Fix AudioDeviceInventory#disconnectLeAudio

This CL fixes disconnectLeAudio to disconnect devices properly
and make it send becoming noisy intent when
an LE audio device is disconnected.

It also calls disconnectLeAudio for broadcast profiles.

Bug: 230298077
Test: manually turning off BT to check if
media is paused.

Merged-In: Ifd74c244e19f5e7f92fdbd8f7d20cd99a054425a
Change-Id: Ifd74c244e19f5e7f92fdbd8f7d20cd99a054425a
(cherry picked from commit 695a264811)
This commit is contained in:
Kyunglyul Hyun
2022-04-26 16:07:24 +09:00
parent 00545d0fd6
commit 80786db7b4
2 changed files with 6 additions and 2 deletions

View File

@@ -829,8 +829,8 @@ public class AudioDeviceInventory {
}
/*package*/ void disconnectLeAudio(int device) {
if (device != AudioSystem.DEVICE_OUT_BLE_HEADSET ||
device != AudioSystem.DEVICE_OUT_BLE_BROADCAST) {
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;
}
@@ -846,6 +846,8 @@ public class AudioDeviceInventory {
new MediaMetrics.Item(mMetricsId + "disconnectLeAudio")
.record();
if (toRemove.size() > 0) {
final int delay = checkSendBecomingNoisyIntentInt(device, 0,
AudioSystem.DEVICE_NONE);
toRemove.stream().forEach(deviceAddress ->
makeLeAudioDeviceUnavailable(deviceAddress, device)
);

View File

@@ -461,6 +461,7 @@ public class BtHelper {
mDeviceBroker.postBtProfileDisconnected(BluetoothProfile.HEADSET);
mDeviceBroker.postBtProfileDisconnected(BluetoothProfile.HEARING_AID);
mDeviceBroker.postBtProfileDisconnected(BluetoothProfile.LE_AUDIO);
mDeviceBroker.postBtProfileDisconnected(BluetoothProfile.LE_AUDIO_BROADCAST);
}
// @GuardedBy("AudioDeviceBroker.mSetModeLock")
@@ -675,6 +676,7 @@ public class BtHelper {
case BluetoothProfile.HEADSET:
case BluetoothProfile.HEARING_AID:
case BluetoothProfile.LE_AUDIO:
case BluetoothProfile.LE_AUDIO_BROADCAST:
mDeviceBroker.postBtProfileDisconnected(profile);
break;