package cn.jiguang.f; import android.content.Context; import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.telephony.TelephonyManager; import android.text.TextUtils; import androidx.core.os.EnvironmentCompat; import androidx.core.view.MotionEventCompat; import cn.jiguang.aq.c; import java.lang.reflect.InvocationTargetException; public class g { public static int a(Context context) { String c = c(context); if (TextUtils.isEmpty(c)) { return 0; } if ("wifi".equals(c)) { return 1; } if ("2g".equals(c)) { return 2; } if ("3g".equals(c)) { return 3; } if ("4g".equals(c)) { return 4; } return "5g".equals(c) ? 5 : 0; } public static String a(int i) { c.a("TeleonyManagerUtils", "getRadioType - networkType:" + i); String str = (i == 4 || i == 7 || i == 5 || i == 6 || i == 12 || i == 14) ? "cdma" : i == 13 ? "lte" : "gsm"; c.a("TeleonyManagerUtils", "getRadioType - radioType:" + str); return str; } public static String a(Context context, int i) { String c = c(context); c.a("TeleonyManagerUtils", "getCurrentNetType - type:" + c); if (TextUtils.isEmpty(c)) { try { Object a = e.a((Class<?>) TelephonyManager.class, "getNetworkClass", new Object[]{Integer.valueOf(i)}, new Class[]{Integer.TYPE}); if (((Integer) a).intValue() == 0) { c = EnvironmentCompat.MEDIA_UNKNOWN; } else if (((Integer) a).intValue() == 1) { c = "2g"; } else if (((Integer) a).intValue() == 2) { c = "3g"; } else if (((Integer) a).intValue() == 3) { c = "4g"; } c.c("TeleonyManagerUtils", "step2 - type:" + c); } catch (Exception | IllegalAccessException | NoSuchMethodException | InvocationTargetException unused) { } } return TextUtils.isEmpty(c) ? EnvironmentCompat.MEDIA_UNKNOWN : c; } private static String b(int i) { c.a("TeleonyManagerUtils", "getNetworkClass networkType:" + i); switch (i) { case 1: case 2: case 4: case 7: case 11: return "2g"; case 3: case 5: case 6: case 8: case 9: case 10: case 12: case 14: case 15: return "3g"; case 13: return "4g"; default: switch (i) { case 16: return "2g"; case MotionEventCompat.AXIS_LTRIGGER: return "3g"; case MotionEventCompat.AXIS_RTRIGGER: case 19: return "4g"; case MotionEventCompat.AXIS_RUDDER: return "5g"; default: return EnvironmentCompat.MEDIA_UNKNOWN; } } } public static String b(Context context) { try { return ((TelephonyManager) context.getSystemService("phone")).getNetworkOperator(); } catch (Exception unused) { return ""; } } public static String c(Context context) { String b; try { NetworkInfo activeNetworkInfo = ((ConnectivityManager) context.getSystemService("connectivity")).getActiveNetworkInfo(); if (activeNetworkInfo == null) { return EnvironmentCompat.MEDIA_UNKNOWN; } if (activeNetworkInfo.getType() == 1) { b = "wifi"; } else if (activeNetworkInfo.getType() != 0) { return EnvironmentCompat.MEDIA_UNKNOWN; } else { b = b(activeNetworkInfo.getSubtype()); } return b; } catch (Exception e) { e.printStackTrace(); return EnvironmentCompat.MEDIA_UNKNOWN; } } }