summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Fyodor Kupolov <fkupolov@google.com> 2016-06-29 15:59:47 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2016-06-29 15:59:48 +0000
commitd2e8ae4a907a9c8cbb49432f329a2b69fd941495 (patch)
tree0b2988c44cc77fdb6f3af6d54430305c0382c189
parent488153094c7fe7830ae6741675e9d73e27ecef00 (diff)
parent38641831460c80f554dc926e486a67e9b9449b11 (diff)
Merge "Fixed race condition by using a separate counter" into nyc-mr1-dev
-rw-r--r--services/core/java/com/android/server/am/UserController.java4
1 files changed, 3 insertions, 1 deletions
diff --git a/services/core/java/com/android/server/am/UserController.java b/services/core/java/com/android/server/am/UserController.java
index 6b44f14883e5..d25f2cb76d74 100644
--- a/services/core/java/com/android/server/am/UserController.java
+++ b/services/core/java/com/android/server/am/UserController.java
@@ -99,6 +99,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;
+import java.util.concurrent.atomic.AtomicInteger;
/**
* Helper class for {@link ActivityManagerService} responsible for multi-user functionality.
@@ -1057,6 +1058,7 @@ final class UserController {
uss.switching = true;
mCurWaitingUserSwitchCallbacks = curWaitingUserSwitchCallbacks;
}
+ final AtomicInteger waitingCallbacksCount = new AtomicInteger(observerCount);
for (int i = 0; i < observerCount; i++) {
try {
// Prepend with unique prefix to guarantee that keys are unique
@@ -1075,7 +1077,7 @@ final class UserController {
}
curWaitingUserSwitchCallbacks.remove(name);
// Continue switching if all callbacks have been notified
- if (curWaitingUserSwitchCallbacks.isEmpty()) {
+ if (waitingCallbacksCount.decrementAndGet() == 0) {
sendContinueUserSwitchLocked(uss, oldUserId, newUserId);
}
}