SettingsApp Implement DISALLOW_GRANT_ADMIN in user creation flow
In the process of creating a user through the Settings app, if the current user has the DISALLOW_GRANT_ADMIN restriction, the dialogue for granting ADMIN privileges will be hidden after this implementation. This action ensures that even if child users can create SECONDARY users, they cannot create ADMIN users. Design doc: go/unicorn-hsum Bug: 357819541 Test: manually verified the user is not allowed to create ADMIN user when DISALLOW_GRANT_ADMIN restriction is applied. Flag: android.multiuser.unicorn_mode_refactoring_for_hsum_read_only Change-Id: I4b40f83b50d4de0af103d4f5ca400e42345144e0
This commit is contained in:
@@ -919,7 +919,7 @@ public class UserSettings extends SettingsPreferenceFragment
|
|||||||
d = mCreateUserDialogController.createDialog(
|
d = mCreateUserDialogController.createDialog(
|
||||||
getActivity(),
|
getActivity(),
|
||||||
this::startActivityForResult,
|
this::startActivityForResult,
|
||||||
UserManager.isMultipleAdminEnabled(),
|
canCreateAdminUser(),
|
||||||
(userName, userIcon, isAdmin) -> {
|
(userName, userIcon, isAdmin) -> {
|
||||||
mPendingUserIcon = userIcon;
|
mPendingUserIcon = userIcon;
|
||||||
mPendingUserName = userName;
|
mPendingUserName = userName;
|
||||||
@@ -937,6 +937,19 @@ public class UserSettings extends SettingsPreferenceFragment
|
|||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the creation of a new admin user is allowed.
|
||||||
|
* @return {@code true} if creating a new admin is allowed, {@code false} otherwise.
|
||||||
|
*/
|
||||||
|
private boolean canCreateAdminUser() {
|
||||||
|
if (Flags.unicornModeRefactoringForHsumReadOnly()) {
|
||||||
|
return UserManager.isMultipleAdminEnabled()
|
||||||
|
&& !mUserManager.hasUserRestriction(UserManager.DISALLOW_GRANT_ADMIN);
|
||||||
|
} else {
|
||||||
|
return UserManager.isMultipleAdminEnabled();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getDialogMetricsCategory(int dialogId) {
|
public int getDialogMetricsCategory(int dialogId) {
|
||||||
switch (dialogId) {
|
switch (dialogId) {
|
||||||
|
Reference in New Issue
Block a user