正在查看: RummyCircle v11000.89 应用的 RNCWebViewManager.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: RummyCircle v11000.89 应用的 RNCWebViewManager.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.reactnativecommunity.webview;
import android.R;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.Activity;
import android.app.DownloadManager;
import android.graphics.Bitmap;
import android.net.Uri;
import android.net.http.SslError;
import android.os.Build;
import android.os.Environment;
import android.os.Message;
import android.os.SystemClock;
import android.text.TextUtils;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.ConsoleMessage;
import android.webkit.CookieManager;
import android.webkit.DownloadListener;
import android.webkit.GeolocationPermissions;
import android.webkit.HttpAuthHandler;
import android.webkit.JavascriptInterface;
import android.webkit.PermissionRequest;
import android.webkit.RenderProcessGoneDetail;
import android.webkit.SslErrorHandler;
import android.webkit.URLUtil;
import android.webkit.ValueCallback;
import android.webkit.WebChromeClient;
import android.webkit.WebResourceRequest;
import android.webkit.WebResourceResponse;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.FrameLayout;
import androidx.annotation.NonNull;
import androidx.camera.camera2.internal.X0;
import androidx.camera.core.impl.utils.i;
import androidx.webkit.internal.e;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.CatalystInstance;
import com.facebook.react.bridge.LifecycleEventListener;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.ReadableMapKeySetIterator;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.bridge.WritableNativeArray;
import com.facebook.react.bridge.WritableNativeMap;
import com.facebook.react.common.c;
import com.facebook.react.uimanager.I;
import com.facebook.react.uimanager.UIManagerModule;
import com.facebook.react.uimanager.ViewGroupManager;
import com.facebook.react.views.scroll.h;
import com.reactnativecommunity.webview.RNCWebViewModule;
import com.reactnativecommunity.webview.events.g;
import com.truecaller.android.sdk.TruecallerSdkScope;
import in.juspay.hypersdk.core.PaymentConstants;
import java.io.File;
import java.io.FileInputStream;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.atomic.AtomicReference;
import org.apache.commons.lang3.StringUtils;
import org.chromium.support_lib_boundary.WebSettingsBoundaryInterface;
import org.json.JSONException;
import org.json.JSONObject;
@com.facebook.react.module.annotations.a(name = "RNCWebView")
public class RNCWebViewManager extends ViewGroupManager<RNCWebViewWrapper> {
protected static final String BLANK_URL = "about:blank";
public static final int COMMAND_CLEAR_CACHE = 1001;
public static final int COMMAND_CLEAR_FORM_DATA = 1000;
public static final int COMMAND_CLEAR_HISTORY = 1002;
public static final int COMMAND_FOCUS = 8;
public static final int COMMAND_GO_BACK = 1;
public static final int COMMAND_GO_FORWARD = 2;
public static final int COMMAND_INJECT_JAVASCRIPT = 6;
public static final int COMMAND_LOAD_URL = 7;
public static final int COMMAND_POST_MESSAGE = 5;
public static final int COMMAND_RELOAD = 3;
public static final int COMMAND_STOP_LOADING = 4;
protected static final String DEFAULT_DOWNLOADING_MESSAGE = "Downloading";
protected static final String DEFAULT_LACK_PERMISSION_TO_DOWNLOAD_MESSAGE = "Cannot download files as permission was denied. Please provide permission to write to storage, in order to download files.";
protected static final String HTML_ENCODING = "UTF-8";
protected static final String HTML_MIME_TYPE = "text/html";
protected static final String HTTP_METHOD_POST = "POST";
protected static final String JAVASCRIPT_INTERFACE = "ReactNativeWebView";
protected static final String REACT_CLASS = "RNCWebView";
protected static final int SHOULD_OVERRIDE_URL_LOADING_TIMEOUT = 250;
private static final String TAG = "RNCWebViewManager";
private static boolean isUserAgentFetchedOnce = false;
protected boolean mAllowsFullscreenVideo;
protected String mDownloadingMessage;
protected String mLackPermissionToDownloadMessage;
protected String mUserAgent;
protected String mUserAgentWithApplicationName;
protected e mWebChromeClient;
protected com.reactnativecommunity.webview.d mWebViewConfig;
public class a implements com.reactnativecommunity.webview.d {
}
public class b implements DownloadListener {
public final RNCWebView a;
public final I b;
public b(RNCWebView rNCWebView, I i) {
this.a = rNCWebView;
this.b = i;
}
@Override
public final void onDownloadStart(String str, String str2, String str3, String str4, long j) {
this.a.setIgnoreErrFailedForThisURL(str);
RNCWebViewModule module = RNCWebViewManager.getModule(this.b);
try {
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(str));
String guessFileName = URLUtil.guessFileName(str, str3, str4);
String b = i.b("Downloading ", guessFileName);
try {
URL url = new URL(str);
request.addRequestHeader("Cookie", CookieManager.getInstance().getCookie(url.getProtocol() + "://" + url.getHost()));
} catch (MalformedURLException e) {
Log.w(RNCWebViewManager.TAG, "Error getting cookie for DownloadManager", e);
}
request.addRequestHeader("User-Agent", str2);
request.setTitle(guessFileName);
request.setDescription(b);
request.allowScanningByMediaScanner();
request.setNotificationVisibility(1);
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, guessFileName);
module.setDownloadRequest(request);
RNCWebViewManager rNCWebViewManager = RNCWebViewManager.this;
if (module.grantFileDownloaderPermissions(rNCWebViewManager.getDownloadingMessage(), rNCWebViewManager.getLackPermissionToDownloadMessage())) {
module.downloadFile(rNCWebViewManager.getDownloadingMessage());
}
} catch (IllegalArgumentException e2) {
Log.w(RNCWebViewManager.TAG, "Unsupported URI, aborting download", e2);
}
}
}
public class c extends e {
public final Activity n;
public final int o;
public c(ReactContext reactContext, WebView webView, Activity activity, int i) {
super(reactContext, webView);
this.n = activity;
this.o = i;
}
@Override
public final Bitmap getDefaultVideoPoster() {
return Bitmap.createBitmap(50, 50, Bitmap.Config.ARGB_8888);
}
@Override
public final void onHideCustomView() {
if (this.c == null) {
return;
}
ViewGroup viewGroup = (ViewGroup) this.a.getCurrentActivity().findViewById(R.id.content);
View rootView = viewGroup.getRootView();
WebView webView = this.b;
if (rootView != webView.getRootView()) {
webView.getRootView().setVisibility(0);
} else {
webView.setVisibility(0);
}
Activity activity = this.n;
activity.getWindow().clearFlags(TruecallerSdkScope.FOOTER_TYPE_MANUALLY);
viewGroup.removeView(this.c);
this.d.onCustomViewHidden();
this.c = null;
this.d = null;
activity.setRequestedOrientation(this.o);
this.a.removeLifecycleEventListener(this);
}
@Override
public final void onShowCustomView(View view, WebChromeClient.CustomViewCallback customViewCallback) {
if (this.c != null) {
customViewCallback.onCustomViewHidden();
return;
}
this.c = view;
this.d = customViewCallback;
Activity activity = this.n;
activity.setRequestedOrientation(-1);
this.c.setSystemUiVisibility(7942);
activity.getWindow().setFlags(TruecallerSdkScope.FOOTER_TYPE_MANUALLY, TruecallerSdkScope.FOOTER_TYPE_MANUALLY);
this.c.setBackgroundColor(-16777216);
ViewGroup viewGroup = (ViewGroup) this.a.getCurrentActivity().findViewById(R.id.content);
viewGroup.addView(this.c, e.m);
View rootView = viewGroup.getRootView();
WebView webView = this.b;
if (rootView != webView.getRootView()) {
webView.getRootView().setVisibility(8);
} else {
webView.setVisibility(8);
}
this.a.addLifecycleEventListener(this);
}
}
public class d extends e {
@Override
public final Bitmap getDefaultVideoPoster() {
return Bitmap.createBitmap(50, 50, Bitmap.Config.ARGB_8888);
}
}
public RNCWebViewManager() {
this.mWebChromeClient = null;
this.mAllowsFullscreenVideo = false;
this.mUserAgent = null;
this.mUserAgentWithApplicationName = null;
this.mDownloadingMessage = null;
this.mLackPermissionToDownloadMessage = null;
this.mWebViewConfig = new a();
}
public String getDownloadingMessage() {
String str = this.mDownloadingMessage;
return str == null ? DEFAULT_DOWNLOADING_MESSAGE : str;
}
public String getLackPermissionToDownloadMessage() {
return this.mDownloadingMessage == null ? DEFAULT_LACK_PERMISSION_TO_DOWNLOAD_MESSAGE : this.mLackPermissionToDownloadMessage;
}
public static RNCWebViewModule getModule(ReactContext reactContext) {
return reactContext.getNativeModule(RNCWebViewModule.class);
}
private void setUserAgentToSharedPref(String str, I i) {
try {
if (isUserAgentFetchedOnce) {
return;
}
Log.d(TAG, "setUserAgentToSharedPref = " + str);
i.getSharedPreferences("UnityActivity", 0).edit().putString("USER_AGENT", str).apply();
isUserAgentFetchedOnce = true;
Log.d(TAG, "setUserAgentToSharedPref done");
} catch (Exception e2) {
Log.w(TAG, "Exception in setUserAgentToSharedPref", e2);
}
}
public RNCWebView createRNCWebViewInstance(I i) {
RNCWebView rNCWebView = new RNCWebView(i);
rNCWebView.c = false;
rNCWebView.g = false;
rNCWebView.i = false;
rNCWebView.j = false;
ReactContext context = rNCWebView.getContext();
if (context != null) {
rNCWebView.f = context.getCatalystInstance();
}
RNCWebView.a aVar = new RNCWebView.a();
aVar.a = false;
rNCWebView.k = aVar;
return rNCWebView;
}
public Map<String, Integer> getCommandsMap() {
c.a a2 = com.facebook.react.common.c.a();
a2.b("goBack", 1);
a2.b("goForward", 2);
a2.b("reload", 3);
a2.b("stopLoading", 4);
a2.b("postMessage", 5);
a2.b("injectJavaScript", 6);
a2.b("loadUrl", 7);
a2.b("requestFocus", 8);
a2.b("clearFormData", Integer.valueOf(COMMAND_CLEAR_FORM_DATA));
a2.b("clearCache", 1001);
a2.b("clearHistory", Integer.valueOf(COMMAND_CLEAR_HISTORY));
return a2.a();
}
public Map getExportedCustomDirectEventTypeConstants() {
Map exportedCustomDirectEventTypeConstants = super/*com.facebook.react.uimanager.BaseViewManager*/.getExportedCustomDirectEventTypeConstants();
if (exportedCustomDirectEventTypeConstants == null) {
exportedCustomDirectEventTypeConstants = new HashMap();
}
exportedCustomDirectEventTypeConstants.put("topLoadingProgress", com.facebook.react.common.c.e("registrationName", "onLoadingProgress"));
exportedCustomDirectEventTypeConstants.put("topShouldStartLoadWithRequest", com.facebook.react.common.c.e("registrationName", "onShouldStartLoadWithRequest"));
exportedCustomDirectEventTypeConstants.put(com.facebook.react.views.scroll.i.e(com.facebook.react.views.scroll.i.c), com.facebook.react.common.c.e("registrationName", "onScroll"));
exportedCustomDirectEventTypeConstants.put("topHttpError", com.facebook.react.common.c.e("registrationName", "onHttpError"));
exportedCustomDirectEventTypeConstants.put("topRenderProcessGone", com.facebook.react.common.c.e("registrationName", "onRenderProcessGone"));
return exportedCustomDirectEventTypeConstants;
}
public String getName() {
return "RNCWebView";
}
@com.facebook.react.uimanager.annotations.a(name = "allowFileAccess")
public void setAllowFileAccess(RNCWebViewWrapper rNCWebViewWrapper, Boolean bool) {
rNCWebViewWrapper.getWebView().getSettings().setAllowFileAccess(bool != null && bool.booleanValue());
}
@com.facebook.react.uimanager.annotations.a(name = "allowFileAccessFromFileURLs")
public void setAllowFileAccessFromFileURLs(RNCWebViewWrapper rNCWebViewWrapper, boolean z) {
rNCWebViewWrapper.getWebView().getSettings().setAllowFileAccessFromFileURLs(z);
}
@com.facebook.react.uimanager.annotations.a(name = "allowUniversalAccessFromFileURLs")
public void setAllowUniversalAccessFromFileURLs(RNCWebViewWrapper rNCWebViewWrapper, boolean z) {
rNCWebViewWrapper.getWebView().getSettings().setAllowUniversalAccessFromFileURLs(z);
}
@com.facebook.react.uimanager.annotations.a(name = "allowsFullscreenVideo")
public void setAllowsFullscreenVideo(RNCWebViewWrapper rNCWebViewWrapper, Boolean bool) {
this.mAllowsFullscreenVideo = bool != null && bool.booleanValue();
setupWebChromeClient((ReactContext) rNCWebViewWrapper.getWebView().getContext(), rNCWebViewWrapper.getWebView());
}
@com.facebook.react.uimanager.annotations.a(name = "appKey")
public void setAppKey(RNCWebViewWrapper rNCWebViewWrapper, String str) {
rNCWebViewWrapper.getWebView().getRNCWebViewClient().setAppKey(str);
}
@com.facebook.react.uimanager.annotations.a(name = "applicationNameForUserAgent")
public void setApplicationNameForUserAgent(RNCWebViewWrapper rNCWebViewWrapper, String str) {
if (str != null) {
this.mUserAgentWithApplicationName = androidx.camera.core.impl.utils.f.d(WebSettings.getDefaultUserAgent(rNCWebViewWrapper.getWebView().getContext()), StringUtils.SPACE, str);
} else {
this.mUserAgentWithApplicationName = null;
}
setUserAgentString(rNCWebViewWrapper);
}
@com.facebook.react.uimanager.annotations.a(name = "basicAuthCredential")
public void setBasicAuthCredential(RNCWebViewWrapper rNCWebViewWrapper, ReadableMap readableMap) {
com.reactnativecommunity.webview.a aVar;
if (readableMap != null && readableMap.hasKey("username") && readableMap.hasKey("password")) {
String string = readableMap.getString("username");
String string2 = readableMap.getString("password");
aVar = new com.reactnativecommunity.webview.a();
aVar.a = string;
aVar.b = string2;
} else {
aVar = null;
}
rNCWebViewWrapper.getWebView().setBasicAuthCredential(aVar);
}
@com.facebook.react.uimanager.annotations.a(name = "setBuiltInZoomControls")
public void setBuiltInZoomControls(RNCWebViewWrapper rNCWebViewWrapper, boolean z) {
rNCWebViewWrapper.getWebView().getSettings().setBuiltInZoomControls(z);
}
@com.facebook.react.uimanager.annotations.a(name = "cacheEnabled")
public void setCacheEnabled(RNCWebViewWrapper rNCWebViewWrapper, boolean z) {
RNCWebView webView = rNCWebViewWrapper.getWebView();
if (!z) {
webView.getSettings().setCacheMode(2);
} else if (webView.getContext() != null) {
webView.getSettings().setCacheMode(-1);
}
}
@com.facebook.react.uimanager.annotations.a(name = "cacheMode")
public void setCacheMode(RNCWebViewWrapper rNCWebViewWrapper, String str) {
char c2;
switch (str.hashCode()) {
case -2059164003:
if (str.equals("LOAD_NO_CACHE")) {
c2 = 2;
break;
}
c2 = 65535;
break;
case -1215135800:
if (str.equals("LOAD_DEFAULT")) {
c2 = 3;
break;
}
c2 = 65535;
break;
case -873877826:
if (str.equals("LOAD_CACHE_ELSE_NETWORK")) {
c2 = 1;
break;
}
c2 = 65535;
break;
case 1548620642:
if (str.equals("LOAD_CACHE_ONLY")) {
c2 = 0;
break;
}
c2 = 65535;
break;
default:
c2 = 65535;
break;
}
rNCWebViewWrapper.getWebView().getSettings().setCacheMode((c2 != 0 ? c2 != 1 ? c2 != 2 ? -1 : 2 : 1 : 3).intValue());
}
@com.facebook.react.uimanager.annotations.a(name = "cachedFolderPaths")
public void setCachedFolderPaths(RNCWebViewWrapper rNCWebViewWrapper, ReadableArray readableArray) {
rNCWebViewWrapper.getWebView().getRNCWebViewClient().setCachedFolderPaths(readableArray);
}
@com.facebook.react.uimanager.annotations.a(name = "setDisplayZoomControls")
public void setDisplayZoomControls(RNCWebViewWrapper rNCWebViewWrapper, boolean z) {
rNCWebViewWrapper.getWebView().getSettings().setDisplayZoomControls(z);
}
@com.facebook.react.uimanager.annotations.a(name = "domStorageEnabled")
public void setDomStorageEnabled(RNCWebViewWrapper rNCWebViewWrapper, boolean z) {
rNCWebViewWrapper.getWebView().getSettings().setDomStorageEnabled(z);
}
@com.facebook.react.uimanager.annotations.a(name = "downloadingMessage")
public void setDownloadingMessage(WebView webView, String str) {
this.mDownloadingMessage = str;
}
@com.facebook.react.uimanager.annotations.a(name = "feedFromCache")
public void setFeedFromCache(RNCWebViewWrapper rNCWebViewWrapper, Boolean bool) {
rNCWebViewWrapper.getWebView().getRNCWebViewClient().setFeedFromCache(bool);
}
@com.facebook.react.uimanager.annotations.a(name = "feedHtmlFor")
public void setFeedHtmlFor(RNCWebViewWrapper rNCWebViewWrapper, String str) {
rNCWebViewWrapper.getWebView().getRNCWebViewClient().setFeedHtmlFor(str);
}
@com.facebook.react.uimanager.annotations.a(name = "forceDarkOn")
public void setForceDarkOn(RNCWebViewWrapper rNCWebViewWrapper, boolean z) {
if (Build.VERSION.SDK_INT > 28) {
if (androidx.webkit.a.a("FORCE_DARK")) {
int i = z ? 2 : 0;
WebSettings settings = rNCWebViewWrapper.getWebView().getSettings();
if (!androidx.webkit.internal.d.d.i()) {
throw new UnsupportedOperationException("This method is not supported by the current version of the framework and the current WebView APK");
}
((WebSettingsBoundaryInterface) org.chromium.support_lib_boundary.util.a.a(WebSettingsBoundaryInterface.class, e.a.a.a.convertSettings(settings))).setForceDark(i);
}
if (z && androidx.webkit.a.a("FORCE_DARK_STRATEGY")) {
WebSettings settings2 = rNCWebViewWrapper.getWebView().getSettings();
if (!androidx.webkit.internal.d.e.i()) {
throw new UnsupportedOperationException("This method is not supported by the current version of the framework and the current WebView APK");
}
((WebSettingsBoundaryInterface) org.chromium.support_lib_boundary.util.a.a(WebSettingsBoundaryInterface.class, e.a.a.a.convertSettings(settings2))).setForceDarkBehavior(2);
}
}
}
@com.facebook.react.uimanager.annotations.a(name = "geolocationEnabled")
public void setGeolocationEnabled(RNCWebViewWrapper rNCWebViewWrapper, Boolean bool) {
rNCWebViewWrapper.getWebView().getSettings().setGeolocationEnabled(bool != null && bool.booleanValue());
}
@com.facebook.react.uimanager.annotations.a(name = "androidHardwareAccelerationDisabled")
public void setHardwareAccelerationDisabled(RNCWebViewWrapper rNCWebViewWrapper, boolean z) {
if (z) {
rNCWebViewWrapper.getWebView().setLayerType(1, null);
}
}
@com.facebook.react.uimanager.annotations.a(name = "incognito")
public void setIncognito(RNCWebViewWrapper rNCWebViewWrapper, boolean z) {
RNCWebView webView = rNCWebViewWrapper.getWebView();
if (z) {
CookieManager.getInstance().removeAllCookies(null);
webView.getSettings().setCacheMode(2);
webView.clearHistory();
webView.clearCache(true);
webView.clearFormData();
webView.getSettings().setSavePassword(false);
webView.getSettings().setSaveFormData(false);
}
}
@com.facebook.react.uimanager.annotations.a(name = "injectedJavaScript")
public void setInjectedJavaScript(RNCWebViewWrapper rNCWebViewWrapper, String str) {
rNCWebViewWrapper.getWebView().setInjectedJavaScript(str);
}
@com.facebook.react.uimanager.annotations.a(name = "injectedJavaScriptBeforeContentLoaded")
public void setInjectedJavaScriptBeforeContentLoaded(RNCWebViewWrapper rNCWebViewWrapper, String str) {
rNCWebViewWrapper.getWebView().setInjectedJavaScriptBeforeContentLoaded(str);
}
@com.facebook.react.uimanager.annotations.a(name = "injectedJavaScriptBeforeContentLoadedForMainFrameOnly")
public void setInjectedJavaScriptBeforeContentLoadedForMainFrameOnly(RNCWebViewWrapper rNCWebViewWrapper, boolean z) {
rNCWebViewWrapper.getWebView().setInjectedJavaScriptBeforeContentLoadedForMainFrameOnly(z);
}
@com.facebook.react.uimanager.annotations.a(name = "injectedJavaScriptForMainFrameOnly")
public void setInjectedJavaScriptForMainFrameOnly(RNCWebViewWrapper rNCWebViewWrapper, boolean z) {
rNCWebViewWrapper.getWebView().setInjectedJavaScriptForMainFrameOnly(z);
}
@com.facebook.react.uimanager.annotations.a(name = "javaScriptCanOpenWindowsAutomatically")
public void setJavaScriptCanOpenWindowsAutomatically(RNCWebViewWrapper rNCWebViewWrapper, boolean z) {
rNCWebViewWrapper.getWebView().getSettings().setJavaScriptCanOpenWindowsAutomatically(z);
}
@com.facebook.react.uimanager.annotations.a(name = "javaScriptEnabled")
public void setJavaScriptEnabled(RNCWebViewWrapper rNCWebViewWrapper, boolean z) {
rNCWebViewWrapper.getWebView().getSettings().setJavaScriptEnabled(z);
}
@com.facebook.react.uimanager.annotations.a(name = "lackPermissionToDownloadMessage")
public void setLackPermissionToDownlaodMessage(WebView webView, String str) {
this.mLackPermissionToDownloadMessage = str;
}
@com.facebook.react.uimanager.annotations.a(name = "androidLayerType")
public void setLayerType(RNCWebViewWrapper rNCWebViewWrapper, String str) {
str.getClass();
rNCWebViewWrapper.getWebView().setLayerType(!str.equals("hardware") ? !str.equals("software") ? 0 : 1 : 2, null);
}
@com.facebook.react.uimanager.annotations.a(name = "mediaPlaybackRequiresUserAction")
@TargetApi(17)
public void setMediaPlaybackRequiresUserAction(RNCWebViewWrapper rNCWebViewWrapper, boolean z) {
rNCWebViewWrapper.getWebView().getSettings().setMediaPlaybackRequiresUserGesture(z);
}
@com.facebook.react.uimanager.annotations.a(name = "messagingEnabled")
public void setMessagingEnabled(RNCWebViewWrapper rNCWebViewWrapper, boolean z) {
rNCWebViewWrapper.getWebView().setMessagingEnabled(z);
}
@com.facebook.react.uimanager.annotations.a(name = "messagingModuleName")
public void setMessagingModuleName(RNCWebViewWrapper rNCWebViewWrapper, String str) {
rNCWebViewWrapper.getWebView().setMessagingModuleName(str);
}
@com.facebook.react.uimanager.annotations.a(name = "minimumFontSize")
public void setMinimumFontSize(RNCWebViewWrapper rNCWebViewWrapper, int i) {
rNCWebViewWrapper.getWebView().getSettings().setMinimumFontSize(i);
}
@com.facebook.react.uimanager.annotations.a(name = "mixedContentMode")
public void setMixedContentMode(RNCWebViewWrapper rNCWebViewWrapper, String str) {
RNCWebView webView = rNCWebViewWrapper.getWebView();
if (str == null || "never".equals(str)) {
webView.getSettings().setMixedContentMode(1);
} else if ("always".equals(str)) {
webView.getSettings().setMixedContentMode(0);
} else if ("compatibility".equals(str)) {
webView.getSettings().setMixedContentMode(2);
}
}
@com.facebook.react.uimanager.annotations.a(name = "nestedScrollEnabled")
public void setNestedScrollEnabled(RNCWebViewWrapper rNCWebViewWrapper, boolean z) {
rNCWebViewWrapper.getWebView().setNestedScrollEnabled(z);
}
@com.facebook.react.uimanager.annotations.a(name = "onContentSizeChange")
public void setOnContentSizeChange(RNCWebViewWrapper rNCWebViewWrapper, boolean z) {
rNCWebViewWrapper.getWebView().setSendContentSizeChangeEvents(z);
}
@com.facebook.react.uimanager.annotations.a(name = "onScroll")
public void setOnScroll(RNCWebViewWrapper rNCWebViewWrapper, boolean z) {
rNCWebViewWrapper.getWebView().setHasScrollEvent(z);
}
@com.facebook.react.uimanager.annotations.a(name = "overScrollMode")
public void setOverScrollMode(RNCWebViewWrapper rNCWebViewWrapper, String str) {
char c2;
int hashCode = str.hashCode();
if (hashCode == -1414557169) {
if (str.equals("always")) {
c2 = 2;
}
c2 = 65535;
} else if (hashCode != 104712844) {
if (hashCode == 951530617 && str.equals("content")) {
c2 = 1;
}
c2 = 65535;
} else {
if (str.equals("never")) {
c2 = 0;
}
c2 = 65535;
}
rNCWebViewWrapper.getWebView().setOverScrollMode((c2 != 0 ? c2 != 1 ? 0 : 1 : 2).intValue());
}
@com.facebook.react.uimanager.annotations.a(name = "saveFormDataDisabled")
public void setSaveFormDataDisabled(RNCWebViewWrapper rNCWebViewWrapper, boolean z) {
rNCWebViewWrapper.getWebView().getSettings().setSaveFormData(!z);
}
@com.facebook.react.uimanager.annotations.a(name = "scalesPageToFit")
public void setScalesPageToFit(RNCWebViewWrapper rNCWebViewWrapper, boolean z) {
rNCWebViewWrapper.getWebView().getSettings().setLoadWithOverviewMode(z);
rNCWebViewWrapper.getWebView().getSettings().setUseWideViewPort(z);
}
@com.facebook.react.uimanager.annotations.a(name = "showsHorizontalScrollIndicator")
public void setShowsHorizontalScrollIndicator(RNCWebViewWrapper rNCWebViewWrapper, boolean z) {
rNCWebViewWrapper.getWebView().setHorizontalScrollBarEnabled(z);
}
@com.facebook.react.uimanager.annotations.a(name = "showsVerticalScrollIndicator")
public void setShowsVerticalScrollIndicator(RNCWebViewWrapper rNCWebViewWrapper, boolean z) {
rNCWebViewWrapper.getWebView().setVerticalScrollBarEnabled(z);
}
@com.facebook.react.uimanager.annotations.a(name = "source")
public void setSource(RNCWebViewWrapper rNCWebViewWrapper, ReadableMap readableMap) {
byte[] bArr;
RNCWebView webView = rNCWebViewWrapper.getWebView();
if (readableMap != null) {
if (readableMap.hasKey("html")) {
webView.loadDataWithBaseURL(readableMap.hasKey("baseUrl") ? readableMap.getString("baseUrl") : "", readableMap.getString("html"), HTML_MIME_TYPE, "UTF-8", null);
return;
}
if (readableMap.hasKey("uri")) {
String string = readableMap.getString("uri");
String url = webView.getUrl();
if (url == null || !url.equals(string)) {
if (readableMap.hasKey("method") && readableMap.getString("method").equalsIgnoreCase(HTTP_METHOD_POST)) {
if (readableMap.hasKey("body")) {
String string2 = readableMap.getString("body");
try {
bArr = string2.getBytes("UTF-8");
} catch (UnsupportedEncodingException unused) {
bArr = string2.getBytes();
}
} else {
bArr = null;
}
if (bArr == null) {
bArr = new byte[0];
}
webView.postUrl(string, bArr);
return;
}
HashMap hashMap = new HashMap();
if (readableMap.hasKey("headers")) {
ReadableMap map = readableMap.getMap("headers");
ReadableMapKeySetIterator keySetIterator = map.keySetIterator();
while (keySetIterator.hasNextKey()) {
String nextKey = keySetIterator.nextKey();
if (!"user-agent".equals(nextKey.toLowerCase(Locale.ENGLISH))) {
hashMap.put(nextKey, map.getString(nextKey));
} else if (webView.getSettings() != null) {
webView.getSettings().setUserAgentString(map.getString(nextKey));
}
}
}
webView.loadUrl(string, hashMap);
return;
}
return;
}
}
webView.loadUrl(BLANK_URL);
}
@com.facebook.react.uimanager.annotations.a(name = "setSupportMultipleWindows")
public void setSupportMultipleWindows(RNCWebViewWrapper rNCWebViewWrapper, boolean z) {
rNCWebViewWrapper.getWebView().getSettings().setSupportMultipleWindows(z);
}
@com.facebook.react.uimanager.annotations.a(name = "textZoom")
public void setTextZoom(RNCWebViewWrapper rNCWebViewWrapper, int i) {
rNCWebViewWrapper.getWebView().getSettings().setTextZoom(i);
}
@com.facebook.react.uimanager.annotations.a(name = "thirdPartyCookiesEnabled")
public void setThirdPartyCookiesEnabled(RNCWebViewWrapper rNCWebViewWrapper, boolean z) {
CookieManager.getInstance().setAcceptThirdPartyCookies(rNCWebViewWrapper.getWebView(), z);
}
@com.facebook.react.uimanager.annotations.a(name = "urlPrefixesForDefaultIntent")
public void setUrlPrefixesForDefaultIntent(RNCWebViewWrapper rNCWebViewWrapper, ReadableArray readableArray) {
f rNCWebViewClient = rNCWebViewWrapper.getWebView().getRNCWebViewClient();
if (rNCWebViewClient == null || readableArray == null) {
return;
}
rNCWebViewClient.setUrlPrefixesForDefaultIntent(readableArray);
}
@com.facebook.react.uimanager.annotations.a(name = "userAgent")
public void setUserAgent(RNCWebViewWrapper rNCWebViewWrapper, String str) {
if (str != null) {
this.mUserAgent = str;
} else {
this.mUserAgent = null;
}
setUserAgentString(rNCWebViewWrapper);
}
public void setUserAgentString(RNCWebViewWrapper rNCWebViewWrapper) {
RNCWebView webView = rNCWebViewWrapper.getWebView();
if (this.mUserAgent != null) {
webView.getSettings().setUserAgentString(this.mUserAgent);
} else if (this.mUserAgentWithApplicationName != null) {
webView.getSettings().setUserAgentString(this.mUserAgentWithApplicationName);
} else {
webView.getSettings().setUserAgentString(WebSettings.getDefaultUserAgent(webView.getContext()));
}
}
public void setupWebChromeClient(ReactContext reactContext, WebView webView) {
Activity currentActivity = reactContext.getCurrentActivity();
if (this.mAllowsFullscreenVideo && currentActivity != null) {
c cVar = new c(reactContext, webView, currentActivity, currentActivity.getRequestedOrientation());
this.mWebChromeClient = cVar;
webView.setWebChromeClient(cVar);
} else {
e eVar = this.mWebChromeClient;
if (eVar != null) {
eVar.onHideCustomView();
}
d dVar = new d(reactContext, webView);
this.mWebChromeClient = dVar;
webView.setWebChromeClient(dVar);
}
}
public void addEventEmitters(I i, RNCWebViewWrapper rNCWebViewWrapper) {
rNCWebViewWrapper.getWebView().setWebViewClient(new f());
}
@NonNull
public RNCWebViewWrapper createViewInstance(@NonNull I i) {
return createViewInstance(i, createRNCWebViewInstance(i));
}
public void onDropViewInstance(RNCWebViewWrapper rNCWebViewWrapper) {
RNCWebView webView = rNCWebViewWrapper.getWebView();
super/*com.facebook.react.uimanager.ViewManager*/.onDropViewInstance(rNCWebViewWrapper);
webView.getContext().removeLifecycleEventListener(webView);
webView.setWebViewClient(null);
webView.destroy();
this.mWebChromeClient = null;
}
public void receiveCommand(RNCWebViewWrapper rNCWebViewWrapper, int i, ReadableArray readableArray) {
RNCWebView webView = rNCWebViewWrapper.getWebView();
boolean z = false;
switch (i) {
case 1:
webView.goBack();
return;
case 2:
webView.goForward();
return;
case 3:
webView.reload();
return;
case 4:
webView.stopLoading();
return;
case 5:
try {
JSONObject jSONObject = new JSONObject();
jSONObject.put("data", readableArray.getString(0));
webView.evaluateJavascript("(function () {var event;var data = " + jSONObject.toString() + ";try {event = new MessageEvent('message', data);} catch (e) {event = document.createEvent('MessageEvent');event.initMessageEvent('message', true, true, data.data, data.origin, data.lastEventId, data.source);}document.dispatchEvent(event);})();", null);
return;
} catch (JSONException e2) {
throw new RuntimeException(e2);
}
case 6:
webView.evaluateJavascript(readableArray.getString(0), null);
return;
case 7:
if (readableArray == null) {
throw new RuntimeException("Arguments for loading an url are null!");
}
webView.k.a = false;
webView.loadUrl(readableArray.getString(0));
return;
case 8:
webView.requestFocus();
return;
default:
switch (i) {
case COMMAND_CLEAR_FORM_DATA:
webView.clearFormData();
return;
case 1001:
if (readableArray != null && readableArray.getBoolean(0)) {
z = true;
}
webView.clearCache(z);
return;
case COMMAND_CLEAR_HISTORY:
webView.clearHistory();
return;
default:
return;
}
}
}
public RNCWebViewManager(com.reactnativecommunity.webview.d dVar) {
this.mWebChromeClient = null;
this.mAllowsFullscreenVideo = false;
this.mUserAgent = null;
this.mUserAgentWithApplicationName = null;
this.mDownloadingMessage = null;
this.mLackPermissionToDownloadMessage = null;
this.mWebViewConfig = dVar;
}
@TargetApi(21)
public RNCWebViewWrapper createViewInstance(I i, RNCWebView rNCWebView) {
RNCWebViewWrapper rNCWebViewWrapper = new RNCWebViewWrapper(i, rNCWebView);
setupWebChromeClient(i, rNCWebView);
i.addLifecycleEventListener(rNCWebView);
this.mWebViewConfig.getClass();
WebSettings settings = rNCWebView.getSettings();
settings.setBuiltInZoomControls(true);
settings.setDisplayZoomControls(false);
settings.setDomStorageEnabled(true);
settings.setSupportMultipleWindows(true);
settings.setAllowFileAccess(false);
settings.setAllowContentAccess(false);
settings.setAllowFileAccessFromFileURLs(false);
setAllowUniversalAccessFromFileURLs(rNCWebViewWrapper, false);
setMixedContentMode(rNCWebViewWrapper, "never");
rNCWebView.setLayoutParams(new ViewGroup.LayoutParams(-1, -1));
rNCWebView.setDownloadListener(new b(rNCWebView, i));
setUserAgentToSharedPref(settings.getUserAgentString(), i);
return new RNCWebViewWrapper(i, rNCWebView);
}
public static class RNCWebView extends WebView implements LifecycleEventListener {
public String a;
public String b;
public boolean c;
public String d;
public f e;
public CatalystInstance f;
public boolean g;
public com.facebook.react.views.scroll.b h;
public boolean i;
public boolean j;
public a k;
public WebChromeClient l;
public static class a {
public boolean a;
}
public class b {
public RNCWebView a;
@JavascriptInterface
public void postMessage(String str) {
RNCWebView rNCWebView = this.a;
rNCWebView.getContext();
if (rNCWebView.e != null) {
rNCWebView.post(new com.reactnativecommunity.webview.b(rNCWebView, rNCWebView, str, rNCWebView));
return;
}
WritableMap createMap = Arguments.createMap();
createMap.putString("data", str);
if (rNCWebView.f != null) {
rNCWebView.b("onMessage", createMap);
} else {
RNCWebView.a(rNCWebView, new com.reactnativecommunity.webview.events.f(RNCWebViewWrapper.a(rNCWebView), createMap));
}
}
}
public static void a(WebView webView, com.facebook.react.uimanager.events.c cVar) {
webView.getContext().getNativeModule(UIManagerModule.class).getEventDispatcher().c(cVar);
}
public final void b(String str, WritableMap writableMap) {
WritableNativeMap writableNativeMap = new WritableNativeMap();
writableNativeMap.putMap("nativeEvent", writableMap);
WritableNativeArray writableNativeArray = new WritableNativeArray();
writableNativeArray.pushMap(writableNativeMap);
this.f.callFunction(this.d, str, writableNativeArray);
}
@Override
public final void destroy() {
WebChromeClient webChromeClient = this.l;
if (webChromeClient != null) {
webChromeClient.onHideCustomView();
}
super.destroy();
}
public f getRNCWebViewClient() {
return this.e;
}
public final void onHostDestroy() {
setWebViewClient(null);
destroy();
}
@Override
public final void onScrollChanged(int i, int i2, int i3, int i4) {
super.onScrollChanged(i, i2, i3, i4);
if (this.i) {
if (this.h == null) {
this.h = new com.facebook.react.views.scroll.b();
}
if (this.h.a(i, i2)) {
com.facebook.react.views.scroll.b bVar = this.h;
a(this, h.a(-1, RNCWebViewWrapper.a(this), com.facebook.react.views.scroll.i.c, i, i2, bVar.c, bVar.d, computeHorizontalScrollRange(), computeVerticalScrollRange(), getWidth(), getHeight()));
}
}
}
@Override
public final void onSizeChanged(int i, int i2, int i3, int i4) {
super.onSizeChanged(i, i2, i3, i4);
if (this.g) {
a(this, new com.facebook.react.uimanager.events.b(RNCWebViewWrapper.a(this), i, i2));
}
}
@Override
public final boolean onTouchEvent(MotionEvent motionEvent) {
if (this.j) {
requestDisallowInterceptTouchEvent(true);
}
return super.onTouchEvent(motionEvent);
}
public void setBasicAuthCredential(com.reactnativecommunity.webview.a aVar) {
this.e.setBasicAuthCredential(aVar);
}
public void setHasScrollEvent(boolean z) {
this.i = z;
}
public void setIgnoreErrFailedForThisURL(String str) {
this.e.setIgnoreErrFailedForThisURL(str);
}
public void setInjectedJavaScript(String str) {
this.a = str;
}
public void setInjectedJavaScriptBeforeContentLoaded(String str) {
this.b = str;
}
@SuppressLint({"AddJavascriptInterface"})
public void setMessagingEnabled(boolean z) {
if (this.c == z) {
return;
}
this.c = z;
if (!z) {
removeJavascriptInterface(RNCWebViewManager.JAVASCRIPT_INTERFACE);
return;
}
b bVar = new b();
bVar.a = this;
addJavascriptInterface(bVar, RNCWebViewManager.JAVASCRIPT_INTERFACE);
}
public void setMessagingModuleName(String str) {
this.d = str;
}
public void setNestedScrollEnabled(boolean z) {
this.j = z;
}
public void setSendContentSizeChangeEvents(boolean z) {
this.g = z;
}
@Override
public void setWebChromeClient(WebChromeClient webChromeClient) {
this.l = webChromeClient;
super.setWebChromeClient(webChromeClient);
if (webChromeClient instanceof e) {
((e) webChromeClient).k = this.k;
}
}
@Override
public void setWebViewClient(WebViewClient webViewClient) {
super.setWebViewClient(webViewClient);
if (webViewClient instanceof f) {
f fVar = (f) webViewClient;
this.e = fVar;
fVar.setProgressChangedFilter(this.k);
}
}
public final void onHostPause() {
}
public final void onHostResume() {
}
public void setInjectedJavaScriptBeforeContentLoadedForMainFrameOnly(boolean z) {
}
public void setInjectedJavaScriptForMainFrameOnly(boolean z) {
}
}
public static class e extends WebChromeClient implements LifecycleEventListener {
public static final FrameLayout.LayoutParams m = new FrameLayout.LayoutParams(-1, -1, 17);
public final ReactContext a;
public final WebView b;
public View c;
public WebChromeClient.CustomViewCallback d;
public PermissionRequest e;
public ArrayList f;
public GeolocationPermissions.Callback g;
public String h;
public boolean i = false;
public final ArrayList j = new ArrayList();
public RNCWebView.a k = null;
@TargetApi(21)
public final X0 l = new X0(this, 9);
public e(ReactContext reactContext, WebView webView) {
this.a = reactContext;
this.b = webView;
}
public final synchronized void a(List<String> list) {
if (this.i) {
this.j.addAll(list);
return;
}
com.facebook.react.modules.core.f currentActivity = this.a.getCurrentActivity();
if (currentActivity == null) {
throw new IllegalStateException("Tried to use permissions API while not attached to an Activity.");
}
if (!(currentActivity instanceof com.facebook.react.modules.core.f)) {
throw new IllegalStateException("Tried to use permissions API but the host Activity doesn't implement PermissionAwareActivity.");
}
this.i = true;
currentActivity.m((String[]) list.toArray(new String[0]), 3, this.l);
this.j.clear();
}
@Override
public final boolean onConsoleMessage(ConsoleMessage consoleMessage) {
return true;
}
@Override
public final boolean onCreateWindow(WebView webView, boolean z, boolean z2, Message message) {
((WebView.WebViewTransport) message.obj).setWebView(new WebView(webView.getContext()));
message.sendToTarget();
return true;
}
@Override
public final void onGeolocationPermissionsShowPrompt(String str, GeolocationPermissions.Callback callback) {
if (androidx.core.content.b.a(this.a, "android.permission.ACCESS_FINE_LOCATION") == 0) {
callback.invoke(str, true, false);
return;
}
this.g = callback;
this.h = str;
a(Collections.singletonList("android.permission.ACCESS_FINE_LOCATION"));
}
public final void onHostResume() {
View view = this.c;
if (view == null || view.getSystemUiVisibility() == 7942) {
return;
}
this.c.setSystemUiVisibility(7942);
}
@Override
@TargetApi(21)
public final void onPermissionRequest(PermissionRequest permissionRequest) {
this.f = new ArrayList();
ArrayList arrayList = new ArrayList();
String[] resources = permissionRequest.getResources();
int length = resources.length;
int i = 0;
while (true) {
String str = null;
if (i >= length) {
break;
}
String str2 = resources[i];
if (str2.equals("android.webkit.resource.AUDIO_CAPTURE")) {
str = "android.permission.RECORD_AUDIO";
} else if (str2.equals("android.webkit.resource.VIDEO_CAPTURE")) {
str = "android.permission.CAMERA";
} else if (str2.equals("android.webkit.resource.PROTECTED_MEDIA_ID")) {
str = "android.webkit.resource.PROTECTED_MEDIA_ID";
}
if (str != null) {
if (androidx.core.content.b.a(this.a, str) == 0) {
this.f.add(str2);
} else {
arrayList.add(str);
}
}
i++;
}
if (arrayList.isEmpty()) {
permissionRequest.grant((String[]) this.f.toArray(new String[0]));
this.f = null;
} else {
this.e = permissionRequest;
a(arrayList);
}
}
@Override
public final void onProgressChanged(WebView webView, int i) {
super.onProgressChanged(webView, i);
String url = webView.getUrl();
if (this.k.a) {
return;
}
int a = RNCWebViewWrapper.a(webView);
WritableMap createMap = Arguments.createMap();
createMap.putDouble("target", a);
createMap.putString("title", webView.getTitle());
createMap.putString(PaymentConstants.URL, url);
createMap.putBoolean("canGoBack", webView.canGoBack());
createMap.putBoolean("canGoForward", webView.canGoForward());
createMap.putDouble("progress", i / 100.0f);
RNCWebView.a(webView, new com.reactnativecommunity.webview.events.d(RNCWebViewWrapper.a(webView), createMap));
}
@Override
@TargetApi(21)
public final boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> valueCallback, WebChromeClient.FileChooserParams fileChooserParams) {
return RNCWebViewManager.getModule(this.a).startPhotoPickerIntent(valueCallback, fileChooserParams.getAcceptTypes(), fileChooserParams.getMode() == 1);
}
public final void onHostDestroy() {
}
public final void onHostPause() {
}
}
public static class f extends WebViewClient {
static final boolean $assertionsDisabled = false;
protected ReadableArray mUrlPrefixesForDefaultIntent;
protected boolean mLastLoadFailed = false;
protected RNCWebView.a progressChangedFilter = null;
protected String ignoreErrFailedForThisURL = null;
protected com.reactnativecommunity.webview.a basicAuthCredential = null;
protected boolean mFeedFromCache = false;
protected String[] mCachedFolderPaths = null;
protected String mFeedHtmlFor = null;
protected String mAppKey = null;
private File fileExistsInCache(File file, String str) {
File file2 = new File(file, str);
if (file2.exists()) {
return file2;
}
return null;
}
private WebResourceResponse getWebviewResourceResponse(File file, String str) {
HashMap hashMap;
WebResourceResponse webResourceResponse;
WebResourceResponse webResourceResponse2 = null;
try {
hashMap = new HashMap();
hashMap.put("Access-Control-Allow-Origin", "*");
webResourceResponse = new WebResourceResponse(str.equals("js") ? "application/javascript" : RNCWebViewManager.HTML_MIME_TYPE, str.equals("js") ? "gzip" : "utf-8", new FileInputStream(file));
} catch (Exception e) {
e = e;
}
try {
webResourceResponse.setResponseHeaders(hashMap);
return webResourceResponse;
} catch (Exception e2) {
e = e2;
webResourceResponse2 = webResourceResponse;
Log.d("shouldInterceptRequest", "getWebviewResourceResponse Error " + e.getMessage());
return webResourceResponse2;
}
}
public WritableMap createWebViewEvent(WebView webView, String str) {
WritableMap createMap = Arguments.createMap();
createMap.putDouble("target", RNCWebViewWrapper.a(webView));
createMap.putString(PaymentConstants.URL, str);
createMap.putBoolean("loading", (this.mLastLoadFailed || webView.getProgress() == 100) ? false : true);
createMap.putString("title", webView.getTitle());
createMap.putBoolean("canGoBack", webView.canGoBack());
createMap.putBoolean("canGoForward", webView.canGoForward());
return createMap;
}
public void emitFinishEvent(WebView webView, String str) {
com.reactnativecommunity.webview.events.c cVar = new com.reactnativecommunity.webview.events.c(RNCWebViewWrapper.a(webView), createWebViewEvent(webView, str));
((RNCWebView) webView).getClass();
RNCWebView.a(webView, cVar);
}
@Override
public void onPageFinished(WebView webView, String str) {
String str2;
super.onPageFinished(webView, str);
if (this.mLastLoadFailed) {
return;
}
RNCWebView rNCWebView = (RNCWebView) webView;
if (rNCWebView.getSettings().getJavaScriptEnabled() && (str2 = rNCWebView.a) != null && !TextUtils.isEmpty(str2)) {
rNCWebView.evaluateJavascript("(function() {\n" + rNCWebView.a + ";\n})();", null);
}
emitFinishEvent(webView, str);
}
@Override
public void onPageStarted(WebView webView, String str, Bitmap bitmap) {
String str2;
super.onPageStarted(webView, str, bitmap);
this.mLastLoadFailed = false;
RNCWebView rNCWebView = (RNCWebView) webView;
if (rNCWebView.getSettings().getJavaScriptEnabled() && (str2 = rNCWebView.b) != null && !TextUtils.isEmpty(str2)) {
rNCWebView.evaluateJavascript("(function() {\n" + rNCWebView.b + ";\n})();", null);
}
RNCWebView.a(webView, new com.reactnativecommunity.webview.events.e(RNCWebViewWrapper.a(webView), createWebViewEvent(webView, str)));
}
@Override
public void onReceivedError(WebView webView, int i, String str, String str2) {
String str3 = this.ignoreErrFailedForThisURL;
if (str3 != null && str2.equals(str3) && i == -1 && str.equals("net::ERR_FAILED")) {
setIgnoreErrFailedForThisURL(null);
return;
}
super.onReceivedError(webView, i, str, str2);
this.mLastLoadFailed = true;
emitFinishEvent(webView, str2);
WritableMap createWebViewEvent = createWebViewEvent(webView, str2);
createWebViewEvent.putDouble("code", i);
createWebViewEvent.putString("description", str);
com.reactnativecommunity.webview.events.b bVar = new com.reactnativecommunity.webview.events.b(RNCWebViewWrapper.a(webView), createWebViewEvent);
((RNCWebView) webView).getClass();
RNCWebView.a(webView, bVar);
}
@Override
public void onReceivedHttpAuthRequest(WebView webView, HttpAuthHandler httpAuthHandler, String str, String str2) {
com.reactnativecommunity.webview.a aVar = this.basicAuthCredential;
if (aVar != null) {
httpAuthHandler.proceed(aVar.a, aVar.b);
} else {
super.onReceivedHttpAuthRequest(webView, httpAuthHandler, str, str2);
}
}
@Override
public void onReceivedHttpError(WebView webView, WebResourceRequest webResourceRequest, WebResourceResponse webResourceResponse) {
super.onReceivedHttpError(webView, webResourceRequest, webResourceResponse);
if (webResourceRequest.isForMainFrame()) {
WritableMap createWebViewEvent = createWebViewEvent(webView, webResourceRequest.getUrl().toString());
createWebViewEvent.putInt("statusCode", webResourceResponse.getStatusCode());
createWebViewEvent.putString("description", webResourceResponse.getReasonPhrase());
com.reactnativecommunity.webview.events.a aVar = new com.reactnativecommunity.webview.events.a(RNCWebViewWrapper.a(webView), createWebViewEvent);
((RNCWebView) webView).getClass();
RNCWebView.a(webView, aVar);
}
}
@Override
public void onReceivedSslError(WebView webView, SslErrorHandler sslErrorHandler, SslError sslError) {
String url = webView.getUrl();
String url2 = sslError.getUrl();
sslErrorHandler.cancel();
if (!url.equalsIgnoreCase(url2)) {
androidx.appcompat.widget.a.g("Resource blocked from loading due to SSL error. Blocked URL: ", url2, RNCWebViewManager.TAG);
} else {
int primaryError = sslError.getPrimaryError();
onReceivedError(webView, primaryError, "SSL error: ".concat(primaryError != 0 ? primaryError != 1 ? primaryError != 2 ? primaryError != 3 ? primaryError != 4 ? primaryError != 5 ? "Unknown SSL Error" : "A generic error occurred" : "The date of the certificate is invalid" : "The certificate authority is not trusted" : "Hostname mismatch" : "The certificate has expired" : "The certificate is not yet valid"), url2);
}
}
@Override
@TargetApi(26)
public boolean onRenderProcessGone(WebView webView, RenderProcessGoneDetail renderProcessGoneDetail) {
if (Build.VERSION.SDK_INT < 26) {
return false;
}
super.onRenderProcessGone(webView, renderProcessGoneDetail);
if (renderProcessGoneDetail.didCrash()) {
Log.e(RNCWebViewManager.TAG, "The WebView rendering process crashed.");
} else {
Log.w(RNCWebViewManager.TAG, "The WebView rendering process was killed by the system.");
}
if (webView == null) {
return true;
}
WritableMap createWebViewEvent = createWebViewEvent(webView, webView.getUrl());
createWebViewEvent.putBoolean("didCrash", renderProcessGoneDetail.didCrash());
RNCWebView.a(webView, new g(RNCWebViewWrapper.a(webView), createWebViewEvent));
return true;
}
public void setAppKey(String str) {
this.mAppKey = str;
}
public void setBasicAuthCredential(com.reactnativecommunity.webview.a aVar) {
this.basicAuthCredential = aVar;
}
public void setCachedFolderPaths(ReadableArray readableArray) {
String[] strArr = new String[readableArray.size()];
for (int i = 0; i < readableArray.size(); i++) {
strArr[i] = readableArray.getString(i);
}
this.mCachedFolderPaths = strArr;
}
public void setFeedFromCache(Boolean bool) {
this.mFeedFromCache = bool.booleanValue();
}
public void setFeedHtmlFor(String str) {
this.mFeedHtmlFor = str;
}
public void setIgnoreErrFailedForThisURL(String str) {
this.ignoreErrFailedForThisURL = str;
}
public void setProgressChangedFilter(RNCWebView.a aVar) {
this.progressChangedFilter = aVar;
}
public void setUrlPrefixesForDefaultIntent(ReadableArray readableArray) {
this.mUrlPrefixesForDefaultIntent = readableArray;
}
@Override
public WebResourceResponse shouldInterceptRequest(WebView webView, WebResourceRequest webResourceRequest) {
Log.d("shouldInterceptRequest", "mFeedFromCache: " + this.mFeedFromCache + " mFeedHtmlFor: " + this.mFeedHtmlFor + "\nmCachedFolderPaths: " + Arrays.toString(this.mCachedFolderPaths));
String uri = webResourceRequest.getUrl().toString();
if (!this.mFeedFromCache || this.mCachedFolderPaths == null || (!uri.endsWith(".js") && !this.mFeedHtmlFor.equals(uri))) {
return super.shouldInterceptRequest(webView, webResourceRequest);
}
Log.d("shouldInterceptRequest", "url ".concat(uri));
try {
File filesDir = webView.getContext().getFilesDir();
int i = 0;
if (this.mFeedHtmlFor.equals(uri)) {
String[] strArr = this.mCachedFolderPaths;
int length = strArr.length;
while (i < length) {
String str = strArr[i] + "/index.html";
File fileExistsInCache = fileExistsInCache(filesDir, str);
if (fileExistsInCache != null) {
Log.d("shouldInterceptRequest", "html File exists " + str);
WebResourceResponse webviewResourceResponse = getWebviewResourceResponse(fileExistsInCache, "html");
return webviewResourceResponse == null ? super.shouldInterceptRequest(webView, webResourceRequest) : webviewResourceResponse;
}
i++;
}
} else {
String str2 = uri.split("/", 0)[r1.length - 1];
String[] strArr2 = this.mCachedFolderPaths;
int length2 = strArr2.length;
while (i < length2) {
String str3 = strArr2[i] + "/" + str2;
File fileExistsInCache2 = fileExistsInCache(filesDir, str3);
if (fileExistsInCache2 != null) {
Log.d("shouldInterceptRequest", "JS File exists " + str3);
WebResourceResponse webviewResourceResponse2 = getWebviewResourceResponse(fileExistsInCache2, "js");
return webviewResourceResponse2 == null ? super.shouldInterceptRequest(webView, webResourceRequest) : webviewResourceResponse2;
}
i++;
}
}
} catch (Exception e) {
Log.d("shouldInterceptRequest", "Error " + e.getMessage());
}
return super.shouldInterceptRequest(webView, webResourceRequest);
}
@Override
public boolean shouldOverrideUrlLoading(WebView webView, String str) {
AtomicReference<RNCWebViewModule.c.a> atomicReference;
Integer valueOf;
RNCWebView rNCWebView = (RNCWebView) webView;
if (webView.getContext().getJavaScriptContextHolder().get() == 0 || rNCWebView.f == null) {
com.facebook.common.logging.a.s(RNCWebViewManager.TAG, "Couldn't use blocking synchronous call for onShouldStartLoadWithRequest due to debugging or missing Catalyst instance, falling back to old event-and-load.");
this.progressChangedFilter.a = true;
RNCWebView.a(webView, new com.reactnativecommunity.webview.events.h(RNCWebViewWrapper.a(webView), createWebViewEvent(webView, str)));
return true;
}
RNCWebViewModule.c cVar = RNCWebViewModule.shouldOverrideUrlLoadingLock;
synchronized (cVar) {
int i = cVar.a;
cVar.a = i + 1;
atomicReference = new AtomicReference<>(RNCWebViewModule.c.a.a);
cVar.b.put(Integer.valueOf(i), atomicReference);
valueOf = Integer.valueOf(i);
}
int intValue = valueOf.intValue();
WritableMap createWebViewEvent = createWebViewEvent(webView, str);
createWebViewEvent.putInt("lockIdentifier", intValue);
rNCWebView.b("onShouldStartLoadWithRequest", createWebViewEvent);
try {
synchronized (atomicReference) {
try {
long elapsedRealtime = SystemClock.elapsedRealtime();
while (atomicReference.get() == RNCWebViewModule.c.a.a) {
if (SystemClock.elapsedRealtime() - elapsedRealtime > 250) {
com.facebook.common.logging.a.s(RNCWebViewManager.TAG, "Did not receive response to shouldOverrideUrlLoading in time, defaulting to allow loading.");
RNCWebViewModule.c cVar2 = RNCWebViewModule.shouldOverrideUrlLoadingLock;
Integer valueOf2 = Integer.valueOf(intValue);
synchronized (cVar2) {
cVar2.b.remove(valueOf2);
}
return false;
}
atomicReference.wait(250L);
}
boolean z = atomicReference.get() == RNCWebViewModule.c.a.b;
RNCWebViewModule.c cVar3 = RNCWebViewModule.shouldOverrideUrlLoadingLock;
Integer valueOf3 = Integer.valueOf(intValue);
synchronized (cVar3) {
cVar3.b.remove(valueOf3);
}
return z;
} catch (Throwable th) {
throw th;
}
}
} catch (InterruptedException e) {
com.facebook.common.logging.a.h(RNCWebViewManager.TAG, "shouldOverrideUrlLoading was interrupted while waiting for result.", e);
RNCWebViewModule.c cVar4 = RNCWebViewModule.shouldOverrideUrlLoadingLock;
Integer valueOf4 = Integer.valueOf(intValue);
synchronized (cVar4) {
cVar4.b.remove(valueOf4);
return false;
}
}
}
@Override
@TargetApi(24)
public boolean shouldOverrideUrlLoading(WebView webView, WebResourceRequest webResourceRequest) {
return shouldOverrideUrlLoading(webView, webResourceRequest.getUrl().toString());
}
}
}