OSDN Git Service

Catch IllegalArgumentException when disconnect
authorSungsoo Lim <sungsoo@google.com>
Thu, 3 Aug 2017 05:01:57 +0000 (14:01 +0900)
committerSungsoo Lim <sungsoo@google.com>
Thu, 3 Aug 2017 05:38:36 +0000 (14:38 +0900)
IllegalArgumentException can happen, if unbindService() is called
after the service is stopped.

Bug: 63439915
Test: Passed MediaBrowserTest
Change-Id: I70ecb9e907af66b9b65960dd4029e55e81639c03

media/java/android/media/browse/MediaBrowser.java

index ece19e4..3d3fcb9 100644 (file)
@@ -256,7 +256,13 @@ public final class MediaBrowser {
      */
     private void forceCloseConnection() {
         if (mServiceConnection != null) {
-            mContext.unbindService(mServiceConnection);
+            try {
+                mContext.unbindService(mServiceConnection);
+            } catch (IllegalArgumentException e) {
+                if (DBG) {
+                    Log.d(TAG, "unbindService failed", e);
+                }
+            }
         }
         mState = CONNECT_STATE_DISCONNECTED;
         mServiceConnection = null;