From 78f9fffca4cbfad50bdb73569bc4f484d84215ab Mon Sep 17 00:00:00 2001 From: Per Edelberg Date: Mon, 30 Aug 2010 20:01:35 +0200 Subject: Handle stopping of services with still bound applications. When a service is stopping we get unbindFinished when all connections are unbinded. If applications are still bound to this Service we will rebind the connection making the service hang in stopping state. This fixed issues with ANR during CTS test android.os.cts.BinderTest#testTransact Change-Id: I9402aebd0d2d0fa3e0e6381fb51d3189d530f31b --- services/java/com/android/server/am/ActivityManagerService.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java index 16cd62beb338..019417c75739 100644 --- a/services/java/com/android/server/am/ActivityManagerService.java +++ b/services/java/com/android/server/am/ActivityManagerService.java @@ -9694,8 +9694,10 @@ public final class ActivityManagerService extends ActivityManagerNative if (DEBUG_SERVICE) Slog.v(TAG, "unbindFinished in " + r + " at " + b + ": apps=" + (b != null ? b.apps.size() : 0)); + + boolean inStopping = mStoppingServices.contains(r); if (b != null) { - if (b.apps.size() > 0) { + if (b.apps.size() > 0 && !inStopping) { // Applications have already bound since the last // unbind, so just rebind right here. requestServiceBindingLocked(r, b, true); @@ -9706,7 +9708,7 @@ public final class ActivityManagerService extends ActivityManagerNative } } - serviceDoneExecutingLocked(r, mStoppingServices.contains(r)); + serviceDoneExecutingLocked(r, inStopping); Binder.restoreCallingIdentity(origId); } -- cgit v1.2.3-59-g8ed1b