Merge "Allow disconnecting always-on VPNs" into nyc-dev

am: 1932aa9

* commit '1932aa95d45ec05758ca376d89def368dcd3c921':
  Allow disconnecting always-on VPNs

Change-Id: I53d63ecf276210582baf568dd4fc9c5aa607f8b3
This commit is contained in:
Robin Lee
2016-04-14 16:58:41 +00:00
committed by android-build-merger
2 changed files with 8 additions and 10 deletions

View File

@@ -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;
}
}

View File

@@ -299,11 +299,6 @@ public class VpnSettings extends RestrictedSettingsFragment implements
return true;
} else if (preference instanceof AppPreference) {
AppPreference pref = (AppPreference) preference;
if (pref.isAlwaysOn()) {
// User can't disconnect vpn when always-on is enabled
return true;
}
boolean connected = (pref.getState() == AppPreference.STATE_CONNECTED);
if (!connected) {