239 lines
8.3 KiB
Java
239 lines
8.3 KiB
Java
|
package o;
|
||
|
|
||
|
import com.google.zxing.ChecksumException;
|
||
|
import com.google.zxing.FormatException;
|
||
|
import com.google.zxing.NotFoundException;
|
||
|
import com.google.zxing.ReaderException;
|
||
|
import java.util.Arrays;
|
||
|
import java.util.Map;
|
||
|
|
||
|
/* loaded from: classes2.dex */
|
||
|
public abstract class rua extends xue {
|
||
|
static final int[][] c;
|
||
|
static final int[][] d;
|
||
|
private final StringBuilder a = new StringBuilder(20);
|
||
|
private final hQI f = new hQI();
|
||
|
private final fGE g = new fGE();
|
||
|
static final int[] i = {1, 1, 1};
|
||
|
static final int[] e = {1, 1, 1, 1, 1};
|
||
|
static final int[] b = {1, 1, 1, 1, 1, 1};
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: protected */
|
||
|
public abstract int b(C17416wdP c17416wdP, int[] iArr, StringBuilder sb) throws NotFoundException;
|
||
|
|
||
|
abstract PTS d();
|
||
|
|
||
|
static {
|
||
|
int[][] iArr = {new int[]{3, 2, 1, 1}, new int[]{2, 2, 2, 1}, new int[]{2, 1, 2, 2}, new int[]{1, 4, 1, 1}, new int[]{1, 1, 3, 2}, new int[]{1, 2, 3, 1}, new int[]{1, 1, 1, 4}, new int[]{1, 3, 1, 2}, new int[]{1, 2, 1, 3}, new int[]{3, 1, 1, 2}};
|
||
|
c = iArr;
|
||
|
int[][] iArr2 = new int[20];
|
||
|
d = iArr2;
|
||
|
System.arraycopy(iArr, 0, iArr2, 0, 10);
|
||
|
for (int i2 = 10; i2 < 20; i2++) {
|
||
|
int[] iArr3 = c[i2 - 10];
|
||
|
int[] iArr4 = new int[iArr3.length];
|
||
|
for (int i3 = 0; i3 < iArr3.length; i3++) {
|
||
|
iArr4[i3] = iArr3[(iArr3.length - i3) - 1];
|
||
|
}
|
||
|
d[i2] = iArr4;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public static int[] a(C17416wdP c17416wdP) throws NotFoundException {
|
||
|
int[] iArr = new int[i.length];
|
||
|
int[] iArr2 = null;
|
||
|
boolean z = false;
|
||
|
int i2 = 0;
|
||
|
while (!z) {
|
||
|
int[] iArr3 = i;
|
||
|
Arrays.fill(iArr, 0, iArr3.length, 0);
|
||
|
iArr2 = c(c17416wdP, i2, false, iArr3, iArr);
|
||
|
int i3 = iArr2[0];
|
||
|
int i4 = iArr2[1];
|
||
|
int i5 = i3 - (i4 - i3);
|
||
|
if (i5 >= 0) {
|
||
|
z = c17416wdP.d(i5, i3);
|
||
|
}
|
||
|
i2 = i4;
|
||
|
}
|
||
|
return iArr2;
|
||
|
}
|
||
|
|
||
|
@Override // o.xue
|
||
|
public WFF d(int i2, C17416wdP c17416wdP, Map<CGg, ?> map) throws NotFoundException, ChecksumException, FormatException {
|
||
|
return a(i2, c17416wdP, a(c17416wdP), map);
|
||
|
}
|
||
|
|
||
|
public WFF a(int i2, C17416wdP c17416wdP, int[] iArr, Map<CGg, ?> map) throws NotFoundException, ChecksumException, FormatException {
|
||
|
int i3;
|
||
|
String c2;
|
||
|
pgq pgqVar = map == null ? null : (pgq) map.get(CGg.NEED_RESULT_POINT_CALLBACK);
|
||
|
if (pgqVar != null) {
|
||
|
pgqVar.a(new qCz((iArr[0] + iArr[1]) / 2.0f, i2));
|
||
|
}
|
||
|
StringBuilder sb = this.a;
|
||
|
sb.setLength(0);
|
||
|
int b2 = b(c17416wdP, iArr, sb);
|
||
|
if (pgqVar != null) {
|
||
|
pgqVar.a(new qCz(b2, i2));
|
||
|
}
|
||
|
int[] e2 = e(c17416wdP, b2);
|
||
|
if (pgqVar != null) {
|
||
|
pgqVar.a(new qCz((e2[0] + e2[1]) / 2.0f, i2));
|
||
|
}
|
||
|
int i4 = e2[1];
|
||
|
int i5 = (i4 - e2[0]) + i4;
|
||
|
if (i5 >= c17416wdP.d || !c17416wdP.d(i4, i5)) {
|
||
|
throw NotFoundException.b();
|
||
|
}
|
||
|
String obj = sb.toString();
|
||
|
if (obj.length() < 8) {
|
||
|
throw FormatException.c();
|
||
|
}
|
||
|
if (!b(obj)) {
|
||
|
throw ChecksumException.e();
|
||
|
}
|
||
|
PTS d2 = d();
|
||
|
float f = i2;
|
||
|
WFF wff = new WFF(obj, null, new qCz[]{new qCz((iArr[1] + iArr[0]) / 2.0f, f), new qCz((e2[1] + e2[0]) / 2.0f, f)}, d2);
|
||
|
try {
|
||
|
WFF e3 = this.f.e(i2, c17416wdP, e2[1]);
|
||
|
wff.b(MoF.UPC_EAN_EXTENSION, e3.b);
|
||
|
Map<MoF, Object> map2 = e3.e;
|
||
|
if (map2 != null) {
|
||
|
Map<MoF, Object> map3 = wff.e;
|
||
|
if (map3 == null) {
|
||
|
wff.e = map2;
|
||
|
} else {
|
||
|
map3.putAll(map2);
|
||
|
}
|
||
|
}
|
||
|
qCz[] qczArr = e3.c;
|
||
|
qCz[] qczArr2 = wff.c;
|
||
|
if (qczArr2 == null) {
|
||
|
wff.c = qczArr;
|
||
|
} else if (qczArr != null && qczArr.length > 0) {
|
||
|
qCz[] qczArr3 = new qCz[qczArr2.length + qczArr.length];
|
||
|
System.arraycopy(qczArr2, 0, qczArr3, 0, qczArr2.length);
|
||
|
System.arraycopy(qczArr, 0, qczArr3, qczArr2.length, qczArr.length);
|
||
|
wff.c = qczArr3;
|
||
|
}
|
||
|
i3 = e3.b.length();
|
||
|
} catch (ReaderException unused) {
|
||
|
i3 = 0;
|
||
|
}
|
||
|
int[] iArr2 = map != null ? (int[]) map.get(CGg.ALLOWED_EAN_EXTENSIONS) : null;
|
||
|
if (iArr2 != null) {
|
||
|
for (int i6 : iArr2) {
|
||
|
if (i3 != i6) {
|
||
|
}
|
||
|
}
|
||
|
throw NotFoundException.b();
|
||
|
}
|
||
|
if ((d2 == PTS.EAN_13 || d2 == PTS.UPC_A) && (c2 = this.g.c(obj)) != null) {
|
||
|
wff.b(MoF.POSSIBLE_COUNTRY, c2);
|
||
|
}
|
||
|
wff.b(MoF.SYMBOLOGY_IDENTIFIER, "]E".concat(String.valueOf(d2 == PTS.EAN_8 ? 4 : 0)));
|
||
|
return wff;
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public boolean b(String str) throws FormatException {
|
||
|
return c(str);
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public static boolean c(CharSequence charSequence) throws FormatException {
|
||
|
int length = charSequence.length();
|
||
|
if (length == 0) {
|
||
|
return false;
|
||
|
}
|
||
|
int i2 = length - 1;
|
||
|
return a(charSequence.subSequence(0, i2)) == Character.digit(charSequence.charAt(i2), 10);
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public static int a(CharSequence charSequence) throws FormatException {
|
||
|
int length = charSequence.length();
|
||
|
int i2 = 0;
|
||
|
for (int i3 = length - 1; i3 >= 0; i3 -= 2) {
|
||
|
int charAt = charSequence.charAt(i3) - '0';
|
||
|
if (charAt < 0 || charAt > 9) {
|
||
|
throw FormatException.c();
|
||
|
}
|
||
|
i2 += charAt;
|
||
|
}
|
||
|
int i4 = i2 * 3;
|
||
|
for (int i5 = length - 2; i5 >= 0; i5 -= 2) {
|
||
|
int charAt2 = charSequence.charAt(i5) - '0';
|
||
|
if (charAt2 < 0 || charAt2 > 9) {
|
||
|
throw FormatException.c();
|
||
|
}
|
||
|
i4 += charAt2;
|
||
|
}
|
||
|
return (1000 - i4) % 10;
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public static int[] d(C17416wdP c17416wdP, int i2, boolean z, int[] iArr) throws NotFoundException {
|
||
|
return c(c17416wdP, i2, z, iArr, new int[iArr.length]);
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public static int e(C17416wdP c17416wdP, int[] iArr, int i2, int[][] iArr2) throws NotFoundException {
|
||
|
b(c17416wdP, i2, iArr);
|
||
|
int length = iArr2.length;
|
||
|
float f = 0.48f;
|
||
|
int i3 = -1;
|
||
|
for (int i4 = 0; i4 < length; i4++) {
|
||
|
float b2 = b(iArr, iArr2[i4], 0.7f);
|
||
|
if (b2 < f) {
|
||
|
i3 = i4;
|
||
|
f = b2;
|
||
|
}
|
||
|
}
|
||
|
if (i3 >= 0) {
|
||
|
return i3;
|
||
|
}
|
||
|
throw NotFoundException.b();
|
||
|
}
|
||
|
|
||
|
private static int[] c(C17416wdP c17416wdP, int i2, boolean z, int[] iArr, int[] iArr2) throws NotFoundException {
|
||
|
int i3 = c17416wdP.d;
|
||
|
int c2 = z ? c17416wdP.c(i2) : c17416wdP.a(i2);
|
||
|
int length = iArr.length;
|
||
|
boolean z2 = z;
|
||
|
int i4 = 0;
|
||
|
int i5 = c2;
|
||
|
while (c2 < i3) {
|
||
|
if (((c17416wdP.a[c2 / 32] & (1 << (c2 & 31))) != 0) != z2) {
|
||
|
iArr2[i4] = iArr2[i4] + 1;
|
||
|
} else {
|
||
|
if (i4 != length - 1) {
|
||
|
i4++;
|
||
|
} else {
|
||
|
if (b(iArr2, iArr, 0.7f) < 0.48f) {
|
||
|
return new int[]{i5, c2};
|
||
|
}
|
||
|
i5 += iArr2[0] + iArr2[1];
|
||
|
int i6 = i4 - 1;
|
||
|
System.arraycopy(iArr2, 2, iArr2, 0, i6);
|
||
|
iArr2[i6] = 0;
|
||
|
iArr2[i4] = 0;
|
||
|
i4--;
|
||
|
}
|
||
|
iArr2[i4] = 1;
|
||
|
z2 = !z2;
|
||
|
}
|
||
|
c2++;
|
||
|
}
|
||
|
throw NotFoundException.b();
|
||
|
}
|
||
|
|
||
|
int[] e(C17416wdP c17416wdP, int i2) throws NotFoundException {
|
||
|
int[] iArr = i;
|
||
|
return c(c17416wdP, i2, false, iArr, new int[iArr.length]);
|
||
|
}
|
||
|
}
|