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

Commit bd396d85 authored by Jaewan Kim's avatar Jaewan Kim
Browse files

MediaSession2: Remove initialization in library session impl constructor

This fixes crash when framework tries to connect to the library session
impl when the session's super constructor is finished but mCallback
isn't set yet.

Bug: 73327626
Test: Run all MediaComponents test once
Change-Id: I42776925fc45b907072c39bc6dbc0dc86a896e0f
parent e4767e39
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -66,15 +66,17 @@ public class MediaLibraryService2Impl extends MediaSessionService2Impl implement

    public static class MediaLibrarySessionImpl extends MediaSession2Impl
            implements MediaLibrarySessionProvider {
        private final MediaLibrarySessionCallback mCallback;

        public MediaLibrarySessionImpl(Context context,
                MediaPlayerInterface player, String id, VolumeProvider2 volumeProvider,
                int ratingType, PendingIntent sessionActivity, Executor callbackExecutor,
                MediaLibrarySessionCallback callback) {
            super(context, player, id, volumeProvider, ratingType, sessionActivity,
                    callbackExecutor, callback);
            mCallback = 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
            // connect to this session assuming that initialization is finished. However, if any
            // initialization logic is here, calls from the server would fail.
            // see: MediaSession2Stub#connect()
        }

        @Override
@@ -89,8 +91,7 @@ public class MediaLibraryService2Impl extends MediaSessionService2Impl implement

        @Override
        MediaLibrarySessionCallback getCallback() {
            // Equivalent to the (MediaLibrarySessionCallback) super.getCallback().
            return mCallback;
            return (MediaLibrarySessionCallback) super.getCallback();
        }

        @Override