From 3114f9321953be421614e304a80d55a9710e893c Mon Sep 17 00:00:00 2001 From: Junghoon Park Date: Wed, 1 Jun 2016 20:20:33 +0900 Subject: [PATCH] Reuse h/w type loader to reduce idle memory - remove common type and s/w type loader - convert h/w type loader to common type and s/w type if they are needed Change-Id: I05130276d12457272f731df64a8721c9cac0ef11 Signed-off-by: Junghoon Park --- CMakeLists.txt | 2 +- inc/launchpad.h | 2 - src/launchpad.c | 88 +--------------------------------- src/launchpad_common.c | 2 - src/launchpad_lib.c | 5 ++ src/launchpad_loader.c | 127 ++++++++++++++++++++++++++++++++++--------------- 6 files changed, 96 insertions(+), 130 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e7eceb5..ac63d95 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,6 @@ INCLUDE(FindPkgConfig) PKG_CHECK_MODULES(${this_target_pool} REQUIRED dlog libsystemd-daemon - vconf security-manager bundle gio-2.0 @@ -26,6 +25,7 @@ PKG_CHECK_MODULES(${this_target_loader} REQUIRED security-manager bundle aul + vconf ) FOREACH(flag ${${this_target_loader}_CFLAGS}) diff --git a/inc/launchpad.h b/inc/launchpad.h index b8508c2..5f8364a 100644 --- a/inc/launchpad.h +++ b/inc/launchpad.h @@ -51,8 +51,6 @@ typedef struct { enum LAUNCHPAD_TYPE { LAUNCHPAD_TYPE_UNSUPPORTED = -1, - LAUNCHPAD_TYPE_COMMON, - LAUNCHPAD_TYPE_SW, LAUNCHPAD_TYPE_HW, LAUNCHPAD_TYPE_USER, LAUNCHPAD_TYPE_DYNAMIC = 100, diff --git a/src/launchpad.c b/src/launchpad.c index 05162bf..17a26f5 100755 --- a/src/launchpad.c +++ b/src/launchpad.c @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include @@ -75,7 +74,6 @@ typedef struct { static GList *loader_info_list; static int user_slot_offset; 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, int detection_method, int timeout_val); @@ -300,30 +298,7 @@ static int __get_launchpad_type(const char *internal_pool, const char *hwacc, if (type >= LAUNCHPAD_TYPE_USER) return type; - if (internal_pool && strcmp(internal_pool, "true") == 0 && hwacc) { - if (strcmp(hwacc, "NOT_USE") == 0) { - _D("[launchpad] launchpad type: S/W(%d)", - LAUNCHPAD_TYPE_SW); - return LAUNCHPAD_TYPE_SW; - } else if (strcmp(hwacc, "USE") == 0) { - _D("[launchpad] launchpad type: H/W(%d)", - LAUNCHPAD_TYPE_HW); - return LAUNCHPAD_TYPE_HW; - } else if (strcmp(hwacc, "SYS") == 0) { - if (sys_hwacc == SETTING_HW_ACCELERATION_ON) { - _D("[launchpad] launchpad type: H/W(%d)", - LAUNCHPAD_TYPE_HW); - return LAUNCHPAD_TYPE_HW; - } else if (sys_hwacc == SETTING_HW_ACCELERATION_OFF) { - _D("[launchpad] launchpad type: S/W(%d)", - LAUNCHPAD_TYPE_SW); - return LAUNCHPAD_TYPE_SW; - } - } - } - - _D("[launchpad] launchpad type: COMMON(%d)", LAUNCHPAD_TYPE_COMMON); - return LAUNCHPAD_TYPE_COMMON; + return LAUNCHPAD_TYPE_HW; } static int __get_loader_id(bundle *kb) @@ -1072,19 +1047,6 @@ static gboolean __handle_launch_event(gpointer data) _W("Launch %d type process", 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); - } else { - _W("Launch directly"); - pid = __launch_directly(menu_info->appid, - app_path, clifd, kb, menu_info, - NULL); - } } else { _W("Launch directly"); pid = __launch_directly(menu_info->appid, app_path, @@ -1290,28 +1252,6 @@ static int __add_default_slots(void) candidate_process_context_t *cpc; int ret; - cpc = __add_slot(LAUNCHPAD_TYPE_COMMON, PAD_LOADER_ID_STATIC, 0, - LOADER_PATH_DEFAULT, NULL, - METHOD_TIMEOUT | METHOD_VISIBILITY, 5000); - if (cpc == NULL) - return -1; - - ret = __prepare_candidate_process(LAUNCHPAD_TYPE_COMMON, - PAD_LOADER_ID_STATIC); - if (ret != 0) - return -1; - - cpc = __add_slot(LAUNCHPAD_TYPE_SW, PAD_LOADER_ID_STATIC, 0, - LOADER_PATH_DEFAULT, NULL, - METHOD_TIMEOUT | METHOD_VISIBILITY, 5000); - if (cpc == NULL) - return -1; - - ret = __prepare_candidate_process(LAUNCHPAD_TYPE_SW, - PAD_LOADER_ID_STATIC); - if (ret != 0) - return -1; - cpc = __add_slot(LAUNCHPAD_TYPE_HW, PAD_LOADER_ID_STATIC, 0, LOADER_PATH_DEFAULT, NULL, METHOD_TIMEOUT | METHOD_VISIBILITY, 5000); @@ -1327,17 +1267,6 @@ static int __add_default_slots(void) return 0; } -static void __vconf_cb(keynode_t *key, void *data) -{ - const char *name; - - name = vconf_keynode_get_name(key); - if (name && strcmp(name, VCONFKEY_SETAPPL_APP_HW_ACCELERATION) == 0) { - sys_hwacc = vconf_keynode_get_int(key); - SECURE_LOGD("sys hwacc: %d", sys_hwacc); - } -} - static int __before_loop(int argc, char **argv) { int ret; @@ -1354,21 +1283,6 @@ static int __before_loop(int argc, char **argv) return -1; } - ret = vconf_get_int(VCONFKEY_SETAPPL_APP_HW_ACCELERATION, &sys_hwacc); - if (ret != VCONF_OK) { - _E("Failed to get vconf int: %s", - VCONFKEY_SETAPPL_APP_HW_ACCELERATION); - } - - SECURE_LOGD("sys hwacc: %d", sys_hwacc); - - ret = vconf_notify_key_changed(VCONFKEY_SETAPPL_APP_HW_ACCELERATION, - __vconf_cb, NULL); - if (ret != 0) { - _E("Failed to register callback for %s", - VCONFKEY_SETAPPL_APP_HW_ACCELERATION); - } - return 0; } diff --git a/src/launchpad_common.c b/src/launchpad_common.c index 5403984..2fc5392 100644 --- a/src/launchpad_common.c +++ b/src/launchpad_common.c @@ -506,11 +506,9 @@ void _modify_bundle(bundle *kb, int caller_pid, appinfo_t *menu_info, int cmd) bundle_del(kb, AUL_K_EXEC); bundle_del(kb, AUL_K_APP_TYPE); bundle_del(kb, AUL_K_PACKAGETYPE); - bundle_del(kb, AUL_K_HWACC); bundle_del(kb, AUL_K_TASKMANAGE); bundle_del(kb, AUL_K_PKGID); bundle_del(kb, AUL_K_COMP_TYPE); - bundle_del(kb, AUL_K_INTERNAL_POOL); /* Parse app_path to retrieve default bundle*/ if (cmd == PAD_CMD_LAUNCH) { diff --git a/src/launchpad_lib.c b/src/launchpad_lib.c index bf25473..7ca5aab 100644 --- a/src/launchpad_lib.c +++ b/src/launchpad_lib.c @@ -380,6 +380,11 @@ static int __after_loop(void) return -1; } +bundle *launchpad_loader_get_bundle() +{ + return __bundle; +} + API int launchpad_loader_main(int argc, char **argv, loader_lifecycle_callback_s *callbacks, loader_adapter_s *adapter, void *user_data) diff --git a/src/launchpad_loader.c b/src/launchpad_loader.c index 9d742f3..d24eee7 100644 --- a/src/launchpad_loader.c +++ b/src/launchpad_loader.c @@ -26,68 +26,92 @@ #include #include #include +#include #include "launchpad_common.h" #include "preload.h" #include "process_pool_preload.h" #include "launchpad.h" +extern bundle *launchpad_loader_get_bundle(); + static Ecore_Fd_Handler *__fd_handler; static loader_receiver_cb __receiver; static int __argc; static char **__argv; +static int __sys_hwacc; +static Evas_Object *__win; +static Evas_Object *__bg; +static Evas_Object *__conform; -static void __init_window(void) +static void __vconf_cb(keynode_t *key, void *data) { - Evas_Object *win; - Evas_Object *bg; - Evas_Object *conform; + const char *name; + + name = vconf_keynode_get_name(key); + if (name && strcmp(name, VCONFKEY_SETAPPL_APP_HW_ACCELERATION) == 0) { + __sys_hwacc = vconf_keynode_get_int(key); + _D("sys hwacc: %d", __sys_hwacc); + } +} - win = elm_win_add(NULL, "package_name", ELM_WIN_BASIC); - if (win == NULL) { +static void __init_window(void) +{ + __win = elm_win_add(NULL, "package_name", ELM_WIN_BASIC); + if (__win == NULL) { _E("[candidate] elm_win_add() failed"); return; } - elm_win_precreated_object_set(win); + elm_win_precreated_object_set(__win); - bg = elm_bg_add(win); - if (bg) { - evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, + __bg = elm_bg_add(__win); + if (__bg) { + evas_object_size_hint_weight_set(__bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - elm_win_resize_object_add(win, bg); - elm_bg_precreated_object_set(bg); + elm_win_resize_object_add(__win, __bg); + elm_bg_precreated_object_set(__bg); } else { _E("[candidate] elm_bg_add() failed"); } - conform = elm_conformant_add(win); - if (conform) { - evas_object_size_hint_weight_set(conform, EVAS_HINT_EXPAND, + __conform = elm_conformant_add(__win); + if (__conform) { + evas_object_size_hint_weight_set(__conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - elm_win_resize_object_add(win, conform); - elm_conformant_precreated_object_set(conform); + elm_win_resize_object_add(__win, __conform); + elm_conformant_precreated_object_set(__conform); } else { _E("elm_conformant_add() failed"); } } -static void __init_theme(void) +static void __fini_window(void) { - char *theme = elm_theme_list_item_path_get(eina_list_data_get( - elm_theme_list_get(NULL)), NULL); - Eina_Bool is_exist = edje_file_group_exists(theme, "*"); - if (!is_exist) - _D("theme path: %s", theme); - - if (theme) - free(theme); + if (__conform) { + evas_object_del(__conform); + elm_conformant_precreated_object_set(NULL); + __conform = NULL; + } + + if (__bg) { + evas_object_del(__bg); + elm_bg_precreated_object_set(NULL); + __bg = NULL; + } + + if (__win) { + evas_object_del(__win); + elm_win_precreated_object_set(NULL); + __win = NULL; + } } static void __loader_create_cb(bundle *extra, int type, void *user_data) { int elm_init_cnt = 0; + int ret; __preload_init(__argc, __argv); __preload_init_for_process_pool(); @@ -95,18 +119,20 @@ static void __loader_create_cb(bundle *extra, int type, void *user_data) elm_init_cnt = elm_init(__argc, __argv); _D("[candidate] elm init, returned: %d", elm_init_cnt); - switch (type) { - case LAUNCHPAD_TYPE_SW: - elm_config_accel_preference_set("none"); - __init_window(); - break; - case LAUNCHPAD_TYPE_HW: - elm_config_accel_preference_set("hw"); - __init_window(); - break; - case LAUNCHPAD_TYPE_COMMON: - __init_theme(); - break; + elm_config_accel_preference_set("hw"); + __init_window(); + + ret = vconf_get_int(VCONFKEY_SETAPPL_APP_HW_ACCELERATION, &__sys_hwacc); + if (ret != VCONF_OK) { + _E("Failed to get vconf int: %s", + VCONFKEY_SETAPPL_APP_HW_ACCELERATION); + } + + ret = vconf_notify_key_changed(VCONFKEY_SETAPPL_APP_HW_ACCELERATION, + __vconf_cb, NULL); + if (ret != 0) { + _E("Failed to register callback for %s", + VCONFKEY_SETAPPL_APP_HW_ACCELERATION); } malloc_trim(0); } @@ -115,6 +141,31 @@ static int __loader_launch_cb(int argc, char **argv, const char *app_path, const char *appid, const char *pkgid, const char *pkg_type, void *user_data) { + const char *hwacc; + bundle *kb = launchpad_loader_get_bundle(); + + vconf_ignore_key_changed(VCONFKEY_SETAPPL_APP_HW_ACCELERATION, __vconf_cb); + if (kb == NULL) + return 0; + + hwacc = bundle_get_val(kb, AUL_K_HWACC); + + if (!hwacc) + return 0; + + if (strcmp(hwacc, "USE") == 0) { + _D("Use preinitialized window"); + return 0; + } else if (strcmp(hwacc, "SYS") == 0 && + __sys_hwacc == SETTING_HW_ACCELERATION_ON) { + _D("Use preinitialized window"); + return 0; + } + + _D("Dispose window"); + __fini_window(); + elm_config_accel_preference_set("none"); + return 0; } -- 2.7.4