Merge "Replace 2 synchronized blocks with one in revokeUserAdmin method"

This commit is contained in:
Tetiana Meronyk
2023-01-11 13:57:00 +00:00
committed by Android (Google) Code Review

View File

@@ -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()) {
// 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));
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;
}
user.info.flags ^= UserInfo.FLAG_ADMIN;
writeUserLP(user);
}
}
}