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

Commit de72882e authored by Shubang's avatar Shubang
Browse files

Send audio status only when in system audio mode

And use clearCallingIdentity to avoid permission issue.

Bug: 111504981
Test: make; local tests;
Change-Id: Ie62dc80416fbffe1cb54fa729ffc80ca008946f5
parent 4c436c0f
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -1781,12 +1781,15 @@ public class AudioService extends IAudioService.Stub
                    }

                    if (mHdmiAudioSystemClient != null &&
                            mHdmiSystemAudioSupported &&
                            streamTypeAlias == AudioSystem.STREAM_MUSIC &&
                            (oldIndex != newIndex || isMuteAdjust)) {
                        final long identity = Binder.clearCallingIdentity();
                        mHdmiAudioSystemClient.sendReportAudioStatusCecCommand(
                                isMuteAdjust, getStreamVolume(AudioSystem.STREAM_MUSIC),
                                getStreamMaxVolume(AudioSystem.STREAM_MUSIC),
                                isStreamMute(AudioSystem.STREAM_MUSIC));
                        Binder.restoreCallingIdentity(identity);
                    }
                }
            }
@@ -2044,12 +2047,15 @@ public class AudioService extends IAudioService.Stub
        synchronized (mHdmiClientLock) {
            if (mHdmiManager != null &&
                    mHdmiAudioSystemClient != null &&
                    mHdmiSystemAudioSupported &&
                    streamTypeAlias == AudioSystem.STREAM_MUSIC &&
                    (oldIndex != index)) {
                final long identity = Binder.clearCallingIdentity();
                mHdmiAudioSystemClient.sendReportAudioStatusCecCommand(
                        false, getStreamVolume(AudioSystem.STREAM_MUSIC),
                        getStreamMaxVolume(AudioSystem.STREAM_MUSIC),
                        isStreamMute(AudioSystem.STREAM_MUSIC));
                Binder.restoreCallingIdentity(identity);
            }
        }
        sendVolumeUpdate(streamType, oldIndex, index, flags);
@@ -7104,11 +7110,11 @@ public class AudioService extends IAudioService.Stub
        int device = AudioSystem.DEVICE_NONE;
        synchronized (mHdmiClientLock) {
            if (mHdmiManager != null) {
                if (mHdmiTvClient == null) {
                    Log.w(TAG, "Only Hdmi-Cec enabled TV device supports system audio mode.");
                if (mHdmiTvClient == null && mHdmiAudioSystemClient == null) {
                    Log.w(TAG, "Only Hdmi-Cec enabled TV or audio system device supports"
                            + "system audio mode.");
                    return device;
                }

                if (mHdmiSystemAudioSupported != on) {
                    mHdmiSystemAudioSupported = on;
                    final int config = on ? AudioSystem.FORCE_HDMI_SYSTEM_AUDIO_ENFORCED :
+1 −0
Original line number Diff line number Diff line
@@ -224,6 +224,7 @@ public class HdmiCecLocalDeviceAudioSystem extends HdmiCecLocalDevice {
            return true;
        }

        mSystemAudioSource = systemAudioStatusOn ? message.getSource() : null;
        mService.sendCecCommand(
                HdmiCecMessageBuilder.buildSetSystemAudioMode(
                        mAddress, Constants.ADDR_BROADCAST, systemAudioStatusOn));