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

Commit eb19b27e authored by Toni Heidenreich's avatar Toni Heidenreich Committed by Android Build Coastguard Worker
Browse files

Add flag to exclude capability propagation when connecting MediaBrowser

Also assume this flag is true when EXTRA_RECENT is used as querying
the recent playback should always only be a one-off short lived request

Manual cherry-pick of ag/33253388

Bug: 393582077
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:c61afbfe43c3da7b72408a43b44b03bb13c3243e)
Cherrypick-From: https://googleplex-android-review.googlesource.com/q/commit:c33d4bfc5b3093e469d52f45d116a78021778f7a
Merged-In: Idc9b428f2ff53cb490ee596da35d24e1e7fca681
Change-Id: Idc9b428f2ff53cb490ee596da35d24e1e7fca681
parent 1cfd8237
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ import android.os.ResultReceiver;
import android.service.media.IMediaBrowserService;
import android.service.media.IMediaBrowserServiceCallbacks;
import android.service.media.MediaBrowserService;
import android.service.media.MediaBrowserService.BrowserRoot;
import android.text.TextUtils;
import android.util.ArrayMap;
import android.util.Log;
@@ -183,8 +184,13 @@ public final class MediaBrowser {

                boolean bound = false;
                try {
                    bound = mContext.bindService(intent, mServiceConnection,
                            Context.BIND_AUTO_CREATE | Context.BIND_INCLUDE_CAPABILITIES);
                    int bindServiceFlags = Context.BIND_AUTO_CREATE;
                    if (mRootHints == null
                        || (!mRootHints.containsKey(BrowserRoot.EXTRA_EXCLUDE_CAPABILITIES)
                                && !mRootHints.containsKey(BrowserRoot.EXTRA_RECENT))) {
                        bindServiceFlags |= Context.BIND_INCLUDE_CAPABILITIES;
                    }
                    bound = mContext.bindService(intent, mServiceConnection, bindServiceFlags);
                } catch (Exception ex) {
                    Log.e(TAG, "Failed binding to service " + mServiceComponent);
                }
+12 −0
Original line number Diff line number Diff line
@@ -608,6 +608,18 @@ public abstract class MediaBrowserService extends Service {
         */
        public static final String EXTRA_SUGGESTED = "android.service.media.extra.SUGGESTED";

        /**
         * A key for the root hint when connecting a browser to indicate that the bind connection
         * should not include capabilities.
         *
         * <p>When using {@link #EXTRA_RECENT}, this flag is assumed to be set as well.
         *
         * @see android.content.Context#BIND_INCLUDE_CAPABILITIES
         * @hide
         */
        public static final String EXTRA_EXCLUDE_CAPABILITIES =
                "android.service.media.extra.EXCLUDE_CAPABILITIES";

        private final String mRootId;
        private final Bundle mExtras;