Merge "Remove actions that delay standby flow" into sc-dev am: feb0a155bd

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14424416

Change-Id: I736be2a90f47045b412659772f57828674bdd2cb
This commit is contained in:
Nathalie Le Clair
2021-05-05 07:01:02 +00:00
committed by Automerger Merge Worker
5 changed files with 59 additions and 8 deletions

View File

@@ -300,6 +300,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.

View File

@@ -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);
}
}

View File

@@ -1136,10 +1136,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);

View File

@@ -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);

View File

@@ -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;