- 28,932 files - Full Java source code - Smali files - Resources Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
174 lines
7.3 KiB
Java
174 lines
7.3 KiB
Java
package com.vungle.ads.internal.bidding;
|
|
|
|
import android.content.Context;
|
|
import androidx.annotation.VisibleForTesting;
|
|
import com.vungle.ads.AnalyticsClient;
|
|
import com.vungle.ads.ServiceLocator;
|
|
import com.vungle.ads.internal.ConfigManager;
|
|
import com.vungle.ads.internal.model.CommonRequestBody;
|
|
import com.vungle.ads.internal.model.RtbRequest;
|
|
import com.vungle.ads.internal.model.RtbToken;
|
|
import com.vungle.ads.internal.network.VungleApiClient;
|
|
import com.vungle.ads.internal.util.ActivityManager;
|
|
import com.vungle.ads.internal.util.InputOutputUtils;
|
|
import com.vungle.ads.internal.util.Logger;
|
|
import kotlin.Lazy;
|
|
import kotlin.LazyKt__LazyJVMKt;
|
|
import kotlin.LazyThreadSafetyMode;
|
|
import kotlin.Unit;
|
|
import kotlin.jvm.functions.Function0;
|
|
import kotlin.jvm.functions.Function1;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
import kotlin.jvm.internal.Intrinsics;
|
|
import kotlin.jvm.internal.Reflection;
|
|
import kotlinx.serialization.SerializationStrategy;
|
|
import kotlinx.serialization.SerializersKt;
|
|
import kotlinx.serialization.StringFormat;
|
|
import kotlinx.serialization.json.Json;
|
|
import kotlinx.serialization.json.JsonBuilder;
|
|
import kotlinx.serialization.json.JsonKt;
|
|
|
|
/* loaded from: classes4.dex */
|
|
public final class BidTokenEncoder {
|
|
public static final Companion Companion = new Companion(null);
|
|
public static final int TOKEN_VERSION = 6;
|
|
private final Context context;
|
|
private long enterBackgroundTime;
|
|
private final Json json;
|
|
private int ordinalView;
|
|
|
|
@VisibleForTesting(otherwise = 2)
|
|
public static /* synthetic */ void getEnterBackgroundTime$vungle_ads_release$annotations() {
|
|
}
|
|
|
|
private static /* synthetic */ void getJson$annotations() {
|
|
}
|
|
|
|
@VisibleForTesting(otherwise = 2)
|
|
public static /* synthetic */ void getOrdinalView$vungle_ads_release$annotations() {
|
|
}
|
|
|
|
public final long getEnterBackgroundTime$vungle_ads_release() {
|
|
return this.enterBackgroundTime;
|
|
}
|
|
|
|
public final int getOrdinalView$vungle_ads_release() {
|
|
return this.ordinalView;
|
|
}
|
|
|
|
public final void setEnterBackgroundTime$vungle_ads_release(long j) {
|
|
this.enterBackgroundTime = j;
|
|
}
|
|
|
|
public final void setOrdinalView$vungle_ads_release(int i) {
|
|
this.ordinalView = i;
|
|
}
|
|
|
|
public BidTokenEncoder(Context context) {
|
|
Intrinsics.checkNotNullParameter(context, "context");
|
|
this.context = context;
|
|
this.json = JsonKt.Json$default((Json) null, new Function1() { // from class: com.vungle.ads.internal.bidding.BidTokenEncoder$json$1
|
|
@Override // kotlin.jvm.functions.Function1
|
|
public /* bridge */ /* synthetic */ Object invoke(Object obj) {
|
|
invoke((JsonBuilder) obj);
|
|
return Unit.INSTANCE;
|
|
}
|
|
|
|
public final void invoke(JsonBuilder Json) {
|
|
Intrinsics.checkNotNullParameter(Json, "$this$Json");
|
|
Json.setIgnoreUnknownKeys(true);
|
|
Json.setEncodeDefaults(true);
|
|
Json.setExplicitNulls(false);
|
|
}
|
|
}, 1, (Object) null);
|
|
ActivityManager.Companion.addLifecycleListener(new ActivityManager.LifeCycleCallback() { // from class: com.vungle.ads.internal.bidding.BidTokenEncoder.1
|
|
@Override // com.vungle.ads.internal.util.ActivityManager.LifeCycleCallback
|
|
public void onResume() {
|
|
super.onResume();
|
|
BidTokenEncoder.this.onResume$vungle_ads_release();
|
|
}
|
|
|
|
@Override // com.vungle.ads.internal.util.ActivityManager.LifeCycleCallback
|
|
public void onPause() {
|
|
super.onPause();
|
|
BidTokenEncoder.this.onPause$vungle_ads_release();
|
|
}
|
|
});
|
|
}
|
|
|
|
public static final class Companion {
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
|
|
private Companion() {
|
|
}
|
|
}
|
|
|
|
@VisibleForTesting(otherwise = 2)
|
|
public final void onResume$vungle_ads_release() {
|
|
if (this.enterBackgroundTime == 0) {
|
|
Logger.Companion.d("BidTokenEncoder", "BidTokenEncoder#onResume skipped");
|
|
return;
|
|
}
|
|
if (System.currentTimeMillis() > this.enterBackgroundTime + ConfigManager.INSTANCE.getSessionTimeout()) {
|
|
this.ordinalView = 0;
|
|
this.enterBackgroundTime = 0L;
|
|
}
|
|
}
|
|
|
|
@VisibleForTesting(otherwise = 2)
|
|
public final void onPause$vungle_ads_release() {
|
|
this.enterBackgroundTime = System.currentTimeMillis();
|
|
}
|
|
|
|
public final String encode() {
|
|
this.ordinalView++;
|
|
return generateBidToken();
|
|
}
|
|
|
|
private final String generateBidToken() {
|
|
try {
|
|
String constructV6Token$vungle_ads_release = constructV6Token$vungle_ads_release();
|
|
Logger.Companion companion = Logger.Companion;
|
|
companion.d("BidTokenEncoder", "BidToken: " + constructV6Token$vungle_ads_release);
|
|
String convertForSending = InputOutputUtils.INSTANCE.convertForSending(constructV6Token$vungle_ads_release);
|
|
companion.d("BidTokenEncoder", "After conversion: 6:" + convertForSending);
|
|
return "6:" + convertForSending;
|
|
} catch (Exception e) {
|
|
AnalyticsClient.INSTANCE.logError$vungle_ads_release(116, "Fail to gzip bidtoken " + e.getLocalizedMessage(), (r13 & 4) != 0 ? null : null, (r13 & 8) != 0 ? null : null, (r13 & 16) != 0 ? null : null);
|
|
return null;
|
|
}
|
|
}
|
|
|
|
/* renamed from: constructV6Token$lambda-0, reason: not valid java name */
|
|
private static final VungleApiClient m3881constructV6Token$lambda0(Lazy lazy) {
|
|
return (VungleApiClient) lazy.getValue();
|
|
}
|
|
|
|
@VisibleForTesting
|
|
public final String constructV6Token$vungle_ads_release() {
|
|
Lazy lazy;
|
|
ServiceLocator.Companion companion = ServiceLocator.Companion;
|
|
final Context context = this.context;
|
|
lazy = LazyKt__LazyJVMKt.lazy(LazyThreadSafetyMode.SYNCHRONIZED, new Function0() { // from class: com.vungle.ads.internal.bidding.BidTokenEncoder$constructV6Token$$inlined$inject$1
|
|
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
|
|
{
|
|
super(0);
|
|
}
|
|
|
|
/* JADX WARN: Type inference failed for: r0v2, types: [com.vungle.ads.internal.network.VungleApiClient, java.lang.Object] */
|
|
@Override // kotlin.jvm.functions.Function0
|
|
public final VungleApiClient invoke() {
|
|
return ServiceLocator.Companion.getInstance(context).getService(VungleApiClient.class);
|
|
}
|
|
});
|
|
CommonRequestBody requestBody = m3881constructV6Token$lambda0(lazy).requestBody(!r1.signalsDisabled(), ConfigManager.INSTANCE.fpdEnabled());
|
|
RtbToken rtbToken = new RtbToken(requestBody.getDevice(), requestBody.getUser(), requestBody.getExt(), new RtbRequest(VungleApiClient.Companion.getHeaderUa()), this.ordinalView);
|
|
StringFormat stringFormat = this.json;
|
|
SerializationStrategy serializer = SerializersKt.serializer(stringFormat.getSerializersModule(), Reflection.typeOf(RtbToken.class));
|
|
Intrinsics.checkNotNull(serializer, "null cannot be cast to non-null type kotlinx.serialization.KSerializer<T of kotlinx.serialization.internal.Platform_commonKt.cast>");
|
|
return stringFormat.encodeToString(serializer, rtbToken);
|
|
}
|
|
}
|