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

Commit 7554d099 authored by RoboErik's avatar RoboErik
Browse files

Reload MediaBrowser children on each call to subscribe

Only one callback can be set on a given media id on MediaBrowser. When you
try to subscribe with a new callback it replaces the old callback, but it
wasn't resending the child data for the id. This causes calling subscribe
again also cause the data to be reloaded and sent to the app again.

bug:18683452
Change-Id: I2d30dbbbfe07cb9a720fb6d65664c1c4c58cb637
parent 2c4b1610
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -293,9 +293,11 @@ public final class MediaBrowser {
     * The list of subscriptions is maintained even when not connected and is
     * restored after reconnection. It is ok to subscribe while not connected
     * but the results will not be returned until the connection completes.
     * </p><p>
     * </p>
     * <p>
     * If the id is already subscribed with a different callback then the new
     * callback will replace the previous one.
     * callback will replace the previous one and the child data will be
     * reloaded.
     * </p>
     *
     * @param parentId The id of the parent media item whose list of children
@@ -322,7 +324,7 @@ public final class MediaBrowser {

        // If we are connected, tell the service that we are watching.  If we aren't
        // connected, the service will be told when we connect.
        if (mState == CONNECT_STATE_CONNECTED && newSubscription) {
        if (mState == CONNECT_STATE_CONNECTED) {
            try {
                mServiceBinder.addSubscription(parentId, mServiceCallbacks);
            } catch (RemoteException ex) {
+3 −5
Original line number Diff line number Diff line
@@ -405,13 +405,11 @@ public abstract class MediaBrowserService extends Service {
     */
    private void addSubscription(String id, ConnectionRecord connection) {
        // Save the subscription
        final boolean added = connection.subscriptions.add(id);
        connection.subscriptions.add(id);

        // If this is a new subscription, send the results
        if (added) {
        // send the results
        performLoadChildren(id, connection);
    }
    }

    /**
     * Call onLoadChildren and then send the results back to the connection.