package com.cmic.sso.sdk.e; import android.content.ContentResolver; import android.content.Context; import android.database.Cursor; import android.net.Uri; import android.os.Build; import android.telephony.SubscriptionInfo; import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; import android.text.TextUtils; import com.cmic.sso.sdk.h.f; import com.cmic.sso.sdk.h.k; import com.cmic.sso.sdk.h.t; import com.kuaishou.weapon.p0.h; import com.umeng.analytics.pro.aq; import java.lang.reflect.Method; import java.util.List; public class b { private static b a; private static long b; private C0029b c = null; public static class a extends Exception { public a(String str) { super(str); } } /* renamed from: com.cmic.sso.sdk.e.b$b reason: collision with other inner class name */ public static class C0029b { private String a = ""; private String b = ""; private String c = ""; private String d = ""; private boolean e = false; private int f = -1; private int g = -1; private int h; private int i; private String j = ""; private String k = ""; private int l = -1; private int m = -1; public String a() { return this.c; } public String a(int i2) { return this.f == i2 ? this.a : this.g == i2 ? this.b : ""; } /* access modifiers changed from: protected */ public void a(String str) { if (str != null) { this.c = str; } } /* access modifiers changed from: protected */ public void a(boolean z) { } public String b() { return this.d; } /* access modifiers changed from: protected */ public void b(int i2) { this.l = i2; } /* access modifiers changed from: protected */ public void b(String str) { if (str != null) { this.d = str; } } /* access modifiers changed from: protected */ public void b(boolean z) { this.e = z; } public String c() { return this.k; } /* access modifiers changed from: protected */ public void c(int i2) { this.f = i2; } /* access modifiers changed from: protected */ public void c(String str) { if (str != null) { this.j = str; } } /* access modifiers changed from: protected */ public void d(int i2) { this.g = i2; } /* access modifiers changed from: protected */ public void d(String str) { this.k = str; } public boolean d() { return this.e; } public int e() { return this.l; } /* access modifiers changed from: protected */ public void e(int i2) { } public int f() { return this.f; } /* access modifiers changed from: protected */ public void f(int i2) { } public int g() { return this.g; } public String g(int i2) { return this.f == i2 ? this.c : this.g == i2 ? this.d : ""; } public int h() { if (!TextUtils.isEmpty(this.d) && !TextUtils.isEmpty(this.c)) { return 2; } if (TextUtils.isEmpty(this.j) || TextUtils.isEmpty(this.k)) { return (!TextUtils.isEmpty(this.c) || !TextUtils.isEmpty(this.d) || !TextUtils.isEmpty(this.j) || !TextUtils.isEmpty(this.k)) ? 1 : 0; } return 2; } public String h(int i2) { return this.f == i2 ? this.j : this.g == i2 ? this.k : ""; } } private b() { } private SubscriptionInfo a(Object obj, String str, Object[] objArr) throws a { return (SubscriptionInfo) a(obj, str, objArr, null); } private SubscriptionInfo a(List<SubscriptionInfo> list, int i) { SubscriptionInfo subscriptionInfo = list.get(0); for (SubscriptionInfo subscriptionInfo2 : list) { if (subscriptionInfo2.getSimSlotIndex() == i) { subscriptionInfo = subscriptionInfo2; } } return subscriptionInfo; } public static b a() { if (a == null) { a = new b(); } return a; } private Object a(Object obj, String str, Object[] objArr, Class[] clsArr) throws a { try { Class<?> cls = Class.forName(obj.getClass().getName()); return (objArr == null || clsArr == null) ? cls.getMethod(str, new Class[0]).invoke(obj, new Object[0]) : cls.getMethod(str, clsArr).invoke(obj, objArr); } catch (Exception unused) { f.a("UMCTelephonyManagement", str + " 反射出错"); throw new a(str); } } private String a(TelephonyManager telephonyManager, String str, int i) throws a { Object a2 = a(telephonyManager, str, new Object[]{Integer.valueOf(i)}, new Class[]{Integer.TYPE}); if (a2 != null) { return a2.toString(); } return null; } private String a(String str) { if (TextUtils.isEmpty(str)) { return ""; } f.b("UMCTelephonyManagement", "operatorChina = ".concat(String.valueOf(str))); return str.contains("中国移动") ? "46000" : str.contains("中国联通") ? "46001" : str.contains("中国电信") ? "46003" : ""; } /* JADX WARNING: Can't wrap try/catch for region: R(3:34|35|36) */ /* JADX WARNING: Can't wrap try/catch for region: R(4:24|25|26|27) */ /* JADX WARNING: Code restructure failed: missing block: B:25:?, code lost: r4.c.a(a(r6, "getSubscriberIdGemini", r0)); */ /* JADX WARNING: Code restructure failed: missing block: B:27:?, code lost: r4.c.a(r6.getSubscriberId()); */ /* JADX WARNING: Code restructure failed: missing block: B:28:0x00cb, code lost: r1 = move-exception; */ /* JADX WARNING: Code restructure failed: missing block: B:29:0x00cc, code lost: r1.printStackTrace(); */ /* JADX WARNING: Code restructure failed: missing block: B:35:?, code lost: r4.c.c(a(r6, "getSimOperatorGemini", r0)); */ /* JADX WARNING: Code restructure failed: missing block: B:36:0x00ea, code lost: return; */ /* JADX WARNING: Code restructure failed: missing block: B:37:0x00eb, code lost: r4.c.c(r6.getSimOperator()); */ /* JADX WARNING: Code restructure failed: missing block: B:39:?, code lost: return; */ /* JADX WARNING: Failed to process nested try/catch */ /* JADX WARNING: Missing exception handler attribute for start block: B:24:0x00b5 */ /* JADX WARNING: Missing exception handler attribute for start block: B:26:0x00c1 */ /* JADX WARNING: Missing exception handler attribute for start block: B:34:0x00df */ private void a(List<SubscriptionInfo> list, TelephonyManager telephonyManager) { SubscriptionInfo subscriptionInfo; int size = list != null ? list.size() : 0; if (size == 1) { subscriptionInfo = list.get(0); } else if (size > 1) { subscriptionInfo = a(list, 0); } else { return; } this.c.a = subscriptionInfo.getIccId(); this.c.c(subscriptionInfo.getSimSlotIndex()); this.c.e(subscriptionInfo.getSubscriptionId()); C0029b bVar = this.c; bVar.j = b(bVar.a); f.b("UMCTelephonyManagement", "readSim1Info1 iccid1 = " + this.c.a); if (this.c.l == -1 && this.c.m == subscriptionInfo.getSubscriptionId()) { this.c.l = subscriptionInfo.getSimSlotIndex(); f.b("UMCTelephonyManagement", "readSim1Info1 dataSlotId = " + this.c.l); } if (t.e()) { int simSlotIndex = a.a() == 0 ? subscriptionInfo.getSimSlotIndex() : subscriptionInfo.getSubscriptionId(); this.c.a(a(telephonyManager, "getSubscriberId", subscriptionInfo.getSubscriptionId())); this.c.c(a(telephonyManager, "getSimOperator", subscriptionInfo.getSubscriptionId())); } } /* JADX INFO: Can't fix incorrect switch cases order, some code will duplicate */ /* JADX WARNING: Code restructure failed: missing block: B:15:0x004f, code lost: if (r6.equals("898607") == false) goto L_0x002f; */ private String b(String str) { char c2 = 6; if (TextUtils.isEmpty(str) && str.length() < 6) { return ""; } String substring = str.substring(0, 6); f.b("UMCTelephonyManagement", "operatorFlag = ".concat(String.valueOf(substring))); substring.hashCode(); switch (substring.hashCode()) { case 1657594879: if (substring.equals("898600")) { c2 = 0; break; } c2 = 65535; break; case 1657594880: if (substring.equals("898601")) { c2 = 1; break; } c2 = 65535; break; case 1657594881: if (substring.equals("898602")) { c2 = 2; break; } c2 = 65535; break; case 1657594882: if (substring.equals("898603")) { c2 = 3; break; } c2 = 65535; break; case 1657594883: if (substring.equals("898604")) { c2 = 4; break; } c2 = 65535; break; case 1657594885: if (substring.equals("898606")) { c2 = 5; break; } c2 = 65535; break; case 1657594886: break; case 1657594888: if (substring.equals("898609")) { c2 = 7; break; } c2 = 65535; break; case 1657594911: if (substring.equals("898611")) { c2 = '\b'; break; } c2 = 65535; break; default: c2 = 65535; break; } switch (c2) { case 0: case 2: case 4: case 6: return "46000"; case 1: case 5: case 7: return "46001"; case 3: case '\b': return "46003"; default: return ""; } } /* JADX WARNING: Code restructure failed: missing block: B:73:0x024b, code lost: if (r12 != null) goto L_0x0258; */ /* JADX WARNING: Code restructure failed: missing block: B:79:0x0255, code lost: if (0 != 0) goto L_0x0258; */ /* JADX WARNING: Code restructure failed: missing block: B:80:0x0258, code lost: r12.close(); */ /* JADX WARNING: Code restructure failed: missing block: B:81:0x025b, code lost: com.cmic.sso.sdk.h.f.b("UMCTelephonyManagement", "readSimInfoDbEnd"); */ /* JADX WARNING: Code restructure failed: missing block: B:82:0x0260, code lost: return; */ private void b(Context context) { f.b("UMCTelephonyManagement", "readSimInfoDbStart"); Uri parse = Uri.parse("content://telephony/siminfo"); ContentResolver contentResolver = context.getContentResolver(); Cursor cursor = null; try { cursor = contentResolver.query(parse, new String[]{aq.d, "icc_id", "sim_id", "mcc", "mnc", "carrier_name"}, "sim_id>=?", new String[]{"0"}, null); if (cursor != null) { while (cursor.moveToNext()) { String string = cursor.getString(cursor.getColumnIndex("icc_id")); int i = cursor.getInt(cursor.getColumnIndex("sim_id")); int i2 = cursor.getInt(cursor.getColumnIndex(aq.d)); String string2 = cursor.getString(cursor.getColumnIndex("mcc")); String string3 = cursor.getString(cursor.getColumnIndex("mnc")); String string4 = cursor.getString(cursor.getColumnIndex("carrier_name")); if (this.c.l == -1 && this.c.m != -1 && this.c.m == i2) { this.c.l = i; f.b("UMCTelephonyManagement", "通过读取sim db获取数据流量卡的卡槽值:" + i); } if (this.c.l == i && !t.d()) { this.c.m = i2; } if (i == 0) { this.c.a = string; this.c.h = i2; if (this.c.f == -1) { this.c.f = i; } if (TextUtils.isEmpty(this.c.j) && !TextUtils.isEmpty(string4)) { String a2 = a(string4); if (!TextUtils.isEmpty(a2)) { this.c.j = a2; } } if (TextUtils.isEmpty(this.c.j)) { String b2 = b(string); if (!TextUtils.isEmpty(b2)) { this.c.j = b2; } } if (TextUtils.isEmpty(this.c.j) && !TextUtils.isEmpty(string2) && !TextUtils.isEmpty(string3)) { if (string3.length() == 1) { string3 = "0" + string3; } this.c.j = string2 + string3; } } else if (i == 1) { this.c.b = string; this.c.i = i2; if (this.c.g == -1) { this.c.g = i; } if (TextUtils.isEmpty(this.c.k) && !TextUtils.isEmpty(string4)) { String a3 = a(string4); if (!TextUtils.isEmpty(a3)) { this.c.k = a3; } } if (TextUtils.isEmpty(this.c.k)) { String b3 = b(string); if (!TextUtils.isEmpty(b3)) { this.c.k = b3; } } if (TextUtils.isEmpty(this.c.k) && !TextUtils.isEmpty(string2) && !TextUtils.isEmpty(string3)) { if (string3.length() == 1) { string3 = "0" + string3; } this.c.k = string2 + string3; } } f.b("UMCTelephonyManagement", "icc_id-->" + string); f.b("UMCTelephonyManagement", "sim_id-->" + i); f.b("UMCTelephonyManagement", "subId或者说是_id->" + i2); f.b("UMCTelephonyManagement", "mcc_string--->" + string3); f.b("UMCTelephonyManagement", "mnc_string--->" + string2); f.b("UMCTelephonyManagement", "carrier_name----->" + string4); f.b("UMCTelephonyManagement", "---------------------------------"); } } } catch (Exception unused) { f.a("UMCTelephonyManagement", "readSimInfoDb error"); } catch (Throwable th) { if (0 != 0) { cursor.close(); } throw th; } } private void b(Context context, boolean z) { if (Build.VERSION.SDK_INT >= 22) { SubscriptionManager from = SubscriptionManager.from(context.getApplicationContext()); if (from != null) { if (z) { try { SubscriptionInfo a2 = a(from, "getDefaultDataSubscriptionInfo", (Object[]) null); if (a2 != null) { this.c.l = a2.getSimSlotIndex(); this.c.m = a2.getSubscriptionId(); f.b("UMCTelephonyManagement", "getDefaultDataSubscriptionInfo适配成功: dataSlotId即sim_id = " + this.c.l); f.b("UMCTelephonyManagement", "getDefaultDataSubscriptionInfo适配成功: dataSubId = " + this.c.m); return; } } catch (Exception unused) { f.a("UMCTelephonyManagement", "readDefaultDataSubId-->getDefaultDataSubscriptionInfo 反射出错"); } } try { if (this.c.l == -1 && Build.VERSION.SDK_INT >= 24) { this.c.m = SubscriptionManager.getDefaultDataSubscriptionId(); f.b("UMCTelephonyManagement", "android 7.0及以上手机getDefaultDataSubscriptionId适配成功: dataSubId = " + this.c.m); return; } } catch (Exception unused2) { f.a("UMCTelephonyManagement", "android 7.0及以上手机getDefaultDataSubscriptionId适配失败"); } try { Method method = from.getClass().getMethod("getDefaultDataSubId", new Class[0]); if (method != null) { this.c.m = ((Integer) method.invoke(from, new Object[0])).intValue(); f.b("UMCTelephonyManagement", "android 7.0以下手机getDefaultDataSubId适配成功: dataSubId = " + this.c.m); return; } } catch (Exception unused3) { f.a("UMCTelephonyManagement", "readDefaultDataSubId-->getDefaultDataSubId 反射出错"); } try { Method method2 = from.getClass().getMethod("getDefaultDataSubscriptionId", new Class[0]); if (method2 != null) { this.c.m = ((Integer) method2.invoke(from, new Object[0])).intValue(); f.b("UMCTelephonyManagement", "反射getDefaultDataSubscriptionId适配成功: dataSubId = " + this.c.m); } } catch (Exception unused4) { f.a("UMCTelephonyManagement", "getDefaultDataSubscriptionId-->getDefaultDataSubscriptionId 反射出错"); } } } else { this.c.l = -1; } } /* JADX WARNING: Code restructure failed: missing block: B:20:?, code lost: r4.c.b(a(r6, "getSubscriberIdGemini", r1)); */ /* JADX WARNING: Code restructure failed: missing block: B:21:0x00b3, code lost: r0 = move-exception; */ /* JADX WARNING: Code restructure failed: missing block: B:22:0x00b4, code lost: r0.printStackTrace(); */ /* JADX WARNING: Code restructure failed: missing block: B:28:?, code lost: r4.c.d(a(r6, "getSimOperatorGemini", r1)); */ /* JADX WARNING: Code restructure failed: missing block: B:29:0x00d2, code lost: return; */ /* JADX WARNING: Code restructure failed: missing block: B:30:0x00d3, code lost: r5 = move-exception; */ /* JADX WARNING: Code restructure failed: missing block: B:31:0x00d4, code lost: r5.printStackTrace(); */ /* JADX WARNING: Code restructure failed: missing block: B:32:?, code lost: return; */ /* JADX WARNING: Failed to process nested try/catch */ /* JADX WARNING: Missing exception handler attribute for start block: B:19:0x00a7 */ /* JADX WARNING: Missing exception handler attribute for start block: B:27:0x00c7 */ private void b(List<SubscriptionInfo> list, TelephonyManager telephonyManager) { int i = 1; if ((list != null ? list.size() : 0) > 1) { SubscriptionInfo a2 = a(list, 1); this.c.d(a2.getSimSlotIndex()); this.c.f(a2.getSubscriptionId()); this.c.b = a2.getIccId(); C0029b bVar = this.c; bVar.k = b(bVar.b); f.b("UMCTelephonyManagement", "readSim1Info2 iccid2 = " + this.c.b); if (this.c.l == -1 && this.c.m == a2.getSubscriptionId()) { this.c.l = a2.getSimSlotIndex(); f.b("UMCTelephonyManagement", "readSim1Info2 dataSlotId = " + this.c.l); } if (t.e()) { if (a.a() != 0) { i = a2.getSubscriptionId(); } this.c.b(a(telephonyManager, "getSubscriberId", a2.getSubscriptionId())); this.c.d(a(telephonyManager, "getSimOperator", a2.getSubscriptionId())); } } } private boolean b(TelephonyManager telephonyManager, String str, int i) throws a { Object a2 = a(telephonyManager, str, new Object[]{Integer.valueOf(i)}, new Class[]{Integer.TYPE}); return a2 != null && Integer.parseInt(a2.toString()) == 5; } private void c(Context context) { List<SubscriptionInfo> e; TelephonyManager telephonyManager = (TelephonyManager) context.getApplicationContext().getSystemService("phone"); if (telephonyManager != null && (e = e(context)) != null && e.size() > 0) { a(e, telephonyManager); b(e, telephonyManager); } } /* JADX WARNING: Can't wrap try/catch for region: R(17:0|1|2|3|4|(2:5|6)|9|10|(2:11|12)|19|20|21|22|25|(2:32|(2:37|(1:44)(2:41|42))(1:36))(1:29)|30|31) */ /* JADX WARNING: Failed to process nested try/catch */ /* JADX WARNING: Missing exception handler attribute for start block: B:11:0x0071 */ /* JADX WARNING: Missing exception handler attribute for start block: B:21:0x00a7 */ /* JADX WARNING: Missing exception handler attribute for start block: B:3:0x003d */ /* JADX WARNING: Missing exception handler attribute for start block: B:5:0x0050 */ private void d(Context context) { TelephonyManager telephonyManager = (TelephonyManager) context.getApplicationContext().getSystemService("phone"); this.c.c(0); this.c.d(1); this.c.b(-1); this.c.a(a(telephonyManager, "getSubscriberId", 0)); this.c.b(a(telephonyManager, "getSubscriberId", 1)); this.c.a(a(telephonyManager, "getSubscriberIdGemini", 0)); this.c.b(a(telephonyManager, "getSubscriberIdGemini", 1)); try { this.c.a(telephonyManager.getSubscriberId()); } catch (Exception e) { e.printStackTrace(); } this.c.a(b(telephonyManager, "getSimState", 0)); this.c.b(b(telephonyManager, "getSimState", 1)); try { this.c.a(b(telephonyManager, "getSimStateGemini", 0)); this.c.b(b(telephonyManager, "getSimStateGemini", 1)); } catch (a unused) { this.c.a(telephonyManager.getSimState() == 5); } this.c.c(a(telephonyManager, "getSimOperator", 0)); this.c.d(a(telephonyManager, "getSimOperator", 1)); try { this.c.c(a(telephonyManager, "getSimOperatorGemini", 0)); this.c.d(a(telephonyManager, "getSimOperatorGemini", 1)); } catch (a unused2) { this.c.c(telephonyManager.getSimOperator()); } if (TextUtils.isEmpty(this.c.a()) && !TextUtils.isEmpty(this.c.b())) { C0029b bVar = this.c; bVar.a(bVar.b()); this.c.b(""); C0029b bVar2 = this.c; bVar2.c(bVar2.g()); this.c.d(-1); C0029b bVar3 = this.c; bVar3.a(bVar3.d()); this.c.b(false); C0029b bVar4 = this.c; bVar4.c(bVar4.c()); this.c.d(""); } else if (!TextUtils.isEmpty(this.c.a()) && TextUtils.isEmpty(this.c.b())) { this.c.b(false); this.c.d(-1); } else if (TextUtils.isEmpty(this.c.a()) && TextUtils.isEmpty(this.c.b())) { this.c.c(-1); this.c.d(-1); this.c.a(false); this.c.b(false); this.c.b(-1); return; } else { return; } C0029b bVar5 = this.c; bVar5.b(bVar5.f()); } private List<SubscriptionInfo> e(Context context) { SubscriptionManager from = SubscriptionManager.from(context.getApplicationContext()); if (from != null) { return from.getActiveSubscriptionInfoList(); } return null; } private int f(Context context) { TelephonyManager telephonyManager; if (!k.a(context, h.c) || (telephonyManager = (TelephonyManager) context.getApplicationContext().getSystemService("phone")) == null) { return -1; } if (!t.e()) { return telephonyManager.getDataNetworkType(); } try { Method method = telephonyManager.getClass().getMethod("getDataNetworkType", Integer.TYPE); f.b("UMCTelephonyManagement", "data dataNetworkType defaultDataSubId = " + this.c.m); int intValue = ((Integer) method.invoke(telephonyManager, Integer.valueOf(this.c.m))).intValue(); f.b("UMCTelephonyManagement", "data dataNetworkType ---------" + intValue); if (intValue != 0 || Build.VERSION.SDK_INT < 24) { return intValue; } f.b("UMCTelephonyManagement", "data dataNetworkType ---->=N " + intValue); return telephonyManager.getDataNetworkType(); } catch (Exception e) { f.a("UMCTelephonyManagement", "data dataNetworkType ----反射出错-----"); e.printStackTrace(); return -1; } } public String a(Context context) { switch (f(context)) { 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 "0"; } } public void a(Context context, boolean z) { if (System.currentTimeMillis() - b >= 5000) { this.c = new C0029b(); if (t.b(context)) { b(context, z); if (t.d() && t.e()) { f.b("UMCTelephonyManagement", "华为手机兼容性处理"); if (this.c.m == 0 || this.c.m == 1) { C0029b bVar = this.c; bVar.l = bVar.m; } } if (z) { try { if (Build.VERSION.SDK_INT >= 22) { c(context); } else { d(context); } } catch (Exception unused) { f.a("UMCTelephonyManagement", "read sim info error"); } } if (Build.VERSION.SDK_INT >= 21) { b(context); } b = System.currentTimeMillis(); } } } public C0029b b() { C0029b bVar = this.c; return bVar == null ? new C0029b() : bVar; } }