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

220 lines
9.5 KiB
Java

package com.google.android.gms.common.internal;
import android.content.Context;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.text.TextUtils;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.collection.SimpleArrayMap;
import androidx.core.os.ConfigurationCompat;
import com.google.android.gms.base.R;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.common.util.DeviceProperties;
import com.google.android.gms.common.wrappers.Wrappers;
import java.util.Locale;
/* loaded from: classes.dex */
public final class zac {
private static final SimpleArrayMap zaa = new SimpleArrayMap(0);
@Nullable
private static Locale zab;
@Nullable
public static String zaa(Context context, int i) {
Resources resources = context.getResources();
switch (i) {
case 1:
return resources.getString(R.string.common_google_play_services_install_title);
case 2:
return resources.getString(R.string.common_google_play_services_update_title);
case 3:
return resources.getString(R.string.common_google_play_services_enable_title);
case 4:
case 6:
case 18:
return null;
case 5:
Log.e("GoogleApiAvailability", "An invalid account was specified when connecting. Please provide a valid account.");
return zah(context, "common_google_play_services_invalid_account_title");
case 7:
Log.e("GoogleApiAvailability", "Network error occurred. Please retry request later.");
return zah(context, "common_google_play_services_network_error_title");
case 8:
Log.e("GoogleApiAvailability", "Internal error occurred. Please see logs for detailed information");
return null;
case 9:
Log.e("GoogleApiAvailability", "Google Play services is invalid. Cannot recover.");
return null;
case 10:
Log.e("GoogleApiAvailability", "Developer error occurred. Please see logs for detailed information");
return null;
case 11:
Log.e("GoogleApiAvailability", "The application is not licensed to the user.");
return null;
case 12:
case 13:
case 14:
case 15:
case 19:
default:
StringBuilder sb = new StringBuilder(String.valueOf(i).length() + 22);
sb.append("Unexpected error code ");
sb.append(i);
Log.e("GoogleApiAvailability", sb.toString());
return null;
case 16:
Log.e("GoogleApiAvailability", "One of the API components you attempted to connect to is not available.");
return null;
case 17:
Log.e("GoogleApiAvailability", "The specified account could not be signed in.");
return zah(context, "common_google_play_services_sign_in_failed_title");
case 20:
Log.e("GoogleApiAvailability", "The current user profile is restricted and could not use authenticated features.");
return zah(context, "common_google_play_services_restricted_profile_title");
}
}
@NonNull
public static String zab(Context context, int i) {
String zaa2;
if (i == 6) {
zaa2 = zah(context, "common_google_play_services_resolution_required_title");
} else {
zaa2 = zaa(context, i);
}
if (zaa2 == null) {
return context.getResources().getString(R.string.common_google_play_services_notification_ticker);
}
return zaa2;
}
@NonNull
public static String zac(Context context, int i) {
Resources resources = context.getResources();
String zaf = zaf(context);
if (i != 1) {
if (i != 2) {
if (i != 3) {
if (i != 5) {
if (i != 7) {
if (i != 9) {
if (i != 20) {
switch (i) {
case 16:
return zag(context, "common_google_play_services_api_unavailable_text", zaf);
case 17:
return zag(context, "common_google_play_services_sign_in_failed_text", zaf);
case 18:
return resources.getString(R.string.common_google_play_services_updating_text, zaf);
default:
return resources.getString(com.google.android.gms.common.R.string.common_google_play_services_unknown_issue, zaf);
}
}
return zag(context, "common_google_play_services_restricted_profile_text", zaf);
}
return resources.getString(R.string.common_google_play_services_unsupported_text, zaf);
}
return zag(context, "common_google_play_services_network_error_text", zaf);
}
return zag(context, "common_google_play_services_invalid_account_text", zaf);
}
return resources.getString(R.string.common_google_play_services_enable_text, zaf);
}
if (DeviceProperties.isWearableWithoutPlayStore(context)) {
return resources.getString(R.string.common_google_play_services_wear_update_text);
}
return resources.getString(R.string.common_google_play_services_update_text, zaf);
}
return resources.getString(R.string.common_google_play_services_install_text, zaf);
}
@NonNull
public static String zad(Context context, int i) {
if (i != 6 && i != 19) {
return zac(context, i);
}
return zag(context, "common_google_play_services_resolution_required_text", zaf(context));
}
@NonNull
public static String zae(Context context, int i) {
Resources resources = context.getResources();
if (i != 1) {
if (i != 2) {
if (i != 3) {
return resources.getString(android.R.string.ok);
}
return resources.getString(R.string.common_google_play_services_enable_button);
}
return resources.getString(R.string.common_google_play_services_update_button);
}
return resources.getString(R.string.common_google_play_services_install_button);
}
public static String zaf(Context context) {
String packageName = context.getPackageName();
try {
return Wrappers.packageManager(context).getApplicationLabel(packageName).toString();
} catch (PackageManager.NameNotFoundException | NullPointerException unused) {
String str = context.getApplicationInfo().name;
if (TextUtils.isEmpty(str)) {
return packageName;
}
return str;
}
}
private static String zag(Context context, String str, String str2) {
Resources resources = context.getResources();
String zah = zah(context, str);
if (zah == null) {
zah = resources.getString(com.google.android.gms.common.R.string.common_google_play_services_unknown_issue);
}
return String.format(resources.getConfiguration().locale, zah, str2);
}
@Nullable
private static String zah(Context context, String str) {
SimpleArrayMap simpleArrayMap = zaa;
synchronized (simpleArrayMap) {
try {
Locale c2 = ConfigurationCompat.a(context.getResources().getConfiguration()).c(0);
if (!c2.equals(zab)) {
simpleArrayMap.clear();
zab = c2;
}
String str2 = (String) simpleArrayMap.get(str);
if (str2 != null) {
return str2;
}
Resources remoteResource = GooglePlayServicesUtil.getRemoteResource(context);
if (remoteResource == null) {
return null;
}
int identifier = remoteResource.getIdentifier(str, "string", "com.google.android.gms");
if (identifier == 0) {
StringBuilder sb = new StringBuilder(str.length() + 18);
sb.append("Missing resource: ");
sb.append(str);
Log.w("GoogleApiAvailability", sb.toString());
return null;
}
String string = remoteResource.getString(identifier);
if (TextUtils.isEmpty(string)) {
StringBuilder sb2 = new StringBuilder(str.length() + 20);
sb2.append("Got empty resource: ");
sb2.append(str);
Log.w("GoogleApiAvailability", sb2.toString());
return null;
}
simpleArrayMap.put(str, string);
return string;
} catch (Throwable th) {
throw th;
}
}
}
}