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


package com.kwad.sdk.utils;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Build;
import android.telephony.ServiceState;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import com.kuaishou.weapon.p0.h;
import com.kwad.sdk.core.e.b;
import java.net.InetAddress;

public final class af {
    private static int bBE;
    private static boolean bBF;

    /* JADX WARNING: Removed duplicated region for block: B:56:0x00bc A[Catch:{ Exception -> 0x00d8 }] */
    /* JADX WARNING: Removed duplicated region for block: B:70:0x00e1  */
    public static int c(Context context, String str, boolean z) {
        int i;
        if (context == null || bBE > 0 || bBF) {
            return bBE;
        }
        boolean z2 = true;
        if (!z) {
            try {
                TelephonyManager telephonyManager = (TelephonyManager) context.getApplicationContext().getSystemService("phone");
                if (Build.VERSION.SDK_INT >= 22) {
                    String simOperator = telephonyManager.getSimOperator();
                    char c = 65535;
                    int hashCode = simOperator.hashCode();
                    if (hashCode != 49679502) {
                        switch (hashCode) {
                            case 49679470:
                                if (simOperator.equals("46000")) {
                                    c = 0;
                                    break;
                                }
                                break;
                            case 49679471:
                                if (simOperator.equals("46001")) {
                                    c = 4;
                                    break;
                                }
                                break;
                            case 49679472:
                                if (simOperator.equals("46002")) {
                                    c = 1;
                                    break;
                                }
                                break;
                            case 49679473:
                                if (simOperator.equals("46003")) {
                                    c = 7;
                                    break;
                                }
                                break;
                            default:
                                switch (hashCode) {
                                    case 49679475:
                                        if (simOperator.equals("46005")) {
                                            c = '\b';
                                            break;
                                        }
                                        break;
                                    case 49679476:
                                        if (simOperator.equals("46006")) {
                                            c = 5;
                                            break;
                                        }
                                        break;
                                    case 49679477:
                                        if (simOperator.equals("46007")) {
                                            c = 2;
                                            break;
                                        }
                                        break;
                                    case 49679478:
                                        if (simOperator.equals("46008")) {
                                            c = 3;
                                            break;
                                        }
                                        break;
                                    case 49679479:
                                        if (simOperator.equals("46009")) {
                                            c = 6;
                                            break;
                                        }
                                        break;
                                }
                        }
                    } else if (simOperator.equals("46011")) {
                        c = '\t';
                    }
                    switch (c) {
                        case 0:
                        case 1:
                        case 2:
                        case 3:
                            bBE = 1;
                            break;
                        case 4:
                        case 5:
                        case 6:
                            bBE = 3;
                            break;
                        case 7:
                        case '\b':
                        case '\t':
                            bBE = 2;
                            break;
                    }
                }
                if (bBE == 0 && !TextUtils.isEmpty(str)) {
                    if (!str.startsWith("46000")) {
                        if (!str.startsWith("46002")) {
                            if (str.startsWith("46001")) {
                                bBE = 3;
                            } else if (str.startsWith("46003")) {
                                bBE = 2;
                            }
                        }
                    }
                    bBE = 1;
                }
            } catch (Exception e) {
                b.printStackTraceOnly(e);
            }
            i = bBE;
            if (i != 0) {
                z2 = false;
            }
            bBF = z2;
            return i;
        }
        bBE = 0;
        if (!str.startsWith("46000")) {
        }
        bBE = 1;
        i = bBE;
        if (i != 0) {
        }
        bBF = z2;
        return i;
    }

    public static NetworkInfo db(Context context) {
        ConnectivityManager connectivityManager;
        if (!SystemUtil.b(context, h.b) || (connectivityManager = (ConnectivityManager) context.getSystemService("connectivity")) == null) {
            return null;
        }
        try {
            return connectivityManager.getActiveNetworkInfo();
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }

    public static int dc(Context context) {
        if (context != null && SystemUtil.b(context, h.b) && SystemUtil.b(context, h.c)) {
            try {
                NetworkInfo db = db(context);
                if (!(db != null && db.isConnected())) {
                    return 0;
                }
                if (1 == db.getType()) {
                    return 100;
                }
                TelephonyManager telephonyManager = (TelephonyManager) context.getApplicationContext().getSystemService("phone");
                if (telephonyManager != null) {
                    int k = k(context, telephonyManager.getNetworkType());
                    if (k == 20) {
                        return 5;
                    }
                    switch (k) {
                        case 1:
                        case 2:
                        case 4:
                        case 7:
                        case 11:
                        case 16:
                            return 2;
                        case 3:
                        case 5:
                        case 6:
                        case 8:
                        case 9:
                        case 10:
                        case 12:
                        case 14:
                        case 15:
                            return 3;
                        case 13:
                            return 4;
                        default:
                            return 0;
                    }
                }
            } catch (Exception unused) {
            }
        }
        return 0;
    }

    private static boolean fs(String str) {
        return str.contains("nrState=NOT_RESTRICTED") || str.contains("nrState=CONNECTED");
    }

    public static boolean ft(String str) {
        return r(str, 3000);
    }

    public static int getActiveNetworkType(Context context) {
        try {
            NetworkInfo db = db(context);
            if (db == null) {
                return -1;
            }
            return db.getType();
        } catch (Exception unused) {
            return -1;
        }
    }

    private static int getSubId() {
        if (Build.VERSION.SDK_INT >= 24) {
            return SubscriptionManager.getDefaultDataSubscriptionId();
        }
        return -1;
    }

    public static boolean isMobileConnected(Context context) {
        try {
            NetworkInfo db = db(context);
            return db != null && db.isConnected() && db.getType() == 0;
        } catch (Exception unused) {
        }
    }

    public static boolean isNetworkConnected(Context context) {
        try {
            NetworkInfo db = db(context);
            return db != null && db.isConnected();
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }

    public static boolean isWifiConnected(Context context) {
        try {
            NetworkInfo db = db(context);
            return db != null && db.isConnected() && 1 == db.getType();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }

    /* JADX WARNING: Removed duplicated region for block: B:21:0x004c A[RETURN] */
    /* JADX WARNING: Removed duplicated region for block: B:22:0x004d  */
    private static int k(Context context, int i) {
        ServiceState serviceState;
        if (Build.VERSION.SDK_INT < 26 || !SystemUtil.b(context, h.b)) {
            return i;
        }
        try {
            TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService("phone");
            if (telephonyManager == null) {
                return i;
            }
            int subId = getSubId();
            if (subId != -1 && (context.getApplicationInfo().targetSdkVersion < 29 || Build.VERSION.SDK_INT < 29)) {
                try {
                    serviceState = (ServiceState) r.a((Object) telephonyManager, "getServiceStateForSubscriber", Integer.valueOf(subId));
                } catch (Throwable unused) {
                }
                if (serviceState != null) {
                    return i;
                }
                if (as.YL()) {
                    Integer num = (Integer) r.a("com.huawei.android.telephony.ServiceStateEx", "getConfigRadioTechnology", serviceState);
                    return num != null ? num.intValue() : i;
                } else if (fs(serviceState.toString())) {
                    return 20;
                } else {
                    return i;
                }
            }
            serviceState = telephonyManager.getServiceState();
            if (serviceState != null) {
            }
        } catch (Exception unused2) {
            return i;
        }
    }

    private static boolean r(String str, int i) {
        try {
            return InetAddress.getByName(str).isReachable(3000);
        } catch (Throwable unused) {
            return false;
        }
    }
}