diff options
author | Junghoon Park <jh9216.park@samsung.com> | 2016-04-20 16:58:37 +0900 |
---|---|---|
committer | Junghoon Park <jh9216.park@samsung.com> | 2016-04-21 17:11:50 +0900 |
commit | 44d986c1aa231b50b96a66b1f3dbf9e051e95dbc (patch) | |
tree | edfac8fe358fd196e5f9a0dcb073f9c573ab7d56 | |
parent | 4316d2c7f3563ce63123cf7b42a6008b579e82db (diff) | |
download | launchpad-44d986c1aa231b50b96a66b1f3dbf9e051e95dbc.tar.gz launchpad-44d986c1aa231b50b96a66b1f3dbf9e051e95dbc.tar.bz2 launchpad-44d986c1aa231b50b96a66b1f3dbf9e051e95dbc.zip |
Provide detection methods to make candidate processessubmit/tizen/20160422.084925accepted/tizen/wearable/20160425.044149accepted/tizen/tv/20160425.044203accepted/tizen/mobile/20160425.044138accepted/tizen/ivi/20160425.044209accepted/tizen/common/20160422.172203
Change-Id: Ie47b053388c03c69fb744b0c087daeb471e99597
Signed-off-by: Junghoon Park <jh9216.park@samsung.com>
-rw-r--r-- | inc/launchpad_common.h | 1 | ||||
-rwxr-xr-x | src/launchpad.c | 113 |
2 files changed, 70 insertions, 44 deletions
diff --git a/inc/launchpad_common.h b/inc/launchpad_common.h index 546bdf0..d27fe28 100644 --- a/inc/launchpad_common.h +++ b/inc/launchpad_common.h @@ -42,6 +42,7 @@ #define PAD_CMD_ADD_LOADER 11 #define PAD_CMD_REMOVE_LOADER 12 #define PAD_CMD_MAKE_DEFAULT_SLOTS 13 +#define PAD_CMD_DEMAND 14 #define PAD_LOADER_ID_STATIC 0 #define PAD_LOADER_ID_DIRECT 1 diff --git a/src/launchpad.c b/src/launchpad.c index e6c13ea..9a6da8f 100755 --- a/src/launchpad.c +++ b/src/launchpad.c @@ -50,6 +50,10 @@ #define LOADER_PATH_WRT "/usr/bin/wrt-loader" #define LOADER_PATH_JS_NATIVE "/usr/bin/jsnative-loader" +#define METHOD_TIMEOUT 0x1 +#define METHOD_VISIBILITY 0x2 +#define METHOD_DEMAND 0x4 + typedef struct { int type; bool prepared; @@ -63,6 +67,8 @@ typedef struct { char *loader_path; char *loader_extra; bool enabled; + int detection_method; + int timeout_val; } candidate_process_context_t; typedef struct { @@ -73,8 +79,8 @@ typedef struct { static GList *candidate_slot_list; static int sys_hwacc = -1; -static candidate_process_context_t* __add_slot(int type, int loader_id, int caller_pid, const char *loader_path, - const char *extra, bool enabled); +static candidate_process_context_t *__add_slot(int type, int loader_id, int caller_pid, const char *loader_path, + const char *extra, bool enabled, int detection_method, int timeout_val); static int __remove_slot(int type, int loader_id); static int __add_default_slots(); @@ -85,7 +91,7 @@ static int __make_loader_id() return ++id; } -static candidate_process_context_t* __find_slot_from_static_type(int type) +static candidate_process_context_t *__find_slot_from_static_type(int type) { GList *iter = candidate_slot_list; @@ -93,7 +99,7 @@ static candidate_process_context_t* __find_slot_from_static_type(int type) return NULL; while (iter) { - candidate_process_context_t *cpc = (candidate_process_context_t*)iter->data; + candidate_process_context_t *cpc = (candidate_process_context_t *)iter->data; if (type == cpc->type) return cpc; @@ -103,12 +109,12 @@ static candidate_process_context_t* __find_slot_from_static_type(int type) return NULL; } -static candidate_process_context_t* __find_slot_from_pid(int pid) +static candidate_process_context_t *__find_slot_from_pid(int pid) { GList *iter = candidate_slot_list; while (iter) { - candidate_process_context_t *cpc = (candidate_process_context_t*)iter->data; + candidate_process_context_t *cpc = (candidate_process_context_t *)iter->data; if (pid == cpc->pid) return cpc; @@ -118,12 +124,12 @@ static candidate_process_context_t* __find_slot_from_pid(int pid) return NULL; } -static candidate_process_context_t* __find_slot_from_caller_pid(int caller_pid) +static candidate_process_context_t *__find_slot_from_caller_pid(int caller_pid) { GList *iter = candidate_slot_list; while (iter) { - candidate_process_context_t *cpc = (candidate_process_context_t*)iter->data; + candidate_process_context_t *cpc = (candidate_process_context_t *)iter->data; if (caller_pid == cpc->caller_pid) return cpc; @@ -133,12 +139,12 @@ static candidate_process_context_t* __find_slot_from_caller_pid(int caller_pid) return NULL; } -static candidate_process_context_t* __find_slot_from_loader_id(int id) +static candidate_process_context_t *__find_slot_from_loader_id(int id) { GList *iter = candidate_slot_list; while (iter) { - candidate_process_context_t *cpc = (candidate_process_context_t*)iter->data; + candidate_process_context_t *cpc = (candidate_process_context_t *)iter->data; if (id == cpc->loader_id) return cpc; @@ -148,7 +154,7 @@ static candidate_process_context_t* __find_slot_from_loader_id(int id) return NULL; } -static candidate_process_context_t* __find_slot(int type, int loader_id) +static candidate_process_context_t *__find_slot(int type, int loader_id) { if (type == LAUNCHPAD_TYPE_DYNAMIC) return __find_slot_from_loader_id(loader_id); @@ -420,7 +426,7 @@ static int __prepare_candidate_process(int type, int loader_id) static gboolean __handle_preparing_candidate_process(gpointer user_data) { - candidate_process_context_t *cpc = (candidate_process_context_t*)user_data; + candidate_process_context_t *cpc = (candidate_process_context_t *)user_data; __prepare_candidate_process(cpc->type, cpc->loader_id); _D("Prepare another candidate process"); @@ -428,8 +434,18 @@ static gboolean __handle_preparing_candidate_process(gpointer user_data) return G_SOURCE_REMOVE; } +static void __set_timer(candidate_process_context_t *cpc) +{ + if (cpc == NULL) + return; + + if (cpc->detection_method & METHOD_TIMEOUT) + cpc->timer = g_timeout_add(cpc->timeout_val, + __handle_preparing_candidate_process, cpc); +} + static int __send_launchpad_loader(candidate_process_context_t *cpc, app_pkt_t *pkt, - const char *app_path, int clifd, const char *comp_type) + const char *app_path, int clifd) { char sock_path[PATH_MAX]; int pid = -1; @@ -458,11 +474,7 @@ static int __send_launchpad_loader(candidate_process_context_t *cpc, app_pkt_t * cpc->timer = 0; } - if (strcmp("uiapp", comp_type) == 0) - cpc->timer = g_timeout_add(5000, __handle_preparing_candidate_process, cpc); - else - cpc->timer = g_timeout_add(2000, __handle_preparing_candidate_process, cpc); - + __set_timer(cpc); return pid; } @@ -596,7 +608,7 @@ static int __launch_directly(const char *appid, const char *app_path, int clifd, #ifdef _APPFW_FEATURE_LAZY_LOADER if (cpc && !cpc->enabled) { cpc->enabled = true; - cpc->timer = g_timeout_add(5000, __handle_preparing_candidate_process, cpc); + __set_timer(cpc); } #endif @@ -742,7 +754,7 @@ static guint __poll_fd(int fd, gushort events, GSourceFunc func, int type, int l static gboolean __handle_loader_client_event(gpointer data) { - loader_context_t *lc = (loader_context_t*) data; + loader_context_t *lc = (loader_context_t *) data; int type = lc->type; int loader_id = lc->loader_id; gushort revents = lc->gpollfd->revents; @@ -774,7 +786,7 @@ static gboolean __handle_loader_client_event(gpointer data) static gboolean __handle_loader_event(gpointer data) { - loader_context_t *lc = (loader_context_t*) data; + loader_context_t *lc = (loader_context_t *) data; int fd = lc->gpollfd->fd; int type = lc->type; int loader_id = lc->loader_id; @@ -809,7 +821,7 @@ static gboolean __handle_loader_event(gpointer data) static gboolean __handle_sigchild(gpointer data) { - loader_context_t *lc = (loader_context_t*) data; + loader_context_t *lc = (loader_context_t *) data; int fd = lc->gpollfd->fd; struct signalfd_siginfo siginfo; ssize_t s; @@ -842,15 +854,16 @@ static gboolean __handle_sigchild(gpointer data) return G_SOURCE_CONTINUE; } -static int __dispatch_cmd_visibility(bundle *kb) +static int __dispatch_cmd_hint(bundle *kb, int detection_method) { GList *iter = candidate_slot_list; - _W("cmd visibility"); + _W("cmd hint %d", detection_method); while (iter) { - candidate_process_context_t *cpc = (candidate_process_context_t*)iter->data; + candidate_process_context_t *cpc = (candidate_process_context_t *)iter->data; - if (cpc->pid == CANDIDATE_NONE) { + if (cpc->pid == CANDIDATE_NONE && + (cpc->detection_method & detection_method)) { if (cpc->timer > 0) { g_source_remove(cpc->timer); cpc->timer = 0; @@ -878,10 +891,9 @@ static int __dispatch_cmd_add_loader(bundle *kb) if (add_slot_str && caller_pid) { lid = __make_loader_id(); - candidate_process_context_t *cpc = __add_slot(LAUNCHPAD_TYPE_DYNAMIC, lid, atoi(caller_pid), add_slot_str, extra, true); - if (cpc) - cpc->timer = g_timeout_add(2000, __handle_preparing_candidate_process, cpc); - + candidate_process_context_t *cpc = __add_slot(LAUNCHPAD_TYPE_DYNAMIC, lid, + atoi(caller_pid), add_slot_str, extra, true, METHOD_TIMEOUT | METHOD_VISIBILITY, 2000); + __set_timer(cpc); return lid; } @@ -921,7 +933,7 @@ static int __check_caller_by_pid(int pid) static gboolean __handle_launch_event(gpointer data) { - loader_context_t *lc = (loader_context_t*) data; + loader_context_t *lc = (loader_context_t *) data; int fd = lc->gpollfd->fd; bundle *kb = NULL; app_pkt_t *pkt = NULL; @@ -956,7 +968,7 @@ static gboolean __handle_launch_event(gpointer data) switch (pkt->cmd) { case PAD_CMD_VISIBILITY: - ret = __dispatch_cmd_visibility(kb); + ret = __dispatch_cmd_hint(kb, METHOD_VISIBILITY); __real_send(clifd, ret); clifd = -1; goto end; @@ -977,6 +989,11 @@ static gboolean __handle_launch_event(gpointer data) __real_send(clifd, ret); clifd = -1; goto end; + case PAD_CMD_DEMAND: + ret = __dispatch_cmd_hint(kb, METHOD_DEMAND); + __real_send(clifd, ret); + clifd = -1; + goto end; } INIT_PERF(kb); @@ -1041,12 +1058,12 @@ static gboolean __handle_launch_event(gpointer data) } else { if (cpc->prepared) { _W("Launch %d type process", type); - pid = __send_launchpad_loader(cpc, pkt, app_path, clifd, menu_info->comp_type); + pid = __send_launchpad_loader(cpc, pkt, app_path, clifd); } else if (cpc->type == LAUNCHPAD_TYPE_SW || cpc->type == LAUNCHPAD_TYPE_HW) { cpc = __find_slot(LAUNCHPAD_TYPE_COMMON, loader_id); if (cpc != NULL && cpc->prepared) { _W("Launch common type process"); - pid = __send_launchpad_loader(cpc, pkt, app_path, clifd, menu_info->comp_type); + pid = __send_launchpad_loader(cpc, pkt, app_path, clifd); } else { _W("Launch directly"); pid = __launch_directly(menu_info->appid, app_path, clifd, kb, menu_info, NULL); @@ -1079,8 +1096,8 @@ end: return G_SOURCE_CONTINUE; } -static candidate_process_context_t* __add_slot(int type, int loader_id, int caller_pid, const char *loader_path, - const char *loader_extra, bool enabled) +static candidate_process_context_t *__add_slot(int type, int loader_id, int caller_pid, const char *loader_path, + const char *loader_extra, bool enabled, int detection_method, int timeout_val) { candidate_process_context_t *cpc; int fd = -1; @@ -1088,7 +1105,7 @@ static candidate_process_context_t* __add_slot(int type, int loader_id, int call if (__find_slot(type, loader_id) != NULL) return NULL; - cpc = (candidate_process_context_t*)malloc(sizeof(candidate_process_context_t)); + cpc = (candidate_process_context_t *)malloc(sizeof(candidate_process_context_t)); if (cpc == NULL) return NULL; @@ -1104,6 +1121,8 @@ static candidate_process_context_t* __add_slot(int type, int loader_id, int call cpc->loader_path = strdup(loader_path); cpc->loader_extra = loader_extra ? strdup(loader_extra) : NULL; cpc->enabled = enabled; + cpc->detection_method = detection_method; + cpc->timeout_val = timeout_val; fd = __listen_candidate_process(cpc->type, cpc->loader_id); if (fd == -1) { @@ -1130,7 +1149,7 @@ static int __remove_slot(int type, int loader_id) iter = candidate_slot_list; while (iter) { - candidate_process_context_t *cpc = (candidate_process_context_t*)iter->data; + candidate_process_context_t *cpc = (candidate_process_context_t *)iter->data; if (type == cpc->type && loader_id == cpc->loader_id) { if (cpc->pid > 0) @@ -1193,27 +1212,32 @@ static int __init_sigchild_fd(void) static int __add_default_slots() { - if (__add_slot(LAUNCHPAD_TYPE_COMMON, PAD_LOADER_ID_STATIC, 0, LOADER_PATH_DEFAULT, NULL, true) == NULL) + if (__add_slot(LAUNCHPAD_TYPE_COMMON, PAD_LOADER_ID_STATIC, 0, LOADER_PATH_DEFAULT, + NULL, true, METHOD_TIMEOUT | METHOD_VISIBILITY, 5000) == NULL) return -1; if (__prepare_candidate_process(LAUNCHPAD_TYPE_COMMON, PAD_LOADER_ID_STATIC) != 0) return -1; - if (__add_slot(LAUNCHPAD_TYPE_SW, PAD_LOADER_ID_STATIC, 0, LOADER_PATH_DEFAULT, NULL, true) == NULL) + if (__add_slot(LAUNCHPAD_TYPE_SW, PAD_LOADER_ID_STATIC, 0, LOADER_PATH_DEFAULT, + NULL, true, METHOD_TIMEOUT | METHOD_VISIBILITY, 5000) == NULL) return -1; if (__prepare_candidate_process(LAUNCHPAD_TYPE_SW, PAD_LOADER_ID_STATIC) != 0) return -1; - if (__add_slot(LAUNCHPAD_TYPE_HW, PAD_LOADER_ID_STATIC, 0, LOADER_PATH_DEFAULT, NULL, true) == NULL) + if (__add_slot(LAUNCHPAD_TYPE_HW, PAD_LOADER_ID_STATIC, 0, LOADER_PATH_DEFAULT, + NULL, true, METHOD_TIMEOUT | METHOD_VISIBILITY, 5000) == NULL) return -1; if (__prepare_candidate_process(LAUNCHPAD_TYPE_HW, PAD_LOADER_ID_STATIC) != 0) return -1; if (access(LOADER_PATH_WRT, F_OK | X_OK) == 0) { #ifdef _APPFW_FEATURE_LAZY_LOADER - if (__add_slot(LAUNCHPAD_TYPE_WRT, PAD_LOADER_ID_STATIC, 0, LOADER_PATH_WRT, NULL, false) == NULL) + if (__add_slot(LAUNCHPAD_TYPE_WRT, PAD_LOADER_ID_STATIC, 0, LOADER_PATH_WRT, + NULL, false, METHOD_TIMEOUT | METHOD_DEMAND, 5000) == NULL) return -1; #else - if (__add_slot(LAUNCHPAD_TYPE_WRT, PAD_LOADER_ID_STATIC, 0, LOADER_PATH_WRT, NULL, true) == NULL) + if (__add_slot(LAUNCHPAD_TYPE_WRT, PAD_LOADER_ID_STATIC, 0, LOADER_PATH_WRT, + NULL, true, METHOD_TIMEOUT | METHOD_DEMAND, 5000) == NULL) return -1; if (__prepare_candidate_process(LAUNCHPAD_TYPE_WRT, PAD_LOADER_ID_STATIC) != 0) return -1; @@ -1221,7 +1245,8 @@ static int __add_default_slots() } if (access(LOADER_PATH_JS_NATIVE, F_OK | X_OK) == 0) { - if (__add_slot(LAUNCHPAD_TYPE_JS_NATIVE, PAD_LOADER_ID_STATIC, 0, LOADER_PATH_JS_NATIVE, NULL, true) == NULL) + if (__add_slot(LAUNCHPAD_TYPE_JS_NATIVE, PAD_LOADER_ID_STATIC, 0, LOADER_PATH_JS_NATIVE, + NULL, true, METHOD_TIMEOUT | METHOD_VISIBILITY, 5000) == NULL) return -1; if (__prepare_candidate_process(LAUNCHPAD_TYPE_JS_NATIVE, PAD_LOADER_ID_STATIC) != 0) return -1; |