Make a flag for on-boot 49/168349/1
authorJunghoon Park <jh9216.park@samsung.com>
Fri, 26 Jan 2018 03:54:59 +0000 (12:54 +0900)
committerJunghoon Park <jh9216.park@samsung.com>
Fri, 26 Jan 2018 03:54:59 +0000 (12:54 +0900)
- The new flag 'touched' was added for supporting ON_BOOT feature
- 'cur_event' should be also initialized

Change-Id: Iedbf6d2087de97228efd22eb642f6531e5f82426
Signed-off-by: Junghoon Park <jh9216.park@samsung.com>
src/launchpad.c

index 2d0e01e..5fe0aba 100755 (executable)
@@ -63,7 +63,6 @@
 #define PAD_ERR_INVALID_PATH           -4
 #define CPU_CHECKER_TIMEOUT            1000
 #define PI                             3.14159265
-#define EVENT_BOOTING                  -1
 
 typedef struct {
        int type;
@@ -88,6 +87,7 @@ typedef struct {
        int cur_event;
        bool on_boot;
        bool app_exists;
+       bool touched;
 } candidate_process_context_t;
 
 typedef struct {
@@ -1183,6 +1183,7 @@ static gboolean __handle_idle_checker(gpointer data)
                __update_threshold(cpc, -0.02f * (per - cpc->threshold));
                __prepare_candidate_process(cpc->type, cpc->loader_id);
                cpc->idle_checker = 0;
+               cpc->touched = true;
                __add_idle_checker(cpc->cur_event, g_list_next(list));
                return G_SOURCE_REMOVE;
        }
@@ -1209,7 +1210,7 @@ static int __add_idle_checker(int detection_method, GList *cur)
                        continue;
                }
 
-               if (detection_method == EVENT_BOOTING && !cpc->on_boot) {
+               if (!cpc->touched && !cpc->on_boot) {
                        iter = g_list_next(iter);
                        continue;
                }
@@ -1220,7 +1221,7 @@ static int __add_idle_checker(int detection_method, GList *cur)
                }
 
                if (cpc->pid == CANDIDATE_NONE &&
-                               (detection_method == EVENT_BOOTING ||
+                               (!cpc->touched ||
                                 (cpc->detection_method & detection_method))) {
                        if (cpc->timer > 0) {
                                g_source_remove(cpc->timer);
@@ -1671,6 +1672,8 @@ static candidate_process_context_t *__add_slot(int type, int loader_id,
        cpc->threshold_min = threshold_min;
        cpc->on_boot = on_boot;
        cpc->app_exists = app_exists;
+       cpc->touched = false;
+       cpc->cur_event = 0;
 
        fd = __listen_candidate_process(cpc->type, cpc->loader_id);
        if (fd == -1) {
@@ -1911,7 +1914,7 @@ static int __add_default_slots(void)
 
        user_slot_offset = 0;
        g_list_foreach(loader_info_list, __add_slot_from_info, NULL);
-       __add_idle_checker(EVENT_BOOTING, candidate_slot_list);
+       __add_idle_checker(0, candidate_slot_list);
 
        return 0;
 }