Move factoryReset to service and protect.
bug:16161518
Change-Id: I02d1bbae1887c62ee426e6f03e8bc1f18c6666bf
diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java
index b785d3d..4e3abad 100644
--- a/services/core/java/com/android/server/ConnectivityService.java
+++ b/services/core/java/com/android/server/ConnectivityService.java
@@ -4444,4 +4444,30 @@
}
return success;
}
+
+ @Override
+ public void factoryReset() {
+ enforceConnectivityInternalPermission();
+ // Turn airplane mode off
+ setAirplaneMode(false);
+
+ // Untether
+ for (String tether : getTetheredIfaces()) {
+ untether(tether);
+ }
+
+ // Turn VPN off
+ VpnConfig vpnConfig = getVpnConfig();
+ if (vpnConfig != null) {
+ if (vpnConfig.legacy) {
+ prepareVpn(VpnConfig.LEGACY_VPN, VpnConfig.LEGACY_VPN);
+ } else {
+ // Prevent this app from initiating VPN connections in the future without
+ // user intervention.
+ setVpnPackageAuthorization(false);
+
+ prepareVpn(vpnConfig.user, VpnConfig.LEGACY_VPN);
+ }
+ }
+ }
}