164 lines
8.7 KiB
Java
164 lines
8.7 KiB
Java
|
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.dynamite.DynamiteModule;
|
||
|
import com.google.android.gms.dynamite.descriptors.com.google.android.gms.vision.dynamite.face.ModuleDescriptor;
|
||
|
import com.google.android.gms.internal.firebase_ml.zzmd;
|
||
|
import com.google.android.gms.vision.face.Face;
|
||
|
import com.google.android.gms.vision.face.FaceDetector;
|
||
|
import com.google.firebase.FirebaseApp;
|
||
|
import com.google.firebase.ml.common.FirebaseMLException;
|
||
|
import com.google.firebase.ml.vision.face.FirebaseVisionFace;
|
||
|
import com.google.firebase.ml.vision.face.FirebaseVisionFaceDetectorOptions;
|
||
|
import java.util.ArrayList;
|
||
|
import java.util.Iterator;
|
||
|
import java.util.List;
|
||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||
|
|
||
|
/* loaded from: classes2.dex */
|
||
|
public final class zzqa implements zznm<List<FirebaseVisionFace>, zzpz>, zznw {
|
||
|
private static AtomicBoolean zzato = new AtomicBoolean(true);
|
||
|
private static volatile Boolean zzaub;
|
||
|
private final Context zzad;
|
||
|
private final zznu zzaqs;
|
||
|
private zzpu zzawc = new zzpu();
|
||
|
private final FirebaseVisionFaceDetectorOptions zzaye;
|
||
|
private FaceDetector zzayl;
|
||
|
private FaceDetector zzaym;
|
||
|
|
||
|
public zzqa(FirebaseApp firebaseApp, FirebaseVisionFaceDetectorOptions firebaseVisionFaceDetectorOptions) {
|
||
|
Preconditions.checkNotNull(firebaseApp, "FirebaseApp can not be null");
|
||
|
Preconditions.checkNotNull(firebaseVisionFaceDetectorOptions, "FirebaseVisionFaceDetectorOptions can not be null");
|
||
|
this.zzad = firebaseApp.getApplicationContext();
|
||
|
this.zzaye = firebaseVisionFaceDetectorOptions;
|
||
|
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.zzaye.getContourMode() == 2) {
|
||
|
if (this.zzaym == null) {
|
||
|
this.zzaym = new FaceDetector.Builder(this.zzad).setLandmarkType(2).setMode(2).setTrackingEnabled(false).setProminentFaceOnly(true).build();
|
||
|
}
|
||
|
if ((this.zzaye.getLandmarkMode() == 2 || this.zzaye.getClassificationMode() == 2 || this.zzaye.getPerformanceMode() == 2) && this.zzayl == null) {
|
||
|
this.zzayl = new FaceDetector.Builder(this.zzad).setLandmarkType(zzpv.zzbn(this.zzaye.getLandmarkMode())).setClassificationType(zzpv.zzbp(this.zzaye.getClassificationMode())).setMode(zzpv.zzbo(this.zzaye.getPerformanceMode())).setMinFaceSize(this.zzaye.getMinFaceSize()).setTrackingEnabled(this.zzaye.isTrackingEnabled()).build();
|
||
|
}
|
||
|
} else if (this.zzayl == null) {
|
||
|
this.zzayl = new FaceDetector.Builder(this.zzad).setLandmarkType(zzpv.zzbn(this.zzaye.getLandmarkMode())).setClassificationType(zzpv.zzbp(this.zzaye.getClassificationMode())).setMode(zzpv.zzbo(this.zzaye.getPerformanceMode())).setMinFaceSize(this.zzaye.getMinFaceSize()).setTrackingEnabled(this.zzaye.isTrackingEnabled()).build();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Override // com.google.android.gms.internal.firebase_ml.zznw
|
||
|
public final void release() {
|
||
|
synchronized (this) {
|
||
|
FaceDetector faceDetector = this.zzayl;
|
||
|
if (faceDetector != null) {
|
||
|
faceDetector.release();
|
||
|
this.zzayl = null;
|
||
|
}
|
||
|
FaceDetector faceDetector2 = this.zzaym;
|
||
|
if (faceDetector2 != null) {
|
||
|
faceDetector2.release();
|
||
|
this.zzaym = null;
|
||
|
}
|
||
|
zzato.set(true);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private final List<FirebaseVisionFace> zza(FaceDetector faceDetector, zzpz zzpzVar, long j) throws FirebaseMLException {
|
||
|
ArrayList arrayList;
|
||
|
synchronized (this) {
|
||
|
if (this.zzaym != null) {
|
||
|
if (zzaub == null) {
|
||
|
zzaub = Boolean.valueOf(DynamiteModule.getLocalVersion(this.zzad, ModuleDescriptor.MODULE_ID) > 0);
|
||
|
}
|
||
|
if (!zzaub.booleanValue()) {
|
||
|
throw new FirebaseMLException("No Face Contour model is bundled. Please check your app setup to include firebase-ml-vision-face-model dependency.", 14);
|
||
|
}
|
||
|
}
|
||
|
if (!faceDetector.isOperational()) {
|
||
|
zza(zzmk.MODEL_NOT_DOWNLOADED, j, zzpzVar, 0, 0);
|
||
|
throw new FirebaseMLException("Waiting for the face detection model to be downloaded. Please wait.", 14);
|
||
|
}
|
||
|
SparseArray<Face> detect = faceDetector.detect(zzpzVar.zzaxe);
|
||
|
arrayList = new ArrayList();
|
||
|
for (int i = 0; i < detect.size(); i++) {
|
||
|
arrayList.add(new FirebaseVisionFace(detect.get(detect.keyAt(i))));
|
||
|
}
|
||
|
}
|
||
|
return arrayList;
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: private */
|
||
|
/* JADX WARN: Code restructure failed: missing block: B:26:0x005c, code lost:
|
||
|
|
||
|
r5 = r2;
|
||
|
*/
|
||
|
/* JADX WARN: Removed duplicated region for block: B:30:0x012a */
|
||
|
/* JADX WARN: Removed duplicated region for block: B:32:0x0133 */
|
||
|
/* JADX WARN: Removed duplicated region for block: B:36:0x0135 A[Catch: all -> 0x014c, TryCatch #0 {, blocks: (B:4:0x0005, B:6:0x000f, B:9:0x0014, B:10:0x0026, B:12:0x0027, B:14:0x0031, B:16:0x003d, B:17:0x0042, B:19:0x0046, B:23:0x0052, B:24:0x0059, B:28:0x0126, B:33:0x013a, B:36:0x0135, B:37:0x012c, B:40:0x0066, B:41:0x006f, B:43:0x0075, B:44:0x0080, B:46:0x0086, B:48:0x0092, B:51:0x0099, B:53:0x00a7, B:55:0x00f4, B:57:0x0102, B:64:0x0114, B:69:0x011f), top: B:3:0x0005 }] */
|
||
|
/* JADX WARN: Removed duplicated region for block: B:37:0x012c A[Catch: all -> 0x014c, TryCatch #0 {, blocks: (B:4:0x0005, B:6:0x000f, B:9:0x0014, B:10:0x0026, B:12:0x0027, B:14:0x0031, B:16:0x003d, B:17:0x0042, B:19:0x0046, B:23:0x0052, B:24:0x0059, B:28:0x0126, B:33:0x013a, B:36:0x0135, B:37:0x012c, B:40:0x0066, B:41:0x006f, B:43:0x0075, B:44:0x0080, B:46:0x0086, B:48:0x0092, B:51:0x0099, B:53:0x00a7, B:55:0x00f4, B:57:0x0102, B:64:0x0114, B:69:0x011f), top: B:3:0x0005 }] */
|
||
|
@Override // com.google.android.gms.internal.firebase_ml.zznm
|
||
|
/*
|
||
|
Code decompiled incorrectly, please refer to instructions dump.
|
||
|
To view partially-correct add '--show-bad-code' argument
|
||
|
*/
|
||
|
public final java.util.List<com.google.firebase.ml.vision.face.FirebaseVisionFace> zza(com.google.android.gms.internal.firebase_ml.zzpz r20) throws com.google.firebase.ml.common.FirebaseMLException {
|
||
|
/*
|
||
|
Method dump skipped, instructions count: 335
|
||
|
To view this dump add '--comments-level debug' option
|
||
|
*/
|
||
|
throw new UnsupportedOperationException("Method not decompiled: com.google.android.gms.internal.firebase_ml.zzqa.zza(com.google.android.gms.internal.firebase_ml.zzpz):java.util.List");
|
||
|
}
|
||
|
|
||
|
private static void zzh(List<FirebaseVisionFace> list) {
|
||
|
Iterator<FirebaseVisionFace> it = list.iterator();
|
||
|
while (it.hasNext()) {
|
||
|
it.next().zzbr(-1);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private final void zza(final zzmk zzmkVar, final long j, final zzpz zzpzVar, final int i, final int i2) {
|
||
|
synchronized (this) {
|
||
|
this.zzaqs.zza(new zznv(this, j, zzmkVar, i, i2, zzpzVar) { // from class: com.google.android.gms.internal.firebase_ml.zzqb
|
||
|
private final long zzatf;
|
||
|
private final zzmk zzawe;
|
||
|
private final zzqa zzayn;
|
||
|
private final int zzayo;
|
||
|
private final int zzayp;
|
||
|
private final zzpz zzayq;
|
||
|
|
||
|
@Override // com.google.android.gms.internal.firebase_ml.zznv
|
||
|
public final zzmd.zzq.zza zzm() {
|
||
|
return this.zzayn.zza(this.zzatf, this.zzawe, this.zzayo, this.zzayp, this.zzayq);
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
{
|
||
|
this.zzayn = this;
|
||
|
this.zzatf = j;
|
||
|
this.zzawe = zzmkVar;
|
||
|
this.zzayo = i;
|
||
|
this.zzayp = i2;
|
||
|
this.zzayq = zzpzVar;
|
||
|
}
|
||
|
}, zzmn.ON_DEVICE_FACE_DETECT);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public final /* synthetic */ zzmd.zzq.zza zza(long j, zzmk zzmkVar, int i, int i2, zzpz zzpzVar) {
|
||
|
return zzmd.zzq.zzjx().zzb(zzmd.zzw.zzkk().zzd(zzmd.zzs.zzkb().zzn(SystemClock.elapsedRealtime() - j).zzc(zzmkVar).zzz(zzato.get()).zzaa(true).zzab(true)).zzb(this.zzaye.zznn()).zzbc(i).zzbd(i2).zzc(zzpv.zzc(zzpzVar)));
|
||
|
}
|
||
|
}
|