summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Zim <zezeozue@google.com> 2020-04-30 13:54:57 +0100
committer Zim <zezeozue@google.com> 2020-04-30 13:54:57 +0100
commit0281bcc971694f4e18ed00c9a3ed5aa0f0b4740b (patch)
tree2805a48ec817a143ca424ff7f3d3193d52bfeb87
parent33696c1cca08c3e2cc896edb292e3e335005fbfb (diff)
Handle Context#unbindService exception
Unbinding a service for a user that is already stopped will throw a java.lang.IllegalArgumentException: Service not registered: com.android.server.storage.StorageUserConnection$ActiveConnection$1@370cd2c We now handle this to avoid crashing the system Test: m Bug: 152299941 Change-Id: I8a76f760f67716f3cafc320a52bdcdad7bdc5d23
-rw-r--r--services/core/java/com/android/server/storage/StorageUserConnection.java8
1 files changed, 7 insertions, 1 deletions
diff --git a/services/core/java/com/android/server/storage/StorageUserConnection.java b/services/core/java/com/android/server/storage/StorageUserConnection.java
index c207a7b4039b..c18a6ebc32ef 100644
--- a/services/core/java/com/android/server/storage/StorageUserConnection.java
+++ b/services/core/java/com/android/server/storage/StorageUserConnection.java
@@ -242,7 +242,13 @@ public final class StorageUserConnection {
}
if (oldConnection != null) {
- mContext.unbindService(oldConnection);
+ try {
+ mContext.unbindService(oldConnection);
+ } catch (Exception e) {
+ // Handle IllegalArgumentException that may be thrown if the user is already
+ // stopped when we try to unbind
+ Slog.w(TAG, "Failed to unbind service", e);
+ }
}
}