Fixed VPNs without INTERNET

pull/153/head
M66B 7 years ago
parent 9890a2f7a4
commit ee9ab905cc

@ -726,17 +726,7 @@ public class Helper {
EntityLog.log(context, "isMetered: no active network"); EntityLog.log(context, "isMetered: no active network");
return null; return null;
} }
/*
NetworkInfo ani = cm.getNetworkInfo(active);
if (log)
EntityLog.log(context, "isMetered: active info=" + ani);
if (ani == null || !ani.isConnected()) {
if (log)
EntityLog.log(context, "isMetered: active network not connected");
return null;
}
*/
NetworkCapabilities caps = cm.getNetworkCapabilities(active); NetworkCapabilities caps = cm.getNetworkCapabilities(active);
if (caps == null) { if (caps == null) {
if (log) if (log)
@ -747,20 +737,21 @@ public class Helper {
if (log) if (log)
EntityLog.log(context, "isMetered: active caps=" + caps); EntityLog.log(context, "isMetered: active caps=" + caps);
if (!caps.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)) { // 21 if (caps.hasCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VPN) &&
!caps.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)) {
if (log) if (log)
EntityLog.log(context, "isMetered: no internet"); EntityLog.log(context, "isMetered: no internet");
return null; return null;
} }
if (!caps.hasCapability(NetworkCapabilities.NET_CAPABILITY_NOT_RESTRICTED)) { // 21 if (!caps.hasCapability(NetworkCapabilities.NET_CAPABILITY_NOT_RESTRICTED)) {
if (log) if (log)
EntityLog.log(context, "isMetered: active restricted"); EntityLog.log(context, "isMetered: active restricted");
return null; return null;
} }
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P && if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P &&
!caps.hasCapability(NetworkCapabilities.NET_CAPABILITY_FOREGROUND)) { // 28 !caps.hasCapability(NetworkCapabilities.NET_CAPABILITY_FOREGROUND)) {
if (log) if (log)
EntityLog.log(context, "isMetered: active background"); EntityLog.log(context, "isMetered: active background");
return null; return null;
@ -779,11 +770,6 @@ public class Helper {
Network[] networks = cm.getAllNetworks(); Network[] networks = cm.getAllNetworks();
if (networks != null) if (networks != null)
for (Network network : networks) { for (Network network : networks) {
/*
NetworkInfo ni = cm.getNetworkInfo(network);
if (log)
Log.i("isMetered: underlying info=" + ni);
*/
caps = cm.getNetworkCapabilities(network); caps = cm.getNetworkCapabilities(network);
if (caps == null) { if (caps == null) {
if (log) if (log)
@ -815,8 +801,6 @@ public class Helper {
if (caps.hasCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VPN)) { if (caps.hasCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VPN)) {
underlying = true; underlying = true;
//if (ni != null && ni.isConnected()) {
if (log) if (log)
Log.i("isMetered: underlying is connected"); Log.i("isMetered: underlying is connected");
@ -825,10 +809,6 @@ public class Helper {
EntityLog.log(context, "isMetered: underlying is unmetered"); EntityLog.log(context, "isMetered: underlying is unmetered");
return false; return false;
} }
//} else {
// if (log)
// Log.i("isMetered: underlying is disconnected");
//}
} }
} }

Loading…
Cancel
Save