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

Commit 4bd3441d authored by Winni Chang's avatar Winni Chang Committed by Android (Google) Code Review
Browse files

Merge "Add delay for switching eARC to ARC" into main

parents e62c5fa8 01ee9f96
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -304,6 +304,10 @@ public class HdmiControlService extends SystemService {
    // Make sure HdmiCecConfig is instantiated and the XMLs are read.
    private HdmiCecConfig mHdmiCecConfig;

    // Timeout value for start ARC action after an established eARC connection was terminated,
    // e.g. because eARC was disabled in Settings.
    private static final int EARC_TRIGGER_START_ARC_ACTION_DELAY = 500;

    /**
     * Interface to report send result.
     */
@@ -5041,7 +5045,12 @@ public class HdmiControlService extends SystemService {
            // AudioService here that the eARC connection is terminated.
            HdmiLogger.debug("eARC state change [new: HDMI_EARC_STATUS_ARC_PENDING(2)]");
            notifyEarcStatusToAudioService(false, new ArrayList<>());
            mHandler.postDelayed( new Runnable() {
                @Override
                public void run() {
                    startArcAction(true, null);
                }
            }, EARC_TRIGGER_START_ARC_ACTION_DELAY);
            getAtomWriter().earcStatusChanged(isEarcSupported(), isEarcEnabled(),
                    oldEarcStatus, status, HdmiStatsEnums.LOG_REASON_EARC_STATUS_CHANGED);
        } else {
+6 −0
Original line number Diff line number Diff line
@@ -106,6 +106,7 @@ public class HdmiControlServiceTest {
    private HdmiPortInfo[] mHdmiPortInfo;
    private ArrayList<Integer> mLocalDeviceTypes = new ArrayList<>();
    private static final int PORT_ID_EARC_SUPPORTED = 3;
    private static final int EARC_TRIGGER_START_ARC_ACTION_DELAY = 500;

    @Before
    public void setUp() throws Exception {
@@ -1374,6 +1375,11 @@ public class HdmiControlServiceTest {
                PORT_ID_EARC_SUPPORTED);
        verify(mHdmiControlServiceSpy, times(1))
                .notifyEarcStatusToAudioService(eq(false), eq(new ArrayList<>()));
        // ARC should be never initiated here. It should be started after 500 ms.
        verify(mHdmiControlServiceSpy, times(0)).startArcAction(anyBoolean(), any());
        // We move 500 ms forward because the action is only started 500 ms later.
        mTestLooper.moveTimeForward(EARC_TRIGGER_START_ARC_ACTION_DELAY);
        mTestLooper.dispatchAll();
        verify(mHdmiControlServiceSpy, times(1)).startArcAction(eq(true), any());
    }