Check transport of underlying network

pull/184/head
M66B 4 years ago
parent 81fdd8dfe0
commit 998be94fee

@ -236,6 +236,11 @@ public class ConnectionHelper {
} }
// VPN: evaluate underlying networks // VPN: evaluate underlying networks
Integer transport = null;
if (caps.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR))
transport = NetworkCapabilities.TRANSPORT_CELLULAR;
else if (caps.hasTransport(NetworkCapabilities.TRANSPORT_WIFI))
transport = NetworkCapabilities.TRANSPORT_WIFI;
boolean underlying = false; boolean underlying = false;
Network[] networks = cm.getAllNetworks(); Network[] networks = cm.getAllNetworks();
@ -264,6 +269,14 @@ public class ConnectionHelper {
continue; continue;
} }
if (!caps.hasTransport(NetworkCapabilities.TRANSPORT_VPN) &&
(caps.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR) ||
caps.hasTransport(NetworkCapabilities.TRANSPORT_WIFI)) &&
(transport != null && !caps.hasTransport(transport))) {
Log.i("isMetered: underlying other transport");
continue;
}
if (caps.hasCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VPN)) { if (caps.hasCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VPN)) {
underlying = true; underlying = true;
Log.i("isMetered: underlying is connected"); Log.i("isMetered: underlying is connected");

Loading…
Cancel
Save