package cn.com.chinatelecom.account.api.e; import android.content.Context; import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.telephony.TelephonyManager; import android.text.TextUtils; import cn.com.chinatelecom.account.api.CtAuth; import cn.com.chinatelecom.account.api.a.d; import com.alibaba.security.common.utils.NetWorkUtils; import com.tencent.connect.common.Constants; import java.lang.reflect.Method; import xh.a; public class g { /* renamed from: a reason: collision with root package name */ public static String f22484a = null; /* renamed from: b reason: collision with root package name */ public static String f22485b = null; /* renamed from: c reason: collision with root package name */ public static String f22486c = null; /* renamed from: d reason: collision with root package name */ public static String f22487d = "0"; /* renamed from: e reason: collision with root package name */ private static final String[] f22488e = {"46000", "46002", "46004", "46007", "46008"}; /* renamed from: f reason: collision with root package name */ private static final String[] f22489f = {"46003", "46005", "46011"}; /* renamed from: g reason: collision with root package name */ private static final String[] f22490g = {"46001", "46006", "46009"}; private static int a(int i10) { int i11 = a.f156959d; if (i10 != -101) { i11 = -1; if (i10 != -1) { switch (i10) { case 1: case 2: case 4: case 7: case 11: case 16: return 1; case 3: case 5: case 6: case 8: case 9: case 10: case 12: case 14: case 15: case 17: return 2; case 13: case 18: case 19: return 3; case 20: return 4; default: return i10; } } } return i11; } public static NetworkInfo a(Context context) { if (context == null) { return null; } return ((ConnectivityManager) context.getSystemService("connectivity")).getActiveNetworkInfo(); } public static String a() { return f22484a; } public static String a(Context context, boolean z10) { String h10 = h(context); if (h10 != null) { for (String str : f22489f) { if (h10.equals(str)) { return z10 ? "1" : "CT"; } } for (String str2 : f22488e) { if (h10.equals(str2)) { return z10 ? "2" : "CM"; } } for (String str3 : f22490g) { if (h10.equals(str3)) { return z10 ? "3" : "CU"; } } } return z10 ? "0" : "UN"; } public static String b() { return f22485b != null ? "https://open.e.189.cn/openapi/special/getTimeStamp.do".replace(d.a(b.f22450g), f22485b) : "https://open.e.189.cn/openapi/special/getTimeStamp.do"; } public static boolean b(Context context) { NetworkInfo a10 = a(context); return a10 != null && a10.isAvailable(); } public static String c() { String str = f22486c; return str != null ? "https://api-e189.21cn.com/gw/client/accountMsg.do".replace("e189.21cn.com", str) : "https://api-e189.21cn.com/gw/client/accountMsg.do"; } public static boolean c(Context context) { NetworkInfo a10 = a(context); return a10 != null && a10.getType() == 0; } public static boolean d(Context context) { if (context == null) { 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 (Throwable th2) { CtAuth.warn("NetUtil", "isMobileEnable error ", th2); return true; } } public static String e(Context context) { int j10 = j(context); return j10 != -101 ? (j10 == -1 || j10 == 0) ? "null" : j10 != 1 ? j10 != 2 ? j10 != 3 ? j10 != 4 ? Integer.toString(j10) : NetWorkUtils.NETWORK_5G : NetWorkUtils.NETWORK_4G : NetWorkUtils.NETWORK_3G : NetWorkUtils.NETWORK_2G : "WIFI"; } public static String f(Context context) { String e10 = e(context); return (e10 == null || !e10.equals("WIFI") || !d(context)) ? e10 : "BOTH"; } public static String g(Context context) { String f10 = f(context); if (!TextUtils.isEmpty(f10) && !f10.equals("null")) { if (f10.equals(NetWorkUtils.NETWORK_2G)) { return "10"; } if (f10.equals(NetWorkUtils.NETWORK_3G)) { return "11"; } if (f10.equals(NetWorkUtils.NETWORK_4G)) { return "12"; } if (f10.equals(NetWorkUtils.NETWORK_5G)) { return Constants.VIA_REPORT_TYPE_START_WAP; } if (f10.equals("WIFI")) { return "13"; } if (f10.equals("BOTH")) { return "14"; } } return Constants.VIA_REPORT_TYPE_WPA_STATE; } public static String h(Context context) { try { String simOperator = ((TelephonyManager) context.getSystemService("phone")).getSimOperator(); return !TextUtils.isEmpty(simOperator) ? simOperator : "00000"; } catch (Throwable th2) { th2.printStackTrace(); return "00000"; } } public static String i(Context context) { return a(context, true); } private static int j(Context context) { int i10 = 0; try { NetworkInfo a10 = a(context); if (a10 == null || !a10.isAvailable() || !a10.isConnected()) { i10 = -1; return a(i10); } int type = a10.getType(); if (type == 1) { i10 = a.f156959d; } else if (type == 0) { try { i10 = ((TelephonyManager) context.getSystemService("phone")).getNetworkType(); } catch (Exception e10) { e10.printStackTrace(); } if (i10 == 0) { i10 = a10.getSubtype(); } } return a(i10); } catch (NullPointerException e11) { e11.printStackTrace(); } catch (Exception e12) { e12.printStackTrace(); } } }