jimu-decompiled/sources/com/baidu/uaq/agent/android/crashes/h.java
2025-05-13 19:24:51 +02:00

145 lines
5.0 KiB
Java

package com.baidu.uaq.agent.android.crashes;
import com.ubt.jimu.diy.model.CategoryModel;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
/* compiled from: ThreadInfo.java */
/* loaded from: classes.dex */
public class h extends com.baidu.uaq.agent.android.harvest.type.d {
private boolean b;
private long c;
private String d;
private int e;
private StackTraceElement[] f;
private String g;
private h() {
}
public static List<h> a(Throwable th) {
ArrayList arrayList = new ArrayList();
h hVar = new h(th);
long e = hVar.e();
arrayList.add(hVar);
for (Map.Entry<Thread, StackTraceElement[]> entry : Thread.getAllStackTraces().entrySet()) {
Thread key = entry.getKey();
StackTraceElement[] value = entry.getValue();
if (key.getId() != e) {
arrayList.add(new h(key, value));
}
}
return arrayList;
}
public static List<h> b(JSONArray jSONArray) {
ArrayList arrayList = new ArrayList();
for (int i = 0; i < jSONArray.length(); i++) {
try {
arrayList.add(a(jSONArray.getJSONObject(i)));
} catch (JSONException e) {
e.printStackTrace();
}
}
return arrayList;
}
private JSONArray f() {
JSONArray jSONArray = new JSONArray();
for (StackTraceElement stackTraceElement : this.f) {
try {
if (stackTraceElement != null) {
JSONObject jSONObject = new JSONObject();
if (stackTraceElement.getFileName() != null) {
jSONObject.put("fileName", stackTraceElement.getFileName());
}
jSONObject.put("className", stackTraceElement.getClassName());
jSONObject.put("methodName", stackTraceElement.getMethodName());
jSONObject.put("lineNumber", Integer.valueOf(stackTraceElement.getLineNumber()));
jSONArray.put(jSONObject);
}
} catch (JSONException e) {
e.printStackTrace();
}
}
return jSONArray;
}
@Override // com.baidu.uaq.agent.android.harvest.type.a
public JSONObject d() {
JSONObject jSONObject = new JSONObject();
try {
jSONObject.put("crashed", Boolean.valueOf(this.b));
jSONObject.put("state", this.g);
jSONObject.put("threadNumber", Long.valueOf(this.c));
jSONObject.put("threadId", this.d);
jSONObject.put("priority", Integer.valueOf(this.e));
jSONObject.put("stack", f());
} catch (JSONException e) {
e.printStackTrace();
}
return jSONObject;
}
public long e() {
return this.c;
}
public h(Throwable th) {
this.b = true;
this.c = Thread.currentThread().getId();
this.d = Thread.currentThread().getName();
this.e = Thread.currentThread().getPriority();
this.f = th.getStackTrace();
this.g = Thread.currentThread().getState().toString();
}
public h(Thread thread, StackTraceElement[] stackTraceElementArr) {
this.b = false;
this.c = thread.getId();
this.d = thread.getName();
this.e = thread.getPriority();
this.f = stackTraceElementArr;
this.g = thread.getState().toString();
}
public static h a(JSONObject jSONObject) {
h hVar = new h();
try {
hVar.b = jSONObject.getBoolean("crashed");
hVar.g = jSONObject.getString("state");
hVar.c = jSONObject.getLong("threadNumber");
hVar.d = jSONObject.getString("threadId");
hVar.e = jSONObject.getInt("priority");
hVar.f = a(jSONObject.getJSONArray("stack"));
} catch (JSONException e) {
e.printStackTrace();
}
return hVar;
}
public static StackTraceElement[] a(JSONArray jSONArray) {
StackTraceElement[] stackTraceElementArr = new StackTraceElement[jSONArray.length()];
int i = 0;
while (i < jSONArray.length()) {
try {
String str = CategoryModel.unknown;
if (jSONArray.getJSONObject(i).optString("fileName") != null) {
str = jSONArray.getJSONObject(i).optString("fileName");
}
StackTraceElement stackTraceElement = new StackTraceElement(jSONArray.getJSONObject(i).getString("className"), jSONArray.getJSONObject(i).getString("methodName"), str, jSONArray.getJSONObject(i).getInt("lineNumber"));
int i2 = i + 1;
stackTraceElementArr[i] = stackTraceElement;
i = i2 + 1;
} catch (JSONException e) {
e.printStackTrace();
}
}
return stackTraceElementArr;
}
}