UserController.getUserInfo outside of mLock
Moves getUserInfo() calls (which call into UserManager and obtain
mUsersLock) outside of the UserController.mLock blocks.
I don't know that doing this inside the mLock block is unsafe, but we
usually make sure to do it outside; to be safe, let's keep doing so.
Actually, getCurrentUserLU() still calls getUserInfo() and is called
inside mLock blocks, and has been that way for ages, so it does appear
to be safe. This cl doesn't touch that method.
Test: boots
Flag: EXEMPT bugfix
Change-Id: I457d1c0bb4fee2913381c24f30172984cc9b923e
diff --git a/services/core/java/com/android/server/am/UserController.java b/services/core/java/com/android/server/am/UserController.java
index a8a9882..5a88364 100644
--- a/services/core/java/com/android/server/am/UserController.java
+++ b/services/core/java/com/android/server/am/UserController.java
@@ -1324,18 +1324,19 @@
private void finishUserStopping(final int userId, final UserState uss,
final boolean allowDelayedLocking) {
+ final UserInfo userInfo = getUserInfo(userId);
EventLog.writeEvent(EventLogTags.UC_FINISH_USER_STOPPING, userId);
synchronized (mLock) {
if (uss.state != UserState.STATE_STOPPING) {
// Whoops, we are being started back up. Abort, abort!
UserJourneySession session = mInjector.getUserJourneyLogger()
- .logUserJourneyFinishWithError(-1, getUserInfo(userId),
+ .logUserJourneyFinishWithError(-1, userInfo,
USER_JOURNEY_USER_STOP, ERROR_CODE_ABORTED);
if (session != null) {
mHandler.removeMessages(CLEAR_USER_JOURNEY_SESSION_MSG, session);
} else {
mInjector.getUserJourneyLogger()
- .logUserJourneyFinishWithError(-1, getUserInfo(userId),
+ .logUserJourneyFinishWithError(-1, userInfo,
USER_JOURNEY_USER_STOP, ERROR_CODE_INVALID_SESSION_ID);
}
return;
@@ -1421,7 +1422,7 @@
+ userId + " callbacks:" + keyEvictedCallbacks);
allowDelayedLocking = false;
}
- userIdToLock = updateUserToLockLU(userId, allowDelayedLocking);
+ userIdToLock = updateUserToLockLU(userInfo, allowDelayedLocking);
if (userIdToLock == UserHandle.USER_NULL) {
lockUser = false;
}
@@ -1561,10 +1562,11 @@
* @return user id to lock. UserHandler.USER_NULL will be returned if no user should be locked.
*/
@GuardedBy("mLock")
- private int updateUserToLockLU(@UserIdInt int userId, boolean allowDelayedLocking) {
+ private int updateUserToLockLU(UserInfo userInfo, boolean allowDelayedLocking) {
+ final int userId = userInfo.id;
if (!canDelayDataLockingForUser(userId)
|| !allowDelayedLocking
- || getUserInfo(userId).isEphemeral()
+ || userInfo.isEphemeral()
|| hasUserRestriction(UserManager.DISALLOW_RUN_IN_BACKGROUND, userId)) {
return userId;
}