soul-browser/sources/java/androidx/sqlite/db/framework/FrameworkSQLiteOpenHelper.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

184 lines
7.3 KiB
Java

package androidx.sqlite.db.framework;
import android.content.Context;
import android.database.DatabaseErrorHandler;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
import android.util.Pair;
import androidx.sqlite.db.SupportSQLiteDatabase;
import androidx.sqlite.db.SupportSQLiteOpenHelper;
import java.io.File;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
/* loaded from: classes.dex */
class FrameworkSQLiteOpenHelper implements SupportSQLiteOpenHelper {
/* renamed from: c, reason: collision with root package name */
public final Context f1660c;
public final String f;
public final SupportSQLiteOpenHelper.Callback g;
public final boolean h;
public final Object i = new Object();
public OpenHelper j;
public boolean k;
/* loaded from: classes.dex */
public static class OpenHelper extends SQLiteOpenHelper {
/* renamed from: c, reason: collision with root package name */
public final FrameworkSQLiteDatabase[] f1661c;
public final SupportSQLiteOpenHelper.Callback f;
public boolean g;
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
public OpenHelper(Context context, String str, final FrameworkSQLiteDatabase[] frameworkSQLiteDatabaseArr, final SupportSQLiteOpenHelper.Callback callback) {
super(context, str, null, 12, new DatabaseErrorHandler() { // from class: androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper.OpenHelper.1
@Override // android.database.DatabaseErrorHandler
public final void onCorruption(SQLiteDatabase sQLiteDatabase) {
FrameworkSQLiteDatabase a2 = OpenHelper.a(frameworkSQLiteDatabaseArr, sQLiteDatabase);
SupportSQLiteOpenHelper.Callback.this.getClass();
Log.e("SupportSQLite", "Corruption reported by sqlite on database: " + a2.f1658c.getPath());
SQLiteDatabase sQLiteDatabase2 = a2.f1658c;
if (!sQLiteDatabase2.isOpen()) {
SupportSQLiteOpenHelper.Callback.a(sQLiteDatabase2.getPath());
return;
}
List<Pair<String, String>> list = null;
try {
try {
list = sQLiteDatabase2.getAttachedDbs();
} finally {
if (list != null) {
Iterator<Pair<String, String>> it = list.iterator();
while (it.hasNext()) {
SupportSQLiteOpenHelper.Callback.a((String) it.next().second);
}
} else {
SupportSQLiteOpenHelper.Callback.a(sQLiteDatabase2.getPath());
}
}
} catch (SQLiteException unused) {
}
try {
a2.close();
} catch (IOException unused2) {
}
}
});
callback.getClass();
this.f = callback;
this.f1661c = frameworkSQLiteDatabaseArr;
}
public static FrameworkSQLiteDatabase a(FrameworkSQLiteDatabase[] frameworkSQLiteDatabaseArr, SQLiteDatabase sQLiteDatabase) {
FrameworkSQLiteDatabase frameworkSQLiteDatabase = frameworkSQLiteDatabaseArr[0];
if (frameworkSQLiteDatabase == null || frameworkSQLiteDatabase.f1658c != sQLiteDatabase) {
frameworkSQLiteDatabaseArr[0] = new FrameworkSQLiteDatabase(sQLiteDatabase);
}
return frameworkSQLiteDatabaseArr[0];
}
public final synchronized SupportSQLiteDatabase b() {
this.g = false;
SQLiteDatabase writableDatabase = super.getWritableDatabase();
if (this.g) {
close();
return b();
}
return a(this.f1661c, writableDatabase);
}
@Override // android.database.sqlite.SQLiteOpenHelper, java.lang.AutoCloseable
public final synchronized void close() {
super.close();
this.f1661c[0] = null;
}
@Override // android.database.sqlite.SQLiteOpenHelper
public final void onConfigure(SQLiteDatabase sQLiteDatabase) {
a(this.f1661c, sQLiteDatabase);
this.f.getClass();
}
@Override // android.database.sqlite.SQLiteOpenHelper
public final void onCreate(SQLiteDatabase sQLiteDatabase) {
this.f.b(a(this.f1661c, sQLiteDatabase));
}
@Override // android.database.sqlite.SQLiteOpenHelper
public final void onDowngrade(SQLiteDatabase sQLiteDatabase, int i, int i2) {
this.g = true;
this.f.c(a(this.f1661c, sQLiteDatabase), i, i2);
}
@Override // android.database.sqlite.SQLiteOpenHelper
public final void onOpen(SQLiteDatabase sQLiteDatabase) {
if (!this.g) {
this.f.d(a(this.f1661c, sQLiteDatabase));
}
}
@Override // android.database.sqlite.SQLiteOpenHelper
public final void onUpgrade(SQLiteDatabase sQLiteDatabase, int i, int i2) {
this.g = true;
this.f.e(a(this.f1661c, sQLiteDatabase), i, i2);
}
}
public FrameworkSQLiteOpenHelper(Context context, String str, SupportSQLiteOpenHelper.Callback callback, boolean z) {
this.f1660c = context;
this.f = str;
this.g = callback;
this.h = z;
}
@Override // androidx.sqlite.db.SupportSQLiteOpenHelper
public final SupportSQLiteDatabase O() {
return a().b();
}
public final OpenHelper a() {
OpenHelper openHelper;
synchronized (this.i) {
try {
if (this.j == null) {
FrameworkSQLiteDatabase[] frameworkSQLiteDatabaseArr = new FrameworkSQLiteDatabase[1];
if (this.f != null && this.h) {
this.j = new OpenHelper(this.f1660c, new File(this.f1660c.getNoBackupFilesDir(), this.f).getAbsolutePath(), frameworkSQLiteDatabaseArr, this.g);
} else {
this.j = new OpenHelper(this.f1660c, this.f, frameworkSQLiteDatabaseArr, this.g);
}
this.j.setWriteAheadLoggingEnabled(this.k);
}
openHelper = this.j;
} catch (Throwable th) {
throw th;
}
}
return openHelper;
}
@Override // java.io.Closeable, java.lang.AutoCloseable
public final void close() {
a().close();
}
@Override // androidx.sqlite.db.SupportSQLiteOpenHelper
public final void setWriteAheadLoggingEnabled(boolean z) {
synchronized (this.i) {
try {
OpenHelper openHelper = this.j;
if (openHelper != null) {
openHelper.setWriteAheadLoggingEnabled(z);
}
this.k = z;
} catch (Throwable th) {
throw th;
}
}
}
}