Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6c562bbf authored by Rubin Xu's avatar Rubin Xu Committed by Android (Google) Code Review
Browse files

Merge "Expose DISALLOW_ADD_PRIVATE_PROFILE" into main

parents 9ce824ca 0887244b
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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";
+7 −2
Original line number Diff line number Diff line
@@ -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";

    /**
+3 −3
Original line number Diff line number Diff line
@@ -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
    );

    /**
+0 −6
Original line number Diff line number Diff line
@@ -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,