Move factoryReset to service and protect.
bug:16161518 Change-Id: I02d1bbae1887c62ee426e6f03e8bc1f18c6666bf
This commit is contained in:
@@ -40,7 +40,6 @@ import android.telephony.SubscriptionManager;
|
|||||||
import android.util.ArrayMap;
|
import android.util.ArrayMap;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.android.internal.net.VpnConfig;
|
|
||||||
import com.android.internal.telephony.ITelephony;
|
import com.android.internal.telephony.ITelephony;
|
||||||
import com.android.internal.telephony.PhoneConstants;
|
import com.android.internal.telephony.PhoneConstants;
|
||||||
import com.android.internal.util.Protocol;
|
import com.android.internal.util.Protocol;
|
||||||
@@ -2515,30 +2514,9 @@ public class ConnectivityManager {
|
|||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public void factoryReset() {
|
public void factoryReset() {
|
||||||
// Turn airplane mode off
|
|
||||||
setAirplaneMode(false);
|
|
||||||
|
|
||||||
// Untether
|
|
||||||
for (String tether : getTetheredIfaces()) {
|
|
||||||
untether(tether);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Turn VPN off
|
|
||||||
try {
|
try {
|
||||||
VpnConfig vpnConfig = mService.getVpnConfig();
|
mService.factoryReset();
|
||||||
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) {
|
} catch (RemoteException e) {
|
||||||
// Well, we tried
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -164,4 +164,6 @@ interface IConnectivityManager
|
|||||||
boolean addVpnAddress(String address, int prefixLength);
|
boolean addVpnAddress(String address, int prefixLength);
|
||||||
boolean removeVpnAddress(String address, int prefixLength);
|
boolean removeVpnAddress(String address, int prefixLength);
|
||||||
boolean setUnderlyingNetworksForVpn(in Network[] networks);
|
boolean setUnderlyingNetworksForVpn(in Network[] networks);
|
||||||
|
|
||||||
|
void factoryReset();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4444,4 +4444,30 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
}
|
}
|
||||||
return success;
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user