Remove outdated alarms 29/214129/4
authorInkyun Kil <inkyun.kil@samsung.com>
Wed, 18 Sep 2019 01:34:01 +0000 (10:34 +0900)
committerInkyun Kil <inkyun.kil@samsung.com>
Wed, 18 Sep 2019 09:34:47 +0000 (18:34 +0900)
- When system time is changed or alarm is outdated unintentionally,
      some alarms should be removed

Change-Id: I14a67fe86f08c636df65b073569f517e9300f1e9
Signed-off-by: Inkyun Kil <inkyun.kil@samsung.com>
server/alarm-manager-schedule.c
server/alarm-manager.c

index a18c068d7a4a8ea396c1b1f5ab3582fe4b59f074..a353e00ae219c0d8b0c95f1a606f4dd7742373d5 100644 (file)
@@ -24,6 +24,8 @@
 
 #include"alarm.h"
 #include"alarm-internal.h"
+#include"alarm-manager-db.h"
+#include"alarm-manager-util.h"
 
 #define DST_TIME_DIFF 1
 
@@ -478,7 +480,25 @@ static bool __find_next_alarm_to_be_scheduled(time_t *min_due_time)
 
                if (interval < 0)       /*When the alarm expires, it may makes an error.*/ {
                        LOGW("The duetime of alarm(%d) is OVER.", entry->alarm_id);
-                       continue;
+
+                       _alarm_set_next_duetime(entry);
+                       if (entry->due_time < current_time) {
+                               const char *dst = entry->callee_pkgid ? entry->callee_pkgid : entry->dst_service_name;
+                               LOGW("The alarm(%d) is removed [unique_name : %s, dst : %s",
+                                               entry->alarm_id, entry->app_unique_name, dst);
+
+                               if (!(entry->alarm_info.alarm_type & ALARM_TYPE_VOLATILE))
+                                       _delete_alarms(entry->alarm_id);
+
+                               _save_alarm_info_log("AUTO_DELETE", entry);
+
+                               alarm_context.alarms = g_slist_remove(alarm_context.alarms, iter->data);
+                               _release_alarm_info_t(entry);
+                               continue;
+                       } else {
+                               due_time = entry->due_time;
+                       }
+
                }
 
                interval = difftime(due_time, min_time);
index 9dd3baaa40d58de346f8251119d60861b37e76d2..a5c5469fd922e71ae3953ea3ab573a9f3715cf92 100755 (executable)
@@ -658,7 +658,7 @@ static void __alarm_update_due_time_of_all_items_in_list(time_t new_time, double
        __alarm_info_t *entry = NULL;
        struct tm *p_time = NULL;
        struct tm due_time_result;
-       bool is_rtc_reset;
+       bool is_rtc_reset = false;
        is_time_changed = true;
 
        if (periodic_alarm_standard_time != 0)
@@ -744,8 +744,26 @@ static void __alarm_update_due_time_of_all_items_in_list(time_t new_time, double
                interval = difftime(due_time, current_time);
 
                if (interval < 0) {
-                       LOGE("The duetime of alarm(%d) is OVER.", entry->alarm_id);
-                       continue;
+                       LOGW("The duetime of alarm(%d) is OVER.", entry->alarm_id);
+
+                       _alarm_set_next_duetime(entry);
+                       if (entry->due_time < current_time) {
+                               const char *dst = entry->callee_pkgid ? entry->callee_pkgid : entry->dst_service_name;
+                               LOGW("The alarm(%d) is removed [unique_name : %s, dst : %s",
+                                               entry->alarm_id, entry->app_unique_name, dst);
+
+                               if (!(entry->alarm_info.alarm_type & ALARM_TYPE_VOLATILE))
+                                       _delete_alarms(entry->alarm_id);
+
+                               _save_alarm_info_log("AUTO_DELETE", entry);
+
+                               alarm_context.alarms = g_slist_remove(alarm_context.alarms, iter->data);
+                               _release_alarm_info_t(entry);
+                               continue;
+                       } else {
+                               due_time = entry->due_time;
+                       }
+
                }
 
                interval = difftime(due_time, min_time);