Move reset network settings into framework.

bug: 16161518
Change-Id: Ic3b537ebd09d1b9723feff9dcc96e20fda05a94f
This commit is contained in:
Stuart Scott
2015-03-30 13:17:11 -07:00
parent fdf2267b50
commit 0f835acb91

View File

@@ -40,6 +40,7 @@ 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;
@@ -2446,6 +2447,38 @@ public class ConnectivityManager {
} catch (RemoteException e) {}
}
/**
* Resets all connectivity manager settings back to factory defaults.
* @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);
}
}
} catch (RemoteException e) {
// Well, we tried
}
}
/**
* Binds the current process to {@code network}. All Sockets created in the future
* (and not explicitly bound via a bound SocketFactory from