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

Commit e9905bd4 authored by RoboErik's avatar RoboErik Committed by Android Git Automerger
Browse files

am f58a9091: Merge "Make setting the session token in MediaBrowserService...

am f58a9091: Merge "Make setting the session token in MediaBrowserService synchronous" into lmp-mr1-dev

* commit 'f58a9091':
  Make setting the session token in MediaBrowserService synchronous
parents 2f6d30df f58a9091
Loading
Loading
Loading
Loading
+5 −7
Original line number Diff line number Diff line
@@ -323,24 +323,22 @@ public abstract class MediaBrowserService extends Service {
     * <p>
     * This should be called as soon as possible during the service's startup.
     * It may only be called once.
     *
     * @return The media session token, must not be null.
     */
    public void setSessionToken(final MediaSession.Token token) {
        if (token == null) {
            throw new IllegalArgumentException("Session token may not be null.");
        }
        mHandler.post(new Runnable() {
            @Override
            public void run() {
        if (mSession != null) {
            throw new IllegalStateException("The session token has already been set.");
        }
        mSession = token;
        mHandler.post(new Runnable() {
            @Override
            public void run() {
                for (IBinder key : mConnections.keySet()) {
                    ConnectionRecord connection = mConnections.get(key);
                    try {
                        connection.callbacks.onConnect(connection.root.getRootId(), mSession,
                        connection.callbacks.onConnect(connection.root.getRootId(), token,
                                connection.root.getExtras());
                    } catch (RemoteException e) {
                        Log.w(TAG, "Connection for " + connection.pkg + " is no longer valid.");