mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2026-07-31 07:44:24 +02:00
Two robustness fixes for the event-triggered Health Connect sync. Debounce: an activity fetch can broadcast ACTION_NEW_DATA several times in quick succession - multi-phase fetches and some chatty drivers emit the finish signal mid-fetch - and each broadcast immediately enqueued a sync. A sync that runs while the fetch is still in progress reads a half-populated database and can drop or duplicate records for the in-flight range. Enqueue the per-device worker with a short initial delay and ExistingWorkPolicy.REPLACE, so a burst of broadcasts collapses into one sync that runs once the fetch has settled. The per-device work name is unchanged (devices debounce independently) and the manual/debug sync paths use separate work names, so "Sync now" is unaffected. Resting heart rate: the platform RestingHeartRateRecord rejects bpm < 1, but the filter allowed 0..300, so a 0 bpm sample threw IllegalArgumentException and aborted that data type's slice. Filter 1..300 instead, matching the regular HeartRate syncer. Update the existing boundary test accordingly.