Add a new dectection method 47/181647/2
authorHwankyu Jhun <h.jhun@samsung.com>
Fri, 15 Jun 2018 08:43:16 +0000 (17:43 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Fri, 15 Jun 2018 08:59:54 +0000 (17:59 +0900)
METHOD_INSTALL is added to handle slot update events.
The loader creation must be sequential.

Change-Id: I3d279999ab342b84b2056ac0ce242d24cdb4b8e6
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
inc/loader_info.h
src/launchpad.c
src/loader_info.c

index 3e650af..2245107 100644 (file)
@@ -31,6 +31,7 @@ enum loader_method_e {
        METHOD_AVAILABLE_MEMORY = 0x0020,
        METHOD_TTL = 0x0040,
        METHOD_OUT_OF_MEMORY = 0x0100,
+       METHOD_INSTALL = 0x0200,
 };
 
 typedef struct _loader_info {
index ebc4d29..cabc266 100755 (executable)
@@ -131,6 +131,7 @@ static app_labels_monitor *label_monitor;
 static GList *launcher_info_list;
 static GHashTable *__pid_table;
 static int __memory_status;
+static guint __timer;
 
 static candidate_process_context_t *__add_slot(int type, int loader_id,
                int caller_pid, const char *loader_path, const char *extra,
@@ -1424,6 +1425,14 @@ static candidate_process_context_t *__find_available_slot(const char *hwacc,
        return NULL;
 }
 
+static gboolean __handle_slot_update(gpointer data)
+{
+       _D("[__LAUNCHPAD__] Handle slot update");
+       __add_idle_checker(METHOD_INSTALL, candidate_slot_list);
+       __timer = 0;
+       return G_SOURCE_REMOVE;
+}
+
 static void __update_slot(int type, bool app_exists)
 {
        candidate_process_context_t *cpc;
@@ -1449,8 +1458,13 @@ static void __update_slot(int type, bool app_exists)
                }
 
                if (cpc->pid == CANDIDATE_NONE &&
-                               cpc->idle_checker == 0)
-                       __set_idle_checker_timer(cpc);
+                               cpc->idle_checker == 0) {
+                       if (__timer)
+                               g_source_remove(__timer);
+
+                       __timer = g_timeout_add(500,
+                                       __handle_slot_update, NULL);
+               }
        }
 }
 
@@ -2139,6 +2153,9 @@ static int __before_loop(int argc, char **argv)
 
 static void __after_loop(void)
 {
+       if (__timer)
+               g_source_remove(__timer);
+
        __unregister_vconf_events();
        if (__pid_table)
                g_hash_table_destroy(__pid_table);
index 2150119..8fd9a8f 100644 (file)
@@ -68,7 +68,8 @@ static loader_info_t *__create_loader_info()
        info->app_types = NULL;
        info->hw_acc = NULL;
        info->alternative_loaders = NULL;
-       info->detection_method = METHOD_TIMEOUT | METHOD_VISIBILITY;
+       info->detection_method = METHOD_TIMEOUT | METHOD_VISIBILITY |
+               METHOD_INSTALL;
        info->timeout_val = 5000;
        info->extra = bundle_create();
        info->cpu_threshold_max = DEFAULT_CPU_THRESHOLD_MAX;
@@ -100,6 +101,7 @@ static void __parse_detection_method(loader_info_t *info, char *line)
                token = strtok_r(NULL, " |\t\r\n", &savedptr);
        }
 
+       info->detection_method |= METHOD_INSTALL;
        _D("detection_method:%d", info->detection_method);
 }