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

Commit 3b75ae35 authored by Vlad Popa's avatar Vlad Popa Committed by Android (Google) Code Review
Browse files

Merge "Only allow STREAM_MUSIC as driving stream for AVRCP" into main

parents 16d7c44f 3b87c1bb
Loading
Loading
Loading
Loading
+19 −8
Original line number Diff line number Diff line
@@ -4684,6 +4684,12 @@ public class AudioService extends IAudioService.Stub
        switch (mode) {
            case AudioSystem.MODE_IN_COMMUNICATION:
            case AudioSystem.MODE_IN_CALL:
                // TODO(b/382704431): remove to allow STREAM_VOICE_CALL to drive abs volume
                //  over A2DP
                if (getDeviceForStream(AudioSystem.STREAM_VOICE_CALL)
                        == AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP) {
                    return AudioSystem.STREAM_MUSIC;
                }
                return AudioSystem.STREAM_VOICE_CALL;
            case AudioSystem.MODE_CALL_SCREENING:
            case AudioSystem.MODE_COMMUNICATION_REDIRECT:
@@ -4695,15 +4701,20 @@ public class AudioService extends IAudioService.Stub
                // other conditions will influence the stream type choice, read on...
                break;
        }
        if (voiceActivityCanOverride
                && mVoicePlaybackActive.get()) {
        if (voiceActivityCanOverride && mVoicePlaybackActive.get()) {
            // TODO(b/382704431): remove to allow STREAM_VOICE_CALL to drive abs volume over A2DP
            if (getDeviceForStream(AudioSystem.STREAM_VOICE_CALL)
                    == AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP) {
                return AudioSystem.STREAM_MUSIC;
            }
            return AudioSystem.STREAM_VOICE_CALL;
        }
        return AudioSystem.STREAM_MUSIC;
    }
    private AtomicBoolean mVoicePlaybackActive = new AtomicBoolean(false);
    private AtomicBoolean mMediaPlaybackActive = new AtomicBoolean(false);
    private final AtomicBoolean mVoicePlaybackActive = new AtomicBoolean(false);
    private final AtomicBoolean mMediaPlaybackActive = new AtomicBoolean(false);
    private final IPlaybackConfigDispatcher mPlaybackActivityMonitor =
            new IPlaybackConfigDispatcher.Stub() {
@@ -4923,7 +4934,7 @@ public class AudioService extends IAudioService.Stub
    private void onUpdateContextualVolumes() {
        final int streamType = getBluetoothContextualVolumeStream();
        Log.i(TAG,
        Slog.i(TAG,
                "onUpdateContextualVolumes: absolute volume driving streams " + streamType
                + " avrcp supported: " + mAvrcpAbsVolSupported);
        synchronized (mCachedAbsVolDrivingStreamsLock) {
@@ -4932,7 +4943,7 @@ public class AudioService extends IAudioService.Stub
                if (absDev == AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP) {
                    enabled = mAvrcpAbsVolSupported;
                    if (!enabled) {
                        Log.w(TAG, "Updating avrcp not supported in onUpdateContextualVolumes");
                        Slog.w(TAG, "Updating avrcp not supported in onUpdateContextualVolumes");
                    }
                }
                if (stream != streamType) {
@@ -4960,7 +4971,7 @@ public class AudioService extends IAudioService.Stub
            return;
        }
        if (absVolumeDevices.size() > 1) {
            Log.w(TAG, "onUpdateContextualVolumes too many active devices: "
            Slog.w(TAG, "onUpdateContextualVolumes too many active devices: "
                    + absVolumeDevices.stream().map(AudioSystem::getOutputDeviceName)
                        .collect(Collectors.joining(","))
                    + ", for stream: " + streamType);
@@ -4971,7 +4982,7 @@ public class AudioService extends IAudioService.Stub
        final int index = getStreamVolume(streamType, device);
        if (DEBUG_VOL) {
            Log.i(TAG, "onUpdateContextualVolumes streamType: " + streamType
            Slog.i(TAG, "onUpdateContextualVolumes streamType: " + streamType
                    + ", device: " + AudioSystem.getOutputDeviceName(device)
                    + ", index: " + index);
        }