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

Commit ce340b8d authored by Tetiana Meronyk's avatar Tetiana Meronyk
Browse files

Replace 2 synchronized blocks with one in revokeUserAdmin method

Bug: 264546208
Test: atest UserManagerServiceTest
Change-Id: Icdb25fe2c570dbab3d7e240e67eb1507fe15019f
parent 2a0fb977
Loading
Loading
Loading
Loading
+7 −12
Original line number Diff line number Diff line
@@ -1476,20 +1476,15 @@ public class UserManagerService extends IUserManager.Stub {
    @Override
    public void revokeUserAdmin(@UserIdInt int userId) {
        checkManageUserAndAcrossUsersFullPermission("revoke admin privileges");

        synchronized (mPackagesLock) {
            UserInfo info;
            synchronized (mUsersLock) {
                info = getUserInfoLU(userId);
            }
            if (info == null || !info.isAdmin()) {
                UserData user = getUserDataLU(userId);
                if (user == null || !user.info.isAdmin()) {
                    // Exit if no user found with that id, or the user is not an Admin.
                    return;
                }

            info.flags ^= UserInfo.FLAG_ADMIN;
            synchronized (mUsersLock) {
                writeUserLP(getUserDataLU(info.id));
                user.info.flags ^= UserInfo.FLAG_ADMIN;
                writeUserLP(user);
            }
        }
    }