Add Android control app and embedded server
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>
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
package main
|
||||
|
||||
/*
|
||||
#include <stdlib.h>
|
||||
*/
|
||||
import "C"
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"honoka-chan/internal/app"
|
||||
systemhandler "honoka-chan/internal/handler/system"
|
||||
"time"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
//export ServerStart
|
||||
func ServerStart(workDir *C.char) *C.char {
|
||||
if err := app.Start(C.GoString(workDir)); err != nil {
|
||||
return C.CString(err.Error())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
//export ServerStop
|
||||
func ServerStop() *C.char {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
defer cancel()
|
||||
|
||||
if err := app.Stop(ctx); err != nil {
|
||||
return C.CString(err.Error())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
//export ServerStatusJSON
|
||||
func ServerStatusJSON() *C.char {
|
||||
return C.CString(app.GetStatusJSON())
|
||||
}
|
||||
|
||||
//export ServerHealthJSON
|
||||
func ServerHealthJSON() *C.char {
|
||||
return C.CString(systemhandler.HealthJSON())
|
||||
}
|
||||
|
||||
//export ServerReload
|
||||
func ServerReload() *C.char {
|
||||
resp, _, err := systemhandler.Reload("", false)
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
data, marshalErr := json.Marshal(resp)
|
||||
if marshalErr != nil {
|
||||
return C.CString(err.Error())
|
||||
}
|
||||
return C.CString(string(data))
|
||||
}
|
||||
|
||||
//export ServerFreeString
|
||||
func ServerFreeString(str *C.char) {
|
||||
if str == nil {
|
||||
return
|
||||
}
|
||||
C.free(unsafe.Pointer(str))
|
||||
}
|
||||
|
||||
func main() {}
|
||||
Reference in New Issue
Block a user