Loading src/com/android/deskclock/alarms/AlarmStateManager.java +14 −8 Original line number Diff line number Diff line Loading @@ -278,8 +278,11 @@ public final class AlarmStateManager extends BroadcastReceiver { // Start the alarm and schedule timeout timer for it AlarmService.startAlarm(context, instance); scheduleInstanceStateChange(context, instance.getTimeout(context), instance, AlarmInstance.MISSED_STATE); Calendar timeout = instance.getTimeout(context); if (timeout != null) { scheduleInstanceStateChange(context, timeout, instance, AlarmInstance.MISSED_STATE); } // Instance not valid anymore, so find next alarm that will fire and notify system updateNextAlarm(context); Loading Loading @@ -425,8 +428,15 @@ public final class AlarmStateManager extends BroadcastReceiver { Calendar missedTTL = instance.getMissedTimeToLive(); if (currentTime.after(missedTTL)) { // Alarm is so old, don't even show missed alarm // Alarm is so old, just dismiss it setDismissState(context, instance); } else if (instance.mAlarmState == AlarmInstance.FIRED_STATE) { // Keep alarm fired, unless it timed out if (timeoutTime != null && currentTime.after(timeoutTime)) { setMissedState(context, instance); } else { setFiredState(context, instance); } } else if (instance.mAlarmState == AlarmInstance.MISSED_STATE) { // Don't allow MISSED alarms to re-activate if (currentTime.before(alarmTime)) { Loading @@ -437,11 +447,7 @@ public final class AlarmStateManager extends BroadcastReceiver { setMissedState(context, instance); } } else if (currentTime.after(alarmTime)) { if (currentTime.before(timeoutTime)) { setFiredState(context, instance); } else { setMissedState(context, instance); } } else if (instance.mAlarmState == AlarmInstance.SNOOZE_STATE) { // We only want to display snooze and not update the time, so we // do it ourselves here Loading src/com/android/deskclock/provider/AlarmInstance.java +33 −1 Original line number Diff line number Diff line Loading @@ -302,6 +302,11 @@ public final class AlarmInstance implements ClockContract.InstancesColumns { mMinute = calendar.get(Calendar.MINUTE); } /** * Return the time when a alarm should fire. * * @return the time */ public Calendar getAlarmTime() { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.YEAR, mYear); Loading @@ -313,28 +318,55 @@ public final class AlarmInstance implements ClockContract.InstancesColumns { return calendar; } /** * Return the time when a low priority notification should be shown. * * @return the time */ public Calendar getLowNotificationTime() { Calendar calendar = getAlarmTime(); calendar.add(Calendar.HOUR_OF_DAY, LOW_NOTIFICATION_HOUR_OFFSET); return calendar; } /** * Return the time when a high priority notification should be shown. * * @return the time */ public Calendar getHighNotificationTime() { Calendar calendar = getAlarmTime(); calendar.add(Calendar.MINUTE, HIGH_NOTIFICATION_MINUTE_OFFSET); return calendar; } /** * Return the time when a missed notification should be removed. * * @return the time */ public Calendar getMissedTimeToLive() { Calendar calendar = getAlarmTime(); calendar.add(Calendar.HOUR, MISSED_TIME_TO_LIVE_HOUR_OFFSET); return calendar; } /** * Return the time when the alarm should stop firing and be marked as missed. * * @param context to figure out the timeout setting * @return the time when alarm should be silence, or null if never */ public Calendar getTimeout(Context context) { String timeoutSetting = PreferenceManager.getDefaultSharedPreferences(context) .getString(SettingsActivity.KEY_AUTO_SILENCE, DEFAULT_ALARM_TIMEOUT_SETTING); int timeoutMinutes = Integer.parseInt(timeoutSetting); // Alarm silence has been set to "None" if (timeoutMinutes < 0) { return null; } Calendar calendar = getAlarmTime(); calendar.add(Calendar.MINUTE, timeoutMinutes); return calendar; Loading Loading
src/com/android/deskclock/alarms/AlarmStateManager.java +14 −8 Original line number Diff line number Diff line Loading @@ -278,8 +278,11 @@ public final class AlarmStateManager extends BroadcastReceiver { // Start the alarm and schedule timeout timer for it AlarmService.startAlarm(context, instance); scheduleInstanceStateChange(context, instance.getTimeout(context), instance, AlarmInstance.MISSED_STATE); Calendar timeout = instance.getTimeout(context); if (timeout != null) { scheduleInstanceStateChange(context, timeout, instance, AlarmInstance.MISSED_STATE); } // Instance not valid anymore, so find next alarm that will fire and notify system updateNextAlarm(context); Loading Loading @@ -425,8 +428,15 @@ public final class AlarmStateManager extends BroadcastReceiver { Calendar missedTTL = instance.getMissedTimeToLive(); if (currentTime.after(missedTTL)) { // Alarm is so old, don't even show missed alarm // Alarm is so old, just dismiss it setDismissState(context, instance); } else if (instance.mAlarmState == AlarmInstance.FIRED_STATE) { // Keep alarm fired, unless it timed out if (timeoutTime != null && currentTime.after(timeoutTime)) { setMissedState(context, instance); } else { setFiredState(context, instance); } } else if (instance.mAlarmState == AlarmInstance.MISSED_STATE) { // Don't allow MISSED alarms to re-activate if (currentTime.before(alarmTime)) { Loading @@ -437,11 +447,7 @@ public final class AlarmStateManager extends BroadcastReceiver { setMissedState(context, instance); } } else if (currentTime.after(alarmTime)) { if (currentTime.before(timeoutTime)) { setFiredState(context, instance); } else { setMissedState(context, instance); } } else if (instance.mAlarmState == AlarmInstance.SNOOZE_STATE) { // We only want to display snooze and not update the time, so we // do it ourselves here Loading
src/com/android/deskclock/provider/AlarmInstance.java +33 −1 Original line number Diff line number Diff line Loading @@ -302,6 +302,11 @@ public final class AlarmInstance implements ClockContract.InstancesColumns { mMinute = calendar.get(Calendar.MINUTE); } /** * Return the time when a alarm should fire. * * @return the time */ public Calendar getAlarmTime() { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.YEAR, mYear); Loading @@ -313,28 +318,55 @@ public final class AlarmInstance implements ClockContract.InstancesColumns { return calendar; } /** * Return the time when a low priority notification should be shown. * * @return the time */ public Calendar getLowNotificationTime() { Calendar calendar = getAlarmTime(); calendar.add(Calendar.HOUR_OF_DAY, LOW_NOTIFICATION_HOUR_OFFSET); return calendar; } /** * Return the time when a high priority notification should be shown. * * @return the time */ public Calendar getHighNotificationTime() { Calendar calendar = getAlarmTime(); calendar.add(Calendar.MINUTE, HIGH_NOTIFICATION_MINUTE_OFFSET); return calendar; } /** * Return the time when a missed notification should be removed. * * @return the time */ public Calendar getMissedTimeToLive() { Calendar calendar = getAlarmTime(); calendar.add(Calendar.HOUR, MISSED_TIME_TO_LIVE_HOUR_OFFSET); return calendar; } /** * Return the time when the alarm should stop firing and be marked as missed. * * @param context to figure out the timeout setting * @return the time when alarm should be silence, or null if never */ public Calendar getTimeout(Context context) { String timeoutSetting = PreferenceManager.getDefaultSharedPreferences(context) .getString(SettingsActivity.KEY_AUTO_SILENCE, DEFAULT_ALARM_TIMEOUT_SETTING); int timeoutMinutes = Integer.parseInt(timeoutSetting); // Alarm silence has been set to "None" if (timeoutMinutes < 0) { return null; } Calendar calendar = getAlarmTime(); calendar.add(Calendar.MINUTE, timeoutMinutes); return calendar; Loading