Loading media/java/android/service/media/MediaBrowserService.java +17 −13 Original line number Diff line number Diff line Loading @@ -107,6 +107,10 @@ public abstract class MediaBrowserService extends Service { private final ServiceState mServiceState = new ServiceState(); // Holds the connection record associated with the currently executing callback operation, if // any. See getCurrentBrowserInfo for an example. Must only be accessed on mHandler. @Nullable private ConnectionRecord mCurrentConnectionOnHandler; /** * All the info about a connection. */ Loading Loading @@ -462,12 +466,12 @@ public abstract class MediaBrowserService extends Service { * @see MediaBrowserService.BrowserRoot#EXTRA_SUGGESTED */ public final Bundle getBrowserRootHints() { ConnectionRecord curConnection = mServiceState.mCurConnection; if (curConnection == null) { ConnectionRecord currentConnection = mCurrentConnectionOnHandler; if (currentConnection == null) { throw new IllegalStateException("This should be called inside of onGetRoot or" + " onLoadChildren or onLoadItem methods"); } return curConnection.rootHints == null ? null : new Bundle(curConnection.rootHints); return currentConnection.rootHints == null ? null : new Bundle(currentConnection.rootHints); } /** Loading @@ -478,12 +482,13 @@ public abstract class MediaBrowserService extends Service { * @see MediaSessionManager#isTrustedForMediaControl(RemoteUserInfo) */ public final RemoteUserInfo getCurrentBrowserInfo() { ConnectionRecord curConnection = mServiceState.mCurConnection; if (curConnection == null) { ConnectionRecord currentConnection = mCurrentConnectionOnHandler; if (currentConnection == null) { throw new IllegalStateException("This should be called inside of onGetRoot or" + " onLoadChildren or onLoadItem methods"); } return new RemoteUserInfo(curConnection.pkg, curConnection.pid, curConnection.uid); return new RemoteUserInfo( currentConnection.pkg, currentConnection.pid, currentConnection.uid); } /** Loading Loading @@ -622,7 +627,6 @@ public abstract class MediaBrowserService extends Service { // Fields accessed from mHandler only. @NonNull private final ArrayMap<IBinder, ConnectionRecord> mConnections = new ArrayMap<>(); @Nullable private ConnectionRecord mCurConnection; public void postOnHandler(Runnable runnable) { mHandler.post(runnable); Loading Loading @@ -705,7 +709,7 @@ public abstract class MediaBrowserService extends Service { // Temporarily sets a placeholder ConnectionRecord to make getCurrentBrowserInfo() work // in onGetRoot(). mCurConnection = mCurrentConnectionOnHandler = new ConnectionRecord( /* serviceState= */ this, pkg, Loading @@ -715,7 +719,7 @@ public abstract class MediaBrowserService extends Service { callbacks, /* root= */ null); BrowserRoot root = onGetRoot(pkg, uid, rootHints); mCurConnection = null; mCurrentConnectionOnHandler = null; // If they didn't return something, don't allow this client. if (root == null) { Loading Loading @@ -831,13 +835,13 @@ public abstract class MediaBrowserService extends Service { } }; mCurConnection = connection; mCurrentConnectionOnHandler = connection; if (options == null) { onLoadChildren(parentId, result); } else { onLoadChildren(parentId, result, options); } mCurConnection = null; mCurrentConnectionOnHandler = null; if (!result.isDone()) { throw new IllegalStateException( Loading Loading @@ -886,9 +890,9 @@ public abstract class MediaBrowserService extends Service { } }; mCurConnection = connection; mCurrentConnectionOnHandler = connection; onLoadItem(itemId, result); mCurConnection = null; mCurrentConnectionOnHandler = null; if (!result.isDone()) { throw new IllegalStateException( Loading Loading
media/java/android/service/media/MediaBrowserService.java +17 −13 Original line number Diff line number Diff line Loading @@ -107,6 +107,10 @@ public abstract class MediaBrowserService extends Service { private final ServiceState mServiceState = new ServiceState(); // Holds the connection record associated with the currently executing callback operation, if // any. See getCurrentBrowserInfo for an example. Must only be accessed on mHandler. @Nullable private ConnectionRecord mCurrentConnectionOnHandler; /** * All the info about a connection. */ Loading Loading @@ -462,12 +466,12 @@ public abstract class MediaBrowserService extends Service { * @see MediaBrowserService.BrowserRoot#EXTRA_SUGGESTED */ public final Bundle getBrowserRootHints() { ConnectionRecord curConnection = mServiceState.mCurConnection; if (curConnection == null) { ConnectionRecord currentConnection = mCurrentConnectionOnHandler; if (currentConnection == null) { throw new IllegalStateException("This should be called inside of onGetRoot or" + " onLoadChildren or onLoadItem methods"); } return curConnection.rootHints == null ? null : new Bundle(curConnection.rootHints); return currentConnection.rootHints == null ? null : new Bundle(currentConnection.rootHints); } /** Loading @@ -478,12 +482,13 @@ public abstract class MediaBrowserService extends Service { * @see MediaSessionManager#isTrustedForMediaControl(RemoteUserInfo) */ public final RemoteUserInfo getCurrentBrowserInfo() { ConnectionRecord curConnection = mServiceState.mCurConnection; if (curConnection == null) { ConnectionRecord currentConnection = mCurrentConnectionOnHandler; if (currentConnection == null) { throw new IllegalStateException("This should be called inside of onGetRoot or" + " onLoadChildren or onLoadItem methods"); } return new RemoteUserInfo(curConnection.pkg, curConnection.pid, curConnection.uid); return new RemoteUserInfo( currentConnection.pkg, currentConnection.pid, currentConnection.uid); } /** Loading Loading @@ -622,7 +627,6 @@ public abstract class MediaBrowserService extends Service { // Fields accessed from mHandler only. @NonNull private final ArrayMap<IBinder, ConnectionRecord> mConnections = new ArrayMap<>(); @Nullable private ConnectionRecord mCurConnection; public void postOnHandler(Runnable runnable) { mHandler.post(runnable); Loading Loading @@ -705,7 +709,7 @@ public abstract class MediaBrowserService extends Service { // Temporarily sets a placeholder ConnectionRecord to make getCurrentBrowserInfo() work // in onGetRoot(). mCurConnection = mCurrentConnectionOnHandler = new ConnectionRecord( /* serviceState= */ this, pkg, Loading @@ -715,7 +719,7 @@ public abstract class MediaBrowserService extends Service { callbacks, /* root= */ null); BrowserRoot root = onGetRoot(pkg, uid, rootHints); mCurConnection = null; mCurrentConnectionOnHandler = null; // If they didn't return something, don't allow this client. if (root == null) { Loading Loading @@ -831,13 +835,13 @@ public abstract class MediaBrowserService extends Service { } }; mCurConnection = connection; mCurrentConnectionOnHandler = connection; if (options == null) { onLoadChildren(parentId, result); } else { onLoadChildren(parentId, result, options); } mCurConnection = null; mCurrentConnectionOnHandler = null; if (!result.isDone()) { throw new IllegalStateException( Loading Loading @@ -886,9 +890,9 @@ public abstract class MediaBrowserService extends Service { } }; mCurConnection = connection; mCurrentConnectionOnHandler = connection; onLoadItem(itemId, result); mCurConnection = null; mCurrentConnectionOnHandler = null; if (!result.isDone()) { throw new IllegalStateException( Loading