From 33ecd1bca766416bb8e7d5bd4cdf12cc4d3d6445 Mon Sep 17 00:00:00 2001 From: Tobias Lindskog Date: Mon, 12 Mar 2018 15:44:47 +0100 Subject: Catch double unbind of dead service If a service receives onBindingDied after it has successfully connected once, unbindService would be called once from the onBindingDied and then again from registerServiceLocked when the service was rebound. This second attempt would typically crash. The first unbindService call has a try/catch, add one around the second call as well. Fixes: 78345567 Test: Manual. Boots and reboots without problems. Change-Id: Ie9eabbcb6ee89c05abc565427465cfd6906f3fa3 Merged-In: Ie9eabbcb6ee89c05abc565427465cfd6906f3fa3 --- .../core/java/com/android/server/notification/ManagedServices.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/notification/ManagedServices.java b/services/core/java/com/android/server/notification/ManagedServices.java index 4c8b91baad0a..477b062ac90f 100644 --- a/services/core/java/com/android/server/notification/ManagedServices.java +++ b/services/core/java/com/android/server/notification/ManagedServices.java @@ -926,7 +926,11 @@ abstract public class ManagedServices { Slog.v(TAG, " disconnecting old " + getCaption() + ": " + info.service); removeServiceLocked(i); if (info.connection != null) { - mContext.unbindService(info.connection); + try { + mContext.unbindService(info.connection); + } catch (IllegalArgumentException e) { + Slog.e(TAG, "failed to unbind " + name, e); + } } } } -- cgit v1.2.3-59-g8ed1b