From aeec76d68b9b1eb8fdbe9d627ef6c96f4c5cd89b Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sat, 28 Oct 2017 13:12:11 +0200 Subject: [PATCH] Resolver: active network gets high priority --- .../utils/AndroidUsingLinkProperties.java | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/utils/AndroidUsingLinkProperties.java b/src/main/java/eu/siacs/conversations/utils/AndroidUsingLinkProperties.java index 1be5168a8..d6a9f9a1a 100644 --- a/src/main/java/eu/siacs/conversations/utils/AndroidUsingLinkProperties.java +++ b/src/main/java/eu/siacs/conversations/utils/AndroidUsingLinkProperties.java @@ -44,18 +44,19 @@ public class AndroidUsingLinkProperties extends AbstractDNSServerLookupMechanism int vpnOffset = 0; for(Network network : networks) { LinkProperties linkProperties = connectivityManager.getLinkProperties(network); + if (linkProperties == null) { + continue; + } NetworkInfo networkInfo = connectivityManager.getNetworkInfo(network); final boolean isActiveNetwork = network.equals(activeNetwork); - if (linkProperties != null) { - if (networkInfo != null && isActiveNetwork && networkInfo.getType() == ConnectivityManager.TYPE_VPN) { - final List tmp = getIPv4First(linkProperties.getDnsServers()); - servers.addAll(0, tmp); - vpnOffset += tmp.size(); - } else if (hasDefaultRoute(linkProperties)) { - servers.addAll(vpnOffset, getIPv4First(linkProperties.getDnsServers())); - } else { - servers.addAll(getIPv4First(linkProperties.getDnsServers())); - } + if (networkInfo != null && isActiveNetwork && networkInfo.getType() == ConnectivityManager.TYPE_VPN) { + final List tmp = getIPv4First(linkProperties.getDnsServers()); + servers.addAll(0, tmp); + vpnOffset += tmp.size(); + } else if (hasDefaultRoute(linkProperties) || isActiveNetwork) { + servers.addAll(vpnOffset, getIPv4First(linkProperties.getDnsServers())); + } else { + servers.addAll(getIPv4First(linkProperties.getDnsServers())); } } return servers.toArray(new String[servers.size()]);