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

Commit 1861c325 authored by Jakub Tyszkowski's avatar Jakub Tyszkowski Committed by Gerrit Code Review
Browse files

Merge "AudioService: Use proper stream context for Le Audio stream volume"

parents f760323d 86806df3
Loading
Loading
Loading
Loading
+12 −8
Original line number Diff line number Diff line
@@ -3841,7 +3841,7 @@ public class AudioService extends IAudioService.Stub
        }
    }

    private void setLeAudioVolumeOnModeUpdate(int mode, int streamType, int device) {
    private void setLeAudioVolumeOnModeUpdate(int mode, int device) {
        switch (mode) {
            case AudioSystem.MODE_IN_COMMUNICATION:
            case AudioSystem.MODE_IN_CALL:
@@ -3857,10 +3857,16 @@ public class AudioService extends IAudioService.Stub
                return;
        }

        // Currently, DEVICE_OUT_BLE_HEADSET is the only output type for LE_AUDIO profile.
        // (See AudioDeviceBroker#createBtDeviceInfo())
        int index = mStreamStates[streamType].getIndex(AudioSystem.DEVICE_OUT_BLE_HEADSET);
        int maxIndex = mStreamStates[streamType].getMaxIndex();
        // Forcefully set LE audio volume as a workaround, since in some cases
        // (like the outgoing call) the value of 'device' is not DEVICE_OUT_BLE_*
        // even when BLE is connected.
        if (!AudioSystem.isLeAudioDeviceType(device)) {
            device = AudioSystem.DEVICE_OUT_BLE_HEADSET;
        }

        final int streamType = getBluetoothContextualVolumeStream(mode);
        final int index = mStreamStates[streamType].getIndex(device);
        final int maxIndex = mStreamStates[streamType].getMaxIndex();

        if (DEBUG_VOL) {
            Log.d(TAG, "setLeAudioVolumeOnModeUpdate postSetLeAudioVolumeIndex index="
@@ -5242,9 +5248,7 @@ public class AudioService extends IAudioService.Stub
                // change of mode may require volume to be re-applied on some devices
                updateAbsVolumeMultiModeDevices(previousMode, mode);

                // Forcefully set LE audio volume as a workaround, since the value of 'device'
                // is not DEVICE_OUT_BLE_* even when BLE is connected.
                setLeAudioVolumeOnModeUpdate(mode, streamType, device);
                setLeAudioVolumeOnModeUpdate(mode, device);

                // when entering RINGTONE, IN_CALL or IN_COMMUNICATION mode, clear all SCO
                // connections not started by the application changing the mode when pid changes