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

Commit 7e4801bf authored by Nathalie Le Clair's avatar Nathalie Le Clair
Browse files

Send <Inactive Source> if put to standby by connected device

<Inactive Source> should only be suppressed if followed by a <Standby>
message.

Since no <Standby> is sent by the device if it was put to sleep by a
connected device via CEC, <Inactive Source> should be sent.

Test: atest
Bug: 183603416
Change-Id: Ibb4393c82b5ba7da13983877e1f91172a19f9add
parent 56b09938
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -143,7 +143,12 @@ public class HdmiCecLocalDevicePlayback extends HdmiCecLocalDeviceSource {
        boolean mTvSendStandbyOnSleep = mService.getHdmiCecConfig().getIntValue(
                HdmiControlManager.CEC_SETTING_NAME_TV_SEND_STANDBY_ON_SLEEP)
                    == HdmiControlManager.TV_SEND_STANDBY_ON_SLEEP_ENABLED;
        if (initiatedByCec || !mTvSendStandbyOnSleep || !wasActiveSource) {
        if (!wasActiveSource) {
            return;
        }
        if (initiatedByCec || !mTvSendStandbyOnSleep) {
            mService.sendCecCommand(HdmiCecMessageBuilder.buildInactiveSource(mAddress,
                            mService.getPhysicalAddress()));
            return;
        }
        switch (standbyAction) {
+25 −0
Original line number Diff line number Diff line
@@ -830,6 +830,31 @@ public class HdmiCecLocalDevicePlaybackTest {
        assertThat(mNativeWrapper.getResultMessages()).contains(inactiveSource);
    }

    @Test
    public void handleOnStandby_CecMessageReceived() {
        mHdmiCecLocalDevicePlayback.mService.getHdmiCecConfig().setStringValue(
                HdmiControlManager.CEC_SETTING_NAME_POWER_CONTROL_MODE,
                HdmiControlManager.POWER_CONTROL_MODE_TV);
        mHdmiCecLocalDevicePlayback.setActiveSource(mPlaybackLogicalAddress,
                mPlaybackPhysicalAddress, "HdmiCecLocalDevicePlaybackTest");
        mHdmiCecLocalDevicePlayback.mService.getHdmiCecConfig().setIntValue(
                HdmiControlManager.CEC_SETTING_NAME_TV_SEND_STANDBY_ON_SLEEP,
                HdmiControlManager.TV_SEND_STANDBY_ON_SLEEP_ENABLED);
        mHdmiCecLocalDevicePlayback.onStandby(true, HdmiControlService.STANDBY_SCREEN_OFF);
        mTestLooper.dispatchAll();

        HdmiCecMessage standbyMessageToTv = HdmiCecMessageBuilder.buildStandby(
                mHdmiCecLocalDevicePlayback.mAddress, ADDR_TV);
        HdmiCecMessage standbyMessageBroadcast = HdmiCecMessageBuilder.buildStandby(
                mHdmiCecLocalDevicePlayback.mAddress, ADDR_BROADCAST);
        HdmiCecMessage inactiveSource = HdmiCecMessageBuilder.buildInactiveSource(
                mPlaybackLogicalAddress, mPlaybackPhysicalAddress);

        assertThat(mNativeWrapper.getResultMessages()).doesNotContain(standbyMessageToTv);
        assertThat(mNativeWrapper.getResultMessages()).doesNotContain(standbyMessageBroadcast);
        assertThat(mNativeWrapper.getResultMessages()).contains(inactiveSource);
    }

    @Test
    public void handleOnInitializeCecComplete_ByEnableCec() {
        mHdmiCecLocalDevicePlayback.onInitializeCecComplete(