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

Commit ce2deed9 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add flag to exclude capability propagation when connecting MediaBrowser" into main

parents f04795c6 f77a46ef
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -42,6 +42,8 @@ import android.text.TextUtils;
import android.util.ArrayMap;
import android.util.Log;

import com.android.media.mediasession.flags.Flags;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.ref.WeakReference;
@@ -463,7 +465,17 @@ public final class MediaBrowser {

        boolean bound = false;
        try {
            int bindServiceFlags = Context.BIND_AUTO_CREATE | Context.BIND_INCLUDE_CAPABILITIES;
            int bindServiceFlags;
            if (Flags.avoidMediaBrowserIncludeCapabilitiesIfNotNeeded()) {
                bindServiceFlags = Context.BIND_AUTO_CREATE;
                if (mRootHints == null
                        || (!mRootHints.containsKey(BrowserRoot.EXTRA_EXCLUDE_CAPABILITIES)
                                && !mRootHints.containsKey(BrowserRoot.EXTRA_RECENT))) {
                    bindServiceFlags |= Context.BIND_INCLUDE_CAPABILITIES;
                }
            } else {
                bindServiceFlags = Context.BIND_AUTO_CREATE | 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
@@ -607,6 +607,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;