soul-browser/sources/java/okhttp3/internal/connection/RealConnectionPool.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

151 lines
7.5 KiB
Java

package okhttp3.internal.connection;
import android.support.v4.media.a;
import com.google.android.gms.ads.RequestConfiguration;
import java.lang.ref.Reference;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.TimeZone;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.TimeUnit;
import kotlin.Metadata;
import kotlin.Unit;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.LongCompanionObject;
import kotlin.jvm.internal.SourceDebugExtension;
import okhttp3.internal._UtilJvmKt;
import okhttp3.internal.concurrent.Task;
import okhttp3.internal.concurrent.TaskQueue;
import okhttp3.internal.concurrent.TaskRunner;
import okhttp3.internal.connection.RealCall;
import okhttp3.internal.platform.Platform;
@Metadata(d1 = {"\u0000\f\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\u0018\u00002\u00020\u0001:\u0001\u0002¨\u0006\u0003"}, d2 = {"Lokhttp3/internal/connection/RealConnectionPool;", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED, "Companion", "okhttp"}, k = 1, mv = {2, 2, 0}, xi = 48)
@SourceDebugExtension({"SMAP\nRealConnectionPool.kt\nKotlin\n*S Kotlin\n*F\n+ 1 RealConnectionPool.kt\nokhttp3/internal/connection/RealConnectionPool\n+ 2 fake.kt\nkotlin/jvm/internal/FakeKt\n+ 3 _Collections.kt\nkotlin/collections/CollectionsKt___CollectionsKt\n+ 4 Lockable.kt\nokhttp3/internal/concurrent/LockableKt\n*L\n1#1,326:1\n1#2:327\n1788#3,3:328\n1791#3:332\n63#4:331\n63#4:333\n63#4:334\n55#4,4:335\n55#4,4:339\n63#4:343\n63#4:344\n63#4:345\n55#4,4:346\n*S KotlinDebug\n*F\n+ 1 RealConnectionPool.kt\nokhttp3/internal/connection/RealConnectionPool\n*L\n64#1:328,3\n64#1:332\n65#1:331\n92#1:333\n111#1:334\n127#1:335,4\n139#1:339,4\n157#1:343\n201#1:344\n247#1:345\n287#1:346,4\n*E\n"})
/* loaded from: classes4.dex */
public final class RealConnectionPool {
/* renamed from: a, reason: collision with root package name */
public final long f22101a;
public final TaskQueue b;
/* renamed from: c, reason: collision with root package name */
public final RealConnectionPool$cleanupTask$1 f22102c;
public final ConcurrentLinkedQueue d;
@Metadata(d1 = {"\u0000\n\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\b\u0086\u0003\u0018\u00002\u00020\u0001¨\u0006\u0002"}, d2 = {"Lokhttp3/internal/connection/RealConnectionPool$Companion;", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED, "okhttp"}, k = 1, mv = {2, 2, 0}, xi = 48)
/* loaded from: classes4.dex */
public static final class Companion {
}
/* JADX WARN: Type inference failed for: r0v3, types: [okhttp3.internal.connection.RealConnectionPool$cleanupTask$1] */
public RealConnectionPool(TaskRunner taskRunner) {
TimeUnit timeUnit = TimeUnit.MINUTES;
Intrinsics.checkNotNullParameter(taskRunner, "taskRunner");
Intrinsics.checkNotNullParameter(timeUnit, "timeUnit");
ConnectionListener$Companion$NONE$1 connectionListener = ConnectionListener.f22092a;
Intrinsics.checkNotNullParameter(connectionListener, "connectionListener");
this.f22101a = timeUnit.toNanos(5L);
this.b = taskRunner.d();
final String p = a.p(new StringBuilder(), _UtilJvmKt.b, " ConnectionPool connection closer");
this.f22102c = new Task(p) { // from class: okhttp3.internal.connection.RealConnectionPool$cleanupTask$1
@Override // okhttp3.internal.concurrent.Task
public final long a() {
RealConnection connection;
RealConnectionPool realConnectionPool = RealConnectionPool.this;
long nanoTime = System.nanoTime();
long j = (nanoTime - realConnectionPool.f22101a) + 1;
Iterator it = realConnectionPool.d.iterator();
Intrinsics.checkNotNullExpressionValue(it, "iterator(...)");
long j2 = LongCompanionObject.MAX_VALUE;
int i = 0;
int i2 = 0;
RealConnection realConnection = null;
RealConnection realConnection2 = null;
while (it.hasNext()) {
RealConnection realConnection3 = (RealConnection) it.next();
Intrinsics.checkNotNull(realConnection3);
synchronized (realConnection3) {
if (realConnectionPool.a(realConnection3, nanoTime) > 0) {
i2++;
} else {
long j3 = j2;
long j4 = realConnection3.u;
if (j4 < j) {
j = j4;
realConnection = realConnection3;
}
i++;
if (j4 < j3) {
j2 = j4;
realConnection2 = realConnection3;
} else {
j2 = j3;
}
}
Unit unit = Unit.INSTANCE;
}
}
long j5 = j2;
if (realConnection != null) {
connection = realConnection;
} else if (i > 5) {
connection = realConnection2;
j = j5;
} else {
j = -1;
connection = null;
}
if (connection != null) {
synchronized (connection) {
if (!connection.t.isEmpty()) {
return 0L;
}
if (connection.u != j) {
return 0L;
}
connection.n = true;
realConnectionPool.d.remove(connection);
_UtilJvmKt.b(connection.i);
Intrinsics.checkNotNullParameter(connection, "connection");
if (realConnectionPool.d.isEmpty()) {
realConnectionPool.b.a();
}
return 0L;
}
}
if (realConnection2 != null) {
return (j5 + realConnectionPool.f22101a) - nanoTime;
}
if (i2 <= 0) {
return -1L;
}
return realConnectionPool.f22101a;
}
};
this.d = new ConcurrentLinkedQueue();
}
public final int a(RealConnection realConnection, long j) {
TimeZone timeZone = _UtilJvmKt.f22077a;
ArrayList arrayList = realConnection.t;
int i = 0;
while (i < arrayList.size()) {
Reference reference = (Reference) arrayList.get(i);
if (reference.get() != null) {
i++;
} else {
Intrinsics.checkNotNull(reference, "null cannot be cast to non-null type okhttp3.internal.connection.RealCall.CallReference");
String str = "A connection to " + realConnection.g.f22069a.h + " was leaked. Did you forget to close a response body?";
Platform platform = Platform.f22173a;
Platform.f22173a.k(((RealCall.CallReference) reference).f22100a, str);
arrayList.remove(i);
if (arrayList.isEmpty()) {
realConnection.u = j - this.f22101a;
return 0;
}
}
}
return arrayList.size();
}
}