MHF: Disconnect audio for HS1 before disconnecting ACL.

When HS2 is connected while call is active on HS1,
disconnect audio first followed by disconnecting ACL
for HS1.
from QCOM
Change-Id: I53b6fedd47008cf0d6d65a72f744b2df4a198e34
diff --git a/android/app/src/com/android/bluetooth/hfp/HeadsetStateMachine.java b/android/app/src/com/android/bluetooth/hfp/HeadsetStateMachine.java
index 641c837..cc5cce8 100644
--- a/android/app/src/com/android/bluetooth/hfp/HeadsetStateMachine.java
+++ b/android/app/src/com/android/bluetooth/hfp/HeadsetStateMachine.java
@@ -1130,6 +1130,17 @@
                         break;
                     }
 
+                    if (max_hf_connections == 1) {
+                        deferMessage(obtainMessage(DISCONNECT, mCurrentDevice));
+                        deferMessage(obtainMessage(CONNECT, device));
+                        if (disconnectAudioNative(getByteAddress(mCurrentDevice))) {
+                            Log.d(TAG, "Disconnecting SCO audio for device = " + mCurrentDevice);
+                        } else {
+                            Log.e(TAG, "disconnectAudioNative failed");
+                        }
+                        break;
+                    }
+
                     if (mConnectedDevicesList.size() >= max_hf_connections) {
                         BluetoothDevice DisconnectConnectedDevice = null;
                         IState CurrentAudioState = getCurrentState();
@@ -1137,8 +1148,7 @@
                                            "one of them first");
                         DisconnectConnectedDevice = mConnectedDevicesList.get(0);
 
-                        if (mActiveScoDevice.equals(DisconnectConnectedDevice)
-                                                     && (max_hf_connections > 1)) {
+                        if (mActiveScoDevice.equals(DisconnectConnectedDevice)) {
                            DisconnectConnectedDevice = mConnectedDevicesList.get(1);
                         }
 
@@ -1157,12 +1167,8 @@
 
                         synchronized (HeadsetStateMachine.this) {
                             mTargetDevice = device;
-                            if (max_hf_connections == 1) {
-                                transitionTo(mPending);
-                            } else {
-                                mMultiDisconnectDevice = DisconnectConnectedDevice;
-                                transitionTo(mMultiHFPending);
-                            }
+                            mMultiDisconnectDevice = DisconnectConnectedDevice;
+                            transitionTo(mMultiHFPending);
                             DisconnectConnectedDevice = null;
                         }
                     } else if(mConnectedDevicesList.size() < max_hf_connections) {