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

Commit 7c2d523e authored by Leslie Watkins's avatar Leslie Watkins Committed by Automerger Merge Worker
Browse files

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

Merge "Add a null check for sBrowseTree when AvrcpControllerStateMachine is disconnecting." am: 5584c799 am: 532f0618

Original change: https://android-review.googlesource.com/c/platform/packages/apps/Bluetooth/+/1702387

Change-Id: Id3d0d55610fe2f10f9b18b9b8deeb958f91c4c9b
parents fa74151b 532f0618
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,