From: Junghoon Park Date: Wed, 2 Dec 2015 00:43:22 +0000 (+0900) Subject: Make candidate processes after an app is resumed X-Git-Tag: accepted/tizen/mobile/20151202.041002^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=caa33930a3ec017ca3fbf986facfbfa07071bad3;p=platform%2Fcore%2Fappfw%2Faul-1.git Make candidate processes after an app is resumed Change-Id: I52042baad1dd983e982cdef95ceca8feac60561f Signed-off-by: Junghoon Park --- diff --git a/am_daemon/amd_launch.c b/am_daemon/amd_launch.c index 2a2b946..d7e1e0f 100644 --- a/am_daemon/amd_launch.c +++ b/am_daemon/amd_launch.c @@ -74,6 +74,8 @@ typedef struct { char *pkg_type; } app_info_from_pkgmgr; +static int __pid_of_last_launched_ui_app; + static void __set_reply_handler(int fd, int pid, int clifd, int cmd); static void __real_send(int clifd, int ret); static int __nofork_processing(int cmd, int pid, bundle * kb, int clifd); @@ -90,52 +92,8 @@ static void __set_stime(bundle *kb) int _start_app_local_with_bundle(uid_t uid, const char *appid, bundle *kb) { - int ret; - int pid; - const struct appinfo *ai; - const char *app_path; - const char *pkg_type; - const char *pkg_id; - const char *hwacc; - const char *process_pool; - char tmpbuf[MAX_PID_STR_BUFSZ]; - - snprintf(tmpbuf, sizeof(tmpbuf), "%d", getpid()); - bundle_add_str(kb, AUL_K_CALLER_PID, tmpbuf); - snprintf(tmpbuf, sizeof(tmpbuf), "%d", uid); - bundle_add_str(kb, AUL_K_CALLER_UID, tmpbuf); - bundle_add_str(kb, AUL_K_APPID, appid); - - pid = _status_app_is_running(appid, uid); - if (pid > 0) { - ret = __nofork_processing(APP_START, pid, kb, -1); - return ret; - } - - ai = appinfo_find(uid, appid); - if (ai == NULL) { - _E("cannot find appinfo of %s", appid); - return -1; - } - - hwacc = appinfo_get_value(ai, AIT_HWACC); - app_path = appinfo_get_value(ai, AIT_EXEC); - pkg_type = appinfo_get_value(ai, AIT_TYPE); - pkg_id = appinfo_get_value(ai, AIT_PKGID); - process_pool = appinfo_get_value(ai, AIT_POOL); - __set_stime(kb); - bundle_add_str(kb, AUL_K_HWACC, hwacc); - bundle_add_str(kb, AUL_K_EXEC, app_path); - bundle_add_str(kb, AUL_K_PACKAGETYPE, pkg_type); - bundle_add_str(kb, AUL_K_PKGID, pkg_id); - bundle_add_str(kb, AUL_K_INTERNAL_POOL, process_pool); - - pid = app_agent_send_cmd(uid, APP_START, kb); - if (pid > 0) - _status_add_app_info_list(appid, app_path, pid, LAUNCHPAD_PID, uid); - - return pid; + return _start_app(appid, kb, APP_START, getpid(), uid, -1); } int _start_app_local(uid_t uid, const char *appid) @@ -737,11 +695,32 @@ static int __check_app_control_privilege(int fd, const char *operation) return 0; } +int _send_hint_for_visibility(uid_t uid) +{ + bundle *b = NULL; + int ret; + + b = bundle_create(); + + ret = app_agent_send_cmd(uid, PAD_CMD_VISIBILITY, b); + + if (b) + bundle_free(b); + __pid_of_last_launched_ui_app = 0; + + return ret; +} + +int _get_pid_of_last_launched_ui_app() +{ + return __pid_of_last_launched_ui_app; +} + int _start_app(const char* appid, bundle* kb, int cmd, int caller_pid, uid_t caller_uid, int fd) { + int ret; const struct appinfo *ai; - int ret = -1; const char *status; const char *multiple = NULL; const char *app_path = NULL; @@ -756,11 +735,10 @@ int _start_app(const char* appid, bundle* kb, int cmd, int caller_pid, const char *hwacc; char *caller_appid; int delay_reply = 0; - int pad_pid = LAUNCHPAD_PID; int lpid; int callee_status = -1; - gboolean can_attach; - gboolean new_process; + gboolean can_attach = FALSE; + gboolean new_process = FALSE; app_group_launch_mode launch_mode; snprintf(tmpbuf, MAX_PID_STR_BUFSZ, "%d", caller_pid); @@ -849,7 +827,7 @@ int _start_app(const char* appid, bundle* kb, int cmd, int caller_pid, else delay_reply = 1; } - } else if (cmd != APP_RESUME) { + } else { if (callee_status == STATUS_DYING && pid > 0) { ret = kill(pid, SIGKILL); if (ret == -1) @@ -862,23 +840,23 @@ int _start_app(const char* appid, bundle* kb, int cmd, int caller_pid, bundle_add(kb, AUL_K_PACKAGETYPE, pkg_type); bundle_add(kb, AUL_K_PKGID, pkg_id); 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) { + _status_add_app_info_list(appid, app_path, pid, LAUNCHPAD_PID, caller_uid); if (strncmp(component_type, APP_TYPE_UI, strlen(APP_TYPE_UI)) == 0) { if (new_process) { _D("add app group info"); + __pid_of_last_launched_ui_app = pid; app_group_start_app(pid, kb, lpid, can_attach, launch_mode); } else { app_group_restart_app(pid, kb); } } - } else { - _E("Unknown application: %s", appid); } - if (pid > 0) - _status_add_app_info_list(appid, app_path, pid, pad_pid, caller_uid); - if (!delay_reply) __real_send(fd, pid); diff --git a/am_daemon/amd_launch.h b/am_daemon/amd_launch.h index 212124d..5c57d20 100644 --- a/am_daemon/amd_launch.h +++ b/am_daemon/amd_launch.h @@ -37,5 +37,8 @@ int _fake_launch_app(int cmd, int pid, bundle * kb, int clifd); int _start_app(const char* appid, bundle* kb, int cmd, int caller_pid, uid_t caller_uid, int fd); int _start_app_local(uid_t uid, const char *appid); int _start_app_local_with_bundle(uid_t uid, const char *appid, bundle *kb); +int _get_pid_of_last_launched_ui_app(); +int _send_hint_for_visibility(uid_t uid); + #endif /* __AUL_AMD_LAUNCH_H_ */ diff --git a/am_daemon/amd_request.c b/am_daemon/amd_request.c index 80f4f5d..637c78be 100644 --- a/am_daemon/amd_request.c +++ b/am_daemon/amd_request.c @@ -888,6 +888,8 @@ static int __dispatch_app_status_update(int clifd, const app_pkt_t *pkt, struct ai = appinfo_find(cr->uid, appid); appinfo_set_value((struct appinfo *)ai, AIT_STATUS, "norestart"); } else { + if (*status == STATUS_VISIBLE && cr->pid == _get_pid_of_last_launched_ui_app()) + _send_hint_for_visibility(cr->uid); _status_update_app_info_list(cr->pid, *status, cr->uid); } close(clifd); diff --git a/include/app_sock.h b/include/app_sock.h index ed3866e..d9a4594 100644 --- a/include/app_sock.h +++ b/include/app_sock.h @@ -87,6 +87,9 @@ enum app_cmd { #define ENOLAUNCHPAD 125 #define EREJECTED 123 +#define PAD_CMD_LAUNCH 0 +#define PAD_CMD_VISIBILITY 10 + typedef struct _app_pkt_t { int cmd; int len; diff --git a/include/aul.h b/include/aul.h index 163bd01..981b702 100644 --- a/include/aul.h +++ b/include/aul.h @@ -155,6 +155,8 @@ typedef enum _aul_type{ #define AUL_K_INTERNAL_POOL "__AUL_INTERNAL_POOL__" /** AUL internal private key */ #define AUL_TEP_PATH "_AUL_TEP_PATH_" +/** AUL internal private key */ +#define AUL_K_COMP_TYPE "__AUL_COMP_TYPE__" /** * @brief This is callback function for aul_launch_init