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

Commit 09c666ff authored by Paul Colta's avatar Paul Colta Committed by Android (Google) Code Review
Browse files

Merge "HDMI: check and wake up avr first [1/1]" into main

parents 00d88eae 02c22ca3
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -1225,11 +1225,15 @@ public class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice {
        boolean avrSystemAudioMode = HdmiUtils.parseCommandParamSystemAudioStatus(message);
        // Set System Audio Mode according to TV's settings.
        // Handle <System Audio Mode Status> here only when
        // SystemAudioAutoInitiationAction timeout
        // SystemAudioAutoInitiationAction timeout.
        // If AVR reports SAM on and it is in standby, the action SystemAudioActionFromTv
        // triggers a <SAM Request> that will wake-up the AVR.
        HdmiDeviceInfo avr = getAvrDeviceInfo();
        if (avr == null) {
            setSystemAudioMode(false);
        } else if (avrSystemAudioMode != tvSystemAudioMode) {
        } else if (avrSystemAudioMode != tvSystemAudioMode
                    || (avrSystemAudioMode && avr.getDevicePowerStatus()
                        == HdmiControlManager.POWER_STATUS_STANDBY)) {
            addAndStartAction(new SystemAudioActionFromTv(this, avr.getLogicalAddress(),
                    tvSystemAudioMode, null));
        } else {
+8 −1
Original line number Diff line number Diff line
@@ -16,7 +16,9 @@

package com.android.server.hdmi;

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

import com.android.internal.annotations.VisibleForTesting;
import com.android.server.hdmi.HdmiControlService.SendMessageCallback;
@@ -89,8 +91,13 @@ final class SystemAudioAutoInitiationAction extends HdmiCecFeatureAction {

        // If System Audio Control feature is enabled, turn on system audio mode when new AVR is
        // detected. Otherwise, turn off system audio mode.
        // If AVR reports SAM on and it is in standby, the action SystemAudioActionFromTv
        // triggers a <SAM Request> that will wake-up the AVR.
        boolean targetSystemAudioMode = tv().isSystemAudioControlFeatureEnabled();
        if (currentSystemAudioMode != targetSystemAudioMode) {
        if (currentSystemAudioMode != targetSystemAudioMode
                || (currentSystemAudioMode && tv().getAvrDeviceInfo() != null
                && tv().getAvrDeviceInfo().getDevicePowerStatus()
                == HdmiControlManager.POWER_STATUS_STANDBY)) {
            // Start System Audio Control feature actions only if necessary.
            addAndStartAction(
                    new SystemAudioActionFromTv(tv(), mAvrAddress, targetSystemAudioMode, null));
+34 −0
Original line number Diff line number Diff line
@@ -2148,6 +2148,40 @@ public class HdmiCecLocalDeviceTvTest {
                .hasSize(1);
    }


    @Test
    public void handleReportAudioStatus_SamOnAvrStandby_startSystemAudioActionFromTv() {
        mHdmiControlService.getHdmiCecConfig().setIntValue(
                HdmiControlManager.CEC_SETTING_NAME_SYSTEM_AUDIO_CONTROL,
                HdmiControlManager.SYSTEM_AUDIO_CONTROL_ENABLED);
        // Emulate Audio device on port 0x1000 (does not support ARC)
        mNativeWrapper.setPortConnectionStatus(1, true);
        HdmiCecMessage reportPhysicalAddress =
                HdmiCecMessageBuilder.buildReportPhysicalAddressCommand(
                        ADDR_AUDIO_SYSTEM, 0x1000, HdmiDeviceInfo.DEVICE_AUDIO_SYSTEM);
        HdmiCecMessage reportPowerStatus =
                HdmiCecMessageBuilder.buildReportPowerStatus(ADDR_AUDIO_SYSTEM, ADDR_TV,
                        HdmiControlManager.POWER_STATUS_STANDBY);
        mNativeWrapper.onCecMessage(reportPhysicalAddress);
        mNativeWrapper.onCecMessage(reportPowerStatus);
        mTestLooper.dispatchAll();
        assertThat(mHdmiCecLocalDeviceTv.getActions(SystemAudioActionFromTv.class)).hasSize(0);

        HdmiCecFeatureAction systemAudioAutoInitiationAction =
                new SystemAudioAutoInitiationAction(mHdmiCecLocalDeviceTv, ADDR_AUDIO_SYSTEM);
        mHdmiCecLocalDeviceTv.addAndStartAction(systemAudioAutoInitiationAction);
        HdmiCecMessage reportSystemAudioMode =
                HdmiCecMessageBuilder.buildReportSystemAudioMode(
                        ADDR_AUDIO_SYSTEM,
                        mHdmiCecLocalDeviceTv.getDeviceInfo().getLogicalAddress(),
                        true);
        mHdmiControlService.handleCecCommand(reportSystemAudioMode);
        mTestLooper.dispatchAll();

        // SAM must be on; ARC must be off
        assertThat(mHdmiCecLocalDeviceTv.getActions(SystemAudioActionFromTv.class)).hasSize(1);
    }

    protected static class MockTvDevice extends HdmiCecLocalDeviceTv {
        MockTvDevice(HdmiControlService service) {
            super(service);