Repository navigation
feat: Keep Android rides running in the background with live notification controls - #120
ThoreKoritzius wants to merge 17 commits into
Conversation
RalfLeonFasler
left a comment
There was a problem hiding this comment.
Thanks a lot for this, Thore! Keeping the ride alive with the screen off is a big step for the app, and the notification looks great. Mirroring the trainer logic natively is fine; I checked the FTMS parsing, ERG ramp and virtual-shifting formula against the web client and they match.
One thing I'd like to see before we merge, and one optional note:
-
Drafting in the background (please add). With virtual shifting on, the web client lowers the air drag by the draft saving (
dragFactorfromdraftInfo()inride/draft.js, up to 30 % from 2–6.5 m behind a rider in the same lane).RideEngine.command()always uses the fullcda, so as soon as the screen goes off, riding in a group suddenly gets harder on the trainer. The service already receives thestatemessages with all riders, so it could compute the same draft from them (ideally with a shared test fixture so the two stay in sync). See the inline comment. -
Rider profiles (#115), not a blocker. The native journal is one file per device, and
mergeNativeRecoveryuses the journal's ride when the current rider has no saved one. Once several riders share a device (#115), rider B could be offered rider A's unfinished ride after a crash. If you're in there anyway, storing the rider/profile id in the snapshot and checking it on recovery would make this work with #115 right away. Otherwise we can do it afterwards.
|
@RalfLeonFasler Thanks for the review! Both points are addressed in 0e95831:
I also merged current Validation: I've replied to and resolved both inline threads. Ready for another look when you have time. |
Why
Switching apps or locking the phone during an indoor ride must not leave trainer control, telemetry and recording dependent on WebView rendering. This adds Android background riding, live notification controls and clearer Bluetooth connection help.
Follows the merged #118 and targets
main. Android version code stays 3, since that release is not published yet.Changes
sdkmanagersetup using the runner's SDK, within the repository action policy.Screenshots
Collapsed and expanded notification, captured on the Android emulator with synthetic trainer input:
Validation
make checkpasses locally, including 1,837 client tests and the Rust suites.lintDebug, APK and release bundle builds pass locally.make checkand Android native tests/lint/build pass locally after merging the rider-profile changes from main. GitHub CI is rerunning for the merge commit.Rollout notes
Deploy the updated web client alongside the Android shell to enable the complete feature. Older shells retain their existing foreground behavior. Force-stop, reboot or process termination stop live riding; the journal recovers saved samples on the next launch. This implementation is Android-specific.
Google Play's connected-device foreground-service declaration must describe the user-started trainer session and notification stop action before rollout. No ride is uploaded by the notification's End/save action.
Recovery now checks the snapshot’s local
profileId, including when the browser autosave is empty. Legacy journals belong tomain. With #115 now on main, snapshot creation and recovery use its roster-backedactiveRider()accessor. Pending recovery reads are guarded by rider generation, and delayed autosave cleanup stays pinned to the rider who left.