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

Commit b8a74e5b authored by Sungsoo Lim's avatar Sungsoo Lim Committed by Android (Google) Code Review
Browse files

Merge "MediaBrowser: Make support lib work properly"

parents 808a91a0 d67933e2
Loading
Loading
Loading
Loading
+16 −10
Original line number Diff line number Diff line
@@ -473,8 +473,9 @@ public final class MediaBrowser {
        // the service will be told when we connect.
        if (mState == CONNECT_STATE_CONNECTED) {
            try {
                // NOTE: In order not to break the behavior of the support library, call
                // addSubscription instead of addSubscriptionWithOptions when the options are null.
                // NOTE: Do not call addSubscriptionWithOptions when options are null. Otherwise,
                // it will break the action of support library which expects addSubscription will
                // be called when options are null.
                if (options == null) {
                    mServiceBinder.addSubscription(parentId, mServiceCallbacks);
                } else {
@@ -500,9 +501,9 @@ public final class MediaBrowser {
        // Tell the service if necessary.
        if (sub != null && sub.remove(options) && mState == CONNECT_STATE_CONNECTED) {
            try {
                // NOTE: In order not to break the behavior of the support library, call
                // removeSubscription instead of removeSubscriptionWithOptions when the options
                // are null.
                // NOTE: Do not call removeSubscriptionWithOptions when options are null. Otherwise,
                // it will break the action of support library which expects removeSubscription will
                // be called when options are null.
                if (options == null) {
                    mServiceBinder.removeSubscription(parentId, mServiceCallbacks);
                } else {
@@ -572,9 +573,9 @@ public final class MediaBrowser {
                    Subscription sub = subscriptionEntry.getValue();
                    for (Bundle options : sub.getOptionsList()) {
                        try {
                            // NOTE: In order not to break the behavior of the support library,
                            // call addSubscription instead of addSubscriptionWithOptions when
                            // the options are null.
                            // NOTE: Do not call addSubscriptionWithOptions when options are null.
                            // Otherwise, it will break the action of support library which expects
                            // addSubscription will be called when options are null.
                            if (options == null) {
                                mServiceBinder.addSubscription(id, mServiceCallbacks);
                            } else {
@@ -1034,7 +1035,7 @@ public final class MediaBrowser {
         * are the initial data as requested.
         */
        @Override
        public void onConnect(final String root, final MediaSession.Token session,
        public void onConnect(String root, MediaSession.Token session,
                final Bundle extras) {
            MediaBrowser mediaBrowser = mMediaBrowser.get();
            if (mediaBrowser != null) {
@@ -1054,7 +1055,12 @@ public final class MediaBrowser {
        }

        @Override
        public void onLoadChildren(final String parentId, final ParceledListSlice list,
        public void onLoadChildren(String parentId, ParceledListSlice list) {
            onLoadChildrenWithOptions(parentId, list, null);
        }

        @Override
        public void onLoadChildrenWithOptions(String parentId, ParceledListSlice list,
                final Bundle options) {
            MediaBrowser mediaBrowser = mMediaBrowser.get();
            if (mediaBrowser != null) {
+1 −1
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@ import android.os.ResultReceiver;
oneway interface IMediaBrowserService {

    // Warning: DO NOT CHANGE the methods signature and order of methods.
    // The change of the order or the method signatures could break the support library.
    // A change of the order or the method signatures could break the support library.

    void connect(String pkg, in Bundle rootHints, IMediaBrowserServiceCallbacks callbacks);
    void disconnect(IMediaBrowserServiceCallbacks callbacks);
+6 −1
Original line number Diff line number Diff line
@@ -13,6 +13,10 @@ import android.os.Bundle;
 * @hide
 */
oneway interface IMediaBrowserServiceCallbacks {

    // Warning: DO NOT CHANGE the methods signature and order of methods.
    // A change of the order or the method signatures could break the support library.

    /**
     * Invoked when the connected has been established.
     * @param root The root media id for browsing.
@@ -22,5 +26,6 @@ oneway interface IMediaBrowserServiceCallbacks {
     */
    void onConnect(String root, in MediaSession.Token session, in Bundle extras);
    void onConnectFailed();
    void onLoadChildren(String mediaId, in ParceledListSlice list, in Bundle options);
    void onLoadChildren(String mediaId, in ParceledListSlice list);
    void onLoadChildrenWithOptions(String mediaId, in ParceledListSlice list, in Bundle options);
}
+8 −1
Original line number Diff line number Diff line
@@ -589,7 +589,14 @@ public abstract class MediaBrowserService extends Service {
                final ParceledListSlice<MediaBrowser.MediaItem> pls =
                        filteredList == null ? null : new ParceledListSlice<>(filteredList);
                try {
                    connection.callbacks.onLoadChildren(parentId, pls, options);
                    // NOTE: Do not call onLoadChildrenWithOptions when options are null. Otherwise,
                    // it will break the action of support library which expects onLoadChildren will
                    // be called when options are null.
                    if (options == null) {
                        connection.callbacks.onLoadChildren(parentId, pls);
                    } else {
                        connection.callbacks.onLoadChildrenWithOptions(parentId, pls, options);
                    }
                } catch (RemoteException ex) {
                    // The other side is in the process of crashing.
                    Log.w(TAG, "Calling onLoadChildren() failed for id=" + parentId