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

Commit fb862d0d authored by Sal Savage's avatar Sal Savage
Browse files

Fetch Available Players on our own when they change

Prior to this change available players were fetched according to when
the MediaBrowser clients wanted the data. This is not sufficient for us
to keep up to data info on available players on the remote device. We
need to fetch them as soon as they're known to be invalid.

Tag: #stability
Bug: 187099538
Test: atest BluetoothInstrumentationTests
Change-Id: I9fa90826e4d9dc02fbc90be4e5a39b81a3562029
parent fe96c202
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -253,6 +253,7 @@ class AvrcpControllerStateMachine extends StateMachine {

    synchronized void onBrowsingConnected() {
        mBrowsingConnected = true;
        requestContents(mBrowseTree.mRootNode);
    }

    synchronized void onBrowsingDisconnected() {
@@ -262,8 +263,10 @@ class AvrcpControllerStateMachine extends StateMachine {
        String previousTrackUuid = previousTrack != null ? previousTrack.getCoverArtUuid() : null;
        mAddressedPlayer.updateCurrentTrack(null);
        mBrowseTree.mNowPlayingNode.setCached(false);
        mBrowseTree.mRootNode.setCached(false);
        if (isActive()) {
            BluetoothMediaBrowserService.notifyChanged(mBrowseTree.mNowPlayingNode);
            BluetoothMediaBrowserService.notifyChanged(mBrowseTree.mRootNode);
        }
        removeUnusedArtwork(previousTrackUuid);
        removeUnusedArtworkFromBrowseTree();
@@ -688,6 +691,7 @@ class AvrcpControllerStateMachine extends StateMachine {
            mBrowseTree.mRootNode.setExpectedChildren(255);
            BluetoothMediaBrowserService.notifyChanged(mBrowseTree.mRootNode);
            removeUnusedArtworkFromBrowseTree();
            requestContents(mBrowseTree.mRootNode);
        }
    }

+21 −0
Original line number Diff line number Diff line
@@ -698,6 +698,27 @@ public class AvrcpControllerStateMachineTest {
                eq(0), eq(4));
    }

    /**
     * Test our reaction to an available players changed event
     *
     * Verify that we issue a command to fetch the new available players
     */
    @Test
    public void testAvailablePlayersChanged() {
        setUpConnectedState(true, true);
        final String rootName = "__ROOT__";

        // Send an available players have changed event
        mAvrcpStateMachine.sendMessage(
                AvrcpControllerStateMachine.MESSAGE_PROCESS_AVAILABLE_PLAYER_CHANGED);

        // Verify we've uncached our browse root and made the call to fetch new players
        Assert.assertFalse(mAvrcpStateMachine.findNode(rootName).isCached());
        verify(mAvrcpControllerService,
                timeout(ASYNC_CALL_TIMEOUT_MILLIS).times(1)).getPlayerListNative(eq(mTestAddress),
                eq(0), eq(19));
    }

    /**
     * Test addressed media player changing to a player we know about
     * Verify when the addressed media player changes browsing data updates