Inspired by HNKServer/honoka-chan-apk-server, but implemented as a JNI-based embedded runtime instead of the original approach. - Add an Android Compose controller app that starts and stops honoka-chan through JNI, shows runtime and health status, manages data directory mounting, and supports backup import/export for data.db - Add an embeddable Go server entrypoint plus JNI-exported status, health, and reload hooks so desktop and Android builds share the same startup and shutdown path - Add Android build scripts, runtime packaging, and project documentation, including generated default config.json content for honoka_runtime.zip - Add runtime bundle hash tracking so updated honoka_runtime.zip assets are automatically redeployed while preserving config.json and user data files - Add in-app service settings for unlock_all_special_rotation with immediate config persistence and automatic reload when the service is running - Split SQLite driver selection by platform, using go-sqlite3 on Android and modernc.org/sqlite elsewhere to avoid Android x86_64 seccomp crashes - Update startup, database initialization, and system health/reload handlers to support the embedded runtime and Android control flow Signed-off-by: Sean Du <do4suki@gmail.com>
40 lines
747 B
Go
40 lines
747 B
Go
//go:build android
|
|
|
|
package db
|
|
|
|
import (
|
|
_ "github.com/mattn/go-sqlite3"
|
|
"xorm.io/xorm"
|
|
)
|
|
|
|
const sqliteDriverName = "sqlite3"
|
|
|
|
func mainSQLiteDSN(dbPath string) string {
|
|
return dbPath
|
|
}
|
|
|
|
func userSQLiteDSN(dbPath string) string {
|
|
return dbPath
|
|
}
|
|
|
|
func prepareMainSQLiteEngine(engine *xorm.Engine) error {
|
|
return applySQLitePragmas(engine, nil)
|
|
}
|
|
|
|
func prepareUserSQLiteEngine(engine *xorm.Engine) error {
|
|
return applySQLitePragmas(engine, []string{
|
|
"PRAGMA busy_timeout = 5000",
|
|
"PRAGMA journal_mode = WAL",
|
|
"PRAGMA synchronous = NORMAL",
|
|
})
|
|
}
|
|
|
|
func applySQLitePragmas(engine *xorm.Engine, pragmas []string) error {
|
|
for _, pragma := range pragmas {
|
|
if _, err := engine.Exec(pragma); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
return nil
|
|
}
|