Commit 7174dc2
fix: declare expiryClearJobs before pauseExpiryFlows in AlertManager (#221)
AlertManager constructor crashed with NullPointerException on cold start
whenever an alert pause was already in prefs. Took StrimmaService down with
it on every reboot, install, or memory-pressure rebind — and ActivityManager
backs off restarts up to 1 hour, effectively killing CGM coverage until the
user re-launches the app.
Root cause: `pauseExpiryFlows`'s initializer calls `scheduleExpiryClear` for
any active pause, and `scheduleExpiryClear` touches `expiryClearJobs` — but
`expiryClearJobs` was declared *after* `pauseExpiryFlows`. Kotlin's top-down
property init meant `expiryClearJobs` was null at the moment of first use.
Fix: move `expiryClearJobs` declaration above `pauseExpiryFlows`, and add a
construction-time regression test (`AlertManagerInitOrderTest`) that
pre-populates an active pause before constructing the manager. The existing
`AlertManagerTest` @before clears prefs *after* construction, which is why
the regression slipped past unit tests.
Introduced in #216 (Pause icon fix + configurable notification action,
2026-05-10). Shipped in 1.3.0-rc.1.
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>1 parent 758a720 commit 7174dc2
2 files changed
Lines changed: 76 additions & 2 deletions
File tree
- app/src
- main/java/com/psjostrom/strimma/notification
- test/java/com/psjostrom/strimma/notification
Lines changed: 8 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
553 | 553 | | |
554 | 554 | | |
555 | 555 | | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
556 | 564 | | |
557 | 565 | | |
558 | 566 | | |
| |||
569 | 577 | | |
570 | 578 | | |
571 | 579 | | |
572 | | - | |
573 | | - | |
574 | 580 | | |
575 | 581 | | |
576 | 582 | | |
| |||
Lines changed: 68 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 | + | |
0 commit comments