Files
rr3-apk/decompiled-community/sources/com/vungle/ads/internal/downloader/AssetDownloader.java
Daniel Elliott c080f0d97f Add Discord community version (64-bit only)
- Added realracing3-community.apk (71.57 MB)
- Removed 32-bit support (armeabi-v7a)
- Only includes arm64-v8a libraries
- Decompiled source code included
- Added README-community.md with analysis
2026-02-18 15:48:36 -08:00

209 lines
11 KiB
Java

package com.vungle.ads.internal.downloader;
import com.vungle.ads.AnalyticsClient;
import com.vungle.ads.OutOfMemory;
import com.vungle.ads.internal.ConfigManager;
import com.vungle.ads.internal.downloader.AssetDownloadListener;
import com.vungle.ads.internal.executor.VungleThreadPoolExecutor;
import com.vungle.ads.internal.task.PriorityRunnable;
import com.vungle.ads.internal.util.Logger;
import com.vungle.ads.internal.util.PathProvider;
import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.TimeUnit;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
import kotlin.text.StringsKt__StringsJVMKt;
import okhttp3.Cache;
import okhttp3.HttpUrl;
import okhttp3.OkHttpClient;
import okhttp3.Response;
import okhttp3.ResponseBody;
import okhttp3.internal.http.RealResponseBody;
import okio.GzipSource;
import okio.Okio;
/* loaded from: classes4.dex */
public final class AssetDownloader implements Downloader {
private static final String CONTENT_ENCODING = "Content-Encoding";
private static final String CONTENT_TYPE = "Content-Type";
public static final Companion Companion = new Companion(null);
private static final int DOWNLOAD_CHUNK_SIZE = 2048;
private static final String GZIP = "gzip";
private static final String IDENTITY = "identity";
private static final int MINIMUM_SPACE_REQUIRED_MB = 20971520;
private static final String TAG = "AssetDownloader";
private static final int TIMEOUT = 30;
private final VungleThreadPoolExecutor downloadExecutor;
private OkHttpClient okHttpClient;
private final PathProvider pathProvider;
private final List<DownloadRequest> transitioning;
public AssetDownloader(VungleThreadPoolExecutor downloadExecutor, PathProvider pathProvider) {
Intrinsics.checkNotNullParameter(downloadExecutor, "downloadExecutor");
Intrinsics.checkNotNullParameter(pathProvider, "pathProvider");
this.downloadExecutor = downloadExecutor;
this.pathProvider = pathProvider;
this.transitioning = new ArrayList();
OkHttpClient.Builder builder = new OkHttpClient.Builder();
TimeUnit timeUnit = TimeUnit.SECONDS;
OkHttpClient.Builder followSslRedirects = builder.readTimeout(30L, timeUnit).connectTimeout(30L, timeUnit).cache(null).followRedirects(true).followSslRedirects(true);
ConfigManager configManager = ConfigManager.INSTANCE;
if (configManager.isCleverCacheEnabled()) {
long cleverCacheDiskSize = configManager.getCleverCacheDiskSize();
int cleverCacheDiskPercentage = configManager.getCleverCacheDiskPercentage();
String absolutePath = pathProvider.getCleverCacheDir().getAbsolutePath();
Intrinsics.checkNotNullExpressionValue(absolutePath, "pathProvider.getCleverCacheDir().absolutePath");
long min = Long.min(cleverCacheDiskSize, (pathProvider.getAvailableBytes(absolutePath) * cleverCacheDiskPercentage) / 100);
if (min > 0) {
followSslRedirects.cache(new Cache(pathProvider.getCleverCacheDir(), min));
} else {
Logger.Companion.w(TAG, "cache disk capacity size <=0, no clever cache active.");
}
}
this.okHttpClient = followSslRedirects.build();
}
public static final class Companion {
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
private Companion() {
}
}
@Override // com.vungle.ads.internal.downloader.Downloader
public void download(final DownloadRequest downloadRequest, final AssetDownloadListener assetDownloadListener) {
if (downloadRequest == null) {
return;
}
this.transitioning.add(downloadRequest);
this.downloadExecutor.execute(new PriorityRunnable() { // from class: com.vungle.ads.internal.downloader.AssetDownloader$download$1
@Override // java.lang.Runnable
public void run() {
AssetDownloader.this.launchRequest(downloadRequest, assetDownloadListener);
}
@Override // com.vungle.ads.internal.task.PriorityRunnable
public int getPriority() {
return downloadRequest.getPriority();
}
}, new Runnable() { // from class: com.vungle.ads.internal.downloader.AssetDownloader$$ExternalSyntheticLambda0
@Override // java.lang.Runnable
public final void run() {
AssetDownloader.m3883download$lambda0(AssetDownloader.this, downloadRequest, assetDownloadListener);
}
});
}
/* JADX INFO: Access modifiers changed from: private */
/* renamed from: download$lambda-0, reason: not valid java name */
public static final void m3883download$lambda0(AssetDownloader this$0, DownloadRequest downloadRequest, AssetDownloadListener assetDownloadListener) {
Intrinsics.checkNotNullParameter(this$0, "this$0");
this$0.deliverError(downloadRequest, assetDownloadListener, new AssetDownloadListener.DownloadError(-1, new OutOfMemory("Cannot complete " + downloadRequest + " : Out of Memory"), AssetDownloadListener.DownloadError.ErrorReason.Companion.getINTERNAL_ERROR()));
}
private final void deliverError(DownloadRequest downloadRequest, AssetDownloadListener assetDownloadListener, AssetDownloadListener.DownloadError downloadError) {
if (assetDownloadListener != null) {
assetDownloadListener.onError(downloadError, downloadRequest);
}
}
@Override // com.vungle.ads.internal.downloader.Downloader
public void cancel(DownloadRequest downloadRequest) {
if (downloadRequest == null || downloadRequest.isCancelled()) {
return;
}
downloadRequest.cancel();
}
@Override // com.vungle.ads.internal.downloader.Downloader
public void cancelAll() {
Iterator<T> it = this.transitioning.iterator();
while (it.hasNext()) {
cancel((DownloadRequest) it.next());
}
this.transitioning.clear();
}
/* JADX INFO: Access modifiers changed from: private */
/* JADX WARN: Multi-variable type inference failed */
/* JADX WARN: Removed duplicated region for block: B:105:0x0598 A[EXC_TOP_SPLITTER, SYNTHETIC] */
/* JADX WARN: Removed duplicated region for block: B:52:0x05d2 A[Catch: all -> 0x06a5, TRY_ENTER, TRY_LEAVE, TryCatch #3 {all -> 0x06a5, blocks: (B:50:0x058b, B:52:0x05d2, B:101:0x05da), top: B:49:0x058b }] */
/* JADX WARN: Removed duplicated region for block: B:59:0x0617 */
/* JADX WARN: Removed duplicated region for block: B:61:0x0620 */
/* JADX WARN: Removed duplicated region for block: B:65:0x062d */
/* JADX WARN: Removed duplicated region for block: B:68:0x065d */
/* JADX WARN: Removed duplicated region for block: B:72:0x0671 */
/* JADX WARN: Removed duplicated region for block: B:77:0x0686 */
/* JADX WARN: Removed duplicated region for block: B:79:0x061c */
/* JADX WARN: Removed duplicated region for block: B:84:0x06aa */
/* JADX WARN: Removed duplicated region for block: B:86:0x06b2 */
/* JADX WARN: Removed duplicated region for block: B:90:0x06bf */
/* JADX WARN: Removed duplicated region for block: B:93:0x06f0 */
/* JADX WARN: Type inference failed for: r0v108, types: [com.vungle.ads.internal.util.FileUtility] */
/* JADX WARN: Type inference failed for: r18v10 */
/* JADX WARN: Type inference failed for: r18v11 */
/* JADX WARN: Type inference failed for: r18v12 */
/* JADX WARN: Type inference failed for: r18v13 */
/* JADX WARN: Type inference failed for: r18v14 */
/* JADX WARN: Type inference failed for: r18v15 */
/* JADX WARN: Type inference failed for: r18v16 */
/* JADX WARN: Type inference failed for: r18v17 */
/* JADX WARN: Type inference failed for: r18v18 */
/* JADX WARN: Type inference failed for: r18v19 */
/* JADX WARN: Type inference failed for: r18v20 */
/* JADX WARN: Type inference failed for: r18v21 */
/* JADX WARN: Type inference failed for: r18v4, types: [okhttp3.Call] */
/* JADX WARN: Type inference failed for: r18v5, types: [okhttp3.Call] */
/* JADX WARN: Type inference failed for: r18v8, types: [okhttp3.Call] */
/* JADX WARN: Type inference failed for: r4v37, types: [java.io.Closeable, okio.BufferedSink] */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public final void launchRequest(com.vungle.ads.internal.downloader.DownloadRequest r45, com.vungle.ads.internal.downloader.AssetDownloadListener r46) {
/*
Method dump skipped, instructions count: 1818
To view this dump add '--comments-level debug' option
*/
throw new UnsupportedOperationException("Method not decompiled: com.vungle.ads.internal.downloader.AssetDownloader.launchRequest(com.vungle.ads.internal.downloader.DownloadRequest, com.vungle.ads.internal.downloader.AssetDownloadListener):void");
}
private final ResponseBody decodeGzipIfNeeded(Response response) {
boolean equals;
ResponseBody body = response.body();
equals = StringsKt__StringsJVMKt.equals(GZIP, Response.header$default(response, "Content-Encoding", null, 2, null), true);
if (!equals || body == null) {
return body;
}
return new RealResponseBody(Response.header$default(response, "Content-Type", null, 2, null), -1L, Okio.buffer(new GzipSource(body.source())));
}
private final void deliverSuccess(File file, DownloadRequest downloadRequest, AssetDownloadListener assetDownloadListener) {
Logger.Companion.d(TAG, "On success " + downloadRequest);
if (assetDownloadListener != null) {
assetDownloadListener.onSuccess(file, downloadRequest);
}
}
private final boolean checkSpaceAvailable() {
PathProvider pathProvider = this.pathProvider;
String absolutePath = pathProvider.getVungleDir().getAbsolutePath();
Intrinsics.checkNotNullExpressionValue(absolutePath, "pathProvider.getVungleDir().absolutePath");
long availableBytes = pathProvider.getAvailableBytes(absolutePath);
if (availableBytes >= 20971520) {
return true;
}
AnalyticsClient.INSTANCE.logError$vungle_ads_release(126, "Insufficient space " + availableBytes, (r13 & 4) != 0 ? null : null, (r13 & 8) != 0 ? null : null, (r13 & 16) != 0 ? null : null);
return false;
}
private final boolean isValidUrl(String str) {
return (str == null || str.length() == 0 || HttpUrl.Companion.parse(str) == null) ? false : true;
}
}