tizen 2.3 release
[framework/appfw/aul-1.git] / am_daemon / amd_status.c
1 /*
2  *  aul
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21
22 #include <stdlib.h>
23 #include <stdio.h>
24 #include <glib.h>
25 #include <aul.h>
26 #include <string.h>
27 #include <Ecore.h>
28 #include <proc_stat.h>
29 #include <pkgmgr-info.h>
30 #ifdef _APPFW_FEATURE_VISIBILITY_CHECK_BY_LCD_STATUS
31 #include <Ecore_X.h>
32 #include <vconf/vconf.h>
33 #endif
34
35 #include "amd_config.h"
36 #include "amd_status.h"
37 #include "amd_appinfo.h"
38 #include "aul_util.h"
39 #include "simple_util.h"
40 #include "app_sock.h"
41 #include "menu_db_util.h"
42
43 GSList *app_status_info_list = NULL;
44 struct appinfomgr *_saf = NULL;
45
46 GHashTable *cooldown_tbl;
47
48 GHashTable *cooldown_black_tbl;
49
50 char *cooldown_list[] = {
51 };
52
53 char *cooldown_black_list[] = {
54 };
55
56 int cooldown_status = 0;
57
58 #define WHITE_LIST_COUNT 0
59 #define BLACK_LIST_COUNT 0
60
61 #ifdef _APPFW_FEATURE_VISIBILITY_CHECK_BY_LCD_STATUS
62 #define LCD_ON  "LCDOn"
63 #define LCD_OFF "LCDOff"
64 #define PROC_SIZE       256
65 #define WAKE_UP_GESTURE_CLOCK           1
66 #endif
67
68 int _status_add_app_info_list(char *appid, char *app_path, const char *caller, int pid, int pad_pid)
69 {
70         GSList *iter = NULL;
71         app_status_info_t *info_t = NULL;
72
73         for (iter = app_status_info_list; iter != NULL; iter = g_slist_next(iter))
74         {
75                 info_t = (app_status_info_t *)iter->data;
76                 if(pid == info_t->pid) {
77                         return 0;
78                 }
79         }
80
81         info_t = malloc(sizeof(app_status_info_t));
82         memset(info_t, 0, sizeof(app_status_info_t));
83
84         strncpy(info_t->appid, appid, MAX_PACKAGE_STR_SIZE-1);
85         strncpy(info_t->app_path, app_path, MAX_PACKAGE_APP_PATH_SIZE-1);
86         if(caller)
87                 strncpy(info_t->caller, caller, MAX_PACKAGE_STR_SIZE-1);
88         info_t->status = STATUS_LAUNCHING;
89         info_t->pid = pid;
90         info_t->pad_pid = pad_pid;
91         app_status_info_list = g_slist_append(app_status_info_list, info_t);
92
93         for (iter = app_status_info_list; iter != NULL; iter = g_slist_next(iter))
94         {
95                 info_t = (app_status_info_t *)iter->data;
96
97                 //SECURE_LOGD("%s, %d, %d", info_t->appid, info_t->pid, info_t->status);
98         }
99
100         return 0;
101 }
102
103 static Eina_Bool __app_terminate_timer_cb(void *data)
104 {
105         int pid = (int)data;
106         int ret = 0;
107
108         _D("pid(%d)", pid);
109
110         ret = kill(pid, SIGKILL);
111         if (ret == -1)
112                 _D("send SIGKILL: %s", strerror(errno));
113
114         return ECORE_CALLBACK_CANCEL;
115 }
116
117 int _status_update_app_info_list(int pid, int status)
118 {
119         GSList *iter = NULL;
120         app_status_info_t *info_t = NULL;
121
122         for (iter = app_status_info_list; iter != NULL; iter = g_slist_next(iter))
123         {
124                 info_t = (app_status_info_t *)iter->data;
125                 if(pid == info_t->pid) {
126                         info_t->status = status;
127                         if(status == STATUS_DYING) {
128                                 if(info_t->pad_pid != DEBUG_LAUNCHPAD_PID)
129                                         ecore_timer_add(2, __app_terminate_timer_cb, info_t->pid);
130                         }
131                         break;
132                 }
133         }
134
135         for (iter = app_status_info_list; iter != NULL; iter = g_slist_next(iter))
136         {
137                 info_t = (app_status_info_t *)iter->data;
138
139                 //SECURE_LOGD("%s, %d, %d", info_t->appid, info_t->pid, info_t->status);
140         }
141
142         return 0;
143 }
144
145 int _status_remove_app_info_list(int pid)
146 {
147         GSList *iter = NULL;
148         app_status_info_t *info_t = NULL;
149
150         for (iter = app_status_info_list; iter != NULL; iter = g_slist_next(iter))
151         {
152                 info_t = (app_status_info_t *)iter->data;
153                 if(pid == info_t->pid) {
154                         app_status_info_list = g_slist_remove(app_status_info_list, info_t);
155                         free(info_t);
156                         break;
157                 }
158         }
159
160         for (iter = app_status_info_list; iter != NULL; iter = g_slist_next(iter))
161         {
162                 info_t = (app_status_info_t *)iter->data;
163
164                 //SECURE_LOGD("%s, %d, %d", info_t->appid, info_t->pid, info_t->status);
165         }
166
167         return 0;
168 }
169
170 int _status_get_app_info_status(int pid)
171 {
172         GSList *iter = NULL;
173         app_status_info_t *info_t = NULL;
174
175         for (iter = app_status_info_list; iter != NULL; iter = g_slist_next(iter))
176         {
177                 info_t = (app_status_info_t *)iter->data;
178                 if(pid == info_t->pid) {
179                         return info_t->status;
180                 }
181         }
182
183         return -1;
184 }
185
186
187 int _status_app_is_running(char *appid)
188 {
189         GSList *iter = NULL;
190         app_status_info_t *info_t = NULL;
191
192         for (iter = app_status_info_list; iter != NULL; iter = g_slist_next(iter))
193         {
194                 info_t = (app_status_info_t *)iter->data;
195                 if( strncmp(appid, info_t->appid, MAX_PACKAGE_STR_SIZE) == 0 ) {
196                         return info_t->pid;
197                 }
198         }
199         return -1;
200 }
201
202 char* _status_app_get_appid_bypid(int pid)
203 {
204         GSList *iter = NULL;
205         app_status_info_t *info_t = NULL;
206
207         for (iter = app_status_info_list; iter != NULL; iter = g_slist_next(iter))
208         {
209                 info_t = (app_status_info_t *)iter->data;
210                 if( pid == info_t->pid ) {
211                         return info_t->appid;
212                 }
213         }
214         return NULL;
215 }
216
217 char* _status_get_caller_by_appid(const char *appid)
218 {
219         GSList *iter = NULL;
220         app_status_info_t *info_t = NULL;
221
222         for (iter = app_status_info_list; iter != NULL; iter = g_slist_next(iter))
223         {
224                 info_t = (app_status_info_t *)iter->data;
225                 if( strncmp(appid, info_t->appid, MAX_PACKAGE_STR_SIZE-1) == 0) {
226                         return info_t->caller;
227                 }
228         }
229
230         return NULL;
231 }
232
233 int _status_send_running_appinfo(int fd)
234 {
235         GSList *iter = NULL;
236         app_status_info_t *info_t = NULL;
237         app_pkt_t *pkt = NULL;
238         int len;
239         char tmp_pid[MAX_PID_STR_BUFSZ];
240
241         pkt = (app_pkt_t *) malloc(sizeof(char) * AUL_SOCK_MAXBUFF);
242         if(!pkt) {
243                 _E("malloc fail");
244                 return 0;
245         }
246
247         memset(pkt, 0, AUL_SOCK_MAXBUFF);
248
249         for (iter = app_status_info_list; iter != NULL; iter = g_slist_next(iter))
250         {
251                 info_t = (app_status_info_t *)iter->data;
252                 snprintf(tmp_pid, MAX_PID_STR_BUFSZ, "%d", info_t->pid);
253                 strncat((char *)pkt->data, tmp_pid, MAX_PID_STR_BUFSZ);
254                 strncat((char *)pkt->data, ":", 1);
255                 strncat((char *)pkt->data, info_t->appid, MAX_PACKAGE_STR_SIZE);
256                 strncat((char *)pkt->data, ":", 1);
257                 strncat((char *)pkt->data, info_t->app_path, MAX_PACKAGE_APP_PATH_SIZE);
258                 strncat((char *)pkt->data, ";", 1);
259         }
260
261         pkt->cmd = APP_RUNNING_INFO_RESULT;
262         pkt->len = strlen((char *)pkt->data) + 1;
263
264         if ((len = send(fd, pkt, pkt->len + 8, 0)) != pkt->len + 8) {
265                 if (errno == EPIPE)
266                         _E("send failed due to EPIPE.\n");
267                 _E("send fail to client");
268         }
269
270         if(pkt)
271                 free(pkt);
272
273         close(fd);
274
275         return 0;
276 }
277
278 int _status_app_is_running_v2(char *appid)
279 {
280         char *apppath = NULL;
281         int ret = 0;
282         int i = 0;
283         const struct appinfo *ai;
284
285         if(appid == NULL)
286                 return -1;
287
288         ai = appinfo_find(_saf, appid);
289
290         if(ai == NULL)
291                 return -1;
292
293         apppath = strdup(appinfo_get_value(ai, AIT_EXEC));
294
295         /*truncate apppath if it includes default bundles */
296         while (apppath[i] != 0) {
297                 if (apppath[i] == ' ' || apppath[i] == '\t') {
298                         apppath[i]='\0';
299                         break;
300                 }
301                 i++;
302         }
303
304         ret = __proc_iter_cmdline(NULL, apppath);
305
306         free(apppath);
307
308         return ret;
309 }
310
311 static int __get_pkginfo(const char *dname, const char *cmdline, void *priv)
312 {
313         app_info_from_db *menu_info;
314         char *r_info;
315
316         r_info = (char *)priv;
317
318         if ((menu_info = _get_app_info_from_db_by_apppath(cmdline)) == NULL)
319                 goto out;
320         else {
321                 strncat(r_info, dname, 8);
322                 strncat(r_info, ":", 1);
323                 strncat(r_info, _get_pkgname(menu_info), MAX_PACKAGE_STR_SIZE);
324                 strncat(r_info, ":", 1);
325                 strncat(r_info, _get_app_path(menu_info), MAX_PACKAGE_APP_PATH_SIZE);
326                 strncat(r_info, ";", 1);
327         }
328
329  out:
330         if (menu_info != NULL)
331                 _free_app_info_from_db(menu_info);
332         return 0;
333 }
334
335 int _status_send_running_appinfo_v2(int fd)
336 {
337         app_pkt_t *pkt = NULL;
338         int len;
339
340         pkt = (app_pkt_t *) malloc(sizeof(char) * AUL_SOCK_MAXBUFF);
341         if(!pkt) {
342                 _E("malloc fail");
343                 close(fd);
344                 return 0;
345         }
346
347         memset(pkt, 0, AUL_SOCK_MAXBUFF);
348
349         __proc_iter_cmdline(__get_pkginfo, pkt->data);
350
351         pkt->cmd = APP_RUNNING_INFO_RESULT;
352         pkt->len = strlen((char *)pkt->data) + 1;
353
354         if ((len = send(fd, pkt, pkt->len + 8, 0)) != pkt->len + 8) {
355                 if (errno == EPIPE)
356                         _E("send failed due to EPIPE.\n");
357                 _E("send fail to client");
358         }
359
360         if(pkt)
361                 free(pkt);
362
363         close(fd);
364
365         return 0;
366 }
367
368 static int __get_pkgname_bypid(int pid, char *pkgname, int len)
369 {
370         char *cmdline;
371         app_info_from_db *menu_info;
372
373         cmdline = __proc_get_cmdline_bypid(pid);
374         if (cmdline == NULL)
375                 return -1;
376
377         if ((menu_info = _get_app_info_from_db_by_apppath(cmdline)) == NULL) {
378                 free(cmdline);
379                 return -1;
380         } else {
381                 snprintf(pkgname, len, "%s", _get_pkgname(menu_info));
382         }
383
384         free(cmdline);
385         _free_app_info_from_db(menu_info);
386
387         return 0;
388 }
389
390 int _status_get_appid_bypid(int fd, int pid)
391 {
392         app_pkt_t *pkt = NULL;
393         int len;
394         int pgid;
395
396         pkt = (app_pkt_t *) malloc(sizeof(char) * AUL_SOCK_MAXBUFF);
397         if(!pkt) {
398                 _E("malloc fail");
399                 close(fd);
400                 return 0;
401         }
402
403         memset(pkt, 0, AUL_SOCK_MAXBUFF);
404
405         pkt->cmd = APP_GET_INFO_ERROR;
406
407         if (__get_pkgname_bypid(pid, (char *)pkt->data, MAX_PACKAGE_STR_SIZE) == 0) {
408                 SECURE_LOGD("appid for %d is %s", pid, pkt->data);
409                 pkt->cmd = APP_GET_INFO_OK;
410                 goto out;
411         }
412         /* support app launched by shell script*/
413         _D("second chance");
414         pgid = getpgid(pid);
415         if (pgid <= 1)
416                 goto out;
417
418         _D("second change pgid = %d, pid = %d", pgid, pid);
419         if (__get_pkgname_bypid(pgid, (char *)pkt->data, MAX_PACKAGE_STR_SIZE) == 0)
420                 pkt->cmd = APP_GET_INFO_OK;
421
422  out:
423         pkt->len = strlen((char *)pkt->data) + 1;
424
425         if ((len = send(fd, pkt, pkt->len + 8, 0)) != pkt->len + 8) {
426                 if (errno == EPIPE)
427                         _E("send failed due to EPIPE.\n");
428                 _E("send fail to client");
429         }
430
431         if(pkt)
432                 free(pkt);
433
434         close(fd);
435
436         return 0;
437 }
438
439 static int __get_pkgid_bypid(int pid, char *pkgid, int len)
440 {
441         char *cmdline;
442         app_info_from_db *menu_info;
443
444         cmdline = __proc_get_cmdline_bypid(pid);
445         if (cmdline == NULL)
446                 return -1;
447
448         if ((menu_info = _get_app_info_from_db_by_apppath(cmdline)) == NULL) {
449                 free(cmdline);
450                 return -1;
451         } else
452                 snprintf(pkgid, len, "%s", _get_pkgid(menu_info));
453
454         free(cmdline);
455         _free_app_info_from_db(menu_info);
456
457         return 0;
458 }
459
460 int _status_get_pkgid_bypid(int fd, int pid)
461 {
462         app_pkt_t *pkt = NULL;
463         int len;
464         int pgid;
465
466         pkt = (app_pkt_t *) malloc(sizeof(char) * AUL_SOCK_MAXBUFF);
467         if(!pkt) {
468                 _E("malloc fail");
469                 close(fd);
470                 return 0;
471         }
472
473         memset(pkt, 0, AUL_SOCK_MAXBUFF);
474
475         pkt->cmd = APP_GET_INFO_ERROR;
476
477         if (__get_pkgid_bypid(pid, (char *)pkt->data, MAX_PACKAGE_STR_SIZE) == 0) {
478                 SECURE_LOGD("appid for %d is %s", pid, pkt->data);
479                 pkt->cmd = APP_GET_INFO_OK;
480                 goto out;
481         }
482         /* support app launched by shell script*/
483         _D("second chance");
484         pgid = getpgid(pid);
485         if (pgid <= 1)
486                 goto out;
487
488         _D("second change pgid = %d, pid = %d", pgid, pid);
489         if (__get_pkgid_bypid(pgid, (char *)pkt->data, MAX_PACKAGE_STR_SIZE) == 0)
490                 pkt->cmd = APP_GET_INFO_OK;
491
492  out:
493         pkt->len = strlen((char *)pkt->data) + 1;
494
495         if ((len = send(fd, pkt, pkt->len + 8, 0)) != pkt->len + 8) {
496                 if (errno == EPIPE)
497                         _E("send failed due to EPIPE.\n");
498                 _E("send fail to client");
499         }
500
501         if(pkt)
502                 free(pkt);
503
504         close(fd);
505
506         return 0;
507 }
508
509 static void __app_info_iter_limit_cb(void *user_data, const char *appid, const struct appinfo *ai)
510 {
511         if(!g_hash_table_lookup(cooldown_tbl, appid)) {
512                 appinfo_set_value(ai, AIT_STATUS, "blocking");
513         }
514 }
515
516 static void __app_info_iter_waring_cb(void *user_data, const char *appid, const struct appinfo *ai)
517 {
518         if(g_hash_table_lookup(cooldown_black_tbl, appid)) {
519                 appinfo_set_value(ai, AIT_STATUS, "blocking");
520         }
521 }
522
523 static void __app_info_iter_release_cb(void *user_data, const char *appid, const struct appinfo *ai)
524 {
525         const char *component = NULL;
526         int onboot = 0;
527         int restart = 0;
528
529         if(!g_hash_table_lookup(cooldown_tbl, appid)) {
530                 component = appinfo_get_value(ai, AIT_COMPTYPE);
531                 onboot = appinfo_get_boolean(ai, AIT_ONBOOT);
532                 restart = appinfo_get_boolean(ai, AIT_RESTART);
533                 if (onboot == 1 && restart == 1 && strncmp(component, "svcapp", 6) == 0)
534                 {
535                         if (_status_app_is_running(appid) < 0)
536                         {
537                                 _I("start service (cooldown release) - %s", appid);
538                                 _start_srv(ai, NULL);
539                         }
540                         else
541                         {
542                                 _E("service: %s is already running", appid);
543                         }
544                 }
545                 appinfo_set_value(ai, AIT_STATUS, "installed");
546         }
547 }
548
549
550
551 static int __cooldown_cb(const char* status, void *data)
552 {
553         GSList *iter = NULL;
554         app_status_info_t *info_t = NULL;
555         int ret;
556         int dummy;
557
558         _I("__cooldown_cb, status: %s", status);
559
560         if(strncmp(status, "LimitAction", 11) == 0) {
561                 appinfo_foreach(_saf, __app_info_iter_limit_cb, NULL);
562                 for (iter = app_status_info_list; iter != NULL; iter = g_slist_next(iter))
563                 {
564                         info_t = (app_status_info_t *)iter->data;
565                         if(!g_hash_table_lookup(cooldown_tbl, info_t->appid)) {
566                                 proc_group_change_status(PROC_CGROUP_SET_TERMINATE_REQUEST, info_t->pid, NULL);
567                                 ret = __app_send_raw_with_noreply(info_t->pid, APP_TERM_BY_PID_ASYNC, (unsigned char *)&dummy, sizeof(int) );
568                         }
569                 }
570                 cooldown_status = COOLDOWN_LIMIT;
571         } else if(strncmp(status, "WarningAction", 13) == 0) {
572                 appinfo_foreach(_saf, __app_info_iter_waring_cb, NULL);
573                 for (iter = app_status_info_list; iter != NULL; iter = g_slist_next(iter))
574                 {
575                         info_t = (app_status_info_t *)iter->data;
576                         if(g_hash_table_lookup(cooldown_black_tbl, info_t->appid)) {
577                                 proc_group_change_status(PROC_CGROUP_SET_TERMINATE_REQUEST, info_t->pid, NULL);
578                                 ret = __app_send_raw_with_noreply(info_t->pid, APP_TERM_BY_PID_ASYNC, (unsigned char *)&dummy, sizeof(int) );
579                         }
580                 }
581                 cooldown_status = COOLDOWN_WARNING;
582         } else if (strncmp(status, "Release", 7) == 0){
583                 appinfo_foreach(_saf, __app_info_iter_release_cb, NULL);
584                 cooldown_status = COOLDOWN_RELEASE;
585         }
586
587         return 0;
588 }
589
590 int _status_get_cooldown_status(void)
591 {
592         return cooldown_status;
593 }
594
595 #ifdef _APPFW_FEATURE_VISIBILITY_CHECK_BY_LCD_STATUS
596 static int __lcd_status_cb(const char *lcd_status, void *data)
597 {
598         int gesture = -1;
599         Ecore_X_Window win;
600         int pid = 0;
601         bundle *kb = NULL;
602         char proc_file[PROC_SIZE] = {0, };
603         static int paused_pid = 0;
604
605         // Check the wake-up gesture is a clock or not.
606         // 0: Off, 1: Clock, 2: Last viewed screen
607         if (vconf_get_int(VCONFKEY_WMS_WAKEUP_BY_GESTURE_SETTING, &gesture) < 0) {
608                 _E("Failed to get VCONFKEY_WMS_WAKEUP_BY_GESTURE_SETTING");
609                 return 0;
610         }
611
612         if (gesture == WAKE_UP_GESTURE_CLOCK) {
613                 SECURE_LOGD("Skip when wake-up gesture is a Clock.");
614                 return 0;
615         }
616
617         // Get the topmost app
618         win = ecore_x_window_focus_get();
619         if (ecore_x_netwm_pid_get(win, &pid) != 1) {
620                 _E("Can't get pid for focus x window (%x)", win);
621                 return 0;
622         }
623         SECURE_LOGD("The topmost app's pid is %d.", pid);
624
625         // Pause or Resume the app when the lcd becomes On/Off
626         if (lcd_status && (strncmp(lcd_status, LCD_OFF, strlen(LCD_OFF)) == 0)) {
627                 SECURE_LOGD("LCD status becomes Off. Pause the topmose app, %d", pid);
628                 paused_pid = pid;
629                 kb = bundle_create();
630                 app_send_cmd_with_noreply(pid, APP_PAUSE_LCD_OFF, kb);
631         }
632         else if (lcd_status && (strncmp(lcd_status, LCD_ON, strlen(LCD_ON)) == 0)) {
633                 if (paused_pid != pid) {
634                         SECURE_LOGE("The topmost app(%d) is different with the paused app(%d).", pid, paused_pid);
635                 }
636
637                 // Check whether the paused app is running or Not
638                 snprintf(proc_file, PROC_SIZE, "/proc/%d/cmdline", paused_pid);
639                 if (access(proc_file, F_OK) != 0) {
640                         SECURE_LOGE("paused app(%d) seems to be killed.", paused_pid);
641                         if (paused_pid != pid) {
642                                 paused_pid = pid;
643                         } else {
644                                 return 0;
645                         }
646                 }
647
648                 SECURE_LOGD("LCD status becomes On. Resume the paused app, %d", paused_pid);
649                 kb = bundle_create();
650                 app_send_cmd_with_noreply(paused_pid, APP_RESUME_LCD_ON, kb);
651         }
652         else {
653                 _E("Invalid input param for lcd_status.");
654         }
655
656         bundle_free(kb);
657         return 0;
658 }
659 #endif
660
661 static int __app_info_handler (const pkgmgrinfo_appinfo_h handle, void *data)
662 {
663         char *tmp_appid;
664         char *appid;
665
666         pkgmgrinfo_appinfo_get_appid(handle, &tmp_appid);
667
668         appid = strdup(tmp_appid);
669
670         g_hash_table_insert(cooldown_tbl, appid, appid);
671
672         SECURE_LOGD("white_list : %s", appid);
673
674         return 0;
675 }
676
677 static int __blacklist_app_info_handler (const pkgmgrinfo_appinfo_h handle, void *data)
678 {
679         char *tmp_appid;
680         char *appid;
681
682         pkgmgrinfo_appinfo_get_appid(handle, &tmp_appid);
683
684         appid = strdup(tmp_appid);
685
686         g_hash_table_insert(cooldown_black_tbl, appid, appid);
687
688         SECURE_LOGD("white_list : %s", appid);
689
690         return 0;
691 }
692
693 int _status_init(struct amdmgr* amd)
694 {
695         int i;
696         pkgmgrinfo_appinfo_h handle = NULL;
697
698         _saf = amd->af;
699
700         aul_listen_cooldown_signal(__cooldown_cb, NULL);
701
702         cooldown_tbl = g_hash_table_new(g_str_hash, g_str_equal);
703         for(i = 0; i < WHITE_LIST_COUNT; i++) {
704                 SECURE_LOGD("pkgid %s", cooldown_list[i]);
705                 if (pkgmgrinfo_pkginfo_get_pkginfo(cooldown_list[i], &handle) == PMINFO_R_OK){
706                         pkgmgrinfo_appinfo_get_list(handle, PMINFO_SVC_APP, __app_info_handler, NULL);
707                         pkgmgrinfo_appinfo_get_list(handle, PMINFO_UI_APP, __app_info_handler, NULL);
708                         pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
709                 }
710         }
711
712         cooldown_black_tbl = g_hash_table_new(g_str_hash, g_str_equal);
713         for(i = 0; i < BLACK_LIST_COUNT; i++) {
714                 SECURE_LOGD("pkgid %s", cooldown_black_list[i]);
715                 if (pkgmgrinfo_pkginfo_get_pkginfo(cooldown_black_list[i], &handle) == PMINFO_R_OK){
716                         pkgmgrinfo_appinfo_get_list(handle, PMINFO_SVC_APP, __blacklist_app_info_handler, NULL);
717                         pkgmgrinfo_appinfo_get_list(handle, PMINFO_UI_APP, __blacklist_app_info_handler, NULL);
718                         pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
719                 }
720         }
721
722 #ifdef _APPFW_FEATURE_VISIBILITY_CHECK_BY_LCD_STATUS
723         // Register callback for LCD On/Off
724         aul_listen_lcd_status_signal(__lcd_status_cb, NULL);
725 #endif
726         return 0;
727 }
728