From 210e9719844fb4d3eab2a9a1c2c6e39defb71453 Mon Sep 17 00:00:00 2001 From: Hyundo Moon Date: Thu, 27 Jan 2022 17:11:41 +0900 Subject: [PATCH] Show volume bar when BLE device's volume is changed Bug: 211836364 Test: atest (--host) bluetooth_vc_test:VolumeControlTest Tested volume changes from earbuds and from phone while playing music Change-Id: I9895578bd2ecda0607f808d645e0acf3a01e1db6 --- .../com/android/server/audio/AudioService.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/services/core/java/com/android/server/audio/AudioService.java b/services/core/java/com/android/server/audio/AudioService.java index e00c8a39074a5..f426afcb2c4c9 100644 --- a/services/core/java/com/android/server/audio/AudioService.java +++ b/services/core/java/com/android/server/audio/AudioService.java @@ -2817,8 +2817,9 @@ public class AudioService extends IAudioService.Stub int step; // skip a2dp absolute volume control request when the device - // is not an a2dp device - if (!AudioSystem.DEVICE_OUT_ALL_A2DP_SET.contains(device) + // is neither an a2dp device nor BLE device + if ((!AudioSystem.DEVICE_OUT_ALL_A2DP_SET.contains(device) + && !AudioSystem.DEVICE_OUT_ALL_BLE_SET.contains(device)) && (flags & AudioManager.FLAG_BLUETOOTH_ABS_VOLUME) != 0) { return; } @@ -2958,7 +2959,8 @@ public class AudioService extends IAudioService.Stub } if (device == AudioSystem.DEVICE_OUT_BLE_HEADSET - && streamType == getBluetoothContextualVolumeStream()) { + && streamType == getBluetoothContextualVolumeStream() + && (flags & AudioManager.FLAG_BLUETOOTH_ABS_VOLUME) == 0) { if (DEBUG_VOL) { Log.d(TAG, "adjustSreamVolume postSetLeAudioVolumeIndex index=" + newIndex + " stream=" + streamType); @@ -3559,8 +3561,9 @@ public class AudioService extends IAudioService.Stub int oldIndex; // skip a2dp absolute volume control request when the device - // is not an a2dp device - if (!AudioSystem.DEVICE_OUT_ALL_A2DP_SET.contains(device) + // is neither an a2dp device nor BLE device + if ((!AudioSystem.DEVICE_OUT_ALL_A2DP_SET.contains(device) + && !AudioSystem.DEVICE_OUT_ALL_BLE_SET.contains(device)) && (flags & AudioManager.FLAG_BLUETOOTH_ABS_VOLUME) != 0) { return; } @@ -3602,7 +3605,8 @@ public class AudioService extends IAudioService.Stub } if (device == AudioSystem.DEVICE_OUT_BLE_HEADSET - && streamType == getBluetoothContextualVolumeStream()) { + && streamType == getBluetoothContextualVolumeStream() + && (flags & AudioManager.FLAG_BLUETOOTH_ABS_VOLUME) == 0) { if (DEBUG_VOL) { Log.d(TAG, "adjustSreamVolume postSetLeAudioVolumeIndex index=" + index + " stream=" + streamType);