Merge "Disallow shell to mutate always-on vpn when DISALLOW_CONFIG_VPN user restriction is set" into nyc-dev
This commit is contained in:
@@ -799,7 +799,8 @@ public class SettingsProvider extends ContentProvider {
|
|||||||
|
|
||||||
// If this is a setting that is currently restricted for this user, do not allow
|
// If this is a setting that is currently restricted for this user, do not allow
|
||||||
// unrestricting changes.
|
// unrestricting changes.
|
||||||
if (isGlobalOrSecureSettingRestrictedForUser(name, callingUserId, value)) {
|
if (isGlobalOrSecureSettingRestrictedForUser(name, callingUserId, value,
|
||||||
|
Binder.getCallingUid())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -930,7 +931,8 @@ public class SettingsProvider extends ContentProvider {
|
|||||||
|
|
||||||
// If this is a setting that is currently restricted for this user, do not allow
|
// If this is a setting that is currently restricted for this user, do not allow
|
||||||
// unrestricting changes.
|
// unrestricting changes.
|
||||||
if (isGlobalOrSecureSettingRestrictedForUser(name, callingUserId, value)) {
|
if (isGlobalOrSecureSettingRestrictedForUser(name, callingUserId, value,
|
||||||
|
Binder.getCallingUid())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1153,7 +1155,7 @@ public class SettingsProvider extends ContentProvider {
|
|||||||
* @return true if the change is prohibited, false if the change is allowed.
|
* @return true if the change is prohibited, false if the change is allowed.
|
||||||
*/
|
*/
|
||||||
private boolean isGlobalOrSecureSettingRestrictedForUser(String setting, int userId,
|
private boolean isGlobalOrSecureSettingRestrictedForUser(String setting, int userId,
|
||||||
String value) {
|
String value, int callingUid) {
|
||||||
String restriction;
|
String restriction;
|
||||||
switch (setting) {
|
switch (setting) {
|
||||||
case Settings.Secure.LOCATION_MODE:
|
case Settings.Secure.LOCATION_MODE:
|
||||||
@@ -1191,6 +1193,15 @@ public class SettingsProvider extends ContentProvider {
|
|||||||
restriction = UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS;
|
restriction = UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case Settings.Secure.ALWAYS_ON_VPN_APP:
|
||||||
|
case Settings.Secure.ALWAYS_ON_VPN_LOCKDOWN:
|
||||||
|
// Whitelist system uid (ConnectivityService) and root uid to change always-on vpn
|
||||||
|
if (callingUid == Process.SYSTEM_UID || callingUid == Process.ROOT_UID) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
restriction = UserManager.DISALLOW_CONFIG_VPN;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (setting != null && setting.startsWith(Settings.Global.DATA_ROAMING)) {
|
if (setting != null && setting.startsWith(Settings.Global.DATA_ROAMING)) {
|
||||||
if ("0".equals(value)) return false;
|
if ("0".equals(value)) return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user