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

264 lines
10 KiB
Java

package com.google.android.gms.common;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.Signature;
import android.util.Log;
import androidx.annotation.NonNull;
import com.google.android.gms.common.annotation.KeepForSdk;
import com.google.android.gms.common.internal.Preconditions;
import com.google.android.gms.common.internal.ShowFirstParty;
import java.util.Set;
import javax.annotation.Nullable;
@ShowFirstParty
@KeepForSdk
/* loaded from: classes.dex */
public class GoogleSignatureVerifier {
@Nullable
private static GoogleSignatureVerifier zza;
@Nullable
private static volatile Set zzd;
@Nullable
private static volatile Set zze;
private final Context zzb;
private volatile String zzc;
public GoogleSignatureVerifier(@NonNull Context context) {
this.zzb = context.getApplicationContext();
}
@NonNull
@KeepForSdk
public static GoogleSignatureVerifier getInstance(@NonNull Context context) {
Preconditions.checkNotNull(context);
synchronized (GoogleSignatureVerifier.class) {
try {
if (zza == null) {
zzo.zza(context);
zza = new GoogleSignatureVerifier(context);
}
} catch (Throwable th) {
throw th;
}
}
return zza;
}
/* JADX WARN: Code restructure failed: missing block: B:42:0x00c0, code lost:
r5 = r9;
*/
/* JADX WARN: Multi-variable type inference failed */
@java.lang.Deprecated
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public static final boolean zza(android.content.pm.PackageInfo r10, boolean r11) {
/*
Method dump skipped, instructions count: 240
To view this dump add '--comments-level debug' option
*/
throw new UnsupportedOperationException("Method not decompiled: com.google.android.gms.common.GoogleSignatureVerifier.zza(android.content.pm.PackageInfo, boolean):boolean");
}
/* JADX WARN: Multi-variable type inference failed */
/* JADX WARN: Removed duplicated region for block: B:16:0x00bd */
/* JADX WARN: Type inference failed for: r8v4, types: [android.os.StrictMode$ThreadPolicy] */
/* JADX WARN: Type inference failed for: r8v6, types: [int] */
@android.annotation.SuppressLint({"PackageManagerGetSignatures"})
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
private final com.google.android.gms.common.zzy zzb(@javax.annotation.Nullable java.lang.String r6, boolean r7, boolean r8) {
/*
r5 = this;
java.lang.String r7 = "null pkg"
if (r6 != 0) goto L9
com.google.android.gms.common.zzy r6 = com.google.android.gms.common.zzy.zzc(r7)
return r6
L9:
java.lang.String r8 = r5.zzc
boolean r8 = r6.equals(r8)
if (r8 != 0) goto Ld0
int r8 = com.google.android.gms.common.zzo.zzh
android.os.StrictMode$ThreadPolicy r8 = android.os.StrictMode.allowThreadDiskReads()
r0 = 1
com.google.android.gms.common.zzo.zzb() // Catch: java.lang.Throwable -> L45 android.os.RemoteException -> L48 com.google.android.gms.dynamite.DynamiteModule.LoadingException -> L4a
com.google.android.gms.common.internal.zzad r1 = com.google.android.gms.common.zzo.zzg // Catch: java.lang.Throwable -> L45 android.os.RemoteException -> L48 com.google.android.gms.dynamite.DynamiteModule.LoadingException -> L4a
boolean r1 = r1.zzg() // Catch: java.lang.Throwable -> L45 android.os.RemoteException -> L48 com.google.android.gms.dynamite.DynamiteModule.LoadingException -> L4a
android.os.StrictMode.setThreadPolicy(r8)
if (r1 == 0) goto L55
com.google.android.gms.common.zzv r7 = new com.google.android.gms.common.zzv
r8 = 0
r7.<init>(r8)
r7.zza(r6)
android.content.Context r8 = r5.zzb
boolean r8 = com.google.android.gms.common.GooglePlayServicesUtilLight.honorsDebugCertificates(r8)
r7.zzb(r8)
r7.zzc(r0)
com.google.android.gms.common.zzw r7 = r7.zzd()
com.google.android.gms.common.zzy r7 = com.google.android.gms.common.zzo.zzc(r7)
goto Lb9
L45:
r6 = move-exception
goto Lcc
L48:
r1 = move-exception
goto L4b
L4a:
r1 = move-exception
L4b:
java.lang.String r2 = "GoogleCertificates"
java.lang.String r3 = "Failed to get Google certificates from remote"
android.util.Log.e(r2, r3, r1) // Catch: java.lang.Throwable -> L45
android.os.StrictMode.setThreadPolicy(r8)
L55:
int r8 = android.os.Build.VERSION.SDK_INT
r1 = 28
if (r8 < r1) goto L5f
r8 = 134217792(0x8000040, float:3.8518893E-34)
goto L61
L5f:
r8 = 64
L61:
android.content.Context r1 = r5.zzb // Catch: android.content.pm.PackageManager.NameNotFoundException -> Lc0
android.content.pm.PackageManager r1 = r1.getPackageManager() // Catch: android.content.pm.PackageManager.NameNotFoundException -> Lc0
android.content.pm.PackageInfo r8 = r1.getPackageInfo(r6, r8) // Catch: android.content.pm.PackageManager.NameNotFoundException -> Lc0
android.content.Context r1 = r5.zzb
boolean r1 = com.google.android.gms.common.GooglePlayServicesUtilLight.honorsDebugCertificates(r1)
if (r8 != 0) goto L78
com.google.android.gms.common.zzy r7 = com.google.android.gms.common.zzy.zzc(r7)
goto Lb9
L78:
android.content.pm.Signature[] r7 = r8.signatures
if (r7 == 0) goto Lb3
int r7 = r7.length
if (r7 == r0) goto L80
goto Lb3
L80:
com.google.android.gms.common.zzk r7 = new com.google.android.gms.common.zzk
android.content.pm.Signature[] r2 = r8.signatures
r3 = 0
r2 = r2[r3]
byte[] r2 = r2.toByteArray()
r7.<init>(r2)
java.lang.String r2 = r8.packageName
com.google.android.gms.common.zzy r1 = com.google.android.gms.common.zzo.zzd(r2, r7, r1, r3)
boolean r4 = r1.zza
if (r4 == 0) goto Lb1
android.content.pm.ApplicationInfo r8 = r8.applicationInfo
if (r8 == 0) goto Lb1
int r8 = r8.flags
r8 = r8 & 2
if (r8 == 0) goto Lb1
com.google.android.gms.common.zzy r7 = com.google.android.gms.common.zzo.zzd(r2, r7, r3, r0)
boolean r7 = r7.zza
if (r7 == 0) goto Lb1
java.lang.String r7 = "debuggable release cert app rejected"
com.google.android.gms.common.zzy r7 = com.google.android.gms.common.zzy.zzc(r7)
goto Lb9
Lb1:
r7 = r1
goto Lb9
Lb3:
java.lang.String r7 = "single cert required"
com.google.android.gms.common.zzy r7 = com.google.android.gms.common.zzy.zzc(r7)
Lb9:
boolean r8 = r7.zza
if (r8 == 0) goto Lbf
r5.zzc = r6
Lbf:
return r7
Lc0:
r7 = move-exception
java.lang.String r8 = "no pkg "
java.lang.String r6 = r8.concat(r6)
com.google.android.gms.common.zzy r6 = com.google.android.gms.common.zzy.zzd(r6, r7)
return r6
Lcc:
android.os.StrictMode.setThreadPolicy(r8)
throw r6
Ld0:
com.google.android.gms.common.zzy r6 = com.google.android.gms.common.zzy.zzb()
return r6
*/
throw new UnsupportedOperationException("Method not decompiled: com.google.android.gms.common.GoogleSignatureVerifier.zzb(java.lang.String, boolean, boolean):com.google.android.gms.common.zzy");
}
@Nullable
private static zzj zzc(PackageInfo packageInfo, zzj... zzjVarArr) {
Signature[] signatureArr = packageInfo.signatures;
if (signatureArr != null) {
if (signatureArr.length != 1) {
Log.w("GoogleSignatureVerifier", "Package has more than one signature.");
return null;
}
zzk zzkVar = new zzk(packageInfo.signatures[0].toByteArray());
for (int i = 0; i < zzjVarArr.length; i++) {
if (zzjVarArr[i].equals(zzkVar)) {
return zzjVarArr[i];
}
}
}
return null;
}
@KeepForSdk
public boolean isGooglePublicSignedPackage(@NonNull PackageInfo packageInfo) {
if (packageInfo == null) {
return false;
}
if (zza(packageInfo, false)) {
return true;
}
if (zza(packageInfo, true)) {
if (GooglePlayServicesUtilLight.honorsDebugCertificates(this.zzb)) {
return true;
}
Log.w("GoogleSignatureVerifier", "Test-keys aren't accepted on this build.");
}
return false;
}
@ShowFirstParty
@KeepForSdk
public boolean isPackageGoogleSigned(@Nullable String str) {
zzy zzb = zzb(str, false, false);
zzb.zze();
return zzb.zza;
}
@ShowFirstParty
@KeepForSdk
public boolean isUidGoogleSigned(int i) {
zzy zzc;
int length;
String[] packagesForUid = this.zzb.getPackageManager().getPackagesForUid(i);
if (packagesForUid != null && (length = packagesForUid.length) != 0) {
zzc = null;
int i2 = 0;
while (true) {
if (i2 < length) {
zzc = zzb(packagesForUid[i2], false, false);
if (zzc.zza) {
break;
}
i2++;
} else {
Preconditions.checkNotNull(zzc);
break;
}
}
} else {
zzc = zzy.zzc("no pkgs");
}
zzc.zze();
return zzc.zza;
}
}