MDA-12 — Delegate app — location sampling during tours
Policy-driven sampling only while a tour is in progress, batching, battery-friendly settings, foreground-service notice on Android.
| Field | Details |
|---|---|
| Task code | MDA-12 |
| Phase | P1 — V1 build & integration |
| Product scope | V1 |
| Status | Planned |
| Start | Tue 15 Dec 2026 |
| Due | Tue 15 Dec 2026 |
| Responsible | Imad — Mobile developer (Flutter) |
| Co-responsible | — |
| Effort | 0.75 person-day(s) planned · 3 from scratch · size S |
| Area · app | Delegate app · mobile |
| Depends on | MOB-10 |
| Unblocks | MOB-12 |
| Milestones | Mobile apps V1 feature-complete |
Summary
Policy-driven sampling only while a tour is in progress, batching, battery-friendly settings, foreground-service notice on Android.
Description
The back-office follows delegates on tour live (FLD-13), but positions may only be collected while a tour is in progress, at the policy's frequency, transparently and with consent (FLD-15, SEC-07). Scope: policy-driven sampling that starts when a tour becomes IN_PROGRESS and stops on suspend, close or sign-out; every 5 min or 200 m (values from the server policy); an Android foreground service with a persistent notification; local buffering in drift and batched upload through POST /delegate/location-pings (sync.locationPings, Idempotency-Key per batch, occurredAt per ping); battery-friendly settings. It needs the sampling policy fields from Anis (SRV-21/SRV-23) and the consent flow from MOB-10. The back-office live map (DSH) and MOB-13's battery measurements depend on it.
Subtasks
| # | Subtask | Owner |
|---|---|---|
| 1 | SamplingController reacting to TourStatus: start on IN_PROGRESS, stop on SUSPENDED, COMPLETED, CANCELLED, sign-out or consent withdrawal; resumes on relaunch if the tour is still IN_PROGRESS | Imad |
| 2 | Android foreground service (geolocator ForegroundNotificationConfig, foregroundServiceType location for Android 14) with notification « Tournée en cours — votre position est partagée avec HOCO » | Imad |
| 3 | Sampling rule: a ping every policy.intervalMinutes (default 5) or after policy.distanceMeters (default 200), balanced accuracy, accuracy and mock flag recorded | Imad |
| 4 | location_pings drift table (id, lat, lng, accuracy, speed, occurredAt, tourId, sent) with local pruning after acknowledgment and never beyond 72 h | Imad |
| 5 | Batch uploader: POST /delegate/location-pings every 10 min or 20 pings when online, Idempotency-Key per batch, retry on failure | Imad |
| 6 | Battery and OEM handling: guide to exclude the app from battery optimisation (Xiaomi, Oppo, Samsung), pause sampling in battery saver only if the policy allows | Imad |
| 7 | Battery-drain measurement script (adb dumpsys batterystats) for a 4-hour simulated tour | Imad |
Deliverables
- packages/hoco_maps/lib/src/sampling/ (controller, foreground service config)
- packages/hoco_offline location_pings table and batch uploader
- Battery measurement notes for MOB-13
Acceptance criteria
- No position is recorded or sent when no tour is IN_PROGRESS, including while suspended (FLD-15, SEC-07)
- During a tour, pings arrive at the configured interval or distance; changing the policy on the server changes the behaviour without a release
- The persistent notification is visible for the whole time sampling runs
- Pings recorded offline are uploaded on reconnection with their original occurredAt and no duplicates
- Battery drain over a 4-hour tour stays within the target agreed with Anis (proposed ≤ 3 % per hour on a mid-range phone)
Requirements covered
| Requirement | Title | Release |
|---|---|---|
| FLD-13 | Live follow-up in the back-office: delegates on tour, positions, visit progress | V1 |
| FLD-15 | Location policy: consent, frequency, tolerance and retention configurable and transparent | V1 |
| SEC-07 | Geolocation consent and transparency for delegates | V1 |
API surface
| Endpoint group | Operations |
|---|---|
| Offline sync & location | 3 |
Test measures
- Unit tests of the SamplingController state machine against TourStatus transitions
- Device test with a simulated route (mock location app in a debug build) verifying interval/distance rules
- Battery drain measurement on two mid-range Android phones
Risks
- OEM task killers stop the foreground service — onboarding tip for battery exemptions and a check-in-time ping as a fallback
- Play Store foreground-service declaration review — keep sampling strictly tied to the visible tour feature and record the demo video early (MOB-14)
KPI
- Delivered by Tue 15 Dec 2026 within 0.75 person-day(s).
- Every acceptance criterion above demonstrated before hand-off; linked requirements' acceptance criteria pass.
- Zero open critical defects, permission gaps or data-integrity regressions at sign-off.
Generated from content/plan/tasks.json by scripts/generate-team-tasks.mjs. Dates are computed by the scheduler (Sunday–Thursday weeks, holidays excluded) — change the plan, not this page.
MDA-11 — Delegate app — messages, settings & sync centre
Announcements and notifications, settings (language, notifications, location transparency), sync centre with pending/error items and retry.
MOB-12 — Staging integration — real API, edge states, performance
Switch both apps from the mock to staging, walk every flow, fix contract mismatches, cold-start and list performance on a mid-range Android.