|
|
@ -300,10 +300,9 @@ public class ConnectionHelper {
|
|
|
|
|
|
|
|
|
|
|
|
if (caps.hasCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VPN)) {
|
|
|
|
if (caps.hasCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VPN)) {
|
|
|
|
if (!caps.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)) {
|
|
|
|
if (!caps.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)) {
|
|
|
|
Log.i("isMetered: active no internet");
|
|
|
|
Log.i("isMetered: no internet");
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
boolean captive = caps.hasCapability(NetworkCapabilities.NET_CAPABILITY_CAPTIVE_PORTAL);
|
|
|
|
boolean captive = caps.hasCapability(NetworkCapabilities.NET_CAPABILITY_CAPTIVE_PORTAL);
|
|
|
|
if ((require_validated || (require_validated_captive && captive)) &&
|
|
|
|
if ((require_validated || (require_validated_captive && captive)) &&
|
|
|
|
Build.VERSION.SDK_INT >= Build.VERSION_CODES.M &&
|
|
|
|
Build.VERSION.SDK_INT >= Build.VERSION_CODES.M &&
|
|
|
@ -331,23 +330,17 @@ public class ConnectionHelper {
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (caps.hasCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VPN)) {
|
|
|
|
if (standalone_vpn ||
|
|
|
|
|
|
|
|
caps.hasCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VPN)) {
|
|
|
|
// NET_CAPABILITY_NOT_METERED is unreliable on older Android versions
|
|
|
|
// NET_CAPABILITY_NOT_METERED is unreliable on older Android versions
|
|
|
|
boolean metered = cm.isActiveNetworkMetered();
|
|
|
|
boolean metered = cm.isActiveNetworkMetered();
|
|
|
|
Log.i("isMetered: active not VPN metered=" + metered);
|
|
|
|
Log.i("isMetered: active not VPN metered=" + metered);
|
|
|
|
return metered;
|
|
|
|
return metered;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Active network is VPN network
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Network[] networks = cm.getAllNetworks();
|
|
|
|
Network[] networks = cm.getAllNetworks();
|
|
|
|
if (standalone_vpn || (networks != null && networks.length == 1)) {
|
|
|
|
if (networks != null && networks.length == 1) {
|
|
|
|
// Standalone VPN
|
|
|
|
// Standalone VPN
|
|
|
|
if (!caps.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)) {
|
|
|
|
|
|
|
|
Log.i("isMetered: VPN no internet");
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
boolean metered = cm.isActiveNetworkMetered();
|
|
|
|
boolean metered = cm.isActiveNetworkMetered();
|
|
|
|
Log.i("isMetered: active VPN metered=" + metered);
|
|
|
|
Log.i("isMetered: active VPN metered=" + metered);
|
|
|
|
return metered;
|
|
|
|
return metered;
|
|
|
|