soul-browser/sources/java/okhttp3/internal/_UtilCommonKt.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

223 lines
7.6 KiB
Java

package okhttp3.internal;
import java.io.Closeable;
import java.util.ArrayList;
import java.util.Comparator;
import kotlin.Metadata;
import kotlin.UByte;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.SourceDebugExtension;
import kotlin.text.StringsKt__StringsJVMKt;
import kotlin.text.StringsKt__StringsKt;
import okio.Buffer;
import okio.BufferedSource;
import okio.ByteString;
import okio.Options;
@Metadata(d1 = {"\u0000\u0002\n\u0000¨\u0006\u0000"}, d2 = {"okhttp"}, k = 2, mv = {2, 2, 0}, xi = 48)
@SourceDebugExtension({"SMAP\n-UtilCommon.kt\nKotlin\n*S Kotlin\n*F\n+ 1 -UtilCommon.kt\nokhttp3/internal/_UtilCommonKt\n+ 2 ArraysJVM.kt\nkotlin/collections/ArraysKt__ArraysJVMKt\n+ 3 _Arrays.kt\nkotlin/collections/ArraysKt___ArraysKt\n+ 4 Okio.kt\nokio/Okio__OkioKt\n*L\n1#1,400:1\n37#2,2:401\n1772#3,6:403\n72#4:409\n58#4,22:410\n*S KotlinDebug\n*F\n+ 1 -UtilCommon.kt\nokhttp3/internal/_UtilCommonKt\n*L\n68#1:401,2\n97#1:403,6\n303#1:409\n303#1:410,22\n*E\n"})
/* loaded from: classes4.dex */
public final class _UtilCommonKt {
/* renamed from: a, reason: collision with root package name */
public static final byte[] f22076a = new byte[0];
static {
int i = Options.f;
ByteString byteString = ByteString.h;
Options.Companion.b(ByteString.Companion.a("efbbbf"), ByteString.Companion.a("feff"), ByteString.Companion.a("fffe0000"), ByteString.Companion.a("fffe"), ByteString.Companion.a("0000feff"));
}
public static final void a(Closeable closeable) {
Intrinsics.checkNotNullParameter(closeable, "<this>");
try {
closeable.close();
} catch (RuntimeException e) {
throw e;
} catch (Exception unused) {
}
}
public static final int b(String str, char c2, int i, int i2) {
Intrinsics.checkNotNullParameter(str, "<this>");
while (i < i2) {
if (str.charAt(i) == c2) {
return i;
}
i++;
}
return i2;
}
public static final int c(String str, int i, int i2, String delimiters) {
boolean contains$default;
Intrinsics.checkNotNullParameter(str, "<this>");
Intrinsics.checkNotNullParameter(delimiters, "delimiters");
while (i < i2) {
contains$default = StringsKt__StringsKt.contains$default(delimiters, str.charAt(i), false, 2, (Object) null);
if (contains$default) {
return i;
}
i++;
}
return i2;
}
public static final boolean d(String[] strArr, String[] strArr2, Comparator comparator) {
Intrinsics.checkNotNullParameter(strArr, "<this>");
Intrinsics.checkNotNullParameter(comparator, "comparator");
if (strArr.length != 0 && strArr2 != null && strArr2.length != 0) {
for (String str : strArr) {
for (String str2 : strArr2) {
if (comparator.compare(str, str2) == 0) {
return true;
}
}
}
}
return false;
}
public static final int e(String str) {
Intrinsics.checkNotNullParameter(str, "<this>");
int length = str.length();
for (int i = 0; i < length; i++) {
char charAt = str.charAt(i);
if (Intrinsics.compare((int) charAt, 31) <= 0 || Intrinsics.compare((int) charAt, 127) >= 0) {
return i;
}
}
return -1;
}
public static final int f(int i, int i2, String str) {
Intrinsics.checkNotNullParameter(str, "<this>");
while (i < i2) {
char charAt = str.charAt(i);
if (charAt != '\t' && charAt != '\n' && charAt != '\f' && charAt != '\r' && charAt != ' ') {
return i;
}
i++;
}
return i2;
}
public static final int g(int i, int i2, String str) {
Intrinsics.checkNotNullParameter(str, "<this>");
int i3 = i2 - 1;
if (i <= i3) {
while (true) {
char charAt = str.charAt(i3);
if (charAt != '\t' && charAt != '\n' && charAt != '\f' && charAt != '\r' && charAt != ' ') {
return i3 + 1;
}
if (i3 == i) {
break;
}
i3--;
}
}
return i;
}
public static final String[] h(String[] strArr, String[] other, Comparator comparator) {
Intrinsics.checkNotNullParameter(strArr, "<this>");
Intrinsics.checkNotNullParameter(other, "other");
Intrinsics.checkNotNullParameter(comparator, "comparator");
ArrayList arrayList = new ArrayList();
for (String str : strArr) {
int length = other.length;
int i = 0;
while (true) {
if (i >= length) {
break;
}
if (comparator.compare(str, other[i]) == 0) {
arrayList.add(str);
break;
}
i++;
}
}
return (String[]) arrayList.toArray(new String[0]);
}
public static final boolean i(String name) {
boolean equals;
boolean equals2;
boolean equals3;
boolean equals4;
Intrinsics.checkNotNullParameter(name, "name");
equals = StringsKt__StringsJVMKt.equals(name, "Authorization", true);
if (!equals) {
equals2 = StringsKt__StringsJVMKt.equals(name, "Cookie", true);
if (!equals2) {
equals3 = StringsKt__StringsJVMKt.equals(name, "Proxy-Authorization", true);
if (!equals3) {
equals4 = StringsKt__StringsJVMKt.equals(name, "Set-Cookie", true);
if (!equals4) {
return false;
}
return true;
}
return true;
}
return true;
}
return true;
}
public static final int j(char c2) {
if ('0' <= c2 && c2 < ':') {
return c2 - '0';
}
if ('a' <= c2 && c2 < 'g') {
return c2 - 'W';
}
if ('A' > c2 || c2 >= 'G') {
return -1;
}
return c2 - '7';
}
public static final int k(BufferedSource bufferedSource) {
Intrinsics.checkNotNullParameter(bufferedSource, "<this>");
return (bufferedSource.readByte() & UByte.MAX_VALUE) | ((bufferedSource.readByte() & UByte.MAX_VALUE) << 16) | ((bufferedSource.readByte() & UByte.MAX_VALUE) << 8);
}
public static final int l(Buffer buffer) {
Intrinsics.checkNotNullParameter(buffer, "<this>");
int i = 0;
while (!buffer.D() && buffer.d(0L) == 61) {
i++;
buffer.readByte();
}
return i;
}
public static final int m(int i, String str) {
if (str != null) {
try {
long parseLong = Long.parseLong(str);
if (parseLong > 2147483647L) {
return Integer.MAX_VALUE;
}
if (parseLong < 0) {
return 0;
}
return (int) parseLong;
} catch (NumberFormatException unused) {
return i;
}
}
return i;
}
public static final String n(int i, int i2, String str) {
Intrinsics.checkNotNullParameter(str, "<this>");
int f = f(i, i2, str);
String substring = str.substring(f, g(f, i2, str));
Intrinsics.checkNotNullExpressionValue(substring, "substring(...)");
return substring;
}
}