package X; import andhook.lib.xposed.ClassUtils; import android.webkit.JavascriptInterface; import android.webkit.ValueCallback; import com.bytedance.covode.number.Covode; import kotlin.g.b.m; import org.json.JSONObject; public final class JCA extends JCB { public final C48716JAz LIZ; public final String LJ = "JSB3BridgeImpl"; public final String LJFF = "JSBridge"; public final String LJI = "Native2JSBridge"; public final String LJII = "JS2NativeBridge"; static { Covode.recordClassIndex(32169); } /* JADX INFO: super call moved to the top of the method (can break code semantics) */ public JCA(C48716JAz jAz) { super(jAz); C21090sc.LIZ(jAz); this.LIZ = jAz; } private final String LIZ(JSONObject jSONObject) { return "javascript:if(window." + this.LJFF + " && window." + this.LJFF + "._handleMessageFromApp){ window." + this.LJFF + " && window." + this.LJFF + "._handleMessageFromApp(" + jSONObject + ')' + "} else if(window." + this.LJI + " && window." + this.LJI + "._handleMessageFromApp){ window." + this.LJI + " && window." + this.LJI + "._handleMessageFromApp(" + jSONObject + ')' + "}"; } private final void LIZ(String str, String str2) { try { LIZ(LIZIZ(str, str2).toString(), new JCH()); } catch (Exception e) { e.printStackTrace(); JCH jch = new JCH(); jch.LIZIZ(JCJ.H5.getType()); jch.LIZ(C49432Jb3.LIZIZ); jch.LIZ(0); C49432Jb3 jb3 = JB3.LIZJ; if (jb3 != null) { jb3.LIZ(jch.LIZ()); } } } private final JSONObject LIZIZ(String str, String str2) { if (str2 == null) { m.LIZ(); } JSONObject jSONObject = new JSONObject(str2); if (jSONObject.opt("func") == null) { String optString = jSONObject.optString("namespace", ""); m.LIZ((Object) optString, ""); if (optString.length() != 0) { str = jSONObject.optString("namespace", "") + ClassUtils.PACKAGE_SEPARATOR_CHAR + str; } jSONObject.put("func", str); } return jSONObject; } @Override // X.JCB public final String LIZ(JC3 jc3, C48704JAn jAn) { C21090sc.LIZ(jc3, jAn); try { JSONObject jSONObject = new JSONObject(); jSONObject.put("__callback_id", jc3.LIZ); jSONObject.put("__params", jAn.LIZ()); jSONObject.put("__msg_type", "callback"); return LIZ(jSONObject); } catch (Throwable th) { C23790wy.m6exceptionOrNullimpl(C23790wy.m3constructorimpl(C23800wz.LIZ(th))); return ""; } } @Override // X.JCB public final void LIZ(String str, JSONObject jSONObject) { Object obj; C21090sc.LIZ(str); try { JSONObject jSONObject2 = new JSONObject(); jSONObject2.put("code", 1); if (jSONObject != null) { jSONObject2.put("data", jSONObject); } JSONObject jSONObject3 = new JSONObject(); jSONObject3.put("__msg_type", C59681Nby.LJIIIIZZ); jSONObject3.put("__event_id", str); jSONObject3.put("__callback_id", str); jSONObject3.put("__params", jSONObject2); LIZ(LIZ(jSONObject3), (ValueCallback<String>) null); obj = C23790wy.m3constructorimpl(C23860x5.LIZ); } catch (Throwable th) { obj = C23790wy.m3constructorimpl(C23800wz.LIZ(th)); } Throwable r3 = C23790wy.m6exceptionOrNullimpl(obj); if (r3 != null) { C21090sc.LIZ(this.LJ, "parse event failed,reason=" + r3.getMessage()); } } @Override // X.JCB public final String LIZIZ() { return this.LJII; } @Override // X.JCB public final JC3 LIZLLL(String str) { String str2; C21090sc.LIZ(str); JSONObject jSONObject = new JSONObject(str); JC3 jc3 = new JC3(this.LIZ); String optString = jSONObject.optString("__callback_id"); m.LIZ((Object) optString, ""); jc3.LIZ(optString); String optString2 = jSONObject.optString("func"); m.LIZ((Object) optString2, ""); jc3.LIZIZ(optString2); JCK jck = this.LIZIZ; if (jck == null || (str2 = jck.LIZ()) == null) { str2 = ""; } jc3.LIZJ(str2); String optString3 = jSONObject.optString("__msg_type"); m.LIZ((Object) optString3, ""); jc3.LIZLLL(optString3); jc3.LJIIIIZZ = jSONObject.optLong("__timestamp", System.currentTimeMillis()); jc3.LJ = jSONObject.opt("params"); String optString4 = jSONObject.optString("JSSDK"); m.LIZ((Object) optString4, ""); jc3.LJ(optString4); String optString5 = jSONObject.optString("namespace", "DEFAULT"); m.LIZ((Object) optString5, ""); jc3.LJFF(optString5); String optString6 = jSONObject.optString("__iframe_url"); m.LIZ((Object) optString6, ""); jc3.LJI(optString6); jc3.LIZ(JCM.Web); jc3.LJII(str); return jc3; } @JavascriptInterface public final String _invokeMethod(String str) { LIZ((String) null, str); return null; } @JavascriptInterface public final String call(String str, String str2) { LIZ(str, str2); return null; } }