Class PauseMode

java.lang.Object
com.aurelienpierre.sioul.PauseMode

final class PauseMode extends Object
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 Classes
    Modifier and Type
    Class
    Description
    (package private) static final class 
    What 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

    Fields
    Modifier and Type
    Field
    Description
    (package private) static final String
    An event's alarms while one of Sioul's modes lets them through: it passes do-not-disturb (EventAlarms).
    (package private) static final String
    Until when Sioul's own change settles (SystemClock.elapsedRealtime): DndReceiver looks again after.
    (package private) static final String
    The dose reminders' channel while a pause lets them through: it passes do-not-disturb.
    private static final String
     
    private static final String
     
    private static final String[]
    Sioul's modes: the two pauses, and its do-not-disturb on every device.
    (package private) static final String
    New mail's channel that passes, for someone Always through while one of Sioul's modes is on (MailNotes).
    private static final long
    A press older than this is not taken: Sioul did not come up meanwhile.
    private static final String
     
    (package private) static final String
    The phone's do-not-disturb as DndReceiver last saw it: on or off.
    private static final long
    How long Sioul's own change of a mode takes to settle.
    (package private) static final String
    Sioul'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
    Modifier
    Constructor
    Description
    private
     
  • Method Summary

    Modifier and Type
    Method
    Description
    private static boolean
     
    (package private) static String
    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 String
    call(Context context, String verb, String json)
    Rust's question (android/main.cpp): "can", "enter", "leave", "pressed", "open".
    private static JSONObject
    can(Context context)
     
    private static String
    channelNow(Context context, String flag, String passing, String usual)
     
    private static Uri
    conditionId(Context context, String kind)
    Sioul's own address for a pause's mode: condition://com.aurelienpierre.sioul/pause.
    (package private) static String
    decide(Context context, String action, int status, String kind, String id)
    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.
    (package private) static String
    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 JSONObject
    enter(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 void
    flags(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(Context context, String kind)
    {holds}: whether the mode of this kind is still on as Sioul turned it on (cheap; Rust asks at each look).
    private static SharedPreferences
    kept(Context context)
    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).
    (package private) static String
    kindOf(String conditionId, String app)
    The kind of a mode from its condition id ("condition://<package>/dnd"); null when not Sioul's.
    (package private) static String
    kindOfRule(Context context, String id)
    The kind of Sioul's mode with this id, as Android has it; null when none.
    private static JSONObject
    leave(Context context, String kind)
    The pause's mode off, Sioul's own and nothing else: {was, still}.
    (package private) static int
    live(Context context, String id)
    Sioul's mode with this id as Android has it now (DndHeard.LIVE_*).
    (package private) static String
    mailChannelNow(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 void
    noteSeen(Context context)
    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).
    private static NotificationManager
     
    private static void
    open(Context context, String which)
    "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 boolean
     
    private static JSONObject
    own(Context context)
    {on}: the phone's own do-not-disturb on now, whatever holds it; {} without the access.
    (package private) static boolean
    passesNow(Map<String,?> kept, String flag)
    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).
    private static boolean
    passingChannel(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 boolean
    paused(Context context)
    Whether the pause for overwhelming moments is on here: the tile shows it.
    private static ZenPolicy
    Who gets through, every field set: one left unset would take the person's own do-not-disturb settings.
    (package private) static void
    pressed(Context context)
    "Pause" pressed on the tile or the home screen's shortcut (PauseOpener).
    private static void
    put(JSONObject object, String name, Object value)
     
    private static JSONObject
    quietOff(Context context)
    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).
    private static AutomaticZenRule
    rule(Context context, String name, String trigger, Uri condition, ZenPolicy policy, boolean enabled)
    The mode as Sioul makes it.
    private static boolean
    Whether a mode is already as Sioul would make it.
    (package private) static boolean
    sioulOn(Context context)
    Whether Sioul's do-not-disturb holds on this phone, as Rust last said (the tile).
    private static Condition
    state(Uri condition, String name, boolean on, boolean pressed)
    The mode's state as Sioul asks it: a press (or its end) is the person's own act.
    private static boolean
    A press since last asked, and recent; once.
    private static boolean
    Modes with their own policy and state, set by the app: Android 10 (API 29).
    private static boolean
    turnedOff(NotificationManager notifications, String id)
    Whether the person turned the mode off while it was on.
    private static ComponentName
    window(Context context)
    Sioul's window, as its icon opens it.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

  • Method Details

    • call

      static String call(Context context, String verb, String json)
      Rust's question (android/main.cpp): "can", "enter", "leave", "pressed", "open". Any thread.
    • tooOld

      private static boolean tooOld()
      Modes with their own policy and state, set by the app: Android 10 (API 29).
    • notifications

      private static NotificationManager notifications(Context context)
    • accessGranted

      private static boolean accessGranted(Context context)
    • can

      private static JSONObject can(Context context)
    • enter

      private static JSONObject enter(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}). 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

      private static JSONObject leave(Context context, String kind)
      The pause's mode off, Sioul's own and nothing else: {was, still}.
    • policy

      private static ZenPolicy policy(PauseMode.Through through)
      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

      private static boolean same(AutomaticZenRule existing, AutomaticZenRule wanted)
      Whether a mode is already as Sioul would make it.
    • state

      private static Condition state(Uri condition, String name, boolean on, boolean pressed)
      The mode's state as Sioul asks it: a press (or its end) is the person's own act.
    • turnedOff

      private static boolean turnedOff(NotificationManager notifications, String id)
      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

      private static Uri conditionId(Context context, String kind)
      Sioul's own address for a pause's mode: condition://com.aurelienpierre.sioul/pause.
    • window

      private static ComponentName window(Context context)
      Sioul's window, as its icon opens it.
    • otherOn

      private static boolean otherOn(SharedPreferences kept, String kind)
    • passingChannel

      private static boolean passingChannel(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. 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

      static boolean passesNow(Map<String,?> kept, String flag)
      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

      private static String channelNow(Context context, String flag, String passing, String usual)
    • dosesChannelNow

      static String dosesChannelNow(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).
    • alarmsChannelNow

      static String alarmsChannelNow(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. Sioul's reminders before an event never come here: they stay in the quiet "Events".
    • mailChannelNow

      static String mailChannelNow(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.
    • pressed

      static void pressed(Context context)
      "Pause" pressed on the tile or the home screen's shortcut (PauseOpener).
    • takePressed

      private static boolean takePressed(Context context)
      A press since last asked, and recent; once.
    • paused

      static boolean paused(Context context)
      Whether the pause for overwhelming moments is on here: the tile shows it.
    • kindOf

      static String kindOf(String conditionId, String app)
      The kind of a mode from its condition id ("condition://<package>/dnd"); null when not Sioul's. Pure.
    • kindOfRule

      static String kindOfRule(Context context, String id)
      The kind of Sioul's mode with this id, as Android has it; null when none.
    • live

      static int live(Context context, String id)
      Sioul's mode with this id as Android has it now (DndHeard.LIVE_*).
    • decide

      static String decide(Context context, String action, int status, String kind, String id)
      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

      static void noteSeen(Context context)
      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

      static boolean sioulOn(Context context)
      Whether Sioul's do-not-disturb holds on this phone, as Rust last said (the tile).
    • flags

      private static void flags(Context context, JSONObject said)
      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

      private static JSONObject holds(Context context, String kind)
      {holds}: whether the mode of this kind is still on as Sioul turned it on (cheap; Rust asks at each look).
    • own

      private static JSONObject own(Context context)
      {on}: the phone's own do-not-disturb on now, whatever holds it; {} without the access.
    • quietOff

      private static JSONObject quietOff(Context context)
      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

      private static void open(Context context, String which)
      "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

      private static SharedPreferences kept(Context context)
      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

      private static void put(JSONObject object, String name, Object value)