Check if app is running by aul_app_get_all_running_app_info 51/117751/3
authorJiwoong Im <jiwoong.im@samsung.com>
Tue, 7 Mar 2017 09:04:55 +0000 (18:04 +0900)
committerJiwoong Im <jiwoong.im@samsung.com>
Wed, 8 Mar 2017 04:43:43 +0000 (13:43 +0900)
- aul_app_is_running() can't check if the watch-app is running or not.
  Replace check step by using aul_app_get_all_running_app_info.

Change-Id: I0061117ebe052e0c0e70c7f31cbe02e344bb0c40
Signed-off-by: Jiwoong Im <jiwoong.im@samsung.com>
alarm-manager.c

index 5b81d17..0688d59 100644 (file)
@@ -169,6 +169,12 @@ int __display_unlock_state(char *state, char *flag);
 
 int __set_time(time_t _time);
 
+struct running_info_t {
+       int pid;
+       char *appid;
+       bool is_running;
+};
+
 struct filtered_alarm_app_s {
        int is_ui_app;
        uid_t uid;
@@ -1647,6 +1653,17 @@ static int __post_notification(guchar *data, int datalen, uid_t uid)
        return ret;
 }
 
+static int __app_info_iter(const aul_app_info *info, void *data)
+{
+       struct running_info_t *app_info = (struct running_info_t *)data;
+
+       if (app_info->pid == info->pid &&
+                       strcmp(app_info->appid, info->appid) == 0)
+               app_info->is_running = true;
+
+       return 0;
+}
+
 static void __alarm_expired()
 {
        int ret;
@@ -1770,6 +1787,7 @@ static void __alarm_expired()
                } else {
                        char appid[MAX_SERVICE_NAME_LEN] = { 0, };
                        pkgmgrinfo_appinfo_h appinfo_handle = NULL;
+                       struct running_info_t app_info;
 
                        if (g_quark_to_string(__alarm_info->quark_bundle) != NULL && strncmp(g_quark_to_string(__alarm_info->quark_dst_service_name), "null", 4) == 0) {
                                SECURE_LOGD("[alarm-server]:destination is null, so we send expired alarm to %s(%u).",
@@ -1805,7 +1823,16 @@ static void __alarm_expired()
 
                        /* Case #2. The process was killed && App type
                         * This app is launched and owner of DBus connection is changed. and then, expiration noti is sent by DBus. */
-                       if (ret == PMINFO_R_OK && !aul_app_is_running_for_uid(appid, __alarm_info->uid)) {
+
+                       app_info.is_running = false;
+                       if (ret == PMINFO_R_OK) {
+                               app_info.pid = __alarm_info->pid;
+                               app_info.appid = appid;
+                               aul_app_get_all_running_app_info_for_uid(__app_info_iter,
+                                               &app_info, __alarm_info->uid);
+                       }
+
+                       if (ret == PMINFO_R_OK && !app_info.is_running) {
                                __expired_alarm_t *expire_info;
                                char alarm_id_str[32] = { 0, };