soul-browser/sources/java/com/google/gson/internal/reflect/ReflectionHelper.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

218 lines
9.4 KiB
Java

package com.google.gson.internal.reflect;
import android.support.v4.media.a;
import com.google.android.gms.ads.RequestConfiguration;
import java.lang.reflect.AccessibleObject;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
/* loaded from: classes3.dex */
public class ReflectionHelper {
/* renamed from: a, reason: collision with root package name */
public static final RecordHelper f12746a;
/* loaded from: classes3.dex */
public static abstract class RecordHelper {
public abstract Method a(Class cls, Field field);
public abstract Constructor b(Class cls);
public abstract String[] c(Class cls);
public abstract boolean d(Class cls);
}
/* loaded from: classes3.dex */
public static class RecordNotSupportedHelper extends RecordHelper {
@Override // com.google.gson.internal.reflect.ReflectionHelper.RecordHelper
public final Method a(Class cls, Field field) {
throw new UnsupportedOperationException("Records are not supported on this JVM, this method should not be called");
}
@Override // com.google.gson.internal.reflect.ReflectionHelper.RecordHelper
public final Constructor b(Class cls) {
throw new UnsupportedOperationException("Records are not supported on this JVM, this method should not be called");
}
@Override // com.google.gson.internal.reflect.ReflectionHelper.RecordHelper
public final String[] c(Class cls) {
throw new UnsupportedOperationException("Records are not supported on this JVM, this method should not be called");
}
@Override // com.google.gson.internal.reflect.ReflectionHelper.RecordHelper
public final boolean d(Class cls) {
return false;
}
}
/* loaded from: classes3.dex */
public static class RecordSupportedHelper extends RecordHelper {
/* renamed from: a, reason: collision with root package name */
public final Method f12747a = Class.class.getMethod("isRecord", null);
public final Method b = Class.class.getMethod("getRecordComponents", null);
/* renamed from: c, reason: collision with root package name */
public final Method f12748c;
public final Method d;
public RecordSupportedHelper() {
Class<?> cls = Class.forName("java.lang.reflect.RecordComponent");
this.f12748c = cls.getMethod("getName", null);
this.d = cls.getMethod("getType", null);
}
@Override // com.google.gson.internal.reflect.ReflectionHelper.RecordHelper
public final Method a(Class cls, Field field) {
try {
return cls.getMethod(field.getName(), null);
} catch (ReflectiveOperationException e) {
RecordHelper recordHelper = ReflectionHelper.f12746a;
throw new RuntimeException("Unexpected ReflectiveOperationException occurred (Gson 2.13.2). To support Java records, reflection is utilized to read out information about records. All these invocations happens after it is established that records exist in the JVM. This exception is unexpected behavior.", e);
}
}
@Override // com.google.gson.internal.reflect.ReflectionHelper.RecordHelper
public final Constructor b(Class cls) {
try {
Object[] objArr = (Object[]) this.b.invoke(cls, null);
Class<?>[] clsArr = new Class[objArr.length];
for (int i = 0; i < objArr.length; i++) {
clsArr[i] = (Class) this.d.invoke(objArr[i], null);
}
return cls.getDeclaredConstructor(clsArr);
} catch (ReflectiveOperationException e) {
RecordHelper recordHelper = ReflectionHelper.f12746a;
throw new RuntimeException("Unexpected ReflectiveOperationException occurred (Gson 2.13.2). To support Java records, reflection is utilized to read out information about records. All these invocations happens after it is established that records exist in the JVM. This exception is unexpected behavior.", e);
}
}
@Override // com.google.gson.internal.reflect.ReflectionHelper.RecordHelper
public final String[] c(Class cls) {
try {
Object[] objArr = (Object[]) this.b.invoke(cls, null);
String[] strArr = new String[objArr.length];
for (int i = 0; i < objArr.length; i++) {
strArr[i] = (String) this.f12748c.invoke(objArr[i], null);
}
return strArr;
} catch (ReflectiveOperationException e) {
RecordHelper recordHelper = ReflectionHelper.f12746a;
throw new RuntimeException("Unexpected ReflectiveOperationException occurred (Gson 2.13.2). To support Java records, reflection is utilized to read out information about records. All these invocations happens after it is established that records exist in the JVM. This exception is unexpected behavior.", e);
}
}
@Override // com.google.gson.internal.reflect.ReflectionHelper.RecordHelper
public final boolean d(Class cls) {
try {
return ((Boolean) this.f12747a.invoke(cls, null)).booleanValue();
} catch (ReflectiveOperationException e) {
RecordHelper recordHelper = ReflectionHelper.f12746a;
throw new RuntimeException("Unexpected ReflectiveOperationException occurred (Gson 2.13.2). To support Java records, reflection is utilized to read out information about records. All these invocations happens after it is established that records exist in the JVM. This exception is unexpected behavior.", e);
}
}
}
/* JADX WARN: Multi-variable type inference failed */
/* JADX WARN: Type inference failed for: r0v1, types: [com.google.gson.internal.reflect.ReflectionHelper$RecordHelper] */
/* JADX WARN: Type inference failed for: r0v3 */
/* JADX WARN: Type inference failed for: r0v4 */
static {
?? r0;
try {
r0 = new RecordSupportedHelper();
} catch (ReflectiveOperationException unused) {
r0 = new Object();
}
f12746a = r0;
}
public static void a(AccessibleObject accessibleObject, StringBuilder sb) {
Class<?>[] parameterTypes;
sb.append('(');
if (accessibleObject instanceof Method) {
parameterTypes = ((Method) accessibleObject).getParameterTypes();
} else {
parameterTypes = ((Constructor) accessibleObject).getParameterTypes();
}
for (int i = 0; i < parameterTypes.length; i++) {
if (i > 0) {
sb.append(", ");
}
sb.append(parameterTypes[i].getSimpleName());
}
sb.append(')');
}
public static String b(Constructor constructor) {
StringBuilder sb = new StringBuilder(constructor.getDeclaringClass().getName());
a(constructor, sb);
return sb.toString();
}
public static String c(Field field) {
return field.getDeclaringClass().getName() + "#" + field.getName();
}
public static String d(AccessibleObject accessibleObject, boolean z) {
String str;
if (accessibleObject instanceof Field) {
str = "field '" + c((Field) accessibleObject) + "'";
} else if (accessibleObject instanceof Method) {
Method method = (Method) accessibleObject;
StringBuilder sb = new StringBuilder(method.getName());
a(method, sb);
str = "method '" + method.getDeclaringClass().getName() + "#" + sb.toString() + "'";
} else if (accessibleObject instanceof Constructor) {
str = "constructor '" + b((Constructor) accessibleObject) + "'";
} else {
str = "<unknown AccessibleObject> " + accessibleObject.toString();
}
if (z && Character.isLowerCase(str.charAt(0))) {
return Character.toUpperCase(str.charAt(0)) + str.substring(1);
}
return str;
}
public static Method e(Class cls, Field field) {
return f12746a.a(cls, field);
}
public static Constructor f(Class cls) {
return f12746a.b(cls);
}
public static String g(Exception exc) {
String str;
if (exc.getClass().getName().equals("java.lang.reflect.InaccessibleObjectException")) {
String message = exc.getMessage();
if (message != null && message.contains("to module com.google.gson")) {
str = "reflection-inaccessible-to-module-gson";
} else {
str = "reflection-inaccessible";
}
return "\nSee " + "https://github.com/google/gson/blob/main/Troubleshooting.md#".concat(str);
}
return RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED;
}
public static String[] h(Class cls) {
return f12746a.c(cls);
}
public static boolean i(Class cls) {
return f12746a.d(cls);
}
public static void j(AccessibleObject accessibleObject) {
try {
accessibleObject.setAccessible(true);
} catch (Exception e) {
StringBuilder w = a.w("Failed making ", d(accessibleObject, false), " accessible; either increase its visibility or write a custom TypeAdapter for its declaring type.");
w.append(g(e));
throw new RuntimeException(w.toString(), e);
}
}
}