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

Commit 0966fac5 authored by Paul Colta's avatar Paul Colta
Browse files

HDMI: Avoid to interrupt standby process by action timeout

SystemAudioInitiationActionFromAvr requests for the current active
source before starting to query the TV for SAM support. If no other
device answer, the DUT will broadcast <AS>.

This is an issue in CTS, where no other CEC-enabled device is connected in the network. Broadcasting `<AS>` will interrupt the standby process failing the specific test.

Bug: 336707943
Test: atest com.android.server.hdmi && run cts -m
CtsHdmiCecHostTestCases -t
android.hdmicec.cts.playback.HdmiCecTvPowerToggleTest#cectTvPowerToggleTest_asleep_tvOn

Change-Id: Idb4fdfa9f39d9a3d1f566ab84263397f06b56107
parent 081955aa
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -3699,7 +3699,6 @@ public class HdmiControlService extends SystemService {
        return mWakeUpMessageReceived;
    }

    @VisibleForTesting
    protected boolean isStandbyMessageReceived() {
        return mStandbyMessageReceived;
    }
+6 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@
package com.android.server.hdmi;

import android.hardware.tv.cec.V1_0.SendMessageResult;
import android.util.Slog;

import com.android.internal.annotations.VisibleForTesting;

@@ -23,6 +24,7 @@ import com.android.internal.annotations.VisibleForTesting;
 * Feature action that handles System Audio Mode initiated by AVR devices.
 */
public class SystemAudioInitiationActionFromAvr extends HdmiCecFeatureAction {
    private static final String TAG = "SystemAudioInitiationActionFromAvr";

    // State that waits for <Active Source> once send <Request Active Source>.
    private static final int STATE_WAITING_FOR_ACTIVE_SOURCE = 1;
@@ -115,6 +117,10 @@ public class SystemAudioInitiationActionFromAvr extends HdmiCecFeatureAction {

    private void handleActiveSourceTimeout() {
        HdmiLogger.debug("Cannot get active source.");
        if (audioSystem().mService.isStandbyMessageReceived()) {
            Slog.d(TAG, "Device is going to sleep, avoid to wake it up.");
            return;
        }
        // If not able to find Active Source and the current device has playbcak functionality,
        // claim Active Source and start to query TV system audio mode support.
        if (audioSystem().mService.isPlaybackDevice()) {
+25 −0
Original line number Diff line number Diff line
@@ -15,6 +15,8 @@
 */
package com.android.server.hdmi;

import static com.android.server.hdmi.HdmiConfig.TIMEOUT_MS;

import static com.google.common.truth.Truth.assertThat;

import static org.junit.Assert.assertFalse;
@@ -60,6 +62,7 @@ public class SystemAudioInitiationActionFromAvrTest {
    private boolean mArcEnabled;
    private boolean mIsPlaybackDevice;
    private boolean mBroadcastActiveSource;
    private boolean mStandbyMessageReceived;

    @Before
    public void SetUp() {
@@ -135,6 +138,11 @@ public class SystemAudioInitiationActionFromAvrTest {
                    int pathToPortId(int path) {
                        return -1;
                    }

                    @Override
                    protected boolean isStandbyMessageReceived() {
                        return mStandbyMessageReceived;
                    }
                };

        Looper looper = mTestLooper.getLooper();
@@ -286,6 +294,22 @@ public class SystemAudioInitiationActionFromAvrTest {
        assertThat(mHdmiCecLocalDeviceAudioSystem.isSystemAudioActivated()).isTrue();
    }

    @Test
    public void onActionStarted_deviceGoesToSleep_noActiveSourceAfterTimeout() {
        resetTestVariables();

        mStandbyMessageReceived = true;
        mHdmiCecLocalDeviceAudioSystem.addAndStartAction(
                new SystemAudioInitiationActionFromAvr(
                mHdmiCecLocalDeviceAudioSystem));
        mTestLooper.dispatchAll();

        mTestLooper.moveTimeForward(TIMEOUT_MS);
        mTestLooper.dispatchAll();

        assertThat(mBroadcastActiveSource).isFalse();
    }

    private void resetTestVariables() {
        mMsgRequestActiveSourceCount = 0;
        mMsgSetSystemAudioModeCount = 0;
@@ -295,5 +319,6 @@ public class SystemAudioInitiationActionFromAvrTest {
        mBroadcastActiveSource = false;
        mHdmiCecLocalDeviceAudioSystem.getActiveSource().physicalAddress =
                Constants.INVALID_PHYSICAL_ADDRESS;
        mStandbyMessageReceived = false;
    }
}