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

Commit aecd3875 authored by Jaewan Kim's avatar Jaewan Kim Committed by Android (Google) Code Review
Browse files

Merge "MediaSession2: Last changes before API unhide"

parents 6af87a95 04de5de9
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

package android.media;

import android.media.session.PlaybackState;
import android.media.IMediaSession2Callback;
import android.os.Bundle;

@@ -44,7 +43,7 @@ interface IMediaSession2 {
    //////////////////////////////////////////////////////////////////////////////////////////////
    oneway void sendCommand(IMediaSession2Callback caller, in Bundle command, in Bundle args);

    PlaybackState getPlaybackState();
    Bundle getPlaybackState();

    //////////////////////////////////////////////////////////////////////////////////////////////
    // Get library service specific
+1 −1
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@ import android.media.IMediaSession2;
 * @hide
 */
oneway interface IMediaSession2Callback {
    void onPlaybackStateChanged(in PlaybackState state);
    void onPlaybackStateChanged(in Bundle state);

    /**
     * Called only when the controller is created with service's token.
+2 −2
Original line number Diff line number Diff line
@@ -99,14 +99,14 @@ public class MediaBrowser2 extends MediaController2 {
                @Nullable Bundle options, @Nullable List<MediaItem2> result) { }
    }

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

    @Override
    MediaBrowser2Provider createProvider(Context context, SessionToken token,
    MediaBrowser2Provider createProvider(Context context, SessionToken2 token,
            ControllerCallback callback, Executor executor) {
        return ApiLoader.getProvider(context)
                .createMediaBrowser2(this, context, token, (BrowserCallback) callback, executor);
+6 −5
Original line number Diff line number Diff line
@@ -54,7 +54,7 @@ import java.util.concurrent.Executor;
 * <p>
 * A controller can be created through token from {@link MediaSessionManager} if you hold the
 * signature|privileged permission "android.permission.MEDIA_CONTENT_CONTROL" permission or are
 * an enabled notification listener or by getting a {@link SessionToken} directly the
 * an enabled notification listener or by getting a {@link SessionToken2} directly the
 * the session owner.
 * <p>
 * MediaController2 objects are thread-safe.
@@ -234,7 +234,7 @@ public class MediaController2 implements AutoCloseable {
    private final MediaController2Provider mProvider;

    /**
     * Create a {@link MediaController2} from the {@link SessionToken}. This connects to the session
     * Create a {@link MediaController2} from the {@link SessionToken2}. This connects to the session
     * and may wake up the service if it's not available.
     *
     * @param context Context
@@ -243,7 +243,7 @@ public class MediaController2 implements AutoCloseable {
     * @param executor executor to run callbacks on.
     */
    // TODO(jaewan): Put @CallbackExecutor to the constructor.
    public MediaController2(@NonNull Context context, @NonNull SessionToken token,
    public MediaController2(@NonNull Context context, @NonNull SessionToken2 token,
            @NonNull ControllerCallback callback, @NonNull Executor executor) {
        super();

@@ -256,7 +256,7 @@ public class MediaController2 implements AutoCloseable {
    }

    MediaController2Provider createProvider(@NonNull Context context,
            @NonNull SessionToken token, @NonNull ControllerCallback callback,
            @NonNull SessionToken2 token, @NonNull ControllerCallback callback,
            @NonNull Executor executor) {
        return ApiLoader.getProvider(context)
                .createMediaController2(this, context, token, callback, executor);
@@ -281,7 +281,8 @@ public class MediaController2 implements AutoCloseable {
    /**
     * @return token
     */
    public @NonNull SessionToken getSessionToken() {
    public @NonNull
    SessionToken2 getSessionToken() {
        return mProvider.getSessionToken_impl();
    }

+14 −9
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.media;

import android.annotation.CallbackExecutor;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.PendingIntent;
@@ -30,6 +31,7 @@ import android.os.Bundle;
import android.service.media.MediaBrowserService.BrowserRoot;

import java.util.List;
import java.util.concurrent.Executor;

/**
 * Base class for media library services.
@@ -67,20 +69,21 @@ public abstract class MediaLibraryService2 extends MediaSessionService2 {
        private final MediaLibrarySessionProvider mProvider;

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

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

        /**
@@ -206,23 +209,25 @@ public abstract class MediaLibraryService2 extends MediaSessionService2 {
            extends BuilderBase<MediaLibrarySessionBuilder, MediaLibrarySessionCallback> {
        public MediaLibrarySessionBuilder(
                @NonNull Context context, @NonNull MediaPlayerBase player,
                @NonNull @CallbackExecutor Executor callbackExecutor,
                @NonNull MediaLibrarySessionCallback callback) {
            super(context, player);
            setSessionCallback(callback);
            setSessionCallback(callbackExecutor, callback);
        }

        @Override
        public MediaLibrarySessionBuilder setSessionCallback(
                @NonNull @CallbackExecutor Executor callbackExecutor,
                @NonNull MediaLibrarySessionCallback callback) {
            if (callback == null) {
                throw new IllegalArgumentException("MediaLibrarySessionCallback cannot be null");
            }
            return super.setSessionCallback(callback);
            return super.setSessionCallback(callbackExecutor, callback);
        }

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