summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Tetiana Meronyk <tetianameronyk@google.com> 2023-11-03 12:48:59 +0000
committer Tetiana Meronyk <tetianameronyk@google.com> 2023-11-09 14:49:12 +0000
commit19b39a778cda416ce45c49ca1d7a41ae6da2d03f (patch)
tree2330cad94869d69090a51603044b5428254471d4
parent3e992962ca35300ffcf3cc492071b9ec9555085e (diff)
Disable multiuser toggle on COPE device and add explanation dialog
Bug: 304359233 Test: manual Change-Id: I226ad8e7ae579dc77d77b764c0cb343062898c3e
-rw-r--r--packages/SettingsLib/src/com/android/settingslib/RestrictedLockUtilsInternal.java26
1 files changed, 26 insertions, 0 deletions
diff --git a/packages/SettingsLib/src/com/android/settingslib/RestrictedLockUtilsInternal.java b/packages/SettingsLib/src/com/android/settingslib/RestrictedLockUtilsInternal.java
index 03d1cda9c071..e77964c6fa0c 100644
--- a/packages/SettingsLib/src/com/android/settingslib/RestrictedLockUtilsInternal.java
+++ b/packages/SettingsLib/src/com/android/settingslib/RestrictedLockUtilsInternal.java
@@ -243,6 +243,32 @@ public class RestrictedLockUtilsInternal extends RestrictedLockUtils {
}
/**
+ * Checks whether add user is disabled on the device
+ *
+ * @param context {@link Context} for the calling user.
+ *
+ *
+ * @param userId User to check enforced admin status for.
+ *
+ * @return EnforcedAdmin Object containing the enforced admin component and admin user details,
+ * or {@code null} If adding user is not disabled.
+ */
+ public static EnforcedAdmin checkIfAddUserDisallowed(Context context, int userId) {
+ final UserManager um = UserManager.get(context);
+ if (!um.hasUserRestriction(UserManager.DISALLOW_ADD_USER, UserHandle.of(userId))) {
+ // Restriction is not enforced.
+ return null;
+ }
+ EnforcedAdmin enforcedAdmin = checkIfRestrictionEnforced(context,
+ UserManager.DISALLOW_ADD_USER, userId);
+ if (enforcedAdmin != null) {
+ return enforcedAdmin;
+ }
+ return EnforcedAdmin.createDefaultEnforcedAdminWithRestriction(
+ UserManager.DISALLOW_ADD_USER);
+ }
+
+ /**
* Check if an application is suspended.
*
* @return EnforcedAdmin Object containing the enforced admin component and admin user details,