diff options
| author | 2022-10-25 15:05:24 +0000 | |
|---|---|---|
| committer | 2022-10-25 15:05:24 +0000 | |
| commit | bff977a13bd6f395930a8b54bfb60960d16b84ed (patch) | |
| tree | 323b7f0d190387d574c9276b9251c3080a49e9df | |
| parent | 7eda1221b9115ce63115e149465993e318e21066 (diff) | |
| parent | 1861c325ae6955ac29017926bfd266318dca7d77 (diff) | |
Merge "AudioService: Use proper stream context for Le Audio stream volume" am: 1861c325ae
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2253034
Change-Id: I8699f9deb9019ddea9530f4dfef475853e5438a4
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
| -rw-r--r-- | services/core/java/com/android/server/audio/AudioService.java | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/services/core/java/com/android/server/audio/AudioService.java b/services/core/java/com/android/server/audio/AudioService.java index 733a412c081e..38cd8c0bbf48 100644 --- a/services/core/java/com/android/server/audio/AudioService.java +++ b/services/core/java/com/android/server/audio/AudioService.java @@ -4011,7 +4011,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: @@ -4025,10 +4025,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=" @@ -5414,9 +5420,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 |