翰林优商.apk(点击下载) / b.java


package com.mobile.auth.gatewayauth.utils;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.Network;
import android.net.NetworkInfo;
import android.net.Proxy;
import android.os.Build;
import android.provider.Settings;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import com.efs.sdk.base.core.util.NetworkUtil;
import com.kuaishou.weapon.p0.h;
import com.mobile.auth.gatewayauth.ExceptionProcessor;
import com.mobile.auth.o.e;
import com.nirvana.tools.core.SupportJarUtils;
import java.lang.reflect.Method;
import java.net.Inet4Address;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.util.Enumeration;

public class b {
    private static volatile String a;
    private static volatile long b;

    public static int a(Context context) {
        try {
            return e.a(context, 4);
        } catch (Throwable th) {
            ExceptionProcessor.processException(th);
            return -1;
        }
    }

    public static int a(String str) {
        if (str == null) {
            return 4;
        }
        char c = 65535;
        try {
            int hashCode = str.hashCode();
            if (hashCode != -1350608857) {
                if (hashCode != 95009260) {
                    if (hashCode == 880617272) {
                        if (str.equals("cm_zyhl")) {
                            c = 0;
                        }
                    }
                } else if (str.equals("cu_xw")) {
                    c = 1;
                }
            } else if (str.equals("ct_sjl")) {
                c = 2;
            }
            if (c == 0) {
                return 1;
            }
            if (c != 1) {
                return c != 2 ? 4 : 3;
            }
            return 2;
        } catch (Throwable th) {
            ExceptionProcessor.processException(th);
            return -1;
        }
    }

    public static String a() {
        try {
            Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
            while (networkInterfaces.hasMoreElements()) {
                Enumeration<InetAddress> inetAddresses = networkInterfaces.nextElement().getInetAddresses();
                while (true) {
                    if (inetAddresses.hasMoreElements()) {
                        InetAddress nextElement = inetAddresses.nextElement();
                        if (!nextElement.isLoopbackAddress() && (nextElement instanceof Inet4Address)) {
                            return nextElement.getHostAddress();
                        }
                    }
                }
            }
            return "";
        } catch (Exception e) {
            try {
                g.a(e);
                return "";
            } catch (Throwable th) {
                ExceptionProcessor.processException(th);
                return null;
            }
        }
    }

    public static String a(Context context, boolean z) {
        try {
            if (System.currentTimeMillis() - b > 500 || a == null || !z) {
                a = h(context);
                b = System.currentTimeMillis();
            }
            return a;
        } catch (Throwable th) {
            ExceptionProcessor.processException(th);
            return null;
        }
    }

    public static String b() {
        try {
            Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
            while (networkInterfaces.hasMoreElements()) {
                NetworkInterface nextElement = networkInterfaces.nextElement();
                if (!nextElement.getDisplayName().contains("wlan") && !nextElement.getDisplayName().equals("eth0")) {
                    Enumeration<InetAddress> inetAddresses = nextElement.getInetAddresses();
                    while (inetAddresses.hasMoreElements()) {
                        InetAddress nextElement2 = inetAddresses.nextElement();
                        if (!nextElement2.isLoopbackAddress() && (nextElement2 instanceof Inet4Address)) {
                            return nextElement2.getHostAddress();
                        }
                    }
                    continue;
                }
            }
            return "";
        } catch (Exception e) {
            try {
                g.a(e);
                return "";
            } catch (Throwable th) {
                ExceptionProcessor.processException(th);
                return null;
            }
        }
    }

    public static String b(Context context) {
        try {
            int a2 = a(context);
            return a2 == 4 ? "unknown" : a2 != 1 ? a2 != 2 ? a2 != 3 ? "unknown" : "ct_sjl" : "cu_xw" : "cm_zyhl";
        } catch (Throwable th) {
            ExceptionProcessor.processException(th);
            return null;
        }
    }

    public static String b(String str) {
        if (str == null) {
            return "unknown";
        }
        char c = 65535;
        try {
            int hashCode = str.hashCode();
            if (hashCode != -1350608857) {
                if (hashCode != 95009260) {
                    if (hashCode == 880617272) {
                        if (str.equals("cm_zyhl")) {
                            c = 0;
                        }
                    }
                } else if (str.equals("cu_xw")) {
                    c = 1;
                }
            } else if (str.equals("ct_sjl")) {
                c = 2;
            }
            return c != 0 ? c != 1 ? c != 2 ? "unknown" : "CTCC" : "CUCC" : "CMCC";
        } catch (Throwable th) {
            ExceptionProcessor.processException(th);
            return null;
        }
    }

    public static String c(Context context) {
        try {
            int a2 = a(context);
            return a2 == 4 ? "unknown" : a2 != 1 ? a2 != 2 ? a2 != 3 ? "unknown" : "CTCC" : "CUCC" : "CMCC";
        } catch (Throwable th) {
            ExceptionProcessor.processException(th);
            return null;
        }
    }

    public static String c(String str) {
        if (str == null) {
            return "unknown";
        }
        char c = 65535;
        try {
            int hashCode = str.hashCode();
            if (hashCode != -1350608857) {
                if (hashCode != 95009260) {
                    if (hashCode == 880617272) {
                        if (str.equals("cm_zyhl")) {
                            c = 0;
                        }
                    }
                } else if (str.equals("cu_xw")) {
                    c = 1;
                }
            } else if (str.equals("ct_sjl")) {
                c = 2;
            }
            return c != 0 ? c != 1 ? c != 2 ? "unknown" : "46003" : "46001" : "46000";
        } catch (Throwable th) {
            ExceptionProcessor.processException(th);
            return null;
        }
    }

    public static boolean d(Context context) {
        try {
            if (!e(context) || g(context)) {
                return false;
            }
            if (f(context)) {
                return true;
            }
            try {
                Method declaredMethod = ConnectivityManager.class.getDeclaredMethod("getMobileDataEnabled", new Class[0]);
                declaredMethod.setAccessible(true);
                return ((Boolean) declaredMethod.invoke((ConnectivityManager) context.getApplicationContext().getSystemService("connectivity"), new Object[0])).booleanValue();
            } catch (Exception e) {
                g.a(e);
                return true;
            }
        } catch (Throwable th) {
            ExceptionProcessor.processException(th);
            return false;
        }
    }

    public static boolean e(Context context) {
        try {
            return ((TelephonyManager) context.getSystemService("phone")).getSimState() == 5;
        } catch (Throwable th) {
            ExceptionProcessor.processException(th);
            return false;
        }
    }

    public static boolean f(Context context) {
        if (context != null) {
            try {
                NetworkInfo networkInfo = ((ConnectivityManager) context.getSystemService("connectivity")).getNetworkInfo(0);
                return networkInfo != null && networkInfo.isAvailable() && networkInfo.isConnected();
            } catch (Throwable th) {
                ExceptionProcessor.processException(th);
            }
        }
        return false;
    }

    /* JADX WARNING: Removed duplicated region for block: B:7:0x0014 A[RETURN, SYNTHETIC] */
    public static boolean g(Context context) {
        try {
            if (Build.VERSION.SDK_INT < 17) {
                return Settings.System.getInt(context.getContentResolver(), "airplane_mode_on", 0) == 1;
            }
            if (Settings.Global.getInt(context.getContentResolver(), "airplane_mode_on", 0) != 1) {
                return false;
            }
        } catch (Throwable th) {
            try {
                ExceptionProcessor.processException(th);
                return false;
            } catch (Throwable th2) {
                ExceptionProcessor.processException(th2);
                return false;
            }
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:23:0x0046 A[Catch:{ all -> 0x0080, all -> 0x0085 }] */
    /* JADX WARNING: Removed duplicated region for block: B:51:? A[ADDED_TO_REGION, RETURN, SYNTHETIC] */
    private static String h(Context context) {
        NetworkInfo networkInfo;
        String i;
        try {
            ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService("connectivity");
            if (SupportJarUtils.checkSelfPermission(context, h.b) != 0) {
                return "NoInternet";
            }
            if (Build.VERSION.SDK_INT >= 23) {
                Network activeNetwork = connectivityManager.getActiveNetwork();
                if (activeNetwork != null) {
                    networkInfo = connectivityManager.getNetworkInfo(activeNetwork);
                    if (networkInfo != null && networkInfo.isConnected()) {
                        String typeName = networkInfo.getTypeName();
                        if ("WIFI".equalsIgnoreCase(typeName)) {
                            i = d(context) ? "wifi+mobile" : NetworkUtil.NETWORK_TYPE_WIFI;
                        } else if (!"MOBILE".equalsIgnoreCase(typeName)) {
                            return "NoInternet";
                        } else {
                            i = TextUtils.isEmpty(Proxy.getDefaultHost()) ? i(context) : "wap";
                        }
                        return i;
                    }
                }
            } else {
                NetworkInfo[] allNetworkInfo = connectivityManager.getAllNetworkInfo();
                if (allNetworkInfo != null) {
                    int length = allNetworkInfo.length;
                    int i2 = 0;
                    while (true) {
                        if (i2 < length) {
                            NetworkInfo networkInfo2 = allNetworkInfo[i2];
                            if (networkInfo2 != null && networkInfo2.isAvailable() && networkInfo2.isConnected()) {
                                networkInfo = networkInfo2;
                                break;
                            }
                            i2++;
                        } else {
                            break;
                        }
                    }
                    return networkInfo != null ? "NoInternet" : "NoInternet";
                }
            }
            networkInfo = null;
            if (networkInfo != null) {
            }
        } catch (Throwable th) {
            ExceptionProcessor.processException(th);
            return null;
        }
    }

    private static String i(Context context) {
        try {
            if (SupportJarUtils.checkSelfPermission(context.getApplicationContext(), h.c) != 0) {
                return "unknow";
            }
            TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService("phone");
            int dataNetworkType = Build.VERSION.SDK_INT >= 30 ? telephonyManager.getDataNetworkType() : telephonyManager.getNetworkType();
            if (dataNetworkType == 20) {
                return NetworkUtil.NETWORK_CLASS_5G;
            }
            switch (dataNetworkType) {
                case 1:
                case 2:
                case 4:
                case 7:
                case 11:
                case 16:
                    return NetworkUtil.NETWORK_CLASS_2G;
                case 3:
                case 5:
                case 6:
                case 8:
                case 9:
                case 10:
                case 12:
                case 14:
                case 15:
                case 17:
                    return NetworkUtil.NETWORK_CLASS_3G;
                case 13:
                    return NetworkUtil.NETWORK_CLASS_4G;
                default:
                    return "unknow";
            }
        } catch (Throwable th) {
            ExceptionProcessor.processException(th);
            return null;
        }
    }
}