diff options
author | Tony Tam <149837+tonytamsf@users.noreply.github.com> | 2021-12-27 08:18:19 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-27 17:18:19 +0100 |
commit | 7768aea11dc9551add8e4f21a2fac5ac51874245 (patch) | |
tree | cce6435496942700f725aa7dce29dff208171f9a /core/src | |
parent | a399702da2e222c586f8f5697076d373b667929a (diff) | |
download | AntennaPod-7768aea11dc9551add8e4f21a2fac5ac51874245.zip |
VPN+Wifi, not treated as metered (#5613)
Diffstat (limited to 'core/src')
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/util/NetworkUtils.java | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/NetworkUtils.java b/core/src/main/java/de/danoeh/antennapod/core/util/NetworkUtils.java index 4cbd8b2c2..63b5db1f9 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/util/NetworkUtils.java +++ b/core/src/main/java/de/danoeh/antennapod/core/util/NetworkUtils.java @@ -96,6 +96,16 @@ public class NetworkUtils { private static boolean isNetworkMetered() { ConnectivityManager connManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); + + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) { + NetworkCapabilities capabilities = connManager.getNetworkCapabilities( + connManager.getActiveNetwork()); + + if (capabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI) + && capabilities.hasTransport(NetworkCapabilities.TRANSPORT_VPN)) { + return false; + } + } return connManager.isActiveNetworkMetered(); } |