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 androidx.exifinterface.media.ExifInterface; import cn.com.chinatelecom.account.api.CtAuth; import cn.com.chinatelecom.account.api.a.d; import com.google.android.exoplayer2.source.rtsp.SessionDescription; import java.lang.reflect.Method; public final class h { public static String a; public static String b; public static String c; public static String d; private static final String[] e = {"46000", "46002", "46004", "46007", "46008"}; private static final String[] f = {"46003", "46005", "46011"}; private static final String[] g = {"46001", "46006", "46009"}; public static String a() { return a; } public static String a(Context context, boolean z) { String g2 = g(context); if (g2 != null) { String[] strArr = f; for (int i = 0; i < 3; i++) { if (g2.equals(strArr[i])) { return z ? "1" : "CT"; } } String[] strArr2 = e; for (int i2 = 0; i2 < 5; i2++) { if (g2.equals(strArr2[i2])) { return z ? "2" : "CM"; } } String[] strArr3 = g; for (int i3 = 0; i3 < 3; i3++) { if (g2.equals(strArr3[i3])) { return z ? ExifInterface.GPS_MEASUREMENT_3D : "CU"; } } } return z ? SessionDescription.SUPPORTED_SDP_VERSION : "UN"; } public static boolean a(Context context) { NetworkInfo i = i(context); return i != null && i.isAvailable(); } public static String b() { return b != null ? "https://open.e.189.cn/openapi/special/getTimeStamp.do".replace(d.a(b.c), b) : "https://open.e.189.cn/openapi/special/getTimeStamp.do"; } public static boolean b(Context context) { NetworkInfo i = i(context); return i != null && i.getType() == 0; } public static String c() { String str = c; 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) { 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 th) { CtAuth.warn("NetUtil", "isMobileEnable error ", th); return true; } } public static String d(Context context) { int j = j(context); return j != -101 ? (j == -1 || j == 0) ? "null" : j != 1 ? j != 2 ? j != 3 ? j != 4 ? Integer.toString(j) : "5G" : "4G" : "3G" : "2G" : "WIFI"; } public static String e(Context context) { String d2 = d(context); return (d2 == null || !d2.equals("WIFI") || !c(context)) ? d2 : "BOTH"; } public static String f(Context context) { String e2 = e(context); if (!TextUtils.isEmpty(e2) && !e2.equals("null")) { if (e2.equals("2G")) { return "10"; } if (e2.equals("3G")) { return "11"; } if (e2.equals("4G")) { return "12"; } if (e2.equals("5G")) { return "16"; } if (e2.equals("WIFI")) { return "13"; } if (e2.equals("BOTH")) { return "14"; } } return "15"; } public static String g(Context context) { try { String simOperator = ((TelephonyManager) context.getSystemService("phone")).getSimOperator(); return !TextUtils.isEmpty(simOperator) ? simOperator : "00000"; } catch (Throwable th) { th.printStackTrace(); return "00000"; } } public static String h(Context context) { return a(context, true); } private static NetworkInfo i(Context context) { if (context == null) { return null; } return ((ConnectivityManager) context.getSystemService("connectivity")).getActiveNetworkInfo(); } /* JADX WARNING: Removed duplicated region for block: B:26:0x0047 */ /* JADX WARNING: Removed duplicated region for block: B:34:0x0055 A[RETURN] */ private static int j(Context context) { int i = 0; try { NetworkInfo i2 = i(context); if (i2 == null || !i2.isAvailable() || !i2.isConnected()) { i = -1; if (i != -101) { return -101; } if (i == -1) { return -1; } switch (i) { 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 i; } } else { int type = i2.getType(); if (type == 1) { i = -101; } else if (type == 0) { try { i = ((TelephonyManager) context.getSystemService("phone")).getNetworkType(); } catch (Exception e2) { e2.printStackTrace(); } if (i == 0) { i = i2.getSubtype(); } } if (i != -101) { } } } catch (NullPointerException e3) { e3.printStackTrace(); } catch (Exception e4) { e4.printStackTrace(); } } }