diff options
| author | 2022-07-28 02:58:56 +0000 | |
|---|---|---|
| committer | 2022-07-28 02:58:56 +0000 | |
| commit | 40e3c6ebfbf38e32e1ee2b0ae743088e6a1dff7c (patch) | |
| tree | 18031d3075a8d1d92c714823bec951db27d8754c | |
| parent | 4acfd1e434233902bac2ab8ee176931078ea26ed (diff) | |
| parent | 9c2fa2c4640a8fe17d4d2770e77ea12df296d4d9 (diff) | |
Merge "Set LE audio volume when audio mode is changed" am: b731a366a0 am: cc1d0701c1 am: 6e5e2c1ee3 am: 93e5af71fe am: 9c2fa2c464
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2160736
Change-Id: Ia98b1c37f2870b428127062b8a4aa56f2b4b9c44
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 | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/services/core/java/com/android/server/audio/AudioService.java b/services/core/java/com/android/server/audio/AudioService.java index 18d5194e8bc0..e40925605899 100644 --- a/services/core/java/com/android/server/audio/AudioService.java +++ b/services/core/java/com/android/server/audio/AudioService.java @@ -3904,6 +3904,36 @@ public class AudioService extends IAudioService.Stub } } + private void setLeAudioVolumeOnModeUpdate(int mode) { + switch (mode) { + case AudioSystem.MODE_IN_COMMUNICATION: + case AudioSystem.MODE_IN_CALL: + case AudioSystem.MODE_NORMAL: + break; + case AudioSystem.MODE_RINGTONE: + // not changing anything for ringtone + return; + case AudioSystem.MODE_CURRENT: + case AudioSystem.MODE_INVALID: + default: + // don't know what to do in this case, better bail + return; + } + + int streamType = getBluetoothContextualVolumeStream(mode); + + // 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(); + + if (DEBUG_VOL) { + Log.d(TAG, "setLeAudioVolumeOnModeUpdate postSetLeAudioVolumeIndex index=" + + index + " maxIndex=" + maxIndex + " streamType=" + streamType); + } + mDeviceBroker.postSetLeAudioVolumeIndex(index, maxIndex, streamType); + } + private void setStreamVolume(int streamType, int index, int flags, String callingPackage, String caller, String attributionTag, int uid, boolean hasModifyAudioSettings) { @@ -5276,6 +5306,10 @@ 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); + // when entering RINGTONE, IN_CALL or IN_COMMUNICATION mode, clear all SCO // connections not started by the application changing the mode when pid changes mDeviceBroker.postSetModeOwnerPid(pid, mode); |