Add DISALLOW_CONFIG_LOCATION_MODE.
Bug: 67674888
Test: cts test will be added in b/67674901
Design doc: https://docs.google.com/document/d/1rvEg5jE3lMhjH-OA0iTLBUY2opM96fg7BrP81MoPnmg/edit#
Change-Id: I284d421eedfb238084fa61e7661638c22b28734f
diff --git a/api/current.txt b/api/current.txt
index 7b203fe..23ba289 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -32279,6 +32279,7 @@
field public static final java.lang.String DISALLOW_CONFIG_CREDENTIALS = "no_config_credentials";
field public static final java.lang.String DISALLOW_CONFIG_DATE_TIME = "no_config_date_time";
field public static final java.lang.String DISALLOW_CONFIG_LOCALE = "no_config_locale";
+ field public static final java.lang.String DISALLOW_CONFIG_LOCATION_MODE = "no_config_location_mode";
field public static final java.lang.String DISALLOW_CONFIG_MOBILE_NETWORKS = "no_config_mobile_networks";
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 75cbd57..9306973 100644
--- a/core/java/android/os/UserManager.java
+++ b/core/java/android/os/UserManager.java
@@ -335,6 +335,28 @@
public static final String DISALLOW_CONFIG_VPN = "no_config_vpn";
/**
+ * Specifies if a user is disallowed from configuring location mode. Device owner and profile
+ * owners can set this restriction and it only applies on the managed user.
+ *
+ * <p>In a managed profile, location sharing is forced off when it's off on primary user, so
+ * user can still turn off location sharing on managed profile when the restriction is set by
+ * profile owner on managed profile.
+ *
+ * <p>This user restriction is different from {@link #DISALLOW_SHARE_LOCATION},
+ * as the device owner or profile owner can still enable or disable location mode via
+ * {@link DevicePolicyManager#setSecureSetting} when this restriction is on.
+ *
+ * <p>The default value is <code>false</code>.
+ *
+ * <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_LOCATION_MODE = "no_config_location_mode";
+
+ /**
* Specifies if date, time and timezone configuring is disallowed.
*
* <p>When restriction is set by device owners, it applies globally - i.e., it disables date,
diff --git a/services/core/java/com/android/server/pm/UserRestrictionsUtils.java b/services/core/java/com/android/server/pm/UserRestrictionsUtils.java
index 4564988..3dedacd 100644
--- a/services/core/java/com/android/server/pm/UserRestrictionsUtils.java
+++ b/services/core/java/com/android/server/pm/UserRestrictionsUtils.java
@@ -115,6 +115,7 @@
UserManager.DISALLOW_AUTOFILL,
UserManager.DISALLOW_USER_SWITCH,
UserManager.DISALLOW_UNIFIED_PASSWORD,
+ UserManager.DISALLOW_CONFIG_LOCATION_MODE
});
/**