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

132 lines
5.7 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package com.google.android.gms.internal.firebase_ml;
import android.content.Context;
import android.os.SystemClock;
import android.util.SparseArray;
import com.google.android.gms.common.internal.Preconditions;
import com.google.android.gms.internal.firebase_ml.zzmd;
import com.google.android.gms.vision.barcode.Barcode;
import com.google.android.gms.vision.barcode.BarcodeDetector;
import com.google.firebase.FirebaseApp;
import com.google.firebase.ml.common.FirebaseMLException;
import com.google.firebase.ml.vision.barcode.FirebaseVisionBarcode;
import com.google.firebase.ml.vision.barcode.FirebaseVisionBarcodeDetectorOptions;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/* loaded from: classes2.dex */
public final class zzpk implements zznm<List<FirebaseVisionBarcode>, zzpz>, zznw {
private static boolean zzata = true;
private final Context zzad;
private final zznu zzaqs;
private final FirebaseVisionBarcodeDetectorOptions zzawa;
private BarcodeDetector zzawb;
private zzpu zzawc = new zzpu();
public zzpk(FirebaseApp firebaseApp, FirebaseVisionBarcodeDetectorOptions firebaseVisionBarcodeDetectorOptions) {
Preconditions.checkNotNull(firebaseApp, "FirebaseApp can not be null");
Preconditions.checkNotNull(firebaseVisionBarcodeDetectorOptions, "FirebaseVisionBarcodeDetectorOptions can not be null");
this.zzad = firebaseApp.getApplicationContext();
this.zzawa = firebaseVisionBarcodeDetectorOptions;
this.zzaqs = zznu.zza(firebaseApp, 1);
}
@Override // com.google.android.gms.internal.firebase_ml.zznm
public final zznw zzlm() {
return this;
}
@Override // com.google.android.gms.internal.firebase_ml.zznw
public final void zzlp() {
synchronized (this) {
if (this.zzawb == null) {
this.zzawb = new BarcodeDetector.Builder(this.zzad).setBarcodeFormats(this.zzawa.zznf()).build();
}
}
}
@Override // com.google.android.gms.internal.firebase_ml.zznw
public final void release() {
synchronized (this) {
BarcodeDetector barcodeDetector = this.zzawb;
if (barcodeDetector != null) {
barcodeDetector.release();
this.zzawb = null;
}
zzata = true;
}
}
/* JADX INFO: Access modifiers changed from: private */
@Override // com.google.android.gms.internal.firebase_ml.zznm
public final List<FirebaseVisionBarcode> zza(zzpz zzpzVar) throws FirebaseMLException {
ArrayList arrayList;
synchronized (this) {
long elapsedRealtime = SystemClock.elapsedRealtime();
BarcodeDetector barcodeDetector = this.zzawb;
if (barcodeDetector == null) {
zza(zzmk.UNKNOWN_ERROR, elapsedRealtime, zzpzVar, (List<FirebaseVisionBarcode>) null);
throw new FirebaseMLException("Model source is unavailable. Please load the model resource first.", 13);
}
if (!barcodeDetector.isOperational()) {
zza(zzmk.MODEL_NOT_DOWNLOADED, elapsedRealtime, zzpzVar, (List<FirebaseVisionBarcode>) null);
throw new FirebaseMLException("Waiting for the barcode detection model to be downloaded. Please wait.", 14);
}
this.zzawc.zzb(zzpzVar);
SparseArray<Barcode> detect = this.zzawb.detect(zzpzVar.zzaxe);
arrayList = new ArrayList();
for (int i = 0; i < detect.size(); i++) {
Barcode barcode = detect.get(detect.keyAt(i));
if (barcode != null) {
arrayList.add(new FirebaseVisionBarcode(barcode));
}
}
zza(zzmk.NO_ERROR, elapsedRealtime, zzpzVar, arrayList);
zzata = false;
}
return arrayList;
}
private final void zza(final zzmk zzmkVar, final long j, final zzpz zzpzVar, final List<FirebaseVisionBarcode> list) {
this.zzaqs.zza(new zznv(this, j, zzmkVar, zzpzVar, list) { // from class: com.google.android.gms.internal.firebase_ml.zzpl
private final long zzatf;
private final zzpk zzawd;
private final zzmk zzawe;
private final zzpz zzawf;
private final List zzawg;
@Override // com.google.android.gms.internal.firebase_ml.zznv
public final zzmd.zzq.zza zzm() {
return this.zzawd.zza(this.zzatf, this.zzawe, this.zzawf, this.zzawg);
}
/* JADX INFO: Access modifiers changed from: package-private */
{
this.zzawd = this;
this.zzatf = j;
this.zzawe = zzmkVar;
this.zzawf = zzpzVar;
this.zzawg = list;
}
}, zzmn.ON_DEVICE_BARCODE_DETECT);
}
/* JADX INFO: Access modifiers changed from: package-private */
public final /* synthetic */ zzmd.zzq.zza zza(long j, zzmk zzmkVar, zzpz zzpzVar, List list) {
zzmd.zzv.zzc zzb = zzmd.zzv.zzki().zzc(zzmd.zzs.zzkb().zzn(SystemClock.elapsedRealtime() - j).zzc(zzmkVar).zzz(zzata).zzaa(true).zzab(true)).zzb(this.zzawa.zzng()).zzb(zzpv.zzc(zzpzVar));
if (list != null) {
ArrayList arrayList = new ArrayList();
ArrayList arrayList2 = new ArrayList();
Iterator it = list.iterator();
while (it.hasNext()) {
FirebaseVisionBarcode firebaseVisionBarcode = (FirebaseVisionBarcode) it.next();
arrayList.add(firebaseVisionBarcode.zznd());
arrayList2.add(firebaseVisionBarcode.zzne());
}
zzb.zzk(arrayList).zzl(arrayList2);
}
return zzmd.zzq.zzjx().zzb(zzb);
}
}