Initial commit

This commit is contained in:
2025-05-13 19:24:51 +02:00
commit a950f49678
10604 changed files with 932663 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
package com.baidu.uaq.agent.android.trace;
import com.baidu.uaq.agent.android.harvest.bean.h;
import java.util.List;
import org.json.JSONObject;
/* compiled from: TraceParser.java */
/* loaded from: classes.dex */
public interface a {
JSONObject a(List<h> list);
}

View File

@@ -0,0 +1,155 @@
package com.baidu.uaq.agent.android.trace.lss;
import com.baidu.uaq.agent.android.harvest.bean.h;
import com.baidu.uaq.agent.android.logging.b;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
/* compiled from: LssTraceParser.java */
/* loaded from: classes.dex */
public class a implements com.baidu.uaq.agent.android.trace.a {
private static final com.baidu.uaq.agent.android.logging.a c = b.a();
private static final Map<String, JSONObject> d = new HashMap();
Map<String, JSONArray> a = new HashMap();
Map<String, JSONArray> b = new HashMap();
private JSONObject b(JSONObject jSONObject) {
JSONArray jSONArray = new JSONArray();
try {
for (Map.Entry<String, JSONObject> entry : d.entrySet()) {
JSONObject value = entry.getValue();
value.put("Events", this.a.get(entry.getKey()));
jSONArray.put(value);
}
jSONObject.put("Traces", jSONArray);
} catch (JSONException e) {
c.a("Caught error while LssTraceParser parse: ", e);
com.baidu.uaq.agent.android.harvest.health.a.a(e);
}
return jSONObject;
}
private void c(JSONObject jSONObject) {
try {
Object obj = jSONObject.get("Trace");
JSONObject jSONObject2 = obj instanceof JSONObject ? (JSONObject) obj : null;
if (jSONObject2 == null || jSONObject2.isNull("TraceId") || jSONObject2.getString("TraceId").isEmpty()) {
c.b("TraceId should not be empty");
return;
}
String str = jSONObject2.getString("TraceId") + d(jSONObject2);
Object remove = jSONObject2.remove("Event");
if (this.a.containsKey(str)) {
this.a.get(str).put(remove);
} else {
this.a.put(str, new JSONArray().put(remove));
d.put(str, jSONObject2);
}
} catch (JSONException e) {
c.a("Caught error while LssTraceParser parse: ", e);
com.baidu.uaq.agent.android.harvest.health.a.a(e);
}
}
private String d(JSONObject jSONObject) {
if (jSONObject.isNull("CommData")) {
return null;
}
try {
Object obj = jSONObject.get("CommData");
if (!(obj instanceof JSONObject)) {
return null;
}
JSONObject jSONObject2 = (JSONObject) obj;
if (jSONObject2.isNull("playID") || jSONObject2.getString("playID").isEmpty()) {
return null;
}
return (String) jSONObject2.get("playID");
} catch (JSONException e) {
c.a("Caught error while getPlayID: ", e);
com.baidu.uaq.agent.android.harvest.health.a.a(e);
return null;
}
}
@Override // com.baidu.uaq.agent.android.trace.a
public JSONObject a(List<h> list) {
Iterator<h> it = list.iterator();
JSONObject jSONObject = new JSONObject();
while (it.hasNext()) {
JSONObject b = it.next().b();
if (b != null) {
Iterator<String> keys = b.keys();
while (keys.hasNext()) {
String next = keys.next();
if (next.equals("Trace")) {
c(b);
} else {
a(b, next);
}
keys.remove();
}
it.remove();
}
}
b(jSONObject);
a(jSONObject);
a();
return jSONObject;
}
private void a() {
Map<String, JSONObject> map = d;
if (map != null) {
map.clear();
}
Map<String, JSONArray> map2 = this.a;
if (map2 != null) {
map2.clear();
}
Map<String, JSONArray> map3 = this.b;
if (map3 != null) {
map3.clear();
}
}
private JSONObject a(JSONObject jSONObject) {
for (Map.Entry<String, JSONArray> entry : this.b.entrySet()) {
if (jSONObject != null) {
try {
jSONObject.put(entry.getKey(), this.b.get(entry.getKey()));
} catch (JSONException e) {
c.a("Caught error while LssTraceParser parse: ", e);
com.baidu.uaq.agent.android.harvest.health.a.a(e);
}
}
}
return jSONObject;
}
private void a(JSONObject jSONObject, String str) {
new JSONArray();
try {
if (this.b.containsKey(str)) {
JSONArray jSONArray = this.b.get(str);
Object obj = jSONObject.get(str);
if (obj instanceof JSONObject) {
jSONArray.put(obj);
}
} else {
Object obj2 = jSONObject.get(str);
if (obj2 instanceof JSONObject) {
this.b.put(str, new JSONArray().put(obj2));
}
}
} catch (JSONException e) {
c.a("Caught error while LssTraceParser parse: ", e);
com.baidu.uaq.agent.android.harvest.health.a.a(e);
}
}
}