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:
Zim
2020-04-30 13:54:57 +01:00
parent 33696c1cca
commit 0281bcc971

View File

@@ -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);
}
}
}