158 lines
5.8 KiB
Java
158 lines
5.8 KiB
Java
package com.kofax.mobile.sdk.h;
|
|
|
|
import android.graphics.Bitmap;
|
|
import android.util.Base64;
|
|
import bolts.Task;
|
|
import com.kofax.kmc.ken.engines.data.BarCodeDataFormat;
|
|
import com.kofax.kmc.ken.engines.data.BarCodeDirection;
|
|
import com.kofax.kmc.ken.engines.data.BarCodeResult;
|
|
import com.kofax.kmc.ken.engines.data.BarCodeType;
|
|
import com.kofax.kmc.ken.engines.data.BoundingTetragon;
|
|
import com.kofax.kmc.ken.engines.data.Image;
|
|
import com.kofax.kmc.kui.uicontrols.Utility;
|
|
import com.kofax.kmc.kut.utilities.error.KmcException;
|
|
import com.kofax.kmc.kut.utilities.error.KmcRuntimeException;
|
|
import com.manateeworks.kfx.BarcodeScanner;
|
|
import java.nio.charset.Charset;
|
|
import java.util.Set;
|
|
import java.util.concurrent.Callable;
|
|
import o.InterfaceC13391fZD;
|
|
|
|
/* loaded from: classes3.dex */
|
|
public class e implements com.kofax.mobile.sdk.a.a {
|
|
private com.kofax.mobile.sdk._internal.f yO;
|
|
private static final Object yN = new Object();
|
|
private static final Charset US_ASCII = Charset.forName("US-ASCII");
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
@InterfaceC13391fZD
|
|
public e(com.kofax.mobile.sdk._internal.f fVar) {
|
|
if (fVar == null) {
|
|
throw new IllegalArgumentException("scaler cannot be null");
|
|
}
|
|
this.yO = fVar;
|
|
}
|
|
|
|
@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.e.1
|
|
final Image yB;
|
|
final Set yC;
|
|
final e yP;
|
|
|
|
{
|
|
this.yP = 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.yP.b(this.yB, this.yC);
|
|
}
|
|
});
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public BarCodeResult b(Image image, Set<BarCodeType> set) {
|
|
String encodeToString;
|
|
BarCodeDataFormat barCodeDataFormat;
|
|
synchronized (yN) {
|
|
try {
|
|
b(set);
|
|
Bitmap a = this.yO.a(image, 1000, 1000);
|
|
byte[] scanGrayscaleImage = BarcodeScanner.scanGrayscaleImage(Utility.imageToGray(a), a.getWidth(), a.getHeight());
|
|
if (scanGrayscaleImage != null && scanGrayscaleImage.length >= 4) {
|
|
if (e(scanGrayscaleImage)) {
|
|
encodeToString = new String(scanGrayscaleImage, US_ASCII);
|
|
barCodeDataFormat = BarCodeDataFormat.ASCII;
|
|
} else {
|
|
encodeToString = Base64.encodeToString(scanGrayscaleImage, 0);
|
|
barCodeDataFormat = BarCodeDataFormat.BASE_64;
|
|
}
|
|
BarCodeResult barCodeResult = new BarCodeResult();
|
|
barCodeResult.setBoundingBox(iR());
|
|
barCodeResult.setDirection(BarCodeDirection.UNKNOWN);
|
|
barCodeResult.setType(iQ());
|
|
barCodeResult.setValue(encodeToString);
|
|
barCodeResult.setDataFormat(barCodeDataFormat);
|
|
return barCodeResult;
|
|
}
|
|
return null;
|
|
} catch (KmcException e) {
|
|
throw new KmcRuntimeException(e.getErrorInfo());
|
|
}
|
|
}
|
|
}
|
|
|
|
private void b(Set<BarCodeType> set) {
|
|
int i;
|
|
if (set.contains(BarCodeType.PDF417)) {
|
|
i = 64;
|
|
BarcodeScanner.registerCode(64, "Kofax.Android.PDF.UDL", "5A52C54FD2EEB8A9DC6599740ABB69E6B397378ADBE1CE342517D4700C9F56AD");
|
|
} else {
|
|
i = 0;
|
|
}
|
|
if (set.contains(BarCodeType.QR)) {
|
|
BarcodeScanner.registerCode(1, "Kofax.Android.QR.UDL", "5C44241E3E38A6E3BFBA3FB5949112DA91544173A67BFA58B622123B0C5341BC");
|
|
i |= 1;
|
|
}
|
|
if (set.contains(BarCodeType.CODE39)) {
|
|
BarcodeScanner.registerCode(8, "Kofax.Android.C39.UDL", "2DBAB7E1F20796746AFA20069DE9F5B7C2D5CAA2F63A86BB6B89634D6C4336DD");
|
|
i |= 8;
|
|
}
|
|
BarcodeScanner.setActiveCodes(i);
|
|
BarcodeScanner.setLevel(5);
|
|
}
|
|
|
|
private static boolean e(byte[] bArr) {
|
|
for (byte b : bArr) {
|
|
if (b < 32 || b >= Byte.MAX_VALUE) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
private static BarCodeType iQ() {
|
|
int lastType = BarcodeScanner.getLastType();
|
|
if (lastType == 1) {
|
|
return BarCodeType.DATAMATRIX;
|
|
}
|
|
if (lastType == 2) {
|
|
return BarCodeType.CODE39;
|
|
}
|
|
switch (lastType) {
|
|
case 7:
|
|
case 8:
|
|
return BarCodeType.EAN;
|
|
case 9:
|
|
case 10:
|
|
return BarCodeType.UPC;
|
|
case 11:
|
|
return BarCodeType.CODE128;
|
|
case 12:
|
|
return BarCodeType.PDF417;
|
|
case 13:
|
|
return BarCodeType.QR;
|
|
case 14:
|
|
return BarCodeType.AZTEC;
|
|
case 15:
|
|
case 16:
|
|
return BarCodeType.CODE25;
|
|
case 17:
|
|
return BarCodeType.CODE93;
|
|
case 18:
|
|
return BarCodeType.CODABAR;
|
|
default:
|
|
return BarCodeType.UNKNOWN;
|
|
}
|
|
}
|
|
|
|
private BoundingTetragon iR() {
|
|
float[] barcodeLocation = BarcodeScanner.getBarcodeLocation();
|
|
return new BoundingTetragon((int) barcodeLocation[0], (int) barcodeLocation[1], (int) barcodeLocation[2], (int) barcodeLocation[3], (int) barcodeLocation[6], (int) barcodeLocation[7], (int) barcodeLocation[4], (int) barcodeLocation[5]);
|
|
}
|
|
}
|