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

Commit c67b893a authored by Nathalie Le Clair's avatar Nathalie Le Clair
Browse files

Default wake on plug to false for audio system

Changes made:
	1. Audio system device no longer wakes up on hotplug (as was already done for playback devices in change https://googleplex-android-review.git.corp.google.com/c/platform/frameworks/base/+/10319601)
	2. Added unit tests for 1.
	3. Added unit tests for change https://googleplex-android-review.git.corp.google.com/c/platform/frameworks/base/+/10319601

Note: we should consider implementing this change in HdmiCecLocalDeviceSource instead (which is the class HdmiCecLocalDevicePlayback and HdmiCecLocalDeviceAudioSystem extend), to have a streamlined behavior for all future source classes.

Test: N/A
Bug: 149479986

Change-Id: I953af5ea93b609919d768fa98dce47daf62f2f06
parent 7e8e12e0
Loading
Loading
Loading
Loading
+4 −1
Original line number Original line Diff line number Diff line
@@ -70,6 +70,9 @@ public class HdmiCecLocalDeviceAudioSystem extends HdmiCecLocalDeviceSource {


    private static final String TAG = "HdmiCecLocalDeviceAudioSystem";
    private static final String TAG = "HdmiCecLocalDeviceAudioSystem";


    private static final boolean WAKE_ON_HOTPLUG =
            SystemProperties.getBoolean(Constants.PROPERTY_WAKE_ON_HOTPLUG, false);

    // Whether the System Audio Control feature is enabled or not. True by default.
    // Whether the System Audio Control feature is enabled or not. True by default.
    @GuardedBy("mLock")
    @GuardedBy("mLock")
    private boolean mSystemAudioControlFeatureEnabled;
    private boolean mSystemAudioControlFeatureEnabled;
@@ -318,7 +321,7 @@ public class HdmiCecLocalDeviceAudioSystem extends HdmiCecLocalDeviceSource {
    @ServiceThreadOnly
    @ServiceThreadOnly
    void onHotplug(int portId, boolean connected) {
    void onHotplug(int portId, boolean connected) {
        assertRunOnServiceThread();
        assertRunOnServiceThread();
        if (connected) {
        if (WAKE_ON_HOTPLUG && connected) {
            mService.wakeUp();
            mService.wakeUp();
        }
        }
        if (mService.getPortInfo(portId).getType() == HdmiPortInfo.PORT_OUTPUT) {
        if (mService.getPortInfo(portId).getType() == HdmiPortInfo.PORT_OUTPUT) {
+18 −1
Original line number Original line Diff line number Diff line
@@ -76,6 +76,7 @@ public class HdmiCecLocalDeviceAudioSystemTest {
    private boolean mMutingEnabled;
    private boolean mMutingEnabled;
    private boolean mArcSupport;
    private boolean mArcSupport;
    private HdmiPortInfo[] mHdmiPortInfo;
    private HdmiPortInfo[] mHdmiPortInfo;
    private boolean mWokenUp;


    @Before
    @Before
    public void setUp() {
    public void setUp() {
@@ -138,7 +139,9 @@ public class HdmiCecLocalDeviceAudioSystemTest {
                }
                }


                @Override
                @Override
                void wakeUp() {}
                void wakeUp() {
                    mWokenUp = true;
                }


                @Override
                @Override
                void invokeDeviceEventListeners(HdmiDeviceInfo device, int status) {
                void invokeDeviceEventListeners(HdmiDeviceInfo device, int status) {
@@ -698,4 +701,18 @@ public class HdmiCecLocalDeviceAudioSystemTest {
            .getCecDeviceInfo(differentDevice.getLogicalAddress())).isEqualTo(differentDevice);
            .getCecDeviceInfo(differentDevice.getLogicalAddress())).isEqualTo(differentDevice);
        assertThat(mInvokeDeviceEventState).isEqualTo(DEVICE_EVENT_ADD_DEVICE);
        assertThat(mInvokeDeviceEventState).isEqualTo(DEVICE_EVENT_ADD_DEVICE);
    }
    }

    @Test
    public void doNotWakeUpOnHotPlug_PlugIn() {
        mWokenUp = false;
        mHdmiCecLocalDeviceAudioSystem.onHotplug(0, true);
        assertThat(mWokenUp).isFalse();
    }

    @Test
    public void doNotWakeUpOnHotPlug_PlugOut() {
        mWokenUp = false;
        mHdmiCecLocalDeviceAudioSystem.onHotplug(0, false);
        assertThat(mWokenUp).isFalse();
    }
}
}
+16 −0
Original line number Original line Diff line number Diff line
@@ -47,6 +47,7 @@ public class HdmiCecLocalDevicePlaybackTest {
    private TestLooper mTestLooper = new TestLooper();
    private TestLooper mTestLooper = new TestLooper();
    private ArrayList<HdmiCecLocalDevice> mLocalDevices = new ArrayList<>();
    private ArrayList<HdmiCecLocalDevice> mLocalDevices = new ArrayList<>();
    private int mPlaybackPhysicalAddress;
    private int mPlaybackPhysicalAddress;
    private boolean mWokenUp;


    @Before
    @Before
    public void setUp() {
    public void setUp() {
@@ -54,6 +55,7 @@ public class HdmiCecLocalDevicePlaybackTest {
            new HdmiControlService(InstrumentationRegistry.getTargetContext()) {
            new HdmiControlService(InstrumentationRegistry.getTargetContext()) {
                @Override
                @Override
                void wakeUp() {
                void wakeUp() {
                    mWokenUp = true;
                }
                }


                @Override
                @Override
@@ -135,4 +137,18 @@ public class HdmiCecLocalDevicePlaybackTest {
        assertThat(mHdmiCecLocalDevicePlayback.handleSystemAudioModeStatus(message)).isTrue();
        assertThat(mHdmiCecLocalDevicePlayback.handleSystemAudioModeStatus(message)).isTrue();
        assertThat(mHdmiCecLocalDevicePlayback.mService.isSystemAudioActivated()).isTrue();
        assertThat(mHdmiCecLocalDevicePlayback.mService.isSystemAudioActivated()).isTrue();
    }
    }

    @Test
    public void doNotWakeUpOnHotPlug_PlugIn() {
        mWokenUp = false;
        mHdmiCecLocalDevicePlayback.onHotplug(0, true);
        assertThat(mWokenUp).isFalse();
    }

    @Test
    public void doNotWakeUpOnHotPlug_PlugOut() {
        mWokenUp = false;
        mHdmiCecLocalDevicePlayback.onHotplug(0, false);
        assertThat(mWokenUp).isFalse();
    }
}
}