activity: re-sync charging gate so step tracking can't wedge off#1663
activity: re-sync charging gate so step tracking can't wedge off#1663Coral-coder wants to merge 2 commits into
Conversation
Step tracking is gated by enabled_charging_state (steps are disabled while plugged in), which is only ever updated from battery state-change events. If such an event is missed -- as happened when the battery service was sampling too sparsely -- the gate stays stuck "as if plugged in" and step counting stays off until reboot. Add an always-on once-a-minute timer (independent of the tracking-gated cron, which is torn down while tracking is stopped) that re-derives the charging gate from the live battery state and re-kicks a start that never happened. prv_set_enable_cb is idempotent, so the re-kick is safe. Signed-off-by: Ara Michelle <coral-coder@proton.me> (cherry picked from commit 5485b83)
activity_init() now registers a regular-timer minute callback for the charging-gate re-sync. The activity test links the real regular_timer service but never initialized it, so the call asserted on its uninitialized callback-list semaphore. Initialize the service once in the test setup (it asserts on re-init, hence the guard) so the registration succeeds. Signed-off-by: Ara Michelle <coral-coder@proton.me> (cherry picked from commit aff5eaf)
|
nice catch! |
It seems like this is papering over a bug (missed events). Can you confirm this is true? What is the root cause of this problem? |
|
In my case, I had a bad charge cable and it kept disconnecting and connecting rapidly, it wedged off the step counter when I disconnected. might be an edge case, but it fixed the issue. |
Before merging this I'd like to get more details, seems like the real problem is the event missed for some unknown reason. Adding logs and using your bad cable should shed some light. |
|
alright, will take me a bit to find that cable again... I think I threw it out... |
|
Unable to find cable. close it if it doesn't seem like a fix for an edge case I guess.. |
Problem
Step tracking is gated by
enabled_charging_state(tracking is disabled while plugged in). That flag is only ever updated from battery state-change events. If a charger-disconnect event is ever missed — we hit this in the field when battery updates were delayed — the gate stays stuck "as if plugged in" and step counting silently stays off until reboot. There is no recovery path: the tracking-gated cron is torn down while tracking is stopped, so nothing ever re-evaluates the gate.Fix
Add an always-on once-a-minute
regular_timercallback (registered inactivity_init, independent of the tracking-gated machinery) that:battery_is_usb_connected()state, andshould_be_started && !startedwhile allowed).Re-evaluation goes through the existing
prv_handle_activity_enabled_change()path on the system task, andprv_set_enable_cbis idempotent, so a redundant re-kick is a no-op. In the steady state the callback compares one bool and returns. Bigboards keep their existing behavior (CONFIG_IS_BIGBOARDexcluded, same as the charger event handler).Testing
waf testsuite passes.Second commit initializes
regular_timerin the activity test harness so the new registration is exercised.