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

Commit 4fe4facb authored by RoboErik's avatar RoboErik Committed by Android (Google) Code Review
Browse files

Merge "Set/unset session on the callback" into lmp-dev

parents bb6c0333 5ea924bc
Loading
Loading
Loading
Loading
+14 −10
Original line number Diff line number Diff line
@@ -180,18 +180,26 @@ public final class MediaSession {
     * @param handler The handler that events should be posted on.
     */
    public void setCallback(@Nullable Callback callback, @Nullable Handler handler) {
        synchronized (mLock) {
            if (callback == null) {
                if (mCallback != null) {
                    mCallback.mCallback.mSession = null;
                }
                mCallback = null;
                return;
            }
        synchronized (mLock) {
            if (mCallback != null && mCallback.mCallback == callback) {
            if (mCallback != null) {
                if (mCallback.mCallback == callback) {
                    Log.w(TAG, "Tried to set same callback, ignoring");
                    return;
                }
                // We're changing callbacks, clear the session from the old one.
                mCallback.mCallback.mSession = null;
            }
            if (handler == null) {
                handler = new Handler();
            }
            callback.mSession = this;
            CallbackMessageHandler msgHandler = new CallbackMessageHandler(handler.getLooper(),
                    callback);
            mCallback = msgHandler;
@@ -824,10 +832,6 @@ public final class MediaSession {
         */
        public void onCustomAction(@NonNull String action, @Nullable Bundle extras) {
        }

        private void setSession(MediaSession session) {
            mSession = session;
        }
    }

    /**