feat(alarms): choose what the volume buttons do while ringing
A new setting in Settings > Alarms: while the ring screen shows, the volume buttons change the volume (the default, and what they did before), snooze, dismiss, or do nothing. It is app-wide, stored next to the clock defaults, and included in the backup; a backup without it restores "change the volume". A press is made without looking, so VolumeButtonPolicy keeps it from ending an alarm more finally than the ring screen would. Dismiss with a dismiss challenge set snoozes instead, so the challenge still stands. With no snoozes left, Snooze (and Dismiss behind a challenge) falls back to changing the volume, never to the engine's refused-snooze path, which dismisses. The key's snooze also asks the engine to keep ringing if the limit turns out to be reached after all (AlarmEngine.snooze's new dismissIfRefused). The ring screen decides whether a press is its own on key down and keeps that for the release, leaves the keys alone once another alarm has taken over the ring, and ignores a second snooze or dismiss while the first is still running. Only the ring screen handles the keys. While the ring is a heads-up over another app, a background app gets no key events, and the one way around that does not hold up: a remote-playback MediaSession whose VolumeProvider takes the keys. On Android 13 and later MediaSessionRecord.canHandleVolumeKey refuses such a session from an app without a MediaRouter2 routing session, which Clockula's would be, so on current Pixels the keys never reach it. Where it does work, it loses to whatever app is in front or played last, shows a cast-volume slider and a phantom media player, and takes media buttons while the alarm rings. AOSP DeskClock and BlackyHawky's Clock also handle the keys in their alarm activity only. ARCHITECTURE.md records the limitation. Fixes #18
This commit is contained in:
1 parent
3f431a7f32
commit
94f09e9e5a
22 files changed
+598
-20
No files matched your search
+5
-1
@@ -136,6 +136,7 @@ device or after a reboot (`docs/PLAN.md` §5). Every imported timer lands
|
||||
"default_timer_ringtone_uri": null,
|
||||
"default_dismiss_challenge": "NONE",
|
||||
"home_zone_id": null,
|
||||
"volume_buttons_while_ringing": "CONTROL_VOLUME",
|
||||
"timer_presets": [60000, 120000, 180000, 300000, 600000, 900000, 1800000, 3600000]
|
||||
}
|
||||
```
|
||||
@@ -143,7 +144,10 @@ device or after a reboot (`docs/PLAN.md` §5). Every imported timer lands
|
||||
Field names mirror `ClockPrefs`'/`SettingsPrefs`' own on-disk keys. Older
|
||||
files may also carry `default_timer_duration_millis`, from a default timer
|
||||
length setting that has since been removed; it is ignored on import like any
|
||||
other unknown field. Every
|
||||
other unknown field. `volume_buttons_while_ringing` is one of
|
||||
`CONTROL_VOLUME`/`SNOOZE`/`DISMISS`/`NOTHING`; a file without it (any backup made
|
||||
before the setting existed) or with a name this version does not know restores
|
||||
`CONTROL_VOLUME`, the behaviour that file's device had. Every
|
||||
numeric/duration value is clamped on *apply* using the same ranges and encoding
|
||||
as the existing preference setters, never on parse.
|
||||
|
||||
|
||||
Reference in new issue
Block a user