feat(sync): add sync health watchdog and stall alerts (#15501)
TH
1d ago+484+484+012345678901234567890123456789-10-10-01234567890123456789
What does this PR do?
Implements an automated device synchronization health watchdog (SyncHealthWatchdog) and user notification alert system to prevent silent multi-day recording loss on Android (#15501).
Problem
Users on Android running Omi with paired hardware devices reported discovering multi-day gaps in recordings with no warning that sync had stopped working or disconnected silently. When the background connection or audio transport stalled, the app gave no indication or notification, leading to permanent loss of unretrieved audio recordings.
Solution
SyncHealthWatchdogsingleton service (app/lib/services/sync_health_watchdog.dart):- Monitors elapsed time since last sync, BLE audio ingestion, or batch recording finalization.
- Evaluates device sync health against a 4-hour stall threshold.
- Dispatches a local notification (
Omi Not Syncing: No recordings have synced from your Omi in over X hours...) with deep-link navigation to/home. - Protects users with a 6-hour notification cooldown and quiet night-hours suppression (22:00 to 08:00).
- Throttles in-memory timestamps to avoid disk I/O thrashing during continuous audio capture.
- Activity Recording Hooks:
DeviceProvider: Starts/stops watchdog lifecycle, updates sync timestamp on device connection, and checks health on disconnection.CaptureController: Records activity on incoming BLE audio packets and finalized batch recordings.LocalRecordingsProvider: Records activity when local recordings are successfully uploaded.
- UI Integration:
DeviceSettings: Exposes a user toggle (Sync Health Alerts) with an active stalled badge and warning text when stalled.HomePage: Sync indicator button switches to an amber disconnected cloud icon (Icons.cloud_off_rounded) when sync has stalled.
- Unit Tests:
- Comprehensive unit test suite in
app/test/unit/sync_health_watchdog_test.dartverifying all 9 gate, cooldown, quiet-hours, preference toggle, and throttle conditions.
- Comprehensive unit test suite in
Line-Count-Exception: app/lib/services/capture/capture_controller.dart | 3124 -> 3127 | record ble audio sync watchdog activity
Closes #15501
Failure-Class: none
PayPal: rwilcox413@gmail.com