Select the loader to launch explicitly 87/74887/1
authorJunghoon Park <jh9216.park@samsung.com>
Thu, 16 Jun 2016 04:01:40 +0000 (13:01 +0900)
committerJunghoon Park <jh9216.park@samsung.com>
Thu, 16 Jun 2016 04:01:40 +0000 (13:01 +0900)
- Caller may add extra data about loader name to launch an app.
- If it exist, the loader will be used with first priority.

Change-Id: I195341ab46a6f2610997ff18fada3c3ddc8d2a88
Signed-off-by: Junghoon Park <jh9216.park@samsung.com>
inc/key.h
inc/launchpad_common.h
inc/loader_info.h
src/launchpad.c
src/launchpad_common.c
src/loader_info.c

index d2f09f8..7d0201f 100644 (file)
--- a/inc/key.h
+++ b/inc/key.h
@@ -42,6 +42,7 @@ extern "C" {
 #define AUL_K_WAYLAND_WORKING_DIR "__AUL_WAYLAND_WORKING_DIR__"
 #define AUL_K_ROOT_PATH                "__AUL_ROOT_PATH__"
 #define AUL_K_API_VERSION      "__AUL_API_VERSION__"
+#define AUL_K_LOADER_NAME      "__AUL_LOADER_NAME__"
 
 #ifdef __cplusplus
 }
index 8ae9705..aad42c8 100644 (file)
@@ -95,6 +95,7 @@ typedef struct {
        char *comp_type;
        char *internal_pool;
        char *root_path;
+       char *loader_name;
 } appinfo_t;
 
 char *_proc_get_cmdline_bypid(int pid);
index 6c411ed..4bc89ec 100644 (file)
@@ -39,6 +39,7 @@ typedef struct _loader_info {
 GList *_loader_info_load(const char *path);
 void _loader_info_dispose(GList *info);
 int _loader_info_find_type(GList *info, const char *app_type, bool hwacc);
+int _loader_info_find_type_by_loader_name(GList *info, const char *loader_name);
 int *_loader_get_alternative_types(GList *info, int type, int *len);
 
 
index 1933365..9474862 100755 (executable)
@@ -912,7 +912,7 @@ static bool __is_hw_acc(const char *hwacc)
 }
 
 static candidate_process_context_t *__find_available_slot(const char *hwacc,
-               const char *app_type)
+               const char *app_type, const char *loader_name)
 {
        int type;
        candidate_process_context_t *cpc;
@@ -920,7 +920,10 @@ static candidate_process_context_t *__find_available_slot(const char *hwacc,
        int len = 0;
        int i;
 
-       type = _loader_info_find_type(loader_info_list,  app_type, __is_hw_acc(hwacc));
+       if (loader_name)
+               type = _loader_info_find_type_by_loader_name(loader_info_list, loader_name);
+       else
+               type = _loader_info_find_type(loader_info_list,  app_type, __is_hw_acc(hwacc));
        cpc = __find_slot(type, PAD_LOADER_ID_STATIC);
        if (!cpc)
                return NULL;
@@ -1043,12 +1046,11 @@ static gboolean __handle_launch_event(gpointer data)
        SECURE_LOGD("app_type : %s\n", menu_info->app_type);
        SECURE_LOGD("pkg_type : %s\n", menu_info->pkg_type);
 
-
        if (menu_info->comp_type &&
-                               strcmp(menu_info->comp_type, "svcapp") == 0) {
+                       strcmp(menu_info->comp_type, "svcapp") == 0) {
                loader_id = PAD_LOADER_ID_DIRECT;
        } else if ((loader_id = __get_loader_id(kb)) <= PAD_LOADER_ID_STATIC) {
-               cpc = __find_available_slot(menu_info->hwacc, menu_info->app_type);
+               cpc = __find_available_slot(menu_info->hwacc, menu_info->app_type, menu_info->loader_name);
        } else {
                type = LAUNCHPAD_TYPE_DYNAMIC;
                cpc = __find_slot(type, loader_id);
index 960c53f..ef42c0a 100644 (file)
@@ -415,6 +415,10 @@ appinfo_t *_appinfo_create(bundle *kb)
        if (ptr)
                menu_info->root_path = strdup(ptr);
 
+       ptr = bundle_get_val(kb, AUL_K_LOADER_NAME);
+       if (ptr)
+               menu_info->loader_name = strdup(ptr);
+
        if (!_appinfo_get_app_path(menu_info)) {
                _appinfo_free(menu_info);
                return NULL;
@@ -483,6 +487,8 @@ void _appinfo_free(appinfo_t *menu_info)
                free(menu_info->internal_pool);
        if (menu_info->root_path != NULL)
                free(menu_info->root_path);
+       if (menu_info->loader_name != NULL)
+               free(menu_info->loader_name);
 
        free(menu_info);
 }
index 2c02a68..b683539 100644 (file)
@@ -92,7 +92,7 @@ static void __parse_app_types(loader_info_t *info, char *line)
        while (token) {
                refined_tok[0] = '\0';
                sscanf(token, "%s", refined_tok);
-               if (refined_tok[0] != '\0')
+               if (refined_tok[0] != '\0' && strcasecmp("null", refined_tok) != 0)
                        info->app_types = g_list_append(info->app_types, strdup(refined_tok));
                token = strtok_r(NULL, "|", &savedptr);
        }
@@ -275,6 +275,8 @@ void _loader_info_dispose(GList *info)
 
 static int __comp_str(gconstpointer a, gconstpointer b)
 {
+       if (!a || !b)
+               return -1;
        return strcmp(a, b);
 }
 
@@ -320,7 +322,6 @@ int _loader_info_find_type(GList *info,  const char *app_type, bool hwacc)
 {
        GList *cur = NULL;
 
-
        if (hwacc)
                cur = g_list_find_custom(info, app_type, __comp_app_type_with_hw_acc);
        else
@@ -334,6 +335,19 @@ int _loader_info_find_type(GList *info,  const char *app_type, bool hwacc)
        return cur_info->type;
 }
 
+int _loader_info_find_type_by_loader_name(GList *info,  const char *loader_name)
+{
+       GList *cur = NULL;
+
+       cur = g_list_find_custom(info, loader_name, __comp_name);
+       if (cur == NULL)
+               return -1;
+
+       loader_info_t *cur_info = (loader_info_t *)cur->data;
+
+       return cur_info->type;
+}
+
 static int *__make_type_array(GList *info, GList *loaders, int *len)
 {
        int l;