Add decompiled APK source code (JADX)

- 28,932 files
- Full Java source code
- Smali files
- Resources

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
2026-02-18 14:52:23 -08:00
parent cc210a65ea
commit f9d20bb3fc
26991 changed files with 2541449 additions and 0 deletions

View File

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

View File

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

View File

@@ -0,0 +1,516 @@
package com.google.zxing.qrcode.encoder;
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;
/* loaded from: classes3.dex */
public abstract class Encoder {
public static final int[] ALPHANUMERIC_TABLE = {-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};
public static int calculateMaskPenalty(ByteMatrix byteMatrix) {
return MaskUtil.applyMaskPenaltyRule1(byteMatrix) + MaskUtil.applyMaskPenaltyRule2(byteMatrix) + MaskUtil.applyMaskPenaltyRule3(byteMatrix) + MaskUtil.applyMaskPenaltyRule4(byteMatrix);
}
/* JADX WARN: Removed duplicated region for block: B:30:0x009b */
/* JADX WARN: Removed duplicated region for block: B:33:0x00a0 */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public static com.google.zxing.qrcode.encoder.QRCode encode(java.lang.String r6, com.google.zxing.qrcode.decoder.ErrorCorrectionLevel r7, java.util.Map r8) {
/*
if (r8 == 0) goto Lc
com.google.zxing.EncodeHintType r0 = com.google.zxing.EncodeHintType.CHARACTER_SET
boolean r0 = r8.containsKey(r0)
if (r0 == 0) goto Lc
r0 = 1
goto Ld
Lc:
r0 = 0
Ld:
if (r0 == 0) goto L1a
com.google.zxing.EncodeHintType r1 = com.google.zxing.EncodeHintType.CHARACTER_SET
java.lang.Object r1 = r8.get(r1)
java.lang.String r1 = r1.toString()
goto L1c
L1a:
java.lang.String r1 = "ISO-8859-1"
L1c:
com.google.zxing.qrcode.decoder.Mode r2 = chooseMode(r6, r1)
com.google.zxing.common.BitArray r3 = new com.google.zxing.common.BitArray
r3.<init>()
com.google.zxing.qrcode.decoder.Mode r4 = com.google.zxing.qrcode.decoder.Mode.BYTE
if (r2 != r4) goto L34
if (r0 == 0) goto L34
com.google.zxing.common.CharacterSetECI r0 = com.google.zxing.common.CharacterSetECI.getCharacterSetECIByName(r1)
if (r0 == 0) goto L34
appendECI(r0, r3)
L34:
if (r8 == 0) goto L55
com.google.zxing.EncodeHintType r0 = com.google.zxing.EncodeHintType.GS1_FORMAT
boolean r5 = r8.containsKey(r0)
if (r5 == 0) goto L55
java.lang.Object r0 = r8.get(r0)
java.lang.String r0 = r0.toString()
java.lang.Boolean r0 = java.lang.Boolean.valueOf(r0)
boolean r0 = r0.booleanValue()
if (r0 == 0) goto L55
com.google.zxing.qrcode.decoder.Mode r0 = com.google.zxing.qrcode.decoder.Mode.FNC1_FIRST_POSITION
appendModeInfo(r0, r3)
L55:
appendModeInfo(r2, r3)
com.google.zxing.common.BitArray r0 = new com.google.zxing.common.BitArray
r0.<init>()
appendBytes(r6, r2, r0, r1)
if (r8 == 0) goto L8d
com.google.zxing.EncodeHintType r1 = com.google.zxing.EncodeHintType.QR_VERSION
boolean r5 = r8.containsKey(r1)
if (r5 == 0) goto L8d
java.lang.Object r8 = r8.get(r1)
java.lang.String r8 = r8.toString()
int r8 = java.lang.Integer.parseInt(r8)
com.google.zxing.qrcode.decoder.Version r8 = com.google.zxing.qrcode.decoder.Version.getVersionForNumber(r8)
int r1 = calculateBitsNeeded(r2, r3, r0, r8)
boolean r1 = willFit(r1, r8, r7)
if (r1 == 0) goto L85
goto L91
L85:
com.google.zxing.WriterException r6 = new com.google.zxing.WriterException
java.lang.String r7 = "Data too big for requested version"
r6.<init>(r7)
throw r6
L8d:
com.google.zxing.qrcode.decoder.Version r8 = recommendVersion(r7, r2, r3, r0)
L91:
com.google.zxing.common.BitArray r1 = new com.google.zxing.common.BitArray
r1.<init>()
r1.appendBitArray(r3)
if (r2 != r4) goto La0
int r6 = r0.getSizeInBytes()
goto La4
La0:
int r6 = r6.length()
La4:
appendLengthInfo(r6, r8, r2, r1)
r1.appendBitArray(r0)
com.google.zxing.qrcode.decoder.Version$ECBlocks r6 = r8.getECBlocksForLevel(r7)
int r0 = r8.getTotalCodewords()
int r3 = r6.getTotalECCodewords()
int r0 = r0 - r3
terminateBits(r0, r1)
int r3 = r8.getTotalCodewords()
int r6 = r6.getNumBlocks()
com.google.zxing.common.BitArray r6 = interleaveWithECBytes(r1, r3, r0, r6)
com.google.zxing.qrcode.encoder.QRCode r0 = new com.google.zxing.qrcode.encoder.QRCode
r0.<init>()
r0.setECLevel(r7)
r0.setMode(r2)
r0.setVersion(r8)
int r1 = r8.getDimensionForVersion()
com.google.zxing.qrcode.encoder.ByteMatrix r2 = new com.google.zxing.qrcode.encoder.ByteMatrix
r2.<init>(r1, r1)
int r1 = chooseMaskPattern(r6, r7, r8, r2)
r0.setMaskPattern(r1)
com.google.zxing.qrcode.encoder.MatrixUtil.buildMatrix(r6, r7, r8, r1, r2)
r0.setMatrix(r2)
return r0
*/
throw new UnsupportedOperationException("Method not decompiled: com.google.zxing.qrcode.encoder.Encoder.encode(java.lang.String, com.google.zxing.qrcode.decoder.ErrorCorrectionLevel, java.util.Map):com.google.zxing.qrcode.encoder.QRCode");
}
public static Version recommendVersion(ErrorCorrectionLevel errorCorrectionLevel, Mode mode, BitArray bitArray, BitArray bitArray2) {
return chooseVersion(calculateBitsNeeded(mode, bitArray, bitArray2, chooseVersion(calculateBitsNeeded(mode, bitArray, bitArray2, Version.getVersionForNumber(1)), errorCorrectionLevel)), errorCorrectionLevel);
}
public static int calculateBitsNeeded(Mode mode, BitArray bitArray, BitArray bitArray2, Version version) {
return bitArray.getSize() + mode.getCharacterCountBits(version) + bitArray2.getSize();
}
public static int getAlphanumericCode(int i) {
int[] iArr = ALPHANUMERIC_TABLE;
if (i < iArr.length) {
return iArr[i];
}
return -1;
}
public static Mode chooseMode(String str, String str2) {
if ("Shift_JIS".equals(str2) && isOnlyDoubleByteKanji(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 (getAlphanumericCode(charAt) == -1) {
return Mode.BYTE;
}
z = true;
}
}
if (z) {
return Mode.ALPHANUMERIC;
}
if (z2) {
return Mode.NUMERIC;
}
return Mode.BYTE;
}
public static boolean isOnlyDoubleByteKanji(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;
}
}
public static int chooseMaskPattern(BitArray bitArray, ErrorCorrectionLevel errorCorrectionLevel, Version version, ByteMatrix byteMatrix) {
int i = Integer.MAX_VALUE;
int i2 = -1;
for (int i3 = 0; i3 < 8; i3++) {
MatrixUtil.buildMatrix(bitArray, errorCorrectionLevel, version, i3, byteMatrix);
int calculateMaskPenalty = calculateMaskPenalty(byteMatrix);
if (calculateMaskPenalty < i) {
i2 = i3;
i = calculateMaskPenalty;
}
}
return i2;
}
public static Version chooseVersion(int i, ErrorCorrectionLevel errorCorrectionLevel) {
for (int i2 = 1; i2 <= 40; i2++) {
Version versionForNumber = Version.getVersionForNumber(i2);
if (willFit(i, versionForNumber, errorCorrectionLevel)) {
return versionForNumber;
}
}
throw new WriterException("Data too big");
}
public static boolean willFit(int i, Version version, ErrorCorrectionLevel errorCorrectionLevel) {
return version.getTotalCodewords() - version.getECBlocksForLevel(errorCorrectionLevel).getTotalECCodewords() >= (i + 7) / 8;
}
public static void terminateBits(int i, BitArray bitArray) {
int i2 = i << 3;
if (bitArray.getSize() > i2) {
throw new WriterException("data bits cannot fit in the QR Code" + bitArray.getSize() + " > " + i2);
}
for (int i3 = 0; i3 < 4 && bitArray.getSize() < i2; i3++) {
bitArray.appendBit(false);
}
int size = bitArray.getSize() & 7;
if (size > 0) {
while (size < 8) {
bitArray.appendBit(false);
size++;
}
}
int sizeInBytes = i - bitArray.getSizeInBytes();
for (int i4 = 0; i4 < sizeInBytes; i4++) {
bitArray.appendBits((i4 & 1) == 0 ? 236 : 17, 8);
}
if (bitArray.getSize() != i2) {
throw new WriterException("Bits size does not equal capacity");
}
}
public static void getNumDataBytesAndNumECBytesForBlockID(int i, int i2, int i3, int i4, int[] iArr, int[] iArr2) {
if (i4 >= i3) {
throw new WriterException("Block ID too large");
}
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;
} else {
iArr[0] = i10;
iArr2[0] = i12;
}
}
public static BitArray interleaveWithECBytes(BitArray bitArray, int i, int i2, int i3) {
if (bitArray.getSizeInBytes() != i2) {
throw new WriterException("Number of bits and data bytes does not match");
}
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];
getNumDataBytesAndNumECBytesForBlockID(i, i2, i3, i7, iArr, iArr2);
int i8 = iArr[0];
byte[] bArr = new byte[i8];
bitArray.toBytes(i4 << 3, bArr, 0, i8);
byte[] generateECBytes = generateECBytes(bArr, iArr2[0]);
arrayList.add(new BlockPair(bArr, generateECBytes));
i5 = Math.max(i5, i8);
i6 = Math.max(i6, generateECBytes.length);
i4 += iArr[0];
}
if (i2 != i4) {
throw new WriterException("Data bytes does not match offset");
}
BitArray bitArray2 = new BitArray();
for (int i9 = 0; i9 < i5; i9++) {
Iterator it = arrayList.iterator();
while (it.hasNext()) {
byte[] dataBytes = ((BlockPair) it.next()).getDataBytes();
if (i9 < dataBytes.length) {
bitArray2.appendBits(dataBytes[i9], 8);
}
}
}
for (int i10 = 0; i10 < i6; i10++) {
Iterator it2 = arrayList.iterator();
while (it2.hasNext()) {
byte[] errorCorrectionBytes = ((BlockPair) it2.next()).getErrorCorrectionBytes();
if (i10 < errorCorrectionBytes.length) {
bitArray2.appendBits(errorCorrectionBytes[i10], 8);
}
}
}
if (i == bitArray2.getSizeInBytes()) {
return bitArray2;
}
throw new WriterException("Interleaving error: " + i + " and " + bitArray2.getSizeInBytes() + " differ.");
}
public static byte[] generateECBytes(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.QR_CODE_FIELD_256).encode(iArr, i);
byte[] bArr2 = new byte[i];
for (int i3 = 0; i3 < i; i3++) {
bArr2[i3] = (byte) iArr[length + i3];
}
return bArr2;
}
public static void appendModeInfo(Mode mode, BitArray bitArray) {
bitArray.appendBits(mode.getBits(), 4);
}
public static void appendLengthInfo(int i, Version version, Mode mode, BitArray bitArray) {
int characterCountBits = mode.getCharacterCountBits(version);
int i2 = 1 << characterCountBits;
if (i >= i2) {
throw new WriterException(i + " is bigger than " + (i2 - 1));
}
bitArray.appendBits(i, characterCountBits);
}
/* renamed from: com.google.zxing.qrcode.encoder.Encoder$1, reason: invalid class name */
public static /* synthetic */ class AnonymousClass1 {
public static final /* synthetic */ int[] $SwitchMap$com$google$zxing$qrcode$decoder$Mode;
static {
int[] iArr = new int[Mode.values().length];
$SwitchMap$com$google$zxing$qrcode$decoder$Mode = iArr;
try {
iArr[Mode.NUMERIC.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
$SwitchMap$com$google$zxing$qrcode$decoder$Mode[Mode.ALPHANUMERIC.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
try {
$SwitchMap$com$google$zxing$qrcode$decoder$Mode[Mode.BYTE.ordinal()] = 3;
} catch (NoSuchFieldError unused3) {
}
try {
$SwitchMap$com$google$zxing$qrcode$decoder$Mode[Mode.KANJI.ordinal()] = 4;
} catch (NoSuchFieldError unused4) {
}
}
}
public static void appendBytes(String str, Mode mode, BitArray bitArray, String str2) {
int i = AnonymousClass1.$SwitchMap$com$google$zxing$qrcode$decoder$Mode[mode.ordinal()];
if (i == 1) {
appendNumericBytes(str, bitArray);
return;
}
if (i == 2) {
appendAlphanumericBytes(str, bitArray);
} else if (i == 3) {
append8BitBytes(str, bitArray, str2);
} else {
if (i == 4) {
appendKanjiBytes(str, bitArray);
return;
}
throw new WriterException("Invalid mode: ".concat(String.valueOf(mode)));
}
}
public static void appendNumericBytes(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.appendBits((charAt * 100) + ((charSequence.charAt(i + 1) - '0') * 10) + (charSequence.charAt(i2) - '0'), 10);
i += 3;
} else {
i++;
if (i < length) {
bitArray.appendBits((charAt * 10) + (charSequence.charAt(i) - '0'), 7);
i = i2;
} else {
bitArray.appendBits(charAt, 4);
}
}
}
}
public static void appendAlphanumericBytes(CharSequence charSequence, BitArray bitArray) {
int length = charSequence.length();
int i = 0;
while (i < length) {
int alphanumericCode = getAlphanumericCode(charSequence.charAt(i));
if (alphanumericCode == -1) {
throw new WriterException();
}
int i2 = i + 1;
if (i2 < length) {
int alphanumericCode2 = getAlphanumericCode(charSequence.charAt(i2));
if (alphanumericCode2 == -1) {
throw new WriterException();
}
bitArray.appendBits((alphanumericCode * 45) + alphanumericCode2, 11);
i += 2;
} else {
bitArray.appendBits(alphanumericCode, 6);
i = i2;
}
}
}
public static void append8BitBytes(String str, BitArray bitArray, String str2) {
try {
for (byte b : str.getBytes(str2)) {
bitArray.appendBits(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 add '--show-bad-code' argument
*/
public static void appendKanjiBytes(java.lang.String r6, com.google.zxing.common.BitArray r7) {
/*
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 = r4
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.appendBits(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.appendKanjiBytes(java.lang.String, com.google.zxing.common.BitArray):void");
}
public static void appendECI(CharacterSetECI characterSetECI, BitArray bitArray) {
bitArray.appendBits(Mode.ECI.getBits(), 4);
bitArray.appendBits(characterSetECI.getValue(), 8);
}
}

View File

@@ -0,0 +1,189 @@
package com.google.zxing.qrcode.encoder;
/* loaded from: classes3.dex */
public abstract class MaskUtil {
public static int applyMaskPenaltyRule1(ByteMatrix byteMatrix) {
return applyMaskPenaltyRule1Internal(byteMatrix, true) + applyMaskPenaltyRule1Internal(byteMatrix, false);
}
public static int applyMaskPenaltyRule2(ByteMatrix byteMatrix) {
byte[][] array = byteMatrix.getArray();
int width = byteMatrix.getWidth();
int height = byteMatrix.getHeight();
int i = 0;
for (int i2 = 0; i2 < height - 1; i2++) {
byte[] bArr = array[i2];
int i3 = 0;
while (i3 < width - 1) {
byte b = bArr[i3];
int i4 = i3 + 1;
if (b == bArr[i4]) {
byte[] bArr2 = array[i2 + 1];
if (b == bArr2[i3] && b == bArr2[i4]) {
i++;
}
}
i3 = i4;
}
}
return i * 3;
}
public static int applyMaskPenaltyRule3(ByteMatrix byteMatrix) {
byte[][] array = byteMatrix.getArray();
int width = byteMatrix.getWidth();
int height = byteMatrix.getHeight();
int i = 0;
for (int i2 = 0; i2 < height; i2++) {
for (int i3 = 0; i3 < width; i3++) {
byte[] bArr = array[i2];
int i4 = i3 + 6;
if (i4 < width && bArr[i3] == 1 && bArr[i3 + 1] == 0 && bArr[i3 + 2] == 1 && bArr[i3 + 3] == 1 && bArr[i3 + 4] == 1 && bArr[i3 + 5] == 0 && bArr[i4] == 1 && (isWhiteHorizontal(bArr, i3 - 4, i3) || isWhiteHorizontal(bArr, i3 + 7, i3 + 11))) {
i++;
}
int i5 = i2 + 6;
if (i5 < height && array[i2][i3] == 1 && array[i2 + 1][i3] == 0 && array[i2 + 2][i3] == 1 && array[i2 + 3][i3] == 1 && array[i2 + 4][i3] == 1 && array[i2 + 5][i3] == 0 && array[i5][i3] == 1 && (isWhiteVertical(array, i3, i2 - 4, i2) || isWhiteVertical(array, i3, i2 + 7, i2 + 11))) {
i++;
}
}
}
return i * 40;
}
public static boolean isWhiteHorizontal(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;
}
public static boolean isWhiteVertical(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;
}
public static int applyMaskPenaltyRule4(ByteMatrix byteMatrix) {
byte[][] array = byteMatrix.getArray();
int width = byteMatrix.getWidth();
int height = byteMatrix.getHeight();
int i = 0;
for (int i2 = 0; i2 < height; i2++) {
byte[] bArr = array[i2];
for (int i3 = 0; i3 < width; i3++) {
if (bArr[i3] == 1) {
i++;
}
}
}
int height2 = byteMatrix.getHeight() * byteMatrix.getWidth();
return ((Math.abs((i << 1) - height2) * 10) / height2) * 10;
}
/* JADX WARN: Can't fix incorrect switch cases order, some code will duplicate */
/* JADX WARN: Removed duplicated region for block: B:10:0x003d A[RETURN] */
/* JADX WARN: Removed duplicated region for block: B:9:0x003c A[RETURN] */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public static boolean getDataMaskBit(int r1, int r2, int r3) {
/*
r0 = 1
switch(r1) {
case 0: goto L30;
case 1: goto L31;
case 2: goto L38;
case 3: goto L34;
case 4: goto L2c;
case 5: goto L25;
case 6: goto L1e;
case 7: goto L14;
default: goto L4;
}
L4:
java.lang.IllegalArgumentException r2 = new java.lang.IllegalArgumentException
java.lang.String r3 = "Invalid mask pattern: "
java.lang.String r1 = java.lang.String.valueOf(r1)
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
L1c:
r1 = r1 & r0
goto L3a
L1e:
int r3 = r3 * r2
r1 = r3 & 1
int r3 = r3 % 3
int r1 = r1 + r3
goto L1c
L25:
int r3 = r3 * r2
r1 = r3 & 1
int r3 = r3 % 3
int r1 = r1 + r3
goto L3a
L2c:
int r3 = r3 / 2
int r2 = r2 / 3
L30:
int r3 = r3 + r2
L31:
r1 = r3 & 1
goto L3a
L34:
int r3 = r3 + r2
int r1 = r3 % 3
goto L3a
L38:
int r1 = r2 % 3
L3a:
if (r1 != 0) goto L3d
return r0
L3d:
r1 = 0
return r1
*/
throw new UnsupportedOperationException("Method not decompiled: com.google.zxing.qrcode.encoder.MaskUtil.getDataMaskBit(int, int, int):boolean");
}
public static int applyMaskPenaltyRule1Internal(ByteMatrix byteMatrix, boolean z) {
int height = z ? byteMatrix.getHeight() : byteMatrix.getWidth();
int width = z ? byteMatrix.getWidth() : byteMatrix.getHeight();
byte[][] array = byteMatrix.getArray();
int i = 0;
for (int i2 = 0; i2 < height; i2++) {
byte b = -1;
int i3 = 0;
for (int i4 = 0; i4 < width; i4++) {
byte b2 = z ? array[i2][i4] : array[i4][i2];
if (b2 == b) {
i3++;
} else {
if (i3 >= 5) {
i += i3 - 2;
}
i3 = 1;
b = b2;
}
}
if (i3 >= 5) {
i += i3 - 2;
}
}
return i;
}
}

View File

@@ -0,0 +1,238 @@
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.ironsource.mediationsdk.utils.IronSourceConstants;
/* loaded from: classes3.dex */
public abstract class MatrixUtil {
public static final int[][] POSITION_DETECTION_PATTERN = {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}};
public static final int[][] POSITION_ADJUSTMENT_PATTERN = {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}};
public static final int[][] POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE = {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, IronSourceConstants.REWARDED_VIDEO_DAILY_CAPPED}, new int[]{6, 24, 50, 76, 102, 128, 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}};
public static final int[][] TYPE_INFO_COORDINATES = {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}};
public static boolean isEmpty(int i) {
return i == -1;
}
public static void clearMatrix(ByteMatrix byteMatrix) {
byteMatrix.clear((byte) -1);
}
public static void buildMatrix(BitArray bitArray, ErrorCorrectionLevel errorCorrectionLevel, Version version, int i, ByteMatrix byteMatrix) {
clearMatrix(byteMatrix);
embedBasicPatterns(version, byteMatrix);
embedTypeInfo(errorCorrectionLevel, i, byteMatrix);
maybeEmbedVersionInfo(version, byteMatrix);
embedDataBits(bitArray, i, byteMatrix);
}
public static void embedBasicPatterns(Version version, ByteMatrix byteMatrix) {
embedPositionDetectionPatternsAndSeparators(byteMatrix);
embedDarkDotAtLeftBottomCorner(byteMatrix);
maybeEmbedPositionAdjustmentPatterns(version, byteMatrix);
embedTimingPatterns(byteMatrix);
}
public static void embedTypeInfo(ErrorCorrectionLevel errorCorrectionLevel, int i, ByteMatrix byteMatrix) {
BitArray bitArray = new BitArray();
makeTypeInfoBits(errorCorrectionLevel, i, bitArray);
for (int i2 = 0; i2 < bitArray.getSize(); i2++) {
boolean z = bitArray.get((bitArray.getSize() - 1) - i2);
int[] iArr = TYPE_INFO_COORDINATES[i2];
byteMatrix.set(iArr[0], iArr[1], z);
if (i2 < 8) {
byteMatrix.set((byteMatrix.getWidth() - i2) - 1, 8, z);
} else {
byteMatrix.set(8, (byteMatrix.getHeight() - 7) + (i2 - 8), z);
}
}
}
public static void maybeEmbedVersionInfo(Version version, ByteMatrix byteMatrix) {
if (version.getVersionNumber() < 7) {
return;
}
BitArray bitArray = new BitArray();
makeVersionInfoBits(version, bitArray);
int i = 17;
for (int i2 = 0; i2 < 6; i2++) {
for (int i3 = 0; i3 < 3; i3++) {
boolean z = bitArray.get(i);
i--;
byteMatrix.set(i2, (byteMatrix.getHeight() - 11) + i3, z);
byteMatrix.set((byteMatrix.getHeight() - 11) + i3, i2, z);
}
}
}
public static void embedDataBits(BitArray bitArray, int i, ByteMatrix byteMatrix) {
boolean z;
int width = byteMatrix.getWidth() - 1;
int height = byteMatrix.getHeight() - 1;
int i2 = 0;
int i3 = -1;
while (width > 0) {
if (width == 6) {
width--;
}
while (height >= 0 && height < byteMatrix.getHeight()) {
for (int i4 = 0; i4 < 2; i4++) {
int i5 = width - i4;
if (isEmpty(byteMatrix.get(i5, height))) {
if (i2 < bitArray.getSize()) {
z = bitArray.get(i2);
i2++;
} else {
z = false;
}
if (i != -1 && MaskUtil.getDataMaskBit(i, i5, height)) {
z = !z;
}
byteMatrix.set(i5, height, z);
}
}
height += i3;
}
i3 = -i3;
height += i3;
width -= 2;
}
if (i2 == bitArray.getSize()) {
return;
}
throw new WriterException("Not all bits consumed: " + i2 + '/' + bitArray.getSize());
}
public static int findMSBSet(int i) {
return 32 - Integer.numberOfLeadingZeros(i);
}
public static int calculateBCHCode(int i, int i2) {
if (i2 == 0) {
throw new IllegalArgumentException("0 polynomial");
}
int findMSBSet = findMSBSet(i2);
int i3 = i << (findMSBSet - 1);
while (findMSBSet(i3) >= findMSBSet) {
i3 ^= i2 << (findMSBSet(i3) - findMSBSet);
}
return i3;
}
public static void makeTypeInfoBits(ErrorCorrectionLevel errorCorrectionLevel, int i, BitArray bitArray) {
if (!QRCode.isValidMaskPattern(i)) {
throw new WriterException("Invalid mask pattern");
}
int bits = (errorCorrectionLevel.getBits() << 3) | i;
bitArray.appendBits(bits, 5);
bitArray.appendBits(calculateBCHCode(bits, 1335), 10);
BitArray bitArray2 = new BitArray();
bitArray2.appendBits(21522, 15);
bitArray.xor(bitArray2);
if (bitArray.getSize() == 15) {
return;
}
throw new WriterException("should not happen but we got: " + bitArray.getSize());
}
public static void makeVersionInfoBits(Version version, BitArray bitArray) {
bitArray.appendBits(version.getVersionNumber(), 6);
bitArray.appendBits(calculateBCHCode(version.getVersionNumber(), 7973), 12);
if (bitArray.getSize() == 18) {
return;
}
throw new WriterException("should not happen but we got: " + bitArray.getSize());
}
public static void embedTimingPatterns(ByteMatrix byteMatrix) {
int i = 8;
while (i < byteMatrix.getWidth() - 8) {
int i2 = i + 1;
int i3 = i2 % 2;
if (isEmpty(byteMatrix.get(i, 6))) {
byteMatrix.set(i, 6, i3);
}
if (isEmpty(byteMatrix.get(6, i))) {
byteMatrix.set(6, i, i3);
}
i = i2;
}
}
public static void embedDarkDotAtLeftBottomCorner(ByteMatrix byteMatrix) {
if (byteMatrix.get(8, byteMatrix.getHeight() - 8) == 0) {
throw new WriterException();
}
byteMatrix.set(8, byteMatrix.getHeight() - 8, 1);
}
public static void embedHorizontalSeparationPattern(int i, int i2, ByteMatrix byteMatrix) {
for (int i3 = 0; i3 < 8; i3++) {
int i4 = i + i3;
if (!isEmpty(byteMatrix.get(i4, i2))) {
throw new WriterException();
}
byteMatrix.set(i4, i2, 0);
}
}
public static void embedVerticalSeparationPattern(int i, int i2, ByteMatrix byteMatrix) {
for (int i3 = 0; i3 < 7; i3++) {
int i4 = i2 + i3;
if (!isEmpty(byteMatrix.get(i, i4))) {
throw new WriterException();
}
byteMatrix.set(i, i4, 0);
}
}
public static void embedPositionAdjustmentPattern(int i, int i2, ByteMatrix byteMatrix) {
for (int i3 = 0; i3 < 5; i3++) {
int[] iArr = POSITION_ADJUSTMENT_PATTERN[i3];
for (int i4 = 0; i4 < 5; i4++) {
byteMatrix.set(i + i4, i2 + i3, iArr[i4]);
}
}
}
public static void embedPositionDetectionPattern(int i, int i2, ByteMatrix byteMatrix) {
for (int i3 = 0; i3 < 7; i3++) {
int[] iArr = POSITION_DETECTION_PATTERN[i3];
for (int i4 = 0; i4 < 7; i4++) {
byteMatrix.set(i + i4, i2 + i3, iArr[i4]);
}
}
}
public static void embedPositionDetectionPatternsAndSeparators(ByteMatrix byteMatrix) {
int length = POSITION_DETECTION_PATTERN[0].length;
embedPositionDetectionPattern(0, 0, byteMatrix);
embedPositionDetectionPattern(byteMatrix.getWidth() - length, 0, byteMatrix);
embedPositionDetectionPattern(0, byteMatrix.getWidth() - length, byteMatrix);
embedHorizontalSeparationPattern(0, 7, byteMatrix);
embedHorizontalSeparationPattern(byteMatrix.getWidth() - 8, 7, byteMatrix);
embedHorizontalSeparationPattern(0, byteMatrix.getWidth() - 8, byteMatrix);
embedVerticalSeparationPattern(7, 0, byteMatrix);
embedVerticalSeparationPattern(byteMatrix.getHeight() - 8, 0, byteMatrix);
embedVerticalSeparationPattern(7, byteMatrix.getHeight() - 7, byteMatrix);
}
public static void maybeEmbedPositionAdjustmentPatterns(Version version, ByteMatrix byteMatrix) {
if (version.getVersionNumber() < 2) {
return;
}
int[] iArr = POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE[version.getVersionNumber() - 1];
for (int i : iArr) {
if (i >= 0) {
for (int i2 : iArr) {
if (i2 >= 0 && isEmpty(byteMatrix.get(i2, i))) {
embedPositionAdjustmentPattern(i2 - 2, i - 2, byteMatrix);
}
}
}
}
}
}

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: classes3.dex */
public final class QRCode {
public ErrorCorrectionLevel ecLevel;
public int maskPattern = -1;
public ByteMatrix matrix;
public Mode mode;
public Version version;
public static boolean isValidMaskPattern(int i) {
return i >= 0 && i < 8;
}
public ByteMatrix getMatrix() {
return this.matrix;
}
public void setECLevel(ErrorCorrectionLevel errorCorrectionLevel) {
this.ecLevel = errorCorrectionLevel;
}
public void setMaskPattern(int i) {
this.maskPattern = i;
}
public void setMatrix(ByteMatrix byteMatrix) {
this.matrix = byteMatrix;
}
public void setMode(Mode mode) {
this.mode = mode;
}
public void setVersion(Version version) {
this.version = version;
}
public String toString() {
StringBuilder sb = new StringBuilder(200);
sb.append("<<\n");
sb.append(" mode: ");
sb.append(this.mode);
sb.append("\n ecLevel: ");
sb.append(this.ecLevel);
sb.append("\n version: ");
sb.append(this.version);
sb.append("\n maskPattern: ");
sb.append(this.maskPattern);
if (this.matrix == null) {
sb.append("\n matrix: null\n");
} else {
sb.append("\n matrix:\n");
sb.append(this.matrix);
}
sb.append(">>\n");
return sb.toString();
}
}