soul-browser/sources/java/com/google/api/client/util/ArrayMap.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

375 lines
10 KiB
Java

package com.google.api.client.util;
import java.util.AbstractMap;
import java.util.AbstractSet;
import java.util.Iterator;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;
/* loaded from: classes3.dex */
public class ArrayMap<K, V> extends AbstractMap<K, V> implements Cloneable {
private Object[] data;
int size;
/* loaded from: classes3.dex */
public final class Entry implements Map.Entry<K, V> {
private int index;
public Entry(int i) {
this.index = i;
}
@Override // java.util.Map.Entry
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof Map.Entry)) {
return false;
}
Map.Entry entry = (Map.Entry) obj;
if (Objects.equal(getKey(), entry.getKey()) && Objects.equal(getValue(), entry.getValue())) {
return true;
}
return false;
}
@Override // java.util.Map.Entry
public K getKey() {
return (K) ArrayMap.this.getKey(this.index);
}
@Override // java.util.Map.Entry
public V getValue() {
return (V) ArrayMap.this.getValue(this.index);
}
@Override // java.util.Map.Entry
public int hashCode() {
int i;
Object key = getKey();
Object value = getValue();
int i2 = 0;
if (key != null) {
i = key.hashCode();
} else {
i = 0;
}
if (value != null) {
i2 = value.hashCode();
}
return i ^ i2;
}
@Override // java.util.Map.Entry
public V setValue(V v) {
return (V) ArrayMap.this.set(this.index, v);
}
}
/* loaded from: classes3.dex */
public final class EntryIterator implements Iterator<Map.Entry<K, V>> {
private int nextIndex;
private boolean removed;
public EntryIterator() {
}
@Override // java.util.Iterator
public boolean hasNext() {
if (this.nextIndex < ArrayMap.this.size) {
return true;
}
return false;
}
@Override // java.util.Iterator
public void remove() {
int i = this.nextIndex - 1;
if (!this.removed && i >= 0) {
ArrayMap.this.remove(i);
this.nextIndex--;
this.removed = true;
return;
}
throw new IllegalArgumentException();
}
@Override // java.util.Iterator
public Map.Entry<K, V> next() {
int i = this.nextIndex;
ArrayMap arrayMap = ArrayMap.this;
if (i != arrayMap.size) {
this.nextIndex = i + 1;
this.removed = false;
return new Entry(i);
}
throw new NoSuchElementException();
}
}
/* loaded from: classes3.dex */
public final class EntrySet extends AbstractSet<Map.Entry<K, V>> {
public EntrySet() {
}
@Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set
public Iterator<Map.Entry<K, V>> iterator() {
return new EntryIterator();
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public int size() {
return ArrayMap.this.size;
}
}
public static <K, V> ArrayMap<K, V> create() {
return new ArrayMap<>();
}
private int getDataIndexOfKey(Object obj) {
int i = this.size << 1;
Object[] objArr = this.data;
for (int i2 = 0; i2 < i; i2 += 2) {
Object obj2 = objArr[i2];
if (obj == null) {
if (obj2 == null) {
return i2;
}
} else {
if (obj.equals(obj2)) {
return i2;
}
}
}
return -2;
}
public static <K, V> ArrayMap<K, V> of(Object... objArr) {
ArrayMap<K, V> create = create(1);
int length = objArr.length;
if (1 != length % 2) {
create.size = objArr.length / 2;
Object[] objArr2 = new Object[length];
((ArrayMap) create).data = objArr2;
System.arraycopy(objArr, 0, objArr2, 0, length);
return create;
}
throw new IllegalArgumentException("missing value for last key: " + objArr[length - 1]);
}
private V removeFromDataIndexOfKey(int i) {
int i2 = this.size << 1;
if (i < 0 || i >= i2) {
return null;
}
V valueAtDataIndex = valueAtDataIndex(i + 1);
Object[] objArr = this.data;
int i3 = (i2 - i) - 2;
if (i3 != 0) {
System.arraycopy(objArr, i + 2, objArr, i, i3);
}
this.size--;
setData(i2 - 2, null, null);
return valueAtDataIndex;
}
private void setData(int i, K k, V v) {
Object[] objArr = this.data;
objArr[i] = k;
objArr[i + 1] = v;
}
private void setDataCapacity(int i) {
if (i == 0) {
this.data = null;
return;
}
int i2 = this.size;
Object[] objArr = this.data;
if (i2 == 0 || i != objArr.length) {
Object[] objArr2 = new Object[i];
this.data = objArr2;
if (i2 != 0) {
System.arraycopy(objArr, 0, objArr2, 0, i2 << 1);
}
}
}
private V valueAtDataIndex(int i) {
if (i < 0) {
return null;
}
return (V) this.data[i];
}
public final void add(K k, V v) {
set(this.size, k, v);
}
@Override // java.util.AbstractMap, java.util.Map
public void clear() {
this.size = 0;
this.data = null;
}
@Override // java.util.AbstractMap, java.util.Map
public final boolean containsKey(Object obj) {
if (-2 != getDataIndexOfKey(obj)) {
return true;
}
return false;
}
@Override // java.util.AbstractMap, java.util.Map
public final boolean containsValue(Object obj) {
int i = this.size << 1;
Object[] objArr = this.data;
for (int i2 = 1; i2 < i; i2 += 2) {
Object obj2 = objArr[i2];
if (obj == null) {
if (obj2 == null) {
return true;
}
} else {
if (obj.equals(obj2)) {
return true;
}
}
}
return false;
}
public final void ensureCapacity(int i) {
int length;
if (i >= 0) {
Object[] objArr = this.data;
int i2 = i << 1;
if (objArr == null) {
length = 0;
} else {
length = objArr.length;
}
if (i2 > length) {
int i3 = (length / 2) * 3;
int i4 = i3 + 1;
if (i4 % 2 != 0) {
i4 = i3 + 2;
}
if (i4 >= i2) {
i2 = i4;
}
setDataCapacity(i2);
return;
}
return;
}
throw new IndexOutOfBoundsException();
}
@Override // java.util.AbstractMap, java.util.Map
public final Set<Map.Entry<K, V>> entrySet() {
return new EntrySet();
}
@Override // java.util.AbstractMap, java.util.Map
public final V get(Object obj) {
return valueAtDataIndex(getDataIndexOfKey(obj) + 1);
}
public final int getIndexOfKey(K k) {
return getDataIndexOfKey(k) >> 1;
}
public final K getKey(int i) {
if (i >= 0 && i < this.size) {
return (K) this.data[i << 1];
}
return null;
}
public final V getValue(int i) {
if (i >= 0 && i < this.size) {
return valueAtDataIndex((i << 1) + 1);
}
return null;
}
@Override // java.util.AbstractMap, java.util.Map
public final V put(K k, V v) {
int indexOfKey = getIndexOfKey(k);
if (indexOfKey == -1) {
indexOfKey = this.size;
}
return set(indexOfKey, k, v);
}
public final V remove(int i) {
return removeFromDataIndexOfKey(i << 1);
}
public final V set(int i, K k, V v) {
if (i >= 0) {
int i2 = i + 1;
ensureCapacity(i2);
int i3 = i << 1;
V valueAtDataIndex = valueAtDataIndex(i3 + 1);
setData(i3, k, v);
if (i2 > this.size) {
this.size = i2;
}
return valueAtDataIndex;
}
throw new IndexOutOfBoundsException();
}
@Override // java.util.AbstractMap, java.util.Map
public final int size() {
return this.size;
}
public final void trim() {
setDataCapacity(this.size << 1);
}
public static <K, V> ArrayMap<K, V> create(int i) {
ArrayMap<K, V> create = create();
create.ensureCapacity(i);
return create;
}
@Override // java.util.AbstractMap
public ArrayMap<K, V> clone() {
try {
ArrayMap<K, V> arrayMap = (ArrayMap) super.clone();
Object[] objArr = this.data;
if (objArr != null) {
int length = objArr.length;
Object[] objArr2 = new Object[length];
arrayMap.data = objArr2;
System.arraycopy(objArr, 0, objArr2, 0, length);
}
return arrayMap;
} catch (CloneNotSupportedException unused) {
return null;
}
}
@Override // java.util.AbstractMap, java.util.Map
public final V remove(Object obj) {
return removeFromDataIndexOfKey(getDataIndexOfKey(obj));
}
public final V set(int i, V v) {
int i2 = this.size;
if (i >= 0 && i < i2) {
int i3 = (i << 1) + 1;
V valueAtDataIndex = valueAtDataIndex(i3);
this.data[i3] = v;
return valueAtDataIndex;
}
throw new IndexOutOfBoundsException();
}
}