send app signal regarding lifecycle events 48/53348/4 accepted/tizen/mobile/20151206.223946 accepted/tizen/tv/20151206.224005 accepted/tizen/wearable/20151206.224020 submit/tizen/20151204.074112
authorDaehyeon Jung <darrenh.jung@samsung.com>
Fri, 4 Dec 2015 06:49:55 +0000 (15:49 +0900)
committerDaehyeon Jung <darrenh.jung@samsung.com>
Fri, 4 Dec 2015 07:32:01 +0000 (16:32 +0900)
Change-Id: I436d7d3a3e259b7add0f035db6e2ce09b9bec3aa
Signed-off-by: Daehyeon Jung <darrenh.jung@samsung.com>
am_daemon/amd_app_group.c
am_daemon/amd_launch.c
am_daemon/amd_main.c
am_daemon/amd_request.c

index 7623175..4a9c164 100644 (file)
@@ -218,14 +218,15 @@ static void __prepare_to_wake_services(int pid)
        SECURE_LOGD("[__SUSPEND__] pid: %d", pid);
        __app_send_raw_with_noreply(pid, APP_WAKE, (unsigned char *)&dummy, sizeof(int));
 }
-
+*/
 static void __set_fg_flag(int cpid, int flag, gboolean force)
 {
        int lpid = app_group_get_leader_pid(cpid);
        GHashTableIter iter;
        gpointer key, value;
+/* BG management
        int bg_category = 0x00;
-
+*/
        g_hash_table_iter_init(&iter, app_group_hash);
        while (g_hash_table_iter_next(&iter, &key, &value)) {
                GList *list = (GList*) value;
@@ -245,8 +246,9 @@ static void __set_fg_flag(int cpid, int flag, gboolean force)
                                        appid = _status_app_get_appid_bypid(ac->pid);
                                        ai = appinfo_find(getuid(), appid);
                                        pkgid = appinfo_get_value(ai, AIT_PKGID);
+/* BG management
                                        bg_category = (bool)appinfo_get_value(ai, AIT_BG_CATEGORY);
-
+*/
                                        if (flag) {
                                                _D("send_signal FG %s", appid);
 
@@ -254,16 +256,20 @@ static void __set_fg_flag(int cpid, int flag, gboolean force)
                                                                                pkgid,
                                                                                STATUS_FOREGROUND,
                                                                                APP_TYPE_UI);
+/* BG management
                                                if (!bg_category)
                                                        _status_find_service_apps(ac->pid, STATUS_VISIBLE, __prepare_to_wake_services, false);
+*/
                                        } else {
                                                _D("send_signal BG %s", appid);
                                                aul_send_app_status_change_signal(ac->pid, appid,
                                                                                pkgid,
                                                                                STATUS_BACKGROUND,
                                                                                APP_TYPE_UI);
+/* BG management
                                                if (!bg_category)
                                                        _status_find_service_apps(ac->pid, STATUS_BG, __prepare_to_suspend_services, true);
+*/
                                        }
                                        ac->fg = flag;
                                }
@@ -273,7 +279,6 @@ static void __set_fg_flag(int cpid, int flag, gboolean force)
                }
        }
 }
-*/
 
 static gboolean __is_visible(int cpid)
 {
@@ -928,7 +933,7 @@ int app_group_set_status(int pid, int status, gboolean force)
 
                                if (last_ac->wid != 0 || status == STATUS_VISIBLE || force == TRUE) {
                                        if (__is_visible(pid)) {
-                                               //__set_fg_flag(pid, 1, force);
+                                               __set_fg_flag(pid, 1, force);
                                                if (!ac->group_sig && GPOINTER_TO_INT(key) != pid) {
                                                        char *appid = NULL;
                                                        const char *pkgid = NULL;
@@ -942,8 +947,8 @@ int app_group_set_status(int pid, int status, gboolean force)
                                                        aul_send_app_group_signal(GPOINTER_TO_INT(key), pid, pkgid);
                                                        ac->group_sig = 1;
                                                }
-                                       } /*else
-                                               __set_fg_flag(pid, 0, force);*/
+                                       } else
+                                               __set_fg_flag(pid, 0, force);
                                }
                                return 0;
                        }
index d7e1e0f..c4fc1e0 100644 (file)
@@ -822,6 +822,7 @@ int _start_app(const char* appid, bundle* kb, int cmd, int caller_pid,
                        SECURE_LOGD("caller process & callee process is same.[%s:%d]", appid, pid);
                        pid = -ELOCALLAUNCH_ID;
                } else {
+                       aul_send_app_resume_request_signal(pid, appid, pkg_id, component_type);
                        if ((ret = __nofork_processing(cmd, pid, kb, fd)) < 0)
                                pid = ret;
                        else
@@ -842,6 +843,8 @@ int _start_app(const char* appid, bundle* kb, int cmd, int caller_pid,
                bundle_add(kb, AUL_K_INTERNAL_POOL, process_pool);
                bundle_add(kb, AUL_K_COMP_TYPE, component_type);
                pid = app_agent_send_cmd(caller_uid, cmd, kb);
+               if (pid > 0)
+                       aul_send_app_launch_request_signal(pid, appid, pkg_id, component_type);
        }
 
        if (pid > 0) {
index 013cc93..4942226 100644 (file)
@@ -100,6 +100,7 @@ static int __kill_bg_apps(int limit)
 
        for (i = 0, iter = r_app_info_list; i < n; i++) {
                info_t = (r_app_info_t *)iter->data;
+               aul_send_app_terminate_request_signal(info_t->pid, NULL, NULL, NULL);
                __send_to_sigkill(info_t->pid);
                iter = g_slist_next(iter);
                r_app_info_list = g_slist_remove(r_app_info_list, info_t);
@@ -369,6 +370,7 @@ static int __app_dead_handler(int pid, void *data)
 
        __remove_item_running_list(pid, getuid());
        _status_remove_app_info_list(pid, getuid());
+       aul_send_app_terminated_signal(pid);
 
        if (restart)
                _start_app_local(getuid(), appid);
index d412810..690c447 100644 (file)
@@ -234,6 +234,9 @@ static int __app_process_by_pid(int cmd,
        int ret;
        int dummy;
        char *appid;
+       const char *pkgid = NULL;
+       const char *type = NULL;
+       const struct appinfo *ai = NULL;
 
        if (pkg_name == NULL)
                return -1;
@@ -251,6 +254,17 @@ static int __app_process_by_pid(int cmd,
                return -1;
        }
 
+       ai = appinfo_find(cr->uid, appid);
+       if (ai) {
+               pkgid = appinfo_get_value(ai, AIT_PKGID);
+               type = appinfo_get_value(ai, AIT_COMP);
+       }
+
+       if (ai && (cmd == APP_RESUME_BY_PID || cmd == APP_PAUSE_BY_PID))
+               aul_send_app_resume_request_signal(pid, appid, pkgid, type);
+       else
+               aul_send_app_terminate_request_signal(pid, appid, pkgid, type);
+
        switch (cmd) {
        case APP_RESUME_BY_PID:
                ret = _resume_app(pid, clifd);