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

175 lines
7 KiB
Java

package com.google.android.gms.common.util;
import android.text.TextUtils;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.google.android.gms.common.annotation.KeepForSdk;
import com.google.android.gms.common.internal.Preconditions;
import java.util.Iterator;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
@KeepForSdk
/* loaded from: classes.dex */
public final class JsonUtils {
private static final Pattern zza = Pattern.compile("\\\\.");
private static final Pattern zzb = Pattern.compile("[\\\\\"/\b\f\n\r\t]");
private JsonUtils() {
}
@KeepForSdk
public static boolean areJsonValuesEquivalent(@Nullable Object obj, @Nullable Object obj2) {
if (obj == null && obj2 == null) {
return true;
}
if (obj == null || obj2 == null) {
return false;
}
if ((obj instanceof JSONObject) && (obj2 instanceof JSONObject)) {
JSONObject jSONObject = (JSONObject) obj;
JSONObject jSONObject2 = (JSONObject) obj2;
if (jSONObject.length() != jSONObject2.length()) {
return false;
}
Iterator<String> keys = jSONObject.keys();
while (keys.hasNext()) {
String next = keys.next();
if (jSONObject2.has(next)) {
try {
Preconditions.checkNotNull(next);
if (!areJsonValuesEquivalent(jSONObject.get(next), jSONObject2.get(next))) {
}
} catch (JSONException unused) {
}
}
return false;
}
return true;
}
if ((obj instanceof JSONArray) && (obj2 instanceof JSONArray)) {
JSONArray jSONArray = (JSONArray) obj;
JSONArray jSONArray2 = (JSONArray) obj2;
if (jSONArray.length() != jSONArray2.length()) {
return false;
}
for (int i = 0; i < jSONArray.length(); i++) {
if (!areJsonValuesEquivalent(jSONArray.get(i), jSONArray2.get(i))) {
return false;
}
}
return true;
}
return obj.equals(obj2);
}
@Nullable
@KeepForSdk
public static String escapeString(@Nullable String str) {
if (!TextUtils.isEmpty(str)) {
Matcher matcher = zzb.matcher(str);
StringBuffer stringBuffer = null;
while (matcher.find()) {
if (stringBuffer == null) {
stringBuffer = new StringBuffer();
}
char charAt = matcher.group().charAt(0);
if (charAt != '\f') {
if (charAt != '\r') {
if (charAt != '\"') {
if (charAt != '/') {
if (charAt != '\\') {
switch (charAt) {
case '\b':
matcher.appendReplacement(stringBuffer, "\\\\b");
break;
case '\t':
matcher.appendReplacement(stringBuffer, "\\\\t");
break;
case '\n':
matcher.appendReplacement(stringBuffer, "\\\\n");
break;
}
} else {
matcher.appendReplacement(stringBuffer, "\\\\\\\\");
}
} else {
matcher.appendReplacement(stringBuffer, "\\\\/");
}
} else {
matcher.appendReplacement(stringBuffer, "\\\\\\\"");
}
} else {
matcher.appendReplacement(stringBuffer, "\\\\r");
}
} else {
matcher.appendReplacement(stringBuffer, "\\\\f");
}
}
if (stringBuffer != null) {
matcher.appendTail(stringBuffer);
return stringBuffer.toString();
}
return str;
}
return str;
}
@NonNull
@KeepForSdk
public static String unescapeString(@NonNull String str) {
if (!TextUtils.isEmpty(str)) {
String zza2 = zzf.zza(str);
Matcher matcher = zza.matcher(zza2);
StringBuffer stringBuffer = null;
while (matcher.find()) {
if (stringBuffer == null) {
stringBuffer = new StringBuffer();
}
char charAt = matcher.group().charAt(1);
if (charAt != '\"') {
if (charAt != '/') {
if (charAt != '\\') {
if (charAt != 'b') {
if (charAt != 'f') {
if (charAt != 'n') {
if (charAt != 'r') {
if (charAt == 't') {
matcher.appendReplacement(stringBuffer, "\t");
} else {
throw new IllegalStateException("Found an escaped character that should never be.");
}
} else {
matcher.appendReplacement(stringBuffer, "\r");
}
} else {
matcher.appendReplacement(stringBuffer, "\n");
}
} else {
matcher.appendReplacement(stringBuffer, "\f");
}
} else {
matcher.appendReplacement(stringBuffer, "\b");
}
} else {
matcher.appendReplacement(stringBuffer, "\\\\");
}
} else {
matcher.appendReplacement(stringBuffer, "/");
}
} else {
matcher.appendReplacement(stringBuffer, "\"");
}
}
if (stringBuffer == null) {
return zza2;
}
matcher.appendTail(stringBuffer);
return stringBuffer.toString();
}
return str;
}
}