Merge "Handle disconnection and connection for LE Audio devices" into tm-dev
diff --git a/src/com/android/server/telecom/bluetooth/BluetoothDeviceManager.java b/src/com/android/server/telecom/bluetooth/BluetoothDeviceManager.java
index 81982c9..5cc54de 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);
            }
         }
     }