QQ浏览器 v12.2.3.7053版本的 MD5 值为:8285ab3059e5c8b521a264dfbc5c3685
以下内容为反编译后的 APWebView.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.webkit.JsPromptResult;
import android.webkit.JsResult;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
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 java.lang.reflect.Method;
public class APWebView {
private static final String TAG = "APWebView";
private IAPWebViewCallback 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(APWebView.TAG, " url = " + str);
APLog.e(APWebView.TAG, " message = " + str2);
if (APMidasPluginDownloadUtils.handlePureH5UpdateJsAlertLogic(APWebView.this.mContext, str2)) {
str3 = "onJsAlert is pure h5 update! Cancel alert!";
} else {
APLog.d(APWebView.TAG, "onJsAlert not pure h5 update!");
if (!APWebProtocol.hookH5Method(APWebView.this.mContext, APWebView.this.mWebview, str, str2, jsResult, APWebView.this.callback)) {
if (APMidasPayAPI.h5PayHook(APWebView.this.mContext, APWebView.this.mWebview, str, str2, jsResult) != 0) {
return super.onJsAlert(webView, str, str2, jsResult);
}
APWebView.this.callback.WebChromeClientJsAlert(webView, str, str2, jsResult);
jsResult.cancel();
return true;
}
str3 = "hookH5Method is processed";
}
APLog.d(APWebView.TAG, str3);
jsResult.cancel();
return true;
}
@Override
public boolean onJsPrompt(WebView webView, String str, String str2, String str3, JsPromptResult jsPromptResult) {
return APWebView.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(APWebView.TAG, "onPageFinished!");
APLog.i("APWebView url == ", str);
APWebView.this.mWebview.setVisibility(0);
APMidasPayAPI.InnerH5PayInit(APWebView.this.mContext, APWebView.this.mWebview);
APWebView.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(APWebView.TAG, "onPageStarted!");
APWebView.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(APWebView.TAG, "onReceivedError!");
APWebView.this.callback.WebViewClientReceivedError(webView, i, str, str2);
}
@Override
public boolean shouldOverrideUrlLoading(WebView webView, String str) {
APLog.d(APWebView.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(APWebView.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(APWebView.this.mContext.getPackageManager()) != null) {
webView.getContext().startActivity(intent);
return true;
}
Toast.makeText(APWebView.this.mContext, "抱歉,你未安装相应客户端", 1).show();
APLog.w(APWebView.TAG, "shouldOverrideUrlLoading() intent.resolveActivity == Null ");
return true;
}
};
public APWebView(Activity activity, WebView webView, IAPWebViewCallback iAPWebViewCallback) {
this.mWebview = null;
this.mContext = null;
this.callback = null;
this.mContext = activity;
this.mWebview = webView;
this.callback = iAPWebViewCallback;
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);
}
}