Allow disconnecting always-on VPNs
Bug: 28072644 Change-Id: If7595f7e17747867158368d95db5addf97d3a14c
This commit is contained in:
@@ -137,11 +137,8 @@ public class AppDialogFragment extends DialogFragment implements AppDialog.Liste
|
||||
private void onDisconnect(final DialogInterface dialog) {
|
||||
final int userId = UserHandle.getUserId(mPackageInfo.applicationInfo.uid);
|
||||
try {
|
||||
final VpnConfig vpnConfig = mService.getVpnConfig(userId);
|
||||
if (vpnConfig == null || vpnConfig.legacy) {
|
||||
return;
|
||||
}
|
||||
if (mPackageInfo.packageName.equals(vpnConfig.user)) {
|
||||
if (mPackageInfo.packageName.equals(getConnectedPackage(mService, userId))) {
|
||||
mService.setAlwaysOnVpnPackage(userId, null);
|
||||
mService.prepareVpn(mPackageInfo.packageName, VpnConfig.LEGACY_VPN, userId);
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
@@ -149,4 +146,10 @@ public class AppDialogFragment extends DialogFragment implements AppDialog.Liste
|
||||
" for user " + userId, e);
|
||||
}
|
||||
}
|
||||
|
||||
private static String getConnectedPackage(IConnectivityManager service, final int userId)
|
||||
throws RemoteException {
|
||||
final VpnConfig config = service.getVpnConfig(userId);
|
||||
return config != null ? config.user : null;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user