Skip to content

Commit 78f9fff

Browse files
Per EdelbergJohan Redestig
authored andcommitted
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
1 parent 69ebb98 commit 78f9fff

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

services/java/com/android/server/am/ActivityManagerService.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9694,8 +9694,10 @@ public void unbindFinished(IBinder token, Intent intent, boolean doRebind) {
96949694
if (DEBUG_SERVICE) Slog.v(TAG, "unbindFinished in " + r
96959695
+ " at " + b + ": apps="
96969696
+ (b != null ? b.apps.size() : 0));
9697+
9698+
boolean inStopping = mStoppingServices.contains(r);
96979699
if (b != null) {
9698-
if (b.apps.size() > 0) {
9700+
if (b.apps.size() > 0 && !inStopping) {
96999701
// Applications have already bound since the last
97009702
// unbind, so just rebind right here.
97019703
requestServiceBindingLocked(r, b, true);
@@ -9706,7 +9708,7 @@ public void unbindFinished(IBinder token, Intent intent, boolean doRebind) {
97069708
}
97079709
}
97089710

9709-
serviceDoneExecutingLocked(r, mStoppingServices.contains(r));
9711+
serviceDoneExecutingLocked(r, inStopping);
97109712

97119713
Binder.restoreCallingIdentity(origId);
97129714
}

0 commit comments

Comments
 (0)