Merge "UserManagerService:getUserDataLU method should called by mUsersLock lock." into main
diff --git a/services/core/java/com/android/server/pm/UserManagerService.java b/services/core/java/com/android/server/pm/UserManagerService.java
index 0e87396..06e9dab 100644
--- a/services/core/java/com/android/server/pm/UserManagerService.java
+++ b/services/core/java/com/android/server/pm/UserManagerService.java
@@ -1677,26 +1677,27 @@
     public void setUserAdmin(@UserIdInt int userId) {
         checkManageUserAndAcrossUsersFullPermission("set user admin");
         mUserJourneyLogger.logUserJourneyBegin(userId, USER_JOURNEY_GRANT_ADMIN);
-        UserInfo info;
+        UserData user;
         synchronized (mPackagesLock) {
             synchronized (mUsersLock) {
-                info = getUserInfoLU(userId);
-            }
-            if (info == null) {
-                // Exit if no user found with that id,
-                mUserJourneyLogger.logNullUserJourneyError(USER_JOURNEY_GRANT_ADMIN,
+                user = getUserDataLU(userId);
+                if (user == null) {
+                    // Exit if no user found with that id,
+                    mUserJourneyLogger.logNullUserJourneyError(USER_JOURNEY_GRANT_ADMIN,
                         getCurrentUserId(), userId, /* userType */ "", /* userFlags */ -1);
-                return;
-            } else if (info.isAdmin()) {
-                // Exit if the user is already an Admin.
-                mUserJourneyLogger.logUserJourneyFinishWithError(getCurrentUserId(), info,
-                        USER_JOURNEY_GRANT_ADMIN, ERROR_CODE_USER_ALREADY_AN_ADMIN);
-                return;
+                    return;
+                } else if (user.info.isAdmin()) {
+                    // Exit if the user is already an Admin.
+                    mUserJourneyLogger.logUserJourneyFinishWithError(getCurrentUserId(),
+                        user.info, USER_JOURNEY_GRANT_ADMIN,
+                        ERROR_CODE_USER_ALREADY_AN_ADMIN);
+                    return;
+                }
+                user.info.flags ^= UserInfo.FLAG_ADMIN;
+                writeUserLP(user);
             }
-            info.flags ^= UserInfo.FLAG_ADMIN;
-            writeUserLP(getUserDataLU(info.id));
         }
-        mUserJourneyLogger.logUserJourneyFinishWithError(getCurrentUserId(), info,
+        mUserJourneyLogger.logUserJourneyFinishWithError(getCurrentUserId(), user.info,
                 USER_JOURNEY_GRANT_ADMIN, ERROR_CODE_UNSPECIFIED);
     }