10 #include <pkgmgr-info.h>
12 #include "amd_config.h"
13 #include "simple_util.h"
14 #include "amd_appinfo.h"
15 #include "amd_launch.h"
16 #include "amd_request.h"
17 #ifdef _APPFW_FEATURE_EXPANSION_PKG_INSTALL
18 #include <pkgmgr-info.h>
19 #include <pkgmgrinfo_type.h>
23 #define SERVICE_GROUP "Service"
26 GHashTable *tbl; /* key is filename, value is struct appinfo */
30 _AI_FILE = 0, /* service filename */
45 #ifdef _APPFW_FEATURE_CHANGEABLE_COLOR
49 #ifdef _APPFW_FEATURE_PROCESS_POOL
53 #ifdef _APPFW_FEATURE_MULTI_INSTANCE
55 _AI_MULTI_INSTANCE_MAINID,
58 #ifdef _APPFW_FEATURE_TTS_MODE
61 #ifdef _APPFW_FEATURE_ULTRA_POWER_SAVING_MODE
64 #ifdef _APPFW_FEATURE_COOLDOWN_MODE_SUPPORT
67 #ifdef _APPFW_FEATURE_EXPANSION_PKG_INSTALL
74 #ifdef _APPFW_FEATURE_EFFECTIVE_APPID
77 #ifdef _APPFW_FEATURE_PRIVATE_SERVICE
82 #define _AI_START _AI_NAME /* start index */
86 enum appinfo_type type;
89 static struct appinfo_t _appinfos[] = {
90 [_AI_NAME] = { "Name", AIT_NAME, },
91 [_AI_EXEC] = { "Exec", AIT_EXEC, },
92 [_AI_TYPE] = { "PkgType", AIT_TYPE, },
93 [_AI_ONBOOT] = { "StartOnBoot", AIT_ONBOOT, },
94 [_AI_RESTART] = { "AutoRestart", AIT_RESTART, },
95 [_AI_MULTI] = { "Multiple", AIT_MULTI, },
96 [_AI_HWACC] = { "Hwacceleration", AIT_HWACC, },
97 [_AI_PERM] = { "PermissionType", AIT_PERM, },
98 [_AI_PKGID] = { "PackageId", AIT_PKGID, },
99 [_AI_TASKMANAGE] = { "Taskmanage", AIT_TASKMANAGE, },
100 [_AI_PRELOAD] = { "Preload", AIT_PRELOAD, },
101 [_AI_INDICATORDISP] = { "indicatordisplay", AIT_INDICATOR_DISP, },
102 [_AI_EFFECTIMAGEPORT] = { "portaitimg", AIT_EFFECTIMAGEPORT, },
103 [_AI_EFFECTIMAGELAND] = { "landscapeimg", AIT_EFFECTIMAGELAND, },
104 #ifdef _APPFW_FEATURE_CHANGEABLE_COLOR
105 [_AI_EFFECTTYPE] = { "EffectType", AIT_EFFECTTYPE, },
107 [_AI_STATUS] = { "status", AIT_STATUS, },
108 #ifdef _APPFW_FEATURE_PROCESS_POOL
109 [_AI_POOL] = { "ProcessPool", AIT_POOL, },
111 [_AI_COMPTYPE] = { "ComponentType", AIT_COMPTYPE, },
112 #ifdef _APPFW_FEATURE_MULTI_INSTANCE
113 [_AI_MULTI_INSTANCE] = { "multi-instance", AIT_MULTI_INSTANCE, },
114 [_AI_MULTI_INSTANCE_MAINID] = { "multi-instance-mainid", AIT_MULTI_INSTANCE_MAINID, },
115 [_AI_TOGGLE_ORDER] = { "toggleOrder", AIT_TOGGLE_ORDER, },
117 #ifdef _APPFW_FEATURE_TTS_MODE
118 [_AI_TTS] = { "TTS", AIT_TTS, },
120 #ifdef _APPFW_FEATURE_ULTRA_POWER_SAVING_MODE
121 [_AI_UPS] = { "UPS", AIT_UPS, },
123 #ifdef _APPFW_FEATURE_COOLDOWN_MODE_SUPPORT
124 [_AI_COOLDOWN] = { "CoolDown", AIT_COOLDOWN, },
126 #ifdef _APPFW_FEATURE_EXPANSION_PKG_INSTALL
127 [_AI_TEP] = {"Tep", AIT_TEP},
128 [_AI_STORAGE_TYPE] = {"StorageType", AIT_STORAGE_TYPE},
130 [_AI_ALLOWED_BG] = {"AllowedBackground", AIT_ALLOWED_BG },
131 [_AI_API_VER] = {"ApiVersion", AIT_API_VER },
132 [_AI_LAUNCH_MODE] = {"launch_mode", AIT_LAUNCH_MODE },
133 #ifdef _APPFW_FEATURE_EFFECTIVE_APPID
134 [_AI_EFFECTIVE_APPID] = {"effective-appid", AIT_EFFECTIVE_APPID },
136 #ifdef _APPFW_FEATURE_PRIVATE_SERVICE
137 [_AI_VISIBILITY] = {"visibility", AIT_VISIBILITY },
155 static void _free_appinfo(gpointer data)
157 struct appinfo *c = data;
163 for (i = 0; i < sizeof(c->val)/sizeof(c->val[0]); i++) {
164 if(c->val[i] != NULL)
171 static void _fini(struct appinfomgr *cf)
175 g_hash_table_destroy(cf->tbl);
176 g_hash_table_destroy(pkg_tbl);
180 static int __set_allowed_bg(const char *category_name, void *user_data)
182 /* assume any of background category declared means that background running is allowed */
183 bool *allowed_bg = (bool *)user_data;
185 if (category_name && strcmp(category_name, "enable") == 0) {
189 if (category_name && strcmp(category_name, "disable") == 0) {
194 _D("background category:%s", category_name);
199 static int __app_info_insert_handler(const pkgmgrinfo_appinfo_h handle, void *data)
202 struct appinfomgr *cf = (struct appinfomgr *)data;
207 #ifdef _APPFW_FEATURE_CHANGEABLE_COLOR
208 char *effectimg_type;
213 char *component_type;
216 #ifdef _APPFW_FEATURE_MULTI_INSTANCE
221 pkgmgrinfo_app_hwacceleration hwacc;
222 pkgmgrinfo_permission_type permission;
223 bool indicator_display;
227 #ifdef _APPFW_FEATURE_PROCESS_POOL
228 bool process_pool = 0;
230 int support_mode = 0;
232 #ifdef _APPFW_FEATURE_EXPANSION_PKG_INSTALL
233 char *tep_name = NULL;
234 pkgmgrinfo_installed_storage installed_storage;
236 bool allowed_bg = false;
237 #ifdef _APPFW_FEATURE_EFFECTIVE_APPID
238 char *effective_appid = NULL;
240 char *api_ver = NULL;
244 _E("null app handle");
248 ret = pkgmgrinfo_appinfo_get_appid(handle, &appid);
250 _E("fail to get appinfo");
254 g_hash_table_remove(cf->tbl, appid);
256 c = calloc(1, sizeof(*c));
258 _E("create appinfo: %s", strerror(errno));
262 memset(c, 0, sizeof(struct appinfo));
264 c->val[_AI_FILE] = strdup(appid);
265 if (!c->val[_AI_FILE]) {
266 _E("create appinfo: %s", strerror(errno));
271 c->val[_AI_NAME] = strdup(appid);
273 r = pkgmgrinfo_appinfo_is_multiple(handle, &multiple);
275 c->val[_AI_MULTI] = strdup("true");
276 else c->val[_AI_MULTI] = strdup("false");
278 r = pkgmgrinfo_appinfo_is_taskmanage(handle, &taskmanage);
279 if (taskmanage == false) {
280 c->val[_AI_TASKMANAGE] = strdup("false");
282 c->val[_AI_TASKMANAGE] = strdup("true");
285 r = pkgmgrinfo_appinfo_is_preload(handle, &preload);
286 if (preload == false) {
287 c->val[_AI_PRELOAD] = strdup("false");
289 c->val[_AI_PRELOAD] = strdup("true");
293 c->val[_AI_HWACC] = strdup("NOT_USE");
295 r = pkgmgrinfo_appinfo_get_hwacceleration(handle, &hwacc);
297 _E("ERROR IN FETCHING HWACCELERATION INFO\n");
298 c->val[_AI_HWACC] = NULL;
300 if (hwacc == PMINFO_HWACCELERATION_ON) {
301 c->val[_AI_HWACC] = strdup("USE");
302 } else if (hwacc == PMINFO_HWACCELERATION_OFF) {
303 c->val[_AI_HWACC] = strdup("NOT_USE");
305 c->val[_AI_HWACC] = strdup("SYS");
310 r = pkgmgrinfo_appinfo_is_indicator_display_allowed(handle, &indicator_display);
312 _E("ERROR IN FETCHING INDICATOR DISP INFO\n");
313 c->val[_AI_INDICATORDISP] = strdup("true");
315 if (indicator_display == true){
316 c->val[_AI_INDICATORDISP] = strdup("true");
318 c->val[_AI_INDICATORDISP] = strdup("false");
322 r = pkgmgrinfo_appinfo_get_effectimage(handle, &portraitimg, &landscapeimg);
324 _E("ERROR IN FETCHING EFFECT IMAGES\n");
325 c->val[_AI_EFFECTIMAGEPORT] = NULL;
326 c->val[_AI_EFFECTIMAGELAND] = NULL;
329 c->val[_AI_EFFECTIMAGEPORT] = strdup(portraitimg);
331 c->val[_AI_EFFECTIMAGEPORT] = NULL;
333 c->val[_AI_EFFECTIMAGELAND] = strdup(landscapeimg);
335 c->val[_AI_EFFECTIMAGELAND] = NULL;
337 #ifdef _APPFW_FEATURE_CHANGEABLE_COLOR
338 r = pkgmgrinfo_appinfo_get_effectimage_type(handle, &effectimg_type);
339 c->val[_AI_EFFECTTYPE] = strdup(effectimg_type);
342 #ifdef _APPFW_FEATURE_PROCESS_POOL
343 r = pkgmgrinfo_appinfo_is_process_pool(handle, &process_pool);
344 if (process_pool == false) {
345 c->val[_AI_POOL] = strdup("false");
347 c->val[_AI_POOL] = strdup("true");
350 r = pkgmgrinfo_appinfo_get_component_type(handle, &component_type);
351 c->val[_AI_COMPTYPE] = strdup(component_type);
353 r = pkgmgrinfo_appinfo_is_onboot(handle, &onboot);
355 c->val[_AI_ONBOOT] = strdup("true");
356 else c->val[_AI_ONBOOT] = strdup("false");
358 r = pkgmgrinfo_appinfo_is_autorestart(handle, &restart);
360 c->val[_AI_RESTART] = strdup("true");
361 else c->val[_AI_RESTART] = strdup("false");
363 #ifdef _APPFW_FEATURE_MULTI_INSTANCE
364 r = pkgmgrinfo_appinfo_is_multi_instance(handle, &multi_instance);
365 if(multi_instance == true)
366 c->val[_AI_MULTI_INSTANCE] = strdup("true");
368 c->val[_AI_MULTI_INSTANCE] = strdup("false");
370 r = pkgmgrinfo_appinfo_get_multi_instance_mainid(handle, &multi_mainid);
371 c->val[_AI_MULTI_INSTANCE_MAINID] = strdup(multi_mainid);
374 c->val[_AI_TOGGLE_ORDER] = strdup("0");
377 r = pkgmgrinfo_appinfo_get_exec(handle, &exec);
378 c->val[_AI_EXEC] = strdup(exec);
380 r = pkgmgrinfo_appinfo_get_apptype(handle, &type);
381 if(strncmp(type, "capp", 4) == 0 ) {
382 c->val[_AI_TYPE] = strdup("rpm");
383 } else if (strncmp(type, "c++app", 6) == 0 || strncmp(type, "ospapp", 6) == 0) {
384 c->val[_AI_TYPE] = strdup("tpk");
385 } else if (strncmp(type, "webapp", 6) == 0) {
386 c->val[_AI_TYPE] = strdup("wgt");
389 r = pkgmgrinfo_appinfo_get_permission_type(handle, &permission);
390 if (permission == PMINFO_PERMISSION_SIGNATURE) {
391 c->val[_AI_PERM] = strdup("signature");
392 } else if (permission == PMINFO_PERMISSION_PRIVILEGE) {
393 c->val[_AI_PERM] = strdup("privilege");
395 c->val[_AI_PERM] = strdup("normal");
398 pkgmgrinfo_appinfo_get_support_mode(handle, &support_mode);
399 #ifdef _APPFW_FEATURE_TTS_MODE
400 if(support_mode & PMINFO_MODE_PROP_SCREEN_READER) {
401 c->val[_AI_TTS] = strdup("true");
403 c->val[_AI_TTS] = strdup("false");
406 #ifdef _APPFW_FEATURE_ULTRA_POWER_SAVING_MODE
407 if(support_mode & PMINFO_MODE_PROP_ULTRA_POWER_SAVING) {
408 c->val[_AI_UPS] = strdup("true");
410 c->val[_AI_UPS] = strdup("false");
413 #ifdef _APPFW_FEATURE_COOLDOWN_MODE_SUPPORT
414 if(support_mode & PMINFO_SUPPORT_MODE_COOL_DOWN) {
415 c->val[_AI_COOLDOWN] = strdup("true");
417 c->val[_AI_COOLDOWN] = strdup("false");
421 r = pkgmgrinfo_appinfo_get_pkgid(handle, &pkgid);
422 c->val[_AI_PKGID] = strdup(pkgid);
424 c->val[_AI_STATUS] = strdup("installed");
426 #ifdef _APPFW_FEATURE_EXPANSION_PKG_INSTALL
428 ret = pkgmgrinfo_appinfo_get_tep_name(handle, &tep_name);
429 if(ret == PMINFO_R_OK) {
430 c->val[_AI_TEP] = strdup(tep_name);
433 ret = pkgmgrinfo_appinfo_get_installed_storage_location(handle, &installed_storage);
434 if(ret == PMINFO_R_OK) {
435 if(installed_storage == PMINFO_INTERNAL_STORAGE)
437 c->val[_AI_STORAGE_TYPE] = strdup("internal");
439 else if(installed_storage == PMINFO_EXTERNAL_STORAGE)
441 c->val[_AI_STORAGE_TYPE] = strdup("external");
446 #ifdef _APPFW_FEATURE_EFFECTIVE_APPID
447 ret = pkgmgrinfo_appinfo_get_effective_appid(handle, &effective_appid);
448 if (ret == PMINFO_R_OK) {
449 if (effective_appid && strlen(effective_appid) > 0)
450 c->val[_AI_EFFECTIVE_APPID] = strdup(effective_appid);
454 ret = pkgmgrinfo_appinfo_get_api_version(handle, &api_ver);
455 if (ret != PMINFO_R_OK) {
456 _E("Failed to get api version");
462 c->val[_AI_API_VER] = strdup(api_ver);
464 c->val[_AI_API_VER] = strdup("NONE");
466 ret = pkgmgrinfo_appinfo_get_launch_mode(handle, &mode);
467 if (ret == PMINFO_R_OK && mode)
468 c->val[_AI_LAUNCH_MODE] = strdup(mode);
470 c->val[_AI_LAUNCH_MODE] = strdup("single");
472 /* TODO each background category may have different background management policies,
473 * so should have real background category value than allowed_background. */
474 pkgmgrinfo_appinfo_foreach_background_category(handle, __set_allowed_bg, &allowed_bg);
475 if (ret != PMINFO_R_OK) {
476 _E("Failed to check allowed background");
480 SECURE_LOGD("[__SUSPEND__] allowed background, appid: %s", appid);
481 c->val[_AI_ALLOWED_BG] = strdup("ALLOWED_BG");
483 c->val[_AI_ALLOWED_BG] = strdup("NONE");
485 #ifdef _APPFW_FEATURE_PRIVATE_SERVICE
486 c->val[_AI_VISIBILITY] = NULL;
488 SECURE_LOGD("appinfo file:%s, type:%s", c->val[_AI_FILE], c->val[_AI_TYPE]);
490 g_hash_table_insert(cf->tbl, c->val[_AI_FILE], c);
495 static int __app_info_delete_handler(const pkgmgrinfo_appinfo_h handle, void *data)
497 struct appinfomgr *cf = (struct appinfomgr *)data;
500 pkgmgrinfo_appinfo_get_appid(handle, &appid);
503 g_hash_table_remove(cf->tbl, appid);
508 static int _read_pkg_info(struct appinfomgr *cf)
512 ret = pkgmgrinfo_appinfo_get_install_list(__app_info_insert_handler, cf);
513 assert(ret == PMINFO_R_OK);
518 static struct appinfomgr *_init()
520 struct appinfomgr *cf;
522 cf = calloc(1, sizeof(*cf));
524 _E("appinfo init: %s", strerror(errno));
528 cf->tbl = g_hash_table_new_full(g_str_hash, g_str_equal,
529 NULL, _free_appinfo);
531 pkg_tbl = g_hash_table_new(g_str_hash, g_str_equal);
532 _E("pkg_tbl : %x", pkg_tbl);
536 static void __amd_pkgmgrinfo_start_handler (gpointer key, gpointer value, gpointer user_data)
538 struct appinfo *c = value;
539 char *pkgid = (char *)user_data;
541 if (c != NULL && strcmp(c->val[_AI_PKGID], pkgid) == 0) {
542 free(c->val[_AI_STATUS]);
543 c->val[_AI_STATUS] = strdup("blocking");
544 SECURE_LOGD("pkgmgr working for this application(%s)", c->val[_AI_NAME]);
548 static void __amd_pkgmgrinfo_fail_handler (gpointer key, gpointer value, gpointer user_data)
550 struct appinfo *c = value;
551 char *pkgid = (char *)user_data;
553 if (c != NULL && strcmp(c->val[_AI_PKGID], pkgid) == 0) {
554 free(c->val[_AI_STATUS]);
555 c->val[_AI_STATUS] = strdup("installed");
556 SECURE_LOGD("pkgmgr fail(%s)", c->val[_AI_NAME]);
560 static int __amd_pkgmgrinfo_install_end_handler(pkgmgrinfo_appinfo_h handle, void *user_data)
563 struct appinfomgr *cf = (struct appinfomgr *)user_data;
565 const char *componet;
568 pkgmgrinfo_appinfo_get_appid(handle, &appid);
570 __app_info_insert_handler(handle, user_data);
571 c = g_hash_table_lookup(cf->tbl, appid);
573 componet = appinfo_get_value(c, AIT_COMPTYPE);
574 r = appinfo_get_boolean(c, AIT_ONBOOT);
576 if (r == 1 && componet && strncmp(componet, "svcapp", 6) == 0)
578 SECURE_LOGW("start service - %s", appid);
585 static int __amd_pkgmgrinfo_update_end_handler(pkgmgrinfo_appinfo_h handle, void *user_data)
588 struct appinfomgr *cf = (struct appinfomgr *)user_data;
590 const char *componet;
593 pkgmgrinfo_appinfo_get_appid(handle, &appid);
594 c = g_hash_table_lookup(cf->tbl, appid);
596 if (c != NULL && strncmp(c->val[_AI_STATUS], "restart", 7) == 0) {
597 __app_info_insert_handler(handle, user_data);
600 __app_info_insert_handler(handle, user_data);
601 c = g_hash_table_lookup(cf->tbl, appid);
603 componet = appinfo_get_value(c, AIT_COMPTYPE);
604 r = appinfo_get_boolean(c, AIT_ONBOOT);
606 if (r == 1 && componet && strncmp(componet, "svcapp", 6) == 0)
608 SECURE_LOGW("start service - %s", appid);
616 static gboolean __amd_pkgmgrinfo_uninstall_end_handler (gpointer key, gpointer value, gpointer user_data)
618 struct appinfo *c = value;
619 char *pkgid = (char *)user_data;
621 if (strcmp(c->val[_AI_PKGID], pkgid) == 0) {
622 SECURE_LOGD("appid(%s), pkgid(%s)", c->val[_AI_NAME], pkgid);
628 static int __amd_pkgmgrinfo_status_cb(int req_id, const char *pkg_type,
629 const char *pkgid, const char *key, const char *val,
630 const void *pmsg, void *user_data)
633 pkgmgrinfo_pkginfo_h handle;
635 struct pkginfo *p = NULL;
636 struct appinfomgr *cf = (struct appinfomgr *)user_data;
638 SECURE_LOGD("pkgid(%s), key(%s), value(%s)", pkgid, key, val);
640 if(strncmp(key,"start", 5) == 0) {
641 g_hash_table_remove(pkg_tbl, pkgid);
642 p = calloc(1, sizeof(*p));
648 p->pkgid = strdup(pkgid);
650 g_hash_table_insert(pkg_tbl, p->pkgid, p);
651 if (strncmp(val, "install", 7) == 0) {
654 else if ((strncmp(val, "update", 6) == 0) || (strncmp(val, "uninstall", 9) == 0)) {
655 g_hash_table_foreach(cf->tbl, __amd_pkgmgrinfo_start_handler, (gpointer)pkgid);
656 _D("__amd_pkgmgrinfo_start_handler");
660 else if (strncmp(key,"end", 3) == 0) {
661 p = g_hash_table_lookup(pkg_tbl, pkgid);
664 SECURE_LOGW("op(%s), value(%s)", op, val);
665 if (strncmp(val, "ok", 2) == 0) {
666 if (op && strncmp(op, "install", 7)== 0) {
667 ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
668 if (ret != PMINFO_R_OK)
670 ret = pkgmgrinfo_appinfo_get_list(handle, PMINFO_UI_APP, __amd_pkgmgrinfo_install_end_handler, user_data);
671 if (ret != PMINFO_R_OK) {
672 pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
675 pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
677 else if (op && strncmp(op, "update", 6) == 0){
678 ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
679 if (ret != PMINFO_R_OK)
681 ret = pkgmgrinfo_appinfo_get_list(handle, PMINFO_UI_APP, __amd_pkgmgrinfo_update_end_handler, user_data);
682 if (ret != PMINFO_R_OK) {
683 pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
686 pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
688 else if (op && strncmp(op, "uninstall", 9) == 0) {
689 ret = g_hash_table_foreach_remove(cf->tbl, __amd_pkgmgrinfo_uninstall_end_handler, (gpointer)pkgid);
690 _D("g_hash_table_foreach_remove, %d", ret);
694 else if (strncmp(val, "fail", 4) == 0) {
695 if ((op && strncmp(op, "update", 6) == 0) || (op && strncmp(op, "uninstall", 9) == 0) ) {
696 g_hash_table_foreach(cf->tbl, __amd_pkgmgrinfo_fail_handler, (gpointer)pkgid);
697 _D("__amd_pkgmgrinfo_fail_handler");
701 g_hash_table_remove(pkg_tbl, p->pkgid);
710 static int __unmounted_list_cb(const pkgmgrinfo_appinfo_h handle, void *user_data)
713 struct appinfomgr *cf = (struct appinfomgr *)user_data;
714 struct appinfo *c = NULL;
716 pkgmgrinfo_appinfo_get_appid(handle, &appid);
718 c = g_hash_table_lookup(cf->tbl, appid);
719 SECURE_LOGD("%s : %s", c->val[_AI_FILE], c->val[_AI_STATUS]);
720 free(c->val[_AI_STATUS]);
721 c->val[_AI_STATUS] = strdup("unmounted");
722 SECURE_LOGD("unmounted(%s)", appid);
724 _E("pkgmgrinfo_appinfo_get_appid() failed");
730 static int __mounted_list_cb(const pkgmgrinfo_appinfo_h handle, void *user_data)
733 struct appinfomgr *cf = (struct appinfomgr *)user_data;
734 struct appinfo *c = NULL;
736 pkgmgrinfo_appinfo_get_appid(handle, &appid);
738 c = g_hash_table_lookup(cf->tbl, appid);
739 SECURE_LOGD("%s : %s", c->val[_AI_FILE], c->val[_AI_STATUS]);
740 if(strncmp(c->val[_AI_STATUS], "unmounted", 9) ==0 ) {
741 free(c->val[_AI_STATUS]);
742 c->val[_AI_STATUS] = strdup("installed");
744 SECURE_LOGD("mounted(%s)", appid);
746 _E("pkgmgrinfo_appinfo_get_appid() failed");
752 #ifdef _APPFW_FEATURE_MMC_SUPPORT
753 static void __amd_mmc_vconf_cb(keynode_t *key, void *data)
758 status = vconf_keynode_get_int(key);
763 if(status == VCONFKEY_SYSMAN_MMC_REMOVED || status == VCONFKEY_SYSMAN_MMC_INSERTED_NOT_MOUNTED) {
764 ret = pkgmgrinfo_appinfo_get_unmounted_list(__unmounted_list_cb, data);
765 if (ret != PMINFO_R_OK){
766 _E("pkgmgrinfo_appinfo_get_unmounted_list failed: %d", ret);
768 } else if(status == VCONFKEY_SYSMAN_MMC_MOUNTED){
769 ret = pkgmgrinfo_appinfo_get_mounted_list(__mounted_list_cb, data);
770 if (ret != PMINFO_R_OK){
771 _E("pkgmgrinfo_appinfo_get_mounted_list failed: %d", ret);
777 int appinfo_init(struct appinfomgr **cf)
779 struct appinfomgr *_cf;
783 char buf[4096] = {0,};
788 _E("appinfo init: %s", strerror(errno));
792 fp = fopen("/proc/cmdline", "r");
794 _E("appinfo init failed: %s", strerror(errno));
797 cmdline = fgets(buf, sizeof(buf), fp);
798 if (cmdline != NULL) {
799 tmp = strstr(buf, "gles");
801 sscanf(tmp,"gles=%d", &gles);
812 r = _read_pkg_info(_cf);
813 if (r != PMINFO_R_OK) {
818 #ifdef _APPFW_FEATURE_MMC_SUPPORT
819 r = vconf_notify_key_changed(VCONFKEY_SYSMAN_MMC_STATUS, __amd_mmc_vconf_cb, _cf);
821 _E("Unable to register vconf notification callback for VCONFKEY_SYSMAN_MMC_STATUS\n");
824 int event_type = PMINFO_CLIENT_STATUS_UPGRADE | PMINFO_CLIENT_STATUS_UNINSTALL | PMINFO_CLIENT_STATUS_INSTALL;
825 pkgmgrinfo_client *pc = NULL;
826 pc = pkgmgrinfo_client_new(PMINFO_LISTENING);
827 pkgmgrinfo_client_set_status_type(pc, event_type);
828 pkgmgrinfo_client_listen_status(pc, __amd_pkgmgrinfo_status_cb , _cf);
835 void appinfo_fini(struct appinfomgr **cf)
844 const struct appinfomgr *appinfo_insert(struct appinfomgr *cf, const char *pkg_name)
846 pkgmgrinfo_pkginfo_h handle;
847 if (pkgmgrinfo_pkginfo_get_pkginfo(pkg_name, &handle) == PMINFO_R_OK){
848 pkgmgrinfo_appinfo_get_list(handle, PMINFO_SVC_APP, __app_info_insert_handler, cf);
849 pkgmgrinfo_appinfo_get_list(handle, PMINFO_UI_APP, __app_info_insert_handler, cf);
850 pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
855 void appinfo_delete(struct appinfomgr *cf, const char *pkg_name)
857 pkgmgrinfo_pkginfo_h handle;
858 if (pkgmgrinfo_pkginfo_get_pkginfo(pkg_name, &handle) != PMINFO_R_OK)
860 pkgmgrinfo_appinfo_get_list(handle, PMINFO_SVC_APP, __app_info_delete_handler, cf);
861 pkgmgrinfo_appinfo_get_list(handle, PMINFO_UI_APP, __app_info_delete_handler, cf);
862 pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
865 const struct appinfo *appinfo_find(struct appinfomgr *cf, const char *filename)
867 if (!cf || !filename || !*filename) {
872 return g_hash_table_lookup(cf->tbl, FILENAME(filename));
875 const char *appinfo_get_value(const struct appinfo *c, enum appinfo_type type)
881 _E("appinfo get value: %s, %d", strerror(errno), type);
885 for (i = _AI_START; i < sizeof(_appinfos)/sizeof(_appinfos[0]); i++) {
886 if (type == _appinfos[i].type)
891 _E("appinfo get value: %s", strerror(errno));
896 const char *appinfo_set_value(struct appinfo *c, enum appinfo_type type, const char* val)
900 SECURE_LOGE("appinfo is NULL, type: %d, val: %s", type, val);
903 for (i = _AI_START; i < sizeof(_appinfos)/sizeof(_appinfos[0]); i++) {
904 if (type == _appinfos[i].type) {
905 SECURE_LOGD("%s : %s : %s", c->val[_AI_FILE], c->val[i], val);
907 c->val[i] = strdup(val);
914 const char *appinfo_get_filename(const struct appinfo *c)
918 SECURE_LOGE("appinfo get filename: %s", strerror(errno));
922 return c->val[_AI_FILE];
926 appinfo_iter_callback cb;
930 static void _iter_cb(gpointer key, gpointer value, gpointer user_data)
932 struct _cbinfo *cbi = user_data;
936 cbi->cb(cbi->cb_data, key, value);
939 void appinfo_foreach(struct appinfomgr *cf, appinfo_iter_callback cb, void *user_data)
945 _E("appinfo foreach: %s", strerror(errno));
950 cbi.cb_data = user_data;
952 g_hash_table_foreach(cf->tbl, _iter_cb, &cbi);
955 int appinfo_get_boolean(const struct appinfo *c, enum appinfo_type type)
959 v = appinfo_get_value(c, type);
963 if (!strcmp(v, "1") || !strcasecmp(v, "true"))
966 if (!strcmp(v, "0") || !strcasecmp(v, "false"))