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

Commit ef3ea9d1 authored by Sal Savage's avatar Sal Savage Committed by Automerger Merge Worker
Browse files

Merge "Defer disconnect commands until post connecting state" into main am: 9adb37e9

parents 53cc22f0 9adb37e9
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -218,6 +218,10 @@ public class A2dpSinkStateMachine extends StateMachine {
                case CONNECT_TIMEOUT:
                    transitionTo(mDisconnected);
                    return true;
                case DISCONNECT:
                    Log.d(TAG, "Received disconnect message while connecting. deferred");
                    deferMessage(message);
                    return true;
            }
            return false;
        }
+8 −1
Original line number Diff line number Diff line
@@ -269,12 +269,19 @@ public class A2dpSinkStateMachineTest {
    }

    @Test
    public void testDisconnectInConnecting() {
    public void testDisconnectInConnecting_disconnectDeferredAndProcessed() {
        testConnectInDisconnected();
        assertThat(mStateMachine.getState()).isEqualTo(BluetoothProfile.STATE_CONNECTING);
        mStateMachine.disconnect();
        TestUtils.waitForLooperToFinishScheduledTask(mStateMachine.getHandler().getLooper());
        assertThat(mStateMachine.getState()).isEqualTo(BluetoothProfile.STATE_CONNECTING);

        // send connected, disconnect should get processed
        sendConnectionEvent(BluetoothProfile.STATE_CONNECTED);
        TestUtils.waitForLooperToFinishScheduledTask(mStateMachine.getHandler().getLooper());
        verify(mNativeInterface, times(1)).disconnectA2dpSink(mDevice);
        verify(mService, timeout(TIMEOUT_MS).times(1)).removeStateMachine(mStateMachine);
        assertThat(mStateMachine.getState()).isEqualTo(BluetoothProfile.STATE_DISCONNECTED);
    }

    /**********************************************************************************************