Disable always-on VPN in factoryReset
When network setting reset is started while always-on VPN is enabled,
application crash occurs with IllegalStateException in prepareVpn().
Therefore, it's necessary to also disable always-on VPN in factoryReset
before prepareVpn() when turning off VPN.
Bug: 29030858
Change-Id: I08c5406717dd7937d197c2e934a56d037477aafc
diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java
index b383633..bdcce22 100644
--- a/services/core/java/com/android/server/ConnectivityService.java
+++ b/services/core/java/com/android/server/ConnectivityService.java
@@ -5206,6 +5206,18 @@
}
}
+ // Turn Always-on VPN off
+ if (mLockdownEnabled && userId == UserHandle.USER_SYSTEM) {
+ final long ident = Binder.clearCallingIdentity();
+ try {
+ mKeyStore.delete(Credentials.LOCKDOWN_VPN);
+ mLockdownEnabled = false;
+ setLockdownTracker(null);
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+ }
+
// Turn VPN off
VpnConfig vpnConfig = getVpnConfig(userId);
if (vpnConfig != null) {