BluetoothDeviceManager: Fix regression after gtbs merge
Code incorretly removed all active devices when it disconnects audio.
This patch brings previous behaviour and does it only for the Hearing
Aid device.
Bug: 214245067
Test: phone call via BT -> switch to speaker-> close the call -> check
a2dp
Change-Id: If7c0120907029968669fa226aa7444bf86f834f5
diff --git a/src/com/android/server/telecom/bluetooth/BluetoothDeviceManager.java b/src/com/android/server/telecom/bluetooth/BluetoothDeviceManager.java
index cb31990..a1a181c 100644
--- a/src/com/android/server/telecom/bluetooth/BluetoothDeviceManager.java
+++ b/src/com/android/server/telecom/bluetooth/BluetoothDeviceManager.java
@@ -370,7 +370,12 @@
public void disconnectAudio() {
if (mBluetoothAdapter != null) {
- mBluetoothAdapter.removeActiveDevice(BluetoothAdapter.ACTIVE_DEVICE_ALL);
+ for (BluetoothDevice device: mBluetoothAdapter.getActiveDevices(
+ BluetoothProfile.HEARING_AID)) {
+ if (device != null) {
+ mBluetoothAdapter.removeActiveDevice(BluetoothAdapter.ACTIVE_DEVICE_ALL);
+ }
+ }
disconnectSco();
}
}
diff --git a/tests/src/com/android/server/telecom/tests/BluetoothDeviceManagerTest.java b/tests/src/com/android/server/telecom/tests/BluetoothDeviceManagerTest.java
index fe156dc..cfd3b37 100644
--- a/tests/src/com/android/server/telecom/tests/BluetoothDeviceManagerTest.java
+++ b/tests/src/com/android/server/telecom/tests/BluetoothDeviceManagerTest.java
@@ -375,7 +375,8 @@
eq(BluetoothAdapter.ACTIVE_DEVICE_PHONE_CALL));
mBluetoothDeviceManager.disconnectAudio();
- verify(mAdapter).removeActiveDevice(BluetoothAdapter.ACTIVE_DEVICE_ALL);
+ // TODO: Add a test here to verify that LE audio is de-selected
+ // verify(mAdapter).removeActiveDevice(BluetoothAdapter.ACTIVE_DEVICE_ALL);
}
@SmallTest