Lines Matching defs:alarm

48     // from the alarm manager.
51 // A public action sent by AlarmKlaxon when the alarm has stopped sounding
57 // can snooze the alarm (after ALARM_ALERT_ACTION and before ALARM_DONE_ACTION).
61 // can dismiss the alarm (after ALARM_ALERT_ACTION and before ALARM_DONE_ACTION).
64 // A public action sent by AlarmAlertFullScreen when a snoozed alarm was dismissed due
68 // A broadcast sent every time the next alarm time is set in the system
72 // show the alarm has been killed.
76 // alarm played before being killed.
79 // Extra in the ALARM_KILLED intent to indicate when alarm was replaced
82 // This string is used to indicate a silent alarm in the db.
90 public static final String ALARM_INTENT_EXTRA = "intent.extra.alarm";
110 * Creates a new Alarm and fills in the given alarm's id.
112 public static long addAlarm(Context context, Alarm alarm) {
113 ContentValues values = createContentValues(alarm);
116 alarm.id = (int) ContentUris.parseId(uri);
118 long timeInMillis = calculateAlarm(alarm);
119 if (alarm.enabled) {
127 * Removes an existing Alarm. If this alarm is snoozing, disables
134 /* If alarm is snoozing, lose it */
167 private static ContentValues createContentValues(Alarm alarm) {
169 // Set the alarm_time value if this alarm does not repeat. This will be
172 if (!alarm.daysOfWeek.isRepeatSet()) {
173 time = calculateAlarm(alarm);
177 if (alarm.id != -1) {
178 values.put(Alarm.Columns._ID, alarm.id);
181 values.put(Alarm.Columns.ENABLED, alarm.enabled ? 1 : 0);
182 values.put(Alarm.Columns.HOUR, alarm.hour);
183 values.put(Alarm.Columns.MINUTES, alarm.minutes);
185 values.put(Alarm.Columns.DAYS_OF_WEEK, alarm.daysOfWeek.getCoded());
186 values.put(Alarm.Columns.VIBRATE, alarm.vibrate);
187 values.put(Alarm.Columns.MESSAGE, alarm.label);
189 // A null alert Uri indicates a silent alarm.
190 values.put(Alarm.Columns.ALERT, alarm.alert == null ? ALARM_ALERT_SILENT
191 : alarm.alert.toString());
197 // If this alarm fires before the next snooze, clear the snooze to
198 // enable this alarm.
213 * Return an Alarm object representing the alarm id in the database.
214 * Returns null if no alarm exists.
221 Alarm alarm = null;
224 alarm = new Alarm(cursor);
228 return alarm;
233 * A convenience method to set an alarm in the Alarms
235 * @return Time when the alarm will fire. Or < 1 if update failed.
237 public static long setAlarm(Context context, Alarm alarm) {
238 ContentValues values = createContentValues(alarm);
241 ContentUris.withAppendedId(Alarm.Columns.CONTENT_URI, alarm.id),
244 Log.e("Error updating alarm " + alarm);
248 long timeInMillis = calculateAlarm(alarm);
250 if (alarm.enabled) {
251 // Disable the snooze if we just changed the snoozed alarm. This
252 // only does work if the snoozed alarm is the same as the given
253 // alarm.
255 disableSnoozeAlert(context, alarm.id);
257 // Disable the snooze if this alarm fires before the snoozed alarm.
258 // This works on every alarm since the user most likely intends to
259 // have the modified alarm fire next.
269 * A convenience method to enable or disable an alarm.
288 final Alarm alarm, boolean enabled) {
289 if (alarm == null) {
297 // If we are enabling the alarm, calculate alarm time since the time
301 if (!alarm.daysOfWeek.isRepeatSet()) {
302 time = calculateAlarm(alarm);
307 disableSnoozeAlert(context, alarm.id);
311 Alarm.Columns.CONTENT_URI, alarm.id), values, null, null);
322 // list. For a non-repeating alarm, when it goes of, it becomes disabled. A snoozed
323 // non-repeating alarm is not in the active list in the database.
348 Alarm alarm = null;
351 // A time of 0 indicates this is a repeating alarm, so
357 // Update the alarm if it has been snoozed
361 Log.v("Disabling expired alarm set for " + Log.formatTime(a.time));
362 // Expired alarm, disable it and move along.
368 alarm = a;
372 return alarm;
386 Alarm alarm = new Alarm(cur);
387 // A time of 0 means this alarm repeats. If the time is
389 if (alarm.time != 0 && alarm.time < now) {
390 Log.v("Disabling expired alarm set for " +
391 Log.formatTime(alarm.time));
392 enableAlarmInternal(context, alarm, false);
403 * the user changes alarm settings. Activates snooze if set,
407 final Alarm alarm = calculateNextAlert(context);
408 if (alarm != null) {
409 enableAlert(context, alarm, alarm.time);
419 * actually launch the alert when the alarm triggers.
421 * @param alarm Alarm.
424 private static void enableAlert(Context context, final Alarm alarm,
429 // Intentionally verbose: always log the alarm time to provide useful
431 Log.v("Alarm set for id=" + alarm.id + " " + Log.formatTime(atTimeInMillis));
445 alarm.writeToParcel(out, 0);
475 // Intentionally verbose: always log the lack of a next alarm to provide useful
477 Log.v("No next alarm");
564 * Returns a boolean indicating whether the alarm was updated.
567 final SharedPreferences prefs, final Alarm alarm) {
568 if (!hasAlarmBeenSnoozed(prefs, alarm.id)) {
569 // No need to modify the alarm
573 final long time = prefs.getLong(getAlarmPrefSnoozeTimeKey(alarm.id), -1);
575 // for a non-repeating alarm. Update this value so the AlarmReceiver
577 alarm.time = time;
583 * Tells the StatusBar whether the alarm is enabled or disabled
591 private static long calculateAlarm(Alarm alarm) {
592 return calculateAlarm(alarm.hour, alarm.minutes, alarm.daysOfWeek)
597 * Given an alarm in hours and minutes, return a time suitable for
610 // if alarm is behind current time, advance one day
646 * Save time of the next alarm, as a formatted string, into the system