From b75ad62dc7d0869cccf0cce2064a20fcb1496ae1 Mon Sep 17 00:00:00 2001 From: Stephanie Bak Date: Wed, 10 Nov 2021 02:32:47 +0000 Subject: [PATCH] Adding a new user restriction DISALLOW_SHARING_ADMIN_CONFIGURED_WIFI Bug: 197558754 Test: atest UserRestrictionsTest Change-Id: Id44b0799efe315501976f127b47dc02669782266 --- core/api/current.txt | 1 + core/java/android/os/UserManager.java | 22 +++++++++++++++++++ .../server/pm/UserRestrictionsUtils.java | 4 +++- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/core/api/current.txt b/core/api/current.txt index 667b983dd2ad1..4cc7e04c39fd8 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -32242,6 +32242,7 @@ package android.os { field public static final String DISALLOW_SET_WALLPAPER = "no_set_wallpaper"; field public static final String DISALLOW_SHARE_INTO_MANAGED_PROFILE = "no_sharing_into_profile"; field public static final String DISALLOW_SHARE_LOCATION = "no_share_location"; + field public static final String DISALLOW_SHARING_ADMIN_CONFIGURED_WIFI = "no_sharing_admin_configured_wifi"; field public static final String DISALLOW_SMS = "no_sms"; field public static final String DISALLOW_SYSTEM_ERROR_DIALOGS = "no_system_error_dialogs"; field public static final String DISALLOW_UNIFIED_PASSWORD = "no_unified_password"; diff --git a/core/java/android/os/UserManager.java b/core/java/android/os/UserManager.java index 14d7e822c70bc..26a4fa7e744eb 100644 --- a/core/java/android/os/UserManager.java +++ b/core/java/android/os/UserManager.java @@ -305,6 +305,25 @@ public class UserManager { */ public static final String DISALLOW_WIFI_TETHERING = "no_wifi_tethering"; + /** + * Specifies if users are disallowed from sharing Wi-Fi for admin configured networks. + * + *

Device owner and profile owner can set this restriction. + * When it is set by any of these owners, it prevents all users from + * sharing Wi-Fi for networks configured by these owners. + * Other networks not configured by these owners are not affected. + * + *

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_SHARING_ADMIN_CONFIGURED_WIFI = + "no_sharing_admin_configured_wifi"; + /** * Specifies if a user is disallowed from changing the device * language. The default value is false. @@ -1476,6 +1495,9 @@ public class UserManager { DISALLOW_CAMERA_TOGGLE, KEY_RESTRICTIONS_PENDING, DISALLOW_BIOMETRIC, + DISALLOW_CHANGE_WIFI_STATE, + DISALLOW_WIFI_TETHERING, + DISALLOW_SHARING_ADMIN_CONFIGURED_WIFI, }) @Retention(RetentionPolicy.SOURCE) public @interface UserRestrictionKey {} diff --git a/services/core/java/com/android/server/pm/UserRestrictionsUtils.java b/services/core/java/com/android/server/pm/UserRestrictionsUtils.java index 7f4237410ea91..328a55f729766 100644 --- a/services/core/java/com/android/server/pm/UserRestrictionsUtils.java +++ b/services/core/java/com/android/server/pm/UserRestrictionsUtils.java @@ -142,7 +142,9 @@ public class UserRestrictionsUtils { UserManager.DISALLOW_MICROPHONE_TOGGLE, UserManager.DISALLOW_CAMERA_TOGGLE, UserManager.DISALLOW_CHANGE_WIFI_STATE, - UserManager.DISALLOW_WIFI_TETHERING + UserManager.DISALLOW_WIFI_TETHERING, + UserManager.DISALLOW_SHARING_ADMIN_CONFIGURED_WIFI + }); public static final Set DEPRECATED_USER_RESTRICTIONS = Sets.newArraySet(