Foreground location service: permissions, notification, battery exemption #15

Open
opened 2026-08-31 17:14:39 +02:00 by robert · 0 comments
robert commented 2026-08-31 17:14:39 +02:00 (Migrated from git.butzei.de)

Goal

Position updates must survive a whole ride with the screen off. This is where most Android bike apps fail.

Acceptance criteria

  • Foreground service with FOREGROUND_SERVICE_LOCATION and a persistent notification showing ride status
  • ACCESS_FINE_LOCATION requested with a clear rationale
  • Battery-optimisation exemption prompted for, with an explanation of why
  • Partial wake lock held only while a ride is running
  • Service restarts and restores state if the system kills it
  • Verified over a 2 hour ride with the screen off

Files

  • companion/.../ride/RideService.kt

Update — 2026-08-31: battery target and minimum Android version

  • The phone must lose no more than 40% of its battery over a 4-hour ride with GPS at 1 Hz and
    the screen off (NFR-B2). Measure it; if the budget is missed, reduce the GPS rate or the map frame
    rate before giving up on the target.
  • Minimum supported Android is 12 / API 31 (NFR-C2), so only the modern
    BLUETOOTH_SCAN / BLUETOOTH_CONNECT permission model is needed - no legacy
    location-permission-for-BLE workaround. Foreground service types are declared but not yet enforced
    at this API level; declare them correctly anyway.
## Goal Position updates must survive a whole ride with the screen off. This is where most Android bike apps fail. ## Acceptance criteria - [ ] Foreground service with `FOREGROUND_SERVICE_LOCATION` and a persistent notification showing ride status - [ ] `ACCESS_FINE_LOCATION` requested with a clear rationale - [ ] Battery-optimisation exemption prompted for, with an explanation of why - [ ] Partial wake lock held only while a ride is running - [ ] Service restarts and restores state if the system kills it - [ ] Verified over a 2 hour ride with the screen off ## Files - `companion/.../ride/RideService.kt` ## Update — 2026-08-31: battery target and minimum Android version - **The phone must lose no more than 40% of its battery over a 4-hour ride** with GPS at 1 Hz and the screen off (NFR-B2). Measure it; if the budget is missed, reduce the GPS rate or the map frame rate before giving up on the target. - **Minimum supported Android is 12 / API 31** (NFR-C2), so only the modern `BLUETOOTH_SCAN` / `BLUETOOTH_CONNECT` permission model is needed - no legacy location-permission-for-BLE workaround. Foreground service types are declared but not yet enforced at this API level; declare them correctly anyway.
Sign in to join this conversation.
No description provided.