Loading services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceSource.java +9 −0 Original line number Diff line number Diff line Loading @@ -296,6 +296,15 @@ abstract class HdmiCecLocalDeviceSource extends HdmiCecLocalDevice { // do nothing } @Override @ServiceThreadOnly protected void disableDevice(boolean initiatedByCec, PendingActionClearedCallback callback) { removeAction(OneTouchPlayAction.class); removeAction(DevicePowerStatusAction.class); super.disableDevice(initiatedByCec, callback); } // Update the power status of the devices connected to the current device. // This only works if the current device is a switch and keeps tracking the device info // of the device connected to it. Loading services/tests/servicestests/src/com/android/server/hdmi/DevicePowerStatusActionTest.java +13 −0 Original line number Diff line number Diff line Loading @@ -282,4 +282,17 @@ public class DevicePowerStatusActionTest { verify(mCallbackMock).onComplete(HdmiControlManager.POWER_STATUS_STANDBY); } @Test public void pendingActionDoesNotBlockSendingStandby() throws Exception { mPlaybackDevice.addAndStartAction(mDevicePowerStatusAction); mTestLooper.dispatchAll(); mNativeWrapper.clearResultMessages(); mHdmiControlService.onStandby(HdmiControlService.STANDBY_SCREEN_OFF); mTestLooper.dispatchAll(); HdmiCecMessage standbyMessage = HdmiCecMessageBuilder.buildStandby( mPlaybackDevice.mAddress, ADDR_TV); assertThat(mNativeWrapper.getResultMessages()).contains(standbyMessage); } } services/tests/servicestests/src/com/android/server/hdmi/HdmiCecLocalDevicePlaybackTest.java +0 −4 Original line number Diff line number Diff line Loading @@ -1046,10 +1046,6 @@ public class HdmiCecLocalDevicePlaybackTest { assertThat(mHdmiCecLocalDevicePlayback.isActiveSource()).isTrue(); // 4. DUT turned off. mHdmiControlService.onStandby(HdmiControlService.STANDBY_SCREEN_OFF); // TODO(b/184939731): remove waiting times once pending actions no longer block <Standby> mTestLooper.moveTimeForward(TIMEOUT_MS); mTestLooper.dispatchAll(); mTestLooper.moveTimeForward(TIMEOUT_MS); mTestLooper.dispatchAll(); HdmiCecMessage standbyMessageBroadcast = HdmiCecMessageBuilder.buildStandby( mHdmiCecLocalDevicePlayback.mAddress, ADDR_BROADCAST); Loading services/tests/servicestests/src/com/android/server/hdmi/HdmiCecLocalDeviceTvTest.java +0 −4 Original line number Diff line number Diff line Loading @@ -295,10 +295,6 @@ public class HdmiCecLocalDeviceTvTest { HdmiControlManager.TV_SEND_STANDBY_ON_SLEEP_ENABLED); mTestLooper.dispatchAll(); mHdmiControlService.onStandby(HdmiControlService.STANDBY_SCREEN_OFF); // TODO(184939731): remove waiting times once pending actions no longer block <Standby> mTestLooper.moveTimeForward(TIMEOUT_MS); mTestLooper.dispatchAll(); mTestLooper.moveTimeForward(TIMEOUT_MS); mTestLooper.dispatchAll(); HdmiCecMessage standby = HdmiCecMessageBuilder.buildStandby(ADDR_TV, ADDR_BROADCAST); assertThat(mNativeWrapper.getResultMessages()).contains(standby); Loading services/tests/servicestests/src/com/android/server/hdmi/OneTouchPlayActionTest.java +37 −0 Original line number Diff line number Diff line Loading @@ -526,6 +526,43 @@ public class OneTouchPlayActionTest { assertThat(playbackDevice.isActiveSource()).isTrue(); } @Test public void pendingActionDoesNotBlockSendingStandby_Cec14b() throws Exception { setUp(true); mHdmiControlService.getHdmiCecNetwork().addCecDevice(INFO_TV); HdmiCecLocalDevicePlayback playbackDevice = new HdmiCecLocalDevicePlayback( mHdmiControlService); playbackDevice.init(); mLocalDevices.add(playbackDevice); playbackDevice.mService.getHdmiCecConfig().setStringValue( HdmiControlManager.CEC_SETTING_NAME_POWER_CONTROL_MODE, HdmiControlManager.POWER_CONTROL_MODE_TV); mHdmiControlService.allocateLogicalAddress(mLocalDevices, INITIATED_BY_ENABLE_CEC); mTestLooper.dispatchAll(); mNativeWrapper.clearResultMessages(); TestActionTimer actionTimer = new TestActionTimer(); TestCallback callback = new TestCallback(); OneTouchPlayAction action = createOneTouchPlayAction(playbackDevice, actionTimer, callback, false); playbackDevice.addAndStartAction(action); mTestLooper.dispatchAll(); assertThat(actionTimer.getState()).isEqualTo(STATE_WAITING_FOR_REPORT_POWER_STATUS); for (int i = 0; i < 5; ++i) { action.handleTimerEvent(STATE_WAITING_FOR_REPORT_POWER_STATUS); mTestLooper.dispatchAll(); } mNativeWrapper.clearResultMessages(); mHdmiControlService.onStandby(HdmiControlService.STANDBY_SCREEN_OFF); mTestLooper.dispatchAll(); HdmiCecMessage standbyMessage = HdmiCecMessageBuilder.buildStandby( playbackDevice.mAddress, ADDR_TV); assertThat(mNativeWrapper.getResultMessages()).contains(standbyMessage); } private static class TestActionTimer implements ActionTimer { private int mState; Loading Loading
services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceSource.java +9 −0 Original line number Diff line number Diff line Loading @@ -296,6 +296,15 @@ abstract class HdmiCecLocalDeviceSource extends HdmiCecLocalDevice { // do nothing } @Override @ServiceThreadOnly protected void disableDevice(boolean initiatedByCec, PendingActionClearedCallback callback) { removeAction(OneTouchPlayAction.class); removeAction(DevicePowerStatusAction.class); super.disableDevice(initiatedByCec, callback); } // Update the power status of the devices connected to the current device. // This only works if the current device is a switch and keeps tracking the device info // of the device connected to it. Loading
services/tests/servicestests/src/com/android/server/hdmi/DevicePowerStatusActionTest.java +13 −0 Original line number Diff line number Diff line Loading @@ -282,4 +282,17 @@ public class DevicePowerStatusActionTest { verify(mCallbackMock).onComplete(HdmiControlManager.POWER_STATUS_STANDBY); } @Test public void pendingActionDoesNotBlockSendingStandby() throws Exception { mPlaybackDevice.addAndStartAction(mDevicePowerStatusAction); mTestLooper.dispatchAll(); mNativeWrapper.clearResultMessages(); mHdmiControlService.onStandby(HdmiControlService.STANDBY_SCREEN_OFF); mTestLooper.dispatchAll(); HdmiCecMessage standbyMessage = HdmiCecMessageBuilder.buildStandby( mPlaybackDevice.mAddress, ADDR_TV); assertThat(mNativeWrapper.getResultMessages()).contains(standbyMessage); } }
services/tests/servicestests/src/com/android/server/hdmi/HdmiCecLocalDevicePlaybackTest.java +0 −4 Original line number Diff line number Diff line Loading @@ -1046,10 +1046,6 @@ public class HdmiCecLocalDevicePlaybackTest { assertThat(mHdmiCecLocalDevicePlayback.isActiveSource()).isTrue(); // 4. DUT turned off. mHdmiControlService.onStandby(HdmiControlService.STANDBY_SCREEN_OFF); // TODO(b/184939731): remove waiting times once pending actions no longer block <Standby> mTestLooper.moveTimeForward(TIMEOUT_MS); mTestLooper.dispatchAll(); mTestLooper.moveTimeForward(TIMEOUT_MS); mTestLooper.dispatchAll(); HdmiCecMessage standbyMessageBroadcast = HdmiCecMessageBuilder.buildStandby( mHdmiCecLocalDevicePlayback.mAddress, ADDR_BROADCAST); Loading
services/tests/servicestests/src/com/android/server/hdmi/HdmiCecLocalDeviceTvTest.java +0 −4 Original line number Diff line number Diff line Loading @@ -295,10 +295,6 @@ public class HdmiCecLocalDeviceTvTest { HdmiControlManager.TV_SEND_STANDBY_ON_SLEEP_ENABLED); mTestLooper.dispatchAll(); mHdmiControlService.onStandby(HdmiControlService.STANDBY_SCREEN_OFF); // TODO(184939731): remove waiting times once pending actions no longer block <Standby> mTestLooper.moveTimeForward(TIMEOUT_MS); mTestLooper.dispatchAll(); mTestLooper.moveTimeForward(TIMEOUT_MS); mTestLooper.dispatchAll(); HdmiCecMessage standby = HdmiCecMessageBuilder.buildStandby(ADDR_TV, ADDR_BROADCAST); assertThat(mNativeWrapper.getResultMessages()).contains(standby); Loading
services/tests/servicestests/src/com/android/server/hdmi/OneTouchPlayActionTest.java +37 −0 Original line number Diff line number Diff line Loading @@ -526,6 +526,43 @@ public class OneTouchPlayActionTest { assertThat(playbackDevice.isActiveSource()).isTrue(); } @Test public void pendingActionDoesNotBlockSendingStandby_Cec14b() throws Exception { setUp(true); mHdmiControlService.getHdmiCecNetwork().addCecDevice(INFO_TV); HdmiCecLocalDevicePlayback playbackDevice = new HdmiCecLocalDevicePlayback( mHdmiControlService); playbackDevice.init(); mLocalDevices.add(playbackDevice); playbackDevice.mService.getHdmiCecConfig().setStringValue( HdmiControlManager.CEC_SETTING_NAME_POWER_CONTROL_MODE, HdmiControlManager.POWER_CONTROL_MODE_TV); mHdmiControlService.allocateLogicalAddress(mLocalDevices, INITIATED_BY_ENABLE_CEC); mTestLooper.dispatchAll(); mNativeWrapper.clearResultMessages(); TestActionTimer actionTimer = new TestActionTimer(); TestCallback callback = new TestCallback(); OneTouchPlayAction action = createOneTouchPlayAction(playbackDevice, actionTimer, callback, false); playbackDevice.addAndStartAction(action); mTestLooper.dispatchAll(); assertThat(actionTimer.getState()).isEqualTo(STATE_WAITING_FOR_REPORT_POWER_STATUS); for (int i = 0; i < 5; ++i) { action.handleTimerEvent(STATE_WAITING_FOR_REPORT_POWER_STATUS); mTestLooper.dispatchAll(); } mNativeWrapper.clearResultMessages(); mHdmiControlService.onStandby(HdmiControlService.STANDBY_SCREEN_OFF); mTestLooper.dispatchAll(); HdmiCecMessage standbyMessage = HdmiCecMessageBuilder.buildStandby( playbackDevice.mAddress, ADDR_TV); assertThat(mNativeWrapper.getResultMessages()).contains(standbyMessage); } private static class TestActionTimer implements ActionTimer { private int mState; Loading