Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 77d89942 authored by Zhihai Xu's avatar Zhihai Xu
Browse files

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
parent 6f3b2c5b
Loading
Loading
Loading
Loading
+14 −8
Original line number Diff line number Diff line
@@ -1130,6 +1130,17 @@ final class HeadsetStateMachine extends StateMachine {
                        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 @@ final class HeadsetStateMachine extends StateMachine {
                                           "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 @@ final class HeadsetStateMachine extends StateMachine {

                        synchronized (HeadsetStateMachine.this) {
                            mTargetDevice = device;
                            if (max_hf_connections == 1) {
                                transitionTo(mPending);
                            } else {
                            mMultiDisconnectDevice = DisconnectConnectedDevice;
                            transitionTo(mMultiHFPending);
                            }
                            DisconnectConnectedDevice = null;
                        }
                    } else if(mConnectedDevicesList.size() < max_hf_connections) {