Implement always-on VPN separate lockdown setting

Allows Settings to control whether always-on VPN is required for the
connection to complete, or if it is offered on a best-efforts basis.

Change-Id: I5eb273a99e7559adc66b05e647c9130a819f99d4
Test: runtest -x tests/app/src/com/android/settings/vpn2/VpnTests.java
Fix: 32420810
This commit is contained in:
Robin Lee
2016-12-16 12:05:04 +00:00
parent fdcd3cfd08
commit e7347dd8c0
6 changed files with 73 additions and 32 deletions

View File

@@ -20,6 +20,7 @@ import android.net.ConnectivityManager;
import android.net.IConnectivityManager;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.provider.Settings;
import android.security.Credentials;
import android.security.KeyStore;
@@ -53,10 +54,14 @@ public class VpnUtils {
return key.equals(getLockdownVpn());
}
public static boolean isAlwaysOnOrLegacyLockdownActive(Context context) {
public static boolean isAnyLockdownActive(Context context) {
final int userId = context.getUserId();
return getLockdownVpn() != null
|| getConnectivityManager(context).getAlwaysOnVpnPackageForUser(userId) != null;
if (getLockdownVpn() != null) {
return true;
}
return getConnectivityManager(context).getAlwaysOnVpnPackageForUser(userId) != null
&& Settings.Secure.getIntForUser(context.getContentResolver(),
Settings.Secure.ALWAYS_ON_VPN_LOCKDOWN, /* default */ 0, userId) != 0;
}
public static boolean isVpnActive(Context context) throws RemoteException {