Merge "Allow adding a user while still removing other users"
This commit is contained in:
committed by
Android (Google) Code Review
commit
3fa61b671e
@@ -1253,7 +1253,10 @@ public class AppOpsService extends IAppOpsService.Stub {
|
||||
public void removeUser(int userHandle) throws RemoteException {
|
||||
checkSystemUid("removeUser");
|
||||
mOpRestrictions.remove(userHandle);
|
||||
mProfileOwnerUids.removeAt(mProfileOwnerUids.indexOfKey(userHandle));
|
||||
final int index = mProfileOwnerUids.indexOfKey(userHandle);
|
||||
if (index >= 0) {
|
||||
mProfileOwnerUids.removeAt(index);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkSystemUid(String function) {
|
||||
|
||||
@@ -511,8 +511,16 @@ public class UserManagerService extends IUserManager.Stub {
|
||||
* Check if we've hit the limit of how many users can be created.
|
||||
*/
|
||||
private boolean isUserLimitReachedLocked() {
|
||||
int nUsers = mUsers.size();
|
||||
return nUsers >= UserManager.getMaxSupportedUsers();
|
||||
int aliveUserCount = 0;
|
||||
final int totalUserCount = mUsers.size();
|
||||
// Skip over users being removed
|
||||
for (int i = 0; i < totalUserCount; i++) {
|
||||
UserInfo user = mUsers.valueAt(i);
|
||||
if (!mRemovingUserIds.get(user.id)) {
|
||||
aliveUserCount++;
|
||||
}
|
||||
}
|
||||
return aliveUserCount >= UserManager.getMaxSupportedUsers();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user