summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Eran Messeri <eranm@google.com> 2018-10-05 15:33:53 +0100
committer Eran Messeri <eranm@google.com> 2018-10-15 07:52:26 +0100
commit09b122daacda168799ad6c3dd100e30eebe47bd4 (patch)
tree3285b2038983ad44f1c78548d13e0f0414d90a84
parente976a1324bd87d69e9c31bd1efaa1db66273efd0 (diff)
Private DNS: Add user restriction
Add a user restriction to prevent the user from changing the Private DNS settings. This would be used together with the new DevicePolicyManager API to set the Private DNS settings by the Device Policy Client to enforce Private DNS settings by the IT admin of the user. Bug: 112982691 Test: atest com.android.cts.devicepolicy.DeviceOwnerTest#testPrivateDnsPolicy Test: m -j RunSettingsRoboTests ROBOTEST_FILTER=PrivateDnsModeDialogPreferenceTest Test: Manual, using TestDPC Change-Id: Ibec3cfcede7e4082db4068cbdd047ada3f6c227e
-rwxr-xr-xapi/current.txt1
-rw-r--r--core/java/android/os/UserManager.java15
-rw-r--r--services/core/java/com/android/server/pm/UserRestrictionsUtils.java10
3 files changed, 24 insertions, 2 deletions
diff --git a/api/current.txt b/api/current.txt
index 0b6af293f667..f4b25c1757fb 100755
--- a/api/current.txt
+++ b/api/current.txt
@@ -33739,6 +33739,7 @@ package android.os {
field public static final java.lang.String DISALLOW_CONFIG_LOCALE = "no_config_locale";
field public static final java.lang.String DISALLOW_CONFIG_LOCATION = "no_config_location";
field public static final java.lang.String DISALLOW_CONFIG_MOBILE_NETWORKS = "no_config_mobile_networks";
+ field public static final java.lang.String DISALLOW_CONFIG_PRIVATE_DNS = "disallow_config_private_dns";
field public static final java.lang.String DISALLOW_CONFIG_SCREEN_TIMEOUT = "no_config_screen_timeout";
field public static final java.lang.String DISALLOW_CONFIG_TETHERING = "no_config_tethering";
field public static final java.lang.String DISALLOW_CONFIG_VPN = "no_config_vpn";
diff --git a/core/java/android/os/UserManager.java b/core/java/android/os/UserManager.java
index 8123744281f4..23599105a107 100644
--- a/core/java/android/os/UserManager.java
+++ b/core/java/android/os/UserManager.java
@@ -983,6 +983,21 @@ public class UserManager {
public static final String DISALLOW_PRINTING = "no_printing";
/**
+ * Specifies whether the user is allowed to modify private DNS settings.
+ *
+ * <p>The default value is <code>false</code>.
+ *
+ * <p>This user restriction can only be applied by the Device Owner.
+ * <p>Key for user restrictions.
+ * <p>Type: Boolean
+ * @see DevicePolicyManager#addUserRestriction(ComponentName, String)
+ * @see DevicePolicyManager#clearUserRestriction(ComponentName, String)
+ * @see #getUserRestrictions()
+ */
+ public static final String DISALLOW_CONFIG_PRIVATE_DNS =
+ "disallow_config_private_dns";
+
+ /**
* 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 13155027a387..dd04652a29b3 100644
--- a/services/core/java/com/android/server/pm/UserRestrictionsUtils.java
+++ b/services/core/java/com/android/server/pm/UserRestrictionsUtils.java
@@ -127,7 +127,8 @@ public class UserRestrictionsUtils {
UserManager.DISALLOW_SHARE_INTO_MANAGED_PROFILE,
UserManager.DISALLOW_AMBIENT_DISPLAY,
UserManager.DISALLOW_CONFIG_SCREEN_TIMEOUT,
- UserManager.DISALLOW_PRINTING
+ UserManager.DISALLOW_PRINTING,
+ UserManager.DISALLOW_CONFIG_PRIVATE_DNS
});
/**
@@ -163,7 +164,8 @@ public class UserRestrictionsUtils {
* User restrictions that cannot be set by profile owners. Applied to all users.
*/
private static final Set<String> DEVICE_OWNER_ONLY_RESTRICTIONS = Sets.newArraySet(
- UserManager.DISALLOW_USER_SWITCH
+ UserManager.DISALLOW_USER_SWITCH,
+ UserManager.DISALLOW_CONFIG_PRIVATE_DNS
);
/**
@@ -741,6 +743,10 @@ public class UserRestrictionsUtils {
restriction = UserManager.DISALLOW_CONFIG_SCREEN_TIMEOUT;
break;
+ case android.provider.Settings.Global.PRIVATE_DNS_MODE:
+ case android.provider.Settings.Global.PRIVATE_DNS_SPECIFIER:
+ restriction = UserManager.DISALLOW_CONFIG_PRIVATE_DNS;
+ break;
default:
if (setting.startsWith(Settings.Global.DATA_ROAMING)) {
if ("0".equals(value)) {