package com.tencent.bugly.idasc.crashreport.common.strategy; import android.content.Context; import com.tencent.bugly.idasc.crashreport.biz.b; import com.tencent.bugly.idasc.proguard.ao; import com.tencent.bugly.idasc.proguard.ap; import com.tencent.bugly.idasc.proguard.o; import com.tencent.bugly.idasc.proguard.p; import com.tencent.bugly.idasc.proguard.r; import com.tencent.bugly.idasc.proguard.w; import com.tencent.bugly.idasc.proguard.x; import com.tencent.bugly.idasc.proguard.z; import java.util.List; import java.util.Map; public final class a { /* renamed from: a reason: collision with root package name */ public static int f26647a = 1000; private static a b; /* renamed from: h reason: collision with root package name */ private static String f26648h; /* renamed from: c reason: collision with root package name */ private final List<com.tencent.bugly.idasc.a> f26649c; private final w d; private final StrategyBean e; private StrategyBean f; /* renamed from: g reason: collision with root package name */ private Context f26650g; private a(Context context, List<com.tencent.bugly.idasc.a> list) { String str; this.f26650g = context; if (com.tencent.bugly.idasc.crashreport.common.info.a.a(context) != null) { String str2 = com.tencent.bugly.idasc.crashreport.common.info.a.a(context).y; if ("oversea".equals(str2)) { str = "https://astat.bugly.qcloud.com/rqd/async"; } else { str = "na_https".equals(str2) ? "https://astat.bugly.cros.wr.pvp.net/:8180/rqd/async" : str; } StrategyBean.f26640a = str; StrategyBean.b = str; } this.e = new StrategyBean(); this.f26649c = list; this.d = w.a(); } public static synchronized a a() { a aVar; synchronized (a.class) { aVar = b; } return aVar; } public static synchronized a a(Context context, List<com.tencent.bugly.idasc.a> list) { a aVar; synchronized (a.class) { if (b == null) { b = new a(context, list); } aVar = b; } return aVar; } public static void a(String str) { if (z.a(str) || !z.c(str)) { x.d("URL user set is invalid.", new Object[0]); } else { f26648h = str; } } public static StrategyBean d() { byte[] bArr; List<r> a5 = p.a().a(2); if (a5 == null || a5.size() <= 0 || (bArr = a5.get(0).f26793g) == null) { return null; } return (StrategyBean) z.a(bArr, StrategyBean.CREATOR); } public final void a(long j) { this.d.a(new Thread() { /* class com.tencent.bugly.idasc.crashreport.common.strategy.a.AnonymousClass1 */ public final void run() { StrategyBean strategyBean; String str; try { Map<String, byte[]> a5 = p.a().a(a.f26647a, (o) null, true); if (a5 != null) { byte[] bArr = a5.get("device"); byte[] bArr2 = a5.get("gateway"); if (bArr != null) { com.tencent.bugly.idasc.crashreport.common.info.a.a(a.this.f26650g).f(new String(bArr)); } if (bArr2 != null) { com.tencent.bugly.idasc.crashreport.common.info.a.a(a.this.f26650g).e(new String(bArr2)); } } a.this.f = a.d(); if (a.this.f != null) { if (z.a(a.f26648h) || !z.c(a.f26648h)) { a.this.f.p = StrategyBean.f26640a; strategyBean = a.this.f; str = StrategyBean.b; } else { a.this.f.p = a.f26648h; strategyBean = a.this.f; str = a.f26648h; } strategyBean.f26644q = str; } } catch (Throwable th2) { if (!x.a(th2)) { th2.printStackTrace(); } } a aVar = a.this; aVar.a(aVar.f, false); } }, j); } public final void a(StrategyBean strategyBean, boolean z) { x.c("[Strategy] Notify %s", b.class.getName()); b.a(strategyBean, z); for (com.tencent.bugly.idasc.a aVar : this.f26649c) { try { x.c("[Strategy] Notify %s", aVar.getClass().getName()); aVar.onServerStrategyChanged(strategyBean); } catch (Throwable th2) { if (!x.a(th2)) { th2.printStackTrace(); } } } } public final void a(ap apVar) { if (apVar != null) { StrategyBean strategyBean = this.f; if (strategyBean == null || apVar.f26756h != strategyBean.n) { StrategyBean strategyBean2 = new StrategyBean(); strategyBean2.e = apVar.f26753a; strategyBean2.f26642g = apVar.f26754c; strategyBean2.f = apVar.b; if (z.a(f26648h) || !z.c(f26648h)) { if (z.c(apVar.d)) { x.c("[Strategy] Upload url changes to %s", apVar.d); strategyBean2.p = apVar.d; } if (z.c(apVar.e)) { x.c("[Strategy] Exception upload url changes to %s", apVar.e); strategyBean2.f26644q = apVar.e; } } ao aoVar = apVar.f; if (aoVar != null && !z.a(aoVar.f26752a)) { strategyBean2.r = apVar.f.f26752a; } long j = apVar.f26756h; if (j != 0) { strategyBean2.n = j; } Map<String, String> map = apVar.f26755g; if (map != null && map.size() > 0) { Map<String, String> map2 = apVar.f26755g; strategyBean2.s = map2; String str = map2.get("B11"); if (str == null || !str.equals("1")) { strategyBean2.f26643h = false; } else { strategyBean2.f26643h = true; } String str2 = apVar.f26755g.get("B3"); if (str2 != null) { strategyBean2.f26646v = Long.valueOf(str2).longValue(); } int i = apVar.i; strategyBean2.o = (long) i; strategyBean2.f26645u = (long) i; String str3 = apVar.f26755g.get("B27"); if (str3 != null && str3.length() > 0) { try { int parseInt = Integer.parseInt(str3); if (parseInt > 0) { strategyBean2.t = parseInt; } } catch (Exception e6) { if (!x.a(e6)) { e6.printStackTrace(); } } } String str4 = apVar.f26755g.get("B25"); if (str4 == null || !str4.equals("1")) { strategyBean2.j = false; } else { strategyBean2.j = true; } } x.a("[Strategy] enableCrashReport:%b, enableQuery:%b, enableUserInfo:%b, enableAnr:%b, enableBlock:%b, enableSession:%b, enableSessionTimer:%b, sessionOverTime:%d, enableCocos:%b, strategyLastUpdateTime:%d", Boolean.valueOf(strategyBean2.e), Boolean.valueOf(strategyBean2.f26642g), Boolean.valueOf(strategyBean2.f), Boolean.valueOf(strategyBean2.f26643h), Boolean.valueOf(strategyBean2.i), Boolean.valueOf(strategyBean2.l), Boolean.valueOf(strategyBean2.m), Long.valueOf(strategyBean2.o), Boolean.valueOf(strategyBean2.j), Long.valueOf(strategyBean2.n)); this.f = strategyBean2; if (!z.c(apVar.d)) { x.c("[Strategy] download url is null", new Object[0]); this.f.p = ""; } if (!z.c(apVar.e)) { x.c("[Strategy] download crashurl is null", new Object[0]); this.f.f26644q = ""; } p.a().b(2); r rVar = new r(); rVar.b = 2; rVar.f26791a = strategyBean2.f26641c; rVar.e = strategyBean2.d; rVar.f26793g = z.a(strategyBean2); p.a().a(rVar); a(strategyBean2, true); } } } public final synchronized boolean b() { return this.f != null; } public final StrategyBean c() { StrategyBean strategyBean = this.f; if (strategyBean != null) { if (!z.c(strategyBean.p)) { this.f.p = StrategyBean.f26640a; } if (!z.c(this.f.f26644q)) { this.f.f26644q = StrategyBean.b; } return this.f; } if (!z.a(f26648h) && z.c(f26648h)) { StrategyBean strategyBean2 = this.e; String str = f26648h; strategyBean2.p = str; strategyBean2.f26644q = str; } return this.e; } }