From caf310f26ad6b781b0f3a764ed85712208c7ef5a Mon Sep 17 00:00:00 2001 From: Jason Parks Date: Mon, 7 Nov 2022 16:22:19 +0000 Subject: [PATCH] Add new user restriction for changing default apps. Test: manual Bug: 254268464 Change-Id: I31190ff3cb9e832f934f4e4f34fe90fc3babf8fe --- core/api/current.txt | 1 + core/java/android/os/UserManager.java | 15 +++++++++++++++ .../android/server/pm/UserRestrictionsUtils.java | 3 ++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/core/api/current.txt b/core/api/current.txt index 8caea30bb0927..b40b79f07a876 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -33212,6 +33212,7 @@ package android.os { field public static final String DISALLOW_CONFIG_CELL_BROADCASTS = "no_config_cell_broadcasts"; field public static final String DISALLOW_CONFIG_CREDENTIALS = "no_config_credentials"; field public static final String DISALLOW_CONFIG_DATE_TIME = "no_config_date_time"; + field public static final String DISALLOW_CONFIG_DEFAULT_APPS = "disallow_config_default_apps"; field public static final String DISALLOW_CONFIG_LOCALE = "no_config_locale"; field public static final String DISALLOW_CONFIG_LOCATION = "no_config_location"; field public static final String DISALLOW_CONFIG_MOBILE_NETWORKS = "no_config_mobile_networks"; diff --git a/core/java/android/os/UserManager.java b/core/java/android/os/UserManager.java index 0e4c2b2928d6e..b016c7815ae7f 100644 --- a/core/java/android/os/UserManager.java +++ b/core/java/android/os/UserManager.java @@ -1471,6 +1471,21 @@ public class UserManager { */ public static final String DISALLOW_BIOMETRIC = "disallow_biometric"; + /** + * Specifies whether the user is allowed to modify default apps in settings. + * + *

This restriction can be set by device or profile owner. + * + *

The default value is false. + * + *

Key for user restrictions. + *

Type: Boolean + * @see DevicePolicyManager#addUserRestriction(ComponentName, String) + * @see DevicePolicyManager#clearUserRestriction(ComponentName, String) + * @see #getUserRestrictions() + */ + public static final String DISALLOW_CONFIG_DEFAULT_APPS = "disallow_config_default_apps"; + /** * Application restriction key that is used to indicate the pending arrival * of real restrictions for the app. diff --git a/services/core/java/com/android/server/pm/UserRestrictionsUtils.java b/services/core/java/com/android/server/pm/UserRestrictionsUtils.java index 27d74d517fb94..214fd617c9991 100644 --- a/services/core/java/com/android/server/pm/UserRestrictionsUtils.java +++ b/services/core/java/com/android/server/pm/UserRestrictionsUtils.java @@ -149,7 +149,8 @@ public class UserRestrictionsUtils { UserManager.DISALLOW_WIFI_DIRECT, UserManager.DISALLOW_ADD_WIFI_CONFIG, UserManager.DISALLOW_CELLULAR_2G, - UserManager.DISALLOW_ULTRA_WIDEBAND_RADIO + UserManager.DISALLOW_ULTRA_WIDEBAND_RADIO, + UserManager.DISALLOW_CONFIG_DEFAULT_APPS }); public static final Set DEPRECATED_USER_RESTRICTIONS = Sets.newArraySet(