Added support for standalone VPNs

Like https://github.com/Genymobile/gnirehtet
This commit is contained in:
M66B
2021-01-03 19:43:01 +01:00
parent 7760d9064a
commit b1e8b450ba
5 changed files with 32 additions and 5 deletions

View File

@@ -265,7 +265,10 @@ public class ConnectionHelper {
return null;
}
if (caps.hasCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VPN)) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean standalone_vpn = prefs.getBoolean("standalone_vpn", false);
if (standalone_vpn ||
caps.hasCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VPN)) {
// NET_CAPABILITY_NOT_METERED is unreliable on older Android versions
boolean metered = cm.isActiveNetworkMetered();
Log.i("isMetered: active not VPN metered=" + metered);