144 lines
5.5 KiB
Java
144 lines
5.5 KiB
Java
|
package com.kofax.mobile.sdk.h;
|
||
|
|
||
|
import bolts.Capture;
|
||
|
import bolts.Task;
|
||
|
import com.kofax.kmc.ken.engines.BarCodeReader;
|
||
|
import com.kofax.kmc.ken.engines.data.BarCodeDataFormat;
|
||
|
import com.kofax.kmc.ken.engines.data.BarCodeResult;
|
||
|
import com.kofax.kmc.ken.engines.data.BarCodeType;
|
||
|
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 java.util.Collections;
|
||
|
import java.util.HashMap;
|
||
|
import java.util.Iterator;
|
||
|
import java.util.List;
|
||
|
import java.util.Map;
|
||
|
import java.util.Set;
|
||
|
import java.util.concurrent.Callable;
|
||
|
import java.util.concurrent.CountDownLatch;
|
||
|
import o.InterfaceC13391fZD;
|
||
|
|
||
|
/* loaded from: classes3.dex */
|
||
|
public class a implements com.kofax.mobile.sdk.a.a {
|
||
|
private static final Object yy = new Object();
|
||
|
private static final Map<BarCodeType, BarCodeReader.Symbology> yz;
|
||
|
private final g wM;
|
||
|
private final com.kofax.mobile.sdk._internal.b yA;
|
||
|
|
||
|
static {
|
||
|
HashMap hashMap = new HashMap();
|
||
|
hashMap.put(BarCodeType.PDF417, BarCodeReader.Symbology.Pdf417);
|
||
|
hashMap.put(BarCodeType.QR, BarCodeReader.Symbology.QRCode);
|
||
|
hashMap.put(BarCodeType.CODE39, BarCodeReader.Symbology.Code39);
|
||
|
yz = Collections.unmodifiableMap(hashMap);
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
@InterfaceC13391fZD
|
||
|
public a(com.kofax.mobile.sdk._internal.b bVar, g gVar) {
|
||
|
this.yA = bVar;
|
||
|
this.wM = gVar;
|
||
|
}
|
||
|
|
||
|
@Override // com.kofax.mobile.sdk.a.a
|
||
|
public Task<BarCodeResult> a(Image image, Set<BarCodeType> set) {
|
||
|
return Task.callInBackground(new Callable<BarCodeResult>(this, image, set) { // from class: com.kofax.mobile.sdk.h.a.1
|
||
|
final Image yB;
|
||
|
final Set yC;
|
||
|
final a yD;
|
||
|
|
||
|
{
|
||
|
this.yD = this;
|
||
|
this.yB = image;
|
||
|
this.yC = set;
|
||
|
}
|
||
|
|
||
|
@Override // java.util.concurrent.Callable
|
||
|
/* renamed from: iN, reason: merged with bridge method [inline-methods] */
|
||
|
public BarCodeResult call() throws Exception {
|
||
|
return this.yD.b(this.yB, this.yC);
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: private */
|
||
|
public BarCodeResult b(Image image, Set<BarCodeType> set) {
|
||
|
BarCodeResult barCodeResult;
|
||
|
synchronized (yy) {
|
||
|
BarCodeReader.Symbology[] a = a(set);
|
||
|
BarCodeReader barCodeReader = new BarCodeReader(a, BarCodeReader.Direction.ALL, a.length);
|
||
|
CountDownLatch countDownLatch = new CountDownLatch(1);
|
||
|
Capture capture = new Capture();
|
||
|
barCodeReader.addBarcodeReadCompleteEventListener(new BarCodeReader.BarcodeReadCompleteListener(this, capture, barCodeReader, countDownLatch) { // from class: com.kofax.mobile.sdk.h.a.2
|
||
|
final a yD;
|
||
|
final Capture yE;
|
||
|
final BarCodeReader yF;
|
||
|
final CountDownLatch yG;
|
||
|
|
||
|
{
|
||
|
this.yD = this;
|
||
|
this.yE = capture;
|
||
|
this.yF = barCodeReader;
|
||
|
this.yG = countDownLatch;
|
||
|
}
|
||
|
|
||
|
@Override // com.kofax.kmc.ken.engines.BarCodeReader.BarcodeReadCompleteListener
|
||
|
public void barcodeReadComplete(BarCodeReader.BarcodeReadCompleteEvent barcodeReadCompleteEvent) {
|
||
|
try {
|
||
|
if (barcodeReadCompleteEvent.getStatus().equals(ErrorInfo.KMC_SUCCESS)) {
|
||
|
this.yE.set(this.yD.a(barcodeReadCompleteEvent));
|
||
|
return;
|
||
|
}
|
||
|
throw new KmcRuntimeException(barcodeReadCompleteEvent.getStatus());
|
||
|
} finally {
|
||
|
this.yF.removeBarcodeReadCompleteEventListener(this);
|
||
|
this.yG.countDown();
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
g.a w = this.wM.w(image);
|
||
|
try {
|
||
|
try {
|
||
|
barCodeReader.readBarcodes(new Image(w.getBitmap()));
|
||
|
countDownLatch.await();
|
||
|
w.be();
|
||
|
barCodeResult = (BarCodeResult) capture.get();
|
||
|
} catch (Exception e) {
|
||
|
throw new RuntimeException(e);
|
||
|
}
|
||
|
} catch (Throwable th) {
|
||
|
w.be();
|
||
|
throw th;
|
||
|
}
|
||
|
}
|
||
|
return barCodeResult;
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: private */
|
||
|
public BarCodeResult a(BarCodeReader.BarcodeReadCompleteEvent barcodeReadCompleteEvent) {
|
||
|
List<BarCodeResult> imageBarCodes = barcodeReadCompleteEvent.getImage().getImageBarCodes();
|
||
|
if (imageBarCodes.isEmpty()) {
|
||
|
return null;
|
||
|
}
|
||
|
BarCodeResult barCodeResult = imageBarCodes.get(0);
|
||
|
if (barCodeResult.getDataFormat() != BarCodeDataFormat.BASE_64) {
|
||
|
return barCodeResult;
|
||
|
}
|
||
|
barCodeResult.setValue(this.yA.decode(barCodeResult.getValue()));
|
||
|
return barCodeResult;
|
||
|
}
|
||
|
|
||
|
private static BarCodeReader.Symbology[] a(Set<BarCodeType> set) {
|
||
|
BarCodeReader.Symbology[] symbologyArr = new BarCodeReader.Symbology[set.size()];
|
||
|
Iterator<BarCodeType> it = set.iterator();
|
||
|
int i = 0;
|
||
|
while (it.hasNext()) {
|
||
|
symbologyArr[i] = yz.get(it.next());
|
||
|
i++;
|
||
|
}
|
||
|
return symbologyArr;
|
||
|
}
|
||
|
}
|