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
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user