what-the-bank/sources/com/kofax/kmc/ken/engines/BarCodeReader.java

471 lines
18 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package com.kofax.kmc.ken.engines;
import android.graphics.Bitmap;
import android.os.Handler;
import android.os.Looper;
import com.kofax.kmc.ken.engines.data.BarCodeType;
import com.kofax.kmc.ken.engines.data.Image;
import com.kofax.kmc.kut.utilities.Licensing;
import com.kofax.kmc.kut.utilities.error.ErrorInfo;
import com.kofax.kmc.kut.utilities.error.KmcException;
import com.kofax.kmc.kut.utilities.error.KmcRuntimeException;
import java.util.ArrayList;
import java.util.EventObject;
import java.util.List;
import org.bouncycastle.asn1.cmp.PKIFailureInfo;
/* loaded from: classes3.dex */
public class BarCodeReader {
private static volatile boolean a;
private Symbology[] _symbology;
private int b;
private Direction c;
private ErrorInfo e;
private final Handler d = new Handler(Looper.getMainLooper());
private final ArrayList<BarcodeReadCompleteListener> f = new ArrayList<>();
/* loaded from: classes3.dex */
public interface BarcodeReadCompleteListener {
void barcodeReadComplete(BarcodeReadCompleteEvent barcodeReadCompleteEvent);
}
public BarCodeReader() {
a(1);
this._symbology = new Symbology[0];
this.c = Direction.ALL;
}
public BarCodeReader(Symbology[] symbologyArr, Direction direction, int i) {
a(i);
if (symbologyArr == null) {
this._symbology = new Symbology[0];
}
this._symbology = symbologyArr;
if (direction == null) {
this.c = Direction.ALL;
}
this.c = direction;
}
public String getBcVersion() {
return new BarcodeReaderEngineManager().b();
}
public void readBarcodes(Image image) throws KmcException {
synchronized (this.d) {
if (a) {
throw new KmcException(ErrorInfo.KMC_BC_BUSY);
}
a = true;
}
try {
a(image);
} catch (KmcException e) {
a = false;
throw e;
} catch (KmcRuntimeException e2) {
a = false;
throw e2;
}
}
/* JADX INFO: Access modifiers changed from: private */
public Bitmap a(Bitmap bitmap) {
return Bitmap.createScaledBitmap(bitmap, (int) (bitmap.getWidth() * 2.0f), (int) (bitmap.getHeight() * 2.0f), true);
}
private void a(Image image) throws KmcException {
this.e = ErrorInfo.KMC_SUCCESS;
a();
ErrorInfo b = b(image);
this.e = b;
if (b != ErrorInfo.KMC_SUCCESS) {
throw new KmcException(this.e);
}
Image.ImageRep imageRepresentation = image.getImageRepresentation();
if (image.getImageRepresentation() == Image.ImageRep.IMAGE_REP_FILE) {
image.imageReadFromFile();
}
Bitmap imageBitmap = image.getImageBitmap();
a(image, imageRepresentation, imageBitmap, imageBitmap.getWidth(), imageBitmap.getHeight(), a(this._symbology), this.c.u, this.b, image.getImageOutputColor().getBitsPerPixel());
}
/* JADX INFO: Access modifiers changed from: package-private */
/* renamed from: com.kofax.kmc.ken.engines.BarCodeReader$1, reason: invalid class name */
/* loaded from: classes3.dex */
public class AnonymousClass1 extends Thread {
final Bitmap g;
final int h;
final int i;
final int j;
final int k;
final int l;
final int m;
final Image n;
/* renamed from: o, reason: collision with root package name */
final Image.ImageRep f6502o;
final BarCodeReader p;
AnonymousClass1(BarCodeReader barCodeReader, Bitmap bitmap, int i, int i2, int i3, int i4, int i5, int i6, Image image, Image.ImageRep imageRep) {
this.p = barCodeReader;
this.g = bitmap;
this.h = i;
this.i = i2;
this.j = i3;
this.k = i4;
this.l = i5;
this.m = i6;
this.n = image;
this.f6502o = imageRep;
}
@Override // java.lang.Thread, java.lang.Runnable
public void run() {
int i;
BarcodeReaderEngineManager barcodeReaderEngineManager = new BarcodeReaderEngineManager();
Symbology[] symbologyArr = {Symbology.QRCode};
Symbology[] symbologyArr2 = {Symbology.QRCode, Symbology.Pdf417};
int a = this.p.a(symbologyArr);
int a2 = this.p.a(symbologyArr2);
RecognitionContext a3 = barcodeReaderEngineManager.a(this.g, this.h, this.i, this.j, this.k, this.l, this.m);
int i2 = 1;
if (a3.getSymbolsFound() == 0 && (a == (i = this.j) || a2 == i)) {
Bitmap a4 = this.p.a(this.g);
a3 = barcodeReaderEngineManager.a(a4, a4.getWidth(), a4.getHeight(), a, this.k, this.l, this.m);
a4.recycle();
i2 = 2;
}
this.p.d.post(new Runnable(this, a3, i2) { // from class: com.kofax.kmc.ken.engines.BarCodeReader.1.1
final RecognitionContext q;
final int r;
final AnonymousClass1 s;
{
this.s = this;
this.q = a3;
this.r = i2;
}
@Override // java.lang.Runnable
public void run() {
ErrorInfo errorInfo = ErrorInfo.KMC_SUCCESS;
ArrayList arrayList = new ArrayList();
try {
RecognitionContext recognitionContext = this.q;
if (recognitionContext != null) {
if (recognitionContext.getBarcode().length == 0) {
errorInfo = this.s.p.a(this.q.getResultCode(), this.q);
}
arrayList.addAll(this.q.getBarCodeResults(this.r));
}
if (this.s.n.getImageBarCodes().size() > 0) {
this.s.n.getImageBarCodes().clear();
}
this.s.n.setImageBarCodes(arrayList);
if (this.s.f6502o == Image.ImageRep.IMAGE_REP_FILE) {
this.s.n.imageClearBitmap();
}
boolean unused = BarCodeReader.a = false;
a(this.s.n, errorInfo, this.s.p.f);
} catch (Throwable th) {
boolean unused2 = BarCodeReader.a = false;
throw th;
}
}
private void a(Image image, ErrorInfo errorInfo, List<BarcodeReadCompleteListener> list) {
if (list != null) {
for (BarcodeReadCompleteListener barcodeReadCompleteListener : list) {
if (barcodeReadCompleteListener != null) {
barcodeReadCompleteListener.barcodeReadComplete(new BarcodeReadCompleteEvent(this, errorInfo, image));
}
}
}
}
});
}
}
private void a(Image image, Image.ImageRep imageRep, Bitmap bitmap, int i, int i2, int i3, int i4, int i5, int i6) {
new AnonymousClass1(this, bitmap, i, i2, i3, i4, i5, i6, image, imageRep).start();
}
/* JADX WARN: Removed duplicated region for block: B:19:0x005c */
/* JADX WARN: Removed duplicated region for block: B:34:? A[RETURN, SYNTHETIC] */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
private com.kofax.kmc.kut.utilities.error.ErrorInfo b(com.kofax.kmc.ken.engines.data.Image r7) throws com.kofax.kmc.kut.utilities.error.KmcException {
/*
r6 = this;
com.kofax.kmc.kut.utilities.error.ErrorInfo r0 = com.kofax.kmc.kut.utilities.error.ErrorInfo.KMC_SUCCESS
if (r7 != 0) goto L7
com.kofax.kmc.kut.utilities.error.ErrorInfo r7 = com.kofax.kmc.kut.utilities.error.ErrorInfo.KMC_BC_INVALID_IMAGE
return r7
L7:
com.kofax.kmc.ken.engines.data.Image$OutputColor r1 = r7.getImageOutputColor()
int r1 = r1.getBitsPerPixel()
r2 = 1
if (r1 != r2) goto L14
com.kofax.kmc.kut.utilities.error.ErrorInfo r0 = com.kofax.kmc.kut.utilities.error.ErrorInfo.KMC_BC_INVALID_IMAGE
L14:
java.lang.Float r1 = r7.getImageBitmapScaling()
float r1 = r1.floatValue()
r3 = 1065353216(0x3f800000, float:1.0)
int r1 = (r1 > r3 ? 1 : (r1 == r3 ? 0 : -1))
r3 = 0
if (r1 >= 0) goto L25
r1 = r2
goto L26
L25:
r1 = r3
L26:
com.kofax.kmc.ken.engines.data.Image$ImageRep r4 = r7.getImageRepresentation()
com.kofax.kmc.ken.engines.data.Image$ImageRep r5 = com.kofax.kmc.ken.engines.data.Image.ImageRep.IMAGE_REP_BITMAP
if (r4 != r5) goto L38
if (r1 == 0) goto L58
com.kofax.kmc.kut.utilities.error.ErrorInfo r0 = com.kofax.kmc.kut.utilities.error.ErrorInfo.KMC_BC_NO_REPRESENTATION
java.lang.String r1 = "Only representation is bitmap but it is scaled down"
r0.setErrCause(r1)
goto L57
L38:
com.kofax.kmc.ken.engines.data.Image$ImageRep r4 = r7.getImageRepresentation()
com.kofax.kmc.ken.engines.data.Image$ImageRep r5 = com.kofax.kmc.ken.engines.data.Image.ImageRep.IMAGE_REP_FILE
if (r4 != r5) goto L4b
com.kofax.kmc.ken.engines.data.Image$ImageFileRep r1 = r7.getImageFileRep()
com.kofax.kmc.ken.engines.data.Image$ImageFileRep r2 = com.kofax.kmc.ken.engines.data.Image.ImageFileRep.FILE_BUFFERED
if (r1 != r2) goto L57
com.kofax.kmc.kut.utilities.error.ErrorInfo r0 = com.kofax.kmc.kut.utilities.error.ErrorInfo.KMC_BC_IMAGE_BUFFERED
goto L57
L4b:
com.kofax.kmc.ken.engines.data.Image$ImageRep r4 = r7.getImageRepresentation()
com.kofax.kmc.ken.engines.data.Image$ImageRep r5 = com.kofax.kmc.ken.engines.data.Image.ImageRep.IMAGE_REP_BOTH
if (r4 != r5) goto L55
r2 = r2 ^ r1
goto L58
L55:
com.kofax.kmc.kut.utilities.error.ErrorInfo r0 = com.kofax.kmc.kut.utilities.error.ErrorInfo.KMC_BC_NO_REPRESENTATION
L57:
r2 = r3
L58:
com.kofax.kmc.kut.utilities.error.ErrorInfo r1 = com.kofax.kmc.kut.utilities.error.ErrorInfo.KMC_SUCCESS
if (r0 != r1) goto L87
if (r2 == 0) goto L6c
android.graphics.Bitmap r7 = r7.getImageBitmap()
if (r7 != 0) goto L87
com.kofax.kmc.kut.utilities.error.ErrorInfo r0 = com.kofax.kmc.kut.utilities.error.ErrorInfo.KMC_ED_NOIMAGE
java.lang.String r7 = "imageBitmap field is null"
r0.setErrCause(r7)
goto L87
L6c:
java.lang.String r7 = r7.getImageFilePath()
if (r7 != 0) goto L7a
com.kofax.kmc.kut.utilities.error.ErrorInfo r0 = com.kofax.kmc.kut.utilities.error.ErrorInfo.KMC_ED_FILEPATH
java.lang.String r7 = "imageFilePath field is null"
r0.setErrCause(r7)
goto L87
L7a:
java.io.File r1 = new java.io.File
r1.<init>(r7)
boolean r7 = r1.exists()
if (r7 != 0) goto L87
com.kofax.kmc.kut.utilities.error.ErrorInfo r0 = com.kofax.kmc.kut.utilities.error.ErrorInfo.KMC_GN_FILE_NOT_FOUND
L87:
return r0
*/
throw new UnsupportedOperationException("Method not decompiled: com.kofax.kmc.ken.engines.BarCodeReader.b(com.kofax.kmc.ken.engines.data.Image):com.kofax.kmc.kut.utilities.error.ErrorInfo");
}
/* JADX INFO: Access modifiers changed from: private */
public int a(Symbology[] symbologyArr) {
int i = 0;
for (Symbology symbology : symbologyArr) {
i |= symbology.u;
}
return i;
}
/* JADX INFO: Access modifiers changed from: private */
public ErrorInfo a(int i, RecognitionContext recognitionContext) {
return i != 0 ? ErrorInfo.KMC_BC_UNKNOWN : ErrorInfo.KMC_SUCCESS;
}
private static void a() {
if (!Licensing.isSdkLicensed(Licensing.LicenseType.BARCODE_CAPTURE)) {
throw new KmcRuntimeException(ErrorInfo.KMC_UT_LICENSE_BARCODE_CAPTURE);
}
}
public void setMaxBarcodes(int i) {
a(i);
}
public void addBarcodeReadCompleteEventListener(BarcodeReadCompleteListener barcodeReadCompleteListener) {
if (barcodeReadCompleteListener == null) {
throw new KmcRuntimeException(ErrorInfo.KMC_BC_UNKNOWN);
}
if (this.f.contains(barcodeReadCompleteListener)) {
return;
}
this.f.add(barcodeReadCompleteListener);
}
public void removeBarcodeReadCompleteEventListener(BarcodeReadCompleteListener barcodeReadCompleteListener) {
if (barcodeReadCompleteListener != null) {
this.f.remove(barcodeReadCompleteListener);
}
}
/* loaded from: classes3.dex */
public static class BarcodeReadCompleteEvent extends EventObject {
private static final long serialVersionUID = 5157442993015269738L;
private ErrorInfo e;
private Image t;
public BarcodeReadCompleteEvent(Object obj, ErrorInfo errorInfo, Image image) {
super(obj);
this.e = errorInfo;
this.t = image;
}
public ErrorInfo getStatus() {
return this.e;
}
public Image getImage() {
return this.t;
}
}
/* loaded from: classes3.dex */
public enum Symbology {
Code128(1),
Ean(6),
Upc(24),
Code39(32),
Code25(64),
Code93(512),
Codabar(1024),
Postnet(4096),
Datamatrix(PKIFailureInfo.badCertTemplate),
Pdf417(PKIFailureInfo.badSenderNonce),
QRCode(4194304);
private final int u;
public static BarCodeType getBarCodeType(int i) {
if (i == 1) {
return BarCodeType.CODE128;
}
if (i != 2) {
switch (i) {
case 4:
break;
case 8:
case 16:
return BarCodeType.UPC;
case 32:
return BarCodeType.CODE39;
case 64:
return BarCodeType.CODE25;
case 512:
return BarCodeType.CODE93;
case 1024:
return BarCodeType.CODABAR;
case 4096:
return BarCodeType.POSTNET;
case PKIFailureInfo.badCertTemplate /* 1048576 */:
return BarCodeType.DATAMATRIX;
case PKIFailureInfo.badSenderNonce /* 2097152 */:
return BarCodeType.PDF417;
case 4194304:
return BarCodeType.QR;
default:
return BarCodeType.UNKNOWN;
}
}
return BarCodeType.EAN;
}
Symbology(int i) {
this.u = i;
}
}
/* JADX WARN: Enum visitor error
jadx.core.utils.exceptions.JadxRuntimeException: Init of enum field 'ALL' uses external variables
at jadx.core.dex.visitors.EnumVisitor.createEnumFieldByConstructor(EnumVisitor.java:451)
at jadx.core.dex.visitors.EnumVisitor.processEnumFieldByRegister(EnumVisitor.java:395)
at jadx.core.dex.visitors.EnumVisitor.extractEnumFieldsFromFilledArray(EnumVisitor.java:324)
at jadx.core.dex.visitors.EnumVisitor.extractEnumFieldsFromInsn(EnumVisitor.java:262)
at jadx.core.dex.visitors.EnumVisitor.convertToEnum(EnumVisitor.java:151)
at jadx.core.dex.visitors.EnumVisitor.visit(EnumVisitor.java:100)
*/
/* JADX WARN: Failed to restore enum class, 'enum' modifier and super class removed */
/* loaded from: classes3.dex */
public static final class Direction {
public static final Direction ALL;
public static final Direction BOTTOM_UP;
public static final Direction LEFT_RIGHT;
public static final Direction RIGHT_LEFT;
public static final Direction TOP_DOWN;
private static final Direction[] v;
private final int u;
public static Direction valueOf(String str) {
return (Direction) Enum.valueOf(Direction.class, str);
}
public static Direction[] values() {
return (Direction[]) v.clone();
}
static {
Direction direction = new Direction("LEFT_RIGHT", 0, 1);
LEFT_RIGHT = direction;
Direction direction2 = new Direction("RIGHT_LEFT", 1, 4);
RIGHT_LEFT = direction2;
Direction direction3 = new Direction("TOP_DOWN", 2, 2);
TOP_DOWN = direction3;
Direction direction4 = new Direction("BOTTOM_UP", 3, 8);
BOTTOM_UP = direction4;
Direction direction5 = new Direction("ALL", 4, direction.u | direction2.u | direction3.u | direction4.u);
ALL = direction5;
v = new Direction[]{direction, direction2, direction3, direction4, direction5};
}
private Direction(String str, int i, int i2) {
this.u = i2;
}
}
private void a(int i) {
if (i <= 0) {
throw new IllegalArgumentException("maxBarcodes <= 0: ".concat(String.valueOf(i)));
}
this.b = i;
}
public void setSearchSymbology(Symbology[] symbologyArr) {
this._symbology = symbologyArr;
}
public void setSearchDirections(Direction direction) {
this.c = direction;
}
public Symbology[] getSearchSymbology() {
return this._symbology;
}
public Direction getSearchDirections() {
return this.c;
}
public int getMaxBarcodes() {
return this.b;
}
}