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

Commit 66b6967d authored by Eric Laurent's avatar Eric Laurent
Browse files

AudioService: clear binder identity before calling AudioSystem

clear binder identity before calling AudioSystem methods reserved
for AudioService.

Bug: 72278478
Test: audio smoke test, CTS tests for AudioRecord and AudioTrack.
Change-Id: Ia8b934fdc39c70c9d359bd1cf02b2b3d917eec75
parent a7070317
Loading
Loading
Loading
Loading
+8 −0
Original line number Original line Diff line number Diff line
@@ -2277,7 +2277,9 @@ public class AudioService extends IAudioService.Stub
        // only mute for the current user
        // only mute for the current user
        if (getCurrentUserId() == userId) {
        if (getCurrentUserId() == userId) {
            final boolean currentMute = AudioSystem.isMicrophoneMuted();
            final boolean currentMute = AudioSystem.isMicrophoneMuted();
            final long identity = Binder.clearCallingIdentity();
            AudioSystem.muteMicrophone(on);
            AudioSystem.muteMicrophone(on);
            Binder.restoreCallingIdentity(identity);
            if (on != currentMute) {
            if (on != currentMute) {
                mContext.sendBroadcast(new Intent(AudioManager.ACTION_MICROPHONE_MUTE_CHANGED)
                mContext.sendBroadcast(new Intent(AudioManager.ACTION_MICROPHONE_MUTE_CHANGED)
                        .setFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY));
                        .setFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY));
@@ -2619,7 +2621,9 @@ public class AudioService extends IAudioService.Stub
            }
            }


            if (actualMode != mMode) {
            if (actualMode != mMode) {
                final long identity = Binder.clearCallingIdentity();
                status = AudioSystem.setPhoneState(actualMode);
                status = AudioSystem.setPhoneState(actualMode);
                Binder.restoreCallingIdentity(identity);
                if (status == AudioSystem.AUDIO_STATUS_OK) {
                if (status == AudioSystem.AUDIO_STATUS_OK) {
                    if (DEBUG_MODE) { Log.v(TAG, " mode successfully set to " + actualMode); }
                    if (DEBUG_MODE) { Log.v(TAG, " mode successfully set to " + actualMode); }
                    mMode = actualMode;
                    mMode = actualMode;
@@ -7194,11 +7198,15 @@ public class AudioService extends IAudioService.Stub
            if (mHasFocusListener) {
            if (mHasFocusListener) {
                mMediaFocusControl.removeFocusFollower(mPolicyCallback);
                mMediaFocusControl.removeFocusFollower(mPolicyCallback);
            }
            }
            final long identity = Binder.clearCallingIdentity();
            AudioSystem.registerPolicyMixes(mMixes, false);
            AudioSystem.registerPolicyMixes(mMixes, false);
            Binder.restoreCallingIdentity(identity);
        }
        }


        void connectMixes() {
        void connectMixes() {
            final long identity = Binder.clearCallingIdentity();
            AudioSystem.registerPolicyMixes(mMixes, true);
            AudioSystem.registerPolicyMixes(mMixes, true);
            Binder.restoreCallingIdentity(identity);
        }
        }
    };
    };