Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit feb0a155 authored by Nathalie Le Clair's avatar Nathalie Le Clair Committed by Android (Google) Code Review
Browse files

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

parents c237dc5a ab9bdf0f
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -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.
+13 −0
Original line number Diff line number Diff line
@@ -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);
    }
}
+0 −4
Original line number Diff line number Diff line
@@ -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);
+0 −4
Original line number Diff line number Diff line
@@ -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);
+37 −0
Original line number Diff line number Diff line
@@ -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;