summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Rubin Xu <rubinxu@google.com> 2024-03-08 14:41:01 +0000
committer Rubin Xu <rubinxu@google.com> 2024-03-14 16:23:39 +0000
commit0887244b4a282eaa926cbd5e7d8b83bfe77c177c (patch)
tree90f46df8b09b32cd003d611e8eba04bc014a603c
parent6ec9ecf78d24fdc4a86f39f41eb3cf28a2a4ef78 (diff)
Expose DISALLOW_ADD_PRIVATE_PROFILE
Allow profile owner of COPE devices to block private space by setting DISALLOW_ADD_PRIVATE_PROFILE on the parent user. Bug: 328758346 Test: PrivateProfileTest Test: UserRestrictionsUtilsTest Change-Id: Ibb3bf03378d0eafbafec01a9211f0ad931524b98
-rw-r--r--core/api/current.txt1
-rw-r--r--core/java/android/os/UserManager.java9
-rw-r--r--services/core/java/com/android/server/pm/UserRestrictionsUtils.java6
-rw-r--r--services/tests/servicestests/src/com/android/server/pm/UserRestrictionsUtilsTest.java6
4 files changed, 11 insertions, 11 deletions
diff --git a/core/api/current.txt b/core/api/current.txt
index 7552b5c00acc..99b8b9ee779b 100644
--- a/core/api/current.txt
+++ b/core/api/current.txt
@@ -33960,6 +33960,7 @@ package android.os {
method public static boolean supportsMultipleUsers();
field public static final String ALLOW_PARENT_PROFILE_APP_LINKING = "allow_parent_profile_app_linking";
field @Deprecated public static final String DISALLOW_ADD_MANAGED_PROFILE = "no_add_managed_profile";
+ field @FlaggedApi("android.os.allow_private_profile") public static final String DISALLOW_ADD_PRIVATE_PROFILE = "no_add_private_profile";
field public static final String DISALLOW_ADD_USER = "no_add_user";
field public static final String DISALLOW_ADD_WIFI_CONFIG = "no_add_wifi_config";
field public static final String DISALLOW_ADJUST_VOLUME = "no_adjust_volume";
diff --git a/core/java/android/os/UserManager.java b/core/java/android/os/UserManager.java
index fdaa0b467566..9e9bbdbd2c97 100644
--- a/core/java/android/os/UserManager.java
+++ b/core/java/android/os/UserManager.java
@@ -1024,7 +1024,11 @@ public class UserManager {
/**
* Specifies if a user is disallowed from creating a private profile.
* <p>The default value for an unmanaged user is <code>false</code>.
- * For users with a device owner set, the default is <code>true</code>.
+ * For users with a device owner set, the default value is <code>true</code> and the
+ * device owner currently cannot change it to <code>false</code>.
+ * On organization-owned managed profile devices, the default value is <code>false</code> but
+ * the profile owner can change it to <code>true</code> via the parent profile to block creating
+ * of private profiles on the personal user.
*
* <p>Holders of the permission
* {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_PROFILES}
@@ -1034,9 +1038,10 @@ public class UserManager {
* <p>Type: Boolean
* @see DevicePolicyManager#addUserRestriction(ComponentName, String)
* @see DevicePolicyManager#clearUserRestriction(ComponentName, String)
+ * @see DevicePolicyManager#getParentProfileInstance(ComponentName)
* @see #getUserRestrictions()
- * @hide
*/
+ @FlaggedApi(android.os.Flags.FLAG_ALLOW_PRIVATE_PROFILE)
public static final String DISALLOW_ADD_PRIVATE_PROFILE = "no_add_private_profile";
/**
diff --git a/services/core/java/com/android/server/pm/UserRestrictionsUtils.java b/services/core/java/com/android/server/pm/UserRestrictionsUtils.java
index c9fd2610bfb7..19191374f12a 100644
--- a/services/core/java/com/android/server/pm/UserRestrictionsUtils.java
+++ b/services/core/java/com/android/server/pm/UserRestrictionsUtils.java
@@ -217,8 +217,7 @@ public class UserRestrictionsUtils {
private static final Set<String> IMMUTABLE_BY_OWNERS = Sets.newArraySet(
UserManager.DISALLOW_RECORD_AUDIO,
UserManager.DISALLOW_WALLPAPER,
- UserManager.DISALLOW_OEM_UNLOCK,
- UserManager.DISALLOW_ADD_PRIVATE_PROFILE
+ UserManager.DISALLOW_OEM_UNLOCK
);
/**
@@ -293,7 +292,8 @@ public class UserRestrictionsUtils {
UserManager.DISALLOW_USB_FILE_TRANSFER,
UserManager.DISALLOW_MOUNT_PHYSICAL_MEDIA,
UserManager.DISALLOW_UNMUTE_MICROPHONE,
- UserManager.DISALLOW_CONFIG_DEFAULT_APPS
+ UserManager.DISALLOW_CONFIG_DEFAULT_APPS,
+ UserManager.DISALLOW_ADD_PRIVATE_PROFILE
);
/**
diff --git a/services/tests/servicestests/src/com/android/server/pm/UserRestrictionsUtilsTest.java b/services/tests/servicestests/src/com/android/server/pm/UserRestrictionsUtilsTest.java
index e249cd7311cf..55c48e07162b 100644
--- a/services/tests/servicestests/src/com/android/server/pm/UserRestrictionsUtilsTest.java
+++ b/services/tests/servicestests/src/com/android/server/pm/UserRestrictionsUtilsTest.java
@@ -90,8 +90,6 @@ public class UserRestrictionsUtilsTest {
public void testCanDeviceOwnerChange() {
assertFalse(UserRestrictionsUtils.canDeviceOwnerChange(UserManager.DISALLOW_RECORD_AUDIO));
assertFalse(UserRestrictionsUtils.canDeviceOwnerChange(UserManager.DISALLOW_WALLPAPER));
- assertFalse(UserRestrictionsUtils.canDeviceOwnerChange(
- UserManager.DISALLOW_ADD_PRIVATE_PROFILE));
assertTrue(UserRestrictionsUtils.canDeviceOwnerChange(UserManager.DISALLOW_ADD_USER));
assertTrue(UserRestrictionsUtils.canDeviceOwnerChange(UserManager.DISALLOW_USER_SWITCH));
}
@@ -110,10 +108,6 @@ public class UserRestrictionsUtilsTest {
UserManager.DISALLOW_USER_SWITCH,
true,
false));
- assertFalse(UserRestrictionsUtils.canProfileOwnerChange(
- UserManager.DISALLOW_ADD_PRIVATE_PROFILE,
- true,
- false));
assertTrue(UserRestrictionsUtils.canProfileOwnerChange(
UserManager.DISALLOW_ADD_USER,
true,