Add decompiled APK source code (JADX)

- 28,932 files
- Full Java source code
- Smali files
- Resources

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
2026-02-18 14:52:23 -08:00
parent cc210a65ea
commit f9d20bb3fc
26991 changed files with 2541449 additions and 0 deletions

View File

@@ -0,0 +1,152 @@
package com.unity3d.services.ads.adunit;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.KeyEvent;
import com.unity3d.services.core.webview.bridge.SharedInstances;
import java.util.ArrayList;
import java.util.Map;
/* loaded from: classes4.dex */
public class AdUnitActivity extends Activity implements IAdUnitActivity {
public static final String EXTRA_ACTIVITY_ID = "activityId";
public static final String EXTRA_DISPLAY_CUTOUT_MODE = "displayCutoutMode";
public static final String EXTRA_KEEP_SCREEN_ON = "keepScreenOn";
public static final String EXTRA_KEY_EVENT_LIST = "keyEvents";
public static final String EXTRA_ORIENTATION = "orientation";
public static final String EXTRA_SYSTEM_UI_VISIBILITY = "systemUiVisibility";
public static final String EXTRA_VIEWS = "views";
protected AdUnitActivityController _controller;
@Override // com.unity3d.services.ads.adunit.IAdUnitActivity
public Activity getActivity() {
return this;
}
@Override // com.unity3d.services.ads.adunit.IAdUnitActivity
public Context getContext() {
return this;
}
public AdUnitActivityController createController() {
return new AdUnitActivityController(this, SharedInstances.INSTANCE.getWebViewEventSender(), new AdUnitViewHandlerFactory());
}
@Override // android.app.Activity
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
AdUnitActivityController createController = createController();
this._controller = createController;
createController.onCreate(bundle);
}
@Override // com.unity3d.services.ads.adunit.IAdUnitActivity
public AdUnitRelativeLayout getLayout() {
return this._controller.getLayout();
}
@Override // android.app.Activity
public void onStart() {
super.onStart();
this._controller.onStart();
}
@Override // android.app.Activity
public void onStop() {
super.onStop();
this._controller.onStop();
}
@Override // android.app.Activity
public void onResume() {
super.onResume();
this._controller.onResume();
}
@Override // android.app.Activity
public void onPause() {
super.onPause();
this._controller.onPause();
}
@Override // android.app.Activity
public void onSaveInstanceState(Bundle bundle) {
super.onSaveInstanceState(bundle);
this._controller.onSaveInstanceState(bundle);
}
@Override // android.app.Activity
public void onDestroy() {
AdUnitActivityController adUnitActivityController = this._controller;
if (adUnitActivityController != null) {
adUnitActivityController.onDestroy();
}
super.onDestroy();
}
@Override // android.app.Activity, android.view.KeyEvent.Callback
public boolean onKeyDown(int i, KeyEvent keyEvent) {
return this._controller.onKeyDown(i, keyEvent);
}
@Override // android.app.Activity, android.view.Window.Callback
public void onWindowFocusChanged(boolean z) {
this._controller.onWindowFocusChanged(z);
super.onWindowFocusChanged(z);
}
@Override // android.app.Activity
public void onRequestPermissionsResult(int i, String[] strArr, int[] iArr) {
this._controller.onRequestPermissionsResult(i, strArr, iArr);
}
@Override // com.unity3d.services.ads.adunit.IAdUnitActivity
public void setViewFrame(String str, int i, int i2, int i3, int i4) {
this._controller.setViewFrame(str, i, i2, i3, i4);
}
@Override // com.unity3d.services.ads.adunit.IAdUnitActivity
public Map<String, Integer> getViewFrame(String str) {
return this._controller.getViewFrame(str);
}
@Override // com.unity3d.services.ads.adunit.IAdUnitActivity
public void setViews(String[] strArr) {
this._controller.setViews(strArr);
}
@Override // com.unity3d.services.ads.adunit.IAdUnitActivity
public String[] getViews() {
return this._controller.getViews();
}
@Override // com.unity3d.services.ads.adunit.IAdUnitActivity
public void setOrientation(int i) {
this._controller.setOrientation(i);
}
@Override // com.unity3d.services.ads.adunit.IAdUnitActivity
public boolean setKeepScreenOn(boolean z) {
return this._controller.setKeepScreenOn(z);
}
@Override // com.unity3d.services.ads.adunit.IAdUnitActivity
public boolean setSystemUiVisibility(int i) {
return this._controller.setSystemUiVisibility(i);
}
@Override // com.unity3d.services.ads.adunit.IAdUnitActivity
public void setKeyEventList(ArrayList<Integer> arrayList) {
this._controller.setKeyEventList(arrayList);
}
public IAdUnitViewHandler getViewHandler(String str) {
return this._controller.getViewHandler(str);
}
@Override // com.unity3d.services.ads.adunit.IAdUnitActivity
public void setLayoutInDisplayCutoutMode(int i) {
this._controller.setLayoutInDisplayCutoutMode(i);
}
}

View File

@@ -0,0 +1,446 @@
package com.unity3d.services.ads.adunit;
import android.graphics.drawable.ColorDrawable;
import android.os.Build;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.RelativeLayout;
import androidx.core.view.ViewCompat;
import com.unity3d.services.ads.api.AdUnit;
import com.unity3d.services.core.api.Intent;
import com.unity3d.services.core.log.DeviceLog;
import com.unity3d.services.core.misc.ViewUtilities;
import com.unity3d.services.core.webview.WebViewApp;
import com.unity3d.services.core.webview.WebViewEventCategory;
import com.unity3d.services.core.webview.bridge.IEventSender;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import org.json.JSONArray;
/* loaded from: classes4.dex */
public class AdUnitActivityController {
private int _activityId;
private final IAdUnitActivity _adUnitActivity;
private final IAdUnitViewHandlerFactory _adUnitViewHandlerFactory;
private int _displayCutoutMode;
private final IEventSender _eventSender;
boolean _keepScreenOn;
private ArrayList<Integer> _keyEventList;
protected AdUnitRelativeLayout _layout;
private int _orientation = -1;
private int _systemUiVisibility;
private Map<String, IAdUnitViewHandler> _viewHandlers;
private String[] _views;
public AdUnitRelativeLayout getLayout() {
return this._layout;
}
public String[] getViews() {
return this._views;
}
public void setKeyEventList(ArrayList<Integer> arrayList) {
this._keyEventList = arrayList;
}
public AdUnitActivityController(IAdUnitActivity iAdUnitActivity, IEventSender iEventSender, IAdUnitViewHandlerFactory iAdUnitViewHandlerFactory) {
this._adUnitActivity = iAdUnitActivity;
this._eventSender = iEventSender;
this._adUnitViewHandlerFactory = iAdUnitViewHandlerFactory;
}
public void onCreate(Bundle bundle) {
AdUnitEvent adUnitEvent;
if (!this._eventSender.canSend()) {
DeviceLog.error("Unity Ads web app is null, closing Unity Ads activity from onCreate");
this._adUnitActivity.finish();
return;
}
AdUnit.setAdUnitActivity(this._adUnitActivity);
Intent.setActiveActivity(this._adUnitActivity.getActivity());
createLayout();
ViewUtilities.removeViewFromParent(this._layout);
IAdUnitActivity iAdUnitActivity = this._adUnitActivity;
AdUnitRelativeLayout adUnitRelativeLayout = this._layout;
iAdUnitActivity.addContentView(adUnitRelativeLayout, adUnitRelativeLayout.getLayoutParams());
if (bundle == null) {
this._views = this._adUnitActivity.getIntent().getStringArrayExtra(AdUnitActivity.EXTRA_VIEWS);
this._keyEventList = this._adUnitActivity.getIntent().getIntegerArrayListExtra(AdUnitActivity.EXTRA_KEY_EVENT_LIST);
if (this._adUnitActivity.getIntent().hasExtra("orientation")) {
this._orientation = this._adUnitActivity.getIntent().getIntExtra("orientation", -1);
}
if (this._adUnitActivity.getIntent().hasExtra(AdUnitActivity.EXTRA_SYSTEM_UI_VISIBILITY)) {
this._systemUiVisibility = this._adUnitActivity.getIntent().getIntExtra(AdUnitActivity.EXTRA_SYSTEM_UI_VISIBILITY, 0);
}
if (this._adUnitActivity.getIntent().hasExtra(AdUnitActivity.EXTRA_ACTIVITY_ID)) {
this._activityId = this._adUnitActivity.getIntent().getIntExtra(AdUnitActivity.EXTRA_ACTIVITY_ID, -1);
}
if (this._adUnitActivity.getIntent().hasExtra(AdUnitActivity.EXTRA_DISPLAY_CUTOUT_MODE)) {
this._displayCutoutMode = this._adUnitActivity.getIntent().getIntExtra(AdUnitActivity.EXTRA_DISPLAY_CUTOUT_MODE, 0);
}
adUnitEvent = AdUnitEvent.ON_CREATE;
} else {
this._views = bundle.getStringArray(AdUnitActivity.EXTRA_VIEWS);
this._orientation = bundle.getInt("orientation", -1);
this._systemUiVisibility = bundle.getInt(AdUnitActivity.EXTRA_SYSTEM_UI_VISIBILITY, 0);
this._keyEventList = bundle.getIntegerArrayList(AdUnitActivity.EXTRA_KEY_EVENT_LIST);
this._keepScreenOn = bundle.getBoolean(AdUnitActivity.EXTRA_KEEP_SCREEN_ON);
this._activityId = bundle.getInt(AdUnitActivity.EXTRA_ACTIVITY_ID, -1);
this._displayCutoutMode = bundle.getInt(AdUnitActivity.EXTRA_DISPLAY_CUTOUT_MODE, 0);
setKeepScreenOn(this._keepScreenOn);
adUnitEvent = AdUnitEvent.ON_RESTORE;
}
setOrientation(this._orientation);
setSystemUiVisibility(this._systemUiVisibility);
setLayoutInDisplayCutoutMode(this._displayCutoutMode);
String[] strArr = this._views;
if (strArr != null) {
for (String str : strArr) {
IAdUnitViewHandler viewHandler = getViewHandler(str);
if (viewHandler != null) {
viewHandler.onCreate(this._adUnitActivity, bundle);
}
}
}
this._eventSender.sendEvent(WebViewEventCategory.ADUNIT, adUnitEvent, Integer.valueOf(this._activityId));
}
public void onStart() {
if (!this._eventSender.canSend()) {
if (this._adUnitActivity.isFinishing()) {
return;
}
DeviceLog.error("Unity Ads web app is null, closing Unity Ads activity from onStart");
this._adUnitActivity.finish();
return;
}
Map<String, IAdUnitViewHandler> map = this._viewHandlers;
if (map != null) {
for (Map.Entry<String, IAdUnitViewHandler> entry : map.entrySet()) {
if (entry.getValue() != null) {
entry.getValue().onStart(this._adUnitActivity);
}
}
}
this._eventSender.sendEvent(WebViewEventCategory.ADUNIT, AdUnitEvent.ON_START, Integer.valueOf(this._activityId));
}
public void onStop() {
if (!this._eventSender.canSend()) {
if (this._adUnitActivity.isFinishing()) {
return;
}
DeviceLog.error("Unity Ads web app is null, closing Unity Ads activity from onStop");
this._adUnitActivity.finish();
return;
}
Map<String, IAdUnitViewHandler> map = this._viewHandlers;
if (map != null) {
for (Map.Entry<String, IAdUnitViewHandler> entry : map.entrySet()) {
if (entry.getValue() != null) {
entry.getValue().onStop(this._adUnitActivity);
}
}
}
this._eventSender.sendEvent(WebViewEventCategory.ADUNIT, AdUnitEvent.ON_STOP, Integer.valueOf(this._activityId));
}
public void onResume() {
if (!this._eventSender.canSend()) {
if (this._adUnitActivity.isFinishing()) {
return;
}
DeviceLog.error("Unity Ads web app is null, closing Unity Ads activity from onResume");
this._adUnitActivity.finish();
return;
}
setViews(this._views);
Map<String, IAdUnitViewHandler> map = this._viewHandlers;
if (map != null) {
for (Map.Entry<String, IAdUnitViewHandler> entry : map.entrySet()) {
if (entry.getValue() != null) {
entry.getValue().onResume(this._adUnitActivity);
}
}
}
this._eventSender.sendEvent(WebViewEventCategory.ADUNIT, AdUnitEvent.ON_RESUME, Integer.valueOf(this._activityId));
}
public void onPause() {
if (!this._eventSender.canSend()) {
if (this._adUnitActivity.isFinishing()) {
return;
}
DeviceLog.error("Unity Ads web app is null, closing Unity Ads activity from onPause");
this._adUnitActivity.finish();
return;
}
if (WebViewApp.getCurrentApp().getWebView() == null) {
DeviceLog.warning("Unity Ads web view is null, from onPause");
} else if (this._adUnitActivity.isFinishing()) {
ViewUtilities.removeViewFromParent(WebViewApp.getCurrentApp().getWebView());
}
Map<String, IAdUnitViewHandler> map = this._viewHandlers;
if (map != null) {
for (Map.Entry<String, IAdUnitViewHandler> entry : map.entrySet()) {
if (entry.getValue() != null) {
entry.getValue().onPause(this._adUnitActivity);
}
}
}
this._eventSender.sendEvent(WebViewEventCategory.ADUNIT, AdUnitEvent.ON_PAUSE, Boolean.valueOf(this._adUnitActivity.isFinishing()), Integer.valueOf(this._activityId));
}
public void onSaveInstanceState(Bundle bundle) {
bundle.putInt("orientation", this._orientation);
bundle.putInt(AdUnitActivity.EXTRA_SYSTEM_UI_VISIBILITY, this._systemUiVisibility);
bundle.putIntegerArrayList(AdUnitActivity.EXTRA_KEY_EVENT_LIST, this._keyEventList);
bundle.putBoolean(AdUnitActivity.EXTRA_KEEP_SCREEN_ON, this._keepScreenOn);
bundle.putStringArray(AdUnitActivity.EXTRA_VIEWS, this._views);
bundle.putInt(AdUnitActivity.EXTRA_ACTIVITY_ID, this._activityId);
}
public void onDestroy() {
if (!this._eventSender.canSend()) {
if (this._adUnitActivity.isFinishing()) {
return;
}
DeviceLog.error("Unity Ads web app is null, closing Unity Ads activity from onDestroy");
this._adUnitActivity.finish();
return;
}
this._eventSender.sendEvent(WebViewEventCategory.ADUNIT, AdUnitEvent.ON_DESTROY, Boolean.valueOf(this._adUnitActivity.isFinishing()), Integer.valueOf(this._activityId));
Map<String, IAdUnitViewHandler> map = this._viewHandlers;
if (map != null) {
for (Map.Entry<String, IAdUnitViewHandler> entry : map.entrySet()) {
if (entry.getValue() != null) {
entry.getValue().onDestroy(this._adUnitActivity);
}
}
}
if (AdUnit.getCurrentAdUnitActivityId() == this._activityId) {
AdUnit.setAdUnitActivity(null);
}
Intent.removeActiveActivity(this._adUnitActivity.getActivity());
}
public boolean onKeyDown(int i, KeyEvent keyEvent) {
ArrayList<Integer> arrayList = this._keyEventList;
if (arrayList == null || !arrayList.contains(Integer.valueOf(i))) {
return false;
}
this._eventSender.sendEvent(WebViewEventCategory.ADUNIT, AdUnitEvent.KEY_DOWN, Integer.valueOf(i), Long.valueOf(keyEvent.getEventTime()), Long.valueOf(keyEvent.getDownTime()), Integer.valueOf(keyEvent.getRepeatCount()), Integer.valueOf(this._activityId));
return true;
}
public void onWindowFocusChanged(boolean z) {
if (z) {
this._eventSender.sendEvent(WebViewEventCategory.ADUNIT, AdUnitEvent.ON_FOCUS_GAINED, Integer.valueOf(this._activityId));
} else {
this._eventSender.sendEvent(WebViewEventCategory.ADUNIT, AdUnitEvent.ON_FOCUS_LOST, Integer.valueOf(this._activityId));
}
}
public void onRequestPermissionsResult(int i, String[] strArr, int[] iArr) {
try {
JSONArray jSONArray = new JSONArray();
JSONArray jSONArray2 = new JSONArray();
for (String str : strArr) {
jSONArray.put(str);
}
for (int i2 : iArr) {
jSONArray2.put(i2);
}
this._eventSender.sendEvent(WebViewEventCategory.PERMISSIONS, PermissionsEvent.PERMISSIONS_RESULT, Integer.valueOf(i), jSONArray, jSONArray2);
} catch (Exception e) {
this._eventSender.sendEvent(WebViewEventCategory.PERMISSIONS, PermissionsEvent.PERMISSIONS_ERROR, e.getMessage());
}
}
/* JADX WARN: Removed duplicated region for block: B:6:0x0025 */
/* JADX WARN: Removed duplicated region for block: B:9:? A[RETURN, SYNTHETIC] */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public void setViewFrame(java.lang.String r3, int r4, int r5, int r6, int r7) {
/*
r2 = this;
com.unity3d.services.ads.adunit.IAdUnitViewHandler r0 = r2.getViewHandler(r3)
java.lang.String r1 = "adunit"
boolean r3 = r3.equals(r1)
r1 = 0
if (r3 == 0) goto L1b
android.widget.FrameLayout$LayoutParams r3 = new android.widget.FrameLayout$LayoutParams
r3.<init>(r6, r7)
r3.setMargins(r4, r5, r1, r1)
com.unity3d.services.ads.adunit.AdUnitRelativeLayout r0 = r2._layout
r0.setLayoutParams(r3)
goto L22
L1b:
if (r0 == 0) goto L22
android.view.View r3 = r0.getView()
goto L23
L22:
r3 = 0
L23:
if (r3 == 0) goto L30
android.widget.RelativeLayout$LayoutParams r0 = new android.widget.RelativeLayout$LayoutParams
r0.<init>(r6, r7)
r0.setMargins(r4, r5, r1, r1)
r3.setLayoutParams(r0)
L30:
return
*/
throw new UnsupportedOperationException("Method not decompiled: com.unity3d.services.ads.adunit.AdUnitActivityController.setViewFrame(java.lang.String, int, int, int, int):void");
}
public Map<String, Integer> getViewFrame(String str) {
IAdUnitViewHandler viewHandler = getViewHandler(str);
if (str.equals("adunit")) {
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) this._layout.getLayoutParams();
HashMap hashMap = new HashMap();
hashMap.put("x", Integer.valueOf(layoutParams.leftMargin));
hashMap.put("y", Integer.valueOf(layoutParams.topMargin));
hashMap.put("width", Integer.valueOf(this._layout.getWidth()));
hashMap.put("height", Integer.valueOf(this._layout.getHeight()));
return hashMap;
}
View view = viewHandler != null ? viewHandler.getView() : null;
if (view == null) {
return null;
}
RelativeLayout.LayoutParams layoutParams2 = (RelativeLayout.LayoutParams) view.getLayoutParams();
HashMap hashMap2 = new HashMap();
hashMap2.put("x", Integer.valueOf(layoutParams2.leftMargin));
hashMap2.put("y", Integer.valueOf(layoutParams2.topMargin));
hashMap2.put("width", Integer.valueOf(view.getWidth()));
hashMap2.put("height", Integer.valueOf(view.getHeight()));
return hashMap2;
}
public void setViews(String[] strArr) {
if (strArr == null) {
strArr = new String[0];
}
ArrayList arrayList = new ArrayList(Arrays.asList(strArr));
if (this._views == null) {
this._views = new String[0];
}
ArrayList arrayList2 = new ArrayList(Arrays.asList(this._views));
arrayList2.removeAll(arrayList);
Iterator it = arrayList2.iterator();
while (it.hasNext()) {
getViewHandler((String) it.next()).destroy();
}
this._views = strArr;
for (String str : strArr) {
if (str != null) {
IAdUnitViewHandler viewHandler = getViewHandler(str);
viewHandler.create(this._adUnitActivity);
if (!handleViewPlacement(viewHandler.getView())) {
return;
}
}
}
}
private boolean handleViewPlacement(View view) {
if (view == null) {
this._adUnitActivity.finish();
DeviceLog.error("Could not place view because it is null, finishing activity");
return false;
}
if (view.getParent() != null && view.getParent().equals(this._layout)) {
this._layout.bringChildToFront(view);
return true;
}
ViewUtilities.removeViewFromParent(view);
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(-1, -1);
layoutParams.addRule(13);
layoutParams.setMargins(0, 0, 0, 0);
view.setPadding(0, 0, 0, 0);
this._layout.addView(view, layoutParams);
return true;
}
public void setOrientation(int i) {
this._orientation = i;
this._adUnitActivity.setRequestedOrientation(i);
}
public boolean setKeepScreenOn(boolean z) {
this._keepScreenOn = z;
if (this._adUnitActivity.getWindow() == null) {
return false;
}
if (z) {
this._adUnitActivity.getWindow().addFlags(128);
return true;
}
this._adUnitActivity.getWindow().clearFlags(128);
return true;
}
public boolean setSystemUiVisibility(int i) {
this._systemUiVisibility = i;
try {
this._adUnitActivity.getWindow().getDecorView().setSystemUiVisibility(i);
return true;
} catch (Exception e) {
DeviceLog.exception("Error while setting SystemUIVisibility", e);
return false;
}
}
public IAdUnitViewHandler getViewHandler(String str) {
Map<String, IAdUnitViewHandler> map = this._viewHandlers;
if (map != null && map.containsKey(str)) {
return this._viewHandlers.get(str);
}
IAdUnitViewHandler createViewHandler = createViewHandler(str);
if (createViewHandler != null) {
if (this._viewHandlers == null) {
this._viewHandlers = new HashMap();
}
this._viewHandlers.put(str, createViewHandler);
}
return createViewHandler;
}
public void setLayoutInDisplayCutoutMode(int i) {
this._displayCutoutMode = i;
if (Build.VERSION.SDK_INT < 28 || this._adUnitActivity.getWindow() == null) {
return;
}
WindowManager.LayoutParams attributes = this._adUnitActivity.getWindow().getAttributes();
try {
attributes.getClass().getField("layoutInDisplayCutoutMode").setInt(attributes, i);
} catch (IllegalAccessException e) {
DeviceLog.debug("Error setting layoutInDisplayCutoutMode", e);
} catch (NoSuchFieldException e2) {
DeviceLog.debug("Error getting layoutInDisplayCutoutMode", e2);
}
}
public void createLayout() {
if (this._layout != null) {
return;
}
AdUnitRelativeLayout adUnitRelativeLayout = new AdUnitRelativeLayout(this._adUnitActivity.getContext());
this._layout = adUnitRelativeLayout;
adUnitRelativeLayout.setLayoutParams(new RelativeLayout.LayoutParams(-1, -1));
ViewUtilities.setBackground(this._layout, new ColorDrawable(ViewCompat.MEASURED_STATE_MASK));
}
private IAdUnitViewHandler createViewHandler(String str) {
return this._adUnitViewHandlerFactory.createViewHandler(str);
}
}

View File

@@ -0,0 +1,21 @@
package com.unity3d.services.ads.adunit;
/* loaded from: classes4.dex */
public enum AdUnitError {
ADUNIT_NULL,
ACTIVITY_ID,
GENERIC,
ORIENTATION,
SCREENVISIBILITY,
CORRUPTED_VIEWLIST,
CORRUPTED_KEYEVENTLIST,
SYSTEM_UI_VISIBILITY,
UNKNOWN_VIEW,
LAYOUT_NULL,
MAX_MOTION_EVENT_COUNT_REACHED,
API_LEVEL_ERROR,
NO_DISPLAY_CUTOUT_AVAILABLE,
DISPLAY_CUTOUT_METHOD_NOT_AVAILABLE,
DISPLAY_CUTOUT_JSON_ERROR,
DISPLAY_CUTOUT_INVOKE_FAILED
}

View File

@@ -0,0 +1,15 @@
package com.unity3d.services.ads.adunit;
/* loaded from: classes4.dex */
public enum AdUnitEvent {
ON_START,
ON_CREATE,
ON_RESUME,
ON_DESTROY,
ON_PAUSE,
KEY_DOWN,
ON_RESTORE,
ON_STOP,
ON_FOCUS_GAINED,
ON_FOCUS_LOST
}

View File

@@ -0,0 +1,68 @@
package com.unity3d.services.ads.adunit;
/* loaded from: classes4.dex */
public class AdUnitMotionEvent {
private int _action;
private int _deviceId;
private long _eventTime;
private boolean _isObscured;
private float _pressure;
private float _size;
private int _source;
private int _toolType;
private float _x;
private float _y;
public int getAction() {
return this._action;
}
public int getDeviceId() {
return this._deviceId;
}
public long getEventTime() {
return this._eventTime;
}
public float getPressure() {
return this._pressure;
}
public float getSize() {
return this._size;
}
public int getSource() {
return this._source;
}
public int getToolType() {
return this._toolType;
}
public float getX() {
return this._x;
}
public float getY() {
return this._y;
}
public boolean isObscured() {
return this._isObscured;
}
public AdUnitMotionEvent(int i, boolean z, int i2, int i3, int i4, float f, float f2, long j, float f3, float f4) {
this._action = i;
this._isObscured = z;
this._toolType = i2;
this._source = i3;
this._deviceId = i4;
this._x = f;
this._y = f2;
this._eventTime = j;
this._pressure = f3;
this._size = f4;
}
}

View File

@@ -0,0 +1,53 @@
package com.unity3d.services.ads.adunit;
import android.os.ConditionVariable;
import com.ironsource.v8;
import com.unity3d.services.core.configuration.Configuration;
import com.unity3d.services.core.misc.Utilities;
import com.unity3d.services.core.request.metrics.AdOperationError;
import com.unity3d.services.core.request.metrics.AdOperationMetric;
import com.unity3d.services.core.request.metrics.SDKMetricsSender;
import com.unity3d.services.core.webview.WebViewApp;
import com.unity3d.services.core.webview.bridge.CallbackStatus;
import java.lang.reflect.Method;
import org.json.JSONObject;
/* loaded from: classes4.dex */
public class AdUnitOpen {
private static Configuration _configuration;
private static final SDKMetricsSender _sdkMetricsSender = (SDKMetricsSender) Utilities.getService(SDKMetricsSender.class);
private static ConditionVariable _waitShowStatus;
public static void setConfiguration(Configuration configuration) {
_configuration = configuration;
}
public static synchronized boolean open(String str, JSONObject jSONObject) throws NoSuchMethodException {
boolean block;
synchronized (AdUnitOpen.class) {
try {
Method method = AdUnitOpen.class.getMethod("showCallback", CallbackStatus.class);
_waitShowStatus = new ConditionVariable();
if (_configuration == null) {
_configuration = new Configuration();
}
WebViewApp.getCurrentApp().invokeMethod(v8.h.K, "show", method, str, jSONObject);
block = _waitShowStatus.block(_configuration.getShowTimeout());
_waitShowStatus = null;
if (!block) {
_sdkMetricsSender.sendMetric(AdOperationMetric.newAdShowFailure(AdOperationError.timeout, Long.valueOf(_configuration.getShowTimeout())));
}
} catch (Throwable th) {
throw th;
}
}
return block;
}
public static void showCallback(CallbackStatus callbackStatus) {
if (_waitShowStatus == null || !callbackStatus.equals(CallbackStatus.OK)) {
return;
}
_waitShowStatus.open();
}
}

View File

@@ -0,0 +1,127 @@
package com.unity3d.services.ads.adunit;
import android.annotation.TargetApi;
import android.content.Context;
import android.util.SparseArray;
import android.util.SparseIntArray;
import android.view.InputEvent;
import android.view.MotionEvent;
import android.widget.RelativeLayout;
import java.util.ArrayList;
import java.util.Iterator;
/* loaded from: classes4.dex */
public class AdUnitRelativeLayout extends RelativeLayout {
private InputEvent _lastInputEvent;
private int _maxEvents;
private final ArrayList<AdUnitMotionEvent> _motionEvents;
private boolean _shouldCapture;
public void endCapture() {
this._shouldCapture = false;
}
public InputEvent getLastInputEvent() {
return this._lastInputEvent;
}
public int getMaxEventCount() {
return this._maxEvents;
}
public void startCapture(int i) {
this._maxEvents = i;
this._shouldCapture = true;
}
public AdUnitRelativeLayout(Context context) {
super(context);
this._motionEvents = new ArrayList<>();
this._maxEvents = 10000;
this._shouldCapture = false;
}
@Override // android.view.ViewGroup
@TargetApi(14)
public boolean onInterceptTouchEvent(MotionEvent motionEvent) {
super.onInterceptTouchEvent(motionEvent);
if (motionEvent.getActionMasked() == 1 || motionEvent.getActionMasked() == 0 || motionEvent.getActionMasked() == 6 || motionEvent.getActionMasked() == 5) {
this._lastInputEvent = motionEvent;
}
if (!this._shouldCapture || this._motionEvents.size() >= this._maxEvents) {
return false;
}
boolean z = (motionEvent.getFlags() & 1) != 0;
synchronized (this._motionEvents) {
this._motionEvents.add(new AdUnitMotionEvent(motionEvent.getActionMasked(), z, motionEvent.getToolType(0), motionEvent.getSource(), motionEvent.getDeviceId(), motionEvent.getX(0), motionEvent.getY(0), motionEvent.getEventTime(), motionEvent.getPressure(0), motionEvent.getSize(0)));
}
return false;
}
public void clearCapture() {
synchronized (this._motionEvents) {
this._motionEvents.clear();
}
}
public int getCurrentEventCount() {
int size;
synchronized (this._motionEvents) {
size = this._motionEvents.size();
}
return size;
}
public SparseArray<SparseArray<AdUnitMotionEvent>> getEvents(SparseArray<ArrayList<Integer>> sparseArray) {
SparseIntArray sparseIntArray = new SparseIntArray();
SparseArray<SparseArray<AdUnitMotionEvent>> sparseArray2 = new SparseArray<>();
synchronized (this._motionEvents) {
try {
Iterator<AdUnitMotionEvent> it = this._motionEvents.iterator();
while (it.hasNext()) {
AdUnitMotionEvent next = it.next();
ArrayList<Integer> arrayList = sparseArray.get(next.getAction());
if (arrayList != null) {
int intValue = arrayList.get(0).intValue();
if (sparseIntArray.get(next.getAction(), 0) == intValue) {
if (sparseArray2.get(next.getAction()) == null) {
sparseArray2.put(next.getAction(), new SparseArray<>());
}
sparseArray2.get(next.getAction()).put(intValue, next);
arrayList.remove(0);
}
sparseIntArray.put(next.getAction(), sparseIntArray.get(next.getAction()) + 1);
}
}
} catch (Throwable th) {
throw th;
}
}
return sparseArray2;
}
public SparseIntArray getEventCount(ArrayList<Integer> arrayList) {
SparseIntArray sparseIntArray = new SparseIntArray();
synchronized (this._motionEvents) {
try {
Iterator<AdUnitMotionEvent> it = this._motionEvents.iterator();
while (it.hasNext()) {
AdUnitMotionEvent next = it.next();
Iterator<Integer> it2 = arrayList.iterator();
while (true) {
if (it2.hasNext()) {
Integer next2 = it2.next();
if (next.getAction() == next2.intValue()) {
sparseIntArray.put(next2.intValue(), sparseIntArray.get(next2.intValue(), 0) + 1);
break;
}
}
}
}
} catch (Throwable th) {
throw th;
}
}
return sparseIntArray;
}
}

View File

@@ -0,0 +1,5 @@
package com.unity3d.services.ads.adunit;
/* loaded from: classes4.dex */
public class AdUnitSoftwareActivity extends AdUnitActivity {
}

View File

@@ -0,0 +1,20 @@
package com.unity3d.services.ads.adunit;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import com.unity3d.services.core.misc.ViewUtilities;
import com.unity3d.services.core.webview.bridge.SharedInstances;
/* loaded from: classes4.dex */
public class AdUnitTransparentActivity extends AdUnitActivity {
@Override // com.unity3d.services.ads.adunit.AdUnitActivity, android.app.Activity
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
ViewUtilities.setBackground(this._controller._layout, new ColorDrawable(0));
}
@Override // com.unity3d.services.ads.adunit.AdUnitActivity
public AdUnitActivityController createController() {
return new AdUnitTransparentActivityController(this, SharedInstances.INSTANCE.getWebViewEventSender(), new AdUnitViewHandlerFactory());
}
}

View File

@@ -0,0 +1,18 @@
package com.unity3d.services.ads.adunit;
import android.graphics.drawable.ColorDrawable;
import com.unity3d.services.core.misc.ViewUtilities;
import com.unity3d.services.core.webview.bridge.IEventSender;
/* loaded from: classes4.dex */
public class AdUnitTransparentActivityController extends AdUnitActivityController {
public AdUnitTransparentActivityController(IAdUnitActivity iAdUnitActivity, IEventSender iEventSender, IAdUnitViewHandlerFactory iAdUnitViewHandlerFactory) {
super(iAdUnitActivity, iEventSender, iAdUnitViewHandlerFactory);
}
@Override // com.unity3d.services.ads.adunit.AdUnitActivityController
public void createLayout() {
super.createLayout();
ViewUtilities.setBackground(this._layout, new ColorDrawable(0));
}
}

View File

@@ -0,0 +1,5 @@
package com.unity3d.services.ads.adunit;
/* loaded from: classes4.dex */
public class AdUnitTransparentSoftwareActivity extends AdUnitTransparentActivity {
}

View File

@@ -0,0 +1,31 @@
package com.unity3d.services.ads.adunit;
import com.unity3d.services.ads.configuration.IAdsModuleConfiguration;
import com.unity3d.services.core.configuration.Configuration;
import com.unity3d.services.core.configuration.IModuleConfiguration;
import com.unity3d.services.core.log.DeviceLog;
import com.unity3d.services.core.webview.WebViewApp;
import java.util.Map;
/* loaded from: classes4.dex */
public class AdUnitViewHandlerFactory implements IAdUnitViewHandlerFactory {
@Override // com.unity3d.services.ads.adunit.IAdUnitViewHandlerFactory
public IAdUnitViewHandler createViewHandler(String str) {
Map<String, Class> adUnitViewHandlers;
if (WebViewApp.getCurrentApp() != null) {
Configuration configuration = WebViewApp.getCurrentApp().getConfiguration();
for (Class cls : configuration.getModuleConfigurationList()) {
IModuleConfiguration moduleConfiguration = configuration.getModuleConfiguration(cls);
if ((moduleConfiguration instanceof IAdsModuleConfiguration) && (adUnitViewHandlers = ((IAdsModuleConfiguration) moduleConfiguration).getAdUnitViewHandlers()) != null && adUnitViewHandlers.containsKey(str)) {
try {
return (IAdUnitViewHandler) adUnitViewHandlers.get(str).newInstance();
} catch (Exception unused) {
DeviceLog.error("Error creating view: " + str);
return null;
}
}
}
}
return null;
}
}

View File

@@ -0,0 +1,53 @@
package com.unity3d.services.ads.adunit;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import java.util.ArrayList;
import java.util.Map;
/* loaded from: classes4.dex */
public interface IAdUnitActivity {
void addContentView(View view, ViewGroup.LayoutParams layoutParams);
void finish();
Activity getActivity();
Context getContext();
Intent getIntent();
AdUnitRelativeLayout getLayout();
int getRequestedOrientation();
Map<String, Integer> getViewFrame(String str);
String[] getViews();
Window getWindow();
boolean isFinishing();
void requestPermissions(String[] strArr, int i);
boolean setKeepScreenOn(boolean z);
void setKeyEventList(ArrayList<Integer> arrayList);
void setLayoutInDisplayCutoutMode(int i);
void setOrientation(int i);
void setRequestedOrientation(int i);
boolean setSystemUiVisibility(int i);
void setViewFrame(String str, int i, int i2, int i3, int i4);
void setViews(String[] strArr);
}

View File

@@ -0,0 +1,25 @@
package com.unity3d.services.ads.adunit;
import android.os.Bundle;
import android.view.View;
/* loaded from: classes4.dex */
public interface IAdUnitViewHandler {
boolean create(IAdUnitActivity iAdUnitActivity);
boolean destroy();
View getView();
void onCreate(IAdUnitActivity iAdUnitActivity, Bundle bundle);
void onDestroy(IAdUnitActivity iAdUnitActivity);
void onPause(IAdUnitActivity iAdUnitActivity);
void onResume(IAdUnitActivity iAdUnitActivity);
void onStart(IAdUnitActivity iAdUnitActivity);
void onStop(IAdUnitActivity iAdUnitActivity);
}

View File

@@ -0,0 +1,6 @@
package com.unity3d.services.ads.adunit;
/* loaded from: classes4.dex */
public interface IAdUnitViewHandlerFactory {
IAdUnitViewHandler createViewHandler(String str);
}

View File

@@ -0,0 +1,7 @@
package com.unity3d.services.ads.adunit;
/* loaded from: classes4.dex */
public enum PermissionsEvent {
PERMISSIONS_RESULT,
PERMISSIONS_ERROR
}

View File

@@ -0,0 +1,86 @@
package com.unity3d.services.ads.adunit;
import android.os.Bundle;
import android.view.View;
import android.widget.RelativeLayout;
import com.unity3d.services.ads.api.VideoPlayer;
import com.unity3d.services.ads.video.VideoPlayerView;
import com.unity3d.services.core.log.DeviceLog;
import com.unity3d.services.core.misc.ViewUtilities;
/* loaded from: classes4.dex */
public class VideoPlayerHandler implements IAdUnitViewHandler {
private RelativeLayout _videoContainer;
private VideoPlayerView _videoView;
@Override // com.unity3d.services.ads.adunit.IAdUnitViewHandler
public View getView() {
return this._videoContainer;
}
@Override // com.unity3d.services.ads.adunit.IAdUnitViewHandler
public void onDestroy(IAdUnitActivity iAdUnitActivity) {
}
@Override // com.unity3d.services.ads.adunit.IAdUnitViewHandler
public void onResume(IAdUnitActivity iAdUnitActivity) {
}
@Override // com.unity3d.services.ads.adunit.IAdUnitViewHandler
public void onStart(IAdUnitActivity iAdUnitActivity) {
}
@Override // com.unity3d.services.ads.adunit.IAdUnitViewHandler
public void onStop(IAdUnitActivity iAdUnitActivity) {
}
@Override // com.unity3d.services.ads.adunit.IAdUnitViewHandler
public boolean create(IAdUnitActivity iAdUnitActivity) {
DeviceLog.entered();
if (this._videoContainer == null) {
this._videoContainer = new RelativeLayout(iAdUnitActivity.getContext());
}
if (this._videoView != null) {
return true;
}
this._videoView = new VideoPlayerView(iAdUnitActivity.getContext());
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(-1, -1);
layoutParams.addRule(13);
this._videoView.setLayoutParams(layoutParams);
this._videoContainer.addView(this._videoView);
VideoPlayer.setVideoPlayerView(this._videoView);
return true;
}
@Override // com.unity3d.services.ads.adunit.IAdUnitViewHandler
public boolean destroy() {
DeviceLog.entered();
VideoPlayerView videoPlayerView = this._videoView;
if (videoPlayerView != null) {
videoPlayerView.stopVideoProgressTimer();
this._videoView.stopPlayback();
ViewUtilities.removeViewFromParent(this._videoView);
if (this._videoView.equals(VideoPlayer.getVideoPlayerView())) {
VideoPlayer.setVideoPlayerView(null);
}
this._videoView = null;
}
RelativeLayout relativeLayout = this._videoContainer;
if (relativeLayout == null) {
return true;
}
ViewUtilities.removeViewFromParent(relativeLayout);
this._videoContainer = null;
return true;
}
@Override // com.unity3d.services.ads.adunit.IAdUnitViewHandler
public void onCreate(IAdUnitActivity iAdUnitActivity, Bundle bundle) {
create(iAdUnitActivity);
}
@Override // com.unity3d.services.ads.adunit.IAdUnitViewHandler
public void onPause(IAdUnitActivity iAdUnitActivity) {
destroy();
}
}

View File

@@ -0,0 +1,75 @@
package com.unity3d.services.ads.adunit;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import com.unity3d.services.ads.webplayer.WebPlayerSettingsCache;
import com.unity3d.services.ads.webplayer.WebPlayerView;
import com.unity3d.services.ads.webplayer.WebPlayerViewCache;
import com.unity3d.services.core.misc.ViewUtilities;
/* loaded from: classes4.dex */
public class WebPlayerHandler implements IAdUnitViewHandler {
private static String webPlayerViewId = "webplayer";
private WebPlayerView _webPlayerView;
@Override // com.unity3d.services.ads.adunit.IAdUnitViewHandler
public View getView() {
return this._webPlayerView;
}
@Override // com.unity3d.services.ads.adunit.IAdUnitViewHandler
public void onPause(IAdUnitActivity iAdUnitActivity) {
}
@Override // com.unity3d.services.ads.adunit.IAdUnitViewHandler
public void onResume(IAdUnitActivity iAdUnitActivity) {
}
@Override // com.unity3d.services.ads.adunit.IAdUnitViewHandler
public void onStart(IAdUnitActivity iAdUnitActivity) {
}
@Override // com.unity3d.services.ads.adunit.IAdUnitViewHandler
public void onStop(IAdUnitActivity iAdUnitActivity) {
}
@Override // com.unity3d.services.ads.adunit.IAdUnitViewHandler
public boolean create(IAdUnitActivity iAdUnitActivity) {
if (this._webPlayerView != null) {
return true;
}
WebPlayerSettingsCache webPlayerSettingsCache = WebPlayerSettingsCache.getInstance();
Context context = iAdUnitActivity.getContext();
String str = webPlayerViewId;
WebPlayerView webPlayerView = new WebPlayerView(context, str, webPlayerSettingsCache.getWebSettings(str), webPlayerSettingsCache.getWebPlayerSettings(webPlayerViewId));
this._webPlayerView = webPlayerView;
webPlayerView.setEventSettings(webPlayerSettingsCache.getWebPlayerEventSettings(webPlayerViewId));
WebPlayerViewCache.getInstance().addWebPlayer(webPlayerViewId, this._webPlayerView);
return true;
}
@Override // com.unity3d.services.ads.adunit.IAdUnitViewHandler
public boolean destroy() {
WebPlayerView webPlayerView = this._webPlayerView;
if (webPlayerView != null) {
ViewUtilities.removeViewFromParent(webPlayerView);
this._webPlayerView.destroy();
}
WebPlayerViewCache.getInstance().removeWebPlayer(webPlayerViewId);
this._webPlayerView = null;
return true;
}
@Override // com.unity3d.services.ads.adunit.IAdUnitViewHandler
public void onCreate(IAdUnitActivity iAdUnitActivity, Bundle bundle) {
create(iAdUnitActivity);
}
@Override // com.unity3d.services.ads.adunit.IAdUnitViewHandler
public void onDestroy(IAdUnitActivity iAdUnitActivity) {
if (iAdUnitActivity.isFinishing()) {
destroy();
}
}
}

View File

@@ -0,0 +1,56 @@
package com.unity3d.services.ads.adunit;
import android.os.Bundle;
import android.view.View;
import com.unity3d.services.core.misc.ViewUtilities;
import com.unity3d.services.core.webview.WebViewApp;
/* loaded from: classes4.dex */
public class WebViewHandler implements IAdUnitViewHandler {
@Override // com.unity3d.services.ads.adunit.IAdUnitViewHandler
public boolean create(IAdUnitActivity iAdUnitActivity) {
return true;
}
@Override // com.unity3d.services.ads.adunit.IAdUnitViewHandler
public void onCreate(IAdUnitActivity iAdUnitActivity, Bundle bundle) {
}
@Override // com.unity3d.services.ads.adunit.IAdUnitViewHandler
public void onPause(IAdUnitActivity iAdUnitActivity) {
}
@Override // com.unity3d.services.ads.adunit.IAdUnitViewHandler
public void onResume(IAdUnitActivity iAdUnitActivity) {
}
@Override // com.unity3d.services.ads.adunit.IAdUnitViewHandler
public void onStart(IAdUnitActivity iAdUnitActivity) {
}
@Override // com.unity3d.services.ads.adunit.IAdUnitViewHandler
public void onStop(IAdUnitActivity iAdUnitActivity) {
}
@Override // com.unity3d.services.ads.adunit.IAdUnitViewHandler
public boolean destroy() {
if (WebViewApp.getCurrentApp() == null || WebViewApp.getCurrentApp().getWebView() == null) {
return true;
}
ViewUtilities.removeViewFromParent(WebViewApp.getCurrentApp().getWebView());
return true;
}
@Override // com.unity3d.services.ads.adunit.IAdUnitViewHandler
public View getView() {
if (WebViewApp.getCurrentApp() != null) {
return WebViewApp.getCurrentApp().getWebView();
}
return null;
}
@Override // com.unity3d.services.ads.adunit.IAdUnitViewHandler
public void onDestroy(IAdUnitActivity iAdUnitActivity) {
destroy();
}
}