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

Commit ddf298dd authored by Paul Colta's avatar Paul Colta
Browse files

HDMI: Do not change Active Source status on all <Routing Change> messages

If the device is AS and received a <Routing Change> message to a PA in the same active path do not change the Active Source status.

E.g.: TV [0.0.0.0] ------ Switch [2.0.0.0] ------ OTT [2.1.0.0] (AS)
TV sends <Routing Change>[2.0.0.0] -> OTT is still AS
TV sends <Routing Change>[0.0.0.0] -> OTT is not AS.
TV sends <Routing Change>[3.0.0.0] -> OTT is not AS.

Test: make && atest HdmiCecLocalDevicePlaybackTest
Bug: 292207388
Change-Id: Ie431892e61e617762961696a533d0adc3655b77f
parent 227073ae
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -357,7 +357,7 @@ final class Constants {

    static final int INVALID_PORT_ID = HdmiDeviceInfo.PORT_INVALID;
    static final int INVALID_PHYSICAL_ADDRESS = HdmiDeviceInfo.PATH_INVALID;
    static final int PATH_INTERNAL = HdmiDeviceInfo.PATH_INTERNAL;
    static final int TV_PHYSICAL_ADDRESS = HdmiDeviceInfo.PATH_INTERNAL;

    // The relationship from one path (physical address) to another.
    @IntDef({
+12 −0
Original line number Diff line number Diff line
@@ -518,6 +518,18 @@ public class HdmiCecLocalDevicePlayback extends HdmiCecLocalDeviceSource {
    @ServiceThreadOnly
    protected void handleRoutingChangeAndInformation(int physicalAddress, HdmiCecMessage message) {
        assertRunOnServiceThread();
        // If the device is active source and received a <Routing Change> or <Routing Information>
        // message to a physical address in the same active path do not change the Active Source
        // status.
        // E.g. TV [0.0.0.0] ------ Switch [2.0.0.0] ------ OTT [2.1.0.0] (Active Source)
        // TV sends <Routing Change>[2.0.0.0] -> OTT is still Active Source
        // TV sends <Routing Change>[0.0.0.0] -> OTT is not Active Source anymore.
        // TV sends <Routing Change>[3.0.0.0] -> OTT is not Active Source anymore.
        if (HdmiUtils.isInActiveRoutingPath(mService.getPhysicalAddress(), physicalAddress)
                && physicalAddress != Constants.TV_PHYSICAL_ADDRESS
                && isActiveSource()) {
            return;
        }
        if (physicalAddress != mService.getPhysicalAddress()) {
            setActiveSource(physicalAddress,
                    "HdmiCecLocalDevicePlayback#handleRoutingChangeAndInformation()");
+1 −1
Original line number Diff line number Diff line
@@ -113,7 +113,7 @@ abstract class SystemAudioAction extends HdmiCecFeatureAction {
        }
        int param = tv().getActivePath();
        return param != Constants.INVALID_PHYSICAL_ADDRESS
                ? param : Constants.PATH_INTERNAL;
                ? param : Constants.TV_PHYSICAL_ADDRESS;
    }

    private void handleSendSystemAudioModeRequestTimeout() {
+41 −0
Original line number Diff line number Diff line
@@ -382,6 +382,47 @@ public class HdmiCecLocalDevicePlaybackTest {
        assertThat(mPowerManager.isInteractive()).isFalse();
    }

    @Test
    public void handleRoutingChange_toSwitchInActivePath_noStandby() {
        int newPlaybackPhysicalAddress = 0x2100;
        int switchPhysicalAddress = 0x2000;
        mNativeWrapper.setPhysicalAddress(newPlaybackPhysicalAddress);
        mHdmiControlService.allocateLogicalAddress(mLocalDevices, INITIATED_BY_ENABLE_CEC);

        mHdmiCecLocalDevicePlayback.mService.getHdmiCecConfig().setStringValue(
                HdmiControlManager.CEC_SETTING_NAME_POWER_STATE_CHANGE_ON_ACTIVE_SOURCE_LOST,
                HdmiControlManager.POWER_STATE_CHANGE_ON_ACTIVE_SOURCE_LOST_STANDBY_NOW);
        mHdmiCecLocalDevicePlayback.setActiveSource(mPlaybackLogicalAddress,
                newPlaybackPhysicalAddress, "HdmiCecLocalDevicePlaybackTest");
        mTestLooper.dispatchAll();

        HdmiCecMessage message =
                HdmiCecMessageBuilder.buildRoutingChange(ADDR_TV, newPlaybackPhysicalAddress,
                        switchPhysicalAddress);
        assertThat(mHdmiCecLocalDevicePlayback.handleRoutingChange(message))
                .isEqualTo(Constants.HANDLED);
        assertThat(mHdmiCecLocalDevicePlayback.isActiveSource()).isTrue();
        assertThat(mPowerManager.isInteractive()).isTrue();
    }

    @Test
    public void handleRoutingChange_toTv_StandbyNow() {
        mHdmiCecLocalDevicePlayback.mService.getHdmiCecConfig().setStringValue(
                HdmiControlManager.CEC_SETTING_NAME_POWER_STATE_CHANGE_ON_ACTIVE_SOURCE_LOST,
                HdmiControlManager.POWER_STATE_CHANGE_ON_ACTIVE_SOURCE_LOST_STANDBY_NOW);
        mHdmiCecLocalDevicePlayback.setActiveSource(mPlaybackLogicalAddress,
                mPlaybackPhysicalAddress, "HdmiCecLocalDevicePlaybackTest");
        mTestLooper.dispatchAll();

        HdmiCecMessage message =
                HdmiCecMessageBuilder.buildRoutingChange(ADDR_TV, mPlaybackPhysicalAddress,
                        Constants.TV_PHYSICAL_ADDRESS);
        assertThat(mHdmiCecLocalDevicePlayback.handleRoutingChange(message))
                .isEqualTo(Constants.HANDLED);
        assertThat(mHdmiCecLocalDevicePlayback.isActiveSource()).isFalse();
        assertThat(mPowerManager.isInteractive()).isFalse();
    }

    @Test
    public void handleRoutingChange_otherDevice_StandbyNow_InactiveSource() {
        mHdmiCecLocalDevicePlayback.mService.getHdmiCecConfig().setStringValue(