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

Commit ed004c47 authored by Ravindra's avatar Ravindra Committed by Gerrit - the friendly Code Review server
Browse files

Reset the connection pending flag when SCO is disconnected

When bluetooth audio is disconnected mBluetoothConnectionPending
needs to be reset in order to get correct bluetooth state.

Change-Id: I2aab54147a9f9f0f35257e6366f400bd65d9be52
CRs-Fixed: 753883
parent d5d35ad5
Loading
Loading
Loading
Loading
+12 −10
Original line number Diff line number Diff line
@@ -55,21 +55,23 @@ public class BluetoothManager {
        @Override
        public void onReceive(Context context, Intent intent) {
            String action = intent.getAction();

            int bluetoothState = 0;
            if (action.equals(BluetoothHeadset.ACTION_CONNECTION_STATE_CHANGED)) {
                int bluetoothHeadsetState = intent.getIntExtra(BluetoothHeadset.EXTRA_STATE,
                bluetoothState = intent.getIntExtra(BluetoothHeadset.EXTRA_STATE,
                                         BluetoothHeadset.STATE_DISCONNECTED);
                Log.d(this, "mReceiver: HEADSET_STATE_CHANGED_ACTION");
                Log.d(this, "==> new state: %s ", bluetoothHeadsetState);
                updateBluetoothState();
                Log.d(this, "==> new state: %s ", bluetoothState);
            } else if (action.equals(BluetoothHeadset.ACTION_AUDIO_STATE_CHANGED)) {
                int bluetoothHeadsetAudioState =
                        intent.getIntExtra(BluetoothHeadset.EXTRA_STATE,
                bluetoothState = intent.getIntExtra(BluetoothHeadset.EXTRA_STATE,
                                       BluetoothHeadset.STATE_AUDIO_DISCONNECTED);
                Log.d(this, "mReceiver: HEADSET_AUDIO_STATE_CHANGED_ACTION");
                Log.d(this, "==> new state: %s", bluetoothHeadsetAudioState);
                updateBluetoothState();
                Log.d(this, "==> new state: %s", bluetoothState);
            }
            if (bluetoothState == BluetoothHeadset.STATE_DISCONNECTED ||
                    bluetoothState == BluetoothHeadset.STATE_AUDIO_DISCONNECTED) {
                mBluetoothConnectionPending = false;
            }
            updateBluetoothState();
        }
    };