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

Commit df10580d authored by Hyundo Moon's avatar Hyundo Moon Committed by Android (Google) Code Review
Browse files

Merge "MediaSession2: Complete MediaSession2#notifyError()" into pi-dev

parents 9c87f279 6ae7465a
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ oneway interface IMediaController2 {
    void onPlaybackInfoChanged(in Bundle playbackInfo);
    void onRepeatModeChanged(int repeatMode);
    void onShuffleModeChanged(int shuffleMode);
    void onError(int errorCode, in Bundle extras);

    void onConnected(IMediaSession2 sessionBinder, in Bundle commandGroup,
            int playerState, long positionEventTimeMs, long positionMs, float playbackSpeed,
+9 −0
Original line number Diff line number Diff line
@@ -906,6 +906,15 @@ public class MediaController2Impl implements MediaController2Provider {
        });
    }

    void pushError(int errorCode, Bundle extras) {
        mCallbackExecutor.execute(() -> {
            if (!mInstance.isConnected()) {
                return;
            }
            mCallback.onError(mInstance, errorCode, extras);
        });
    }

    // Should be used without a lock to prevent potential deadlock.
    void onConnectedNotLocked(IMediaSession2 sessionBinder,
            final CommandGroup allowedCommands,
+12 −0
Original line number Diff line number Diff line
@@ -213,6 +213,18 @@ public class MediaController2Stub extends IMediaController2.Stub {
        controller.pushShuffleModeChanges(shuffleMode);
    }

    @Override
    public void onError(int errorCode, Bundle extras) {
        final MediaController2Impl controller;
        try {
            controller = getController();
        } catch (IllegalStateException e) {
            Log.w(TAG, "Don't fail silently here. Highly likely a bug");
            return;
        }
        controller.pushError(errorCode, extras);
    }

    @Override
    public void onConnected(IMediaSession2 sessionBinder, Bundle commandGroup,
            int playerState, long positionEventTimeMs, long positionMs, float playbackSpeed,
+1 −1
Original line number Diff line number Diff line
@@ -682,7 +682,7 @@ public class MediaSession2Impl implements MediaSession2Provider {

    @Override
    public void notifyError_impl(int errorCode, Bundle extras) {
        // TODO(jaewan): Implement
        mSessionStub.notifyError(errorCode, extras);
    }

    ///////////////////////////////////////////////////
+6 −0
Original line number Diff line number Diff line
@@ -1044,6 +1044,12 @@ public class MediaSession2Stub extends IMediaSession2.Stub {
        });
    }

    public void notifyError(int errorCode, Bundle extras) {
        notifyAll((unused, iController) -> {
            iController.onError(errorCode, extras);
        });
    }

    //////////////////////////////////////////////////////////////////////////////////////////////
    // APIs for MediaLibrarySessionImpl
    //////////////////////////////////////////////////////////////////////////////////////////////