fix(android): persist prefs/logs under app filesDir - #877
Merged
H-Chris233 merged 2 commits intoAug 2, 2026
Conversation
Honor devices reject writes under /data/local/tmp, which caused PreferencesStore to fall back to openless_prefs_fallback.json and settings saves to fail. Initialize JNI storage roots before Coordinator and file logging, route logs to files/logs/openless.log, and export via ContentResolver for SAF content:// URIs.
Contributor
PR Reviewer Guide 🔍(Review updated until commit 10b3c02)Here are some key observations to aid the review process:
|
… logs Reject persisting style pack icons when asset_root is empty to avoid writing under cwd; no-op cleanup on empty root. Limit Coordinator persistence degrade log suffix to Android only. Add unit test. Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
|
Persistent review updated to latest commit 10b3c02 |
6 tasks
H-Chris233
added a commit
that referenced
this pull request
Aug 3, 2026
* feat(android): expose advanced debug tools on mobile Show Advanced debug tools on Android with mobile-friendly layout. Backend SAF log export already landed in #877. Co-authored-by: Cursor <cursoragent@cursor.com> * fix(settings): 调试工具保留条数说明仅移动端展示,导出成功消息可换行并显示完整路径 --------- Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: Chris233 <h-chris233@outlook.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
User description
Summary
Fixes Honor / Huawei devices where Settings → Services provider switches and preference saves fail with generic「操作失败」.
Root cause: On Android,
Coordinator::new()ran before JNIContextwas ready.data_dir()fell back tostd::env::temp_dir()(/data/local/tmp), which the app sandbox cannot write.PreferencesStorethen degraded toopenless_prefs_fallback.jsonunder/data/local/tmp, so everyupdatePrefs/set_settingswrite failed.This PR also includes SAF
content://log export (dialog save URI) and multi-path lookup foropenless.logonce file logging is created underfiles/logs/.Related to #865 — this PR fixes preferences / shared
data_dirpersistence and log export only. It does not changeCredentialsVault/ Android Keystore /set_credential. If「只保存 API Key」still fails after this lands, that needs a separate follow-up.Error UX: Settings toasts remain generic「操作失败」; we intentionally do not surface Rust error strings in
ProvidersSection. Use Advanced → Debug tools → Export log for details.Changes
persistence/android_storage.rs: resolvefilesDirvia JNI +OnceLock; never use/data/local/tmpfor persistencemobile_runtime:init_android_storage_roots→init_file_logger→Coordinator::new→app.manageinsidesetup()asset_rootis empty (memory-only fallback)/data/local/tmpnotelog_dir_path()→{filesDir}/logs; export viaContentResolverfor SAF URIsfilesDir/OpenLessfor overlay prefs readsNot included: ADB specialist debug kit, CI workflow changes, specialist-only UI, or credential storage changes.
Test plan
adb install -r(nopm clear)openless_prefs_fallbackrun-as com.openless.app ls files/OpenLess files/logsshowspreferences.jsonandopenless.logPR Type
Bug fix, Tests
Description
Fix Honor settings saves by using app filesDir.
Initialize storage roots before Coordinator in setup.
Add SAF content:// log export via ContentResolver.
Make Android fallback stores memory-only with empty paths.
Diagram Walkthrough
flowchart LR A["Android setup()"] --> B["init_android_storage_roots (JNI filesDir)"] B --> C["file logger + Coordinator"] C --> D["persistence stores under filesDir/OpenLess"] D --> E["settings saves work"] F["export_error_log"] --> G["content:// URI"] G --> H["OpenLessContentWriter.writeBytes"]File Walkthrough
2 files
Add JNI write_content_uri SAF helperAdd Kotlin ContentResolver SAF writer13 files
Route log export via content URI on AndroidUse Android filesDir logs and improve logger initInitialize Coordinator after Android storage rootsAdd Android storage roots resolver and unit testsUse memory-only fallback path on AndroidUse memory-only fallback path on AndroidUse memory-only fallback path on AndroidAdd empty path guard and Android data_dirUse memory-only fallback path on AndroidUse memory-only fallback path on AndroidGuard empty asset root and add testOmit dialog filters on Android for save exportPrefer filesDir when reading Android preferences1 files
Add Android degrade log suffix1 files
Show export error message in debug tools2 files
Bump plugin-dialog dependency to 2.7.2Bump tauri-plugin-dialog to 2.7.21 files
Include OpenLessContentWriter in Kotlin scaffolding