Update mUserUnlockedStates locking and docs.

Bug: n/a
Change-Id: If210e0012ebc838183c3ca6b82ded9aae21f62b2
Test: atest UsageStatsTest
This commit is contained in:
Varun Shah
2021-10-07 22:16:18 +00:00
parent 915e5c3302
commit 53ba8ca01c

View File

@@ -381,8 +381,8 @@ public class UsageStatsService extends SystemService implements
UsageStatsIdleService.scheduleUpdateMappingsJob(getContext());
}
synchronized (mLock) {
// This should be safe to add this early. Other than reportEventOrAddToQueue, every
// other user grabs the lock before accessing
// This should be safe to add this early. Other than reportEventOrAddToQueue and
// getBackupPayload, every other user grabs the lock before accessing
// mUserUnlockedStates. reportEventOrAddToQueue does not depend on anything other than
// mUserUnlockedStates, and the lock will protect the handler.
mUserUnlockedStates.add(userId);
@@ -1438,8 +1438,8 @@ public class UsageStatsService extends SystemService implements
}
} else if ("mappings".equals(arg)) {
final IndentingPrintWriter ipw = new IndentingPrintWriter(pw, " ");
final int userId = parseUserIdFromArgs(args, i, ipw);
synchronized (mLock) {
final int userId = parseUserIdFromArgs(args, i, ipw);
if (userId != UserHandle.USER_NULL) {
mUserState.get(userId).dumpMappings(ipw);
}