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

Commit 6b061bbd authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "HDMI: Retry one time to send <Request Active Source>" into main

parents 856a037e ec4922d2
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -29,6 +29,12 @@ public class RequestActiveSourceAction extends HdmiCecFeatureAction {
    // State to wait for the <Active Source> message.
    private static final int STATE_WAIT_FOR_ACTIVE_SOURCE = 1;

    // Number of retries <Request Active Source> is sent if no device answers this message.
    private static final int MAX_SEND_RETRY_COUNT = 1;

    private int mSendRetryCount = 0;


    RequestActiveSourceAction(HdmiCecLocalDevice source, IHdmiControlCallback callback) {
        super(source, callback);
    }
@@ -60,7 +66,12 @@ public class RequestActiveSourceAction extends HdmiCecFeatureAction {
            return;
        }
        if (mState == STATE_WAIT_FOR_ACTIVE_SOURCE) {
            if (mSendRetryCount++ < MAX_SEND_RETRY_COUNT) {
                sendCommand(HdmiCecMessageBuilder.buildRequestActiveSource(getSourceAddress()));
                addTimer(mState, HdmiConfig.TIMEOUT_MS);
            } else {
                finishWithCallback(HdmiControlManager.RESULT_TIMEOUT);
            }
        }
    }
}
+4 −0
Original line number Diff line number Diff line
@@ -1722,7 +1722,11 @@ public class HdmiCecLocalDeviceTvTest {
        mNativeWrapper.clearResultMessages();
        mTestLooper.moveTimeForward(HdmiConfig.TIMEOUT_MS);
        mTestLooper.dispatchAll();
        assertThat(mNativeWrapper.getResultMessages()).doesNotContain(activeSourceFromTv);

        // Skip the retry.
        mTestLooper.moveTimeForward(HdmiConfig.TIMEOUT_MS);
        mTestLooper.dispatchAll();
        assertThat(mNativeWrapper.getResultMessages()).contains(activeSourceFromTv);
    }