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

357 lines
12 KiB
Java

package com.google.android.gms.common.util;
import android.annotation.TargetApi;
import android.app.ActivityManager;
import android.content.Context;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Build;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.google.android.apps.common.proguard.SideEffectFree;
import com.google.android.gms.common.GooglePlayServicesUtilLight;
import com.google.android.gms.common.annotation.KeepForSdk;
import com.google.android.gms.common.internal.Objects;
@KeepForSdk
/* loaded from: classes.dex */
public final class DeviceProperties {
@Nullable
private static Boolean zza;
@Nullable
private static Boolean zzb;
@Nullable
private static Boolean zzc;
@Nullable
private static Boolean zzd;
@Nullable
private static Boolean zze;
@Nullable
private static Boolean zzf;
@Nullable
private static Boolean zzg;
@Nullable
private static Boolean zzh;
@Nullable
private static Boolean zzi;
@Nullable
private static Boolean zzj;
@Nullable
private static Boolean zzk;
@Nullable
private static Boolean zzl;
@Nullable
private static Boolean zzm;
@Nullable
private static Boolean zzn;
@Nullable
private static Boolean zzo;
@Nullable
private static Boolean zzp;
@Nullable
private static Boolean zzq;
private DeviceProperties() {
}
@SideEffectFree
@KeepForSdk
public static boolean isAuto(@NonNull Context context) {
return zze(context.getPackageManager());
}
@SideEffectFree
@KeepForSdk
public static boolean isBstar(@NonNull Context context) {
if (zzo == null) {
boolean z = false;
if (PlatformVersion.isAtLeastR() && context.getPackageManager().hasSystemFeature("com.google.android.play.feature.HPE_EXPERIENCE")) {
z = true;
}
zzo = Boolean.valueOf(z);
}
return zzo.booleanValue();
}
@KeepForSdk
public static boolean isFoldable(@NonNull Context context) {
if (zzd == null) {
boolean z = false;
if (PlatformVersion.isAtLeastR() && context.getPackageManager().hasSystemFeature("android.hardware.sensor.hinge_angle")) {
z = true;
}
zzd = Boolean.valueOf(z);
}
return zzd.booleanValue();
}
@KeepForSdk
public static boolean isLatchsky(@NonNull Context context) {
if (zzh == null) {
PackageManager packageManager = context.getPackageManager();
boolean z = false;
if (packageManager.hasSystemFeature("com.google.android.feature.services_updater") && packageManager.hasSystemFeature("cn.google.services")) {
z = true;
}
zzh = Boolean.valueOf(z);
}
return zzh.booleanValue();
}
/* JADX WARN: Code restructure failed: missing block: B:33:0x0088, code lost:
if (com.google.android.gms.common.util.DeviceProperties.zzq.booleanValue() == false) goto L37;
*/
@com.google.android.gms.common.annotation.KeepForSdk
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public static boolean isPhone(@androidx.annotation.NonNull android.content.Context r4) {
/*
java.lang.Boolean r0 = com.google.android.gms.common.util.DeviceProperties.zza
if (r0 != 0) goto L92
boolean r0 = isFoldable(r4)
r1 = 1
if (r0 != 0) goto L8c
boolean r0 = isTablet(r4)
r2 = 0
if (r0 != 0) goto L8b
boolean r0 = isWearable(r4)
if (r0 != 0) goto L8b
boolean r0 = zzd(r4)
if (r0 != 0) goto L8b
java.lang.Boolean r0 = com.google.android.gms.common.util.DeviceProperties.zzk
if (r0 != 0) goto L32
android.content.pm.PackageManager r0 = r4.getPackageManager()
java.lang.String r3 = "org.chromium.arc"
boolean r0 = r0.hasSystemFeature(r3)
java.lang.Boolean r0 = java.lang.Boolean.valueOf(r0)
com.google.android.gms.common.util.DeviceProperties.zzk = r0
L32:
java.lang.Boolean r0 = com.google.android.gms.common.util.DeviceProperties.zzk
boolean r0 = r0.booleanValue()
if (r0 != 0) goto L8b
boolean r0 = isAuto(r4)
if (r0 != 0) goto L8b
boolean r0 = isTv(r4)
if (r0 != 0) goto L8b
java.lang.Boolean r0 = com.google.android.gms.common.util.DeviceProperties.zzn
if (r0 != 0) goto L5a
android.content.pm.PackageManager r0 = r4.getPackageManager()
java.lang.String r3 = "com.google.android.feature.AMATI_EXPERIENCE"
boolean r0 = r0.hasSystemFeature(r3)
java.lang.Boolean r0 = java.lang.Boolean.valueOf(r0)
com.google.android.gms.common.util.DeviceProperties.zzn = r0
L5a:
java.lang.Boolean r0 = com.google.android.gms.common.util.DeviceProperties.zzn
boolean r0 = r0.booleanValue()
if (r0 != 0) goto L8b
boolean r0 = isBstar(r4)
if (r0 != 0) goto L8b
boolean r0 = isXr(r4)
if (r0 != 0) goto L8b
java.lang.Boolean r0 = com.google.android.gms.common.util.DeviceProperties.zzq
if (r0 != 0) goto L82
android.content.pm.PackageManager r4 = r4.getPackageManager()
java.lang.String r0 = "com.google.desktop.gms"
boolean r4 = r4.hasSystemFeature(r0)
java.lang.Boolean r4 = java.lang.Boolean.valueOf(r4)
com.google.android.gms.common.util.DeviceProperties.zzq = r4
L82:
java.lang.Boolean r4 = com.google.android.gms.common.util.DeviceProperties.zzq
boolean r4 = r4.booleanValue()
if (r4 != 0) goto L8b
goto L8c
L8b:
r1 = r2
L8c:
java.lang.Boolean r4 = java.lang.Boolean.valueOf(r1)
com.google.android.gms.common.util.DeviceProperties.zza = r4
L92:
java.lang.Boolean r4 = com.google.android.gms.common.util.DeviceProperties.zza
boolean r4 = r4.booleanValue()
return r4
*/
throw new UnsupportedOperationException("Method not decompiled: com.google.android.gms.common.util.DeviceProperties.isPhone(android.content.Context):boolean");
}
@KeepForSdk
public static boolean isPhoneGo(@NonNull Context context) {
ActivityManager activityManager;
boolean z = false;
if (context == null) {
return false;
}
if (zzb == null) {
if (isPhone(context)) {
if (zzi == null && (activityManager = (ActivityManager) context.getSystemService("activity")) != null) {
zzi = Boolean.valueOf(activityManager.isLowRamDevice());
}
if (Objects.equal(zzi, Boolean.TRUE) && Build.VERSION.SDK_INT >= 27) {
z = true;
}
}
zzb = Boolean.valueOf(z);
}
return zzb.booleanValue();
}
@KeepForSdk
public static boolean isSevenInchTablet(@NonNull Context context) {
return zza(context.getResources());
}
@KeepForSdk
public static boolean isSidewinder(@NonNull Context context) {
return zzc(context);
}
@KeepForSdk
public static boolean isTablet(@NonNull Context context) {
return isTablet(context.getResources());
}
@SideEffectFree
@KeepForSdk
public static boolean isTv(@NonNull Context context) {
return zzf(context.getPackageManager());
}
@KeepForSdk
public static boolean isUserBuild() {
int i = GooglePlayServicesUtilLight.GOOGLE_PLAY_SERVICES_VERSION_CODE;
return "user".equals(Build.TYPE);
}
@SideEffectFree
@KeepForSdk
public static boolean isWearable(@NonNull Context context) {
return zzb(context.getPackageManager());
}
@KeepForSdk
@TargetApi(26)
public static boolean isWearableWithoutPlayStore(@NonNull Context context) {
if (!isWearable(context) || PlatformVersion.isAtLeastN()) {
if (zzc(context)) {
if (!PlatformVersion.isAtLeastO() || PlatformVersion.isAtLeastR()) {
return true;
}
return false;
}
return false;
}
return true;
}
@SideEffectFree
@KeepForSdk
public static boolean isXr(@NonNull Context context) {
return zzg(context.getPackageManager());
}
public static boolean zza(@NonNull Resources resources) {
boolean z = false;
if (resources == null) {
return false;
}
if (zze == null) {
Configuration configuration = resources.getConfiguration();
if ((configuration.screenLayout & 15) <= 3 && configuration.smallestScreenWidthDp >= 600) {
z = true;
}
zze = Boolean.valueOf(z);
}
return zze.booleanValue();
}
@SideEffectFree
public static boolean zzb(@NonNull PackageManager packageManager) {
if (zzf == null) {
zzf = Boolean.valueOf(packageManager.hasSystemFeature("android.hardware.type.watch"));
}
return zzf.booleanValue();
}
public static boolean zzc(@NonNull Context context) {
if (zzg == null) {
zzg = Boolean.valueOf(context.getPackageManager().hasSystemFeature("cn.google"));
}
return zzg.booleanValue();
}
public static boolean zzd(@NonNull Context context) {
boolean hasSystemFeature;
if (zzj == null) {
if (PlatformVersion.isAtLeastO()) {
hasSystemFeature = context.getPackageManager().hasSystemFeature("android.hardware.type.embedded");
} else {
hasSystemFeature = context.getPackageManager().hasSystemFeature("android.hardware.type.iot");
}
zzj = Boolean.valueOf(hasSystemFeature);
}
return zzj.booleanValue();
}
@SideEffectFree
public static boolean zze(@NonNull PackageManager packageManager) {
if (zzl == null) {
boolean z = false;
if (PlatformVersion.isAtLeastO() && packageManager.hasSystemFeature("android.hardware.type.automotive")) {
z = true;
}
zzl = Boolean.valueOf(z);
}
return zzl.booleanValue();
}
@SideEffectFree
public static boolean zzf(@NonNull PackageManager packageManager) {
if (zzm == null) {
boolean z = true;
if (!packageManager.hasSystemFeature("com.google.android.tv") && !packageManager.hasSystemFeature("android.hardware.type.television") && !packageManager.hasSystemFeature("android.software.leanback") && !packageManager.hasSystemFeature("com.google.android.feature.AMATI_EXPERIENCE")) {
z = false;
}
zzm = Boolean.valueOf(z);
}
return zzm.booleanValue();
}
@SideEffectFree
public static boolean zzg(@NonNull PackageManager packageManager) {
if (zzp == null) {
zzp = Boolean.valueOf(packageManager.hasSystemFeature("android.software.xr.api.spatial"));
}
return zzp.booleanValue();
}
@KeepForSdk
public static boolean isTablet(@NonNull Resources resources) {
if (resources == null) {
return false;
}
if (zzc == null) {
zzc = Boolean.valueOf((resources.getConfiguration().screenLayout & 15) > 3 || zza(resources));
}
return zzc.booleanValue();
}
}