soul-browser/sources/java/kotlin/jvm/internal/CollectionToArray.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

170 lines
8.7 KiB
Java

package kotlin.jvm.internal;
import com.google.android.gms.ads.RequestConfiguration;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import kotlin.Deprecated;
import kotlin.DeprecatedSinceKotlin;
import kotlin.Metadata;
import kotlin.jvm.JvmName;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.functions.Function2;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@Metadata(d1 = {"\u00002\n\u0000\n\u0002\u0010\u0011\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0010\b\n\u0002\b\u0002\n\u0002\u0010\u001e\n\u0002\b\u0006\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\u001a#\u0010\u0006\u001a\n\u0012\u0006\u0012\u0004\u0018\u00010\u00020\u00012\n\u0010\u0007\u001a\u0006\u0012\u0002\b\u00030\bH\u0007¢\u0006\u0004\b\t\u0010\n\u001a5\u0010\u0006\u001a\n\u0012\u0006\u0012\u0004\u0018\u00010\u00020\u00012\n\u0010\u0007\u001a\u0006\u0012\u0002\b\u00030\b2\u0010\u0010\u000b\u001a\f\u0012\u0006\u0012\u0004\u0018\u00010\u0002\u0018\u00010\u0001H\u0007¢\u0006\u0004\b\t\u0010\f\u001a~\u0010\r\u001a\n\u0012\u0006\u0012\u0004\u0018\u00010\u00020\u00012\n\u0010\u0007\u001a\u0006\u0012\u0002\b\u00030\b2\u0014\u0010\u000e\u001a\u0010\u0012\f\u0012\n\u0012\u0006\u0012\u0004\u0018\u00010\u00020\u00010\u000f2\u001a\u0010\u0010\u001a\u0016\u0012\u0004\u0012\u00020\u0005\u0012\f\u0012\n\u0012\u0006\u0012\u0004\u0018\u00010\u00020\u00010\u00112(\u0010\u0012\u001a$\u0012\f\u0012\n\u0012\u0006\u0012\u0004\u0018\u00010\u00020\u0001\u0012\u0004\u0012\u00020\u0005\u0012\f\u0012\n\u0012\u0006\u0012\u0004\u0018\u00010\u00020\u00010\u0013H\u0082\b¢\u0006\u0002\u0010\u0014\"\u0018\u0010\u0000\u001a\n\u0012\u0006\u0012\u0004\u0018\u00010\u00020\u0001X\u0082\u0004¢\u0006\u0004\n\u0002\u0010\u0003\"\u000e\u0010\u0004\u001a\u00020\u0005X\u0082T¢\u0006\u0002\n\u0000¨\u0006\u0015"}, d2 = {"EMPTY", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED, RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED, "[Ljava/lang/Object;", "MAX_SIZE", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED, "collectionToArray", "collection", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED, "toArray", "(Ljava/util/Collection;)[Ljava/lang/Object;", "a", "(Ljava/util/Collection;[Ljava/lang/Object;)[Ljava/lang/Object;", "toArrayImpl", "empty", "Lkotlin/Function0;", "alloc", "Lkotlin/Function1;", "trim", "Lkotlin/Function2;", "(Ljava/util/Collection;Lkotlin/jvm/functions/Function0;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;)[Ljava/lang/Object;", "kotlin-stdlib"}, k = 2, mv = {2, 2, 0}, xi = 48)
@JvmName(name = "CollectionToArray")
@SourceDebugExtension({"SMAP\nCollectionToArray.kt\nKotlin\n*S Kotlin\n*F\n+ 1 CollectionToArray.kt\nkotlin/jvm/internal/CollectionToArray\n*L\n1#1,88:1\n63#1,22:89\n63#1,22:111\n*S KotlinDebug\n*F\n+ 1 CollectionToArray.kt\nkotlin/jvm/internal/CollectionToArray\n*L\n22#1:89,22\n37#1:111,22\n*E\n"})
/* loaded from: classes4.dex */
public final class CollectionToArray {
@NotNull
private static final Object[] EMPTY = new Object[0];
private static final int MAX_SIZE = 2147483645;
@JvmName(name = "toArray")
@NotNull
@Deprecated(message = "This function will be made internal in a future release")
@DeprecatedSinceKotlin(errorSince = "2.1", warningSince = "1.9")
public static final Object[] toArray(@NotNull Collection<?> collection, @Nullable Object[] objArr) {
Object[] objArr2;
Intrinsics.checkNotNullParameter(collection, "collection");
objArr.getClass();
int size = collection.size();
int i = 0;
if (size == 0) {
if (objArr.length > 0) {
objArr[0] = null;
return objArr;
}
} else {
Iterator<?> it = collection.iterator();
if (!it.hasNext()) {
if (objArr.length > 0) {
objArr[0] = null;
}
} else {
if (size <= objArr.length) {
objArr2 = objArr;
} else {
Object newInstance = Array.newInstance(objArr.getClass().getComponentType(), size);
Intrinsics.checkNotNull(newInstance, "null cannot be cast to non-null type kotlin.Array<kotlin.Any?>");
objArr2 = (Object[]) newInstance;
}
while (true) {
int i2 = i + 1;
objArr2[i] = it.next();
if (i2 >= objArr2.length) {
if (!it.hasNext()) {
return objArr2;
}
int i3 = ((i2 * 3) + 1) >>> 1;
if (i3 <= i2) {
i3 = MAX_SIZE;
if (i2 >= MAX_SIZE) {
throw new OutOfMemoryError();
}
}
objArr2 = Arrays.copyOf(objArr2, i3);
Intrinsics.checkNotNullExpressionValue(objArr2, "copyOf(...)");
} else if (!it.hasNext()) {
if (objArr2 == objArr) {
objArr[i2] = null;
return objArr;
}
Object[] copyOf = Arrays.copyOf(objArr2, i2);
Intrinsics.checkNotNullExpressionValue(copyOf, "copyOf(...)");
return copyOf;
}
i = i2;
}
}
}
return objArr;
}
/* JADX WARN: Type inference failed for: r3v4, types: [java.lang.Object, java.lang.Object[]] */
/* JADX WARN: Type inference failed for: r3v5 */
/* JADX WARN: Type inference failed for: r3v6, types: [java.lang.Object[], java.lang.Object] */
/* JADX WARN: Type inference failed for: r3v7 */
/* JADX WARN: Type inference failed for: r3v8 */
private static final Object[] toArrayImpl(Collection<?> collection, Function0<Object[]> function0, Function1<? super Integer, Object[]> function1, Function2<? super Object[], ? super Integer, Object[]> function2) {
int size = collection.size();
if (size == 0) {
return function0.invoke();
}
Iterator<?> it = collection.iterator();
if (!it.hasNext()) {
return function0.invoke();
}
Object[] invoke = function1.invoke(Integer.valueOf(size));
int i = 0;
?? r3 = invoke;
while (true) {
int i2 = i + 1;
r3[i] = it.next();
if (i2 >= r3.length) {
if (!it.hasNext()) {
return r3;
}
int i3 = ((i2 * 3) + 1) >>> 1;
if (i3 <= i2) {
i3 = MAX_SIZE;
if (i2 >= MAX_SIZE) {
throw new OutOfMemoryError();
}
}
r3 = Arrays.copyOf((Object[]) r3, i3);
Intrinsics.checkNotNullExpressionValue(r3, "copyOf(...)");
} else if (!it.hasNext()) {
return function2.invoke(r3, Integer.valueOf(i2));
}
i = i2;
r3 = r3;
}
}
@JvmName(name = "toArray")
@NotNull
@Deprecated(message = "This function will be made internal in a future release")
@DeprecatedSinceKotlin(errorSince = "2.1", warningSince = "1.9")
public static final Object[] toArray(@NotNull Collection<?> collection) {
Intrinsics.checkNotNullParameter(collection, "collection");
int size = collection.size();
if (size == 0) {
return EMPTY;
}
Iterator<?> it = collection.iterator();
if (!it.hasNext()) {
return EMPTY;
}
Object[] objArr = new Object[size];
int i = 0;
while (true) {
int i2 = i + 1;
objArr[i] = it.next();
if (i2 >= objArr.length) {
if (!it.hasNext()) {
return objArr;
}
int i3 = ((i2 * 3) + 1) >>> 1;
if (i3 <= i2) {
i3 = MAX_SIZE;
if (i2 >= MAX_SIZE) {
throw new OutOfMemoryError();
}
}
objArr = Arrays.copyOf(objArr, i3);
Intrinsics.checkNotNullExpressionValue(objArr, "copyOf(...)");
} else if (!it.hasNext()) {
Object[] copyOf = Arrays.copyOf(objArr, i2);
Intrinsics.checkNotNullExpressionValue(copyOf, "copyOf(...)");
return copyOf;
}
i = i2;
}
}
}