AI Chat v1.1.8版本的 MD5 值为:1bcdce875f86738c8cfbf1e5f4064353
以下内容为反编译后的 z.java 源代码,内容仅作参考
package com.bytedance.sdk.component.a;
import android.annotation.SuppressLint;
import android.content.Context;
import android.os.Build;
import android.os.Looper;
import android.text.TextUtils;
import android.util.Base64;
import android.webkit.JavascriptInterface;
import android.webkit.WebView;
public class z extends a {
public static final boolean j = true;
public String h;
public WebView i;
@Override
public Context a(j jVar) {
Context context = jVar.e;
if (context != null) {
return context;
}
WebView webView = jVar.a;
if (webView != null) {
return webView.getContext();
}
throw new IllegalStateException("WebView cannot be null!");
}
@Override
@SuppressLint({"JavascriptInterface", "AddJavascriptInterface"})
public void b(j jVar) {
this.i = jVar.a;
this.h = jVar.c;
if (Build.VERSION.SDK_INT < 17 || jVar.n) {
return;
}
c();
}
@SuppressLint({"AddJavascriptInterface"})
public void c() {
if (!j && this.i == null) {
throw new AssertionError();
}
this.i.addJavascriptInterface(this, this.h);
}
public void d() {
this.i.removeJavascriptInterface(this.h);
}
@Override
@JavascriptInterface
public void invokeMethod(String str) {
super.invokeMethod(str);
}
@Override
public String a() {
return this.i.getUrl();
}
@Override
public void b() {
super.b();
d();
}
@Override
public void a(String str, q qVar) {
if (qVar != null && !TextUtils.isEmpty(qVar.h)) {
String str2 = qVar.h;
a(str, String.format("javascript:(function(){ const iframe = document.querySelector(atob('%s')); if (iframe && iframe.contentWindow) { iframe.contentWindow.postMessage(%s, atob('%s')); }})()", Base64.encodeToString(String.format("iframe[src=\"%s\"", str2).getBytes(), 2), str, Base64.encodeToString(str2.getBytes(), 2)));
return;
}
super.a(str, qVar);
}
@Override
public void a(String str) {
a(str, "javascript:" + this.h + "._handleMessageFromToutiao(" + str + ")");
}
private void a(String str, final String str2) {
if (this.f || TextUtils.isEmpty(str2)) {
return;
}
Runnable runnable = new Runnable() {
@Override
public void run() {
if (z.this.f) {
return;
}
try {
if (Build.VERSION.SDK_INT >= 19) {
i.a("Invoking Jsb using evaluateJavascript: " + str2);
z.this.i.evaluateJavascript(str2, null);
} else {
i.a("Invoking Jsb using loadUrl: " + str2);
z.this.i.loadUrl(str2);
}
} catch (Throwable th) {
th.printStackTrace();
}
}
};
if (Looper.myLooper() != Looper.getMainLooper()) {
i.a("Received call on sub-thread, posting to main thread: " + str2);
this.f1051d.post(runnable);
return;
}
runnable.run();
}
}