Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ae3c56e6 authored by Fyodor Kupolov's avatar Fyodor Kupolov Committed by android-build-merger
Browse files

Merge \\"Fixed race condition by using a separate counter\\" into nyc-mr1-dev am: d2e8ae4a

am: a0e3d607

Change-Id: I4ba38ea91cf6f3b867b886bf97d9f4e6287aab6b
parents e271b662 a0e3d607
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -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);
                                }
                            }