Context
Came up while discussing the Android permission-diagnostic work in #282/#284: those four checks (full-screen intent, exact-alarm scheduling, battery-optimization exemption, notifications) are all Android-specific and correctly no-op on desktop (plugins/alarm-manager/src/desktop.rs, plugins/os-prefs/src/desktop.rs -- check_* always return Ok(true), open_* are no-ops, and the frontend gates the whole diagnostic behind isAndroid in Settings.tsx so these never even get called there). None of that needed a desktop equivalent -- but looking at the actual desktop scheduler while answering "does macOS/Windows need something similar" surfaced a different, unrelated gap worth tracking.
What was found
AlarmManager::schedule_internal (plugins/alarm-manager/src/desktop.rs) is a plain tokio::spawn task that computes a delay and calls sleep_until. There's no integration with either platform's OS-level wake-from-sleep mechanism:
- Windows:
SetWaitableTimerEx with the WAKE_SYSTEM flag (or the Task Scheduler equivalent) is the sanctioned way to have the OS actually wake a sleeping machine at a specific time.
- macOS: power-assertion APIs (
IOPMAssertionCreateWithName / pmset-adjacent mechanisms) are the equivalent.
Without either, it's unclear what actually happens if the desktop/laptop is asleep when a scheduled alarm's trigger time arrives -- does it fire late on wake, or not until something else wakes the machine? This hasn't been tested; sleep_until's behaviour across an OS suspend/resume cycle wasn't verified as part of this investigation, just flagged as untested.
Why it matters
For a phone, this is a non-issue -- AlarmManager.setAlarmClock (Android) already guarantees a Doze-mode wake. For desktop, if Threshold is meant to be a serious "this will wake you up" surface rather than just a convenience mirror of the phone app, a laptop that's asleep at 7am with the lid closed is exactly the scenario that needs to work.
Suggested next step
- Verify actual behaviour empirically on both platforms: schedule an alarm, put the machine to sleep, and observe what happens at/after the trigger time.
- If it doesn't fire reliably, look at wiring up the platform-specific wake-timer APIs above from
desktop.rs's scheduler.
Not scoped or estimated -- this is a "worth investigating" flag, not a confirmed bug report.
Reference
Discussed while working on #282/#284: #282
Context
Came up while discussing the Android permission-diagnostic work in #282/#284: those four checks (full-screen intent, exact-alarm scheduling, battery-optimization exemption, notifications) are all Android-specific and correctly no-op on desktop (
plugins/alarm-manager/src/desktop.rs,plugins/os-prefs/src/desktop.rs--check_*always returnOk(true),open_*are no-ops, and the frontend gates the whole diagnostic behindisAndroidinSettings.tsxso these never even get called there). None of that needed a desktop equivalent -- but looking at the actual desktop scheduler while answering "does macOS/Windows need something similar" surfaced a different, unrelated gap worth tracking.What was found
AlarmManager::schedule_internal(plugins/alarm-manager/src/desktop.rs) is a plaintokio::spawntask that computes a delay and callssleep_until. There's no integration with either platform's OS-level wake-from-sleep mechanism:SetWaitableTimerExwith theWAKE_SYSTEMflag (or the Task Scheduler equivalent) is the sanctioned way to have the OS actually wake a sleeping machine at a specific time.IOPMAssertionCreateWithName/pmset-adjacent mechanisms) are the equivalent.Without either, it's unclear what actually happens if the desktop/laptop is asleep when a scheduled alarm's trigger time arrives -- does it fire late on wake, or not until something else wakes the machine? This hasn't been tested;
sleep_until's behaviour across an OS suspend/resume cycle wasn't verified as part of this investigation, just flagged as untested.Why it matters
For a phone, this is a non-issue --
AlarmManager.setAlarmClock(Android) already guarantees a Doze-mode wake. For desktop, if Threshold is meant to be a serious "this will wake you up" surface rather than just a convenience mirror of the phone app, a laptop that's asleep at 7am with the lid closed is exactly the scenario that needs to work.Suggested next step
desktop.rs's scheduler.Not scoped or estimated -- this is a "worth investigating" flag, not a confirmed bug report.
Reference
Discussed while working on #282/#284: #282