Lines Matching defs:alarm

45     // from the alarm manager.
48 // A public action sent by AlarmKlaxon when the alarm has stopped sounding
54 // can snooze the alarm (after ALARM_ALERT_ACTION and before ALARM_DONE_ACTION).
58 // can dismiss the alarm (after ALARM_ALERT_ACTION and before ALARM_DONE_ACTION).
62 // show the alarm has been killed.
66 // alarm played before being killed.
69 // This string is used to indicate a silent alarm in the db.
77 public static final String ALARM_INTENT_EXTRA = "intent.extra.alarm";
97 * Creates a new Alarm and fills in the given alarm's id.
99 public static long addAlarm(Context context, Alarm alarm) {
100 ContentValues values = createContentValues(alarm);
103 alarm.id = (int) ContentUris.parseId(uri);
105 long timeInMillis = calculateAlarm(alarm);
106 if (alarm.enabled) {
114 * Removes an existing Alarm. If this alarm is snoozing, disables
121 /* If alarm is snoozing, lose it */
148 private static ContentValues createContentValues(Alarm alarm) {
150 // Set the alarm_time value if this alarm does not repeat. This will be
153 if (!alarm.daysOfWeek.isRepeatSet()) {
154 time = calculateAlarm(alarm);
157 values.put(Alarm.Columns.ENABLED, alarm.enabled ? 1 : 0);
158 values.put(Alarm.Columns.HOUR, alarm.hour);
159 values.put(Alarm.Columns.MINUTES, alarm.minutes);
161 values.put(Alarm.Columns.DAYS_OF_WEEK, alarm.daysOfWeek.getCoded());
162 values.put(Alarm.Columns.VIBRATE, alarm.vibrate);
163 values.put(Alarm.Columns.MESSAGE, alarm.label);
165 // A null alert Uri indicates a silent alarm.
166 values.put(Alarm.Columns.ALERT, alarm.alert == null ? ALARM_ALERT_SILENT
167 : alarm.alert.toString());
173 // If this alarm fires before the next snooze, clear the snooze to
174 // enable this alarm.
189 * Return an Alarm object representing the alarm id in the database.
190 * Returns null if no alarm exists.
197 Alarm alarm = null;
200 alarm = new Alarm(cursor);
204 return alarm;
209 * A convenience method to set an alarm in the Alarms
211 * @return Time when the alarm will fire.
213 public static long setAlarm(Context context, Alarm alarm) {
214 ContentValues values = createContentValues(alarm);
217 ContentUris.withAppendedId(Alarm.Columns.CONTENT_URI, alarm.id),
220 long timeInMillis = calculateAlarm(alarm);
222 if (alarm.enabled) {
223 // Disable the snooze if we just changed the snoozed alarm. This
224 // only does work if the snoozed alarm is the same as the given
225 // alarm.
227 disableSnoozeAlert(context, alarm.id);
229 // Disable the snooze if this alarm fires before the snoozed alarm.
230 // This works on every alarm since the user most likely intends to
231 // have the modified alarm fire next.
241 * A convenience method to enable or disable an alarm.
260 final Alarm alarm, boolean enabled) {
261 if (alarm == null) {
269 // If we are enabling the alarm, calculate alarm time since the time
273 if (!alarm.daysOfWeek.isRepeatSet()) {
274 time = calculateAlarm(alarm);
279 disableSnoozeAlert(context, alarm.id);
283 Alarm.Columns.CONTENT_URI, alarm.id), values, null, null);
294 // list. For a non-repeating alarm, when it goes of, it becomes disabled. A snoozed
295 // non-repeating alarm is not in the active list in the database.
320 Alarm alarm = null;
323 // A time of 0 indicates this is a repeating alarm, so
329 // Update the alarm if it has been snoozed
333 Log.v("Disabling expired alarm set for " + Log.formatTime(a.time));
334 // Expired alarm, disable it and move along.
340 alarm = a;
344 return alarm;
358 Alarm alarm = new Alarm(cur);
359 // A time of 0 means this alarm repeats. If the time is
361 if (alarm.time != 0 && alarm.time < now) {
362 Log.v("Disabling expired alarm set for " +
363 Log.formatTime(alarm.time));
364 enableAlarmInternal(context, alarm, false);
375 * the user changes alarm settings. Activates snooze if set,
379 final Alarm alarm = calculateNextAlert(context);
380 if (alarm != null) {
381 enableAlert(context, alarm, alarm.time);
389 * actually launch the alert when the alarm triggers.
391 * @param alarm Alarm.
394 private static void enableAlert(Context context, final Alarm alarm,
400 Log.v("** setAlert id " + alarm.id + " atTime " + atTimeInMillis);
415 alarm.writeToParcel(out, 0);
533 * Returns a boolean indicating whether the alarm was updated.
536 final SharedPreferences prefs, final Alarm alarm) {
537 if (!hasAlarmBeenSnoozed(prefs, alarm.id)) {
538 // No need to modify the alarm
542 final long time = prefs.getLong(getAlarmPrefSnoozeTimeKey(alarm.id), -1);
544 // for a non-repeating alarm. Update this value so the AlarmReceiver
546 alarm.time = time;
552 * Tells the StatusBar whether the alarm is enabled or disabled
560 private static long calculateAlarm(Alarm alarm) {
561 return calculateAlarm(alarm.hour, alarm.minutes, alarm.daysOfWeek)
566 * Given an alarm in hours and minutes, return a time suitable for
579 // if alarm is behind current time, advance one day
615 * Save time of the next alarm, as a formatted string, into the system