[Bug] Android 11/12 export failure when TMPDIR is not configured
维护者通常 1 天内回复
评估
调研方向
The change belongs in RustInterface.kt, where SQLITE_TMPDIR is already set from context.cacheDir; the issue proposes also setting TMPDIR to the same path before the Rust native library loads. Pull request #398 already targets this fix, so review that first and do not start a parallel patch. Done means the proposed assignment is present and raw-data export succeeds on Android 11 and 12.
由索引模型根据 Issue 内容生成。
描述
Summary
Android data export can fail on Android 11 and Android 12 because the Rust process may use an unwritable temporary directory when TMPDIR is not configured.
This appears to be a specific, reproducible cause of the export symptoms discussed in #143. This issue isolates the temporary-directory problem and proposes a small upstream fix.
Observed behavior
- On Android 11 and Android 12, JSON export could report success while producing an empty file.
- CSV export could fail before the system folder picker appeared.
- Android 14 did not exhibit the same export failure in testing.
- After setting
TMPDIRto the app's cache directory, export completed successfully on the affected Android versions.
The fix was tested with app build 0.14.4b1.
No device manufacturer, model, vendor-specific Android skin, or other device-identifying details are included because they are not relevant to reproducing or fixing this issue.
Root cause
The current RustInterface.kt sets only the SQLite-specific variable:
if (context != null) {
Os.setenv("SQLITE_TMPDIR", context.cacheDir.absolutePath, true)
}
This configures SQLite's temporary directory, but it does not configure the general temporary directory used by Rust.
Rust's std::env::temp_dir() uses the TMPDIR environment variable when it is set. According to the Rust standard-library documentation, when TMPDIR is unset, an app running in its application namespace uses its app cache directory on Android 13 and later, but falls back to /data/local/tmp on earlier Android versions. A regular Android app cannot write to that system directory.
The Rust tempfile crate uses std::env::temp_dir() as its default temporary directory. Therefore, setting SQLITE_TMPDIR alone does not fix temporary-file creation performed through Rust's general temporary-file mechanism.
References:
Proposed fix
Set TMPDIR to the app's writable cache directory before loading the Rust native library, while retaining the existing SQLITE_TMPDIR setting:
if (context != null) {
val appTempDir = context.cacheDir.absolutePath
// Rust's Android temp directory may otherwise resolve to /data/local/tmp,
// which an ordinary application cannot write to.
Os.setenv("TMPDIR", appTempDir, true)
// SQLite uses its own temporary-directory environment variable.
Os.setenv("SQLITE_TMPDIR", appTempDir, true)
}
Verification
The change above was applied and tested. Raw-data export then completed successfully on Android 11 and Android 12, where the failure had been observed. Android 14 did not show the same failure in testing.
This points to the missing TMPDIR assignment as the cause of the Android 11/12 export failure. The proposed change is limited to temporary-directory configuration and does not address the separate browser/server-access concern also mentioned in #143.
Suggested upstream action: add the TMPDIR assignment alongside the existing SQLITE_TMPDIR assignment in RustInterface.kt.
— ChatGPT (technical analysis and report drafting assistance)
- 主要语言
- Kotlin
- 星标
- 287
- 派生
- 65
- 平均合并
- 4 天 14 小时
- 30 天内合并 PR
- 6
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
ActivityWatch/aw-android 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 68/100
ActivityWatch/aw-android#383 · 2 条评论 ·
维护者通常 1 天内回复
-
Web watcher: add support for Brave (`com.brave.browser` missing from KNOWN_BROWSER_PACKAGES)可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
ActivityWatch/aw-android#306 · 1 条评论 · 2 个 reaction ·
维护者通常 1 天内回复
-
AuthSettingsActivity crashes on launch (InflateException: Material attributes under AppCompat theme)可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 2/5 1-3 小时 新手友好度 75/100
ActivityWatch/aw-android#210 · 11 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
-
Allow to easily pause logging可能已有人在做 @TimeToBuildBob 于 19 天前认领。 未关闭
难度 5/5 一周以上 新手友好度 25/100
ActivityWatch/aw-android#385 · 4 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 50/100
ActivityWatch/aw-android#384 · 1 条评论 ·
维护者通常 1 天内回复
查看 ActivityWatch/aw-android 的全部 Issue
相似的 Issue
-
unconfirmed
难度 2/5 1-3 小时 新手友好度 64/100
thunderbird/thunderbird-android#11953 · 1 条评论 ·
维护者通常 3 天内回复
-
The triage routine files service failures, slow journeys and viewer reports sensibly可能已有人在做 @neutraltone 今天认领。 未关闭enhancement ready-for-agent
难度 2/5 1-3 小时 新手友好度 64/100
neutraltone/settee#636 ·
维护者通常 1 天内回复
-
[Type] Bug
难度 2/5 1-3 小时 新手友好度 74/100
wordpress-mobile/GutenbergKit#940 ·
维护者通常 1 天内回复
-
enhancement
难度 2/5 1-3 小时 新手友好度 65/100
deniscerri/ytdlnis#1512 ·
维护者通常 2 天内回复
-
documentation good first issue help wanted
难度 2/5 半天 新手友好度 66/100
维护者通常 1 天内回复