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

Commit 4c345158 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Apply unmute to all aliased streams."

parents 0f12bc27 31c19b07
Loading
Loading
Loading
Loading
+17 −13
Original line number Original line Diff line number Diff line
@@ -355,7 +355,7 @@ public class AudioService extends IAudioService.Stub
    private static final int MSG_SET_ALL_VOLUMES = 10;
    private static final int MSG_SET_ALL_VOLUMES = 10;
    private static final int MSG_UNLOAD_SOUND_EFFECTS = 15;
    private static final int MSG_UNLOAD_SOUND_EFFECTS = 15;
    private static final int MSG_SYSTEM_READY = 16;
    private static final int MSG_SYSTEM_READY = 16;
    private static final int MSG_UNMUTE_STREAM = 18;
    private static final int MSG_UNMUTE_STREAM_ON_SINGLE_VOL_DEVICE = 18;
    private static final int MSG_DYN_POLICY_MIX_STATE_UPDATE = 19;
    private static final int MSG_DYN_POLICY_MIX_STATE_UPDATE = 19;
    private static final int MSG_INDICATE_SYSTEM_READY = 20;
    private static final int MSG_INDICATE_SYSTEM_READY = 20;
    private static final int MSG_ACCESSORY_PLUG_MEDIA_UNMUTE = 21;
    private static final int MSG_ACCESSORY_PLUG_MEDIA_UNMUTE = 21;
@@ -3506,7 +3506,7 @@ public class AudioService extends IAudioService.Stub
        if (adjustVolume && (direction != AudioManager.ADJUST_SAME)
        if (adjustVolume && (direction != AudioManager.ADJUST_SAME)
                && (keyEventMode != AudioDeviceVolumeManager.ADJUST_MODE_END)) {
                && (keyEventMode != AudioDeviceVolumeManager.ADJUST_MODE_END)) {
            mAudioHandler.removeMessages(MSG_UNMUTE_STREAM);
            mAudioHandler.removeMessages(MSG_UNMUTE_STREAM_ON_SINGLE_VOL_DEVICE);
            if (isMuteAdjust && !mFullVolumeDevices.contains(device)) {
            if (isMuteAdjust && !mFullVolumeDevices.contains(device)) {
                boolean state;
                boolean state;
@@ -3533,8 +3533,9 @@ public class AudioService extends IAudioService.Stub
                        muteAliasStreams(streamTypeAlias, false);
                        muteAliasStreams(streamTypeAlias, false);
                    } else if (direction == AudioManager.ADJUST_LOWER) {
                    } else if (direction == AudioManager.ADJUST_LOWER) {
                        if (mIsSingleVolume) {
                        if (mIsSingleVolume) {
                            sendMsg(mAudioHandler, MSG_UNMUTE_STREAM, SENDMSG_QUEUE,
                            sendMsg(mAudioHandler, MSG_UNMUTE_STREAM_ON_SINGLE_VOL_DEVICE,
                                    streamTypeAlias, flags, null, UNMUTE_STREAM_DELAY);
                                    SENDMSG_QUEUE, streamTypeAlias, flags, null,
                                    UNMUTE_STREAM_DELAY);
                        }
                        }
                    }
                    }
                }
                }
@@ -3693,18 +3694,21 @@ public class AudioService extends IAudioService.Stub
    }
    }
    // Called after a delay when volume down is pressed while muted
    // Called after a delay when volume down is pressed while muted
    private void onUnmuteStream(int stream, int flags) {
    private void onUnmuteStreamOnSingleVolDevice(int streamAlias, int flags) {
        boolean wasMuted;
        boolean wasMuted;
        synchronized (VolumeStreamState.class) {
        synchronized (VolumeStreamState.class) {
            final VolumeStreamState streamState = mStreamStates[stream];
            final VolumeStreamState streamState = mStreamStates[streamAlias];
            // if unmuting causes a change, it was muted
            // if unmuting causes a change, it was muted
            wasMuted = streamState.mute(false, "onUnmuteStream");
            wasMuted = streamState.mute(false, "onUnmuteStreamOnSingleVolDevice");
            if (wasMuted) {
            final int device = getDeviceForStream(stream);
                // Unmute all aliasted streams
                muteAliasStreams(streamAlias, false);
            }
            final int device = getDeviceForStream(streamAlias);
            final int index = streamState.getIndex(device);
            final int index = streamState.getIndex(device);
            sendVolumeUpdate(stream, index, index, flags, device);
            sendVolumeUpdate(streamAlias, index, index, flags, device);
        }
        }
        if (stream == AudioSystem.STREAM_MUSIC && wasMuted) {
        if (streamAlias == AudioSystem.STREAM_MUSIC && wasMuted) {
            synchronized (mHdmiClientLock) {
            synchronized (mHdmiClientLock) {
                maybeSendSystemAudioStatusCommand(true);
                maybeSendSystemAudioStatusCommand(true);
            }
            }
@@ -9191,8 +9195,8 @@ public class AudioService extends IAudioService.Stub
                    onAccessoryPlugMediaUnmute(msg.arg1);
                    onAccessoryPlugMediaUnmute(msg.arg1);
                    break;
                    break;
                case MSG_UNMUTE_STREAM:
                case MSG_UNMUTE_STREAM_ON_SINGLE_VOL_DEVICE:
                    onUnmuteStream(msg.arg1, msg.arg2);
                    onUnmuteStreamOnSingleVolDevice(msg.arg1, msg.arg2);
                    break;
                    break;
                case MSG_DYN_POLICY_MIX_STATE_UPDATE:
                case MSG_DYN_POLICY_MIX_STATE_UPDATE: