Reduce calls for target power state
Only look up the target power state for 2.0 devices. Bug: 182460328 Test: atest DeviceSelectActionTest and OneTouchPlayActionTest Change-Id: I2471d20e750ae37719d70ea3e0215fe6fae94c6a
This commit is contained in:
@@ -100,18 +100,22 @@ final class DeviceSelectAction extends HdmiCecFeatureAction {
|
||||
// Wake-up on <Set Stream Path> was not mandatory before CEC 2.0.
|
||||
// The message is re-sent at the end of the action for devices that don't support 2.0.
|
||||
sendSetStreamPath();
|
||||
int targetPowerStatus = HdmiControlManager.POWER_STATUS_UNKNOWN;
|
||||
HdmiDeviceInfo targetDevice = localDevice().mService.getHdmiCecNetwork().getCecDeviceInfo(
|
||||
getTargetAddress());
|
||||
if (targetDevice != null) {
|
||||
targetPowerStatus = targetDevice.getDevicePowerStatus();
|
||||
}
|
||||
|
||||
if (!mIsCec20 || targetPowerStatus == HdmiControlManager.POWER_STATUS_UNKNOWN) {
|
||||
if (!mIsCec20) {
|
||||
queryDevicePowerStatus();
|
||||
} else if (targetPowerStatus == HdmiControlManager.POWER_STATUS_ON) {
|
||||
finishWithCallback(HdmiControlManager.RESULT_SUCCESS);
|
||||
return true;
|
||||
} else {
|
||||
int targetPowerStatus = HdmiControlManager.POWER_STATUS_UNKNOWN;
|
||||
HdmiDeviceInfo targetDevice = localDevice().mService.getHdmiCecNetwork()
|
||||
.getCecDeviceInfo(getTargetAddress());
|
||||
if (targetDevice != null) {
|
||||
targetPowerStatus = targetDevice.getDevicePowerStatus();
|
||||
}
|
||||
if (targetPowerStatus == HdmiControlManager.POWER_STATUS_UNKNOWN) {
|
||||
queryDevicePowerStatus();
|
||||
} else if (targetPowerStatus == HdmiControlManager.POWER_STATUS_ON) {
|
||||
finishWithCallback(HdmiControlManager.RESULT_SUCCESS);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
mState = STATE_WAIT_FOR_REPORT_POWER_STATUS;
|
||||
addTimer(mState, HdmiConfig.TIMEOUT_MS);
|
||||
|
||||
@@ -89,7 +89,7 @@ final class OneTouchPlayAction extends HdmiCecFeatureAction {
|
||||
mSource = source();
|
||||
sendCommand(HdmiCecMessageBuilder.buildTextViewOn(getSourceAddress(), mTargetAddress));
|
||||
|
||||
boolean targetOnBefore = getTargetDevicePowerStatus(mSource, mTargetAddress,
|
||||
boolean is20TargetOnBefore = mIsCec20 && getTargetDevicePowerStatus(mSource, mTargetAddress,
|
||||
HdmiControlManager.POWER_STATUS_UNKNOWN) == HdmiControlManager.POWER_STATUS_ON;
|
||||
broadcastActiveSource();
|
||||
// If the device is not an audio system itself, request the connected audio system to
|
||||
@@ -98,18 +98,23 @@ final class OneTouchPlayAction extends HdmiCecFeatureAction {
|
||||
sendCommand(HdmiCecMessageBuilder.buildSystemAudioModeRequest(getSourceAddress(),
|
||||
Constants.ADDR_AUDIO_SYSTEM, getSourcePath(), true));
|
||||
}
|
||||
int targetPowerStatus = getTargetDevicePowerStatus(mSource, mTargetAddress,
|
||||
HdmiControlManager.POWER_STATUS_UNKNOWN);
|
||||
if (!mIsCec20 || targetPowerStatus == HdmiControlManager.POWER_STATUS_UNKNOWN) {
|
||||
|
||||
if (!mIsCec20) {
|
||||
queryDevicePowerStatus();
|
||||
} else if (targetPowerStatus == HdmiControlManager.POWER_STATUS_ON) {
|
||||
if (!targetOnBefore) {
|
||||
// Suppress 2nd <Active Source> message if the target device was already on when
|
||||
// the 1st one was sent.
|
||||
broadcastActiveSource();
|
||||
} else {
|
||||
int targetPowerStatus = getTargetDevicePowerStatus(mSource, mTargetAddress,
|
||||
HdmiControlManager.POWER_STATUS_UNKNOWN);
|
||||
if (targetPowerStatus == HdmiControlManager.POWER_STATUS_UNKNOWN) {
|
||||
queryDevicePowerStatus();
|
||||
} else if (targetPowerStatus == HdmiControlManager.POWER_STATUS_ON) {
|
||||
if (!is20TargetOnBefore) {
|
||||
// Suppress 2nd <Active Source> message if the target device was already on when
|
||||
// the 1st one was sent.
|
||||
broadcastActiveSource();
|
||||
}
|
||||
finishWithCallback(HdmiControlManager.RESULT_SUCCESS);
|
||||
return true;
|
||||
}
|
||||
finishWithCallback(HdmiControlManager.RESULT_SUCCESS);
|
||||
return true;
|
||||
}
|
||||
mState = STATE_WAITING_FOR_REPORT_POWER_STATUS;
|
||||
addTimer(mState, HdmiConfig.TIMEOUT_MS);
|
||||
|
||||
Reference in New Issue
Block a user