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


package com.czhj.sdk.common.utils;

import android.app.ActivityManager;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.Signature;
import android.net.ConnectivityManager;
import android.net.Network;
import android.net.NetworkCapabilities;
import android.net.NetworkInfo;
import android.net.NetworkRequest;
import android.net.wifi.WifiManager;
import android.os.BatteryManager;
import android.os.Build;
import android.os.IBinder;
import android.os.StatFs;
import android.os.SystemClock;
import android.os.storage.StorageManager;
import android.os.storage.StorageVolume;
import android.provider.Settings;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.view.Display;
import android.view.WindowManager;
import com.baidu.idl.face.platform.FaceEnvironment;
import com.bytedance.sdk.openadsdk.downloadnew.core.TTDownloadField;
import com.czhj.sdk.common.utils.ReflectionUtil;
import com.czhj.sdk.logger.SigmobLog;
import com.efs.sdk.base.core.util.NetworkUtil;
import com.kuaishou.weapon.p0.h;
import com.umeng.analytics.pro.am;
import java.io.BufferedReader;
import java.io.File;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.lang.reflect.Method;
import java.net.Inet4Address;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.security.MessageDigest;
import java.util.Enumeration;
import java.util.Locale;
import kotlin.UByte;

public class DeviceUtils {
    static final String[] a = {"/system/lib/libdroid4x.so", "/system/bin/mount.vboxsf", "/system/lib/vboxguest.ko", "/etc/mumu-configs", "/system/lib/vboxsf.ko", "/system/lib/vboxvideo.ko", "/data/.bluestacks.prop", "/system/bin/microvirt-vbox-sf", "/system/lib/tboxsf.ko", "/system/bin/androVM-vbox-sf", "/system/bin/microvirtd", "/system/bin/windroyed", "/system/lib/libdroid4x.so"};
    private static final int b = 31457280;
    private static final String c = "getSimState";
    private static final String d = "getImei";
    private static final String e = "getLine1Number";
    private static final int f = 31457280;
    private static final int g = 104857600;
    private static final int h = -1;
    private static String i;
    private static int j = 0;
    private static String k;
    private static String l;
    private static String m;
    private static String n;
    private static NetworkType o;
    private static boolean p;
    private static long q;
    private static long r;
    private static long s;
    private static long t;

    public static class NetBroadcastReceiver extends BroadcastReceiver {
        public void onReceive(Context context, Intent intent) {
            if (intent.getAction().equals("android.net.conn.CONNECTIVITY_CHANGE")) {
                DeviceUtils.updateNetworkType(context);
            }
        }
    }

    public enum NetworkType {
        UNKNOWN(0),
        ETHERNET(101),
        WIFI(100),
        MOBILE(1),
        MOBILE_2G(2),
        MOBILE_3G(3),
        MOBILE_4G(4),
        MOBILE_5G(5);
        
        private final int mId;

        private NetworkType(int i) {
            this.mId = i;
        }

        /* access modifiers changed from: private */
        public static NetworkType b(Context context, int i) {
            if (i != 0) {
                if (i == 1) {
                    return WIFI;
                }
                if (!(i == 2 || i == 3 || i == 4 || i == 5)) {
                    return i != 9 ? UNKNOWN : ETHERNET;
                }
            }
            return DeviceUtils.getDataNetworkType(context);
        }

        public int getId() {
            return this.mId;
        }

        public String toString() {
            return Integer.toString(this.mId);
        }
    }

    private static boolean a(int i2, int i3) {
        return (i2 & i3) != 0;
    }

    private static boolean a(Context context) {
        return context.checkCallingOrSelfPermission(h.a) == 0;
    }

    private static boolean a(String str) {
        Process process = null;
        try {
            Runtime runtime = Runtime.getRuntime();
            process = runtime.exec("ls -l " + str);
            String readLine = new BufferedReader(new InputStreamReader(process.getInputStream())).readLine();
            if (readLine != null && readLine.length() >= 4) {
                char charAt = readLine.charAt(3);
                if (charAt == 's' || charAt == 'x') {
                    if (process != null) {
                        process.destroy();
                    }
                    return true;
                }
            }
            if (process == null) {
                return false;
            }
        } catch (Throwable unused) {
            if (0 == 0) {
                return false;
            }
        }
        process.destroy();
        return false;
    }

    public static long diskCacheSizeBytes(File file, long j2) {
        try {
            StatFs statFs = new StatFs(file.getAbsolutePath());
            j2 = (((long) statFs.getBlockCount()) * ((long) statFs.getBlockSize())) / 50;
        } catch (IllegalArgumentException unused) {
            SigmobLog.d("Unable to calculate 2% of available disk space, defaulting to minimum");
        }
        return Math.max(Math.min(j2, 104857600L), 31457280L);
    }

    public static NetworkType getActiveNetworkType() {
        return o;
    }

    public static String getAndroidId(Context context) {
        if (TextUtils.isEmpty(m) && context != null) {
            try {
                m = Settings.Secure.getString(context.getContentResolver(), "android_id");
            } catch (Throwable th) {
                SigmobLog.e(th.getMessage());
            }
        }
        return m;
    }

    public static String getApkSha1OrMd5(Context context, String str) {
        Signature signature;
        try {
            PackageInfo packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 64);
            if (packageInfo == null || packageInfo.signatures == null || packageInfo.signatures.length <= 0 || (signature = packageInfo.signatures[0]) == null) {
                return null;
            }
            byte[] byteArray = signature.toByteArray();
            MessageDigest instance = MessageDigest.getInstance(str);
            if (instance == null) {
                return null;
            }
            byte[] digest = instance.digest(byteArray);
            StringBuilder sb = new StringBuilder();
            for (byte b2 : digest) {
                sb.append(Integer.toHexString((b2 & UByte.MAX_VALUE) | 256).substring(1, 3).toUpperCase());
                sb.append(":");
            }
            return sb.substring(0, sb.length() - 1);
        } catch (Exception e2) {
            SigmobLog.e(e2.getMessage());
            return null;
        }
    }

    public static int getAppLaunchCount(Context context, String str) {
        try {
            Intent launchIntentForPackage = context.getPackageManager().getLaunchIntentForPackage(str);
            SigmobLog.d("getAppLaunchCount==" + str);
            if (launchIntentForPackage == null) {
                return 0;
            }
            ComponentName component = launchIntentForPackage.getComponent();
            SigmobLog.d("getAppLaunchCount==" + str);
            Object invoke = Class.forName("android.os.ServiceManager").getMethod("getService", String.class).invoke(null, "usagestats");
            Object invoke2 = Class.forName("com.android.internal.app.IUsageStats$Stub").getMethod("asInterface", IBinder.class).invoke(null, invoke);
            Object invoke3 = invoke2.getClass().getMethod("getPkgUsageStats", ComponentName.class).invoke(invoke2, component);
            SigmobLog.d("getAppLaunchCount==" + str);
            if (invoke3 == null) {
                return 0;
            }
            Class<?> cls = Class.forName("com.android.internal.os.PkgUsageStats");
            SigmobLog.d("getAppLaunchCount==" + str);
            return cls.getDeclaredField("launchCount").getInt(invoke3);
        } catch (Exception e2) {
            e2.printStackTrace();
            return 0;
        }
    }

    public static float getBatteryLevel(Context context) {
        BatteryManager batteryManager;
        if (Build.VERSION.SDK_INT < 21 || (batteryManager = (BatteryManager) context.getSystemService("batterymanager")) == null) {
            return 0.0f;
        }
        return ((float) batteryManager.getIntProperty(4)) / 100.0f;
    }

    public static boolean getBatterySaveEnable(Context context) {
        BatteryManager batteryManager;
        return Build.VERSION.SDK_INT >= 21 && (batteryManager = (BatteryManager) context.getSystemService("batterymanager")) != null && batteryManager.getIntProperty(4) < 16;
    }

    public static int getBatteryState(Context context) {
        BatteryManager batteryManager;
        if (Build.VERSION.SDK_INT < 21 || (batteryManager = (BatteryManager) context.getSystemService("batterymanager")) == null) {
            return 0;
        }
        int intProperty = Build.VERSION.SDK_INT >= 26 ? batteryManager.getIntProperty(6) : 0;
        if (intProperty == 2) {
            return 2;
        }
        if (intProperty == 3 || intProperty == 4) {
            return 1;
        }
        return intProperty != 5 ? 0 : 3;
    }

    public static String getBlueToothName(Context context) {
        if (TextUtils.isEmpty(n)) {
            try {
                n = Settings.Secure.getString(context.getContentResolver(), "bluetooth_name");
            } catch (Throwable th) {
                SigmobLog.e(th.getMessage());
            }
        }
        return n;
    }

    public static long getBootSystemTime() {
        return System.currentTimeMillis() - SystemClock.elapsedRealtime();
    }

    public static String getCPUInfo() {
        try {
            return Build.VERSION.SDK_INT >= 21 ? Build.SUPPORTED_ABIS[0] : Build.CPU_ABI;
        } catch (Throwable th) {
            SigmobLog.e(th.getMessage());
            return null;
        }
    }

    public static String getCell_ip() {
        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 "0.0.0.0";
        } catch (SocketException e2) {
            e2.printStackTrace();
            return "0.0.0.0";
        } catch (Exception e3) {
            e3.printStackTrace();
            return "0.0.0.0";
        }
    }

    public static ConnectivityManager getConnectivityManager(Context context) {
        if (context != null) {
            return (ConnectivityManager) context.getSystemService("connectivity");
        }
        return null;
    }

    /* JADX WARNING: Removed duplicated region for block: B:17:0x0044  */
    /* JADX WARNING: Removed duplicated region for block: B:26:0x0053  */
    public static NetworkType getDataNetworkType(Context context) {
        int i2;
        NetworkInfo activeNetworkInfo;
        SigmobLog.d("getDataNetworkType ");
        TelephonyManager telephonyManager = getTelephonyManager(context);
        if (telephonyManager != null) {
            if (Build.VERSION.SDK_INT >= 24) {
                i2 = telephonyManager.getDataNetworkType();
            } else {
                try {
                    i2 = telephonyManager.getNetworkType();
                } catch (Exception unused) {
                }
            }
            ConnectivityManager connectivityManager = getConnectivityManager(context);
            if (!(i2 != 0 || connectivityManager == null || (activeNetworkInfo = connectivityManager.getActiveNetworkInfo()) == null)) {
                i2 = activeNetworkInfo.getSubtype();
            }
            SigmobLog.d("getDataNetworkType " + i2);
            if (i2 != 20) {
                return NetworkType.MOBILE_5G;
            }
            switch (i2) {
                case 1:
                case 2:
                case 4:
                case 7:
                case 11:
                    return NetworkType.MOBILE_2G;
                case 3:
                case 5:
                case 6:
                case 8:
                case 9:
                case 10:
                case 12:
                case 14:
                case 15:
                    return NetworkType.MOBILE_3G;
                case 13:
                    return NetworkType.MOBILE_4G;
                default:
                    return NetworkType.MOBILE;
            }
        }
        i2 = 0;
        ConnectivityManager connectivityManager2 = getConnectivityManager(context);
        i2 = activeNetworkInfo.getSubtype();
        SigmobLog.d("getDataNetworkType " + i2);
        if (i2 != 20) {
        }
    }

    public static float getDensityDpi(Context context) {
        try {
            return (float) context.getResources().getDisplayMetrics().densityDpi;
        } catch (Throwable th) {
            SigmobLog.e(th.getMessage());
            return 0.0f;
        }
    }

    public static String getDeviceBrand() {
        return Build.BRAND;
    }

    public static String getDeviceDispaly() {
        return Build.DISPLAY;
    }

    public static Locale getDeviceLocale(Context context) {
        try {
            return context.getResources().getConfiguration().locale;
        } catch (Throwable th) {
            SigmobLog.e(th.getMessage());
            return null;
        }
    }

    public static String getDeviceManufacturer() {
        return Build.MANUFACTURER;
    }

    public static String getDeviceModel() {
        return Build.MODEL;
    }

    public static String getDeviceName(Context context) {
        if (Build.VERSION.SDK_INT < 17) {
            return getBlueToothName(context);
        }
        try {
            return Settings.Global.getString(context.getContentResolver(), am.J);
        } catch (Throwable th) {
            SigmobLog.e(th.getMessage());
            return null;
        }
    }

    public static int getDeviceOSLevel() {
        return Build.VERSION.SDK_INT;
    }

    public static String getDeviceOsVersion() {
        return Build.VERSION.RELEASE;
    }

    public static int getDeviceScreenHeightDip(Context context) {
        if (context == null) {
            return 0;
        }
        return Dips.screenHeightAsIntDips(context);
    }

    public static int getDeviceScreenRealHeightDip(Context context) {
        if (context == null) {
            return 0;
        }
        return Dips.pixelsToIntDips((float) getRealMetrics(context).heightPixels, context);
    }

    public static int getDeviceScreenRealWidthDip(Context context) {
        if (context == null) {
            return 0;
        }
        return Dips.pixelsToIntDips((float) getRealMetrics(context).widthPixels, context);
    }

    public static int getDeviceScreenWidthDip(Context context) {
        return Dips.screenWidthAsIntDips(context);
    }

    public static String getDeviceSerial() {
        return Build.SERIAL;
    }

    public static String getDeviceType(Context context) {
        return isTablet(context) ? "pad" : "phone";
    }

    public static DisplayMetrics getDisplayMetrics(Context context) {
        try {
            return context.getResources().getDisplayMetrics();
        } catch (Throwable th) {
            SigmobLog.e(th.getMessage());
            return null;
        }
    }

    public static String getNetworkOperator(Context context) {
        TelephonyManager telephonyManager = getTelephonyManager(context);
        if (telephonyManager != null) {
            return (telephonyManager.getPhoneType() == 2 && telephonyManager.getSimState() == 5) ? telephonyManager.getSimOperator() : telephonyManager.getNetworkOperator();
        }
        return null;
    }

    public static String getNetworkOperatorForUrl(Context context) {
        return getNetworkOperator(context);
    }

    public static int getOrientationInt(Context context) {
        return context.getResources().getConfiguration().orientation;
    }

    public static String getProperty(String str) {
        try {
            Object invoke = Class.forName("android.os.SystemProperties").getMethod("get", String.class).invoke(null, str);
            if (invoke != null) {
                return (String) invoke;
            }
            return null;
        } catch (Throwable unused) {
            return null;
        }
    }

    public static DisplayMetrics getRealMetrics(Context context) {
        WindowManager windowManger = getWindowManger(context);
        DisplayMetrics displayMetrics = new DisplayMetrics();
        Display defaultDisplay = windowManger.getDefaultDisplay();
        if (Build.VERSION.SDK_INT >= 17) {
            defaultDisplay.getRealMetrics(displayMetrics);
        } else {
            try {
                Class.forName("android.view.Display").getMethod("getRealMetrics", DisplayMetrics.class).invoke(defaultDisplay, displayMetrics);
            } catch (Exception e2) {
                SigmobLog.e(e2.getMessage());
            }
        }
        return displayMetrics;
    }

    public static String getRotation(Context context) {
        WindowManager windowManger = getWindowManger(context);
        if (windowManger == null) {
            return "0";
        }
        int rotation = windowManger.getDefaultDisplay().getRotation();
        return rotation != 1 ? rotation != 2 ? rotation != 3 ? "0" : "270" : "180" : "90";
    }

    public static String getSDCardPath(Context context) {
        StorageManager storageManager = (StorageManager) context.getSystemService("storage");
        if (Build.VERSION.SDK_INT >= 24) {
            for (StorageVolume storageVolume : storageManager.getStorageVolumes()) {
                if (storageVolume.isRemovable()) {
                    try {
                        return (String) storageVolume.getClass().getMethod("getPath", new Class[0]).invoke(storageVolume, new Object[0]);
                    } catch (Exception e2) {
                        SigmobLog.e(e2.getMessage());
                    }
                }
            }
            return null;
        }
        try {
            Method method = storageManager.getClass().getMethod("getVolumeList", new Class[0]);
            Class<?> cls = Class.forName("android.os.storage.StorageVolume");
            Method method2 = cls.getMethod("getPath", new Class[0]);
            Method method3 = cls.getMethod("isRemovable", new Class[0]);
            Object invoke = method.invoke(storageManager, new Object[0]);
            int length = Array.getLength(invoke);
            for (int i2 = 0; i2 < length; i2++) {
                try {
                    Object obj = Array.get(invoke, i2);
                    Object invoke2 = method3.invoke(obj, new Object[0]);
                    if ((invoke2 instanceof Boolean) && ((Boolean) invoke2).booleanValue()) {
                        Object invoke3 = method2.invoke(obj, new Object[0]);
                        if (invoke3 instanceof String) {
                            return (String) invoke3;
                        }
                    }
                } catch (Throwable unused) {
                }
            }
            return null;
        } catch (Throwable unused2) {
            return null;
        }
    }

    public static long getSysteTotalMemorySize(Context context) {
        try {
            if (Build.VERSION.SDK_INT < 16) {
                return 0;
            }
            ActivityManager activityManager = (ActivityManager) context.getSystemService(TTDownloadField.TT_ACTIVITY);
            ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo();
            if (activityManager == null) {
                return 0;
            }
            activityManager.getMemoryInfo(memoryInfo);
            return memoryInfo.totalMem;
        } catch (Throwable th) {
            SigmobLog.e(th.getMessage());
            return 0;
        }
    }

    public static TelephonyManager getTelephonyManager(Context context) {
        if (context == null) {
            return null;
        }
        try {
            if (!isCanUsePhoneState(context)) {
                return null;
            }
        } catch (Throwable unused) {
        }
        return (TelephonyManager) context.getSystemService("phone");
    }

    public static WifiManager getWifiManager(Context context) {
        if (context == null || !isCanUseWifiState(context)) {
            return null;
        }
        return (WifiManager) context.getSystemService(NetworkUtil.NETWORK_TYPE_WIFI);
    }

    public static WindowManager getWindowManger(Context context) {
        return (WindowManager) context.getSystemService("window");
    }

    public static boolean isCanRetryIMEI() {
        boolean z = System.currentTimeMillis() - q > 30000;
        if (z) {
            q = System.currentTimeMillis();
        }
        SigmobLog.d("isCanRetryIMEI status " + z);
        return z;
    }

    public static boolean isCanRetryLocation() {
        boolean z = System.currentTimeMillis() - s > 36000;
        if (z) {
            s = System.currentTimeMillis();
        }
        SigmobLog.d("isCanRetryLocation status " + z);
        return z;
    }

    public static boolean isCanRetryWIFI() {
        boolean z = System.currentTimeMillis() - t > 30000;
        if (z) {
            t = System.currentTimeMillis();
        }
        SigmobLog.d("isCanRetryWIFI status " + z);
        return z;
    }

    public static boolean isCanUseLocation(Context context) {
        boolean z = context.checkCallingOrSelfPermission(h.h) == 0 || context.checkCallingOrSelfPermission(h.g) == 0;
        SigmobLog.d("isCanUseLocation status " + z);
        return z;
    }

    public static boolean isCanUsePhoneState(Context context) {
        boolean z = context.checkCallingOrSelfPermission(h.c) == 0;
        SigmobLog.d("isCanUsePhoneState status " + z);
        return z;
    }

    public static boolean isCanUseWifiState(Context context) {
        boolean z = context.checkCallingOrSelfPermission(h.d) == 0;
        SigmobLog.d("isCanUseWifiState status " + z);
        return z;
    }

    public static boolean isCanUseWriteExternal(Context context) {
        boolean z = context.checkCallingOrSelfPermission(h.j) == 0;
        SigmobLog.d("isCanUseWriteExternal status " + z);
        return z;
    }

    public static boolean isEmulator() {
        int i2;
        int i3 = j;
        if (i3 > 0) {
            return i3 > 3;
        }
        try {
            String property = getProperty("gsm.version.baseband");
            if (TextUtils.isEmpty(property) || property.contains("1.0.0.0")) {
                j++;
            }
            String property2 = getProperty("ro.build.flavor");
            if (TextUtils.isEmpty(property2)) {
                j++;
            } else if (property2.contains("vbox") || property2.contains("sdk_gphone")) {
                j += 10;
            }
            String property3 = getProperty("ro.product.board");
            if (TextUtils.isEmpty(property3)) {
                j++;
            } else if (property3.contains(FaceEnvironment.OS) || property3.contains("goldfish")) {
                j += 10;
            }
            String property4 = getProperty("ro.board.platform");
            if (TextUtils.isEmpty(property4) || property4.contains(FaceEnvironment.OS)) {
                j++;
            }
            String property5 = getProperty("ro.hardware");
            if (property5 == null) {
                j++;
            } else {
                if (property5.toLowerCase().contains("ttvm")) {
                    i2 = j;
                } else if (property5.toLowerCase().contains("nox")) {
                    i2 = j;
                }
                j = i2 + 10;
            }
            String[] strArr = a;
            for (String str : strArr) {
                if (new File(str).exists()) {
                    SigmobLog.e("find emulator " + str);
                    j = j + 10;
                }
            }
        } catch (Throwable unused) {
        }
        return j > 3;
    }

    public static boolean isNetworkConnected() {
        return p;
    }

    public static boolean isNetworkValid(NetworkCapabilities networkCapabilities) {
        if (networkCapabilities == null || Build.VERSION.SDK_INT < 21) {
            return false;
        }
        return networkCapabilities.hasTransport(1) || networkCapabilities.hasTransport(0) || networkCapabilities.hasTransport(3) || networkCapabilities.hasTransport(4) || (Build.VERSION.SDK_INT >= 23 ? networkCapabilities.hasCapability(16) : false);
    }

    public static boolean isRoot() {
        return (new File("/system/bin/su").exists() && a("/system/bin/su")) || (new File("/system/xbin/su").exists() && a("/system/xbin/su"));
    }

    public static boolean isTablet(Context context) {
        return (context.getResources().getConfiguration().screenLayout & 15) >= 3;
    }

    public static int memoryCacheSizeBytes(Context context) {
        ActivityManager activityManager = (ActivityManager) context.getSystemService(TTDownloadField.TT_ACTIVITY);
        if (activityManager == null) {
            return 0;
        }
        long memoryClass = (long) activityManager.getMemoryClass();
        try {
            if (a(context.getApplicationInfo().flags, ApplicationInfo.class.getDeclaredField("FLAG_LARGE_HEAP").getInt(null))) {
                memoryClass = (long) ((Integer) new ReflectionUtil.MethodBuilder(activityManager, "getLargeMemoryClass").execute()).intValue();
            }
        } catch (Throwable unused) {
            SigmobLog.d("Unable to reflectively determine large heap size.");
        }
        return (int) Math.min(31457280L, (memoryClass / 8) * 1024 * 1024);
    }

    public static void registerNetworkChange(final Context context) {
        if (Build.VERSION.SDK_INT < 21) {
            context.registerReceiver(new NetBroadcastReceiver(), new IntentFilter("android.net.conn.CONNECTIVITY_CHANGE"));
            return;
        }
        NetworkRequest build = new NetworkRequest.Builder().addTransportType(0).addTransportType(1).build();
        ConnectivityManager connectivityManager = getConnectivityManager(context);
        if (connectivityManager != null) {
            connectivityManager.registerNetworkCallback(build, new ConnectivityManager.NetworkCallback() {
                /* class com.czhj.sdk.common.utils.DeviceUtils.AnonymousClass1 */

                public void onAvailable(Network network) {
                    SigmobLog.d("registerNetworkCallback  onAvailable");
                    super.onAvailable(network);
                    DeviceUtils.updateNetworkType(context);
                }

                public void onLost(Network network) {
                    SigmobLog.d("registerNetworkCallback  onLost");
                    super.onLost(network);
                    NetworkType unused = DeviceUtils.o = NetworkType.UNKNOWN;
                    boolean unused2 = DeviceUtils.p = false;
                }
            });
        }
    }

    public static void resetRetryIMEI() {
        q = 0;
    }

    public static void updateNetworkType(Context context) {
        NetworkType b2;
        try {
            if (a(context)) {
                if (Build.VERSION.SDK_INT >= 23) {
                    Network activeNetwork = getConnectivityManager(context).getActiveNetwork();
                    NetworkCapabilities networkCapabilities = null;
                    if (activeNetwork != null) {
                        networkCapabilities = getConnectivityManager(context).getNetworkCapabilities(activeNetwork);
                    }
                    if (networkCapabilities != null) {
                        SigmobLog.d("updateNetworkType " + networkCapabilities);
                        p = isNetworkValid(networkCapabilities);
                        SigmobLog.d("updateNetworkType misNetworkConnected" + p);
                        b2 = (!networkCapabilities.hasCapability(12) || !networkCapabilities.hasTransport(1)) ? (!networkCapabilities.hasCapability(12) || !networkCapabilities.hasTransport(0)) ? NetworkType.UNKNOWN : getDataNetworkType(context) : NetworkType.WIFI;
                    } else {
                        return;
                    }
                } else {
                    NetworkInfo activeNetworkInfo = getConnectivityManager(context).getActiveNetworkInfo();
                    if (activeNetworkInfo != null) {
                        p = activeNetworkInfo.isAvailable();
                    }
                    b2 = NetworkType.b(context, activeNetworkInfo != null ? activeNetworkInfo.getType() : -1);
                }
                o = b2;
            }
        } catch (Exception unused) {
        }
    }
}