Shinigami ID v1.1.3版本的 MD5 值为:c381e85feac697f048c400ae89b7b92d
以下内容为反编译后的 WebPlayerView.java 源代码,内容仅作参考
package com.unity3d.services.ads.webplayer;
import aa.p;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.drawable.ColorDrawable;
import android.net.Uri;
import android.net.http.SslError;
import android.os.Message;
import android.view.KeyEvent;
import android.view.View;
import android.webkit.ClientCertRequest;
import android.webkit.ConsoleMessage;
import android.webkit.DownloadListener;
import android.webkit.GeolocationPermissions;
import android.webkit.HttpAuthHandler;
import android.webkit.JsPromptResult;
import android.webkit.JsResult;
import android.webkit.PermissionRequest;
import android.webkit.RenderProcessGoneDetail;
import android.webkit.SslErrorHandler;
import android.webkit.ValueCallback;
import android.webkit.WebChromeClient;
import android.webkit.WebResourceError;
import android.webkit.WebResourceRequest;
import android.webkit.WebResourceResponse;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import com.unity3d.services.core.log.DeviceLog;
import com.unity3d.services.core.misc.Utilities;
import com.unity3d.services.core.misc.ViewUtilities;
import com.unity3d.services.core.webview.WebViewApp;
import com.unity3d.services.core.webview.WebViewEventCategory;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import org.json.JSONArray;
import org.json.JSONObject;
public class WebPlayerView extends WebView {
private Map<String, String> _erroredSettings;
private Method _evaluateJavascript;
private JSONObject _eventSettings;
private Runnable _unsubscribeLayoutChange;
private String viewId;
public class JavaScriptInvocation implements Runnable {
private String _jsString;
private WebView _webView;
public JavaScriptInvocation(String str, WebView webView) {
this._jsString = str;
this._webView = webView;
}
@Override
public void run() {
if (this._jsString == null) {
DeviceLog.error("Could not process JavaScript, the string is NULL");
return;
}
try {
WebPlayerView.this._evaluateJavascript.invoke(this._webView, this._jsString, null);
} catch (Exception e10) {
DeviceLog.exception("Error while processing JavaScriptString", e10);
}
}
}
public class WebPlayerChromeClient extends WebChromeClient {
private WebPlayerChromeClient() {
}
@Override
public void onCloseWindow(WebView webView) {
if (WebPlayerView.this.shouldCallSuper("onCloseWindow")) {
super.onCloseWindow(webView);
}
if (WebPlayerView.this.shouldSendEvent("onCloseWindow")) {
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.CLOSE_WINDOW, WebPlayerView.this.viewId);
}
}
@Override
public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
Boolean bool = Boolean.FALSE;
if (WebPlayerView.this.shouldCallSuper("onConsoleMessage")) {
bool = Boolean.valueOf(super.onConsoleMessage(consoleMessage));
}
if (WebPlayerView.this.shouldSendEvent("onConsoleMessage")) {
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.CONSOLE_MESSAGE, consoleMessage != null ? consoleMessage.message() : "", WebPlayerView.this.viewId);
}
if (WebPlayerView.this.hasReturnValue("onConsoleMessage")) {
bool = (Boolean) WebPlayerView.this.getReturnValue("onConsoleMessage", Boolean.class, Boolean.TRUE);
}
return bool.booleanValue();
}
@Override
public boolean onCreateWindow(WebView webView, boolean z10, boolean z11, Message message) {
Boolean bool = Boolean.FALSE;
Boolean valueOf = WebPlayerView.this.shouldCallSuper("onCreateWindow") ? Boolean.valueOf(super.onCreateWindow(webView, z10, z11, message)) : bool;
if (WebPlayerView.this.shouldSendEvent("onCreateWindow")) {
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.CREATE_WINDOW, Boolean.valueOf(z10), Boolean.valueOf(z11), message, WebPlayerView.this.viewId);
}
if (WebPlayerView.this.hasReturnValue("onCreateWindow")) {
valueOf = (Boolean) WebPlayerView.this.getReturnValue("onCreateWindow", Boolean.class, bool);
}
return valueOf.booleanValue();
}
@Override
public void onGeolocationPermissionsShowPrompt(String str, GeolocationPermissions.Callback callback) {
if (WebPlayerView.this.shouldCallSuper("onGeolocationPermissionsShowPrompt")) {
super.onGeolocationPermissionsShowPrompt(str, callback);
}
if (WebPlayerView.this.shouldSendEvent("onGeolocationPermissionsShowPrompt")) {
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.GEOLOCATION_PERMISSIONS_SHOW, str, WebPlayerView.this.viewId);
}
}
@Override
public void onHideCustomView() {
if (WebPlayerView.this.shouldCallSuper("onHideCustomView")) {
super.onHideCustomView();
}
if (WebPlayerView.this.shouldSendEvent("onHideCustomView")) {
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.HIDE_CUSTOM_VIEW, WebPlayerView.this.viewId);
}
}
@Override
public boolean onJsAlert(WebView webView, String str, String str2, JsResult jsResult) {
Boolean bool = Boolean.FALSE;
if (WebPlayerView.this.shouldCallSuper("onJsAlert")) {
bool = Boolean.valueOf(super.onJsAlert(webView, str, str2, jsResult));
}
if (WebPlayerView.this.shouldSendEvent("onJsAlert")) {
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.JS_ALERT, str, str2, jsResult, WebPlayerView.this.viewId);
}
if (WebPlayerView.this.hasReturnValue("onJsAlert")) {
bool = (Boolean) WebPlayerView.this.getReturnValue("onJsAlert", Boolean.class, Boolean.TRUE);
}
return bool.booleanValue();
}
@Override
public boolean onJsConfirm(WebView webView, String str, String str2, JsResult jsResult) {
Boolean bool = Boolean.FALSE;
if (WebPlayerView.this.shouldCallSuper("onJsConfirm")) {
bool = Boolean.valueOf(super.onJsConfirm(webView, str, str2, jsResult));
}
if (WebPlayerView.this.shouldSendEvent("onJsConfirm")) {
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.JS_CONFIRM, str, str2, WebPlayerView.this.viewId);
}
if (WebPlayerView.this.hasReturnValue("onJsConfirm")) {
bool = (Boolean) WebPlayerView.this.getReturnValue("onJsConfirm", Boolean.class, Boolean.TRUE);
}
return bool.booleanValue();
}
@Override
public boolean onJsPrompt(WebView webView, String str, String str2, String str3, JsPromptResult jsPromptResult) {
Boolean bool = Boolean.FALSE;
if (WebPlayerView.this.shouldCallSuper("onJsPrompt")) {
bool = Boolean.valueOf(super.onJsPrompt(webView, str, str2, str3, jsPromptResult));
}
if (WebPlayerView.this.shouldSendEvent("onJsPrompt")) {
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.JS_PROMPT, str, str2, str3, WebPlayerView.this.viewId);
}
if (WebPlayerView.this.hasReturnValue("onJsPrompt")) {
bool = (Boolean) WebPlayerView.this.getReturnValue("onJsPrompt", Boolean.class, Boolean.TRUE);
}
return bool.booleanValue();
}
@Override
public void onPermissionRequest(PermissionRequest permissionRequest) {
if (WebPlayerView.this.shouldCallSuper("onPermissionRequest")) {
super.onPermissionRequest(permissionRequest);
}
if (WebPlayerView.this.shouldSendEvent("onPermissionRequest")) {
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.PERMISSION_REQUEST, (permissionRequest == null || permissionRequest.getOrigin() == null) ? "" : permissionRequest.getOrigin().toString(), WebPlayerView.this.viewId);
}
}
@Override
public void onProgressChanged(WebView webView, int i10) {
if (WebPlayerView.this.shouldCallSuper("onProgressChanged")) {
super.onProgressChanged(webView, i10);
}
if (WebPlayerView.this.shouldSendEvent("onProgressChanged")) {
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.PROGRESS_CHANGED, Integer.valueOf(i10), WebPlayerView.this.viewId);
}
}
@Override
public void onReceivedIcon(WebView webView, Bitmap bitmap) {
if (WebPlayerView.this.shouldCallSuper("onReceivedIcon")) {
super.onReceivedIcon(webView, bitmap);
}
if (WebPlayerView.this.shouldSendEvent("onReceivedIcon")) {
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.RECEIVED_ICON, WebPlayerView.this.viewId);
}
}
@Override
public void onReceivedTitle(WebView webView, String str) {
if (WebPlayerView.this.shouldCallSuper("onReceivedTitle")) {
super.onReceivedTitle(webView, str);
}
if (WebPlayerView.this.shouldSendEvent("onReceivedTitle")) {
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.RECEIVED_TITLE, str, WebPlayerView.this.viewId);
}
}
@Override
public void onReceivedTouchIconUrl(WebView webView, String str, boolean z10) {
if (WebPlayerView.this.shouldCallSuper("onReceivedTouchIconUrl")) {
super.onReceivedTouchIconUrl(webView, str, z10);
}
if (WebPlayerView.this.shouldSendEvent("onReceivedTouchIconUrl")) {
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.RECEIVED_TOUCH_ICON_URL, str, Boolean.valueOf(z10), WebPlayerView.this.viewId);
}
}
@Override
public void onRequestFocus(WebView webView) {
if (WebPlayerView.this.shouldCallSuper("onRequestFocus")) {
super.onRequestFocus(webView);
}
if (WebPlayerView.this.shouldSendEvent("onRequestFocus")) {
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.REQUEST_FOCUS, WebPlayerView.this.viewId);
}
}
@Override
public void onShowCustomView(View view, WebChromeClient.CustomViewCallback customViewCallback) {
if (WebPlayerView.this.shouldCallSuper("onShowCustomView")) {
super.onShowCustomView(view, customViewCallback);
}
if (WebPlayerView.this.shouldSendEvent("onShowCustomView")) {
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.SHOW_CUSTOM_VIEW, WebPlayerView.this.viewId);
}
}
@Override
public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> valueCallback, WebChromeClient.FileChooserParams fileChooserParams) {
Boolean bool = Boolean.FALSE;
if (WebPlayerView.this.shouldCallSuper("onShowFileChooser")) {
bool = Boolean.valueOf(super.onShowFileChooser(webView, valueCallback, fileChooserParams));
}
if (WebPlayerView.this.shouldSendEvent("onShowFileChooser")) {
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.SHOW_FILE_CHOOSER, WebPlayerView.this.viewId);
}
if (WebPlayerView.this.hasReturnValue("onShowFileChooser")) {
bool = (Boolean) WebPlayerView.this.getReturnValue("onShowFileChooser", Boolean.class, Boolean.TRUE);
if (bool.booleanValue()) {
valueCallback.onReceiveValue(null);
}
}
return bool.booleanValue();
}
}
public class WebPlayerClient extends WebViewClient {
private WebPlayerClient() {
}
@Override
public void onFormResubmission(WebView webView, Message message, Message message2) {
if (WebPlayerView.this.shouldCallSuper("onFormResubmission")) {
super.onFormResubmission(webView, message, message2);
}
if (WebPlayerView.this.shouldSendEvent("onFormResubmission")) {
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.FORM_RESUBMISSION, WebPlayerView.this.viewId);
}
}
@Override
public void onLoadResource(WebView webView, String str) {
if (WebPlayerView.this.shouldCallSuper("onLoadResource")) {
super.onLoadResource(webView, str);
}
if (WebPlayerView.this.shouldSendEvent("onLoadResource")) {
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.LOAD_RESOUCE, str, WebPlayerView.this.viewId);
}
}
@Override
public void onPageCommitVisible(WebView webView, String str) {
if (WebPlayerView.this.shouldCallSuper("onPageCommitVisible")) {
super.onPageCommitVisible(webView, str);
}
if (WebPlayerView.this.shouldSendEvent("onPageCommitVisible")) {
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.PAGE_COMMIT_VISIBLE, str, WebPlayerView.this.viewId);
}
}
@Override
public void onPageFinished(WebView webView, String str) {
if (WebPlayerView.this.shouldCallSuper("onPageFinished")) {
super.onPageFinished(webView, str);
}
if (WebPlayerView.this.shouldSendEvent("onPageFinished")) {
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.PAGE_FINISHED, str, WebPlayerView.this.viewId);
}
}
@Override
public void onPageStarted(WebView webView, String str, Bitmap bitmap) {
if (WebPlayerView.this.shouldCallSuper("onPageStarted")) {
super.onPageStarted(webView, str, bitmap);
}
if (WebPlayerView.this.shouldSendEvent("onPageStarted")) {
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.PAGE_STARTED, str, WebPlayerView.this.viewId);
}
}
@Override
public void onReceivedClientCertRequest(WebView webView, ClientCertRequest clientCertRequest) {
int i10;
String str;
if (WebPlayerView.this.shouldCallSuper("onReceivedClientCertRequest")) {
super.onReceivedClientCertRequest(webView, clientCertRequest);
}
if (WebPlayerView.this.shouldSendEvent("onReceivedClientCertRequest")) {
if (clientCertRequest != null) {
str = clientCertRequest.getHost();
i10 = clientCertRequest.getPort();
} else {
i10 = -1;
str = "";
}
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.CLIENT_CERT_REQUEST, str, Integer.valueOf(i10), WebPlayerView.this.viewId);
}
}
@Override
public void onReceivedError(WebView webView, int i10, String str, String str2) {
if (WebPlayerView.this.shouldCallSuper("onReceivedError")) {
super.onReceivedError(webView, i10, str, str2);
}
if (WebPlayerView.this.shouldSendEvent("onReceivedError")) {
WebPlayerEventBridge.error(WebPlayerView.this.viewId, str2, str);
}
}
@Override
public void onReceivedError(WebView webView, WebResourceRequest webResourceRequest, WebResourceError webResourceError) {
if (WebPlayerView.this.shouldCallSuper("onReceivedError")) {
super.onReceivedError(webView, webResourceRequest, webResourceError);
}
if (WebPlayerView.this.shouldSendEvent("onReceivedError")) {
String str = "";
String charSequence = (webResourceError == null || webResourceError.getDescription() == null) ? "" : webResourceError.getDescription().toString();
if (webResourceRequest != null && webResourceRequest.getUrl() != null) {
str = webResourceRequest.getUrl().toString();
}
WebPlayerEventBridge.error(WebPlayerView.this.viewId, str, charSequence);
}
}
@Override
public void onReceivedHttpAuthRequest(WebView webView, HttpAuthHandler httpAuthHandler, String str, String str2) {
if (WebPlayerView.this.shouldCallSuper("onReceivedHttpAuthRequest")) {
super.onReceivedHttpAuthRequest(webView, httpAuthHandler, str, str2);
}
if (WebPlayerView.this.shouldSendEvent("onReceivedHttpAuthRequest")) {
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.HTTP_AUTH_REQUEST, str, str2, WebPlayerView.this.viewId);
}
}
@Override
public void onReceivedHttpError(WebView webView, WebResourceRequest webResourceRequest, WebResourceResponse webResourceResponse) {
if (WebPlayerView.this.shouldCallSuper("onReceivedHttpError")) {
super.onReceivedHttpError(webView, webResourceRequest, webResourceResponse);
}
if (WebPlayerView.this.shouldSendEvent("onReceivedHttpError")) {
String str = "";
String uri = (webResourceRequest == null || webResourceRequest.getUrl() == null) ? "" : webResourceRequest.getUrl().toString();
int i10 = -1;
if (webResourceResponse != null) {
i10 = webResourceResponse.getStatusCode();
str = webResourceResponse.getReasonPhrase();
}
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.HTTP_ERROR, uri, str, Integer.valueOf(i10), WebPlayerView.this.viewId);
}
}
@Override
public void onReceivedLoginRequest(WebView webView, String str, String str2, String str3) {
if (WebPlayerView.this.shouldCallSuper("onReceivedLoginRequest")) {
super.onReceivedLoginRequest(webView, str, str2, str3);
}
if (WebPlayerView.this.shouldSendEvent("onReceivedLoginRequest")) {
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.LOGIN_REQUEST, str, str2, str3, WebPlayerView.this.viewId);
}
}
@Override
public void onReceivedSslError(WebView webView, SslErrorHandler sslErrorHandler, SslError sslError) {
super.onReceivedSslError(webView, sslErrorHandler, sslError);
DeviceLog.error("Received SSL error for '%s': %s", sslError.getUrl(), sslError.toString());
if (WebPlayerView.this.shouldSendEvent("onReceivedSslError")) {
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.SSL_ERROR, sslError.getUrl(), WebPlayerView.this.viewId);
}
}
@Override
public boolean onRenderProcessGone(final WebView webView, RenderProcessGoneDetail renderProcessGoneDetail) {
Utilities.runOnUiThread(new Runnable() {
@Override
public void run() {
ViewUtilities.removeViewFromParent(webView);
webView.destroy();
}
});
String str = WebPlayerView.this.viewId;
String url = WebPlayerView.this.getUrl();
StringBuilder w10 = p.w("UnityAds Sdk WebPlayer onRenderProcessGone : ");
w10.append(renderProcessGoneDetail.toString());
WebPlayerEventBridge.error(str, url, w10.toString());
DeviceLog.error("UnityAds Sdk WebPlayer onRenderProcessGone : " + renderProcessGoneDetail.toString());
return true;
}
@Override
public void onScaleChanged(WebView webView, float f10, float f11) {
if (WebPlayerView.this.shouldCallSuper("onScaleChanged")) {
super.onScaleChanged(webView, f10, f11);
}
if (WebPlayerView.this.shouldSendEvent("onScaleChanged")) {
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.SCALE_CHANGED, Float.valueOf(f10), Float.valueOf(f11), WebPlayerView.this.viewId);
}
}
@Override
public void onUnhandledKeyEvent(WebView webView, KeyEvent keyEvent) {
if (WebPlayerView.this.shouldCallSuper("onUnhandledKeyEvent")) {
super.onUnhandledKeyEvent(webView, keyEvent);
}
if (WebPlayerView.this.shouldSendEvent("onUnhandledKeyEvent")) {
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.UNHANDLED_KEY_EVENT, Integer.valueOf(keyEvent.getKeyCode()), Integer.valueOf(keyEvent.getAction()), WebPlayerView.this.viewId);
}
}
@Override
public WebResourceResponse shouldInterceptRequest(WebView webView, WebResourceRequest webResourceRequest) {
WebResourceResponse shouldInterceptRequest = WebPlayerView.this.shouldCallSuper("shouldInterceptRequest") ? super.shouldInterceptRequest(webView, webResourceRequest) : null;
if (WebPlayerView.this.shouldSendEvent("shouldInterceptRequest")) {
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.SHOULD_INTERCEPT_REQUEST, webResourceRequest.getUrl().toString(), WebPlayerView.this.viewId);
}
return shouldInterceptRequest;
}
@Override
public boolean shouldOverrideKeyEvent(WebView webView, KeyEvent keyEvent) {
Boolean bool = Boolean.FALSE;
if (WebPlayerView.this.shouldCallSuper("shouldOverrideKeyEvent")) {
bool = Boolean.valueOf(super.shouldOverrideKeyEvent(webView, keyEvent));
}
if (WebPlayerView.this.shouldSendEvent("shouldOverrideKeyEvent")) {
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.SHOULD_OVERRIDE_KEY_EVENT, Integer.valueOf(keyEvent.getKeyCode()), Integer.valueOf(keyEvent.getAction()), WebPlayerView.this.viewId);
}
if (WebPlayerView.this.hasReturnValue("shouldOverrideKeyEvent")) {
bool = (Boolean) WebPlayerView.this.getReturnValue("shouldOverrideKeyEvent", Boolean.class, Boolean.TRUE);
}
return bool.booleanValue();
}
@Override
public boolean shouldOverrideUrlLoading(WebView webView, WebResourceRequest webResourceRequest) {
Boolean bool = Boolean.FALSE;
if (WebPlayerView.this.shouldCallSuper("shouldOverrideUrlLoading")) {
bool = Boolean.valueOf(super.shouldOverrideUrlLoading(webView, webResourceRequest));
}
if (WebPlayerView.this.shouldSendEvent("shouldOverrideUrlLoading")) {
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.SHOULD_OVERRIDE_URL_LOADING, webResourceRequest.getUrl().toString(), webResourceRequest.getMethod(), WebPlayerView.this.viewId);
}
if (WebPlayerView.this.hasReturnValue("shouldOverrideUrlLoading")) {
bool = (Boolean) WebPlayerView.this.getReturnValue("shouldOverrideUrlLoading", Boolean.class, Boolean.TRUE);
}
return bool.booleanValue();
}
@Override
public boolean shouldOverrideUrlLoading(WebView webView, String str) {
Boolean bool = Boolean.FALSE;
if (WebPlayerView.this.shouldCallSuper("shouldOverrideUrlLoading")) {
bool = Boolean.valueOf(super.shouldOverrideUrlLoading(webView, str));
}
if (WebPlayerView.this.shouldSendEvent("shouldOverrideUrlLoading")) {
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.SHOULD_OVERRIDE_URL_LOADING, str, WebPlayerView.this.viewId);
}
if (WebPlayerView.this.hasReturnValue("shouldOverrideUrlLoading")) {
bool = (Boolean) WebPlayerView.this.getReturnValue("shouldOverrideUrlLoading", Boolean.class, Boolean.TRUE);
}
return bool.booleanValue();
}
}
public class WebPlayerDownloadListener implements DownloadListener {
private WebPlayerDownloadListener() {
}
@Override
public void onDownloadStart(String str, String str2, String str3, String str4, long j10) {
if (WebPlayerView.this.shouldSendEvent("onDownloadStart")) {
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.DOWNLOAD_START, str, str2, str3, str4, Long.valueOf(j10), WebPlayerView.this.viewId);
}
}
}
public WebPlayerView(Context context, String str, JSONObject jSONObject, JSONObject jSONObject2) {
super(context);
this._evaluateJavascript = null;
this._unsubscribeLayoutChange = null;
this.viewId = str;
WebSettings settings = getSettings();
settings.setAllowFileAccessFromFileURLs(false);
settings.setAllowUniversalAccessFromFileURLs(false);
try {
this._evaluateJavascript = WebView.class.getMethod("evaluateJavascript", String.class, ValueCallback.class);
} catch (NoSuchMethodException e10) {
DeviceLog.exception("Method evaluateJavascript not found", e10);
this._evaluateJavascript = null;
}
settings.setCacheMode(2);
settings.setDatabaseEnabled(false);
settings.setDomStorageEnabled(false);
settings.setGeolocationEnabled(false);
settings.setJavaScriptEnabled(true);
settings.setLoadsImagesAutomatically(true);
settings.setPluginState(WebSettings.PluginState.OFF);
settings.setRenderPriority(WebSettings.RenderPriority.NORMAL);
settings.setSaveFormData(false);
settings.setSavePassword(false);
setHorizontalScrollBarEnabled(false);
setVerticalScrollBarEnabled(false);
setInitialScale(0);
setBackgroundColor(0);
ViewUtilities.setBackground(this, new ColorDrawable(0));
setBackgroundResource(0);
setSettings(jSONObject, jSONObject2);
setWebViewClient(new WebPlayerClient());
setWebChromeClient(new WebPlayerChromeClient());
setDownloadListener(new WebPlayerDownloadListener());
addJavascriptInterface(new WebPlayerBridgeInterface(str), "webplayerbridge");
WebPlayerViewCache.getInstance().addWebPlayer(str, this);
subscribeOnLayoutChange();
}
private void addErroredSetting(String str, String str2) {
if (this._erroredSettings == null) {
this._erroredSettings = new HashMap();
}
this._erroredSettings.put(str, str2);
}
public <T> T getReturnValue(String str, Class<T> cls, T t10) {
try {
JSONObject jSONObject = this._eventSettings;
if (jSONObject != null && jSONObject.has(str) && this._eventSettings.getJSONObject(str).has("returnValue")) {
return cls.cast(this._eventSettings.getJSONObject(str).get("returnValue"));
}
} catch (Exception e10) {
DeviceLog.exception("Error getting default return value", e10);
}
return t10;
}
private Class<?>[] getTypes(JSONArray jSONArray) {
if (jSONArray == null) {
return null;
}
Class<?>[] clsArr = new Class[jSONArray.length()];
for (int i10 = 0; i10 < jSONArray.length(); i10++) {
if (jSONArray.get(i10) instanceof JSONObject) {
clsArr[i10] = Class.forName(((JSONObject) jSONArray.get(i10)).getString("className"));
} else {
clsArr[i10] = getPrimitiveClass(jSONArray.get(i10).getClass());
}
}
return clsArr;
}
private Object[] getValues(JSONArray jSONArray) {
if (jSONArray == null) {
return null;
}
Object[] objArr = new Object[jSONArray.length()];
Object[] objArr2 = new Object[jSONArray.length()];
for (int i10 = 0; i10 < jSONArray.length(); i10++) {
if (jSONArray.get(i10) instanceof JSONObject) {
JSONObject jSONObject = (JSONObject) jSONArray.get(i10);
Object obj = jSONObject.get("value");
String string = jSONObject.getString("type");
String string2 = jSONObject.has("className") ? jSONObject.getString("className") : null;
if (string2 != null && string.equals("Enum")) {
objArr2[i10] = Enum.valueOf(Class.forName(string2), (String) obj);
}
} else {
objArr2[i10] = jSONArray.get(i10);
}
}
System.arraycopy(objArr2, 0, objArr, 0, jSONArray.length());
return objArr;
}
public boolean hasReturnValue(String str) {
try {
JSONObject jSONObject = this._eventSettings;
if (jSONObject == null || !jSONObject.has(str)) {
return false;
}
return this._eventSettings.getJSONObject(str).has("returnValue");
} catch (Exception e10) {
DeviceLog.exception("Error getting default return value", e10);
return false;
}
}
private Object setTargetSettings(Object obj, JSONObject jSONObject) {
if (jSONObject != null) {
Iterator<String> keys = jSONObject.keys();
while (keys.hasNext()) {
String next = keys.next();
try {
JSONArray jSONArray = jSONObject.getJSONArray(next);
obj.getClass().getMethod(next, getTypes(jSONArray)).invoke(obj, getValues(jSONArray));
} catch (Exception e10) {
addErroredSetting(next, e10.getMessage());
DeviceLog.exception("Setting errored", e10);
}
}
}
return obj;
}
public boolean shouldCallSuper(String str) {
try {
JSONObject jSONObject = this._eventSettings;
if (jSONObject != null && jSONObject.has(str) && this._eventSettings.getJSONObject(str).has("callSuper")) {
return this._eventSettings.getJSONObject(str).getBoolean("callSuper");
}
return true;
} catch (Exception e10) {
DeviceLog.exception("Error getting super call status", e10);
return true;
}
}
public boolean shouldSendEvent(String str) {
try {
JSONObject jSONObject = this._eventSettings;
if (jSONObject != null && jSONObject.has(str) && this._eventSettings.getJSONObject(str).has("sendEvent")) {
return this._eventSettings.getJSONObject(str).getBoolean("sendEvent");
}
return false;
} catch (Exception e10) {
DeviceLog.exception("Error getting send event status", e10);
return false;
}
}
private void subscribeOnLayoutChange() {
Runnable runnable = this._unsubscribeLayoutChange;
if (runnable != null) {
runnable.run();
}
final View.OnLayoutChangeListener onLayoutChangeListener = new View.OnLayoutChangeListener() {
@Override
public void onLayoutChange(View view, int i10, int i11, int i12, int i13, int i14, int i15, int i16, int i17) {
WebPlayerView.this.onLayoutChange();
}
};
addOnLayoutChangeListener(onLayoutChangeListener);
this._unsubscribeLayoutChange = new Runnable() {
@Override
public void run() {
WebPlayerView.this.removeOnLayoutChangeListener(onLayoutChangeListener);
}
};
}
@Override
public void destroy() {
super.destroy();
WebPlayerViewCache.getInstance().removeWebPlayer(this.viewId);
Runnable runnable = this._unsubscribeLayoutChange;
if (runnable != null) {
runnable.run();
}
}
public Map<String, String> getErroredSettings() {
return this._erroredSettings;
}
public Class<?> getPrimitiveClass(Class<?> cls) {
String name = cls.getName();
return name.equals("java.lang.Byte") ? Byte.TYPE : name.equals("java.lang.Short") ? Short.TYPE : name.equals("java.lang.Integer") ? Integer.TYPE : name.equals("java.lang.Long") ? Long.TYPE : name.equals("java.lang.Character") ? Character.TYPE : name.equals("java.lang.Float") ? Float.TYPE : name.equals("java.lang.Double") ? Double.TYPE : name.equals("java.lang.Boolean") ? Boolean.TYPE : name.equals("java.lang.Void") ? Void.TYPE : cls;
}
public void invokeJavascript(String str) {
Utilities.runOnUiThread(new JavaScriptInvocation(str, this));
}
public void onLayoutChange() {
int[] iArr = new int[2];
getLocationOnScreen(iArr);
WebPlayerEventBridge.sendFrameUpdate(this.viewId, iArr[0], iArr[1], getWidth(), getHeight(), getAlpha());
}
@Override
public void onSizeChanged(int i10, int i11, int i12, int i13) {
super.onSizeChanged(i10, i11, i12, i13);
onLayoutChange();
}
public void sendEvent(JSONArray jSONArray) {
StringBuilder w10 = p.w("javascript:window.nativebridge.receiveEvent(");
w10.append(jSONArray.toString());
w10.append(")");
invokeJavascript(w10.toString());
}
public void setEventSettings(JSONObject jSONObject) {
this._eventSettings = jSONObject;
}
public void setSettings(JSONObject jSONObject, JSONObject jSONObject2) {
Map<String, String> map = this._erroredSettings;
if (map != null) {
map.clear();
}
setTargetSettings(getSettings(), jSONObject);
setTargetSettings(this, jSONObject2);
}
}