package X; import android.os.Build; import android.os.Handler; import android.os.SystemClock; import android.text.TextUtils; import android.webkit.ValueCallback; import android.webkit.WebView; import com.bytedance.covode.number.Covode; import java.lang.ref.WeakReference; import java.util.List; import org.json.JSONException; import org.json.JSONObject; public final class P1K implements ValueCallback<String> { public static final String LIZ = "javascript:var result = {};var timing = window.performance && window.performance.timing;result.dom_ready = timing.domComplete - timing.domInteractive;"; public static long LJIIL; public boolean LIZIZ; public P1N LIZJ = new P1N(); public WeakReference<WebView> LIZLLL; public WebView LJ; public AbstractC69422oN LJFF; public String LJI; public int LJII; public int LJIIIIZZ; public final Handler LJIIIZ = new Handler(); public long LJIIJ; public final Runnable LJIIJJI = new P1O(this); public List<String> LJIILIIL; public boolean LJIILJJIL; public String LJIILL; public long LJIILLIIL; static { Covode.recordClassIndex(47332); } public P1K(WebView webView, List<String> list, AbstractC69422oN r4, AbstractC63746P1b p1b) { this.LIZLLL = new WeakReference<>(webView); this.LJ = webView; this.LJIILIIL = list; this.LJFF = r4; this.LJIILJJIL = p1b != null && p1b.LJI(); this.LJI = p1b != null ? p1b.LJFF() : ""; } private boolean LIZ(P1N p1n) { if (!(this.LJIILIIL == null || p1n == null || TextUtils.isEmpty(p1n.LJII))) { for (String str : this.LJIILIIL) { if (p1n.LJII.contains(str)) { return true; } } } return false; } public static boolean LIZ(String str) { if (LIZIZ(str)) { return false; } if (!TextUtils.equals("about:blank", str)) { return str != null && str.length() > 9 && str.substring(0, 10).equalsIgnoreCase("javascript"); } return true; } public static boolean LIZIZ(String str) { if (TextUtils.isEmpty(str)) { return false; } return str.startsWith("http") || str.startsWith("https"); } public final JSONObject LIZ() { P1N p1n = this.LIZJ; if (p1n == null) { return null; } JSONObject jSONObject = new JSONObject(); try { jSONObject.put("isBlank", Boolean.toString(p1n.LIZ)); jSONObject.put("pageFinish", Boolean.toString(p1n.LJIILLIIL)); jSONObject.put("mainFrameError", Boolean.toString(p1n.LJIILL)); jSONObject.put("webViewType", p1n.LJI); jSONObject.put("isOfflineCache", Boolean.toString(p1n.LJIJJLI > 0)); jSONObject.put("errUrl", p1n.LJJIII); jSONObject.put("errType", Integer.toString(p1n.LJJI)); jSONObject.put("errCode", Integer.toString(p1n.LJJIFFI.intValue())); jSONObject.put("errMsg", p1n.LJJII); jSONObject.put("useCache", Boolean.toString(LIZ(p1n))); } catch (Exception e) { e.printStackTrace(); } return jSONObject; } public final void LIZ(String str, ValueCallback<String> valueCallback) { if (this.LJ != null) { int i2 = Build.VERSION.SDK_INT; if (this.LJIILJJIL) { this.LJ.evaluateJavascript("ttwebview:/*" + str + "*/;", valueCallback); } } } public final void LIZ(boolean z, boolean z2) { if (!this.LIZIZ) { this.LIZIZ = true; if (!this.LIZJ.LJIILL) { if (z || !z2) { this.LIZJ.LJIILLIIL = true; } } } } public final JSONObject LIZIZ() { P1N p1n = this.LIZJ; if (p1n == null) { return null; } JSONObject jSONObject = new JSONObject(); try { jSONObject.put("ttweb_isBlank", p1n.LIZ); jSONObject.put("ttweb_pageFinish", p1n.LJIILLIIL); jSONObject.put("ttweb_originalUrl", p1n.LJII); jSONObject.put("ttweb_pageUrl", p1n.LJIIIIZZ); jSONObject.put("ttweb_webviewType", p1n.LJI); jSONObject.put("ttweb_mainFrameError", p1n.LJIILL); jSONObject.put("ttweb_errUrl", p1n.LJJIII); jSONObject.put("ttweb_errType", p1n.LJJI); jSONObject.put("ttweb_errCode", p1n.LJJIFFI); jSONObject.put("ttweb_errMsg", p1n.LJJII); jSONObject.put("ttweb_useCache", LIZ(p1n)); if (LJIIL > 0) { jSONObject.put("ttweb_initToLoadUrl", p1n.LJIIJ - LJIIL); jSONObject.put("ttweb_initToPageStart", p1n.LJIIJJI - LJIIL); jSONObject.put("ttweb_initToPageFinish", p1n.LJIIL - LJIIL); } jSONObject.put("ttweb_detectDuration", p1n.LIZIZ); jSONObject.put("ttweb_attachedWindowToLoadUrl", p1n.LJIIJ - p1n.LJ); jSONObject.put("ttweb_loadUrlToAttachedWindow", p1n.LJ - p1n.LJIIJ); jSONObject.put("ttweb_loadUrlToPageFinish", p1n.LJIIL - p1n.LJIIJ); jSONObject.put("ttweb_loadUrlToPageStart", p1n.LJIIJJI - p1n.LJIIJ); jSONObject.put("ttweb_attachedWindowToDetachWindow", p1n.LJFF - p1n.LJ); jSONObject.put("ttweb_pageStartToPageFinish", p1n.LJIIL - p1n.LJIIJJI); jSONObject.put("ttweb_loadUrlToDetachWindow", p1n.LJFF - p1n.LJIIJ); jSONObject.put("ttweb_loadResCount", p1n.LJIIZILJ); jSONObject.put("ttweb_requestResCount", p1n.LJIJ); jSONObject.put("ttweb_loadResErrorCount", p1n.LJIJI); jSONObject.put("ttweb_ttNetResCount", p1n.LJIJJ); jSONObject.put("ttweb_offlineResCount", p1n.LJIJJLI); jSONObject.put("ttweb_TTWebViewData", this.LJIILL); } catch (JSONException e) { e.printStackTrace(); } return jSONObject; } public final JSONObject LIZJ() { P1N p1n = this.LIZJ; if (p1n == null) { return null; } JSONObject jSONObject = new JSONObject(); try { jSONObject.put("detectDuration", p1n.LIZIZ); jSONObject.put("attachedWindowToLoadUrl", p1n.LJIIJ - p1n.LJ); jSONObject.put("loadUrlToAttachedWindow", p1n.LJ - p1n.LJIIJ); jSONObject.put("loadUrlToPageFinish", p1n.LJIIL - p1n.LJIIJ); jSONObject.put("loadUrlToPageStart", p1n.LJIIJJI - p1n.LJIIJ); jSONObject.put("attachedWindowToDetachWindow", p1n.LJFF - p1n.LJ); jSONObject.put("pageStartToPageFinish", p1n.LJIIL - p1n.LJIIJJI); jSONObject.put("loadUrlToDetachWindow", p1n.LJFF - p1n.LJIIJ); jSONObject.put("loadResCount", p1n.LJIIZILJ); jSONObject.put("requestResCount", p1n.LJIJ); jSONObject.put("loadResErrorCount", p1n.LJIJI); jSONObject.put("ttNetResCount", p1n.LJIJJ); jSONObject.put("offlineResCount", p1n.LJIJJLI); } catch (JSONException e) { e.printStackTrace(); } return jSONObject; } public final void LIZLLL() { if (this.LIZJ.LJJI != 0) { if (TextUtils.equals(this.LIZJ.LJJIII, this.LIZJ.LJIIIIZZ)) { this.LIZJ.LJIILL = true; LIZ(true, false); return; } this.LIZJ.LJIJI++; } } /* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */ @Override // android.webkit.ValueCallback public final /* synthetic */ void onReceiveValue(String str) { String str2 = str; if (!TextUtils.isEmpty(str2) && !TextUtils.equals("null", str2) && !TextUtils.equals("{}", str2)) { try { JSONObject jSONObject = new JSONObject(str2); if (jSONObject.has("detailGetWebViewData")) { this.LJIILL = jSONObject.getString("detailGetWebViewData"); this.LJIILLIIL = SystemClock.uptimeMillis(); } jSONObject.has("detailClearWebViewData"); jSONObject.has("detailEnableDomData"); } catch (Exception unused) { } } } }