package com.baidu.uaq.agent.android.crashes; import com.baidu.uaq.agent.android.UAQ; import com.baidu.uaq.agent.android.util.l; import com.ubt.jimu.diy.view.fragment.BuildStepFragment; import java.util.Iterator; import java.util.List; import java.util.UUID; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; /* compiled from: Crash.java */ /* loaded from: classes.dex */ public class b extends com.baidu.uaq.agent.android.harvest.type.d { private static final UAQ l = UAQ.getInstance(); private int b; private final UUID c; private final String d; private final long e; private final String f; private final String g; private e h; private a i; private f j; private List k; public b(UUID uuid, String str, long j) { this.b = 1; this.c = uuid; this.d = str; this.e = j; this.f = l.getConfig().getAPIKey(); this.g = l.getConfig().getCuid(); } private static Throwable a(Throwable th) { Throwable cause = th.getCause(); return cause == null ? th : a(cause); } public static b b(String str) { b bVar; JSONObject jSONObject; try { jSONObject = new JSONObject(str); bVar = new b(UUID.fromString(jSONObject.getString(BuildStepFragment.UUID)), jSONObject.getString("buildId"), jSONObject.getLong("timestamp")); } catch (JSONException e) { e = e; bVar = null; } try { bVar.h = e.a(jSONObject.getJSONObject("deviceInfo")); bVar.i = a.a(jSONObject.getJSONObject("appInfo")); bVar.j = f.a(jSONObject.getJSONObject("exception")); bVar.k = h.b(jSONObject.getJSONArray("threads")); } catch (JSONException e2) { e = e2; e.printStackTrace(); return bVar; } return bVar; } public static String f() { return ""; } private JSONArray g() { JSONArray jSONArray = new JSONArray(); Iterator it = this.k.iterator(); while (it.hasNext()) { jSONArray.put(it.next().d()); } return jSONArray; } @Override // com.baidu.uaq.agent.android.harvest.type.a public JSONObject d() { JSONObject jSONObject = new JSONObject(); try { jSONObject.put("protocolVersion", this.b); jSONObject.put("platform", "Android"); jSONObject.put(BuildStepFragment.UUID, this.c.toString()); jSONObject.put("buildId", this.d); jSONObject.put("timestamp", Long.valueOf(this.e)); jSONObject.put("appToken", this.f); jSONObject.put("cuid", com.baidu.uaq.agent.android.util.e.a(this.g)); jSONObject.put("deviceInfo", this.h.d()); jSONObject.put("appInfo", this.i.d()); jSONObject.put("exception", this.j.d()); jSONObject.put("threads", g()); jSONObject.put("activityHistory", new JSONArray()); com.baidu.uaq.agent.android.harvest.bean.b j = com.baidu.uaq.agent.android.harvest.multiharvest.d.c().j(); if (j != null) { jSONObject.put("dataToken", j.a()); } } catch (Exception e) { e.printStackTrace(); } return jSONObject; } public UUID e() { return this.c; } public b(Throwable th) { this.b = 1; com.baidu.uaq.agent.android.b a = com.baidu.uaq.agent.android.a.a(); Throwable a2 = a(th); this.c = new UUID(l.a().nextLong(), l.a().nextLong()); this.d = f(); this.e = System.currentTimeMillis() / 1000; this.f = l.getConfig().getAPIKey(); this.g = l.getConfig().getCuid(); this.h = new e(a.a(), a.e()); this.i = new a(a.b()); this.j = new f(a2); this.k = h.a(a2); } }