QQ浏览器 v12.2.3.7053版本的 MD5 值为:8285ab3059e5c8b521a264dfbc5c3685
以下内容为反编译后的 APX5WebView.java 源代码,内容仅作参考
package com.tencent.midas.jsbridge;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Build;
import android.widget.Toast;
import com.tencent.midas.api.APMidasPayAPI;
import com.tencent.midas.comm.APLog;
import com.tencent.midas.download.APMidasPluginDownloadUtils;
import com.tencent.qqlive.module.videoreport.inject.webview.jsinject.JsInjector;
import com.tencent.smtt.export.external.interfaces.JsPromptResult;
import com.tencent.smtt.export.external.interfaces.JsResult;
import com.tencent.smtt.sdk.WebChromeClient;
import com.tencent.smtt.sdk.WebSettings;
import com.tencent.smtt.sdk.WebView;
import com.tencent.smtt.sdk.WebViewClient;
import java.lang.reflect.Method;
public class APX5WebView {
private static final String TAG = "APX5WebView";
private IAPX5WebViewCallback callback;
private Activity mContext;
private WebView mWebview;
private WebChromeClient mChromeClient = new WebChromeClient() {
@Override
public boolean onJsAlert(WebView webView, String str, String str2, JsResult jsResult) {
String str3;
APLog.e("inner onJsAlert message", str2);
APLog.e(APX5WebView.TAG, " url = " + str);
APLog.e(APX5WebView.TAG, " message = " + str2);
if (APMidasPluginDownloadUtils.handlePureH5UpdateJsAlertLogic(APX5WebView.this.mContext, str2)) {
str3 = "onJsAlert is pure h5 update! Cancel alert!";
} else {
APLog.d(APX5WebView.TAG, "onJsAlert not pure h5 update!");
if (!APWebProtocol.hookH5Method(APX5WebView.this.mContext, APX5WebView.this.mWebview, str, str2, jsResult, APX5WebView.this.callback)) {
if (APMidasPayAPI.h5PayHookX5(APX5WebView.this.mContext, APX5WebView.this.mWebview, str, str2, jsResult) != 0) {
return super.onJsAlert(webView, str, str2, jsResult);
}
APX5WebView.this.callback.WebChromeClientJsAlert(webView, str, str2, jsResult);
jsResult.cancel();
return true;
}
str3 = "hookH5Method is processed";
}
APLog.d(APX5WebView.TAG, str3);
jsResult.cancel();
return true;
}
@Override
public boolean onJsPrompt(WebView webView, String str, String str2, String str3, JsPromptResult jsPromptResult) {
return APX5WebView.this.callback.WebChromeClientJsPrompt(webView, str, str2, str3, jsPromptResult);
}
@Override
public void onProgressChanged(WebView webView, int i) {
JsInjector.getInstance().onProgressChanged(webView, i);
super.onProgressChanged(webView, i);
}
};
private WebViewClient mWebViewClient = new WebViewClient() {
@Override
public void onPageFinished(WebView webView, String str) {
super.onPageFinished(webView, str);
APLog.d(APX5WebView.TAG, "onPageFinished!");
APLog.i("APWebView url == ", str);
APX5WebView.this.mWebview.setVisibility(0);
APMidasPayAPI.InnerH5PayInitX5(APX5WebView.this.mContext, APX5WebView.this.mWebview);
APX5WebView.this.callback.WebViewClientPageFinished(webView, str);
}
@Override
public void onPageStarted(WebView webView, String str, Bitmap bitmap) {
JsInjector.getInstance().onPageStarted(webView);
super.onPageStarted(webView, str, bitmap);
APLog.d(APX5WebView.TAG, "onPageStarted!");
APX5WebView.this.callback.WebViewClientPageStarted(webView, str, bitmap);
}
@Override
public void onReceivedError(WebView webView, int i, String str, String str2) {
super.onReceivedError(webView, i, str, str2);
APLog.d(APX5WebView.TAG, "onReceivedError!");
APX5WebView.this.callback.WebViewClientReceivedError(webView, i, str, str2);
}
@Override
public boolean shouldOverrideUrlLoading(WebView webView, String str) {
APLog.d(APX5WebView.TAG, "shouldOverrideUrlLoading url = " + str);
if (!str.startsWith("http://unipay.sdk.android/?") && !str.startsWith("wsj://") && !str.startsWith("mqqapi://") && !str.startsWith("weixin://") && !str.startsWith("sms://")) {
webView.loadUrl(str);
APLog.d(APX5WebView.TAG, "shouldOverrideUrlLoading loadUrl = ");
}
if (!str.startsWith("mqqapi://") && !str.startsWith("weixin://") && !str.startsWith("sms://")) {
return true;
}
Intent intent = new Intent("android.intent.action.VIEW", Uri.parse(str));
if (intent.resolveActivity(APX5WebView.this.mContext.getPackageManager()) != null) {
webView.getContext().startActivity(intent);
return true;
}
Toast.makeText(APX5WebView.this.mContext, "抱歉,你未安装相应客户端", 1).show();
APLog.w(APX5WebView.TAG, "shouldOverrideUrlLoading() intent.resolveActivity == Null ");
return true;
}
};
public APX5WebView(Activity activity, WebView webView, IAPX5WebViewCallback iAPX5WebViewCallback) {
this.mWebview = null;
this.mContext = null;
this.callback = null;
this.mContext = activity;
this.mWebview = webView;
this.callback = iAPX5WebViewCallback;
InitWebView();
}
private void InitWebView() {
WebSettings settings = this.mWebview.getSettings();
settings.setJavaScriptEnabled(true);
if (Build.VERSION.SDK_INT >= 19) {
APMidasPayAPI.env.equals(APMidasPayAPI.ENV_TEST);
}
settings.setDomStorageEnabled(true);
settings.setAppCachePath(this.mContext.getApplicationContext().getDir("cache", 0).getPath());
settings.setAllowFileAccess(true);
settings.setAppCacheEnabled(true);
settings.setCacheMode(-1);
this.mWebview.setScrollBarStyle(0);
this.mWebview.setWebChromeClient(this.mChromeClient);
this.mWebview.setWebViewClient(this.mWebViewClient);
removeInterface();
}
private void removeInterface() {
try {
Method method = this.mWebview.getClass().getMethod("removeJavascriptInterface", String.class);
if (method != null) {
method.invoke(this.mWebview, "searchBoxJavaBridge_");
method.invoke(this.mWebview, "accessibility");
method.invoke(this.mWebview, "accessibilityTraversal");
}
} catch (Exception e) {
APLog.i("removeJavascriptInterface", e.toString());
}
}
public WebView getWebView() {
return this.mWebview;
}
public void loadUrl(String str) {
this.mWebview.loadUrl(str);
}
}