|
|
@ -36,8 +36,6 @@ import android.content.res.TypedArray;
|
|
|
|
import android.graphics.Bitmap;
|
|
|
|
import android.graphics.Bitmap;
|
|
|
|
import android.graphics.BitmapFactory;
|
|
|
|
import android.graphics.BitmapFactory;
|
|
|
|
import android.net.ConnectivityManager;
|
|
|
|
import android.net.ConnectivityManager;
|
|
|
|
import android.net.LinkAddress;
|
|
|
|
|
|
|
|
import android.net.LinkProperties;
|
|
|
|
|
|
|
|
import android.net.Network;
|
|
|
|
import android.net.Network;
|
|
|
|
import android.net.NetworkCapabilities;
|
|
|
|
import android.net.NetworkCapabilities;
|
|
|
|
import android.net.NetworkInfo;
|
|
|
|
import android.net.NetworkInfo;
|
|
|
@ -76,9 +74,6 @@ import java.io.InputStream;
|
|
|
|
import java.io.InputStreamReader;
|
|
|
|
import java.io.InputStreamReader;
|
|
|
|
import java.io.OutputStream;
|
|
|
|
import java.io.OutputStream;
|
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
|
import java.net.Inet4Address;
|
|
|
|
|
|
|
|
import java.net.InetAddress;
|
|
|
|
|
|
|
|
import java.net.UnknownHostException;
|
|
|
|
|
|
|
|
import java.security.MessageDigest;
|
|
|
|
import java.security.MessageDigest;
|
|
|
|
import java.security.NoSuchAlgorithmException;
|
|
|
|
import java.security.NoSuchAlgorithmException;
|
|
|
|
import java.text.DateFormat;
|
|
|
|
import java.text.DateFormat;
|
|
|
@ -699,43 +694,6 @@ public class Helper {
|
|
|
|
return filename.substring(index + 1);
|
|
|
|
return filename.substring(index + 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static InetAddress getLocalIp(Context context) throws UnknownHostException {
|
|
|
|
|
|
|
|
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.M)
|
|
|
|
|
|
|
|
return InetAddress.getLocalHost();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Network active = cm.getActiveNetwork();
|
|
|
|
|
|
|
|
if (active == null)
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NetworkInfo ani = cm.getNetworkInfo(active);
|
|
|
|
|
|
|
|
if (ani == null || !ani.isConnected())
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NetworkCapabilities caps = cm.getNetworkCapabilities(active);
|
|
|
|
|
|
|
|
if (caps == null)
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!caps.hasCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VPN))
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LinkProperties props = cm.getLinkProperties(active);
|
|
|
|
|
|
|
|
if (props == null)
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<LinkAddress> addresses = props.getLinkAddresses();
|
|
|
|
|
|
|
|
if (addresses == null || addresses.size() == 0)
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Prefer IPv4
|
|
|
|
|
|
|
|
for (LinkAddress address : addresses)
|
|
|
|
|
|
|
|
if (address.getAddress() instanceof Inet4Address)
|
|
|
|
|
|
|
|
return address.getAddress();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return addresses.get(0).getAddress();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static Boolean isMetered(Context context, boolean log) {
|
|
|
|
static Boolean isMetered(Context context, boolean log) {
|
|
|
|
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
|
|
|
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
|
|
|
|
|
|
|
|
|
|
|