soul-browser/sources/java/kotlin/io/encoding/Base64.java
KaKi87 550ddb0413
Decompile and recreate Soul Browser v1.4.85 with APK CI builds (#1)
* Decompile and recreate Soul Browser v1.4.85 with APK CI builds

Co-authored-by: KaKi87 <KaKi87@pm.me>

* Fix CI build: include bundled google.jks and remove PR trigger

The apktool build failed in CI because app/unknown/.../google.jks was
excluded by the *.jks gitignore rule. Whitelist app-bundled JKS files
and commit the missing resource.

Also remove the redundant pull_request workflow trigger.

Co-authored-by: KaKi87 <KaKi87@pm.me>

* Change package ID to com.github.kaki87.soulbrowser

Rename the application ID so the rebuilt APK can be installed
alongside the original Soul Browser from Google Play.

- Update AndroidManifest package, permissions, providers, and actions
- Update R class references in smali (com/github/kaki87/soulbrowser/R)
- Update shortcuts.xml targetPackage
- Rename app label to "Soul Rebuild" for easy identification

Co-authored-by: KaKi87 <KaKi87@pm.me>

* Fix install compatibility: remove split APK metadata and bundle native libs

The rebuilt APK still declared requiredSplitTypes and Play Store split
metadata, causing Android to reject standalone installs as incompatible.

- Remove requiredSplitTypes and split-related manifest meta-data
- Merge native libs from all ABI splits with uncompressed storage
- Page-align before signing for extractNativeLibs=false
- Add .so to apktool doNotCompress list

Co-authored-by: KaKi87 <KaKi87@pm.me>

* Fix install failure: use apksigner v2/v3 and bundle arm64 native libs

Target SDK 36 requires APK Signature Scheme v2+, but jarsigner only
produces v1 signatures, causing Android to reject the install.

- Sign with apksigner (v1+v2+v3) instead of jarsigner
- Add arm64-v8a native libraries from universal Soul Browser 1.4.79
- Set extractNativeLibs=true for reliable sideload installs
- Commit stable debug keystore for consistent signatures across builds

Co-authored-by: KaKi87 <KaKi87@pm.me>

* Add committed debug keystore for consistent APK signatures

Co-authored-by: KaKi87 <KaKi87@pm.me>

* Fix startup crash: use original classes2.dex desugar libraries

Apktool recompiles smali_classes2 into a broken classes2.dex, causing
ClassNotFoundException for j$.com.android.tools.r8.a at ML Kit init.

Inject the original classes2.dex (Java 8+ desugar libs) after apktool
build instead of using the recompiled version.

Co-authored-by: KaKi87 <KaKi87@pm.me>

* Fix missing drawable resources from density split APKs

The base APK is an app bundle module; density-specific drawables like
seek_thumb_nor_b live in config.xhdpi.apk and were missing after rebuild,
causing Resources$NotFoundException at runtime.

- Merge non-9-patch resources from split APKs before apktool build
- Sync public.xml IDs from R smali only when backing files exist
- Add 713 density-specific resource IDs to public.xml

Co-authored-by: KaKi87 <KaKi87@pm.me>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2026-08-10 16:07:14 +02:00

725 lines
38 KiB
Java

package kotlin.io.encoding;
import android.support.v4.media.a;
import com.google.android.gms.ads.RequestConfiguration;
import java.nio.charset.Charset;
import kotlin.Metadata;
import kotlin.SinceKotlin;
import kotlin.UByte;
import kotlin.WasExperimental;
import kotlin.collections.AbstractList;
import kotlin.enums.EnumEntries;
import kotlin.enums.EnumEntriesKt;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
import kotlin.text.CharsKt;
import kotlin.text.Charsets;
import org.jetbrains.annotations.NotNull;
@SinceKotlin(version = "2.2")
@Metadata(d1 = {"\u0000L\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0010\u000b\n\u0002\b\u0002\n\u0002\u0010\b\n\u0000\n\u0002\u0018\u0002\n\u0002\b\r\n\u0002\u0010\u0012\n\u0002\b\u0007\n\u0002\u0010\u000e\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\r\n\u0002\b\u0013\n\u0002\u0010\u0002\n\u0002\b\t\b\u0017\u0018\u0000 B2\u00020\u0001:\u0002ABB)\b\u0002\u0012\u0006\u0010\u0002\u001a\u00020\u0003\u0012\u0006\u0010\u0004\u001a\u00020\u0003\u0012\u0006\u0010\u0005\u001a\u00020\u0006\u0012\u0006\u0010\u0007\u001a\u00020\\u0006\u0004\b\t\u0010\nJ\u0010\u0010\u0013\u001a\u00020\u00002\u0006\u0010\u0014\u001a\u00020\bH\u0007J\"\u0010\u0015\u001a\u00020\u00162\u0006\u0010\u0017\u001a\u00020\u00162\b\b\u0002\u0010\u0018\u001a\u00020\u00062\b\b\u0002\u0010\u0019\u001a\u00020\u0006J4\u0010\u001a\u001a\u00020\u00062\u0006\u0010\u0017\u001a\u00020\u00162\u0006\u0010\u001b\u001a\u00020\u00162\b\b\u0002\u0010\u001c\u001a\u00020\u00062\b\b\u0002\u0010\u0018\u001a\u00020\u00062\b\b\u0002\u0010\u0019\u001a\u00020\u0006J\"\u0010\u001d\u001a\u00020\u001e2\u0006\u0010\u0017\u001a\u00020\u00162\b\b\u0002\u0010\u0018\u001a\u00020\u00062\b\b\u0002\u0010\u0019\u001a\u00020\u0006J=\u0010\u001f\u001a\u0002H \"\f\b\u0000\u0010 *\u00060!j\u0002`\"2\u0006\u0010\u0017\u001a\u00020\u00162\u0006\u0010\u001b\u001a\u0002H 2\b\b\u0002\u0010\u0018\u001a\u00020\u00062\b\b\u0002\u0010\u0019\u001a\u00020\u0006¢\u0006\u0002\u0010#J\"\u0010$\u001a\u00020\u00162\u0006\u0010\u0017\u001a\u00020\u00162\b\b\u0002\u0010\u0018\u001a\u00020\u00062\b\b\u0002\u0010\u0019\u001a\u00020\u0006J4\u0010%\u001a\u00020\u00062\u0006\u0010\u0017\u001a\u00020\u00162\u0006\u0010\u001b\u001a\u00020\u00162\b\b\u0002\u0010\u001c\u001a\u00020\u00062\b\b\u0002\u0010\u0018\u001a\u00020\u00062\b\b\u0002\u0010\u0019\u001a\u00020\u0006J\"\u0010$\u001a\u00020\u00162\u0006\u0010\u0017\u001a\u00020&2\b\b\u0002\u0010\u0018\u001a\u00020\u00062\b\b\u0002\u0010\u0019\u001a\u00020\u0006J4\u0010%\u001a\u00020\u00062\u0006\u0010\u0017\u001a\u00020&2\u0006\u0010\u001b\u001a\u00020\u00162\b\b\u0002\u0010\u001c\u001a\u00020\u00062\b\b\u0002\u0010\u0018\u001a\u00020\u00062\b\b\u0002\u0010\u0019\u001a\u00020\u0006J%\u0010'\u001a\u00020\u00162\u0006\u0010\u0017\u001a\u00020\u00162\u0006\u0010\u0018\u001a\u00020\u00062\u0006\u0010\u0019\u001a\u00020\u0006H\u0000¢\u0006\u0002\b(J5\u0010)\u001a\u00020\u00062\u0006\u0010\u0017\u001a\u00020\u00162\u0006\u0010\u001b\u001a\u00020\u00162\u0006\u0010\u001c\u001a\u00020\u00062\u0006\u0010\u0018\u001a\u00020\u00062\u0006\u0010\u0019\u001a\u00020\u0006H\u0000¢\u0006\u0002\b*J\u0015\u0010+\u001a\u00020\u00062\u0006\u0010,\u001a\u00020\u0006H\u0000¢\u0006\u0002\b-J\b\u0010.\u001a\u00020\u0003H\u0002J0\u0010/\u001a\u00020\u00062\u0006\u0010\u0017\u001a\u00020\u00162\u0006\u0010\u001b\u001a\u00020\u00162\u0006\u0010\u001c\u001a\u00020\u00062\u0006\u0010\u0018\u001a\u00020\u00062\u0006\u0010\u0019\u001a\u00020\u0006H\u0002J%\u00100\u001a\u00020\u00062\u0006\u0010\u0017\u001a\u00020\u00162\u0006\u0010\u0018\u001a\u00020\u00062\u0006\u0010\u0019\u001a\u00020\u0006H\u0000¢\u0006\u0002\b1J%\u00102\u001a\u00020\u00162\u0006\u0010\u0017\u001a\u00020&2\u0006\u0010\u0018\u001a\u00020\u00062\u0006\u0010\u0019\u001a\u00020\u0006H\u0000¢\u0006\u0002\b3J\u0015\u00104\u001a\u00020\u001e2\u0006\u0010\u0017\u001a\u00020\u0016H\u0000¢\u0006\u0002\b5J(\u00106\u001a\u00020\u00062\u0006\u0010\u0017\u001a\u00020\u00162\u0006\u00107\u001a\u00020\u00062\u0006\u0010\u0019\u001a\u00020\u00062\u0006\u00108\u001a\u00020\u0006H\u0002J\u0010\u00109\u001a\u00020:2\u0006\u00107\u001a\u00020\u0006H\u0002J \u0010;\u001a\u00020\u00062\u0006\u0010\u0017\u001a\u00020\u00162\u0006\u0010\u0018\u001a\u00020\u00062\u0006\u0010\u0019\u001a\u00020\u0006H\u0002J%\u0010<\u001a\u00020:2\u0006\u0010,\u001a\u00020\u00062\u0006\u0010\u0018\u001a\u00020\u00062\u0006\u0010\u0019\u001a\u00020\u0006H\u0000¢\u0006\u0002\b=J \u0010>\u001a\u00020:2\u0006\u0010?\u001a\u00020\u00062\u0006\u0010\u001c\u001a\u00020\u00062\u0006\u0010@\u001a\u00020\u0006H\u0002R\u0014\u0010\u0002\u001a\u00020\u0003X\u0080\u0004¢\u0006\b\n\u0000\u001a\u0004\b\u000b\u0010\fR\u0014\u0010\u0004\u001a\u00020\u0003X\u0080\u0004¢\u0006\b\n\u0000\u001a\u0004\b\r\u0010\fR\u0014\u0010\u0005\u001a\u00020\u0006X\u0080\u0004¢\u0006\b\n\u0000\u001a\u0004\b\u000e\u0010\u000fR\u0014\u0010\u0007\u001a\u00020\bX\u0080\u0004¢\u0006\b\n\u0000\u001a\u0004\b\u0010\u0010\u0011R\u000e\u0010\u0012\u001a\u00020\u0006X\u0082\u0004¢\u0006\u0002\n\u0000¨\u0006C"}, d2 = {"Lkotlin/io/encoding/Base64;", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED, "isUrlSafe", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED, "isMimeScheme", "mimeLineLength", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED, "paddingOption", "Lkotlin/io/encoding/Base64$PaddingOption;", "<init>", "(ZZILkotlin/io/encoding/Base64$PaddingOption;)V", "isUrlSafe$kotlin_stdlib", "()Z", "isMimeScheme$kotlin_stdlib", "getMimeLineLength$kotlin_stdlib", "()I", "getPaddingOption$kotlin_stdlib", "()Lkotlin/io/encoding/Base64$PaddingOption;", "mimeGroupsPerLine", "withPadding", "option", "encodeToByteArray", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED, "source", "startIndex", "endIndex", "encodeIntoByteArray", "destination", "destinationOffset", "encode", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED, "encodeToAppendable", "A", "Ljava/lang/Appendable;", "Lkotlin/text/Appendable;", "([BLjava/lang/Appendable;II)Ljava/lang/Appendable;", "decode", "decodeIntoByteArray", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED, "encodeToByteArrayImpl", "encodeToByteArrayImpl$kotlin_stdlib", "encodeIntoByteArrayImpl", "encodeIntoByteArrayImpl$kotlin_stdlib", "encodeSize", "sourceSize", "encodeSize$kotlin_stdlib", "shouldPadOnEncode", "decodeImpl", "decodeSize", "decodeSize$kotlin_stdlib", "charsToBytesImpl", "charsToBytesImpl$kotlin_stdlib", "bytesToStringImpl", "bytesToStringImpl$kotlin_stdlib", "handlePaddingSymbol", "padIndex", "byteStart", "checkPaddingIsAllowed", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED, "skipIllegalSymbolsIfMime", "checkSourceBounds", "checkSourceBounds$kotlin_stdlib", "checkDestinationBounds", "destinationSize", "capacityNeeded", "PaddingOption", "Default", "kotlin-stdlib"}, k = 1, mv = {2, 2, 0}, xi = 48)
@WasExperimental(markerClass = {ExperimentalEncodingApi.class})
/* loaded from: classes4.dex */
public class Base64 {
@NotNull
private static final Base64 Mime;
@NotNull
private static final Base64 Pem;
@NotNull
private static final Base64 UrlSafe;
private static final int bitsPerByte = 8;
private static final int bitsPerSymbol = 6;
public static final int bytesPerGroup = 3;
private static final int lineLengthMime = 76;
private static final int lineLengthPem = 64;
public static final byte padSymbol = 61;
public static final int symbolsPerGroup = 4;
private final boolean isMimeScheme;
private final boolean isUrlSafe;
private final int mimeGroupsPerLine;
private final int mimeLineLength;
@NotNull
private final PaddingOption paddingOption;
/* renamed from: Default, reason: from kotlin metadata */
@NotNull
public static final Companion INSTANCE = new Companion(null);
@NotNull
private static final byte[] mimeLineSeparatorSymbols = {13, 10};
@Metadata(d1 = {"\u0000$\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\b\n\u0002\b\u0004\n\u0002\u0010\u0005\n\u0002\b\u0003\n\u0002\u0010\u0012\n\u0002\b\n\b\u0086\u0003\u0018\u00002\u00020\u0001B\t\b\u0002¢\u0006\u0004\b\u0002\u0010\u0003R\u000e\u0010\u0004\u001a\u00020\u0005X\u0082T¢\u0006\u0002\n\u0000R\u000e\u0010\u0006\u001a\u00020\u0005X\u0082T¢\u0006\u0002\n\u0000R\u000e\u0010\u0007\u001a\u00020\u0005X\u0080T¢\u0006\u0002\n\u0000R\u000e\u0010\b\u001a\u00020\u0005X\u0080T¢\u0006\u0002\n\u0000R\u000e\u0010\t\u001a\u00020\nX\u0080T¢\u0006\u0002\n\u0000R\u000e\u0010\u000b\u001a\u00020\u0005X\u0082T¢\u0006\u0002\n\u0000R\u000e\u0010\f\u001a\u00020\u0005X\u0082T¢\u0006\u0002\n\u0000R\u0014\u0010\r\u001a\u00020\u000eX\u0080\u0004¢\u0006\b\n\u0000\u001a\u0004\b\u000f\u0010\u0010R\u0011\u0010\u0011\u001a\u00020\u0001¢\u0006\b\n\u0000\u001a\u0004\b\u0012\u0010\u0013R\u0011\u0010\u0014\u001a\u00020\u0001¢\u0006\b\n\u0000\u001a\u0004\b\u0015\u0010\u0013R\u0011\u0010\u0016\u001a\u00020\u0001¢\u0006\b\n\u0000\u001a\u0004\b\u0017\u0010\u0013¨\u0006\u0018"}, d2 = {"Lkotlin/io/encoding/Base64$Default;", "Lkotlin/io/encoding/Base64;", "<init>", "()V", "bitsPerByte", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED, "bitsPerSymbol", "bytesPerGroup", "symbolsPerGroup", "padSymbol", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED, "lineLengthMime", "lineLengthPem", "mimeLineSeparatorSymbols", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED, "getMimeLineSeparatorSymbols$kotlin_stdlib", "()[B", "UrlSafe", "getUrlSafe", "()Lkotlin/io/encoding/Base64;", "Mime", "getMime", "Pem", "getPem", "kotlin-stdlib"}, k = 1, mv = {2, 2, 0}, xi = 48)
/* renamed from: kotlin.io.encoding.Base64$Default, reason: from kotlin metadata */
/* loaded from: classes4.dex */
public static final class Companion extends Base64 {
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
@NotNull
public final Base64 getMime() {
return Base64.Mime;
}
@NotNull
public final byte[] getMimeLineSeparatorSymbols$kotlin_stdlib() {
return Base64.mimeLineSeparatorSymbols;
}
@NotNull
public final Base64 getPem() {
return Base64.Pem;
}
@NotNull
public final Base64 getUrlSafe() {
return Base64.UrlSafe;
}
private Companion() {
super(false, false, -1, PaddingOption.PRESENT, null);
}
}
/* JADX WARN: Failed to restore enum class, 'enum' modifier and super class removed */
/* JADX WARN: Unknown enum class pattern. Please report as an issue! */
@SinceKotlin(version = "2.0")
@Metadata(d1 = {"\u0000\f\n\u0002\u0018\u0002\n\u0002\u0010\u0010\n\u0002\b\u0007\b\u0087\u0081\u0002\u0018\u00002\b\u0012\u0004\u0012\u00020\u00000\u0001B\t\b\u0002¢\u0006\u0004\b\u0002\u0010\u0003j\u0002\b\u0004j\u0002\b\u0005j\u0002\b\u0006j\u0002\b\u0007¨\u0006\b"}, d2 = {"Lkotlin/io/encoding/Base64$PaddingOption;", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED, "<init>", "(Ljava/lang/String;I)V", "PRESENT", "ABSENT", "PRESENT_OPTIONAL", "ABSENT_OPTIONAL", "kotlin-stdlib"}, k = 1, mv = {2, 2, 0}, xi = 48)
/* loaded from: classes4.dex */
public static final class PaddingOption {
private static final /* synthetic */ EnumEntries $ENTRIES;
private static final /* synthetic */ PaddingOption[] $VALUES;
public static final PaddingOption PRESENT = new PaddingOption("PRESENT", 0);
public static final PaddingOption ABSENT = new PaddingOption("ABSENT", 1);
public static final PaddingOption PRESENT_OPTIONAL = new PaddingOption("PRESENT_OPTIONAL", 2);
public static final PaddingOption ABSENT_OPTIONAL = new PaddingOption("ABSENT_OPTIONAL", 3);
private static final /* synthetic */ PaddingOption[] $values() {
return new PaddingOption[]{PRESENT, ABSENT, PRESENT_OPTIONAL, ABSENT_OPTIONAL};
}
static {
PaddingOption[] $values = $values();
$VALUES = $values;
$ENTRIES = EnumEntriesKt.enumEntries($values);
}
private PaddingOption(String str, int i) {
}
@NotNull
public static EnumEntries<PaddingOption> getEntries() {
return $ENTRIES;
}
public static PaddingOption valueOf(String str) {
return (PaddingOption) Enum.valueOf(PaddingOption.class, str);
}
public static PaddingOption[] values() {
return (PaddingOption[]) $VALUES.clone();
}
}
static {
PaddingOption paddingOption = PaddingOption.PRESENT;
UrlSafe = new Base64(true, false, -1, paddingOption);
Mime = new Base64(false, true, lineLengthMime, paddingOption);
Pem = new Base64(false, true, 64, paddingOption);
}
public /* synthetic */ Base64(boolean z, boolean z2, int i, PaddingOption paddingOption, DefaultConstructorMarker defaultConstructorMarker) {
this(z, z2, i, paddingOption);
}
private final void checkDestinationBounds(int destinationSize, int destinationOffset, int capacityNeeded) {
if (destinationOffset >= 0 && destinationOffset <= destinationSize) {
int i = destinationOffset + capacityNeeded;
if (i >= 0 && i <= destinationSize) {
return;
}
StringBuilder u = a.u("The destination array does not have enough capacity, destination offset: ", destinationOffset, destinationSize, ", destination size: ", ", capacity needed: ");
u.append(capacityNeeded);
throw new IndexOutOfBoundsException(u.toString());
}
throw new IndexOutOfBoundsException(androidx.work.impl.workers.a.s("destination offset: ", destinationOffset, destinationSize, ", destination size: "));
}
private final void checkPaddingIsAllowed(int padIndex) {
if (this.paddingOption != PaddingOption.ABSENT) {
} else {
throw new IllegalArgumentException(a.e(padIndex, "The padding option is set to ABSENT, but the input has a pad character at index "));
}
}
public static /* synthetic */ byte[] decode$default(Base64 base64, byte[] bArr, int i, int i2, int i3, Object obj) {
if (obj != null) {
throw new UnsupportedOperationException("Super calls with default arguments not supported in this target, function: decode");
}
if ((i3 & 2) != 0) {
i = 0;
}
if ((i3 & 4) != 0) {
i2 = bArr.length;
}
return base64.decode(bArr, i, i2);
}
private final int decodeImpl(byte[] source, byte[] destination, int destinationOffset, int startIndex, int endIndex) {
int[] access$getBase64DecodeMap$p;
int i;
int i2;
int i3;
if (this.isUrlSafe) {
access$getBase64DecodeMap$p = Base64Kt.access$getBase64UrlDecodeMap$p();
} else {
access$getBase64DecodeMap$p = Base64Kt.access$getBase64DecodeMap$p();
}
int i4 = -8;
int i5 = destinationOffset;
int i6 = startIndex;
int i7 = -8;
int i8 = 0;
while (true) {
if (i6 < endIndex) {
if (i7 == i4 && i6 + 3 < endIndex) {
i = 8;
int i9 = access$getBase64DecodeMap$p[source[i6] & UByte.MAX_VALUE];
i3 = 1;
int i10 = i6 + 4;
int i11 = (access$getBase64DecodeMap$p[source[i6 + 1] & UByte.MAX_VALUE] << 12) | (i9 << 18) | (access$getBase64DecodeMap$p[source[i6 + 2] & UByte.MAX_VALUE] << 6) | access$getBase64DecodeMap$p[source[i6 + 3] & UByte.MAX_VALUE];
if (i11 >= 0) {
destination[i5] = (byte) (i11 >> 16);
int i12 = i5 + 2;
destination[i5 + 1] = (byte) (i11 >> 8);
i5 += 3;
destination[i12] = (byte) i11;
i6 = i10;
i4 = -8;
}
} else {
i = 8;
i3 = 1;
}
int i13 = source[i6] & UByte.MAX_VALUE;
int i14 = access$getBase64DecodeMap$p[i13];
if (i14 < 0) {
if (i14 == -2) {
i6 = handlePaddingSymbol(source, i6, endIndex, i7);
i2 = i3;
break;
}
if (this.isMimeScheme) {
i6++;
} else {
StringBuilder sb = new StringBuilder("Invalid symbol '");
sb.append((char) i13);
sb.append("'(");
String num = Integer.toString(i13, CharsKt.checkRadix(i));
Intrinsics.checkNotNullExpressionValue(num, "toString(...)");
sb.append(num);
sb.append(") at index ");
sb.append(i6);
throw new IllegalArgumentException(sb.toString());
}
} else {
i6++;
i8 = (i8 << 6) | i14;
int i15 = i7 + 6;
if (i15 >= 0) {
destination[i5] = (byte) (i8 >>> i15);
i8 &= (i3 << i15) - 1;
i7 -= 2;
i5++;
} else {
i7 = i15;
}
}
i4 = -8;
} else {
i = 8;
i2 = 0;
break;
}
}
if (i7 != -2) {
if (i7 != -8 && i2 == 0 && this.paddingOption == PaddingOption.PRESENT) {
throw new IllegalArgumentException("The padding option is set to PRESENT, but the input is not properly padded");
}
if (i8 == 0) {
int skipIllegalSymbolsIfMime = skipIllegalSymbolsIfMime(source, i6, endIndex);
if (skipIllegalSymbolsIfMime >= endIndex) {
return i5 - destinationOffset;
}
int i16 = source[skipIllegalSymbolsIfMime] & UByte.MAX_VALUE;
StringBuilder sb2 = new StringBuilder("Symbol '");
sb2.append((char) i16);
sb2.append("'(");
String num2 = Integer.toString(i16, CharsKt.checkRadix(i));
Intrinsics.checkNotNullExpressionValue(num2, "toString(...)");
sb2.append(num2);
sb2.append(") at index ");
throw new IllegalArgumentException(a.g(skipIllegalSymbolsIfMime - 1, " is prohibited after the pad character", sb2));
}
throw new IllegalArgumentException("The pad bits must be zeros");
}
throw new IllegalArgumentException("The last unit of input does not have enough bits");
}
public static /* synthetic */ int decodeIntoByteArray$default(Base64 base64, byte[] bArr, byte[] bArr2, int i, int i2, int i3, int i4, Object obj) {
if (obj != null) {
throw new UnsupportedOperationException("Super calls with default arguments not supported in this target, function: decodeIntoByteArray");
}
if ((i4 & 4) != 0) {
i = 0;
}
if ((i4 & 8) != 0) {
i2 = 0;
}
if ((i4 & 16) != 0) {
i3 = bArr.length;
}
return base64.decodeIntoByteArray(bArr, bArr2, i, i2, i3);
}
public static /* synthetic */ String encode$default(Base64 base64, byte[] bArr, int i, int i2, int i3, Object obj) {
if (obj == null) {
if ((i3 & 2) != 0) {
i = 0;
}
if ((i3 & 4) != 0) {
i2 = bArr.length;
}
return base64.encode(bArr, i, i2);
}
throw new UnsupportedOperationException("Super calls with default arguments not supported in this target, function: encode");
}
public static /* synthetic */ int encodeIntoByteArray$default(Base64 base64, byte[] bArr, byte[] bArr2, int i, int i2, int i3, int i4, Object obj) {
if (obj == null) {
if ((i4 & 4) != 0) {
i = 0;
}
if ((i4 & 8) != 0) {
i2 = 0;
}
if ((i4 & 16) != 0) {
i3 = bArr.length;
}
return base64.encodeIntoByteArray(bArr, bArr2, i, i2, i3);
}
throw new UnsupportedOperationException("Super calls with default arguments not supported in this target, function: encodeIntoByteArray");
}
public static /* synthetic */ Appendable encodeToAppendable$default(Base64 base64, byte[] bArr, Appendable appendable, int i, int i2, int i3, Object obj) {
if (obj == null) {
if ((i3 & 4) != 0) {
i = 0;
}
if ((i3 & 8) != 0) {
i2 = bArr.length;
}
return base64.encodeToAppendable(bArr, appendable, i, i2);
}
throw new UnsupportedOperationException("Super calls with default arguments not supported in this target, function: encodeToAppendable");
}
public static /* synthetic */ byte[] encodeToByteArray$default(Base64 base64, byte[] bArr, int i, int i2, int i3, Object obj) {
if (obj == null) {
if ((i3 & 2) != 0) {
i = 0;
}
if ((i3 & 4) != 0) {
i2 = bArr.length;
}
return base64.encodeToByteArray(bArr, i, i2);
}
throw new UnsupportedOperationException("Super calls with default arguments not supported in this target, function: encodeToByteArray");
}
private final int handlePaddingSymbol(byte[] source, int padIndex, int endIndex, int byteStart) {
if (byteStart != -8) {
if (byteStart != -6) {
if (byteStart != -4) {
if (byteStart == -2) {
return padIndex + 1;
}
throw new IllegalStateException("Unreachable");
}
checkPaddingIsAllowed(padIndex);
int skipIllegalSymbolsIfMime = skipIllegalSymbolsIfMime(source, padIndex + 1, endIndex);
if (skipIllegalSymbolsIfMime != endIndex && source[skipIllegalSymbolsIfMime] == 61) {
return skipIllegalSymbolsIfMime + 1;
}
throw new IllegalArgumentException(a.e(skipIllegalSymbolsIfMime, "Missing one pad character at index "));
}
checkPaddingIsAllowed(padIndex);
return padIndex + 1;
}
throw new IllegalArgumentException(a.e(padIndex, "Redundant pad character at index "));
}
private final boolean shouldPadOnEncode() {
PaddingOption paddingOption = this.paddingOption;
if (paddingOption != PaddingOption.PRESENT && paddingOption != PaddingOption.PRESENT_OPTIONAL) {
return false;
}
return true;
}
private final int skipIllegalSymbolsIfMime(byte[] source, int startIndex, int endIndex) {
if (!this.isMimeScheme) {
return startIndex;
}
while (startIndex < endIndex) {
if (Base64Kt.access$getBase64DecodeMap$p()[source[startIndex] & UByte.MAX_VALUE] != -1) {
break;
}
startIndex++;
}
return startIndex;
}
@NotNull
public final String bytesToStringImpl$kotlin_stdlib(@NotNull byte[] source) {
Intrinsics.checkNotNullParameter(source, "source");
StringBuilder sb = new StringBuilder(source.length);
for (byte b : source) {
sb.append((char) b);
}
return sb.toString();
}
@NotNull
public final byte[] charsToBytesImpl$kotlin_stdlib(@NotNull CharSequence source, int startIndex, int endIndex) {
Intrinsics.checkNotNullParameter(source, "source");
checkSourceBounds$kotlin_stdlib(source.length(), startIndex, endIndex);
byte[] bArr = new byte[endIndex - startIndex];
int i = 0;
while (startIndex < endIndex) {
char charAt = source.charAt(startIndex);
if (charAt <= 255) {
bArr[i] = (byte) charAt;
i++;
} else {
bArr[i] = 63;
i++;
}
startIndex++;
}
return bArr;
}
public final void checkSourceBounds$kotlin_stdlib(int sourceSize, int startIndex, int endIndex) {
AbstractList.INSTANCE.checkBoundsIndexes$kotlin_stdlib(startIndex, endIndex, sourceSize);
}
@NotNull
public final byte[] decode(@NotNull byte[] source, int startIndex, int endIndex) {
Intrinsics.checkNotNullParameter(source, "source");
checkSourceBounds$kotlin_stdlib(source.length, startIndex, endIndex);
int decodeSize$kotlin_stdlib = decodeSize$kotlin_stdlib(source, startIndex, endIndex);
byte[] bArr = new byte[decodeSize$kotlin_stdlib];
if (decodeImpl(source, bArr, 0, startIndex, endIndex) == decodeSize$kotlin_stdlib) {
return bArr;
}
throw new IllegalStateException("Check failed.");
}
public final int decodeIntoByteArray(@NotNull byte[] source, @NotNull byte[] destination, int destinationOffset, int startIndex, int endIndex) {
Intrinsics.checkNotNullParameter(source, "source");
Intrinsics.checkNotNullParameter(destination, "destination");
checkSourceBounds$kotlin_stdlib(source.length, startIndex, endIndex);
checkDestinationBounds(destination.length, destinationOffset, decodeSize$kotlin_stdlib(source, startIndex, endIndex));
return decodeImpl(source, destination, destinationOffset, startIndex, endIndex);
}
public final int decodeSize$kotlin_stdlib(@NotNull byte[] source, int startIndex, int endIndex) {
Intrinsics.checkNotNullParameter(source, "source");
int i = endIndex - startIndex;
if (i == 0) {
return 0;
}
if (i != 1) {
if (this.isMimeScheme) {
while (true) {
if (startIndex >= endIndex) {
break;
}
int i2 = Base64Kt.access$getBase64DecodeMap$p()[source[startIndex] & UByte.MAX_VALUE];
if (i2 < 0) {
if (i2 == -2) {
i -= endIndex - startIndex;
break;
}
i--;
}
startIndex++;
}
} else if (source[endIndex - 1] == 61) {
int i3 = i - 1;
if (source[endIndex - 2] == 61) {
i -= 2;
} else {
i = i3;
}
}
return (int) ((i * 6) / 8);
}
throw new IllegalArgumentException(androidx.work.impl.workers.a.s("Input should have at least 2 symbols for Base64 decoding, startIndex: ", startIndex, endIndex, ", endIndex: "));
}
@NotNull
public final String encode(@NotNull byte[] source, int startIndex, int endIndex) {
Intrinsics.checkNotNullParameter(source, "source");
return new String(encodeToByteArrayImpl$kotlin_stdlib(source, startIndex, endIndex), Charsets.ISO_8859_1);
}
public final int encodeIntoByteArray(@NotNull byte[] source, @NotNull byte[] destination, int destinationOffset, int startIndex, int endIndex) {
Intrinsics.checkNotNullParameter(source, "source");
Intrinsics.checkNotNullParameter(destination, "destination");
return encodeIntoByteArrayImpl$kotlin_stdlib(source, destination, destinationOffset, startIndex, endIndex);
}
public final int encodeIntoByteArrayImpl$kotlin_stdlib(@NotNull byte[] source, @NotNull byte[] destination, int destinationOffset, int startIndex, int endIndex) {
byte[] access$getBase64EncodeMap$p;
int i;
int i2 = startIndex;
Intrinsics.checkNotNullParameter(source, "source");
Intrinsics.checkNotNullParameter(destination, "destination");
checkSourceBounds$kotlin_stdlib(source.length, i2, endIndex);
checkDestinationBounds(destination.length, destinationOffset, encodeSize$kotlin_stdlib(endIndex - i2));
if (this.isUrlSafe) {
access$getBase64EncodeMap$p = Base64Kt.access$getBase64UrlEncodeMap$p();
} else {
access$getBase64EncodeMap$p = Base64Kt.access$getBase64EncodeMap$p();
}
if (this.isMimeScheme) {
i = this.mimeGroupsPerLine;
} else {
i = Integer.MAX_VALUE;
}
int i3 = destinationOffset;
while (i2 + 2 < endIndex) {
int min = Math.min((endIndex - i2) / 3, i);
for (int i4 = 0; i4 < min; i4++) {
int i5 = source[i2] & UByte.MAX_VALUE;
int i6 = i2 + 2;
int i7 = source[i2 + 1] & UByte.MAX_VALUE;
i2 += 3;
int i8 = (i7 << 8) | (i5 << 16) | (source[i6] & UByte.MAX_VALUE);
destination[i3] = access$getBase64EncodeMap$p[i8 >>> 18];
destination[i3 + 1] = access$getBase64EncodeMap$p[(i8 >>> 12) & 63];
int i9 = i3 + 3;
destination[i3 + 2] = access$getBase64EncodeMap$p[(i8 >>> 6) & 63];
i3 += 4;
destination[i9] = access$getBase64EncodeMap$p[i8 & 63];
}
if (min == i && i2 != endIndex) {
int i10 = i3 + 1;
byte[] bArr = mimeLineSeparatorSymbols;
destination[i3] = bArr[0];
i3 += 2;
destination[i10] = bArr[1];
}
}
int i11 = endIndex - i2;
if (i11 != 1) {
if (i11 == 2) {
int i12 = i2 + 1;
int i13 = source[i2] & UByte.MAX_VALUE;
i2 += 2;
int i14 = ((source[i12] & UByte.MAX_VALUE) << 2) | (i13 << 10);
destination[i3] = access$getBase64EncodeMap$p[i14 >>> 12];
destination[i3 + 1] = access$getBase64EncodeMap$p[(i14 >>> 6) & 63];
int i15 = i3 + 3;
destination[i3 + 2] = access$getBase64EncodeMap$p[i14 & 63];
if (shouldPadOnEncode()) {
i3 += 4;
destination[i15] = padSymbol;
} else {
i3 = i15;
}
}
} else {
int i16 = i2 + 1;
int i17 = (source[i2] & UByte.MAX_VALUE) << 4;
destination[i3] = access$getBase64EncodeMap$p[i17 >>> 6];
int i18 = i3 + 2;
destination[i3 + 1] = access$getBase64EncodeMap$p[i17 & 63];
if (shouldPadOnEncode()) {
int i19 = i3 + 3;
destination[i18] = padSymbol;
i3 += 4;
destination[i19] = padSymbol;
i2 = i16;
} else {
i2 = i16;
i3 = i18;
}
}
if (i2 == endIndex) {
return i3 - destinationOffset;
}
throw new IllegalStateException("Check failed.");
}
public final int encodeSize$kotlin_stdlib(int sourceSize) {
int i = sourceSize / 3;
int i2 = sourceSize % 3;
int i3 = 4;
int i4 = i * 4;
if (i2 != 0) {
if (!shouldPadOnEncode()) {
i3 = i2 + 1;
}
i4 += i3;
}
if (i4 >= 0) {
if (this.isMimeScheme) {
i4 += ((i4 - 1) / this.mimeLineLength) * 2;
}
if (i4 >= 0) {
return i4;
}
throw new IllegalArgumentException("Input is too big");
}
throw new IllegalArgumentException("Input is too big");
}
@NotNull
public final <A extends Appendable> A encodeToAppendable(@NotNull byte[] source, @NotNull A destination, int startIndex, int endIndex) {
Intrinsics.checkNotNullParameter(source, "source");
Intrinsics.checkNotNullParameter(destination, "destination");
destination.append(new String(encodeToByteArrayImpl$kotlin_stdlib(source, startIndex, endIndex), Charsets.ISO_8859_1));
return destination;
}
@NotNull
public final byte[] encodeToByteArray(@NotNull byte[] source, int startIndex, int endIndex) {
Intrinsics.checkNotNullParameter(source, "source");
return encodeToByteArrayImpl$kotlin_stdlib(source, startIndex, endIndex);
}
@NotNull
public final byte[] encodeToByteArrayImpl$kotlin_stdlib(@NotNull byte[] source, int startIndex, int endIndex) {
Intrinsics.checkNotNullParameter(source, "source");
checkSourceBounds$kotlin_stdlib(source.length, startIndex, endIndex);
byte[] bArr = new byte[encodeSize$kotlin_stdlib(endIndex - startIndex)];
encodeIntoByteArrayImpl$kotlin_stdlib(source, bArr, 0, startIndex, endIndex);
return bArr;
}
/* renamed from: getMimeLineLength$kotlin_stdlib, reason: from getter */
public final int getMimeLineLength() {
return this.mimeLineLength;
}
@NotNull
/* renamed from: getPaddingOption$kotlin_stdlib, reason: from getter */
public final PaddingOption getPaddingOption() {
return this.paddingOption;
}
/* renamed from: isMimeScheme$kotlin_stdlib, reason: from getter */
public final boolean getIsMimeScheme() {
return this.isMimeScheme;
}
/* renamed from: isUrlSafe$kotlin_stdlib, reason: from getter */
public final boolean getIsUrlSafe() {
return this.isUrlSafe;
}
@SinceKotlin(version = "2.0")
@NotNull
public final Base64 withPadding(@NotNull PaddingOption option) {
Intrinsics.checkNotNullParameter(option, "option");
if (this.paddingOption == option) {
return this;
}
return new Base64(this.isUrlSafe, this.isMimeScheme, this.mimeLineLength, option);
}
private Base64(boolean z, boolean z2, int i, PaddingOption paddingOption) {
this.isUrlSafe = z;
this.isMimeScheme = z2;
this.mimeLineLength = i;
this.paddingOption = paddingOption;
if (z && z2) {
throw new IllegalArgumentException("Failed requirement.");
}
this.mimeGroupsPerLine = i / 4;
}
public static /* synthetic */ byte[] decode$default(Base64 base64, CharSequence charSequence, int i, int i2, int i3, Object obj) {
if (obj != null) {
throw new UnsupportedOperationException("Super calls with default arguments not supported in this target, function: decode");
}
if ((i3 & 2) != 0) {
i = 0;
}
if ((i3 & 4) != 0) {
i2 = charSequence.length();
}
return base64.decode(charSequence, i, i2);
}
public static /* synthetic */ int decodeIntoByteArray$default(Base64 base64, CharSequence charSequence, byte[] bArr, int i, int i2, int i3, int i4, Object obj) {
if (obj != null) {
throw new UnsupportedOperationException("Super calls with default arguments not supported in this target, function: decodeIntoByteArray");
}
if ((i4 & 4) != 0) {
i = 0;
}
if ((i4 & 8) != 0) {
i2 = 0;
}
if ((i4 & 16) != 0) {
i3 = charSequence.length();
}
return base64.decodeIntoByteArray(charSequence, bArr, i, i2, i3);
}
public final int decodeIntoByteArray(@NotNull CharSequence source, @NotNull byte[] destination, int destinationOffset, int startIndex, int endIndex) {
byte[] charsToBytesImpl$kotlin_stdlib;
Intrinsics.checkNotNullParameter(source, "source");
Intrinsics.checkNotNullParameter(destination, "destination");
if (source instanceof String) {
String str = (String) source;
checkSourceBounds$kotlin_stdlib(str.length(), startIndex, endIndex);
String substring = str.substring(startIndex, endIndex);
Intrinsics.checkNotNullExpressionValue(substring, "substring(...)");
Charset charset = Charsets.ISO_8859_1;
Intrinsics.checkNotNull(substring, "null cannot be cast to non-null type java.lang.String");
charsToBytesImpl$kotlin_stdlib = substring.getBytes(charset);
Intrinsics.checkNotNullExpressionValue(charsToBytesImpl$kotlin_stdlib, "getBytes(...)");
} else {
charsToBytesImpl$kotlin_stdlib = charsToBytesImpl$kotlin_stdlib(source, startIndex, endIndex);
}
return decodeIntoByteArray$default(this, charsToBytesImpl$kotlin_stdlib, destination, destinationOffset, 0, 0, 24, (Object) null);
}
@NotNull
public final byte[] decode(@NotNull CharSequence source, int startIndex, int endIndex) {
byte[] charsToBytesImpl$kotlin_stdlib;
Intrinsics.checkNotNullParameter(source, "source");
if (source instanceof String) {
String str = (String) source;
checkSourceBounds$kotlin_stdlib(str.length(), startIndex, endIndex);
String substring = str.substring(startIndex, endIndex);
Intrinsics.checkNotNullExpressionValue(substring, "substring(...)");
Charset charset = Charsets.ISO_8859_1;
Intrinsics.checkNotNull(substring, "null cannot be cast to non-null type java.lang.String");
charsToBytesImpl$kotlin_stdlib = substring.getBytes(charset);
Intrinsics.checkNotNullExpressionValue(charsToBytesImpl$kotlin_stdlib, "getBytes(...)");
} else {
charsToBytesImpl$kotlin_stdlib = charsToBytesImpl$kotlin_stdlib(source, startIndex, endIndex);
}
return decode$default(this, charsToBytesImpl$kotlin_stdlib, 0, 0, 6, (Object) null);
}
}