package X; import android.content.Context; import com.bytedance.covode.number.Covode; import com.bytedance.framwork.core.sdkmonitor.SDKMonitorUtils; import com.bytedance.pitaya.api.bean.PTYErrorCode; import com.bytedance.pitaya.inner.api.bean.SetupInfo; import java.util.Iterator; import java.util.Map; import kotlin.g.b.m; import org.json.JSONException; import org.json.JSONObject; public final class Q9M { public static final Q9M LIZ = new Q9M(); public static C275717i LIZIZ; public static SetupInfo LIZJ; static { Covode.recordClassIndex(30667); } public final void LIZ(SetupInfo setupInfo) { C21090sc.LIZ(setupInfo); SDKMonitorUtils.LIZ("8326", AnonymousClass1ZP.LIZ("https://mon.isnssdk.com/monitor/appmonitor/v2/settings")); SDKMonitorUtils.LIZIZ("8326", AnonymousClass1ZP.LIZ("https://mon.isnssdk.com/monitor/collect/")); JSONObject jSONObject = new JSONObject(); jSONObject.put("device_id", setupInfo.getDid()).put("host_aid", setupInfo.getAid()).put("channel", setupInfo.getChannel()).put("app_version", setupInfo.getAppVersion()).put("sdk_version", "2.1.0.i18n-rc.84-r21b"); Context LIZ2 = Q9P.LIZIZ.LIZ(); if (LIZ2 != null) { SDKMonitorUtils.LIZ(LIZ2, "8326", jSONObject, new Q9L(setupInfo)); LIZIZ = SDKMonitorUtils.LIZ("8326"); LIZJ = setupInfo; return; } throw new C23830x2("null cannot be cast to non-null type android.content.Context"); } public final void LIZ(String str, String str2, String str3) { C21090sc.LIZ(str); Map<Thread, StackTraceElement[]> allStackTraces = Thread.getAllStackTraces(); m.LIZ((Object) allStackTraces, ""); StackTraceElement stackTraceElement = null; for (Map.Entry<Thread, StackTraceElement[]> entry : allStackTraces.entrySet()) { Thread key = entry.getKey(); m.LIZ((Object) key, ""); String name = key.getName(); Thread currentThread = Thread.currentThread(); m.LIZ((Object) currentThread, ""); if (m.LIZ((Object) name, (Object) currentThread.getName())) { StackTraceElement[] value = entry.getValue(); m.LIZ((Object) value, ""); if (value.length != 0) { StackTraceElement[] value2 = entry.getValue(); m.LIZ((Object) value2, ""); stackTraceElement = (StackTraceElement) AnonymousClass1YG.LIZJ(value2); } } } if (stackTraceElement == null) { stackTraceElement = new StackTraceElement("PitayaCore", "Unknown method", "", 0); } if (stackTraceElement != null) { Thread currentThread2 = Thread.currentThread(); m.LIZ((Object) currentThread2, ""); C272716e LIZ2 = C272716e.LIZ(stackTraceElement, "com.bytedance.pitaya.thirdpart.SDKMonitor.threadException", "RunTaskError", currentThread2.getName(), false, "EnsureNotReachHere", "pitaya_sdk_task_runtime_error"); m.LIZ((Object) LIZ2, ""); if (str2 != null) { try { JSONObject jSONObject = new JSONObject(str2); Iterator<String> keys = jSONObject.keys(); m.LIZ((Object) keys, ""); while (keys.hasNext()) { String next = keys.next(); LIZ2.LIZ(next, jSONObject.optString(next)); } LIZ2.LIZ("type", str); } catch (JSONException e) { Q9K.LIZ(Q9K.LIZ, e, null, null, 6); } } if (str3 != null) { try { JSONObject jSONObject2 = new JSONObject(str3); Iterator<String> keys2 = jSONObject2.keys(); m.LIZ((Object) keys2, ""); while (keys2.hasNext()) { String next2 = keys2.next(); LIZ2.LIZJ(next2, jSONObject2.optString(next2)); } } catch (JSONException e2) { Q9K.LIZ(Q9K.LIZ, e2, null, null, 6); } } C06620Ot.LIZ(LIZ2); } } public final void LIZ(String str, Throwable th) { C21090sc.LIZ(str, th); JSONObject jSONObject = new JSONObject(); SetupInfo setupInfo = LIZJ; JSONObject put = jSONObject.put("app_ver", setupInfo != null ? setupInfo.getAppVersion() : null).put("code", PTYErrorCode.SUB_MODULE_SO_ERROR).put("err", str); SetupInfo setupInfo2 = LIZJ; JSONObject put2 = put.put("plugin", setupInfo2 != null ? setupInfo2.getPluginVersion() : null); SetupInfo setupInfo3 = LIZJ; LIZ("pitaya2_submodule_load_error", put2.put("sdk_build_ver", setupInfo3 != null ? setupInfo3.getSdkBuildVersion() : null).put("sdk_ver", "2.1.0"), null, new JSONObject().put("error_detail", th.toString()).put("extra_info", (Object) null)); } public final void LIZ(String str, JSONObject jSONObject, JSONObject jSONObject2, JSONObject jSONObject3) { C21090sc.LIZ(str); JSONObject put = new JSONObject().put("extra", jSONObject3); C275717i r0 = LIZIZ; if (r0 != null) { r0.LIZ(str, jSONObject, jSONObject2, put); } } }