Resolver: active network gets high priority
This commit is contained in:
parent
4d0986ee91
commit
aeec76d68b
|
@ -44,20 +44,21 @@ 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<String> tmp = getIPv4First(linkProperties.getDnsServers());
|
||||
servers.addAll(0, tmp);
|
||||
vpnOffset += tmp.size();
|
||||
} else if (hasDefaultRoute(linkProperties)) {
|
||||
} else if (hasDefaultRoute(linkProperties) || isActiveNetwork) {
|
||||
servers.addAll(vpnOffset, getIPv4First(linkProperties.getDnsServers()));
|
||||
} else {
|
||||
servers.addAll(getIPv4First(linkProperties.getDnsServers()));
|
||||
}
|
||||
}
|
||||
}
|
||||
return servers.toArray(new String[servers.size()]);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue