mirror of
https://github.com/M66B/FairEmail.git
synced 2025-02-21 21:57:19 +00:00
Auto detect standalone VPN
This commit is contained in:
parent
bb9900e1e8
commit
9872700c56
1 changed files with 8 additions and 1 deletions
|
@ -336,6 +336,14 @@ public class ConnectionHelper {
|
||||||
return metered;
|
return metered;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Network[] networks = cm.getAllNetworks();
|
||||||
|
if (networks != null && networks.length == 1) {
|
||||||
|
// Standalone VPN
|
||||||
|
boolean metered = cm.isActiveNetworkMetered();
|
||||||
|
Log.i("isMetered: active VPN metered=" + metered);
|
||||||
|
return metered;
|
||||||
|
}
|
||||||
|
|
||||||
// VPN: evaluate underlying networks
|
// VPN: evaluate underlying networks
|
||||||
Integer transport = null;
|
Integer transport = null;
|
||||||
if (caps.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR))
|
if (caps.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR))
|
||||||
|
@ -344,7 +352,6 @@ public class ConnectionHelper {
|
||||||
transport = NetworkCapabilities.TRANSPORT_WIFI;
|
transport = NetworkCapabilities.TRANSPORT_WIFI;
|
||||||
|
|
||||||
boolean underlying = false;
|
boolean underlying = false;
|
||||||
Network[] networks = cm.getAllNetworks();
|
|
||||||
for (Network network : networks) {
|
for (Network network : networks) {
|
||||||
caps = cm.getNetworkCapabilities(network);
|
caps = cm.getNetworkCapabilities(network);
|
||||||
if (caps == null) {
|
if (caps == null) {
|
||||||
|
|
Loading…
Reference in a new issue