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

Commit 9135d866 authored by Ajay Panicker's avatar Ajay Panicker Committed by Andre Eisenbach
Browse files

HFP/A2DP: Remove pending auto-connect messages when connected

Fixes a bug in which being paired with multiple headsets causes
previously connected headsets to disconnect. This fix removes
pending connect attemps once one device is successfully connected.

Bug: 23111466
Change-Id: Id471189d92643b9626e63197c00e76defd0a72bf
parent 72ecb4ca
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -479,6 +479,12 @@ final class A2dpStateMachine extends StateMachine {
    private class Connected extends State {
        @Override
        public void enter() {
            // Remove pending connection attempts that were deferred during the pending
            // state. This is to prevent auto connect attempts from disconnecting
            // devices that previously successfully connected.
            // TODO: This needs to check for multiple A2DP connections, once supported...
            removeDeferredMessages(CONNECT);

            log("Enter Connected: " + getCurrentMessage().what);
            // Upon connected, the audio starts out as stopped
            broadcastAudioState(mCurrentDevice, BluetoothA2dp.STATE_NOT_PLAYING,
+10 −4
Original line number Diff line number Diff line
@@ -741,6 +741,12 @@ final class HeadsetStateMachine extends StateMachine {
    private class Connected extends State {
        @Override
        public void enter() {
            // Remove pending connection attempts that were deferred during the pending
            // state. This is to prevent auto connect attempts from disconnecting
            // devices that previously successfully connected.
            // TODO: This needs to check for multiple HFP connections, once supported...
            removeDeferredMessages(CONNECT);

            log("Enter Connected: " + getCurrentMessage().what +
                           ", size: " + mConnectedDevicesList.size());
            // start phone state listener here so that the CIND response as part of SLC can be