package com.uc.crashsdk.a; import android.os.Build; import android.os.Process; import android.text.TextUtils; import android.util.SparseArray; import com.baidu.idl.face.platform.FaceEnvironment; import com.baidu.speech.asr.SpeechConstant; import com.google.android.material.timepicker.TimeModel; import com.mbridge.msdk.MBridgeConstans; import com.uc.crashsdk.JNIBridge; import com.uc.crashsdk.b; import com.uc.crashsdk.e; import com.uc.crashsdk.g; import com.umeng.analytics.pro.am; import java.io.File; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.Locale; import java.util.Map; import kotlin.jvm.internal.ByteCompanionObject; /* compiled from: ProGuard */ public class h { static final /* synthetic */ boolean a = true; private static final Object b = new Object(); private static final Map<String, String> c = new HashMap(); private static int d = 0; private static final Map<String, a> e = new HashMap(); private static final Object f = new Object(); private static final Object g = new Object(); private static final SparseArray<String> h = new SparseArray<>(); private static boolean i = false; private static boolean j = false; private static final Object k = new Object(); private static String l = null; static /* synthetic */ String a(long j2) { if (j2 < 524288) { return "512M"; } return String.format(Locale.US, "%dG", Long.valueOf(((j2 / 1024) + 512) / 1024)); } static /* synthetic */ void a(StringBuilder sb, String str, long j2) { b(sb, str, String.valueOf(j2)); } static /* synthetic */ void a(StringBuilder sb, Map map) { for (String str : map.keySet()) { b(sb, str, (String) map.get(str)); } } static /* synthetic */ Map c(String str) { HashMap hashMap = new HashMap(); String[] split = str.split("`"); for (String str2 : split) { if (str2.length() > 1) { String[] split2 = str2.split("=", 3); if (split2.length == 2) { hashMap.put(split2[0], split2[1]); } } } return hashMap; } /* access modifiers changed from: private */ /* compiled from: ProGuard */ public static class a { long a = 0; int b = 0; Map<String, String> c = new HashMap(); private String d; private boolean e = false; private boolean f = false; a(String str, boolean z, boolean z2) { this.d = str; this.e = z; this.f = z2; } /* access modifiers changed from: package-private */ public final void a(String str, String str2) { this.c.put(str, str2); } /* access modifiers changed from: package-private */ public final void a(String str, long j) { long d2 = d(str) + j; if (d2 <= 100) { j = d2 < 0 ? 0 : d2; } a(str, String.valueOf(j)); } /* access modifiers changed from: package-private */ public final boolean a(a aVar) { if (!this.f) { a.a("crashsdk", String.format(Locale.US, "WaItem '%s' is not mergable!", this.d), null); return false; } for (String str : aVar.c.keySet()) { if (str.startsWith("c_")) { a(str, aVar.a(str)); } else { long d2 = aVar.d(str); if (d2 == 0) { a(str, aVar.a(str)); } else if (d2 < 100) { a(str, d2); } } } return true; } /* access modifiers changed from: package-private */ public final String a(String str) { return this.c.get(str); } /* access modifiers changed from: package-private */ public final String b(String str) { String a2 = a(str); return a2 == null ? "" : a2; } private long d(String str) { return g.a(a(str), true); } /* access modifiers changed from: package-private */ public final String a(boolean z, boolean z2, boolean z3) { if (this.d == null) { return null; } StringBuilder sb = new StringBuilder(); if (z) { h.b(sb, "lt", "uc"); h.b(sb, "pre", g.e()); h.b(sb, "pkg", com.uc.crashsdk.a.a); h.b(sb, "rom", Build.VERSION.RELEASE); h.b(sb, "brd", Build.BRAND); h.b(sb, "model", Build.MODEL); h.a(sb, "sdk", (long) Build.VERSION.SDK_INT); h.b(sb, "cpu", e.e()); h.b(sb, "hdw", e.f()); long o = h.o(); h.a(sb, "ram", o); h.b(sb, "aram", h.a(o)); h.b(sb, "cver", "3.3.1.1"); h.b(sb, "cseq", "210916105822"); h.b(sb, "ctag", "release"); h.b(sb, "aver", com.uc.crashsdk.a.a()); h.b(sb, "ver", g.R()); h.b(sb, "sver", g.S()); h.b(sb, "seq", g.T()); h.b(sb, "grd", b.A() ? "fg" : "bg"); h.b(sb, am.x, FaceEnvironment.OS); h.b(sb, "dn", e.q()); String Z = g.Z(); if (TextUtils.isEmpty(Z)) { Z = e.q(); } h.b(sb, "k_uid", Z); String aa = g.aa(); if (!TextUtils.isEmpty(aa)) { h.b(sb, "k_channel", aa); } sb.append("\n"); } h.b(sb, "lt", this.d); h.a(sb, this.c); if (this.e && !z2) { long j = this.a; if (j != 0) { h.b(sb, "up", String.valueOf(j)); } if (z3) { h.b(sb, SpeechConstant.PID, String.format(Locale.US, TimeModel.NUMBER_FORMAT, Integer.valueOf(Process.myPid()))); } else if (this.b != 0) { h.b(sb, SpeechConstant.PID, String.format(Locale.US, TimeModel.NUMBER_FORMAT, Integer.valueOf(this.b))); } } sb.append("\n"); return sb.toString(); } /* access modifiers changed from: package-private */ public final boolean c(String str) { if (g.a(str)) { return false; } String str2 = null; long j = 0; HashMap hashMap = new HashMap(); Map c2 = h.c(str); int i = 0; for (String str3 : c2.keySet()) { String str4 = (String) c2.get(str3); if (str3.equals("lt")) { str2 = str4; } else if (this.e && str3.equals("up")) { j = g.a(str4, true); } else if (!this.e || !str3.equals(SpeechConstant.PID)) { hashMap.put(str3, str4); } else { i = (int) g.a(str4, true); } } String str5 = this.d; if (!(str5 == null || str5.equals(str2))) { return false; } this.a = j; this.b = i; this.d = str2; this.c = hashMap; return true; } } /* access modifiers changed from: private */ public static void b(StringBuilder sb, String str, String str2) { sb.append(str); sb.append("="); sb.append(str2); sb.append("`"); } static void a(String str) { synchronized (b) { File file = new File(m()); a aVar = new a("pv", true, true); String c2 = g.c(file); a.a("wa", "addAuthStat, read data: " + c2); if (!g.a(c2)) { aVar.c(c2); } aVar.a(str, 1); aVar.a("aujv", 1); String a2 = aVar.a(false, false, false); a.a("wa", "addAuthStat, save data: " + a2); g.a(file, a2); } } public static void a() { a(0, b.H() ? 700000 : 70000); } public static void b() { a(2, 0); } public static void c() { a(3, 0); } private static void a(int i2, long j2) { if (b.F()) { f.a(0, new e(302, new Object[]{Integer.valueOf(i2)}), j2); } } public static void d() { b(2, 2000); a(1, 70000); } public static boolean a(String str, String str2) { String str3; try { String str4 = "c_" + str.replaceAll("[^0-9a-zA-Z-_]", "-"); if (g.a(str2)) { str3 = ""; } else { str3 = str2.replaceAll("[`=]", "-"); } Map<String, String> map = c; synchronized (map) { if (map.get(str4) == null) { int i2 = d; if (i2 >= 20) { return false; } d = i2 + 1; } map.put(str4, str3); return true; } } catch (Throwable th) { g.a(th); return false; } } private static void a(a aVar) { Map<String, String> map = c; synchronized (map) { for (String str : map.keySet()) { aVar.a(str, c.get(str)); } } } public static boolean e() { return j; } private static void b(int i2, long j2) { if (g.O()) { f.a(1, new e(301, new Object[]{Integer.valueOf(i2)}), j2); } } public static void f() { b(1, 2000); } public static void g() { b(3, 0); } public static void h() { b(4, 0); } public static void a(boolean z) { a(1, z); } public static boolean a(boolean z, String str) { if (!b.d || z || !JNIBridge.nativeIsCrashing()) { return false; } a.b("crashsdk", "Native is crashing, skip stat for " + str); return true; } private static void a(int i2, boolean z) { if (!a(z, "crash rate")) { String str = g.U() + "cr.wa"; b.a(b, str, new e(351, new Object[]{str, Integer.valueOf(i2)})); } } /* JADX WARNING: Code restructure failed: missing block: B:33:0x009d, code lost: if (r3 == false) goto L_0x009f; */ /* JADX WARNING: Removed duplicated region for block: B:44:0x00ca */ /* JADX WARNING: Removed duplicated region for block: B:49:0x0103 */ static void a(int i2, Object[] objArr) { long j2; boolean z; String str; boolean z2; switch (i2) { case 301: if (a || objArr != null) { a(((Integer) objArr[0]).intValue(), false); return; } throw new AssertionError(); case 302: if (a || objArr != null) { synchronized (b) { int intValue = ((Integer) objArr[0]).intValue(); if (intValue == 0) { if (!i) { i = true; } } if (!com.uc.crashsdk.a.b.equals(MBridgeConstans.NATIVE_VIDEO_VERSION) || !b.c(268435456)) { File file = new File(m()); String c2 = g.c(file); a aVar = new a("pv", true, true); a.a("wa", "addPvStatImpl, read data: " + c2); if (!g.a(c2)) { aVar.c(c2); } if (intValue == 0) { a.a("wa", String.format(Locale.US, "Last upload pid is %d", Integer.valueOf(aVar.b))); if (aVar.b != Process.myPid()) { z2 = false; break; } else { z2 = true; break; } } if (intValue == 0) { aVar.a("pv", 1); str = "fjv"; } else if (intValue == 1) { str = "hpv"; } else { if (intValue == 2) { aVar.a("pv", 1); str = "npv"; } String q = e.q(); j2 = aVar.a; if (j2 != 0) { long currentTimeMillis = System.currentTimeMillis(); long j3 = currentTimeMillis - j2; a.a("wa", String.format(Locale.US, "Upload delta %d s, min interval: %d s", Long.valueOf(j3 / 1000), 28800L)); if (j3 < 28800000) { z = false; if (z) { aVar.c = new HashMap(); aVar.a = System.currentTimeMillis(); aVar.b = Process.myPid(); } String a2 = aVar.a(false, false, true); a.a("wa", "addPvStatImpl, save data: " + a2); g.a(file, a2); } } z = c(q, aVar.a(true, true, false)); if (z) { } String a22 = aVar.a(false, false, true); a.a("wa", "addPvStatImpl, save data: " + a22); g.a(file, a22); } aVar.a(str, 1); String q2 = e.q(); j2 = aVar.a; if (j2 != 0) { } z = c(q2, aVar.a(true, true, false)); if (z) { } String a222 = aVar.a(false, false, true); a.a("wa", "addPvStatImpl, save data: " + a222); g.a(file, a222); } else { a.a("wa", "pv stat is disabled"); } } return; } throw new AssertionError(); case 303: b(false); return; default: if (!a) { throw new AssertionError(); } return; } } static boolean b(int i2, Object[] objArr) { switch (i2) { case 351: if (a || objArr != null) { String str = (String) objArr[0]; int intValue = ((Integer) objArr[1]).intValue(); if (intValue == 1) { if (j) { return false; } j = true; } if (!g.X()) { a.a("wa", "disable crp stat log"); return false; } File file = new File(str); ArrayList<a> a2 = a(file, "crp", 100); if (intValue != 4) { a aVar = new a("crp", false, false); String str2 = "1"; if (intValue == 1) { aVar.a("et", String.valueOf(b.I())); aVar.a("ete", String.valueOf(b.J())); } else if (intValue == 3) { aVar.a("et", str2); aVar.a("ete", str2); } else if (intValue == 2) { aVar.a("hpv", str2); } aVar.a("prc", e.h()); if (!b.F()) { str2 = "0"; } aVar.a("imp", str2); a(aVar); a2.add(0, aVar); } if (!a2.isEmpty()) { boolean c2 = c(e.q(), a((Iterable<a>) a2, true, false).toString()); g.b(file); if (!c2) { g.a(file, a((Iterable<a>) a2, false, true).toString()); } } return true; } throw new AssertionError(); case 352: if (a || objArr != null) { return d((String) objArr[0]); } throw new AssertionError(); case 353: if (a || objArr != null) { return b((String) objArr[0], (String) objArr[1], ((Boolean) objArr[2]).booleanValue(), ((Boolean) objArr[3]).booleanValue()); } throw new AssertionError(); case 354: if (a || objArr != null) { File file2 = new File((String) objArr[0]); boolean c3 = c(e.q(), a((Iterable<a>) a(file2, "cst", 30), true, false).toString()); if (c3) { g.b(file2); } return c3; } throw new AssertionError(); default: return false; } } private static StringBuilder a(Iterable<a> iterable, boolean z, boolean z2) { StringBuilder sb = new StringBuilder(); boolean z3 = true; for (a aVar : iterable) { if (z3) { sb.append(aVar.a(z, z, z2)); z3 = false; } else { sb.append(aVar.a(false, z, z2)); } } return sb; } public static void a(String str, int i2, int i3) { if (g.O()) { synchronized (f) { Map<String, a> map = e; a aVar = map.get(str); if (aVar == null) { aVar = new a("cst", false, true); map.put(str, aVar); a(aVar); } SparseArray<String> sparseArray = h; synchronized (sparseArray) { if (sparseArray.size() == 0) { a(100, "pv"); a(102, "hpv"); a(1, "all"); a(2, "afg"); a(101, "abg"); a(3, "jfg"); a(4, "jbg"); a(7, "nfg"); a(8, "nbg"); a(27, "nafg"); a(28, "nabg"); a(9, "nho"); a(10, "uar"); a(29, "ulm"); a(30, "ukt"); a(31, "uet"); a(32, "urs"); a(11, "ufg"); a(12, "ubg"); a(40, "anf"); a(41, "anb"); a(42, "ancf"); a(43, "ancb"); a(13, "lup"); a(14, "luf"); a(15, "lef"); a(200, "ltf"); a(16, "laf"); a(22, "lac"); a(23, "lau"); a(17, "llf"); a(18, "lul"); a(19, "lub"); a(20, "luc"); a(21, "luu"); a(24, "lzc"); a(201, "lec"); a(25, "lrc"); a(26, "lss"); } } String str2 = sparseArray.get(i2); if (str2 == null) { a.a("crashsdk", "map key is not set with: " + i2, null); } aVar.a("prc", str); if (str2 != null) { aVar.a(str2, String.valueOf(i3)); } } } } public static void i() { if (g.O()) { f.a(1, new e(303)); } } public static void b(boolean z) { if (!a(z, "crash detail upload")) { String str = g.U() + "dt.wa"; b.a(f, str, new e(352, new Object[]{str})); String n = n(); b.a(g, n, new e(354, new Object[]{n})); } } private static boolean d(String str) { boolean z; File file = new File(str); Iterator<a> it = a(file, "cst", 30).iterator(); while (it.hasNext()) { a next = it.next(); String a2 = next.a("prc"); if (!g.a(a2)) { Map<String, a> map = e; a aVar = map.get(a2); if (aVar != null) { aVar.a(next); } else { map.put(a2, next); } } } Map<String, a> map2 = e; StringBuilder a3 = a((Iterable<a>) map2.values(), true, false); if (g.Y()) { z = b(e.q(), a3.toString()); } else { z = c(e.q(), a3.toString()); } g.b(file); if (z || g.a(file, a((Iterable<a>) map2.values(), false, true).toString())) { map2.clear(); } return true; } /* JADX WARNING: Removed duplicated region for block: B:13:0x007c */ /* JADX WARNING: Removed duplicated region for block: B:14:0x007f */ /* JADX WARNING: Removed duplicated region for block: B:17:0x00aa */ /* JADX WARNING: Removed duplicated region for block: B:20:0x00c6 A[RETURN] */ /* JADX WARNING: Removed duplicated region for block: B:21:0x00c7 */ private static boolean b(String str, String str2) { boolean z; String sb; if (g.a(str2)) { return true; } a.a("wa", "Reporting datas: " + str2); byte[] bytes = str2.getBytes(); long currentTimeMillis = System.currentTimeMillis(); String c2 = g.c(g.e() + str + currentTimeMillis + "AppChk#2014"); try { byte[] a2 = c.a(bytes, c2.substring(c2.length() - 16, c2.length()).getBytes()); if (a2 != null) { bytes = a2; z = true; String substring = c2.substring(c2.length() - 8, c2.length()); StringBuilder sb2 = new StringBuilder(); sb2.append(!g.P() ? "https://px-intl.ucweb.com" : "https://px.ucweb.com"); sb2.append("/api/v1/crashtrack/upload?chk="); sb2.append(substring); sb2.append("&vno="); sb2.append(currentTimeMillis); sb2.append("&uuid="); sb2.append(str); sb2.append("&app="); sb2.append(g.e()); if (z) { sb2.append("&enc=aes"); } sb = sb2.toString(); a.a("wa", "url: " + sb); if (sb != null) { return false; } byte[] a3 = c.a(sb, bytes, true); if (a3 == null) { a.a("wa", "px response is empty!"); return false; } String str3 = new String(a3); a.a("wa", "px response: " + str3); if (str3.contains("retcode=0")) { return true; } return false; } } catch (Throwable th) { g.a(th); } z = false; String substring2 = c2.substring(c2.length() - 8, c2.length()); StringBuilder sb22 = new StringBuilder(); sb22.append(!g.P() ? "https://px-intl.ucweb.com" : "https://px.ucweb.com"); sb22.append("/api/v1/crashtrack/upload?chk="); sb22.append(substring2); sb22.append("&vno="); sb22.append(currentTimeMillis); sb22.append("&uuid="); sb22.append(str); sb22.append("&app="); sb22.append(g.e()); if (z) { } sb = sb22.toString(); a.a("wa", "url: " + sb); if (sb != null) { } } public static boolean a(String str, String str2, boolean z, boolean z2) { if (!g.O()) { return false; } String n = n(); return b.a(g, n, new e(353, new Object[]{str, str2, Boolean.valueOf(z), Boolean.valueOf(z2)})); } private static boolean b(String str, String str2, boolean z, boolean z2) { a aVar; File file = new File(n()); ArrayList<a> a2 = a(file, "cst", 30); String str3 = str + str2; Iterator<a> it = a2.iterator(); while (true) { if (!it.hasNext()) { aVar = null; break; } aVar = it.next(); if (str3.equals(aVar.b("prc") + aVar.b("typ"))) { break; } } if (aVar == null) { aVar = new a("cst", false, true); aVar.a("prc", str); aVar.a("typ", str2); a(aVar); a2.add(aVar); } aVar.a("cnt", 1); if (z) { aVar.a("lim", 1); } if (z2) { aVar.a("syu", 1); } return g.a(file, a((Iterable<a>) a2, false, false).toString()); } private static void a(int i2, String str) { h.put(i2, str); } private static ArrayList<a> a(File file, String str, int i2) { ArrayList<String> a2 = g.a(file, i2); ArrayList<a> arrayList = new ArrayList<>(); Iterator<String> it = a2.iterator(); while (it.hasNext()) { a aVar = new a(str, false, false); if (aVar.c(it.next())) { arrayList.add(aVar); } } return arrayList; } private static String m() { return g.U() + "pv.wa"; } private static String n() { return g.U() + "cdt.wa"; } /* JADX WARNING: Removed duplicated region for block: B:12:0x0055 */ /* JADX WARNING: Removed duplicated region for block: B:15:0x005d */ /* JADX WARNING: Removed duplicated region for block: B:16:0x0060 */ /* JADX WARNING: Removed duplicated region for block: B:19:0x0087 */ /* JADX WARNING: Removed duplicated region for block: B:20:0x0089 */ /* JADX WARNING: Removed duplicated region for block: B:32:0x0106 A[RETURN] */ /* JADX WARNING: Removed duplicated region for block: B:33:0x0107 A[RETURN] */ private static boolean c(String str, String str2) { boolean z; String c2; String str3; byte[] a2; String str4; if (g.a(str2)) { return true; } a.a("wa", "Reporting datas: " + str2); byte[] bytes = str2.getBytes(); try { byte[] bArr = new byte[16]; c.a(bArr, 0, c.a()); c.a(bArr, 4, j()); c.a(bArr, 8, com.uc.crashsdk.a.f()); c.a(bArr, 12, d.d()); byte[] a3 = c.a(bytes, bArr); if (a3 != null) { bytes = a3; z = true; if (str == null) { str = "unknown"; } String str5 = !g.P() ? "4ea4e41a3993" : "28ef1713347d"; String valueOf = String.valueOf(System.currentTimeMillis()); c2 = g.c(str5 + str + valueOf + "AppChk#2014"); if (c2 != null) { str3 = null; } else { StringBuilder sb = new StringBuilder(); sb.append(p()); sb.append("?chk="); sb.append(c2.substring(c2.length() - 8, c2.length())); sb.append("&vno="); sb.append(valueOf); sb.append("&uuid="); sb.append(str); sb.append("&app="); sb.append(str5); if (z) { sb.append("&enc=aes"); } str3 = sb.toString(); } a.a("wa", "url: " + str3); if (str3 != null || (a2 = c.a(str3, bytes, true)) == null) { return false; } str4 = new String(a2); a.a("wa", "wa response: " + str4); if (!str4.contains("retcode=0")) { return true; } return false; } } catch (Throwable th) { g.a(th); } z = false; if (str == null) { } if (!g.P()) { } String valueOf2 = String.valueOf(System.currentTimeMillis()); c2 = g.c(str5 + str + valueOf2 + "AppChk#2014"); if (c2 != null) { } a.a("wa", "url: " + str3); if (str3 != null) { return false; } str4 = new String(a2); a.a("wa", "wa response: " + str4); if (!str4.contains("retcode=0")) { } } /* access modifiers changed from: private */ public static long o() { Iterator<String> it = g.a(new File("/proc/meminfo"), 2).iterator(); while (it.hasNext()) { String next = it.next(); if (next.contains("MemTotal:")) { try { return Long.parseLong(next.replaceAll("\\D+", "")); } catch (NumberFormatException e2) { g.a(e2); } } } return 0; } static byte[] j() { return new byte[]{ByteCompanionObject.MAX_VALUE, 100, 110, 31}; } static void b(String str) { synchronized (k) { l = str; String k2 = b.k(); b.a(k2, str + "\n"); } } private static String p() { String str = l; if (g.a(str)) { synchronized (k) { String str2 = "https://errlog.umeng.com/api/crashsdk/logcollect"; if (g.P()) { str2 = "https://errlogos.umeng.com/api/crashsdk/logcollect"; } str = g.a(b.k(), str2, true); l = str; } } return str; } public static void k() { synchronized (k) { l = null; } } }