Simplication

pull/214/head
M66B 12 months ago
parent 46bc3846a5
commit f716f1cad5

@ -24,7 +24,6 @@ import android.net.ConnectivityManager;
import android.net.DnsResolver; import android.net.DnsResolver;
import android.net.LinkProperties; import android.net.LinkProperties;
import android.net.Network; import android.net.Network;
import android.net.NetworkInfo;
import android.os.Build; import android.os.Build;
import android.text.TextUtils; import android.text.TextUtils;
@ -55,12 +54,10 @@ import java.io.IOException;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.UnknownHostException; import java.net.UnknownHostException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Set;
import java.util.concurrent.Executor; import java.util.concurrent.Executor;
import java.util.concurrent.Semaphore; import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -326,25 +323,11 @@ public class DnsHelper {
if (cm == null) if (cm == null)
return result; return result;
LinkProperties props = null; Network active = ConnectionHelper.getActiveNetwork(context);
if (active == null)
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) return result;
for (Network network : cm.getAllNetworks()) {
NetworkInfo ni = cm.getNetworkInfo(network);
if (ni != null && ni.isConnected()) {
props = cm.getLinkProperties(network);
Log.i("Old props=" + props);
break;
}
}
else {
Network active = cm.getActiveNetwork();
if (active == null)
return result;
props = cm.getLinkProperties(active);
Log.i("New props=" + props);
}
LinkProperties props = cm.getLinkProperties(active);
if (props == null) if (props == null)
return result; return result;

Loading…
Cancel
Save