jimu-decompiled/sources/com/google/zxing/qrcode/decoder/DecodedBitStreamParser.java
2025-05-13 19:24:51 +02:00

241 lines
8.6 KiB
Java

package com.google.zxing.qrcode.decoder;
import com.google.zxing.DecodeHintType;
import com.google.zxing.FormatException;
import com.google.zxing.common.BitSource;
import com.google.zxing.common.CharacterSetECI;
import com.google.zxing.common.StringUtils;
import com.ubtrobot.jimu.robotapi.PeripheralType;
import java.io.UnsupportedEncodingException;
import java.util.Collection;
import java.util.Map;
/* loaded from: classes.dex */
final class DecodedBitStreamParser {
private static final char[] a = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:".toCharArray();
/* renamed from: com.google.zxing.qrcode.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.NUMERIC.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
a[Mode.ALPHANUMERIC.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
try {
a[Mode.BYTE.ordinal()] = 3;
} catch (NoSuchFieldError unused3) {
}
try {
a[Mode.KANJI.ordinal()] = 4;
} catch (NoSuchFieldError unused4) {
}
try {
a[Mode.TERMINATOR.ordinal()] = 5;
} catch (NoSuchFieldError unused5) {
}
try {
a[Mode.FNC1_FIRST_POSITION.ordinal()] = 6;
} catch (NoSuchFieldError unused6) {
}
try {
a[Mode.FNC1_SECOND_POSITION.ordinal()] = 7;
} catch (NoSuchFieldError unused7) {
}
try {
a[Mode.STRUCTURED_APPEND.ordinal()] = 8;
} catch (NoSuchFieldError unused8) {
}
try {
a[Mode.ECI.ordinal()] = 9;
} catch (NoSuchFieldError unused9) {
}
try {
a[Mode.HANZI.ordinal()] = 10;
} catch (NoSuchFieldError unused10) {
}
}
}
/* JADX WARN: Can't fix incorrect switch cases order, some code will duplicate */
/* JADX WARN: Removed duplicated region for block: B:25:0x00dc A[LOOP:0: B:2:0x001e->B:25:0x00dc, LOOP_END] */
/* JADX WARN: Removed duplicated region for block: B:26:0x00ba A[SYNTHETIC] */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct code enable 'Show inconsistent code' option in preferences
*/
static com.google.zxing.common.DecoderResult a(byte[] r17, com.google.zxing.qrcode.decoder.Version r18, com.google.zxing.qrcode.decoder.ErrorCorrectionLevel r19, java.util.Map<com.google.zxing.DecodeHintType, ?> r20) throws com.google.zxing.FormatException {
/*
Method dump skipped, instructions count: 244
To view this dump change 'Code comments level' option to 'DEBUG'
*/
throw new UnsupportedOperationException("Method not decompiled: com.google.zxing.qrcode.decoder.DecodedBitStreamParser.a(byte[], com.google.zxing.qrcode.decoder.Version, com.google.zxing.qrcode.decoder.ErrorCorrectionLevel, java.util.Map):com.google.zxing.common.DecoderResult");
}
private static void b(BitSource bitSource, StringBuilder sb, int i) throws FormatException {
if (i * 13 > bitSource.a()) {
throw FormatException.getFormatInstance();
}
byte[] bArr = new byte[i * 2];
int i2 = 0;
while (i > 0) {
int a2 = bitSource.a(13);
int i3 = (a2 % 192) | ((a2 / 192) << 8);
int i4 = i3 + (i3 < 7936 ? 33088 : 49472);
bArr[i2] = (byte) (i4 >> 8);
bArr[i2 + 1] = (byte) i4;
i2 += 2;
i--;
}
try {
sb.append(new String(bArr, "SJIS"));
} catch (UnsupportedEncodingException unused) {
throw FormatException.getFormatInstance();
}
}
private static void c(BitSource bitSource, StringBuilder sb, int i) throws FormatException {
while (i >= 3) {
if (bitSource.a() < 10) {
throw FormatException.getFormatInstance();
}
int a2 = bitSource.a(10);
if (a2 >= 1000) {
throw FormatException.getFormatInstance();
}
sb.append(a(a2 / 100));
sb.append(a((a2 / 10) % 10));
sb.append(a(a2 % 10));
i -= 3;
}
if (i == 2) {
if (bitSource.a() < 7) {
throw FormatException.getFormatInstance();
}
int a3 = bitSource.a(7);
if (a3 >= 100) {
throw FormatException.getFormatInstance();
}
sb.append(a(a3 / 10));
sb.append(a(a3 % 10));
return;
}
if (i == 1) {
if (bitSource.a() < 4) {
throw FormatException.getFormatInstance();
}
int a4 = bitSource.a(4);
if (a4 >= 10) {
throw FormatException.getFormatInstance();
}
sb.append(a(a4));
}
}
private static void a(BitSource bitSource, StringBuilder sb, int i) throws FormatException {
if (i * 13 <= bitSource.a()) {
byte[] bArr = new byte[i * 2];
int i2 = 0;
while (i > 0) {
int a2 = bitSource.a(13);
int i3 = (a2 % 96) | ((a2 / 96) << 8);
int i4 = i3 + (i3 < 959 ? 41377 : 42657);
bArr[i2] = (byte) (i4 >> 8);
bArr[i2 + 1] = (byte) i4;
i2 += 2;
i--;
}
try {
sb.append(new String(bArr, "GB2312"));
return;
} catch (UnsupportedEncodingException unused) {
throw FormatException.getFormatInstance();
}
}
throw FormatException.getFormatInstance();
}
private static void a(BitSource bitSource, StringBuilder sb, int i, CharacterSetECI characterSetECI, Collection<byte[]> collection, Map<DecodeHintType, ?> map) throws FormatException {
String name;
if ((i << 3) <= bitSource.a()) {
byte[] bArr = new byte[i];
for (int i2 = 0; i2 < i; i2++) {
bArr[i2] = (byte) bitSource.a(8);
}
if (characterSetECI == null) {
name = StringUtils.a(bArr, map);
} else {
name = characterSetECI.name();
}
try {
sb.append(new String(bArr, name));
collection.add(bArr);
return;
} catch (UnsupportedEncodingException unused) {
throw FormatException.getFormatInstance();
}
}
throw FormatException.getFormatInstance();
}
private static char a(int i) throws FormatException {
char[] cArr = a;
if (i < cArr.length) {
return cArr[i];
}
throw FormatException.getFormatInstance();
}
private static void a(BitSource bitSource, StringBuilder sb, int i, boolean z) throws FormatException {
while (i > 1) {
if (bitSource.a() >= 11) {
int a2 = bitSource.a(11);
sb.append(a(a2 / 45));
sb.append(a(a2 % 45));
i -= 2;
} else {
throw FormatException.getFormatInstance();
}
}
if (i == 1) {
if (bitSource.a() >= 6) {
sb.append(a(bitSource.a(6)));
} else {
throw FormatException.getFormatInstance();
}
}
if (z) {
for (int length = sb.length(); length < sb.length(); length++) {
if (sb.charAt(length) == '%') {
if (length < sb.length() - 1) {
int i2 = length + 1;
if (sb.charAt(i2) == '%') {
sb.deleteCharAt(i2);
}
}
sb.setCharAt(length, (char) 29);
}
}
}
}
private static int a(BitSource bitSource) throws FormatException {
int a2 = bitSource.a(8);
if ((a2 & PeripheralType.SERVO) == 0) {
return a2 & 127;
}
if ((a2 & 192) == 128) {
return bitSource.a(8) | ((a2 & 63) << 8);
}
if ((a2 & 224) == 192) {
return bitSource.a(16) | ((a2 & 31) << 16);
}
throw FormatException.getFormatInstance();
}
}