soul-browser/sources/java/kotlin/collections/RingBuffer.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

182 lines
9.5 KiB
Java

package kotlin.collections;
import com.google.android.gms.ads.RequestConfiguration;
import java.util.Arrays;
import java.util.Iterator;
import java.util.RandomAccess;
import kotlin.Metadata;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.SourceDebugExtension;
import kotlin.ranges.RangesKt;
import org.jetbrains.annotations.NotNull;
@Metadata(d1 = {"\u0000<\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0011\n\u0002\u0010\u0000\n\u0000\n\u0002\u0010\b\n\u0002\b\u000e\n\u0002\u0010\u000b\n\u0000\n\u0002\u0010(\n\u0002\b\u0007\n\u0002\u0010\u0002\n\u0002\b\u0006\b\u0002\u0018\u0000*\u0004\b\u0000\u0010\u00012\b\u0012\u0004\u0012\u0002H\u00010\u00022\u00060\u0003j\u0002`\u0004B\u001f\u0012\u000e\u0010\u0005\u001a\n\u0012\u0006\u0012\u0004\u0018\u00010\u00070\u0006\u0012\u0006\u0010\b\u001a\u00020\\u0006\u0004\b\n\u0010\u000bB\u0011\b\u0016\u0012\u0006\u0010\f\u001a\u00020\\u0006\u0004\b\n\u0010\rJ\u0016\u0010\u0014\u001a\u00028\u00002\u0006\u0010\u0015\u001a\u00020\tH\u0096\u0002¢\u0006\u0002\u0010\u0016J\u0006\u0010\u0017\u001a\u00020\u0018J\u000f\u0010\u0019\u001a\b\u0012\u0004\u0012\u00028\u00000\u001aH\u0096\u0002J'\u0010\u001b\u001a\b\u0012\u0004\u0012\u0002H\u00010\u0006\"\u0004\b\u0001\u0010\u00012\f\u0010\u001c\u001a\b\u0012\u0004\u0012\u0002H\u00010\u0006H\u0014¢\u0006\u0002\u0010\u001dJ\u0015\u0010\u001b\u001a\n\u0012\u0006\u0012\u0004\u0018\u00010\u00070\u0006H\u0014¢\u0006\u0002\u0010\u001eJ\u0014\u0010\u001f\u001a\b\u0012\u0004\u0012\u00028\u00000\u00002\u0006\u0010 \u001a\u00020\tJ\u0013\u0010!\u001a\u00020\"2\u0006\u0010#\u001a\u00028\u0000¢\u0006\u0002\u0010$J\u000e\u0010%\u001a\u00020\"2\u0006\u0010&\u001a\u00020\tJ\u0015\u0010'\u001a\u00020\t*\u00020\t2\u0006\u0010&\u001a\u00020\tH\u0082\bR\u0018\u0010\u0005\u001a\n\u0012\u0006\u0012\u0004\u0018\u00010\u00070\u0006X\u0082\u0004¢\u0006\u0004\n\u0002\u0010\u000eR\u000e\u0010\f\u001a\u00020\tX\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u000f\u001a\u00020\tX\u0082\u000e¢\u0006\u0002\n\u0000R\u001e\u0010\u0011\u001a\u00020\t2\u0006\u0010\u0010\u001a\u00020\t@RX\u0096\u000e¢\u0006\b\n\u0000\u001a\u0004\b\u0012\u0010\u0013¨\u0006("}, d2 = {"Lkotlin/collections/RingBuffer;", RequestConfiguration.MAX_AD_CONTENT_RATING_T, "Lkotlin/collections/AbstractList;", "Ljava/util/RandomAccess;", "Lkotlin/collections/RandomAccess;", "buffer", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED, RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED, "filledSize", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED, "<init>", "([Ljava/lang/Object;I)V", "capacity", "(I)V", "[Ljava/lang/Object;", "startIndex", "value", "size", "getSize", "()I", "get", "index", "(I)Ljava/lang/Object;", "isFull", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED, "iterator", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED, "toArray", "array", "([Ljava/lang/Object;)[Ljava/lang/Object;", "()[Ljava/lang/Object;", "expanded", "maxCapacity", "add", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED, "element", "(Ljava/lang/Object;)V", "removeFirst", "n", "forward", "kotlin-stdlib"}, k = 1, mv = {2, 2, 0}, xi = 48)
@SourceDebugExtension({"SMAP\nSlidingWindow.kt\nKotlin\n*S Kotlin\n*F\n+ 1 SlidingWindow.kt\nkotlin/collections/RingBuffer\n+ 2 fake.kt\nkotlin/jvm/internal/FakeKt\n*L\n1#1,206:1\n204#1:208\n204#1:209\n204#1:210\n1#2:207\n*S KotlinDebug\n*F\n+ 1 SlidingWindow.kt\nkotlin/collections/RingBuffer\n*L\n106#1:208\n175#1:209\n188#1:210\n*E\n"})
/* loaded from: classes3.dex */
final class RingBuffer<T> extends AbstractList<T> implements RandomAccess {
@NotNull
private final Object[] buffer;
private final int capacity;
private int size;
private int startIndex;
public RingBuffer(@NotNull Object[] buffer, int i) {
Intrinsics.checkNotNullParameter(buffer, "buffer");
this.buffer = buffer;
if (i >= 0) {
if (i <= buffer.length) {
this.capacity = buffer.length;
this.size = i;
return;
} else {
StringBuilder s = android.support.v4.media.a.s(i, "ring buffer filled size: ", " cannot be larger than the buffer size: ");
s.append(buffer.length);
throw new IllegalArgumentException(s.toString().toString());
}
}
throw new IllegalArgumentException(android.support.v4.media.a.e(i, "ring buffer filled size should not be negative but it is ").toString());
}
private final int forward(int i, int i2) {
return (i + i2) % this.capacity;
}
@Override // java.util.Collection, java.util.List
public final void add(T element) {
if (!isFull()) {
this.buffer[(size() + this.startIndex) % this.capacity] = element;
this.size = size() + 1;
return;
}
throw new IllegalStateException("ring buffer is full");
}
/* JADX WARN: Multi-variable type inference failed */
@NotNull
public final RingBuffer<T> expanded(int maxCapacity) {
Object[] array;
int i = this.capacity;
int coerceAtMost = RangesKt.coerceAtMost(i + (i >> 1) + 1, maxCapacity);
if (this.startIndex == 0) {
array = Arrays.copyOf(this.buffer, coerceAtMost);
Intrinsics.checkNotNullExpressionValue(array, "copyOf(...)");
} else {
array = toArray(new Object[coerceAtMost]);
}
return new RingBuffer<>(array, size());
}
@Override // kotlin.collections.AbstractList, java.util.List
public T get(int index) {
AbstractList.INSTANCE.checkElementIndex$kotlin_stdlib(index, size());
return (T) this.buffer[(this.startIndex + index) % this.capacity];
}
@Override // kotlin.collections.AbstractList, kotlin.collections.AbstractCollection
/* renamed from: getSize, reason: from getter */
public int get_size() {
return this.size;
}
public final boolean isFull() {
if (size() == this.capacity) {
return true;
}
return false;
}
@Override // kotlin.collections.AbstractList, kotlin.collections.AbstractCollection, java.util.Collection, java.lang.Iterable
@NotNull
public Iterator<T> iterator() {
return new AbstractIterator<T>(this) { // from class: kotlin.collections.RingBuffer$iterator$1
private int count;
private int index;
final /* synthetic */ RingBuffer<T> this$0;
{
int i;
this.this$0 = this;
this.count = this.size();
i = ((RingBuffer) this).startIndex;
this.index = i;
}
/* JADX WARN: Multi-variable type inference failed */
@Override // kotlin.collections.AbstractIterator
public void computeNext() {
Object[] objArr;
if (this.count != 0) {
objArr = ((RingBuffer) this.this$0).buffer;
setNext(objArr[this.index]);
this.index = (this.index + 1) % ((RingBuffer) this.this$0).capacity;
this.count--;
return;
}
done();
}
};
}
public final void removeFirst(int n) {
if (n >= 0) {
if (n <= size()) {
if (n > 0) {
int i = this.startIndex;
int i2 = (i + n) % this.capacity;
if (i > i2) {
ArraysKt___ArraysJvmKt.fill(this.buffer, (Object) null, i, this.capacity);
ArraysKt___ArraysJvmKt.fill(this.buffer, (Object) null, 0, i2);
} else {
ArraysKt___ArraysJvmKt.fill(this.buffer, (Object) null, i, i2);
}
this.startIndex = i2;
this.size = size() - n;
return;
}
return;
}
StringBuilder s = android.support.v4.media.a.s(n, "n shouldn't be greater than the buffer size: n = ", ", size = ");
s.append(size());
throw new IllegalArgumentException(s.toString().toString());
}
throw new IllegalArgumentException(android.support.v4.media.a.e(n, "n shouldn't be negative but it is ").toString());
}
@Override // kotlin.collections.AbstractCollection, java.util.Collection
@NotNull
public <T> T[] toArray(@NotNull T[] array) {
Intrinsics.checkNotNullParameter(array, "array");
int length = array.length;
Object[] objArr = array;
if (length < size()) {
Object[] objArr2 = (T[]) Arrays.copyOf(array, size());
Intrinsics.checkNotNullExpressionValue(objArr2, "copyOf(...)");
objArr = objArr2;
}
int size = size();
int i = 0;
int i2 = 0;
for (int i3 = this.startIndex; i2 < size && i3 < this.capacity; i3++) {
objArr[i2] = this.buffer[i3];
i2++;
}
while (i2 < size) {
objArr[i2] = this.buffer[i];
i2++;
i++;
}
return (T[]) CollectionsKt__CollectionsJVMKt.terminateCollectionToArray(size, objArr);
}
/* JADX WARN: Multi-variable type inference failed */
@Override // kotlin.collections.AbstractCollection, java.util.Collection
@NotNull
public Object[] toArray() {
return toArray(new Object[size()]);
}
public RingBuffer(int i) {
this(new Object[i], 0);
}
}