fix files directory handling: use internal storage and add exception handling

- Use internal files dir instead of external (fixes scoped storage permissions)
- Pass files directory from Android context via JNI instead of hardcoding
- Add exception handling in ScanAppsDirectory to prevent crashes on permission errors
- Use std::error_code overload of fs::exists() to avoid throwing on access denial

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-19 21:49:58 +01:00
parent 76d97e202b
commit 8cf24d8c2a
4 changed files with 113 additions and 68 deletions

View File

@@ -19,6 +19,7 @@ class NativeService : Service() {
}
external fun getBinderNative(): IBinder
external fun setAssetManager(assetManager: AssetManager)
external fun setFilesDir(filesDir: String)
override fun onBind(intent: Intent): IBinder {
return getBinderNative()
@@ -27,6 +28,9 @@ class NativeService : Service() {
override fun onCreate() {
super.onCreate()
setAssetManager(assets)
// Use internal files dir - more reliable access in service processes
// For debugging, use: adb shell run-as com.omixlab.mosis ls files/
setFilesDir(filesDir.absolutePath)
}
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {