Data-integrity review: browser visit lost on watcher destroy, export overwrite without truncate, notify drops startOfDay minutes (+2)

未关闭
#409 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
28/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
android, kotlin
领域
mobile, mobile-dev

调研方向

Start with watcher/WebWatcher.kt around onDestroy (410-417): flush the open session via sessionTracker.handleUrl(null, null) before writer.shutdown(), using a Robolectric ServiceController and recording writer to prove it. Then inspect fragments/WebUIFragment.kt writeExport (1070) for the "wt" truncation fix and sendText (167-168) for surrogate-safe chunking. workers/NotifyWorker.kt parseStartOfDayHour (134) needs a LocalTime; the extractor findings at WebWatcher.kt 98/136/140 need a device repro and a privacy decision before changing recording behavior.

由索引模型根据 Issue 内容生成。

描述

Remaining findings from a data-integrity review of aw-android master (aa9cea0). I checked each one against the code. They are not fixed in #407 (DST day window) or #408 (sub-second browser durations), and none of them duplicates an open issue or PR.

1. The browser visit in progress is lost when the accessibility service is destroyed. Two reviewers found this independently. A visit is written only when the URL, browser or window changes. WebWatcher.onDestroy (watcher/WebWatcher.kt:410-417) shuts down writer without first calling sessionTracker.handleUrl(null, null). If the user turns the service off, or the system unbinds it while a page is open, that whole visit is dropped. There is no upper bound on how much is lost: reading one page for 40 minutes loses 40 minutes. Fix: in onDestroy, flush the open session before writer.shutdown(). A test needs a Robolectric ServiceController with a recording writer, because the defect is a missing call that a pure tracker test can't see. A process kill (battery optimisation, app update) loses the visit too. Fixing that would need periodic chunked writes, as MediaPlaybackSegments already does.

2. Saving an export over an existing file can leave the old file's tail behind. WebUIFragment.writeExport (fragments/WebUIFragment.kt:1070) opens the URI with openOutputStream(uri), which means mode "w". Some providers (MediaProvider/FUSE-backed Downloads) don't truncate on "w", so a shorter re-export to the same file ends up with stale bytes after the closing ]. The SAF mirror already uses "wt" for this reason (SyncInterface.kt:605). Fix: openOutputStream(uri, "wt").

3. NotifyWorker drops the minutes of startOfDay. parseStartOfDayHour (workers/NotifyWorker.kt:134) keeps only the hour, so "04:30" becomes 4, while the widget and webui use 04:30. Between 04:00 and 04:30, alerts already query the new day and fire against totals that don't match what the app shows. The fired-key date also changes 30 minutes early. Fix: carry a LocalTime through logicalDayDate, with the logicalDate/logicalDayWindow helpers from #407.

4. Text typed into the address bar may be recorded as page URLs in Chrome, Edge, Samsung Internet and Opera (needs a device repro; privacy). The extractors at watcher/WebWatcher.kt:98, :136 and :140 read url_bar from the event source without ignoreFocused. Brave and the detected Chromium forks pass ignoreFocused = true "to avoid recording typed text" (#307). If typing fires content-changed events whose source includes the focused bar, each partial query becomes a short visit with url="how t". The device test only covers Brave. This changes what gets recorded, so Erik should decide on it.

5. A blob export can split an emoji across a 256K bridge chunk (medium confidence). sendText (WebUIFragment.kt:167-168) slices by UTF-16 code units. A surrogate pair that straddles a chunk boundary is split, and the halves likely reach Java as U+FFFD. Fix: don't end a chunk on a high surrogate.

Checked and found no defect: the usage-stats import cursors, replay and dedupe (read back from the DB, so a kill just replays and merges), timestamp precision, MediaWatcher flushes, the SAF mirror cleanup, and the JSON parse/error paths.

主要语言
Kotlin
星标
289
派生
67
平均合并
8 天 52 分钟
30 天内合并 PR
8

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

ActivityWatch/aw-android 的其他 Issue

查看 ActivityWatch/aw-android 的全部 Issue

相似的 Issue

更多 Kotlin Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。