Merge "Fixed race condition by using a separate counter" into nyc-mr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
d2e8ae4a90
@@ -99,6 +99,7 @@ import java.util.HashSet;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper class for {@link ActivityManagerService} responsible for multi-user functionality.
|
* Helper class for {@link ActivityManagerService} responsible for multi-user functionality.
|
||||||
@@ -1057,6 +1058,7 @@ final class UserController {
|
|||||||
uss.switching = true;
|
uss.switching = true;
|
||||||
mCurWaitingUserSwitchCallbacks = curWaitingUserSwitchCallbacks;
|
mCurWaitingUserSwitchCallbacks = curWaitingUserSwitchCallbacks;
|
||||||
}
|
}
|
||||||
|
final AtomicInteger waitingCallbacksCount = new AtomicInteger(observerCount);
|
||||||
for (int i = 0; i < observerCount; i++) {
|
for (int i = 0; i < observerCount; i++) {
|
||||||
try {
|
try {
|
||||||
// Prepend with unique prefix to guarantee that keys are unique
|
// Prepend with unique prefix to guarantee that keys are unique
|
||||||
@@ -1075,7 +1077,7 @@ final class UserController {
|
|||||||
}
|
}
|
||||||
curWaitingUserSwitchCallbacks.remove(name);
|
curWaitingUserSwitchCallbacks.remove(name);
|
||||||
// Continue switching if all callbacks have been notified
|
// Continue switching if all callbacks have been notified
|
||||||
if (curWaitingUserSwitchCallbacks.isEmpty()) {
|
if (waitingCallbacksCount.decrementAndGet() == 0) {
|
||||||
sendContinueUserSwitchLocked(uss, oldUserId, newUserId);
|
sendContinueUserSwitchLocked(uss, oldUserId, newUserId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user