Skip to content
Ilya Konovalov edited this page Jul 21, 2013 · 3 revisions

AlarmManager is a component mimicking behavior of the Android AlarmManager and is different in that it is triggered based on JTT ticks.

To implement this feature there has to be a way to translate JTT into integer value that are different for all JTTs on a period long enough. Currently there is mapping JTT->ticks since last sunset which is only good for one day.

Once such consistent numbering is implemented, it will be possible to keep the (relative) list of scheduled alarms (PendingIntents) in the Clockwork service and trigger them as the time passes.

Simplest approach is to add JDN*TICKS_PER_DAY to all JTT ticks numbers. This is guaranteed to make all JTTs consistent within one geographical area.

Problem: Time going backwards

This is entirely possible since we operate with user time, not real time. This can affect repeating alarms:

  • An alarm is set to me triggered every full hour
  • A hour passes, alarm is triggered and moved to beginning of next hour
  • User time is changed, JTT is now before the already triggered hour
  • Alarm has to be moved back to its previous position

The solution is to detect these changes and re-schedule repeating alarms back to front. This in turn adds a limitation: delay to alarm cannot be larger than repeat period.

Clone this wiki locally