Move factoryReset to service and protect.

bug:16161518
Change-Id: I02d1bbae1887c62ee426e6f03e8bc1f18c6666bf
This commit is contained in:
Stuart Scott
2015-04-02 18:00:02 -07:00
parent d06906840a
commit d546364a81
3 changed files with 29 additions and 23 deletions

View File

@@ -40,7 +40,6 @@ import android.telephony.SubscriptionManager;
import android.util.ArrayMap;
import android.util.Log;
import com.android.internal.net.VpnConfig;
import com.android.internal.telephony.ITelephony;
import com.android.internal.telephony.PhoneConstants;
import com.android.internal.util.Protocol;
@@ -2515,30 +2514,9 @@ public class ConnectivityManager {
* @hide
*/
public void factoryReset() {
// Turn airplane mode off
setAirplaneMode(false);
// Untether
for (String tether : getTetheredIfaces()) {
untether(tether);
}
// Turn VPN off
try {
VpnConfig vpnConfig = mService.getVpnConfig();
if (vpnConfig != null) {
if (vpnConfig.legacy) {
mService.prepareVpn(VpnConfig.LEGACY_VPN, VpnConfig.LEGACY_VPN);
} else {
// Prevent this app from initiating VPN connections in the future without
// user intervention.
mService.setVpnPackageAuthorization(false);
mService.prepareVpn(vpnConfig.user, VpnConfig.LEGACY_VPN);
}
}
mService.factoryReset();
} catch (RemoteException e) {
// Well, we tried
}
}

View File

@@ -164,4 +164,6 @@ interface IConnectivityManager
boolean addVpnAddress(String address, int prefixLength);
boolean removeVpnAddress(String address, int prefixLength);
boolean setUnderlyingNetworksForVpn(in Network[] networks);
void factoryReset();
}

View File

@@ -4444,4 +4444,30 @@ public class ConnectivityService extends IConnectivityManager.Stub
}
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);
}
}
}
}