what-the-bank/sources/com/kofax/mobile/sdk/extract/id/QuickExtractorAgent.java

191 lines
7.1 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package com.kofax.mobile.sdk.extract.id;
import android.content.Context;
import bolts.Continuation;
import bolts.Task;
import com.kofax.kmc.ken.engines.data.Image;
import com.kofax.mobile.sdk._internal.IBus;
import com.kofax.mobile.sdk._internal.dagger.Injector;
import com.kofax.mobile.sdk._internal.impl.event.PreviewImageReadyBusEvent;
import com.kofax.mobile.sdk._internal.impl.event.aa;
import com.kofax.mobile.sdk._internal.impl.event.ap;
import com.kofax.mobile.sdk._internal.impl.event.p;
import com.kofax.mobile.sdk._internal.impl.extraction.onDevice.quick.BufferedQuickBarcodeExtractor;
import com.kofax.mobile.sdk._internal.impl.extraction.onDevice.quick.BufferedQuickFaceExtractor;
import com.kofax.mobile.sdk._internal.impl.extraction.onDevice.quick.BufferedQuickMrzExtractor;
import com.kofax.mobile.sdk._internal.impl.extraction.onDevice.quick.f;
import com.kofax.mobile.sdk._internal.k;
import java.util.concurrent.Callable;
import java.util.concurrent.atomic.AtomicBoolean;
import o.InterfaceC13006fNs;
/* loaded from: classes3.dex */
public final class QuickExtractorAgent {
private static final String TAG = "QuickExtractorAgent";
private final BufferedQuickMrzExtractor aeE;
private final BufferedQuickBarcodeExtractor aeF;
private final BufferedQuickFaceExtractor aeG;
private final QuickExtractorAgentListener aeH;
private final IBus aeI;
private final a aeJ;
private Task<Void> aeK;
private Task<Void> aeL;
private final AtomicBoolean aeM;
private Task<Void> aeN;
private final AtomicBoolean aeO;
public QuickExtractorAgent(Context context, QuickExtractorSettings quickExtractorSettings, QuickExtractorAgentListener quickExtractorAgentListener) {
this(new BufferedQuickMrzExtractor(), new BufferedQuickBarcodeExtractor(quickExtractorSettings.getBarcodes()), new BufferedQuickFaceExtractor(context, quickExtractorSettings), quickExtractorAgentListener, Injector.getInjector(context).getIBus());
}
QuickExtractorAgent(BufferedQuickMrzExtractor bufferedQuickMrzExtractor, BufferedQuickBarcodeExtractor bufferedQuickBarcodeExtractor, BufferedQuickFaceExtractor bufferedQuickFaceExtractor, QuickExtractorAgentListener quickExtractorAgentListener, IBus iBus) {
a aVar = new a();
this.aeJ = aVar;
this.aeK = Task.forResult((Object) null);
this.aeL = Task.forResult((Object) null);
this.aeM = new AtomicBoolean();
this.aeN = Task.forResult((Object) null);
this.aeO = new AtomicBoolean();
this.aeE = bufferedQuickMrzExtractor;
this.aeF = bufferedQuickBarcodeExtractor;
this.aeG = bufferedQuickFaceExtractor;
this.aeH = quickExtractorAgentListener;
this.aeI = iBus;
iBus.register(aVar);
}
public final void destroy() {
this.aeM.set(true);
this.aeO.set(true);
this.aeI.unregister(this.aeJ);
this.aeE.destroy();
this.aeF.destroy();
this.aeG.destroy();
}
/* JADX INFO: Access modifiers changed from: private */
public void h(PreviewImageReadyBusEvent previewImageReadyBusEvent) {
if (this.aeM.get()) {
return;
}
if (this.aeK.isCompleted()) {
this.aeK = this.aeE.extract(previewImageReadyBusEvent).continueWithTask(a(this.aeM));
} else {
k.b(TAG, "MRZ extractor is busy");
}
if (this.aeL.isCompleted()) {
this.aeL = this.aeF.extract(previewImageReadyBusEvent).continueWithTask(a(this.aeM));
} else {
k.b(TAG, "Barcode extractor is busy");
}
}
/* JADX INFO: Access modifiers changed from: private */
public void i(PreviewImageReadyBusEvent previewImageReadyBusEvent) {
if (this.aeO.get()) {
return;
}
if (this.aeN.isCompleted()) {
this.aeN = this.aeG.extract(previewImageReadyBusEvent).continueWithTask(a(this.aeO));
} else {
k.b(TAG, "Face extractor is busy");
}
}
private Continuation<f, Task<Void>> a(AtomicBoolean atomicBoolean) {
return new Continuation<f, Task<Void>>(this, atomicBoolean) { // from class: com.kofax.mobile.sdk.extract.id.QuickExtractorAgent.1
final AtomicBoolean aeP;
final QuickExtractorAgent aeQ;
{
this.aeQ = this;
this.aeP = atomicBoolean;
}
/* renamed from: then, reason: collision with other method in class */
public /* bridge */ /* synthetic */ Object m293then(Task task) throws Exception {
return then((Task<f>) task);
}
public Task<Void> then(Task<f> task) {
Exception error = task.getError();
if (error != null) {
k.b(QuickExtractorAgent.TAG, "Exception", (Throwable) error);
}
f fVar = (f) task.getResult();
if (fVar != null && this.aeP.compareAndSet(false, true)) {
return this.aeQ.b(fVar);
}
return Task.forResult((Object) null);
}
};
}
/* JADX INFO: Access modifiers changed from: private */
public Task<Void> b(f fVar) {
return Task.call(new Callable<Void>(this, fVar) { // from class: com.kofax.mobile.sdk.extract.id.QuickExtractorAgent.2
final QuickExtractorAgent aeQ;
final f aeR;
{
this.aeQ = this;
this.aeR = fVar;
}
@Override // java.util.concurrent.Callable
public Void call() {
Image qi = this.aeR.qi();
if (qi != null) {
this.aeQ.aeH.onFaceExtracted(qi, this.aeR.qj());
return null;
}
this.aeQ.aeH.onFieldsExtracted(this.aeR.getFields(), this.aeR.qj());
return null;
}
}, Task.UI_THREAD_EXECUTOR);
}
/* loaded from: classes3.dex */
class a {
private volatile boolean II;
private volatile boolean Ix;
private volatile boolean Jf;
final QuickExtractorAgent aeQ;
private a(QuickExtractorAgent quickExtractorAgent) {
this.aeQ = quickExtractorAgent;
}
@InterfaceC13006fNs
public void c(aa aaVar) {
this.II = aaVar.II;
}
@InterfaceC13006fNs
public void a(p pVar) {
this.Ix = pVar.mn();
}
@InterfaceC13006fNs
public void d(ap apVar) {
this.Jf = apVar.Jf;
}
@InterfaceC13006fNs
public void j(PreviewImageReadyBusEvent previewImageReadyBusEvent) {
if (!this.II) {
k.b(QuickExtractorAgent.TAG, "Not focused");
return;
}
if (!this.Ix) {
k.b(QuickExtractorAgent.TAG, "Not stable");
} else if (this.Jf) {
this.aeQ.h(previewImageReadyBusEvent);
this.aeQ.i(previewImageReadyBusEvent);
} else {
k.b(QuickExtractorAgent.TAG, "No document");
}
}
}
}