soul-browser/sources/java/com/google/common/collect/MinMaxPriorityQueue.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

217 lines
6.4 KiB
Java

package com.google.common.collect;
import com.google.common.annotations.GwtCompatible;
import com.google.common.base.Preconditions;
import j$.util.Objects;
import java.util.AbstractQueue;
import java.util.Collection;
import java.util.ConcurrentModificationException;
import java.util.Iterator;
import java.util.NoSuchElementException;
@GwtCompatible
/* loaded from: classes3.dex */
public final class MinMaxPriorityQueue<E> extends AbstractQueue<E> {
/* renamed from: c, reason: collision with root package name */
public Object[] f12363c;
public int f;
public int g;
/* loaded from: classes3.dex */
public static final class Builder<B> {
}
/* loaded from: classes3.dex */
public final class Heap {
}
/* loaded from: classes3.dex */
public static final class MoveDesc<E> {
}
/* loaded from: classes3.dex */
public final class QueueIterator implements Iterator<E> {
/* renamed from: c, reason: collision with root package name */
public int f12364c = -1;
public int f = -1;
public int g;
public boolean h;
public QueueIterator() {
this.g = MinMaxPriorityQueue.this.g;
}
@Override // java.util.Iterator
public final boolean hasNext() {
MinMaxPriorityQueue minMaxPriorityQueue = MinMaxPriorityQueue.this;
if (minMaxPriorityQueue.g == this.g) {
int i = this.f12364c + 1;
if (this.f < i) {
this.f = i;
}
if (this.f < minMaxPriorityQueue.f) {
return true;
}
return false;
}
throw new ConcurrentModificationException();
}
@Override // java.util.Iterator
public final Object next() {
MinMaxPriorityQueue minMaxPriorityQueue = MinMaxPriorityQueue.this;
if (minMaxPriorityQueue.g == this.g) {
int i = this.f12364c + 1;
if (this.f < i) {
this.f = i;
}
int i2 = this.f;
if (i2 < minMaxPriorityQueue.f) {
this.f12364c = i2;
this.h = true;
Object obj = minMaxPriorityQueue.f12363c[i2];
Objects.requireNonNull(obj);
return obj;
}
throw new NoSuchElementException("iterator moved past last element in queue.");
}
throw new ConcurrentModificationException();
}
@Override // java.util.Iterator
public final void remove() {
CollectPreconditions.d(this.h);
MinMaxPriorityQueue minMaxPriorityQueue = MinMaxPriorityQueue.this;
int i = minMaxPriorityQueue.g;
int i2 = this.g;
if (i == i2) {
this.h = false;
this.g = i2 + 1;
int i3 = this.f12364c;
if (i3 < minMaxPriorityQueue.f) {
minMaxPriorityQueue.a(i3);
this.f12364c--;
this.f--;
return;
}
throw null;
}
throw new ConcurrentModificationException();
}
}
public final void a(int i) {
Preconditions.i(i, this.f);
boolean z = true;
this.g++;
int i2 = this.f - 1;
this.f = i2;
if (i2 == i) {
this.f12363c[i2] = null;
return;
}
Objects.requireNonNull(this.f12363c[i2]);
if ((~(~(this.f + 1))) <= 0) {
z = false;
}
Preconditions.m(z, "negative index");
throw null;
}
@Override // java.util.AbstractQueue, java.util.AbstractCollection, java.util.Collection, java.util.Queue
public final boolean add(Object obj) {
offer(obj);
throw null;
}
@Override // java.util.AbstractQueue, java.util.AbstractCollection, java.util.Collection
public final boolean addAll(Collection collection) {
Iterator<E> it = collection.iterator();
if (!it.hasNext()) {
return false;
}
offer(it.next());
throw null;
}
@Override // java.util.AbstractQueue, java.util.AbstractCollection, java.util.Collection
public final void clear() {
for (int i = 0; i < this.f; i++) {
this.f12363c[i] = null;
}
this.f = 0;
}
@Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable
public final Iterator iterator() {
return new QueueIterator();
}
@Override // java.util.Queue
public final boolean offer(Object obj) {
int i;
obj.getClass();
boolean z = true;
this.g++;
int i2 = this.f + 1;
this.f = i2;
Object[] objArr = this.f12363c;
if (i2 > objArr.length) {
int length = objArr.length;
if (length >= 64) {
long j = (length / 2) * 3;
i = (int) j;
if (j != i) {
throw new ArithmeticException();
}
} else {
i = (length + 1) * 2;
}
Object[] objArr2 = new Object[Math.min(i - 1, 0) + 1];
Object[] objArr3 = this.f12363c;
System.arraycopy(objArr3, 0, objArr2, 0, objArr3.length);
this.f12363c = objArr2;
}
if ((~(~i2)) <= 0) {
z = false;
}
Preconditions.m(z, "negative index");
throw null;
}
@Override // java.util.Queue
public final Object peek() {
if (isEmpty()) {
return null;
}
Object obj = this.f12363c[0];
Objects.requireNonNull(obj);
return obj;
}
@Override // java.util.Queue
public final Object poll() {
if (isEmpty()) {
return null;
}
Object obj = this.f12363c[0];
Objects.requireNonNull(obj);
a(0);
return obj;
}
@Override // java.util.AbstractCollection, java.util.Collection
public final int size() {
return this.f;
}
@Override // java.util.AbstractCollection, java.util.Collection
public final Object[] toArray() {
int i = this.f;
Object[] objArr = new Object[i];
System.arraycopy(this.f12363c, 0, objArr, 0, i);
return objArr;
}
}