Always start DeviceSelectAction with <Set Stream Path>
Before this change: For CEC 1.4 devices, the action waits for the target device to turn on before sending <Set Stream Path>. After this change: For CEC 1.4 devices, the action sends <Set Stream Path> already at the start. Result: the action will complete more quickly for target devices that support waking up to and caching <Send Stream Path> messages when still asleep. <Set Stream Path> will still be sent only once for 2.0 devices but twice for 1.4 devices. Test: atest DeviceSelectActionTest Bug: 179463842 Change-Id: Iac2a622e63b5c0610cc224b3eedeb037820a8cf4
This commit is contained in:
@@ -100,9 +100,9 @@ final class DeviceSelectAction extends HdmiCecFeatureAction {
|
||||
|
||||
@Override
|
||||
public boolean start() {
|
||||
if (mIsCec20) {
|
||||
sendSetStreamPath();
|
||||
}
|
||||
// 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 = localDevice().mService.getHdmiCecNetwork()
|
||||
.getCecDeviceInfo(getTargetAddress()).getDevicePowerStatus();
|
||||
if (!mIsCec20 || targetPowerStatus == HdmiControlManager.POWER_STATUS_UNKNOWN) {
|
||||
|
||||
@@ -221,7 +221,8 @@ public class DeviceSelectActionTest {
|
||||
"testDeviceSelect");
|
||||
action.start();
|
||||
mTestLooper.dispatchAll();
|
||||
assertThat(mNativeWrapper.getResultMessages()).doesNotContain(SET_STREAM_PATH);
|
||||
assertThat(mNativeWrapper.getResultMessages()).contains(SET_STREAM_PATH);
|
||||
mNativeWrapper.clearResultMessages();
|
||||
assertThat(actionTimer.getState()).isEqualTo(STATE_WAIT_FOR_REPORT_POWER_STATUS);
|
||||
action.processCommand(REPORT_POWER_STATUS_ON);
|
||||
mTestLooper.dispatchAll();
|
||||
@@ -238,12 +239,15 @@ public class DeviceSelectActionTest {
|
||||
DeviceSelectAction action = createDeviceSelectAction(actionTimer, callback,
|
||||
/*isCec20=*/false);
|
||||
action.start();
|
||||
mTestLooper.dispatchAll();
|
||||
assertThat(mNativeWrapper.getResultMessages()).contains(SET_STREAM_PATH);
|
||||
assertThat(actionTimer.getState()).isEqualTo(STATE_WAIT_FOR_REPORT_POWER_STATUS);
|
||||
action.processCommand(REPORT_POWER_STATUS_STANDBY);
|
||||
mTestLooper.dispatchAll();
|
||||
HdmiCecMessage userControlPressed = HdmiCecMessageBuilder.buildUserControlPressed(
|
||||
ADDR_TV, ADDR_PLAYBACK_1, HdmiCecKeycode.CEC_KEYCODE_POWER);
|
||||
assertThat(mNativeWrapper.getResultMessages()).contains(userControlPressed);
|
||||
mNativeWrapper.clearResultMessages();
|
||||
assertThat(actionTimer.getState()).isEqualTo(STATE_WAIT_FOR_DEVICE_POWER_ON);
|
||||
action.handleTimerEvent(STATE_WAIT_FOR_DEVICE_POWER_ON);
|
||||
action.processCommand(REPORT_POWER_STATUS_ON);
|
||||
@@ -261,6 +265,9 @@ public class DeviceSelectActionTest {
|
||||
DeviceSelectAction action = createDeviceSelectAction(actionTimer, callback,
|
||||
/*isCec20=*/false);
|
||||
action.start();
|
||||
mTestLooper.dispatchAll();
|
||||
assertThat(mNativeWrapper.getResultMessages()).contains(SET_STREAM_PATH);
|
||||
mNativeWrapper.clearResultMessages();
|
||||
assertThat(actionTimer.getState()).isEqualTo(STATE_WAIT_FOR_REPORT_POWER_STATUS);
|
||||
action.processCommand(REPORT_POWER_STATUS_STANDBY);
|
||||
assertThat(actionTimer.getState()).isEqualTo(STATE_WAIT_FOR_DEVICE_POWER_ON);
|
||||
@@ -285,6 +292,9 @@ public class DeviceSelectActionTest {
|
||||
DeviceSelectAction action = createDeviceSelectAction(actionTimer, callback,
|
||||
/*isCec20=*/false);
|
||||
action.start();
|
||||
mTestLooper.dispatchAll();
|
||||
assertThat(mNativeWrapper.getResultMessages()).contains(SET_STREAM_PATH);
|
||||
mNativeWrapper.clearResultMessages();
|
||||
assertThat(actionTimer.getState()).isEqualTo(STATE_WAIT_FOR_REPORT_POWER_STATUS);
|
||||
action.processCommand(REPORT_POWER_STATUS_STANDBY);
|
||||
assertThat(actionTimer.getState()).isEqualTo(STATE_WAIT_FOR_DEVICE_POWER_ON);
|
||||
@@ -330,8 +340,11 @@ public class DeviceSelectActionTest {
|
||||
action.start();
|
||||
mTestLooper.dispatchAll();
|
||||
assertThat(mNativeWrapper.getResultMessages()).contains(SET_STREAM_PATH);
|
||||
mNativeWrapper.clearResultMessages();
|
||||
assertThat(actionTimer.getState()).isEqualTo(STATE_WAIT_FOR_REPORT_POWER_STATUS);
|
||||
action.processCommand(REPORT_POWER_STATUS_ON);
|
||||
mTestLooper.dispatchAll();
|
||||
assertThat(mNativeWrapper.getResultMessages()).doesNotContain(SET_STREAM_PATH);
|
||||
assertThat(callback.getResult()).isEqualTo(HdmiControlManager.RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
@@ -354,9 +367,12 @@ public class DeviceSelectActionTest {
|
||||
HdmiCecMessage userControlPressed = HdmiCecMessageBuilder.buildUserControlPressed(
|
||||
ADDR_TV, ADDR_PLAYBACK_1, HdmiCecKeycode.CEC_KEYCODE_POWER);
|
||||
assertThat(mNativeWrapper.getResultMessages()).doesNotContain(userControlPressed);
|
||||
mNativeWrapper.clearResultMessages();
|
||||
assertThat(actionTimer.getState()).isEqualTo(STATE_WAIT_FOR_DEVICE_POWER_ON);
|
||||
action.handleTimerEvent(STATE_WAIT_FOR_DEVICE_POWER_ON);
|
||||
action.processCommand(REPORT_POWER_STATUS_ON);
|
||||
mTestLooper.dispatchAll();
|
||||
assertThat(mNativeWrapper.getResultMessages()).doesNotContain(SET_STREAM_PATH);
|
||||
assertThat(callback.getResult()).isEqualTo(HdmiControlManager.RESULT_SUCCESS);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user