package com.amap.api.services.a; import android.content.Context; import android.os.Build; import android.text.TextUtils; import cn.xiaochuankeji.octoflutter.webapi.http.BindingHttpRequest; import com.eclipsesource.v8.Platform; import com.inno.innosdk.pb.InnoMain; import com.tonyodev.fetch2core.server.FileResponse; import java.net.URLDecoder; import java.util.HashMap; import java.util.Map; import javax.crypto.Cipher; import javax.crypto.IllegalBlockSizeException; import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.SecretKeySpec; import kotlinx.coroutines.DebugKt; import okhttp3.HttpUrl; import org.json.JSONException; import org.json.JSONObject; public class bh { /* renamed from: a reason: collision with root package name */ public static int f16212a = -1; /* renamed from: b reason: collision with root package name */ public static String f16213b = ""; public static class b extends dg { private String c; private Map<String, String> d; private boolean e; public b(Context context, bp bpVar, String str, Map<String, String> map) { super(context, bpVar); this.c = str; this.d = map; this.e = Build.VERSION.SDK_INT != 19; } private Map<String, String> r() { String v = bk.v(this.f16332a); if (TextUtils.isEmpty(v)) { v = bk.i(this.f16332a); } if (!TextUtils.isEmpty(v)) { v = bn.b(new StringBuilder(v).reverse().toString()); } HashMap hashMap = new HashMap(); hashMap.put("authkey", this.c); hashMap.put("plattype", Platform.ANDROID); hashMap.put(InnoMain.INNO_KEY_PRODUCT, this.f16333b.a()); hashMap.put("version", this.f16333b.b()); hashMap.put("output", BindingHttpRequest.JSON); hashMap.put("androidversion", Build.VERSION.SDK_INT + ""); hashMap.put("deviceId", v); hashMap.put("manufacture", Build.MANUFACTURER); Map<String, String> map = this.d; if (map != null && !map.isEmpty()) { hashMap.putAll(this.d); } hashMap.put("abitype", bq.a(this.f16332a)); hashMap.put("ext", this.f16333b.d()); return hashMap; } public boolean a() { return this.e; } @Override // com.amap.api.services.a.dg public byte[] b() { return null; } @Override // com.amap.api.services.a.dg public byte[] c() { return bq.a(bq.a(r())); } @Override // com.amap.api.services.a.dk public Map<String, String> e() { return null; } @Override // com.amap.api.services.a.dg public String f() { return "3.0"; } @Override // com.amap.api.services.a.dk public String i() { return this.e ? "https://restapi.amap.com/v3/iasdkauth" : "http://restapi.amap.com/v3/iasdkauth"; } } public static boolean a(String str, boolean z) { try { if (TextUtils.isEmpty(str)) { return z; } String[] split = URLDecoder.decode(str).split("/"); if (split[split.length - 1].charAt(4) % 2 == 1) { return true; } return false; } catch (Throwable unused) { return z; } } public static class a { @Deprecated public c A; public c B; public b C; public b D; public b E; public b F; public f G; private boolean H; /* renamed from: a reason: collision with root package name */ public String f16214a; /* renamed from: b reason: collision with root package name */ public int f16215b = -1; @Deprecated public JSONObject c; @Deprecated public JSONObject d; @Deprecated public JSONObject e; @Deprecated public JSONObject f; @Deprecated public JSONObject g; @Deprecated public JSONObject h; @Deprecated public JSONObject i; @Deprecated public JSONObject j; @Deprecated public JSONObject k; @Deprecated public JSONObject l; @Deprecated public JSONObject m; @Deprecated public JSONObject n; @Deprecated public JSONObject o; @Deprecated public JSONObject p; @Deprecated public JSONObject q; @Deprecated public JSONObject r; @Deprecated public JSONObject s; @Deprecated public JSONObject t; @Deprecated public JSONObject u; @Deprecated public JSONObject v; public JSONObject w; public C0131a x; public d y; public e z; /* renamed from: com.amap.api.services.a.bh$a$a reason: collision with other inner class name */ public static class C0131a { /* renamed from: a reason: collision with root package name */ public boolean f16216a; /* renamed from: b reason: collision with root package name */ public boolean f16217b; public JSONObject c; } public static class b { /* renamed from: a reason: collision with root package name */ public boolean f16218a; /* renamed from: b reason: collision with root package name */ public String f16219b; public String c; public String d; public boolean e; } public static class c { /* renamed from: a reason: collision with root package name */ public String f16220a; /* renamed from: b reason: collision with root package name */ public String f16221b; } public static class d { /* renamed from: a reason: collision with root package name */ public String f16222a; /* renamed from: b reason: collision with root package name */ public String f16223b; public String c; } public static class e { /* renamed from: a reason: collision with root package name */ public boolean f16224a; } public static class f { /* renamed from: a reason: collision with root package name */ public boolean f16225a; /* renamed from: b reason: collision with root package name */ public boolean f16226b; public boolean c; public String d; public String e; public String f; } public boolean a() { return this.H; } } public static a a(Context context, bp bpVar, String str, Map<String, String> map) { return a(context, bpVar, str, map, false); } /* JADX WARNING: Removed duplicated region for block: B:98:0x018a A[RETURN] */ /* JADX WARNING: Removed duplicated region for block: B:99:0x018b */ public static a a(Context context, bp bpVar, String str, Map<String, String> map, boolean z) { String str2; String str3; String str4; String str5; String str6; byte[] bArr; dm dmVar; String str7; bf e; Throwable th; bf e2; String sb; a aVar = new a(); aVar.w = new JSONObject(); bm.a().a(context); String str8 = null; try { df dfVar = new df(); try { StringBuilder sb2 = new StringBuilder(); str6 = "11K"; try { sb2.append(str); sb2.append(";14N;"); sb2.append("15K"); sb2.append(";"); sb2.append("16H"); sb = sb2.toString(); } catch (bf e3) { e2 = e3; throw e2; } catch (Throwable unused) { str5 = "16H"; str2 = "result"; str3 = ";"; str4 = str; try { throw new bf("未知的错误"); } catch (bf e4) { e = e4; dmVar = null; bArr = null; aVar.f16214a = e.a(); cc.a(bpVar, "/v3/iasdkauth", e); if (bArr == null) { } } catch (IllegalBlockSizeException unused2) { dmVar = null; bArr = null; if (bArr == null) { } } catch (Throwable th2) { th = th2; dmVar = null; bArr = null; cc.c(th, "at", "lc"); if (bArr == null) { } } } try { str5 = "16H"; try { b bVar = new b(context, bpVar, sb, map); dmVar = dfVar.a(bVar, bVar.a()); if (dmVar != null) { try { bArr = dmVar.f16344a; } catch (bf e5) { e = e5; str4 = sb; str2 = "result"; str3 = ";"; bArr = null; aVar.f16214a = e.a(); cc.a(bpVar, "/v3/iasdkauth", e); if (bArr == null) { } } catch (IllegalBlockSizeException unused3) { str4 = sb; str2 = "result"; str3 = ";"; bArr = null; } catch (Throwable th3) { th = th3; str4 = sb; str2 = "result"; str3 = ";"; bArr = null; cc.c(th, "at", "lc"); if (bArr == null) { } } } else { bArr = null; } dmVar = dmVar; } catch (bf e6) { e2 = e6; throw e2; } catch (Throwable unused4) { str4 = sb; str2 = "result"; str3 = ";"; throw new bf("未知的错误"); } } catch (bf e7) { e2 = e7; throw e2; } catch (Throwable unused5) { str5 = "16H"; str4 = sb; str2 = "result"; str3 = ";"; throw new bf("未知的错误"); } } catch (bf e8) { e2 = e8; throw e2; } catch (Throwable unused6) { str5 = "16H"; str6 = "11K"; str2 = "result"; str3 = ";"; str4 = str; throw new bf("未知的错误"); } try { byte[] bArr2 = new byte[16]; str4 = sb; try { byte[] bArr3 = new byte[(bArr.length - 16)]; str3 = ";"; try { System.arraycopy(bArr, 0, bArr2, 0, 16); str2 = "result"; try { System.arraycopy(bArr, 16, bArr3, 0, bArr.length - 16); SecretKeySpec secretKeySpec = new SecretKeySpec(bArr2, com.kuaishou.weapon.p0.b.f18974b); Cipher instance = Cipher.getInstance(com.kuaishou.weapon.p0.b.f18973a); instance.init(2, secretKeySpec, new IvParameterSpec(bq.c())); str8 = bq.a(instance.doFinal(bArr3)); } catch (bf e9) { e = e9; dmVar = dmVar; aVar.f16214a = e.a(); cc.a(bpVar, "/v3/iasdkauth", e); if (bArr == null) { } } catch (IllegalBlockSizeException unused7) { } catch (Throwable th4) { th = th4; dmVar = dmVar; cc.c(th, "at", "lc"); if (bArr == null) { } } } catch (bf e10) { e = e10; str2 = "result"; dmVar = dmVar; aVar.f16214a = e.a(); cc.a(bpVar, "/v3/iasdkauth", e); if (bArr == null) { } } catch (IllegalBlockSizeException unused8) { str2 = "result"; } catch (Throwable th5) { th = th5; str2 = "result"; dmVar = dmVar; cc.c(th, "at", "lc"); if (bArr == null) { } } } catch (bf e11) { e = e11; str2 = "result"; str3 = ";"; dmVar = dmVar; aVar.f16214a = e.a(); cc.a(bpVar, "/v3/iasdkauth", e); if (bArr == null) { } } catch (IllegalBlockSizeException unused9) { str2 = "result"; str3 = ";"; dmVar = dmVar; if (bArr == null) { } } catch (Throwable th6) { th = th6; str2 = "result"; str3 = ";"; dmVar = dmVar; cc.c(th, "at", "lc"); if (bArr == null) { } } } catch (bf e12) { e = e12; str4 = sb; str2 = "result"; str3 = ";"; dmVar = dmVar; aVar.f16214a = e.a(); cc.a(bpVar, "/v3/iasdkauth", e); if (bArr == null) { } } catch (IllegalBlockSizeException unused10) { str4 = sb; str2 = "result"; str3 = ";"; dmVar = dmVar; if (bArr == null) { } } catch (Throwable th7) { th = th7; str4 = sb; str2 = "result"; str3 = ";"; dmVar = dmVar; cc.c(th, "at", "lc"); if (bArr == null) { } } } catch (bf e13) { e = e13; str5 = "16H"; str6 = "11K"; str2 = "result"; str3 = ";"; str4 = str; dmVar = null; bArr = null; aVar.f16214a = e.a(); cc.a(bpVar, "/v3/iasdkauth", e); if (bArr == null) { } } catch (IllegalBlockSizeException unused11) { str5 = "16H"; str6 = "11K"; str2 = "result"; str3 = ";"; str4 = str; dmVar = null; bArr = null; if (bArr == null) { } } catch (Throwable th8) { th = th8; str5 = "16H"; str6 = "11K"; str2 = "result"; str3 = ";"; str4 = str; dmVar = null; bArr = null; cc.c(th, "at", "lc"); if (bArr == null) { } } if (bArr == null) { return aVar; } if (TextUtils.isEmpty(str8)) { str8 = bq.a(bArr); } try { JSONObject jSONObject = new JSONObject(str8); if (jSONObject.has("status")) { int i = jSONObject.getInt("status"); if (i == 1) { f16212a = 1; } else if (i == 0) { String str9 = "authcsid"; String str10 = "authgsid"; if (dmVar != null) { str9 = dmVar.c; str10 = dmVar.d; } bq.a(context, str9, str10, jSONObject); f16212a = 0; if (jSONObject.has("info")) { f16213b = jSONObject.getString("info"); } if (jSONObject.has("infocode")) { str7 = jSONObject.getString("infocode"); } else { str7 = ""; } cc.a(bpVar, "/v3/iasdkauth", f16213b, str10, str7); if (f16212a == 0) { aVar.f16214a = f16213b; return aVar; } } try { if (jSONObject.has("ver")) { aVar.f16215b = jSONObject.getInt("ver"); } } catch (Throwable th9) { bz.a(th9, "at", "lc"); } if (bq.a(jSONObject, str2)) { a.C0131a aVar2 = new a.C0131a(); aVar2.f16216a = false; aVar2.f16217b = false; aVar.x = aVar2; JSONObject jSONObject2 = jSONObject.getJSONObject(str2); try { String[] split = str4.split(str3); if (split != null && split.length > 0) { for (String str11 : split) { if (jSONObject2.has(str11)) { aVar.w.putOpt(str11, jSONObject2.get(str11)); } } } } catch (Throwable th10) { bz.a(th10, "at", "co"); } if (bq.a(jSONObject2, str5)) { aVar.H = a(jSONObject2.getJSONObject(str5).optString("able"), false); } if (bq.a(jSONObject2, str6)) { try { JSONObject jSONObject3 = jSONObject2.getJSONObject(str6); aVar2.f16216a = a(jSONObject3.getString("able"), false); if (jSONObject3.has(DebugKt.DEBUG_PROPERTY_VALUE_OFF)) { aVar2.c = jSONObject3.getJSONObject(DebugKt.DEBUG_PROPERTY_VALUE_OFF); } } catch (Throwable th11) { bz.a(th11, "AuthConfigManager", "loadException"); } } if (bq.a(jSONObject2, "001")) { JSONObject jSONObject4 = jSONObject2.getJSONObject("001"); a.d dVar = new a.d(); a(jSONObject4, dVar); aVar.y = dVar; } if (bq.a(jSONObject2, "002")) { JSONObject jSONObject5 = jSONObject2.getJSONObject("002"); a.c cVar = new a.c(); a(jSONObject5, cVar); aVar.A = cVar; } if (bq.a(jSONObject2, "14S")) { JSONObject jSONObject6 = jSONObject2.getJSONObject("14S"); a.c cVar2 = new a.c(); a(jSONObject6, cVar2); aVar.B = cVar2; } a(aVar, jSONObject2); if (bq.a(jSONObject2, "14Z")) { JSONObject jSONObject7 = jSONObject2.getJSONObject("14Z"); a.f fVar = new a.f(); a(jSONObject7, fVar); aVar.G = fVar; } if (bq.a(jSONObject2, "151")) { JSONObject jSONObject8 = jSONObject2.getJSONObject("151"); a.e eVar = new a.e(); a(jSONObject8, eVar); aVar.z = eVar; } a(aVar, jSONObject2); if (bq.a(jSONObject2, "14N")) { JSONObject jSONObject9 = jSONObject2.getJSONObject("14N"); a.b bVar2 = new a.b(); bVar2.f16218a = a(jSONObject9.optString("able"), false); bVar2.f16219b = jSONObject9.optString("url"); bVar2.c = jSONObject9.optString(FileResponse.FIELD_MD5); if (bVar2.f16218a) { bp a2 = bx.a(); if (a2 != null) { co coVar = new co(bVar2.f16219b, bVar2.c, "", aVar.H); coVar.a(z); new cn(context, coVar, a2).a(); } } else { ct.a(context, "aiu"); } } a(context, jSONObject2); } } } catch (Throwable th12) { bz.a(th12, "at", "lc"); } return aVar; } private static void a(Context context, JSONObject jSONObject) { try { JSONObject jSONObject2 = jSONObject.getJSONObject("15K"); boolean a2 = a(jSONObject2.optString("isTargetAble"), false); if (!a(jSONObject2.optString("able"), false)) { bm.a().b(context); } else { bm.a().a(context, a2); } } catch (Throwable th) { th.printStackTrace(); } } public static String a(JSONObject jSONObject, String str) throws JSONException { if (jSONObject != null && jSONObject.has(str) && !jSONObject.getString(str).equals(HttpUrl.PATH_SEGMENT_ENCODE_SET_URI)) { return jSONObject.optString(str); } return ""; } private static void a(JSONObject jSONObject, a.b bVar) { if (bVar != null) { try { String a2 = a(jSONObject, "m"); String a3 = a(jSONObject, "u"); String a4 = a(jSONObject, "v"); String a5 = a(jSONObject, "able"); String a6 = a(jSONObject, DebugKt.DEBUG_PROPERTY_VALUE_ON); bVar.c = a2; bVar.f16219b = a3; bVar.d = a4; bVar.f16218a = a(a5, false); bVar.e = a(a6, true); } catch (Throwable th) { bz.a(th, "at", "pe"); } } } private static void a(JSONObject jSONObject, a.f fVar) { if (fVar != null) { try { String a2 = a(jSONObject, FileResponse.FIELD_MD5); String a3 = a(jSONObject, "md5info"); String a4 = a(jSONObject, "url"); String a5 = a(jSONObject, "able"); String a6 = a(jSONObject, DebugKt.DEBUG_PROPERTY_VALUE_ON); String a7 = a(jSONObject, "mobileable"); fVar.e = a2; fVar.f = a3; fVar.d = a4; fVar.f16225a = a(a5, false); fVar.f16226b = a(a6, false); fVar.c = a(a7, false); } catch (Throwable th) { bz.a(th, "at", "pes"); } } } private static void a(JSONObject jSONObject, a.c cVar) { if (jSONObject != null) { try { String a2 = a(jSONObject, FileResponse.FIELD_MD5); String a3 = a(jSONObject, "url"); cVar.f16221b = a2; cVar.f16220a = a3; } catch (Throwable th) { bz.a(th, "at", "psc"); } } } private static void a(JSONObject jSONObject, a.d dVar) { if (jSONObject != null) { try { String a2 = a(jSONObject, FileResponse.FIELD_MD5); String a3 = a(jSONObject, "url"); String a4 = a(jSONObject, "sdkversion"); if (!TextUtils.isEmpty(a2) && !TextUtils.isEmpty(a3)) { if (!TextUtils.isEmpty(a4)) { dVar.f16222a = a3; dVar.f16223b = a2; dVar.c = a4; } } } catch (Throwable th) { bz.a(th, "at", "psu"); } } } private static void a(JSONObject jSONObject, a.e eVar) { if (eVar != null && jSONObject != null) { eVar.f16224a = a(jSONObject.optString("able"), false); } } private static void a(a aVar, JSONObject jSONObject) { try { if (bq.a(jSONObject, "11B")) { aVar.h = jSONObject.getJSONObject("11B"); } if (bq.a(jSONObject, "11C")) { aVar.k = jSONObject.getJSONObject("11C"); } if (bq.a(jSONObject, "11I")) { aVar.l = jSONObject.getJSONObject("11I"); } if (bq.a(jSONObject, "11H")) { aVar.m = jSONObject.getJSONObject("11H"); } if (bq.a(jSONObject, "11E")) { aVar.n = jSONObject.getJSONObject("11E"); } if (bq.a(jSONObject, "11F")) { aVar.o = jSONObject.getJSONObject("11F"); } if (bq.a(jSONObject, "13A")) { aVar.q = jSONObject.getJSONObject("13A"); } if (bq.a(jSONObject, "13J")) { aVar.i = jSONObject.getJSONObject("13J"); } if (bq.a(jSONObject, "11G")) { aVar.p = jSONObject.getJSONObject("11G"); } if (bq.a(jSONObject, "006")) { aVar.r = jSONObject.getJSONObject("006"); } if (bq.a(jSONObject, "010")) { aVar.s = jSONObject.getJSONObject("010"); } if (bq.a(jSONObject, "11Z")) { JSONObject jSONObject2 = jSONObject.getJSONObject("11Z"); a.b bVar = new a.b(); a(jSONObject2, bVar); aVar.C = bVar; } if (bq.a(jSONObject, "135")) { aVar.j = jSONObject.getJSONObject("135"); } if (bq.a(jSONObject, "13S")) { aVar.g = jSONObject.getJSONObject("13S"); } if (bq.a(jSONObject, "121")) { JSONObject jSONObject3 = jSONObject.getJSONObject("121"); a.b bVar2 = new a.b(); a(jSONObject3, bVar2); aVar.D = bVar2; } if (bq.a(jSONObject, "122")) { JSONObject jSONObject4 = jSONObject.getJSONObject("122"); a.b bVar3 = new a.b(); a(jSONObject4, bVar3); aVar.E = bVar3; } if (bq.a(jSONObject, "123")) { JSONObject jSONObject5 = jSONObject.getJSONObject("123"); a.b bVar4 = new a.b(); a(jSONObject5, bVar4); aVar.F = bVar4; } if (bq.a(jSONObject, "011")) { aVar.c = jSONObject.getJSONObject("011"); } if (bq.a(jSONObject, "012")) { aVar.d = jSONObject.getJSONObject("012"); } if (bq.a(jSONObject, "013")) { aVar.e = jSONObject.getJSONObject("013"); } if (bq.a(jSONObject, "014")) { aVar.f = jSONObject.getJSONObject("014"); } if (bq.a(jSONObject, "145")) { aVar.t = jSONObject.getJSONObject("145"); } if (bq.a(jSONObject, "14B")) { aVar.u = jSONObject.getJSONObject("14B"); } if (bq.a(jSONObject, "14D")) { aVar.v = jSONObject.getJSONObject("14D"); } } catch (Throwable th) { cc.c(th, "at", "pe"); } } }