diff options
| author | 2022-03-23 13:32:19 +0000 | |
|---|---|---|
| committer | 2022-07-15 14:58:03 -0700 | |
| commit | b9201a0a9d17abf5e138a9ff7955ff778cc310ec (patch) | |
| tree | 3f5cf1b5bfdad8f986bd3a2def86dc7ae9c4955d | |
| parent | c4a11b4ee19d16ca468b1294919038e6400e3193 (diff) | |
le_audio: Extend handling of Broadcaster as active device
Patch extends handling Broadcaster as active Bluetooth device.
Broadcast device.
Bug: 150670922
Tag: #feature
Test: PTS and presubmit
Sponsor: jpawlowski@
Merged-In: Ic41c619411f1784bf586aa48ad0fa4a39a37ecb7
Change-Id: Ic41c619411f1784bf586aa48ad0fa4a39a37ecb7
(cherry picked from commit 7c1bf84c373f10ad88f2b220b787dd9f71f1ff76)
| -rw-r--r-- | services/core/java/com/android/server/audio/AudioDeviceInventory.java | 39 | ||||
| -rw-r--r-- | services/core/java/com/android/server/audio/AudioService.java | 8 |
2 files changed, 34 insertions, 13 deletions
diff --git a/services/core/java/com/android/server/audio/AudioDeviceInventory.java b/services/core/java/com/android/server/audio/AudioDeviceInventory.java index a3c6f0a68c78..282714a5dd21 100644 --- a/services/core/java/com/android/server/audio/AudioDeviceInventory.java +++ b/services/core/java/com/android/server/audio/AudioDeviceInventory.java @@ -363,6 +363,7 @@ public class AudioDeviceInventory { } break; case BluetoothProfile.LE_AUDIO: + case BluetoothProfile.LE_AUDIO_BROADCAST: if (switchToUnavailable) { makeLeAudioDeviceUnavailable(address, btInfo.mAudioSystemDevice); } else if (switchToAvailable) { @@ -814,7 +815,10 @@ public class AudioDeviceInventory { disconnectHearingAid(); break; case BluetoothProfile.LE_AUDIO: - disconnectLeAudio(); + disconnectLeAudioUnicast(); + break; + case BluetoothProfile.LE_AUDIO_BROADCAST: + disconnectLeAudioBroadcast(); break; default: // Not a valid profile to disconnect @@ -824,28 +828,39 @@ public class AudioDeviceInventory { } } - /*package*/ void disconnectLeAudio() { + /*package*/ void disconnectLeAudio(int device) { + if (device != AudioSystem.DEVICE_OUT_BLE_HEADSET || + device != AudioSystem.DEVICE_OUT_BLE_BROADCAST) { + Log.e(TAG, "disconnectLeAudio: Can't disconnect not LE Audio device " + device); + return; + } + synchronized (mDevicesLock) { final ArraySet<String> toRemove = new ArraySet<>(); - // Disconnect ALL DEVICE_OUT_BLE_HEADSET devices + // Disconnect ALL DEVICE_OUT_BLE_HEADSET or DEVICE_OUT_BLE_BROADCAST devices mConnectedDevices.values().forEach(deviceInfo -> { - if (deviceInfo.mDeviceType == AudioSystem.DEVICE_OUT_BLE_HEADSET) { + if (deviceInfo.mDeviceType == device) { toRemove.add(deviceInfo.mDeviceAddress); } }); new MediaMetrics.Item(mMetricsId + "disconnectLeAudio") .record(); if (toRemove.size() > 0) { - final int delay = checkSendBecomingNoisyIntentInt( - AudioSystem.DEVICE_OUT_BLE_HEADSET, 0, AudioSystem.DEVICE_NONE); toRemove.stream().forEach(deviceAddress -> - makeLeAudioDeviceUnavailable(deviceAddress, - AudioSystem.DEVICE_OUT_BLE_HEADSET) + makeLeAudioDeviceUnavailable(deviceAddress, device) ); } } } + /*package*/ void disconnectLeAudioUnicast() { + disconnectLeAudio(AudioSystem.DEVICE_OUT_BLE_HEADSET); + } + + /*package*/ void disconnectLeAudioBroadcast() { + disconnectLeAudio(AudioSystem.DEVICE_OUT_BLE_BROADCAST); + } + // must be called before removing the device from mConnectedDevices // musicDevice argument is used when not AudioSystem.DEVICE_NONE instead of querying // from AudioSystem @@ -875,7 +890,9 @@ public class AudioDeviceInventory { int delay; synchronized (mDevicesLock) { if (!info.mSupprNoisy - && ((info.mProfile == BluetoothProfile.LE_AUDIO && info.mIsLeOutput) + && (((info.mProfile == BluetoothProfile.LE_AUDIO + || info.mProfile == BluetoothProfile.LE_AUDIO_BROADCAST) + && info.mIsLeOutput) || info.mProfile == BluetoothProfile.HEARING_AID || info.mProfile == BluetoothProfile.A2DP)) { @AudioService.ConnectionState int asState = @@ -1110,8 +1127,7 @@ public class AudioDeviceInventory { return; } - final int leAudioVolIndex = mDeviceBroker.getVssVolumeForDevice(streamType, - AudioSystem.DEVICE_OUT_BLE_HEADSET); + final int leAudioVolIndex = mDeviceBroker.getVssVolumeForDevice(streamType, device); final int maxIndex = mDeviceBroker.getMaxVssVolumeForStream(streamType); mDeviceBroker.postSetLeAudioVolumeIndex(leAudioVolIndex, maxIndex, streamType); mDeviceBroker.postApplyVolumeOnDevice(streamType, device, "makeLeAudioDeviceAvailable"); @@ -1163,6 +1179,7 @@ public class AudioDeviceInventory { BECOMING_NOISY_INTENT_DEVICES_SET.add(AudioSystem.DEVICE_OUT_LINE); BECOMING_NOISY_INTENT_DEVICES_SET.add(AudioSystem.DEVICE_OUT_HEARING_AID); BECOMING_NOISY_INTENT_DEVICES_SET.add(AudioSystem.DEVICE_OUT_BLE_HEADSET); + BECOMING_NOISY_INTENT_DEVICES_SET.add(AudioSystem.DEVICE_OUT_BLE_BROADCAST); BECOMING_NOISY_INTENT_DEVICES_SET.addAll(AudioSystem.DEVICE_OUT_ALL_A2DP_SET); BECOMING_NOISY_INTENT_DEVICES_SET.addAll(AudioSystem.DEVICE_OUT_ALL_USB_SET); BECOMING_NOISY_INTENT_DEVICES_SET.addAll(AudioSystem.DEVICE_OUT_ALL_BLE_SET); diff --git a/services/core/java/com/android/server/audio/AudioService.java b/services/core/java/com/android/server/audio/AudioService.java index 1cc044387553..490f84456823 100644 --- a/services/core/java/com/android/server/audio/AudioService.java +++ b/services/core/java/com/android/server/audio/AudioService.java @@ -2998,7 +2998,8 @@ public class AudioService extends IAudioService.Stub mDeviceBroker.postSetAvrcpAbsoluteVolumeIndex(newIndex / 10); } - if (device == AudioSystem.DEVICE_OUT_BLE_HEADSET + if ((device == AudioSystem.DEVICE_OUT_BLE_HEADSET + || device == AudioSystem.DEVICE_OUT_BLE_BROADCAST) && streamType == getBluetoothContextualVolumeStream() && (flags & AudioManager.FLAG_BLUETOOTH_ABS_VOLUME) == 0) { if (DEBUG_VOL) { @@ -3644,7 +3645,8 @@ public class AudioService extends IAudioService.Stub mDeviceBroker.postSetAvrcpAbsoluteVolumeIndex(index / 10); } - if (device == AudioSystem.DEVICE_OUT_BLE_HEADSET + if ((device == AudioSystem.DEVICE_OUT_BLE_HEADSET + || device == AudioSystem.DEVICE_OUT_BLE_BROADCAST) && streamType == getBluetoothContextualVolumeStream() && (flags & AudioManager.FLAG_BLUETOOTH_ABS_VOLUME) == 0) { if (DEBUG_VOL) { @@ -6336,6 +6338,7 @@ public class AudioService extends IAudioService.Stub BluetoothProfile.A2DP, BluetoothProfile.A2DP_SINK, BluetoothProfile.LE_AUDIO, + BluetoothProfile.LE_AUDIO_BROADCAST, }) @Retention(RetentionPolicy.SOURCE) public @interface BtProfile {} @@ -6357,6 +6360,7 @@ public class AudioService extends IAudioService.Stub final int profile = info.getProfile(); if (profile != BluetoothProfile.A2DP && profile != BluetoothProfile.A2DP_SINK && profile != BluetoothProfile.LE_AUDIO + && profile != BluetoothProfile.LE_AUDIO_BROADCAST && profile != BluetoothProfile.HEARING_AID) { throw new IllegalArgumentException("Illegal BluetoothProfile profile for device " + previousDevice + " -> " + newDevice + ". Got: " + profile); |