* 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>
347 lines
11 KiB
Java
347 lines
11 KiB
Java
package go;
|
|
|
|
import android.content.Context;
|
|
import android.support.v4.media.a;
|
|
import j$.util.DesugarCollections;
|
|
import java.lang.ref.PhantomReference;
|
|
import java.lang.ref.ReferenceQueue;
|
|
import java.util.Arrays;
|
|
import java.util.Collection;
|
|
import java.util.HashSet;
|
|
import java.util.IdentityHashMap;
|
|
import java.util.logging.Logger;
|
|
|
|
/* loaded from: classes3.dex */
|
|
public class Seq {
|
|
static final RefTracker tracker;
|
|
private static Logger log = Logger.getLogger("GoSeq");
|
|
private static final int NULL_REFNUM = 41;
|
|
public static final Ref nullRef = new Ref(NULL_REFNUM, null);
|
|
private static final GoRefQueue goRefQueue = new GoRefQueue();
|
|
|
|
/* loaded from: classes3.dex */
|
|
public interface GoObject {
|
|
int incRefnum();
|
|
}
|
|
|
|
/* loaded from: classes3.dex */
|
|
public static class GoRef extends PhantomReference<GoObject> {
|
|
final int refnum;
|
|
|
|
public GoRef(int i, GoObject goObject, GoRefQueue goRefQueue) {
|
|
super(goObject, goRefQueue);
|
|
if (i <= 0) {
|
|
this.refnum = i;
|
|
return;
|
|
}
|
|
throw new RuntimeException(a.e(i, "GoRef instantiated with a Java refnum "));
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes3.dex */
|
|
public static class GoRefQueue extends ReferenceQueue<GoObject> {
|
|
private final Collection<GoRef> refs = DesugarCollections.synchronizedCollection(new HashSet());
|
|
|
|
public GoRefQueue() {
|
|
Thread thread = new Thread(new Runnable() { // from class: go.Seq.GoRefQueue.1
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
while (true) {
|
|
try {
|
|
GoRef goRef = (GoRef) GoRefQueue.this.remove();
|
|
GoRefQueue.this.refs.remove(goRef);
|
|
Seq.destroyRef(goRef.refnum);
|
|
goRef.clear();
|
|
} catch (InterruptedException unused) {
|
|
}
|
|
}
|
|
}
|
|
});
|
|
thread.setDaemon(true);
|
|
thread.setName("GoRefQueue Finalizer Thread");
|
|
thread.start();
|
|
}
|
|
|
|
public void track(int i, GoObject goObject) {
|
|
this.refs.add(new GoRef(i, goObject, this));
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes3.dex */
|
|
public interface Proxy extends GoObject {
|
|
}
|
|
|
|
/* loaded from: classes3.dex */
|
|
public static final class Ref {
|
|
public final Object obj;
|
|
private int refcnt;
|
|
public final int refnum;
|
|
|
|
public Ref(int i, Object obj) {
|
|
if (i >= 0) {
|
|
this.refnum = i;
|
|
this.refcnt = 0;
|
|
this.obj = obj;
|
|
return;
|
|
}
|
|
throw new RuntimeException(a.e(i, "Ref instantiated with a Go refnum "));
|
|
}
|
|
|
|
public static /* synthetic */ int access$110(Ref ref) {
|
|
int i = ref.refcnt;
|
|
ref.refcnt = i - 1;
|
|
return i;
|
|
}
|
|
|
|
public void inc() {
|
|
int i = this.refcnt;
|
|
if (i != Integer.MAX_VALUE) {
|
|
this.refcnt = i + 1;
|
|
} else {
|
|
throw new RuntimeException(a.g(this.refnum, " overflow", new StringBuilder("refnum ")));
|
|
}
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes3.dex */
|
|
public static final class RefMap {
|
|
private int next = 0;
|
|
private int live = 0;
|
|
private int[] keys = new int[16];
|
|
private Ref[] objs = new Ref[16];
|
|
|
|
private void grow() {
|
|
Ref[] refArr;
|
|
int roundPow2 = roundPow2(this.live) * 2;
|
|
int[] iArr = this.keys;
|
|
if (roundPow2 > iArr.length) {
|
|
iArr = new int[iArr.length * 2];
|
|
refArr = new Ref[this.objs.length * 2];
|
|
} else {
|
|
refArr = this.objs;
|
|
}
|
|
int i = 0;
|
|
int i2 = 0;
|
|
while (true) {
|
|
int[] iArr2 = this.keys;
|
|
if (i >= iArr2.length) {
|
|
break;
|
|
}
|
|
Ref ref = this.objs[i];
|
|
if (ref != null) {
|
|
iArr[i2] = iArr2[i];
|
|
refArr[i2] = ref;
|
|
i2++;
|
|
}
|
|
i++;
|
|
}
|
|
for (int i3 = i2; i3 < iArr.length; i3++) {
|
|
iArr[i3] = 0;
|
|
refArr[i3] = null;
|
|
}
|
|
this.keys = iArr;
|
|
this.objs = refArr;
|
|
this.next = i2;
|
|
if (this.live == i2) {
|
|
return;
|
|
}
|
|
throw new RuntimeException("bad state: live=" + this.live + ", next=" + this.next);
|
|
}
|
|
|
|
private static int roundPow2(int i) {
|
|
int i2 = 1;
|
|
while (i2 < i) {
|
|
i2 *= 2;
|
|
}
|
|
return i2;
|
|
}
|
|
|
|
public Ref get(int i) {
|
|
int binarySearch = Arrays.binarySearch(this.keys, 0, this.next, i);
|
|
if (binarySearch >= 0) {
|
|
return this.objs[binarySearch];
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public void put(int i, Ref ref) {
|
|
if (ref != null) {
|
|
int binarySearch = Arrays.binarySearch(this.keys, 0, this.next, i);
|
|
if (binarySearch >= 0) {
|
|
Ref[] refArr = this.objs;
|
|
if (refArr[binarySearch] == null) {
|
|
refArr[binarySearch] = ref;
|
|
this.live++;
|
|
}
|
|
if (refArr[binarySearch] == ref) {
|
|
return;
|
|
} else {
|
|
throw new RuntimeException(a.f(i, "replacing an existing ref (with key ", ")"));
|
|
}
|
|
}
|
|
if (this.next >= this.keys.length) {
|
|
grow();
|
|
binarySearch = Arrays.binarySearch(this.keys, 0, this.next, i);
|
|
}
|
|
int i2 = ~binarySearch;
|
|
int i3 = this.next;
|
|
if (i2 < i3) {
|
|
int[] iArr = this.keys;
|
|
int i4 = i2 + 1;
|
|
System.arraycopy(iArr, i2, iArr, i4, i3 - i2);
|
|
Ref[] refArr2 = this.objs;
|
|
System.arraycopy(refArr2, i2, refArr2, i4, this.next - i2);
|
|
}
|
|
this.keys[i2] = i;
|
|
this.objs[i2] = ref;
|
|
this.live++;
|
|
this.next++;
|
|
return;
|
|
}
|
|
throw new RuntimeException(a.f(i, "put a null ref (with key ", ")"));
|
|
}
|
|
|
|
public void remove(int i) {
|
|
int binarySearch = Arrays.binarySearch(this.keys, 0, this.next, i);
|
|
if (binarySearch >= 0) {
|
|
Ref[] refArr = this.objs;
|
|
if (refArr[binarySearch] != null) {
|
|
refArr[binarySearch] = null;
|
|
this.live--;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes3.dex */
|
|
public static final class RefTracker {
|
|
private static final int REF_OFFSET = 42;
|
|
private int next = REF_OFFSET;
|
|
private final RefMap javaObjs = new RefMap();
|
|
private final IdentityHashMap<Object, Integer> javaRefs = new IdentityHashMap<>();
|
|
|
|
public synchronized void dec(int i) {
|
|
if (i <= 0) {
|
|
Seq.log.severe("dec request for Go object " + i);
|
|
return;
|
|
}
|
|
if (i == Seq.nullRef.refnum) {
|
|
return;
|
|
}
|
|
Ref ref = this.javaObjs.get(i);
|
|
if (ref != null) {
|
|
Ref.access$110(ref);
|
|
if (ref.refcnt <= 0) {
|
|
this.javaObjs.remove(i);
|
|
this.javaRefs.remove(ref.obj);
|
|
}
|
|
return;
|
|
}
|
|
throw new RuntimeException("referenced Java object is not found: refnum=" + i);
|
|
}
|
|
|
|
public synchronized Ref get(int i) {
|
|
if (i >= 0) {
|
|
if (i == Seq.NULL_REFNUM) {
|
|
return Seq.nullRef;
|
|
}
|
|
Ref ref = this.javaObjs.get(i);
|
|
if (ref != null) {
|
|
return ref;
|
|
}
|
|
throw new RuntimeException("unknown java Ref: " + i);
|
|
}
|
|
throw new RuntimeException("ref called with Go refnum " + i);
|
|
}
|
|
|
|
public synchronized int inc(Object obj) {
|
|
if (obj == null) {
|
|
return Seq.NULL_REFNUM;
|
|
}
|
|
if (obj instanceof Proxy) {
|
|
return ((Proxy) obj).incRefnum();
|
|
}
|
|
Integer num = this.javaRefs.get(obj);
|
|
if (num == null) {
|
|
int i = this.next;
|
|
if (i != Integer.MAX_VALUE) {
|
|
this.next = i + 1;
|
|
num = Integer.valueOf(i);
|
|
this.javaRefs.put(obj, num);
|
|
} else {
|
|
throw new RuntimeException("createRef overflow for " + obj);
|
|
}
|
|
}
|
|
int intValue = num.intValue();
|
|
Ref ref = this.javaObjs.get(intValue);
|
|
if (ref == null) {
|
|
ref = new Ref(intValue, obj);
|
|
this.javaObjs.put(intValue, ref);
|
|
}
|
|
ref.inc();
|
|
return intValue;
|
|
}
|
|
|
|
public synchronized void incRefnum(int i) {
|
|
Ref ref = this.javaObjs.get(i);
|
|
if (ref != null) {
|
|
ref.inc();
|
|
} else {
|
|
throw new RuntimeException("referenced Java object is not found: refnum=" + i);
|
|
}
|
|
}
|
|
}
|
|
|
|
static {
|
|
System.loadLibrary("gojni");
|
|
init();
|
|
Universe.touch();
|
|
tracker = new RefTracker();
|
|
}
|
|
|
|
private Seq() {
|
|
}
|
|
|
|
public static void decRef(int i) {
|
|
tracker.dec(i);
|
|
}
|
|
|
|
public static native void destroyRef(int i);
|
|
|
|
public static Ref getRef(int i) {
|
|
return tracker.get(i);
|
|
}
|
|
|
|
public static int incGoObjectRef(GoObject goObject) {
|
|
return goObject.incRefnum();
|
|
}
|
|
|
|
public static native void incGoRef(int i, GoObject goObject);
|
|
|
|
public static int incRef(Object obj) {
|
|
return tracker.inc(obj);
|
|
}
|
|
|
|
public static void incRefnum(int i) {
|
|
tracker.incRefnum(i);
|
|
}
|
|
|
|
private static native void init();
|
|
|
|
public static void setContext(Context context) {
|
|
setContext((Object) context);
|
|
}
|
|
|
|
public static native void setContext(Object obj);
|
|
|
|
public static void touch() {
|
|
}
|
|
|
|
public static void trackGoRef(int i, GoObject goObject) {
|
|
if (i <= 0) {
|
|
goRefQueue.track(i, goObject);
|
|
return;
|
|
}
|
|
throw new RuntimeException(a.e(i, "trackGoRef called with Java refnum "));
|
|
}
|
|
}
|