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

Commit 01ee9f96 authored by Winni Chang's avatar Winni Chang
Browse files

Add delay for switching eARC to ARC

Certain eARC devices need to wait for eARC timeout to enter ARC mode.
If there is no delay for these devices, devices would answer
<Request ARC Initiated> with <Feature Abort> [Not in correct mode to
respond].

[Solution]
Add delay when switching eARC mode from eARC to ARC.
The reason for 500ms is as follows.

TeARC_LOST_HEARTBEAT  120-130ms
timeout starting from last received heartbeat to entering [RX DISC1] state
130ms is max time for AVR to leave RX_eARC

TeARC_RX_TIMEOUT 250-300ms
Heartbeat timeout startingfrom entry into [RX IDLE1] state @ eARC RX
300ms is max time for AVR to give up waiting for next heartbeat start

In total this means a max. total timeout of 430 ms. That's why we delay ARC initiation by 500 ms.

Bug: 253387972
(cherry picked from https://keystone-mtk-review.git.corp.google.com/c/platform/frameworks/base/+/135980)

Change-Id: Idd9221f206144e04241a70af9ca7529a20913adb
parent 3814571e
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -286,6 +286,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.
     */
@@ -4871,7 +4875,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
@@ -97,6 +97,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 {
@@ -1245,6 +1246,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());
    }