From 7554d099e7f3a7cec166a999615245e7457bd620 Mon Sep 17 00:00:00 2001 From: RoboErik Date: Tue, 6 Jan 2015 15:34:24 -0800 Subject: [PATCH] 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 --- media/java/android/media/browse/MediaBrowser.java | 12 +++++++----- .../android/service/media/MediaBrowserService.java | 8 +++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/media/java/android/media/browse/MediaBrowser.java b/media/java/android/media/browse/MediaBrowser.java index d260b05fb9052..e82567c7b27dc 100644 --- a/media/java/android/media/browse/MediaBrowser.java +++ b/media/java/android/media/browse/MediaBrowser.java @@ -291,15 +291,17 @@ public final class MediaBrowser { * the specified id and subscribes to receive updates when they change. *

* The list of subscriptions is maintained even when not connected and is - * restored after reconnection. It is ok to subscribe while not connected + * restored after reconnection. It is ok to subscribe while not connected * but the results will not be returned until the connection completes. - *

+ *

+ *

* 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. *

* * @param parentId The id of the parent media item whose list of children - * will be subscribed. + * will be subscribed. * @param callback The callback to receive the list of children. */ public void subscribe(@NonNull String parentId, @NonNull SubscriptionCallback callback) { @@ -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) { diff --git a/media/java/android/service/media/MediaBrowserService.java b/media/java/android/service/media/MediaBrowserService.java index 26aedbd26a999..47cb94b8af4cc 100644 --- a/media/java/android/service/media/MediaBrowserService.java +++ b/media/java/android/service/media/MediaBrowserService.java @@ -405,12 +405,10 @@ 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) { - performLoadChildren(id, connection); - } + // send the results + performLoadChildren(id, connection); } /**