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

Commit 43d1e9ec authored by Hall Liu's avatar Hall Liu
Browse files

Fix weird race condition in BT manager

When switching from one BT device to another, sometimes we'll get the
signal that the second device connected right after the first device
disconnected. The transition to the AudioOff state from the
disconnection will sometimes happen at the exact right time so as to
disconnect the second device as well.
This change removes the code that disconnects all remaining devices when
transitioning into AudioOff since it's not actually useful for anything
except creating bugs.

Change-Id: Ieb0a87cc4db990aaa7d9de65d643ade4d9835068
Fixes: 112285293
Test: unit tests
parent fea1c0db
Loading
Loading
Loading
Loading
+3 −2
Original line number Original line Diff line number Diff line
@@ -123,8 +123,9 @@ public class BluetoothRouteManager extends StateMachine {
            BluetoothDevice erroneouslyConnectedDevice = getBluetoothAudioConnectedDevice();
            BluetoothDevice erroneouslyConnectedDevice = getBluetoothAudioConnectedDevice();
            if (erroneouslyConnectedDevice != null) {
            if (erroneouslyConnectedDevice != null) {
                Log.w(LOG_TAG, "Entering AudioOff state but device %s appears to be connected. " +
                Log.w(LOG_TAG, "Entering AudioOff state but device %s appears to be connected. " +
                        "Disconnecting.", erroneouslyConnectedDevice);
                        "Switching to audio-on state for %s", erroneouslyConnectedDevice);
                disconnectAudio();
                // change this to just transition to the new audio on state
                transitionToActualState();
            }
            }
            cleanupStatesForDisconnectedDevices();
            cleanupStatesForDisconnectedDevices();
            if (mListener != null) {
            if (mListener != null) {