Commit 8b1c1b5
fix: refresh foreground notification every minute, not only on stale flips (#223)
* fix: refresh foreground notification every minute, not only on stale flips
The stale-check loop previously only called updateNotification() when the
stale-state flipped or workout mode was active:
if (isStale != wasStale || workoutCountdownActive || workoutModeOn) {
updateNotification()
}
This left the notification's "Xm" since-text (and the IOB / alert-pause /
workout-elapsed countdowns rendered in composeReadingText) frozen at
whatever value they had at the moment of the last reading. The most visible
symptom: when CamAPS stops posting fresh values (sensor disconnect,
"Attempting" reposts that the parser correctly drops), the notification
keeps showing "0m" against the last good value until either a new reading
arrives or the 10-min stale threshold trips. The user gets a false sense
that data is fresh when it isn't.
Drop the gate — call updateNotification() on every tick (every 60 s). The
work is one DB read + one IOB calc + one notification rebuild; cheap
enough at this cadence and the only path that keeps the displayed
counters honest. The original gate's stated reason (avoid rebuilding
during stable readings) doesn't justify the silent-stale display in a
medical app.
Also drop the now-unused `wasStale` field.
Verified on device: with no new readings for >1 min, the notification
"Xm" advances correctly each minute.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* fix: refresh widget every minute alongside notification, add render-test
The 60s tick in startStaleCheckLoop was rebuilding the foreground
notification but not the home-screen widget. The widget's "Xm" / "now"
freshness label is computed from System.currentTimeMillis() - reading.ts
(StrimmaWidget.kt:120) but updateWidgets() was only called from
onNewReading — between readings the widget froze at whatever counter
value it had at the last reading-arrival, mirroring the notification bug
that #223 fixes. Same medical-safety class (a glanceable surface lying
about freshness).
Adds NotificationHelperRenderTest pinning the rendering contract that
the loop depends on: each call to buildNotification produces a tv_delta
text reflecting the current elapsed minutes from reading.ts (0m / 5m /
9m). If a future refactor breaks the rendering math or someone
re-introduces a gate around the per-tick updateNotification call, this
catches the rendering-side half of the regression.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>1 parent 486438b commit 8b1c1b5
2 files changed
Lines changed: 82 additions & 14 deletions
File tree
- app/src
- main/java/com/psjostrom/strimma/service
- test/java/com/psjostrom/strimma/notification
Lines changed: 11 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
107 | | - | |
108 | | - | |
109 | 107 | | |
110 | 108 | | |
111 | 109 | | |
| |||
269 | 267 | | |
270 | 268 | | |
271 | 269 | | |
272 | | - | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
277 | | - | |
278 | | - | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | | - | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
283 | 281 | | |
284 | 282 | | |
285 | 283 | | |
| |||
448 | 446 | | |
449 | 447 | | |
450 | 448 | | |
451 | | - | |
452 | 449 | | |
453 | 450 | | |
454 | 451 | | |
| |||
Lines changed: 71 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
0 commit comments