Class WakeAlarms

java.lang.Object
com.aurelienpierre.sioul.WakeAlarms

final class WakeAlarms extends Object
The alarm at waking (docs/android.md, "Waking"): it rings when the night ends, on the mornings ticked with the night in Sioul's Health settings. Rust hands the coming wakings, eight days ahead, whenever they change (crates/sioul-app/src/wake.rs, through android/main.cpp). Here they are kept, in the storage a phone reads before its first unlock (a phone that restarted in the night still rings), and the next is given to Android's alarm clock: setAlarmClock, exact, through Doze, the alarm shown in the status bar. At each ring, a little before each and as each night starts, after a restart, a change of time or of zone, Rust is asked again (WakeReceiver); when it cannot answer, the list kept goes on, then the usual week, repeated: never nothing. Apart from the doses: its own list, codes, channel and receiver.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final String
    After "10 min later": when it rings again.
    private static final int
     
    private static final String
    The ring last given to Android, and the last that rang: a ring missed while the phone was off.
    (package private) static final String
    A ring's time (Unix milliseconds), on its intent.
    (package private) static final String
    The "Waking" channel: the ring's notification, and the one after "10 min later".
    private static final long
    A ring due within a minute is the one ringing now: never given again.
    private static final String
     
    (package private) static final String
     
    (package private) static final String
     
    (package private) static final int
     
    (package private) static final int
    Minutes "10 min later" puts the alarm off by (wake.rs, LATER_MINUTES).
    private static final String
     
    (package private) static final String
     
    private static final int
     
    private static final long
    A ring missed while the phone was off rings as it starts again, when this late at most.
    private static final String
     
    (package private) static final String
     
    private static final int
     
    (package private) static final int
     
    private static final int
     
    (package private) static final String
     
    (package private) static final int
     
    (package private) static final String
    On a ring and its buttons: a try's; and a try's last ring, after its "10 min later" (no other).
    (package private) static final String
    "Try the alarm": rung as a waking, by its own action (told apart in `dumpsys alarm`).
    private static final String
    A try's own keys: when it rings, and its words (before any list).
    private static final int
     
    (package private) static final int
     
    (package private) static final int
     
    (package private) static final int
     
    (package private) static final int
     
    (package private) static final int
    A try's answers (wake.rs): it rings; exact alarms, notifications or the full screen refused.
    (package private) static final int
    Seconds before a try rings (wake.rs, TRY_SECONDS).
    (package private) static final int
     
    private static final String
     
    private static final String[][]
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
     
  • Method Summary

    Modifier and Type
    Method
    Description
    (package private) static void
    arm(Context context, String why)
    The next ring and look given to Android's alarm clock, from the list kept: Android forgets them at a restart, a change of zone moves them.
    (package private) static void
    ask(Context context, boolean fetch, String why)
    Rust asked for the coming wakings, then given them (WakeReceiver, on a thread of its own: Rust reads the sharing first, `fetch` the sync app given twenty seconds).
    (package private) static void
    channel(Context context)
    The "Waking" channel: high importance (over the lock screen, the screen lit).
    (package private) static boolean
    exact(Context context)
    "Alarms & reminders": Android 12 gives it at install and lets you take it back; 13 gives it for good (USE_EXACT_ALARM).
    private static long
    first(JSONArray times, ZoneId made, ZoneId here, long after)
    The first of `times` after `after`, moved to the same time on the clock here; 0 when none.
    (package private) static boolean
    The screen lit over the lock screen as it rings: yours to refuse from Android 14.
    private static SharedPreferences
    kept(Context context)
    Kept where the phone reads it before its first unlock (device-protected storage): times and words only, nothing of what Sioul keeps.
    (package private) static long
    later(Context context)
    "10 min later": the alarm again in ten minutes, kept for a restart; when.
    private static JSONObject
    list(Context context)
     
    private static PendingIntent
    look(Context context)
    The question before a ring and as a night starts.
    (package private) static long
    missed(Context context)
    A ring the phone missed while it was off, no more than half an hour ago; 0 when none.
    (package private) static String
    nativeNext(String zone, boolean fetch)
    The coming wakings (wake.rs, `sioul_wake_next`), in the phone's `zone`; JSON, or {"unknown": true}.
    (package private) static boolean
    Sioul's notifications shown, and the "Waking" channel not turned off: else the ring has no Stop to show.
    (package private) static void
    rang(Context context, long at)
    A ring rang (or rings now): known, so that a restart does not ring it again.
    (package private) static long
    rezoned(long at, ZoneId made, ZoneId here)
    A time made in another zone (the phone taken elsewhere, or Sioul's zone a few minutes behind a change), at the same time on the clock here: a waking at 07:00 stays at 07:00.
    private static PendingIntent
    ring(Context context, int code, long at)
    A ring's alarm (the next waking, or the one after "10 min later"), to WakeReceiver, by no other app.
    (package private) static void
    set(Context context, String json)
    Rust's wakings (wake.rs): {rings, looks (Unix ms), week (Monday first, "07:00" or ""), zone, words}.
    (package private) static void
    settings(Context context, String which)
    Android's page where one is allowed: "exact", "screen", "notifications"; Sioul's own page else.
    private static PendingIntent
    show(Context context)
    The alarm tapped in the status bar or on the lock screen: Sioul, as by its icon.
    (package private) static int
    state(Context context)
    For Rust (android/main.cpp): 1 exact alarms, 2 the full screen, 4 notifications.
    (package private) static void
    stopped(Context context)
    Stop: nothing rings again before the next waking.
    private static PendingIntent
    trial(Context context, long at, boolean last)
    A try's alarm: to WakeReceiver as a waking's, by its own action and code.
    (package private) static long
    tryLater(Context context)
    A try's "10 min later": rung once more, as a try, its last time (without "10 min later"); when.
    (package private) static int
    tryNow(Context context, String json)
    "Try the alarm" (Health's settings; wake.rs hands {at (Unix ms), words}): the alarm at `at`, ten seconds on, through the path a waking takes: Android's alarm clock, WakeReceiver, WakeRinger (the rising sound, in the foreground), WakeScreen over the lock screen.
    (package private) static void
    A try over (Stop, or its last ring): its alarm, if one is left, taken back; nothing of the waking's.
    (package private) static boolean
    unlocked(Context context)
    Whether the phone was unlocked since it started: Sioul's own files can be read.
    (package private) static long
    usual(JSONArray week, ZoneId here, long after)
    The next ring of the usual `week` (Monday first: "07:00", or "" when that morning does not ring) after `after`, here; 0 when none is ticked.
    (package private) static String
    word(Context context, String which)
    The words said here, as Rust gave them with the wakings (or with a try), in the person's language (crates/sioul-core/locales); before either, these, by the phone's language.
    private static ZoneId
     

    Methods inherited from class java.lang.Object

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

  • Constructor Details

  • Method Details

    • nativeNext

      static String nativeNext(String zone, boolean fetch)
      The coming wakings (wake.rs, `sioul_wake_next`), in the phone's `zone`; JSON, or {"unknown": true}.
    • set

      static void set(Context context, String json)
      Rust's wakings (wake.rs): {rings, looks (Unix ms), week (Monday first, "07:00" or ""), zone, words}. Kept, then the next ring and look given to Android. Rust not knowing ({"unknown": true}: the night's file does not read) changes nothing kept. Any thread.
    • arm

      static void arm(Context context, String why)
      The next ring and look given to Android's alarm clock, from the list kept: Android forgets them at a restart, a change of zone moves them. The list run out (Sioul not asked for eight days), the usual week. A ring after "10 min later" given again too. Never inexact: without "Alarms & reminders", nothing, and the Health settings say so. Any thread.
    • ask

      static void ask(Context context, boolean fetch, String why)
      Rust asked for the coming wakings, then given them (WakeReceiver, on a thread of its own: Rust reads the sharing first, `fetch` the sync app given twenty seconds). Not before the phone's first unlock: Sioul's files cannot be read then, and the list kept rings. No answer: the list kept goes on.
    • rang

      static void rang(Context context, long at)
      A ring rang (or rings now): known, so that a restart does not ring it again.
    • missed

      static long missed(Context context)
      A ring the phone missed while it was off, no more than half an hour ago; 0 when none.
    • later

      static long later(Context context)
      "10 min later": the alarm again in ten minutes, kept for a restart; when.
    • stopped

      static void stopped(Context context)
      Stop: nothing rings again before the next waking.
    • tryNow

      static int tryNow(Context context, String json)
      "Try the alarm" (Health's settings; wake.rs hands {at (Unix ms), words}): the alarm at `at`, ten seconds on, through the path a waking takes: Android's alarm clock, WakeReceiver, WakeRinger (the rising sound, in the foreground), WakeScreen over the lock screen. By its own action, code and keys: the next waking, its list and its "10 min later" are left as they are, and nothing is written of the night. When Android refuses exact alarms, notifications or the full screen, nothing is set: the answer says which (TRY_NO_…), for the setting to say why, rather than a try that rings unseen or not at all. Not given again after a restart.
    • tryLater

      static long tryLater(Context context)
      A try's "10 min later": rung once more, as a try, its last time (without "10 min later"); when.
    • tryStopped

      static void tryStopped(Context context)
      A try over (Stop, or its last ring): its alarm, if one is left, taken back; nothing of the waking's.
    • trial

      private static PendingIntent trial(Context context, long at, boolean last)
      A try's alarm: to WakeReceiver as a waking's, by its own action and code.
    • first

      private static long first(JSONArray times, ZoneId made, ZoneId here, long after)
      The first of `times` after `after`, moved to the same time on the clock here; 0 when none.
    • rezoned

      static long rezoned(long at, ZoneId made, ZoneId here)
      A time made in another zone (the phone taken elsewhere, or Sioul's zone a few minutes behind a change), at the same time on the clock here: a waking at 07:00 stays at 07:00.
    • usual

      static long usual(JSONArray week, ZoneId here, long after)
      The next ring of the usual `week` (Monday first: "07:00", or "" when that morning does not ring) after `after`, here; 0 when none is ticked. What rings when Sioul cannot be asked: the usual mornings, repeated.
    • zone

      private static ZoneId zone(String id)
    • ring

      private static PendingIntent ring(Context context, int code, long at)
      A ring's alarm (the next waking, or the one after "10 min later"), to WakeReceiver, by no other app.
    • look

      private static PendingIntent look(Context context)
      The question before a ring and as a night starts.
    • show

      private static PendingIntent show(Context context)
      The alarm tapped in the status bar or on the lock screen: Sioul, as by its icon.
    • exact

      static boolean exact(Context context)
      "Alarms & reminders": Android 12 gives it at install and lets you take it back; 13 gives it for good (USE_EXACT_ALARM).
    • fullScreen

      static boolean fullScreen(Context context)
      The screen lit over the lock screen as it rings: yours to refuse from Android 14.
    • notificationsAllowed

      static boolean notificationsAllowed(Context context)
      Sioul's notifications shown, and the "Waking" channel not turned off: else the ring has no Stop to show.
    • state

      static int state(Context context)
      For Rust (android/main.cpp): 1 exact alarms, 2 the full screen, 4 notifications.
    • settings

      static void settings(Context context, String which)
      Android's page where one is allowed: "exact", "screen", "notifications"; Sioul's own page else.
    • unlocked

      static boolean unlocked(Context context)
      Whether the phone was unlocked since it started: Sioul's own files can be read.
    • channel

      static void channel(Context context)
      The "Waking" channel: high importance (over the lock screen, the screen lit). Without a sound of its own: WakeRinger plays it, rising, where a channel's would be at one volume and stop as the shade opens.
    • kept

      private static SharedPreferences kept(Context context)
      Kept where the phone reads it before its first unlock (device-protected storage): times and words only, nothing of what Sioul keeps.
    • list

      private static JSONObject list(Context context)
    • word

      static String word(Context context, String which)
      The words said here, as Rust gave them with the wakings (or with a try), in the person's language (crates/sioul-core/locales); before either, these, by the phone's language.