diff options
-rw-r--r-- | inc/launchpad_common.h | 4 | ||||
-rwxr-xr-x | src/launchpad.c | 56 |
2 files changed, 32 insertions, 28 deletions
diff --git a/inc/launchpad_common.h b/inc/launchpad_common.h index 86cd679..48c4a95 100644 --- a/inc/launchpad_common.h +++ b/inc/launchpad_common.h @@ -41,6 +41,10 @@ #define PAD_CMD_ADD_LOADER 11 #define PAD_CMD_REMOVE_LOADER 12 +#define PAD_LOADER_ID_STATIC 0 +#define PAD_LOADER_ID_DIRECT 1 +#define PAD_LOADER_ID_DYNAMIC_BASE 10 + #define _E(fmt, arg...) LOGE(fmt, ##arg) #define _D(fmt, arg...) LOGD(fmt, ##arg) #define _W(fmt, arg...) LOGW(fmt, ##arg) diff --git a/src/launchpad.c b/src/launchpad.c index 00b1dd3..bfcab22 100755 --- a/src/launchpad.c +++ b/src/launchpad.c @@ -72,7 +72,7 @@ static int __remove_slot(int type, int loader_id); static int __make_loader_id() { - static int id = 0; + static int id = PAD_LOADER_ID_DYNAMIC_BASE; return ++id; } @@ -899,6 +899,7 @@ static gboolean __handle_launch_event(gpointer data) bundle *kb = NULL; app_pkt_t *pkt = NULL; appinfo_t *menu_info = NULL; + candidate_process_context_t *cpc; const char *app_path = NULL; int pid = -1; @@ -906,7 +907,6 @@ static gboolean __handle_launch_event(gpointer data) struct ucred cr; int type = -1; int loader_id; - int i; int ret; pkt = _recv_pkt_raw(fd, &clifd, &cr); @@ -970,13 +970,13 @@ static gboolean __handle_launch_event(gpointer data) SECURE_LOGD("internal pool : %s\n", menu_info->internal_pool); SECURE_LOGD("hwacc : %s\n", menu_info->hwacc); - if ((loader_id = __get_loader_id(kb)) < 0) { + if ((loader_id = __get_loader_id(kb)) <= PAD_LOADER_ID_STATIC) { type = __get_launchpad_type(menu_info->internal_pool, menu_info->hwacc); if (type < 0) { _E("failed to get launchpad type"); goto end; } - loader_id = 0; + loader_id = PAD_LOADER_ID_STATIC; } else { type = LAUNCHPAD_TYPE_DYNAMIC; } @@ -988,32 +988,32 @@ static gboolean __handle_launch_event(gpointer data) } PERF("get package information & modify bundle done"); - candidate_process_context_t *cpc = __find_slot(type, loader_id); - - for (i = 0; i < 2; i++) { - if (cpc == NULL) - break; + if (loader_id == PAD_LOADER_ID_DIRECT || + (cpc = __find_slot(type, loader_id)) == NULL) { + _W("Launch directly"); + pid = __launch_directly(menu_info->appid, app_path, clifd, kb, menu_info); + } else { if (cpc->prepared) { - _W("Launch on type-based process-pool"); + _W("Launch %d type process", type); pid = __send_launchpad_loader(cpc, pkt, app_path, clifd, menu_info->comp_type); - clifd = -1; - goto end; - } - - if (cpc->type == LAUNCHPAD_TYPE_SW || cpc->type == LAUNCHPAD_TYPE_HW) { - cpc = __find_slot(LAUNCHPAD_TYPE_COMMON, 0); - continue; + } 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); + } else { + _W("Launch directly"); + pid = __launch_directly(menu_info->appid, app_path, clifd, kb, menu_info); + } + } else { + _W("Launch directly"); + pid = __launch_directly(menu_info->appid, app_path, clifd, kb, menu_info); } - - break; } - _W("Candidate is not prepared"); - pid = __launch_directly(menu_info->appid, app_path, clifd, kb, menu_info); __send_result_to_caller(clifd, pid, app_path); clifd = -1; - end: if (clifd != -1) close(clifd); @@ -1137,19 +1137,19 @@ static int __init_sigchild_fd(void) static int __add_default_slots() { - if (__add_slot(LAUNCHPAD_TYPE_COMMON, 0, 0, LOADER_PATH_DEFAULT) == NULL) + if (__add_slot(LAUNCHPAD_TYPE_COMMON, PAD_LOADER_ID_STATIC, 0, LOADER_PATH_DEFAULT) == NULL) return -1; - if (__prepare_candidate_process(LAUNCHPAD_TYPE_COMMON, 0) != 0) + if (__prepare_candidate_process(LAUNCHPAD_TYPE_COMMON, PAD_LOADER_ID_STATIC) != 0) return -1; - if (__add_slot(LAUNCHPAD_TYPE_SW, 0, 0, LOADER_PATH_DEFAULT) == NULL) + if (__add_slot(LAUNCHPAD_TYPE_SW, PAD_LOADER_ID_STATIC, 0, LOADER_PATH_DEFAULT) == NULL) return -1; - if (__prepare_candidate_process(LAUNCHPAD_TYPE_SW, 0) != 0) + if (__prepare_candidate_process(LAUNCHPAD_TYPE_SW, PAD_LOADER_ID_STATIC) != 0) return -1; - if (__add_slot(LAUNCHPAD_TYPE_HW, 0, 0, LOADER_PATH_DEFAULT) == NULL) + if (__add_slot(LAUNCHPAD_TYPE_HW, PAD_LOADER_ID_STATIC, 0, LOADER_PATH_DEFAULT) == NULL) return -1; - if (__prepare_candidate_process(LAUNCHPAD_TYPE_HW, 0) != 0) + if (__prepare_candidate_process(LAUNCHPAD_TYPE_HW, PAD_LOADER_ID_STATIC) != 0) return -1; return 0; |