Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1932aa95 authored by Robin Lee's avatar Robin Lee Committed by Android (Google) Code Review
Browse files

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

parents 78f1e3de b3c4133a
Loading
Loading
Loading
Loading
+8 −5
Original line number Diff line number Diff line
@@ -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;
    }
}
+0 −5
Original line number Diff line number Diff line
@@ -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) {