package com.tencent.midas.jsbridge; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.graphics.Bitmap; import android.net.Uri; 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.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 com.tencent.xweb.xwalk.plugin.XWalkPlugin; import java.lang.reflect.Method; import k30.a; public class APX5WebView { private static final String TAG = "APX5WebView"; private IAPX5WebViewCallback callback = null; private WebChromeClient mChromeClient = new WebChromeClient() { /* class com.tencent.midas.jsbridge.APX5WebView.AnonymousClass1 */ public boolean onJsAlert(WebView webView, String str, String str2, JsResult jsResult) { 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)) { APLog.d(APX5WebView.TAG, "onJsAlert is pure h5 update! Cancel alert!"); jsResult.cancel(); return true; } APLog.d(APX5WebView.TAG, "onJsAlert not pure h5 update!"); if (APWebProtocol.hookH5Method(APX5WebView.this.mContext, APX5WebView.this.mWebview, str, str2, jsResult, APX5WebView.this.callback)) { APLog.d(APX5WebView.TAG, "hookH5Method is processed"); jsResult.cancel(); return true; } else if (APMidasPayAPI.h5PayHookX5(APX5WebView.this.mContext, APX5WebView.this.mWebview, str, str2, jsResult) != 0) { return APX5WebView.super.onJsAlert(webView, str, str2, jsResult); } else { APX5WebView.this.callback.WebChromeClientJsAlert(webView, str, str2, jsResult); jsResult.cancel(); return true; } } public boolean onJsPrompt(WebView webView, String str, String str2, String str3, JsPromptResult jsPromptResult) { return APX5WebView.this.callback.WebChromeClientJsPrompt(webView, str, str2, str3, jsPromptResult); } }; private Activity mContext = null; private WebViewClient mWebViewClient = new WebViewClient() { /* class com.tencent.midas.jsbridge.APX5WebView.AnonymousClass2 */ private byte _hellAccFlag_; public void onPageFinished(WebView webView, String str) { APX5WebView.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); } public void onPageStarted(WebView webView, String str, Bitmap bitmap) { APX5WebView.super.onPageStarted(webView, str, bitmap); APLog.d(APX5WebView.TAG, "onPageStarted!"); APX5WebView.this.callback.WebViewClientPageStarted(webView, str, bitmap); } public void onReceivedError(WebView webView, int i15, String str, String str2) { APX5WebView.super.onReceivedError(webView, i15, str, str2); APLog.d(APX5WebView.TAG, "onReceivedError!"); APX5WebView.this.callback.WebViewClientReceivedError(webView, i15, str, str2); } 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) { Context context = webView.getContext(); a aVar = new a(); aVar.c(intent); j30.a.d(context, aVar.b(), "com/tencent/midas/jsbridge/APX5WebView$2", "shouldOverrideUrlLoading", "(Lcom/tencent/smtt/sdk/WebView;Ljava/lang/String;)Z", "Undefined", "startActivity", "(Landroid/content/Intent;)V"); context.startActivity((Intent) aVar.a(0)); j30.a.e(context, "com/tencent/midas/jsbridge/APX5WebView$2", "shouldOverrideUrlLoading", "(Lcom/tencent/smtt/sdk/WebView;Ljava/lang/String;)Z", "Undefined", "startActivity", "(Landroid/content/Intent;)V"); return true; } Toast.makeText(APX5WebView.this.mContext, "抱歉,你未安装相应客户端", 1).show(); APLog.w(APX5WebView.TAG, "shouldOverrideUrlLoading() intent.resolveActivity == Null "); return true; } }; private WebView mWebview = null; public APX5WebView(Activity activity, WebView webView, IAPX5WebViewCallback iAPX5WebViewCallback) { this.mContext = activity; this.mWebview = webView; this.callback = iAPX5WebViewCallback; InitWebView(); } private void InitWebView() { WebSettings settings = this.mWebview.getSettings(); settings.setJavaScriptEnabled(true); APMidasPayAPI.env.equals(APMidasPayAPI.ENV_TEST); settings.setDomStorageEnabled(true); settings.setAppCachePath(this.mContext.getApplicationContext().getDir(XWalkPlugin.PRIVATE_CACHE_DIR_NAME, 0).getPath()); settings.setAllowFileAccess(true); settings.setAppCacheEnabled(true); settings.setCacheMode(-1); try { settings.setSavePassword(false); } catch (Exception unused) { } 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 e15) { APLog.i("removeJavascriptInterface", e15.toString()); } } public WebView getWebView() { return this.mWebview; } public void loadUrl(String str) { this.mWebview.loadUrl(str); } }