Merge "Remove actions that delay standby flow" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
feb0a155bd
@@ -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.
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user