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,14 @@
package com.vungle.ads.internal.network;
import java.io.IOException;
/* loaded from: classes4.dex */
public interface Call<T> {
void cancel();
void enqueue(Callback<T> callback);
Response<T> execute() throws IOException;
boolean isCanceled();
}

View File

@@ -0,0 +1,8 @@
package com.vungle.ads.internal.network;
/* loaded from: classes4.dex */
public interface Callback<T> {
void onFailure(Call<T> call, Throwable th);
void onResponse(Call<T> call, Response<T> response);
}

View File

@@ -0,0 +1,262 @@
package com.vungle.ads.internal.network;
import com.vungle.ads.internal.network.converters.Converter;
import com.vungle.ads.internal.util.Logger;
import java.io.IOException;
import java.util.Objects;
import kotlin.Unit;
import kotlin.io.CloseableKt;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
import okhttp3.MediaType;
import okhttp3.ResponseBody;
import okio.Buffer;
import okio.BufferedSource;
import okio.ForwardingSource;
import okio.Okio;
/* loaded from: classes4.dex */
public final class OkHttpCall<T> implements Call<T> {
public static final Companion Companion = new Companion(null);
private static final String TAG = "OkHttpCall";
private volatile boolean canceled;
private final okhttp3.Call rawCall;
private final Converter<ResponseBody, T> responseConverter;
public OkHttpCall(okhttp3.Call rawCall, Converter<ResponseBody, T> responseConverter) {
Intrinsics.checkNotNullParameter(rawCall, "rawCall");
Intrinsics.checkNotNullParameter(responseConverter, "responseConverter");
this.rawCall = rawCall;
this.responseConverter = responseConverter;
}
@Override // com.vungle.ads.internal.network.Call
public void enqueue(final Callback<T> callback) {
okhttp3.Call call;
Intrinsics.checkNotNullParameter(callback, "callback");
Objects.requireNonNull(callback, "callback == null");
synchronized (this) {
call = this.rawCall;
Unit unit = Unit.INSTANCE;
}
if (this.canceled) {
call.cancel();
}
call.enqueue(new okhttp3.Callback(this) { // from class: com.vungle.ads.internal.network.OkHttpCall$enqueue$2
final /* synthetic */ OkHttpCall<T> this$0;
{
this.this$0 = this;
}
@Override // okhttp3.Callback
public void onResponse(okhttp3.Call call2, okhttp3.Response response) {
Intrinsics.checkNotNullParameter(call2, "call");
Intrinsics.checkNotNullParameter(response, "response");
try {
try {
callback.onResponse(this.this$0, this.this$0.parseResponse(response));
} catch (Throwable th) {
OkHttpCall.Companion.throwIfFatal(th);
Logger.Companion.e("OkHttpCall", "Cannot pass response to callback", th);
}
} catch (Throwable th2) {
OkHttpCall.Companion.throwIfFatal(th2);
callFailure(th2);
}
}
@Override // okhttp3.Callback
public void onFailure(okhttp3.Call call2, IOException e) {
Intrinsics.checkNotNullParameter(call2, "call");
Intrinsics.checkNotNullParameter(e, "e");
callFailure(e);
}
private final void callFailure(Throwable th) {
try {
callback.onFailure(this.this$0, th);
} catch (Throwable th2) {
OkHttpCall.Companion.throwIfFatal(th2);
Logger.Companion.e("OkHttpCall", "Cannot pass failure to callback", th2);
}
}
});
}
@Override // com.vungle.ads.internal.network.Call
public Response<T> execute() throws IOException {
okhttp3.Call call;
synchronized (this) {
call = this.rawCall;
Unit unit = Unit.INSTANCE;
}
if (this.canceled) {
call.cancel();
}
return parseResponse(call.execute());
}
public final Response<T> parseResponse(okhttp3.Response rawResp) throws IOException {
Intrinsics.checkNotNullParameter(rawResp, "rawResp");
ResponseBody body = rawResp.body();
if (body == null) {
return null;
}
okhttp3.Response build = rawResp.newBuilder().body(new NoContentResponseBody(body.contentType(), body.contentLength())).build();
int code = build.code();
if (code >= 200 && code < 300) {
if (code == 204 || code == 205) {
body.close();
return Response.Companion.success(null, build);
}
ExceptionCatchingResponseBody exceptionCatchingResponseBody = new ExceptionCatchingResponseBody(body);
try {
return Response.Companion.success(this.responseConverter.convert(exceptionCatchingResponseBody), build);
} catch (RuntimeException e) {
exceptionCatchingResponseBody.throwIfCaught();
throw e;
}
}
try {
Response<T> error = Response.Companion.error(buffer(body), build);
CloseableKt.closeFinally(body, null);
return error;
} finally {
}
}
private final ResponseBody buffer(ResponseBody responseBody) throws IOException {
Buffer buffer = new Buffer();
responseBody.source().readAll(buffer);
return ResponseBody.Companion.create(buffer, responseBody.contentType(), responseBody.contentLength());
}
@Override // com.vungle.ads.internal.network.Call
public void cancel() {
okhttp3.Call call;
this.canceled = true;
synchronized (this) {
call = this.rawCall;
Unit unit = Unit.INSTANCE;
}
call.cancel();
}
@Override // com.vungle.ads.internal.network.Call
public boolean isCanceled() {
boolean isCanceled;
if (this.canceled) {
return true;
}
synchronized (this) {
isCanceled = this.rawCall.isCanceled();
}
return isCanceled;
}
public static final class NoContentResponseBody extends ResponseBody {
private final long contentLength;
private final MediaType contentType;
@Override // okhttp3.ResponseBody
public long contentLength() {
return this.contentLength;
}
@Override // okhttp3.ResponseBody
public MediaType contentType() {
return this.contentType;
}
public NoContentResponseBody(MediaType mediaType, long j) {
this.contentType = mediaType;
this.contentLength = j;
}
@Override // okhttp3.ResponseBody
public BufferedSource source() {
throw new IllegalStateException("Cannot read raw response body of a converted body.");
}
}
public static final class ExceptionCatchingResponseBody extends ResponseBody {
private final ResponseBody delegate;
private final BufferedSource delegateSource;
private IOException thrownException;
public final IOException getThrownException() {
return this.thrownException;
}
public final void setThrownException(IOException iOException) {
this.thrownException = iOException;
}
@Override // okhttp3.ResponseBody
public BufferedSource source() {
return this.delegateSource;
}
public ExceptionCatchingResponseBody(ResponseBody delegate) {
Intrinsics.checkNotNullParameter(delegate, "delegate");
this.delegate = delegate;
this.delegateSource = Okio.buffer(new ForwardingSource(delegate.source()) { // from class: com.vungle.ads.internal.network.OkHttpCall.ExceptionCatchingResponseBody.1
@Override // okio.ForwardingSource, okio.Source
public long read(Buffer sink, long j) throws IOException {
Intrinsics.checkNotNullParameter(sink, "sink");
try {
return super.read(sink, j);
} catch (IOException e) {
ExceptionCatchingResponseBody.this.setThrownException(e);
throw e;
}
}
});
}
@Override // okhttp3.ResponseBody
public MediaType contentType() {
return this.delegate.contentType();
}
@Override // okhttp3.ResponseBody
public long contentLength() {
return this.delegate.contentLength();
}
@Override // okhttp3.ResponseBody, java.io.Closeable, java.lang.AutoCloseable
public void close() {
this.delegate.close();
}
public final void throwIfCaught() throws IOException {
IOException iOException = this.thrownException;
if (iOException != null) {
throw iOException;
}
}
}
public static final class Companion {
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
private Companion() {
}
/* JADX INFO: Access modifiers changed from: private */
public final void throwIfFatal(Throwable th) {
if (th instanceof VirtualMachineError) {
throw th;
}
if (th instanceof ThreadDeath) {
throw th;
}
if (th instanceof LinkageError) {
throw th;
}
}
}
}

View File

@@ -0,0 +1,83 @@
package com.vungle.ads.internal.network;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
import okhttp3.Headers;
import okhttp3.ResponseBody;
/* loaded from: classes4.dex */
public final class Response<T> {
public static final Companion Companion = new Companion(null);
private final T body;
private final ResponseBody errorBody;
private final okhttp3.Response rawResponse;
public /* synthetic */ Response(okhttp3.Response response, Object obj, ResponseBody responseBody, DefaultConstructorMarker defaultConstructorMarker) {
this(response, obj, responseBody);
}
public final T body() {
return this.body;
}
public final ResponseBody errorBody() {
return this.errorBody;
}
public final okhttp3.Response raw() {
return this.rawResponse;
}
private Response(okhttp3.Response response, T t, ResponseBody responseBody) {
this.rawResponse = response;
this.body = t;
this.errorBody = responseBody;
}
public final int code() {
return this.rawResponse.code();
}
public final String message() {
return this.rawResponse.message();
}
public final Headers headers() {
return this.rawResponse.headers();
}
public final boolean isSuccessful() {
return this.rawResponse.isSuccessful();
}
public String toString() {
return this.rawResponse.toString();
}
public static final class Companion {
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
private Companion() {
}
/* JADX WARN: Multi-variable type inference failed */
public final <T> Response<T> success(T t, okhttp3.Response rawResponse) {
Intrinsics.checkNotNullParameter(rawResponse, "rawResponse");
if (!rawResponse.isSuccessful()) {
throw new IllegalArgumentException("rawResponse must be successful response".toString());
}
return new Response<>(rawResponse, t, null, 0 == true ? 1 : 0);
}
public final <T> Response<T> error(ResponseBody responseBody, okhttp3.Response rawResponse) {
Intrinsics.checkNotNullParameter(rawResponse, "rawResponse");
if (!(!rawResponse.isSuccessful())) {
throw new IllegalArgumentException("rawResponse should not be successful response".toString());
}
DefaultConstructorMarker defaultConstructorMarker = null;
return new Response<>(rawResponse, defaultConstructorMarker, responseBody, defaultConstructorMarker);
}
}
}

View File

@@ -0,0 +1,229 @@
package com.vungle.ads.internal.network;
import androidx.annotation.VisibleForTesting;
import com.vungle.ads.AnalyticsClient;
import com.vungle.ads.TpatRetryFailure;
import com.vungle.ads.internal.Constants;
import com.vungle.ads.internal.load.BaseAdLoader;
import com.vungle.ads.internal.persistence.FilePreferences;
import com.vungle.ads.internal.protos.Sdk;
import com.vungle.ads.internal.signals.SignalManager;
import com.vungle.ads.internal.util.Logger;
import com.vungle.ads.internal.util.PathProvider;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.concurrent.Executor;
import java.util.regex.Pattern;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.Reflection;
import kotlin.reflect.KTypeProjection;
import kotlin.text.Regex;
import kotlinx.serialization.DeserializationStrategy;
import kotlinx.serialization.SerializationStrategy;
import kotlinx.serialization.SerializersKt;
import kotlinx.serialization.StringFormat;
import kotlinx.serialization.json.Json;
import kotlinx.serialization.modules.SerializersModule;
/* loaded from: classes4.dex */
public final class TpatSender {
public static final Companion Companion = new Companion(null);
private static final String FAILED_TPATS = "FAILED_TPATS";
private static final int MAX_RETRIES = 5;
private static final String TAG = "TpatSender";
private final String creativeId;
private final String eventId;
private final String placementId;
private final SignalManager signalManager;
private final FilePreferences tpatFilePreferences;
private final VungleApiClient vungleApiClient;
public final String getCreativeId() {
return this.creativeId;
}
public final String getEventId() {
return this.eventId;
}
public final String getPlacementId() {
return this.placementId;
}
public final SignalManager getSignalManager() {
return this.signalManager;
}
public final VungleApiClient getVungleApiClient() {
return this.vungleApiClient;
}
public TpatSender(VungleApiClient vungleApiClient, String str, String str2, String str3, Executor ioExecutor, PathProvider pathProvider, SignalManager signalManager) {
Intrinsics.checkNotNullParameter(vungleApiClient, "vungleApiClient");
Intrinsics.checkNotNullParameter(ioExecutor, "ioExecutor");
Intrinsics.checkNotNullParameter(pathProvider, "pathProvider");
this.vungleApiClient = vungleApiClient;
this.placementId = str;
this.creativeId = str2;
this.eventId = str3;
this.signalManager = signalManager;
this.tpatFilePreferences = FilePreferences.Companion.get(ioExecutor, pathProvider, FilePreferences.TPAT_FAILED_FILENAME);
}
public /* synthetic */ TpatSender(VungleApiClient vungleApiClient, String str, String str2, String str3, Executor executor, PathProvider pathProvider, SignalManager signalManager, int i, DefaultConstructorMarker defaultConstructorMarker) {
this(vungleApiClient, str, str2, str3, executor, pathProvider, (i & 64) != 0 ? null : signalManager);
}
public static final class Companion {
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
private Companion() {
}
}
public final void sendWinNotification(String urlString, Executor executor) {
Intrinsics.checkNotNullParameter(urlString, "urlString");
Intrinsics.checkNotNullParameter(executor, "executor");
final String injectSessionIdToUrl = injectSessionIdToUrl(urlString);
executor.execute(new Runnable() { // from class: com.vungle.ads.internal.network.TpatSender$$ExternalSyntheticLambda1
@Override // java.lang.Runnable
public final void run() {
TpatSender.m3942sendWinNotification$lambda0(TpatSender.this, injectSessionIdToUrl);
}
});
}
/* JADX INFO: Access modifiers changed from: private */
/* renamed from: sendWinNotification$lambda-0, reason: not valid java name */
public static final void m3942sendWinNotification$lambda0(TpatSender this$0, String url) {
Intrinsics.checkNotNullParameter(this$0, "this$0");
Intrinsics.checkNotNullParameter(url, "$url");
BaseAdLoader.ErrorInfo pingTPAT = this$0.vungleApiClient.pingTPAT(url);
if (pingTPAT != null) {
AnalyticsClient.INSTANCE.logError$vungle_ads_release(Sdk.SDKError.Reason.AD_WIN_NOTIFICATION_ERROR, "Fail to send " + url + ", error: " + pingTPAT.getDescription(), this$0.placementId, this$0.creativeId, this$0.eventId);
}
}
public final void sendTpat(final String url, Executor executor) {
Intrinsics.checkNotNullParameter(url, "url");
Intrinsics.checkNotNullParameter(executor, "executor");
final String injectSessionIdToUrl = injectSessionIdToUrl(url);
executor.execute(new Runnable() { // from class: com.vungle.ads.internal.network.TpatSender$$ExternalSyntheticLambda0
@Override // java.lang.Runnable
public final void run() {
TpatSender.m3941sendTpat$lambda2(TpatSender.this, url, injectSessionIdToUrl);
}
});
}
/* JADX INFO: Access modifiers changed from: private */
/* renamed from: sendTpat$lambda-2, reason: not valid java name */
public static final void m3941sendTpat$lambda2(TpatSender this$0, String url, String urlWithSessionId) {
Intrinsics.checkNotNullParameter(this$0, "this$0");
Intrinsics.checkNotNullParameter(url, "$url");
Intrinsics.checkNotNullParameter(urlWithSessionId, "$urlWithSessionId");
HashMap<String, Integer> storedTpats = this$0.getStoredTpats();
Integer num = storedTpats.get(url);
if (num == null) {
num = 0;
}
int intValue = num.intValue();
BaseAdLoader.ErrorInfo pingTPAT = this$0.vungleApiClient.pingTPAT(urlWithSessionId);
if (pingTPAT == null) {
if (intValue != 0) {
storedTpats.remove(url);
this$0.saveStoredTpats(storedTpats);
return;
}
return;
}
if (!pingTPAT.getErrorIsTerminal()) {
if (intValue >= 5) {
storedTpats.remove(url);
this$0.saveStoredTpats(storedTpats);
new TpatRetryFailure(urlWithSessionId).logErrorNoReturnValue$vungle_ads_release();
} else {
storedTpats.put(url, Integer.valueOf(intValue + 1));
this$0.saveStoredTpats(storedTpats);
}
}
Logger.Companion.e(TAG, "TPAT failed with " + pingTPAT.getDescription() + ", url:" + urlWithSessionId);
if (pingTPAT.getReason() != 29) {
AnalyticsClient.INSTANCE.logError$vungle_ads_release(Sdk.SDKError.Reason.TPAT_ERROR, "Fail to send " + urlWithSessionId + ", error: " + pingTPAT.getDescription(), this$0.placementId, this$0.creativeId, this$0.eventId);
return;
}
AnalyticsClient.INSTANCE.logMetric$vungle_ads_release(Sdk.SDKMetric.SDKMetricType.NOTIFICATION_REDIRECT, (r15 & 2) != 0 ? 0L : 0L, (r15 & 4) != 0 ? null : this$0.placementId, (r15 & 8) != 0 ? null : null, (r15 & 16) != 0 ? null : null, (r15 & 32) == 0 ? urlWithSessionId : null);
}
private final HashMap<String, Integer> getStoredTpats() {
HashMap<String, Integer> hashMap;
String string = this.tpatFilePreferences.getString(FAILED_TPATS);
try {
if (string != null) {
StringFormat stringFormat = Json.Default;
SerializersModule serializersModule = stringFormat.getSerializersModule();
KTypeProjection.Companion companion = KTypeProjection.Companion;
DeserializationStrategy serializer = SerializersKt.serializer(serializersModule, Reflection.typeOf(HashMap.class, companion.invariant(Reflection.typeOf(String.class)), companion.invariant(Reflection.typeOf(Integer.TYPE))));
Intrinsics.checkNotNull(serializer, "null cannot be cast to non-null type kotlinx.serialization.KSerializer<T of kotlinx.serialization.internal.Platform_commonKt.cast>");
hashMap = (HashMap) stringFormat.decodeFromString(serializer, string);
} else {
hashMap = new HashMap<>();
}
return hashMap;
} catch (Exception unused) {
Logger.Companion.e(TAG, "Failed to decode stored tpats: " + string);
return new HashMap<>();
}
}
private final void saveStoredTpats(HashMap<String, Integer> hashMap) {
try {
FilePreferences filePreferences = this.tpatFilePreferences;
StringFormat stringFormat = Json.Default;
SerializersModule serializersModule = stringFormat.getSerializersModule();
KTypeProjection.Companion companion = KTypeProjection.Companion;
SerializationStrategy serializer = SerializersKt.serializer(serializersModule, Reflection.typeOf(HashMap.class, companion.invariant(Reflection.typeOf(String.class)), companion.invariant(Reflection.typeOf(Integer.TYPE))));
Intrinsics.checkNotNull(serializer, "null cannot be cast to non-null type kotlinx.serialization.KSerializer<T of kotlinx.serialization.internal.Platform_commonKt.cast>");
filePreferences.put(FAILED_TPATS, stringFormat.encodeToString(serializer, hashMap)).apply();
} catch (Exception unused) {
Logger.Companion.e(TAG, "Failed to encode the about to storing tpats: " + hashMap);
}
}
public final void resendStoredTpats$vungle_ads_release(Executor executor) {
Intrinsics.checkNotNullParameter(executor, "executor");
Iterator<Map.Entry<String, Integer>> it = getStoredTpats().entrySet().iterator();
while (it.hasNext()) {
sendTpat(it.next().getKey(), executor);
}
}
@VisibleForTesting
public final String injectSessionIdToUrl(String url) {
String str;
Intrinsics.checkNotNullParameter(url, "url");
SignalManager signalManager = this.signalManager;
if (signalManager == null || (str = signalManager.getUuid()) == null) {
str = "";
}
if (str.length() <= 0) {
return url;
}
String quote = Pattern.quote(Constants.SESSION_ID);
Intrinsics.checkNotNullExpressionValue(quote, "quote(Constants.SESSION_ID)");
return new Regex(quote).replace(url, str);
}
public final void sendTpats(Iterable<String> urls, Executor executor) {
Intrinsics.checkNotNullParameter(urls, "urls");
Intrinsics.checkNotNullParameter(executor, "executor");
Iterator<String> it = urls.iterator();
while (it.hasNext()) {
sendTpat(it.next(), executor);
}
}
}

View File

@@ -0,0 +1,27 @@
package com.vungle.ads.internal.network;
import androidx.annotation.Keep;
import com.vungle.ads.internal.model.AdPayload;
import com.vungle.ads.internal.model.CommonRequestBody;
import com.vungle.ads.internal.model.ConfigPayload;
import okhttp3.RequestBody;
@Keep
/* loaded from: classes4.dex */
public interface VungleApi {
Call<AdPayload> ads(String str, String str2, CommonRequestBody commonRequestBody);
Call<ConfigPayload> config(String str, String str2, CommonRequestBody commonRequestBody);
Call<Void> pingTPAT(String str, String str2);
Call<Void> ri(String str, String str2, CommonRequestBody commonRequestBody);
Call<Void> sendAdMarkup(String str, RequestBody requestBody);
Call<Void> sendErrors(String str, String str2, RequestBody requestBody);
Call<Void> sendMetrics(String str, String str2, RequestBody requestBody);
void setAppId(String str);
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,194 @@
package com.vungle.ads.internal.network;
import androidx.annotation.VisibleForTesting;
import com.ironsource.nb;
import com.vungle.ads.AnalyticsClient;
import com.vungle.ads.internal.model.AdPayload;
import com.vungle.ads.internal.model.CommonRequestBody;
import com.vungle.ads.internal.model.ConfigPayload;
import com.vungle.ads.internal.network.converters.EmptyResponseConverter;
import com.vungle.ads.internal.network.converters.JsonConverter;
import java.util.List;
import kotlin.Unit;
import kotlin.collections.CollectionsKt___CollectionsKt;
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;
import okhttp3.Call;
import okhttp3.HttpUrl;
import okhttp3.MediaType;
import okhttp3.Request;
import okhttp3.RequestBody;
/* loaded from: classes4.dex */
public final class VungleApiImpl implements VungleApi {
private static final String VUNGLE_VERSION = "7.1.0";
private String appId;
private final EmptyResponseConverter emptyResponseConverter;
private final Call.Factory okHttpClient;
public static final Companion Companion = new Companion(null);
private static final Json json = JsonKt.Json$default((Json) null, new Function1() { // from class: com.vungle.ads.internal.network.VungleApiImpl$Companion$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);
Json.setAllowStructuredMapKeys(true);
}
}, 1, (Object) null);
@VisibleForTesting
public final Call.Factory getOkHttpClient$vungle_ads_release() {
return this.okHttpClient;
}
@Override // com.vungle.ads.internal.network.VungleApi
public void setAppId(String appId) {
Intrinsics.checkNotNullParameter(appId, "appId");
this.appId = appId;
}
public VungleApiImpl(Call.Factory okHttpClient) {
Intrinsics.checkNotNullParameter(okHttpClient, "okHttpClient");
this.okHttpClient = okHttpClient;
this.emptyResponseConverter = new EmptyResponseConverter();
}
public static final class Companion {
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
private Companion() {
}
}
public static /* synthetic */ Request.Builder defaultBuilder$default(VungleApiImpl vungleApiImpl, String str, String str2, String str3, int i, Object obj) {
if ((i & 4) != 0) {
str3 = null;
}
return vungleApiImpl.defaultBuilder(str, str2, str3);
}
private final Request.Builder defaultBuilder(String str, String str2, String str3) {
Request.Builder addHeader = new Request.Builder().url(str2).addHeader("User-Agent", str).addHeader("Vungle-Version", VUNGLE_VERSION).addHeader("Content-Type", nb.L);
String str4 = this.appId;
if (str4 != null) {
addHeader.addHeader("X-Vungle-App-Id", str4);
}
if (str3 != null) {
addHeader.addHeader("X-Vungle-Placement-Ref-Id", str3);
}
return addHeader;
}
private final Request.Builder defaultProtoBufBuilder(String str, String str2) {
Request.Builder addHeader = new Request.Builder().url(str2).addHeader("User-Agent", str).addHeader("Vungle-Version", VUNGLE_VERSION).addHeader("Content-Type", "application/x-protobuf");
String str3 = this.appId;
if (str3 != null) {
addHeader.addHeader("X-Vungle-App-Id", str3);
}
return addHeader;
}
@Override // com.vungle.ads.internal.network.VungleApi
public Call<ConfigPayload> config(String ua, String path, CommonRequestBody body) {
Intrinsics.checkNotNullParameter(ua, "ua");
Intrinsics.checkNotNullParameter(path, "path");
Intrinsics.checkNotNullParameter(body, "body");
try {
StringFormat stringFormat = json;
SerializationStrategy serializer = SerializersKt.serializer(stringFormat.getSerializersModule(), Reflection.typeOf(CommonRequestBody.class));
Intrinsics.checkNotNull(serializer, "null cannot be cast to non-null type kotlinx.serialization.KSerializer<T of kotlinx.serialization.internal.Platform_commonKt.cast>");
return new OkHttpCall(this.okHttpClient.newCall(defaultBuilder$default(this, ua, path, null, 4, null).post(RequestBody.Companion.create(stringFormat.encodeToString(serializer, body), (MediaType) null)).build()), new JsonConverter(Reflection.typeOf(ConfigPayload.class)));
} catch (Exception unused) {
return null;
}
}
@Override // com.vungle.ads.internal.network.VungleApi
public Call<AdPayload> ads(String ua, String path, CommonRequestBody body) {
String str;
List<String> placements;
Object firstOrNull;
Intrinsics.checkNotNullParameter(ua, "ua");
Intrinsics.checkNotNullParameter(path, "path");
Intrinsics.checkNotNullParameter(body, "body");
try {
StringFormat stringFormat = json;
SerializationStrategy serializer = SerializersKt.serializer(stringFormat.getSerializersModule(), Reflection.typeOf(CommonRequestBody.class));
Intrinsics.checkNotNull(serializer, "null cannot be cast to non-null type kotlinx.serialization.KSerializer<T of kotlinx.serialization.internal.Platform_commonKt.cast>");
String encodeToString = stringFormat.encodeToString(serializer, body);
CommonRequestBody.RequestParam request = body.getRequest();
if (request == null || (placements = request.getPlacements()) == null) {
str = null;
} else {
firstOrNull = CollectionsKt___CollectionsKt.firstOrNull((List) placements);
str = (String) firstOrNull;
}
return new OkHttpCall(this.okHttpClient.newCall(defaultBuilder(ua, path, str).post(RequestBody.Companion.create(encodeToString, (MediaType) null)).build()), new JsonConverter(Reflection.typeOf(AdPayload.class)));
} catch (Exception unused) {
AnalyticsClient.INSTANCE.logError$vungle_ads_release(101, "Error with url: " + path, (r13 & 4) != 0 ? null : null, (r13 & 8) != 0 ? null : null, (r13 & 16) != 0 ? null : null);
return null;
}
}
@Override // com.vungle.ads.internal.network.VungleApi
public Call<Void> ri(String ua, String path, CommonRequestBody body) {
Intrinsics.checkNotNullParameter(ua, "ua");
Intrinsics.checkNotNullParameter(path, "path");
Intrinsics.checkNotNullParameter(body, "body");
try {
StringFormat stringFormat = json;
SerializationStrategy serializer = SerializersKt.serializer(stringFormat.getSerializersModule(), Reflection.typeOf(CommonRequestBody.class));
Intrinsics.checkNotNull(serializer, "null cannot be cast to non-null type kotlinx.serialization.KSerializer<T of kotlinx.serialization.internal.Platform_commonKt.cast>");
return new OkHttpCall(this.okHttpClient.newCall(defaultBuilder$default(this, ua, path, null, 4, null).post(RequestBody.Companion.create(stringFormat.encodeToString(serializer, body), (MediaType) null)).build()), this.emptyResponseConverter);
} catch (Exception unused) {
AnalyticsClient.INSTANCE.logError$vungle_ads_release(101, "Error with url: " + path, (r13 & 4) != 0 ? null : null, (r13 & 8) != 0 ? null : null, (r13 & 16) != 0 ? null : null);
return null;
}
}
@Override // com.vungle.ads.internal.network.VungleApi
public Call<Void> pingTPAT(String ua, String url) {
Intrinsics.checkNotNullParameter(ua, "ua");
Intrinsics.checkNotNullParameter(url, "url");
return new OkHttpCall(this.okHttpClient.newCall(defaultBuilder$default(this, ua, HttpUrl.Companion.get(url).newBuilder().build().toString(), null, 4, null).get().build()), this.emptyResponseConverter);
}
@Override // com.vungle.ads.internal.network.VungleApi
public Call<Void> sendMetrics(String ua, String path, RequestBody requestBody) {
Intrinsics.checkNotNullParameter(ua, "ua");
Intrinsics.checkNotNullParameter(path, "path");
Intrinsics.checkNotNullParameter(requestBody, "requestBody");
return new OkHttpCall(this.okHttpClient.newCall(defaultProtoBufBuilder(ua, HttpUrl.Companion.get(path).newBuilder().build().toString()).post(requestBody).build()), this.emptyResponseConverter);
}
@Override // com.vungle.ads.internal.network.VungleApi
public Call<Void> sendErrors(String ua, String path, RequestBody requestBody) {
Intrinsics.checkNotNullParameter(ua, "ua");
Intrinsics.checkNotNullParameter(path, "path");
Intrinsics.checkNotNullParameter(requestBody, "requestBody");
return new OkHttpCall(this.okHttpClient.newCall(defaultProtoBufBuilder(ua, HttpUrl.Companion.get(path).newBuilder().build().toString()).post(requestBody).build()), this.emptyResponseConverter);
}
@Override // com.vungle.ads.internal.network.VungleApi
public Call<Void> sendAdMarkup(String url, RequestBody requestBody) {
Intrinsics.checkNotNullParameter(url, "url");
Intrinsics.checkNotNullParameter(requestBody, "requestBody");
return new OkHttpCall(this.okHttpClient.newCall(defaultBuilder$default(this, "debug", HttpUrl.Companion.get(url).newBuilder().build().toString(), null, 4, null).post(requestBody).build()), this.emptyResponseConverter);
}
}

View File

@@ -0,0 +1,8 @@
package com.vungle.ads.internal.network.converters;
import java.io.IOException;
/* loaded from: classes4.dex */
public interface Converter<In, Out> {
Out convert(In in) throws IOException;
}

View File

@@ -0,0 +1,15 @@
package com.vungle.ads.internal.network.converters;
import okhttp3.ResponseBody;
/* loaded from: classes4.dex */
public final class EmptyResponseConverter implements Converter<ResponseBody, Void> {
@Override // com.vungle.ads.internal.network.converters.Converter
public Void convert(ResponseBody responseBody) {
if (responseBody == null) {
return null;
}
responseBody.close();
return null;
}
}

View File

@@ -0,0 +1,66 @@
package com.vungle.ads.internal.network.converters;
import java.io.IOException;
import kotlin.Unit;
import kotlin.io.CloseableKt;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
import kotlin.reflect.KType;
import kotlinx.serialization.SerializersKt;
import kotlinx.serialization.json.Json;
import kotlinx.serialization.json.JsonBuilder;
import kotlinx.serialization.json.JsonKt;
import okhttp3.ResponseBody;
/* loaded from: classes4.dex */
public final class JsonConverter<E> implements Converter<ResponseBody, E> {
public static final Companion Companion = new Companion(null);
private static final Json json = JsonKt.Json$default((Json) null, new Function1() { // from class: com.vungle.ads.internal.network.converters.JsonConverter$Companion$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);
Json.setAllowStructuredMapKeys(true);
}
}, 1, (Object) null);
private final KType kType;
public JsonConverter(KType kType) {
Intrinsics.checkNotNullParameter(kType, "kType");
this.kType = kType;
}
public static final class Companion {
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
private Companion() {
}
}
@Override // com.vungle.ads.internal.network.converters.Converter
public E convert(ResponseBody responseBody) throws IOException {
if (responseBody != null) {
try {
String string = responseBody.string();
if (string != null) {
E e = (E) json.decodeFromString(SerializersKt.serializer(Json.Default.getSerializersModule(), this.kType), string);
CloseableKt.closeFinally(responseBody, null);
return e;
}
} finally {
}
}
CloseableKt.closeFinally(responseBody, null);
return null;
}
}