Package com.aurelienpierre.sioul
Class PauseMode
java.lang.Object
com.aurelienpierre.sioul.PauseMode
The phone's do-not-disturb during Sioul's pauses and for its own
do-not-disturb (crates/sioul-app/src/dnd.rs, docs/android.md "Pauses"): a
mode of Sioul's own for each, an AutomaticZenRule named "Pause" / "En
pause", "Free time" / "Temps libre" or "Do not disturb (Sioul)",
letting through what the matrix of what reaches you lets through then, as
far as Android can say it (sioul_core::attention::Silence, docs/attention.md
ยง3.3): calls and messages from nobody, starred contacts, contacts or
anyone; a second call within 15 minutes; the conversations marked
important in Android (Android 11 and later); alarms; the sound of what the
person plays. Sioul's dose reminders and an event's alarms, through
channels of their own that pass it. Turned on and off with
setAutomaticZenRuleState: the person's own do-not-disturb, and every other
mode, is never touched; the system combines them, the strictest winning.
Needs "Do Not Disturb access" (Modes access from Android 15), which the
person gives in Android's settings; without it, nothing is done and Rust
says so. Also the tile and the shortcut's press (PauseOpener, PauseTile).
Both ways (docs/do-not-disturb.md): before each change of its own, Sioul
notes until when it settles (`changing_until`), so that DndReceiver never
takes it for the person's; a mode is recorded on before Android is asked to
turn it on. A switch "on" taken from the phone's own do-not-disturb adds no
mode of Sioul's over it (`stack` false:
held.<kind>, its channels that
pass still used). Sioul's going off turns the phone's own off too, up to
Android 14 (`quiet-off`).
Rust asks through call(verb, json) (android/main.cpp), and is answered in JSON.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final classWhat one of Sioul's modes lets through, as Rust asks it (dnd.rs's Ask, from the matrix: sioul_core::attention::Silence): who may call and who may write ("none", "starred", "contacts", "anyone"), a second call within 15 minutes, the conversations marked important in Android, alarms, the doses' and an event's alarms' channels. -
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final StringAn event's alarms while one of Sioul's modes lets them through: it passes do-not-disturb (EventAlarms).(package private) static final StringUntil when Sioul's own change settles (SystemClock.elapsedRealtime): DndReceiver looks again after.(package private) static final StringThe dose reminders' channel while a pause lets them through: it passes do-not-disturb.private static final Stringprivate static final Stringprivate static final String[]Sioul's modes: the two pauses, and its do-not-disturb on every device.(package private) static final StringNew mail's channel that passes, for someone Always through while one of Sioul's modes is on (MailNotes).private static final longA press older than this is not taken: Sioul did not come up meanwhile.private static final String(package private) static final StringThe phone's do-not-disturb as DndReceiver last saw it: on or off.private static final longHow long Sioul's own change of a mode takes to settle.(package private) static final StringSioul's do-not-disturb holds on this phone, as Rust said at its last apply (the tile, DndReceiver).private static final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static booleanaccessGranted(Context context) (package private) static StringalarmsChannelNow(Context context) The channel an event's alarm goes to now (EventAlarms): the one that passes while every mode on lets an event's alarms through, the usual "An event's alarms" otherwise.(package private) static StringRust's question (android/main.cpp): "can", "enter", "leave", "pressed", "open".private static JSONObjectprivate static StringchannelNow(Context context, String flag, String passing, String usual) private static UriconditionId(Context context, String kind) Sioul's own address for a pause's mode: condition://com.aurelienpierre.sioul/pause.(package private) static StringA change heard by DndReceiver, decided (DndHeard.decide(boolean, java.util.Map<java.lang.String, ?>, java.lang.String, int, java.lang.String, int, int, long)) from what Android has now and Sioul's record; the phone's state noted as seen, unless the decision waits for Sioul's own change to settle.(package private) static StringdosesChannelNow(Context context) The channel a dose reminder goes to now (DoseAlarms): the pauses' own while every mode on lets the doses through, the usual one otherwise (a mode that holds them, or none).private static JSONObjectenter(Context context, JSONObject asked) The pause's mode on, made or brought up to date first: {kind, name, trigger, calls, messages, repeat, conversations, alarms, doses, events, channel, events_channel} (an older Sioul: {kind, name, trigger, people, doses, channel}).private static voidflags(Context context, JSONObject said) Rust's word at each apply: {on}, Sioul's do-not-disturb here; the tile shown again when it changed.private static JSONObject{holds}: whether the mode of this kind is still on as Sioul turned it on (cheap; Rust asks at each look).private static SharedPreferencesWhat Sioul's own process keeps of its modes (the only one that turns them on and off), read again when it changed: new mail is told from the background service's process too (MailNotes).(package private) static StringThe kind of a mode from its condition id ("condition://<package>/dnd"); null when not Sioul's.(package private) static StringkindOfRule(Context context, String id) The kind of Sioul's mode with this id, as Android has it; null when none.private static JSONObjectThe pause's mode off, Sioul's own and nothing else: {was, still}.(package private) static intSioul's mode with this id as Android has it now (DndHeard.LIVE_*).(package private) static StringmailChannelNow(Context context, boolean through, String name) The channel new mail goes to now (MailNotes, from the window's process or the background service's): the one that passes while one of Sioul's modes is on and someone Always through wrote (`through`, Rust's word: told through the system's do-not-disturb), made then with `name`; the quiet "New mail" otherwise.(package private) static voidAt a restart or an update: the phone's state found, not heard, noted as seen, so that the next change counts from what holds now (forgetting it made the first change after each update a "first sight", never heard).private static NotificationManagernotifications(Context context) private static void"access": Android's list where Sioul is given Do Not Disturb access (no page there on some phones: Sioul's own page then).private static booleanotherOn(SharedPreferences kept, String kind) private static JSONObject{on}: the phone's own do-not-disturb on now, whatever holds it; {} without the access.(package private) static booleanWhether a channel that passes is the one now: one of Sioul's modes is on, and every mode on lets `flag` through ("doses.", "events."; null: any mode on will do), as `kept` has them (SharedPreferences.getAll).private static booleanpassingChannel(NotificationManager notifications, String id, String name) A channel that passes do-not-disturb, for what one of Sioul's modes lets through: the doses ("Doses during a pause"), an event's alarms, the mail of someone Always through.(package private) static booleanWhether the pause for overwhelming moments is on here: the tile shows it.private static ZenPolicypolicy(PauseMode.Through through) Who gets through, every field set: one left unset would take the person's own do-not-disturb settings.(package private) static void"Pause" pressed on the tile or the home screen's shortcut (PauseOpener).private static voidput(JSONObject object, String name, Object value) private static JSONObjectSioul's do-not-disturb gone off on this phone: the phone's own off too, with Sioul's Do Not Disturb access, up to Android 14 (it also snoozes every other mode on then, until it ends by itself).private static AutomaticZenRulerule(Context context, String name, String trigger, Uri condition, ZenPolicy policy, boolean enabled) The mode as Sioul makes it.private static booleansame(AutomaticZenRule existing, AutomaticZenRule wanted) Whether a mode is already as Sioul would make it.(package private) static booleanWhether Sioul's do-not-disturb holds on this phone, as Rust last said (the tile).private static ConditionThe mode's state as Sioul asks it: a press (or its end) is the person's own act.private static booleantakePressed(Context context) A press since last asked, and recent; once.private static booleantooOld()Modes with their own policy and state, set by the app: Android 10 (API 29).private static booleanturnedOff(NotificationManager notifications, String id) Whether the person turned the mode off while it was on.private static ComponentNameSioul's window, as its icon opens it.
-
Field Details
-
TAG
- See Also:
-
DOSES_CHANNEL
The dose reminders' channel while a pause lets them through: it passes do-not-disturb.- See Also:
-
DOSES_USUAL
- See Also:
-
ALARMS_CHANNEL
An event's alarms while one of Sioul's modes lets them through: it passes do-not-disturb (EventAlarms).- See Also:
-
KEPT
- See Also:
-
PRESSED
- See Also:
-
PRESS_KEPT_MS
A press older than this is not taken: Sioul did not come up meanwhile.- See Also:
-
KINDS
Sioul's modes: the two pauses, and its do-not-disturb on every device. -
CHANGING
Until when Sioul's own change settles (SystemClock.elapsedRealtime): DndReceiver looks again after.- See Also:
-
SETTLE_MS
How long Sioul's own change of a mode takes to settle.- See Also:
-
SEEN
The phone's do-not-disturb as DndReceiver last saw it: on or off.- See Also:
-
SIOUL_ON
Sioul's do-not-disturb holds on this phone, as Rust said at its last apply (the tile, DndReceiver).- See Also:
-
MAIL_CHANNEL
New mail's channel that passes, for someone Always through while one of Sioul's modes is on (MailNotes).- See Also:
-
-
Constructor Details
-
PauseMode
private PauseMode()
-
-
Method Details
-
call
Rust's question (android/main.cpp): "can", "enter", "leave", "pressed", "open". Any thread. -
tooOld
Modes with their own policy and state, set by the app: Android 10 (API 29). -
notifications
-
accessGranted
-
can
-
enter
The pause's mode on, made or brought up to date first: {kind, name, trigger, calls, messages, repeat, conversations, alarms, doses, events, channel, events_channel} (an older Sioul: {kind, name, trigger, people, doses, channel}). Answers what the mode lets through, read back from Android (the person may have changed it in Android's settings): {api, access, rule: {name, calls, messages, repeat, alarms, conversations (Android 11 and later), channels (15 and later)}, doses, events, already, disabled, turned_off}. -
leave
The pause's mode off, Sioul's own and nothing else: {was, still}. -
policy
Who gets through, every field set: one left unset would take the person's own do-not-disturb settings. Calls and messages as Rust asks (nobody, starred contacts, contacts, anyone), a second call within 15 minutes, the conversations marked important (Android 11 and later; Android 10 has no conversations: they are messages there); alarms; media (the music the person plays); priority channels (Sioul's doses and an event's alarms, from Android 15; before, Android lets a channel that passes through whatever the mode says). Other apps' reminders and events stay held. Notifications held stay in the shade and the status bar, without sound, banner, light, full screen or ambient display, as Android's own do-not-disturb does by default; they come back after. -
rule
private static AutomaticZenRule rule(Context context, String name, String trigger, Uri condition, ZenPolicy policy, boolean enabled) The mode as Sioul makes it. Its settings in Android open Sioul (the configuration activity a mode needs without a condition provider). From Android 15, a mode of its own kind with its words and icon, not turned on from Android's settings (only a pause turns it on). -
same
Whether a mode is already as Sioul would make it. -
state
The mode's state as Sioul asks it: a press (or its end) is the person's own act. -
turnedOff
Whether the person turned the mode off while it was on. Android 15's getAutomaticZenRuleState gives Sioul's own condition and misses a snooze from the quick settings (AOSP 16: "Buggy, does not consider snoozing"); with the Modes UI of Android 16 it says the mode's state. The filter at ALL says it on every version: while one of Sioul's modes is on and not snoozed, the phone is never at ALL. -
conditionId
Sioul's own address for a pause's mode: condition://com.aurelienpierre.sioul/pause. -
window
Sioul's window, as its icon opens it. -
passingChannel
A channel that passes do-not-disturb, for what one of Sioul's modes lets through: the doses ("Doses during a pause"), an event's alarms, the mail of someone Always through. At Android's default importance (its sound, no banner), allowed to pass with Do Not Disturb access, and only while the person has not changed the channel: then their choice stays. The usual channels are never changed: outside Sioul's modes, the person's own do-not-disturb holds them as before. Whether it gets through, as Android has the channel now. -
passesNow
Whether a channel that passes is the one now: one of Sioul's modes is on, and every mode on lets `flag` through ("doses.", "events."; null: any mode on will do), as `kept` has them (SharedPreferences.getAll). Pure, checked on a JVM (android/jvm-checks/: ModeCheck, HeardCheck). -
channelNow
-
dosesChannelNow
The channel a dose reminder goes to now (DoseAlarms): the pauses' own while every mode on lets the doses through, the usual one otherwise (a mode that holds them, or none). -
alarmsChannelNow
The channel an event's alarm goes to now (EventAlarms): the one that passes while every mode on lets an event's alarms through, the usual "An event's alarms" otherwise. Sioul's reminders before an event never come here: they stay in the quiet "Events". -
mailChannelNow
The channel new mail goes to now (MailNotes, from the window's process or the background service's): the one that passes while one of Sioul's modes is on and someone Always through wrote (`through`, Rust's word: told through the system's do-not-disturb), made then with `name`; the quiet "New mail" otherwise. -
pressed
"Pause" pressed on the tile or the home screen's shortcut (PauseOpener). -
takePressed
A press since last asked, and recent; once. -
paused
Whether the pause for overwhelming moments is on here: the tile shows it. -
kindOf
The kind of a mode from its condition id ("condition://<package>/dnd"); null when not Sioul's. Pure. -
kindOfRule
The kind of Sioul's mode with this id, as Android has it; null when none. -
live
Sioul's mode with this id as Android has it now (DndHeard.LIVE_*). -
decide
A change heard by DndReceiver, decided (DndHeard.decide(boolean, java.util.Map<java.lang.String, ?>, java.lang.String, int, java.lang.String, int, int, long)) from what Android has now and Sioul's record; the phone's state noted as seen, unless the decision waits for Sioul's own change to settle. -
noteSeen
At a restart or an update: the phone's state found, not heard, noted as seen, so that the next change counts from what holds now (forgetting it made the first change after each update a "first sight", never heard). Without the access, nothing is known: forgotten. -
sioulOn
Whether Sioul's do-not-disturb holds on this phone, as Rust last said (the tile). -
flags
Rust's word at each apply: {on}, Sioul's do-not-disturb here; the tile shown again when it changed. The phone's state noted when none was ever seen (a first install): the next change is heard. -
holds
{holds}: whether the mode of this kind is still on as Sioul turned it on (cheap; Rust asks at each look). -
own
{on}: the phone's own do-not-disturb on now, whatever holds it; {} without the access. -
quietOff
Sioul's do-not-disturb gone off on this phone: the phone's own off too, with Sioul's Do Not Disturb access, up to Android 14 (it also snoozes every other mode on then, until it ends by itself). From Android 15 an application may end only a mode of its own: {done: false}, and Rust says so. -
open
"access": Android's list where Sioul is given Do Not Disturb access (no page there on some phones: Sioul's own page then). "starred": the Contacts app's starred list, where the person stars who may reach them (Sioul never writes stars), else the Contacts app. -
kept
What Sioul's own process keeps of its modes (the only one that turns them on and off), read again when it changed: new mail is told from the background service's process too (MailNotes). -
put
-