Handle disconnection and connection for LE Audio devices
Avoid staying in AudioConnected state when swtiching from BT device.
Fixes: 230679734
Test: atest TelecomUnitTests
Sponsor: @jpawlowski
Bug: 230679734
Change-Id: Iec55cc210d40c460374f528f550c210f13b0790d
Merged-Id: I3400dae5941820a29229494bf1a002d6a181d26c
diff --git a/src/com/android/server/telecom/bluetooth/BluetoothDeviceManager.java b/src/com/android/server/telecom/bluetooth/BluetoothDeviceManager.java
index da387b6..dc8fbd8 100644
--- a/src/com/android/server/telecom/bluetooth/BluetoothDeviceManager.java
+++ b/src/com/android/server/telecom/bluetooth/BluetoothDeviceManager.java
@@ -429,6 +429,7 @@
if (mAudioManager.getCommunicationDevice() != null
&& mAudioManager.getCommunicationDevice().getType()
== AudioDeviceInfo.TYPE_BLE_HEADSET) {
+ mBluetoothRouteManager.onAudioLost(mAudioManager.getCommunicationDevice().getAddress());
mAudioManager.clearCommunicationDevice();
}
mLeAudioSetAsCommunicationDevice = false;
@@ -493,6 +494,7 @@
Log.w(this, " Could not set bleHeadset device");
} else {
Log.i(this, " bleHeadset device set");
+ mBluetoothRouteManager.onAudioOn(bleHeadset.getAddress());
mLeAudioSetAsCommunicationDevice = true;
}
return result;
diff --git a/src/com/android/server/telecom/bluetooth/BluetoothStateReceiver.java b/src/com/android/server/telecom/bluetooth/BluetoothStateReceiver.java
index 1ffcc8a..e5fe971 100644
--- a/src/com/android/server/telecom/bluetooth/BluetoothStateReceiver.java
+++ b/src/com/android/server/telecom/bluetooth/BluetoothStateReceiver.java
@@ -196,9 +196,10 @@
Log.w(LOG_TAG,
"Device %s cannot be use as hearing aid communication device.",
device);
+ } else {
+ mBluetoothRouteManager.sendMessage(BT_AUDIO_IS_ON, args);
}
}
- mBluetoothRouteManager.sendMessage(BT_AUDIO_IS_ON, args);
}
}
}