Disable Le Audio communication flag before notifying audio lost

While disconnecting BT LE audio headset, currently audio lost is notified
and then mLeAudioSetAsCommunicationDevice is cleared. This is causing
wrong AudioState because BlueToothRouteManager sees that BT LE audio
is still connected. So first clear the flag and notify audio lost
so that when BlueToothRouteManager queries BT connected state,
LE audio devices are ignored and moves to AudioOff state.

Bug: 237642330
Change-Id: Id6b76a84e557a1a74511224fc7d0e3e336262982
diff --git a/src/com/android/server/telecom/bluetooth/BluetoothDeviceManager.java b/src/com/android/server/telecom/bluetooth/BluetoothDeviceManager.java
index dc8fbd8..58c74fc 100644
--- a/src/com/android/server/telecom/bluetooth/BluetoothDeviceManager.java
+++ b/src/com/android/server/telecom/bluetooth/BluetoothDeviceManager.java
@@ -420,10 +420,9 @@
         if (!mLeAudioSetAsCommunicationDevice) {
             return;
         }
-
+        mLeAudioSetAsCommunicationDevice = false;
         if (mAudioManager == null) {
             Log.i(this, "clearLeAudioCommunicationDevice: mAudioManager is null");
-            mLeAudioSetAsCommunicationDevice = false;
             return;
         }
         if (mAudioManager.getCommunicationDevice() != null
@@ -432,24 +431,22 @@
             mBluetoothRouteManager.onAudioLost(mAudioManager.getCommunicationDevice().getAddress());
             mAudioManager.clearCommunicationDevice();
         }
-        mLeAudioSetAsCommunicationDevice = false;
     }
 
     public void clearHearingAidCommunicationDevice() {
         if (!mHearingAidSetAsCommunicationDevice) {
             return;
         }
-
+        mHearingAidSetAsCommunicationDevice = false;
         if (mAudioManager == null) {
             Log.i(this, "clearHearingAidCommunicationDevice: mAudioManager is null");
-            mHearingAidSetAsCommunicationDevice = false;
+            return;
         }
         if (mAudioManager.getCommunicationDevice() != null
                 && mAudioManager.getCommunicationDevice().getType()
                 == AudioDeviceInfo.TYPE_HEARING_AID) {
             mAudioManager.clearCommunicationDevice();
         }
-        mHearingAidSetAsCommunicationDevice = false;
     }
 
     public boolean setLeAudioCommunicationDevice() {