fix: play through the alarm stream so the ring cuts through DND
DND silences the media stream by default, so playback on STREAM_MUSIC was invisible during DND even though the notification showed. Switch to STREAM_ALARM + USAGE_ALARM, which DND exempts by default, and restore/force the alarm stream volume instead of media.
This commit is contained in:
parent
63791b9f5e
commit
5e5d53ab9b
2 changed files with 20 additions and 16 deletions
13
README.md
13
README.md
|
|
@ -49,11 +49,14 @@ refuse to play any sound.** This is enforced at two points:
|
|||
Only after the user flips that toggle will a trigger actually ring.
|
||||
|
||||
When access **is** granted, `RingService`:
|
||||
- saves the current music volume,
|
||||
- forces `AudioManager.STREAM_MUSIC` to max,
|
||||
- requests `AUDIOFOCUS_GAIN_TRANSIENT` using `USAGE_NOTIFICATION_RINGTONE` and
|
||||
sets `AudioManager.mode = MODE_RINGTONE` so the sound cuts through DND,
|
||||
- plays for 30 s, then restores the volume and abandons focus.
|
||||
- saves the current **alarm-stream** volume,
|
||||
- forces `AudioManager.STREAM_ALARM` to max,
|
||||
- requests `AUDIOFOCUS_GAIN_TRANSIENT` using `AudioAttributes.USAGE_ALARM`,
|
||||
- plays on the **alarm stream** — the one stream Do Not Disturb does **not**
|
||||
silence by default (media/music *is* silenced), which is what lets the ring
|
||||
cut through DND,
|
||||
- plays for the configured number of seconds, then restores the volume and
|
||||
abandons focus.
|
||||
|
||||
---
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue