Optimization

This commit is contained in:
M66B 2023-09-05 16:43:45 +02:00
parent 23a53c151c
commit ceb27b6941
1 changed files with 9 additions and 2 deletions

View File

@ -530,8 +530,15 @@ public class ConnectionHelper {
return false;
try {
for (Network network : cm.getAllNetworks()) {
NetworkCapabilities caps = cm.getNetworkCapabilities(network);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
for (Network network : cm.getAllNetworks()) {
NetworkCapabilities caps = cm.getNetworkCapabilities(network);
if (caps != null && caps.hasTransport(NetworkCapabilities.TRANSPORT_VPN))
return true;
}
} else {
Network active = cm.getActiveNetwork();
NetworkCapabilities caps = (active == null ? null : cm.getNetworkCapabilities(active));
if (caps != null && caps.hasTransport(NetworkCapabilities.TRANSPORT_VPN))
return true;
}