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

Commit bc2aab3e authored by Shubang's avatar Shubang
Browse files

Reuse setSystemAudioMode() in terminateSystemAudioMode()

Bug: 80296770
Test: atest com.android.server.hdmi
Change-Id: I12244fd8bdd8b0a15f5abde498f9b6ae2831a03a
parent 2fd186ea
Loading
Loading
Loading
Loading
+8 −28
Original line number Diff line number Diff line
@@ -66,11 +66,7 @@ public class HdmiCecLocalDeviceAudioSystem extends HdmiCecLocalDevice {
                    Constants.PROPERTY_LAST_SYSTEM_AUDIO_CONTROL,
                    mSystemAudioActivated ? "true" : "false");
        }
        if (setSystemAudioMode(false)) {
            mService.sendCecCommand(
                    HdmiCecMessageBuilder.buildSetSystemAudioMode(
                            mAddress, Constants.ADDR_BROADCAST, false));
        }
        terminateSystemAudioMode();
    }

    @Override
@@ -335,31 +331,15 @@ public class HdmiCecLocalDeviceAudioSystem extends HdmiCecLocalDevice {
    protected void terminateSystemAudioMode() {
        // remove pending initiation actions
        removeAction(SystemAudioInitiationActionFromAvr.class);

        synchronized (mLock) {
            if (!mSystemAudioActivated) {
        if (!isSystemAudioActivated()) {
            return;
        }
        }

        if (setSystemAudioMode(false)) {
            // send <Set System Audio Mode> [“Off”]
            mService.sendCecCommand(
                    HdmiCecMessageBuilder.buildSetSystemAudioMode(
                            mAddress, Constants.ADDR_BROADCAST, false));

        // mute speaker
        if (!mService.getAudioManager().isStreamMute(AudioManager.STREAM_MUSIC)) {
            mService.getAudioManager()
                    .adjustStreamVolume(
                            AudioManager.STREAM_MUSIC,
                            AudioManager.ADJUST_MUTE,
                            0);
        }

        mSystemAudioSource = null;
        synchronized (mLock) {
            mSystemAudioActivated = false;
            mService.announceSystemAudioModeChange(false);
        }
    }