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

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

Merge "Fix thirt party app security exception when call to AudioManager.setMicrophoneMute()"

parents 4e913da1 3cf3c640
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -269,6 +269,7 @@ public class AudioService extends IAudioService.Stub
    private static final int MSG_OBSERVE_DEVICES_FOR_ALL_STREAMS = 27;
    private static final int MSG_HDMI_VOLUME_CHECK = 28;
    private static final int MSG_PLAYBACK_CONFIG_CHANGE = 29;
    private static final int MSG_BROADCAST_MICROPHONE_MUTE = 30;
    // start of messages handled under wakelock
    //   these messages can only be queued, i.e. sent with queueMsgUnderWakeLock(),
    //   and not with sendMsg(..., ..., SENDMSG_QUEUE, ...)
@@ -2925,9 +2926,8 @@ public class AudioService extends IAudioService.Stub
            AudioSystem.muteMicrophone(muted);
            try {
                if (muted != currentMute) {
                    mContext.sendBroadcastAsUser(
                        new Intent(AudioManager.ACTION_MICROPHONE_MUTE_CHANGED)
                                .setFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY), UserHandle.ALL);
                    sendMsg(mAudioHandler, MSG_BROADCAST_MICROPHONE_MUTE,
                                SENDMSG_NOOP, 0, 0, null, 0);
                }
            } finally {
                Binder.restoreCallingIdentity(identity);
@@ -5236,6 +5236,13 @@ public class AudioService extends IAudioService.Stub
                case MSG_PLAYBACK_CONFIG_CHANGE:
                    onPlaybackConfigChange((List<AudioPlaybackConfiguration>) msg.obj);
                    break;

                case MSG_BROADCAST_MICROPHONE_MUTE:
                    mContext.sendBroadcastAsUser(
                            new Intent(AudioManager.ACTION_MICROPHONE_MUTE_CHANGED)
                                    .setFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY),
                                    UserHandle.ALL);
                    break;
            }
        }
    }