package fo3; import android.content.Context; import android.content.MutableContextWrapper; import android.view.MotionEvent; import android.view.ViewGroup; import android.view.ViewParent; import android.webkit.ValueCallback; import com.tencent.kinda.framework.widget.tools.ConstantsKinda; import com.tencent.midas.data.APMidasPluginInfo; import com.tencent.mm.app.d0; import com.tencent.mm.plugin.appbrand.appcache.q0; import com.tencent.mm.plugin.appbrand.appcache.r0; import com.tencent.mm.plugin.brandservice.ui.timeline.item.BizTLRecCardJsEngine; import com.tencent.mm.plugin.report.service.q; import com.tencent.mm.sdk.platformtools.BuildInfo; import com.tencent.mm.sdk.platformtools.Log; import com.tencent.mm.sdk.platformtools.MMApplicationContext; import com.tencent.mm.sdk.platformtools.MMKVSlotManager; import com.tencent.mm.sdk.platformtools.MMSlotKt; import com.tencent.mm.sdk.platformtools.MultiProcessMMKV; import com.tencent.youtu.sdkkitframework.common.StateEvent; import ek4.r; import go3.c; import go3.f; import go3.m; import go3.p; import ho3.b; import ho3.c; import ho3.e; import java.net.URL; import java.util.HashMap; import java.util.Iterator; import java.util.concurrent.ConcurrentHashMap; import lh4.o; import wg4.b0; import wg4.n; import xc4.t; public abstract class g extends ho3.c implements m { public static final wg4.g<MMKVSlotManager> P = wg4.h.a(a.f216156d); public final String C = "MicroMsg.WebCanvasJsEngine"; public final wg4.g D = wg4.h.a(new e(this)); public final ho3.f E = new ho3.f(1477); public final HashMap<String, Integer> F = new HashMap<>(); public final wg4.g G = wg4.h.a(new b(this)); public final ConcurrentHashMap<String, a> H = new ConcurrentHashMap<>(); public final ho3.b I = new ho3.b(1498, MMSlotKt.now(), null, 4, null); public final wg4.g J = wg4.h.a(new l(this)); public final wg4.g K = wg4.h.a(new c(this)); public d0.a L; public String M; public String N; public static final class a extends o implements kh4.a<MMKVSlotManager> { /* renamed from: d */ public static final a f216156d = new a(); public a() { super(0); } @Override // kh4.a public MMKVSlotManager invoke() { MultiProcessMMKV mmkv = MultiProcessMMKV.getMMKV("__webcanvans__"); lh4.m.f(mmkv, "getMMKV(\"__webcanvans__\")"); return new MMKVSlotManager(mmkv, 259200); } } public static final class b extends o implements kh4.a<a50.g> { /* renamed from: d */ public final /* synthetic */ g f216157d; /* JADX INFO: super call moved to the top of the method (can break code semantics) */ public b(g gVar) { super(0); this.f216157d = gVar; } @Override // kh4.a public a50.g invoke() { return com.tencent.mm.plugin.webview.webcompt.a.b(this.f216157d.W1()); } } public static final class c extends o implements kh4.a<q0> { /* renamed from: d */ public final /* synthetic */ g f216158d; /* JADX INFO: super call moved to the top of the method (can break code semantics) */ public c(g gVar) { super(0); this.f216158d = gVar; } @Override // kh4.a public q0 invoke() { long now = MMSlotKt.now(); c.b bVar = ho3.c.f227523y; t tVar = t.f216222a; boolean z15 = true; if (tVar.c() != 1) { z15 = false; } q0 b15 = c.b.b(bVar, bVar.a("index.wspkg", z15, tVar.b("wxf337cbaa27790d8e"), "wxf337cbaa27790d8e"), new h(this.f216158d), i.f216181d, false, 8, null); ho3.b bVar2 = this.f216158d.I; long now2 = MMSlotKt.now() - now; bVar2.e(123, 1); bVar2.e(124, now2); Log.i("MicroMsg.WebCanvasPerformanceReporter", "performance: [bizPkg]:" + now2 + " ms"); return b15; } } public static final class d extends o implements kh4.l<String, b0> { /* renamed from: d */ public final /* synthetic */ g f216159d; /* renamed from: e */ public final /* synthetic */ String f216160e; /* renamed from: f */ public final /* synthetic */ long f216161f; /* JADX INFO: super call moved to the top of the method (can break code semantics) */ public d(g gVar, String str, long j15) { super(1); this.f216159d = gVar; this.f216160e = str; this.f216161f = j15; } @Override // kh4.l public b0 invoke(String str) { boolean z15; boolean z16; boolean z17; boolean z18; ho3.b bVar = this.f216159d.I; String str2 = this.f216160e; long j15 = this.f216161f; bVar.getClass(); lh4.m.g(str2, "id"); b.C3000b bVar2 = bVar.f227510g.get(str2); if (bVar2 != null) { boolean z19 = true; bVar2.f227521c = true; long currentTimeMillis = System.currentTimeMillis() - j15; if (currentTimeMillis > 10000) { Log.w("MicroMsg.WebCanvasPerformanceReporter", "invalid timePast " + currentTimeMillis); } else { if (!bVar2.f227520b) { bVar.e(28, currentTimeMillis); if (50 > currentTimeMillis || currentTimeMillis >= 101) { z17 = false; } else { z17 = true; } if (z17) { bVar.e(30, 1); } else { if (101 > currentTimeMillis || currentTimeMillis >= 301) { z18 = false; } else { z18 = true; } if (z18) { bVar.e(31, 1); } else { if (301 > currentTimeMillis || currentTimeMillis >= 501) { z19 = false; } if (z19) { bVar.e(32, 1); } else if (currentTimeMillis > 500) { bVar.e(33, 1); } } } } else { bVar.e(39, currentTimeMillis); if (50 > currentTimeMillis || currentTimeMillis >= 101) { z15 = false; } else { z15 = true; } if (z15) { bVar.e(41, 1); } else { if (101 > currentTimeMillis || currentTimeMillis >= 301) { z16 = false; } else { z16 = true; } if (z16) { bVar.e(42, 1); } else { if (301 > currentTimeMillis || currentTimeMillis >= 501) { z19 = false; } if (z19) { bVar.e(43, 1); } else if (currentTimeMillis > 500) { bVar.e(44, 1); } } } } String str3 = bVar.f227506c + "," + str2 + "," + bVar2.f227522d + "," + currentTimeMillis + "," + (bVar2.f227520b ? 1 : 0); lh4.m.f(str3, "StringBuilder().apply {\n…\n }.toString()"); q.INSTANCE.kvStat(20920, str3); Log.i("MicroMsg.WebCanvasPerformanceReporter", "performance: [ClientContextReady]:" + currentTimeMillis + "ms isMainContextStarted:" + bVar2.f227520b); } } a U1 = this.f216159d.X1().U1(this.f216160e); if (U1 != null) { U1.n(); } g.U1(this.f216159d, "create", this.f216160e, null, 4, null); return b0.f332794a; } } public static final class e extends o implements kh4.a<com.tencent.mm.appbrand.v8.j> { /* renamed from: d */ public final /* synthetic */ g f216162d; /* JADX INFO: super call moved to the top of the method (can break code semantics) */ public e(g gVar) { super(0); this.f216162d = gVar; } @Override // kh4.a public com.tencent.mm.appbrand.v8.j invoke() { return this.f216162d.f90889g; } } public static final class f extends o implements kh4.a<zd.o> { /* renamed from: d */ public final /* synthetic */ g f216163d; /* JADX INFO: super call moved to the top of the method (can break code semantics) */ public f(g gVar) { super(0); this.f216163d = gVar; } @Override // kh4.a public zd.o invoke() { return new zd.o(this.f216163d.m(), this.f216163d.N0(), this.f216163d.k()); } } /* renamed from: fo3.g$g */ public static final class C2631g implements de.a { /* renamed from: d */ public final /* synthetic */ g f216164d; public C2631g(g gVar) { this.f216164d = gVar; } @Override // de.a public void a() { this.f216164d.f90888f.a(); } @Override // de.a public boolean d() { return this.f216164d.f90888f.d(); } @Override // de.a public String e() { return this.f216164d.e(); } @Override // de.a public void p(Runnable runnable, boolean z15) { lh4.m.g(runnable, "p0"); this.f216164d.p(runnable, z15); } @Override // de.a public boolean q() { return this.f216164d.f90888f.j(); } } public static final class h extends o implements kh4.l<String, b0> { /* renamed from: d */ public final /* synthetic */ g f216165d; /* JADX INFO: super call moved to the top of the method (can break code semantics) */ public h(g gVar) { super(1); this.f216165d = gVar; } @Override // kh4.l public b0 invoke(String str) { this.f216165d.I.d(0); return b0.f332794a; } } public static final class i extends d0.a { /* renamed from: d */ public boolean f216166d = true; /* renamed from: e */ public final /* synthetic */ g f216167e; public static final class a implements Runnable { /* renamed from: d */ public final /* synthetic */ g f216168d; /* renamed from: e */ public final /* synthetic */ i f216169e; /* renamed from: fo3.g$i$a$a */ public static final class C2632a<T> implements ValueCallback { /* renamed from: a */ public final /* synthetic */ g f216170a; public C2632a(g gVar) { this.f216170a = gVar; } @Override // android.webkit.ValueCallback public void onReceiveValue(Object obj) { String str = (String) obj; Log.i(this.f216170a.C, "logicJsEngine pause callback"); } } public static final class b implements Runnable { /* renamed from: d */ public final /* synthetic */ g f216171d; /* renamed from: e */ public final /* synthetic */ i f216172e; public b(g gVar, i iVar) { this.f216171d = gVar; this.f216172e = iVar; } public final void run() { String str = this.f216171d.C; Log.i(str, "logicJsEngine pause isAppForeground=" + this.f216172e.f216166d); if (!this.f216172e.f216166d) { g gVar = this.f216171d; if (!gVar.f227530w) { gVar.pause(); } } } } public a(g gVar, i iVar) { this.f216168d = gVar; this.f216169e = iVar; } public final void run() { g gVar = this.f216168d; if (!gVar.f227530w) { this.f216169e.f216166d = false; c.a.a(gVar, "background", null, new C2632a(gVar), 2, null); t tVar = xc4.j.f338034d; b bVar = new b(this.f216168d, this.f216169e); xc4.j jVar = (xc4.j) tVar; jVar.getClass(); jVar.w(bVar, 3000, false); if (this.f216168d.Y1()) { x X1 = this.f216168d.X1(); synchronized (X1) { if (!X1.M) { X1.M = true; if (X1.N) { X1.N = false; m60.d.O(new a0(X1)); } X1.pause(); Log.i(X1.G, "renderJsEngine pause"); } b0 b0Var = b0.f332794a; } } } } } public static final class b implements Runnable { /* renamed from: d */ public final /* synthetic */ g f216173d; /* renamed from: e */ public final /* synthetic */ i f216174e; public b(g gVar, i iVar) { this.f216173d = gVar; this.f216174e = iVar; } public final void run() { g gVar = this.f216173d; if (!gVar.f227530w) { this.f216174e.f216166d = true; Log.i(gVar.C, "logicJsEngine resume"); try { if (this.f216173d.Y1()) { x X1 = this.f216173d.X1(); synchronized (X1) { if (X1.M) { X1.M = false; X1.resume(); if (!X1.N) { X1.N = true; m60.d.O(new b0(X1)); } Log.i(X1.G, "renderJsEngine resume"); } b0 b0Var = b0.f332794a; } } this.f216173d.resume(); c.a.a(this.f216173d, "foreground", null, null, 6, null); } catch (Exception e15) { Log.printErrStackTrace(this.f216173d.C, e15, "onAppForeground ex", new Object[0]); } } } } public i(g gVar) { this.f216167e = gVar; } @Override // com.tencent.mm.app.d0 public synchronized void onAppBackground(String str) { ((xc4.j) xc4.j.f338034d).z(new a(this.f216167e, this)); } @Override // com.tencent.mm.app.d0 public synchronized void onAppForeground(String str) { ((xc4.j) xc4.j.f338034d).z(new b(this.f216167e, this)); } } public static final class j<T> implements ValueCallback { /* renamed from: a */ public final /* synthetic */ g f216175a; public j(g gVar) { this.f216175a = gVar; } @Override // android.webkit.ValueCallback public void onReceiveValue(Object obj) { String str = (String) obj; String str2 = this.f216175a.C; } } public static final class k implements ValueCallback { /* renamed from: a */ public final /* synthetic */ kh4.l f216176a; public k(kh4.l lVar) { this.f216176a = lVar; } @Override // android.webkit.ValueCallback public final /* synthetic */ void onReceiveValue(Object obj) { this.f216176a.invoke(obj); } } public static final class l extends o implements kh4.a<q0> { /* renamed from: d */ public final /* synthetic */ g f216177d; /* JADX INFO: super call moved to the top of the method (can break code semantics) */ public l(g gVar) { super(0); this.f216177d = gVar; } @Override // kh4.a public q0 invoke() { long now = MMSlotKt.now(); c.b bVar = ho3.c.f227523y; t tVar = t.f216222a; boolean z15 = true; if (tVar.c() != 1) { z15 = false; } q0 b15 = c.b.b(bVar, bVar.a("webtimeline.wspkg", z15, tVar.b("wxfedb0854e2b1820d"), "wxfedb0854e2b1820d"), l.f216189d, m.f216191d, false, 8, null); ho3.b bVar2 = this.f216177d.I; long now2 = MMSlotKt.now() - now; bVar2.e(120, 1); bVar2.e(121, now2); Log.i("MicroMsg.WebCanvasPerformanceReporter", "performance: [basePkg]:" + now2 + " ms"); return b15; } } public g() { Z1(); this.M = "none"; this.N = ""; } /* JADX DEBUG: Multi-variable search result rejected for r0v0, resolved type: fo3.g */ /* JADX WARN: Multi-variable type inference failed */ public static void U1(g gVar, String str, String str2, ValueCallback valueCallback, int i15, Object obj) { if (obj == null) { if ((i15 & 4) != 0) { valueCallback = null; } gVar.getClass(); lh4.m.g(str, "event"); lh4.m.g(str2, "canvasId"); gVar.M0(str, "{target:'" + str2 + "'}", valueCallback); return; } throw new UnsupportedOperationException("Super calls with default arguments not supported in this target, function: emit"); } public static /* synthetic */ void d2(g gVar, String str, long j15, int i15, Object obj) { if (obj == null) { if ((i15 & 2) != 0) { j15 = -1; } gVar.c2(str, j15); return; } throw new UnsupportedOperationException("Super calls with default arguments not supported in this target, function: reflow"); } @Override // ho3.c public void C1(com.tencent.mm.plugin.appbrand.jsruntime.h hVar, String str, String str2, kh4.l<? super String, b0> lVar, c.a aVar) { lh4.m.g(hVar, "context"); lh4.m.g(str, "name"); lh4.m.g(str2, "type"); com.tencent.mm.plugin.appbrand.jsruntime.h z15 = z(); if (z15 != null) { z15.L(hVar, "NativeGlobal"); } super.C1(hVar, str, str2, lVar, aVar); } @Override // ho3.c public c.a G1(String str) { long j15; lh4.m.g(str, "type"); String V1 = V1(); a50.g m15 = ((a50.g) ((n) this.G).getValue()).optJSONObject("client").optJSONObject(str); if (m15 != null) { j15 = m15.optLong("idKey"); } else { j15 = 0; } return new c.a(V1, j15); } @Override // ho3.c public ho3.f I1() { return this.E; } @Override // ho3.c public q0 K1() { return (q0) this.J.getValue(); } @Override // ho3.c public void N1(String str, String str2, com.tencent.mm.plugin.appbrand.jsruntime.h hVar, ho3.e eVar, kh4.l<? super String, b0> lVar) { k kVar; lh4.m.g(str, "name"); lh4.m.g(str2, "type"); lh4.m.g(hVar, "context"); lh4.m.g(eVar, "contextReporter"); try { String string = ((a50.g) ((n) this.G).getValue()).getJSONObject("client").getJSONObject(str2).getString(ConstantsKinda.INTENT_LITEAPP_PATH); q0 W1 = W1(); lh4.m.f(string, ConstantsKinda.INTENT_LITEAPP_PATH); String a15 = r0.a(W1, string); k kVar2 = null; if (!BuildInfo.DEBUG || 1 <= Log.getLogLevel()) { URL url = new URL("https://ws/usr/" + V1() + string); String E1 = E1(V1(), string); String valueOf = String.valueOf(com.tencent.mm.plugin.webview.webcompt.a.c(W1())); if (lVar != null) { kVar = new k(lVar); } else { kVar = null; } hVar.U0(url, E1, valueOf, 0, a15, kVar); return; } if (lVar != null) { kVar2 = new k(lVar); } hVar.evaluateJavascript(a15, kVar2); } catch (Exception e15) { eVar.a(new e.f()); throw e15; } } @Override // ho3.c public void O1(String str, String str2) { lh4.m.g(str, StateEvent.Name.MESSAGE); lh4.m.g(str2, "targetOrigin"); X1().M1(str, str2); } public void R1(String str) { lh4.m.g(str, "canvasId"); String str2 = this.C; Log.i(str2, "attach #" + str); U1(this, "attach", str, null, 4, null); } public void S1() { ViewGroup viewGroup; MutableContextWrapper mutableContextWrapper; ((kp3.l) ((BizTLRecCardJsEngine) this).S).f247885c = MMApplicationContext.getContext(); if (Y1()) { x X1 = X1(); Iterator<String> it = X1.P.iterator(); while (it.hasNext()) { String next = it.next(); Log.i(X1.G, "canvasContext#" + next + " should be destroyed"); a aVar = X1.C.H.get(next); if (aVar != null) { m0 m0Var = aVar.f216084h; if (m0Var != null) { aVar.i().K(m0Var.f216194c); aVar.i().M0("destroy", "{target:'" + aVar.f216080d + "'}", d.f216131a); ViewParent parent = m0Var.b().getParent(); if (parent instanceof ViewGroup) { viewGroup = (ViewGroup) parent; } else { viewGroup = null; } if (viewGroup != null) { viewGroup.removeView(m0Var.b()); } Context context = m0Var.b().getContext(); if (context instanceof MutableContextWrapper) { mutableContextWrapper = (MutableContextWrapper) context; } else { mutableContextWrapper = null; } if (mutableContextWrapper != null) { mutableContextWrapper.setBaseContext(MMApplicationContext.getContext()); } Log.i("MicroMsg.WebCanvasContext", "canvas#" + aVar.f216080d + ':' + m0Var.f216194c + '@' + m0Var.b().getVirtualElementId() + " has been destroyed"); m0Var.b().a(); } aVar.f216084h = null; } } X1.P.clear(); } } public final synchronized a T1(String str, String str2, String str3, Context context) { lh4.m.g(str, "type"); lh4.m.g(str2, "canvasId"); lh4.m.g(str3, "data"); lh4.m.g(context, "context"); if (this.F.containsKey(str2)) { d2(this, str2, 0, 2, null); return x.W1(X1(), context, str2, false, false, 12, null); } c0.f216126a.a(str2); long now = MMSlotKt.now(); String str4 = this.C; Log.i(str4, "create #" + str2 + ", dataSize=" + str3.length()); HashMap<String, Integer> hashMap = this.F; com.tencent.mm.plugin.appbrand.jsruntime.h Z = Z(); a2(context, str2, str3, Z); ho3.c.D1(this, Z, "CanvasContext#" + str2, str, new d(this, str2, now), null, 16, null); this.I.a(str2, now); hashMap.put(str2, Integer.valueOf(((com.tencent.mm.plugin.appbrand.jsruntime.g) Z).f90926h)); ho3.b bVar = this.I; bVar.getClass(); bVar.f227510g.put(str2, new b.C3000b(now, bVar.f227508e)); return x.W1(X1(), context, str2, false, false, 12, null); } public abstract String V1(); public final q0 W1() { return (q0) this.K.getValue(); } public abstract x X1(); public boolean Y1() { return false; } public void Z1() { Log.i(this.C, APMidasPluginInfo.LAUNCH_INTERFACE_INIT); if (BuildInfo.DEBUG || BuildInfo.IS_FLAVOR_RED) { zd.m mVar = new zd.m(); mVar.f351930a = MMApplicationContext.getContext(); mVar.f351932c = new f(this); mVar.f351931b = new C2631g(this); mVar.l(); } go3.j jVar = new go3.j(this); com.tencent.mm.plugin.appbrand.jsruntime.h z15 = z(); lh4.m.f(z15, "mainJsContext"); jVar.a(z15); this.I.c(0); B1(new h(this)); this.I.b(0); i iVar = new i(this); iVar.alive(); this.L = iVar; } public void a2(Context context, String str, String str2, com.tencent.mm.plugin.appbrand.jsruntime.j jVar) { lh4.m.g(context, "context"); lh4.m.g(str, "canvasId"); lh4.m.g(str2, "data"); lh4.m.g(jVar, "jsRuntime"); new go3.l(this).a(jVar); a W1 = x.W1(X1(), context, str, false, false, 12, null); new go3.f(W1).a(jVar); new p(new v(W1, this)).a(jVar); } public final void b2(String str, int i15) { lh4.m.g(str, "canvasId"); M0("destroy", "{target:'" + str + "'}", new j(this)); K(i15); String str2 = this.C; Log.i(str2, "recycleContext canvasId=" + str + ", contextId=" + i15); } public final void c2(String str, long j15) { lh4.m.g(str, "canvasId"); String str2 = this.C; Log.i(str2, "reflow #" + str); a U1 = X1().U1(str); if (U1 != null) { U1.n(); } c.a.a(this, "reflow", "{target:'" + str + "', start:" + j15 + '}', null, 4, null); } @Override // com.tencent.mm.plugin.appbrand.jsruntime.j, com.tencent.mm.plugin.appbrand.jsruntime.h, ho3.c, com.tencent.mm.plugin.appbrand.jsruntime.e, com.tencent.mm.plugin.appbrand.jsruntime.b public void destroy() { d0.a aVar = this.L; if (aVar != null) { aVar.dead(); } super.destroy(); } public void e2(String str, MotionEvent motionEvent) { String str2; lh4.m.g(str, "canvasId"); lh4.m.g(motionEvent, "touch"); int action = motionEvent.getAction(); if (action == 0) { str2 = "touchstart"; } else if (action == 1) { str2 = "touchend"; } else if (action == 2) { str2 = "touchmove"; } else if (action != 3) { str2 = null; } else { str2 = "touchcancel"; } if (str2 != null) { int actionIndex = motionEvent.getActionIndex(); StringBuilder sb5 = new StringBuilder(); sb5.append("\n {\n target:\""); sb5.append(str); sb5.append("\",\n touches: [{\n identifier:"); sb5.append(motionEvent.getPointerId(actionIndex)); sb5.append(",\n clientX:"); f.c cVar = go3.f.f221926d; sb5.append(cVar.a(Float.valueOf(motionEvent.getX()))); sb5.append(",\n clientY:"); sb5.append(cVar.a(Float.valueOf(motionEvent.getY()))); sb5.append("\n }]\n }\n "); c.a.a(this, str2, r.b(sb5.toString()), null, 4, null); } } @Override // go3.m public int l0() { return com.tencent.mm.plugin.webview.webcompt.a.c(K1()); } @Override // go3.m public int x0() { return com.tencent.mm.plugin.webview.webcompt.a.c(W1()); } }