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

Commit b516b591 authored by Anna Bauza's avatar Anna Bauza Committed by Automerger Merge Worker
Browse files

Merge "UserManagerService:getUserDataLU method should called by mUsersLock...

Merge "UserManagerService:getUserDataLU method should called by mUsersLock lock." into main am: 9f425078

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/3043832



Change-Id: I7e33af41b3192a8acdbe6e12cdec0150be83f653
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 794d3af6 9f425078
Loading
Loading
Loading
Loading
+16 −15
Original line number Diff line number Diff line
@@ -1677,26 +1677,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) {
                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()) {
                } else if (user.info.isAdmin()) {
                    // Exit if the user is already an Admin.
                mUserJourneyLogger.logUserJourneyFinishWithError(getCurrentUserId(), info,
                        USER_JOURNEY_GRANT_ADMIN, ERROR_CODE_USER_ALREADY_AN_ADMIN);
                    mUserJourneyLogger.logUserJourneyFinishWithError(getCurrentUserId(),
                        user.info, USER_JOURNEY_GRANT_ADMIN,
                        ERROR_CODE_USER_ALREADY_AN_ADMIN);
                    return;
                }
            info.flags ^= UserInfo.FLAG_ADMIN;
            writeUserLP(getUserDataLU(info.id));
                user.info.flags ^= UserInfo.FLAG_ADMIN;
                writeUserLP(user);
            }
        mUserJourneyLogger.logUserJourneyFinishWithError(getCurrentUserId(), info,
        }
        mUserJourneyLogger.logUserJourneyFinishWithError(getCurrentUserId(), user.info,
                USER_JOURNEY_GRANT_ADMIN, ERROR_CODE_UNSPECIFIED);
    }