fw/services/notifications: schedule Quiet Time boundaries with cron - #2099
Merged
Merged
Conversation
Lets a test of a cron client assert when its next boundary falls without reaching into the service's job list. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
The scheduled Quiet Time periods were driven by a new_timer armed for the number of seconds until the next boundary. That is a wall-clock event, so any time change (user adjustment, phone sync, DST, time zone) invalidated the delay, and the service compensated by rebuilding the timer from the clock change hook. It also encoded the weekday / weekend handover as a hand-computed "days until the other schedule starts" delay. Register cron jobs instead: a start and an end job per enabled schedule, masked to WDAY_WEEKDAYS / WDAY_WEEKENDS, plus a midnight job on Monday and Saturday for the handover between the two schedules. Cron recomputes the jobs itself when the clock changes, so the clock change hook only re-evaluates whether we are inside a period. Being inside a period is now computed directly from the current time rather than inferred from which boundary the timer was armed for. The unit test runs against the real cron service and keeps the same next-boundary expectations, now asserted through the service's next execute time; the private timer-id accessors are gone. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
jplexer
approved these changes
Sep 17, 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.
Scheduled Quiet Time was driven by a
new_timerarmed for "seconds until the next boundary", plus a clock-change hook that rebuilt the timer whenever the wall clock moved. Those are wall-clock events, which is exactly whatcronexists for.This replaces the timer with cron jobs: a start and an end job per enabled schedule (masked to
WDAY_WEEKDAYS/WDAY_WEEKENDS) and a midnight job on Monday and Saturday for the weekday ↔ weekend handover. Cron recomputes execute times on clock/DST/timezone changes itself, sodo_not_disturb_handle_clock_change()now only re-evaluates whether we are inside a period, which is computed directly from the current time rather than inferred from which boundary the timer had been armed for.The behaviour is unchanged:
test_do_not_disturbnow runs against the real cron service and keeps every next-boundary expectation from the old test (17 cases inweekday_weekend_schedule), asserted through a new UNITTEST-onlycron_service_get_next_execute_time(). A new case exercises the cron firing path, including the "manual DND is cleared when a scheduled period ends" rule.Follow-up to the same change in the day/night backlight branch (#2092).
Verified:
test_do_not_disturb,test_cron,test_alarm*,test_activity,test_light,test_timeline_peekpass; obelix and asterix firmware build.🤖 Generated with Claude Code