Merge "Remove ControllerLink"
diff --git a/media/java/android/media/session/ControllerLink.aidl b/media/java/android/media/session/ControllerLink.aidl
deleted file mode 100644
index 532df59..0000000
--- a/media/java/android/media/session/ControllerLink.aidl
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.media.session;
-
-parcelable ControllerLink;
diff --git a/media/java/android/media/session/ControllerLink.java b/media/java/android/media/session/ControllerLink.java
deleted file mode 100644
index d4ea2a3..0000000
--- a/media/java/android/media/session/ControllerLink.java
+++ /dev/null
@@ -1,1042 +0,0 @@
-/*
- * Copyright 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.media.session;
-
-import android.annotation.NonNull;
-import android.annotation.Nullable;
-import android.app.PendingIntent;
-import android.media.MediaMetadata;
-import android.media.MediaParceledListSlice;
-import android.media.Rating;
-import android.media.session.MediaController.PlaybackInfo;
-import android.net.Uri;
-import android.os.Bundle;
-import android.os.IBinder;
-import android.os.Parcel;
-import android.os.Parcelable;
-import android.os.RemoteException;
-import android.os.ResultReceiver;
-import android.view.KeyEvent;
-
-import java.util.List;
-import java.util.Objects;
-
-/**
- * Handles incoming commands from {@link MediaController}.
- * @hide
- */
-public final class ControllerLink implements Parcelable {
-    public static final @android.annotation.NonNull Parcelable.Creator<ControllerLink> CREATOR =
-            new Parcelable.Creator<ControllerLink>() {
-                @Override
-                public ControllerLink createFromParcel(Parcel in) {
-                    return new ControllerLink(in.readStrongBinder());
-                }
-
-                @Override
-                public ControllerLink[] newArray(int size) {
-                    return new ControllerLink[size];
-                }
-            };
-
-    final ControllerStub mControllerStub;
-    final ISessionController mISessionController;
-
-    /**
-     * Constructor for stub (Callee)
-     */
-    public ControllerLink(@NonNull ControllerStub controllerStub) {
-        mControllerStub = controllerStub;
-        mISessionController = new StubProxy();
-    }
-
-    /**
-     * Constructor for interface (Caller)
-     */
-    public ControllerLink(IBinder binder) {
-        mControllerStub = null;
-        mISessionController = ISessionController.Stub.asInterface(binder);
-    }
-
-    /**
-     * Tell system that a controller sends a command.
-     *
-     * @param packageName the package name of the controller
-     * @param caller the {@link ControllerCallbackLink} of the controller
-     * @param command the name of the command
-     * @param args the arguments included with the command
-     * @param cb the result receiver for getting the result of the command
-     */
-    void sendCommand(@NonNull String packageName, @NonNull ControllerCallbackLink caller,
-            @NonNull String command, @Nullable Bundle args, @Nullable ResultReceiver cb) {
-        try {
-            mISessionController.sendCommand(packageName, caller, command, args, cb);
-        } catch (RemoteException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    /**
-     * Tell system that a controller sends a media button event.
-     *
-     * @param packageName the package name of the controller
-     * @param caller the {@link ControllerCallbackLink} of the controller
-     * @param mediaButton the media button key event
-     */
-    boolean sendMediaButton(@NonNull String packageName,
-            @NonNull ControllerCallbackLink caller, @NonNull KeyEvent mediaButton) {
-        try {
-            return mISessionController.sendMediaButton(packageName, caller, mediaButton);
-        } catch (RemoteException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    /**
-     * Registers a controller callback link to the system.
-     *
-     * @param packageName the package name of the controller
-     * @param cb the controller callback link to register
-     */
-    void registerCallback(@NonNull String packageName, @NonNull ControllerCallbackLink cb) {
-        try {
-            mISessionController.registerCallback(packageName, cb);
-        } catch (RemoteException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    /**
-     * Unregisters a controller callback link from the system.
-     *
-     * @param cb the controller callback link to register
-     */
-    void unregisterCallback(@NonNull ControllerCallbackLink cb) {
-        try {
-            mISessionController.unregisterCallback(cb);
-        } catch (RemoteException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    /**
-     * Gets the package name of the connected session.
-     */
-    @NonNull
-    String getPackageName() {
-        try {
-            return mISessionController.getPackageName();
-        } catch (RemoteException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    /**
-     * Gets the tag of the connected session.
-     */
-    @NonNull
-    String getTag() {
-        try {
-            return mISessionController.getTag();
-        } catch (RemoteException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    /**
-     * Gets the session info of the connected session.
-     */
-    @Nullable
-    Bundle getSessionInfo() {
-        try {
-            return mISessionController.getSessionInfo();
-        } catch (RemoteException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    /**
-     * Gets the {@link PendingIntent} for launching UI of the connected session.
-     */
-    @Nullable
-    PendingIntent getLaunchPendingIntent() {
-        try {
-            return mISessionController.getLaunchPendingIntent();
-        } catch (RemoteException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    /**
-     * Gets the flags of the connected session.
-     */
-    long getFlags() {
-        try {
-            return mISessionController.getFlags();
-        } catch (RemoteException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    /**
-     * Gets the volume attributes of the connected session.
-     */
-    @NonNull
-    PlaybackInfo getVolumeAttributes() {
-        try {
-            return mISessionController.getVolumeAttributes();
-        } catch (RemoteException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    /**
-     * Tell system that a controller requests adjusting the volume.
-     *
-     * @param packageName the package name of the controller
-     * @param opPackageName the op package name of this request
-     * @param caller the {@link ControllerCallbackLink} of the controller
-     * @param direction the direction to adjust the volume in
-     * @param flags the flags with this volume change request
-     */
-    void adjustVolume(@NonNull String packageName, @NonNull String opPackageName,
-            @NonNull ControllerCallbackLink caller, int direction,
-            int flags) {
-        try {
-            mISessionController.adjustVolume(packageName, opPackageName, caller, direction, flags);
-        } catch (RemoteException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    /**
-     * Tell system that a controller requests setting the volume.
-     *
-     * @param packageName the package name of the controller
-     * @param opPackageName the op package name of this request
-     * @param caller the {@link ControllerCallbackLink} of the controller
-     * @param flags the flags with this volume change request
-     */
-    void setVolumeTo(@NonNull String packageName, @NonNull String opPackageName,
-            @NonNull ControllerCallbackLink caller, int value, int flags) {
-        try {
-            mISessionController.setVolumeTo(packageName, opPackageName, caller, value, flags);
-        } catch (RemoteException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    /**
-     * Tell system that a controller requests preparing media.
-     *
-     * @param packageName the package name of the controller
-     * @param caller the {@link ControllerCallbackLink} of the controller
-     */
-    void prepare(@NonNull String packageName, @NonNull ControllerCallbackLink caller) {
-        try {
-            mISessionController.prepare(packageName, caller);
-        } catch (RemoteException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    /**
-     * Tell system that a controller requests preparing media from given media ID.
-     *
-     * @param packageName the package name of the controller
-     * @param caller the {@link ControllerCallbackLink} of the controller
-     * @param mediaId the ID of the media
-     * @param extras the extras included with this request.
-     */
-    void prepareFromMediaId(@NonNull String packageName,
-            @NonNull ControllerCallbackLink caller, @NonNull String mediaId,
-            @Nullable Bundle extras) {
-        try {
-            mISessionController.prepareFromMediaId(packageName, caller, mediaId, extras);
-        } catch (RemoteException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    /**
-     * Tell system that a controller requests preparing media from given search query.
-     *
-     * @param packageName the package name of the controller
-     * @param caller the {@link ControllerCallbackLink} of the controller
-     * @param query the search query
-     * @param extras the extras included with this request.
-     */
-    void prepareFromSearch(@NonNull String packageName,
-            @NonNull ControllerCallbackLink caller, @NonNull String query,
-            @Nullable Bundle extras) {
-        try {
-            mISessionController.prepareFromSearch(packageName, caller, query, extras);
-        } catch (RemoteException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    /**
-     * Tell system that a controller requests preparing media from given uri.
-     *
-     * @param packageName the package name of the controller
-     * @param caller the {@link ControllerCallbackLink} of the controller
-     * @param uri the uri of the media
-     * @param extras the extras included with this request.
-     */
-    void prepareFromUri(@NonNull String packageName, @NonNull ControllerCallbackLink caller,
-            @NonNull Uri uri, @Nullable Bundle extras) {
-        try {
-            mISessionController.prepareFromUri(packageName, caller, uri, extras);
-        } catch (RemoteException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    /**
-     * Tell system that a controller requests playing media.
-     *
-     * @param packageName the package name of the controller
-     * @param caller the {@link ControllerCallbackLink} of the controller
-     */
-    void play(@NonNull String packageName, @NonNull ControllerCallbackLink caller) {
-        try {
-            mISessionController.play(packageName, caller);
-        } catch (RemoteException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    /**
-     * Tell system that a controller requests playing media from given media ID.
-     *
-     * @param packageName the package name of the controller
-     * @param caller the {@link ControllerCallbackLink} of the controller
-     * @param mediaId the ID of the media
-     * @param extras the extras included with this request.
-     */
-    void playFromMediaId(@NonNull String packageName, @NonNull ControllerCallbackLink caller,
-            @NonNull String mediaId, @Nullable Bundle extras) {
-        try {
-            mISessionController.playFromMediaId(packageName, caller, mediaId, extras);
-        } catch (RemoteException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    /**
-     * Tell system that a controller requests playing media from given search query.
-     *
-     * @param packageName the package name of the controller
-     * @param caller the {@link ControllerCallbackLink} of the controller
-     * @param query the search query
-     * @param extras the extras included with this request.
-     */
-    void playFromSearch(@NonNull String packageName, @NonNull ControllerCallbackLink caller,
-            @NonNull String query, @Nullable Bundle extras) {
-        try {
-            mISessionController.playFromSearch(packageName, caller, query, extras);
-        } catch (RemoteException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    /**
-     * Tell system that a controller requests playing media from given uri.
-     *
-     * @param packageName the package name of the controller
-     * @param caller the {@link ControllerCallbackLink} of the controller
-     * @param uri the uri of the media
-     * @param extras the extras included with this request.
-     */
-    void playFromUri(@NonNull String packageName, @NonNull ControllerCallbackLink caller,
-            @NonNull Uri uri, @Nullable Bundle extras) {
-        try {
-            mISessionController.playFromUri(packageName, caller, uri, extras);
-        } catch (RemoteException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    /**
-     * Tell system that a controller requests skipping to the queue item with given ID.
-     *
-     * @param packageName the package name of the controller
-     * @param caller the {@link ControllerCallbackLink} of the controller
-     * @param id the queue id of the item
-     */
-    void skipToQueueItem(@NonNull String packageName, @NonNull ControllerCallbackLink caller,
-            long id) {
-        try {
-            mISessionController.skipToQueueItem(packageName, caller, id);
-        } catch (RemoteException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    /**
-     * Tell system that a controller requests pausing media.
-     *
-     * @param packageName the package name of the controller
-     * @param caller the {@link ControllerCallbackLink} of the controller
-     */
-    void pause(@NonNull String packageName, @NonNull ControllerCallbackLink caller) {
-        try {
-            mISessionController.pause(packageName, caller);
-        } catch (RemoteException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    /**
-     * Tell system that a controller requests stopping media.
-     *
-     * @param packageName the package name of the controller
-     * @param caller the {@link ControllerCallbackLink} of the controller
-     */
-    void stop(@NonNull String packageName, @NonNull ControllerCallbackLink caller) {
-        try {
-            mISessionController.stop(packageName, caller);
-        } catch (RemoteException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    /**
-     * Tell system that a controller requests skipping to the next queue item.
-     *
-     * @param packageName the package name of the controller
-     * @param caller the {@link ControllerCallbackLink} of the controller
-     */
-    void next(@NonNull String packageName, @NonNull ControllerCallbackLink caller) {
-        try {
-            mISessionController.next(packageName, caller);
-        } catch (RemoteException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    /**
-     * Tell system that a controller requests skipping to the previous queue item.
-     *
-     * @param packageName the package name of the controller
-     * @param caller the {@link ControllerCallbackLink} of the controller
-     */
-    void previous(@NonNull String packageName, @NonNull ControllerCallbackLink caller) {
-        try {
-            mISessionController.previous(packageName, caller);
-        } catch (RemoteException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    /**
-     * Tell system that a controller requests fast-forwarding.
-     *
-     * @param packageName the package name of the controller
-     * @param caller the {@link ControllerCallbackLink} of the controller
-     */
-    void fastForward(@NonNull String packageName, @NonNull ControllerCallbackLink caller) {
-        try {
-            mISessionController.fastForward(packageName, caller);
-        } catch (RemoteException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    /**
-     * Tell system that a controller requests rewinding.
-     *
-     * @param packageName the package name of the controller
-     * @param caller the {@link ControllerCallbackLink} of the controller
-     */
-    void rewind(@NonNull String packageName, @NonNull ControllerCallbackLink caller) {
-        try {
-            mISessionController.rewind(packageName, caller);
-        } catch (RemoteException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    /**
-     * Tell system that a controller requests seeking to the specific position.
-     *
-     * @param packageName the package name of the controller
-     * @param caller the {@link ControllerCallbackLink} of the controller
-     * @param pos the position to move to, in milliseconds
-     */
-    void seekTo(@NonNull String packageName, @NonNull ControllerCallbackLink caller,
-            long pos) {
-        try {
-            mISessionController.seekTo(packageName, caller, pos);
-        } catch (RemoteException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    /**
-     * Tell system that a controller requests rating of the current media.
-     *
-     * @param packageName the package name of the controller
-     * @param caller the {@link ControllerCallbackLink} of the controller
-     * @param rating the rating of the current media
-     */
-    void rate(@NonNull String packageName, @NonNull ControllerCallbackLink caller,
-            @NonNull Rating rating) {
-        try {
-            mISessionController.rate(packageName, caller, rating);
-        } catch (RemoteException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    /**
-     * Tell system that a controller requests changing the playback speed.
-     *
-     * @param packageName the package name of the controller
-     * @param caller the {@link ControllerCallbackLink} of the controller
-     * @param speed the playback speed
-     */
-    void setPlaybackSpeed(@NonNull String packageName, @NonNull ControllerCallbackLink caller,
-            float speed) {
-        try {
-            mISessionController.setPlaybackSpeed(packageName, caller, speed);
-        } catch (RemoteException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    /**
-     * Tell system that a controller sends a custom action.
-     *
-     * @param packageName the package name of the controller
-     * @param caller the {@link ControllerCallbackLink} of the controller
-     * @param action the name of the action
-     * @param args the arguments included with this action
-     */
-    void sendCustomAction(@NonNull String packageName,
-            @NonNull ControllerCallbackLink caller, @NonNull String action, @Nullable Bundle args) {
-        try {
-            mISessionController.sendCustomAction(packageName, caller, action, args);
-        } catch (RemoteException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    /**
-     * Gets the current metadata of the connected session.
-     */
-    @Nullable
-    public MediaMetadata getMetadata() {
-        try {
-            return mISessionController.getMetadata();
-        } catch (RemoteException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    /**
-     * Gets the current playback state of the connected session.
-     */
-    @Nullable
-    public PlaybackState getPlaybackState() {
-        try {
-            return mISessionController.getPlaybackState();
-        } catch (RemoteException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    /**
-     * Gets the current queue of the connected session.
-     */
-    @Nullable
-    public List<MediaSession.QueueItem> getQueue() {
-        try {
-            MediaParceledListSlice queue = mISessionController.getQueue();
-            return queue == null ? null : queue.getList();
-        } catch (RemoteException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    /**
-     * Gets the current queue title of the connected session.
-     */
-    @Nullable
-    public CharSequence getQueueTitle() {
-        try {
-            return mISessionController.getQueueTitle();
-        } catch (RemoteException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    /**
-     * Gets the current extras of the connected session.
-     */
-    @Nullable
-    public Bundle getExtras() {
-        try {
-            return mISessionController.getExtras();
-        } catch (RemoteException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    /**
-     * Gets the current rating type of the connected session.
-     */
-    public int getRatingType() {
-        try {
-            return mISessionController.getRatingType();
-        } catch (RemoteException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    /** Gets the binder */
-    @NonNull
-    public IBinder getBinder() {
-        return mISessionController.asBinder();
-    }
-
-    @Override
-    public int describeContents() {
-        return 0;
-    }
-
-    @Override
-    public void writeToParcel(Parcel dest, int flags) {
-        dest.writeStrongBinder(mISessionController.asBinder());
-    }
-
-    @Override
-    public int hashCode() {
-        return mISessionController.asBinder().hashCode();
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        if (this == obj) {
-            return true;
-        }
-        if (!(obj instanceof ControllerLink)) {
-            return false;
-        }
-        ControllerLink other = (ControllerLink) obj;
-        return Objects.equals(getBinder(), other.getBinder());
-    }
-
-    /**
-     * Class for Stub implementation
-     */
-    public abstract static class ControllerStub {
-        /** Stub method for ISessionController.sendCommand */
-        public void sendCommand(@NonNull String packageName, @NonNull ControllerCallbackLink caller,
-                @NonNull String command, @Nullable Bundle args, @Nullable ResultReceiver cb) {
-        }
-
-        /** Stub method for ISessionController.sendMediaButton */
-        public boolean sendMediaButton(@NonNull String packageName,
-                @NonNull ControllerCallbackLink caller, @NonNull KeyEvent mediaButton) {
-            return false;
-        }
-
-        /** Stub method for ISessionController.registerCallback */
-        public void registerCallback(@NonNull String packageName,
-                @NonNull ControllerCallbackLink cb) {
-        }
-
-        /** Stub method for ISessionController.unregisterCallback */
-        public void unregisterCallback(@NonNull ControllerCallbackLink cb) {
-        }
-
-        /** Stub method for ISessionController.getPackageName */
-        @NonNull
-        public String getPackageName() {
-            return null;
-        }
-
-        /** Stub method for ISessionController.getTag */
-        @NonNull
-        public String getTag() {
-            return null;
-        }
-
-        /** Stub method for ISessionController.getSessionInfo */
-        @Nullable
-        public Bundle getSessionInfo() {
-            return null;
-        }
-
-        /** Stub method for ISessionController.getLaunchPendingIntent */
-        @Nullable
-        public PendingIntent getLaunchPendingIntent() {
-            return null;
-        }
-
-        /** Stub method for ISessionController.getFlags */
-        public long getFlags() {
-            return 0;
-        }
-
-        /** Stub method for ISessionController.getVolumeAttributes */
-        @NonNull
-        public PlaybackInfo getVolumeAttributes() {
-            return null;
-        }
-
-        /** Stub method for ISessionController.adjustVolume */
-        public void adjustVolume(@NonNull String packageName, @NonNull String opPackageName,
-                @NonNull ControllerCallbackLink caller, int direction, int flags) {
-        }
-
-        /** Stub method for ISessionController.setVolumeTo */
-        public void setVolumeTo(@NonNull String packageName, @NonNull String opPackageName,
-                @NonNull ControllerCallbackLink caller, int value, int flags) {
-        }
-
-        /** Stub method for ISessionController.prepare */
-        public void prepare(@NonNull String packageName, @NonNull ControllerCallbackLink caller) {
-        }
-
-        /** Stub method for ISessionController.prepareFromMediaId */
-        public void prepareFromMediaId(@NonNull String packageName,
-                @NonNull ControllerCallbackLink caller, @NonNull String mediaId,
-                @Nullable Bundle extras) {
-        }
-
-        /** Stub method for ISessionController.prepareFromSearch */
-        public void prepareFromSearch(@NonNull String packageName,
-                @NonNull ControllerCallbackLink caller, @NonNull String query,
-                @Nullable Bundle extras) {
-        }
-
-        /** Stub method for ISessionController.prepareFromUri */
-        public void prepareFromUri(@NonNull String packageName,
-                @NonNull ControllerCallbackLink caller, @NonNull Uri uri, @Nullable Bundle extras) {
-        }
-
-        /** Stub method for ISessionController.play */
-        public void play(@NonNull String packageName, @NonNull ControllerCallbackLink caller) {
-        }
-
-        /** Stub method for ISessionController.playFromMediaId */
-        public void playFromMediaId(@NonNull String packageName,
-                @NonNull ControllerCallbackLink caller, @NonNull String mediaId,
-                @Nullable Bundle extras) {
-        }
-
-        /** Stub method for ISessionController.playFromSearch */
-        public void playFromSearch(@NonNull String packageName,
-                @NonNull ControllerCallbackLink caller, @NonNull String query,
-                @Nullable Bundle extras) {
-        }
-
-        /** Stub method for ISessionController.playFromUri */
-        public void playFromUri(@NonNull String packageName, @NonNull ControllerCallbackLink caller,
-                @NonNull Uri uri, @Nullable Bundle extras) {
-        }
-
-        /** Stub method for ISessionController.skipToQueueItem */
-        public void skipToQueueItem(@NonNull String packageName,
-                @NonNull ControllerCallbackLink caller, long id) {
-        }
-
-        /** Stub method for ISessionController.pause */
-        public void pause(@NonNull String packageName, @NonNull ControllerCallbackLink caller) {
-        }
-
-        /** Stub method for ISessionController.stop */
-        public void stop(@NonNull String packageName, @NonNull ControllerCallbackLink caller) {
-        }
-
-        /** Stub method for ISessionController.next */
-        public void next(@NonNull String packageName, @NonNull ControllerCallbackLink caller) {
-        }
-
-        /** Stub method for ISessionController.previous */
-        public void previous(@NonNull String packageName, @NonNull ControllerCallbackLink caller) {
-        }
-
-        /** Stub method for ISessionController.fastForward */
-        public void fastForward(@NonNull String packageName,
-                @NonNull ControllerCallbackLink caller) {
-        }
-
-        /** Stub method for ISessionController.rewind */
-        public void rewind(@NonNull String packageName, @NonNull ControllerCallbackLink caller) {
-        }
-
-        /** Stub method for ISessionController.seekTo */
-        public void seekTo(@NonNull String packageName, @NonNull ControllerCallbackLink caller,
-                long pos) {
-        }
-
-        /** Stub method for ISessionController.rate */
-        public void rate(@NonNull String packageName, @NonNull ControllerCallbackLink caller,
-                @NonNull Rating rating) {
-        }
-
-        /** Stub method for ISessionController.setPlaybackSpeed */
-        public void setPlaybackSpeed(@NonNull String packageName,
-                @NonNull ControllerCallbackLink caller, float speed) {
-        }
-
-        /** Stub method for ISessionController.sendCustomAction */
-        public void sendCustomAction(@NonNull String packageName,
-                @NonNull ControllerCallbackLink caller, @NonNull String action,
-                @Nullable Bundle args) {
-        }
-
-        /** Stub method for ISessionController.getMetadata */
-        @Nullable
-        public MediaMetadata getMetadata() {
-            return null;
-        }
-
-        /** Stub method for ISessionController.getPlaybackState */
-        @Nullable
-        public PlaybackState getPlaybackState() {
-            return null;
-        }
-
-        /** Stub method for ISessionController.getQueue */
-        @Nullable
-        public List<MediaSession.QueueItem> getQueue() {
-            return null;
-        }
-
-        /** Stub method for ISessionController.getQueueTitle */
-        @Nullable
-        public CharSequence getQueueTitle() {
-            return null;
-        }
-
-        /** Stub method for ISessionController.getExtras */
-        @Nullable
-        public Bundle getExtras() {
-            return null;
-        }
-
-        /** Stub method for ISessionController.getRatingType */
-        public int getRatingType() {
-            return Rating.RATING_NONE;
-        }
-    }
-
-    private class StubProxy extends ISessionController.Stub {
-        @Override
-        public void sendCommand(String packageName, ControllerCallbackLink caller,
-                String command, Bundle args, ResultReceiver cb) {
-            mControllerStub.sendCommand(packageName, caller, command, args, cb);
-        }
-
-        @Override
-        public boolean sendMediaButton(String packageName, ControllerCallbackLink caller,
-                KeyEvent mediaButton) {
-            return mControllerStub.sendMediaButton(packageName, caller, mediaButton);
-        }
-
-        @Override
-        public void registerCallback(String packageName, ControllerCallbackLink cb) {
-            mControllerStub.registerCallback(packageName, cb);
-        }
-
-        @Override
-        public void unregisterCallback(ControllerCallbackLink cb) {
-            mControllerStub.unregisterCallback(cb);
-        }
-
-        @Override
-        public String getPackageName() {
-            return mControllerStub.getPackageName();
-        }
-
-        @Override
-        public String getTag() {
-            return mControllerStub.getTag();
-        }
-
-        @Override
-        public Bundle getSessionInfo() {
-            return mControllerStub.getSessionInfo();
-        }
-
-        @Override
-        public PendingIntent getLaunchPendingIntent() {
-            return mControllerStub.getLaunchPendingIntent();
-        }
-
-        @Override
-        public long getFlags() {
-            return mControllerStub.getFlags();
-        }
-
-        @Override
-        public PlaybackInfo getVolumeAttributes() {
-            return mControllerStub.getVolumeAttributes();
-        }
-
-        @Override
-        public void adjustVolume(String packageName, String opPackageName,
-                ControllerCallbackLink caller, int direction, int flags) {
-            mControllerStub.adjustVolume(packageName, opPackageName, caller, direction, flags);
-        }
-
-        @Override
-        public void setVolumeTo(String packageName, String opPackageName,
-                ControllerCallbackLink caller, int value, int flags) {
-            mControllerStub.setVolumeTo(packageName, opPackageName, caller, value, flags);
-        }
-
-        @Override
-        public void prepare(String packageName, ControllerCallbackLink caller) {
-            mControllerStub.prepare(packageName, caller);
-        }
-
-        @Override
-        public void prepareFromMediaId(String packageName, ControllerCallbackLink caller,
-                String mediaId, Bundle extras) {
-            mControllerStub.prepareFromMediaId(packageName, caller, mediaId, extras);
-        }
-
-        @Override
-        public void prepareFromSearch(String packageName, ControllerCallbackLink caller,
-                String query, Bundle extras) {
-            mControllerStub.prepareFromSearch(packageName, caller, query, extras);
-        }
-
-        @Override
-        public void prepareFromUri(String packageName, ControllerCallbackLink caller,
-                Uri uri, Bundle extras) {
-            mControllerStub.prepareFromUri(packageName, caller, uri, extras);
-        }
-
-        @Override
-        public void play(String packageName, ControllerCallbackLink caller) {
-            mControllerStub.play(packageName, caller);
-        }
-
-        @Override
-        public void playFromMediaId(String packageName, ControllerCallbackLink caller,
-                String mediaId, Bundle extras) {
-            mControllerStub.playFromMediaId(packageName, caller, mediaId, extras);
-        }
-
-        @Override
-        public void playFromSearch(String packageName, ControllerCallbackLink caller,
-                String query, Bundle extras) {
-            mControllerStub.playFromSearch(packageName, caller, query, extras);
-        }
-
-        @Override
-        public void playFromUri(String packageName, ControllerCallbackLink caller,
-                Uri uri, Bundle extras) {
-            mControllerStub.playFromUri(packageName, caller, uri, extras);
-        }
-
-        @Override
-        public void skipToQueueItem(String packageName, ControllerCallbackLink caller, long id) {
-            mControllerStub.skipToQueueItem(packageName, caller, id);
-        }
-
-        @Override
-        public void pause(String packageName, ControllerCallbackLink caller) {
-            mControllerStub.pause(packageName, caller);
-        }
-
-        @Override
-        public void stop(String packageName, ControllerCallbackLink caller) {
-            mControllerStub.stop(packageName, caller);
-        }
-
-        @Override
-        public void next(String packageName, ControllerCallbackLink caller) {
-            mControllerStub.next(packageName, caller);
-        }
-
-        @Override
-        public void previous(String packageName, ControllerCallbackLink caller) {
-            mControllerStub.previous(packageName, caller);
-        }
-
-        @Override
-        public void fastForward(String packageName, ControllerCallbackLink caller) {
-            mControllerStub.fastForward(packageName, caller);
-        }
-
-        @Override
-        public void rewind(String packageName, ControllerCallbackLink caller) {
-            mControllerStub.rewind(packageName, caller);
-        }
-
-        @Override
-        public void seekTo(String packageName, ControllerCallbackLink caller, long pos) {
-            mControllerStub.seekTo(packageName, caller, pos);
-        }
-
-        @Override
-        public void rate(String packageName, ControllerCallbackLink caller, Rating rating) {
-            mControllerStub.rate(packageName, caller, rating);
-        }
-
-        @Override
-        public void setPlaybackSpeed(String packageName, ControllerCallbackLink caller,
-                float speed) {
-            mControllerStub.setPlaybackSpeed(packageName, caller, speed);
-        }
-
-        @Override
-        public void sendCustomAction(String packageName, ControllerCallbackLink caller,
-                String action, Bundle args) {
-            mControllerStub.sendCustomAction(packageName, caller, action, args);
-        }
-
-        @Override
-        public MediaMetadata getMetadata() {
-            return mControllerStub.getMetadata();
-        }
-
-        @Override
-        public PlaybackState getPlaybackState() {
-            return mControllerStub.getPlaybackState();
-        }
-
-        @Override
-        public MediaParceledListSlice getQueue() {
-            List<MediaSession.QueueItem> queue = mControllerStub.getQueue();
-            return queue == null ? null : new MediaParceledListSlice(queue);
-        }
-
-        @Override
-        public CharSequence getQueueTitle() {
-            return mControllerStub.getQueueTitle();
-        }
-
-        @Override
-        public Bundle getExtras() {
-            return mControllerStub.getExtras();
-        }
-
-        @Override
-        public int getRatingType() {
-            return mControllerStub.getRatingType();
-        }
-    }
-}
diff --git a/media/java/android/media/session/ISession.aidl b/media/java/android/media/session/ISession.aidl
index 9b1ad7b..fcde95a 100644
--- a/media/java/android/media/session/ISession.aidl
+++ b/media/java/android/media/session/ISession.aidl
@@ -19,7 +19,7 @@
 import android.media.AudioAttributes;
 import android.media.MediaMetadata;
 import android.media.MediaParceledListSlice;
-import android.media.session.ControllerLink;
+import android.media.session.ISessionController;
 import android.media.session.PlaybackState;
 import android.media.session.MediaSession;
 import android.os.Bundle;
@@ -31,7 +31,7 @@
  */
 interface ISession {
     void sendEvent(String event, in Bundle data);
-    ControllerLink getController();
+    ISessionController getController();
     void setFlags(int flags);
     void setActive(boolean active);
     void setMediaButtonReceiver(in PendingIntent mbr);
diff --git a/media/java/android/media/session/MediaController.java b/media/java/android/media/session/MediaController.java
index 7334044..036cd78 100644
--- a/media/java/android/media/session/MediaController.java
+++ b/media/java/android/media/session/MediaController.java
@@ -24,6 +24,7 @@
 import android.media.AudioAttributes;
 import android.media.AudioManager;
 import android.media.MediaMetadata;
+import android.media.MediaParceledListSlice;
 import android.media.Rating;
 import android.media.VolumeProvider;
 import android.media.session.MediaSession.QueueItem;
@@ -34,6 +35,7 @@
 import android.os.Message;
 import android.os.Parcel;
 import android.os.Parcelable;
+import android.os.RemoteException;
 import android.os.ResultReceiver;
 import android.text.TextUtils;
 import android.util.Log;
@@ -67,7 +69,7 @@
     private static final int MSG_UPDATE_EXTRAS = 7;
     private static final int MSG_DESTROYED = 8;
 
-    private final ControllerLink mSessionBinder;
+    private final ISessionController mSessionBinder;
 
     private final MediaSession.Token mToken;
     private final Context mContext;
@@ -95,10 +97,10 @@
         if (token == null) {
             throw new IllegalArgumentException("token shouldn't be null");
         }
-        if (token.getControllerLink() == null) {
-            throw new IllegalArgumentException("token.getControllerLink() shouldn't be null");
+        if (token.getBinder() == null) {
+            throw new IllegalArgumentException("token.getBinder() shouldn't be null");
         }
-        mSessionBinder = token.getControllerLink();
+        mSessionBinder = token.getBinder();
         mTransportControls = new TransportControls();
         mToken = token;
         mContext = context;
@@ -131,7 +133,7 @@
         }
         try {
             return mSessionBinder.sendMediaButton(mContext.getPackageName(), mCbStub, keyEvent);
-        } catch (RuntimeException e) {
+        } catch (RemoteException e) {
             // System is dead. =(
         }
         return false;
@@ -145,7 +147,7 @@
     public @Nullable PlaybackState getPlaybackState() {
         try {
             return mSessionBinder.getPlaybackState();
-        } catch (RuntimeException e) {
+        } catch (RemoteException e) {
             Log.wtf(TAG, "Error calling getPlaybackState.", e);
             return null;
         }
@@ -159,7 +161,7 @@
     public @Nullable MediaMetadata getMetadata() {
         try {
             return mSessionBinder.getMetadata();
-        } catch (RuntimeException e) {
+        } catch (RemoteException e) {
             Log.wtf(TAG, "Error calling getMetadata.", e);
             return null;
         }
@@ -173,8 +175,9 @@
      */
     public @Nullable List<MediaSession.QueueItem> getQueue() {
         try {
-            return mSessionBinder.getQueue();
-        } catch (RuntimeException e) {
+            MediaParceledListSlice list = mSessionBinder.getQueue();
+            return list == null ? null : list.getList();
+        } catch (RemoteException e) {
             Log.wtf(TAG, "Error calling getQueue.", e);
         }
         return null;
@@ -186,7 +189,7 @@
     public @Nullable CharSequence getQueueTitle() {
         try {
             return mSessionBinder.getQueueTitle();
-        } catch (RuntimeException e) {
+        } catch (RemoteException e) {
             Log.wtf(TAG, "Error calling getQueueTitle", e);
         }
         return null;
@@ -198,7 +201,7 @@
     public @Nullable Bundle getExtras() {
         try {
             return mSessionBinder.getExtras();
-        } catch (RuntimeException e) {
+        } catch (RemoteException e) {
             Log.wtf(TAG, "Error calling getExtras", e);
         }
         return null;
@@ -221,7 +224,7 @@
     public int getRatingType() {
         try {
             return mSessionBinder.getRatingType();
-        } catch (RuntimeException e) {
+        } catch (RemoteException e) {
             Log.wtf(TAG, "Error calling getRatingType.", e);
             return Rating.RATING_NONE;
         }
@@ -235,7 +238,7 @@
     public long getFlags() {
         try {
             return mSessionBinder.getFlags();
-        } catch (RuntimeException e) {
+        } catch (RemoteException e) {
             Log.wtf(TAG, "Error calling getFlags.", e);
         }
         return 0;
@@ -249,7 +252,7 @@
     public @Nullable PlaybackInfo getPlaybackInfo() {
         try {
             return mSessionBinder.getVolumeAttributes();
-        } catch (RuntimeException e) {
+        } catch (RemoteException e) {
             Log.wtf(TAG, "Error calling getAudioInfo.", e);
         }
         return null;
@@ -264,7 +267,7 @@
     public @Nullable PendingIntent getSessionActivity() {
         try {
             return mSessionBinder.getLaunchPendingIntent();
-        } catch (RuntimeException e) {
+        } catch (RemoteException e) {
             Log.wtf(TAG, "Error calling getPendingIntent.", e);
         }
         return null;
@@ -297,7 +300,7 @@
             //       AppOpsManager usages.
             mSessionBinder.setVolumeTo(mContext.getPackageName(), mContext.getOpPackageName(),
                     mCbStub, value, flags);
-        } catch (RuntimeException e) {
+        } catch (RemoteException e) {
             Log.wtf(TAG, "Error calling setVolumeTo.", e);
         }
     }
@@ -322,7 +325,7 @@
             //       AppOpsManager usages.
             mSessionBinder.adjustVolume(mContext.getPackageName(), mContext.getOpPackageName(),
                     mCbStub, direction, flags);
-        } catch (RuntimeException e) {
+        } catch (RemoteException e) {
             Log.wtf(TAG, "Error calling adjustVolumeBy.", e);
         }
     }
@@ -388,7 +391,7 @@
         }
         try {
             mSessionBinder.sendCommand(mContext.getPackageName(), mCbStub, command, args, cb);
-        } catch (RuntimeException e) {
+        } catch (RemoteException e) {
             Log.d(TAG, "Dead object in sendCommand.", e);
         }
     }
@@ -402,7 +405,7 @@
         if (mPackageName == null) {
             try {
                 mPackageName = mSessionBinder.getPackageName();
-            } catch (RuntimeException e) {
+            } catch (RemoteException e) {
                 Log.d(TAG, "Dead object in getPackageName.", e);
             }
         }
@@ -419,7 +422,7 @@
         if (mSessionInfo == null) {
             try {
                 mSessionInfo = mSessionBinder.getSessionInfo();
-            } catch (RuntimeException e) {
+            } catch (RemoteException e) {
                 Log.d(TAG, "Dead object in getSessionInfo.", e);
             }
         }
@@ -436,7 +439,7 @@
         if (mTag == null) {
             try {
                 mTag = mSessionBinder.getTag();
-            } catch (RuntimeException e) {
+            } catch (RemoteException e) {
                 Log.d(TAG, "Dead object in getTag.", e);
             }
         }
@@ -446,7 +449,7 @@
     /*
      * @hide
      */
-    ControllerLink getSessionBinder() {
+    ISessionController getSessionBinder() {
         return mSessionBinder;
     }
 
@@ -456,7 +459,7 @@
     @UnsupportedAppUsage
     public boolean controlsSameSession(MediaController other) {
         if (other == null) return false;
-        return mSessionBinder.getBinder() == other.getSessionBinder().getBinder();
+        return mSessionBinder.asBinder() == other.getSessionBinder().asBinder();
     }
 
     private void addCallbackLocked(Callback cb, Handler handler) {
@@ -472,7 +475,7 @@
             try {
                 mSessionBinder.registerCallback(mContext.getPackageName(), mCbStub);
                 mCbRegistered = true;
-            } catch (RuntimeException e) {
+            } catch (RemoteException e) {
                 Log.e(TAG, "Dead object in registerCallback", e);
             }
         }
@@ -491,7 +494,7 @@
         if (mCbRegistered && mCallbacks.size() == 0) {
             try {
                 mSessionBinder.unregisterCallback(mCbStub);
-            } catch (RuntimeException e) {
+            } catch (RemoteException e) {
                 Log.e(TAG, "Dead object in removeCallbackLocked");
             }
             mCbRegistered = false;
@@ -618,7 +621,7 @@
         public void prepare() {
             try {
                 mSessionBinder.prepare(mContext.getPackageName(), mCbStub);
-            } catch (RuntimeException e) {
+            } catch (RemoteException e) {
                 Log.wtf(TAG, "Error calling prepare.", e);
             }
         }
@@ -643,7 +646,7 @@
             try {
                 mSessionBinder.prepareFromMediaId(mContext.getPackageName(), mCbStub, mediaId,
                         extras);
-            } catch (RuntimeException e) {
+            } catch (RemoteException e) {
                 Log.wtf(TAG, "Error calling prepare(" + mediaId + ").", e);
             }
         }
@@ -670,7 +673,7 @@
             try {
                 mSessionBinder.prepareFromSearch(mContext.getPackageName(), mCbStub, query,
                         extras);
-            } catch (RuntimeException e) {
+            } catch (RemoteException e) {
                 Log.wtf(TAG, "Error calling prepare(" + query + ").", e);
             }
         }
@@ -694,7 +697,7 @@
             }
             try {
                 mSessionBinder.prepareFromUri(mContext.getPackageName(), mCbStub, uri, extras);
-            } catch (RuntimeException e) {
+            } catch (RemoteException e) {
                 Log.wtf(TAG, "Error calling prepare(" + uri + ").", e);
             }
         }
@@ -705,7 +708,7 @@
         public void play() {
             try {
                 mSessionBinder.play(mContext.getPackageName(), mCbStub);
-            } catch (RuntimeException e) {
+            } catch (RemoteException e) {
                 Log.wtf(TAG, "Error calling play.", e);
             }
         }
@@ -725,7 +728,7 @@
             try {
                 mSessionBinder.playFromMediaId(mContext.getPackageName(), mCbStub, mediaId,
                         extras);
-            } catch (RuntimeException e) {
+            } catch (RemoteException e) {
                 Log.wtf(TAG, "Error calling play(" + mediaId + ").", e);
             }
         }
@@ -747,7 +750,7 @@
             }
             try {
                 mSessionBinder.playFromSearch(mContext.getPackageName(), mCbStub, query, extras);
-            } catch (RuntimeException e) {
+            } catch (RemoteException e) {
                 Log.wtf(TAG, "Error calling play(" + query + ").", e);
             }
         }
@@ -766,7 +769,7 @@
             }
             try {
                 mSessionBinder.playFromUri(mContext.getPackageName(), mCbStub, uri, extras);
-            } catch (RuntimeException e) {
+            } catch (RemoteException e) {
                 Log.wtf(TAG, "Error calling play(" + uri + ").", e);
             }
         }
@@ -778,7 +781,7 @@
         public void skipToQueueItem(long id) {
             try {
                 mSessionBinder.skipToQueueItem(mContext.getPackageName(), mCbStub, id);
-            } catch (RuntimeException e) {
+            } catch (RemoteException e) {
                 Log.wtf(TAG, "Error calling skipToItem(" + id + ").", e);
             }
         }
@@ -790,7 +793,7 @@
         public void pause() {
             try {
                 mSessionBinder.pause(mContext.getPackageName(), mCbStub);
-            } catch (RuntimeException e) {
+            } catch (RemoteException e) {
                 Log.wtf(TAG, "Error calling pause.", e);
             }
         }
@@ -802,7 +805,7 @@
         public void stop() {
             try {
                 mSessionBinder.stop(mContext.getPackageName(), mCbStub);
-            } catch (RuntimeException e) {
+            } catch (RemoteException e) {
                 Log.wtf(TAG, "Error calling stop.", e);
             }
         }
@@ -815,7 +818,7 @@
         public void seekTo(long pos) {
             try {
                 mSessionBinder.seekTo(mContext.getPackageName(), mCbStub, pos);
-            } catch (RuntimeException e) {
+            } catch (RemoteException e) {
                 Log.wtf(TAG, "Error calling seekTo.", e);
             }
         }
@@ -827,7 +830,7 @@
         public void fastForward() {
             try {
                 mSessionBinder.fastForward(mContext.getPackageName(), mCbStub);
-            } catch (RuntimeException e) {
+            } catch (RemoteException e) {
                 Log.wtf(TAG, "Error calling fastForward.", e);
             }
         }
@@ -838,7 +841,7 @@
         public void skipToNext() {
             try {
                 mSessionBinder.next(mContext.getPackageName(), mCbStub);
-            } catch (RuntimeException e) {
+            } catch (RemoteException e) {
                 Log.wtf(TAG, "Error calling next.", e);
             }
         }
@@ -850,7 +853,7 @@
         public void rewind() {
             try {
                 mSessionBinder.rewind(mContext.getPackageName(), mCbStub);
-            } catch (RuntimeException e) {
+            } catch (RemoteException e) {
                 Log.wtf(TAG, "Error calling rewind.", e);
             }
         }
@@ -861,7 +864,7 @@
         public void skipToPrevious() {
             try {
                 mSessionBinder.previous(mContext.getPackageName(), mCbStub);
-            } catch (RuntimeException e) {
+            } catch (RemoteException e) {
                 Log.wtf(TAG, "Error calling previous.", e);
             }
         }
@@ -876,7 +879,7 @@
         public void setRating(Rating rating) {
             try {
                 mSessionBinder.rate(mContext.getPackageName(), mCbStub, rating);
-            } catch (RuntimeException e) {
+            } catch (RemoteException e) {
                 Log.wtf(TAG, "Error calling rate.", e);
             }
         }
@@ -889,7 +892,7 @@
         public void setPlaybackSpeed(float speed) {
             try {
                 mSessionBinder.setPlaybackSpeed(mContext.getPackageName(), mCbStub, speed);
-            } catch (RuntimeException e) {
+            } catch (RemoteException e) {
                 Log.wtf(TAG, "Error calling setPlaybackSpeed.", e);
             }
         }
@@ -924,7 +927,7 @@
             }
             try {
                 mSessionBinder.sendCustomAction(mContext.getPackageName(), mCbStub, action, args);
-            } catch (RuntimeException e) {
+            } catch (RemoteException e) {
                 Log.d(TAG, "Dead object in sendCustomAction.", e);
             }
         }
diff --git a/media/java/android/media/session/MediaSession.java b/media/java/android/media/session/MediaSession.java
index c4f8b79..4fc436c 100644
--- a/media/java/android/media/session/MediaSession.java
+++ b/media/java/android/media/session/MediaSession.java
@@ -445,19 +445,19 @@
     public static final class Token implements Parcelable {
 
         private final int mUid;
-        private final ControllerLink mControllerLink;
+        private final ISessionController mBinder;
 
         /**
          * @hide
          */
-        public Token(ControllerLink controllerLink) {
+        public Token(ISessionController binder) {
             mUid = Process.myUid();
-            mControllerLink = controllerLink;
+            mBinder = binder;
         }
 
         Token(Parcel in) {
             mUid = in.readInt();
-            mControllerLink = in.readParcelable(null);
+            mBinder = ISessionController.Stub.asInterface(in.readStrongBinder());
         }
 
         @Override
@@ -468,15 +468,14 @@
         @Override
         public void writeToParcel(Parcel dest, int flags) {
             dest.writeInt(mUid);
-            dest.writeParcelable(mControllerLink, flags);
+            dest.writeStrongBinder(mBinder.asBinder());
         }
 
         @Override
         public int hashCode() {
             final int prime = 31;
             int result = mUid;
-            result = prime * result + ((mControllerLink == null)
-                    ? 0 : mControllerLink.getBinder().hashCode());
+            result = prime * result + (mBinder == null ? 0 : mBinder.asBinder().hashCode());
             return result;
         }
 
@@ -492,7 +491,10 @@
             if (mUid != other.mUid) {
                 return false;
             }
-            return Objects.equals(mControllerLink, other.mControllerLink);
+            if (mBinder == null || other.mBinder == null) {
+                return mBinder == other.mBinder;
+            }
+            return Objects.equals(mBinder.asBinder(), other.mBinder.asBinder());
         }
 
         /**
@@ -504,11 +506,11 @@
         }
 
         /**
-         * Gets the controller link in this token.
+         * Gets the controller binder in this token.
          * @hide
          */
-        public ControllerLink getControllerLink() {
-            return mControllerLink;
+        public ISessionController getBinder() {
+            return mBinder;
         }
 
         public static final @android.annotation.NonNull Parcelable.Creator<Token> CREATOR =
diff --git a/media/java/android/media/session/SessionLink.java b/media/java/android/media/session/SessionLink.java
index 2b42a2d..a47c262 100644
--- a/media/java/android/media/session/SessionLink.java
+++ b/media/java/android/media/session/SessionLink.java
@@ -83,10 +83,10 @@
     }
 
     /**
-     * Gets the controller link from the system.
+     * Gets the controller binder from the system.
      */
     @NonNull
-    ControllerLink getController() {
+    ISessionController getController() {
         try {
             return mISession.getController();
         } catch (RemoteException e) {
@@ -304,7 +304,7 @@
 
         /** Stub method for ISession.getController */
         @NonNull
-        public ControllerLink getController() {
+        public ISessionController getController() {
             return null;
         }
 
@@ -373,7 +373,7 @@
         }
 
         @Override
-        public ControllerLink getController() {
+        public ISessionController getController() {
             return mSessionStub.getController();
         }
 
diff --git a/services/core/java/com/android/server/media/MediaSessionRecord.java b/services/core/java/com/android/server/media/MediaSessionRecord.java
index 152cf7f..192ad6d 100644
--- a/services/core/java/com/android/server/media/MediaSessionRecord.java
+++ b/services/core/java/com/android/server/media/MediaSessionRecord.java
@@ -24,10 +24,11 @@
 import android.media.AudioManagerInternal;
 import android.media.AudioSystem;
 import android.media.MediaMetadata;
+import android.media.MediaParceledListSlice;
 import android.media.Rating;
 import android.media.VolumeProvider;
 import android.media.session.ControllerCallbackLink;
-import android.media.session.ControllerLink;
+import android.media.session.ISessionController;
 import android.media.session.MediaController;
 import android.media.session.MediaController.PlaybackInfo;
 import android.media.session.MediaSession;
@@ -78,7 +79,7 @@
     private final String mPackageName;
     private final String mTag;
     private final Bundle mSessionInfo;
-    private final ControllerLink mController;
+    private final ControllerStub mController;
     private final MediaSession.Token mSessionToken;
     private final SessionLink mSession;
     private final SessionCb mSessionCb;
@@ -130,7 +131,7 @@
         mPackageName = ownerPackageName;
         mTag = tag;
         mSessionInfo = sessionInfo;
-        mController = new ControllerLink(new ControllerStub());
+        mController = new ControllerStub();
         mSessionToken = new MediaSession.Token(mController);
         mSession = new SessionLink(new SessionStub());
         mSessionCb = new SessionCb(cb);
@@ -152,11 +153,11 @@
     }
 
     /**
-     * Get the controller link for the {@link MediaController}.
+     * Get the controller binder for the {@link MediaController}.
      *
-     * @return The controller link apps talk to.
+     * @return The controller binder apps talk to.
      */
-    public ControllerLink getControllerLink() {
+    public ISessionController getControllerBinder() {
         return mController;
     }
 
@@ -835,7 +836,7 @@
         }
 
         @Override
-        public ControllerLink getController() {
+        public ISessionController getController() {
             return mController;
         }
 
@@ -1248,7 +1249,7 @@
         }
     }
 
-    class ControllerStub extends ControllerLink.ControllerStub {
+    class ControllerStub extends ISessionController.Stub {
         @Override
         public void sendCommand(String packageName, ControllerCallbackLink caller,
                 String command, Bundle args, ResultReceiver cb) {
@@ -1488,9 +1489,9 @@
         }
 
         @Override
-        public List<QueueItem> getQueue() {
+        public MediaParceledListSlice getQueue() {
             synchronized (mLock) {
-                return mQueue;
+                return mQueue == null ? null : new MediaParceledListSlice<>(mQueue);
             }
         }
 
diff --git a/services/core/java/com/android/server/media/MediaSessionStack.java b/services/core/java/com/android/server/media/MediaSessionStack.java
index 9ba50ee..a5e7d8e 100644
--- a/services/core/java/com/android/server/media/MediaSessionStack.java
+++ b/services/core/java/com/android/server/media/MediaSessionStack.java
@@ -144,7 +144,7 @@
      */
     public MediaSessionRecord getMediaSessionRecord(MediaSession.Token sessionToken) {
         for (MediaSessionRecord record : mSessions) {
-            if (Objects.equals(record.getControllerLink(), sessionToken.getControllerLink())) {
+            if (Objects.equals(record.getControllerBinder(), sessionToken.getBinder())) {
                 return record;
             }
         }