diff --git a/core/java/android/os/UserManager.java b/core/java/android/os/UserManager.java index 8606687d8c689..7d68b44581de8 100644 --- a/core/java/android/os/UserManager.java +++ b/core/java/android/os/UserManager.java @@ -250,6 +250,10 @@ public class UserManager { * use {@link android.accounts.AccountManager} APIs to add or remove accounts when account * management is disallowed. * + *

Holders of the permission + * {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_ACCOUNT_MANAGEMENT} + * can set this restriction using the DevicePolicyManager APIs mentioned below. + * *

Key for user restrictions. *

Type: Boolean * @see DevicePolicyManager#addUserRestriction(ComponentName, String) @@ -267,6 +271,9 @@ public class UserManager { * primary user or by a profile owner of an organization-owned managed profile on the parent * profile, it disallows the primary user from changing Wi-Fi access points. * + *

Holders of the permission {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_WIFI} + * can set this restriction using the DevicePolicyManager APIs mentioned below. + * *

The default value is false. * *

Key for user restrictions. @@ -285,6 +292,9 @@ public class UserManager { * When it is set by any of these owners, it applies globally - i.e., it disables airplane mode * from changing Wi-Fi state. * + *

Holders of the permission {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_WIFI} + * can set this restriction using the DevicePolicyManager APIs mentioned below. + * *

The default value is false. * *

Key for user restrictions. @@ -306,6 +316,9 @@ public class UserManager { * When it is set by any of these owners, it prevents all users from using * Wi-Fi tethering. Other forms of tethering are not affected. * + *

Holders of the permission {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_WIFI} + * can set this restriction using the DevicePolicyManager APIs mentioned below. + * * This user restriction disables only Wi-Fi tethering. * Use {@link #DISALLOW_CONFIG_TETHERING} to limit all forms of tethering. * When {@link #DISALLOW_CONFIG_TETHERING} is set, this user restriction becomes obsolete. @@ -346,6 +359,9 @@ public class UserManager { * sharing Wi-Fi for networks configured by these owners. * Other networks not configured by these owners are not affected. * + *

Holders of the permission {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_WIFI} + * can set this restriction using the DevicePolicyManager APIs mentioned below. + * *

The default value is false. * *

Key for user restrictions. @@ -365,6 +381,9 @@ public class UserManager { * When it is set by any of these owners, it prevents all users from using * Wi-Fi Direct. * + *

Holders of the permission {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_WIFI} + * can set this restriction using the DevicePolicyManager APIs mentioned below. + * *

The default value is false. * *

Key for user restrictions. @@ -384,6 +403,9 @@ public class UserManager { * a new Wi-Fi configuration. This does not limit the owner and carrier's ability * to add a new configuration. * + *

Holders of the permission {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_WIFI} + * can set this restriction using the DevicePolicyManager APIs mentioned below. + * *

The default value is false. * *

Key for user restrictions. @@ -398,6 +420,9 @@ public class UserManager { * Specifies if a user is disallowed from changing the device * language. The default value is false. * + *

Holders of the permission {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_LOCALE} + * can set this restriction using the DevicePolicyManager APIs mentioned below. + * *

Key for user restrictions. *

Type: Boolean * @see DevicePolicyManager#addUserRestriction(ComponentName, String) @@ -411,6 +436,10 @@ public class UserManager { * prevents device owners and profile owners installing apps. The default value is * {@code false}. * + *

Holders of the permission + * {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_APPS_CONTROL} + * can set this restriction using the DevicePolicyManager APIs mentioned below. + * *

Key for user restrictions. *

Type: Boolean * @see DevicePolicyManager#addUserRestriction(ComponentName, String) @@ -423,6 +452,10 @@ public class UserManager { * Specifies if a user is disallowed from uninstalling applications. * The default value is false. * + *

Holders of the permission + * {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_APPS_CONTROL} + * can set this restriction using the DevicePolicyManager APIs mentioned below. + * *

Key for user restrictions. *

Type: Boolean * @see DevicePolicyManager#addUserRestriction(ComponentName, String) @@ -442,6 +475,10 @@ public class UserManager { * managed profile on the parent profile, it prevents the primary user from turning on * location sharing. * + *

Holders of the permission + * {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_LOCATION} + * can set this restriction using the DevicePolicyManager APIs mentioned below. + * *

The default value is false. * *

Key for user restrictions. @@ -460,6 +497,10 @@ public class UserManager { * When it is set by any of these owners, it applies globally - i.e., it disables airplane mode * on the entire device. * + *

Holders of the permission + * {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_AIRPLANE_MODE} + * can set this restriction using the DevicePolicyManager APIs mentioned below. + * *

The default value is false. * *

Key for user restrictions. @@ -476,6 +517,10 @@ public class UserManager { * *

The default value is false. * + *

Holders of the permission + * {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_DISPLAY} + * can set this restriction using the DevicePolicyManager APIs mentioned below. + * *

This user restriction has no effect on managed profiles. *

Key for user restrictions. *

Type: Boolean @@ -490,6 +535,10 @@ public class UserManager { * *

The default value is false. * + *

Holders of the permission + * {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_DISPLAY} + * can set this restriction using the DevicePolicyManager APIs mentioned below. + * *

This user restriction has no effect on managed profiles. *

Key for user restrictions. *

Type: Boolean @@ -504,6 +553,10 @@ public class UserManager { * *

The default value is false. * + *

Holders of the permission + * {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_DISPLAY} + * can set this restriction using the DevicePolicyManager APIs mentioned below. + * *

This user restriction has no effect on managed profiles. *

Key for user restrictions. *

Type: Boolean @@ -519,6 +572,10 @@ public class UserManager { * Unknown sources exclude adb and special apps such as trusted app stores. * The default value is false. * + *

Holders of the permission + * {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_INSTALL_UNKNOWN_SOURCES} + * can set this restriction using the DevicePolicyManager APIs mentioned below. + * *

Key for user restrictions. *

Type: Boolean * @see DevicePolicyManager#addUserRestriction(ComponentName, String) @@ -536,6 +593,10 @@ public class UserManager { * This restriction can be enabled by the profile owner, in which case all accounts and * profiles will be affected. * + *

Holders of the permission + * {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_INSTALL_UNKNOWN_SOURCES} + * can set this restriction using the DevicePolicyManager APIs mentioned below. + * * The default value is false. * *

Key for user restrictions. @@ -559,6 +620,10 @@ public class UserManager { * primary user or by a profile owner of an organization-owned managed profile on the parent * profile, it disallows the primary user from configuring bluetooth. * + *

Holders of the permission + * {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_BLUETOOTH} + * can set this restriction using the DevicePolicyManager APIs mentioned below. + * *

The default value is false. * *

Key for user restrictions. @@ -581,6 +646,10 @@ public class UserManager { * profile, it disables the primary user from using bluetooth and configuring bluetooth * in Settings. * + *

Holders of the permission + * {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_BLUETOOTH} + * can set this restriction using the DevicePolicyManager APIs mentioned below. + * *

The default value is false. * *

Key for user restrictions. @@ -599,6 +668,10 @@ public class UserManager { * profile owner of an organization-owned managed profile on the parent profile, it disables * the primary user from any outgoing bluetooth sharing. * + *

Holders of the permission + * {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_BLUETOOTH} + * can set this restriction using the DevicePolicyManager APIs mentioned below. + * *

Default is true for managed profiles and false otherwise. * *

When a device upgrades to {@link android.os.Build.VERSION_CODES#O}, the system sets it @@ -626,6 +699,10 @@ public class UserManager { * user on the device is able to use file transfer over USB because the UI for file transfer * is always associated with the primary user. * + *

Holders of the permission + * {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_USB_FILE_TRANSFER} + * can set this restriction using the DevicePolicyManager APIs mentioned below. + * *

The default value is false. * *

Key for user restrictions. @@ -640,6 +717,10 @@ public class UserManager { * Specifies if a user is disallowed from configuring user * credentials. The default value is false. * + *

Holders of the permission + * {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_LOCK_CREDENTIALS} + * can set this restriction using the DevicePolicyManager APIs mentioned below. + * *

Key for user restrictions. *

Type: Boolean * @see DevicePolicyManager#addUserRestriction(ComponentName, String) @@ -654,6 +735,10 @@ public class UserManager { * This restriction has no effect on managed profiles. * The default value is false. * + *

Holders of the permission + * {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_USERS} + * can set this restriction using the DevicePolicyManager APIs mentioned below. + * *

Key for user restrictions. *

Type: Boolean * @see DevicePolicyManager#addUserRestriction(ComponentName, String) @@ -692,6 +777,10 @@ public class UserManager { * that user only, including starting activities, making service calls, accessing content * providers, sending broadcasts, installing/uninstalling packages, clearing user data, etc. * + *

Holders of the permission + * {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_DEBUGGING_FEATURES} + * can set this restriction using the DevicePolicyManager APIs mentioned below. + * *

The default value is false. * *

Key for user restrictions. @@ -712,6 +801,10 @@ public class UserManager { *

From Android 12 ({@linkplain android.os.Build.VERSION_CODES#S API level 31}) enforcing * this restriction clears currently active VPN if it was configured by the user. * + *

Holders of the permission + * {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_VPN} + * can set this restriction using the DevicePolicyManager APIs mentioned below. + * *

Key for user restrictions. *

Type: Boolean * @see DevicePolicyManager#addUserRestriction(ComponentName, String) @@ -729,6 +822,10 @@ public class UserManager { * managed profile on the parent profile, it disallows the primary user from turning location * on or off. * + *

Holders of the permission + * {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_LOCATION} + * can set this restriction using the DevicePolicyManager APIs mentioned below. + * *

The default value is false. * *

This user restriction is different from {@link #DISALLOW_SHARE_LOCATION}, @@ -755,6 +852,10 @@ public class UserManager { * from configuring date, time and timezone and disables all configuring of date, time and * timezone in Settings. * + *

Holders of the permission + * {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_TIME} + * can set this restriction using the DevicePolicyManager APIs mentioned below. + * *

The default value is false. * *

Key for user restrictions. @@ -776,6 +877,10 @@ public class UserManager { * the parent profile, it disables the primary user from using Tethering and hotspots and * disables all configuring of Tethering and hotspots in Settings. * + *

Holders of the permission + * {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_MOBILE_NETWORK} + * can set this restriction using the DevicePolicyManager APIs mentioned below. + * *

The default value is false. * *

In Android 9.0 or higher, if tethering is enabled when this restriction is set, @@ -796,6 +901,10 @@ public class UserManager { *

This restriction has no effect on secondary users and managed profiles since only the * primary user can reset the network settings of the device. * + *

Holders of the permission + * {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_MOBILE_NETWORK} + * can set this restriction using the DevicePolicyManager APIs mentioned below. + * *

Key for user restrictions. *

Type: Boolean * @see DevicePolicyManager#addUserRestriction(ComponentName, String) @@ -811,6 +920,10 @@ public class UserManager { *

This restriction has no effect on non-admin users since they cannot factory reset the * device. * + *

Holders of the permission + * {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_FACTORY_RESET} + * can set this restriction using the DevicePolicyManager APIs mentioned below. + * *

Key for user restrictions. *

Type: Boolean * @see DevicePolicyManager#addUserRestriction(ComponentName, String) @@ -827,6 +940,10 @@ public class UserManager { *

When the device is an organization-owned device provisioned with a managed profile, * this restriction will be set as a base restriction which cannot be removed by any admin. * + *

Holders of the permission + * {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_USERS} + * can set this restriction using the DevicePolicyManager APIs mentioned below. + * *

Key for user restrictions. *

Type: Boolean * @see DevicePolicyManager#addUserRestriction(ComponentName, String) @@ -858,6 +975,10 @@ public class UserManager { *

The default value for an unmanaged user is false. * For users with a device owner set, the default is true. * + *

Holders of the permission + * {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_PROFILES} + * can set this restriction using the DevicePolicyManager APIs mentioned below. + * *

Key for user restrictions. *

Type: Boolean * @see DevicePolicyManager#addUserRestriction(ComponentName, String) @@ -876,6 +997,10 @@ public class UserManager { * the system enforces app verification across all users on the device. Running in earlier * Android versions, this restriction affects only the profile that sets it. * + *

Holders of the permission + * {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_INSTALL_UNKNOWN_SOURCES} + * can set this restriction using the DevicePolicyManager APIs mentioned below. + * *

Key for user restrictions. *

Type: Boolean * @see DevicePolicyManager#addUserRestriction(ComponentName, String) @@ -893,6 +1018,10 @@ public class UserManager { * on the primary user or by a profile owner of an organization-owned managed profile on * the parent profile, it disables the primary user from configuring cell broadcasts. * + *

Holders of the permission + * {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_MOBILE_NETWORK} + * can set this restriction using the DevicePolicyManager APIs mentioned below. + * *

The default value is false. * *

This restriction has no effect on secondary users and managed profiles since only the @@ -915,6 +1044,10 @@ public class UserManager { * on the primary user or by a profile owner of an organization-owned managed profile on * the parent profile, it disables the primary user from configuring mobile networks. * + *

Holders of the permission + * {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_MOBILE_NETWORK} + * can set this restriction using the DevicePolicyManager APIs mentioned below. + * *

The default value is false. * *

This restriction has no effect on secondary users and managed profiles since only the @@ -949,6 +1082,10 @@ public class UserManager { * {@link DevicePolicyManager#addPersistentPreferredActivity(ComponentName, IntentFilter, ComponentName)} * to add a default intent handler for a given intent filter. * + *

Holders of the permission + * {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_APPS_CONTROL} + * can set this restriction using the DevicePolicyManager APIs mentioned below. + * *

Key for user restrictions. *

Type: Boolean * @see DevicePolicyManager#addUserRestriction(ComponentName, String) @@ -966,6 +1103,10 @@ public class UserManager { * on the primary user or by a profile owner of an organization-owned managed profile on * the parent profile, it disables the primary user from mounting physical external media. * + *

Holders of the permission + * {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_PHYSICAL_MEDIA} + * can set this restriction using the DevicePolicyManager APIs mentioned below. + * *

The default value is false. * *

Key for user restrictions. @@ -986,6 +1127,10 @@ public class UserManager { * organization-owned managed profile on the parent profile, it will disallow the primary user * from adjusting the microphone volume. * + *

Holders of the permission + * {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_MICROPHONE} + * can set this restriction using the DevicePolicyManager APIs mentioned below. + * *

The default value is false. * *

Key for user restrictions. @@ -1004,6 +1149,10 @@ public class UserManager { *

When the restriction is set by profile owners, then it only applies to relevant * profiles. * + *

Holders of the permission + * {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_AUDIO_OUTPUT} + * can set this restriction using the DevicePolicyManager APIs mentioned below. + * *

This restriction has no effect on managed profiles. *

Key for user restrictions. *

Type: Boolean @@ -1022,6 +1171,10 @@ public class UserManager { * primary user or by a profile owner of an organization-owned managed profile on the parent * profile, it disallows the primary user from making outgoing phone calls. * + *

Holders of the permission + * {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_CALLS} + * can set this restriction using the DevicePolicyManager APIs mentioned below. + * *

The default value is false. * *

Key for user restrictions. @@ -1041,6 +1194,10 @@ public class UserManager { * on the primary user or by a profile owner of an organization-owned managed profile on * the parent profile, it disables the primary user from sending or receiving SMS messages. * + *

Holders of the permission + * {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_SMS} + * can set this restriction using the DevicePolicyManager APIs mentioned below. + * *

The default value is false. * *

Key for user restrictions. @@ -1056,6 +1213,10 @@ public class UserManager { * device owner may wish to prevent the user from experiencing amusement or * joy while using the device. The default value is false. * + *

Holders of the permission + * {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_FUN} + * can set this restriction using the DevicePolicyManager APIs mentioned below. + * *

Key for user restrictions. *

Type: Boolean * @see DevicePolicyManager#addUserRestriction(ComponentName, String) @@ -1073,6 +1234,10 @@ public class UserManager { *

This can only be set by device owners and profile owners on the primary user. * The default value is false. * + *

Holders of the permission + * {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_WINDOWS} + * can set this restriction using the DevicePolicyManager APIs mentioned below. + * *

Key for user restrictions. *

Type: Boolean * @see DevicePolicyManager#addUserRestriction(ComponentName, String) @@ -1091,6 +1256,10 @@ public class UserManager { * the profile owner of the primary user or a secondary user, the restriction affects only the * calling user. This user restriction has no effect on managed profiles. * + *

Holders of the permission + * {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_SYSTEM_DIALOGS} + * can set this restriction using the DevicePolicyManager APIs mentioned below. + * *

Key for user restrictions. *

Type: Boolean * @see DevicePolicyManager#addUserRestriction(ComponentName, String) @@ -1108,6 +1277,10 @@ public class UserManager { * optical character recognition (OCR), we strongly recommend combining this user restriction * with {@link DevicePolicyManager#setScreenCaptureDisabled(ComponentName, boolean)}. * + *

Holders of the permission + * {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_PROFILE_INTERACTION} + * can set this restriction using the DevicePolicyManager APIs mentioned below. + * *

Key for user restrictions. *

Type: Boolean * @see DevicePolicyManager#addUserRestriction(ComponentName, String) @@ -1120,6 +1293,10 @@ public class UserManager { * Specifies if the user is not allowed to use NFC to beam out data from apps. * The default value is false. * + *

Holders of the permission + * {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_NEARBY_COMMUNICATION} + * can set this restriction using the DevicePolicyManager APIs mentioned below. + * *

Key for user restrictions. *

Type: Boolean * @see DevicePolicyManager#addUserRestriction(ComponentName, String) @@ -1145,6 +1322,10 @@ public class UserManager { * are able to set wallpaper regardless of this restriction. * The default value is false. * + *

Holders of the permission + * {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_WALLPAPER} + * can set this restriction using the DevicePolicyManager APIs mentioned below. + * *

Key for user restrictions. *

Type: Boolean * @see DevicePolicyManager#addUserRestriction(ComponentName, String) @@ -1163,6 +1344,10 @@ public class UserManager { * the parent profile, it disables the primary user from rebooting the device into safe * boot mode. * + *

Holders of the permission + * {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_SAFE_BOOT} + * can set this restriction using the DevicePolicyManager APIs mentioned below. + * *

The default value is false. * *

Key for user restrictions. @@ -1191,6 +1376,10 @@ public class UserManager { * *

This restriction can be set by device owners and profile owners. * + *

Holders of the permission + * {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_RUN_IN_BACKGROUND} + * can set this restriction using the DevicePolicyManager APIs mentioned below. + * * @see DevicePolicyManager#addUserRestriction(ComponentName, String) * @see DevicePolicyManager#clearUserRestriction(ComponentName, String) * @see #getUserRestrictions() @@ -1208,6 +1397,10 @@ public class UserManager { * profile owner of an organization-owned managed profile on the parent profile, it disables * the primary user from using camera. * + *

Holders of the permission + * {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_CAMERA} + * can set this restriction using the DevicePolicyManager APIs mentioned below. + * *

The default value is false. * * @see DevicePolicyManager#addUserRestriction(ComponentName, String) @@ -1220,6 +1413,10 @@ public class UserManager { /** * Specifies if a user is not allowed to unmute the device's global volume. * + *

Holders of the permission + * {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_AUDIO_OUTPUT} + * can set this restriction using the DevicePolicyManager APIs mentioned below. + * * @see DevicePolicyManager#setMasterVolumeMuted(ComponentName, boolean) * @see DevicePolicyManager#clearUserRestriction(ComponentName, String) * @see #getUserRestrictions() @@ -1236,6 +1433,10 @@ public class UserManager { * on the primary user or by a profile owner of an organization-owned managed profile on * the parent profile, it disables the primary user from using cellular data when roaming. * + *

Holders of the permission + * {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_MOBILE_NETWORK} + * can set this restriction using the DevicePolicyManager APIs mentioned below. + * *

The default value is false. * * @see DevicePolicyManager#addUserRestriction(ComponentName, String) @@ -1249,6 +1450,10 @@ public class UserManager { * can set this restriction. When it is set by device owner, only the target user will be * affected. The default value is false. * + *

Holders of the permission + * {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_USERS} + * can set this restriction using the DevicePolicyManager APIs mentioned below. + * *

Key for user restrictions. *

Type: Boolean * @see DevicePolicyManager#addUserRestriction(ComponentName, String) @@ -1285,6 +1490,11 @@ public class UserManager { * *

Can be set by profile owners. It only has effect on managed profiles when set by managed * profile owner. Has no effect on non-managed profiles or users. + * + *

Holders of the permission + * {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_LOCK_CREDENTIALS} + * can set this restriction using the DevicePolicyManager APIs mentioned below. + * *

Key for user restrictions. *

Type: Boolean * @see DevicePolicyManager#addUserRestriction(ComponentName, String) @@ -1302,7 +1512,12 @@ public class UserManager { * {@link android.content.Intent#ACTION_VIEW}, * category {@link android.content.Intent#CATEGORY_BROWSABLE}, scheme http or https, and which * define a host can handle intents from the managed profile. - * The default value is false. + * + *

Holders of the permission + * {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_PROFILES} + * can set this restriction using the DevicePolicyManager APIs mentioned below. + * + *

The default value is false. * *

Key for user restrictions. *

Type: Boolean @@ -1319,6 +1534,10 @@ public class UserManager { *

Device owner and profile owner can set this restriction. When it is set by device owner, * only the target user will be affected. * + *

Holders of the permission + * {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_AUTOFILL} + * can set this restriction using the DevicePolicyManager APIs mentioned below. + * *

The default value is false. * * @see DevicePolicyManager#addUserRestriction(ComponentName, String) @@ -1336,6 +1555,10 @@ public class UserManager { * managed profile on the parent profile, it disables the primary user's screen from being * captured for artificial intelligence purposes. * + *

Holders of the permission + * {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_SCREEN_CONTENT} + * can set this restriction using the DevicePolicyManager APIs mentioned below. + * *

The default value is false. * * @see DevicePolicyManager#addUserRestriction(ComponentName, String) @@ -1353,6 +1576,10 @@ public class UserManager { * managed profile on the parent profile, it disables the primary user from receiving content * suggestions for selections based on the contents of their screen. * + *

Holders of the permission + * {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_SCREEN_CONTENT} + * can set this restriction using the DevicePolicyManager APIs mentioned below. + * *

The default value is false. * * @see DevicePolicyManager#addUserRestriction(ComponentName, String) @@ -1369,6 +1596,10 @@ public class UserManager { * {@link DevicePolicyManager#switchUser(ComponentName, UserHandle)} when this restriction is * set. * + *

Holders of the permission + * {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_USERS} + * can set this restriction using the DevicePolicyManager APIs mentioned below. + * *

The default value is false. * * @see DevicePolicyManager#addUserRestriction(ComponentName, String) @@ -1391,7 +1622,12 @@ public class UserManager { * This restriction is only meaningful when set by profile owner. When it is set by device * owner, it does not have any effect. *

- * The default value is false. + * + *

Holders of the permission + * {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_PROFILE_INTERACTION} + * can set this restriction using the DevicePolicyManager APIs mentioned below. + * + *

The default value is false. * * @see DevicePolicyManager#addUserRestriction(ComponentName, String) * @see DevicePolicyManager#clearUserRestriction(ComponentName, String) @@ -1404,6 +1640,10 @@ public class UserManager { * * This restriction can be set by device or profile owner. * + *

Holders of the permission + * {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_PRINTING} + * can set this restriction using the DevicePolicyManager APIs mentioned below. + * * The default value is {@code false}. * * @see DevicePolicyManager#addUserRestriction(ComponentName, String) @@ -1419,6 +1659,10 @@ public class UserManager { * organization-owned managed profile on the parent profile. When it is set by either of these * owners, it applies globally. * + *

Holders of the permission + * {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_RESTRICT_PRIVATE_DNS} + * can set this restriction using the DevicePolicyManager APIs mentioned below. + * *

The default value is false. * *

Key for user restrictions. @@ -1525,6 +1769,10 @@ public class UserManager { * In all cases, the setting applies globally on the device and will prevent the device from * scanning for or connecting to 2g networks, except in the case of an emergency. * + *

Holders of the permission + * {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_MOBILE_NETWORK} + * can set this restriction using the DevicePolicyManager APIs mentioned below. + * *

The default value is false. * * @see DevicePolicyManager#addUserRestriction(ComponentName, String) @@ -1537,15 +1785,19 @@ public class UserManager { * This user restriction specifies if Ultra-wideband is disallowed on the device. If * Ultra-wideband is disallowed it cannot be turned on via Settings. * + *

+ * Ultra-wideband (UWB) is a radio technology that can use a very low energy level + * for short-range, high-bandwidth communications over a large portion of the radio spectrum. + * *

This restriction can only be set by a device owner or a profile owner of an * organization-owned managed profile on the parent profile. * In both cases, the restriction applies globally on the device and will turn off the * ultra-wideband radio if it's currently on and prevent the radio from being turned on in * the future. * - *

- * Ultra-wideband (UWB) is a radio technology that can use a very low energy level - * for short-range, high-bandwidth communications over a large portion of the radio spectrum. + *

Holders of the permission + * {@link android.Manifest.permission#MANAGE_DEVICE_POLICY_NEARBY_COMMUNICATION} + * can set this restriction using the DevicePolicyManager APIs mentioned below. * *

Default is false. * diff --git a/core/tests/coretests/src/android/widget/RemoteViewsTest.java b/core/tests/coretests/src/android/widget/RemoteViewsTest.java index 963014e0bb505..467222696dfb3 100644 --- a/core/tests/coretests/src/android/widget/RemoteViewsTest.java +++ b/core/tests/coretests/src/android/widget/RemoteViewsTest.java @@ -22,7 +22,6 @@ import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.spy; @@ -34,9 +33,6 @@ import android.app.PendingIntent; import android.appwidget.AppWidgetHostView; import android.content.Context; import android.content.Intent; -import android.graphics.Bitmap; -import android.graphics.drawable.BitmapDrawable; -import android.graphics.drawable.Drawable; import android.graphics.drawable.Icon; import android.net.Uri; import android.os.AsyncTask; @@ -90,19 +86,6 @@ public class RemoteViewsTest { mContainer = new LinearLayout(mContext); } - @Test - public void clone_doesNotCopyBitmap() { - RemoteViews original = new RemoteViews(mPackage, R.layout.remote_views_test); - Bitmap bitmap = Bitmap.createBitmap(10, 10, Bitmap.Config.ARGB_8888); - - original.setImageViewBitmap(R.id.image, bitmap); - RemoteViews clone = original.clone(); - View inflated = clone.apply(mContext, mContainer); - - Drawable drawable = ((ImageView) inflated.findViewById(R.id.image)).getDrawable(); - assertSame(bitmap, ((BitmapDrawable)drawable).getBitmap()); - } - @Test public void clone_originalCanStillBeApplied() { RemoteViews original = new RemoteViews(mPackage, R.layout.remote_views_test); diff --git a/packages/SystemUI/src/com/android/systemui/ChooserSelector.kt b/packages/SystemUI/src/com/android/systemui/ChooserSelector.kt deleted file mode 100644 index 227f0ace33dd7..0000000000000 --- a/packages/SystemUI/src/com/android/systemui/ChooserSelector.kt +++ /dev/null @@ -1,81 +0,0 @@ -package com.android.systemui - -import android.content.ComponentName -import android.content.Context -import android.content.pm.PackageManager -import android.util.Log -import com.android.internal.R -import com.android.systemui.dagger.SysUISingleton -import com.android.systemui.dagger.qualifiers.Application -import com.android.systemui.dagger.qualifiers.Background -import com.android.systemui.flags.FeatureFlags -import com.android.systemui.flags.FlagListenable -import com.android.systemui.flags.Flags -import com.android.systemui.settings.UserTracker -import kotlinx.coroutines.CoroutineDispatcher -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.launch -import kotlinx.coroutines.suspendCancellableCoroutine -import kotlinx.coroutines.withContext -import javax.inject.Inject - -@SysUISingleton -class ChooserSelector @Inject constructor( - private val context: Context, - private val userTracker: UserTracker, - private val featureFlags: FeatureFlags, - @Application private val coroutineScope: CoroutineScope, - @Background private val bgDispatcher: CoroutineDispatcher, -) : CoreStartable { - - private val chooserComponent = ComponentName.unflattenFromString( - context.resources.getString(R.string.config_chooserActivity)) - - override fun start() { - coroutineScope.launch { - val listener = FlagListenable.Listener { event -> - if (event.flagName == Flags.CHOOSER_UNBUNDLED.name) { - launch { updateUnbundledChooserEnabled() } - event.requestNoRestart() - } - } - featureFlags.addListener(Flags.CHOOSER_UNBUNDLED, listener) - updateUnbundledChooserEnabled() - - awaitCancellationAndThen { featureFlags.removeListener(listener) } - } - } - - private suspend fun updateUnbundledChooserEnabled() { - setUnbundledChooserEnabled(withContext(bgDispatcher) { - featureFlags.isEnabled(Flags.CHOOSER_UNBUNDLED) - }) - } - - private fun setUnbundledChooserEnabled(enabled: Boolean) { - val newState = if (enabled) { - PackageManager.COMPONENT_ENABLED_STATE_ENABLED - } else { - PackageManager.COMPONENT_ENABLED_STATE_DISABLED - } - userTracker.userProfiles.forEach { - try { - context.createContextAsUser(it.userHandle, /* flags = */ 0).packageManager - .setComponentEnabledSetting(chooserComponent, newState, /* flags = */ 0) - } catch (e: IllegalArgumentException) { - Log.w( - "ChooserSelector", - "Unable to set IntentResolver enabled=$enabled for user ${it.id}", - e, - ) - } - } - } - - suspend inline fun awaitCancellation(): Nothing = suspendCancellableCoroutine { } - suspend inline fun awaitCancellationAndThen(block: () -> Unit): Nothing = try { - awaitCancellation() - } finally { - block() - } -} diff --git a/packages/SystemUI/src/com/android/systemui/dagger/SystemUICoreStartableModule.kt b/packages/SystemUI/src/com/android/systemui/dagger/SystemUICoreStartableModule.kt index 5d6479ef4532a..fe54d34c1f677 100644 --- a/packages/SystemUI/src/com/android/systemui/dagger/SystemUICoreStartableModule.kt +++ b/packages/SystemUI/src/com/android/systemui/dagger/SystemUICoreStartableModule.kt @@ -17,7 +17,6 @@ package com.android.systemui.dagger import com.android.keyguard.KeyguardBiometricLockoutLogger -import com.android.systemui.ChooserSelector import com.android.systemui.CoreStartable import com.android.systemui.LatencyTester import com.android.systemui.ScreenDecorations @@ -84,12 +83,6 @@ abstract class SystemUICoreStartableModule { service: BiometricNotificationService ): CoreStartable - /** Inject into ChooserCoreStartable. */ - @Binds - @IntoMap - @ClassKey(ChooserSelector::class) - abstract fun bindChooserSelector(sysui: ChooserSelector): CoreStartable - /** Inject into ClipboardListener. */ @Binds @IntoMap diff --git a/packages/SystemUI/tests/src/com/android/systemui/ChooserSelectorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/ChooserSelectorTest.kt deleted file mode 100644 index babbe451dd6ab..0000000000000 --- a/packages/SystemUI/tests/src/com/android/systemui/ChooserSelectorTest.kt +++ /dev/null @@ -1,215 +0,0 @@ -package com.android.systemui - -import android.content.ComponentName -import android.content.Context -import android.content.pm.PackageManager -import android.content.pm.UserInfo -import android.content.res.Resources -import android.testing.AndroidTestingRunner -import androidx.test.filters.SmallTest -import com.android.systemui.flags.FeatureFlags -import com.android.systemui.flags.Flag -import com.android.systemui.flags.FlagListenable -import com.android.systemui.flags.Flags -import com.android.systemui.flags.ReleasedFlag -import com.android.systemui.flags.UnreleasedFlag -import com.android.systemui.settings.UserTracker -import com.android.systemui.util.mockito.any -import com.android.systemui.util.mockito.eq -import com.android.systemui.util.mockito.kotlinArgumentCaptor -import com.android.systemui.util.mockito.whenever -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.cancel -import kotlinx.coroutines.test.TestCoroutineDispatcher -import org.junit.After -import org.junit.Before -import org.junit.Test -import org.junit.runner.RunWith -import org.mockito.Mock -import org.mockito.Mockito.anyInt -import org.mockito.Mockito.clearInvocations -import org.mockito.Mockito.never -import org.mockito.Mockito.times -import org.mockito.Mockito.verify -import org.mockito.Mockito.verifyZeroInteractions -import org.mockito.MockitoAnnotations - -@OptIn(ExperimentalCoroutinesApi::class) -@RunWith(AndroidTestingRunner::class) -@SmallTest -class ChooserSelectorTest : SysuiTestCase() { - - private val flagListener = kotlinArgumentCaptor() - - private val testDispatcher = TestCoroutineDispatcher() - private val testScope = CoroutineScope(testDispatcher) - - private lateinit var chooserSelector: ChooserSelector - - @Mock private lateinit var mockContext: Context - @Mock private lateinit var mockProfileContext: Context - @Mock private lateinit var mockUserTracker: UserTracker - @Mock private lateinit var mockPackageManager: PackageManager - @Mock private lateinit var mockResources: Resources - @Mock private lateinit var mockFeatureFlags: FeatureFlags - - @Before - fun setup() { - MockitoAnnotations.initMocks(this) - - whenever(mockContext.createContextAsUser(any(), anyInt())).thenReturn(mockProfileContext) - whenever(mockContext.resources).thenReturn(mockResources) - whenever(mockProfileContext.packageManager).thenReturn(mockPackageManager) - whenever(mockResources.getString(anyInt())).thenReturn( - ComponentName("TestPackage", "TestClass").flattenToString()) - whenever(mockUserTracker.userProfiles).thenReturn(listOf(UserInfo(), UserInfo())) - - chooserSelector = ChooserSelector( - mockContext, - mockUserTracker, - mockFeatureFlags, - testScope, - testDispatcher, - ) - } - - @After - fun tearDown() { - testDispatcher.cleanupTestCoroutines() - } - - @Test - fun initialize_registersFlagListenerUntilScopeCancelled() { - // Arrange - - // Act - chooserSelector.start() - - // Assert - verify(mockFeatureFlags).addListener( - eq>(Flags.CHOOSER_UNBUNDLED), - flagListener.capture(), - ) - verify(mockFeatureFlags, never()).removeListener(any()) - - // Act - testScope.cancel() - - // Assert - verify(mockFeatureFlags).removeListener(eq(flagListener.value)) - } - - @Test - fun initialize_enablesUnbundledChooser_whenFlagEnabled() { - // Arrange - setFlagMock(true) - - // Act - chooserSelector.start() - - // Assert - verify(mockPackageManager, times(2)).setComponentEnabledSetting( - eq(ComponentName("TestPackage", "TestClass")), - eq(PackageManager.COMPONENT_ENABLED_STATE_ENABLED), - anyInt(), - ) - } - - @Test - fun initialize_disablesUnbundledChooser_whenFlagDisabled() { - // Arrange - setFlagMock(false) - - // Act - chooserSelector.start() - - // Assert - verify(mockPackageManager, times(2)).setComponentEnabledSetting( - eq(ComponentName("TestPackage", "TestClass")), - eq(PackageManager.COMPONENT_ENABLED_STATE_DISABLED), - anyInt(), - ) - } - - @Test - fun enablesUnbundledChooser_whenFlagBecomesEnabled() { - // Arrange - setFlagMock(false) - chooserSelector.start() - verify(mockFeatureFlags).addListener( - eq>(Flags.CHOOSER_UNBUNDLED), - flagListener.capture(), - ) - verify(mockPackageManager, never()).setComponentEnabledSetting( - any(), - eq(PackageManager.COMPONENT_ENABLED_STATE_ENABLED), - anyInt(), - ) - - // Act - setFlagMock(true) - flagListener.value.onFlagChanged(TestFlagEvent(Flags.CHOOSER_UNBUNDLED.name)) - - // Assert - verify(mockPackageManager, times(2)).setComponentEnabledSetting( - eq(ComponentName("TestPackage", "TestClass")), - eq(PackageManager.COMPONENT_ENABLED_STATE_ENABLED), - anyInt(), - ) - } - - @Test - fun disablesUnbundledChooser_whenFlagBecomesDisabled() { - // Arrange - setFlagMock(true) - chooserSelector.start() - verify(mockFeatureFlags).addListener( - eq>(Flags.CHOOSER_UNBUNDLED), - flagListener.capture(), - ) - verify(mockPackageManager, never()).setComponentEnabledSetting( - any(), - eq(PackageManager.COMPONENT_ENABLED_STATE_DISABLED), - anyInt(), - ) - - // Act - setFlagMock(false) - flagListener.value.onFlagChanged(TestFlagEvent(Flags.CHOOSER_UNBUNDLED.name)) - - // Assert - verify(mockPackageManager, times(2)).setComponentEnabledSetting( - eq(ComponentName("TestPackage", "TestClass")), - eq(PackageManager.COMPONENT_ENABLED_STATE_DISABLED), - anyInt(), - ) - } - - @Test - fun doesNothing_whenAnotherFlagChanges() { - // Arrange - setFlagMock(false) - chooserSelector.start() - verify(mockFeatureFlags).addListener( - eq>(Flags.CHOOSER_UNBUNDLED), - flagListener.capture(), - ) - clearInvocations(mockPackageManager) - - // Act - flagListener.value.onFlagChanged(TestFlagEvent("other flag")) - - // Assert - verifyZeroInteractions(mockPackageManager) - } - - private fun setFlagMock(enabled: Boolean) { - whenever(mockFeatureFlags.isEnabled(any())).thenReturn(enabled) - whenever(mockFeatureFlags.isEnabled(any())).thenReturn(enabled) - } - - private class TestFlagEvent(override val flagName: String) : FlagListenable.FlagEvent { - override fun requestNoRestart() {} - } -}