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

Commit 82773e66 authored by Sherry Huang's avatar Sherry Huang
Browse files

HDMI-CEC: Increase number of retry for DevicePowerStatusAction

DevicePowerStatusAction takes more time when the screen is off and on.
This might cause the timeout to happen more frequent, leading to wrong
mIsCecAvailable state. The number of retry is increased in this CL.

Bug: b/420549554
Test: atest com.android.server.hdmi and updated tests
Flag: EXEMPT minor fix
Change-Id: Id073c83bca73024fd2d04ca66f645144176e8c08
parent dc22418a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -42,7 +42,7 @@ final class DevicePowerStatusAction extends HdmiCecFeatureAction {

    // Retry the power status query as it might happen when the target device is waking up. In
    // that case a device may be quite busy and can fail to respond within the 2s timeout.
    private int mRetriesOnTimeout = 1;
    private int mRetriesOnTimeout = 3;

    static DevicePowerStatusAction create(HdmiCecLocalDevice source,
            int targetAddress, IHdmiControlCallback callback) {
+7 −4
Original line number Diff line number Diff line
@@ -59,6 +59,7 @@ import java.util.Collections;
public class DevicePowerStatusActionTest {

    private static final int TIMEOUT_MS = HdmiConfig.TIMEOUT_MS + 1;
    private static final int RETRY_ON_TIMEOUT = 3;

    private Context mContextSpy;
    private HdmiControlService mHdmiControlService;
@@ -200,10 +201,12 @@ public class DevicePowerStatusActionTest {
        mTestLooper.moveTimeForward(TIMEOUT_MS);
        mTestLooper.dispatchAll();

        for (int i = 0; i < RETRY_ON_TIMEOUT; i++) {
            assertThat(mNativeWrapper.getResultMessages()).contains(expected);
            mNativeWrapper.clearResultMessages();
            mTestLooper.moveTimeForward(TIMEOUT_MS);
            mTestLooper.dispatchAll();
        }

        verify(mCallbackMock).onComplete(HdmiControlManager.POWER_STATUS_UNKNOWN);
    }
+10 −5
Original line number Diff line number Diff line
@@ -110,6 +110,7 @@ public class HdmiControlServiceTest {
    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;
    private static final int RETRY_ON_TIMEOUT = 3;

    @Before
    public void setUp() throws Exception {
@@ -801,12 +802,14 @@ public class HdmiControlServiceTest {
                HdmiControlManager.CEC_SETTING_NAME_HDMI_CEC_ENABLED,
                HdmiControlManager.HDMI_CEC_CONTROL_ENABLED);
        mTestLooper.dispatchAll();
        // Hit timeout twice due to retries
        mTestLooper.moveTimeForward(HdmiConfig.TIMEOUT_MS);
        mTestLooper.dispatchAll();

        // Hit timeout multiple times due to retries
        for (int i = 0; i < RETRY_ON_TIMEOUT; i++) {
            mTestLooper.moveTimeForward(HdmiConfig.TIMEOUT_MS);
            mTestLooper.dispatchAll();

        }
        assertThat(hdmiControlStatusCallback.mCecEnabled).isTrue();
        assertThat(hdmiControlStatusCallback.mCecAvailable).isFalse();
    }
@@ -925,9 +928,11 @@ public class HdmiControlServiceTest {
        // Wait for DevicePowerStatusAction to finish.
        mTestLooper.moveTimeForward(HdmiConfig.TIMEOUT_MS);
        mTestLooper.dispatchAll();

        for (int i = 0; i < RETRY_ON_TIMEOUT; i++) {
            mTestLooper.moveTimeForward(HdmiConfig.TIMEOUT_MS);
            mTestLooper.dispatchAll();

        }
        assertThat(hdmiControlStatusCallback.mCecEnabled).isTrue();
        assertThat(hdmiControlStatusCallback.mCecAvailable).isFalse();
    }