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

Commit 3b87c1bb authored by Vlad Popa's avatar Vlad Popa
Browse files

Only allow STREAM_MUSIC as driving stream for AVRCP

The BT AVRCP service is storing the last volume of STREAM_MUSIC when
something changes. This is inconsistent with the audio framework which
now allows to have STREAM_VOICE_CALL drive the absolute volume too.

As a quick fix, enforcing on the audio fwk side to be consistent with
the AVRCP service and report only STREAM_MUSIC as the driving stream for
AVRCP.

Test: bug repro with active STREAM_VC when AVRCP active
Bug: 379917442
Bug: 382366084
Flag: EXEMPT bugfix
Change-Id: I4e87edfc938d34c341b0012736e1af2affaa2746
parent 48d2f0d3
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);
        }