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,61 @@
package com.unity3d.services;
import com.unity3d.ads.core.domain.SendDiagnosticEvent;
import java.util.Map;
import kotlin.ResultKt;
import kotlin.TuplesKt;
import kotlin.Unit;
import kotlin.collections.MapsKt__MapsKt;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.intrinsics.IntrinsicsKt__IntrinsicsKt;
import kotlin.coroutines.jvm.internal.DebugMetadata;
import kotlin.coroutines.jvm.internal.SuspendLambda;
import kotlin.jvm.functions.Function2;
import kotlinx.coroutines.CoroutineScope;
@DebugMetadata(c = "com.unity3d.services.SDKErrorHandler$sendDiagnostic$1", f = "SDKErrorHandler.kt", l = {}, m = "invokeSuspend")
/* loaded from: classes4.dex */
public final class SDKErrorHandler$sendDiagnostic$1 extends SuspendLambda implements Function2 {
final /* synthetic */ String $name;
final /* synthetic */ String $reason;
final /* synthetic */ String $scopeName;
final /* synthetic */ String $stackTrace;
int label;
final /* synthetic */ SDKErrorHandler this$0;
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
public SDKErrorHandler$sendDiagnostic$1(SDKErrorHandler sDKErrorHandler, String str, String str2, String str3, String str4, Continuation continuation) {
super(2, continuation);
this.this$0 = sDKErrorHandler;
this.$name = str;
this.$reason = str2;
this.$stackTrace = str3;
this.$scopeName = str4;
}
@Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
public final Continuation create(Object obj, Continuation continuation) {
return new SDKErrorHandler$sendDiagnostic$1(this.this$0, this.$name, this.$reason, this.$stackTrace, this.$scopeName, continuation);
}
@Override // kotlin.jvm.functions.Function2
public final Object invoke(CoroutineScope coroutineScope, Continuation continuation) {
return ((SDKErrorHandler$sendDiagnostic$1) create(coroutineScope, continuation)).invokeSuspend(Unit.INSTANCE);
}
@Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
public final Object invokeSuspend(Object obj) {
SendDiagnosticEvent sendDiagnosticEvent;
Map mapOf;
IntrinsicsKt__IntrinsicsKt.getCOROUTINE_SUSPENDED();
if (this.label == 0) {
ResultKt.throwOnFailure(obj);
sendDiagnosticEvent = this.this$0.sendDiagnosticEvent;
String str = this.$name;
mapOf = MapsKt__MapsKt.mapOf(TuplesKt.to("reason", this.$reason), TuplesKt.to("reason_debug", this.$stackTrace), TuplesKt.to("coroutine_name", this.$scopeName));
SendDiagnosticEvent.DefaultImpls.invoke$default(sendDiagnosticEvent, str, null, mapOf, null, null, 26, null);
return Unit.INSTANCE;
}
throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
}
}

View File

@@ -0,0 +1,143 @@
package com.unity3d.services;
import com.unity3d.ads.core.configuration.AlternativeFlowReader;
import com.unity3d.ads.core.domain.SendDiagnosticEvent;
import com.unity3d.ads.core.extensions.ExceptionExtensionsKt;
import com.unity3d.services.core.log.DeviceLog;
import com.unity3d.services.core.request.metrics.Metric;
import com.unity3d.services.core.request.metrics.SDKMetricsSender;
import java.io.PrintWriter;
import java.io.StringWriter;
import kotlin.coroutines.CoroutineContext;
import kotlin.jvm.functions.Function2;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
import kotlin.sequences.Sequence;
import kotlin.sequences.SequencesKt___SequencesKt;
import kotlin.text.StringsKt__StringsKt;
import kotlinx.coroutines.BuildersKt__Builders_commonKt;
import kotlinx.coroutines.CoroutineDispatcher;
import kotlinx.coroutines.CoroutineExceptionHandler;
import kotlinx.coroutines.CoroutineName;
import kotlinx.coroutines.CoroutineScope;
import kotlinx.coroutines.CoroutineScopeKt;
/* loaded from: classes4.dex */
public final class SDKErrorHandler implements CoroutineExceptionHandler {
public static final Companion Companion = new Companion(null);
public static final String UNITY_PACKAGE = "com.unity3d";
public static final String UNKNOWN_FILE = "unknown";
private final AlternativeFlowReader alternativeFlowReader;
private final CoroutineDispatcher ioDispatcher;
private final CoroutineExceptionHandler.Key key;
private final CoroutineScope scope;
private final SDKMetricsSender sdkMetricsSender;
private final SendDiagnosticEvent sendDiagnosticEvent;
@Override // kotlin.coroutines.CoroutineContext.Element
public CoroutineExceptionHandler.Key getKey() {
return this.key;
}
public SDKErrorHandler(CoroutineDispatcher ioDispatcher, AlternativeFlowReader alternativeFlowReader, SendDiagnosticEvent sendDiagnosticEvent, SDKMetricsSender sdkMetricsSender) {
Intrinsics.checkNotNullParameter(ioDispatcher, "ioDispatcher");
Intrinsics.checkNotNullParameter(alternativeFlowReader, "alternativeFlowReader");
Intrinsics.checkNotNullParameter(sendDiagnosticEvent, "sendDiagnosticEvent");
Intrinsics.checkNotNullParameter(sdkMetricsSender, "sdkMetricsSender");
this.ioDispatcher = ioDispatcher;
this.alternativeFlowReader = alternativeFlowReader;
this.sendDiagnosticEvent = sendDiagnosticEvent;
this.sdkMetricsSender = sdkMetricsSender;
this.scope = CoroutineScopeKt.plus(CoroutineScopeKt.CoroutineScope(ioDispatcher), new CoroutineName("SDKErrorHandler"));
this.key = CoroutineExceptionHandler.Key;
}
@Override // kotlin.coroutines.CoroutineContext
public <R> R fold(R r, Function2 function2) {
return (R) CoroutineExceptionHandler.DefaultImpls.fold(this, r, function2);
}
@Override // kotlin.coroutines.CoroutineContext.Element, kotlin.coroutines.CoroutineContext
public <E extends CoroutineContext.Element> E get(CoroutineContext.Key key) {
return (E) CoroutineExceptionHandler.DefaultImpls.get(this, key);
}
@Override // kotlin.coroutines.CoroutineContext
public CoroutineContext minusKey(CoroutineContext.Key key) {
return CoroutineExceptionHandler.DefaultImpls.minusKey(this, key);
}
@Override // kotlin.coroutines.CoroutineContext
public CoroutineContext plus(CoroutineContext coroutineContext) {
return CoroutineExceptionHandler.DefaultImpls.plus(this, coroutineContext);
}
@Override // kotlinx.coroutines.CoroutineExceptionHandler
public void handleException(CoroutineContext context, Throwable exception) {
String str;
Intrinsics.checkNotNullParameter(context, "context");
Intrinsics.checkNotNullParameter(exception, "exception");
String retrieveCoroutineName = retrieveCoroutineName(context);
if (exception instanceof NullPointerException) {
str = "native_exception_npe";
} else if (exception instanceof OutOfMemoryError) {
str = "native_exception_oom";
} else if (exception instanceof IllegalStateException) {
str = "native_exception_ise";
} else if (exception instanceof SecurityException) {
str = "native_exception_se";
} else {
str = exception instanceof RuntimeException ? "native_exception_re" : "native_exception";
}
String str2 = str;
boolean invoke = this.alternativeFlowReader.invoke();
String retrieveUnityCrashValue = ExceptionExtensionsKt.retrieveUnityCrashValue(exception);
DeviceLog.error("Unity Ads SDK encountered an exception: " + retrieveUnityCrashValue);
if (invoke) {
sendDiagnostic(str2, retrieveUnityCrashValue, retrieveCoroutineName, getShortenedStackTrace(exception, 15));
} else {
sendMetric(new Metric(str2, retrieveUnityCrashValue, null, 4, null));
}
}
private final void sendDiagnostic(String str, String str2, String str3, String str4) {
BuildersKt__Builders_commonKt.launch$default(this.scope, null, null, new SDKErrorHandler$sendDiagnostic$1(this, str, str2, str4, str3, null), 3, null);
}
private final void sendMetric(Metric metric) {
this.sdkMetricsSender.sendMetric(metric);
}
private final String retrieveCoroutineName(CoroutineContext coroutineContext) {
String name;
CoroutineName coroutineName = (CoroutineName) coroutineContext.get(CoroutineName.Key);
return (coroutineName == null || (name = coroutineName.getName()) == null) ? "unknown" : name;
}
private final String getShortenedStackTrace(Throwable th, int i) {
CharSequence trim;
Sequence take;
String joinToString$default;
try {
StringWriter stringWriter = new StringWriter();
th.printStackTrace(new PrintWriter(stringWriter));
String stringWriter2 = stringWriter.toString();
Intrinsics.checkNotNullExpressionValue(stringWriter2, "writer.toString()");
trim = StringsKt__StringsKt.trim(stringWriter2);
take = SequencesKt___SequencesKt.take(StringsKt__StringsKt.lineSequence(trim.toString()), i);
joinToString$default = SequencesKt___SequencesKt.joinToString$default(take, "\n", null, null, 0, null, null, 62, null);
return joinToString$default;
} catch (Throwable unused) {
return "";
}
}
public static final class Companion {
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
private Companion() {
}
}
}

View File

@@ -0,0 +1,131 @@
package com.unity3d.services;
/* loaded from: classes4.dex */
public final class UnityAdsConstants {
public static final UnityAdsConstants INSTANCE = new UnityAdsConstants();
private UnityAdsConstants() {
}
public static final class Messages {
public static final Messages INSTANCE = new Messages();
public static final String MSG_INTERNAL_ERROR = "Internal error";
public static final String MSG_UNITY_BASE = "[Unity Ads] ";
private Messages() {
}
}
public static final class Timeout {
public static final long GET_TOKEN_TIMEOUT_MS = 5000;
public static final long INIT_TIMEOUT_MS = 120000;
public static final Timeout INSTANCE = new Timeout();
private Timeout() {
}
}
public static final class RequestPolicy {
public static final int CONNECT_TIMEOUT_MS = 10000;
public static final RequestPolicy INSTANCE = new RequestPolicy();
public static final int OVERALL_TIMEOUT_MS = 10000;
public static final int READ_TIMEOUT_MS = 10000;
public static final float RETRY_JITTER_PCT = 0.1f;
public static final int RETRY_MAX_DURATION = 20000;
public static final int RETRY_MAX_INTERVAL = 1000;
public static final float RETRY_SCALING_FACTOR = 2.0f;
public static final int RETRY_WAIT_BASE = 500;
public static final boolean SHOULD_STORE_LOCALLY = false;
public static final int WRITE_TIMEOUT_MS = 10000;
private RequestPolicy() {
}
}
public static final class SharedFlow {
public static final int EXTRA_CAPACITY = 10;
public static final SharedFlow INSTANCE = new SharedFlow();
public static final int REPLAY = 10;
private SharedFlow() {
}
}
public static final class DefaultUrls {
public static final String AD_ASSET_DOMAIN = "unity.ads.asset";
public static final String AD_ASSET_PATH = "/";
public static final String AD_CACHE_DOMAIN = "unity.ads.cache";
public static final String AD_MARKUP_URL = "https://gateway.unityads.unity3d.com/tools/convert_ad_response_to_ad_markup";
public static final String AD_PLAYER_QUERY_PARAMS = "?platform=android&";
public static final String ASSET_DOMAIN = "cdn-creatives-cf-prd.acquire.unity3dusercontent.com";
public static final String CACHE_DIR_NAME = "UnityAdsCache";
public static final String GATEWAY_URL = "https://gateway.unityads.unity3d.com/v1";
public static final String HTTP_CACHE_DIR_NAME = "UnityAdsHttpCache";
public static final DefaultUrls INSTANCE = new DefaultUrls();
public static final String WEBVIEW_ASSET_PATH = "/unity-ads-sdk-webview/";
public static final String WEBVIEW_DOMAIN = "config.unityads.unity3d.com";
private DefaultUrls() {
}
}
public static final class ClientInfo {
public static final ClientInfo INSTANCE = new ClientInfo();
public static final int SDK_VERSION = 41203;
public static final String SDK_VERSION_NAME = "4.12.3";
private ClientInfo() {
}
}
public static final class OpenMeasurement {
public static final OpenMeasurement INSTANCE = new OpenMeasurement();
public static final String OM_JS_SERVICE_FILENAME = "ad-viewer/omsdk-v1.js";
public static final String OM_JS_SESSION_FILENAME = "ad-viewer/omid-session-client-v1.js";
public static final String OM_JS_URL_SERVICE = "unity-ads-cache://unity.ads.asset/ad-viewer/omsdk-v1.js";
public static final String OM_JS_URL_SESSION = "unity-ads-cache://unity.ads.asset/ad-viewer/omid-session-client-v1.js";
public static final String OM_PARTNER_NAME = "Unity3d";
public static final String OM_PARTNER_VERSION = "1";
public static final long OM_SESSION_FINISH_DELAY_MS = 1000;
private OpenMeasurement() {
}
}
public static final class Cache {
public static final String CACHE_SCHEME = "unity-ads-cache";
public static final Cache INSTANCE = new Cache();
private Cache() {
}
}
public static final class AdOperations {
public static final int GET_TOKEN_TIMEOUT_MS = 5000;
public static final AdOperations INSTANCE = new AdOperations();
public static final int LOAD_TIMEOUT_MS = 30000;
public static final int SHOW_TIMEOUT_MS = 10000;
private AdOperations() {
}
}
public static final class Preferences {
public static final Preferences INSTANCE = new Preferences();
public static final String PREF_KEY_AUID = "auid";
public static final String PREF_KEY_IDFI = "unityads-idfi";
public static final String PREF_NAME_AUID = "supersonic_shared_preferen";
public static final String PREF_NAME_IDFI = "unityads-installinfo";
private Preferences() {
}
}
public static final class ErrorHandler {
public static final int ERROR_HANDLER_STACK_TRACE_LINES_MAX = 15;
public static final ErrorHandler INSTANCE = new ErrorHandler();
private ErrorHandler() {
}
}
}

View File

@@ -0,0 +1,33 @@
package com.unity3d.services;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.jvm.internal.ContinuationImpl;
import kotlin.coroutines.jvm.internal.DebugMetadata;
@DebugMetadata(c = "com.unity3d.services.UnityAdsSDK", f = "UnityAdsSDK.kt", l = {143}, m = "fetchToken")
/* loaded from: classes4.dex */
public final class UnityAdsSDK$fetchToken$1 extends ContinuationImpl {
long J$0;
Object L$0;
Object L$1;
Object L$2;
Object L$3;
int label;
/* synthetic */ Object result;
final /* synthetic */ UnityAdsSDK this$0;
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
public UnityAdsSDK$fetchToken$1(UnityAdsSDK unityAdsSDK, Continuation continuation) {
super(continuation);
this.this$0 = unityAdsSDK;
}
@Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
public final Object invokeSuspend(Object obj) {
Object fetchToken;
this.result = obj;
this.label |= Integer.MIN_VALUE;
fetchToken = this.this$0.fetchToken(null, this);
return fetchToken;
}
}

View File

@@ -0,0 +1,92 @@
package com.unity3d.services;
import kotlin.Unit;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.jvm.internal.DebugMetadata;
import kotlin.coroutines.jvm.internal.SuspendLambda;
import kotlin.jvm.functions.Function2;
import kotlin.jvm.internal.SourceDebugExtension;
import kotlinx.coroutines.CoroutineScope;
@DebugMetadata(c = "com.unity3d.services.UnityAdsSDK$finishOMIDSession$1", f = "UnityAdsSDK.kt", l = {170, 171}, m = "invokeSuspend")
@SourceDebugExtension({"SMAP\nUnityAdsSDK.kt\nKotlin\n*S Kotlin\n*F\n+ 1 UnityAdsSDK.kt\ncom/unity3d/services/UnityAdsSDK$finishOMIDSession$1\n+ 2 fake.kt\nkotlin/jvm/internal/FakeKt\n*L\n1#1,177:1\n1#2:178\n*E\n"})
/* loaded from: classes4.dex */
public final class UnityAdsSDK$finishOMIDSession$1 extends SuspendLambda implements Function2 {
final /* synthetic */ CoroutineScope $omidScope;
final /* synthetic */ String $opportunityId;
int label;
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
public UnityAdsSDK$finishOMIDSession$1(String str, CoroutineScope coroutineScope, Continuation continuation) {
super(2, continuation);
this.$opportunityId = str;
this.$omidScope = coroutineScope;
}
@Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
public final Continuation create(Object obj, Continuation continuation) {
return new UnityAdsSDK$finishOMIDSession$1(this.$opportunityId, this.$omidScope, continuation);
}
@Override // kotlin.jvm.functions.Function2
public final Object invoke(CoroutineScope coroutineScope, Continuation continuation) {
return ((UnityAdsSDK$finishOMIDSession$1) create(coroutineScope, continuation)).invokeSuspend(Unit.INSTANCE);
}
/* JADX WARN: Removed duplicated region for block: B:14:0x0040 */
@Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public final java.lang.Object invokeSuspend(java.lang.Object r5) {
/*
r4 = this;
java.lang.Object r0 = kotlin.coroutines.intrinsics.IntrinsicsKt.getCOROUTINE_SUSPENDED()
int r1 = r4.label
r2 = 2
r3 = 1
if (r1 == 0) goto L1e
if (r1 == r3) goto L1a
if (r1 != r2) goto L12
kotlin.ResultKt.throwOnFailure(r5)
goto L4f
L12:
java.lang.IllegalStateException r5 = new java.lang.IllegalStateException
java.lang.String r0 = "call to 'resume' before 'invoke' with coroutine"
r5.<init>(r0)
throw r5
L1a:
kotlin.ResultKt.throwOnFailure(r5)
goto L3c
L1e:
kotlin.ResultKt.throwOnFailure(r5)
com.unity3d.services.UnityAdsSDK r5 = com.unity3d.services.UnityAdsSDK.INSTANCE
com.unity3d.ads.core.configuration.AlternativeFlowReader r1 = com.unity3d.services.UnityAdsSDK.access$getAlternativeFlowReader(r5)
boolean r1 = r1.invoke()
if (r1 == 0) goto L4f
com.unity3d.ads.core.domain.GetAdObject r5 = com.unity3d.services.UnityAdsSDK.access$getGetAdObject(r5)
java.lang.String r1 = r4.$opportunityId
r4.label = r3
java.lang.Object r5 = r5.invoke(r1, r4)
if (r5 != r0) goto L3c
return r0
L3c:
com.unity3d.ads.core.data.model.AdObject r5 = (com.unity3d.ads.core.data.model.AdObject) r5
if (r5 == 0) goto L4f
com.unity3d.services.UnityAdsSDK r1 = com.unity3d.services.UnityAdsSDK.INSTANCE
com.unity3d.ads.core.domain.om.OmFinishSession r1 = com.unity3d.services.UnityAdsSDK.access$getOmFinishSession(r1)
r4.label = r2
java.lang.Object r5 = r1.invoke(r5, r4)
if (r5 != r0) goto L4f
return r0
L4f:
kotlinx.coroutines.CoroutineScope r5 = r4.$omidScope
r0 = 0
kotlinx.coroutines.CoroutineScopeKt.cancel$default(r5, r0, r3, r0)
kotlin.Unit r5 = kotlin.Unit.INSTANCE
return r5
*/
throw new UnsupportedOperationException("Method not decompiled: com.unity3d.services.UnityAdsSDK$finishOMIDSession$1.invokeSuspend(java.lang.Object):java.lang.Object");
}
}

View File

@@ -0,0 +1,52 @@
package com.unity3d.services;
import kotlin.ResultKt;
import kotlin.Unit;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.intrinsics.IntrinsicsKt__IntrinsicsKt;
import kotlin.coroutines.jvm.internal.DebugMetadata;
import kotlin.coroutines.jvm.internal.SuspendLambda;
import kotlin.jvm.functions.Function2;
import kotlinx.coroutines.CoroutineScope;
@DebugMetadata(c = "com.unity3d.services.UnityAdsSDK$getToken$1", f = "UnityAdsSDK.kt", l = {115}, m = "invokeSuspend")
/* loaded from: classes4.dex */
public final class UnityAdsSDK$getToken$1 extends SuspendLambda implements Function2 {
int label;
public UnityAdsSDK$getToken$1(Continuation continuation) {
super(2, continuation);
}
@Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
public final Continuation create(Object obj, Continuation continuation) {
return new UnityAdsSDK$getToken$1(continuation);
}
@Override // kotlin.jvm.functions.Function2
public final Object invoke(CoroutineScope coroutineScope, Continuation continuation) {
return ((UnityAdsSDK$getToken$1) create(coroutineScope, continuation)).invokeSuspend(Unit.INSTANCE);
}
@Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
public final Object invokeSuspend(Object obj) {
Object coroutine_suspended;
coroutine_suspended = IntrinsicsKt__IntrinsicsKt.getCOROUTINE_SUSPENDED();
int i = this.label;
if (i == 0) {
ResultKt.throwOnFailure(obj);
UnityAdsSDK unityAdsSDK = UnityAdsSDK.INSTANCE;
this.label = 1;
obj = unityAdsSDK.fetchToken("true", this);
if (obj == coroutine_suspended) {
return coroutine_suspended;
}
} else {
if (i != 1) {
throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
}
ResultKt.throwOnFailure(obj);
}
return obj;
}
}

View File

@@ -0,0 +1,65 @@
package com.unity3d.services;
import com.unity3d.ads.IUnityAdsTokenListener;
import com.unity3d.ads.core.domain.GetAsyncHeaderBiddingToken;
import kotlin.Lazy;
import kotlin.ResultKt;
import kotlin.Unit;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.intrinsics.IntrinsicsKt__IntrinsicsKt;
import kotlin.coroutines.jvm.internal.DebugMetadata;
import kotlin.coroutines.jvm.internal.SuspendLambda;
import kotlin.jvm.functions.Function2;
import kotlinx.coroutines.CoroutineScope;
import kotlinx.coroutines.CoroutineScopeKt;
@DebugMetadata(c = "com.unity3d.services.UnityAdsSDK$getToken$2", f = "UnityAdsSDK.kt", l = {122}, m = "invokeSuspend")
/* loaded from: classes4.dex */
public final class UnityAdsSDK$getToken$2 extends SuspendLambda implements Function2 {
final /* synthetic */ Lazy $getAsyncHeaderBiddingToken$delegate;
final /* synthetic */ CoroutineScope $getTokenScope;
final /* synthetic */ IUnityAdsTokenListener $listener;
int label;
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
public UnityAdsSDK$getToken$2(IUnityAdsTokenListener iUnityAdsTokenListener, CoroutineScope coroutineScope, Lazy lazy, Continuation continuation) {
super(2, continuation);
this.$listener = iUnityAdsTokenListener;
this.$getTokenScope = coroutineScope;
this.$getAsyncHeaderBiddingToken$delegate = lazy;
}
@Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
public final Continuation create(Object obj, Continuation continuation) {
return new UnityAdsSDK$getToken$2(this.$listener, this.$getTokenScope, this.$getAsyncHeaderBiddingToken$delegate, continuation);
}
@Override // kotlin.jvm.functions.Function2
public final Object invoke(CoroutineScope coroutineScope, Continuation continuation) {
return ((UnityAdsSDK$getToken$2) create(coroutineScope, continuation)).invokeSuspend(Unit.INSTANCE);
}
@Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
public final Object invokeSuspend(Object obj) {
Object coroutine_suspended;
GetAsyncHeaderBiddingToken token$lambda$0;
coroutine_suspended = IntrinsicsKt__IntrinsicsKt.getCOROUTINE_SUSPENDED();
int i = this.label;
if (i == 0) {
ResultKt.throwOnFailure(obj);
token$lambda$0 = UnityAdsSDK.getToken$lambda$0(this.$getAsyncHeaderBiddingToken$delegate);
IUnityAdsTokenListener iUnityAdsTokenListener = this.$listener;
this.label = 1;
if (token$lambda$0.invoke(iUnityAdsTokenListener, this) == coroutine_suspended) {
return coroutine_suspended;
}
} else {
if (i != 1) {
throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
}
ResultKt.throwOnFailure(obj);
}
CoroutineScopeKt.cancel$default(this.$getTokenScope, null, 1, null);
return Unit.INSTANCE;
}
}

View File

@@ -0,0 +1,78 @@
package com.unity3d.services;
import com.unity3d.ads.core.configuration.AlternativeFlowReader;
import com.unity3d.ads.core.domain.InitializeBoldSDK;
import com.unity3d.services.core.domain.task.EmptyParams;
import com.unity3d.services.core.domain.task.InitializeSDK;
import kotlin.Result;
import kotlin.ResultKt;
import kotlin.Unit;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.intrinsics.IntrinsicsKt__IntrinsicsKt;
import kotlin.coroutines.jvm.internal.DebugMetadata;
import kotlin.coroutines.jvm.internal.SuspendLambda;
import kotlin.jvm.functions.Function2;
import kotlinx.coroutines.CoroutineScope;
import kotlinx.coroutines.CoroutineScopeKt;
@DebugMetadata(c = "com.unity3d.services.UnityAdsSDK$initialize$1", f = "UnityAdsSDK.kt", l = {75, 77}, m = "invokeSuspend")
/* loaded from: classes4.dex */
public final class UnityAdsSDK$initialize$1 extends SuspendLambda implements Function2 {
final /* synthetic */ CoroutineScope $initScope;
int label;
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
public UnityAdsSDK$initialize$1(CoroutineScope coroutineScope, Continuation continuation) {
super(2, continuation);
this.$initScope = coroutineScope;
}
@Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
public final Continuation create(Object obj, Continuation continuation) {
return new UnityAdsSDK$initialize$1(this.$initScope, continuation);
}
@Override // kotlin.jvm.functions.Function2
public final Object invoke(CoroutineScope coroutineScope, Continuation continuation) {
return ((UnityAdsSDK$initialize$1) create(coroutineScope, continuation)).invokeSuspend(Unit.INSTANCE);
}
@Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
public final Object invokeSuspend(Object obj) {
Object coroutine_suspended;
AlternativeFlowReader alternativeFlowReader;
InitializeSDK initializeSDK;
InitializeBoldSDK initializeBoldSDK;
coroutine_suspended = IntrinsicsKt__IntrinsicsKt.getCOROUTINE_SUSPENDED();
int i = this.label;
if (i == 0) {
ResultKt.throwOnFailure(obj);
UnityAdsSDK unityAdsSDK = UnityAdsSDK.INSTANCE;
alternativeFlowReader = unityAdsSDK.getAlternativeFlowReader();
if (alternativeFlowReader.invoke()) {
initializeBoldSDK = unityAdsSDK.getInitializeBoldSDK();
this.label = 1;
if (initializeBoldSDK.invoke(this) == coroutine_suspended) {
return coroutine_suspended;
}
} else {
initializeSDK = unityAdsSDK.getInitializeSDK();
EmptyParams emptyParams = EmptyParams.INSTANCE;
this.label = 2;
if (initializeSDK.mo3761invokegIAlus(emptyParams, this) == coroutine_suspended) {
return coroutine_suspended;
}
}
} else if (i == 1) {
ResultKt.throwOnFailure(obj);
} else {
if (i != 2) {
throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
}
ResultKt.throwOnFailure(obj);
((Result) obj).m4067unboximpl();
}
CoroutineScopeKt.cancel$default(this.$initScope, null, 1, null);
return Unit.INSTANCE;
}
}

View File

@@ -0,0 +1,79 @@
package com.unity3d.services;
import android.content.Context;
import com.unity3d.ads.IUnityAdsLoadListener;
import com.unity3d.ads.UnityAdsLoadOptions;
import com.unity3d.ads.core.domain.LegacyLoadUseCase;
import com.unity3d.services.banners.UnityBannerSize;
import kotlin.ResultKt;
import kotlin.Unit;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.intrinsics.IntrinsicsKt__IntrinsicsKt;
import kotlin.coroutines.jvm.internal.DebugMetadata;
import kotlin.coroutines.jvm.internal.SuspendLambda;
import kotlin.jvm.functions.Function2;
import kotlin.jvm.internal.Reflection;
import kotlin.jvm.internal.SourceDebugExtension;
import kotlinx.coroutines.CoroutineScope;
import kotlinx.coroutines.CoroutineScopeKt;
@DebugMetadata(c = "com.unity3d.services.UnityAdsSDK$load$1", f = "UnityAdsSDK.kt", l = {94}, m = "invokeSuspend")
@SourceDebugExtension({"SMAP\nUnityAdsSDK.kt\nKotlin\n*S Kotlin\n*F\n+ 1 UnityAdsSDK.kt\ncom/unity3d/services/UnityAdsSDK$load$1\n+ 2 IServiceComponent.kt\ncom/unity3d/services/core/di/IServiceComponentKt\n*L\n1#1,177:1\n16#2,4:178\n*S KotlinDebug\n*F\n+ 1 UnityAdsSDK.kt\ncom/unity3d/services/UnityAdsSDK$load$1\n*L\n93#1:178,4\n*E\n"})
/* loaded from: classes4.dex */
public final class UnityAdsSDK$load$1 extends SuspendLambda implements Function2 {
final /* synthetic */ UnityBannerSize $bannerSize;
final /* synthetic */ IUnityAdsLoadListener $listener;
final /* synthetic */ UnityAdsLoadOptions $loadOptions;
final /* synthetic */ CoroutineScope $loadScope;
final /* synthetic */ String $placementId;
int label;
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
public UnityAdsSDK$load$1(String str, UnityAdsLoadOptions unityAdsLoadOptions, IUnityAdsLoadListener iUnityAdsLoadListener, UnityBannerSize unityBannerSize, CoroutineScope coroutineScope, Continuation continuation) {
super(2, continuation);
this.$placementId = str;
this.$loadOptions = unityAdsLoadOptions;
this.$listener = iUnityAdsLoadListener;
this.$bannerSize = unityBannerSize;
this.$loadScope = coroutineScope;
}
@Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
public final Continuation create(Object obj, Continuation continuation) {
return new UnityAdsSDK$load$1(this.$placementId, this.$loadOptions, this.$listener, this.$bannerSize, this.$loadScope, continuation);
}
@Override // kotlin.jvm.functions.Function2
public final Object invoke(CoroutineScope coroutineScope, Continuation continuation) {
return ((UnityAdsSDK$load$1) create(coroutineScope, continuation)).invokeSuspend(Unit.INSTANCE);
}
@Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
public final Object invokeSuspend(Object obj) {
Object coroutine_suspended;
Context context;
coroutine_suspended = IntrinsicsKt__IntrinsicsKt.getCOROUTINE_SUSPENDED();
int i = this.label;
if (i == 0) {
ResultKt.throwOnFailure(obj);
UnityAdsSDK unityAdsSDK = UnityAdsSDK.INSTANCE;
LegacyLoadUseCase legacyLoadUseCase = (LegacyLoadUseCase) unityAdsSDK.getServiceProvider().getRegistry().getService("", Reflection.getOrCreateKotlinClass(LegacyLoadUseCase.class));
context = unityAdsSDK.getContext();
String str = this.$placementId;
UnityAdsLoadOptions unityAdsLoadOptions = this.$loadOptions;
IUnityAdsLoadListener iUnityAdsLoadListener = this.$listener;
UnityBannerSize unityBannerSize = this.$bannerSize;
this.label = 1;
if (legacyLoadUseCase.invoke(context, str, unityAdsLoadOptions, iUnityAdsLoadListener, unityBannerSize, this) == coroutine_suspended) {
return coroutine_suspended;
}
} else {
if (i != 1) {
throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
}
ResultKt.throwOnFailure(obj);
}
CoroutineScopeKt.cancel$default(this.$loadScope, null, 1, null);
return Unit.INSTANCE;
}
}

View File

@@ -0,0 +1,73 @@
package com.unity3d.services;
import android.content.Context;
import com.unity3d.ads.UnityAdsShowOptions;
import com.unity3d.ads.core.data.model.Listeners;
import com.unity3d.ads.core.domain.LegacyShowUseCase;
import kotlin.ResultKt;
import kotlin.Unit;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.intrinsics.IntrinsicsKt__IntrinsicsKt;
import kotlin.coroutines.jvm.internal.DebugMetadata;
import kotlin.coroutines.jvm.internal.SuspendLambda;
import kotlin.jvm.functions.Function2;
import kotlinx.coroutines.CoroutineScope;
import kotlinx.coroutines.CoroutineScopeKt;
@DebugMetadata(c = "com.unity3d.services.UnityAdsSDK$show$1", f = "UnityAdsSDK.kt", l = {104}, m = "invokeSuspend")
/* loaded from: classes4.dex */
public final class UnityAdsSDK$show$1 extends SuspendLambda implements Function2 {
final /* synthetic */ Listeners $listener;
final /* synthetic */ String $placementId;
final /* synthetic */ LegacyShowUseCase $showBoldSDK;
final /* synthetic */ UnityAdsShowOptions $showOptions;
final /* synthetic */ CoroutineScope $showScope;
int label;
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
public UnityAdsSDK$show$1(LegacyShowUseCase legacyShowUseCase, String str, UnityAdsShowOptions unityAdsShowOptions, Listeners listeners, CoroutineScope coroutineScope, Continuation continuation) {
super(2, continuation);
this.$showBoldSDK = legacyShowUseCase;
this.$placementId = str;
this.$showOptions = unityAdsShowOptions;
this.$listener = listeners;
this.$showScope = coroutineScope;
}
@Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
public final Continuation create(Object obj, Continuation continuation) {
return new UnityAdsSDK$show$1(this.$showBoldSDK, this.$placementId, this.$showOptions, this.$listener, this.$showScope, continuation);
}
@Override // kotlin.jvm.functions.Function2
public final Object invoke(CoroutineScope coroutineScope, Continuation continuation) {
return ((UnityAdsSDK$show$1) create(coroutineScope, continuation)).invokeSuspend(Unit.INSTANCE);
}
@Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
public final Object invokeSuspend(Object obj) {
Object coroutine_suspended;
Context context;
coroutine_suspended = IntrinsicsKt__IntrinsicsKt.getCOROUTINE_SUSPENDED();
int i = this.label;
if (i == 0) {
ResultKt.throwOnFailure(obj);
LegacyShowUseCase legacyShowUseCase = this.$showBoldSDK;
context = UnityAdsSDK.INSTANCE.getContext();
String str = this.$placementId;
UnityAdsShowOptions unityAdsShowOptions = this.$showOptions;
Listeners listeners = this.$listener;
this.label = 1;
if (legacyShowUseCase.invoke(context, str, unityAdsShowOptions, listeners, this) == coroutine_suspended) {
return coroutine_suspended;
}
} else {
if (i != 1) {
throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
}
ResultKt.throwOnFailure(obj);
}
CoroutineScopeKt.cancel$default(this.$showScope, null, 1, null);
return Unit.INSTANCE;
}
}

View File

@@ -0,0 +1,342 @@
package com.unity3d.services;
import android.content.Context;
import com.unity3d.ads.IUnityAdsLoadListener;
import com.unity3d.ads.IUnityAdsTokenListener;
import com.unity3d.ads.UnityAdsLoadOptions;
import com.unity3d.ads.UnityAdsShowOptions;
import com.unity3d.ads.core.configuration.AlternativeFlowReader;
import com.unity3d.ads.core.data.model.InitializationState;
import com.unity3d.ads.core.data.model.Listeners;
import com.unity3d.ads.core.domain.GetAdObject;
import com.unity3d.ads.core.domain.GetAsyncHeaderBiddingToken;
import com.unity3d.ads.core.domain.GetHeaderBiddingToken;
import com.unity3d.ads.core.domain.GetInitializationState;
import com.unity3d.ads.core.domain.InitializeBoldSDK;
import com.unity3d.ads.core.domain.LegacyShowUseCase;
import com.unity3d.ads.core.domain.SendDiagnosticEvent;
import com.unity3d.ads.core.domain.SetInitializationState;
import com.unity3d.ads.core.domain.om.OmFinishSession;
import com.unity3d.services.banners.UnityBannerSize;
import com.unity3d.services.core.di.IServiceComponent;
import com.unity3d.services.core.di.IServiceProvider;
import com.unity3d.services.core.di.ServiceProvider;
import com.unity3d.services.core.domain.task.InitializeSDK;
import kotlin.Lazy;
import kotlin.LazyKt__LazyJVMKt;
import kotlin.LazyThreadSafetyMode;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.Reflection;
import kotlin.jvm.internal.SourceDebugExtension;
import kotlinx.coroutines.BuildersKt__BuildersKt;
import kotlinx.coroutines.BuildersKt__Builders_commonKt;
import kotlinx.coroutines.CoroutineScope;
import kotlinx.coroutines.Job;
@SourceDebugExtension({"SMAP\nUnityAdsSDK.kt\nKotlin\n*S Kotlin\n*F\n+ 1 UnityAdsSDK.kt\ncom/unity3d/services/UnityAdsSDK\n+ 2 IServiceComponent.kt\ncom/unity3d/services/core/di/IServiceComponentKt\n+ 3 fake.kt\nkotlin/jvm/internal/FakeKt\n*L\n1#1,177:1\n19#2:178\n19#2:179\n19#2:180\n16#2,4:181\n29#2,5:185\n19#2:190\n29#2,5:191\n19#2:197\n29#2,5:198\n29#2,5:203\n29#2,5:208\n29#2,5:213\n29#2,5:218\n29#2,5:223\n29#2,5:228\n29#2,5:233\n29#2,5:238\n1#3:196\n*S KotlinDebug\n*F\n+ 1 UnityAdsSDK.kt\ncom/unity3d/services/UnityAdsSDK\n*L\n70#1:178\n90#1:179\n100#1:180\n101#1:181,4\n119#1:185,5\n120#1:190\n128#1:191,5\n166#1:197\n49#1:198,5\n50#1:203,5\n51#1:208,5\n52#1:213,5\n53#1:218,5\n54#1:223,5\n55#1:228,5\n56#1:233,5\n57#1:238,5\n*E\n"})
/* loaded from: classes4.dex */
public final class UnityAdsSDK implements IServiceComponent {
public static final UnityAdsSDK INSTANCE;
private static final Lazy alternativeFlowReader$delegate;
private static final Lazy context$delegate;
private static final Lazy getAdObject$delegate;
private static final Lazy getInitializationState$delegate;
private static final Lazy initializeBoldSDK$delegate;
private static final Lazy initializeSDK$delegate;
private static final Lazy omFinishSession$delegate;
private static final Lazy sendDiagnosticEvent$delegate;
private static final Lazy setInitializationState$delegate;
public final void finishOMIDSession(String opportunityId) {
Intrinsics.checkNotNullParameter(opportunityId, "opportunityId");
CoroutineScope coroutineScope = (CoroutineScope) getServiceProvider().getRegistry().getService(ServiceProvider.NAMED_OMID_SCOPE, Reflection.getOrCreateKotlinClass(CoroutineScope.class));
BuildersKt__Builders_commonKt.launch$default(coroutineScope, null, null, new UnityAdsSDK$finishOMIDSession$1(opportunityId, coroutineScope, null), 3, null);
}
public final Job load(String str, UnityAdsLoadOptions loadOptions, IUnityAdsLoadListener iUnityAdsLoadListener, UnityBannerSize unityBannerSize) {
Job launch$default;
Intrinsics.checkNotNullParameter(loadOptions, "loadOptions");
CoroutineScope coroutineScope = (CoroutineScope) getServiceProvider().getRegistry().getService(ServiceProvider.NAMED_LOAD_SCOPE, Reflection.getOrCreateKotlinClass(CoroutineScope.class));
launch$default = BuildersKt__Builders_commonKt.launch$default(coroutineScope, null, null, new UnityAdsSDK$load$1(str, loadOptions, iUnityAdsLoadListener, unityBannerSize, coroutineScope, null), 3, null);
return launch$default;
}
public final Job show(String str, UnityAdsShowOptions unityAdsShowOptions, Listeners listener) {
Job launch$default;
Intrinsics.checkNotNullParameter(listener, "listener");
CoroutineScope coroutineScope = (CoroutineScope) getServiceProvider().getRegistry().getService(ServiceProvider.NAMED_SHOW_SCOPE, Reflection.getOrCreateKotlinClass(CoroutineScope.class));
launch$default = BuildersKt__Builders_commonKt.launch$default(coroutineScope, null, null, new UnityAdsSDK$show$1((LegacyShowUseCase) getServiceProvider().getRegistry().getService("", Reflection.getOrCreateKotlinClass(LegacyShowUseCase.class)), str, unityAdsShowOptions, listener, coroutineScope, null), 3, null);
return launch$default;
}
static {
Lazy lazy;
Lazy lazy2;
Lazy lazy3;
Lazy lazy4;
Lazy lazy5;
Lazy lazy6;
Lazy lazy7;
Lazy lazy8;
Lazy lazy9;
final UnityAdsSDK unityAdsSDK = new UnityAdsSDK();
INSTANCE = unityAdsSDK;
LazyThreadSafetyMode lazyThreadSafetyMode = LazyThreadSafetyMode.NONE;
final String str = "";
lazy = LazyKt__LazyJVMKt.lazy(lazyThreadSafetyMode, new Function0() { // from class: com.unity3d.services.UnityAdsSDK$special$$inlined$inject$default$1
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
{
super(0);
}
/* JADX WARN: Type inference failed for: r0v3, types: [com.unity3d.services.core.domain.task.InitializeSDK, java.lang.Object] */
@Override // kotlin.jvm.functions.Function0
public final InitializeSDK invoke() {
IServiceComponent iServiceComponent = IServiceComponent.this;
return iServiceComponent.getServiceProvider().getRegistry().getService(str, Reflection.getOrCreateKotlinClass(InitializeSDK.class));
}
});
initializeSDK$delegate = lazy;
lazy2 = LazyKt__LazyJVMKt.lazy(lazyThreadSafetyMode, new Function0() { // from class: com.unity3d.services.UnityAdsSDK$special$$inlined$inject$default$2
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
{
super(0);
}
/* JADX WARN: Type inference failed for: r0v3, types: [com.unity3d.ads.core.configuration.AlternativeFlowReader, java.lang.Object] */
@Override // kotlin.jvm.functions.Function0
public final AlternativeFlowReader invoke() {
IServiceComponent iServiceComponent = IServiceComponent.this;
return iServiceComponent.getServiceProvider().getRegistry().getService(str, Reflection.getOrCreateKotlinClass(AlternativeFlowReader.class));
}
});
alternativeFlowReader$delegate = lazy2;
lazy3 = LazyKt__LazyJVMKt.lazy(lazyThreadSafetyMode, new Function0() { // from class: com.unity3d.services.UnityAdsSDK$special$$inlined$inject$default$3
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
{
super(0);
}
/* JADX WARN: Type inference failed for: r0v3, types: [com.unity3d.ads.core.domain.InitializeBoldSDK, java.lang.Object] */
@Override // kotlin.jvm.functions.Function0
public final InitializeBoldSDK invoke() {
IServiceComponent iServiceComponent = IServiceComponent.this;
return iServiceComponent.getServiceProvider().getRegistry().getService(str, Reflection.getOrCreateKotlinClass(InitializeBoldSDK.class));
}
});
initializeBoldSDK$delegate = lazy3;
lazy4 = LazyKt__LazyJVMKt.lazy(lazyThreadSafetyMode, new Function0() { // from class: com.unity3d.services.UnityAdsSDK$special$$inlined$inject$default$4
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
{
super(0);
}
/* JADX WARN: Type inference failed for: r0v3, types: [com.unity3d.ads.core.domain.GetInitializationState, java.lang.Object] */
@Override // kotlin.jvm.functions.Function0
public final GetInitializationState invoke() {
IServiceComponent iServiceComponent = IServiceComponent.this;
return iServiceComponent.getServiceProvider().getRegistry().getService(str, Reflection.getOrCreateKotlinClass(GetInitializationState.class));
}
});
getInitializationState$delegate = lazy4;
lazy5 = LazyKt__LazyJVMKt.lazy(lazyThreadSafetyMode, new Function0() { // from class: com.unity3d.services.UnityAdsSDK$special$$inlined$inject$default$5
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
{
super(0);
}
/* JADX WARN: Type inference failed for: r0v3, types: [com.unity3d.ads.core.domain.SendDiagnosticEvent, java.lang.Object] */
@Override // kotlin.jvm.functions.Function0
public final SendDiagnosticEvent invoke() {
IServiceComponent iServiceComponent = IServiceComponent.this;
return iServiceComponent.getServiceProvider().getRegistry().getService(str, Reflection.getOrCreateKotlinClass(SendDiagnosticEvent.class));
}
});
sendDiagnosticEvent$delegate = lazy5;
lazy6 = LazyKt__LazyJVMKt.lazy(lazyThreadSafetyMode, new Function0() { // from class: com.unity3d.services.UnityAdsSDK$special$$inlined$inject$default$6
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
{
super(0);
}
/* JADX WARN: Type inference failed for: r0v3, types: [com.unity3d.ads.core.domain.om.OmFinishSession, java.lang.Object] */
@Override // kotlin.jvm.functions.Function0
public final OmFinishSession invoke() {
IServiceComponent iServiceComponent = IServiceComponent.this;
return iServiceComponent.getServiceProvider().getRegistry().getService(str, Reflection.getOrCreateKotlinClass(OmFinishSession.class));
}
});
omFinishSession$delegate = lazy6;
lazy7 = LazyKt__LazyJVMKt.lazy(lazyThreadSafetyMode, new Function0() { // from class: com.unity3d.services.UnityAdsSDK$special$$inlined$inject$default$7
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
{
super(0);
}
/* JADX WARN: Type inference failed for: r0v3, types: [com.unity3d.ads.core.domain.GetAdObject, java.lang.Object] */
@Override // kotlin.jvm.functions.Function0
public final GetAdObject invoke() {
IServiceComponent iServiceComponent = IServiceComponent.this;
return iServiceComponent.getServiceProvider().getRegistry().getService(str, Reflection.getOrCreateKotlinClass(GetAdObject.class));
}
});
getAdObject$delegate = lazy7;
lazy8 = LazyKt__LazyJVMKt.lazy(lazyThreadSafetyMode, new Function0() { // from class: com.unity3d.services.UnityAdsSDK$special$$inlined$inject$default$8
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
{
super(0);
}
/* JADX WARN: Type inference failed for: r0v3, types: [com.unity3d.ads.core.domain.SetInitializationState, java.lang.Object] */
@Override // kotlin.jvm.functions.Function0
public final SetInitializationState invoke() {
IServiceComponent iServiceComponent = IServiceComponent.this;
return iServiceComponent.getServiceProvider().getRegistry().getService(str, Reflection.getOrCreateKotlinClass(SetInitializationState.class));
}
});
setInitializationState$delegate = lazy8;
lazy9 = LazyKt__LazyJVMKt.lazy(lazyThreadSafetyMode, new Function0() { // from class: com.unity3d.services.UnityAdsSDK$special$$inlined$inject$default$9
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
{
super(0);
}
/* JADX WARN: Type inference failed for: r0v3, types: [android.content.Context, java.lang.Object] */
@Override // kotlin.jvm.functions.Function0
public final Context invoke() {
IServiceComponent iServiceComponent = IServiceComponent.this;
return iServiceComponent.getServiceProvider().getRegistry().getService(str, Reflection.getOrCreateKotlinClass(Context.class));
}
});
context$delegate = lazy9;
}
public final void getToken(IUnityAdsTokenListener iUnityAdsTokenListener) {
Lazy lazy;
final String str = "";
lazy = LazyKt__LazyJVMKt.lazy(LazyThreadSafetyMode.NONE, new Function0() { // from class: com.unity3d.services.UnityAdsSDK$getToken$$inlined$inject$default$1
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
{
super(0);
}
/* JADX WARN: Type inference failed for: r0v3, types: [com.unity3d.ads.core.domain.GetAsyncHeaderBiddingToken, java.lang.Object] */
@Override // kotlin.jvm.functions.Function0
public final GetAsyncHeaderBiddingToken invoke() {
IServiceComponent iServiceComponent = IServiceComponent.this;
return iServiceComponent.getServiceProvider().getRegistry().getService(str, Reflection.getOrCreateKotlinClass(GetAsyncHeaderBiddingToken.class));
}
});
CoroutineScope coroutineScope = (CoroutineScope) getServiceProvider().getRegistry().getService(ServiceProvider.NAMED_GET_TOKEN_SCOPE, Reflection.getOrCreateKotlinClass(CoroutineScope.class));
BuildersKt__Builders_commonKt.launch$default(coroutineScope, null, null, new UnityAdsSDK$getToken$2(iUnityAdsTokenListener, coroutineScope, lazy, null), 3, null);
}
private UnityAdsSDK() {
}
@Override // com.unity3d.services.core.di.IServiceComponent
public IServiceProvider getServiceProvider() {
return IServiceComponent.DefaultImpls.getServiceProvider(this);
}
/* JADX INFO: Access modifiers changed from: private */
public final InitializeSDK getInitializeSDK() {
return (InitializeSDK) initializeSDK$delegate.getValue();
}
/* JADX INFO: Access modifiers changed from: private */
public final AlternativeFlowReader getAlternativeFlowReader() {
return (AlternativeFlowReader) alternativeFlowReader$delegate.getValue();
}
/* JADX INFO: Access modifiers changed from: private */
public final InitializeBoldSDK getInitializeBoldSDK() {
return (InitializeBoldSDK) initializeBoldSDK$delegate.getValue();
}
private final GetInitializationState getGetInitializationState() {
return (GetInitializationState) getInitializationState$delegate.getValue();
}
private final SendDiagnosticEvent getSendDiagnosticEvent() {
return (SendDiagnosticEvent) sendDiagnosticEvent$delegate.getValue();
}
/* JADX INFO: Access modifiers changed from: private */
public final OmFinishSession getOmFinishSession() {
return (OmFinishSession) omFinishSession$delegate.getValue();
}
/* JADX INFO: Access modifiers changed from: private */
public final GetAdObject getGetAdObject() {
return (GetAdObject) getAdObject$delegate.getValue();
}
private final SetInitializationState getSetInitializationState() {
return (SetInitializationState) setInitializationState$delegate.getValue();
}
/* JADX INFO: Access modifiers changed from: private */
public final Context getContext() {
return (Context) context$delegate.getValue();
}
public final boolean isAlternativeFlowEnabled() {
return getAlternativeFlowReader().invoke();
}
public final void initialize() {
getSetInitializationState().invoke(InitializationState.INITIALIZING);
CoroutineScope coroutineScope = (CoroutineScope) getServiceProvider().getRegistry().getService(ServiceProvider.NAMED_INIT_SCOPE, Reflection.getOrCreateKotlinClass(CoroutineScope.class));
BuildersKt__Builders_commonKt.launch$default(coroutineScope, null, null, new UnityAdsSDK$initialize$1(coroutineScope, null), 3, null);
}
public static /* synthetic */ Job load$default(UnityAdsSDK unityAdsSDK, String str, UnityAdsLoadOptions unityAdsLoadOptions, IUnityAdsLoadListener iUnityAdsLoadListener, UnityBannerSize unityBannerSize, int i, Object obj) {
if ((i & 8) != 0) {
unityBannerSize = null;
}
return unityAdsSDK.load(str, unityAdsLoadOptions, iUnityAdsLoadListener, unityBannerSize);
}
public final String getToken() {
Object runBlocking$default;
runBlocking$default = BuildersKt__BuildersKt.runBlocking$default(null, new UnityAdsSDK$getToken$1(null), 1, null);
return (String) runBlocking$default;
}
/* JADX INFO: Access modifiers changed from: private */
public static final GetAsyncHeaderBiddingToken getToken$lambda$0(Lazy lazy) {
return (GetAsyncHeaderBiddingToken) lazy.getValue();
}
/* JADX INFO: Access modifiers changed from: private */
/* JADX WARN: Can't wrap try/catch for region: R(20:0|1|(2:3|(16:5|6|(1:(4:9|10|11|12)(2:37|38))(2:39|(10:41|17|(1:19)(1:30)|20|21|(1:23)|24|(1:26)|27|28)(3:42|43|(1:45)(1:46)))|13|14|15|16|17|(0)(0)|20|21|(0)|24|(0)|27|28))|50|6|(0)(0)|13|14|15|16|17|(0)(0)|20|21|(0)|24|(0)|27|28|(1:(0))) */
/* JADX WARN: Code restructure failed: missing block: B:32:0x00d6, code lost:
r0 = e;
*/
/* JADX WARN: Multi-variable type inference failed */
/* JADX WARN: Removed duplicated region for block: B:19:0x00ed */
/* JADX WARN: Removed duplicated region for block: B:23:0x011f */
/* JADX WARN: Removed duplicated region for block: B:26:0x012e */
/* JADX WARN: Removed duplicated region for block: B:30:0x00f1 */
/* JADX WARN: Removed duplicated region for block: B:39:0x0056 */
/* JADX WARN: Removed duplicated region for block: B:8:0x002e */
/* JADX WARN: Type inference failed for: r0v9, types: [T, java.lang.String] */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public final java.lang.Object fetchToken(java.lang.String r22, kotlin.coroutines.Continuation r23) {
/*
Method dump skipped, instructions count: 325
To view this dump add '--comments-level debug' option
*/
throw new UnsupportedOperationException("Method not decompiled: com.unity3d.services.UnityAdsSDK.fetchToken(java.lang.String, kotlin.coroutines.Continuation):java.lang.Object");
}
private static final GetHeaderBiddingToken fetchToken$lambda$1(Lazy lazy) {
return (GetHeaderBiddingToken) lazy.getValue();
}
}

View File

@@ -0,0 +1,209 @@
package com.unity3d.services;
import android.app.Activity;
import android.app.Application;
import android.content.Context;
import com.unity3d.ads.IUnityAdsInitializationListener;
import com.unity3d.ads.UnityAds;
import com.unity3d.services.core.configuration.EnvironmentCheck;
import com.unity3d.services.core.configuration.InitializeEventsMetricSender;
import com.unity3d.services.core.device.Device;
import com.unity3d.services.core.lifecycle.CachedLifecycle;
import com.unity3d.services.core.log.DeviceLog;
import com.unity3d.services.core.properties.ClientProperties;
import com.unity3d.services.core.properties.SdkProperties;
import com.unity3d.services.core.properties.Session;
import com.unity3d.services.core.request.metrics.InitMetric;
import kotlin.jvm.internal.Intrinsics;
import kotlin.text.StringsKt__StringNumberConversionsKt;
/* loaded from: classes4.dex */
public final class UnityServices {
public static final UnityServices INSTANCE = new UnityServices();
private static final boolean isSupported = true;
public enum UnityServicesError {
INVALID_ARGUMENT,
INIT_SANITY_CHECK_FAIL
}
public /* synthetic */ class WhenMappings {
public static final /* synthetic */ int[] $EnumSwitchMapping$0;
static {
int[] iArr = new int[SdkProperties.InitializationState.values().length];
try {
iArr[SdkProperties.InitializationState.INITIALIZED_SUCCESSFULLY.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
iArr[SdkProperties.InitializationState.INITIALIZED_FAILED.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
try {
iArr[SdkProperties.InitializationState.INITIALIZING.ordinal()] = 3;
} catch (NoSuchFieldError unused3) {
}
$EnumSwitchMapping$0 = iArr;
}
}
public static /* synthetic */ void getDebugMode$annotations() {
}
public static /* synthetic */ void getVersion$annotations() {
}
public static /* synthetic */ void isInitialized$annotations() {
}
public static final boolean isSupported() {
return isSupported;
}
public static /* synthetic */ void isSupported$annotations() {
}
private UnityServices() {
}
public static final void initialize(Context context, String str, boolean z, IUnityAdsInitializationListener iUnityAdsInitializationListener) {
Integer intOrNull;
String str2;
DeviceLog.entered();
if (str != null) {
intOrNull = StringsKt__StringNumberConversionsKt.toIntOrNull(str);
if (intOrNull != null) {
if (SdkProperties.getCurrentInitializationState() != SdkProperties.InitializationState.NOT_INITIALIZED) {
String gameId = ClientProperties.getGameId();
boolean isTestMode = SdkProperties.isTestMode();
StringBuilder sb = new StringBuilder();
if (gameId != null && !Intrinsics.areEqual(gameId, str)) {
InitializeEventsMetricSender.getInstance().sendMetric(InitMetric.newInitGameIdChanged(gameId, str));
sb.append(INSTANCE.createExpectedParametersString("Game ID", gameId, str));
Intrinsics.checkNotNullExpressionValue(sb, "append(value)");
sb.append('\n');
Intrinsics.checkNotNullExpressionValue(sb, "append('\\n')");
} else {
InitializeEventsMetricSender.getInstance().sendMetric(InitMetric.newInitGameIdSame(gameId, str));
}
if (isTestMode != z) {
InitializeEventsMetricSender.getInstance().sendMetric(InitMetric.newInitTestModeChanged(Boolean.valueOf(isTestMode), Boolean.valueOf(z)));
sb.append(INSTANCE.createExpectedParametersString("Test Mode", Boolean.valueOf(isTestMode), Boolean.valueOf(z)));
Intrinsics.checkNotNullExpressionValue(sb, "append(value)");
sb.append('\n');
Intrinsics.checkNotNullExpressionValue(sb, "append('\\n')");
} else {
InitializeEventsMetricSender.getInstance().sendMetric(InitMetric.newInitTestModeSame(Boolean.valueOf(isTestMode), Boolean.valueOf(z)));
}
String sb2 = sb.toString();
Intrinsics.checkNotNullExpressionValue(sb2, "StringBuilder().apply(builderAction).toString()");
if (sb2.length() > 0) {
str2 = "different parameters: \n" + sb2;
} else {
str2 = "the same Game ID: " + str + " and Test Mode: " + z + " values.";
}
DeviceLog.warning("Unity Ads SDK initialize has already been called with " + str2 + " Responding with first initialization result.");
}
SdkProperties.addInitializationListener(iUnityAdsInitializationListener);
SdkProperties.InitializationState currentInitializationState = SdkProperties.getCurrentInitializationState();
int i = currentInitializationState == null ? -1 : WhenMappings.$EnumSwitchMapping$0[currentInitializationState.ordinal()];
if (i == 1) {
SdkProperties.notifyInitializationComplete();
return;
}
if (i != 2) {
if (i == 3) {
return;
} else {
SdkProperties.setInitializeState(SdkProperties.InitializationState.INITIALIZING);
}
} else {
if (!UnityAdsSDK.INSTANCE.isAlternativeFlowEnabled()) {
SdkProperties.notifyInitializationFailed(UnityAds.UnityAdsInitializationError.INTERNAL_ERROR, "Unity Ads SDK failed to initialize due to previous failed reason");
return;
}
SdkProperties.setInitializeState(SdkProperties.InitializationState.INITIALIZING);
}
ClientProperties.setGameId(str);
SdkProperties.setTestMode(z);
if (!isSupported) {
DeviceLog.error("Error while initializing Unity Services: device is not supported");
SdkProperties.notifyInitializationFailed(UnityAds.UnityAdsInitializationError.INTERNAL_ERROR, "Unity Ads SDK failed to initialize due to device is not supported");
return;
}
SdkProperties.setInitializationTime(Device.getElapsedRealtime());
SdkProperties.setInitializationTimeSinceEpoch(System.currentTimeMillis());
if (str.length() == 0) {
DeviceLog.error("Error while initializing Unity Services: empty game ID, halting Unity Ads init");
SdkProperties.notifyInitializationFailed(UnityAds.UnityAdsInitializationError.INVALID_ARGUMENT, "Unity Ads SDK failed to initialize due to empty game ID");
return;
}
if (context == null) {
DeviceLog.error("Error while initializing Unity Services: null context, halting Unity Ads init");
SdkProperties.notifyInitializationFailed(UnityAds.UnityAdsInitializationError.INVALID_ARGUMENT, "Unity Ads SDK failed to initialize due to null context");
return;
}
if (context instanceof Application) {
ClientProperties.setApplication((Application) context);
} else if (context instanceof Activity) {
Activity activity = (Activity) context;
if (activity.getApplication() != null) {
ClientProperties.setApplication(activity.getApplication());
} else {
DeviceLog.error("Error while initializing Unity Services: cannot retrieve application from context, halting Unity Ads init");
SdkProperties.notifyInitializationFailed(UnityAds.UnityAdsInitializationError.INVALID_ARGUMENT, "Unity Ads SDK failed to initialize due to inability to retrieve application from context");
return;
}
} else {
DeviceLog.error("Error while initializing Unity Services: invalid context, halting Unity Ads init");
SdkProperties.notifyInitializationFailed(UnityAds.UnityAdsInitializationError.INVALID_ARGUMENT, "Unity Ads SDK failed to initialize due to invalid context");
return;
}
DeviceLog.info("Initializing Unity Services " + SdkProperties.getVersionName() + " (" + SdkProperties.getVersionCode() + ") with game id " + str + " in " + (z ? "test mode" : "production mode") + ", session " + Session.Default.getId());
SdkProperties.setDebugMode(SdkProperties.getDebugMode());
if (context.getApplicationContext() != null) {
ClientProperties.setApplicationContext(context.getApplicationContext());
if (!EnvironmentCheck.isEnvironmentOk()) {
DeviceLog.error("Error during Unity Services environment check, halting Unity Services init");
SdkProperties.notifyInitializationFailed(UnityAds.UnityAdsInitializationError.INTERNAL_ERROR, "Unity Ads SDK failed to initialize due to environment check failed");
return;
} else {
DeviceLog.info("Unity Services environment check OK");
CachedLifecycle.register();
UnityAdsSDK.INSTANCE.initialize();
return;
}
}
DeviceLog.error("Error while initializing Unity Services: cannot retrieve application context, halting Unity Ads init");
SdkProperties.notifyInitializationFailed(UnityAds.UnityAdsInitializationError.INVALID_ARGUMENT, "Unity Ads SDK failed to initialize due to inability to retrieve application context");
return;
}
}
if (iUnityAdsInitializationListener != null) {
iUnityAdsInitializationListener.onInitializationFailed(UnityAds.UnityAdsInitializationError.INVALID_ARGUMENT, "gameId \"" + str + "\" should be a number.");
}
}
public static final boolean isInitialized() {
return SdkProperties.isInitialized();
}
public static final String getVersion() {
String versionName = SdkProperties.getVersionName();
Intrinsics.checkNotNullExpressionValue(versionName, "getVersionName()");
return versionName;
}
public static final boolean getDebugMode() {
return SdkProperties.getDebugMode();
}
public static final void setDebugMode(boolean z) {
SdkProperties.setDebugMode(z);
}
private final String createExpectedParametersString(String str, Object obj, Object obj2) {
return "- " + str + " Current: " + obj + " | Received: " + obj2;
}
}

View File

@@ -0,0 +1,35 @@
package com.unity3d.services.ads;
import android.app.Activity;
import android.content.Context;
import androidx.annotation.Nullable;
import com.unity3d.ads.IUnityAdsInitializationListener;
import com.unity3d.ads.IUnityAdsLoadListener;
import com.unity3d.ads.IUnityAdsShowListener;
import com.unity3d.ads.IUnityAdsTokenListener;
import com.unity3d.ads.UnityAdsLoadOptions;
import com.unity3d.ads.UnityAdsShowOptions;
/* loaded from: classes4.dex */
public interface IUnityAds {
boolean getDebugMode();
@Nullable
String getToken();
void getToken(IUnityAdsTokenListener iUnityAdsTokenListener);
String getVersion();
void initialize(Context context, String str, boolean z, IUnityAdsInitializationListener iUnityAdsInitializationListener);
boolean isInitialized();
boolean isSupported();
void load(String str, UnityAdsLoadOptions unityAdsLoadOptions, IUnityAdsLoadListener iUnityAdsLoadListener);
void setDebugMode(boolean z);
void show(Activity activity, String str, UnityAdsShowOptions unityAdsShowOptions, IUnityAdsShowListener iUnityAdsShowListener);
}

View File

@@ -0,0 +1,227 @@
package com.unity3d.services.ads;
import android.app.Activity;
import android.content.Context;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.unity3d.ads.IUnityAdsInitializationListener;
import com.unity3d.ads.IUnityAdsLoadListener;
import com.unity3d.ads.IUnityAdsShowListener;
import com.unity3d.ads.IUnityAdsTokenListener;
import com.unity3d.ads.UnityAds;
import com.unity3d.ads.UnityAdsLoadOptions;
import com.unity3d.ads.UnityAdsShowOptions;
import com.unity3d.ads.core.configuration.AlternativeFlowReader;
import com.unity3d.ads.core.data.model.Listeners;
import com.unity3d.ads.core.data.model.LoadResult;
import com.unity3d.services.UnityAdsSDK;
import com.unity3d.services.UnityServices;
import com.unity3d.services.ads.gmascar.managers.BiddingBaseManager;
import com.unity3d.services.ads.gmascar.managers.BiddingManagerFactory;
import com.unity3d.services.ads.operation.load.LoadModule;
import com.unity3d.services.ads.operation.load.LoadOperationState;
import com.unity3d.services.ads.operation.show.ShowModule;
import com.unity3d.services.ads.operation.show.ShowOperationState;
import com.unity3d.services.ads.token.AsyncTokenStorage;
import com.unity3d.services.ads.token.TokenStorage;
import com.unity3d.services.core.configuration.Configuration;
import com.unity3d.services.core.configuration.ConfigurationReader;
import com.unity3d.services.core.log.DeviceLog;
import com.unity3d.services.core.misc.Utilities;
import com.unity3d.services.core.properties.ClientProperties;
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.WebViewBridgeInvoker;
/* loaded from: classes4.dex */
public final class UnityAdsImplementation implements IUnityAds {
private static Configuration configuration;
private static IUnityAds instance;
private static WebViewBridgeInvoker webViewBridgeInvoker = new WebViewBridgeInvoker();
public static void setConfiguration(Configuration configuration2) {
configuration = configuration2;
}
public static IUnityAds getInstance() {
if (instance == null) {
instance = new UnityAdsImplementation();
}
return instance;
}
@Override // com.unity3d.services.ads.IUnityAds
public void initialize(Context context, String str, boolean z, IUnityAdsInitializationListener iUnityAdsInitializationListener) {
DeviceLog.entered();
UnityServices.initialize(context, str, z, iUnityAdsInitializationListener);
}
@Override // com.unity3d.services.ads.IUnityAds
public boolean isInitialized() {
return UnityServices.isInitialized();
}
@Override // com.unity3d.services.ads.IUnityAds
public boolean isSupported() {
return UnityServices.isSupported();
}
@Override // com.unity3d.services.ads.IUnityAds
public String getVersion() {
return UnityServices.getVersion();
}
public void show(Activity activity, String str) {
show(activity, str, new UnityAdsShowOptions(), null);
}
public void show(Activity activity, String str, IUnityAdsShowListener iUnityAdsShowListener) {
show(activity, str, new UnityAdsShowOptions(), iUnityAdsShowListener);
}
@Override // com.unity3d.services.ads.IUnityAds
public void show(@Nullable Activity activity, @Nullable String str, @Nullable UnityAdsShowOptions unityAdsShowOptions, @Nullable final IUnityAdsShowListener iUnityAdsShowListener) {
if (((AlternativeFlowReader) Utilities.getService(AlternativeFlowReader.class)).invoke()) {
UnityAdsSDK.INSTANCE.show(str, unityAdsShowOptions, new Listeners() { // from class: com.unity3d.services.ads.UnityAdsImplementation.1
@Override // com.unity3d.ads.core.data.model.Listeners
public void onLeftApplication(String str2) {
}
@Override // com.unity3d.ads.core.data.model.Listeners
public void onError(String str2, UnityAds.UnityAdsShowError unityAdsShowError, String str3) {
IUnityAdsShowListener iUnityAdsShowListener2 = iUnityAdsShowListener;
if (iUnityAdsShowListener2 != null) {
iUnityAdsShowListener2.onUnityAdsShowFailure(str2, unityAdsShowError, str3);
}
}
@Override // com.unity3d.ads.core.data.model.Listeners
public void onStart(String str2) {
IUnityAdsShowListener iUnityAdsShowListener2 = iUnityAdsShowListener;
if (iUnityAdsShowListener2 != null) {
iUnityAdsShowListener2.onUnityAdsShowStart(str2);
}
}
@Override // com.unity3d.ads.core.data.model.Listeners
public void onClick(String str2) {
IUnityAdsShowListener iUnityAdsShowListener2 = iUnityAdsShowListener;
if (iUnityAdsShowListener2 != null) {
iUnityAdsShowListener2.onUnityAdsShowClick(str2);
}
}
@Override // com.unity3d.ads.core.data.model.Listeners
public void onComplete(String str2, UnityAds.UnityAdsShowCompletionState unityAdsShowCompletionState) {
IUnityAdsShowListener iUnityAdsShowListener2 = iUnityAdsShowListener;
if (iUnityAdsShowListener2 != null) {
iUnityAdsShowListener2.onUnityAdsShowComplete(str2, unityAdsShowCompletionState);
}
}
});
return;
}
if (!isSupported()) {
handleShowError(iUnityAdsShowListener, str, UnityAds.UnityAdsShowError.NOT_INITIALIZED, "Unity Ads is not supported for this device");
return;
}
if (!isInitialized()) {
handleShowError(iUnityAdsShowListener, str, UnityAds.UnityAdsShowError.NOT_INITIALIZED, LoadResult.MSG_NOT_INITIALIZED);
return;
}
if (activity == null) {
handleShowError(iUnityAdsShowListener, str, UnityAds.UnityAdsShowError.INVALID_ARGUMENT, "Activity must not be null");
return;
}
if (str == null) {
handleShowError(iUnityAdsShowListener, "", UnityAds.UnityAdsShowError.INVALID_ARGUMENT, LoadResult.MSG_PLACEMENT_NULL);
return;
}
Configuration configuration2 = configuration;
if (configuration2 == null) {
configuration2 = new Configuration();
}
ClientProperties.setActivity(activity);
ShowModule.getInstance().executeAdOperation(WebViewApp.getCurrentApp(), new ShowOperationState(str, iUnityAdsShowListener, activity, unityAdsShowOptions, configuration2));
}
private void handleShowError(IUnityAdsShowListener iUnityAdsShowListener, String str, UnityAds.UnityAdsShowError unityAdsShowError, String str2) {
((SDKMetricsSender) Utilities.getService(SDKMetricsSender.class)).sendMetricWithInitState(AdOperationMetric.newAdShowFailure(unityAdsShowError, (Long) 0L));
if (iUnityAdsShowListener == null) {
return;
}
iUnityAdsShowListener.onUnityAdsShowFailure(str, unityAdsShowError, str2);
}
@Override // com.unity3d.services.ads.IUnityAds
public void setDebugMode(boolean z) {
UnityServices.setDebugMode(z);
}
@Override // com.unity3d.services.ads.IUnityAds
public boolean getDebugMode() {
return UnityServices.getDebugMode();
}
@Override // com.unity3d.services.ads.IUnityAds
public void load(@Nullable String str, @NonNull UnityAdsLoadOptions unityAdsLoadOptions, @Nullable IUnityAdsLoadListener iUnityAdsLoadListener) {
if (((AlternativeFlowReader) Utilities.getService(AlternativeFlowReader.class)).invoke()) {
UnityAdsSDK.INSTANCE.load(str, unityAdsLoadOptions, iUnityAdsLoadListener, null);
return;
}
Configuration configuration2 = configuration;
if (configuration2 == null) {
configuration2 = new Configuration();
}
LoadModule.getInstance().executeAdOperation(webViewBridgeInvoker, new LoadOperationState(str, iUnityAdsLoadListener, unityAdsLoadOptions, configuration2));
}
@Override // com.unity3d.services.ads.IUnityAds
@Nullable
public String getToken() {
if (((AlternativeFlowReader) Utilities.getService(AlternativeFlowReader.class)).invoke()) {
return UnityAdsSDK.INSTANCE.getToken();
}
String token = ((TokenStorage) Utilities.getService(TokenStorage.class)).getToken();
if (token == null || token.isEmpty()) {
return null;
}
Configuration configuration2 = configuration;
if (configuration2 == null) {
configuration2 = new ConfigurationReader().getCurrentConfiguration();
}
BiddingBaseManager createManager = BiddingManagerFactory.getInstance().createManager(null, configuration2.getExperiments());
createManager.start();
return createManager.getFormattedToken(token);
}
@Override // com.unity3d.services.ads.IUnityAds
public void getToken(@Nullable final IUnityAdsTokenListener iUnityAdsTokenListener) {
if (((AlternativeFlowReader) Utilities.getService(AlternativeFlowReader.class)).invoke()) {
UnityAdsSDK.INSTANCE.getToken(iUnityAdsTokenListener);
return;
}
if (iUnityAdsTokenListener == null) {
DeviceLog.info("Please provide non-null listener to UnityAds.GetToken method");
return;
}
if (ClientProperties.getApplicationContext() == null) {
Utilities.wrapCustomerListener(new Runnable() { // from class: com.unity3d.services.ads.UnityAdsImplementation$$ExternalSyntheticLambda0
@Override // java.lang.Runnable
public final void run() {
IUnityAdsTokenListener.this.onUnityAdsTokenReady(null);
}
});
return;
}
AsyncTokenStorage asyncTokenStorage = (AsyncTokenStorage) Utilities.getService(AsyncTokenStorage.class);
Configuration configuration2 = configuration;
if (configuration2 == null) {
configuration2 = new ConfigurationReader().getCurrentConfiguration();
}
BiddingBaseManager createManager = BiddingManagerFactory.getInstance().createManager(iUnityAdsTokenListener, configuration2.getExperiments());
createManager.start();
asyncTokenStorage.getToken(createManager);
}
}

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();
}
}

View File

@@ -0,0 +1,545 @@
package com.unity3d.services.ads.api;
import android.content.Intent;
import android.os.Build;
import android.util.SparseArray;
import android.util.SparseIntArray;
import android.view.WindowInsets;
import com.facebook.share.internal.ShareConstants;
import com.mbridge.msdk.playercommon.exoplayer2.text.ttml.TtmlNode;
import com.unity3d.services.ads.adunit.AdUnitActivity;
import com.unity3d.services.ads.adunit.AdUnitError;
import com.unity3d.services.ads.adunit.AdUnitMotionEvent;
import com.unity3d.services.ads.adunit.AdUnitSoftwareActivity;
import com.unity3d.services.ads.adunit.AdUnitTransparentActivity;
import com.unity3d.services.ads.adunit.AdUnitTransparentSoftwareActivity;
import com.unity3d.services.ads.adunit.IAdUnitActivity;
import com.unity3d.services.core.log.DeviceLog;
import com.unity3d.services.core.misc.Utilities;
import com.unity3d.services.core.properties.ClientProperties;
import com.unity3d.services.core.webview.bridge.WebViewCallback;
import com.unity3d.services.core.webview.bridge.WebViewExposed;
import csdk.gluads.Consts;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
/* loaded from: classes4.dex */
public class AdUnit {
private static IAdUnitActivity _adUnitActivity = null;
private static int _currentActivityId = -1;
public static IAdUnitActivity getAdUnitActivity() {
return _adUnitActivity;
}
public static int getCurrentAdUnitActivityId() {
return _currentActivityId;
}
public static void setAdUnitActivity(IAdUnitActivity iAdUnitActivity) {
_adUnitActivity = iAdUnitActivity;
}
public static void setCurrentAdUnitActivityId(int i) {
_currentActivityId = i;
}
private AdUnit() {
}
@WebViewExposed
public static void open(Integer num, JSONArray jSONArray, Integer num2, WebViewCallback webViewCallback) {
open(num, jSONArray, num2, null, webViewCallback);
}
@WebViewExposed
public static void open(Integer num, JSONArray jSONArray, Integer num2, JSONArray jSONArray2, WebViewCallback webViewCallback) {
open(num, jSONArray, num2, jSONArray2, 0, Boolean.TRUE, webViewCallback);
}
@WebViewExposed
public static void open(Integer num, JSONArray jSONArray, Integer num2, JSONArray jSONArray2, Integer num3, Boolean bool, WebViewCallback webViewCallback) {
open(num, jSONArray, num2, jSONArray2, num3, bool, Boolean.FALSE, webViewCallback);
}
@WebViewExposed
public static void open(Integer num, JSONArray jSONArray, Integer num2, JSONArray jSONArray2, Integer num3, Boolean bool, Boolean bool2, WebViewCallback webViewCallback) {
open(num, jSONArray, num2, jSONArray2, num3, bool, bool2, 0, webViewCallback);
}
@WebViewExposed
public static void open(Integer num, JSONArray jSONArray, Integer num2, JSONArray jSONArray2, Integer num3, Boolean bool, Boolean bool2, Integer num4, WebViewCallback webViewCallback) {
Intent intent;
if (!bool.booleanValue() && bool2.booleanValue()) {
DeviceLog.debug("Unity Ads opening new transparent ad unit activity, hardware acceleration disabled");
intent = new Intent(ClientProperties.getActivity(), (Class<?>) AdUnitTransparentSoftwareActivity.class);
} else if (bool.booleanValue() && !bool2.booleanValue()) {
DeviceLog.debug("Unity Ads opening new hardware accelerated ad unit activity");
intent = new Intent(ClientProperties.getActivity(), (Class<?>) AdUnitActivity.class);
} else if (bool.booleanValue() && bool2.booleanValue()) {
DeviceLog.debug("Unity Ads opening new hardware accelerated transparent ad unit activity");
intent = new Intent(ClientProperties.getActivity(), (Class<?>) AdUnitTransparentActivity.class);
} else {
DeviceLog.debug("Unity Ads opening new ad unit activity, hardware acceleration disabled");
intent = new Intent(ClientProperties.getActivity(), (Class<?>) AdUnitSoftwareActivity.class);
}
intent.addFlags(268500992);
if (num != null) {
try {
intent.putExtra(AdUnitActivity.EXTRA_ACTIVITY_ID, num.intValue());
setCurrentAdUnitActivityId(num.intValue());
try {
intent.putExtra(AdUnitActivity.EXTRA_VIEWS, getViewList(jSONArray));
if (jSONArray2 != null) {
try {
intent.putExtra(AdUnitActivity.EXTRA_KEY_EVENT_LIST, getKeyEventList(jSONArray2));
} catch (Exception e) {
DeviceLog.exception("Error parsing views from viewList", e);
webViewCallback.error(AdUnitError.CORRUPTED_KEYEVENTLIST, jSONArray2, e.getMessage());
return;
}
}
intent.putExtra(AdUnitActivity.EXTRA_SYSTEM_UI_VISIBILITY, num3);
intent.putExtra("orientation", num2);
intent.putExtra(AdUnitActivity.EXTRA_DISPLAY_CUTOUT_MODE, num4);
ClientProperties.getActivity().startActivity(intent);
DeviceLog.debug("Opened AdUnitActivity with: " + jSONArray.toString());
webViewCallback.invoke(new Object[0]);
return;
} catch (Exception e2) {
DeviceLog.exception("Error parsing views from viewList", e2);
webViewCallback.error(AdUnitError.CORRUPTED_VIEWLIST, jSONArray, e2.getMessage());
return;
}
} catch (Exception e3) {
DeviceLog.exception("Could not set activityId for intent", e3);
webViewCallback.error(AdUnitError.ACTIVITY_ID, Integer.valueOf(num.intValue()), e3.getMessage());
return;
}
}
DeviceLog.error("Activity ID is NULL");
webViewCallback.error(AdUnitError.ACTIVITY_ID, "Activity ID NULL");
}
@WebViewExposed
public static void close(WebViewCallback webViewCallback) {
if (getAdUnitActivity() != null) {
getAdUnitActivity().finish();
webViewCallback.invoke(new Object[0]);
} else {
webViewCallback.error(AdUnitError.ADUNIT_NULL, new Object[0]);
}
}
@WebViewExposed
public static void setViews(final JSONArray jSONArray, WebViewCallback webViewCallback) {
try {
getViewList(jSONArray);
Utilities.runOnUiThread(new Runnable() { // from class: com.unity3d.services.ads.api.AdUnit.1
@Override // java.lang.Runnable
public void run() {
if (AdUnit.getAdUnitActivity() != null) {
try {
AdUnit.getAdUnitActivity().setViews(AdUnit.getViewList(jSONArray));
} catch (Exception e) {
DeviceLog.exception("Corrupted viewlist", e);
}
}
}
});
} catch (JSONException unused) {
webViewCallback.error(AdUnitError.CORRUPTED_VIEWLIST, jSONArray);
}
if (getAdUnitActivity() != null) {
webViewCallback.invoke(jSONArray);
} else {
webViewCallback.error(AdUnitError.ADUNIT_NULL, new Object[0]);
}
}
@WebViewExposed
public static void getViews(WebViewCallback webViewCallback) {
if (getAdUnitActivity() != null) {
webViewCallback.invoke(new JSONArray((Collection) Arrays.asList(getAdUnitActivity().getViews())));
} else {
webViewCallback.error(AdUnitError.ADUNIT_NULL, new Object[0]);
}
}
@WebViewExposed
public static void setOrientation(final Integer num, WebViewCallback webViewCallback) {
Utilities.runOnUiThread(new Runnable() { // from class: com.unity3d.services.ads.api.AdUnit.2
@Override // java.lang.Runnable
public void run() {
if (AdUnit.getAdUnitActivity() != null) {
AdUnit.getAdUnitActivity().setOrientation(num.intValue());
}
}
});
if (getAdUnitActivity() != null) {
webViewCallback.invoke(num);
} else {
webViewCallback.error(AdUnitError.ADUNIT_NULL, new Object[0]);
}
}
@WebViewExposed
public static void getOrientation(WebViewCallback webViewCallback) {
if (getAdUnitActivity() != null) {
webViewCallback.invoke(Integer.valueOf(getAdUnitActivity().getRequestedOrientation()));
} else {
webViewCallback.error(AdUnitError.ADUNIT_NULL, new Object[0]);
}
}
@WebViewExposed
public static void setKeepScreenOn(final Boolean bool, WebViewCallback webViewCallback) {
Utilities.runOnUiThread(new Runnable() { // from class: com.unity3d.services.ads.api.AdUnit.3
@Override // java.lang.Runnable
public void run() {
if (AdUnit.getAdUnitActivity() != null) {
AdUnit.getAdUnitActivity().setKeepScreenOn(bool.booleanValue());
}
}
});
if (getAdUnitActivity() != null) {
webViewCallback.invoke(new Object[0]);
} else {
webViewCallback.error(AdUnitError.ADUNIT_NULL, new Object[0]);
}
}
@WebViewExposed
public static void setSystemUiVisibility(final Integer num, WebViewCallback webViewCallback) {
Utilities.runOnUiThread(new Runnable() { // from class: com.unity3d.services.ads.api.AdUnit.4
@Override // java.lang.Runnable
public void run() {
if (AdUnit.getAdUnitActivity() != null) {
AdUnit.getAdUnitActivity().setSystemUiVisibility(num.intValue());
}
}
});
if (getAdUnitActivity() != null) {
webViewCallback.invoke(num);
} else {
webViewCallback.error(AdUnitError.ADUNIT_NULL, new Object[0]);
}
}
@WebViewExposed
public static void setKeyEventList(JSONArray jSONArray, WebViewCallback webViewCallback) {
if (getAdUnitActivity() != null) {
try {
getAdUnitActivity().setKeyEventList(getKeyEventList(jSONArray));
webViewCallback.invoke(jSONArray);
return;
} catch (Exception e) {
DeviceLog.exception("Error parsing views from viewList", e);
webViewCallback.error(AdUnitError.CORRUPTED_KEYEVENTLIST, jSONArray, e.getMessage());
return;
}
}
webViewCallback.error(AdUnitError.ADUNIT_NULL, new Object[0]);
}
@WebViewExposed
public static void setViewFrame(final String str, final Integer num, final Integer num2, final Integer num3, final Integer num4, WebViewCallback webViewCallback) {
Utilities.runOnUiThread(new Runnable() { // from class: com.unity3d.services.ads.api.AdUnit.5
@Override // java.lang.Runnable
public void run() {
if (AdUnit.getAdUnitActivity() != null) {
AdUnit.getAdUnitActivity().setViewFrame(str, num.intValue(), num2.intValue(), num3.intValue(), num4.intValue());
}
}
});
if (getAdUnitActivity() != null) {
webViewCallback.invoke(new Object[0]);
} else {
webViewCallback.error(AdUnitError.ADUNIT_NULL, new Object[0]);
}
}
@WebViewExposed
public static void getViewFrame(String str, WebViewCallback webViewCallback) {
if (getAdUnitActivity() != null) {
if (getAdUnitActivity().getViewFrame(str) != null) {
Map<String, Integer> viewFrame = getAdUnitActivity().getViewFrame(str);
webViewCallback.invoke(viewFrame.get("x"), viewFrame.get("y"), viewFrame.get("width"), viewFrame.get("height"));
return;
} else {
webViewCallback.error(AdUnitError.UNKNOWN_VIEW, new Object[0]);
return;
}
}
webViewCallback.error(AdUnitError.ADUNIT_NULL, new Object[0]);
}
@WebViewExposed
public static void startMotionEventCapture(Integer num, WebViewCallback webViewCallback) {
if (getAdUnitActivity() != null) {
if (getAdUnitActivity().getLayout() != null) {
getAdUnitActivity().getLayout().startCapture(num.intValue());
webViewCallback.invoke(new Object[0]);
return;
} else {
webViewCallback.error(AdUnitError.LAYOUT_NULL, new Object[0]);
return;
}
}
webViewCallback.error(AdUnitError.ADUNIT_NULL, new Object[0]);
}
@WebViewExposed
public static void endMotionEventCapture(WebViewCallback webViewCallback) {
if (getAdUnitActivity() != null) {
if (getAdUnitActivity().getLayout() != null) {
getAdUnitActivity().getLayout().endCapture();
webViewCallback.invoke(new Object[0]);
return;
} else {
webViewCallback.error(AdUnitError.LAYOUT_NULL, new Object[0]);
return;
}
}
webViewCallback.error(AdUnitError.ADUNIT_NULL, new Object[0]);
}
@WebViewExposed
public static void clearMotionEventCapture(WebViewCallback webViewCallback) {
if (getAdUnitActivity() != null) {
if (getAdUnitActivity().getLayout() != null) {
getAdUnitActivity().getLayout().clearCapture();
webViewCallback.invoke(new Object[0]);
return;
} else {
webViewCallback.error(AdUnitError.LAYOUT_NULL, new Object[0]);
return;
}
}
webViewCallback.error(AdUnitError.ADUNIT_NULL, new Object[0]);
}
@WebViewExposed
public static void getMotionEventCount(JSONArray jSONArray, WebViewCallback webViewCallback) {
ArrayList<Integer> arrayList = new ArrayList<>();
for (int i = 0; i < jSONArray.length(); i++) {
try {
arrayList.add(Integer.valueOf(jSONArray.getInt(i)));
} catch (Exception e) {
DeviceLog.exception("Error retrieving int from eventTypes", e);
}
}
if (getAdUnitActivity() != null) {
if (getAdUnitActivity().getLayout() != null) {
if (getAdUnitActivity().getLayout().getCurrentEventCount() >= getAdUnitActivity().getLayout().getMaxEventCount()) {
webViewCallback.error(AdUnitError.MAX_MOTION_EVENT_COUNT_REACHED, new Object[0]);
return;
}
SparseIntArray eventCount = getAdUnitActivity().getLayout().getEventCount(arrayList);
JSONObject jSONObject = new JSONObject();
for (int i2 = 0; i2 < eventCount.size(); i2++) {
int keyAt = eventCount.keyAt(i2);
try {
jSONObject.put(Integer.toString(keyAt), eventCount.get(keyAt));
} catch (Exception e2) {
DeviceLog.exception("Error building response JSON", e2);
}
}
webViewCallback.invoke(jSONObject);
return;
}
webViewCallback.error(AdUnitError.LAYOUT_NULL, new Object[0]);
return;
}
webViewCallback.error(AdUnitError.ADUNIT_NULL, new Object[0]);
}
@WebViewExposed
public static void getMotionEventData(JSONObject jSONObject, WebViewCallback webViewCallback) {
JSONArray jSONArray;
Iterator<String> keys = jSONObject.keys();
SparseArray<ArrayList<Integer>> sparseArray = new SparseArray<>();
while (true) {
if (!keys.hasNext()) {
break;
}
String next = keys.next();
int parseInt = Integer.parseInt(next);
if (sparseArray.get(parseInt) == null) {
sparseArray.put(parseInt, new ArrayList<>());
}
try {
jSONArray = jSONObject.getJSONArray(next);
} catch (Exception e) {
DeviceLog.exception("Couldn't fetch keyIndices", e);
jSONArray = null;
}
if (jSONArray != null) {
for (int i = 0; i < jSONArray.length(); i++) {
try {
sparseArray.get(parseInt).add(Integer.valueOf(jSONArray.getInt(i)));
} catch (Exception e2) {
DeviceLog.exception("Couldn't add value to requested infos", e2);
}
}
}
}
if (getAdUnitActivity() != null) {
if (getAdUnitActivity().getLayout() != null) {
if (getAdUnitActivity().getLayout().getCurrentEventCount() >= getAdUnitActivity().getLayout().getMaxEventCount()) {
webViewCallback.error(AdUnitError.MAX_MOTION_EVENT_COUNT_REACHED, new Object[0]);
return;
}
SparseArray<SparseArray<AdUnitMotionEvent>> events = getAdUnitActivity().getLayout().getEvents(sparseArray);
JSONObject jSONObject2 = new JSONObject();
for (int i2 = 0; i2 < events.size(); i2++) {
int keyAt = events.keyAt(i2);
SparseArray<AdUnitMotionEvent> sparseArray2 = events.get(keyAt);
JSONObject jSONObject3 = new JSONObject();
for (int i3 = 0; i3 < sparseArray2.size(); i3++) {
JSONObject jSONObject4 = new JSONObject();
int keyAt2 = sparseArray2.keyAt(i3);
AdUnitMotionEvent adUnitMotionEvent = sparseArray2.get(keyAt2);
try {
jSONObject4.put("action", adUnitMotionEvent.getAction());
jSONObject4.put("isObscured", adUnitMotionEvent.isObscured());
jSONObject4.put("toolType", adUnitMotionEvent.getToolType());
jSONObject4.put(ShareConstants.FEED_SOURCE_PARAM, adUnitMotionEvent.getSource());
jSONObject4.put("deviceId", adUnitMotionEvent.getDeviceId());
jSONObject4.put("x", adUnitMotionEvent.getX());
jSONObject4.put("y", adUnitMotionEvent.getY());
jSONObject4.put("eventTime", adUnitMotionEvent.getEventTime());
jSONObject4.put("pressure", adUnitMotionEvent.getPressure());
jSONObject4.put("size", adUnitMotionEvent.getSize());
jSONObject3.put(Integer.toString(keyAt2), jSONObject4);
} catch (Exception e3) {
DeviceLog.debug("Couldn't construct event info", e3);
}
}
try {
jSONObject2.put(Integer.toString(keyAt), jSONObject3);
} catch (Exception e4) {
DeviceLog.debug("Couldn't construct info object", e4);
}
}
webViewCallback.invoke(jSONObject2);
return;
}
webViewCallback.error(AdUnitError.LAYOUT_NULL, new Object[0]);
return;
}
webViewCallback.error(AdUnitError.ADUNIT_NULL, new Object[0]);
}
@WebViewExposed
public static void getCurrentMotionEventCount(WebViewCallback webViewCallback) {
if (getAdUnitActivity() != null) {
if (getAdUnitActivity().getLayout() != null) {
webViewCallback.invoke(Integer.valueOf(getAdUnitActivity().getLayout().getCurrentEventCount()));
return;
} else {
webViewCallback.error(AdUnitError.LAYOUT_NULL, new Object[0]);
return;
}
}
webViewCallback.error(AdUnitError.ADUNIT_NULL, new Object[0]);
}
@WebViewExposed
public static void getSafeAreaInsets(WebViewCallback webViewCallback) {
if (getAdUnitActivity() == null || getAdUnitActivity().getLayout() == null) {
webViewCallback.error(AdUnitError.ADUNIT_NULL, new Object[0]);
return;
}
if (Build.VERSION.SDK_INT >= 28) {
WindowInsets rootWindowInsets = getAdUnitActivity().getLayout().getRootWindowInsets();
if (rootWindowInsets != null) {
JSONObject jSONObject = new JSONObject();
try {
Object invoke = rootWindowInsets.getClass().getMethod("getDisplayCutout", new Class[0]).invoke(rootWindowInsets, new Object[0]);
if (invoke != null) {
Object invoke2 = invoke.getClass().getMethod("getSafeInsetTop", new Class[0]).invoke(invoke, new Object[0]);
Object invoke3 = invoke.getClass().getMethod("getSafeInsetRight", new Class[0]).invoke(invoke, new Object[0]);
Object invoke4 = invoke.getClass().getMethod("getSafeInsetBottom", new Class[0]).invoke(invoke, new Object[0]);
Object invoke5 = invoke.getClass().getMethod("getSafeInsetLeft", new Class[0]).invoke(invoke, new Object[0]);
jSONObject.put("top", invoke2);
jSONObject.put(TtmlNode.RIGHT, invoke3);
jSONObject.put(Consts.SDK_BANNER_POSITION_BOTTOM, invoke4);
jSONObject.put("left", invoke5);
webViewCallback.invoke(jSONObject);
} else {
webViewCallback.error(AdUnitError.NO_DISPLAY_CUTOUT_AVAILABLE, new Object[0]);
}
return;
} catch (IllegalAccessException e) {
e = e;
webViewCallback.error(AdUnitError.DISPLAY_CUTOUT_INVOKE_FAILED, new Object[0]);
DeviceLog.debug("Error while calling displayCutout getter", e);
return;
} catch (NoSuchMethodException e2) {
webViewCallback.error(AdUnitError.DISPLAY_CUTOUT_METHOD_NOT_AVAILABLE, new Object[0]);
DeviceLog.debug("Method getDisplayCutout not found", e2);
return;
} catch (InvocationTargetException e3) {
e = e3;
webViewCallback.error(AdUnitError.DISPLAY_CUTOUT_INVOKE_FAILED, new Object[0]);
DeviceLog.debug("Error while calling displayCutout getter", e);
return;
} catch (JSONException e4) {
webViewCallback.error(AdUnitError.DISPLAY_CUTOUT_JSON_ERROR, new Object[0]);
DeviceLog.debug("JSON error while constructing display cutout object", e4);
return;
}
}
webViewCallback.error(AdUnitError.NO_DISPLAY_CUTOUT_AVAILABLE, new Object[0]);
return;
}
webViewCallback.error(AdUnitError.API_LEVEL_ERROR, new Object[0]);
}
@WebViewExposed
public static void setLayoutInDisplayCutoutMode(final Integer num, WebViewCallback webViewCallback) {
Utilities.runOnUiThread(new Runnable() { // from class: com.unity3d.services.ads.api.AdUnit.6
@Override // java.lang.Runnable
public void run() {
if (AdUnit.getAdUnitActivity() != null) {
AdUnit.getAdUnitActivity().setLayoutInDisplayCutoutMode(num.intValue());
}
}
});
if (getAdUnitActivity() != null) {
webViewCallback.invoke(num);
} else {
webViewCallback.error(AdUnitError.ADUNIT_NULL, new Object[0]);
}
}
/* JADX INFO: Access modifiers changed from: private */
public static String[] getViewList(JSONArray jSONArray) throws JSONException {
String[] strArr = new String[jSONArray.length()];
for (int i = 0; i < jSONArray.length(); i++) {
strArr[i] = jSONArray.getString(i);
}
return strArr;
}
private static ArrayList<Integer> getKeyEventList(JSONArray jSONArray) throws JSONException {
ArrayList<Integer> arrayList = new ArrayList<>();
int i = 0;
while (true) {
Integer valueOf = Integer.valueOf(i);
if (valueOf.intValue() >= jSONArray.length()) {
return arrayList;
}
arrayList.add(Integer.valueOf(jSONArray.getInt(valueOf.intValue())));
i = valueOf.intValue() + 1;
}
}
}

View File

@@ -0,0 +1,47 @@
package com.unity3d.services.ads.api;
import com.unity3d.scar.adapter.common.scarads.UnityAdFormat;
import com.unity3d.services.ads.gmascar.GMA;
import com.unity3d.services.ads.gmascar.GMAScarAdapterBridge;
import com.unity3d.services.core.webview.bridge.WebViewCallback;
import com.unity3d.services.core.webview.bridge.WebViewExposed;
/* loaded from: classes4.dex */
public class GMAScar {
private static final GMAScarAdapterBridge gmaScarAdapterBridge = GMA.getInstance().getBridge();
@WebViewExposed
public static void initializeScar(WebViewCallback webViewCallback) {
gmaScarAdapterBridge.initializeScar();
webViewCallback.invoke(new Object[0]);
}
@WebViewExposed
public static void getVersion(WebViewCallback webViewCallback) {
gmaScarAdapterBridge.getVersion();
webViewCallback.invoke(new Object[0]);
}
public static void isInitialized(WebViewCallback webViewCallback) {
gmaScarAdapterBridge.isInitialized();
webViewCallback.invoke(new Object[0]);
}
@WebViewExposed
public static void getSCARSignal(String str, String str2, WebViewCallback webViewCallback) {
gmaScarAdapterBridge.getSCARSignal(str, UnityAdFormat.valueOf(str2.toUpperCase()));
webViewCallback.invoke(new Object[0]);
}
@WebViewExposed
public static void load(String str, String str2, Boolean bool, String str3, String str4, Integer num, WebViewCallback webViewCallback) {
gmaScarAdapterBridge.load(bool.booleanValue(), str, str2, str4, str3, num.intValue());
webViewCallback.invoke(new Object[0]);
}
@WebViewExposed
public static void show(String str, String str2, Boolean bool, WebViewCallback webViewCallback) {
gmaScarAdapterBridge.show(str, str2, bool.booleanValue());
webViewCallback.invoke(new Object[0]);
}
}

View File

@@ -0,0 +1,21 @@
package com.unity3d.services.ads.api;
import com.unity3d.ads.UnityAds;
import com.unity3d.services.ads.operation.load.LoadModule;
import com.unity3d.services.core.webview.bridge.WebViewCallback;
import com.unity3d.services.core.webview.bridge.WebViewExposed;
/* loaded from: classes4.dex */
public class Load {
@WebViewExposed
public static void sendAdLoaded(String str, String str2, WebViewCallback webViewCallback) {
LoadModule.getInstance().onUnityAdsAdLoaded(str2);
webViewCallback.invoke(new Object[0]);
}
@WebViewExposed
public static void sendAdFailedToLoad(String str, String str2, String str3, String str4, WebViewCallback webViewCallback) {
LoadModule.getInstance().onUnityAdsFailedToLoad(str2, UnityAds.UnityAdsLoadError.valueOf(str3), str4);
webViewCallback.invoke(new Object[0]);
}
}

View File

@@ -0,0 +1,44 @@
package com.unity3d.services.ads.api;
import android.view.InputEvent;
import com.unity3d.services.ads.measurements.MeasurementsErrors;
import com.unity3d.services.ads.measurements.MeasurementsService;
import com.unity3d.services.core.misc.Utilities;
import com.unity3d.services.core.webview.bridge.WebViewCallback;
import com.unity3d.services.core.webview.bridge.WebViewExposed;
/* loaded from: classes4.dex */
public class Measurements {
private static final MeasurementsService measurementsService = (MeasurementsService) Utilities.getService(MeasurementsService.class);
@WebViewExposed
public static void checkAvailability(WebViewCallback webViewCallback) {
measurementsService.checkAvailability();
webViewCallback.invoke(new Object[0]);
}
@WebViewExposed
public static void registerView(String str, WebViewCallback webViewCallback) {
measurementsService.registerView(str);
webViewCallback.invoke(new Object[0]);
}
@WebViewExposed
public static void registerClick(String str, WebViewCallback webViewCallback) {
if (AdUnit.getAdUnitActivity() == null) {
webViewCallback.error(MeasurementsErrors.ERROR_AD_UNIT_NULL, new Object[0]);
return;
}
if (AdUnit.getAdUnitActivity().getLayout() == null) {
webViewCallback.error(MeasurementsErrors.ERROR_LAYOUT_NULL, new Object[0]);
return;
}
InputEvent lastInputEvent = AdUnit.getAdUnitActivity().getLayout().getLastInputEvent();
if (lastInputEvent == null) {
webViewCallback.error(MeasurementsErrors.ERROR_LAST_INPUT_EVENT_NULL, new Object[0]);
} else {
measurementsService.registerClick(str, lastInputEvent);
webViewCallback.invoke(new Object[0]);
}
}
}

View File

@@ -0,0 +1,39 @@
package com.unity3d.services.ads.api;
import com.unity3d.ads.UnityAds;
import com.unity3d.services.ads.operation.show.ShowModule;
import com.unity3d.services.core.webview.bridge.WebViewCallback;
import com.unity3d.services.core.webview.bridge.WebViewExposed;
/* loaded from: classes4.dex */
public class Show {
@WebViewExposed
public static void sendShowFailedEvent(String str, String str2, String str3, String str4, WebViewCallback webViewCallback) {
ShowModule.getInstance().onUnityAdsShowFailure(str2, UnityAds.UnityAdsShowError.valueOf(str3), str4);
webViewCallback.invoke(new Object[0]);
}
@WebViewExposed
public static void sendShowConsentEvent(String str, String str2, WebViewCallback webViewCallback) {
ShowModule.getInstance().onUnityAdsShowConsent(str2);
webViewCallback.invoke(new Object[0]);
}
@WebViewExposed
public static void sendShowStartEvent(String str, String str2, WebViewCallback webViewCallback) {
ShowModule.getInstance().onUnityAdsShowStart(str2);
webViewCallback.invoke(new Object[0]);
}
@WebViewExposed
public static void sendShowClickEvent(String str, String str2, WebViewCallback webViewCallback) {
ShowModule.getInstance().onUnityAdsShowClick(str2);
webViewCallback.invoke(new Object[0]);
}
@WebViewExposed
public static void sendShowCompleteEvent(String str, String str2, String str3, WebViewCallback webViewCallback) {
ShowModule.getInstance().onUnityAdsShowComplete(str2, UnityAds.UnityAdsShowCompletionState.valueOf(str3));
webViewCallback.invoke(new Object[0]);
}
}

View File

@@ -0,0 +1,46 @@
package com.unity3d.services.ads.api;
import com.unity3d.services.ads.token.TokenError;
import com.unity3d.services.ads.token.TokenStorage;
import com.unity3d.services.core.misc.Utilities;
import com.unity3d.services.core.webview.bridge.WebViewCallback;
import com.unity3d.services.core.webview.bridge.WebViewExposed;
import org.json.JSONArray;
import org.json.JSONException;
/* loaded from: classes4.dex */
public class Token {
private static final TokenStorage tokenStorage = (TokenStorage) Utilities.getService(TokenStorage.class);
@WebViewExposed
public static void createTokens(JSONArray jSONArray, WebViewCallback webViewCallback) {
try {
tokenStorage.createTokens(jSONArray);
webViewCallback.invoke(new Object[0]);
} catch (JSONException e) {
webViewCallback.error(TokenError.JSON_EXCEPTION, e.getMessage());
}
}
@WebViewExposed
public static void appendTokens(JSONArray jSONArray, WebViewCallback webViewCallback) {
try {
tokenStorage.appendTokens(jSONArray);
webViewCallback.invoke(new Object[0]);
} catch (JSONException e) {
webViewCallback.error(TokenError.JSON_EXCEPTION, e.getMessage());
}
}
@WebViewExposed
public static void deleteTokens(WebViewCallback webViewCallback) {
tokenStorage.deleteTokens();
webViewCallback.invoke(new Object[0]);
}
@WebViewExposed
public static void getNativeGeneratedToken(WebViewCallback webViewCallback) {
tokenStorage.getNativeGeneratedToken();
webViewCallback.invoke(new Object[0]);
}
}

View File

@@ -0,0 +1,22 @@
package com.unity3d.services.ads.api;
import com.unity3d.services.ads.topics.TopicsService;
import com.unity3d.services.core.misc.Utilities;
import com.unity3d.services.core.webview.bridge.WebViewCallback;
import com.unity3d.services.core.webview.bridge.WebViewExposed;
/* loaded from: classes4.dex */
public class Topics {
private static final TopicsService topicsService = (TopicsService) Utilities.getService(TopicsService.class);
@WebViewExposed
public static void checkAvailability(WebViewCallback webViewCallback) {
webViewCallback.invoke(topicsService.checkAvailability());
}
@WebViewExposed
public static void getTopics(String str, Boolean bool, WebViewCallback webViewCallback) {
topicsService.getTopics(str, bool.booleanValue());
webViewCallback.invoke(new Object[0]);
}
}

View File

@@ -0,0 +1,194 @@
package com.unity3d.services.ads.api;
import com.unity3d.services.ads.video.VideoPlayerError;
import com.unity3d.services.ads.video.VideoPlayerEvent;
import com.unity3d.services.ads.video.VideoPlayerView;
import com.unity3d.services.core.log.DeviceLog;
import com.unity3d.services.core.misc.Utilities;
import com.unity3d.services.core.webview.WebViewEventCategory;
import com.unity3d.services.core.webview.bridge.WebViewCallback;
import com.unity3d.services.core.webview.bridge.WebViewExposed;
/* loaded from: classes4.dex */
public class VideoPlayer {
private static VideoPlayerView _videoPlayerView;
public static VideoPlayerView getVideoPlayerView() {
return _videoPlayerView;
}
public static void setVideoPlayerView(VideoPlayerView videoPlayerView) {
_videoPlayerView = videoPlayerView;
}
@WebViewExposed
public static void setProgressEventInterval(final Integer num, WebViewCallback webViewCallback) {
Utilities.runOnUiThread(new Runnable() { // from class: com.unity3d.services.ads.api.VideoPlayer.1
@Override // java.lang.Runnable
public void run() {
if (VideoPlayer.getVideoPlayerView() != null) {
VideoPlayer.getVideoPlayerView().setProgressEventInterval(num.intValue());
}
}
});
if (getVideoPlayerView() != null) {
webViewCallback.invoke(new Object[0]);
} else {
webViewCallback.error(VideoPlayerError.VIDEOVIEW_NULL, new Object[0]);
}
}
@WebViewExposed
public static void getProgressEventInterval(WebViewCallback webViewCallback) {
if (getVideoPlayerView() != null) {
webViewCallback.invoke(Integer.valueOf(getVideoPlayerView().getProgressEventInterval()));
} else {
webViewCallback.error(VideoPlayerError.VIDEOVIEW_NULL, new Object[0]);
}
}
@WebViewExposed
public static void prepare(String str, Double d, WebViewCallback webViewCallback) {
prepare(str, d, 0, webViewCallback);
}
@WebViewExposed
public static void prepare(final String str, final Double d, final Integer num, WebViewCallback webViewCallback) {
DeviceLog.debug("Preparing video for playback: " + str);
Utilities.runOnUiThread(new Runnable() { // from class: com.unity3d.services.ads.api.VideoPlayer.2
@Override // java.lang.Runnable
public void run() {
if (VideoPlayer.getVideoPlayerView() != null) {
VideoPlayer.getVideoPlayerView().prepare(str, d.floatValue(), num.intValue());
}
}
});
if (getVideoPlayerView() != null) {
webViewCallback.invoke(str);
} else {
webViewCallback.error(VideoPlayerError.VIDEOVIEW_NULL, new Object[0]);
}
}
@WebViewExposed
public static void play(WebViewCallback webViewCallback) {
DeviceLog.debug("Starting playback of prepared video");
Utilities.runOnUiThread(new Runnable() { // from class: com.unity3d.services.ads.api.VideoPlayer.3
@Override // java.lang.Runnable
public void run() {
if (VideoPlayer.getVideoPlayerView() != null) {
VideoPlayer.getVideoPlayerView().play();
}
}
});
if (getVideoPlayerView() != null) {
webViewCallback.invoke(new Object[0]);
} else {
webViewCallback.error(VideoPlayerError.VIDEOVIEW_NULL, new Object[0]);
}
}
@WebViewExposed
public static void pause(WebViewCallback webViewCallback) {
DeviceLog.debug("Pausing current video");
Utilities.runOnUiThread(new Runnable() { // from class: com.unity3d.services.ads.api.VideoPlayer.4
@Override // java.lang.Runnable
public void run() {
if (VideoPlayer.getVideoPlayerView() != null) {
VideoPlayer.getVideoPlayerView().pause();
}
}
});
if (getVideoPlayerView() != null) {
webViewCallback.invoke(new Object[0]);
} else {
webViewCallback.error(VideoPlayerError.VIDEOVIEW_NULL, new Object[0]);
}
}
@WebViewExposed
public static void stop(WebViewCallback webViewCallback) {
DeviceLog.debug("Stopping current video");
Utilities.runOnUiThread(new Runnable() { // from class: com.unity3d.services.ads.api.VideoPlayer.5
@Override // java.lang.Runnable
public void run() {
if (VideoPlayer.getVideoPlayerView() != null) {
VideoPlayer.getVideoPlayerView().stop();
}
}
});
if (getVideoPlayerView() != null) {
webViewCallback.invoke(new Object[0]);
} else {
webViewCallback.error(VideoPlayerError.VIDEOVIEW_NULL, new Object[0]);
}
}
@WebViewExposed
public static void seekTo(final Integer num, WebViewCallback webViewCallback) {
DeviceLog.debug("Seeking video to time: " + num);
Utilities.runOnUiThread(new Runnable() { // from class: com.unity3d.services.ads.api.VideoPlayer.6
@Override // java.lang.Runnable
public void run() {
if (VideoPlayer.getVideoPlayerView() != null) {
VideoPlayer.getVideoPlayerView().seekTo(num.intValue());
}
}
});
if (getVideoPlayerView() != null) {
webViewCallback.invoke(new Object[0]);
} else {
webViewCallback.error(VideoPlayerError.VIDEOVIEW_NULL, new Object[0]);
}
}
@WebViewExposed
public static void getCurrentPosition(WebViewCallback webViewCallback) {
if (getVideoPlayerView() != null) {
webViewCallback.invoke(Integer.valueOf(getVideoPlayerView().getCurrentPosition()));
} else {
webViewCallback.error(VideoPlayerError.VIDEOVIEW_NULL, new Object[0]);
}
}
@WebViewExposed
public static void getVolume(WebViewCallback webViewCallback) {
if (getVideoPlayerView() != null) {
webViewCallback.invoke(Float.valueOf(getVideoPlayerView().getVolume()));
} else {
webViewCallback.error(VideoPlayerError.VIDEOVIEW_NULL, new Object[0]);
}
}
@WebViewExposed
public static void setVolume(Double d, WebViewCallback webViewCallback) {
DeviceLog.debug("Setting video volume: " + d);
if (getVideoPlayerView() != null) {
getVideoPlayerView().setVolume(Float.valueOf(d.floatValue()));
webViewCallback.invoke(d);
} else {
webViewCallback.error(VideoPlayerError.VIDEOVIEW_NULL, new Object[0]);
}
}
@WebViewExposed
public static void setInfoListenerEnabled(boolean z, WebViewCallback webViewCallback) {
if (getVideoPlayerView() != null) {
getVideoPlayerView().setInfoListenerEnabled(z);
webViewCallback.invoke(WebViewEventCategory.VIDEOPLAYER, VideoPlayerEvent.INFO, Boolean.valueOf(z));
} else {
webViewCallback.error(VideoPlayerError.VIDEOVIEW_NULL, new Object[0]);
}
}
@WebViewExposed
public static void getVideoViewRectangle(WebViewCallback webViewCallback) {
VideoPlayerView videoPlayerView = getVideoPlayerView();
if (videoPlayerView != null) {
int[] videoViewRectangle = videoPlayerView.getVideoViewRectangle();
webViewCallback.invoke(Integer.valueOf(videoViewRectangle[0]), Integer.valueOf(videoViewRectangle[1]), Integer.valueOf(videoViewRectangle[2]), Integer.valueOf(videoViewRectangle[3]));
} else {
webViewCallback.error(VideoPlayerError.VIDEOVIEW_NULL, new Object[0]);
}
}
}

View File

@@ -0,0 +1,168 @@
package com.unity3d.services.ads.api;
import com.unity3d.services.ads.webplayer.WebPlayerError;
import com.unity3d.services.ads.webplayer.WebPlayerEventBridge;
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.log.DeviceLog;
import com.unity3d.services.core.misc.Utilities;
import com.unity3d.services.core.webview.bridge.WebViewCallback;
import com.unity3d.services.core.webview.bridge.WebViewExposed;
import java.util.Map;
import org.json.JSONArray;
import org.json.JSONObject;
/* loaded from: classes4.dex */
public class WebPlayer {
@WebViewExposed
public static void setUrl(final String str, String str2, WebViewCallback webViewCallback) {
final WebPlayerView webPlayer = WebPlayerViewCache.getInstance().getWebPlayer(str2);
if (webPlayer != null) {
Utilities.runOnUiThread(new Runnable() { // from class: com.unity3d.services.ads.api.WebPlayer.1
@Override // java.lang.Runnable
public void run() {
WebPlayerView.this.loadUrl(str);
}
});
webViewCallback.invoke(new Object[0]);
} else {
webViewCallback.error(WebPlayerError.WEBPLAYER_NULL, new Object[0]);
}
}
@WebViewExposed
public static void setData(final String str, final String str2, final String str3, String str4, WebViewCallback webViewCallback) {
final WebPlayerView webPlayer = WebPlayerViewCache.getInstance().getWebPlayer(str4);
if (webPlayer != null) {
Utilities.runOnUiThread(new Runnable() { // from class: com.unity3d.services.ads.api.WebPlayer.2
@Override // java.lang.Runnable
public void run() {
WebPlayerView.this.loadData(str, str2, str3);
}
});
webViewCallback.invoke(new Object[0]);
} else {
webViewCallback.error(WebPlayerError.WEBPLAYER_NULL, new Object[0]);
}
}
@WebViewExposed
public static void setDataWithUrl(final String str, final String str2, final String str3, final String str4, String str5, WebViewCallback webViewCallback) {
final WebPlayerView webPlayer = WebPlayerViewCache.getInstance().getWebPlayer(str5);
if (webPlayer != null) {
Utilities.runOnUiThread(new Runnable() { // from class: com.unity3d.services.ads.api.WebPlayer.3
@Override // java.lang.Runnable
public void run() {
WebPlayerView.this.loadDataWithBaseURL(str, str2, str3, str4, null);
}
});
webViewCallback.invoke(new Object[0]);
} else {
webViewCallback.error(WebPlayerError.WEBPLAYER_NULL, new Object[0]);
}
}
@WebViewExposed
public static void setSettings(final JSONObject jSONObject, final JSONObject jSONObject2, String str, WebViewCallback webViewCallback) {
WebPlayerSettingsCache.getInstance().addWebSettings(str, jSONObject);
WebPlayerSettingsCache.getInstance().addWebPlayerSettings(str, jSONObject2);
final WebPlayerView webPlayer = WebPlayerViewCache.getInstance().getWebPlayer(str);
if (webPlayer != null) {
Utilities.runOnUiThread(new Runnable() { // from class: com.unity3d.services.ads.api.WebPlayer.4
@Override // java.lang.Runnable
public void run() {
WebPlayerView.this.setSettings(jSONObject, jSONObject2);
}
});
webViewCallback.invoke(new Object[0]);
} else {
webViewCallback.error(WebPlayerError.WEBPLAYER_NULL, new Object[0]);
}
}
@WebViewExposed
public static void setEventSettings(final JSONObject jSONObject, String str, WebViewCallback webViewCallback) {
WebPlayerSettingsCache.getInstance().addWebPlayerEventSettings(str, jSONObject);
final WebPlayerView webPlayer = WebPlayerViewCache.getInstance().getWebPlayer(str);
if (webPlayer != null) {
Utilities.runOnUiThread(new Runnable() { // from class: com.unity3d.services.ads.api.WebPlayer.5
@Override // java.lang.Runnable
public void run() {
WebPlayerView.this.setEventSettings(jSONObject);
}
});
webViewCallback.invoke(new Object[0]);
} else {
webViewCallback.error(WebPlayerError.WEBPLAYER_NULL, new Object[0]);
}
}
@WebViewExposed
public static void clearSettings(String str, WebViewCallback webViewCallback) {
WebPlayerSettingsCache webPlayerSettingsCache = WebPlayerSettingsCache.getInstance();
webPlayerSettingsCache.removeWebSettings(str);
webPlayerSettingsCache.removeWebPlayerSettings(str);
webPlayerSettingsCache.removeWebPlayerEventSettings(str);
final WebPlayerView webPlayer = WebPlayerViewCache.getInstance().getWebPlayer(str);
if (webPlayer != null) {
Utilities.runOnUiThread(new Runnable() { // from class: com.unity3d.services.ads.api.WebPlayer.6
@Override // java.lang.Runnable
public void run() {
WebPlayerView.this.setSettings(new JSONObject(), new JSONObject());
WebPlayerView.this.setEventSettings(new JSONObject());
}
});
webViewCallback.invoke(new Object[0]);
} else {
webViewCallback.error(WebPlayerError.WEBPLAYER_NULL, new Object[0]);
}
}
@WebViewExposed
public static void getErroredSettings(String str, WebViewCallback webViewCallback) {
WebPlayerView webPlayer = WebPlayerViewCache.getInstance().getWebPlayer(str);
if (webPlayer != null) {
Map<String, String> erroredSettings = webPlayer.getErroredSettings();
JSONObject jSONObject = new JSONObject();
try {
for (Map.Entry<String, String> entry : erroredSettings.entrySet()) {
jSONObject.put(entry.getKey(), entry.getValue());
}
} catch (Exception e) {
DeviceLog.exception("Error forming JSON object", e);
}
webViewCallback.invoke(jSONObject);
webViewCallback.invoke(new Object[0]);
return;
}
webViewCallback.error(WebPlayerError.WEBPLAYER_NULL, new Object[0]);
}
@WebViewExposed
public static void sendEvent(JSONArray jSONArray, String str, WebViewCallback webViewCallback) {
WebPlayerView webPlayer = WebPlayerViewCache.getInstance().getWebPlayer(str);
if (webPlayer != null) {
webPlayer.sendEvent(jSONArray);
webViewCallback.invoke(new Object[0]);
} else {
webViewCallback.error(WebPlayerError.WEBPLAYER_NULL, new Object[0]);
}
}
@WebViewExposed
public static void getFrame(final String str, final String str2, WebViewCallback webViewCallback) {
webViewCallback.invoke(new Object[0]);
final WebPlayerView webPlayer = WebPlayerViewCache.getInstance().getWebPlayer(str2);
if (webPlayer != null) {
Utilities.runOnUiThread(new Runnable() { // from class: com.unity3d.services.ads.api.WebPlayer.7
@Override // java.lang.Runnable
public void run() {
int[] iArr = new int[2];
WebPlayerView.this.getLocationOnScreen(iArr);
WebPlayerEventBridge.sendGetFrameResponse(str, str2, iArr[0], iArr[1], WebPlayerView.this.getWidth(), WebPlayerView.this.getHeight(), WebPlayerView.this.getAlpha());
}
});
}
}
}

View File

@@ -0,0 +1,70 @@
package com.unity3d.services.ads.configuration;
import com.ironsource.v8;
import com.unity3d.services.ads.UnityAdsImplementation;
import com.unity3d.services.ads.adunit.AdUnitOpen;
import com.unity3d.services.ads.adunit.VideoPlayerHandler;
import com.unity3d.services.ads.adunit.WebPlayerHandler;
import com.unity3d.services.ads.adunit.WebViewHandler;
import com.unity3d.services.ads.api.AdUnit;
import com.unity3d.services.ads.api.GMAScar;
import com.unity3d.services.ads.api.Load;
import com.unity3d.services.ads.api.Measurements;
import com.unity3d.services.ads.api.Show;
import com.unity3d.services.ads.api.Token;
import com.unity3d.services.ads.api.Topics;
import com.unity3d.services.ads.api.VideoPlayer;
import com.unity3d.services.ads.api.WebPlayer;
import com.unity3d.services.ads.token.AsyncTokenStorage;
import com.unity3d.services.ads.token.TokenStorage;
import com.unity3d.services.core.configuration.Configuration;
import com.unity3d.services.core.configuration.ErrorState;
import com.unity3d.services.core.misc.Utilities;
import java.net.InetAddress;
import java.util.HashMap;
import java.util.Map;
/* loaded from: classes4.dex */
public class AdsModuleConfiguration implements IAdsModuleConfiguration {
private InetAddress _address;
private final TokenStorage tokenStorage = (TokenStorage) Utilities.getService(TokenStorage.class);
private final AsyncTokenStorage asyncTokenStorage = (AsyncTokenStorage) Utilities.getService(AsyncTokenStorage.class);
@Override // com.unity3d.services.core.configuration.IModuleConfiguration
public Class[] getWebAppApiClassList() {
return new Class[]{AdUnit.class, VideoPlayer.class, WebPlayer.class, Load.class, Show.class, Token.class, GMAScar.class, Measurements.class, Topics.class};
}
@Override // com.unity3d.services.core.configuration.IModuleConfiguration
public boolean resetState(Configuration configuration) {
AdUnitOpen.setConfiguration(configuration);
UnityAdsImplementation.setConfiguration(configuration);
this.tokenStorage.deleteTokens();
this.asyncTokenStorage.setConfiguration(configuration);
return true;
}
@Override // com.unity3d.services.core.configuration.IModuleConfiguration
public boolean initErrorState(Configuration configuration, ErrorState errorState, String str) {
this.tokenStorage.setInitToken(null);
this.tokenStorage.deleteTokens();
return true;
}
@Override // com.unity3d.services.core.configuration.IModuleConfiguration
public boolean initCompleteState(Configuration configuration) {
AdUnitOpen.setConfiguration(configuration);
UnityAdsImplementation.setConfiguration(configuration);
this.asyncTokenStorage.setConfiguration(configuration);
return true;
}
@Override // com.unity3d.services.ads.configuration.IAdsModuleConfiguration
public Map<String, Class> getAdUnitViewHandlers() {
HashMap hashMap = new HashMap();
hashMap.put("videoplayer", VideoPlayerHandler.class);
hashMap.put("webplayer", WebPlayerHandler.class);
hashMap.put(v8.h.K, WebViewHandler.class);
return hashMap;
}
}

View File

@@ -0,0 +1,9 @@
package com.unity3d.services.ads.configuration;
import com.unity3d.services.core.configuration.IModuleConfiguration;
import java.util.Map;
/* loaded from: classes4.dex */
public interface IAdsModuleConfiguration extends IModuleConfiguration {
Map<String, Class> getAdUnitViewHandlers();
}

View File

@@ -0,0 +1,39 @@
package com.unity3d.services.ads.gmascar;
import com.unity3d.services.ads.gmascar.adapters.ScarAdapterFactory;
import com.unity3d.services.ads.gmascar.bridges.AdapterStatusBridge;
import com.unity3d.services.ads.gmascar.bridges.InitializationStatusBridge;
import com.unity3d.services.ads.gmascar.bridges.InitializeListenerBridge;
import com.unity3d.services.ads.gmascar.bridges.mobileads.MobileAdsBridgeFactory;
import com.unity3d.services.ads.gmascar.handlers.BiddingSignalsHandler;
import com.unity3d.services.ads.gmascar.handlers.WebViewErrorHandler;
import com.unity3d.services.ads.gmascar.listeners.IBiddingSignalsListener;
import com.unity3d.services.ads.gmascar.utils.GMAEventSender;
/* loaded from: classes4.dex */
public class GMA {
private static GMAScarAdapterBridge _gmaScarAdapterBridge = new GMAScarAdapterBridge(new MobileAdsBridgeFactory().createMobileAdsBridge(), new InitializeListenerBridge(), new InitializationStatusBridge(), new AdapterStatusBridge(), new WebViewErrorHandler(), new ScarAdapterFactory(), new GMAEventSender());
private static GMA instance;
public GMAScarAdapterBridge getBridge() {
return _gmaScarAdapterBridge;
}
private GMA() {
}
public static GMA getInstance() {
if (instance == null) {
instance = new GMA();
}
return instance;
}
public boolean hasSCARBiddingSupport() {
return _gmaScarAdapterBridge.hasSCARBiddingSupport();
}
public void getSCARBiddingSignals(boolean z, IBiddingSignalsListener iBiddingSignalsListener) {
_gmaScarAdapterBridge.getSCARBiddingSignals(z, new BiddingSignalsHandler(z, iBiddingSignalsListener));
}
}

View File

@@ -0,0 +1,173 @@
package com.unity3d.services.ads.gmascar;
import android.content.Context;
import com.unity3d.scar.adapter.common.GMAAdsError;
import com.unity3d.scar.adapter.common.GMAEvent;
import com.unity3d.scar.adapter.common.IScarAdapter;
import com.unity3d.scar.adapter.common.WebViewAdsError;
import com.unity3d.scar.adapter.common.scarads.ScarAdMetadata;
import com.unity3d.scar.adapter.common.scarads.UnityAdFormat;
import com.unity3d.services.ads.gmascar.adapters.ScarAdapterFactory;
import com.unity3d.services.ads.gmascar.bridges.AdapterStatusBridge;
import com.unity3d.services.ads.gmascar.bridges.InitializationStatusBridge;
import com.unity3d.services.ads.gmascar.bridges.InitializeListenerBridge;
import com.unity3d.services.ads.gmascar.bridges.mobileads.MobileAdsBridgeBase;
import com.unity3d.services.ads.gmascar.finder.GMAInitializer;
import com.unity3d.services.ads.gmascar.finder.PresenceDetector;
import com.unity3d.services.ads.gmascar.finder.ScarVersionFinder;
import com.unity3d.services.ads.gmascar.handlers.BiddingSignalsHandler;
import com.unity3d.services.ads.gmascar.handlers.ScarBannerAdHandler;
import com.unity3d.services.ads.gmascar.handlers.ScarInterstitialAdHandler;
import com.unity3d.services.ads.gmascar.handlers.ScarRewardedAdHandler;
import com.unity3d.services.ads.gmascar.handlers.SignalsHandler;
import com.unity3d.services.ads.gmascar.handlers.WebViewErrorHandler;
import com.unity3d.services.ads.gmascar.utils.GMAEventSender;
import com.unity3d.services.banners.BannerView;
import com.unity3d.services.banners.UnityBannerSize;
import com.unity3d.services.banners.bridge.BannerBridge;
import com.unity3d.services.core.misc.EventSubject;
import com.unity3d.services.core.properties.ClientProperties;
import com.unity3d.services.core.timer.DefaultIntervalTimerFactory;
import com.unity3d.services.core.webview.WebViewApp;
import com.unity3d.services.core.webview.WebViewEventCategory;
import java.util.ArrayDeque;
import java.util.Arrays;
/* loaded from: classes4.dex */
public class GMAScarAdapterBridge {
private final AdapterStatusBridge _adapterStatusBridge;
private final GMAEventSender _gmaEventSender;
private final GMAInitializer _gmaInitializer;
private final InitializeListenerBridge _initializationListenerBridge;
private final InitializationStatusBridge _initializationStatusBridge;
private final MobileAdsBridgeBase _mobileAdsBridge;
private final PresenceDetector _presenceDetector;
private IScarAdapter _scarAdapter;
private final ScarAdapterFactory _scarAdapterFactory;
private final ScarVersionFinder _scarVersionFinder;
private final WebViewErrorHandler _webViewErrorHandler;
public GMAScarAdapterBridge(MobileAdsBridgeBase mobileAdsBridgeBase, InitializeListenerBridge initializeListenerBridge, InitializationStatusBridge initializationStatusBridge, AdapterStatusBridge adapterStatusBridge, WebViewErrorHandler webViewErrorHandler, ScarAdapterFactory scarAdapterFactory, GMAEventSender gMAEventSender) {
this._initializationStatusBridge = initializationStatusBridge;
this._initializationListenerBridge = initializeListenerBridge;
this._adapterStatusBridge = adapterStatusBridge;
this._webViewErrorHandler = webViewErrorHandler;
this._scarAdapterFactory = scarAdapterFactory;
this._mobileAdsBridge = mobileAdsBridgeBase;
this._gmaEventSender = gMAEventSender;
PresenceDetector presenceDetector = new PresenceDetector(mobileAdsBridgeBase, initializeListenerBridge, initializationStatusBridge, adapterStatusBridge);
this._presenceDetector = presenceDetector;
GMAInitializer gMAInitializer = new GMAInitializer(mobileAdsBridgeBase, initializeListenerBridge, initializationStatusBridge, adapterStatusBridge, gMAEventSender);
this._gmaInitializer = gMAInitializer;
this._scarVersionFinder = new ScarVersionFinder(mobileAdsBridgeBase, presenceDetector, gMAInitializer, gMAEventSender);
}
public void initializeScar() {
if (this._presenceDetector.areGMAClassesPresent()) {
this._gmaEventSender.send(GMAEvent.SCAR_PRESENT, new Object[0]);
this._gmaInitializer.initializeGMA();
} else {
this._webViewErrorHandler.handleError((WebViewAdsError) new GMAAdsError(GMAEvent.SCAR_NOT_PRESENT, new Object[0]));
}
}
public boolean isInitialized() {
return this._gmaInitializer.isInitialized();
}
public void getVersion() {
this._scarVersionFinder.getVersion();
}
public void getSCARSignal(String str, UnityAdFormat unityAdFormat) {
this._scarAdapter = getScarAdapterObject();
SignalsHandler signalsHandler = new SignalsHandler(this._gmaEventSender);
IScarAdapter iScarAdapter = this._scarAdapter;
if (iScarAdapter != null) {
iScarAdapter.getSCARSignal(ClientProperties.getApplicationContext(), str, unityAdFormat, signalsHandler);
} else {
this._webViewErrorHandler.handleError((WebViewAdsError) GMAAdsError.InternalSignalsError("Could not create SCAR adapter object"));
}
}
public boolean hasSCARBiddingSupport() {
MobileAdsBridgeBase mobileAdsBridgeBase = this._mobileAdsBridge;
if (mobileAdsBridgeBase == null || !mobileAdsBridgeBase.hasSCARBiddingSupport()) {
return false;
}
IScarAdapter scarAdapterObject = getScarAdapterObject();
this._scarAdapter = scarAdapterObject;
return scarAdapterObject != null;
}
public void getSCARBiddingSignals(boolean z, BiddingSignalsHandler biddingSignalsHandler) {
MobileAdsBridgeBase mobileAdsBridgeBase = this._mobileAdsBridge;
if (mobileAdsBridgeBase != null && mobileAdsBridgeBase.hasSCARBiddingSupport()) {
IScarAdapter scarAdapterObject = getScarAdapterObject();
this._scarAdapter = scarAdapterObject;
if (scarAdapterObject != null) {
scarAdapterObject.getSCARBiddingSignals(ClientProperties.getApplicationContext(), z, biddingSignalsHandler);
return;
} else {
biddingSignalsHandler.onSignalsCollectionFailed("Could not create SCAR adapter object.");
return;
}
}
biddingSignalsHandler.onSignalsCollectionFailed("SCAR bidding unsupported.");
}
public void load(boolean z, String str, String str2, String str3, String str4, int i) {
ScarAdMetadata scarAdMetadata = new ScarAdMetadata(str, str2, str4, str3, Integer.valueOf(i));
IScarAdapter scarAdapterObject = getScarAdapterObject();
this._scarAdapter = scarAdapterObject;
if (scarAdapterObject == null) {
this._webViewErrorHandler.handleError((WebViewAdsError) GMAAdsError.InternalLoadError(scarAdMetadata, "Scar Adapter object is null"));
} else if (z) {
loadInterstitialAd(scarAdMetadata);
} else {
loadRewardedAd(scarAdMetadata);
}
}
private void loadInterstitialAd(ScarAdMetadata scarAdMetadata) {
this._scarAdapter.loadInterstitialAd(ClientProperties.getApplicationContext(), scarAdMetadata, new ScarInterstitialAdHandler(scarAdMetadata, getScarEventSubject(scarAdMetadata.getVideoLengthMs()), this._gmaEventSender));
}
private void loadRewardedAd(ScarAdMetadata scarAdMetadata) {
this._scarAdapter.loadRewardedAd(ClientProperties.getApplicationContext(), scarAdMetadata, new ScarRewardedAdHandler(scarAdMetadata, getScarEventSubject(scarAdMetadata.getVideoLengthMs()), this._gmaEventSender));
}
public void loadBanner(Context context, BannerView bannerView, String str, ScarAdMetadata scarAdMetadata, UnityBannerSize unityBannerSize) {
this._scarAdapter = getScarAdapterObject();
ScarBannerAdHandler scarBannerAdHandler = new ScarBannerAdHandler(str);
IScarAdapter iScarAdapter = this._scarAdapter;
if (iScarAdapter != null) {
iScarAdapter.loadBannerAd(context, bannerView, scarAdMetadata, unityBannerSize.getWidth(), unityBannerSize.getHeight(), scarBannerAdHandler);
} else {
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.BANNER, BannerBridge.BannerEvent.SCAR_BANNER_LOAD_FAILED, str);
}
}
public void show(String str, String str2, boolean z) {
ScarAdMetadata scarAdMetadata = new ScarAdMetadata(str, str2);
IScarAdapter scarAdapterObject = getScarAdapterObject();
this._scarAdapter = scarAdapterObject;
if (scarAdapterObject != null) {
scarAdapterObject.show(ClientProperties.getActivity(), str2, str);
} else {
this._webViewErrorHandler.handleError((WebViewAdsError) GMAAdsError.InternalShowError(scarAdMetadata, "Scar Adapter object is null"));
}
}
private EventSubject getScarEventSubject(Integer num) {
return new EventSubject(new ArrayDeque(Arrays.asList(GMAEvent.FIRST_QUARTILE, GMAEvent.MIDPOINT, GMAEvent.THIRD_QUARTILE, GMAEvent.LAST_QUARTILE)), num, new DefaultIntervalTimerFactory());
}
private IScarAdapter getScarAdapterObject() {
MobileAdsBridgeBase mobileAdsBridgeBase;
if (this._scarAdapter == null && (mobileAdsBridgeBase = this._mobileAdsBridge) != null) {
this._scarAdapter = this._scarAdapterFactory.createScarAdapter(mobileAdsBridgeBase.getAdapterVersion(this._scarVersionFinder.getVersionCode()), this._webViewErrorHandler);
}
return this._scarAdapter;
}
}

View File

@@ -0,0 +1,61 @@
package com.unity3d.services.ads.gmascar.adapters;
import com.unity3d.scar.adapter.common.GMAAdsError;
import com.unity3d.scar.adapter.common.IAdsErrorHandler;
import com.unity3d.scar.adapter.common.IScarAdapter;
import com.unity3d.scar.adapter.common.WebViewAdsError;
import com.unity3d.scar.adapter.v2000.ScarAdapter;
import com.unity3d.services.ads.gmascar.finder.ScarAdapterVersion;
import com.unity3d.services.core.log.DeviceLog;
import com.unity3d.services.core.properties.SdkProperties;
/* loaded from: classes4.dex */
public class ScarAdapterFactory {
/* renamed from: com.unity3d.services.ads.gmascar.adapters.ScarAdapterFactory$1, reason: invalid class name */
public static /* synthetic */ class AnonymousClass1 {
static final /* synthetic */ int[] $SwitchMap$com$unity3d$services$ads$gmascar$finder$ScarAdapterVersion;
static {
int[] iArr = new int[ScarAdapterVersion.values().length];
$SwitchMap$com$unity3d$services$ads$gmascar$finder$ScarAdapterVersion = iArr;
try {
iArr[ScarAdapterVersion.V20.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
$SwitchMap$com$unity3d$services$ads$gmascar$finder$ScarAdapterVersion[ScarAdapterVersion.V21.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
try {
$SwitchMap$com$unity3d$services$ads$gmascar$finder$ScarAdapterVersion[ScarAdapterVersion.V23.ordinal()] = 3;
} catch (NoSuchFieldError unused3) {
}
try {
$SwitchMap$com$unity3d$services$ads$gmascar$finder$ScarAdapterVersion[ScarAdapterVersion.NA.ordinal()] = 4;
} catch (NoSuchFieldError unused4) {
}
}
}
public IScarAdapter createScarAdapter(ScarAdapterVersion scarAdapterVersion, IAdsErrorHandler<WebViewAdsError> iAdsErrorHandler) {
int i = AnonymousClass1.$SwitchMap$com$unity3d$services$ads$gmascar$finder$ScarAdapterVersion[scarAdapterVersion.ordinal()];
if (i == 1) {
return new ScarAdapter(iAdsErrorHandler);
}
if (i == 2) {
return new com.unity3d.scar.adapter.v2100.ScarAdapter(iAdsErrorHandler, SdkProperties.getVersionName());
}
if (i == 3) {
return new com.unity3d.scar.adapter.v2300.ScarAdapter(iAdsErrorHandler, SdkProperties.getVersionName());
}
reportAdapterFailure(scarAdapterVersion, iAdsErrorHandler);
return null;
}
private void reportAdapterFailure(ScarAdapterVersion scarAdapterVersion, IAdsErrorHandler<WebViewAdsError> iAdsErrorHandler) {
String format = String.format("SCAR version %s is not supported.", scarAdapterVersion.name());
iAdsErrorHandler.handleError(GMAAdsError.AdapterCreationError(format));
DeviceLog.debug(format);
}
}

View File

@@ -0,0 +1,43 @@
package com.unity3d.services.ads.gmascar.bridges;
import com.unity3d.services.core.log.DeviceLog;
import com.unity3d.services.core.reflection.GenericBridge;
import java.util.HashMap;
/* loaded from: classes4.dex */
public class AdapterStatusBridge extends GenericBridge {
private static final String initializeStateMethodName = "getInitializationState";
private Class _adapterStateClass;
@Override // com.unity3d.services.core.reflection.GenericBridge
public String getClassName() {
return "com.google.android.gms.ads.initialization.AdapterStatus";
}
public AdapterStatusBridge() {
super(new HashMap<String, Class<?>[]>() { // from class: com.unity3d.services.ads.gmascar.bridges.AdapterStatusBridge.1
{
put(AdapterStatusBridge.initializeStateMethodName, new Class[0]);
}
});
AdapterStatusStateBridge adapterStatusStateBridge = new AdapterStatusStateBridge();
try {
this._adapterStateClass = Class.forName(adapterStatusStateBridge.getClassName());
} catch (ClassNotFoundException e) {
DeviceLog.debug("ERROR: Could not find class %s %s", adapterStatusStateBridge.getClassName(), e.getLocalizedMessage());
}
}
public boolean isGMAInitialized(Object obj) {
Object[] adapterStatesEnum = getAdapterStatesEnum();
if (adapterStatesEnum != null) {
return callNonVoidMethod(initializeStateMethodName, obj, new Object[0]) == adapterStatesEnum[1];
}
DeviceLog.debug("ERROR: Could not get adapter states enum from AdapterStatus.State");
return false;
}
public Object[] getAdapterStatesEnum() {
return this._adapterStateClass.getEnumConstants();
}
}

View File

@@ -0,0 +1,8 @@
package com.unity3d.services.ads.gmascar.bridges;
/* loaded from: classes4.dex */
public class AdapterStatusStateBridge {
public String getClassName() {
return "com.google.android.gms.ads.initialization.AdapterStatus$State";
}
}

View File

@@ -0,0 +1,27 @@
package com.unity3d.services.ads.gmascar.bridges;
import com.unity3d.services.core.reflection.GenericBridge;
import java.util.HashMap;
import java.util.Map;
/* loaded from: classes4.dex */
public class InitializationStatusBridge extends GenericBridge {
private static final String adapterStatusMapMethodName = "getAdapterStatusMap";
@Override // com.unity3d.services.core.reflection.GenericBridge
public String getClassName() {
return "com.google.android.gms.ads.initialization.InitializationStatus";
}
public InitializationStatusBridge() {
super(new HashMap<String, Class<?>[]>() { // from class: com.unity3d.services.ads.gmascar.bridges.InitializationStatusBridge.1
{
put(InitializationStatusBridge.adapterStatusMapMethodName, new Class[0]);
}
});
}
public Map<String, Object> getAdapterStatusMap(Object obj) {
return (Map) callNonVoidMethod(adapterStatusMapMethodName, obj, new Object[0]);
}
}

View File

@@ -0,0 +1,55 @@
package com.unity3d.services.ads.gmascar.bridges;
import com.google.android.gms.ads.initialization.InitializationStatus;
import com.unity3d.services.ads.gmascar.listeners.IInitializationStatusListener;
import com.unity3d.services.core.log.DeviceLog;
import com.unity3d.services.core.reflection.GenericBridge;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.HashMap;
/* loaded from: classes4.dex */
public class InitializeListenerBridge extends GenericBridge {
private static final String initializationCompleteMethodName = "onInitializationComplete";
private IInitializationStatusListener _initializationStatusListener;
@Override // com.unity3d.services.core.reflection.GenericBridge
public String getClassName() {
return "com.google.android.gms.ads.initialization.OnInitializationCompleteListener";
}
public void setStatusListener(IInitializationStatusListener iInitializationStatusListener) {
this._initializationStatusListener = iInitializationStatusListener;
}
public InitializeListenerBridge() {
super(new HashMap<String, Class<?>[]>() { // from class: com.unity3d.services.ads.gmascar.bridges.InitializeListenerBridge.1
{
try {
put(InitializeListenerBridge.initializationCompleteMethodName, new Class[]{InitializationStatus.class});
} catch (ClassNotFoundException e) {
DeviceLog.debug("Could not find class \"com.google.android.gms.ads.initialization.InitializationStatus\" %s", e.getLocalizedMessage());
}
}
});
}
public Object createInitializeListenerProxy() {
try {
return Proxy.newProxyInstance(classForName().getClassLoader(), new Class[]{classForName()}, new InvocationHandler() { // from class: com.unity3d.services.ads.gmascar.bridges.InitializeListenerBridge.2
@Override // java.lang.reflect.InvocationHandler
public Object invoke(Object obj, Method method, Object[] objArr) {
if (!method.getName().equals(InitializeListenerBridge.initializationCompleteMethodName) || InitializeListenerBridge.this._initializationStatusListener == null) {
return null;
}
InitializeListenerBridge.this._initializationStatusListener.onInitializationComplete(objArr[0]);
return null;
}
});
} catch (Exception unused) {
DeviceLog.debug("ERROR: Could not create InitializeCompletionListener");
return null;
}
}
}

View File

@@ -0,0 +1,21 @@
package com.unity3d.services.ads.gmascar.bridges.mobileads;
import android.content.Context;
import com.unity3d.services.ads.gmascar.finder.ScarAdapterVersion;
/* loaded from: classes4.dex */
public interface IMobileAdsBridge {
ScarAdapterVersion getAdapterVersion(int i);
Object getInitializationStatus();
int getVersionCodeIndex();
String getVersionMethodName();
String getVersionString();
void initialize(Context context, Object obj);
boolean shouldInitialize();
}

View File

@@ -0,0 +1,61 @@
package com.unity3d.services.ads.gmascar.bridges.mobileads;
import android.content.Context;
import com.google.android.gms.ads.initialization.OnInitializationCompleteListener;
import com.unity3d.services.ads.gmascar.finder.ScarAdapterVersion;
import com.unity3d.services.core.configuration.ConfigurationReader;
import com.unity3d.services.core.log.DeviceLog;
import java.util.HashMap;
/* loaded from: classes4.dex */
public class MobileAdsBridge extends MobileAdsBridgeBase {
public static final int CODE_21 = 21;
public static final String versionMethodName = "getVersion";
private ConfigurationReader _configurationReader;
@Override // com.unity3d.services.ads.gmascar.bridges.mobileads.IMobileAdsBridge
public int getVersionCodeIndex() {
return 0;
}
@Override // com.unity3d.services.ads.gmascar.bridges.mobileads.IMobileAdsBridge
public String getVersionMethodName() {
return versionMethodName;
}
@Override // com.unity3d.services.ads.gmascar.bridges.mobileads.MobileAdsBridgeBase
public boolean hasSCARBiddingSupport() {
return true;
}
public MobileAdsBridge() {
super(new HashMap<String, Class<?>[]>() { // from class: com.unity3d.services.ads.gmascar.bridges.mobileads.MobileAdsBridge.1
{
try {
put(MobileAdsBridgeBase.initializeMethodName, new Class[]{Context.class, OnInitializationCompleteListener.class});
} catch (ClassNotFoundException e) {
DeviceLog.debug("Could not find class \"com.google.android.gms.ads.initialization.OnInitializationCompleteListener\" %s", e.getLocalizedMessage());
}
put(MobileAdsBridgeBase.initializationStatusMethodName, new Class[0]);
put(MobileAdsBridge.versionMethodName, new Class[0]);
}
});
this._configurationReader = new ConfigurationReader();
}
@Override // com.unity3d.services.ads.gmascar.bridges.mobileads.IMobileAdsBridge
public ScarAdapterVersion getAdapterVersion(int i) {
if (i == -1) {
return ScarAdapterVersion.NA;
}
if (i < 23) {
return ScarAdapterVersion.V21;
}
return ScarAdapterVersion.V23;
}
@Override // com.unity3d.services.ads.gmascar.bridges.mobileads.IMobileAdsBridge
public boolean shouldInitialize() {
return this._configurationReader.getCurrentConfiguration().getExperiments().isScarInitEnabled();
}
}

View File

@@ -0,0 +1,38 @@
package com.unity3d.services.ads.gmascar.bridges.mobileads;
import android.content.Context;
import com.unity3d.services.core.reflection.GenericBridge;
import java.util.Map;
/* loaded from: classes4.dex */
public abstract class MobileAdsBridgeBase extends GenericBridge implements IMobileAdsBridge {
public static final String initializationStatusMethodName = "getInitializationStatus";
public static final String initializeMethodName = "initialize";
@Override // com.unity3d.services.core.reflection.GenericBridge
public String getClassName() {
return "com.google.android.gms.ads.MobileAds";
}
public abstract boolean hasSCARBiddingSupport();
public MobileAdsBridgeBase(Map<String, Class<?>[]> map) {
super(map);
}
@Override // com.unity3d.services.ads.gmascar.bridges.mobileads.IMobileAdsBridge
public void initialize(Context context, Object obj) {
callVoidMethod(initializeMethodName, null, context, obj);
}
@Override // com.unity3d.services.ads.gmascar.bridges.mobileads.IMobileAdsBridge
public Object getInitializationStatus() {
return callNonVoidMethod(initializationStatusMethodName, null, new Object[0]);
}
@Override // com.unity3d.services.ads.gmascar.bridges.mobileads.IMobileAdsBridge
public String getVersionString() {
Object callNonVoidMethod = callNonVoidMethod(getVersionMethodName(), null, new Object[0]);
return callNonVoidMethod == null ? "0.0.0" : callNonVoidMethod.toString();
}
}

View File

@@ -0,0 +1,16 @@
package com.unity3d.services.ads.gmascar.bridges.mobileads;
/* loaded from: classes4.dex */
public class MobileAdsBridgeFactory {
public MobileAdsBridgeBase createMobileAdsBridge() {
MobileAdsBridge mobileAdsBridge = new MobileAdsBridge();
if (mobileAdsBridge.exists()) {
return mobileAdsBridge;
}
MobileAdsBridgeLegacy mobileAdsBridgeLegacy = new MobileAdsBridgeLegacy();
if (mobileAdsBridgeLegacy.exists()) {
return mobileAdsBridgeLegacy;
}
return null;
}
}

View File

@@ -0,0 +1,56 @@
package com.unity3d.services.ads.gmascar.bridges.mobileads;
import android.content.Context;
import com.google.android.gms.ads.initialization.OnInitializationCompleteListener;
import com.unity3d.services.ads.gmascar.finder.ScarAdapterVersion;
import com.unity3d.services.core.log.DeviceLog;
import java.util.HashMap;
/* loaded from: classes4.dex */
public class MobileAdsBridgeLegacy extends MobileAdsBridgeBase {
public static final int CODE_20_0 = 210402000;
public static final int CODE_21_0 = 221310000;
public static final String versionStringMethodName = "getVersionString";
@Override // com.unity3d.services.ads.gmascar.bridges.mobileads.IMobileAdsBridge
public int getVersionCodeIndex() {
return 1;
}
@Override // com.unity3d.services.ads.gmascar.bridges.mobileads.IMobileAdsBridge
public String getVersionMethodName() {
return versionStringMethodName;
}
@Override // com.unity3d.services.ads.gmascar.bridges.mobileads.MobileAdsBridgeBase
public boolean hasSCARBiddingSupport() {
return false;
}
@Override // com.unity3d.services.ads.gmascar.bridges.mobileads.IMobileAdsBridge
public boolean shouldInitialize() {
return true;
}
public MobileAdsBridgeLegacy() {
super(new HashMap<String, Class<?>[]>() { // from class: com.unity3d.services.ads.gmascar.bridges.mobileads.MobileAdsBridgeLegacy.1
{
try {
put(MobileAdsBridgeBase.initializeMethodName, new Class[]{Context.class, OnInitializationCompleteListener.class});
} catch (ClassNotFoundException e) {
DeviceLog.debug("Could not find class \"com.google.android.gms.ads.initialization.OnInitializationCompleteListener\" %s", e.getLocalizedMessage());
}
put(MobileAdsBridgeBase.initializationStatusMethodName, new Class[0]);
put(MobileAdsBridgeLegacy.versionStringMethodName, new Class[0]);
}
});
}
@Override // com.unity3d.services.ads.gmascar.bridges.mobileads.IMobileAdsBridge
public ScarAdapterVersion getAdapterVersion(int i) {
if (i >= 210402000 && i < 221310000) {
return ScarAdapterVersion.V20;
}
return ScarAdapterVersion.NA;
}
}

View File

@@ -0,0 +1,66 @@
package com.unity3d.services.ads.gmascar.finder;
import com.unity3d.scar.adapter.common.GMAEvent;
import com.unity3d.services.ads.gmascar.bridges.AdapterStatusBridge;
import com.unity3d.services.ads.gmascar.bridges.InitializationStatusBridge;
import com.unity3d.services.ads.gmascar.bridges.InitializeListenerBridge;
import com.unity3d.services.ads.gmascar.bridges.mobileads.MobileAdsBridgeBase;
import com.unity3d.services.ads.gmascar.utils.GMAEventSender;
import com.unity3d.services.core.log.DeviceLog;
import com.unity3d.services.core.properties.ClientProperties;
/* loaded from: classes4.dex */
public class GMAInitializer {
private AdapterStatusBridge _adapterStatusBridge;
private GMAEventSender _gmaEventSender;
private InitializeListenerBridge _initializationListenerBridge;
private InitializationStatusBridge _initializationStatusBridge;
private MobileAdsBridgeBase _mobileAdsBridge;
public InitializeListenerBridge getInitializeListenerBridge() {
return this._initializationListenerBridge;
}
public GMAInitializer(MobileAdsBridgeBase mobileAdsBridgeBase, InitializeListenerBridge initializeListenerBridge, InitializationStatusBridge initializationStatusBridge, AdapterStatusBridge adapterStatusBridge, GMAEventSender gMAEventSender) {
this._mobileAdsBridge = mobileAdsBridgeBase;
this._initializationListenerBridge = initializeListenerBridge;
this._initializationStatusBridge = initializationStatusBridge;
this._adapterStatusBridge = adapterStatusBridge;
this._gmaEventSender = gMAEventSender;
}
public void initializeGMA() {
if (shouldInitialize()) {
this._mobileAdsBridge.initialize(ClientProperties.getApplicationContext(), this._initializationListenerBridge.createInitializeListenerProxy());
}
}
public boolean initSuccessful(Object obj) {
Object obj2 = this._initializationStatusBridge.getAdapterStatusMap(obj).get(this._mobileAdsBridge.getClassName());
if (obj2 != null) {
if (this._adapterStatusBridge.isGMAInitialized(obj2)) {
this._gmaEventSender.send(GMAEvent.INIT_SUCCESS, new Object[0]);
return true;
}
this._gmaEventSender.send(GMAEvent.INIT_ERROR, new Object[0]);
}
return false;
}
public boolean isInitialized() {
try {
return initSuccessful(this._mobileAdsBridge.getInitializationStatus());
} catch (Exception e) {
DeviceLog.debug("ERROR: Could not get initialization status of GMA SDK - %s", e.getLocalizedMessage());
return false;
}
}
public boolean shouldInitialize() {
if (isInitialized()) {
this._gmaEventSender.send(GMAEvent.ALREADY_INITIALIZED, new Object[0]);
return false;
}
return this._mobileAdsBridge.shouldInitialize();
}
}

View File

@@ -0,0 +1,26 @@
package com.unity3d.services.ads.gmascar.finder;
import com.unity3d.services.ads.gmascar.bridges.AdapterStatusBridge;
import com.unity3d.services.ads.gmascar.bridges.InitializationStatusBridge;
import com.unity3d.services.ads.gmascar.bridges.InitializeListenerBridge;
import com.unity3d.services.ads.gmascar.bridges.mobileads.MobileAdsBridgeBase;
/* loaded from: classes4.dex */
public class PresenceDetector {
private AdapterStatusBridge _adapterStatusBridge;
private InitializeListenerBridge _initializationListenerBridge;
private InitializationStatusBridge _initializationStatusBridge;
private MobileAdsBridgeBase _mobileAdsBridge;
public PresenceDetector(MobileAdsBridgeBase mobileAdsBridgeBase, InitializeListenerBridge initializeListenerBridge, InitializationStatusBridge initializationStatusBridge, AdapterStatusBridge adapterStatusBridge) {
this._mobileAdsBridge = mobileAdsBridgeBase;
this._initializationListenerBridge = initializeListenerBridge;
this._initializationStatusBridge = initializationStatusBridge;
this._adapterStatusBridge = adapterStatusBridge;
}
public boolean areGMAClassesPresent() {
MobileAdsBridgeBase mobileAdsBridgeBase = this._mobileAdsBridge;
return mobileAdsBridgeBase != null && this._initializationListenerBridge != null && this._initializationStatusBridge != null && this._adapterStatusBridge != null && mobileAdsBridgeBase.exists() && this._initializationListenerBridge.exists() && this._initializationStatusBridge.exists() && this._adapterStatusBridge.exists();
}
}

View File

@@ -0,0 +1,9 @@
package com.unity3d.services.ads.gmascar.finder;
/* loaded from: classes4.dex */
public enum ScarAdapterVersion {
V20,
V21,
V23,
NA
}

View File

@@ -0,0 +1,61 @@
package com.unity3d.services.ads.gmascar.finder;
import com.unity3d.services.ads.gmascar.bridges.mobileads.IMobileAdsBridge;
import com.unity3d.services.ads.gmascar.listeners.IInitializationStatusListener;
import com.unity3d.services.ads.gmascar.utils.GMAEventSender;
import com.unity3d.services.core.log.DeviceLog;
/* loaded from: classes4.dex */
public class ScarVersionFinder implements IInitializationStatusListener {
private static IMobileAdsBridge _mobileAdsBridge;
private GMAEventSender _gmaEventSender;
private GMAInitializer _gmaInitializer;
private int _gmaSdkVersionCode = -1;
private PresenceDetector _presenceDetector;
public ScarVersionFinder(IMobileAdsBridge iMobileAdsBridge, PresenceDetector presenceDetector, GMAInitializer gMAInitializer, GMAEventSender gMAEventSender) {
_mobileAdsBridge = iMobileAdsBridge;
this._presenceDetector = presenceDetector;
this._gmaInitializer = gMAInitializer;
this._gmaEventSender = gMAEventSender;
gMAInitializer.getInitializeListenerBridge().setStatusListener(this);
}
public void getVersion() {
try {
if (!this._presenceDetector.areGMAClassesPresent()) {
this._gmaEventSender.sendVersion("0.0.0");
} else if (this._gmaInitializer.shouldInitialize()) {
this._gmaInitializer.initializeGMA();
} else {
findAndSendVersion(true);
}
} catch (Exception e) {
DeviceLog.debug("Got exception finding GMA SDK: %s", e.getLocalizedMessage());
}
}
public void findAndSendVersion(boolean z) {
this._gmaEventSender.sendVersion(z ? _mobileAdsBridge.getVersionString() : "0.0.0");
}
public int getVersionCode() {
String versionString;
if (this._gmaSdkVersionCode == -1 && (versionString = _mobileAdsBridge.getVersionString()) != null) {
String[] split = versionString.split("\\.");
if (split.length > _mobileAdsBridge.getVersionCodeIndex()) {
try {
this._gmaSdkVersionCode = Integer.parseInt(split[_mobileAdsBridge.getVersionCodeIndex()]);
} catch (NumberFormatException e) {
DeviceLog.debug("Could not parse %s to an Integer: %s", split[_mobileAdsBridge.getVersionCodeIndex()], e.getLocalizedMessage());
}
}
}
return this._gmaSdkVersionCode;
}
@Override // com.unity3d.services.ads.gmascar.listeners.IInitializationStatusListener
public void onInitializationComplete(Object obj) {
findAndSendVersion(this._gmaInitializer.initSuccessful(obj));
}
}

View File

@@ -0,0 +1,45 @@
package com.unity3d.services.ads.gmascar.handlers;
import com.unity3d.scar.adapter.common.signals.ISignalCollectionListener;
import com.unity3d.scar.adapter.common.signals.SignalsCollectorBase;
import com.unity3d.services.ads.gmascar.listeners.IBiddingSignalsListener;
import com.unity3d.services.ads.gmascar.models.BiddingSignals;
import org.json.JSONException;
import org.json.JSONObject;
/* loaded from: classes4.dex */
public class BiddingSignalsHandler implements ISignalCollectionListener {
private final boolean isBannerEnabled;
private final IBiddingSignalsListener listener;
public BiddingSignalsHandler(boolean z, IBiddingSignalsListener iBiddingSignalsListener) {
this.listener = iBiddingSignalsListener;
this.isBannerEnabled = z;
}
@Override // com.unity3d.scar.adapter.common.signals.ISignalCollectionListener
public void onSignalsCollected(String str) {
this.listener.onSignalsReady(getSignals(str));
}
@Override // com.unity3d.scar.adapter.common.signals.ISignalCollectionListener
public void onSignalsCollectionFailed(String str) {
this.listener.onSignalsFailure(str);
}
private BiddingSignals getSignals(String str) {
try {
JSONObject jSONObject = new JSONObject(str);
if (this.isBannerEnabled) {
return new BiddingSignals(getSignalFromJson(jSONObject, SignalsCollectorBase.SCAR_RV_SIGNAL), getSignalFromJson(jSONObject, SignalsCollectorBase.SCAR_INT_SIGNAL), getSignalFromJson(jSONObject, SignalsCollectorBase.SCAR_BAN_SIGNAL));
}
return new BiddingSignals(getSignalFromJson(jSONObject, SignalsCollectorBase.SCAR_RV_SIGNAL), getSignalFromJson(jSONObject, SignalsCollectorBase.SCAR_INT_SIGNAL));
} catch (JSONException unused) {
return null;
}
}
private String getSignalFromJson(JSONObject jSONObject, String str) {
return jSONObject.optString(str);
}
}

View File

@@ -0,0 +1,53 @@
package com.unity3d.services.ads.gmascar.handlers;
import com.unity3d.scar.adapter.common.GMAEvent;
import com.unity3d.scar.adapter.common.IScarAdListenerWrapper;
import com.unity3d.scar.adapter.common.scarads.ScarAdMetadata;
import com.unity3d.services.ads.gmascar.utils.GMAEventSender;
import com.unity3d.services.core.misc.EventSubject;
import com.unity3d.services.core.misc.IEventListener;
/* loaded from: classes4.dex */
public abstract class ScarAdHandlerBase implements IScarAdListenerWrapper {
protected final EventSubject<GMAEvent> _eventSubject;
protected final GMAEventSender _gmaEventSender;
protected final ScarAdMetadata _scarAdMetadata;
public ScarAdHandlerBase(ScarAdMetadata scarAdMetadata, EventSubject<GMAEvent> eventSubject, GMAEventSender gMAEventSender) {
this._scarAdMetadata = scarAdMetadata;
this._eventSubject = eventSubject;
this._gmaEventSender = gMAEventSender;
}
@Override // com.unity3d.scar.adapter.common.IScarAdListenerWrapper
public void onAdLoaded() {
this._gmaEventSender.send(GMAEvent.AD_LOADED, this._scarAdMetadata.getPlacementId(), this._scarAdMetadata.getQueryId());
}
@Override // com.unity3d.scar.adapter.common.IScarAdListenerWrapper
public void onAdFailedToLoad(int i, String str) {
this._gmaEventSender.send(GMAEvent.LOAD_ERROR, this._scarAdMetadata.getPlacementId(), this._scarAdMetadata.getQueryId(), str, Integer.valueOf(i));
}
@Override // com.unity3d.scar.adapter.common.IScarAdListenerWrapper
public void onAdOpened() {
this._gmaEventSender.send(GMAEvent.AD_STARTED, new Object[0]);
this._eventSubject.subscribe(new IEventListener<GMAEvent>() { // from class: com.unity3d.services.ads.gmascar.handlers.ScarAdHandlerBase.1
@Override // com.unity3d.services.core.misc.IEventListener
public void onNextEvent(GMAEvent gMAEvent) {
ScarAdHandlerBase.this._gmaEventSender.send(gMAEvent, new Object[0]);
}
});
}
@Override // com.unity3d.scar.adapter.common.IScarAdListenerWrapper
public void onAdClicked() {
this._gmaEventSender.send(GMAEvent.AD_CLICKED, new Object[0]);
}
@Override // com.unity3d.scar.adapter.common.IScarAdListenerWrapper
public void onAdClosed() {
this._gmaEventSender.send(GMAEvent.AD_CLOSED, new Object[0]);
this._eventSubject.unsubscribe();
}
}

View File

@@ -0,0 +1,47 @@
package com.unity3d.services.ads.gmascar.handlers;
import com.unity3d.scar.adapter.common.IScarBannerAdListenerWrapper;
import com.unity3d.services.banners.BannerViewCache;
import com.unity3d.services.banners.bridge.BannerBridge;
import com.unity3d.services.core.webview.WebViewApp;
import com.unity3d.services.core.webview.WebViewEventCategory;
/* loaded from: classes4.dex */
public class ScarBannerAdHandler implements IScarBannerAdListenerWrapper {
private String _operationId;
public ScarBannerAdHandler(String str) {
this._operationId = str;
}
@Override // com.unity3d.scar.adapter.common.IScarAdListenerWrapper
public void onAdLoaded() {
BannerViewCache.getInstance().addScarContainer(this._operationId);
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.BANNER, BannerBridge.BannerEvent.SCAR_BANNER_LOADED, this._operationId);
}
@Override // com.unity3d.scar.adapter.common.IScarAdListenerWrapper
public void onAdFailedToLoad(int i, String str) {
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.BANNER, BannerBridge.BannerEvent.SCAR_BANNER_LOAD_FAILED, this._operationId, Integer.valueOf(i), str);
}
@Override // com.unity3d.scar.adapter.common.IScarAdListenerWrapper
public void onAdOpened() {
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.BANNER, BannerBridge.BannerEvent.SCAR_BANNER_OPENED, this._operationId);
}
@Override // com.unity3d.scar.adapter.common.IScarAdListenerWrapper
public void onAdClicked() {
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.BANNER, BannerBridge.BannerEvent.SCAR_BANNER_CLICKED, this._operationId);
}
@Override // com.unity3d.scar.adapter.common.IScarAdListenerWrapper
public void onAdClosed() {
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.BANNER, BannerBridge.BannerEvent.SCAR_BANNER_CLOSED, this._operationId);
}
@Override // com.unity3d.scar.adapter.common.IScarBannerAdListenerWrapper
public void onAdImpression() {
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.BANNER, BannerBridge.BannerEvent.SCAR_BANNER_IMPRESSION, this._operationId);
}
}

View File

@@ -0,0 +1,42 @@
package com.unity3d.services.ads.gmascar.handlers;
import com.unity3d.scar.adapter.common.GMAEvent;
import com.unity3d.scar.adapter.common.IScarInterstitialAdListenerWrapper;
import com.unity3d.scar.adapter.common.scarads.ScarAdMetadata;
import com.unity3d.services.ads.gmascar.utils.GMAEventSender;
import com.unity3d.services.core.misc.EventSubject;
/* loaded from: classes4.dex */
public class ScarInterstitialAdHandler extends ScarAdHandlerBase implements IScarInterstitialAdListenerWrapper {
public ScarInterstitialAdHandler(ScarAdMetadata scarAdMetadata, EventSubject<GMAEvent> eventSubject, GMAEventSender gMAEventSender) {
super(scarAdMetadata, eventSubject, gMAEventSender);
}
@Override // com.unity3d.scar.adapter.common.IScarInterstitialAdListenerWrapper
public void onAdFailedToShow(int i, String str) {
this._gmaEventSender.send(GMAEvent.INTERSTITIAL_SHOW_ERROR, this._scarAdMetadata.getPlacementId(), this._scarAdMetadata.getQueryId(), str, Integer.valueOf(i));
}
@Override // com.unity3d.scar.adapter.common.IScarInterstitialAdListenerWrapper
public void onAdSkipped() {
this._gmaEventSender.send(GMAEvent.AD_SKIPPED, new Object[0]);
}
@Override // com.unity3d.services.ads.gmascar.handlers.ScarAdHandlerBase, com.unity3d.scar.adapter.common.IScarAdListenerWrapper
public void onAdClosed() {
if (!this._eventSubject.eventQueueIsEmpty()) {
onAdSkipped();
}
super.onAdClosed();
}
@Override // com.unity3d.scar.adapter.common.IScarInterstitialAdListenerWrapper
public void onAdLeftApplication() {
this._gmaEventSender.send(GMAEvent.AD_LEFT_APPLICATION, new Object[0]);
}
@Override // com.unity3d.scar.adapter.common.IScarInterstitialAdListenerWrapper
public void onAdImpression() {
this._gmaEventSender.send(GMAEvent.INTERSTITIAL_IMPRESSION_RECORDED, new Object[0]);
}
}

View File

@@ -0,0 +1,46 @@
package com.unity3d.services.ads.gmascar.handlers;
import com.unity3d.scar.adapter.common.GMAEvent;
import com.unity3d.scar.adapter.common.IScarRewardedAdListenerWrapper;
import com.unity3d.scar.adapter.common.scarads.ScarAdMetadata;
import com.unity3d.services.ads.gmascar.utils.GMAEventSender;
import com.unity3d.services.core.misc.EventSubject;
/* loaded from: classes4.dex */
public class ScarRewardedAdHandler extends ScarAdHandlerBase implements IScarRewardedAdListenerWrapper {
private boolean _hasEarnedReward;
public ScarRewardedAdHandler(ScarAdMetadata scarAdMetadata, EventSubject<GMAEvent> eventSubject, GMAEventSender gMAEventSender) {
super(scarAdMetadata, eventSubject, gMAEventSender);
this._hasEarnedReward = false;
}
@Override // com.unity3d.scar.adapter.common.IScarRewardedAdListenerWrapper
public void onAdFailedToShow(int i, String str) {
this._gmaEventSender.send(GMAEvent.REWARDED_SHOW_ERROR, this._scarAdMetadata.getPlacementId(), this._scarAdMetadata.getQueryId(), str, Integer.valueOf(i));
}
@Override // com.unity3d.scar.adapter.common.IScarRewardedAdListenerWrapper
public void onUserEarnedReward() {
this._hasEarnedReward = true;
this._gmaEventSender.send(GMAEvent.AD_EARNED_REWARD, new Object[0]);
}
@Override // com.unity3d.scar.adapter.common.IScarRewardedAdListenerWrapper
public void onAdSkipped() {
this._gmaEventSender.send(GMAEvent.AD_SKIPPED, new Object[0]);
}
@Override // com.unity3d.services.ads.gmascar.handlers.ScarAdHandlerBase, com.unity3d.scar.adapter.common.IScarAdListenerWrapper
public void onAdClosed() {
if (!this._hasEarnedReward) {
onAdSkipped();
}
super.onAdClosed();
}
@Override // com.unity3d.scar.adapter.common.IScarRewardedAdListenerWrapper
public void onAdImpression() {
this._gmaEventSender.send(GMAEvent.REWARDED_IMPRESSION_RECORDED, new Object[0]);
}
}

View File

@@ -0,0 +1,24 @@
package com.unity3d.services.ads.gmascar.handlers;
import com.unity3d.scar.adapter.common.GMAEvent;
import com.unity3d.scar.adapter.common.signals.ISignalCollectionListener;
import com.unity3d.services.ads.gmascar.utils.GMAEventSender;
/* loaded from: classes4.dex */
public class SignalsHandler implements ISignalCollectionListener {
private GMAEventSender _gmaEventSender;
public SignalsHandler(GMAEventSender gMAEventSender) {
this._gmaEventSender = gMAEventSender;
}
@Override // com.unity3d.scar.adapter.common.signals.ISignalCollectionListener
public void onSignalsCollected(String str) {
this._gmaEventSender.send(GMAEvent.SIGNALS, str);
}
@Override // com.unity3d.scar.adapter.common.signals.ISignalCollectionListener
public void onSignalsCollectionFailed(String str) {
this._gmaEventSender.send(GMAEvent.SIGNALS_ERROR, str);
}
}

View File

@@ -0,0 +1,25 @@
package com.unity3d.services.ads.gmascar.handlers;
import com.unity3d.scar.adapter.common.IAdsErrorHandler;
import com.unity3d.scar.adapter.common.WebViewAdsError;
import com.unity3d.services.core.webview.WebViewEventCategory;
import com.unity3d.services.core.webview.bridge.IEventSender;
import com.unity3d.services.core.webview.bridge.SharedInstances;
/* loaded from: classes4.dex */
public class WebViewErrorHandler implements IAdsErrorHandler<WebViewAdsError> {
private final IEventSender _eventSender;
public WebViewErrorHandler() {
this(SharedInstances.INSTANCE.getWebViewEventSender());
}
public WebViewErrorHandler(IEventSender iEventSender) {
this._eventSender = iEventSender;
}
@Override // com.unity3d.scar.adapter.common.IAdsErrorHandler
public void handleError(WebViewAdsError webViewAdsError) {
this._eventSender.sendEvent(WebViewEventCategory.valueOf(webViewAdsError.getDomain()), webViewAdsError.getErrorCategory(), webViewAdsError.getErrorArguments());
}
}

View File

@@ -0,0 +1,10 @@
package com.unity3d.services.ads.gmascar.listeners;
import com.unity3d.services.ads.gmascar.models.BiddingSignals;
/* loaded from: classes4.dex */
public interface IBiddingSignalsListener {
void onSignalsFailure(String str);
void onSignalsReady(BiddingSignals biddingSignals);
}

View File

@@ -0,0 +1,6 @@
package com.unity3d.services.ads.gmascar.listeners;
/* loaded from: classes4.dex */
public interface IInitializationStatusListener {
void onInitializationComplete(Object obj);
}

View File

@@ -0,0 +1,156 @@
package com.unity3d.services.ads.gmascar.managers;
import com.unity3d.ads.IUnityAdsTokenListener;
import com.unity3d.services.ads.gmascar.GMA;
import com.unity3d.services.ads.gmascar.listeners.IBiddingSignalsListener;
import com.unity3d.services.ads.gmascar.models.BiddingSignals;
import com.unity3d.services.ads.gmascar.utils.ScarConstants;
import com.unity3d.services.ads.gmascar.utils.ScarRequestHandler;
import com.unity3d.services.core.configuration.ConfigurationReader;
import com.unity3d.services.core.misc.Utilities;
import com.unity3d.services.core.request.metrics.SDKMetricsSender;
import com.unity3d.services.core.request.metrics.ScarMetric;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
/* loaded from: classes4.dex */
public abstract class BiddingBaseManager implements IBiddingManager {
private final boolean _isAsyncTokenCall;
private final boolean _isBannerEnabled;
private final ScarRequestHandler _scarRequestHandler;
protected final AtomicBoolean isUploadPermitted;
private final AtomicReference<BiddingSignals> signals;
private final String tokenIdentifier;
private final IUnityAdsTokenListener unityAdsTokenListener;
@Override // com.unity3d.services.ads.gmascar.managers.IBiddingManager
public String getTokenIdentifier() {
return this.tokenIdentifier;
}
public abstract void start();
public BiddingBaseManager(boolean z, IUnityAdsTokenListener iUnityAdsTokenListener) {
this(z, iUnityAdsTokenListener, new ScarRequestHandler());
}
public BiddingBaseManager(boolean z, IUnityAdsTokenListener iUnityAdsTokenListener, ScarRequestHandler scarRequestHandler) {
this.isUploadPermitted = new AtomicBoolean(false);
this.signals = new AtomicReference<>();
this.tokenIdentifier = UUID.randomUUID().toString();
this._isBannerEnabled = z;
this.unityAdsTokenListener = iUnityAdsTokenListener;
this._isAsyncTokenCall = iUnityAdsTokenListener != null;
this._scarRequestHandler = scarRequestHandler;
}
@Override // com.unity3d.services.ads.gmascar.managers.IBiddingManager
public String getFormattedToken(String str) {
if (str == null || str.isEmpty()) {
return null;
}
String tokenIdentifier = getTokenIdentifier();
return (tokenIdentifier == null || tokenIdentifier.isEmpty()) ? str : String.format(ScarConstants.TOKEN_WITH_SCAR_FORMAT, tokenIdentifier, str);
}
/* JADX INFO: Access modifiers changed from: private */
public /* synthetic */ void lambda$onUnityAdsTokenReady$0(String str) {
this.unityAdsTokenListener.onUnityAdsTokenReady(str);
}
@Override // com.unity3d.ads.IUnityAdsTokenListener
public final void onUnityAdsTokenReady(final String str) {
if (this.unityAdsTokenListener != null) {
Utilities.wrapCustomerListener(new Runnable() { // from class: com.unity3d.services.ads.gmascar.managers.BiddingBaseManager$$ExternalSyntheticLambda1
@Override // java.lang.Runnable
public final void run() {
BiddingBaseManager.this.lambda$onUnityAdsTokenReady$0(str);
}
});
}
}
public void permitUpload() {
this.isUploadPermitted.set(true);
}
public void permitSignalsUpload() {
this.isUploadPermitted.set(true);
attemptUpload();
}
public void fetchSignals() {
getMetricSender().sendMetric(ScarMetric.hbSignalsFetchStart(this._isAsyncTokenCall));
new Thread(new Runnable() { // from class: com.unity3d.services.ads.gmascar.managers.BiddingBaseManager$$ExternalSyntheticLambda0
@Override // java.lang.Runnable
public final void run() {
BiddingBaseManager.this.lambda$fetchSignals$1();
}
}).start();
}
/* JADX INFO: Access modifiers changed from: private */
public /* synthetic */ void lambda$fetchSignals$1() {
GMA.getInstance().getSCARBiddingSignals(this._isBannerEnabled, new IBiddingSignalsListener() { // from class: com.unity3d.services.ads.gmascar.managers.BiddingBaseManager.1
@Override // com.unity3d.services.ads.gmascar.listeners.IBiddingSignalsListener
public void onSignalsReady(BiddingSignals biddingSignals) {
BiddingBaseManager.this.onSignalsReady(biddingSignals);
BiddingBaseManager.this.sendFetchResult("");
}
@Override // com.unity3d.services.ads.gmascar.listeners.IBiddingSignalsListener
public void onSignalsFailure(String str) {
BiddingBaseManager.this.sendFetchResult(str);
}
});
}
public void sendFetchResult(String str) {
if (str != "") {
getMetricSender().sendMetric(ScarMetric.hbSignalsFetchFailure(this._isAsyncTokenCall, str));
} else {
getMetricSender().sendMetric(ScarMetric.hbSignalsFetchSuccess(this._isAsyncTokenCall));
}
}
public void onSignalsReady(BiddingSignals biddingSignals) {
this.signals.set(biddingSignals);
attemptUpload();
}
private synchronized void attemptUpload() {
if (this.signals.get() != null && this.isUploadPermitted.compareAndSet(true, false)) {
uploadSignals();
}
}
public void uploadSignals() {
getMetricSender().sendMetric(ScarMetric.hbSignalsUploadStart(this._isAsyncTokenCall));
final BiddingSignals biddingSignals = this.signals.get();
if (biddingSignals == null || biddingSignals.isEmpty()) {
getMetricSender().sendMetric(ScarMetric.hbSignalsUploadFailure(this._isAsyncTokenCall, "null or empty signals"));
} else {
new Thread(new Runnable() { // from class: com.unity3d.services.ads.gmascar.managers.BiddingBaseManager$$ExternalSyntheticLambda2
@Override // java.lang.Runnable
public final void run() {
BiddingBaseManager.this.lambda$uploadSignals$2(biddingSignals);
}
}).start();
}
}
/* JADX INFO: Access modifiers changed from: private */
public /* synthetic */ void lambda$uploadSignals$2(BiddingSignals biddingSignals) {
try {
this._scarRequestHandler.makeUploadRequest(this.tokenIdentifier, biddingSignals, new ConfigurationReader().getCurrentConfiguration().getScarBiddingUrl());
getMetricSender().sendMetric(ScarMetric.hbSignalsUploadSuccess(this._isAsyncTokenCall));
} catch (Exception e) {
getMetricSender().sendMetric(ScarMetric.hbSignalsUploadFailure(this._isAsyncTokenCall, e.getLocalizedMessage()));
}
}
public SDKMetricsSender getMetricSender() {
return (SDKMetricsSender) Utilities.getService(SDKMetricsSender.class);
}
}

View File

@@ -0,0 +1,19 @@
package com.unity3d.services.ads.gmascar.managers;
import com.unity3d.ads.IUnityAdsTokenListener;
/* loaded from: classes4.dex */
public class BiddingDisabledManager extends BiddingBaseManager {
@Override // com.unity3d.services.ads.gmascar.managers.BiddingBaseManager, com.unity3d.services.ads.gmascar.managers.IBiddingManager
public String getTokenIdentifier() {
return null;
}
@Override // com.unity3d.services.ads.gmascar.managers.BiddingBaseManager
public void start() {
}
public BiddingDisabledManager(IUnityAdsTokenListener iUnityAdsTokenListener) {
super(false, iUnityAdsTokenListener);
}
}

View File

@@ -0,0 +1,16 @@
package com.unity3d.services.ads.gmascar.managers;
import com.unity3d.ads.IUnityAdsTokenListener;
/* loaded from: classes4.dex */
public class BiddingEagerManager extends BiddingBaseManager {
public BiddingEagerManager(boolean z, IUnityAdsTokenListener iUnityAdsTokenListener) {
super(z, iUnityAdsTokenListener);
}
@Override // com.unity3d.services.ads.gmascar.managers.BiddingBaseManager
public void start() {
permitSignalsUpload();
fetchSignals();
}
}

View File

@@ -0,0 +1,55 @@
package com.unity3d.services.ads.gmascar.managers;
import com.unity3d.ads.IUnityAdsTokenListener;
import com.unity3d.services.ads.gmascar.GMA;
import com.unity3d.services.core.configuration.IExperiments;
/* loaded from: classes4.dex */
public class BiddingManagerFactory {
private static BiddingManagerFactory instance;
private BiddingManagerFactory() {
}
public static BiddingManagerFactory getInstance() {
if (instance == null) {
instance = new BiddingManagerFactory();
}
return instance;
}
public BiddingBaseManager createManager(IUnityAdsTokenListener iUnityAdsTokenListener, IExperiments iExperiments) {
if (GMA.getInstance().hasSCARBiddingSupport()) {
return getExperiment(iUnityAdsTokenListener, iExperiments);
}
return new BiddingDisabledManager(iUnityAdsTokenListener);
}
private BiddingBaseManager getExperiment(IUnityAdsTokenListener iUnityAdsTokenListener, IExperiments iExperiments) {
if (iExperiments == null || iExperiments.getScarBiddingManager() == null) {
return new BiddingDisabledManager(iUnityAdsTokenListener);
}
if (AnonymousClass1.$SwitchMap$com$unity3d$services$ads$gmascar$managers$ScarBiddingManagerType[ScarBiddingManagerType.fromName(iExperiments.getScarBiddingManager()).ordinal()] == 1) {
return new BiddingEagerManager(iExperiments.isScarBannerHbEnabled(), iUnityAdsTokenListener);
}
return new BiddingDisabledManager(iUnityAdsTokenListener);
}
/* renamed from: com.unity3d.services.ads.gmascar.managers.BiddingManagerFactory$1, reason: invalid class name */
public static /* synthetic */ class AnonymousClass1 {
static final /* synthetic */ int[] $SwitchMap$com$unity3d$services$ads$gmascar$managers$ScarBiddingManagerType;
static {
int[] iArr = new int[ScarBiddingManagerType.values().length];
$SwitchMap$com$unity3d$services$ads$gmascar$managers$ScarBiddingManagerType = iArr;
try {
iArr[ScarBiddingManagerType.EAGER.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
$SwitchMap$com$unity3d$services$ads$gmascar$managers$ScarBiddingManagerType[ScarBiddingManagerType.DISABLED.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
}
}
}

View File

@@ -0,0 +1,10 @@
package com.unity3d.services.ads.gmascar.managers;
import com.unity3d.ads.IUnityAdsTokenListener;
/* loaded from: classes4.dex */
public interface IBiddingManager extends IUnityAdsTokenListener {
String getFormattedToken(String str);
String getTokenIdentifier();
}

View File

@@ -0,0 +1,30 @@
package com.unity3d.services.ads.gmascar.managers;
/* loaded from: classes4.dex */
public enum ScarBiddingManagerType {
DISABLED("dis"),
EAGER("eag");
private final String name;
public String getName() {
return this.name;
}
ScarBiddingManagerType(String str) {
this.name = str;
}
public static ScarBiddingManagerType fromName(String str) {
int hashCode = str.hashCode();
return (hashCode != 99470 && hashCode == 100171 && str.equals("eag")) ? EAGER : DISABLED;
}
public static class Constants {
private static final String DIS = "dis";
private static final String EAG = "eag";
private Constants() {
}
}
}

View File

@@ -0,0 +1,55 @@
package com.unity3d.services.ads.gmascar.models;
import android.text.TextUtils;
import com.unity3d.services.ads.gmascar.utils.ScarConstants;
import java.util.HashMap;
import java.util.Map;
/* loaded from: classes4.dex */
public class BiddingSignals {
private final String bannerSignal;
private final String interstitialSignal;
private final String rvSignal;
public String getBannerSignal() {
return this.bannerSignal;
}
public String getInterstitialSignal() {
return this.interstitialSignal;
}
public String getRvSignal() {
return this.rvSignal;
}
public BiddingSignals(String str, String str2, String str3) {
this.rvSignal = str;
this.interstitialSignal = str2;
this.bannerSignal = str3;
}
public BiddingSignals(String str, String str2) {
this.rvSignal = str;
this.interstitialSignal = str2;
this.bannerSignal = "";
}
public boolean isEmpty() {
return TextUtils.isEmpty(getRvSignal()) && TextUtils.isEmpty(getInterstitialSignal()) && TextUtils.isEmpty(getBannerSignal());
}
public Map<String, String> getMap() {
HashMap hashMap = new HashMap();
if (!TextUtils.isEmpty(getRvSignal())) {
hashMap.put("rv", getRvSignal());
}
if (!TextUtils.isEmpty(getInterstitialSignal())) {
hashMap.put(ScarConstants.IN_SIGNAL_KEY, getInterstitialSignal());
}
if (!TextUtils.isEmpty(getBannerSignal())) {
hashMap.put(ScarConstants.BN_SIGNAL_KEY, getBannerSignal());
}
return hashMap;
}
}

View File

@@ -0,0 +1,27 @@
package com.unity3d.services.ads.gmascar.utils;
import com.unity3d.scar.adapter.common.GMAEvent;
import com.unity3d.services.core.webview.WebViewEventCategory;
import com.unity3d.services.core.webview.bridge.IEventSender;
import com.unity3d.services.core.webview.bridge.SharedInstances;
/* loaded from: classes4.dex */
public class GMAEventSender {
private final IEventSender _eventSender;
public GMAEventSender() {
this(SharedInstances.INSTANCE.getWebViewEventSender());
}
public GMAEventSender(IEventSender iEventSender) {
this._eventSender = iEventSender;
}
public void send(GMAEvent gMAEvent, Object... objArr) {
this._eventSender.sendEvent(WebViewEventCategory.GMA, gMAEvent, objArr);
}
public void sendVersion(String str) {
this._eventSender.sendEvent(WebViewEventCategory.INIT_GMA, GMAEvent.VERSION, str);
}
}

View File

@@ -0,0 +1,13 @@
package com.unity3d.services.ads.gmascar.utils;
/* loaded from: classes4.dex */
public class ScarConstants {
public static final String BN_SIGNAL_KEY = "bn";
public static final String IDFI_KEY = "idfi";
public static final String IN_SIGNAL_KEY = "in";
public static final String RV_SIGNAL_KEY = "rv";
public static final String SCAR_PRD_BIDDING_ENDPOINT = "https://scar.unityads.unity3d.com/v1/capture-scar-signals";
public static final String SCAR_TOKEN_IDENTIFIER_KEY = "scarId";
public static final String TOKEN_ID_KEY = "tid";
public static final String TOKEN_WITH_SCAR_FORMAT = "%s:%s";
}

View File

@@ -0,0 +1,28 @@
package com.unity3d.services.ads.gmascar.utils;
import com.ironsource.nb;
import com.unity3d.services.ads.gmascar.models.BiddingSignals;
import com.unity3d.services.core.device.Device;
import com.unity3d.services.core.misc.Utilities;
import com.unity3d.services.core.network.core.HttpClient;
import com.unity3d.services.core.network.model.HttpRequest;
import com.unity3d.services.core.network.model.RequestType;
import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.HashMap;
import org.json.JSONObject;
/* loaded from: classes4.dex */
public class ScarRequestHandler {
private final HttpClient httpClient = (HttpClient) Utilities.getService(HttpClient.class);
public void makeUploadRequest(String str, BiddingSignals biddingSignals, String str2) throws Exception {
HashMap hashMap = new HashMap();
hashMap.put("Content-Type", Collections.singletonList(nb.L));
HashMap hashMap2 = new HashMap();
hashMap2.put(ScarConstants.IDFI_KEY, Device.getIdfi());
hashMap2.put(ScarConstants.TOKEN_ID_KEY, str);
hashMap2.putAll(biddingSignals.getMap());
this.httpClient.executeBlocking(new HttpRequest(str2, "", RequestType.POST, new JSONObject(hashMap2).toString().getBytes(StandardCharsets.UTF_8), hashMap));
}
}

View File

@@ -0,0 +1,13 @@
package com.unity3d.services.ads.measurements;
/* loaded from: classes4.dex */
public enum MeasurementsErrors {
ERROR_AD_SERVICES_DISABLED,
ERROR_EXTENSION_BELOW_4,
ERROR_API_BELOW_33,
ERROR_MANAGER_NULL,
ERROR_EXCEPTION,
ERROR_AD_UNIT_NULL,
ERROR_LAYOUT_NULL,
ERROR_LAST_INPUT_EVENT_NULL
}

View File

@@ -0,0 +1,11 @@
package com.unity3d.services.ads.measurements;
/* loaded from: classes4.dex */
public enum MeasurementsEvents {
NOT_AVAILABLE,
AVAILABLE,
VIEW_SUCCESSFUL,
VIEW_ERROR,
CLICK_SUCCESSFUL,
CLICK_ERROR
}

View File

@@ -0,0 +1,34 @@
package com.unity3d.services.ads.measurements;
import android.annotation.SuppressLint;
import android.os.OutcomeReceiver;
import com.unity3d.services.core.webview.WebViewEventCategory;
import com.unity3d.services.core.webview.bridge.IEventSender;
import kotlin.jvm.internal.Intrinsics;
@SuppressLint({"NewApi", "MissingPermission"})
/* loaded from: classes4.dex */
public final class MeasurementsReceiver implements OutcomeReceiver {
private final MeasurementsEvents errorEvent;
private final IEventSender eventSender;
private final MeasurementsEvents successEvent;
public MeasurementsReceiver(IEventSender eventSender, MeasurementsEvents successEvent, MeasurementsEvents errorEvent) {
Intrinsics.checkNotNullParameter(eventSender, "eventSender");
Intrinsics.checkNotNullParameter(successEvent, "successEvent");
Intrinsics.checkNotNullParameter(errorEvent, "errorEvent");
this.eventSender = eventSender;
this.successEvent = successEvent;
this.errorEvent = errorEvent;
}
public void onResult(Object p0) {
Intrinsics.checkNotNullParameter(p0, "p0");
this.eventSender.sendEvent(WebViewEventCategory.MEASUREMENTS, this.successEvent, new Object[0]);
}
public void onError(Exception error) {
Intrinsics.checkNotNullParameter(error, "error");
this.eventSender.sendEvent(WebViewEventCategory.MEASUREMENTS, this.errorEvent, error.toString());
}
}

View File

@@ -0,0 +1,88 @@
package com.unity3d.services.ads.measurements;
import android.adservices.AdServicesState;
import android.adservices.measurement.MeasurementManager;
import android.annotation.SuppressLint;
import android.content.Context;
import android.net.Uri;
import android.os.ext.SdkExtensions;
import android.view.InputEvent;
import androidx.core.os.OutcomeReceiverKt$$ExternalSyntheticApiModelOutline0;
import androidx.privacysandbox.ads.adservices.measurement.MeasurementManager$Api33Ext5Impl$$ExternalSyntheticApiModelOutline23;
import androidx.privacysandbox.ads.adservices.measurement.MeasurementManager$Api33Ext5Impl$$ExternalSyntheticApiModelOutline24;
import com.unity3d.services.core.device.Device;
import com.unity3d.services.core.domain.ISDKDispatchers;
import com.unity3d.services.core.webview.WebViewEventCategory;
import com.unity3d.services.core.webview.bridge.IEventSender;
import kotlin.jvm.internal.Intrinsics;
import kotlinx.coroutines.ExecutorsKt;
@SuppressLint({"NewApi", "MissingPermission"})
/* loaded from: classes4.dex */
public final class MeasurementsService {
private final ISDKDispatchers dispatchers;
private final IEventSender eventSender;
private final MeasurementManager measurementManager;
public MeasurementsService(Context context, ISDKDispatchers dispatchers, IEventSender eventSender) {
Intrinsics.checkNotNullParameter(context, "context");
Intrinsics.checkNotNullParameter(dispatchers, "dispatchers");
Intrinsics.checkNotNullParameter(eventSender, "eventSender");
this.dispatchers = dispatchers;
this.eventSender = eventSender;
this.measurementManager = getMeasurementManager(context);
}
public final void checkAvailability() {
int extensionVersion;
boolean isAdServicesStateEnabled;
if (Device.getApiLevel() < 33) {
this.eventSender.sendEvent(WebViewEventCategory.MEASUREMENTS, MeasurementsEvents.NOT_AVAILABLE, MeasurementsErrors.ERROR_API_BELOW_33);
return;
}
extensionVersion = SdkExtensions.getExtensionVersion(1000000);
if (extensionVersion < 4) {
this.eventSender.sendEvent(WebViewEventCategory.MEASUREMENTS, MeasurementsEvents.NOT_AVAILABLE, MeasurementsErrors.ERROR_EXTENSION_BELOW_4);
return;
}
if (this.measurementManager == null) {
this.eventSender.sendEvent(WebViewEventCategory.MEASUREMENTS, MeasurementsEvents.NOT_AVAILABLE, MeasurementsErrors.ERROR_MANAGER_NULL);
return;
}
isAdServicesStateEnabled = AdServicesState.isAdServicesStateEnabled();
if (!isAdServicesStateEnabled) {
this.eventSender.sendEvent(WebViewEventCategory.MEASUREMENTS, MeasurementsEvents.NOT_AVAILABLE, MeasurementsErrors.ERROR_AD_SERVICES_DISABLED);
} else {
this.measurementManager.getMeasurementApiStatus(ExecutorsKt.asExecutor(this.dispatchers.getDefault()), OutcomeReceiverKt$$ExternalSyntheticApiModelOutline0.m(new MeasurementsStatusReceiver(this.eventSender)));
}
}
public final void registerView(String url) {
Intrinsics.checkNotNullParameter(url, "url");
MeasurementManager measurementManager = this.measurementManager;
if (measurementManager != null) {
measurementManager.registerSource(Uri.parse(url), null, ExecutorsKt.asExecutor(this.dispatchers.getDefault()), OutcomeReceiverKt$$ExternalSyntheticApiModelOutline0.m(new MeasurementsReceiver(this.eventSender, MeasurementsEvents.VIEW_SUCCESSFUL, MeasurementsEvents.VIEW_ERROR)));
}
}
public final void registerClick(String url, InputEvent inputEvent) {
Intrinsics.checkNotNullParameter(url, "url");
Intrinsics.checkNotNullParameter(inputEvent, "inputEvent");
MeasurementManager measurementManager = this.measurementManager;
if (measurementManager != null) {
measurementManager.registerSource(Uri.parse(url), inputEvent, ExecutorsKt.asExecutor(this.dispatchers.getDefault()), OutcomeReceiverKt$$ExternalSyntheticApiModelOutline0.m(new MeasurementsReceiver(this.eventSender, MeasurementsEvents.CLICK_SUCCESSFUL, MeasurementsEvents.CLICK_ERROR)));
}
}
private final MeasurementManager getMeasurementManager(Context context) {
int extensionVersion;
if (Device.getApiLevel() < 33) {
return null;
}
extensionVersion = SdkExtensions.getExtensionVersion(1000000);
if (extensionVersion < 4) {
return null;
}
return MeasurementManager$Api33Ext5Impl$$ExternalSyntheticApiModelOutline24.m(context.getSystemService(MeasurementManager$Api33Ext5Impl$$ExternalSyntheticApiModelOutline23.m()));
}
}

View File

@@ -0,0 +1,31 @@
package com.unity3d.services.ads.measurements;
import android.annotation.SuppressLint;
import android.os.OutcomeReceiver;
import com.unity3d.services.core.webview.WebViewEventCategory;
import com.unity3d.services.core.webview.bridge.IEventSender;
import kotlin.jvm.internal.Intrinsics;
@SuppressLint({"NewApi", "MissingPermission"})
/* loaded from: classes4.dex */
public final class MeasurementsStatusReceiver implements OutcomeReceiver {
private final IEventSender eventSender;
public MeasurementsStatusReceiver(IEventSender eventSender) {
Intrinsics.checkNotNullParameter(eventSender, "eventSender");
this.eventSender = eventSender;
}
public /* bridge */ /* synthetic */ void onResult(Object obj) {
onResult(((Number) obj).intValue());
}
public void onResult(int i) {
this.eventSender.sendEvent(WebViewEventCategory.MEASUREMENTS, MeasurementsEvents.AVAILABLE, Integer.valueOf(i));
}
public void onError(Exception error) {
Intrinsics.checkNotNullParameter(error, "error");
this.eventSender.sendEvent(WebViewEventCategory.MEASUREMENTS, MeasurementsEvents.NOT_AVAILABLE, MeasurementsErrors.ERROR_EXCEPTION, error.toString());
}
}

View File

@@ -0,0 +1,22 @@
package com.unity3d.services.ads.operation;
import com.unity3d.services.core.request.metrics.SDKMetricsSender;
import com.unity3d.services.core.webview.bridge.IWebViewSharedObject;
import com.unity3d.services.core.webview.bridge.WebViewBridgeSharedObjectStore;
import com.unity3d.services.core.webview.bridge.invocation.WebViewBridgeInvocationSingleThreadedExecutor;
import java.util.concurrent.ExecutorService;
/* loaded from: classes4.dex */
public abstract class AdModule<T extends IWebViewSharedObject, T2> extends WebViewBridgeSharedObjectStore<T> implements IAdModule<T, T2> {
protected ExecutorService _executorService = WebViewBridgeInvocationSingleThreadedExecutor.getInstance().getExecutorService();
protected SDKMetricsSender _sdkMetrics;
@Override // com.unity3d.services.ads.operation.IAdModule
public SDKMetricsSender getMetricSender() {
return this._sdkMetrics;
}
public AdModule(SDKMetricsSender sDKMetricsSender) {
this._sdkMetrics = sDKMetricsSender;
}
}

View File

@@ -0,0 +1,26 @@
package com.unity3d.services.ads.operation;
import com.unity3d.services.core.webview.bridge.invocation.IWebViewBridgeInvocation;
/* loaded from: classes4.dex */
public abstract class AdOperation implements IAdOperation {
private static String invocationClassName = "webview";
private String _invocationMethodName;
private IWebViewBridgeInvocation _webViewBridgeInvocation;
public AdOperation(IWebViewBridgeInvocation iWebViewBridgeInvocation, String str) throws NullPointerException {
this._invocationMethodName = str;
if (str == null || str.isEmpty()) {
throw new IllegalArgumentException("invocationMethodName cannot be null");
}
this._webViewBridgeInvocation = iWebViewBridgeInvocation;
if (iWebViewBridgeInvocation == null) {
throw new IllegalArgumentException("webViewBridgeInvocation cannot be null");
}
}
@Override // com.unity3d.services.ads.operation.IAdOperation
public void invoke(int i, Object... objArr) {
this._webViewBridgeInvocation.invoke(invocationClassName, this._invocationMethodName, i, objArr);
}
}

View File

@@ -0,0 +1,13 @@
package com.unity3d.services.ads.operation;
import com.unity3d.services.core.request.metrics.SDKMetricsSender;
import com.unity3d.services.core.webview.bridge.IWebViewBridgeInvoker;
import com.unity3d.services.core.webview.bridge.IWebViewBridgeSharedObjectStore;
import com.unity3d.services.core.webview.bridge.IWebViewSharedObject;
/* loaded from: classes4.dex */
public interface IAdModule<T extends IWebViewSharedObject, T2> extends IWebViewBridgeSharedObjectStore<T> {
void executeAdOperation(IWebViewBridgeInvoker iWebViewBridgeInvoker, T2 t2);
SDKMetricsSender getMetricSender();
}

View File

@@ -0,0 +1,8 @@
package com.unity3d.services.ads.operation;
import com.unity3d.services.core.webview.bridge.IWebViewSharedObject;
/* loaded from: classes4.dex */
public interface IAdOperation extends IWebViewSharedObject {
void invoke(int i, Object... objArr);
}

View File

@@ -0,0 +1,36 @@
package com.unity3d.services.ads.operation;
import com.unity3d.services.core.configuration.Configuration;
import com.unity3d.services.core.timer.BaseTimer;
import com.unity3d.services.core.webview.bridge.IWebViewSharedObject;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
/* loaded from: classes4.dex */
public class OperationState implements IWebViewSharedObject {
private static String _emptyPlacementId = "";
public Configuration configuration;
public String id;
public String placementId;
public long startTime;
public BaseTimer timeoutTimer;
@Override // com.unity3d.services.core.webview.bridge.IWebViewSharedObject
public String getId() {
return this.id;
}
public OperationState(String str, Configuration configuration) {
this.placementId = str == null ? _emptyPlacementId : str;
this.configuration = configuration;
this.id = UUID.randomUUID().toString();
}
public void start() {
this.startTime = System.nanoTime();
}
public long duration() {
return TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - this.startTime);
}
}

View File

@@ -0,0 +1,124 @@
package com.unity3d.services.ads.operation.load;
import android.text.TextUtils;
import com.facebook.gamingservices.cloudgaming.internal.SDKConstants;
import com.ironsource.v8;
import com.unity3d.ads.UnityAds;
import com.unity3d.services.ads.operation.AdModule;
import com.unity3d.services.core.device.Device;
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.bridge.CallbackStatus;
import com.unity3d.services.core.webview.bridge.IWebViewBridgeInvoker;
import com.unity3d.services.core.webview.bridge.invocation.IWebViewBridgeInvocationCallback;
import com.unity3d.services.core.webview.bridge.invocation.WebViewBridgeInvocation;
import org.json.JSONException;
import org.json.JSONObject;
/* loaded from: classes4.dex */
public abstract class BaseLoadModule extends AdModule<ILoadOperation, LoadOperationState> implements ILoadModule {
static final String errorMsgFailedToCreateLoadRequest = "[UnityAds] Failed to create load request";
static final String errorMsgInternalCommunicationFailure = "[UnityAds] Internal communication failure";
static final String errorMsgInternalCommunicationTimeout = "[UnityAds] Internal communication timeout";
static final String errorMsgPlacementIdNull = "[UnityAds] Placement ID cannot be null";
public abstract void addOptionalParameters(LoadOperationState loadOperationState, JSONObject jSONObject) throws JSONException;
public BaseLoadModule(SDKMetricsSender sDKMetricsSender) {
super(sDKMetricsSender);
}
@Override // com.unity3d.services.ads.operation.IAdModule
public void executeAdOperation(IWebViewBridgeInvoker iWebViewBridgeInvoker, final LoadOperationState loadOperationState) {
if (TextUtils.isEmpty(loadOperationState.placementId)) {
sendOnUnityAdsFailedToLoad(loadOperationState, UnityAds.UnityAdsLoadError.INVALID_ARGUMENT, "[UnityAds] Placement ID cannot be null", true);
return;
}
LoadOperation loadOperation = new LoadOperation(loadOperationState, new WebViewBridgeInvocation(this._executorService, iWebViewBridgeInvoker, new IWebViewBridgeInvocationCallback() { // from class: com.unity3d.services.ads.operation.load.BaseLoadModule.1
@Override // com.unity3d.services.core.webview.bridge.invocation.IWebViewBridgeInvocationCallback
public void onSuccess() {
}
@Override // com.unity3d.services.core.webview.bridge.invocation.IWebViewBridgeInvocationCallback
public void onFailure(String str, CallbackStatus callbackStatus) {
BaseLoadModule.this.getMetricSender().sendMetricWithInitState(AdOperationMetric.newAdLoadFailure(AdOperationError.callback_error, Long.valueOf(loadOperationState.duration()), loadOperationState.isBanner(), loadOperationState.isHeaderBidding()));
BaseLoadModule.this.sendOnUnityAdsFailedToLoad(loadOperationState, UnityAds.UnityAdsLoadError.INTERNAL_ERROR, "[UnityAds] Internal communication failure", false);
BaseLoadModule.this.remove(loadOperationState.getId());
}
@Override // com.unity3d.services.core.webview.bridge.invocation.IWebViewBridgeInvocationCallback
public void onTimeout() {
BaseLoadModule.this.getMetricSender().sendMetricWithInitState(AdOperationMetric.newAdLoadFailure(AdOperationError.callback_timeout, Long.valueOf(loadOperationState.duration()), loadOperationState.isBanner(), loadOperationState.isHeaderBidding()));
BaseLoadModule.this.sendOnUnityAdsFailedToLoad(loadOperationState, UnityAds.UnityAdsLoadError.INTERNAL_ERROR, "[UnityAds] Internal communication timeout", false);
BaseLoadModule.this.remove(loadOperationState.getId());
}
}));
try {
JSONObject buildBaseParameters = buildBaseParameters(loadOperationState, loadOperation);
set(loadOperation);
loadOperation.invoke(loadOperationState.configuration.getWebViewBridgeTimeout(), buildBaseParameters);
} catch (NullPointerException | JSONException unused) {
sendOnUnityAdsFailedToLoad(loadOperationState, UnityAds.UnityAdsLoadError.INTERNAL_ERROR, "[UnityAds] Failed to create load request", true);
}
}
public JSONObject buildBaseParameters(LoadOperationState loadOperationState, LoadOperation loadOperation) throws JSONException {
JSONObject jSONObject = new JSONObject();
JSONObject buildBaseOptions = buildBaseOptions(loadOperationState);
buildBaseOptions.put("headerBiddingOptions", loadOperationState.loadOptions.getData());
jSONObject.put(SDKConstants.PARAM_GAME_REQUESTS_OPTIONS, buildBaseOptions);
jSONObject.put("listenerId", loadOperation.getId());
jSONObject.put(v8.j, loadOperationState.placementId);
jSONObject.put("time", Device.getElapsedRealtime());
addOptionalParameters(loadOperationState, jSONObject);
return jSONObject;
}
public JSONObject buildBaseOptions(LoadOperationState loadOperationState) throws JSONException {
JSONObject jSONObject = new JSONObject();
jSONObject.put("headerBiddingOptions", loadOperationState.loadOptions.getData());
return jSONObject;
}
@Override // com.unity3d.services.ads.operation.load.ILoadModule
public void onUnityAdsAdLoaded(String str) {
ILoadOperation iLoadOperation = (ILoadOperation) get(str);
if (iLoadOperation == null || iLoadOperation.getLoadOperationState() == null) {
return;
}
LoadOperationState loadOperationState = iLoadOperation.getLoadOperationState();
getMetricSender().sendMetricWithInitState(AdOperationMetric.newAdLoadSuccess(Long.valueOf(loadOperationState.duration()), loadOperationState.isBanner(), loadOperationState.isHeaderBidding()));
iLoadOperation.onUnityAdsAdLoaded(loadOperationState.placementId);
remove(str);
}
@Override // com.unity3d.services.ads.operation.load.ILoadModule
public void onUnityAdsFailedToLoad(String str, UnityAds.UnityAdsLoadError unityAdsLoadError, String str2) {
ILoadOperation iLoadOperation = (ILoadOperation) get(str);
if (iLoadOperation == null || iLoadOperation.getLoadOperationState() == null) {
return;
}
LoadOperationState loadOperationState = iLoadOperation.getLoadOperationState();
getMetricSender().sendMetricWithInitState(AdOperationMetric.newAdLoadFailure(unityAdsLoadError, Long.valueOf(loadOperationState.duration()), loadOperationState.isBanner(), loadOperationState.isHeaderBidding()));
iLoadOperation.onUnityAdsFailedToLoad(loadOperationState.placementId, unityAdsLoadError, str2);
remove(str);
}
/* JADX INFO: Access modifiers changed from: private */
public void sendOnUnityAdsFailedToLoad(final LoadOperationState loadOperationState, final UnityAds.UnityAdsLoadError unityAdsLoadError, final String str, boolean z) {
if (loadOperationState == null || loadOperationState.listener == null) {
return;
}
if (z) {
getMetricSender().sendMetricWithInitState(AdOperationMetric.newAdLoadFailure(unityAdsLoadError, Long.valueOf(loadOperationState.duration()), loadOperationState.isBanner(), loadOperationState.isHeaderBidding()));
}
Utilities.runOnUiThread(new Runnable() { // from class: com.unity3d.services.ads.operation.load.BaseLoadModule.2
@Override // java.lang.Runnable
public void run() {
loadOperationState.onUnityAdsFailedToLoad(unityAdsLoadError, str);
}
});
}
}

View File

@@ -0,0 +1,11 @@
package com.unity3d.services.ads.operation.load;
import com.unity3d.ads.UnityAds;
import com.unity3d.services.ads.operation.IAdModule;
/* loaded from: classes4.dex */
public interface ILoadModule extends IAdModule<ILoadOperation, LoadOperationState> {
void onUnityAdsAdLoaded(String str);
void onUnityAdsFailedToLoad(String str, UnityAds.UnityAdsLoadError unityAdsLoadError, String str2);
}

View File

@@ -0,0 +1,9 @@
package com.unity3d.services.ads.operation.load;
import com.unity3d.ads.IUnityAdsLoadListener;
import com.unity3d.services.ads.operation.IAdOperation;
/* loaded from: classes4.dex */
public interface ILoadOperation extends IAdOperation, IUnityAdsLoadListener {
LoadOperationState getLoadOperationState();
}

View File

@@ -0,0 +1,33 @@
package com.unity3d.services.ads.operation.load;
import com.unity3d.services.core.configuration.ExperimentsReader;
import com.unity3d.services.core.configuration.InitializationNotificationCenter;
import com.unity3d.services.core.misc.Utilities;
import com.unity3d.services.core.request.metrics.SDKMetricsSender;
import org.json.JSONException;
import org.json.JSONObject;
/* loaded from: classes4.dex */
public class LoadBannerModule extends BaseLoadModule {
static ILoadModule _instance;
public static ILoadModule getInstance() {
if (_instance == null) {
_instance = new LoadModuleDecoratorTimeout(new LoadModuleDecoratorInitializationBuffer(new LoadBannerModule((SDKMetricsSender) Utilities.getService(SDKMetricsSender.class)), InitializationNotificationCenter.getInstance()), new ExperimentsReader());
}
return _instance;
}
public LoadBannerModule(SDKMetricsSender sDKMetricsSender) {
super(sDKMetricsSender);
}
@Override // com.unity3d.services.ads.operation.load.BaseLoadModule
public void addOptionalParameters(LoadOperationState loadOperationState, JSONObject jSONObject) throws JSONException {
if (loadOperationState instanceof LoadBannerOperationState) {
LoadBannerOperationState loadBannerOperationState = (LoadBannerOperationState) loadOperationState;
jSONObject.put("width", loadBannerOperationState.getSize().getWidth());
jSONObject.put("height", loadBannerOperationState.getSize().getHeight());
}
}
}

View File

@@ -0,0 +1,39 @@
package com.unity3d.services.ads.operation.load;
import com.unity3d.ads.IUnityAdsLoadListener;
import com.unity3d.ads.UnityAdsLoadOptions;
import com.unity3d.scar.adapter.common.scarads.ScarAdMetadata;
import com.unity3d.services.banners.UnityBannerSize;
import com.unity3d.services.core.configuration.Configuration;
/* loaded from: classes4.dex */
public class LoadBannerOperationState extends LoadOperationState {
private ScarAdMetadata _scarAdMetadata;
private UnityBannerSize _size;
public ScarAdMetadata getScarAdMetadata() {
return this._scarAdMetadata;
}
public UnityBannerSize getSize() {
return this._size;
}
public boolean isScarAd() {
return this._scarAdMetadata != null;
}
public void setScarAdMetadata(ScarAdMetadata scarAdMetadata) {
this._scarAdMetadata = scarAdMetadata;
}
public void setSize(UnityBannerSize unityBannerSize) {
this._size = unityBannerSize;
}
public LoadBannerOperationState(String str, String str2, UnityBannerSize unityBannerSize, IUnityAdsLoadListener iUnityAdsLoadListener, UnityAdsLoadOptions unityAdsLoadOptions, Configuration configuration) {
super(str, iUnityAdsLoadListener, unityAdsLoadOptions, configuration);
this.id = str2;
this._size = unityBannerSize;
}
}

View File

@@ -0,0 +1,27 @@
package com.unity3d.services.ads.operation.load;
import com.unity3d.services.core.configuration.ExperimentsReader;
import com.unity3d.services.core.configuration.InitializationNotificationCenter;
import com.unity3d.services.core.misc.Utilities;
import com.unity3d.services.core.request.metrics.SDKMetricsSender;
import org.json.JSONObject;
/* loaded from: classes4.dex */
public class LoadModule extends BaseLoadModule {
static ILoadModule _instance;
@Override // com.unity3d.services.ads.operation.load.BaseLoadModule
public void addOptionalParameters(LoadOperationState loadOperationState, JSONObject jSONObject) {
}
public static ILoadModule getInstance() {
if (_instance == null) {
_instance = new LoadModuleDecoratorTimeout(new LoadModuleDecoratorInitializationBuffer(new LoadModule((SDKMetricsSender) Utilities.getService(SDKMetricsSender.class)), InitializationNotificationCenter.getInstance()), new ExperimentsReader());
}
return _instance;
}
public LoadModule(SDKMetricsSender sDKMetricsSender) {
super(sDKMetricsSender);
}
}

View File

@@ -0,0 +1,49 @@
package com.unity3d.services.ads.operation.load;
import com.unity3d.ads.UnityAds;
import com.unity3d.services.core.request.metrics.SDKMetricsSender;
import com.unity3d.services.core.webview.bridge.IWebViewBridgeInvoker;
/* loaded from: classes4.dex */
public class LoadModuleDecorator implements ILoadModule {
private final ILoadModule _loadModule;
public LoadModuleDecorator(ILoadModule iLoadModule) {
this._loadModule = iLoadModule;
}
@Override // com.unity3d.services.ads.operation.IAdModule
public void executeAdOperation(IWebViewBridgeInvoker iWebViewBridgeInvoker, LoadOperationState loadOperationState) {
this._loadModule.executeAdOperation(iWebViewBridgeInvoker, loadOperationState);
}
@Override // com.unity3d.services.ads.operation.IAdModule
public SDKMetricsSender getMetricSender() {
return this._loadModule.getMetricSender();
}
@Override // com.unity3d.services.ads.operation.load.ILoadModule
public void onUnityAdsAdLoaded(String str) {
this._loadModule.onUnityAdsAdLoaded(str);
}
@Override // com.unity3d.services.ads.operation.load.ILoadModule
public void onUnityAdsFailedToLoad(String str, UnityAds.UnityAdsLoadError unityAdsLoadError, String str2) {
this._loadModule.onUnityAdsFailedToLoad(str, unityAdsLoadError, str2);
}
@Override // com.unity3d.services.core.webview.bridge.IWebViewBridgeSharedObjectStore
public ILoadOperation get(String str) {
return (ILoadOperation) this._loadModule.get(str);
}
@Override // com.unity3d.services.core.webview.bridge.IWebViewBridgeSharedObjectStore
public void set(ILoadOperation iLoadOperation) {
this._loadModule.set(iLoadOperation);
}
@Override // com.unity3d.services.core.webview.bridge.IWebViewBridgeSharedObjectStore
public void remove(String str) {
this._loadModule.remove(str);
}
}

View File

@@ -0,0 +1,99 @@
package com.unity3d.services.ads.operation.load;
import com.unity3d.ads.UnityAds;
import com.unity3d.services.core.configuration.ErrorState;
import com.unity3d.services.core.configuration.IInitializationListener;
import com.unity3d.services.core.configuration.IInitializationNotificationCenter;
import com.unity3d.services.core.misc.Utilities;
import com.unity3d.services.core.properties.SdkProperties;
import com.unity3d.services.core.request.metrics.AdOperationMetric;
import com.unity3d.services.core.webview.bridge.IWebViewBridgeInvoker;
import java.util.Iterator;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/* loaded from: classes4.dex */
public class LoadModuleDecoratorInitializationBuffer extends LoadModuleDecorator implements IInitializationListener {
private static final String errorMsgInitializationFailed = "[UnityAds] SDK Initialization Failed";
private static final String errorMsgInitializationFailure = "[UnityAds] SDK Initialization Failure";
private ConcurrentHashMap<LoadOperationState, IWebViewBridgeInvoker> _queuedLoadEvents;
public LoadModuleDecoratorInitializationBuffer(ILoadModule iLoadModule, IInitializationNotificationCenter iInitializationNotificationCenter) {
super(iLoadModule);
iInitializationNotificationCenter.addListener(this);
this._queuedLoadEvents = new ConcurrentHashMap<>();
}
/* renamed from: com.unity3d.services.ads.operation.load.LoadModuleDecoratorInitializationBuffer$2, reason: invalid class name */
public static /* synthetic */ class AnonymousClass2 {
static final /* synthetic */ int[] $SwitchMap$com$unity3d$services$core$properties$SdkProperties$InitializationState;
static {
int[] iArr = new int[SdkProperties.InitializationState.values().length];
$SwitchMap$com$unity3d$services$core$properties$SdkProperties$InitializationState = iArr;
try {
iArr[SdkProperties.InitializationState.INITIALIZED_SUCCESSFULLY.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
$SwitchMap$com$unity3d$services$core$properties$SdkProperties$InitializationState[SdkProperties.InitializationState.INITIALIZED_FAILED.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
}
}
/* JADX WARN: Can't rename method to resolve collision */
@Override // com.unity3d.services.ads.operation.load.LoadModuleDecorator, com.unity3d.services.ads.operation.IAdModule
public void executeAdOperation(IWebViewBridgeInvoker iWebViewBridgeInvoker, LoadOperationState loadOperationState) {
if (loadOperationState == null) {
return;
}
int i = AnonymousClass2.$SwitchMap$com$unity3d$services$core$properties$SdkProperties$InitializationState[SdkProperties.getCurrentInitializationState().ordinal()];
if (i == 1) {
super.executeAdOperation(iWebViewBridgeInvoker, loadOperationState);
} else if (i == 2) {
sendOnUnityAdsFailedToLoad(loadOperationState, UnityAds.UnityAdsLoadError.INITIALIZE_FAILED, "[UnityAds] SDK Initialization Failed");
} else {
this._queuedLoadEvents.put(loadOperationState, iWebViewBridgeInvoker);
}
}
@Override // com.unity3d.services.core.configuration.IInitializationListener
public synchronized void onSdkInitialized() {
try {
for (Map.Entry<LoadOperationState, IWebViewBridgeInvoker> entry : this._queuedLoadEvents.entrySet()) {
super.executeAdOperation(entry.getValue(), entry.getKey());
}
this._queuedLoadEvents.clear();
} catch (Throwable th) {
throw th;
}
}
@Override // com.unity3d.services.core.configuration.IInitializationListener
public synchronized void onSdkInitializationFailed(String str, ErrorState errorState, int i) {
try {
Iterator<LoadOperationState> it = this._queuedLoadEvents.keySet().iterator();
while (it.hasNext()) {
sendOnUnityAdsFailedToLoad(it.next(), UnityAds.UnityAdsLoadError.INITIALIZE_FAILED, "[UnityAds] SDK Initialization Failure");
}
this._queuedLoadEvents.clear();
} catch (Throwable th) {
throw th;
}
}
private void sendOnUnityAdsFailedToLoad(final LoadOperationState loadOperationState, final UnityAds.UnityAdsLoadError unityAdsLoadError, final String str) {
if (loadOperationState == null || loadOperationState.listener == null) {
return;
}
getMetricSender().sendMetricWithInitState(AdOperationMetric.newAdLoadFailure(unityAdsLoadError, Long.valueOf(loadOperationState.duration()), loadOperationState.isBanner(), loadOperationState.isHeaderBidding()));
Utilities.runOnUiThread(new Runnable() { // from class: com.unity3d.services.ads.operation.load.LoadModuleDecoratorInitializationBuffer.1
@Override // java.lang.Runnable
public void run() {
LoadOperationState loadOperationState2 = loadOperationState;
loadOperationState2.listener.onUnityAdsFailedToLoad(loadOperationState2.placementId, unityAdsLoadError, str);
}
});
}
}

View File

@@ -0,0 +1,88 @@
package com.unity3d.services.ads.operation.load;
import com.unity3d.ads.UnityAds;
import com.unity3d.services.core.configuration.ExperimentsReader;
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.timer.BaseTimer;
import com.unity3d.services.core.timer.ITimerListener;
import com.unity3d.services.core.webview.bridge.IWebViewBridgeInvoker;
import java.util.concurrent.Executors;
/* loaded from: classes4.dex */
public class LoadModuleDecoratorTimeout extends LoadModuleDecorator {
private static final String errorMsgTimeoutLoading = "[UnityAds] Timeout while loading ";
private final ExperimentsReader _experimentsReader;
public LoadModuleDecoratorTimeout(ILoadModule iLoadModule, ExperimentsReader experimentsReader) {
super(iLoadModule);
this._experimentsReader = experimentsReader;
}
/* JADX WARN: Can't rename method to resolve collision */
@Override // com.unity3d.services.ads.operation.load.LoadModuleDecorator, com.unity3d.services.ads.operation.IAdModule
public void executeAdOperation(IWebViewBridgeInvoker iWebViewBridgeInvoker, LoadOperationState loadOperationState) {
getMetricSender().sendMetricWithInitState(AdOperationMetric.newAdLoadStart(loadOperationState.isBanner(), loadOperationState.isHeaderBidding()));
loadOperationState.start();
if (!this._experimentsReader.getCurrentlyActiveExperiments().isNativeLoadTimeoutDisabled()) {
startLoadTimeout(loadOperationState);
}
super.executeAdOperation(iWebViewBridgeInvoker, loadOperationState);
}
private void startLoadTimeout(final LoadOperationState loadOperationState) {
if (loadOperationState == null) {
return;
}
BaseTimer baseTimer = new BaseTimer(Integer.valueOf(loadOperationState.configuration.getLoadTimeout()), new ITimerListener() { // from class: com.unity3d.services.ads.operation.load.LoadModuleDecoratorTimeout.1
@Override // com.unity3d.services.core.timer.ITimerListener
public void onTimerFinished() {
LoadModuleDecoratorTimeout.this.onOperationTimeout(loadOperationState);
}
});
loadOperationState.timeoutTimer = baseTimer;
baseTimer.start(Executors.newSingleThreadScheduledExecutor());
}
@Override // com.unity3d.services.ads.operation.load.LoadModuleDecorator, com.unity3d.services.ads.operation.load.ILoadModule
public void onUnityAdsAdLoaded(String str) {
releaseOperationTimeoutLock(str);
super.onUnityAdsAdLoaded(str);
}
@Override // com.unity3d.services.ads.operation.load.LoadModuleDecorator, com.unity3d.services.ads.operation.load.ILoadModule
public void onUnityAdsFailedToLoad(String str, UnityAds.UnityAdsLoadError unityAdsLoadError, String str2) {
releaseOperationTimeoutLock(str);
super.onUnityAdsFailedToLoad(str, unityAdsLoadError, str2);
}
private void releaseOperationTimeoutLock(String str) {
LoadOperationState loadOperationState;
BaseTimer baseTimer;
ILoadOperation iLoadOperation = get(str);
if (iLoadOperation == null || (loadOperationState = iLoadOperation.getLoadOperationState()) == null || (baseTimer = loadOperationState.timeoutTimer) == null) {
return;
}
baseTimer.kill();
}
/* JADX INFO: Access modifiers changed from: private */
public void onOperationTimeout(final LoadOperationState loadOperationState) {
if (loadOperationState != null) {
getMetricSender().sendMetricWithInitState(AdOperationMetric.newAdLoadFailure(AdOperationError.timeout, Long.valueOf(loadOperationState.duration()), loadOperationState.isBanner(), loadOperationState.isHeaderBidding()));
remove(loadOperationState.id);
Utilities.runOnUiThread(new Runnable() { // from class: com.unity3d.services.ads.operation.load.LoadModuleDecoratorTimeout$$ExternalSyntheticLambda0
@Override // java.lang.Runnable
public final void run() {
LoadModuleDecoratorTimeout.lambda$onOperationTimeout$0(LoadOperationState.this);
}
});
}
}
/* JADX INFO: Access modifiers changed from: private */
public static /* synthetic */ void lambda$onOperationTimeout$0(LoadOperationState loadOperationState) {
loadOperationState.onUnityAdsFailedToLoad(UnityAds.UnityAdsLoadError.TIMEOUT, "[UnityAds] Timeout while loading " + loadOperationState.placementId);
}
}

View File

@@ -0,0 +1,58 @@
package com.unity3d.services.ads.operation.load;
import com.unity3d.ads.UnityAds;
import com.unity3d.services.ads.operation.AdOperation;
import com.unity3d.services.core.misc.Utilities;
import com.unity3d.services.core.webview.bridge.invocation.IWebViewBridgeInvocation;
/* loaded from: classes4.dex */
public class LoadOperation extends AdOperation implements ILoadOperation {
private LoadOperationState _loadOperationState;
@Override // com.unity3d.services.ads.operation.load.ILoadOperation
public LoadOperationState getLoadOperationState() {
return this._loadOperationState;
}
public LoadOperation(LoadOperationState loadOperationState, IWebViewBridgeInvocation iWebViewBridgeInvocation) {
super(iWebViewBridgeInvocation, "load");
this._loadOperationState = loadOperationState;
}
@Override // com.unity3d.ads.IUnityAdsLoadListener
public void onUnityAdsAdLoaded(String str) {
LoadOperationState loadOperationState = this._loadOperationState;
if (loadOperationState == null || loadOperationState.listener == null || str == null) {
return;
}
Utilities.runOnUiThread(new Runnable() { // from class: com.unity3d.services.ads.operation.load.LoadOperation.1
@Override // java.lang.Runnable
public void run() {
if (LoadOperation.this._loadOperationState != null) {
LoadOperation.this._loadOperationState.onUnityAdsAdLoaded();
}
}
});
}
@Override // com.unity3d.ads.IUnityAdsLoadListener
public void onUnityAdsFailedToLoad(String str, final UnityAds.UnityAdsLoadError unityAdsLoadError, final String str2) {
LoadOperationState loadOperationState = this._loadOperationState;
if (loadOperationState == null || loadOperationState.listener == null || str == null) {
return;
}
Utilities.runOnUiThread(new Runnable() { // from class: com.unity3d.services.ads.operation.load.LoadOperation.2
@Override // java.lang.Runnable
public void run() {
if (LoadOperation.this._loadOperationState != null) {
LoadOperation.this._loadOperationState.onUnityAdsFailedToLoad(unityAdsLoadError, str2);
}
}
});
}
@Override // com.unity3d.services.core.webview.bridge.IWebViewSharedObject
public String getId() {
return this._loadOperationState.id;
}
}

View File

@@ -0,0 +1,64 @@
package com.unity3d.services.ads.operation.load;
import com.unity3d.ads.IUnityAdsLoadListener;
import com.unity3d.ads.UnityAds;
import com.unity3d.ads.UnityAdsLoadOptions;
import com.unity3d.services.ads.operation.OperationState;
import com.unity3d.services.core.configuration.Configuration;
import com.unity3d.services.core.misc.Utilities;
/* loaded from: classes4.dex */
public class LoadOperationState extends OperationState {
public IUnityAdsLoadListener listener;
public UnityAdsLoadOptions loadOptions;
public LoadOperationState(String str, IUnityAdsLoadListener iUnityAdsLoadListener, UnityAdsLoadOptions unityAdsLoadOptions, Configuration configuration) {
super(str, configuration);
this.listener = iUnityAdsLoadListener;
this.loadOptions = unityAdsLoadOptions;
}
public void onUnityAdsFailedToLoad(final UnityAds.UnityAdsLoadError unityAdsLoadError, final String str) {
if (this.listener != null) {
Utilities.wrapCustomerListener(new Runnable() { // from class: com.unity3d.services.ads.operation.load.LoadOperationState$$ExternalSyntheticLambda1
@Override // java.lang.Runnable
public final void run() {
LoadOperationState.this.lambda$onUnityAdsFailedToLoad$0(unityAdsLoadError, str);
}
});
}
}
/* JADX INFO: Access modifiers changed from: private */
public /* synthetic */ void lambda$onUnityAdsFailedToLoad$0(UnityAds.UnityAdsLoadError unityAdsLoadError, String str) {
this.listener.onUnityAdsFailedToLoad(this.placementId, unityAdsLoadError, str);
}
public void onUnityAdsAdLoaded() {
if (this.listener != null) {
Utilities.wrapCustomerListener(new Runnable() { // from class: com.unity3d.services.ads.operation.load.LoadOperationState$$ExternalSyntheticLambda0
@Override // java.lang.Runnable
public final void run() {
LoadOperationState.this.lambda$onUnityAdsAdLoaded$1();
}
});
}
}
/* JADX INFO: Access modifiers changed from: private */
public /* synthetic */ void lambda$onUnityAdsAdLoaded$1() {
this.listener.onUnityAdsAdLoaded(this.placementId);
}
public boolean isBanner() {
return this instanceof LoadBannerOperationState;
}
public boolean isHeaderBidding() {
UnityAdsLoadOptions unityAdsLoadOptions = this.loadOptions;
if (unityAdsLoadOptions == null || unityAdsLoadOptions.getData() == null) {
return false;
}
return this.loadOptions.getData().has("adMarkup");
}
}

Some files were not shown because too many files have changed in this diff Show More