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

Commit 7ca3fd92 authored by Satish Kodishala's avatar Satish Kodishala Committed by Linux Build Service Account
Browse files

BT: Don't switch devices when one of the connected BT headsets disconnects

Two BT headsets, hs1 and hs2 are connected to the device and
a voice call is made. Call audio is present on hs2. If hs1
is disconnected, we should not switch the audio to handset
or speaker.

CRs-Fixed: 968437
Change-Id: I4108c7ab810f9b56a95f820c99b2b981a9a17157
parent 51f0a553
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -3097,6 +3097,18 @@ public class AudioService extends IAudioService.Stub {
        boolean success =
            handleDeviceConnection(connected, outDevice, address, btDeviceName) &&
            handleDeviceConnection(connected, inDevice, address, btDeviceName);

        /* When one BT headset is disconnected while there is SCO with another BT
         * headset, ignore the BT headset disconncting/disconnected intents.
         */
        if ((state == BluetoothProfile.STATE_DISCONNECTED ||
            state == BluetoothProfile.STATE_DISCONNECTING) &&
            mBluetoothHeadset != null &&
            mBluetoothHeadset.getAudioState(btDevice) == BluetoothHeadset.STATE_AUDIO_CONNECTED) {
            Log.w(TAG, "SCO is there with another device, returning");
            return;
        }

        if (success) {
            synchronized (mScoClients) {
                if (connected) {
@@ -5250,7 +5262,7 @@ public class AudioService extends IAudioService.Stub {
                state = intent.getIntExtra(BluetoothProfile.EXTRA_STATE,
                                               BluetoothProfile.STATE_DISCONNECTED);
                BluetoothDevice btDevice = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);

                Log.d(TAG, "Bt device " + btDevice.getAddress() + "disconnection intent received");
                setBtScoDeviceConnectionState(btDevice, state);
            } else if (action.equals(BluetoothHeadset.ACTION_AUDIO_STATE_CHANGED)) {
                boolean broadcast = false;