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

オープン
#409 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
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分
マージ済み PR(30日)
8

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

ActivityWatch/aw-android のほかの issue

ActivityWatch/aw-android の issue をすべて見る

似ている issue

Kotlin の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。