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

Commit 5584c799 authored by Leslie Watkins's avatar Leslie Watkins Committed by Gerrit Code Review
Browse files

Merge "Add a null check for sBrowseTree when AvrcpControllerStateMachine is disconnecting."

parents d15ff534 a7c01d58
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -947,8 +947,10 @@ class AvrcpControllerStateMachine extends StateMachine {
        public void enter() {
            disconnectCoverArt();
            onBrowsingDisconnected();
            if (mService.sBrowseTree != null) {
                mService.sBrowseTree.mRootNode.removeChild(mBrowseTree.mRootNode);
                BluetoothMediaBrowserService.notifyChanged(mService.sBrowseTree.mRootNode);
            }
            broadcastConnectionStateChanged(BluetoothProfile.STATE_DISCONNECTING);
            transitionTo(mDisconnected);
        }
+18 −1
Original line number Diff line number Diff line
@@ -318,12 +318,29 @@ public class AvrcpControllerStateMachineTest {

    /**
     * Test to confirm that the state machine is capable of cycling through the 4
     * connection states, and that upon completion, it cleans up aftwards.
     * connection states, and that upon completion, it cleans up afterwards.
     */
    @Test
    public void testDisconnect() {
        int numBroadcastsSent = setUpConnectedState(true, true);
        testDisconnectInternal(numBroadcastsSent);
    }

    /**
     * Test to confirm that the state machine is capable of cycling through the 4
     * connection states with no crashes, even if the {@link AvrcpControllerService} is stopped and
     * the {@code sBrowseTree} is null. This could happen if BT is disabled as the profile is being
     * disconnected.
     */
    @Test
    public void testDisconnectWithNullBrowseTree() {
        int numBroadcastsSent = setUpConnectedState(true, true);
        mAvrcpControllerService.stop();

        testDisconnectInternal(numBroadcastsSent);
    }

    private void testDisconnectInternal(int numBroadcastsSent) {
        mAvrcpStateMachine.disconnect();
        numBroadcastsSent += 2;
        verify(mAvrcpControllerService,