summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJusung Son <jusung07.son@samsung.com>2019-09-16 07:09:00 (GMT)
committerJusung Son <jusung07.son@samsung.com>2019-09-18 02:03:12 (GMT)
commite12736b675b0d868409db1753fe58efdabb0dc01 (patch)
tree62e3e25c3475f367bbc86f58771a95f44038ee46
parentd603d96c1b03bb7cfbf4445fe1816a01041b7b82 (diff)
downloadalarm-manager-tizen_5.0.zip
alarm-manager-tizen_5.0.tar.gz
alarm-manager-tizen_5.0.tar.bz2
Handle zombie alarmtizen_5.0
- If G_DBUS_ERROR_SERVICE_UNKNOWN error occurs, exclude it from alarm schedule list. Change-Id: I66285c5165be9b6c83d97d5863febb1c03921bce Signed-off-by: Jusung Son <jusung07.son@samsung.com>
-rw-r--r--alarm-manager-schedule.c20
-rw-r--r--alarm-manager.c131
-rw-r--r--include/alarm-internal.h1
3 files changed, 138 insertions, 14 deletions
diff --git a/alarm-manager-schedule.c b/alarm-manager-schedule.c
index 743b3c0..f439c28 100644
--- a/alarm-manager-schedule.c
+++ b/alarm-manager-schedule.c
@@ -39,6 +39,10 @@ extern __alarm_server_context_t alarm_context;
extern GSList *g_scheduled_alarm_list;
extern bool is_time_changed;
+#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
+extern void _save_alarm_info_log(const char *tag, __alarm_info_t *info);
+#endif
+
static time_t __alarm_next_duetime_once(__alarm_info_t *__alarm_info);
static time_t __alarm_next_duetime_repeat(__alarm_info_t *__alarm_info);
static time_t __alarm_next_duetime_annually(__alarm_info_t *__alarm_info);
@@ -524,8 +528,9 @@ static bool __find_next_alarm_to_be_scheduled(time_t *min_due_time)
double interval = 0;
- SECURE_LOGD("alarm[%d] with duetime(%ld) at current(%ld) pid: (%d)\n",
- entry->alarm_id, due_time, current_time, entry->pid);
+ SECURE_LOGW("alarm[%d] with duetime(%ld) at current(%ld) - (%s) z:%d",
+ entry->alarm_id, due_time, current_time,
+ entry->app_unique_name, (int)entry->zombie_mode);
if (due_time == 0) /*0 means this alarm has been disabled*/ {
continue;
}
@@ -534,7 +539,8 @@ static bool __find_next_alarm_to_be_scheduled(time_t *min_due_time)
if (interval < 0) /*2008.08.06 when the alarm expires, it may makes an error.*/ {
time_t next_duetime;
- ALARM_MGR_EXCEPTION_PRINT("The duetime of alarm(%d) is OVER.", entry->alarm_id);
+ ALARM_MGR_EXCEPTION_PRINT("The duetime of alarm(%d) is OVER(z:%d)",
+ entry->alarm_id, (int)entry->zombie_mode);
next_duetime = _alarm_next_duetime(entry);
if (next_duetime < current_time) {
@@ -546,6 +552,9 @@ static bool __find_next_alarm_to_be_scheduled(time_t *min_due_time)
if (!(entry->alarm_info.alarm_type & ALARM_TYPE_VOLATILE))
_delete_alarms(entry->alarm_id);
+#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
+ _save_alarm_info_log("AUTO_DELETE", entry);
+#endif
alarm_context.alarms = g_slist_remove(alarm_context.alarms, iter->data);
_release_alarm_info_t(entry);
continue;
@@ -554,6 +563,9 @@ static bool __find_next_alarm_to_be_scheduled(time_t *min_due_time)
}
}
+ if (entry->zombie_mode)
+ continue;
+
interval = difftime(due_time, min_time);
if ((interval < 0) || min_time == -1)
@@ -580,7 +592,7 @@ bool _alarm_schedule()
entry = iter->data;
due_time = entry->due_time;
- if (due_time == min_time)
+ if (due_time == min_time && entry->zombie_mode == false)
_add_to_scheduled_alarm_list(entry);
}
_alarm_set_timer(&alarm_context, alarm_context.timer, min_time);
diff --git a/alarm-manager.c b/alarm-manager.c
index ad35b02..2b04fab 100644
--- a/alarm-manager.c
+++ b/alarm-manager.c
@@ -178,7 +178,7 @@ static notification_h __get_notification(guchar *data, int datalen);
#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
static void __initialize_module_log(void);
static bool __save_module_log(const char *tag, const char *messgae);
-static void __save_alarm_info_log(const char *tag, __alarm_info_t *info);
+void _save_alarm_info_log(const char *tag, __alarm_info_t *info);
#endif
int __display_lock_state(char *state, char *flag, unsigned int timeout);
@@ -192,6 +192,11 @@ struct running_info_t {
bool is_running;
};
+struct watch_info_t {
+ int watch_id;
+ alarm_id_t alarm_id;
+};
+
struct filtered_alarm_app_s {
int is_ui_app;
uid_t uid;
@@ -1126,7 +1131,7 @@ static bool __alarm_create_appsvc(alarm_info_t *alarm_info, alarm_id_t *alarm_id
}
#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
- __save_alarm_info_log("CREATE SVC", __alarm_info);
+ _save_alarm_info_log("CREATE SVC", __alarm_info);
#endif
@@ -1202,7 +1207,7 @@ static bool __alarm_create(alarm_info_t *alarm_info, alarm_id_t *alarm_id, uid_t
}
#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
- __save_alarm_info_log("CREATE", __alarm_info);
+ _save_alarm_info_log("CREATE", __alarm_info);
#endif
return true;
@@ -1321,7 +1326,7 @@ static bool __alarm_create_noti(alarm_info_t *alarm_info, alarm_id_t *alarm_id,
}
#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
- __save_alarm_info_log("CREATE NOTI", __alarm_info);
+ _save_alarm_info_log("CREATE NOTI", __alarm_info);
#endif
return true;
@@ -1360,7 +1365,7 @@ static bool __alarm_update(uid_t uid, int pid, alarm_id_t alarm_id,
result = _remove_from_scheduled_alarm_list(uid, alarm_id);
#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
- __save_alarm_info_log("UPDATE", __alarm_info);
+ _save_alarm_info_log("UPDATE", __alarm_info);
#endif
if (result == true && g_slist_length(g_scheduled_alarm_list) == 0) {
@@ -1574,11 +1579,115 @@ static gboolean __send_noti_to_session_bus(char *service_name,
return TRUE;
}
+static void __on_name_appeared(GDBusConnection *connection,
+ const gchar *name,
+ const gchar *name_owner,
+ gpointer user_data)
+{
+ SECURE_LOGW("alarm sender name appeared : %s %s", name, name_owner);
+
+ struct watch_info_t *watch_info = (struct watch_info_t *)user_data;
+ GSList *gs_iter;
+ __alarm_info_t *entry;
+ alarm_id_t alarm_id = watch_info->alarm_id;
+
+ g_bus_unwatch_name(watch_info->watch_id);
+ free(watch_info);
+
+ for (gs_iter = alarm_context.alarms; gs_iter != NULL; gs_iter = g_slist_next(gs_iter)) {
+ entry = gs_iter->data;
+ if (alarm_id == entry->alarm_id) {
+ entry->zombie_mode = false;
+
+ _alarm_disable_timer(alarm_context);
+ _clear_scheduled_alarm_list();
+ _alarm_schedule();
+ __rtc_set();
+
+ return;
+ }
+ }
+}
+
+static void __alarm_send_noti_to_application_reply(
+ GObject *source_object, GAsyncResult *res, gpointer user_data) {
+
+ GVariant *message;
+ GDBusConnection *conn;
+ GError *error = NULL;
+ alarm_id_t *reply_alarm_id = (alarm_id_t *)user_data;
+ char *service_name = NULL;
+ char *app_unique_name = NULL;
+ struct watch_info_t *watch_info;
+
+ GSList *gs_iter;
+ __alarm_info_t *entry;
+ bool is_existed = false;
+
+ conn = G_DBUS_CONNECTION(source_object);
+ message = g_dbus_connection_call_finish(conn, res, &error);
+
+ if (error != NULL && error->code == G_DBUS_ERROR_SERVICE_UNKNOWN) {
+ for (gs_iter = alarm_context.alarms; gs_iter != NULL; gs_iter = g_slist_next(gs_iter) ) {
+ entry = gs_iter->data;
+
+ if (*reply_alarm_id == entry->alarm_id) {
+ is_existed = true;
+
+ app_unique_name = entry->app_unique_name;
+
+ if (entry->dst_service_name == NULL)
+ service_name = entry->app_service_name_mod;
+ else
+ service_name = entry->dst_service_name_mod;
+
+ break;
+ }
+ }
+
+#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
+ char log_message[ALARMMGR_LOG_MESSAGE_SIZE] = {0,};
+ snprintf(log_message, sizeof(log_message),
+ "failed to send alarm expired noti [%d: %s] [id : %d, %s -> %s]",
+ error->code, error->message, *reply_alarm_id, app_unique_name, service_name);
+
+ __save_module_log("EXPIRED_FAIL", log_message);
+#endif
+ g_error_free(error);
+
+ if (is_existed) {
+ entry->zombie_mode = true;
+ watch_info = (struct watch_info_t *)calloc(1, sizeof(struct watch_info_t));
+ watch_info->alarm_id = entry->alarm_id;
+ watch_info->watch_id = g_bus_watch_name_on_connection(
+ alarm_context.connection,
+ service_name,
+ G_BUS_NAME_WATCHER_FLAGS_NONE,
+ __on_name_appeared,
+ NULL,
+ watch_info,
+ NULL);
+
+ alarm_context.c_due_time = -1;
+ _alarm_disable_timer(alarm_context);
+ _clear_scheduled_alarm_list();
+ _alarm_schedule();
+ __rtc_set();
+ }
+ } else {
+ g_variant_unref(message);
+ }
+
+ free(reply_alarm_id);
+
+}
+
static void __alarm_send_noti_to_application(const char *app_service_name,
alarm_id_t alarm_id, int msec, uid_t uid)
{
char service_name[MAX_SERVICE_NAME_LEN] = {0,};
gboolean ret;
+ alarm_id_t *reply_alarm_id;
if (app_service_name == NULL || strlen(app_service_name) == 0) {
ALARM_MGR_EXCEPTION_PRINT("This alarm destination is invalid.");
@@ -1597,6 +1706,8 @@ static void __alarm_send_noti_to_application(const char *app_service_name,
ALARM_MGR_EXCEPTION_PRINT("failed to send alarm expired noti for %d, %s",
alarm_id, service_name);
} else {
+ reply_alarm_id = (alarm_id_t *)calloc(1, sizeof(alarm_id_t));
+ *reply_alarm_id = alarm_id;
g_dbus_connection_call(alarm_context.connection,
service_name,
"/org/tizen/alarm/client",
@@ -1607,8 +1718,8 @@ static void __alarm_send_noti_to_application(const char *app_service_name,
G_DBUS_CALL_FLAGS_NONE,
-1,
NULL,
- NULL,
- NULL);
+ __alarm_send_noti_to_application_reply,
+ reply_alarm_id);
}
}
@@ -2141,14 +2252,14 @@ static void __alarm_expired()
__alarm_info->caller_pkgid, __alarm_info->app_unique_name);
#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
- __save_alarm_info_log("EXPIRED", __alarm_info);
+ _save_alarm_info_log("EXPIRED", __alarm_info);
#endif
if (__alarm_info->alarm_info.mode.repeat == ALARM_REPEAT_MODE_ONCE) {
__alarm_remove_from_list(__alarm_info->uid, alarm_id, NULL);
} else {
_alarm_next_duetime(__alarm_info);
#ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG
- __save_alarm_info_log("DUETIME", __alarm_info);
+ _save_alarm_info_log("DUETIME", __alarm_info);
#endif
}
}
@@ -2608,7 +2719,7 @@ static bool __save_module_log(const char *tag, const char *message)
return true;
}
-static void __save_alarm_info_log(const char *tag, __alarm_info_t *info)
+void _save_alarm_info_log(const char *tag, __alarm_info_t *info)
{
char log_message[ALARMMGR_LOG_MESSAGE_SIZE] = {0,};
char *due_time_str = ctime(&(info->due_time));
diff --git a/include/alarm-internal.h b/include/alarm-internal.h
index b5e18fc..a0edf84 100644
--- a/include/alarm-internal.h
+++ b/include/alarm-internal.h
@@ -191,6 +191,7 @@ typedef struct {
long requested_interval;
int is_ref;
bool global;
+ bool zombie_mode;
} __alarm_info_t;
typedef struct {