Repository navigation
fix: Bluetooth-off status, GPS in background, sleep coach card timing, stopped ring clock (#136 #139 #140 #142) - #144
Open
foureight84 wants to merge 9 commits into
Open
foureight84 wants to merge 9 commits into
foureight84 wants to merge 9 commits into
Conversation
…d, stopped ring clock - #136: mark the link disconnected as soon as the phone's Bluetooth turns off (adapter-state receiver for every ring family, watchdog fallback), instead of showing "Connected" until it comes back. - #139: run the workout foreground service with the location type when the workout records GPS, so while-in-use location keeps flowing with the phone in a pocket. No background-location grant needed. - #140: don't write the sleep coach card while the Bedtime / quiet-hours window is still open (capped at 8 h), and rewrite it straight away when a later sync makes the night longer. The hypnogram now draws a sub-minute gap between records that the Awake and Records cards count. - #142: detect a YCBT ring whose clock has stopped from where it stamps its own copy of a spot reading, and offer a guided restart: power off (03 16 01, vendor appShutDown(1)), put it on the charger, reconnect.
- #142 detector: judge a pass only when it delivered HR/SpO2 history (a sleep-only pass no longer counts as a missing copy), pair each spot reading with its closest copy in the pass rather than the first sample in the window, clear on any copy short of the evidence threshold, and reset on Forget, on connecting another ring family, and after a restart. - #142 restart: powerOff() reports whether it queued a command; restartRing() returns SENT / NOT_CONNECTED / UNSUPPORTED; the walkthrough's state lives in TodayScreen so the charger step survives the warning clearing; the Restart button is hidden for rings that can't be powered off. - #140: draw the sub-minute gap ahead of the next record on a tied minute; skip the rewrite floor only for 15+ more minutes asleep; an open DND only counts as night if it started by the night's end plus an hour. - #139: remember a refused location type instead of retrying every refresh; accept GPS fixes up to 15 s old so batched screen-off fixes aren't dropped. - #136: clear the Bluetooth-off message when Bluetooth comes back on.
This was referenced Nov 13, 2026
RC feedback: the Bluetooth-off message only reached the pairing screen, so every other surface just read Disconnected. BLEState now carries bluetoothOff, set from the adapter at init (covers a launch with Bluetooth already off), the ACTION_STATE_CHANGED receiver, and re-synced each watchdog tick. The header pill, the Settings hero card and the Wearable card use it. Replaces the unused isBluetoothReady field.
English output is unchanged: values/strings.xml carries the original copy verbatim, and the existing unit tests pass without modification. - Composables use stringResource / pluralStringResource. Code without a Context goes through util/L10n, which in JVM tests reads the default values/strings.xml directly. - util/LocaleFormats picks date/time patterns from Android's best-pattern skeletons, falling back to the original pattern when java.time or SimpleDateFormat rejects the platform's one (zh-TW "Bh:mm" on Android 12/13). Patterns and formatters are cached per (skeleton, locale). - coach/context/CoachLanguage reads the coach_language resource, so the coach replies in the language the UI actually resolved. For English the directive is empty and prompts are byte-for-byte unchanged. Coach summary signatures carry the language, so a language switch regenerates cards. - Strings that would otherwise stick after a per-app language switch (tool progress labels, threshold units, the sleep no-data card) are resolved on read. - Coach chart colours also match a translation's own metric words.
- values-ru/strings.xml covers every string in values/strings.xml (except app_name), with Russian plural forms wherever a count precedes a noun. - coach_language = "Russian", so the coach replies in Russian when the app shows Russian. - res/xml/locales_config.xml enables the Android 13+ per-app language picker. - README.ru.md, linked from README.md. - Onboarding welcome tiles grow to fit a wrapped title instead of clipping it at a fixed height; the Russian titles surfaced this.
…lose sync race (#142, #103) RC feedback on #142: Doze wakeups at :57/:58 were skipped by the 5m + 75s margin before the ring's reading and dropped the whole 2h slot. - ScheduledSpo2Slots: set CONNECT_AND_SYNC_SECONDS = 30 (105s pre-reading budget in isClear), add 75s isClearToMeasure for the post-sync check, and add nextClear to retry 5 min after the conflicting reading. - ScheduledSpo2Worker: set isMeasuring = true at doWork() entry before Room reads so a concurrent RingSyncWorker yields GATT in shared Doze windows, re-check isClearToMeasure after startup sync, and schedule via min(nextClear, nextSlot) when skipped for ring proximity. - ScheduledSpo2SlotsTest: update pre-reading boundary assertions and cover isClearToMeasure, nextClear, midnight rollovers, and grid recovery.
This was referenced Nov 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #136, #139, #140, #142.
#136: "Connected" while the phone's Bluetooth is off
No
onConnectionStateChangearrives when the adapter goes down, and the watchdog skipped its probes while Bluetooth was off.RingBLEClientnow listens forACTION_STATE_CHANGEDfor every ring family (before this, only CRP did), marks the link disconnected and shows "Phone Bluetooth is off". The watchdog also catches a missed broadcast. Reconnecting when Bluetooth comes back works the same as before.#139: GPS route stops when the phone is in a pocket
The workout foreground service was
healthonly, so Android 10+ cut off "while using the app" location once the app was in the background. It now also runs aslocationwhen the workout records GPS, which needsFOREGROUND_SERVICE_LOCATIONand no background-location grant. The GPS filter also accepts fixes up to 15 s old, so fixes the phone delivers in batches with the screen off aren't dropped as stale.#140: Sleep
#142: Ring clock stops
There's no command to read the ring's clock, so PulseLoop watches the copy a YCBT ring logs of each spot reading it completed. A running clock stamps that copy when the measurement ends. A stopped clock stamps it at the last time we set, or the copy lands nowhere near our reading. Two such cases within 24 h show a card on Today with a guided restart: power off (
03 16 01, the vendor'sappShutDown(1), offered on every SmartHealth ring), put the ring on its charger, and PulseLoop reconnects and sets the time. The card clears on a healthy reading, a restart, Forget, or when a ring from another family connects. Each spot reading is judged only after a sync pass that delivered vitals history, and only against the closest copy in that pass.Not done: the weaker "no automatic HR for 2× the interval" hint. An unworn ring looks exactly the same.
Testing
./gradlew testDebugUnitTest: 1700 tests, 0 failures.CRPSyncEngineTestfails between 19:55 and 20:05 local time, becauseCRPDecoder.nearSleepDayRolloverreads the wall clock. That's pre-existing and unrelated to this PR.