|
|
|
@ -23,6 +23,7 @@ import android.accounts.AccountsException;
|
|
|
|
|
import android.content.Context;
|
|
|
|
|
import android.content.SharedPreferences;
|
|
|
|
|
import android.net.ConnectivityManager;
|
|
|
|
|
import android.net.LinkAddress;
|
|
|
|
|
import android.net.LinkProperties;
|
|
|
|
|
import android.net.Network;
|
|
|
|
|
import android.net.NetworkCapabilities;
|
|
|
|
@ -651,7 +652,19 @@ public class ConnectionHelper {
|
|
|
|
|
ConnectivityManager cm = Helper.getSystemService(context, ConnectivityManager.class);
|
|
|
|
|
Network active = (cm == null ? null : cm.getActiveNetwork());
|
|
|
|
|
LinkProperties props = (active == null ? null : cm.getLinkProperties(active));
|
|
|
|
|
ifacename = (props == null ? null : props.getInterfaceName());
|
|
|
|
|
List<LinkAddress> las = (props == null ? null : props.getLinkAddresses());
|
|
|
|
|
if (las != null)
|
|
|
|
|
for (LinkAddress la : las) {
|
|
|
|
|
InetAddress addr = la.getAddress();
|
|
|
|
|
boolean local = (addr.isLoopbackAddress() || addr.isLinkLocalAddress());
|
|
|
|
|
if (local)
|
|
|
|
|
continue;
|
|
|
|
|
if (addr instanceof Inet4Address)
|
|
|
|
|
has4 = true;
|
|
|
|
|
else if (addr instanceof Inet6Address)
|
|
|
|
|
has6 = true;
|
|
|
|
|
}
|
|
|
|
|
return new boolean[]{has4, has6};
|
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
|
Log.e(ex);
|
|
|
|
|
}
|
|
|
|
|