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

Commit 17455858 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Adding system audio control muting logic."

parents 1ef5e35e cce55e01
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -273,6 +273,16 @@ final class Constants {
    // TODO(OEM): Set this to true to enable 'Set Menu Language' feature. False by default.
    static final String PROPERTY_SET_MENU_LANGUAGE = "ro.hdmi.set_menu_language";

    /**
     * Property to disable muting logic in System Audio Control handling. Default is true.
     *
     * <p>True means enabling muting logic.
     * <p>False means never mute device.
     */
    // TODO(OEM): set to true to disable muting.
    static final String PROPERTY_SYSTEM_AUDIO_MODE_MUTING_ENABLE =
            "ro.hdmi.property_system_audio_mode_muting_enable";

    // Set to false to allow playback device to go to suspend mode even
    // when it's an active source. True by default.
    static final String PROPERTY_KEEP_AWAKE = "persist.sys.hdmi.keep_awake";
+19 −3
Original line number Diff line number Diff line
@@ -77,6 +77,8 @@ public class HdmiCecLocalDeviceAudioSystem extends HdmiCecLocalDevice {
        // TODO(amyjojo) make System Audio Control controllable by users
        /*mSystemAudioControlFeatureEnabled =
        mService.readBooleanSetting(Global.HDMI_SYSTEM_AUDIO_CONTROL_ENABLED, true);*/
        // TODO(b/80297700): set read-only property in config instead of setting here
        SystemProperties.set(Constants.PROPERTY_SYSTEM_AUDIO_MODE_MUTING_ENABLE, "false");
        mAutoDeviceOff = mService.readBooleanSetting(
                Global.HDMI_CONTROL_AUTO_DEVICE_OFF_ENABLED, true);
        mAutoTvOff = mService.readBooleanSetting(
@@ -425,7 +427,21 @@ public class HdmiCecLocalDeviceAudioSystem extends HdmiCecLocalDevice {
        if (newSystemAudioMode && port >= 0) {
            switchToAudioInput();
        }
        // TODO(b/80297700): Mute device when TV terminates the system audio control
        // Mute device when feature is turned off and unmute device when feature is turned on.
        // PROPERTY_SYSTEM_AUDIO_MODE_MUTING_ENABLE is false when device never needs to be muted.
        boolean currentMuteStatus =
                mService.getAudioManager().isStreamMute(AudioManager.STREAM_MUSIC);
        if (SystemProperties.getBoolean(
                Constants.PROPERTY_SYSTEM_AUDIO_MODE_MUTING_ENABLE, true)
                && currentMuteStatus == newSystemAudioMode) {
            mService.getAudioManager()
                    .adjustStreamVolume(
                            AudioManager.STREAM_MUSIC,
                            newSystemAudioMode
                                    ? AudioManager.ADJUST_UNMUTE
                                    : AudioManager.ADJUST_MUTE,
                                    0);
        }
        updateAudioManagerForSystemAudio(newSystemAudioMode);
        synchronized (mLock) {
            if (mSystemAudioActivated != newSystemAudioMode) {
+3 −5
Original line number Diff line number Diff line
@@ -34,7 +34,6 @@ import androidx.test.filters.SmallTest;
import com.android.server.hdmi.HdmiCecLocalDevice.ActiveSource;

import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@@ -149,6 +148,7 @@ public class HdmiCecLocalDeviceAudioSystemTest {
        mAvrPhysicalAddress  = 0x2000;
        mNativeWrapper.setPhysicalAddress(mAvrPhysicalAddress);
        SystemProperties.set(Constants.PROPERTY_ARC_SUPPORT, "true");
        SystemProperties.set(Constants.PROPERTY_SYSTEM_AUDIO_MODE_MUTING_ENABLE, "true");
    }

    @Test
@@ -179,7 +179,6 @@ public class HdmiCecLocalDeviceAudioSystemTest {
        assertThat(mNativeWrapper.getOnlyResultMessage()).isEqualTo(expectedMessage);
    }

    @Ignore("b/80297700")
    @Test
    public void handleRequestShortAudioDescriptor_featureDisabled() throws Exception {
        HdmiCecMessage expectedMessage =
@@ -261,7 +260,6 @@ public class HdmiCecLocalDeviceAudioSystemTest {
        assertThat(mMusicMute).isFalse();
    }

    @Ignore("b/80297700")
    @Test
    public void handleSystemAudioModeRequest_turnOffByTv() throws Exception {
        assertThat(mMusicMute).isFalse();
@@ -289,9 +287,10 @@ public class HdmiCecLocalDeviceAudioSystemTest {
        assertThat(mMusicMute).isTrue();
    }

    @Ignore("b/80297700")
    @Test
    public void onStandbyAudioSystem_currentSystemAudioControlOn() throws Exception {
        mHdmiCecLocalDeviceAudioSystem.setAutoDeviceOff(false);
        mHdmiCecLocalDeviceAudioSystem.setAutoTvOff(false);
        // Set system audio control on first
        mHdmiCecLocalDeviceAudioSystem.setSystemAudioMode(true);
        // Check if standby correctly turns off the feature
@@ -372,7 +371,6 @@ public class HdmiCecLocalDeviceAudioSystemTest {
        assertThat(mNativeWrapper.getResultMessages()).isEmpty();
    }

    @Ignore("b/80297700")
    @Test
    public void terminateSystemAudioMode_systemAudioModeOn() throws Exception {
        mHdmiCecLocalDeviceAudioSystem.setSystemAudioMode(true);