soul-browser/sources/java/com/google/firebase/encoders/json/JsonValueObjectEncoderContext.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

207 lines
6.6 KiB
Java

package com.google.firebase.encoders.json;
import android.util.Base64;
import android.util.JsonWriter;
import com.google.firebase.encoders.FieldDescriptor;
import com.google.firebase.encoders.ObjectEncoder;
import com.google.firebase.encoders.ObjectEncoderContext;
import com.google.firebase.encoders.ValueEncoder;
import com.google.firebase.encoders.ValueEncoderContext;
import java.io.Writer;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
/* loaded from: classes3.dex */
final class JsonValueObjectEncoderContext implements ObjectEncoderContext, ValueEncoderContext {
/* renamed from: a, reason: collision with root package name */
public final boolean f12643a = true;
public final JsonWriter b;
/* renamed from: c, reason: collision with root package name */
public final Map f12644c;
public final Map d;
public final ObjectEncoder e;
public final boolean f;
public JsonValueObjectEncoderContext(Writer writer, HashMap hashMap, HashMap hashMap2, a aVar, boolean z) {
this.b = new JsonWriter(writer);
this.f12644c = hashMap;
this.d = hashMap2;
this.e = aVar;
this.f = z;
}
@Override // com.google.firebase.encoders.ObjectEncoderContext
public final ObjectEncoderContext a(FieldDescriptor fieldDescriptor, long j) {
String str = fieldDescriptor.f12637a;
g();
JsonWriter jsonWriter = this.b;
jsonWriter.name(str);
g();
jsonWriter.value(j);
return this;
}
@Override // com.google.firebase.encoders.ValueEncoderContext
public final ValueEncoderContext b(String str) {
g();
this.b.value(str);
return this;
}
@Override // com.google.firebase.encoders.ValueEncoderContext
public final ValueEncoderContext c(boolean z) {
g();
this.b.value(z);
return this;
}
@Override // com.google.firebase.encoders.ObjectEncoderContext
public final ObjectEncoderContext d(FieldDescriptor fieldDescriptor, Object obj) {
f(obj, fieldDescriptor.f12637a);
return this;
}
public final JsonValueObjectEncoderContext e(Object obj) {
JsonWriter jsonWriter = this.b;
if (obj == null) {
jsonWriter.nullValue();
return this;
}
if (obj instanceof Number) {
jsonWriter.value((Number) obj);
return this;
}
int i = 0;
if (obj.getClass().isArray()) {
if (obj instanceof byte[]) {
g();
jsonWriter.value(Base64.encodeToString((byte[]) obj, 2));
return this;
}
jsonWriter.beginArray();
if (obj instanceof int[]) {
int length = ((int[]) obj).length;
while (i < length) {
jsonWriter.value(r7[i]);
i++;
}
} else if (obj instanceof long[]) {
long[] jArr = (long[]) obj;
int length2 = jArr.length;
while (i < length2) {
long j = jArr[i];
g();
jsonWriter.value(j);
i++;
}
} else if (obj instanceof double[]) {
double[] dArr = (double[]) obj;
int length3 = dArr.length;
while (i < length3) {
jsonWriter.value(dArr[i]);
i++;
}
} else if (obj instanceof boolean[]) {
boolean[] zArr = (boolean[]) obj;
int length4 = zArr.length;
while (i < length4) {
jsonWriter.value(zArr[i]);
i++;
}
} else if (obj instanceof Number[]) {
Number[] numberArr = (Number[]) obj;
int length5 = numberArr.length;
while (i < length5) {
e(numberArr[i]);
i++;
}
} else {
Object[] objArr = (Object[]) obj;
int length6 = objArr.length;
while (i < length6) {
e(objArr[i]);
i++;
}
}
jsonWriter.endArray();
return this;
}
if (obj instanceof Collection) {
jsonWriter.beginArray();
Iterator it = ((Collection) obj).iterator();
while (it.hasNext()) {
e(it.next());
}
jsonWriter.endArray();
return this;
}
if (obj instanceof Map) {
jsonWriter.beginObject();
for (Map.Entry entry : ((Map) obj).entrySet()) {
Object key = entry.getKey();
try {
f(entry.getValue(), (String) key);
} catch (ClassCastException e) {
throw new RuntimeException(String.format("Only String keys are currently supported in maps, got %s of type %s instead.", key, key.getClass()), e);
}
}
jsonWriter.endObject();
return this;
}
ObjectEncoder objectEncoder = (ObjectEncoder) this.f12644c.get(obj.getClass());
if (objectEncoder != null) {
jsonWriter.beginObject();
objectEncoder.a(obj, this);
jsonWriter.endObject();
return this;
}
ValueEncoder valueEncoder = (ValueEncoder) this.d.get(obj.getClass());
if (valueEncoder != null) {
valueEncoder.a(obj, this);
return this;
}
if (obj instanceof Enum) {
String name = ((Enum) obj).name();
g();
jsonWriter.value(name);
return this;
}
jsonWriter.beginObject();
this.e.a(obj, this);
jsonWriter.endObject();
return this;
}
public final JsonValueObjectEncoderContext f(Object obj, String str) {
boolean z = this.f;
JsonWriter jsonWriter = this.b;
if (z) {
if (obj == null) {
return this;
}
g();
jsonWriter.name(str);
e(obj);
return this;
}
g();
jsonWriter.name(str);
if (obj == null) {
jsonWriter.nullValue();
return this;
}
e(obj);
return this;
}
public final void g() {
if (this.f12643a) {
} else {
throw new IllegalStateException("Parent context used since this context was created. Cannot use this context anymore.");
}
}
}