From 7c7cecec4a44e7567cd103dfccb1b550d0e1a93f Mon Sep 17 00:00:00 2001 From: Stuart Scott Date: Mon, 20 Apr 2015 14:07:45 -0700 Subject: [PATCH] Network Reset should have a lockdown like Factory Reset. bug:20332322 Change-Id: I7c61a011d11e89513757f112abf320bb2a785edb --- .../android/server/ConnectivityService.java | 35 ++++++++++++------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java index 7ac26556b9..f848f6500f 100644 --- a/services/core/java/com/android/server/ConnectivityService.java +++ b/services/core/java/com/android/server/ConnectivityService.java @@ -4602,27 +4602,36 @@ public class ConnectivityService extends IConnectivityManager.Stub @Override public void factoryReset() { enforceConnectivityInternalPermission(); + + if (mUserManager.hasUserRestriction(UserManager.DISALLOW_NETWORK_RESET)) { + return; + } + final int userId = UserHandle.getCallingUserId(); // Turn airplane mode off setAirplaneMode(false); - // Untether - for (String tether : getTetheredIfaces()) { - untether(tether); + if (!mUserManager.hasUserRestriction(UserManager.DISALLOW_CONFIG_TETHERING)) { + // Untether + for (String tether : getTetheredIfaces()) { + untether(tether); + } } - // Turn VPN off - VpnConfig vpnConfig = getVpnConfig(userId); - if (vpnConfig != null) { - if (vpnConfig.legacy) { - prepareVpn(VpnConfig.LEGACY_VPN, VpnConfig.LEGACY_VPN, userId); - } else { - // Prevent this app (packagename = vpnConfig.user) from initiating VPN connections - // in the future without user intervention. - setVpnPackageAuthorization(vpnConfig.user, userId, false); + if (!mUserManager.hasUserRestriction(UserManager.DISALLOW_CONFIG_VPN)) { + // Turn VPN off + VpnConfig vpnConfig = getVpnConfig(userId); + if (vpnConfig != null) { + if (vpnConfig.legacy) { + prepareVpn(VpnConfig.LEGACY_VPN, VpnConfig.LEGACY_VPN, userId); + } else { + // Prevent this app (packagename = vpnConfig.user) from initiating VPN connections + // in the future without user intervention. + setVpnPackageAuthorization(vpnConfig.user, userId, false); - prepareVpn(vpnConfig.user, VpnConfig.LEGACY_VPN, userId); + prepareVpn(vpnConfig.user, VpnConfig.LEGACY_VPN, userId); + } } } }