157 lines
6.0 KiB
Java
157 lines
6.0 KiB
Java
|
package com.kofax.mobile.sdk.extract.id;
|
||
|
|
||
|
import android.content.Context;
|
||
|
import android.graphics.Bitmap;
|
||
|
import bolts.Continuation;
|
||
|
import bolts.Task;
|
||
|
import com.kofax.kmc.ken.engines.data.Image;
|
||
|
import com.kofax.kmc.kut.utilities.error.ErrorInfo;
|
||
|
import com.kofax.kmc.kut.utilities.error.KmcRuntimeException;
|
||
|
import com.kofax.mobile.sdk._internal.g;
|
||
|
import com.kofax.mobile.sdk._internal.impl.extraction.onDevice.quick.b;
|
||
|
import com.kofax.mobile.sdk._internal.impl.extraction.onDevice.quick.d;
|
||
|
import com.kofax.mobile.sdk._internal.impl.extraction.onDevice.quick.e;
|
||
|
import com.kofax.mobile.sdk._internal.impl.extraction.onDevice.quick.f;
|
||
|
import com.kofax.mobile.sdk._internal.impl.extraction.onDevice.quick.g;
|
||
|
import com.kofax.mobile.sdk._internal.impl.extraction.onDevice.quick.h;
|
||
|
import com.kofax.mobile.sdk._internal.impl.u;
|
||
|
import com.kofax.mobile.sdk.al.a;
|
||
|
import java.util.ArrayList;
|
||
|
import java.util.Arrays;
|
||
|
import java.util.LinkedHashSet;
|
||
|
import java.util.List;
|
||
|
import java.util.concurrent.Callable;
|
||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||
|
|
||
|
/* loaded from: classes3.dex */
|
||
|
public class QuickExtractor {
|
||
|
private static final String TAG = "QuickExtractor";
|
||
|
private final d aeu;
|
||
|
private final g aev;
|
||
|
private final u aes = new u();
|
||
|
private final AtomicBoolean aew = new AtomicBoolean(false);
|
||
|
private final AtomicBoolean aex = new AtomicBoolean(false);
|
||
|
private final h aet = new h();
|
||
|
|
||
|
public QuickExtractor(Context context, QuickExtractorSettings quickExtractorSettings) {
|
||
|
this.aeu = new d(quickExtractorSettings.getBarcodes());
|
||
|
this.aev = new g(context, quickExtractorSettings);
|
||
|
}
|
||
|
|
||
|
public void destroy() {
|
||
|
if (this.aex.compareAndSet(false, true)) {
|
||
|
this.aet.destroy();
|
||
|
this.aeu.destroy();
|
||
|
this.aev.destroy();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public void extract(Image image, QuickExtractorListener quickExtractorListener) {
|
||
|
if (this.aex.get()) {
|
||
|
throw new IllegalStateException("Destroyed");
|
||
|
}
|
||
|
if (!this.aew.compareAndSet(false, true)) {
|
||
|
throw new KmcRuntimeException(ErrorInfo.KMC_EV_PROCESS_PAGE_BUSY);
|
||
|
}
|
||
|
g.a w = this.aes.w(image);
|
||
|
try {
|
||
|
a(w.getBitmap(), quickExtractorListener);
|
||
|
} finally {
|
||
|
w.be();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void a(Bitmap bitmap, QuickExtractorListener quickExtractorListener) {
|
||
|
b bVar = new b(bitmap, 0);
|
||
|
Task callInBackground = Task.callInBackground(new Callable<f>(this, bVar) { // from class: com.kofax.mobile.sdk.extract.id.QuickExtractor.1
|
||
|
final e aey;
|
||
|
final QuickExtractor aez;
|
||
|
|
||
|
{
|
||
|
this.aez = this;
|
||
|
this.aey = bVar;
|
||
|
}
|
||
|
|
||
|
@Override // java.util.concurrent.Callable
|
||
|
/* renamed from: qh, reason: merged with bridge method [inline-methods] */
|
||
|
public f call() {
|
||
|
return this.aez.aet.a(this.aey);
|
||
|
}
|
||
|
});
|
||
|
Task callInBackground2 = Task.callInBackground(new Callable<f>(this, bVar) { // from class: com.kofax.mobile.sdk.extract.id.QuickExtractor.2
|
||
|
final e aey;
|
||
|
final QuickExtractor aez;
|
||
|
|
||
|
{
|
||
|
this.aez = this;
|
||
|
this.aey = bVar;
|
||
|
}
|
||
|
|
||
|
@Override // java.util.concurrent.Callable
|
||
|
/* renamed from: qh, reason: merged with bridge method [inline-methods] */
|
||
|
public f call() {
|
||
|
return this.aez.aeu.a(this.aey);
|
||
|
}
|
||
|
});
|
||
|
Task callInBackground3 = Task.callInBackground(new Callable<f>(this, bVar) { // from class: com.kofax.mobile.sdk.extract.id.QuickExtractor.3
|
||
|
final e aey;
|
||
|
final QuickExtractor aez;
|
||
|
|
||
|
{
|
||
|
this.aez = this;
|
||
|
this.aey = bVar;
|
||
|
}
|
||
|
|
||
|
@Override // java.util.concurrent.Callable
|
||
|
/* renamed from: qh, reason: merged with bridge method [inline-methods] */
|
||
|
public f call() {
|
||
|
return this.aez.aev.a(this.aey);
|
||
|
}
|
||
|
});
|
||
|
Task.whenAll(Arrays.asList(callInBackground, callInBackground2, callInBackground3)).continueWith(new Continuation<Void, Void>(this, callInBackground, callInBackground2, callInBackground3, quickExtractorListener) { // from class: com.kofax.mobile.sdk.extract.id.QuickExtractor.4
|
||
|
final Task aeA;
|
||
|
final Task aeB;
|
||
|
final Task aeC;
|
||
|
final QuickExtractorListener aeD;
|
||
|
final QuickExtractor aez;
|
||
|
|
||
|
{
|
||
|
this.aez = this;
|
||
|
this.aeA = callInBackground;
|
||
|
this.aeB = callInBackground2;
|
||
|
this.aeC = callInBackground3;
|
||
|
this.aeD = quickExtractorListener;
|
||
|
}
|
||
|
|
||
|
public /* bridge */ /* synthetic */ Object then(Task task) throws Exception {
|
||
|
return m292then((Task<Void>) task);
|
||
|
}
|
||
|
|
||
|
/* renamed from: then, reason: collision with other method in class */
|
||
|
public Void m292then(Task<Void> task) {
|
||
|
f fVar = (f) this.aeA.getResult();
|
||
|
f fVar2 = (f) this.aeB.getResult();
|
||
|
f fVar3 = (f) this.aeC.getResult();
|
||
|
List<DataField> a = QuickExtractor.a(fVar, fVar2);
|
||
|
Image qi = fVar3 == null ? null : fVar3.qi();
|
||
|
this.aez.aew.set(false);
|
||
|
if (!this.aez.aex.get()) {
|
||
|
this.aeD.onExtractionComplete(a, qi, task.getError());
|
||
|
}
|
||
|
return null;
|
||
|
}
|
||
|
}, Task.UI_THREAD_EXECUTOR).continueWithTask(new a(TAG), Task.BACKGROUND_EXECUTOR);
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: private */
|
||
|
public static List<DataField> a(f... fVarArr) {
|
||
|
LinkedHashSet linkedHashSet = new LinkedHashSet();
|
||
|
for (f fVar : fVarArr) {
|
||
|
if (fVar != null && fVar.getFields() != null) {
|
||
|
linkedHashSet.addAll(fVar.getFields());
|
||
|
}
|
||
|
}
|
||
|
return new ArrayList(linkedHashSet);
|
||
|
}
|
||
|
}
|