package com.tencent.mm.plugin.appbrand.jsapi; import com.eclipsesource.mmv8.Platform; import com.tencent.luggage.sdk.config.AppBrandInitConfigLU; import com.tencent.mm.plugin.appbrand.appstorage.ICommLibReader; import com.tencent.mm.plugin.appbrand.config.AppBrandInitConfig; import com.tencent.mm.plugin.appbrand.j; import com.tencent.mm.plugin.appbrand.jsruntime.h; import com.tencent.mm.plugin.appbrand.page.b4; import com.tencent.mm.plugin.appbrand.page.f1; import com.tencent.mm.sdk.platformtools.Log; import ek4.c; import gh.q; import java.io.BufferedWriter; import java.io.IOException; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.net.HttpURLConnection; import java.net.URL; import java.net.URLConnection; import lh4.m; import org.json.JSONObject; public final class o0 { public static final class a implements Runnable { /* renamed from: d reason: collision with root package name */ public final /* synthetic */ j f89667d; /* renamed from: e reason: collision with root package name */ public final /* synthetic */ String f89668e; public a(j jVar, String str) { this.f89667d = jVar; this.f89668e = str; } public final void run() { BufferedWriter bufferedWriter; try { URLConnection openConnection = new URL("https://weapp.tencent.com/weapplib_coverage/saveCoverageData").openConnection(); m.e(openConnection, "null cannot be cast to non-null type java.net.HttpURLConnection"); HttpURLConnection httpURLConnection = (HttpURLConnection) openConnection; httpURLConnection.setDoOutput(true); httpURLConnection.setRequestMethod("POST"); httpURLConnection.addRequestProperty("Content-Type", "application/json"); OutputStream outputStream = httpURLConnection.getOutputStream(); m.f(outputStream, "connection.outputStream"); OutputStreamWriter outputStreamWriter = new OutputStreamWriter(outputStream, c.f208058a); if (outputStreamWriter instanceof BufferedWriter) { bufferedWriter = (BufferedWriter) outputStreamWriter; } else { bufferedWriter = new BufferedWriter(outputStreamWriter, 8192); } bufferedWriter.write(this.f89668e); bufferedWriter.flush(); bufferedWriter.close(); httpURLConnection.getOutputStream().close(); int responseCode = httpURLConnection.getResponseCode(); Log.i("Luggage.JSCoverageUtils", "reportCoverage for appId:" + this.f89667d.getAppId() + ", responseCode:" + responseCode + ", data:" + this.f89668e); } catch (IOException e15) { Log.e("Luggage.JSCoverageUtils", "reportCoverage for appId:" + this.f89667d.getAppId() + ", get exception:" + e15 + ", data:" + this.f89668e); } } } public static final void a(j jVar, Object obj, String str) { String str2; String str3; m.g(jVar, "component"); m.g(obj, "jsRuntime"); StringBuilder sb5 = new StringBuilder(); sb5.append("reportCoverage(appId:"); sb5.append(jVar.getAppId()); sb5.append(", "); if (obj instanceof com.tencent.mm.appbrand.v8.j) { str2 = "Worker"; } else if (obj instanceof h) { StringBuilder sb6 = new StringBuilder(); sb6.append("Context("); h hVar = (h) obj; if (hVar.w()) { str3 = "Main"; } else { str3 = String.valueOf(hVar.getContextId()); } sb6.append(str3); sb6.append(')'); str2 = sb6.toString(); } else if (obj instanceof b4) { StringBuilder sb7 = new StringBuilder(); sb7.append("Page("); f1 f1Var = ((b4) obj).f92901e; sb7.append(f1Var != null ? f1Var.V0() : null); sb7.append(')'); str2 = sb7.toString(); } else { throw new IllegalStateException("Invalid jsRuntime".toString()); } sb5.append(str2); sb5.append(", data:"); sb5.append(str); sb5.append(')'); Log.i("Luggage.JSCoverageUtils", sb5.toString()); if (!(str == null || str.length() == 0) && !m.b("null", str) && !m.b("undefined", str)) { ICommLibReader l15 = jVar.l(); m.d(l15); JSONObject jSONObject = new JSONObject(); AppBrandInitConfig d05 = jVar.getRuntime().d0(); m.e(d05, "null cannot be cast to non-null type com.tencent.luggage.sdk.config.AppBrandInitConfigLU"); jSONObject.put("userUin", q.a(((AppBrandInitConfigLU) d05).U)); jSONObject.put("platform", Platform.ANDROID); jSONObject.put("CoverageData", str); jSONObject.put("weapplibVersion", l15.V()); jSONObject.put("weapplibTime", l15.Ld()); String appId = jVar.getAppId(); if (appId == null) { appId = ""; } jSONObject.put("appId", appId); String jSONObject2 = jSONObject.toString(); m.f(jSONObject2, "JSONObject().apply {\n …y())\n }.toString()"); ((xc4.j) xc4.j.f338034d).o(new a(jVar, jSONObject2)); } } }