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

293 lines
8.8 KiB
Java

package com.google.android.gms.common.internal;
import android.os.Handler;
import android.os.Looper;
import android.support.v4.media.a;
import android.text.TextUtils;
import androidx.annotation.IntRange;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.google.android.gms.common.annotation.KeepForSdk;
@KeepForSdk
/* loaded from: classes.dex */
public final class Preconditions {
private Preconditions() {
throw new AssertionError("Uninstantiable");
}
@KeepForSdk
public static void checkArgument(boolean z) {
if (!z) {
throw new IllegalArgumentException();
}
}
@KeepForSdk
public static double checkArgumentInRange(double d, double d2, double d3, @NonNull String str) {
if (d < d2) {
throw new IllegalArgumentException(zza("%s is out of range of [%f, %f] (too low)", str, Double.valueOf(d2), Double.valueOf(d3)));
}
if (d <= d3) {
return d;
}
throw new IllegalArgumentException(zza("%s is out of range of [%f, %f] (too high)", str, Double.valueOf(d2), Double.valueOf(d3)));
}
@IntRange
@KeepForSdk
public static int checkArgumentNonnegative(int i) {
if (i >= 0) {
return i;
}
throw new IllegalArgumentException("Given value is negative");
}
@KeepForSdk
public static void checkHandlerThread(@NonNull Handler handler) {
String str;
Looper myLooper = Looper.myLooper();
if (myLooper != handler.getLooper()) {
if (myLooper != null) {
str = myLooper.getThread().getName();
} else {
str = "null current looper";
}
String name = handler.getLooper().getThread().getName();
int length = String.valueOf(name).length();
StringBuilder sb = new StringBuilder(String.valueOf(str).length() + length + 35 + 1);
a.z(sb, "Must be called on ", name, " thread, but got ", str);
sb.append(".");
throw new IllegalStateException(sb.toString());
}
}
@KeepForSdk
public static void checkMainThread() {
checkMainThread("Must be called on the main application thread");
}
@NonNull
@KeepForSdk
public static String checkNotEmpty(@Nullable String str) {
if (TextUtils.isEmpty(str)) {
throw new IllegalArgumentException("Given String is empty or null");
}
return str;
}
@KeepForSdk
public static void checkNotGoogleApiHandlerThread() {
checkNotGoogleApiHandlerThread("Must not be called on GoogleApiHandler thread.");
}
@KeepForSdk
public static void checkNotMainThread() {
checkNotMainThread("Must not be called on the main application thread");
}
@NonNull
@KeepForSdk
public static <T> T checkNotNull(@Nullable T t) {
if (t != null) {
return t;
}
throw new NullPointerException("null reference");
}
@KeepForSdk
public static int checkNotZero(int i) {
if (i != 0) {
return i;
}
throw new IllegalArgumentException("Given Integer is zero");
}
@KeepForSdk
public static void checkState(boolean z) {
if (!z) {
throw new IllegalStateException();
}
}
public static String zza(String str, Object... objArr) {
int indexOf;
StringBuilder sb = new StringBuilder(str.length() + 48);
int i = 0;
int i2 = 0;
while (i < 3 && (indexOf = str.indexOf("%s", i2)) != -1) {
sb.append(str.substring(i2, indexOf));
sb.append(objArr[i]);
i2 = indexOf + 2;
i++;
}
sb.append(str.substring(i2));
if (i < 3) {
sb.append(" [");
sb.append(objArr[i]);
for (int i3 = i + 1; i3 < 3; i3++) {
sb.append(", ");
sb.append(objArr[i3]);
}
sb.append("]");
}
return sb.toString();
}
@KeepForSdk
public static void checkArgument(boolean z, @NonNull Object obj) {
if (!z) {
throw new IllegalArgumentException(String.valueOf(obj));
}
}
@IntRange
@KeepForSdk
public static int checkArgumentNonnegative(int i, @NonNull String str) {
if (i >= 0) {
return i;
}
throw new IllegalArgumentException(str);
}
@KeepForSdk
public static void checkMainThread(@NonNull String str) {
if (!com.google.android.gms.common.util.zze.zza()) {
throw new IllegalStateException(str);
}
}
@KeepForSdk
public static void checkNotGoogleApiHandlerThread(@NonNull String str) {
Looper myLooper = Looper.myLooper();
if (myLooper != null && j$.util.Objects.equals(myLooper.getThread().getName(), "GoogleApiHandler")) {
throw new IllegalStateException(str);
}
}
@KeepForSdk
public static void checkNotMainThread(@NonNull String str) {
if (com.google.android.gms.common.util.zze.zza()) {
throw new IllegalStateException(str);
}
}
@NonNull
@KeepForSdk
public static <T> T checkNotNull(@NonNull T t, @NonNull Object obj) {
if (t != null) {
return t;
}
throw new NullPointerException(String.valueOf(obj));
}
@KeepForSdk
public static int checkNotZero(int i, @NonNull Object obj) {
if (i != 0) {
return i;
}
throw new IllegalArgumentException(String.valueOf(obj));
}
@KeepForSdk
public static void checkState(boolean z, @NonNull Object obj) {
if (!z) {
throw new IllegalStateException(String.valueOf(obj));
}
}
@KeepForSdk
public static void checkArgument(boolean z, @NonNull String str, @NonNull Object... objArr) {
if (!z) {
throw new IllegalArgumentException(String.format(str, objArr));
}
}
@KeepForSdk
public static long checkArgumentNonnegative(long j) {
if (j >= 0) {
return j;
}
throw new IllegalArgumentException("Given value is negative");
}
@NonNull
@KeepForSdk
public static String checkNotEmpty(@Nullable String str, @NonNull Object obj) {
if (TextUtils.isEmpty(str)) {
throw new IllegalArgumentException(String.valueOf(obj));
}
return str;
}
@KeepForSdk
public static long checkNotZero(long j) {
if (j != 0) {
return j;
}
throw new IllegalArgumentException("Given Long is zero");
}
@KeepForSdk
public static void checkState(boolean z, @NonNull String str, @NonNull Object... objArr) {
if (!z) {
throw new IllegalStateException(String.format(str, objArr));
}
}
@KeepForSdk
public static float checkArgumentInRange(float f, float f2, float f3, @NonNull String str) {
if (f < f2) {
throw new IllegalArgumentException(zza("%s is out of range of [%f, %f] (too low)", str, Float.valueOf(f2), Float.valueOf(f3)));
}
if (f <= f3) {
return f;
}
throw new IllegalArgumentException(zza("%s is out of range of [%f, %f] (too high)", str, Float.valueOf(f2), Float.valueOf(f3)));
}
@KeepForSdk
public static long checkArgumentNonnegative(long j, @NonNull String str) {
if (j >= 0) {
return j;
}
throw new IllegalArgumentException(str);
}
@KeepForSdk
public static long checkNotZero(long j, @NonNull Object obj) {
if (j != 0) {
return j;
}
throw new IllegalArgumentException(String.valueOf(obj));
}
@KeepForSdk
public static int checkArgumentInRange(int i, int i2, int i3, @NonNull String str) {
if (i < i2) {
throw new IllegalArgumentException(zza("%s is out of range of [%d, %d] (too low)", str, Integer.valueOf(i2), Integer.valueOf(i3)));
}
if (i <= i3) {
return i;
}
throw new IllegalArgumentException(zza("%s is out of range of [%d, %d] (too high)", str, Integer.valueOf(i2), Integer.valueOf(i3)));
}
@KeepForSdk
public static long checkArgumentInRange(long j, long j2, long j3, @NonNull String str) {
if (j < j2) {
throw new IllegalArgumentException(zza("%s is out of range of [%d, %d] (too low)", str, Long.valueOf(j2), Long.valueOf(j3)));
}
if (j <= j3) {
return j;
}
throw new IllegalArgumentException(zza("%s is out of range of [%d, %d] (too high)", str, Long.valueOf(j2), Long.valueOf(j3)));
}
@KeepForSdk
public static void checkHandlerThread(@NonNull Handler handler, @NonNull String str) {
if (Looper.myLooper() != handler.getLooper()) {
throw new IllegalStateException(str);
}
}
}