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

Commit 00f7a005 authored by Jaewan Kim's avatar Jaewan Kim
Browse files

MediaSession2: Remove MediaSession2#registerPlayerEventCallback()

Bug: 74157064
Test: Run CTS with MediaComponents/runcts.sh
Change-Id: Ib43f841d3989c363296a81224a5e2e8d33a0fab0
parent b1add7fb
Loading
Loading
Loading
Loading
+5 −54
Original line number Original line Diff line number Diff line
@@ -88,7 +88,6 @@ public class MediaSession2Impl implements MediaSession2Provider {
    private final MediaSession2Stub mSessionStub;
    private final MediaSession2Stub mSessionStub;
    private final SessionToken2 mSessionToken;
    private final SessionToken2 mSessionToken;
    private final AudioManager mAudioManager;
    private final AudioManager mAudioManager;
    private final ArrayMap<PlayerEventCallback, Executor> mCallbacks = new ArrayMap<>();
    private final PendingIntent mSessionActivity;
    private final PendingIntent mSessionActivity;
    private final PlayerEventCallback mPlayerEventCallback;
    private final PlayerEventCallback mPlayerEventCallback;
    private final PlaylistEventCallback mPlaylistEventCallback;
    private final PlaylistEventCallback mPlaylistEventCallback;
@@ -650,31 +649,6 @@ public class MediaSession2Impl implements MediaSession2Provider {
        }
        }
    }
    }


    @Override
    public void registerPlayerEventCallback_impl(Executor executor, PlayerEventCallback callback) {
        if (executor == null) {
            throw new IllegalArgumentException("executor shouldn't be null");
        }
        if (callback == null) {
            throw new IllegalArgumentException("callback shouldn't be null");
        }
        ensureCallingThread();
        if (mCallbacks.get(callback) != null) {
            Log.w(TAG, "callback is already added. Ignoring.");
            return;
        }
        mCallbacks.put(callback, executor);
    }

    @Override
    public void unregisterPlayerEventCallback_impl(PlayerEventCallback callback) {
        if (callback == null) {
            throw new IllegalArgumentException("callback shouldn't be null");
        }
        ensureCallingThread();
        mCallbacks.remove(callback);
    }

    @Override
    @Override
    public void notifyError_impl(int errorCode, Bundle extras) {
    public void notifyError_impl(int errorCode, Bundle extras) {
        // TODO(jaewan): Implement
        // TODO(jaewan): Implement
@@ -725,19 +699,11 @@ public class MediaSession2Impl implements MediaSession2Provider {
    }
    }


    private void notifyPlayerUpdatedNotLocked(MediaPlayerBase oldPlayer) {
    private void notifyPlayerUpdatedNotLocked(MediaPlayerBase oldPlayer) {
        ArrayMap<PlayerEventCallback, Executor> callbacks = new ArrayMap<>();
        final MediaPlayerBase player = mPlayer;
        MediaPlayerBase player;
        // TODO(jaewan): (Can be post-P) Find better way for player.getPlayerState() //
        synchronized (mLock) {
        //               In theory, Session.getXXX() may not be the same as Player.getXXX()
            player = mPlayer;
        //               and we should notify information of the session.getXXX() instead of
            callbacks.putAll(mCallbacks);
        //               player.getXXX()
        }
        // Notify to callbacks added directly to this session
        for (int i = 0; i < callbacks.size(); i++) {
            final PlayerEventCallback callback = callbacks.keyAt(i);
            final Executor executor = callbacks.valueAt(i);
            // TODO: Uncomment or remove
            //executor.execute(() -> callback.onPlaybackStateChanged(state));
        }
        // Notify to controllers as well.
        // Notify to controllers as well.
        final int state = player.getPlayerState();
        final int state = player.getPlayerState();
        if (state != oldPlayer.getPlayerState()) {
        if (state != oldPlayer.getPlayerState()) {
@@ -761,21 +727,6 @@ public class MediaSession2Impl implements MediaSession2Provider {
        }
        }
    }
    }


    private void notifyErrorNotLocked(String mediaId, int what, int extra) {
        ArrayMap<PlayerEventCallback, Executor> callbacks = new ArrayMap<>();
        synchronized (mLock) {
            callbacks.putAll(mCallbacks);
        }
        // Notify to callbacks added directly to this session
        for (int i = 0; i < callbacks.size(); i++) {
            final PlayerEventCallback callback = callbacks.keyAt(i);
            final Executor executor = callbacks.valueAt(i);
            // TODO: Uncomment or remove
            //executor.execute(() -> callback.onError(mediaId, what, extra));
        }
        // TODO(jaewan): Notify to controllers as well.
    }

    Context getContext() {
    Context getContext() {
        return mContext;
        return mContext;
    }
    }