soul-browser/sources/java/com/google/android/gms/common/util/CollectionUtils.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

190 lines
5.4 KiB
Java

package com.google.android.gms.common.util;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.collection.ArraySet;
import androidx.collection.SimpleArrayMap;
import com.google.android.gms.common.annotation.KeepForSdk;
import j$.util.DesugarCollections;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import kotlin.uuid.Uuid;
@KeepForSdk
/* loaded from: classes.dex */
public final class CollectionUtils {
private CollectionUtils() {
}
@KeepForSdk
public static boolean isEmpty(@Nullable Collection<?> collection) {
if (collection != null && !collection.isEmpty()) {
return false;
}
return true;
}
@NonNull
@KeepForSdk
@Deprecated
public static <T> List<T> listOf() {
return Collections.EMPTY_LIST;
}
@NonNull
@KeepForSdk
public static <K, V> Map<K, V> mapOf(@NonNull K k, @NonNull V v, @NonNull K k2, @NonNull V v2, @NonNull K k3, @NonNull V v3) {
Map zzb = zzb(3, false);
zzb.put(k, v);
zzb.put(k2, v2);
zzb.put(k3, v3);
return DesugarCollections.unmodifiableMap(zzb);
}
@NonNull
@KeepForSdk
public static <K, V> Map<K, V> mapOfKeyValueArrays(@NonNull K[] kArr, @NonNull V[] vArr) {
int length = kArr.length;
int length2 = vArr.length;
if (length == length2) {
if (length != 0) {
if (length != 1) {
Map zzb = zzb(length, false);
for (int i = 0; i < kArr.length; i++) {
zzb.put(kArr[i], vArr[i]);
}
return DesugarCollections.unmodifiableMap(zzb);
}
return Collections.singletonMap(kArr[0], vArr[0]);
}
return Collections.EMPTY_MAP;
}
throw new IllegalArgumentException(com.mycompany.app.dialog.a.m(new StringBuilder(String.valueOf(length).length() + 44 + String.valueOf(length2).length()), "Key and values array lengths not equal: ", length, " != ", length2));
}
@NonNull
@KeepForSdk
public static <T> Set<T> mutableSetOfWithSize(int i) {
if (i == 0) {
return new ArraySet(0);
}
return zza(i, true);
}
@NonNull
@KeepForSdk
@Deprecated
public static <T> Set<T> setOf(@NonNull T t, @NonNull T t2, @NonNull T t3) {
Set zza = zza(3, false);
zza.add(t);
zza.add(t2);
zza.add(t3);
return DesugarCollections.unmodifiableSet(zza);
}
private static Set zza(int i, boolean z) {
int i2;
float f;
if (true != z) {
i2 = 256;
} else {
i2 = Uuid.SIZE_BITS;
}
if (i <= i2) {
return new ArraySet(i);
}
if (true != z) {
f = 1.0f;
} else {
f = 0.75f;
}
return new HashSet(i, f);
}
/* JADX WARN: Type inference failed for: r2v3, types: [java.util.Map, androidx.collection.SimpleArrayMap] */
private static Map zzb(int i, boolean z) {
if (i <= 256) {
return new SimpleArrayMap(i);
}
return new HashMap(i, 1.0f);
}
@NonNull
@KeepForSdk
@Deprecated
public static <T> List<T> listOf(@NonNull T t) {
return Collections.singletonList(t);
}
@NonNull
@KeepForSdk
@Deprecated
public static <T> List<T> listOf(@NonNull T... tArr) {
int length = tArr.length;
if (length == 0) {
return Collections.EMPTY_LIST;
}
if (length != 1) {
return DesugarCollections.unmodifiableList(Arrays.asList(tArr));
}
return Collections.singletonList(tArr[0]);
}
@NonNull
@KeepForSdk
public static <K, V> Map<K, V> mapOf(@NonNull K k, @NonNull V v, @NonNull K k2, @NonNull V v2, @NonNull K k3, @NonNull V v3, @NonNull K k4, @NonNull V v4, @NonNull K k5, @NonNull V v5, @NonNull K k6, @NonNull V v6) {
Map zzb = zzb(6, false);
zzb.put(k, v);
zzb.put(k2, v2);
zzb.put(k3, v3);
zzb.put(k4, v4);
zzb.put(k5, v5);
zzb.put(k6, v6);
return DesugarCollections.unmodifiableMap(zzb);
}
@NonNull
@KeepForSdk
@Deprecated
public static <T> Set<T> setOf(@NonNull T... tArr) {
int length = tArr.length;
if (length == 0) {
return Collections.EMPTY_SET;
}
if (length == 1) {
return Collections.singleton(tArr[0]);
}
if (length == 2) {
T t = tArr[0];
T t2 = tArr[1];
Set zza = zza(2, false);
zza.add(t);
zza.add(t2);
return DesugarCollections.unmodifiableSet(zza);
}
if (length == 3) {
return setOf(tArr[0], tArr[1], tArr[2]);
}
if (length != 4) {
Set zza2 = zza(length, false);
Collections.addAll(zza2, tArr);
return DesugarCollections.unmodifiableSet(zza2);
}
T t3 = tArr[0];
T t4 = tArr[1];
T t5 = tArr[2];
T t6 = tArr[3];
Set zza3 = zza(4, false);
zza3.add(t3);
zza3.add(t4);
zza3.add(t5);
zza3.add(t6);
return DesugarCollections.unmodifiableSet(zza3);
}
}