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

Commit c8508bf0 authored by Jaewan Kim's avatar Jaewan Kim Committed by Sungsoo Lim
Browse files

MediaSession2: Clean up TODOs under frameworks/base

This change includes
  - Addressed trivial TODOs (takes less than 1min)
  - Renamed playlist controller to playlist agent
  - Renamed mplc to playlistAgent
  - Renamed mpb to player
  - Assigned buganizer issues for TODOs

Bug: 74361045
Test: Run MediaComponentsTest
Change-Id: I44b4c7b543ac513914632e3ee235d3151840d3e0
parent fa97d22b
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -314,12 +314,12 @@ public class MediaController2Impl implements MediaController2Provider {
    }

    @Override
    public void skipToPrevious_impl() {
    public void skipToPreviousItem_impl() {
        sendTransportControlCommand(MediaSession2.COMMAND_CODE_PLAYBACK_SKIP_PREV_ITEM);
    }

    @Override
    public void skipToNext_impl() {
    public void skipToNextItem_impl() {
        sendTransportControlCommand(MediaSession2.COMMAND_CODE_PLAYBACK_SKIP_NEXT_ITEM);
    }

@@ -651,7 +651,7 @@ public class MediaController2Impl implements MediaController2Provider {
    }

    @Override
    public MediaItem2 getCurrentPlaylistItem_impl() {
    public MediaItem2 getCurrentMediaItem_impl() {
        // TODO(jaewan): Implement
        return null;
    }
+3 −3
Original line number Diff line number Diff line
@@ -68,11 +68,11 @@ public class MediaLibraryService2Impl extends MediaSessionService2Impl implement
    public static class MediaLibrarySessionImpl extends MediaSession2Impl
            implements MediaLibrarySessionProvider {
        public MediaLibrarySessionImpl(Context context,
                MediaPlayerBase player, String id, MediaPlaylistAgent mplc,
                MediaPlayerBase player, String id, MediaPlaylistAgent playlistAgent,
                VolumeProvider2 volumeProvider,
                PendingIntent sessionActivity, Executor callbackExecutor,
                MediaLibrarySessionCallback callback) {
            super(context, player, id, mplc, volumeProvider, sessionActivity, callbackExecutor,
            super(context, player, id, playlistAgent, volumeProvider, sessionActivity, callbackExecutor,
                    callback);
            // Don't put any extra initialization here. Here's the reason.
            // System service will recognize this session inside of the super constructor and would
@@ -141,7 +141,7 @@ public class MediaLibraryService2Impl extends MediaSessionService2Impl implement

        @Override
        public MediaLibrarySession build_impl() {
            return new MediaLibrarySessionImpl(mContext, mPlayer, mId, mMplc,
            return new MediaLibrarySessionImpl(mContext, mPlayer, mId, mPlaylistAgent,
                    mVolumeProvider, mSessionActivity, mCallbackExecutor, mCallback).getInstance();
        }
    }
+19 −18
Original line number Diff line number Diff line
@@ -105,7 +105,7 @@ public class MediaSession2Impl implements MediaSession2Provider {
    @GuardedBy("mLock")
    private MediaPlayerBase mPlayer;
    @GuardedBy("mLock")
    private MediaPlaylistAgent mMplc;
    private MediaPlaylistAgent mPlaylistAgent;
    @GuardedBy("mLock")
    private VolumeProvider2 mVolumeProvider;
    @GuardedBy("mLock")
@@ -118,14 +118,14 @@ public class MediaSession2Impl implements MediaSession2Provider {
     * @param context
     * @param player
     * @param id
     * @param mplc
     * @param playlistAgent
     * @param volumeProvider
     * @param sessionActivity
     * @param callbackExecutor
     * @param callback
     */
    public MediaSession2Impl(Context context, MediaPlayerBase player, String id,
            MediaPlaylistAgent mplc, VolumeProvider2 volumeProvider,
            MediaPlaylistAgent playlistAgent, VolumeProvider2 volumeProvider,
            PendingIntent sessionActivity,
            Executor callbackExecutor, SessionCallback callback) {
        // TODO(jaewan): Keep other params.
@@ -140,7 +140,7 @@ public class MediaSession2Impl implements MediaSession2Provider {
        mSessionActivity = sessionActivity;
        mSessionStub = new MediaSession2Stub(this);
        mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
        mMplc = mplc;
        mPlaylistAgent = playlistAgent;

        // Infer type from the id and package name.
        String libraryService = getServiceName(context, MediaLibraryService2.SERVICE_INTERFACE, id);
@@ -204,13 +204,13 @@ public class MediaSession2Impl implements MediaSession2Provider {
    }

    @Override
    public void updatePlayer_impl(MediaPlayerBase player, MediaPlaylistAgent mplc,
    public void updatePlayer_impl(MediaPlayerBase player, MediaPlaylistAgent playlistAgent,
            VolumeProvider2 volumeProvider) throws IllegalArgumentException {
        ensureCallingThread();
        if (player == null) {
            throw new IllegalArgumentException("player shouldn't be null");
        }
        mMplc = mplc;
        mPlaylistAgent = playlistAgent;
        setPlayer(player, volumeProvider);
    }

@@ -342,18 +342,16 @@ public class MediaSession2Impl implements MediaSession2Provider {
        ensureCallingThread();
        final MediaPlayerBase player = mPlayer;
        if (player != null) {
            // TODO: Uncomment or remove
            //player.stop();
            player.pause();
            player.reset();
        } else if (DEBUG) {
            Log.d(TAG, "API calls after the close()", new IllegalStateException());
        }
    }

    @Override
    public void skipToPrevious_impl() {
    public void skipToPreviousItem_impl() {
        ensureCallingThread();
        // TODO: Uncomment or remove
        // TODO(jaewan): Implement this (b/74175632)
        /*
        final MediaPlayerBase player = mPlayer;
        if (player != null) {
@@ -366,14 +364,17 @@ public class MediaSession2Impl implements MediaSession2Provider {
    }

    @Override
    public void skipToNext_impl() {
    public void skipToNextItem_impl() {
        ensureCallingThread();
        // TODO(jaewan): Implement this (b/74175632)
        /*
        final MediaPlayerBase player = mPlayer;
        if (player != null) {
            player.skipToNext();
        } else if (DEBUG) {
            Log.d(TAG, "API calls after the close()", new IllegalStateException());
        }
        */
    }

    @Override
@@ -1275,7 +1276,7 @@ public class MediaSession2Impl implements MediaSession2Provider {
        String mId;
        Executor mCallbackExecutor;
        C mCallback;
        MediaPlaylistAgent mMplc;
        MediaPlaylistAgent mPlaylistAgent;
        VolumeProvider2 mVolumeProvider;
        PendingIntent mSessionActivity;

@@ -1304,11 +1305,11 @@ public class MediaSession2Impl implements MediaSession2Provider {
        }

        @Override
        public void setPlaylistController_impl(MediaPlaylistAgent mplc) {
            if (mplc == null) {
                throw new IllegalArgumentException("mplc shouldn't be null");
        public void setPlaylistAgent_impl(MediaPlaylistAgent playlistAgent) {
            if (playlistAgent == null) {
                throw new IllegalArgumentException("playlistAgent shouldn't be null");
            }
            mMplc = mplc;
            mPlaylistAgent = playlistAgent;
        }

        public void setVolumeProvider_impl(VolumeProvider2 volumeProvider) {
@@ -1357,7 +1358,7 @@ public class MediaSession2Impl implements MediaSession2Provider {
                mCallback = new SessionCallback(mContext) {};
            }

            return new MediaSession2Impl(mContext, mPlayer, mId, mMplc,
            return new MediaSession2Impl(mContext, mPlayer, mId, mPlaylistAgent,
                    mVolumeProvider, mSessionActivity, mCallbackExecutor, mCallback).getInstance();
        }
    }
+1 −1
Original line number Diff line number Diff line
@@ -138,7 +138,7 @@ public class MediaSessionService2Impl implements MediaSessionService2Provider {

    private class SessionServiceEventCallback extends PlayerEventCallback {
        @Override
        public void onPlayerStateChanged(MediaPlayerBase mpb, int state) {
        public void onPlayerStateChanged(MediaPlayerBase player, int state) {
            // TODO: Implement this
            return;
        }