soul-browser/sources/java/com/google/android/gms/dynamite/DynamiteModule.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

266 lines
12 KiB
Java

package com.google.android.gms.dynamite;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.ProviderInfo;
import android.os.IBinder;
import android.os.IInterface;
import android.util.Log;
import androidx.annotation.NonNull;
import com.google.android.gms.common.GoogleApiAvailabilityLight;
import com.google.android.gms.common.annotation.KeepForSdk;
import com.google.android.gms.common.internal.Objects;
import com.google.android.gms.common.internal.Preconditions;
import com.google.android.gms.common.util.DynamiteApi;
import com.google.android.gms.common.util.PlatformVersion;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
@KeepForSdk
/* loaded from: classes.dex */
public final class DynamiteModule {
public static final VersionPolicy d = null;
public static Boolean f = null;
public static String g = null;
public static boolean h = false;
public static int i = -1;
public static Boolean j;
public static zzp n;
public static zzq o;
/* renamed from: a, reason: collision with root package name */
public final Context f3729a;
public static final ThreadLocal k = new ThreadLocal();
public static final ThreadLocal l = new ThreadLocal();
public static final VersionPolicy.IVersions m = new Object();
public static final VersionPolicy b = new Object();
/* renamed from: c, reason: collision with root package name */
public static final VersionPolicy f3728c = new Object();
public static final VersionPolicy e = new Object();
@DynamiteApi
/* loaded from: classes.dex */
public static class DynamiteLoaderClassLoader {
@NonNull
public static ClassLoader sClassLoader;
}
@KeepForSdk
/* loaded from: classes.dex */
public static class LoadingException extends Exception {
}
/* loaded from: classes.dex */
public interface VersionPolicy {
@KeepForSdk
/* loaded from: classes.dex */
public interface IVersions {
int a(Context context, String str, boolean z);
int b(Context context, String str);
}
@KeepForSdk
/* loaded from: classes.dex */
public static class SelectionResult {
/* renamed from: a, reason: collision with root package name */
public int f3730a = 0;
public int b = 0;
/* renamed from: c, reason: collision with root package name */
public int f3731c = 0;
}
SelectionResult a(Context context, String str, IVersions iVersions);
}
public DynamiteModule(Context context) {
Preconditions.checkNotNull(context);
this.f3729a = context;
}
public static int a(Context context, String str) {
try {
ClassLoader classLoader = context.getApplicationContext().getClassLoader();
StringBuilder sb = new StringBuilder(String.valueOf(str).length() + 61);
sb.append("com.google.android.gms.dynamite.descriptors.");
sb.append(str);
sb.append(".ModuleDescriptor");
Class<?> loadClass = classLoader.loadClass(sb.toString());
Field declaredField = loadClass.getDeclaredField("MODULE_ID");
Field declaredField2 = loadClass.getDeclaredField("MODULE_VERSION");
if (!Objects.equal(declaredField.get(null), str)) {
String valueOf = String.valueOf(declaredField.get(null));
StringBuilder sb2 = new StringBuilder(valueOf.length() + 50 + String.valueOf(str).length() + 1);
sb2.append("Module descriptor id '");
sb2.append(valueOf);
sb2.append("' didn't match expected id '");
sb2.append(str);
sb2.append("'");
Log.e("DynamiteModule", sb2.toString());
return 0;
}
return declaredField2.getInt(null);
} catch (ClassNotFoundException unused) {
StringBuilder sb3 = new StringBuilder(String.valueOf(str).length() + 45);
sb3.append("Local module descriptor class for ");
sb3.append(str);
sb3.append(" not found.");
Log.w("DynamiteModule", sb3.toString());
return 0;
} catch (Exception e2) {
Log.e("DynamiteModule", "Failed to load module descriptor class: ".concat(String.valueOf(e2.getMessage())));
return 0;
}
}
/* JADX WARN: Multi-variable type inference failed */
/* JADX WARN: Removed duplicated region for block: B:69:0x0315 A[DONT_GENERATE] */
/* JADX WARN: Removed duplicated region for block: B:72:0x0324 A[DONT_GENERATE] */
/* JADX WARN: Removed duplicated region for block: B:75:0x031b A[DONT_GENERATE] */
/* JADX WARN: Type inference failed for: r15v0, types: [com.google.android.gms.dynamite.zzn, java.lang.Object] */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public static com.google.android.gms.dynamite.DynamiteModule c(android.content.Context r29, com.google.android.gms.dynamite.DynamiteModule.VersionPolicy r30, java.lang.String r31) {
/*
Method dump skipped, instructions count: 972
To view this dump add '--comments-level debug' option
*/
throw new UnsupportedOperationException("Method not decompiled: com.google.android.gms.dynamite.DynamiteModule.c(android.content.Context, com.google.android.gms.dynamite.DynamiteModule$VersionPolicy, java.lang.String):com.google.android.gms.dynamite.DynamiteModule");
}
/* JADX WARN: Code restructure failed: missing block: B:43:0x019e, code lost:
if (r4 != false) goto L102;
*/
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public static int d(android.content.Context r13, java.lang.String r14, boolean r15) {
/*
Method dump skipped, instructions count: 584
To view this dump add '--comments-level debug' option
*/
throw new UnsupportedOperationException("Method not decompiled: com.google.android.gms.dynamite.DynamiteModule.d(android.content.Context, java.lang.String, boolean):int");
}
public static boolean e(Context context) {
int i2;
ApplicationInfo applicationInfo;
Boolean bool = Boolean.TRUE;
if (bool.equals(null) || bool.equals(j)) {
return true;
}
boolean z = false;
if (j == null) {
PackageManager packageManager = context.getPackageManager();
if (true != PlatformVersion.isAtLeastQ()) {
i2 = 0;
} else {
i2 = 268435456;
}
ProviderInfo resolveContentProvider = packageManager.resolveContentProvider("com.google.android.gms.chimera", i2);
if (GoogleApiAvailabilityLight.getInstance().isGooglePlayServicesAvailable(context, 10000000) == 0 && resolveContentProvider != null && "com.google.android.gms".equals(resolveContentProvider.packageName)) {
z = true;
}
j = Boolean.valueOf(z);
if (z && (applicationInfo = resolveContentProvider.applicationInfo) != null && (applicationInfo.flags & 129) == 0) {
Log.i("DynamiteModule", "Non-system-image GmsCore APK, forcing V1");
h = true;
}
}
if (!z) {
Log.e("DynamiteModule", "Invalid GmsCore APK, remote loading disabled.");
}
return z;
}
/* JADX WARN: Code restructure failed: missing block: B:38:0x0137, code lost:
if (r6 != false) goto L92;
*/
/* JADX WARN: Finally extract failed */
/* JADX WARN: Removed duplicated region for block: B:14:0x00e7 A[EXC_TOP_SPLITTER, SYNTHETIC] */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public static int f(android.content.Context r14, java.lang.String r15, boolean r16, boolean r17) {
/*
Method dump skipped, instructions count: 413
To view this dump add '--comments-level debug' option
*/
throw new UnsupportedOperationException("Method not decompiled: com.google.android.gms.dynamite.DynamiteModule.f(android.content.Context, java.lang.String, boolean, boolean):int");
}
/* JADX WARN: Multi-variable type inference failed */
/* JADX WARN: Type inference failed for: r1v4, types: [com.google.android.gms.internal.common.zza] */
public static void g(ClassLoader classLoader) {
try {
zzq zzqVar = null;
IBinder iBinder = (IBinder) classLoader.loadClass("com.google.android.gms.dynamiteloader.DynamiteLoaderV2").getConstructor(null).newInstance(null);
if (iBinder != null) {
IInterface queryLocalInterface = iBinder.queryLocalInterface("com.google.android.gms.dynamite.IDynamiteLoaderV2");
if (queryLocalInterface instanceof zzq) {
zzqVar = (zzq) queryLocalInterface;
} else {
zzqVar = new com.google.android.gms.internal.common.zza(iBinder, "com.google.android.gms.dynamite.IDynamiteLoaderV2");
}
}
o = zzqVar;
} catch (ClassNotFoundException | IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException e2) {
throw new Exception("Failed to instantiate dynamite loader", e2);
}
}
/* JADX WARN: Multi-variable type inference failed */
public static zzp h(Context context) {
zzp zzpVar;
synchronized (DynamiteModule.class) {
zzp zzpVar2 = n;
if (zzpVar2 != null) {
return zzpVar2;
}
try {
IBinder iBinder = (IBinder) context.createPackageContext("com.google.android.gms", 3).getClassLoader().loadClass("com.google.android.gms.chimera.container.DynamiteLoaderImpl").newInstance();
if (iBinder == null) {
zzpVar = 0;
} else {
IInterface queryLocalInterface = iBinder.queryLocalInterface("com.google.android.gms.dynamite.IDynamiteLoader");
if (queryLocalInterface instanceof zzp) {
zzpVar = (zzp) queryLocalInterface;
} else {
zzpVar = new com.google.android.gms.internal.common.zza(iBinder, "com.google.android.gms.dynamite.IDynamiteLoader");
}
}
if (zzpVar != 0) {
n = zzpVar;
return zzpVar;
}
} catch (Exception e2) {
String message = e2.getMessage();
StringBuilder sb = new StringBuilder(String.valueOf(message).length() + 45);
sb.append("Failed to load IDynamiteLoader from GmsCore: ");
sb.append(message);
Log.e("DynamiteModule", sb.toString());
}
return null;
}
}
public final IBinder b(String str) {
try {
return (IBinder) this.f3729a.getClassLoader().loadClass(str).newInstance();
} catch (ClassNotFoundException | IllegalAccessException | InstantiationException e2) {
throw new Exception("Failed to instantiate module class: ".concat(String.valueOf(str)), e2);
}
}
}