what-the-bank/sources/com/google/android/gms/internal/firebase_ml/zzoq.java

260 lines
9.5 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package com.google.android.gms.internal.firebase_ml;
import com.google.android.gms.common.internal.GmsLogger;
import com.google.firebase.FirebaseApp;
import com.google.firebase.ml.common.FirebaseMLException;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
/* loaded from: classes2.dex */
public final class zzoq {
private static final GmsLogger zzaoz = new GmsLogger("RemoteModelFileManager", "");
private static String zzarb = "com.google.firebase.ml.%s.models";
private static final String zzarc = String.format("com.google.firebase.ml.%s.models", "custom");
private static final String zzard = String.format(zzarb, "automl");
private static final String zzare = String.format(zzarb, "base");
private static final String zzarf = String.format(zzarb, "translate");
private final FirebaseApp zzapo;
private final String zzaqg;
private final zzok zzara;
private final zzox zzarg;
private final zzoh zzarh;
public zzoq(FirebaseApp firebaseApp, String str, zzol zzolVar, zzok zzokVar) {
this.zzapo = firebaseApp;
this.zzaqg = str;
this.zzara = zzokVar;
this.zzarg = new zzox(zzolVar);
int i = zzor.zzari[zzokVar.ordinal()];
if (i == 1) {
this.zzarh = new zzob(firebaseApp, str);
return;
}
if (i == 2) {
this.zzarh = new zzot(firebaseApp, str);
} else {
if (i == 3 || i == 4) {
this.zzarh = new zzos(firebaseApp, str);
return;
}
throw new IllegalArgumentException("Unexpected model type");
}
}
/* JADX WARN: Code restructure failed: missing block: B:48:0x00fa, code lost:
r8 = com.google.android.gms.internal.firebase_ml.zzoq.zzaoz;
r9 = java.lang.String.valueOf(r9);
*/
/* JADX WARN: Code restructure failed: missing block: B:49:0x0104, code lost:
if (r9.length() == 0) goto L46;
*/
/* JADX WARN: Code restructure failed: missing block: B:50:0x0106, code lost:
r9 = "Hash does not match with expected: ".concat(r9);
*/
/* JADX WARN: Code restructure failed: missing block: B:51:0x0114, code lost:
r8.d("RemoteModelFileManager", r9);
*/
/* JADX WARN: Code restructure failed: missing block: B:52:0x010d, code lost:
r9 = new java.lang.String("Hash does not match with expected: ");
*/
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public final java.io.File zza(android.os.ParcelFileDescriptor r8, java.lang.String r9, com.google.android.gms.internal.firebase_ml.zzon r10) throws com.google.firebase.ml.common.FirebaseMLException {
/*
Method dump skipped, instructions count: 382
To view this dump add '--comments-level debug' option
*/
throw new UnsupportedOperationException("Method not decompiled: com.google.android.gms.internal.firebase_ml.zzoq.zza(android.os.ParcelFileDescriptor, java.lang.String, com.google.android.gms.internal.firebase_ml.zzon):java.io.File");
}
public final boolean zzb(File file) throws FirebaseMLException {
synchronized (this) {
File zza = zza(this.zzapo, this.zzaqg, this.zzara, false);
if (!zza.exists()) {
return false;
}
boolean z = true;
for (File file2 : zza.listFiles()) {
if (!file2.equals(file) && !zze(file2)) {
z = false;
}
}
return z;
}
}
public final File zzc(File file) throws FirebaseMLException {
synchronized (this) {
File file2 = new File(String.valueOf(zza(this.zzapo, this.zzaqg, this.zzara, false).getAbsolutePath()).concat("/0"));
return file2.exists() ? file : file.renameTo(file2) ? file2 : file;
}
}
public final String zzmf() throws FirebaseMLException {
synchronized (this) {
File zza = zza(this.zzapo, this.zzaqg, this.zzara, false);
int zzd = zzd(zza);
if (zzd < 0) {
return null;
}
String absolutePath = zza.getAbsolutePath();
StringBuilder sb = new StringBuilder(String.valueOf(absolutePath).length() + 12);
sb.append(absolutePath);
sb.append("/");
sb.append(zzd);
return sb.toString();
}
}
public final void zzmg() throws FirebaseMLException {
synchronized (this) {
this.zzarh.zzlt();
}
}
/* JADX INFO: Access modifiers changed from: package-private */
public static File zza(FirebaseApp firebaseApp, String str, zzok zzokVar) throws FirebaseMLException {
return zza(firebaseApp, str, zzokVar, true);
}
/* JADX INFO: Access modifiers changed from: package-private */
public static File zzb(FirebaseApp firebaseApp, String str, zzok zzokVar) throws FirebaseMLException {
return zza(firebaseApp, str, zzokVar, false);
}
private static File zza(FirebaseApp firebaseApp, String str, zzok zzokVar, boolean z) throws FirebaseMLException {
String str2;
int i = zzor.zzari[zzokVar.ordinal()];
if (i == 1) {
str2 = zzare;
} else if (i == 2) {
str2 = zzarf;
} else if (i == 3) {
str2 = zzard;
} else {
if (i != 4) {
String name = zzokVar.name();
StringBuilder sb = new StringBuilder(String.valueOf(name).length() + 69);
sb.append("Unknown model type ");
sb.append(name);
sb.append(". Cannot find a dir to store the downloaded model.");
throw new FirebaseMLException(sb.toString(), 13);
}
str2 = zzarc;
}
File file = new File(firebaseApp.getApplicationContext().getNoBackupFilesDir(), str2);
if (z) {
file = new File(file, "temp");
}
File file2 = new File(new File(file, firebaseApp.getPersistenceKey()), str);
if (!file2.exists()) {
GmsLogger gmsLogger = zzaoz;
String valueOf = String.valueOf(file2.getAbsolutePath());
gmsLogger.d("RemoteModelFileManager", valueOf.length() != 0 ? "model folder does not exist, creating one: ".concat(valueOf) : new String("model folder does not exist, creating one: "));
file2.mkdirs();
} else if (!file2.isDirectory()) {
String valueOf2 = String.valueOf(file2);
StringBuilder sb2 = new StringBuilder(String.valueOf(valueOf2).length() + 71);
sb2.append("Can not create model folder, since an existing file has the same name: ");
sb2.append(valueOf2);
throw new FirebaseMLException(sb2.toString(), 6);
}
return file2;
}
/* JADX INFO: Access modifiers changed from: package-private */
public static int zzd(File file) {
File[] listFiles = file.listFiles();
if (listFiles.length == 0) {
return -1;
}
int i = 0;
for (File file2 : listFiles) {
try {
i = Math.max(i, Integer.parseInt(file2.getName()));
} catch (NumberFormatException unused) {
GmsLogger gmsLogger = zzaoz;
String valueOf = String.valueOf(file2.getName());
gmsLogger.d("RemoteModelFileManager", valueOf.length() != 0 ? "Contains non-integer file name ".concat(valueOf) : new String("Contains non-integer file name "));
}
}
return i;
}
/* JADX INFO: Access modifiers changed from: package-private */
/* JADX WARN: Code restructure failed: missing block: B:15:0x0021, code lost:
if (r5 != false) goto L14;
*/
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public static boolean zze(java.io.File r7) {
/*
boolean r0 = r7.isDirectory()
r1 = 0
r2 = 1
if (r0 == 0) goto L23
java.io.File[] r0 = r7.listFiles()
int r3 = r0.length
r4 = r1
r5 = r2
Lf:
if (r4 >= r3) goto L21
r6 = r0[r4]
if (r5 == 0) goto L1d
boolean r5 = zze(r6)
if (r5 == 0) goto L1d
r5 = r2
goto L1e
L1d:
r5 = r1
L1e:
int r4 = r4 + 1
goto Lf
L21:
if (r5 == 0) goto L2a
L23:
boolean r7 = r7.delete()
if (r7 == 0) goto L2a
return r2
L2a:
return r1
*/
throw new UnsupportedOperationException("Method not decompiled: com.google.android.gms.internal.firebase_ml.zzoq.zze(java.io.File):boolean");
}
private static /* synthetic */ void zza(Throwable th, FileOutputStream fileOutputStream) {
if (th == null) {
fileOutputStream.close();
return;
}
try {
fileOutputStream.close();
} catch (Throwable th2) {
zzlx.zza(th, th2);
}
}
private static /* synthetic */ void zza(Throwable th, FileInputStream fileInputStream) {
if (th == null) {
fileInputStream.close();
return;
}
try {
fileInputStream.close();
} catch (Throwable th2) {
zzlx.zza(th, th2);
}
}
}