- 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
449 lines
17 KiB
Java
449 lines
17 KiB
Java
package com.vungle.ads.internal.util;
|
|
|
|
import android.webkit.URLUtil;
|
|
import androidx.annotation.VisibleForTesting;
|
|
import com.vungle.ads.internal.util.Logger;
|
|
import java.io.Closeable;
|
|
import java.io.File;
|
|
import java.io.FileInputStream;
|
|
import java.io.FileOutputStream;
|
|
import java.io.IOException;
|
|
import java.io.InputStream;
|
|
import java.io.ObjectInputStream;
|
|
import java.io.ObjectOutputStream;
|
|
import java.io.Serializable;
|
|
import java.nio.file.Files;
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.HashSet;
|
|
import java.util.LinkedHashSet;
|
|
import java.util.List;
|
|
import kotlin.collections.CollectionsKt__CollectionsKt;
|
|
import kotlin.io.FilesKt__FileReadWriteKt;
|
|
import kotlin.jvm.internal.Intrinsics;
|
|
import kotlin.text.Charsets;
|
|
import okhttp3.HttpUrl;
|
|
|
|
/* loaded from: classes4.dex */
|
|
public final class FileUtility {
|
|
private static final List<Class<?>> allowedClasses;
|
|
public static final FileUtility INSTANCE = new FileUtility();
|
|
private static ObjectInputStreamProvider objectInputStreamProvider = new ObjectInputStreamProvider() { // from class: com.vungle.ads.internal.util.FileUtility$$ExternalSyntheticLambda0
|
|
@Override // com.vungle.ads.internal.util.FileUtility.ObjectInputStreamProvider
|
|
public final ObjectInputStream provideObjectInputStream(InputStream inputStream) {
|
|
ObjectInputStream m3990objectInputStreamProvider$lambda0;
|
|
m3990objectInputStreamProvider$lambda0 = FileUtility.m3990objectInputStreamProvider$lambda0(inputStream);
|
|
return m3990objectInputStreamProvider$lambda0;
|
|
}
|
|
};
|
|
private static final String TAG = FileUtility.class.getSimpleName();
|
|
|
|
public interface ObjectInputStreamProvider {
|
|
ObjectInputStream provideObjectInputStream(InputStream inputStream) throws IOException, ClassNotFoundException;
|
|
}
|
|
|
|
@VisibleForTesting
|
|
public static /* synthetic */ void getAllowedClasses$vungle_ads_release$annotations() {
|
|
}
|
|
|
|
public static final void printDirectoryTree(File file) {
|
|
}
|
|
|
|
public final List<Class<?>> getAllowedClasses$vungle_ads_release() {
|
|
return allowedClasses;
|
|
}
|
|
|
|
@VisibleForTesting
|
|
public final ObjectInputStreamProvider getObjectInputStreamProvider() {
|
|
return objectInputStreamProvider;
|
|
}
|
|
|
|
@VisibleForTesting
|
|
public final void setObjectInputStreamProvider(ObjectInputStreamProvider objectInputStreamProvider2) {
|
|
Intrinsics.checkNotNullParameter(objectInputStreamProvider2, "<set-?>");
|
|
objectInputStreamProvider = objectInputStreamProvider2;
|
|
}
|
|
|
|
private FileUtility() {
|
|
}
|
|
|
|
static {
|
|
List<Class<?>> listOf;
|
|
listOf = CollectionsKt__CollectionsKt.listOf((Object[]) new Class[]{LinkedHashSet.class, HashSet.class, HashMap.class, ArrayList.class, File.class});
|
|
allowedClasses = listOf;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
/* renamed from: objectInputStreamProvider$lambda-0, reason: not valid java name */
|
|
public static final ObjectInputStream m3990objectInputStreamProvider$lambda0(InputStream inputStream) {
|
|
return new SafeObjectInputStream(inputStream, allowedClasses);
|
|
}
|
|
|
|
private final void printDirectoryTree(File file, int i, StringBuilder sb) {
|
|
if (file == null) {
|
|
return;
|
|
}
|
|
if (!file.isDirectory()) {
|
|
throw new IllegalArgumentException("folder is not a Directory".toString());
|
|
}
|
|
sb.append(getIndentString(i));
|
|
sb.append("+--");
|
|
sb.append(file.getName());
|
|
sb.append("/\n");
|
|
File[] listFiles = file.listFiles();
|
|
if (listFiles == null) {
|
|
return;
|
|
}
|
|
for (File file2 : listFiles) {
|
|
if (file2.isDirectory()) {
|
|
printDirectoryTree(file2, i + 1, sb);
|
|
} else {
|
|
Intrinsics.checkNotNullExpressionValue(file2, "file");
|
|
printFile(file2, i + 1, sb);
|
|
}
|
|
}
|
|
}
|
|
|
|
private final void printFile(File file, int i, StringBuilder sb) {
|
|
sb.append(getIndentString(i));
|
|
sb.append("+--");
|
|
sb.append(file.getName());
|
|
sb.append('\n');
|
|
}
|
|
|
|
private final String getIndentString(int i) {
|
|
StringBuilder sb = new StringBuilder();
|
|
for (int i2 = 0; i2 < i; i2++) {
|
|
sb.append("| ");
|
|
}
|
|
String sb2 = sb.toString();
|
|
Intrinsics.checkNotNullExpressionValue(sb2, "sb.toString()");
|
|
return sb2;
|
|
}
|
|
|
|
public static final void delete(File file) {
|
|
if (file != null) {
|
|
try {
|
|
if (file.exists()) {
|
|
if (file.isDirectory()) {
|
|
deleteContents(file);
|
|
}
|
|
if (file.delete()) {
|
|
return;
|
|
}
|
|
Logger.Companion companion = Logger.Companion;
|
|
String TAG2 = TAG;
|
|
Intrinsics.checkNotNullExpressionValue(TAG2, "TAG");
|
|
companion.d(TAG2, "Failed to delete file: " + file);
|
|
}
|
|
} catch (Exception e) {
|
|
Logger.Companion companion2 = Logger.Companion;
|
|
String TAG3 = TAG;
|
|
Intrinsics.checkNotNullExpressionValue(TAG3, "TAG");
|
|
companion2.e(TAG3, "Failed to delete file: " + e.getLocalizedMessage());
|
|
}
|
|
}
|
|
}
|
|
|
|
public static final void deleteContents(File folder) {
|
|
Intrinsics.checkNotNullParameter(folder, "folder");
|
|
File[] listFiles = folder.listFiles();
|
|
if (listFiles == null) {
|
|
return;
|
|
}
|
|
for (File file : listFiles) {
|
|
delete(file);
|
|
}
|
|
}
|
|
|
|
public static final void deleteAndLogIfFailed(File file) {
|
|
Intrinsics.checkNotNullParameter(file, "file");
|
|
try {
|
|
Files.delete(file.toPath());
|
|
} catch (Exception e) {
|
|
Logger.Companion companion = Logger.Companion;
|
|
String TAG2 = TAG;
|
|
Intrinsics.checkNotNullExpressionValue(TAG2, "TAG");
|
|
companion.e(TAG2, "Cannot delete " + file.getName(), e);
|
|
}
|
|
}
|
|
|
|
public final void closeQuietly(Closeable closeable) {
|
|
if (closeable != null) {
|
|
try {
|
|
closeable.close();
|
|
} catch (IOException unused) {
|
|
}
|
|
}
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
/* JADX WARN: Type inference failed for: r4v1 */
|
|
/* JADX WARN: Type inference failed for: r4v3 */
|
|
/* JADX WARN: Type inference failed for: r4v4, types: [java.io.Closeable] */
|
|
/* JADX WARN: Type inference failed for: r4v5 */
|
|
/* JADX WARN: Type inference failed for: r4v6 */
|
|
/* JADX WARN: Type inference failed for: r4v7, types: [java.io.Closeable, java.io.ObjectOutputStream] */
|
|
/* JADX WARN: Type inference failed for: r4v8 */
|
|
/* JADX WARN: Type inference failed for: r5v15, types: [com.vungle.ads.internal.util.FileUtility] */
|
|
/* JADX WARN: Type inference failed for: r5v9, types: [com.vungle.ads.internal.util.FileUtility] */
|
|
public static final void writeSerializable(File file, Serializable serializable) {
|
|
FileOutputStream fileOutputStream;
|
|
?? r4;
|
|
Intrinsics.checkNotNullParameter(file, "file");
|
|
if (file.exists()) {
|
|
deleteAndLogIfFailed(file);
|
|
}
|
|
if (serializable == null) {
|
|
return;
|
|
}
|
|
FileOutputStream fileOutputStream2 = null;
|
|
try {
|
|
fileOutputStream = new FileOutputStream(file);
|
|
} catch (IOException e) {
|
|
e = e;
|
|
r4 = 0;
|
|
} catch (Throwable th) {
|
|
th = th;
|
|
fileOutputStream = null;
|
|
}
|
|
try {
|
|
r4 = new ObjectOutputStream(fileOutputStream);
|
|
} catch (IOException e2) {
|
|
e = e2;
|
|
r4 = 0;
|
|
} catch (Throwable th2) {
|
|
th = th2;
|
|
FileUtility fileUtility = INSTANCE;
|
|
fileUtility.closeQuietly(fileOutputStream2);
|
|
fileUtility.closeQuietly(fileOutputStream);
|
|
throw th;
|
|
}
|
|
try {
|
|
r4.writeObject(serializable);
|
|
r4.reset();
|
|
?? r5 = INSTANCE;
|
|
r5.closeQuietly(r4);
|
|
r5.closeQuietly(fileOutputStream);
|
|
} catch (IOException e3) {
|
|
e = e3;
|
|
fileOutputStream2 = fileOutputStream;
|
|
r4 = r4;
|
|
try {
|
|
Logger.Companion companion = Logger.Companion;
|
|
String TAG2 = TAG;
|
|
Intrinsics.checkNotNullExpressionValue(TAG2, "TAG");
|
|
companion.e(TAG2, String.valueOf(e.getMessage()));
|
|
?? r52 = INSTANCE;
|
|
r52.closeQuietly(r4);
|
|
r52.closeQuietly(fileOutputStream2);
|
|
} catch (Throwable th3) {
|
|
th = th3;
|
|
fileOutputStream = fileOutputStream2;
|
|
fileOutputStream2 = r4;
|
|
FileUtility fileUtility2 = INSTANCE;
|
|
fileUtility2.closeQuietly(fileOutputStream2);
|
|
fileUtility2.closeQuietly(fileOutputStream);
|
|
throw th;
|
|
}
|
|
} catch (Throwable th4) {
|
|
th = th4;
|
|
fileOutputStream2 = r4;
|
|
FileUtility fileUtility22 = INSTANCE;
|
|
fileUtility22.closeQuietly(fileOutputStream2);
|
|
fileUtility22.closeQuietly(fileOutputStream);
|
|
throw th;
|
|
}
|
|
}
|
|
|
|
public final void writeString(File file, String str) {
|
|
Intrinsics.checkNotNullParameter(file, "file");
|
|
if (str == null) {
|
|
return;
|
|
}
|
|
try {
|
|
FilesKt__FileReadWriteKt.writeText(file, str, Charsets.UTF_8);
|
|
} catch (IOException e) {
|
|
Logger.Companion companion = Logger.Companion;
|
|
String TAG2 = TAG;
|
|
Intrinsics.checkNotNullExpressionValue(TAG2, "TAG");
|
|
companion.e(TAG2, String.valueOf(e.getMessage()));
|
|
}
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
/* JADX WARN: Not initialized variable reg: 3, insn: 0x0028: MOVE (r2 I:??[OBJECT, ARRAY]) = (r3 I:??[OBJECT, ARRAY]), block:B:47:0x0028 */
|
|
/* JADX WARN: Type inference failed for: r0v1, types: [com.vungle.ads.internal.util.FileUtility] */
|
|
/* JADX WARN: Type inference failed for: r0v9, types: [com.vungle.ads.internal.util.FileUtility] */
|
|
/* JADX WARN: Type inference failed for: r1v1, types: [boolean] */
|
|
/* JADX WARN: Type inference failed for: r1v10 */
|
|
/* JADX WARN: Type inference failed for: r1v11, types: [java.io.Closeable, java.io.FileInputStream, java.io.InputStream] */
|
|
/* JADX WARN: Type inference failed for: r1v2, types: [java.io.Closeable] */
|
|
/* JADX WARN: Type inference failed for: r1v3 */
|
|
/* JADX WARN: Type inference failed for: r1v4 */
|
|
/* JADX WARN: Type inference failed for: r1v5 */
|
|
/* JADX WARN: Type inference failed for: r1v6 */
|
|
/* JADX WARN: Type inference failed for: r1v7 */
|
|
/* JADX WARN: Type inference failed for: r1v8 */
|
|
/* JADX WARN: Type inference failed for: r3v11, types: [com.vungle.ads.internal.util.FileUtility$ObjectInputStreamProvider] */
|
|
public static final <T> T readSerializable(File file) {
|
|
Closeable closeable;
|
|
ObjectInputStream objectInputStream;
|
|
Closeable closeable2;
|
|
Intrinsics.checkNotNullParameter(file, "file");
|
|
?? exists = file.exists();
|
|
Closeable closeable3 = null;
|
|
try {
|
|
if (exists == 0) {
|
|
return null;
|
|
}
|
|
try {
|
|
exists = new FileInputStream(file);
|
|
} catch (IOException e) {
|
|
e = e;
|
|
exists = 0;
|
|
objectInputStream = null;
|
|
} catch (ClassNotFoundException e2) {
|
|
e = e2;
|
|
exists = 0;
|
|
objectInputStream = null;
|
|
} catch (Exception e3) {
|
|
e = e3;
|
|
exists = 0;
|
|
objectInputStream = null;
|
|
} catch (Throwable th) {
|
|
th = th;
|
|
exists = 0;
|
|
}
|
|
try {
|
|
objectInputStream = objectInputStreamProvider.provideObjectInputStream(exists);
|
|
try {
|
|
T t = (T) objectInputStream.readObject();
|
|
?? r0 = INSTANCE;
|
|
r0.closeQuietly(objectInputStream);
|
|
r0.closeQuietly(exists);
|
|
return t;
|
|
} catch (IOException e4) {
|
|
e = e4;
|
|
Logger.Companion companion = Logger.Companion;
|
|
String TAG2 = TAG;
|
|
Intrinsics.checkNotNullExpressionValue(TAG2, "TAG");
|
|
companion.e(TAG2, "IOException: " + e.getMessage());
|
|
closeable2 = exists;
|
|
FileUtility fileUtility = INSTANCE;
|
|
fileUtility.closeQuietly(objectInputStream);
|
|
fileUtility.closeQuietly(closeable2);
|
|
try {
|
|
delete(file);
|
|
} catch (IOException unused) {
|
|
}
|
|
return null;
|
|
} catch (ClassNotFoundException e5) {
|
|
e = e5;
|
|
Logger.Companion companion2 = Logger.Companion;
|
|
String TAG3 = TAG;
|
|
Intrinsics.checkNotNullExpressionValue(TAG3, "TAG");
|
|
companion2.e(TAG3, "ClassNotFoundException: " + e.getMessage());
|
|
closeable2 = exists;
|
|
FileUtility fileUtility2 = INSTANCE;
|
|
fileUtility2.closeQuietly(objectInputStream);
|
|
fileUtility2.closeQuietly(closeable2);
|
|
delete(file);
|
|
return null;
|
|
} catch (Exception e6) {
|
|
e = e6;
|
|
Logger.Companion companion3 = Logger.Companion;
|
|
String TAG4 = TAG;
|
|
Intrinsics.checkNotNullExpressionValue(TAG4, "TAG");
|
|
companion3.e(TAG4, "cannot read serializable " + e.getMessage());
|
|
closeable2 = exists;
|
|
FileUtility fileUtility22 = INSTANCE;
|
|
fileUtility22.closeQuietly(objectInputStream);
|
|
fileUtility22.closeQuietly(closeable2);
|
|
delete(file);
|
|
return null;
|
|
}
|
|
} catch (IOException e7) {
|
|
e = e7;
|
|
objectInputStream = null;
|
|
} catch (ClassNotFoundException e8) {
|
|
e = e8;
|
|
objectInputStream = null;
|
|
} catch (Exception e9) {
|
|
e = e9;
|
|
objectInputStream = null;
|
|
} catch (Throwable th2) {
|
|
th = th2;
|
|
?? r02 = INSTANCE;
|
|
r02.closeQuietly(closeable3);
|
|
r02.closeQuietly(exists);
|
|
throw th;
|
|
}
|
|
} catch (Throwable th3) {
|
|
th = th3;
|
|
closeable3 = closeable;
|
|
}
|
|
}
|
|
|
|
public final String readString(File file) {
|
|
String readText$default;
|
|
Intrinsics.checkNotNullParameter(file, "file");
|
|
if (!file.exists()) {
|
|
return null;
|
|
}
|
|
try {
|
|
readText$default = FilesKt__FileReadWriteKt.readText$default(file, null, 1, null);
|
|
return readText$default;
|
|
} catch (IOException e) {
|
|
Logger.Companion companion = Logger.Companion;
|
|
String TAG2 = TAG;
|
|
Intrinsics.checkNotNullExpressionValue(TAG2, "TAG");
|
|
companion.e(TAG2, "IOException: " + e.getMessage());
|
|
return null;
|
|
} catch (Exception e2) {
|
|
Logger.Companion companion2 = Logger.Companion;
|
|
String TAG3 = TAG;
|
|
Intrinsics.checkNotNullExpressionValue(TAG3, "TAG");
|
|
companion2.e(TAG3, "cannot read string " + e2.getMessage());
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public final boolean isValidUrl(String str) {
|
|
return (str == null || str.length() == 0 || HttpUrl.Companion.parse(str) == null) ? false : true;
|
|
}
|
|
|
|
public final long size(File file) {
|
|
long j = 0;
|
|
if (file == null || !file.exists()) {
|
|
return 0L;
|
|
}
|
|
if (file.isDirectory()) {
|
|
File[] listFiles = file.listFiles();
|
|
if (listFiles != null) {
|
|
if (!(listFiles.length == 0)) {
|
|
for (File file2 : listFiles) {
|
|
j += size(file2);
|
|
}
|
|
}
|
|
}
|
|
return j;
|
|
}
|
|
return file.length();
|
|
}
|
|
|
|
public static /* synthetic */ String guessFileName$default(FileUtility fileUtility, String str, String str2, int i, Object obj) {
|
|
if ((i & 2) != 0) {
|
|
str2 = null;
|
|
}
|
|
return fileUtility.guessFileName(str, str2);
|
|
}
|
|
|
|
public final String guessFileName(String url, String str) {
|
|
Intrinsics.checkNotNullParameter(url, "url");
|
|
String guessFileName = URLUtil.guessFileName(url, null, str);
|
|
Intrinsics.checkNotNullExpressionValue(guessFileName, "guessFileName(url, null, ext)");
|
|
return guessFileName;
|
|
}
|
|
}
|