Lines Matching defs:alarm
44 // from the alarm manager.
47 // A public action sent by AlarmKlaxon when the alarm has stopped sounding
53 // can snooze the alarm (after ALARM_ALERT_ACTION and before ALARM_DONE_ACTION).
57 // can dismiss the alarm (after ALARM_ALERT_ACTION and before ALARM_DONE_ACTION).
61 // show the alarm has been killed.
65 // alarm played before being killed.
68 // This string is used to indicate a silent alarm in the db.
76 public static final String ALARM_INTENT_EXTRA = "intent.extra.alarm";
83 // This string is used to identify the alarm id passed to SetAlarm from the
98 * Creates a new Alarm and fills in the given alarm's id.
100 public static long addAlarm(Context context, Alarm alarm) {
101 ContentValues values = createContentValues(alarm);
104 alarm.id = (int) ContentUris.parseId(uri);
106 long timeInMillis = calculateAlarm(alarm);
107 if (alarm.enabled) {
115 * Removes an existing Alarm. If this alarm is snoozing, disables
122 /* If alarm is snoozing, lose it */
149 private static ContentValues createContentValues(Alarm alarm) {
151 // Set the alarm_time value if this alarm does not repeat. This will be
154 if (!alarm.daysOfWeek.isRepeatSet()) {
155 time = calculateAlarm(alarm);
158 values.put(Alarm.Columns.ENABLED, alarm.enabled ? 1 : 0);
159 values.put(Alarm.Columns.HOUR, alarm.hour);
160 values.put(Alarm.Columns.MINUTES, alarm.minutes);
161 values.put(Alarm.Columns.ALARM_TIME, alarm.time);
162 values.put(Alarm.Columns.DAYS_OF_WEEK, alarm.daysOfWeek.getCoded());
163 values.put(Alarm.Columns.VIBRATE, alarm.vibrate);
164 values.put(Alarm.Columns.MESSAGE, alarm.label);
166 // A null alert Uri indicates a silent alarm.
167 values.put(Alarm.Columns.ALERT, alarm.alert == null ? ALARM_ALERT_SILENT
168 : alarm.alert.toString());
174 // If this alarm fires before the next snooze, clear the snooze to
175 // enable this alarm.
185 * Return an Alarm object representing the alarm id in the database.
186 * Returns null if no alarm exists.
193 Alarm alarm = null;
196 alarm = new Alarm(cursor);
200 return alarm;
205 * A convenience method to set an alarm in the Alarms
207 * @return Time when the alarm will fire.
209 public static long setAlarm(Context context, Alarm alarm) {
210 ContentValues values = createContentValues(alarm);
213 ContentUris.withAppendedId(Alarm.Columns.CONTENT_URI, alarm.id),
216 long timeInMillis = calculateAlarm(alarm);
218 if (alarm.enabled) {
219 // Disable the snooze if we just changed the snoozed alarm. This
220 // only does work if the snoozed alarm is the same as the given
221 // alarm.
223 disableSnoozeAlert(context, alarm.id);
225 // Disable the snooze if this alarm fires before the snoozed alarm.
226 // This works on every alarm since the user most likely intends to
227 // have the modified alarm fire next.
237 * A convenience method to enable or disable an alarm.
256 final Alarm alarm, boolean enabled) {
257 if (alarm == null) {
265 // If we are enabling the alarm, calculate alarm time since the time
269 if (!alarm.daysOfWeek.isRepeatSet()) {
270 time = calculateAlarm(alarm);
275 disableSnoozeAlert(context, alarm.id);
279 Alarm.Columns.CONTENT_URI, alarm.id), values, null, null);
283 Alarm alarm = null;
291 // A time of 0 indicates this is a repeating alarm, so
296 // Expired alarm, disable it and move along.
302 alarm = a;
308 return alarm;
321 Alarm alarm = new Alarm(cur);
322 // A time of 0 means this alarm repeats. If the time is
324 if (alarm.time != 0 && alarm.time < now) {
326 Log.v("** DISABLE " + alarm.id + " now " + now +" set "
327 + alarm.time);
329 enableAlarmInternal(context, alarm, false);
338 * the user changes alarm settings. Activates snooze if set,
343 Alarm alarm = calculateNextAlert(context);
344 if (alarm != null) {
345 enableAlert(context, alarm, alarm.time);
354 * actually launch the alert when the alarm triggers.
356 * @param alarm Alarm.
359 private static void enableAlert(Context context, final Alarm alarm,
365 Log.v("** setAlert id " + alarm.id + " atTime " + atTimeInMillis);
380 alarm.writeToParcel(out, 0);
477 // Get the alarm from the db.
478 final Alarm alarm = getAlarm(context.getContentResolver(), id);
479 if (alarm == null) {
483 // for a non-repeating alarm. Update this value so the AlarmReceiver
485 alarm.time = time;
487 enableAlert(context, alarm, time);
492 * Tells the StatusBar whether the alarm is enabled or disabled
500 private static long calculateAlarm(Alarm alarm) {
501 return calculateAlarm(alarm.hour, alarm.minutes, alarm.daysOfWeek)
506 * Given an alarm in hours and minutes, return a time suitable for
519 // if alarm is behind current time, advance one day
555 * Save time of the next alarm, as a formatted string, into the system