soul-browser/sources/java/kotlinx/coroutines/internal/LimitedDispatcher.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

135 lines
6.1 KiB
Java

package kotlinx.coroutines.internal;
import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
import kotlin.Metadata;
import kotlin.coroutines.CoroutineContext;
import kotlin.coroutines.EmptyCoroutineContext;
import kotlin.jvm.internal.SourceDebugExtension;
import kotlinx.coroutines.CancellableContinuationImpl;
import kotlinx.coroutines.CoroutineDispatcher;
import kotlinx.coroutines.CoroutineExceptionHandlerKt;
import kotlinx.coroutines.DefaultExecutorKt;
import kotlinx.coroutines.Delay;
import kotlinx.coroutines.DisposableHandle;
@Metadata(d1 = {"\u0000\u0014\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\b\u0000\u0018\u00002\u00020\u00012\u00020\u0002:\u0001\u0005R\u000b\u0010\u0004\u001a\u00020\u00038\u0002X\u0082\u0004¨\u0006\u0006"}, d2 = {"Lkotlinx/coroutines/internal/LimitedDispatcher;", "Lkotlinx/coroutines/CoroutineDispatcher;", "Lkotlinx/coroutines/Delay;", "Lkotlinx/atomicfu/AtomicInt;", "runningWorkers", "Worker", "kotlinx-coroutines-core"}, k = 1, mv = {1, 9, 0}, xi = 48)
@SourceDebugExtension({"SMAP\nLimitedDispatcher.kt\nKotlin\n*S Kotlin\n*F\n+ 1 LimitedDispatcher.kt\nkotlinx/coroutines/internal/LimitedDispatcher\n+ 2 Synchronized.common.kt\nkotlinx/coroutines/internal/Synchronized_commonKt\n+ 3 Synchronized.kt\nkotlinx/coroutines/internal/SynchronizedKt\n*L\n1#1,130:1\n62#1,8:131\n62#1,8:139\n24#2,4:147\n24#2,4:152\n16#3:151\n16#3:156\n*S KotlinDebug\n*F\n+ 1 LimitedDispatcher.kt\nkotlinx/coroutines/internal/LimitedDispatcher\n*L\n44#1:131,8\n51#1:139,8\n75#1:147,4\n88#1:152,4\n75#1:151\n88#1:156\n*E\n"})
/* loaded from: classes4.dex */
public final class LimitedDispatcher extends CoroutineDispatcher implements Delay {
public static final /* synthetic */ AtomicIntegerFieldUpdater k = AtomicIntegerFieldUpdater.newUpdater(LimitedDispatcher.class, "runningWorkers$volatile");
public final CoroutineDispatcher f;
public final int g;
public final /* synthetic */ Delay h;
public final LockFreeTaskQueue i;
public final Object j;
private volatile /* synthetic */ int runningWorkers$volatile;
@Metadata(d1 = {"\u0000\u000e\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\b\u0082\u0004\u0018\u00002\u00060\u0001j\u0002`\u0002¨\u0006\u0003"}, d2 = {"Lkotlinx/coroutines/internal/LimitedDispatcher$Worker;", "Ljava/lang/Runnable;", "Lkotlinx/coroutines/Runnable;", "kotlinx-coroutines-core"}, k = 1, mv = {1, 9, 0}, xi = 48)
/* loaded from: classes4.dex */
public final class Worker implements Runnable {
/* renamed from: c, reason: collision with root package name */
public Runnable f21882c;
public Worker(Runnable runnable) {
this.f21882c = runnable;
}
@Override // java.lang.Runnable
public final void run() {
LimitedDispatcher limitedDispatcher = LimitedDispatcher.this;
CoroutineDispatcher coroutineDispatcher = limitedDispatcher.f;
int i = 0;
while (true) {
try {
this.f21882c.run();
} catch (Throwable th) {
CoroutineExceptionHandlerKt.a(EmptyCoroutineContext.INSTANCE, th);
}
AtomicIntegerFieldUpdater atomicIntegerFieldUpdater = LimitedDispatcher.k;
Runnable X = limitedDispatcher.X();
if (X == null) {
return;
}
this.f21882c = X;
i++;
if (i >= 16 && coroutineDispatcher.W(limitedDispatcher)) {
coroutineDispatcher.S(limitedDispatcher, this);
return;
}
}
}
}
/* JADX WARN: Multi-variable type inference failed */
public LimitedDispatcher(CoroutineDispatcher coroutineDispatcher, int i) {
Delay delay;
this.f = coroutineDispatcher;
this.g = i;
if (coroutineDispatcher instanceof Delay) {
delay = (Delay) coroutineDispatcher;
} else {
delay = null;
}
this.h = delay == null ? DefaultExecutorKt.f21582a : delay;
this.i = new LockFreeTaskQueue();
this.j = new Object();
}
@Override // kotlinx.coroutines.CoroutineDispatcher
public final void S(CoroutineContext coroutineContext, Runnable runnable) {
Runnable X;
this.i.a(runnable);
if (k.get(this) < this.g && Z() && (X = X()) != null) {
this.f.S(this, new Worker(X));
}
}
@Override // kotlinx.coroutines.CoroutineDispatcher
public final void T(CoroutineContext coroutineContext, Runnable runnable) {
Runnable X;
this.i.a(runnable);
if (k.get(this) < this.g && Z() && (X = X()) != null) {
this.f.T(this, new Worker(X));
}
}
public final Runnable X() {
while (true) {
Runnable runnable = (Runnable) this.i.d();
if (runnable == null) {
synchronized (this.j) {
AtomicIntegerFieldUpdater atomicIntegerFieldUpdater = k;
atomicIntegerFieldUpdater.decrementAndGet(this);
if (this.i.c() == 0) {
return null;
}
atomicIntegerFieldUpdater.incrementAndGet(this);
}
} else {
return runnable;
}
}
}
public final boolean Z() {
synchronized (this.j) {
AtomicIntegerFieldUpdater atomicIntegerFieldUpdater = k;
if (atomicIntegerFieldUpdater.get(this) >= this.g) {
return false;
}
atomicIntegerFieldUpdater.incrementAndGet(this);
return true;
}
}
@Override // kotlinx.coroutines.Delay
public final void e(long j, CancellableContinuationImpl cancellableContinuationImpl) {
this.h.e(j, cancellableContinuationImpl);
}
@Override // kotlinx.coroutines.Delay
public final DisposableHandle o(long j, Runnable runnable, CoroutineContext coroutineContext) {
return this.h.o(j, runnable, coroutineContext);
}
}