13 #include "pkgmgr-info.h"
14 #include "pkgmgrinfo_debug.h"
15 #include "pkgmgrinfo_private.h"
16 #include "pkgmgr_parser.h"
17 #include "manager/pkginfo_manager.h"
19 static bool _get_bool_value(const char *str)
21 if (str && !strcmp(str, "true"))
27 static void __cleanup_appinfo(pkgmgr_appinfo_x *data)
29 pkgmgr_appinfo_x *info = data;
33 free((void *)info->package);
35 free((void *)info->locale);
37 pkgmgrinfo_basic_free_application(info->app_info);
42 static void __free_applications(gpointer data)
44 pkgmgrinfo_basic_free_application((application_x *)data);
47 static gint __disable_chk_func(gconstpointer data1, gconstpointer data2)
49 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)data1;
50 pkgmgrinfo_appinfo_disable_type value = GPOINTER_TO_INT(data2);
52 if (value == E_APPINFO_DISABLE_TYPE_PKG)
53 return (node->prop == E_PMINFO_APPINFO_PROP_PKG_DISABLE)
56 return (node->prop == E_PMINFO_APPINFO_PROP_APP_DISABLE)
60 static bool __check_disable_filter_exist(pkgmgrinfo_filter_x *filter,
61 pkgmgrinfo_appinfo_disable_type type)
68 link = g_slist_find_custom(filter->list,
69 GINT_TO_POINTER(type), __disable_chk_func);
76 static int _pkgmgrinfo_get_appinfo(const char *appid, uid_t uid,
77 pkgmgrinfo_appinfo_filter_h filter, pkgmgrinfo_appinfo_h *handle)
79 int ret = PMINFO_R_OK;
81 pkgmgr_appinfo_x *info;
83 if (appid == NULL || filter == NULL || handle == NULL) {
84 LOGE("invalid parameter");
85 return PMINFO_R_EINVAL;
88 list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
91 return PMINFO_R_ERROR;
93 ret = _appinfo_get_applications(uid, filter,
94 PMINFO_APPINFO_GET_ALL, list);
95 if (ret != PMINFO_R_OK) {
96 g_hash_table_destroy(list);
100 if (!g_hash_table_size(list) || !g_hash_table_lookup(list, appid) ||
101 ((application_x *)g_hash_table_lookup(list, appid))->package == NULL) {
102 _LOGD("appinfo for [%s] is not existed for user [%d]",
104 g_hash_table_destroy(list);
105 return PMINFO_R_ENOENT;
108 info = calloc(1, sizeof(pkgmgr_appinfo_x));
110 _LOGE("out of memory");
111 g_hash_table_destroy(list);
112 return PMINFO_R_ERROR;
115 info->app_info = (application_x *)g_hash_table_lookup(list, appid);
116 info->locale = strdup(info->app_info->locale);
118 _LOGE("out of memory");
119 g_hash_table_destroy(list);
121 return PMINFO_R_ERROR;
123 info->package = strdup(info->app_info->package);
124 if (!info->package) {
125 _LOGE("out of memory");
127 g_hash_table_destroy(list);
129 return PMINFO_R_ERROR;
132 /* just free list only */
133 g_hash_table_steal(list, (gconstpointer)appid);
134 g_hash_table_destroy(list);
141 API int pkgmgrinfo_appinfo_get_usr_disabled_appinfo(
142 const char *appid, uid_t uid, pkgmgrinfo_appinfo_h *handle)
145 pkgmgrinfo_appinfo_filter_h filter;
147 if (appid == NULL || handle == NULL) {
148 LOGE("invalid parameter");
149 return PMINFO_R_EINVAL;
152 ret = pkgmgrinfo_appinfo_filter_create(&filter);
153 if (ret != PMINFO_R_OK)
156 ret = pkgmgrinfo_appinfo_filter_add_string(filter,
157 PMINFO_APPINFO_PROP_APP_ID, appid);
158 if (ret != PMINFO_R_OK) {
159 pkgmgrinfo_appinfo_filter_destroy(filter);
160 return PMINFO_R_ERROR;
163 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
164 PMINFO_APPINFO_PROP_APP_DISABLE, true);
165 if (ret != PMINFO_R_OK) {
166 pkgmgrinfo_appinfo_filter_destroy(filter);
167 return PMINFO_R_ERROR;
170 ret = _pkgmgrinfo_get_appinfo(appid, uid, filter, handle);
171 pkgmgrinfo_appinfo_filter_destroy(filter);
176 API int pkgmgrinfo_appinfo_get_disabled_appinfo(
177 const char *appid, pkgmgrinfo_appinfo_h *handle)
179 return pkgmgrinfo_appinfo_get_usr_disabled_appinfo(
180 appid, _getuid(), handle);
183 API int pkgmgrinfo_appinfo_get_usr_appinfo(const char *appid, uid_t uid,
184 pkgmgrinfo_appinfo_h *handle)
187 pkgmgrinfo_appinfo_filter_h filter;
189 if (appid == NULL || handle == NULL) {
190 LOGE("invalid parameter");
191 return PMINFO_R_EINVAL;
194 ret = pkgmgrinfo_appinfo_filter_create(&filter);
195 if (ret != PMINFO_R_OK)
198 ret = pkgmgrinfo_appinfo_filter_add_string(filter,
199 PMINFO_APPINFO_PROP_APP_ID, appid);
200 if (ret != PMINFO_R_OK) {
201 pkgmgrinfo_appinfo_filter_destroy(filter);
202 return PMINFO_R_ERROR;
205 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
206 PMINFO_APPINFO_PROP_APP_DISABLE, false);
207 if (ret != PMINFO_R_OK) {
208 pkgmgrinfo_appinfo_filter_destroy(filter);
209 return PMINFO_R_ERROR;
212 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
213 PMINFO_APPINFO_PROP_PKG_DISABLE, false);
214 if (ret != PMINFO_R_OK) {
215 pkgmgrinfo_appinfo_filter_destroy(filter);
216 return PMINFO_R_ERROR;
219 ret = _pkgmgrinfo_get_appinfo(appid, uid, filter, handle);
220 pkgmgrinfo_appinfo_filter_destroy(filter);
224 API int pkgmgrinfo_appinfo_get_appinfo(
225 const char *appid, pkgmgrinfo_appinfo_h *handle)
227 return pkgmgrinfo_appinfo_get_usr_appinfo(appid, _getuid(), handle);
230 API int pkgmgrinfo_appinfo_get_usr_all_appinfo(const char *appid, uid_t uid,
231 pkgmgrinfo_appinfo_h *handle)
234 pkgmgrinfo_appinfo_filter_h filter;
236 if (appid == NULL || handle == NULL) {
237 LOGE("invalid parameter");
238 return PMINFO_R_EINVAL;
241 ret = pkgmgrinfo_appinfo_filter_create(&filter);
242 if (ret != PMINFO_R_OK)
245 ret = pkgmgrinfo_appinfo_filter_add_string(filter,
246 PMINFO_APPINFO_PROP_APP_ID, appid);
247 if (ret != PMINFO_R_OK) {
248 pkgmgrinfo_appinfo_filter_destroy(filter);
249 return PMINFO_R_ERROR;
252 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
253 PMINFO_APPINFO_PROP_APP_CHECK_STORAGE, false);
254 if (ret != PMINFO_R_OK) {
255 pkgmgrinfo_appinfo_filter_destroy(filter);
256 return PMINFO_R_ERROR;
259 ret = _pkgmgrinfo_get_appinfo(appid, uid, filter, handle);
260 pkgmgrinfo_appinfo_filter_destroy(filter);
265 API int pkgmgrinfo_appinfo_get_all_appinfo(
266 const char *appid, pkgmgrinfo_appinfo_h *handle)
268 return pkgmgrinfo_appinfo_get_usr_all_appinfo(appid, _getuid(), handle);
271 static gpointer __copy_str(gconstpointer src, gpointer data)
273 const char *tmp = (const char *)src;
276 buffer = strdup(tmp);
277 if (buffer == NULL) {
278 LOGE("memory alloc failed");
286 static gpointer __copy_label(gconstpointer src, gpointer data)
288 label_x *tmp = (label_x *)src;
291 label = calloc(1, sizeof(label_x));
293 LOGE("memory alloc failed");
299 label->name = strdup(tmp->name);
301 label->text = strdup(tmp->text);
303 label->lang = strdup(tmp->lang);
308 static gpointer __copy_icon(gconstpointer src, gpointer data)
310 icon_x *tmp = (icon_x *)src;
313 icon = calloc(1, sizeof(icon_x));
315 LOGE("memory alloc failed");
321 icon->text = strdup(tmp->text);
323 icon->lang = strdup(tmp->lang);
325 icon->section = strdup(tmp->section);
327 icon->size = strdup(tmp->size);
329 icon->resolution = strdup(tmp->resolution);
334 static gpointer __copy_metadata(gconstpointer src, gpointer data)
336 metadata_x *tmp = (metadata_x *)src;
337 metadata_x *metadata;
339 metadata = calloc(1, sizeof(metadata_x));
340 if (metadata == NULL) {
341 LOGE("memory alloc failed");
347 metadata->key = strdup(tmp->key);
349 metadata->value = strdup(tmp->value);
354 static gpointer __copy_datacontrol(gconstpointer src, gpointer data)
356 datacontrol_x *tmp = (datacontrol_x *)src;
357 datacontrol_x *datacontrol;
359 datacontrol = calloc(1, sizeof(datacontrol_x));
360 if (datacontrol == NULL) {
361 LOGE("memory alloc failed");
367 datacontrol->providerid = strdup(tmp->providerid);
369 datacontrol->access = strdup(tmp->access);
371 datacontrol->type = strdup(tmp->type);
373 datacontrol->trusted = strdup(tmp->trusted);
378 static gpointer __copy_appcontrol(gconstpointer src, gpointer data)
380 appcontrol_x *tmp = (appcontrol_x *)src;
381 appcontrol_x *appcontrol;
383 appcontrol = calloc(1, sizeof(appcontrol_x));
384 if (appcontrol == NULL) {
385 LOGE("memory alloc failed");
391 appcontrol->operation = strdup(tmp->operation);
393 appcontrol->uri = strdup(tmp->uri);
395 appcontrol->mime = strdup(tmp->mime);
400 static gpointer __copy_splashscreens(gconstpointer src, gpointer data)
402 splashscreen_x *tmp = (splashscreen_x *)src;
403 splashscreen_x *splashscreen;
405 splashscreen = (splashscreen_x *)calloc(1, sizeof(splashscreen_x));
406 if (splashscreen == NULL) {
407 LOGE("memory alloc failed");
413 splashscreen->src = strdup(tmp->src);
415 splashscreen->type = strdup(tmp->type);
416 if (tmp->orientation)
417 splashscreen->orientation = strdup(tmp->orientation);
418 if (tmp->indicatordisplay)
419 splashscreen->indicatordisplay = strdup(tmp->indicatordisplay);
421 splashscreen->operation = strdup(tmp->operation);
422 if (tmp->color_depth)
423 splashscreen->color_depth = strdup(tmp->color_depth);
428 static int _appinfo_copy_appinfo(
429 application_x **application, application_x *data)
431 application_x *app_info;
434 app_info = calloc(1, sizeof(application_x));
435 if (app_info == NULL) {
436 LOGE("memory alloc failed");
437 return PMINFO_R_ERROR;
440 if (data->appid != NULL)
441 app_info->appid = strdup(data->appid);
442 if (data->exec != NULL)
443 app_info->exec = strdup(data->exec);
444 if (data->nodisplay != NULL)
445 app_info->nodisplay = strdup(data->nodisplay);
446 if (data->multiple != NULL)
447 app_info->multiple = strdup(data->multiple);
448 if (data->taskmanage != NULL)
449 app_info->taskmanage = strdup(data->taskmanage);
450 if (data->type != NULL)
451 app_info->type = strdup(data->type);
452 if (data->categories != NULL)
453 app_info->categories = strdup(data->categories);
454 if (data->hwacceleration != NULL)
455 app_info->hwacceleration = strdup(data->hwacceleration);
456 if (data->screenreader != NULL)
457 app_info->screenreader = strdup(data->screenreader);
458 if (data->mainapp != NULL)
459 app_info->mainapp = strdup(data->mainapp);
460 if (data->package != NULL)
461 app_info->package = strdup(data->package);
462 if (data->recentimage != NULL)
463 app_info->recentimage = strdup(data->recentimage);
464 if (data->launchcondition != NULL)
465 app_info->launchcondition = strdup(data->launchcondition);
466 if (data->indicatordisplay != NULL)
467 app_info->indicatordisplay = strdup(data->indicatordisplay);
468 if (data->portraitimg != NULL)
469 app_info->portraitimg = strdup(data->portraitimg);
470 if (data->landscapeimg != NULL)
471 app_info->landscapeimg = strdup(data->landscapeimg);
472 if (data->guestmode_visibility != NULL)
473 app_info->guestmode_visibility =
474 strdup(data->guestmode_visibility);
475 if (data->component != NULL)
476 app_info->component = strdup(data->component);
477 if (data->permission_type != NULL)
478 app_info->permission_type = strdup(data->permission_type);
479 if (data->component_type != NULL)
480 app_info->component_type = strdup(data->component_type);
481 if (data->preload != NULL)
482 app_info->preload = strdup(data->preload);
483 if (data->submode != NULL)
484 app_info->submode = strdup(data->submode);
485 if (data->submode_mainid != NULL)
486 app_info->submode_mainid = strdup(data->submode_mainid);
487 if (data->process_pool != NULL)
488 app_info->process_pool = strdup(data->process_pool);
489 if (data->installed_storage != NULL)
490 app_info->installed_storage = strdup(data->installed_storage);
491 if (data->autorestart != NULL)
492 app_info->autorestart = strdup(data->autorestart);
493 if (data->onboot != NULL)
494 app_info->onboot = strdup(data->onboot);
495 if (data->support_disable != NULL)
496 app_info->support_disable = strdup(data->support_disable);
497 if (data->ui_gadget != NULL)
498 app_info->ui_gadget = strdup(data->ui_gadget);
499 if (data->launch_mode != NULL)
500 app_info->launch_mode = strdup(data->launch_mode);
501 if (data->package_type != NULL)
502 app_info->package_type = strdup(data->package_type);
503 if (data->effective_appid != NULL)
504 app_info->effective_appid = strdup(data->effective_appid);
505 if (data->splash_screen_display != NULL)
506 app_info->splash_screen_display =
507 strdup(data->splash_screen_display);
511 app_info->label = g_list_copy_deep(data->label, __copy_label, &ret);
513 LOGE("memory alloc failed");
514 pkgmgrinfo_basic_free_application(app_info);
515 return PMINFO_R_ERROR;
519 app_info->icon = g_list_copy_deep(data->icon, __copy_icon, &ret);
521 LOGE("memory alloc failed");
522 pkgmgrinfo_basic_free_application(app_info);
523 return PMINFO_R_ERROR;
527 app_info->category = g_list_copy_deep(data->category, __copy_str, &ret);
529 LOGE("memory alloc failed");
530 pkgmgrinfo_basic_free_application(app_info);
531 return PMINFO_R_ERROR;
535 app_info->metadata = g_list_copy_deep(data->metadata,
536 __copy_metadata, &ret);
538 LOGE("memory alloc failed");
539 pkgmgrinfo_basic_free_application(app_info);
540 return PMINFO_R_ERROR;
544 app_info->datacontrol = g_list_copy_deep(data->datacontrol,
545 __copy_datacontrol, &ret);
547 LOGE("memory alloc failed");
548 pkgmgrinfo_basic_free_application(app_info);
549 return PMINFO_R_ERROR;
553 app_info->appcontrol = g_list_copy_deep(data->appcontrol,
554 __copy_appcontrol, &ret);
556 LOGE("memory alloc failed");
557 pkgmgrinfo_basic_free_application(app_info);
558 return PMINFO_R_ERROR;
562 app_info->background_category =
563 g_list_copy_deep(data->background_category,
566 LOGE("memory alloc failed");
567 pkgmgrinfo_basic_free_application(app_info);
568 return PMINFO_R_ERROR;
572 app_info->splashscreens = g_list_copy_deep(data->splashscreens,
573 __copy_splashscreens, &ret);
575 LOGE("memory alloc failed");
576 pkgmgrinfo_basic_free_application(app_info);
577 return PMINFO_R_ERROR;
580 *application = app_info;
585 API int pkgmgrinfo_appinfo_clone_appinfo(pkgmgrinfo_appinfo_h handle,
586 pkgmgrinfo_appinfo_h *clone)
588 pkgmgr_appinfo_x *info;
589 pkgmgr_appinfo_x *temp = (pkgmgr_appinfo_x *)handle;
592 return PMINFO_R_EINVAL;
594 info = calloc(1, sizeof(pkgmgr_appinfo_x));
596 LOGE("memory alloc failed");
597 return PMINFO_R_ERROR;
600 if (temp->package != NULL)
601 info->package = strdup(temp->package);
602 if (temp->locale != NULL)
603 info->locale = strdup(temp->locale);
605 info->app_component = temp->app_component;
607 if (_appinfo_copy_appinfo(&info->app_info, temp->app_info) < 0) {
608 LOGE("appinfo copy failed");
610 free((void *)info->package);
614 return PMINFO_R_ERROR;
622 static int _appinfo_get_filtered_foreach_appinfo(uid_t uid,
623 pkgmgrinfo_filter_x *filter, int flag,
624 pkgmgrinfo_app_list_cb app_list_cb,
628 pkgmgr_appinfo_x info;
634 list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
635 __free_applications);
637 return PMINFO_R_ERROR;
639 ret = _appinfo_get_applications(uid, filter,
640 flag | PMINFO_APPINFO_GET_BASICINFO, list);
641 if (ret == PMINFO_R_ERROR) {
642 g_hash_table_destroy(list);
646 g_hash_table_iter_init(&iter, list);
647 while (g_hash_table_iter_next(&iter, NULL, &value)) {
648 app = (application_x *)value;
650 info.locale = info.app_info->locale;
651 info.package = app->package;
652 if (app_list_cb(&info, user_data) < 0)
655 g_hash_table_destroy(list);
660 static const char *__appcomponent_str(pkgmgrinfo_app_component comp);
662 API int pkgmgrinfo_appinfo_get_usr_list(pkgmgrinfo_pkginfo_h handle,
663 pkgmgrinfo_app_component component,
664 pkgmgrinfo_app_list_cb app_func, void *user_data, uid_t uid)
667 pkgmgrinfo_appinfo_filter_h filter;
669 const char *comp_str = NULL;
671 if (handle == NULL || app_func == NULL) {
672 LOGE("invalid parameter");
673 return PMINFO_R_EINVAL;
676 if (pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid)) {
677 LOGE("invalid parameter");
678 return PMINFO_R_EINVAL;
681 if (pkgmgrinfo_appinfo_filter_create(&filter))
682 return PMINFO_R_ERROR;
684 if (pkgmgrinfo_appinfo_filter_add_string(filter,
685 PMINFO_APPINFO_PROP_APP_PACKAGE, pkgid)) {
686 pkgmgrinfo_appinfo_filter_destroy(filter);
687 return PMINFO_R_ERROR;
690 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
691 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
692 pkgmgrinfo_appinfo_filter_destroy(filter);
693 return PMINFO_R_ERROR;
696 comp_str = __appcomponent_str(component);
699 if (pkgmgrinfo_appinfo_filter_add_string(filter,
700 PMINFO_APPINFO_PROP_APP_COMPONENT,
702 pkgmgrinfo_appinfo_filter_destroy(filter);
703 return PMINFO_R_ERROR;
707 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter,
708 PMINFO_APPINFO_GET_ALL, app_func, user_data);
710 pkgmgrinfo_appinfo_filter_destroy(filter);
715 API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle,
716 pkgmgrinfo_app_component component,
717 pkgmgrinfo_app_list_cb app_func, void *user_data)
719 return pkgmgrinfo_appinfo_get_usr_list(handle,
720 component, app_func, user_data, _getuid());
723 API int pkgmgrinfo_appinfo_get_usr_installed_list_full(
724 pkgmgrinfo_app_list_cb app_func, uid_t uid, int flag,
728 pkgmgrinfo_appinfo_filter_h filter;
730 if (app_func == NULL) {
731 LOGE("invalid parameter");
732 return PMINFO_R_EINVAL;
735 if (pkgmgrinfo_appinfo_filter_create(&filter))
736 return PMINFO_R_ERROR;
738 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
739 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
740 pkgmgrinfo_appinfo_filter_destroy(filter);
741 return PMINFO_R_ERROR;
744 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
745 PMINFO_APPINFO_PROP_PKG_DISABLE, false)) {
746 pkgmgrinfo_appinfo_filter_destroy(filter);
747 return PMINFO_R_ERROR;
750 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
751 PMINFO_APPINFO_PROP_APP_CHECK_STORAGE, false)) {
752 pkgmgrinfo_appinfo_filter_destroy(filter);
753 return PMINFO_R_ERROR;
756 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter, flag, app_func,
759 pkgmgrinfo_appinfo_filter_destroy(filter);
764 API int pkgmgrinfo_appinfo_get_installed_list_full(
765 pkgmgrinfo_app_list_cb app_func, int flag, void *user_data)
767 return pkgmgrinfo_appinfo_get_usr_installed_list_full(app_func,
768 _getuid(), flag, user_data);
771 API int pkgmgrinfo_appinfo_get_usr_installed_list(
772 pkgmgrinfo_app_list_cb app_func, uid_t uid, void *user_data)
775 pkgmgrinfo_appinfo_filter_h filter;
777 if (app_func == NULL) {
778 LOGE("invalid parameter");
779 return PMINFO_R_EINVAL;
782 /* create an empty filter */
783 ret = pkgmgrinfo_appinfo_filter_create(&filter);
784 if (ret != PMINFO_R_OK)
787 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
788 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
789 pkgmgrinfo_appinfo_filter_destroy(filter);
790 return PMINFO_R_ERROR;
793 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
794 PMINFO_APPINFO_PROP_PKG_DISABLE, false)) {
795 pkgmgrinfo_appinfo_filter_destroy(filter);
796 return PMINFO_R_ERROR;
799 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter,
800 PMINFO_APPINFO_GET_ALL, app_func, user_data);
802 pkgmgrinfo_appinfo_filter_destroy(filter);
807 API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func,
810 return pkgmgrinfo_appinfo_get_usr_installed_list(app_func, _getuid(),
814 API int pkgmgrinfo_appinfo_get_appid(pkgmgrinfo_appinfo_h handle, char **appid)
816 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
818 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
819 retvm_if(appid == NULL, PMINFO_R_EINVAL,
820 "Argument supplied to hold return value is NULL");
822 if (info->app_info == NULL || info->app_info->appid == NULL)
823 return PMINFO_R_ERROR;
824 *appid = (char *)info->app_info->appid;
829 API int pkgmgrinfo_appinfo_get_pkgname(
830 pkgmgrinfo_appinfo_h handle, char **pkg_name)
832 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
834 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
835 retvm_if(pkg_name == NULL, PMINFO_R_EINVAL,
836 "Argument supplied to hold return value is NULL");
838 if (info->package == NULL)
839 return PMINFO_R_ERROR;
841 *pkg_name = (char *)info->package;
846 API int pkgmgrinfo_appinfo_get_pkgid(pkgmgrinfo_appinfo_h handle, char **pkgid)
848 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
850 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
851 retvm_if(pkgid == NULL, PMINFO_R_EINVAL,
852 "Argument supplied to hold return value is NULL");
854 if (info->package == NULL)
855 return PMINFO_R_ERROR;
857 *pkgid = (char *)info->package;
862 API int pkgmgrinfo_appinfo_get_pkgtype(
863 pkgmgrinfo_appinfo_h handle, char **pkgtype)
865 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
866 retvm_if(pkgtype == NULL, PMINFO_R_EINVAL,
867 "Argument supplied to hold return value is NULL");
868 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
870 *pkgtype = (char *)info->app_info->package_type;
875 API int pkgmgrinfo_appinfo_get_exec(pkgmgrinfo_appinfo_h handle, char **exec)
877 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
879 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
880 retvm_if(exec == NULL, PMINFO_R_EINVAL,
881 "Argument supplied to hold return value is NULL");
883 if (info->app_info == NULL || info->app_info->exec == NULL)
884 return PMINFO_R_ERROR;
885 *exec = (char *)info->app_info->exec;
891 API int pkgmgrinfo_appinfo_get_icon(pkgmgrinfo_appinfo_h handle, char **icon)
894 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
896 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
897 retvm_if(icon == NULL, PMINFO_R_EINVAL,
898 "Argument supplied to hold return value is NULL");
900 if (info->app_info == NULL)
901 return PMINFO_R_ERROR;
903 if (info->app_info->icon == NULL) {
908 ptr = (icon_x *)info->app_info->icon->data;
910 return PMINFO_R_ERROR;
912 if (ptr->text == NULL)
913 return PMINFO_R_ERROR;
921 API int pkgmgrinfo_appinfo_get_label(pkgmgrinfo_appinfo_h handle, char **label)
924 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
929 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
930 retvm_if(label == NULL, PMINFO_R_EINVAL,
931 "Argument supplied to hold return value is NULL");
933 if (info->app_info == NULL)
934 return PMINFO_R_ERROR;
936 locale = info->locale;
938 locale = DEFAULT_LOCALE;
940 for (tmp = info->app_info->label; tmp; tmp = tmp->next) {
941 ptr = (label_x *)tmp->data;
942 if (ptr == NULL || strcmp(locale, ptr->lang) != 0)
953 for (tmp = info->app_info->label; tmp; tmp = tmp->next) {
954 ptr = (label_x *)tmp->data;
955 if (ptr == NULL || strcmp(DEFAULT_LOCALE, ptr->lang) != 0)
961 *label = lbl ? lbl : "";
966 API int pkgmgrinfo_appinfo_usr_get_localed_label(const char *appid,
967 const char *locale, uid_t uid, char **label)
971 retvm_if(appid == NULL || locale == NULL || label == NULL,
972 PMINFO_R_EINVAL, "Argument is NULL");
973 val = _appinfo_get_localed_label(appid, locale, uid);
975 return PMINFO_R_ERROR;
981 API int pkgmgrinfo_appinfo_get_localed_label(
982 const char *appid, const char *locale, char **label)
984 return pkgmgrinfo_appinfo_usr_get_localed_label(
985 appid, locale, _getuid(), label);
988 API int pkgmgrinfo_appinfo_get_metadata_value(
989 pkgmgrinfo_appinfo_h handle, const char *metadata_key,
990 char **metadata_value)
992 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
993 retvm_if(metadata_key == NULL, PMINFO_R_EINVAL, "metadata_key is NULL");
994 retvm_if(metadata_value == NULL, PMINFO_R_EINVAL,
995 "metadata_value is NULL");
997 GList *list_md = NULL;
998 metadata_x *metadata = NULL;
999 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1001 list_md = info->app_info->metadata;
1003 for (; list_md; list_md = list_md->next) {
1004 metadata = (metadata_x *)list_md->data;
1005 if (metadata && metadata->key) {
1006 if (strcasecmp(metadata->key, metadata_key) == 0) {
1007 if (metadata->value == NULL)
1008 *metadata_value = "";
1011 (char *)metadata->value;
1017 return PMINFO_R_EINVAL;
1020 static pkgmgrinfo_app_component __appcomponent_convert(const char *comp)
1022 if (strcasecmp(comp, "uiapp") == 0)
1023 return PMINFO_UI_APP;
1024 else if (strcasecmp(comp, "svcapp") == 0)
1025 return PMINFO_SVC_APP;
1026 else if (strcasecmp(comp, "widgetapp") == 0)
1027 return PMINFO_WIDGET_APP;
1028 else if (strcasecmp(comp, "watchapp") == 0)
1029 return PMINFO_WATCH_APP;
1030 else if (strcasecmp(comp, "componentbasedapp") == 0)
1031 return PMINFO_COMPONENT_BASED_APP;
1036 static const char *__appcomponent_str(pkgmgrinfo_app_component comp)
1041 case PMINFO_SVC_APP:
1043 case PMINFO_WIDGET_APP:
1045 case PMINFO_WATCH_APP:
1047 case PMINFO_COMPONENT_BASED_APP:
1048 return "componentbasedapp";
1054 API int pkgmgrinfo_appinfo_get_component(
1055 pkgmgrinfo_appinfo_h handle,
1056 pkgmgrinfo_app_component *component)
1058 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1061 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1062 retvm_if(component == NULL, PMINFO_R_EINVAL,
1063 "Argument supplied to hold return value is NULL");
1065 if (info->app_info == NULL)
1066 return PMINFO_R_ERROR;
1068 comp = __appcomponent_convert(info->app_info->component);
1070 return PMINFO_R_ERROR;
1077 API int pkgmgrinfo_appinfo_get_apptype(
1078 pkgmgrinfo_appinfo_h handle, char **app_type)
1080 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1082 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1083 retvm_if(app_type == NULL, PMINFO_R_EINVAL,
1084 "Argument supplied to hold return value is NULL");
1086 if (info->app_info == NULL || info->app_info->type == NULL)
1087 return PMINFO_R_ERROR;
1088 *app_type = (char *)info->app_info->type;
1093 API int pkgmgrinfo_appinfo_get_notification_icon(
1094 pkgmgrinfo_appinfo_h handle, char **icon)
1099 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1101 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1102 retvm_if(icon == NULL, PMINFO_R_EINVAL,
1103 "Argument supplied to hold return value is NULL\n");
1105 if (info->app_info == NULL)
1106 return PMINFO_R_ERROR;
1108 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1109 ptr = (icon_x *)tmp->data;
1110 if (ptr == NULL || ptr->section == NULL)
1113 val = (char *)ptr->section;
1114 if (val && strcmp(val, "notification") == 0) {
1115 *icon = (char *)ptr->text;
1120 return PMINFO_R_ERROR;
1123 API int pkgmgrinfo_appinfo_get_recent_image_type(
1124 pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_recentimage *type)
1127 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1129 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1130 retvm_if(type == NULL, PMINFO_R_EINVAL,
1131 "Argument supplied to hold return value is NULL");
1133 if (info->app_info == NULL || info->app_info->recentimage == NULL)
1134 return PMINFO_R_ERROR;
1136 val = (char *)info->app_info->recentimage;
1137 if (strcasecmp(val, "capture") == 0)
1138 *type = PMINFO_RECENTIMAGE_USE_CAPTURE;
1139 else if (strcasecmp(val, "icon") == 0)
1140 *type = PMINFO_RECENTIMAGE_USE_ICON;
1142 *type = PMINFO_RECENTIMAGE_USE_NOTHING;
1147 API int pkgmgrinfo_appinfo_get_preview_image(
1148 pkgmgrinfo_appinfo_h handle, char **preview_img)
1153 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1155 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1156 retvm_if(preview_img == NULL, PMINFO_R_EINVAL,
1157 "Argument supplied to hold return value is NULL\n");
1159 if (info->app_info == NULL)
1160 return PMINFO_R_ERROR;
1162 for (tmp = info->app_info->image; tmp; tmp = tmp->next) {
1163 ptr = (image_x *)tmp->data;
1164 if (ptr == NULL || ptr->section == NULL)
1167 val = (char *)ptr->section;
1168 if (val && strcmp(val, "preview") == 0) {
1169 *preview_img = (char *)ptr->text;
1174 return PMINFO_R_ERROR;
1177 API int pkgmgrinfo_appinfo_get_permission_type(
1178 pkgmgrinfo_appinfo_h handle,
1179 pkgmgrinfo_permission_type *permission)
1182 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1184 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1185 retvm_if(permission == NULL, PMINFO_R_EINVAL,
1186 "Argument supplied to hold return value is NULL\n");
1188 val = info->app_info->permission_type;
1190 return PMINFO_R_ERROR;
1192 if (strcmp(val, "signature") == 0)
1193 *permission = PMINFO_PERMISSION_SIGNATURE;
1194 else if (strcmp(val, "privilege") == 0)
1195 *permission = PMINFO_PERMISSION_PRIVILEGE;
1197 *permission = PMINFO_PERMISSION_NORMAL;
1202 API int pkgmgrinfo_appinfo_get_component_type(
1203 pkgmgrinfo_appinfo_h handle, char **component_type)
1205 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1207 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1208 retvm_if(component_type == NULL, PMINFO_R_EINVAL,
1209 "Argument supplied to hold return value is NULL");
1211 if (info->app_info == NULL || info->app_info->component_type == NULL)
1212 return PMINFO_R_ERROR;
1214 *component_type = (char *)info->app_info->component_type;
1219 API int pkgmgrinfo_appinfo_get_hwacceleration(
1220 pkgmgrinfo_appinfo_h handle,
1221 pkgmgrinfo_app_hwacceleration *hwacceleration)
1224 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1226 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1227 retvm_if(hwacceleration == NULL, PMINFO_R_EINVAL,
1228 "Argument supplied to hold return value is NULL");
1230 if (info->app_info == NULL || info->app_info->hwacceleration == NULL)
1231 return PMINFO_R_ERROR;
1233 val = (char *)info->app_info->hwacceleration;
1234 if (strcasecmp(val, "off") == 0)
1235 *hwacceleration = PMINFO_HWACCELERATION_OFF;
1236 else if (strcasecmp(val, "on") == 0)
1237 *hwacceleration = PMINFO_HWACCELERATION_ON;
1239 *hwacceleration = PMINFO_HWACCELERATION_DEFAULT;
1244 API int pkgmgrinfo_appinfo_get_screenreader(
1245 pkgmgrinfo_appinfo_h handle,
1246 pkgmgrinfo_app_screenreader *screenreader)
1249 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1251 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1252 retvm_if(screenreader == NULL, PMINFO_R_EINVAL,
1253 "Argument supplied to hold return value is NULL");
1255 if (info->app_info == NULL || info->app_info->screenreader == NULL)
1256 return PMINFO_R_ERROR;
1258 val = (char *)info->app_info->screenreader;
1259 if (strcasecmp(val, "screenreader-off") == 0)
1260 *screenreader = PMINFO_SCREENREADER_OFF;
1261 else if (strcasecmp(val, "screenreader-on") == 0)
1262 *screenreader = PMINFO_SCREENREADER_ON;
1264 *screenreader = PMINFO_SCREENREADER_USE_SYSTEM_SETTING;
1269 API int pkgmgrinfo_appinfo_get_effectimage(
1270 pkgmgrinfo_appinfo_h handle, char **portrait_img,
1271 char **landscape_img)
1273 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1275 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1276 retvm_if(portrait_img == NULL, PMINFO_R_EINVAL,
1277 "Argument supplied to hold return value is NULL");
1278 retvm_if(landscape_img == NULL, PMINFO_R_EINVAL,
1279 "Argument supplied to hold return value is NULL");
1281 if (info->app_info == NULL)
1282 return PMINFO_R_ERROR;
1284 if (info->app_info->portraitimg == NULL)
1287 *portrait_img = (char *)info->app_info->portraitimg;
1289 if (info->app_info->landscapeimg == NULL)
1290 *landscape_img = "";
1292 *landscape_img = (char *)info->app_info->landscapeimg;
1297 API int pkgmgrinfo_appinfo_get_effectimage_type(
1298 pkgmgrinfo_appinfo_h handle, char **effectimage_type)
1300 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1302 if (handle == NULL || effectimage_type == NULL) {
1303 LOGE("invalid parameter");
1304 return PMINFO_R_EINVAL;
1307 if (info->app_info == NULL || info->app_info->effectimage_type == NULL)
1308 return PMINFO_R_ERROR;
1310 *effectimage_type = (char *)info->app_info->effectimage_type;
1315 API int pkgmgrinfo_appinfo_get_submode_mainid(
1316 pkgmgrinfo_appinfo_h handle, char **submode_mainid)
1318 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1320 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1321 retvm_if(submode_mainid == NULL, PMINFO_R_EINVAL,
1322 "Argument supplied to hold return value is NULL");
1324 if (info->app_info == NULL)
1325 return PMINFO_R_ERROR;
1327 if (info->app_info->submode_mainid == NULL)
1328 *submode_mainid = "";
1330 *submode_mainid = (char *)info->app_info->submode_mainid;
1335 API int pkgmgrinfo_appinfo_get_installed_storage_location(
1336 pkgmgrinfo_appinfo_h handle,
1337 pkgmgrinfo_installed_storage *storage)
1339 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1340 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1342 if (info->app_info && info->app_info->installed_storage) {
1343 if (strcmp(info->app_info->installed_storage,
1344 "installed_internal") == 0)
1345 *storage = PMINFO_INTERNAL_STORAGE;
1346 else if (strcmp(info->app_info->installed_storage,
1347 "installed_external") == 0)
1348 *storage = PMINFO_EXTERNAL_STORAGE;
1350 return PMINFO_R_ERROR;
1352 return PMINFO_R_ERROR;
1358 API int pkgmgrinfo_appinfo_get_launch_mode(
1359 pkgmgrinfo_appinfo_h handle, char **mode)
1361 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1363 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1364 retvm_if(mode == NULL, PMINFO_R_EINVAL,
1365 "Argument supplied to hold return value is NULL\n");
1367 if (info->app_info->launch_mode == NULL)
1368 return PMINFO_R_ERROR;
1370 *mode = (char *)(info->app_info->launch_mode);
1375 API int pkgmgrinfo_appinfo_get_alias_appid(
1376 pkgmgrinfo_appinfo_h handle, char **alias_appid)
1378 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1380 if (handle == NULL || alias_appid == NULL) {
1381 LOGE("invalid parameter");
1382 return PMINFO_R_EINVAL;
1385 if (info->app_info == NULL || info->app_info->alias_appid == NULL)
1386 return PMINFO_R_ERROR;
1388 *alias_appid = (char *)info->app_info->alias_appid;
1393 API int pkgmgrinfo_appinfo_get_effective_appid(
1394 pkgmgrinfo_appinfo_h handle, char **effective_appid)
1396 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1398 if (handle == NULL || effective_appid == NULL) {
1399 LOGE("invalid parameter");
1400 return PMINFO_R_EINVAL;
1403 if (info->app_info == NULL)
1404 return PMINFO_R_ERROR;
1406 if (info->app_info->effective_appid == NULL)
1407 *effective_appid = "";
1409 *effective_appid = (char *)info->app_info->effective_appid;
1414 API int pkgmgrinfo_appinfo_get_tep_name(
1415 pkgmgrinfo_appinfo_h handle, char **tep_name)
1417 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1419 if (handle == NULL || tep_name == NULL) {
1420 LOGE("invalid parameter");
1421 return PMINFO_R_EINVAL;
1424 if (info->app_info == NULL)
1425 return PMINFO_R_ERROR;
1427 if (info->app_info->tep_name == NULL)
1430 *tep_name = (char *)info->app_info->tep_name;
1435 API int pkgmgrinfo_appinfo_get_zip_mount_file(
1436 pkgmgrinfo_appinfo_h handle, char **zip_mount_file)
1438 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1440 if (handle == NULL || zip_mount_file == NULL) {
1441 LOGE("invalid parameter");
1442 return PMINFO_R_EINVAL;
1445 if (info->app_info == NULL)
1446 return PMINFO_R_ERROR;
1448 if (info->app_info->zip_mount_file == NULL)
1449 *zip_mount_file = "";
1451 *zip_mount_file = (char *)info->app_info->zip_mount_file;
1456 API int pkgmgrinfo_appinfo_get_root_path(
1457 pkgmgrinfo_appinfo_h handle, char **root_path)
1459 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1461 if (handle == NULL || root_path == NULL) {
1462 LOGE("invalid parameter");
1463 return PMINFO_R_EINVAL;
1466 if (info->app_info == NULL || info->app_info->root_path == NULL)
1467 return PMINFO_R_ERROR;
1469 *root_path = (char *)info->app_info->root_path;
1474 API int pkgmgrinfo_appinfo_get_api_version(
1475 pkgmgrinfo_appinfo_h handle, char **api_version)
1477 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1479 if (handle == NULL || api_version == NULL) {
1480 LOGE("invalid parameter");
1481 return PMINFO_R_EINVAL;
1484 if (info->app_info == NULL || info->app_info->api_version == NULL)
1485 return PMINFO_R_ERROR;
1487 *api_version = (char *)info->app_info->api_version;
1492 API int pkgmgrinfo_appinfo_get_installed_time(
1493 pkgmgrinfo_appinfo_h handle, int *installed_time)
1495 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1497 if (handle == NULL || installed_time == NULL) {
1498 LOGE("invalid parameter");
1499 return PMINFO_R_EINVAL;
1502 if (info->app_info == NULL ||
1503 info->app_info->package_installed_time == NULL)
1504 return PMINFO_R_ERROR;
1506 *installed_time = atoi(info->app_info->package_installed_time);
1511 API int pkgmgrinfo_appinfo_usr_get_datacontrol_info(const char *providerid,
1512 const char *type, uid_t uid, char **appid, char **access)
1516 if (providerid == NULL || type == NULL || appid == NULL ||
1518 LOGE("invalid parameter");
1519 return PMINFO_R_EINVAL;
1522 ret = _appinfo_get_datacontrol_info(
1523 providerid, type, uid, appid, access);
1524 /* FIXME: It should return PMINFO_R_ENOENT but to keep previous
1525 * implementation, return PMINFO_R_ERROR. This should be
1528 if (ret == PMINFO_R_ENOENT) {
1529 LOGE("no datacontrol info of %s", providerid);
1530 ret = PMINFO_R_ERROR;
1536 API int pkgmgrinfo_appinfo_get_datacontrol_info(const char *providerid,
1537 const char *type, char **appid, char **access)
1539 return pkgmgrinfo_appinfo_usr_get_datacontrol_info(providerid,
1540 type, _getuid(), appid, access);
1543 API int pkgmgrinfo_appinfo_usr_get_datacontrol_appid(const char *providerid,
1544 uid_t uid, char **appid)
1548 if (providerid == NULL || appid == NULL) {
1549 LOGE("invalid parameter");
1550 return PMINFO_R_EINVAL;
1553 ret = _appinfo_get_datacontrol_appid(providerid, uid, appid);
1554 /* FIXME: It should return PMINFO_R_ENOENT but to keep previous
1555 * implementation, return PMINFO_R_ERROR. This should be
1558 if (ret == PMINFO_R_ENOENT) {
1559 LOGE("no datacontrol appid of %s", providerid);
1560 ret = PMINFO_R_ERROR;
1566 API int pkgmgrinfo_appinfo_get_datacontrol_appid(
1567 const char *providerid, char **appid)
1569 return pkgmgrinfo_appinfo_usr_get_datacontrol_appid(
1570 providerid, _getuid(), appid);
1573 API int pkgmgrinfo_appinfo_usr_get_datacontrol_trusted_info(
1574 const char *providerid, const char *type, uid_t uid,
1575 char **appid, bool *is_trusted)
1578 char *trusted = NULL;
1580 if (providerid == NULL || type == NULL || appid == NULL ||
1581 is_trusted == NULL) {
1582 LOGE("invalid parameter");
1583 return PMINFO_R_EINVAL;
1586 ret = _appinfo_get_datacontrol_trusted_info(providerid, type, uid,
1589 /* FIXME: It should return PMINFO_R_ENOENT but to keep previous
1590 * implementation, return PMINFO_R_ERROR. This should be
1593 if (ret == PMINFO_R_ENOENT) {
1594 LOGE("no datacontrol trusted info of %s", providerid);
1595 ret = PMINFO_R_ERROR;
1597 *is_trusted = _get_bool_value(trusted);
1603 API int pkgmgrinfo_appinfo_get_datacontrol_trsuted_info(const char *providerid,
1604 const char *type, char **appid, bool *is_trusted)
1606 return pkgmgrinfo_appinfo_usr_get_datacontrol_trusted_info(providerid,
1607 type, _getuid(), appid, is_trusted);
1610 API int pkgmgrinfo_appinfo_usr_foreach_datacontrol_privileges(
1611 const char *providerid, const char *type,
1612 pkgmgrinfo_pkg_privilege_list_cb privilege_func,
1613 void *user_data, uid_t uid)
1620 if (providerid == NULL || type == NULL || privilege_func == NULL) {
1621 LOGE("invalid parameter");
1622 return PMINFO_R_EINVAL;
1625 ret = _appinfo_get_datacontrol_privileges(providerid, type, uid, &list);
1626 if (ret == PMINFO_R_ERROR) {
1627 g_list_free_full(list, free);
1631 for (tmp = list; tmp != NULL; tmp = g_list_next(tmp)) {
1633 ret = privilege_func((char *)tmp->data, user_data);
1638 g_list_free_full(list, free);
1642 API int pkgmgrinfo_appinfo_foreach_datacontrol_privileges(
1643 const char *providerid, const char *type,
1644 pkgmgrinfo_pkg_privilege_list_cb privilege_func,
1647 return pkgmgrinfo_appinfo_usr_foreach_datacontrol_privileges(
1648 providerid, type, privilege_func, user_data, _getuid());
1651 API int pkgmgrinfo_appinfo_get_support_mode(
1652 pkgmgrinfo_appinfo_h handle, int *support_mode)
1654 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1655 retvm_if(support_mode == NULL, PMINFO_R_EINVAL,
1656 "Argument supplied to hold return value is NULL");
1658 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1660 if (info->app_info->support_mode)
1661 *support_mode = atoi(info->app_info->support_mode);
1668 API int pkgmgrinfo_appinfo_foreach_category(pkgmgrinfo_appinfo_h handle,
1669 pkgmgrinfo_app_category_list_cb category_func, void *user_data)
1671 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1672 retvm_if(category_func == NULL, PMINFO_R_EINVAL,
1673 "Callback function is NULL");
1675 const char *category;
1677 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1679 if (info->app_info == NULL)
1680 return PMINFO_R_ERROR;
1682 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
1683 category = (const char *)tmp->data;
1685 ret = category_func(category, user_data);
1693 API int pkgmgrinfo_appinfo_foreach_metadata(pkgmgrinfo_appinfo_h handle,
1694 pkgmgrinfo_app_metadata_list_cb metadata_func, void *user_data)
1696 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1697 retvm_if(metadata_func == NULL, PMINFO_R_EINVAL,
1698 "Callback function is NULL");
1702 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1704 if (info->app_info == NULL)
1705 return PMINFO_R_ERROR;
1707 for (tmp = info->app_info->metadata; tmp; tmp = tmp->next) {
1708 ptr = (metadata_x *)tmp->data;
1712 ret = metadata_func(ptr->key, ptr->value ?
1713 ptr->value : "", user_data);
1721 API int pkgmgrinfo_appinfo_usr_foreach_appcontrol_privileges(const char *appid,
1722 const char *operation,
1723 pkgmgrinfo_pkg_privilege_list_cb privilege_func,
1724 void *user_data, uid_t uid)
1727 GList *privilege_list = NULL;
1730 if (appid == NULL || operation == NULL || privilege_func == NULL) {
1731 LOGE("invalid parameter");
1732 return PMINFO_R_EINVAL;
1735 ret = _appinfo_get_appcontrol_privileges(appid, operation, uid,
1737 if (ret == PMINFO_R_ENOENT) {
1739 } else if (ret != PMINFO_R_OK) {
1740 g_list_free_full(privilege_list, free);
1744 for (tmp_list = privilege_list; tmp_list != NULL;
1745 tmp_list = g_list_next(tmp_list)) {
1746 ret = privilege_func((char *)tmp_list->data, user_data);
1751 g_list_free_full(privilege_list, free);
1755 API int pkgmgrinfo_appinfo_foreach_appcontrol_privileges(const char *appid,
1756 const char *operation,
1757 pkgmgrinfo_pkg_privilege_list_cb privilege_func,
1760 return pkgmgrinfo_appinfo_usr_foreach_appcontrol_privileges(appid,
1761 operation, privilege_func, user_data, _getuid());
1764 API int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
1765 pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
1767 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1768 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL,
1769 "Callback function is NULL");
1771 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1772 appcontrol_x *appcontrol;
1775 if (info->app_info == NULL)
1776 return PMINFO_R_ERROR;
1778 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
1779 appcontrol = (appcontrol_x *)tmp->data;
1780 if (appcontrol == NULL || !strcasecmp(
1781 appcontrol->visibility, "remote-only"))
1783 ret = appcontrol_func(appcontrol->operation,
1784 appcontrol->uri, appcontrol->mime, user_data);
1792 API int pkgmgrinfo_appinfo_foreach_remote_appcontrol(
1793 pkgmgrinfo_appinfo_h handle,
1794 pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
1796 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1797 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL,
1798 "Callback function is NULL");
1800 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1801 appcontrol_x *appcontrol;
1804 if (info->app_info == NULL)
1805 return PMINFO_R_ERROR;
1807 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
1808 appcontrol = (appcontrol_x *)tmp->data;
1809 if (appcontrol == NULL || !strcasecmp(
1810 appcontrol->visibility, "local-only"))
1812 ret = appcontrol_func(appcontrol->operation, appcontrol->uri,
1813 appcontrol->mime, user_data);
1821 API int pkgmgrinfo_appinfo_foreach_background_category(
1822 pkgmgrinfo_appinfo_h handle,
1823 pkgmgrinfo_app_background_category_list_cb category_func,
1826 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1830 if (handle == NULL || category_func == NULL || info->app_info == NULL) {
1831 LOGE("invalid parameter");
1832 return PMINFO_R_EINVAL;
1835 for (tmp = info->app_info->background_category; tmp; tmp = tmp->next) {
1836 category = (char *)tmp->data;
1837 if (category == NULL)
1840 if (category_func(category, user_data) < 0)
1847 API int pkgmgrinfo_appinfo_foreach_splash_screen(pkgmgrinfo_appinfo_h handle,
1848 pkgmgrinfo_app_splash_screen_list_cb splash_screen_func,
1851 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1852 splashscreen_x *splashscreen;
1856 if (info == NULL || info->app_info == NULL
1857 || splash_screen_func == NULL) {
1858 LOGE("invalid parameter");
1859 return PMINFO_R_EINVAL;
1862 for (tmp = info->app_info->splashscreens; tmp; tmp = tmp->next) {
1863 splashscreen = (splashscreen_x *)tmp->data;
1864 if (splashscreen == NULL)
1866 ret = splash_screen_func(splashscreen->src,
1868 splashscreen->orientation,
1869 splashscreen->indicatordisplay,
1870 splashscreen->operation,
1871 splashscreen->color_depth,
1880 API int pkgmgrinfo_appinfo_is_nodisplay(
1881 pkgmgrinfo_appinfo_h handle, bool *nodisplay)
1883 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1884 retvm_if(nodisplay == NULL, PMINFO_R_EINVAL,
1885 "Argument supplied to hold return value is NULL");
1886 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1888 if (info->app_info == NULL || info->app_info->nodisplay == NULL)
1889 return PMINFO_R_ERROR;
1891 *nodisplay = _get_bool_value(info->app_info->nodisplay);
1896 API int pkgmgrinfo_appinfo_is_multiple(
1897 pkgmgrinfo_appinfo_h handle, bool *multiple)
1899 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1900 retvm_if(multiple == NULL, PMINFO_R_EINVAL,
1901 "Argument supplied to hold return value is NULL");
1902 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1904 if (info->app_info == NULL || info->app_info->multiple == NULL)
1905 return PMINFO_R_ERROR;
1907 *multiple = _get_bool_value(info->app_info->multiple);
1912 API int pkgmgrinfo_appinfo_is_indicator_display_allowed(
1913 pkgmgrinfo_appinfo_h handle, bool *indicator_disp)
1915 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1916 retvm_if(indicator_disp == NULL, PMINFO_R_EINVAL,
1917 "Argument supplied to hold return value is NULL");
1918 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1920 if (info->app_info == NULL || info->app_info->indicatordisplay == NULL)
1921 return PMINFO_R_ERROR;
1923 *indicator_disp = _get_bool_value(info->app_info->indicatordisplay);
1928 API int pkgmgrinfo_appinfo_is_taskmanage(
1929 pkgmgrinfo_appinfo_h handle, bool *taskmanage)
1931 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1932 retvm_if(taskmanage == NULL, PMINFO_R_EINVAL,
1933 "Argument supplied to hold return value is NULL");
1934 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1936 if (info->app_info == NULL || info->app_info->taskmanage == NULL)
1937 return PMINFO_R_ERROR;
1939 *taskmanage = _get_bool_value(info->app_info->taskmanage);
1944 API int pkgmgrinfo_appinfo_is_enabled(
1945 pkgmgrinfo_appinfo_h handle, bool *enabled)
1947 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1948 retvm_if(enabled == NULL, PMINFO_R_EINVAL,
1949 "Argument supplied to hold return value is NULL");
1950 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1952 if (info->app_info == NULL || info->app_info->is_disabled == NULL)
1953 return PMINFO_R_ERROR;
1955 *enabled = !_get_bool_value(info->app_info->is_disabled);
1960 API int pkgmgrinfo_appinfo_is_onboot(
1961 pkgmgrinfo_appinfo_h handle, bool *onboot)
1963 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1964 retvm_if(onboot == NULL, PMINFO_R_EINVAL,
1965 "Argument supplied to hold return value is NULL");
1966 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1968 if (info->app_info == NULL || info->app_info->onboot == NULL)
1969 return PMINFO_R_ERROR;
1971 *onboot = _get_bool_value(info->app_info->onboot);
1976 API int pkgmgrinfo_appinfo_is_autorestart(
1977 pkgmgrinfo_appinfo_h handle, bool *autorestart)
1979 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1980 retvm_if(autorestart == NULL, PMINFO_R_EINVAL,
1981 "Argument supplied to hold return value is NULL");
1982 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1984 if (info->app_info == NULL || info->app_info->autorestart == NULL)
1985 return PMINFO_R_ERROR;
1987 *autorestart = _get_bool_value(info->app_info->autorestart);
1992 API int pkgmgrinfo_appinfo_is_mainapp(
1993 pkgmgrinfo_appinfo_h handle, bool *mainapp)
1995 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1996 retvm_if(mainapp == NULL, PMINFO_R_EINVAL,
1997 "Argument supplied to hold return value is NULL");
1998 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2000 if (info->app_info == NULL || info->app_info->mainapp == NULL)
2001 return PMINFO_R_ERROR;
2003 *mainapp = _get_bool_value(info->app_info->mainapp);
2008 API int pkgmgrinfo_appinfo_is_preload(
2009 pkgmgrinfo_appinfo_h handle, bool *preload)
2011 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2012 retvm_if(preload == NULL, PMINFO_R_EINVAL,
2013 "Argument supplied to hold return value is NULL\n");
2014 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2016 if (info->app_info == NULL || info->app_info->preload == NULL)
2017 return PMINFO_R_ERROR;
2019 *preload = _get_bool_value(info->app_info->preload);
2024 API int pkgmgrinfo_appinfo_is_submode(
2025 pkgmgrinfo_appinfo_h handle, bool *submode)
2027 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2028 retvm_if(submode == NULL, PMINFO_R_EINVAL,
2029 "Argument supplied to hold return value is NULL\n");
2030 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2032 if (info->app_info == NULL || info->app_info->submode == NULL)
2033 return PMINFO_R_ERROR;
2035 *submode = _get_bool_value(info->app_info->submode);
2040 API int pkgmgrinfo_appinfo_is_process_pool(
2041 pkgmgrinfo_appinfo_h handle, bool *process_pool)
2043 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2045 if (handle == NULL || process_pool == NULL) {
2046 LOGE("invalid parameter");
2047 return PMINFO_R_EINVAL;
2050 if (info->app_info == NULL)
2051 return PMINFO_R_ERROR;
2053 *process_pool = _get_bool_value(info->app_info->process_pool);
2058 API int pkgmgrinfo_appinfo_is_category_exist(
2059 pkgmgrinfo_appinfo_h handle, const char *category, bool *exist)
2061 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2062 retvm_if(category == NULL, PMINFO_R_EINVAL, "category is NULL");
2063 retvm_if(exist == NULL, PMINFO_R_EINVAL, "exist is NULL");
2067 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2069 if (info->app_info == NULL)
2070 return PMINFO_R_ERROR;
2073 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
2074 val = (const char *)tmp->data;
2077 if (strcasecmp(val, category) == 0) {
2086 API int pkgmgrinfo_appinfo_is_ui_gadget(pkgmgrinfo_appinfo_h handle,
2089 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2091 if (info == NULL || info->app_info == NULL || ui_gadget == NULL) {
2092 _LOGE("invalid parameter");
2093 return PMINFO_R_EINVAL;
2095 if (info->app_info->ui_gadget == NULL)
2096 info->app_info->ui_gadget = strdup("false");
2098 *ui_gadget = _get_bool_value(info->app_info->ui_gadget);
2103 API int pkgmgrinfo_appinfo_is_support_disable(pkgmgrinfo_appinfo_h handle,
2104 bool *support_disable)
2106 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2108 if (info == NULL || info->app_info == NULL || support_disable == NULL) {
2109 _LOGE("invalid parameter");
2110 return PMINFO_R_EINVAL;
2113 *support_disable = _get_bool_value(info->app_info->support_disable);
2118 API int pkgmgrinfo_appinfo_is_removable(pkgmgrinfo_appinfo_h handle,
2121 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2123 if (info == NULL || info->app_info == NULL || removable == NULL) {
2124 _LOGE("invalid parameter");
2125 return PMINFO_R_EINVAL;
2128 *removable = _get_bool_value(info->app_info->removable);
2133 API int pkgmgrinfo_appinfo_is_system(pkgmgrinfo_appinfo_h handle, bool *system)
2135 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2137 if (info == NULL || info->app_info == NULL || system == NULL) {
2138 _LOGE("invalid parameter");
2139 return PMINFO_R_EINVAL;
2142 *system = _get_bool_value(info->app_info->package_system);
2147 API int pkgmgrinfo_appinfo_is_disabled(
2148 pkgmgrinfo_appinfo_h handle, bool *disabled)
2150 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2151 retvm_if(disabled == NULL, PMINFO_R_EINVAL,
2152 "Argument supplied to hold return value is NULL");
2153 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2155 if (info->app_info == NULL || info->app_info->is_disabled == NULL)
2156 return PMINFO_R_ERROR;
2158 *disabled = _get_bool_value(info->app_info->is_disabled);
2163 API int pkgmgrinfo_appinfo_is_global(pkgmgrinfo_appinfo_h handle, bool *global)
2165 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2167 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2168 retvm_if(global == NULL, PMINFO_R_EINVAL,
2169 "Argument supplied to hold return value is NULL\n");
2171 if (info->app_info == NULL || info->app_info->for_all_users == NULL)
2172 return PMINFO_R_ERROR;
2174 *global = _get_bool_value(info->app_info->for_all_users);
2179 API int pkgmgrinfo_appinfo_get_splash_screen_display(
2180 pkgmgrinfo_appinfo_h handle, bool *splash_screen_display)
2182 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2184 if (info == NULL || splash_screen_display == NULL) {
2185 _LOGE("Invalid parameter");
2186 return PMINFO_R_EINVAL;
2189 if (info->app_info == NULL ||
2190 info->app_info->splash_screen_display == NULL)
2191 return PMINFO_R_ERROR;
2193 *splash_screen_display =
2194 _get_bool_value(info->app_info->splash_screen_display);
2199 API int pkgmgrinfo_appinfo_get_setup_appid(
2200 pkgmgrinfo_appinfo_h handle, char **setup_appid)
2202 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2204 if (info == NULL || setup_appid == NULL) {
2205 _LOGE("Invalid parameter");
2206 return PMINFO_R_EINVAL;
2209 if (info->app_info == NULL || info->app_info->setup_appid == NULL)
2210 return PMINFO_R_ERROR;
2212 *setup_appid = info->app_info->setup_appid;
2216 API int pkgmgrinfo_appinfo_is_support_ambient(pkgmgrinfo_appinfo_h handle,
2217 bool *support_ambient)
2219 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2221 if (info == NULL || support_ambient == NULL) {
2222 _LOGE("Invalid parameter");
2223 return PMINFO_R_EINVAL;
2226 if (info->app_info == NULL || info->app_info->support_ambient == NULL)
2227 return PMINFO_R_ERROR;
2229 *support_ambient = _get_bool_value(info->app_info->support_ambient);
2234 API int pkgmgrinfo_appinfo_destroy_appinfo(pkgmgrinfo_appinfo_h handle)
2236 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2237 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2239 __cleanup_appinfo(info);
2243 API int pkgmgrinfo_appinfo_filter_create(pkgmgrinfo_appinfo_filter_h *handle)
2245 return pkgmgrinfo_pkginfo_filter_create(handle);
2248 API int pkgmgrinfo_appinfo_filter_destroy(pkgmgrinfo_appinfo_filter_h handle)
2250 return pkgmgrinfo_pkginfo_filter_destroy(handle);
2253 static gint __compare_func(gconstpointer data1, gconstpointer data2)
2255 pkgmgrinfo_node_x *node1 = (pkgmgrinfo_node_x *)data1;
2256 pkgmgrinfo_node_x *node2 = (pkgmgrinfo_node_x *)data2;
2258 if (node1->prop == node2->prop)
2260 else if (node1->prop > node2->prop)
2266 API int pkgmgrinfo_appinfo_filter_add_int(pkgmgrinfo_appinfo_filter_h handle,
2267 const char *property, const int value)
2269 retvm_if(handle == NULL, PMINFO_R_EINVAL,
2270 "Filter handle input parameter is NULL\n");
2271 retvm_if(property == NULL, PMINFO_R_EINVAL,
2272 "Filter handle input parameter is NULL\n");
2273 char buf[PKG_VALUE_STRING_LEN_MAX] = {'\0'};
2275 GSList *link = NULL;
2278 prop = _pminfo_appinfo_convert_to_prop_int(property);
2279 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_INT ||
2280 prop > E_PMINFO_APPINFO_PROP_APP_MAX_INT) {
2281 _LOGE("Invalid Integer Property\n");
2282 return PMINFO_R_EINVAL;
2284 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2285 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1,
2286 sizeof(pkgmgrinfo_node_x));
2288 _LOGE("Out of Memory!!!\n");
2289 return PMINFO_R_ERROR;
2291 snprintf(buf, PKG_VALUE_STRING_LEN_MAX - 1, "%d", value);
2292 val = strndup(buf, PKG_VALUE_STRING_LEN_MAX - 1);
2294 _LOGE("Out of Memory\n");
2297 return PMINFO_R_ERROR;
2303 * If API is called multiple times for same property,
2304 * we should override the previous values.
2305 * Last value set will be used for filtering.
2307 link = g_slist_find_custom(filter->list,
2308 (gconstpointer)node, __compare_func);
2310 filter->list = g_slist_delete_link(filter->list, link);
2311 filter->list = g_slist_append(filter->list, (gpointer)node);
2316 API int pkgmgrinfo_appinfo_filter_add_bool(pkgmgrinfo_appinfo_filter_h handle,
2317 const char *property, const bool value)
2319 retvm_if(handle == NULL, PMINFO_R_EINVAL,
2320 "Filter handle input parameter is NULL\n");
2321 retvm_if(property == NULL, PMINFO_R_EINVAL,
2322 "Filter handle input parameter is NULL\n");
2324 GSList *link = NULL;
2327 prop = _pminfo_appinfo_convert_to_prop_bool(property);
2328 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_BOOL ||
2329 prop > E_PMINFO_APPINFO_PROP_APP_MAX_BOOL) {
2330 _LOGE("Invalid Boolean Property\n");
2331 return PMINFO_R_EINVAL;
2333 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2334 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1,
2335 sizeof(pkgmgrinfo_node_x));
2337 _LOGE("Out of Memory!!!\n");
2338 return PMINFO_R_ERROR;
2341 val = strndup("true", 4);
2343 val = strndup("false", 5);
2345 _LOGE("Out of Memory\n");
2348 return PMINFO_R_ERROR;
2353 * If API is called multiple times for same property,
2354 * we should override the previous values.
2355 * Last value set will be used for filtering.
2357 link = g_slist_find_custom(filter->list,
2358 (gconstpointer)node, __compare_func);
2360 filter->list = g_slist_delete_link(filter->list, link);
2361 filter->list = g_slist_append(filter->list, (gpointer)node);
2366 API int pkgmgrinfo_appinfo_filter_add_string(pkgmgrinfo_appinfo_filter_h handle,
2367 const char *property, const char *value)
2369 retvm_if(handle == NULL, PMINFO_R_EINVAL,
2370 "Filter handle input parameter is NULL\n");
2371 retvm_if(property == NULL, PMINFO_R_EINVAL,
2372 "Filter handle input parameter is NULL\n");
2373 retvm_if(value == NULL, PMINFO_R_EINVAL,
2374 "Filter handle input parameter is NULL\n");
2376 pkgmgrinfo_node_x *ptr = NULL;
2377 char prev[PKG_STRING_LEN_MAX] = {'\0'};
2378 char temp[PKG_STRING_LEN_MAX] = {'\0'};
2379 GSList *link = NULL;
2383 prop = _pminfo_appinfo_convert_to_prop_str(property);
2384 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_STR ||
2385 prop > E_PMINFO_APPINFO_PROP_APP_MAX_STR) {
2386 _LOGE("Invalid String Property\n");
2387 return PMINFO_R_EINVAL;
2389 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2390 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1,
2391 sizeof(pkgmgrinfo_node_x));
2393 _LOGE("Out of Memory!!!\n");
2394 return PMINFO_R_ERROR;
2398 case E_PMINFO_APPINFO_PROP_APP_COMPONENT:
2399 node->value = strdup(value);
2400 link = g_slist_find_custom(filter->list,
2401 (gconstpointer)node, __compare_func);
2403 filter->list = g_slist_delete_link(filter->list, link);
2404 filter->list = g_slist_append(filter->list, (gpointer)node);
2406 case E_PMINFO_APPINFO_PROP_APP_CATEGORY:
2407 val = (char *)calloc(1, PKG_STRING_LEN_MAX);
2409 _LOGE("Out of Memory\n");
2412 return PMINFO_R_ERROR;
2414 link = g_slist_find_custom(filter->list,
2415 (gconstpointer)node, __compare_func);
2417 ptr = (pkgmgrinfo_node_x *)link->data;
2418 strncpy(prev, ptr->value, PKG_STRING_LEN_MAX - 1);
2419 _LOGI("Previous value is %s\n", prev);
2420 filter->list = g_slist_delete_link(filter->list, link);
2421 ret = snprintf(temp, PKG_STRING_LEN_MAX - 1,
2422 "%s,%s", prev, value);
2423 if (ret < 0 || ret > PKG_STRING_LEN_MAX - 1) {
2424 _LOGE("snprintf fail\n");
2427 return PMINFO_R_ERROR;
2429 strncpy(val, temp, PKG_STRING_LEN_MAX);
2430 _LOGI("New value is %s\n", val);
2432 filter->list = g_slist_append(
2433 filter->list, (gpointer)node);
2434 memset(temp, '\0', PKG_STRING_LEN_MAX);
2436 snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s", value);
2437 strncpy(val, temp, PKG_STRING_LEN_MAX);
2438 _LOGI("First value is %s\n", val);
2440 filter->list = g_slist_append(
2441 filter->list, (gpointer)node);
2442 memset(temp, '\0', PKG_STRING_LEN_MAX);
2446 node->value = strndup(value, PKG_STRING_LEN_MAX - 1);
2447 link = g_slist_find_custom(filter->list,
2448 (gconstpointer)node, __compare_func);
2450 filter->list = g_slist_delete_link(filter->list, link);
2451 filter->list = g_slist_append(filter->list, (gpointer)node);
2457 API int pkgmgrinfo_appinfo_usr_filter_count(
2458 pkgmgrinfo_appinfo_filter_h handle, int *count, uid_t uid)
2463 pkgmgrinfo_filter_x *filter;
2465 if (handle == NULL || count == NULL) {
2466 _LOGE("invalid parameter");
2467 return PMINFO_R_EINVAL;
2470 filter = (pkgmgrinfo_filter_x *)handle;
2471 list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
2472 __free_applications);
2474 return PMINFO_R_ERROR;
2476 if (__check_disable_filter_exist(
2477 handle, E_APPINFO_DISABLE_TYPE_APP) == false) {
2478 if (pkgmgrinfo_appinfo_filter_add_bool(handle,
2479 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
2480 g_hash_table_destroy(list);
2481 return PMINFO_R_ERROR;
2485 if (__check_disable_filter_exist(
2486 handle, E_APPINFO_DISABLE_TYPE_PKG) == false) {
2487 if (pkgmgrinfo_appinfo_filter_add_bool(handle,
2488 PMINFO_APPINFO_PROP_PKG_DISABLE, false)) {
2489 g_hash_table_destroy(list);
2490 return PMINFO_R_ERROR;
2494 ret = _appinfo_get_applications(uid, filter, 0, list);
2495 query_count = g_hash_table_size(list);
2496 g_hash_table_destroy(list);
2497 if (ret == PMINFO_R_ERROR)
2500 *count = query_count;
2504 API int pkgmgrinfo_appinfo_filter_count(
2505 pkgmgrinfo_appinfo_filter_h handle, int *count)
2507 return pkgmgrinfo_appinfo_usr_filter_count(handle, count, _getuid());
2510 API int pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(
2511 pkgmgrinfo_appinfo_filter_h handle,
2512 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
2514 if (handle == NULL || app_cb == NULL) {
2515 LOGE("invalid parameter");
2516 return PMINFO_R_EINVAL;
2519 if (__check_disable_filter_exist(
2520 handle, E_APPINFO_DISABLE_TYPE_APP) == false) {
2521 if (pkgmgrinfo_appinfo_filter_add_bool(handle,
2522 PMINFO_APPINFO_PROP_APP_DISABLE, false))
2523 return PMINFO_R_ERROR;
2526 if (__check_disable_filter_exist(
2527 handle, E_APPINFO_DISABLE_TYPE_PKG) == false) {
2528 if (pkgmgrinfo_appinfo_filter_add_bool(handle,
2529 PMINFO_APPINFO_PROP_PKG_DISABLE, false))
2530 return PMINFO_R_ERROR;
2533 return _appinfo_get_filtered_foreach_appinfo(uid,
2534 handle, PMINFO_APPINFO_GET_ALL, app_cb, user_data);
2537 API int pkgmgrinfo_appinfo_filter_foreach_appinfo(
2538 pkgmgrinfo_appinfo_filter_h handle,
2539 pkgmgrinfo_app_list_cb app_cb, void *user_data)
2541 return pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(
2542 handle, app_cb, user_data, _getuid());
2545 API int pkgmgrinfo_appinfo_metadata_filter_create(
2546 pkgmgrinfo_appinfo_metadata_filter_h *handle)
2548 return pkgmgrinfo_pkginfo_filter_create(handle);
2551 API int pkgmgrinfo_appinfo_metadata_filter_destroy(
2552 pkgmgrinfo_appinfo_metadata_filter_h handle)
2554 return pkgmgrinfo_pkginfo_filter_destroy(handle);
2557 API int pkgmgrinfo_appinfo_metadata_filter_add(
2558 pkgmgrinfo_appinfo_metadata_filter_h handle,
2559 const char *key, const char *value)
2561 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2562 pkgmgrinfo_metadata_node_x *node;
2564 /* value can be NULL.
2565 * In that case all apps with specified key should be displayed
2568 LOGE("invalid parameter");
2569 return PMINFO_R_EINVAL;
2572 node = calloc(1, sizeof(pkgmgrinfo_metadata_node_x));
2574 LOGE("out of memory");
2575 return PMINFO_R_ERROR;
2578 node->key = strdup(key);
2579 if (value && strlen(value))
2580 node->value = strdup(value);
2582 filter->list_metadata = g_slist_append(filter->list_metadata,
2588 API int pkgmgrinfo_appinfo_usr_metadata_filter_foreach(
2589 pkgmgrinfo_appinfo_metadata_filter_h handle,
2590 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
2592 if (handle == NULL || app_cb == NULL) {
2593 LOGE("invalid parameter");
2594 return PMINFO_R_EINVAL;
2597 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2599 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
2600 PMINFO_APPINFO_PROP_APP_DISABLE, false))
2601 return PMINFO_R_ERROR;
2603 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
2604 PMINFO_APPINFO_PROP_PKG_DISABLE, false))
2605 return PMINFO_R_ERROR;
2607 return _appinfo_get_filtered_foreach_appinfo(uid, handle,
2608 PMINFO_APPINFO_GET_ALL, app_cb,
2612 API int pkgmgrinfo_appinfo_metadata_filter_foreach(
2613 pkgmgrinfo_appinfo_metadata_filter_h handle,
2614 pkgmgrinfo_app_list_cb app_cb, void *user_data)
2616 return pkgmgrinfo_appinfo_usr_metadata_filter_foreach(handle, app_cb,
2617 user_data, _getuid());
2620 API int pkgmgrinfo_appinfo_is_guestmode_visibility(
2621 pkgmgrinfo_appinfo_h handle, bool *status)
2624 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2626 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2627 retvm_if(status == NULL, PMINFO_R_EINVAL,
2628 "Argument supplied to hold return value is NULL\n");
2630 val = info->app_info->guestmode_visibility;
2631 *status = _get_bool_value(val);
2635 API int pkgmgrinfo_appinfo_foreach_appcontrol_v2(pkgmgrinfo_appinfo_h handle,
2636 pkgmgrinfo_app_control_list_cb_v2 appcontrol_func,
2639 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2640 retvm_if(appcontrol_func == NULL,
2641 PMINFO_R_EINVAL, "Callback function is NULL");
2643 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2644 appcontrol_x *appcontrol;
2647 if (info->app_info == NULL)
2648 return PMINFO_R_ERROR;
2650 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
2651 appcontrol = (appcontrol_x *)tmp->data;
2652 if (appcontrol == NULL ||
2653 !strcasecmp(appcontrol->visibility,
2656 ret = appcontrol_func(appcontrol->operation, appcontrol->uri,
2657 appcontrol->mime, appcontrol->id, user_data);
2665 API int pkgmgrinfo_appinfo_foreach_remote_appcontrol_v2(
2666 pkgmgrinfo_appinfo_h handle,
2667 pkgmgrinfo_app_control_list_cb_v2 appcontrol_func,
2670 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2671 retvm_if(appcontrol_func == NULL,
2672 PMINFO_R_EINVAL, "Callback function is NULL");
2674 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2675 appcontrol_x *appcontrol;
2678 if (info->app_info == NULL)
2679 return PMINFO_R_ERROR;
2681 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
2682 appcontrol = (appcontrol_x *)tmp->data;
2683 if (appcontrol == NULL ||
2684 !strcasecmp(appcontrol->visibility,
2687 ret = appcontrol_func(appcontrol->operation, appcontrol->uri,
2688 appcontrol->mime, appcontrol->id, user_data);