Loading media/java/android/media/browse/MediaBrowser.java +71 −51 Original line number Diff line number Diff line Loading @@ -776,7 +776,10 @@ public final class MediaBrowser { */ private class MediaServiceConnection implements ServiceConnection { @Override public void onServiceConnected(ComponentName name, IBinder binder) { public void onServiceConnected(final ComponentName name, final IBinder binder) { postOrRun(new Runnable() { @Override public void run() { if (DBG) { Log.d(TAG, "MediaServiceConnection.onServiceConnected name=" + name + " binder=" + binder); Loading Loading @@ -804,11 +807,13 @@ public final class MediaBrowser { Log.d(TAG, "ServiceCallbacks.onConnect..."); dump(); } mServiceBinder.connect(mContext.getPackageName(), mRootHints, mServiceCallbacks); mServiceBinder.connect(mContext.getPackageName(), mRootHints, mServiceCallbacks); } catch (RemoteException ex) { // Connect failed, which isn't good. But the auto-reconnect on the service // will take over and we will come back. We will also get the // onServiceDisconnected, which has all the cleanup code. So let that do it. // onServiceDisconnected, which has all the cleanup code. So let that do // it. Log.w(TAG, "RemoteException during connect for " + mServiceComponent); if (DBG) { Log.d(TAG, "ServiceCallbacks.onConnect..."); Loading @@ -816,9 +821,14 @@ public final class MediaBrowser { } } } }); } @Override public void onServiceDisconnected(ComponentName name) { public void onServiceDisconnected(final ComponentName name) { postOrRun(new Runnable() { @Override public void run() { if (DBG) { Log.d(TAG, "MediaServiceConnection.onServiceDisconnected name=" + name + " this=" + this + " mServiceConnection=" + mServiceConnection); Loading @@ -839,6 +849,16 @@ public final class MediaBrowser { mState = CONNECT_STATE_SUSPENDED; mCallback.onConnectionSuspended(); } }); } private void postOrRun(Runnable r) { if (Thread.currentThread() == mHandler.getLooper().getThread()) { r.run(); } else { mHandler.post(r); } } /** * Return true if this is the current ServiceConnection. Also logs if it's not. Loading Loading
media/java/android/media/browse/MediaBrowser.java +71 −51 Original line number Diff line number Diff line Loading @@ -776,7 +776,10 @@ public final class MediaBrowser { */ private class MediaServiceConnection implements ServiceConnection { @Override public void onServiceConnected(ComponentName name, IBinder binder) { public void onServiceConnected(final ComponentName name, final IBinder binder) { postOrRun(new Runnable() { @Override public void run() { if (DBG) { Log.d(TAG, "MediaServiceConnection.onServiceConnected name=" + name + " binder=" + binder); Loading Loading @@ -804,11 +807,13 @@ public final class MediaBrowser { Log.d(TAG, "ServiceCallbacks.onConnect..."); dump(); } mServiceBinder.connect(mContext.getPackageName(), mRootHints, mServiceCallbacks); mServiceBinder.connect(mContext.getPackageName(), mRootHints, mServiceCallbacks); } catch (RemoteException ex) { // Connect failed, which isn't good. But the auto-reconnect on the service // will take over and we will come back. We will also get the // onServiceDisconnected, which has all the cleanup code. So let that do it. // onServiceDisconnected, which has all the cleanup code. So let that do // it. Log.w(TAG, "RemoteException during connect for " + mServiceComponent); if (DBG) { Log.d(TAG, "ServiceCallbacks.onConnect..."); Loading @@ -816,9 +821,14 @@ public final class MediaBrowser { } } } }); } @Override public void onServiceDisconnected(ComponentName name) { public void onServiceDisconnected(final ComponentName name) { postOrRun(new Runnable() { @Override public void run() { if (DBG) { Log.d(TAG, "MediaServiceConnection.onServiceDisconnected name=" + name + " this=" + this + " mServiceConnection=" + mServiceConnection); Loading @@ -839,6 +849,16 @@ public final class MediaBrowser { mState = CONNECT_STATE_SUSPENDED; mCallback.onConnectionSuspended(); } }); } private void postOrRun(Runnable r) { if (Thread.currentThread() == mHandler.getLooper().getThread()) { r.run(); } else { mHandler.post(r); } } /** * Return true if this is the current ServiceConnection. Also logs if it's not. Loading