diff options
| -rw-r--r-- | services/core/java/com/android/server/pm/UserManagerService.java | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/services/core/java/com/android/server/pm/UserManagerService.java b/services/core/java/com/android/server/pm/UserManagerService.java index e3261bd1322a..bb6708ac1d08 100644 --- a/services/core/java/com/android/server/pm/UserManagerService.java +++ b/services/core/java/com/android/server/pm/UserManagerService.java @@ -2005,26 +2005,27 @@ public class UserManagerService extends IUserManager.Stub { 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); } |