fix: keep the scan's foreground service inside Android's start budget

ScanController called stopService() from a Dispatchers.Default coroutine right
after startForegroundService(), so a scan that finished at once or a Cancel tap
could beat the pending foreground start on the main thread. ScanService then
never reached startForeground() and Android killed the process a few seconds
later with
RemoteServiceException$ForegroundServiceDidNotStartInTimeException - a stack
with no app frames.

- ScanService enters the foreground in onCreate() and at the top of every
  onStartCommand(), before the Cancel early-return.
- A refused startForeground() (start not allowed, missing service type or
  permission, rejected notification) is logged instead of crashing, and a
  notification error can no longer kill the state collector.
- The service stops itself when it observes scanning == false; nothing outside
  it calls stopService() any more.
- New Robolectric ScanServiceTest covers onCreate, the idle and cancel paths, a
  failing startForeground() and the Android 15 onTimeout path.
- Version 1.1.2 / versionCode 7: versionCode 6 (1.1.1) is already on a Play
  track. CHANGELOG, AGENTS.md, codemap, ROADMAP and the release checklist
  (1.1.2 artefact record and paste-ready notes) are updated.
This commit is contained in:
2026-11-09 00:25:56 +01:00
parent 4739069737
commit 6d031082a3
9 changed files with 336 additions and 57 deletions
+4 -3
View File
@@ -48,9 +48,10 @@ Legend: ✅ done · 🚧 in progress · ⏳ not started · 💡 candidate (propo
## Suggested order
1. ✅ **Done** — the scan-stall hardening and the `BoundedCall` fix shipped as **1.0.1**
(`versionCode` 2); **1.0.2** (`versionCode` 3) was the last paid build. The next upload is
**1.1.1** (`versionCode` 6), the fixed freemium build, which also needs the Play Console changes in
[MONETIZATION](MONETIZATION.md). Only the on-device re-check of the 5,363-photo scan remains.
(`versionCode` 2); **1.0.2** (`versionCode` 3) was the last paid build. The freemium
listing went out as **1.1.1** (`versionCode` 6); the current upload is **1.1.2**
(`versionCode` 7), the `ForegroundServiceDidNotStartInTime` fix, which still needs the
Play Console changes in [MONETIZATION](MONETIZATION.md).
2. Finish the Play Console paperwork and roll out through **internal → closed → production**.
3. ✅ **Done** — **M10 store assets**: the icon and feature graphic are generated from the
app's own vectors, the screenshot normaliser enforces Play's 2:1 limit, the listing copy is