423 lines
16 KiB
Java
423 lines
16 KiB
Java
package com.google.zxing.datamatrix.decoder;
|
|
|
|
import androidx.recyclerview.widget.ItemTouchHelper;
|
|
import com.google.zxing.FormatException;
|
|
import com.google.zxing.common.BitSource;
|
|
import com.google.zxing.common.DecoderResult;
|
|
import com.ijm.dataencryption.de.DataDecryptTool;
|
|
import com.ubtrobot.jimu.robotapi.PeripheralType;
|
|
import java.io.UnsupportedEncodingException;
|
|
import java.util.ArrayList;
|
|
import java.util.Collection;
|
|
|
|
/* loaded from: classes.dex */
|
|
final class DecodedBitStreamParser {
|
|
private static final char[] a = {'*', '*', '*', ' ', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
|
|
private static final char[] b = {'!', '\"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '@', '[', '\\', ']', '^', '_'};
|
|
private static final char[] c = {'*', '*', '*', ' ', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
|
|
private static final char[] d = b;
|
|
private static final char[] e = {'`', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '{', '|', '}', '~', 127};
|
|
|
|
/* renamed from: com.google.zxing.datamatrix.decoder.DecodedBitStreamParser$1, reason: invalid class name */
|
|
static /* synthetic */ class AnonymousClass1 {
|
|
static final /* synthetic */ int[] a = new int[Mode.values().length];
|
|
|
|
static {
|
|
try {
|
|
a[Mode.C40_ENCODE.ordinal()] = 1;
|
|
} catch (NoSuchFieldError unused) {
|
|
}
|
|
try {
|
|
a[Mode.TEXT_ENCODE.ordinal()] = 2;
|
|
} catch (NoSuchFieldError unused2) {
|
|
}
|
|
try {
|
|
a[Mode.ANSIX12_ENCODE.ordinal()] = 3;
|
|
} catch (NoSuchFieldError unused3) {
|
|
}
|
|
try {
|
|
a[Mode.EDIFACT_ENCODE.ordinal()] = 4;
|
|
} catch (NoSuchFieldError unused4) {
|
|
}
|
|
try {
|
|
a[Mode.BASE256_ENCODE.ordinal()] = 5;
|
|
} catch (NoSuchFieldError unused5) {
|
|
}
|
|
}
|
|
}
|
|
|
|
private enum Mode {
|
|
PAD_ENCODE,
|
|
ASCII_ENCODE,
|
|
C40_ENCODE,
|
|
TEXT_ENCODE,
|
|
ANSIX12_ENCODE,
|
|
EDIFACT_ENCODE,
|
|
BASE256_ENCODE
|
|
}
|
|
|
|
static DecoderResult a(byte[] bArr) throws FormatException {
|
|
BitSource bitSource = new BitSource(bArr);
|
|
StringBuilder sb = new StringBuilder(100);
|
|
StringBuilder sb2 = new StringBuilder(0);
|
|
ArrayList arrayList = new ArrayList(1);
|
|
Mode mode = Mode.ASCII_ENCODE;
|
|
do {
|
|
if (mode == Mode.ASCII_ENCODE) {
|
|
mode = a(bitSource, sb, sb2);
|
|
} else {
|
|
int i = AnonymousClass1.a[mode.ordinal()];
|
|
if (i == 1) {
|
|
b(bitSource, sb);
|
|
} else if (i == 2) {
|
|
d(bitSource, sb);
|
|
} else if (i == 3) {
|
|
a(bitSource, sb);
|
|
} else if (i == 4) {
|
|
c(bitSource, sb);
|
|
} else {
|
|
if (i != 5) {
|
|
throw FormatException.getFormatInstance();
|
|
}
|
|
a(bitSource, sb, arrayList);
|
|
}
|
|
mode = Mode.ASCII_ENCODE;
|
|
}
|
|
if (mode == Mode.PAD_ENCODE) {
|
|
break;
|
|
}
|
|
} while (bitSource.a() > 0);
|
|
if (sb2.length() > 0) {
|
|
sb.append((CharSequence) sb2);
|
|
}
|
|
String sb3 = sb.toString();
|
|
if (arrayList.isEmpty()) {
|
|
arrayList = null;
|
|
}
|
|
return new DecoderResult(bArr, sb3, arrayList, null);
|
|
}
|
|
|
|
private static void b(BitSource bitSource, StringBuilder sb) throws FormatException {
|
|
int a2;
|
|
int[] iArr = new int[3];
|
|
boolean z = false;
|
|
int i = 0;
|
|
while (bitSource.a() != 8 && (a2 = bitSource.a(8)) != 254) {
|
|
a(a2, bitSource.a(8), iArr);
|
|
boolean z2 = z;
|
|
for (int i2 = 0; i2 < 3; i2++) {
|
|
int i3 = iArr[i2];
|
|
if (i != 0) {
|
|
if (i != 1) {
|
|
if (i == 2) {
|
|
char[] cArr = b;
|
|
if (i3 < cArr.length) {
|
|
char c2 = cArr[i3];
|
|
if (z2) {
|
|
sb.append((char) (c2 + 128));
|
|
z2 = false;
|
|
} else {
|
|
sb.append(c2);
|
|
}
|
|
} else if (i3 == 27) {
|
|
sb.append((char) 29);
|
|
} else {
|
|
if (i3 != 30) {
|
|
throw FormatException.getFormatInstance();
|
|
}
|
|
z2 = true;
|
|
}
|
|
i = 0;
|
|
} else {
|
|
if (i != 3) {
|
|
throw FormatException.getFormatInstance();
|
|
}
|
|
if (z2) {
|
|
sb.append((char) (i3 + 224));
|
|
z2 = false;
|
|
i = 0;
|
|
} else {
|
|
sb.append((char) (i3 + 96));
|
|
i = 0;
|
|
}
|
|
}
|
|
} else if (z2) {
|
|
sb.append((char) (i3 + PeripheralType.SERVO));
|
|
z2 = false;
|
|
i = 0;
|
|
} else {
|
|
sb.append((char) i3);
|
|
i = 0;
|
|
}
|
|
} else if (i3 < 3) {
|
|
i = i3 + 1;
|
|
} else {
|
|
char[] cArr2 = a;
|
|
if (i3 >= cArr2.length) {
|
|
throw FormatException.getFormatInstance();
|
|
}
|
|
char c3 = cArr2[i3];
|
|
if (z2) {
|
|
sb.append((char) (c3 + 128));
|
|
z2 = false;
|
|
} else {
|
|
sb.append(c3);
|
|
}
|
|
}
|
|
}
|
|
if (bitSource.a() <= 0) {
|
|
return;
|
|
} else {
|
|
z = z2;
|
|
}
|
|
}
|
|
}
|
|
|
|
private static void c(BitSource bitSource, StringBuilder sb) {
|
|
while (bitSource.a() > 16) {
|
|
for (int i = 0; i < 4; i++) {
|
|
int a2 = bitSource.a(6);
|
|
if (a2 == 31) {
|
|
int b2 = 8 - bitSource.b();
|
|
if (b2 != 8) {
|
|
bitSource.a(b2);
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
if ((a2 & 32) == 0) {
|
|
a2 |= 64;
|
|
}
|
|
sb.append((char) a2);
|
|
}
|
|
if (bitSource.a() <= 0) {
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
private static void d(BitSource bitSource, StringBuilder sb) throws FormatException {
|
|
int a2;
|
|
int[] iArr = new int[3];
|
|
boolean z = false;
|
|
int i = 0;
|
|
while (bitSource.a() != 8 && (a2 = bitSource.a(8)) != 254) {
|
|
a(a2, bitSource.a(8), iArr);
|
|
boolean z2 = z;
|
|
for (int i2 = 0; i2 < 3; i2++) {
|
|
int i3 = iArr[i2];
|
|
if (i != 0) {
|
|
if (i != 1) {
|
|
if (i == 2) {
|
|
char[] cArr = d;
|
|
if (i3 < cArr.length) {
|
|
char c2 = cArr[i3];
|
|
if (z2) {
|
|
sb.append((char) (c2 + 128));
|
|
z2 = false;
|
|
} else {
|
|
sb.append(c2);
|
|
}
|
|
} else if (i3 == 27) {
|
|
sb.append((char) 29);
|
|
} else {
|
|
if (i3 != 30) {
|
|
throw FormatException.getFormatInstance();
|
|
}
|
|
z2 = true;
|
|
}
|
|
i = 0;
|
|
} else {
|
|
if (i != 3) {
|
|
throw FormatException.getFormatInstance();
|
|
}
|
|
char[] cArr2 = e;
|
|
if (i3 >= cArr2.length) {
|
|
throw FormatException.getFormatInstance();
|
|
}
|
|
char c3 = cArr2[i3];
|
|
if (z2) {
|
|
sb.append((char) (c3 + 128));
|
|
z2 = false;
|
|
i = 0;
|
|
} else {
|
|
sb.append(c3);
|
|
i = 0;
|
|
}
|
|
}
|
|
} else if (z2) {
|
|
sb.append((char) (i3 + PeripheralType.SERVO));
|
|
z2 = false;
|
|
i = 0;
|
|
} else {
|
|
sb.append((char) i3);
|
|
i = 0;
|
|
}
|
|
} else if (i3 < 3) {
|
|
i = i3 + 1;
|
|
} else {
|
|
char[] cArr3 = c;
|
|
if (i3 >= cArr3.length) {
|
|
throw FormatException.getFormatInstance();
|
|
}
|
|
char c4 = cArr3[i3];
|
|
if (z2) {
|
|
sb.append((char) (c4 + 128));
|
|
z2 = false;
|
|
} else {
|
|
sb.append(c4);
|
|
}
|
|
}
|
|
}
|
|
if (bitSource.a() <= 0) {
|
|
return;
|
|
} else {
|
|
z = z2;
|
|
}
|
|
}
|
|
}
|
|
|
|
private static Mode a(BitSource bitSource, StringBuilder sb, StringBuilder sb2) throws FormatException {
|
|
boolean z = false;
|
|
do {
|
|
int a2 = bitSource.a(8);
|
|
if (a2 == 0) {
|
|
throw FormatException.getFormatInstance();
|
|
}
|
|
if (a2 > 128) {
|
|
if (a2 != 129) {
|
|
if (a2 <= 229) {
|
|
int i = a2 - 130;
|
|
if (i < 10) {
|
|
sb.append('0');
|
|
}
|
|
sb.append(i);
|
|
} else {
|
|
switch (a2) {
|
|
case 230:
|
|
return Mode.C40_ENCODE;
|
|
case 231:
|
|
return Mode.BASE256_ENCODE;
|
|
case 232:
|
|
sb.append((char) 29);
|
|
break;
|
|
case 233:
|
|
case 234:
|
|
case 241:
|
|
break;
|
|
case 235:
|
|
z = true;
|
|
break;
|
|
case 236:
|
|
sb.append("[)>\u001e05\u001d");
|
|
sb2.insert(0, "\u001e\u0004");
|
|
break;
|
|
case 237:
|
|
sb.append("[)>\u001e06\u001d");
|
|
sb2.insert(0, "\u001e\u0004");
|
|
break;
|
|
case 238:
|
|
return Mode.ANSIX12_ENCODE;
|
|
case 239:
|
|
return Mode.TEXT_ENCODE;
|
|
case 240:
|
|
return Mode.EDIFACT_ENCODE;
|
|
default:
|
|
if (a2 != 254 || bitSource.a() != 0) {
|
|
throw FormatException.getFormatInstance();
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
} else {
|
|
return Mode.PAD_ENCODE;
|
|
}
|
|
} else {
|
|
if (z) {
|
|
a2 += PeripheralType.SERVO;
|
|
}
|
|
sb.append((char) (a2 - 1));
|
|
return Mode.ASCII_ENCODE;
|
|
}
|
|
} while (bitSource.a() > 0);
|
|
return Mode.ASCII_ENCODE;
|
|
}
|
|
|
|
private static void a(BitSource bitSource, StringBuilder sb) throws FormatException {
|
|
int a2;
|
|
int[] iArr = new int[3];
|
|
while (bitSource.a() != 8 && (a2 = bitSource.a(8)) != 254) {
|
|
a(a2, bitSource.a(8), iArr);
|
|
for (int i = 0; i < 3; i++) {
|
|
int i2 = iArr[i];
|
|
if (i2 == 0) {
|
|
sb.append('\r');
|
|
} else if (i2 == 1) {
|
|
sb.append('*');
|
|
} else if (i2 == 2) {
|
|
sb.append('>');
|
|
} else if (i2 == 3) {
|
|
sb.append(' ');
|
|
} else if (i2 < 14) {
|
|
sb.append((char) (i2 + 44));
|
|
} else if (i2 < 40) {
|
|
sb.append((char) (i2 + 51));
|
|
} else {
|
|
throw FormatException.getFormatInstance();
|
|
}
|
|
}
|
|
if (bitSource.a() <= 0) {
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
private static void a(int i, int i2, int[] iArr) {
|
|
int i3 = ((i << 8) + i2) - 1;
|
|
int i4 = i3 / 1600;
|
|
iArr[0] = i4;
|
|
int i5 = i3 - (i4 * 1600);
|
|
int i6 = i5 / 40;
|
|
iArr[1] = i6;
|
|
iArr[2] = i5 - (i6 * 40);
|
|
}
|
|
|
|
private static void a(BitSource bitSource, StringBuilder sb, Collection<byte[]> collection) throws FormatException {
|
|
int c2 = bitSource.c() + 1;
|
|
int i = c2 + 1;
|
|
int a2 = a(bitSource.a(8), c2);
|
|
if (a2 == 0) {
|
|
a2 = bitSource.a() / 8;
|
|
} else if (a2 >= 250) {
|
|
a2 = ((a2 - 249) * ItemTouchHelper.Callback.DEFAULT_SWIPE_ANIMATION_DURATION) + a(bitSource.a(8), i);
|
|
i++;
|
|
}
|
|
if (a2 >= 0) {
|
|
byte[] bArr = new byte[a2];
|
|
int i2 = 0;
|
|
while (i2 < a2) {
|
|
if (bitSource.a() >= 8) {
|
|
bArr[i2] = (byte) a(bitSource.a(8), i);
|
|
i2++;
|
|
i++;
|
|
} else {
|
|
throw FormatException.getFormatInstance();
|
|
}
|
|
}
|
|
collection.add(bArr);
|
|
try {
|
|
sb.append(new String(bArr, "ISO8859_1"));
|
|
return;
|
|
} catch (UnsupportedEncodingException e2) {
|
|
throw new IllegalStateException("Platform does not support required encoding: ".concat(String.valueOf(e2)));
|
|
}
|
|
}
|
|
throw FormatException.getFormatInstance();
|
|
}
|
|
|
|
private static int a(int i, int i2) {
|
|
int i3 = i - (((i2 * 149) % 255) + 1);
|
|
return i3 >= 0 ? i3 : i3 + DataDecryptTool.DECRYPT_ALL_FILE;
|
|
}
|
|
}
|