package com.tencent.wxop.stat; import android.content.Context; import android.os.Build; import com.appara.feed.constant.TTParam; import com.tencent.a.a.a.a.g; import com.tencent.wxop.stat.b.b; import com.tencent.wxop.stat.b.l; import com.tencent.wxop.stat.b.q; import com.tencent.wxop.stat.b.r; import com.xiaomi.mipush.sdk.Constants; import java.net.URI; import java.util.Iterator; import org.json.JSONException; import org.json.JSONObject; public final class u { private static int A = 1; private static String B = null; private static String C; private static String D; private static String E = "mta_channel"; private static int F = 180; private static int G = 1024; private static long H = 0; private static long I = Constants.ASSEMBLE_PUSH_NETWORK_INTERVAL; private static volatile String J = "http://pingma.qq.com:80/mstat/report"; private static int K = 0; private static volatile int L = 0; private static int M = 20; private static int N = 0; private static boolean O = false; private static int P = 4096; private static boolean Q = false; private static String R = null; private static boolean S = false; private static k T = null; /* renamed from: a reason: collision with root package name */ static j f8116a = new j(2); /* renamed from: b reason: collision with root package name */ static j f8117b = new j(1); static String c = "__HIBERNATE__"; static String d = "__HIBERNATE__TIME"; static String e = "__MTA_KILL__"; static String f = ""; static boolean g = false; static int h = 100; static long i = 10000; static boolean j = true; public static boolean k = true; /* renamed from: l reason: collision with root package name */ static volatile String f8118l = "pingma.qq.com:80"; static boolean m = true; static int n = 0; static long o = 10000; static int p = 512; private static b q = l.c(); private static d r = d.APP_LAUNCH; private static boolean s = false; private static boolean t = true; private static int u = 30000; private static int v = 100000; private static int w = 30; private static int x = 10; private static int y = 100; private static int z = 30; public static d a() { return r; } public static synchronized String a(Context context) { synchronized (u.class) { if (C != null) { return C; } if (context != null && C == null) { C = l.f(context); } if (C == null || C.trim().length() == 0) { q.d("AppKey can not be null or empty, please read Developer's Guide first!"); } return C; } } static String a(String str) { try { String string = f8117b.f8103b.getString(str); if (string != null) { return string; } return null; } catch (Throwable unused) { q.c("can't find custom key:".concat(String.valueOf(str))); return null; } } private static void a(long j2) { q.a(m.a(), c, j2); a(false); q.b("MTA is disable for current SDK version"); } static void a(Context context, j jVar) { if (jVar.f8102a == f8117b.f8102a) { f8117b = jVar; a(jVar.f8103b); if (!f8117b.f8103b.isNull("iplist")) { x.a(context).a(f8117b.f8103b.getString("iplist")); } } else if (jVar.f8102a == f8116a.f8102a) { f8116a = jVar; } } public static void a(Context context, String str) { b bVar; String str2; String str3; if (context == null) { bVar = q; str2 = "ctx in StatConfig.setAppKey() is null"; } else if (str == null || str.length() > 256) { bVar = q; str2 = "appkey in StatConfig.setAppKey() is null or exceed 256 bytes"; } else { if (C == null) { C = r.a(q.a(context, "_mta_ky_tag_", (String) null)); } if ((d(str) || d(l.f(context))) && (str3 = C) != null) { q.b(context, "_mta_ky_tag_", r.b(str3)); return; } return; } bVar.d(str2); } static void a(Context context, JSONObject jSONObject) { JSONObject jSONObject2; j jVar; try { Iterator<String> keys = jSONObject.keys(); while (keys.hasNext()) { String next = keys.next(); if (next.equalsIgnoreCase(Integer.toString(f8117b.f8102a))) { jSONObject2 = jSONObject.getJSONObject(next); jVar = f8117b; } else if (next.equalsIgnoreCase(Integer.toString(f8116a.f8102a))) { jSONObject2 = jSONObject.getJSONObject(next); jVar = f8116a; } else if (next.equalsIgnoreCase("rs")) { d a2 = d.a(jSONObject.getInt(next)); if (a2 != null) { r = a2; if (s) { b bVar = q; bVar.g("Change to ReportStrategy:" + a2.name()); } } } else { return; } a(context, jVar, jSONObject2); } } catch (JSONException e2) { q.b((Throwable) e2); } } public static void a(d dVar) { r = dVar; if (dVar != d.PERIOD) { v.c = 0; } if (s) { q.g("Change to statSendStrategy: ".concat(String.valueOf(dVar))); } } private static void a(JSONObject jSONObject) { try { d a2 = d.a(jSONObject.getInt("rs")); if (a2 != null) { a(a2); } } catch (JSONException unused) { if (s) { q.a("rs not found."); } } } public static void a(boolean z2) { t = z2; if (!z2) { q.b("!!!!!!MTA StatService has been disabled!!!!!!"); } } private static boolean a(JSONObject jSONObject, String str, String str2) { if (jSONObject.isNull(str)) { return false; } String optString = jSONObject.optString(str); return l.c(str2) && l.c(optString) && str2.equalsIgnoreCase(optString); } public static synchronized String b(Context context) { synchronized (u.class) { if (D != null) { return D; } String a2 = q.a(context, E, ""); D = a2; if (a2 == null || D.trim().length() == 0) { D = l.g(context); } if (D == null || D.trim().length() == 0) { q.c("installChannel can not be null or empty, please read Developer's Guide first!"); } return D; } } public static void b(Context context, String str) { if (str.length() > 128) { q.d("the length of installChannel can not exceed the range of 128 bytes."); return; } D = str; q.b(context, E, str); } public static void b(String str) { if (str.length() > 128) { q.d("the length of installChannel can not exceed the range of 128 bytes."); } else { D = str; } } public static boolean b() { return s; } public static String c(Context context) { return q.a(context, "mta.acc.qq", f); } public static void c(String str) { if (str == null || str.length() == 0) { q.d("statReportUrl cannot be null or empty."); return; } J = str; try { f8118l = new URI(J).getHost(); } catch (Exception e2) { q.c(e2); } if (s) { b bVar = q; bVar.a("url:" + J + ", domain:" + f8118l); } } public static boolean c() { return t; } public static int d() { return y; } public static String d(Context context) { if (context == null) { q.d("Context for getCustomUid is null."); return null; } if (R == null) { R = q.a(context, "MTA_CUSTOM_UID", ""); } return R; } private static boolean d(String str) { if (str == null) { return false; } String str2 = C; if (str2 == null) { C = str; return true; } else if (str2.contains(str)) { return false; } else { C += "|" + str; return true; } } public static int e() { return z; } public static int f() { return x; } public static int g() { return A; } static int h() { return w; } public static int i() { return v; } public static void j() { F = 60; } public static int k() { return F; } public static void l() { j = true; } public static boolean m() { return k; } public static String n() { return J; } static synchronized void o() { synchronized (u.class) { L = 0; } } public static int p() { return M; } static void q() { N++; } static void r() { N = 0; } static int s() { return N; } public static boolean t() { return Q; } public static k u() { return T; } /* JADX WARNING: Code restructure failed: missing block: B:85:0x0269, code lost: com.tencent.wxop.stat.u.q.g("__HIBERNATE__ not found."); */ /* JADX WARNING: Code restructure failed: missing block: B:89:0x0274, code lost: r9 = th; */ /* JADX WARNING: Failed to process nested try/catch */ /* JADX WARNING: Removed duplicated region for block: B:47:0x00c0 A[Catch:{ Exception -> 0x022f }] */ /* JADX WARNING: Removed duplicated region for block: B:89:0x0274 A[ExcHandler: Throwable (th java.lang.Throwable), Splitter:B:0:0x0000] */ private static void a(Context context, j jVar, JSONObject jSONObject) { int i2; Integer valueOf; try { Iterator<String> keys = jSONObject.keys(); boolean z2 = false; boolean z3 = false; while (keys.hasNext()) { String next = keys.next(); if (next.equalsIgnoreCase("v")) { int i3 = jSONObject.getInt(next); if (jVar.d != i3) { z3 = true; } jVar.d = i3; } else if (next.equalsIgnoreCase("c")) { String string = jSONObject.getString("c"); if (string.length() > 0) { jVar.f8103b = new JSONObject(string); } } else if (next.equalsIgnoreCase("m")) { jVar.c = jSONObject.getString("m"); } } if (z3) { ai a2 = ai.a(m.a()); if (a2 != null) { a2.a(jVar); } if (jVar.f8102a == f8117b.f8102a) { a(jVar.f8103b); JSONObject jSONObject2 = jVar.f8103b; if (!(jSONObject2 == null || jSONObject2.length() == 0)) { Context a3 = m.a(); try { String optString = jSONObject2.optString(e); if (l.c(optString)) { JSONObject jSONObject3 = new JSONObject(optString); if (jSONObject3.length() != 0) { if (!jSONObject3.isNull("sm")) { Object obj = jSONObject3.get("sm"); if (obj instanceof Integer) { valueOf = (Integer) obj; } else if (obj instanceof String) { valueOf = Integer.valueOf((String) obj); } else { i2 = 0; if (i2 > 0) { if (s) { b bVar = q; bVar.a("match sleepTime:" + i2 + " minutes"); } q.a(a3, d, System.currentTimeMillis() + ((long) (i2 * 60 * 1000))); a(false); q.b("MTA is disable for current SDK version"); } } i2 = valueOf.intValue(); if (i2 > 0) { } } if (a(jSONObject3, "sv", "2.0.3")) { q.a("match sdk version:2.0.3"); z2 = true; } if (a(jSONObject3, "md", Build.MODEL)) { b bVar2 = q; bVar2.a("match MODEL:" + Build.MODEL); z2 = true; } if (a(jSONObject3, "av", l.i(a3))) { b bVar3 = q; bVar3.a("match app version:" + l.i(a3)); z2 = true; } if (a(jSONObject3, "mf", Build.MANUFACTURER)) { b bVar4 = q; bVar4.a("match MANUFACTURER:" + Build.MANUFACTURER); z2 = true; } StringBuilder sb = new StringBuilder(); sb.append(Build.VERSION.SDK_INT); if (a(jSONObject3, "osv", sb.toString())) { b bVar5 = q; bVar5.a("match android SDK version:" + Build.VERSION.SDK_INT); z2 = true; } StringBuilder sb2 = new StringBuilder(); sb2.append(Build.VERSION.SDK_INT); if (a(jSONObject3, "ov", sb2.toString())) { b bVar6 = q; bVar6.a("match android SDK version:" + Build.VERSION.SDK_INT); z2 = true; } if (a(jSONObject3, "ui", ai.a(a3).b(a3).f8074a)) { b bVar7 = q; bVar7.a("match imei:" + ai.a(a3).b(a3).f8074a); z2 = true; } if (a(jSONObject3, TTParam.KEY_mid, e(a3))) { b bVar8 = q; bVar8.a("match mid:" + e(a3)); z2 = true; } if (z2) { a(l.b("2.0.3")); } } } } catch (Exception e2) { q.b((Throwable) e2); } String string2 = jSONObject2.getString(c); if (s) { b bVar9 = q; bVar9.g("hibernateVer:" + string2 + ", current version:2.0.3"); } long b2 = l.b(string2); if (l.b("2.0.3") <= b2) { a(b2); } } } } a(context, jVar); } catch (JSONException e3) { th = e3; q.b(th); } catch (Throwable th) { } } public static String e(Context context) { return context != null ? g.a(context).a().c : "0"; } }