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

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

Merge "MediaSession2: Apply apilint"

parents 1d92689e e62f9b24
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -16,8 +16,10 @@

package android.media;

import android.annotation.CallbackExecutor;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.content.Context;
import android.media.update.ApiLoader;
import android.media.update.MediaBrowser2Provider;
@@ -99,17 +101,17 @@ public class MediaBrowser2 extends MediaController2 {
                @Nullable Bundle options, @Nullable List<MediaItem2> result) { }
    }

    public MediaBrowser2(Context context, SessionToken2 token, BrowserCallback callback,
            Executor executor) {
        super(context, token, callback, executor);
    public MediaBrowser2(@NonNull Context context, @NonNull SessionToken2 token,
            @NonNull @CallbackExecutor Executor executor, @NonNull BrowserCallback callback) {
        super(context, token, executor, callback);
        mProvider = (MediaBrowser2Provider) getProvider();
    }

    @Override
    MediaBrowser2Provider createProvider(Context context, SessionToken2 token,
            ControllerCallback callback, Executor executor) {
            Executor executor, ControllerCallback callback) {
        return ApiLoader.getProvider(context)
                .createMediaBrowser2(this, context, token, (BrowserCallback) callback, executor);
                .createMediaBrowser2(context, this, token, executor, (BrowserCallback) callback);
    }

    public void getBrowserRoot(Bundle rootHints) {
+13 −14
Original line number Diff line number Diff line
@@ -16,15 +16,17 @@

package android.media;

import android.annotation.CallbackExecutor;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.app.PendingIntent;
import android.content.Context;
import android.media.MediaSession2.Command;
import android.media.MediaSession2.CommandButton;
import android.media.MediaSession2.CommandGroup;
import android.media.MediaSession2.ControllerInfo;
import android.media.MediaSession2.PlaylistParam;
import android.media.MediaSession2.PlaylistParams;
import android.media.session.MediaSessionManager;
import android.media.update.ApiLoader;
import android.media.update.MediaController2Provider;
@@ -63,8 +65,6 @@ import java.util.concurrent.Executor;
 * @see MediaSessionService2
 * @hide
 */
// TODO(jaewan): Unhide
// TODO(jaewan): Revisit comments. Currently MediaBrowser case is missing.
public class MediaController2 implements AutoCloseable {
    /**
     * Interface for listening to change in activeness of the {@link MediaSession2}.  It's
@@ -130,7 +130,7 @@ public class MediaController2 implements AutoCloseable {
         * @param param
         */
        public void onPlaylistChanged(
                @NonNull List<MediaItem2> list, @NonNull PlaylistParam param) { }
                @NonNull List<MediaItem2> list, @NonNull PlaylistParams param) { }

        /**
         * Called when the playback state is changed.
@@ -239,12 +239,12 @@ public class MediaController2 implements AutoCloseable {
     *
     * @param context Context
     * @param token token to connect to
     * @param callback controller callback to receive changes in
     * @param executor executor to run callbacks on.
     * @param callback controller callback to receive changes in
     */
    // TODO(jaewan): Put @CallbackExecutor to the constructor.
    public MediaController2(@NonNull Context context, @NonNull SessionToken2 token,
            @NonNull ControllerCallback callback, @NonNull Executor executor) {
            @NonNull @CallbackExecutor Executor executor, @NonNull ControllerCallback callback) {
        super();

        // This also connects to the token.
@@ -252,14 +252,14 @@ public class MediaController2 implements AutoCloseable {
        // session whose session binder is only valid while it's active.
        // prevent a controller from reusable after the
        // session is released and recreated.
        mProvider = createProvider(context, token, callback, executor);
        mProvider = createProvider(context, token, executor, callback);
    }

    MediaController2Provider createProvider(@NonNull Context context,
            @NonNull SessionToken2 token, @NonNull ControllerCallback callback,
            @NonNull Executor executor) {
            @NonNull SessionToken2 token, @NonNull Executor executor,
            @NonNull ControllerCallback callback) {
        return ApiLoader.getProvider(context)
                .createMediaController2(this, context, token, callback, executor);
                .createMediaController2(context, this, token, executor, callback);
    }

    /**
@@ -271,9 +271,7 @@ public class MediaController2 implements AutoCloseable {
        mProvider.close_impl();
    }

    /**
     * @hide
     */
    @SystemApi
    public MediaController2Provider getProvider() {
        return mProvider;
    }
@@ -578,7 +576,8 @@ public class MediaController2 implements AutoCloseable {
        return mProvider.getPlaylist_impl();
    }

    public @Nullable PlaylistParam getPlaylistParam() {
    public @Nullable
    PlaylistParams getPlaylistParam() {
        return mProvider.getPlaylistParam_impl();
    }

+2 −6
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package android.media;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.os.Bundle;
import android.text.TextUtils;

@@ -32,15 +33,10 @@ import java.lang.annotation.RetentionPolicy;
 * When it's sent to a controller or browser, it's anonymized and data descriptor wouldn't be sent.
 * <p>
 * This object isn't a thread safe.
 *
 * @hide
 */
// TODO(jaewan): Unhide and extends from DataSourceDesc.
//               Note) Feels like an anti-pattern. We should anonymize MediaItem2 to remove *all*
//                     information in the DataSourceDesc. Why it should extends from this?
// TODO(jaewan): Move this to updatable
// Previously MediaBrowser.MediaItem
public class MediaItem2 {
    // TODO(jaewan): Keep DataSourceDesc.
    private final int mFlags;
    private MediaMetadata2 mMetadata;

+17 −19
Original line number Diff line number Diff line
@@ -28,7 +28,6 @@ import android.media.update.MediaLibraryService2Provider.MediaLibrarySessionProv
import android.media.update.MediaSession2Provider;
import android.media.update.MediaSessionService2Provider;
import android.os.Bundle;
import android.service.media.MediaBrowserService.BrowserRoot;

import java.util.List;
import java.util.concurrent.Executor;
@@ -54,7 +53,6 @@ import java.util.concurrent.Executor;
 * declare metadata in the manifest as follows.
 * @hide
 */
// TODO(jaewan): Unhide
public abstract class MediaLibraryService2 extends MediaSessionService2 {
    /**
     * This is the interface name that a service implementing a session service should say that it
@@ -69,21 +67,21 @@ public abstract class MediaLibraryService2 extends MediaSessionService2 {
        private final MediaLibrarySessionProvider mProvider;

        MediaLibrarySession(Context context, MediaPlayerBase player, String id,
                Executor callbackExecutor, SessionCallback callback, VolumeProvider volumeProvider,
                int ratingType, PendingIntent sessionActivity) {
            super(context, player, id, callbackExecutor, callback, volumeProvider, ratingType,
                    sessionActivity);
                VolumeProvider volumeProvider, int ratingType, PendingIntent sessionActivity,
                Executor callbackExecutor, SessionCallback callback) {
            super(context, player, id, volumeProvider, ratingType, sessionActivity,
                    callbackExecutor, callback);
            mProvider = (MediaLibrarySessionProvider) getProvider();
        }

        @Override
        MediaSession2Provider createProvider(Context context, MediaPlayerBase player, String id,
                Executor callbackExecutor, SessionCallback callback, VolumeProvider volumeProvider,
                int ratingType, PendingIntent sessionActivity) {
                VolumeProvider volumeProvider, int ratingType, PendingIntent sessionActivity,
                Executor callbackExecutor, SessionCallback callback) {
            return ApiLoader.getProvider(context)
                    .createMediaLibraryService2MediaLibrarySession(this, context, player, id,
                            callbackExecutor, (MediaLibrarySessionCallback) callback,
                            volumeProvider, ratingType, sessionActivity);
                    .createMediaLibraryService2MediaLibrarySession(context, this, player, id,
                            volumeProvider, ratingType, sessionActivity,
                            callbackExecutor, (MediaLibrarySessionCallback) callback);
        }

        /**
@@ -226,9 +224,9 @@ public abstract class MediaLibraryService2 extends MediaSessionService2 {
        }

        @Override
        public MediaLibrarySession build() throws IllegalStateException {
            return new MediaLibrarySession(mContext, mPlayer, mId, mCallbackExecutor, mCallback,
                    mVolumeProvider, mRatingType, mSessionActivity);
        public MediaLibrarySession build() {
            return new MediaLibrarySession(mContext, mPlayer, mId, mVolumeProvider, mRatingType,
                    mSessionActivity, mCallbackExecutor, mCallback);
        }
    }

@@ -277,7 +275,7 @@ public abstract class MediaLibraryService2 extends MediaSessionService2 {
         * @see #EXTRA_OFFLINE
         * @see #EXTRA_SUGGESTED
         */
        public static final String EXTRA_RECENT = "android.service.media.extra.RECENT";
        public static final String EXTRA_RECENT = "android.media.extra.RECENT";

        /**
         * The lookup key for a boolean that indicates whether the browser service should return a
@@ -295,7 +293,7 @@ public abstract class MediaLibraryService2 extends MediaSessionService2 {
         * @see #EXTRA_RECENT
         * @see #EXTRA_SUGGESTED
         */
        public static final String EXTRA_OFFLINE = "android.service.media.extra.OFFLINE";
        public static final String EXTRA_OFFLINE = "android.media.extra.OFFLINE";

        /**
         * The lookup key for a boolean that indicates whether the browser service should return a
@@ -303,8 +301,8 @@ public abstract class MediaLibraryService2 extends MediaSessionService2 {
         *
         * <p>When creating a media browser for a given media browser service, this key can be
         * supplied as a root hint for retrieving the media items suggested by the media browser
         * service. The list of media items passed in {@link android.media.browse.MediaBrowser.SubscriptionCallback#onChildrenLoaded(String, List)}
         * is considered ordered by relevance, first being the top suggestion.
         * service. The list of media items is considered ordered by relevance, first being the top
         * suggestion.
         * If the media browser service can provide such media items, the implementation must return
         * the key in the root hint when
         * {@link MediaLibrarySessionCallback#onGetRoot(ControllerInfo, Bundle)} is called back.
@@ -314,7 +312,7 @@ public abstract class MediaLibraryService2 extends MediaSessionService2 {
         * @see #EXTRA_RECENT
         * @see #EXTRA_OFFLINE
         */
        public static final String EXTRA_SUGGESTED = "android.service.media.extra.SUGGESTED";
        public static final String EXTRA_SUGGESTED = "android.media.extra.SUGGESTED";

        final private String mRootId;
        final private Bundle mExtras;
+2 −1
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import java.util.Set;

/**
 * Contains metadata about an item, such as the title, artist, etc.
 *
 * @hide
 */
// TODO(jaewan): Move this to updatable
@@ -218,7 +219,7 @@ public final class MediaMetadata2 {
    /**
     * A Uri formatted String representing the content. This value is specific to the
     * service providing the content. It may be used with
     * {@link MediaController2#playFromUri(Uri, Bundle)}
     * {@link MediaController2#playFromUri(String, Bundle)}
     * to initiate playback when provided by a {@link MediaBrowser2} connected to
     * the same app.
     */
Loading