Initial commit

This commit is contained in:
2025-05-13 19:24:51 +02:00
commit a950f49678
10604 changed files with 932663 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
package com.google.zxing.qrcode.encoder;
/* loaded from: classes.dex */
final class BlockPair {
private final byte[] a;
private final byte[] b;
BlockPair(byte[] bArr, byte[] bArr2) {
this.a = bArr;
this.b = bArr2;
}
public byte[] a() {
return this.a;
}
public byte[] b() {
return this.b;
}
}

View File

@@ -0,0 +1,66 @@
package com.google.zxing.qrcode.encoder;
import java.lang.reflect.Array;
import java.util.Arrays;
/* loaded from: classes.dex */
public final class ByteMatrix {
private final byte[][] a;
private final int b;
private final int c;
public ByteMatrix(int i, int i2) {
this.a = (byte[][]) Array.newInstance((Class<?>) byte.class, i2, i);
this.b = i;
this.c = i2;
}
public byte a(int i, int i2) {
return this.a[i2][i];
}
public int b() {
return this.c;
}
public int c() {
return this.b;
}
public String toString() {
StringBuilder sb = new StringBuilder((this.b * 2 * this.c) + 2);
for (int i = 0; i < this.c; i++) {
byte[] bArr = this.a[i];
for (int i2 = 0; i2 < this.b; i2++) {
byte b = bArr[i2];
if (b == 0) {
sb.append(" 0");
} else if (b != 1) {
sb.append(" ");
} else {
sb.append(" 1");
}
}
sb.append('\n');
}
return sb.toString();
}
public byte[][] a() {
return this.a;
}
public void a(int i, int i2, int i3) {
this.a[i2][i] = (byte) i3;
}
public void a(int i, int i2, boolean z) {
this.a[i2][i] = z ? (byte) 1 : (byte) 0;
}
public void a(byte b) {
for (byte[] bArr : this.a) {
Arrays.fill(bArr, b);
}
}
}

View File

@@ -0,0 +1,459 @@
package com.google.zxing.qrcode.encoder;
import com.google.zxing.EncodeHintType;
import com.google.zxing.WriterException;
import com.google.zxing.common.BitArray;
import com.google.zxing.common.CharacterSetECI;
import com.google.zxing.common.reedsolomon.GenericGF;
import com.google.zxing.common.reedsolomon.ReedSolomonEncoder;
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
import com.google.zxing.qrcode.decoder.Mode;
import com.google.zxing.qrcode.decoder.Version;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Map;
/* loaded from: classes.dex */
public final class Encoder {
private static final int[] a = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 36, -1, -1, -1, 37, 38, -1, -1, -1, -1, 39, 40, -1, 41, 42, 43, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 44, -1, -1, -1, -1, -1, -1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1};
/* renamed from: com.google.zxing.qrcode.encoder.Encoder$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) {
}
}
}
private static int a(ByteMatrix byteMatrix) {
return MaskUtil.a(byteMatrix) + MaskUtil.b(byteMatrix) + MaskUtil.c(byteMatrix) + MaskUtil.d(byteMatrix);
}
static void b(CharSequence charSequence, BitArray bitArray) {
int length = charSequence.length();
int i = 0;
while (i < length) {
int charAt = charSequence.charAt(i) - '0';
int i2 = i + 2;
if (i2 < length) {
bitArray.a((charAt * 100) + ((charSequence.charAt(i + 1) - '0') * 10) + (charSequence.charAt(i2) - '0'), 10);
i += 3;
} else {
i++;
if (i < length) {
bitArray.a((charAt * 10) + (charSequence.charAt(i) - '0'), 7);
i = i2;
} else {
bitArray.a(charAt, 4);
}
}
}
}
public static QRCode a(String str, ErrorCorrectionLevel errorCorrectionLevel, Map<EncodeHintType, ?> map) throws WriterException {
Version a2;
CharacterSetECI characterSetECIByName;
boolean z = map != null && map.containsKey(EncodeHintType.CHARACTER_SET);
String obj = z ? map.get(EncodeHintType.CHARACTER_SET).toString() : "ISO-8859-1";
Mode a3 = a(str, obj);
BitArray bitArray = new BitArray();
if (a3 == Mode.BYTE && z && (characterSetECIByName = CharacterSetECI.getCharacterSetECIByName(obj)) != null) {
a(characterSetECIByName, bitArray);
}
if ((map != null && map.containsKey(EncodeHintType.GS1_FORMAT)) && Boolean.valueOf(map.get(EncodeHintType.GS1_FORMAT).toString()).booleanValue()) {
a(Mode.FNC1_FIRST_POSITION, bitArray);
}
a(a3, bitArray);
BitArray bitArray2 = new BitArray();
a(str, a3, bitArray2, obj);
if (map != null && map.containsKey(EncodeHintType.QR_VERSION)) {
a2 = Version.c(Integer.parseInt(map.get(EncodeHintType.QR_VERSION).toString()));
if (!a(a(a3, bitArray, bitArray2, a2), a2, errorCorrectionLevel)) {
throw new WriterException("Data too big for requested version");
}
} else {
a2 = a(errorCorrectionLevel, a3, bitArray, bitArray2);
}
BitArray bitArray3 = new BitArray();
bitArray3.a(bitArray);
a(a3 == Mode.BYTE ? bitArray2.i() : str.length(), a2, a3, bitArray3);
bitArray3.a(bitArray2);
Version.ECBlocks a4 = a2.a(errorCorrectionLevel);
int d = a2.d() - a4.d();
a(d, bitArray3);
BitArray a5 = a(bitArray3, a2.d(), d, a4.c());
QRCode qRCode = new QRCode();
qRCode.a(errorCorrectionLevel);
qRCode.a(a3);
qRCode.a(a2);
int c = a2.c();
ByteMatrix byteMatrix = new ByteMatrix(c, c);
int a6 = a(a5, errorCorrectionLevel, a2, byteMatrix);
qRCode.a(a6);
MatrixUtil.a(a5, errorCorrectionLevel, a2, a6, byteMatrix);
qRCode.a(byteMatrix);
return qRCode;
}
private static Version a(ErrorCorrectionLevel errorCorrectionLevel, Mode mode, BitArray bitArray, BitArray bitArray2) throws WriterException {
return a(a(mode, bitArray, bitArray2, a(a(mode, bitArray, bitArray2, Version.c(1)), errorCorrectionLevel)), errorCorrectionLevel);
}
private static int a(Mode mode, BitArray bitArray, BitArray bitArray2, Version version) {
return bitArray.h() + mode.getCharacterCountBits(version) + bitArray2.h();
}
static int a(int i) {
int[] iArr = a;
if (i < iArr.length) {
return iArr[i];
}
return -1;
}
private static Mode a(String str, String str2) {
if ("Shift_JIS".equals(str2) && a(str)) {
return Mode.KANJI;
}
boolean z = false;
boolean z2 = false;
for (int i = 0; i < str.length(); i++) {
char charAt = str.charAt(i);
if (charAt >= '0' && charAt <= '9') {
z2 = true;
} else {
if (a(charAt) == -1) {
return Mode.BYTE;
}
z = true;
}
}
if (z) {
return Mode.ALPHANUMERIC;
}
if (z2) {
return Mode.NUMERIC;
}
return Mode.BYTE;
}
private static boolean a(String str) {
try {
byte[] bytes = str.getBytes("Shift_JIS");
int length = bytes.length;
if (length % 2 != 0) {
return false;
}
for (int i = 0; i < length; i += 2) {
int i2 = bytes[i] & 255;
if ((i2 < 129 || i2 > 159) && (i2 < 224 || i2 > 235)) {
return false;
}
}
return true;
} catch (UnsupportedEncodingException unused) {
return false;
}
}
private static int a(BitArray bitArray, ErrorCorrectionLevel errorCorrectionLevel, Version version, ByteMatrix byteMatrix) throws WriterException {
int i = Integer.MAX_VALUE;
int i2 = -1;
for (int i3 = 0; i3 < 8; i3++) {
MatrixUtil.a(bitArray, errorCorrectionLevel, version, i3, byteMatrix);
int a2 = a(byteMatrix);
if (a2 < i) {
i2 = i3;
i = a2;
}
}
return i2;
}
private static Version a(int i, ErrorCorrectionLevel errorCorrectionLevel) throws WriterException {
for (int i2 = 1; i2 <= 40; i2++) {
Version c = Version.c(i2);
if (a(i, c, errorCorrectionLevel)) {
return c;
}
}
throw new WriterException("Data too big");
}
private static boolean a(int i, Version version, ErrorCorrectionLevel errorCorrectionLevel) {
return version.d() - version.a(errorCorrectionLevel).d() >= (i + 7) / 8;
}
static void a(int i, BitArray bitArray) throws WriterException {
int i2 = i << 3;
if (bitArray.h() <= i2) {
for (int i3 = 0; i3 < 4 && bitArray.h() < i2; i3++) {
bitArray.a(false);
}
int h = bitArray.h() & 7;
if (h > 0) {
while (h < 8) {
bitArray.a(false);
h++;
}
}
int i4 = i - bitArray.i();
for (int i5 = 0; i5 < i4; i5++) {
bitArray.a((i5 & 1) == 0 ? 236 : 17, 8);
}
if (bitArray.h() != i2) {
throw new WriterException("Bits size does not equal capacity");
}
return;
}
throw new WriterException("data bits cannot fit in the QR Code" + bitArray.h() + " > " + i2);
}
static void a(int i, int i2, int i3, int i4, int[] iArr, int[] iArr2) throws WriterException {
if (i4 < i3) {
int i5 = i % i3;
int i6 = i3 - i5;
int i7 = i / i3;
int i8 = i7 + 1;
int i9 = i2 / i3;
int i10 = i9 + 1;
int i11 = i7 - i9;
int i12 = i8 - i10;
if (i11 != i12) {
throw new WriterException("EC bytes mismatch");
}
if (i3 != i6 + i5) {
throw new WriterException("RS blocks mismatch");
}
if (i != ((i9 + i11) * i6) + ((i10 + i12) * i5)) {
throw new WriterException("Total bytes mismatch");
}
if (i4 < i6) {
iArr[0] = i9;
iArr2[0] = i11;
return;
} else {
iArr[0] = i10;
iArr2[0] = i12;
return;
}
}
throw new WriterException("Block ID too large");
}
static BitArray a(BitArray bitArray, int i, int i2, int i3) throws WriterException {
if (bitArray.i() == i2) {
ArrayList arrayList = new ArrayList(i3);
int i4 = 0;
int i5 = 0;
int i6 = 0;
for (int i7 = 0; i7 < i3; i7++) {
int[] iArr = new int[1];
int[] iArr2 = new int[1];
a(i, i2, i3, i7, iArr, iArr2);
int i8 = iArr[0];
byte[] bArr = new byte[i8];
bitArray.a(i4 << 3, bArr, 0, i8);
byte[] a2 = a(bArr, iArr2[0]);
arrayList.add(new BlockPair(bArr, a2));
i5 = Math.max(i5, i8);
i6 = Math.max(i6, a2.length);
i4 += iArr[0];
}
if (i2 == i4) {
BitArray bitArray2 = new BitArray();
for (int i9 = 0; i9 < i5; i9++) {
Iterator it = arrayList.iterator();
while (it.hasNext()) {
byte[] a3 = ((BlockPair) it.next()).a();
if (i9 < a3.length) {
bitArray2.a(a3[i9], 8);
}
}
}
for (int i10 = 0; i10 < i6; i10++) {
Iterator it2 = arrayList.iterator();
while (it2.hasNext()) {
byte[] b = ((BlockPair) it2.next()).b();
if (i10 < b.length) {
bitArray2.a(b[i10], 8);
}
}
}
if (i == bitArray2.i()) {
return bitArray2;
}
throw new WriterException("Interleaving error: " + i + " and " + bitArray2.i() + " differ.");
}
throw new WriterException("Data bytes does not match offset");
}
throw new WriterException("Number of bits and data bytes does not match");
}
static byte[] a(byte[] bArr, int i) {
int length = bArr.length;
int[] iArr = new int[length + i];
for (int i2 = 0; i2 < length; i2++) {
iArr[i2] = bArr[i2] & 255;
}
new ReedSolomonEncoder(GenericGF.l).a(iArr, i);
byte[] bArr2 = new byte[i];
for (int i3 = 0; i3 < i; i3++) {
bArr2[i3] = (byte) iArr[length + i3];
}
return bArr2;
}
static void a(Mode mode, BitArray bitArray) {
bitArray.a(mode.getBits(), 4);
}
static void a(int i, Version version, Mode mode, BitArray bitArray) throws WriterException {
int characterCountBits = mode.getCharacterCountBits(version);
int i2 = 1 << characterCountBits;
if (i < i2) {
bitArray.a(i, characterCountBits);
return;
}
throw new WriterException(i + " is bigger than " + (i2 - 1));
}
static void a(String str, Mode mode, BitArray bitArray, String str2) throws WriterException {
int i = AnonymousClass1.a[mode.ordinal()];
if (i == 1) {
b(str, bitArray);
return;
}
if (i == 2) {
a((CharSequence) str, bitArray);
} else if (i == 3) {
a(str, bitArray, str2);
} else {
if (i == 4) {
a(str, bitArray);
return;
}
throw new WriterException("Invalid mode: ".concat(String.valueOf(mode)));
}
}
static void a(CharSequence charSequence, BitArray bitArray) throws WriterException {
int length = charSequence.length();
int i = 0;
while (i < length) {
int a2 = a(charSequence.charAt(i));
if (a2 == -1) {
throw new WriterException();
}
int i2 = i + 1;
if (i2 < length) {
int a3 = a(charSequence.charAt(i2));
if (a3 != -1) {
bitArray.a((a2 * 45) + a3, 11);
i += 2;
} else {
throw new WriterException();
}
} else {
bitArray.a(a2, 6);
i = i2;
}
}
}
static void a(String str, BitArray bitArray, String str2) throws WriterException {
try {
for (byte b : str.getBytes(str2)) {
bitArray.a(b, 8);
}
} catch (UnsupportedEncodingException e) {
throw new WriterException(e);
}
}
/* JADX WARN: Removed duplicated region for block: B:11:0x0035 A[LOOP:0: B:4:0x0008->B:11:0x0035, LOOP_END] */
/* JADX WARN: Removed duplicated region for block: B:12:0x0044 A[SYNTHETIC] */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct code enable 'Show inconsistent code' option in preferences
*/
static void a(java.lang.String r6, com.google.zxing.common.BitArray r7) throws com.google.zxing.WriterException {
/*
java.lang.String r0 = "Shift_JIS"
byte[] r6 = r6.getBytes(r0) // Catch: java.io.UnsupportedEncodingException -> L4d
int r0 = r6.length
r1 = 0
L8:
if (r1 >= r0) goto L4c
r2 = r6[r1]
r2 = r2 & 255(0xff, float:3.57E-43)
int r3 = r1 + 1
r3 = r6[r3]
r3 = r3 & 255(0xff, float:3.57E-43)
int r2 = r2 << 8
r2 = r2 | r3
r3 = 33088(0x8140, float:4.6366E-41)
r4 = -1
if (r2 < r3) goto L24
r5 = 40956(0x9ffc, float:5.7392E-41)
if (r2 > r5) goto L24
L22:
int r2 = r2 - r3
goto L33
L24:
r3 = 57408(0xe040, float:8.0446E-41)
if (r2 < r3) goto L32
r3 = 60351(0xebbf, float:8.457E-41)
if (r2 > r3) goto L32
r3 = 49472(0xc140, float:6.9325E-41)
goto L22
L32:
r2 = -1
L33:
if (r2 == r4) goto L44
int r3 = r2 >> 8
int r3 = r3 * 192
r2 = r2 & 255(0xff, float:3.57E-43)
int r3 = r3 + r2
r2 = 13
r7.a(r3, r2)
int r1 = r1 + 2
goto L8
L44:
com.google.zxing.WriterException r6 = new com.google.zxing.WriterException
java.lang.String r7 = "Invalid byte sequence"
r6.<init>(r7)
throw r6
L4c:
return
L4d:
r6 = move-exception
com.google.zxing.WriterException r7 = new com.google.zxing.WriterException
r7.<init>(r6)
throw r7
*/
throw new UnsupportedOperationException("Method not decompiled: com.google.zxing.qrcode.encoder.Encoder.a(java.lang.String, com.google.zxing.common.BitArray):void");
}
private static void a(CharacterSetECI characterSetECI, BitArray bitArray) {
bitArray.a(Mode.ECI.getBits(), 4);
bitArray.a(characterSetECI.getValue(), 8);
}
}

View File

@@ -0,0 +1,204 @@
package com.google.zxing.qrcode.encoder;
/* loaded from: classes.dex */
final class MaskUtil {
static int a(ByteMatrix byteMatrix) {
return a(byteMatrix, true) + a(byteMatrix, false);
}
static int b(ByteMatrix byteMatrix) {
byte[][] a = byteMatrix.a();
int c = byteMatrix.c();
int b = byteMatrix.b();
int i = 0;
int i2 = 0;
while (i < b - 1) {
byte[] bArr = a[i];
int i3 = i2;
int i4 = 0;
while (i4 < c - 1) {
byte b2 = bArr[i4];
int i5 = i4 + 1;
if (b2 == bArr[i5]) {
int i6 = i + 1;
if (b2 == a[i6][i4] && b2 == a[i6][i5]) {
i3++;
}
}
i4 = i5;
}
i++;
i2 = i3;
}
return i2 * 3;
}
static int c(ByteMatrix byteMatrix) {
byte[][] a = byteMatrix.a();
int c = byteMatrix.c();
int b = byteMatrix.b();
int i = 0;
int i2 = 0;
while (i < b) {
int i3 = i2;
for (int i4 = 0; i4 < c; i4++) {
byte[] bArr = a[i];
int i5 = i4 + 6;
if (i5 < c && bArr[i4] == 1 && bArr[i4 + 1] == 0 && bArr[i4 + 2] == 1 && bArr[i4 + 3] == 1 && bArr[i4 + 4] == 1 && bArr[i4 + 5] == 0 && bArr[i5] == 1 && (a(bArr, i4 - 4, i4) || a(bArr, i4 + 7, i4 + 11))) {
i3++;
}
int i6 = i + 6;
if (i6 < b && a[i][i4] == 1 && a[i + 1][i4] == 0 && a[i + 2][i4] == 1 && a[i + 3][i4] == 1 && a[i + 4][i4] == 1 && a[i + 5][i4] == 0 && a[i6][i4] == 1 && (a(a, i4, i - 4, i) || a(a, i4, i + 7, i + 11))) {
i3++;
}
}
i++;
i2 = i3;
}
return i2 * 40;
}
static int d(ByteMatrix byteMatrix) {
byte[][] a = byteMatrix.a();
int c = byteMatrix.c();
int b = byteMatrix.b();
int i = 0;
int i2 = 0;
while (i < b) {
byte[] bArr = a[i];
int i3 = i2;
for (int i4 = 0; i4 < c; i4++) {
if (bArr[i4] == 1) {
i3++;
}
}
i++;
i2 = i3;
}
int b2 = byteMatrix.b() * byteMatrix.c();
return ((Math.abs((i2 << 1) - b2) * 10) / b2) * 10;
}
private static boolean a(byte[] bArr, int i, int i2) {
int min = Math.min(i2, bArr.length);
for (int max = Math.max(i, 0); max < min; max++) {
if (bArr[max] == 1) {
return false;
}
}
return true;
}
private static boolean a(byte[][] bArr, int i, int i2, int i3) {
int min = Math.min(i3, bArr.length);
for (int max = Math.max(i2, 0); max < min; max++) {
if (bArr[max][i] == 1) {
return false;
}
}
return true;
}
/* JADX WARN: Can't fix incorrect switch cases order, some code will duplicate */
/* JADX WARN: Removed duplicated region for block: B:10:0x0040 A[RETURN] */
/* JADX WARN: Removed duplicated region for block: B:9:0x003f A[RETURN] */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct code enable 'Show inconsistent code' option in preferences
*/
static boolean a(int r1, int r2, int r3) {
/*
r0 = 1
switch(r1) {
case 0: goto L3a;
case 1: goto L3b;
case 2: goto L37;
case 3: goto L33;
case 4: goto L2e;
case 5: goto L26;
case 6: goto L1d;
case 7: goto L14;
default: goto L4;
}
L4:
java.lang.IllegalArgumentException r2 = new java.lang.IllegalArgumentException
java.lang.String r1 = java.lang.String.valueOf(r1)
java.lang.String r3 = "Invalid mask pattern: "
java.lang.String r1 = r3.concat(r1)
r2.<init>(r1)
throw r2
L14:
int r1 = r3 * r2
int r1 = r1 % 3
int r3 = r3 + r2
r2 = r3 & 1
int r1 = r1 + r2
goto L24
L1d:
int r3 = r3 * r2
r1 = r3 & 1
int r3 = r3 % 3
int r1 = r1 + r3
L24:
r1 = r1 & r0
goto L3d
L26:
int r3 = r3 * r2
r1 = r3 & 1
int r3 = r3 % 3
int r1 = r1 + r3
goto L3d
L2e:
int r3 = r3 / 2
int r2 = r2 / 3
goto L3a
L33:
int r3 = r3 + r2
int r1 = r3 % 3
goto L3d
L37:
int r1 = r2 % 3
goto L3d
L3a:
int r3 = r3 + r2
L3b:
r1 = r3 & 1
L3d:
if (r1 != 0) goto L40
return r0
L40:
r1 = 0
return r1
*/
throw new UnsupportedOperationException("Method not decompiled: com.google.zxing.qrcode.encoder.MaskUtil.a(int, int, int):boolean");
}
private static int a(ByteMatrix byteMatrix, boolean z) {
int b = z ? byteMatrix.b() : byteMatrix.c();
int c = z ? byteMatrix.c() : byteMatrix.b();
byte[][] a = byteMatrix.a();
int i = 0;
for (int i2 = 0; i2 < b; i2++) {
int i3 = i;
int i4 = 0;
byte b2 = -1;
for (int i5 = 0; i5 < c; i5++) {
byte b3 = z ? a[i2][i5] : a[i5][i2];
if (b3 == b2) {
i4++;
} else {
if (i4 >= 5) {
i3 += (i4 - 5) + 3;
}
i4 = 1;
b2 = b3;
}
}
if (i4 >= 5) {
i3 += (i4 - 5) + 3;
}
i = i3;
}
return i;
}
}

View File

@@ -0,0 +1,246 @@
package com.google.zxing.qrcode.encoder;
import com.google.zxing.WriterException;
import com.google.zxing.common.BitArray;
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
import com.google.zxing.qrcode.decoder.Version;
import com.ubtrobot.jimu.robotapi.PeripheralType;
/* loaded from: classes.dex */
final class MatrixUtil {
private static final int[][] a = {new int[]{1, 1, 1, 1, 1, 1, 1}, new int[]{1, 0, 0, 0, 0, 0, 1}, new int[]{1, 0, 1, 1, 1, 0, 1}, new int[]{1, 0, 1, 1, 1, 0, 1}, new int[]{1, 0, 1, 1, 1, 0, 1}, new int[]{1, 0, 0, 0, 0, 0, 1}, new int[]{1, 1, 1, 1, 1, 1, 1}};
private static final int[][] b = {new int[]{1, 1, 1, 1, 1}, new int[]{1, 0, 0, 0, 1}, new int[]{1, 0, 1, 0, 1}, new int[]{1, 0, 0, 0, 1}, new int[]{1, 1, 1, 1, 1}};
private static final int[][] c = {new int[]{-1, -1, -1, -1, -1, -1, -1}, new int[]{6, 18, -1, -1, -1, -1, -1}, new int[]{6, 22, -1, -1, -1, -1, -1}, new int[]{6, 26, -1, -1, -1, -1, -1}, new int[]{6, 30, -1, -1, -1, -1, -1}, new int[]{6, 34, -1, -1, -1, -1, -1}, new int[]{6, 22, 38, -1, -1, -1, -1}, new int[]{6, 24, 42, -1, -1, -1, -1}, new int[]{6, 26, 46, -1, -1, -1, -1}, new int[]{6, 28, 50, -1, -1, -1, -1}, new int[]{6, 30, 54, -1, -1, -1, -1}, new int[]{6, 32, 58, -1, -1, -1, -1}, new int[]{6, 34, 62, -1, -1, -1, -1}, new int[]{6, 26, 46, 66, -1, -1, -1}, new int[]{6, 26, 48, 70, -1, -1, -1}, new int[]{6, 26, 50, 74, -1, -1, -1}, new int[]{6, 30, 54, 78, -1, -1, -1}, new int[]{6, 30, 56, 82, -1, -1, -1}, new int[]{6, 30, 58, 86, -1, -1, -1}, new int[]{6, 34, 62, 90, -1, -1, -1}, new int[]{6, 28, 50, 72, 94, -1, -1}, new int[]{6, 26, 50, 74, 98, -1, -1}, new int[]{6, 30, 54, 78, 102, -1, -1}, new int[]{6, 28, 54, 80, 106, -1, -1}, new int[]{6, 32, 58, 84, 110, -1, -1}, new int[]{6, 30, 58, 86, 114, -1, -1}, new int[]{6, 34, 62, 90, 118, -1, -1}, new int[]{6, 26, 50, 74, 98, 122, -1}, new int[]{6, 30, 54, 78, 102, 126, -1}, new int[]{6, 26, 52, 78, 104, 130, -1}, new int[]{6, 30, 56, 82, 108, 134, -1}, new int[]{6, 34, 60, 86, 112, 138, -1}, new int[]{6, 30, 58, 86, 114, 142, -1}, new int[]{6, 34, 62, 90, 118, 146, -1}, new int[]{6, 30, 54, 78, 102, 126, 150}, new int[]{6, 24, 50, 76, 102, PeripheralType.SERVO, 154}, new int[]{6, 28, 54, 80, 106, 132, 158}, new int[]{6, 32, 58, 84, 110, 136, 162}, new int[]{6, 26, 54, 82, 110, 138, 166}, new int[]{6, 30, 58, 86, 114, 142, 170}};
private static final int[][] d = {new int[]{8, 0}, new int[]{8, 1}, new int[]{8, 2}, new int[]{8, 3}, new int[]{8, 4}, new int[]{8, 5}, new int[]{8, 7}, new int[]{8, 8}, new int[]{7, 8}, new int[]{5, 8}, new int[]{4, 8}, new int[]{3, 8}, new int[]{2, 8}, new int[]{1, 8}, new int[]{0, 8}};
static void a(ByteMatrix byteMatrix) {
byteMatrix.a((byte) -1);
}
private static void b(ByteMatrix byteMatrix) throws WriterException {
if (byteMatrix.a(8, byteMatrix.b() - 8) == 0) {
throw new WriterException();
}
byteMatrix.a(8, byteMatrix.b() - 8, 1);
}
private static boolean b(int i) {
return i == -1;
}
static void c(Version version, ByteMatrix byteMatrix) throws WriterException {
if (version.e() < 7) {
return;
}
BitArray bitArray = new BitArray();
a(version, bitArray);
int i = 0;
int i2 = 17;
while (i < 6) {
int i3 = i2;
for (int i4 = 0; i4 < 3; i4++) {
boolean a2 = bitArray.a(i3);
i3--;
byteMatrix.a(i, (byteMatrix.b() - 11) + i4, a2);
byteMatrix.a((byteMatrix.b() - 11) + i4, i, a2);
}
i++;
i2 = i3;
}
}
private static void d(ByteMatrix byteMatrix) {
int i = 8;
while (i < byteMatrix.c() - 8) {
int i2 = i + 1;
int i3 = i2 % 2;
if (b(byteMatrix.a(i, 6))) {
byteMatrix.a(i, 6, i3);
}
if (b(byteMatrix.a(6, i))) {
byteMatrix.a(6, i, i3);
}
i = i2;
}
}
static void a(BitArray bitArray, ErrorCorrectionLevel errorCorrectionLevel, Version version, int i, ByteMatrix byteMatrix) throws WriterException {
a(byteMatrix);
a(version, byteMatrix);
a(errorCorrectionLevel, i, byteMatrix);
c(version, byteMatrix);
a(bitArray, i, byteMatrix);
}
private static void b(int i, int i2, ByteMatrix byteMatrix) {
for (int i3 = 0; i3 < 5; i3++) {
int[] iArr = b[i3];
for (int i4 = 0; i4 < 5; i4++) {
byteMatrix.a(i + i4, i2 + i3, iArr[i4]);
}
}
}
private static void b(Version version, ByteMatrix byteMatrix) {
if (version.e() < 2) {
return;
}
int[] iArr = c[version.e() - 1];
for (int i : iArr) {
if (i >= 0) {
for (int i2 : iArr) {
if (i2 >= 0 && b(byteMatrix.a(i2, i))) {
b(i2 - 2, i - 2, byteMatrix);
}
}
}
}
}
static void a(Version version, ByteMatrix byteMatrix) throws WriterException {
c(byteMatrix);
b(byteMatrix);
b(version, byteMatrix);
d(byteMatrix);
}
private static void c(int i, int i2, ByteMatrix byteMatrix) {
for (int i3 = 0; i3 < 7; i3++) {
int[] iArr = a[i3];
for (int i4 = 0; i4 < 7; i4++) {
byteMatrix.a(i + i4, i2 + i3, iArr[i4]);
}
}
}
private static void d(int i, int i2, ByteMatrix byteMatrix) throws WriterException {
for (int i3 = 0; i3 < 7; i3++) {
int i4 = i2 + i3;
if (b(byteMatrix.a(i, i4))) {
byteMatrix.a(i, i4, 0);
} else {
throw new WriterException();
}
}
}
private static void c(ByteMatrix byteMatrix) throws WriterException {
int length = a[0].length;
c(0, 0, byteMatrix);
c(byteMatrix.c() - length, 0, byteMatrix);
c(0, byteMatrix.c() - length, byteMatrix);
a(0, 7, byteMatrix);
a(byteMatrix.c() - 8, 7, byteMatrix);
a(0, byteMatrix.c() - 8, byteMatrix);
d(7, 0, byteMatrix);
d((byteMatrix.b() - 7) - 1, 0, byteMatrix);
d(7, byteMatrix.b() - 7, byteMatrix);
}
static void a(ErrorCorrectionLevel errorCorrectionLevel, int i, ByteMatrix byteMatrix) throws WriterException {
BitArray bitArray = new BitArray();
a(errorCorrectionLevel, i, bitArray);
for (int i2 = 0; i2 < bitArray.h(); i2++) {
boolean a2 = bitArray.a((bitArray.h() - 1) - i2);
int[] iArr = d[i2];
byteMatrix.a(iArr[0], iArr[1], a2);
if (i2 < 8) {
byteMatrix.a((byteMatrix.c() - i2) - 1, 8, a2);
} else {
byteMatrix.a(8, (byteMatrix.b() - 7) + (i2 - 8), a2);
}
}
}
static void a(BitArray bitArray, int i, ByteMatrix byteMatrix) throws WriterException {
boolean z;
int c2 = byteMatrix.c() - 1;
int b2 = byteMatrix.b() - 1;
int i2 = 0;
int i3 = -1;
while (c2 > 0) {
if (c2 == 6) {
c2--;
}
while (b2 >= 0 && b2 < byteMatrix.b()) {
int i4 = i2;
for (int i5 = 0; i5 < 2; i5++) {
int i6 = c2 - i5;
if (b(byteMatrix.a(i6, b2))) {
if (i4 < bitArray.h()) {
z = bitArray.a(i4);
i4++;
} else {
z = false;
}
if (i != -1 && MaskUtil.a(i, i6, b2)) {
z = !z;
}
byteMatrix.a(i6, b2, z);
}
}
b2 += i3;
i2 = i4;
}
i3 = -i3;
b2 += i3;
c2 -= 2;
}
if (i2 == bitArray.h()) {
return;
}
throw new WriterException("Not all bits consumed: " + i2 + '/' + bitArray.h());
}
static int a(int i) {
return 32 - Integer.numberOfLeadingZeros(i);
}
static int a(int i, int i2) {
if (i2 != 0) {
int a2 = a(i2);
int i3 = i << (a2 - 1);
while (a(i3) >= a2) {
i3 ^= i2 << (a(i3) - a2);
}
return i3;
}
throw new IllegalArgumentException("0 polynomial");
}
static void a(ErrorCorrectionLevel errorCorrectionLevel, int i, BitArray bitArray) throws WriterException {
if (QRCode.b(i)) {
int bits = (errorCorrectionLevel.getBits() << 3) | i;
bitArray.a(bits, 5);
bitArray.a(a(bits, 1335), 10);
BitArray bitArray2 = new BitArray();
bitArray2.a(21522, 15);
bitArray.b(bitArray2);
if (bitArray.h() == 15) {
return;
}
throw new WriterException("should not happen but we got: " + bitArray.h());
}
throw new WriterException("Invalid mask pattern");
}
static void a(Version version, BitArray bitArray) throws WriterException {
bitArray.a(version.e(), 6);
bitArray.a(a(version.e(), 7973), 12);
if (bitArray.h() == 18) {
return;
}
throw new WriterException("should not happen but we got: " + bitArray.h());
}
private static void a(int i, int i2, ByteMatrix byteMatrix) throws WriterException {
for (int i3 = 0; i3 < 8; i3++) {
int i4 = i + i3;
if (b(byteMatrix.a(i4, i2))) {
byteMatrix.a(i4, i2, 0);
} else {
throw new WriterException();
}
}
}
}

View File

@@ -0,0 +1,63 @@
package com.google.zxing.qrcode.encoder;
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
import com.google.zxing.qrcode.decoder.Mode;
import com.google.zxing.qrcode.decoder.Version;
/* loaded from: classes.dex */
public final class QRCode {
private Mode a;
private ErrorCorrectionLevel b;
private Version c;
private int d = -1;
private ByteMatrix e;
public static boolean b(int i) {
return i >= 0 && i < 8;
}
public ByteMatrix a() {
return this.e;
}
public String toString() {
StringBuilder sb = new StringBuilder(200);
sb.append("<<\n");
sb.append(" mode: ");
sb.append(this.a);
sb.append("\n ecLevel: ");
sb.append(this.b);
sb.append("\n version: ");
sb.append(this.c);
sb.append("\n maskPattern: ");
sb.append(this.d);
if (this.e == null) {
sb.append("\n matrix: null\n");
} else {
sb.append("\n matrix:\n");
sb.append(this.e);
}
sb.append(">>\n");
return sb.toString();
}
public void a(Mode mode) {
this.a = mode;
}
public void a(ErrorCorrectionLevel errorCorrectionLevel) {
this.b = errorCorrectionLevel;
}
public void a(Version version) {
this.c = version;
}
public void a(int i) {
this.d = i;
}
public void a(ByteMatrix byteMatrix) {
this.e = byteMatrix;
}
}