Initial commit

This commit is contained in:
2025-05-13 19:24:51 +02:00
commit a950f49678
10604 changed files with 932663 additions and 0 deletions

View File

@@ -0,0 +1,114 @@
package com.unity3d.ads.webview;
import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.os.Build;
import android.webkit.ValueCallback;
import android.webkit.WebSettings;
import com.unity3d.ads.log.DeviceLog;
import com.unity3d.ads.misc.Utilities;
import com.unity3d.ads.misc.ViewUtilities;
import com.unity3d.ads.webview.bridge.WebViewBridgeInterface;
import java.lang.reflect.Method;
/* loaded from: classes2.dex */
public class WebView extends android.webkit.WebView {
private static Method _evaluateJavascript;
private class JavaScriptInvocation implements Runnable {
private String _jsString;
private android.webkit.WebView _webView;
public JavaScriptInvocation(String str, android.webkit.WebView webView) {
this._jsString = null;
this._webView = null;
this._jsString = str;
this._webView = webView;
}
@Override // java.lang.Runnable
public void run() {
String str = this._jsString;
if (str == null) {
DeviceLog.error("Could not process JavaScript, the string is NULL");
return;
}
try {
if (Build.VERSION.SDK_INT >= 19) {
WebView._evaluateJavascript.invoke(this._webView, this._jsString, null);
} else {
WebView.this.loadUrl(str);
}
} catch (Exception e) {
DeviceLog.exception("Error while processing JavaScriptString", e);
}
}
}
public WebView(Context context) {
super(context);
WebSettings settings = getSettings();
if (Build.VERSION.SDK_INT >= 16) {
settings.setAllowFileAccessFromFileURLs(true);
settings.setAllowUniversalAccessFromFileURLs(true);
}
if (Build.VERSION.SDK_INT >= 19) {
try {
_evaluateJavascript = android.webkit.WebView.class.getMethod("evaluateJavascript", String.class, ValueCallback.class);
} catch (NoSuchMethodException e) {
DeviceLog.exception("Method evaluateJavascript not found", e);
_evaluateJavascript = null;
}
}
settings.setAppCacheEnabled(false);
settings.setBlockNetworkImage(false);
settings.setBlockNetworkLoads(false);
settings.setBuiltInZoomControls(false);
settings.setCacheMode(2);
settings.setDatabaseEnabled(false);
if (Build.VERSION.SDK_INT >= 11) {
settings.setDisplayZoomControls(false);
}
settings.setDomStorageEnabled(false);
if (Build.VERSION.SDK_INT >= 11) {
settings.setEnableSmoothTransition(false);
}
settings.setGeolocationEnabled(false);
settings.setJavaScriptCanOpenWindowsAutomatically(false);
settings.setJavaScriptEnabled(true);
settings.setLightTouchEnabled(false);
settings.setLoadWithOverviewMode(false);
settings.setLoadsImagesAutomatically(true);
if (Build.VERSION.SDK_INT >= 17) {
settings.setMediaPlaybackRequiresUserGesture(false);
}
if (Build.VERSION.SDK_INT >= 21) {
settings.setMixedContentMode(1);
}
settings.setNeedInitialFocus(true);
settings.setPluginState(WebSettings.PluginState.OFF);
settings.setRenderPriority(WebSettings.RenderPriority.NORMAL);
settings.setSaveFormData(false);
settings.setSavePassword(false);
settings.setSupportMultipleWindows(false);
settings.setSupportZoom(false);
settings.setUseWideViewPort(true);
setHorizontalScrollBarEnabled(false);
setVerticalScrollBarEnabled(false);
setInitialScale(0);
setBackgroundColor(0);
ViewUtilities.setBackground(this, new ColorDrawable(0));
setBackgroundResource(0);
addJavascriptInterface(new WebViewBridgeInterface(), "webviewbridge");
}
public void invokeJavascript(String str) {
Utilities.runOnUiThread(new JavaScriptInvocation(str, this));
}
@Override // android.webkit.WebView
public void loadUrl(String str) {
DeviceLog.debug("Loading url: " + str);
super.loadUrl(str);
}
}

View File

@@ -0,0 +1,320 @@
package com.unity3d.ads.webview;
import android.os.Build;
import android.os.ConditionVariable;
import android.os.Looper;
import android.webkit.WebChromeClient;
import android.webkit.WebResourceError;
import android.webkit.WebResourceRequest;
import android.webkit.WebViewClient;
import com.unity3d.ads.configuration.Configuration;
import com.unity3d.ads.log.DeviceLog;
import com.unity3d.ads.misc.Utilities;
import com.unity3d.ads.properties.ClientProperties;
import com.unity3d.ads.properties.SdkProperties;
import com.unity3d.ads.webview.bridge.CallbackStatus;
import com.unity3d.ads.webview.bridge.Invocation;
import com.unity3d.ads.webview.bridge.NativeCallback;
import com.unity3d.ads.webview.bridge.WebViewBridge;
import java.io.File;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Method;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import org.json.JSONArray;
import org.json.JSONException;
/* loaded from: classes2.dex */
public class WebViewApp extends WebViewClient {
private static final int INVOKE_JS_CHARS_LENGTH = 22;
private static ConditionVariable _conditionVariable;
private static WebViewApp _currentApp;
private Configuration _configuration;
private boolean _initialized;
private HashMap<String, NativeCallback> _nativeCallbacks;
private boolean _webAppLoaded;
private WebView _webView;
private class WebAppChromeClient extends WebChromeClient {
private WebAppChromeClient() {
}
@Override // android.webkit.WebChromeClient
public void onConsoleMessage(String str, int i, String str2) {
File file;
try {
file = new File(str2);
} catch (Exception e) {
DeviceLog.exception("Could not handle sourceId", e);
file = null;
}
if (file != null) {
str2 = file.getName();
}
if (Build.VERSION.SDK_INT < 19) {
DeviceLog.debug("JavaScript (sourceId=" + str2 + ", line=" + i + "): " + str);
}
}
}
private class WebAppClient extends WebViewClient {
private WebAppClient() {
}
@Override // android.webkit.WebViewClient
public void onPageFinished(android.webkit.WebView webView, String str) {
super.onPageFinished(webView, str);
DeviceLog.debug("onPageFinished url: " + str);
}
@Override // android.webkit.WebViewClient
public void onReceivedError(android.webkit.WebView webView, WebResourceRequest webResourceRequest, WebResourceError webResourceError) {
super.onReceivedError(webView, webResourceRequest, webResourceError);
if (webView != null) {
DeviceLog.error("WEBVIEW_ERROR: " + webView.toString());
}
if (webResourceRequest != null) {
DeviceLog.error("WEBVIEW_ERROR: " + webResourceRequest.toString());
}
if (webResourceError != null) {
DeviceLog.error("WEBVIEW_ERROR: " + webResourceError.toString());
}
}
@Override // android.webkit.WebViewClient
public boolean shouldOverrideUrlLoading(android.webkit.WebView webView, String str) {
DeviceLog.debug("Trying to load url: " + str);
return false;
}
}
public static boolean create(final Configuration configuration) throws IllegalThreadStateException {
DeviceLog.entered();
if (Thread.currentThread().equals(Looper.getMainLooper().getThread())) {
throw new IllegalThreadStateException("Cannot call create() from main thread!");
}
Utilities.runOnUiThread(new Runnable() { // from class: com.unity3d.ads.webview.WebViewApp.1
@Override // java.lang.Runnable
public void run() {
try {
WebViewApp webViewApp = new WebViewApp(Configuration.this);
String str = "?platform=android";
try {
if (Configuration.this.getWebViewUrl() != null) {
str = "?platform=android&origin=" + URLEncoder.encode(Configuration.this.getWebViewUrl(), "UTF-8");
}
} catch (UnsupportedEncodingException e) {
DeviceLog.exception("Unsupported charset when encoding origin url", e);
}
try {
if (Configuration.this.getWebViewVersion() != null) {
str = str + "&version=" + URLEncoder.encode(Configuration.this.getWebViewVersion(), "UTF-8");
}
} catch (UnsupportedEncodingException e2) {
DeviceLog.exception("Unsupported charset when encoding webview version", e2);
}
webViewApp.getWebView().loadDataWithBaseURL("file://" + SdkProperties.getLocalWebViewFile() + str, Configuration.this.getWebViewData(), "text/html", "UTF-8", null);
WebViewApp.setCurrentApp(webViewApp);
} catch (Exception unused) {
DeviceLog.error("Couldn't construct WebViewApp");
WebViewApp._conditionVariable.open();
}
}
});
_conditionVariable = new ConditionVariable();
return _conditionVariable.block(60000L) && getCurrentApp() != null;
}
public static WebViewApp getCurrentApp() {
return _currentApp;
}
private void invokeJavascriptMethod(String str, String str2, JSONArray jSONArray) throws JSONException {
String jSONArray2 = jSONArray.toString();
StringBuilder sb = new StringBuilder(str.length() + 22 + str2.length() + jSONArray2.length());
sb.append("javascript:window.");
sb.append(str);
sb.append(".");
sb.append(str2);
sb.append("(");
sb.append(jSONArray2);
sb.append(");");
String sb2 = sb.toString();
DeviceLog.debug("Invoking javascript: " + sb2);
getWebView().invokeJavascript(sb2);
}
public static void setCurrentApp(WebViewApp webViewApp) {
_currentApp = webViewApp;
}
public void addCallback(NativeCallback nativeCallback) {
if (this._nativeCallbacks == null) {
this._nativeCallbacks = new HashMap<>();
}
synchronized (this._nativeCallbacks) {
this._nativeCallbacks.put(nativeCallback.getId(), nativeCallback);
}
}
public NativeCallback getCallback(String str) {
NativeCallback nativeCallback;
synchronized (this._nativeCallbacks) {
nativeCallback = this._nativeCallbacks.get(str);
}
return nativeCallback;
}
public Configuration getConfiguration() {
return this._configuration;
}
public WebView getWebView() {
return this._webView;
}
public boolean invokeCallback(Invocation invocation) {
if (!isWebAppLoaded()) {
DeviceLog.debug("invokeBatchCallback ignored because web app is not loaded");
return false;
}
JSONArray jSONArray = new JSONArray();
ArrayList<ArrayList<Object>> responses = invocation.getResponses();
if (responses != null && !responses.isEmpty()) {
Iterator<ArrayList<Object>> it = responses.iterator();
while (it.hasNext()) {
ArrayList<Object> next = it.next();
CallbackStatus callbackStatus = (CallbackStatus) next.get(0);
Enum r5 = (Enum) next.get(1);
Object[] objArr = (Object[]) next.get(2);
String str = (String) objArr[0];
Object[] copyOfRange = Arrays.copyOfRange(objArr, 1, objArr.length);
ArrayList arrayList = new ArrayList();
arrayList.add(str);
arrayList.add(callbackStatus.toString());
JSONArray jSONArray2 = new JSONArray();
if (r5 != null) {
jSONArray2.put(r5.name());
}
for (Object obj : copyOfRange) {
jSONArray2.put(obj);
}
arrayList.add(jSONArray2);
JSONArray jSONArray3 = new JSONArray();
Iterator it2 = arrayList.iterator();
while (it2.hasNext()) {
jSONArray3.put(it2.next());
}
jSONArray.put(jSONArray3);
}
}
try {
invokeJavascriptMethod("nativebridge", "handleCallback", jSONArray);
} catch (Exception e) {
DeviceLog.exception("Error while invoking batch response for WebView", e);
}
return true;
}
public boolean invokeMethod(String str, String str2, Method method, Object... objArr) {
if (!isWebAppLoaded()) {
DeviceLog.debug("invokeMethod ignored because web app is not loaded");
return false;
}
JSONArray jSONArray = new JSONArray();
jSONArray.put(str);
jSONArray.put(str2);
if (method != null) {
NativeCallback nativeCallback = new NativeCallback(method);
addCallback(nativeCallback);
jSONArray.put(nativeCallback.getId());
} else {
jSONArray.put((Object) null);
}
if (objArr != null) {
for (Object obj : objArr) {
jSONArray.put(obj);
}
}
try {
invokeJavascriptMethod("nativebridge", "handleInvocation", jSONArray);
return true;
} catch (Exception e) {
DeviceLog.exception("Error invoking javascript method", e);
return false;
}
}
public boolean isWebAppInitialized() {
return this._initialized;
}
public boolean isWebAppLoaded() {
return this._webAppLoaded;
}
public void removeCallback(NativeCallback nativeCallback) {
HashMap<String, NativeCallback> hashMap = this._nativeCallbacks;
if (hashMap == null) {
return;
}
synchronized (hashMap) {
this._nativeCallbacks.remove(nativeCallback.getId());
}
}
public boolean sendEvent(Enum r4, Enum r5, Object... objArr) {
if (!isWebAppLoaded()) {
DeviceLog.debug("sendEvent ignored because web app is not loaded");
return false;
}
JSONArray jSONArray = new JSONArray();
jSONArray.put(r4.name());
jSONArray.put(r5.name());
for (Object obj : objArr) {
jSONArray.put(obj);
}
try {
invokeJavascriptMethod("nativebridge", "handleEvent", jSONArray);
return true;
} catch (Exception e) {
DeviceLog.exception("Error while sending event to WebView", e);
return false;
}
}
public void setConfiguration(Configuration configuration) {
this._configuration = configuration;
}
public void setWebAppInitialized(boolean z) {
this._initialized = z;
_conditionVariable.open();
}
public void setWebAppLoaded(boolean z) {
this._webAppLoaded = z;
}
public void setWebView(WebView webView) {
this._webView = webView;
}
private WebViewApp(Configuration configuration) {
this._webAppLoaded = false;
this._initialized = false;
setConfiguration(configuration);
WebViewBridge.setClassTable(getConfiguration().getWebAppApiClassList());
this._webView = new WebView(ClientProperties.getApplicationContext());
this._webView.setWebViewClient(new WebAppClient());
this._webView.setWebChromeClient(new WebAppChromeClient());
}
public WebViewApp() {
this._webAppLoaded = false;
this._initialized = false;
}
}

View File

@@ -0,0 +1,17 @@
package com.unity3d.ads.webview;
/* loaded from: classes2.dex */
public enum WebViewEventCategory {
ADUNIT,
VIDEOPLAYER,
REQUEST,
RESOLVE,
CACHE,
CONNECTIVITY,
STORAGE,
BROADCAST,
LIFECYCLE,
DEVICEINFO,
WEBPLAYER,
PURCHASING
}

View File

@@ -0,0 +1,7 @@
package com.unity3d.ads.webview.bridge;
/* loaded from: classes2.dex */
public enum CallbackStatus {
OK,
ERROR
}

View File

@@ -0,0 +1,83 @@
package com.unity3d.ads.webview.bridge;
import com.unity3d.ads.log.DeviceLog;
import com.unity3d.ads.webview.WebViewApp;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
/* loaded from: classes2.dex */
public class Invocation {
private static AtomicInteger _idCount = new AtomicInteger(0);
private static Map<Integer, Invocation> _invocationSets;
private int _invocationId = _idCount.getAndIncrement();
private ArrayList<ArrayList<Object>> _invocations;
private ArrayList<ArrayList<Object>> _responses;
public Invocation() {
if (_invocationSets == null) {
_invocationSets = new HashMap();
}
_invocationSets.put(Integer.valueOf(this._invocationId), this);
}
public static synchronized Invocation getInvocationById(int i) {
synchronized (Invocation.class) {
if (_invocationSets == null || !_invocationSets.containsKey(Integer.valueOf(i))) {
return null;
}
return _invocationSets.get(Integer.valueOf(i));
}
}
public void addInvocation(String str, String str2, Object[] objArr, WebViewCallback webViewCallback) {
if (this._invocations == null) {
this._invocations = new ArrayList<>();
}
ArrayList<Object> arrayList = new ArrayList<>();
arrayList.add(str);
arrayList.add(str2);
arrayList.add(objArr);
arrayList.add(webViewCallback);
this._invocations.add(arrayList);
}
public int getId() {
return this._invocationId;
}
public ArrayList<ArrayList<Object>> getResponses() {
return this._responses;
}
public boolean nextInvocation() {
ArrayList<ArrayList<Object>> arrayList = this._invocations;
if (arrayList == null || arrayList.size() <= 0) {
return false;
}
ArrayList<Object> remove = this._invocations.remove(0);
try {
WebViewBridge.handleInvocation((String) remove.get(0), (String) remove.get(1), (Object[]) remove.get(2), (WebViewCallback) remove.get(3));
} catch (Exception e) {
DeviceLog.exception("Error handling invocation", e);
}
return true;
}
public void sendInvocationCallback() {
_invocationSets.remove(Integer.valueOf(getId()));
WebViewApp.getCurrentApp().invokeCallback(this);
}
public void setInvocationResponse(CallbackStatus callbackStatus, Enum r3, Object... objArr) {
if (this._responses == null) {
this._responses = new ArrayList<>();
}
ArrayList<Object> arrayList = new ArrayList<>();
arrayList.add(callbackStatus);
arrayList.add(r3);
arrayList.add(objArr);
this._responses.add(arrayList);
}
}

View File

@@ -0,0 +1,46 @@
package com.unity3d.ads.webview.bridge;
import com.unity3d.ads.log.DeviceLog;
import com.unity3d.ads.webview.WebViewApp;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Locale;
import java.util.concurrent.atomic.AtomicInteger;
/* loaded from: classes2.dex */
public class NativeCallback {
private static AtomicInteger _callbackCount = new AtomicInteger(0);
private Method _callback;
private String _id;
public NativeCallback(Method method) {
this._callback = method;
this._id = this._callback.getName().toUpperCase(Locale.US) + "_" + _callbackCount.getAndIncrement();
}
public String getId() {
return this._id;
}
public void invoke(String str, Object... objArr) throws InvocationTargetException, IllegalAccessException, IllegalArgumentException {
Object[] array;
try {
CallbackStatus valueOf = CallbackStatus.valueOf(str);
if (objArr == null) {
array = new Object[]{valueOf};
} else {
ArrayList arrayList = new ArrayList(Arrays.asList(objArr));
arrayList.add(0, valueOf);
array = arrayList.toArray();
}
this._callback.invoke(null, array);
WebViewApp.getCurrentApp().removeCallback(this);
} catch (Exception e) {
DeviceLog.error("Illegal status");
WebViewApp.getCurrentApp().removeCallback(this);
throw e;
}
}
}

View File

@@ -0,0 +1,100 @@
package com.unity3d.ads.webview.bridge;
import com.unity3d.ads.BuildConfig;
import com.unity3d.ads.log.DeviceLog;
import com.unity3d.ads.webview.WebViewApp;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.HashMap;
import org.json.JSONException;
/* loaded from: classes2.dex */
public class WebViewBridge {
private static HashMap<String, HashMap<String, HashMap<Integer, Method>>> _classTable;
private static Method findMethod(String str, String str2, Object[] objArr) throws JSONException, NoSuchMethodException {
if (!_classTable.containsKey(str)) {
throw new NoSuchMethodException();
}
HashMap<String, HashMap<Integer, Method>> hashMap = _classTable.get(str);
if (hashMap.containsKey(str2)) {
return hashMap.get(str2).get(Integer.valueOf(Arrays.deepHashCode(getTypes(objArr))));
}
throw new NoSuchMethodException();
}
private static Class<?>[] getTypes(Object[] objArr) throws JSONException {
Class<?>[] clsArr = objArr == null ? new Class[1] : new Class[objArr.length + 1];
if (objArr != null) {
for (int i = 0; i < objArr.length; i++) {
clsArr[i] = objArr[i].getClass();
}
}
clsArr[clsArr.length - 1] = WebViewCallback.class;
return clsArr;
}
private static Object[] getValues(Object[] objArr, WebViewCallback webViewCallback) throws JSONException {
Object[] objArr2;
if (objArr != null) {
objArr2 = new Object[objArr.length + (webViewCallback != null ? 1 : 0)];
} else {
if (webViewCallback == null) {
return null;
}
objArr2 = new Object[1];
}
if (objArr != null) {
System.arraycopy(objArr, 0, objArr2, 0, objArr.length);
}
if (webViewCallback != null) {
objArr2[objArr2.length - 1] = webViewCallback;
}
return objArr2;
}
public static void handleCallback(String str, String str2, Object[] objArr) throws Exception {
try {
WebViewApp.getCurrentApp().getCallback(str).invoke(str2, getValues(objArr, null));
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | JSONException e) {
DeviceLog.error("Error while invoking method");
throw e;
}
}
public static void handleInvocation(String str, String str2, Object[] objArr, WebViewCallback webViewCallback) throws Exception {
try {
try {
findMethod(str, str2, objArr).invoke(null, getValues(objArr, webViewCallback));
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | JSONException e) {
webViewCallback.error(WebViewBridgeError.INVOCATION_FAILED, str, str2, objArr, e.getMessage());
throw e;
}
} catch (NoSuchMethodException | JSONException e2) {
webViewCallback.error(WebViewBridgeError.METHOD_NOT_FOUND, str, str2, objArr);
throw e2;
}
}
public static void setClassTable(Class[] clsArr) {
if (clsArr == null) {
return;
}
_classTable = new HashMap<>();
for (Class cls : clsArr) {
if (cls != null && cls.getPackage().getName().startsWith(BuildConfig.APPLICATION_ID)) {
HashMap<String, HashMap<Integer, Method>> hashMap = new HashMap<>();
for (Method method : cls.getMethods()) {
if (method.getAnnotation(WebViewExposed.class) != null) {
String name = method.getName();
HashMap<Integer, Method> hashMap2 = hashMap.containsKey(name) ? hashMap.get(name) : new HashMap<>();
hashMap2.put(Integer.valueOf(Arrays.deepHashCode(method.getParameterTypes())), method);
hashMap.put(name, hashMap2);
}
}
_classTable.put(cls.getName(), hashMap);
}
}
}
}

View File

@@ -0,0 +1,15 @@
package com.unity3d.ads.webview.bridge;
/* loaded from: classes2.dex */
public enum WebViewBridgeError {
CLASS_NOT_FOUND,
CLASS_NOT_EXPOSED,
GETALLOWEDMETHODS_NOT_FOUND,
GETALLOWEDMETHODS_INVOCATION_FAILED,
METHOD_NOT_FOUND,
METHOD_UNALLOWED,
DATA_JSON_PARSE_FAILED,
DATA_GET_PARAMETER_VALUE_FAILED,
DATA_PARAMETER_NULL,
INVOCATION_FAILED
}

View File

@@ -0,0 +1,48 @@
package com.unity3d.ads.webview.bridge;
import android.webkit.JavascriptInterface;
import com.unity3d.ads.log.DeviceLog;
import org.json.JSONArray;
import org.json.JSONException;
/* loaded from: classes2.dex */
public class WebViewBridgeInterface {
private Object[] getParameters(JSONArray jSONArray) throws JSONException {
Object[] objArr = new Object[jSONArray.length()];
for (int i = 0; i < jSONArray.length(); i++) {
objArr[i] = jSONArray.get(i);
}
return objArr;
}
@JavascriptInterface
public void handleCallback(String str, String str2, String str3) throws Exception {
Object[] objArr;
DeviceLog.debug("handleCallback " + str + " " + str2 + " " + str3);
JSONArray jSONArray = new JSONArray(str3);
if (jSONArray.length() > 0) {
objArr = new Object[jSONArray.length()];
for (int i = 0; i < jSONArray.length(); i++) {
objArr[i] = jSONArray.get(i);
}
} else {
objArr = null;
}
WebViewBridge.handleCallback(str, str2, objArr);
}
@JavascriptInterface
public void handleInvocation(String str) throws JSONException {
DeviceLog.debug("handleInvocation " + str);
JSONArray jSONArray = new JSONArray(str);
Invocation invocation = new Invocation();
for (int i = 0; i < jSONArray.length(); i++) {
JSONArray jSONArray2 = (JSONArray) jSONArray.get(i);
invocation.addInvocation((String) jSONArray2.get(0), (String) jSONArray2.get(1), getParameters((JSONArray) jSONArray2.get(2)), new WebViewCallback((String) jSONArray2.get(3), invocation.getId()));
}
for (int i2 = 0; i2 < jSONArray.length(); i2++) {
invocation.nextInvocation();
}
invocation.sendInvocationCallback();
}
}

View File

@@ -0,0 +1,83 @@
package com.unity3d.ads.webview.bridge;
import android.os.Parcel;
import android.os.Parcelable;
import com.unity3d.ads.log.DeviceLog;
import java.util.ArrayList;
import java.util.Arrays;
/* loaded from: classes2.dex */
public class WebViewCallback implements Parcelable {
public static final Parcelable.Creator<WebViewCallback> CREATOR = new Parcelable.Creator<WebViewCallback>() { // from class: com.unity3d.ads.webview.bridge.WebViewCallback.1
/* JADX WARN: Can't rename method to resolve collision */
@Override // android.os.Parcelable.Creator
public WebViewCallback createFromParcel(Parcel parcel) {
return new WebViewCallback(parcel);
}
/* JADX WARN: Can't rename method to resolve collision */
@Override // android.os.Parcelable.Creator
public WebViewCallback[] newArray(int i) {
return new WebViewCallback[i];
}
};
private String _callbackId;
private int _invocationId;
private boolean _invoked;
public WebViewCallback(String str, int i) {
this._callbackId = str;
this._invocationId = i;
}
@Override // android.os.Parcelable
public int describeContents() {
return 45678;
}
public void error(Enum r2, Object... objArr) {
invoke(CallbackStatus.ERROR, r2, objArr);
}
public String getCallbackId() {
return this._callbackId;
}
public int getInvocationId() {
return this._invocationId;
}
public void invoke(Object... objArr) {
invoke(CallbackStatus.OK, null, objArr);
}
@Override // android.os.Parcelable
public void writeToParcel(Parcel parcel, int i) {
parcel.writeString(this._callbackId);
parcel.writeByte(this._invoked ? (byte) 1 : (byte) 0);
parcel.writeInt(this._invocationId);
}
private void invoke(CallbackStatus callbackStatus, Enum r4, Object... objArr) {
String str;
if (this._invoked || (str = this._callbackId) == null || str.length() == 0) {
return;
}
this._invoked = true;
ArrayList arrayList = new ArrayList();
arrayList.addAll(Arrays.asList(objArr));
arrayList.add(0, this._callbackId);
Invocation invocationById = Invocation.getInvocationById(this._invocationId);
if (invocationById != null) {
invocationById.setInvocationResponse(callbackStatus, r4, arrayList.toArray());
return;
}
DeviceLog.error("Couldn't get batch with id: " + getInvocationId());
}
public WebViewCallback(Parcel parcel) {
this._callbackId = parcel.readString();
this._invoked = parcel.readByte() != 0;
this._invocationId = parcel.readInt();
}
}

View File

@@ -0,0 +1,12 @@
package com.unity3d.ads.webview.bridge;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target({ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
/* loaded from: classes2.dex */
public @interface WebViewExposed {
}