12 #include "pkgmgr-info.h"
13 #include "pkgmgrinfo_debug.h"
14 #include "pkgmgrinfo_private.h"
15 #include "pkgmgr_parser.h"
16 #include "manager/pkginfo_manager.h"
18 static bool _get_bool_value(const char *str)
20 if (str && !strcmp(str, "true"))
26 static void __cleanup_appinfo(pkgmgr_appinfo_x *data)
28 pkgmgr_appinfo_x *info = data;
32 free((void *)info->package);
34 free((void *)info->locale);
36 pkgmgrinfo_basic_free_application(info->app_info);
41 static void __free_applications(gpointer data)
43 pkgmgrinfo_basic_free_application((application_x *)data);
46 static gint __disable_chk_func(gconstpointer data1, gconstpointer data2)
48 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)data1;
49 pkgmgrinfo_appinfo_disable_type value = GPOINTER_TO_INT(data2);
51 if (value == E_APPINFO_DISABLE_TYPE_PKG)
52 return (node->prop == E_PMINFO_APPINFO_PROP_PKG_DISABLE)
55 return (node->prop == E_PMINFO_APPINFO_PROP_APP_DISABLE)
59 static bool __check_disable_filter_exist(pkgmgrinfo_filter_x *filter,
60 pkgmgrinfo_appinfo_disable_type type)
67 link = g_slist_find_custom(filter->list,
68 GINT_TO_POINTER(type), __disable_chk_func);
75 static int _pkgmgrinfo_get_appinfo(const char *appid, uid_t uid,
76 pkgmgrinfo_appinfo_filter_h filter, pkgmgrinfo_appinfo_h *handle)
78 int ret = PMINFO_R_OK;
80 pkgmgr_appinfo_x *info;
82 if (appid == NULL || filter == NULL || handle == NULL) {
83 LOGE("invalid parameter");
84 return PMINFO_R_EINVAL;
87 list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
90 return PMINFO_R_ERROR;
92 ret = _appinfo_get_applications(uid, filter,
93 PMINFO_APPINFO_GET_ALL, list);
94 if (ret != PMINFO_R_OK) {
95 g_hash_table_destroy(list);
99 if (!g_hash_table_size(list) || !g_hash_table_lookup(list, appid) ||
100 ((application_x *)g_hash_table_lookup(list, appid))->package == NULL) {
101 _LOGD("appinfo for [%s] is not existed for user [%d]",
103 g_hash_table_destroy(list);
104 return PMINFO_R_ENOENT;
107 info = calloc(1, sizeof(pkgmgr_appinfo_x));
109 _LOGE("out of memory");
110 g_hash_table_destroy(list);
111 return PMINFO_R_ERROR;
114 info->app_info = (application_x *)g_hash_table_lookup(list, appid);
115 info->locale = strdup(info->app_info->locale);
117 _LOGE("out of memory");
118 g_hash_table_destroy(list);
120 return PMINFO_R_ERROR;
122 info->package = strdup(info->app_info->package);
123 if (!info->package) {
124 _LOGE("out of memory");
126 g_hash_table_destroy(list);
128 return PMINFO_R_ERROR;
131 /* just free list only */
132 g_hash_table_steal(list, (gconstpointer)appid);
133 g_hash_table_destroy(list);
140 API int pkgmgrinfo_appinfo_get_usr_disabled_appinfo(
141 const char *appid, uid_t uid, pkgmgrinfo_appinfo_h *handle)
144 pkgmgrinfo_appinfo_filter_h filter;
146 if (appid == NULL || handle == NULL) {
147 LOGE("invalid parameter");
148 return PMINFO_R_EINVAL;
151 ret = pkgmgrinfo_appinfo_filter_create(&filter);
152 if (ret != PMINFO_R_OK)
155 ret = pkgmgrinfo_appinfo_filter_add_string(filter,
156 PMINFO_APPINFO_PROP_APP_ID, appid);
157 if (ret != PMINFO_R_OK) {
158 pkgmgrinfo_appinfo_filter_destroy(filter);
159 return PMINFO_R_ERROR;
162 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
163 PMINFO_APPINFO_PROP_APP_DISABLE, true);
164 if (ret != PMINFO_R_OK) {
165 pkgmgrinfo_appinfo_filter_destroy(filter);
166 return PMINFO_R_ERROR;
169 ret = _pkgmgrinfo_get_appinfo(appid, uid, filter, handle);
170 pkgmgrinfo_appinfo_filter_destroy(filter);
175 API int pkgmgrinfo_appinfo_get_disabled_appinfo(
176 const char *appid, pkgmgrinfo_appinfo_h *handle)
178 return pkgmgrinfo_appinfo_get_usr_disabled_appinfo(
179 appid, _getuid(), handle);
182 static char *__get_real_appid(const char *appid)
192 token = strtok_r(str, "::", &saveptr);
196 LOGD("Real appid = %s", token);
197 token = strdup(token);
202 API int pkgmgrinfo_appinfo_get_usr_appinfo(const char *appid, uid_t uid,
203 pkgmgrinfo_appinfo_h *handle)
206 pkgmgrinfo_appinfo_filter_h filter;
209 if (appid == NULL || handle == NULL) {
210 LOGE("invalid parameter");
211 return PMINFO_R_EINVAL;
214 ret = pkgmgrinfo_appinfo_filter_create(&filter);
215 if (ret != PMINFO_R_OK)
218 real_appid = __get_real_appid(appid);
219 if (real_appid == NULL) {
220 LOGE("Out of memory");
221 pkgmgrinfo_appinfo_filter_destroy(filter);
222 return PMINFO_R_ERROR;
225 ret = pkgmgrinfo_appinfo_filter_add_string(filter,
226 PMINFO_APPINFO_PROP_APP_ID, real_appid);
227 if (ret != PMINFO_R_OK) {
228 pkgmgrinfo_appinfo_filter_destroy(filter);
230 return PMINFO_R_ERROR;
233 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
234 PMINFO_APPINFO_PROP_APP_DISABLE, false);
235 if (ret != PMINFO_R_OK) {
236 pkgmgrinfo_appinfo_filter_destroy(filter);
238 return PMINFO_R_ERROR;
241 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
242 PMINFO_APPINFO_PROP_PKG_DISABLE, false);
243 if (ret != PMINFO_R_OK) {
244 pkgmgrinfo_appinfo_filter_destroy(filter);
246 return PMINFO_R_ERROR;
249 ret = _pkgmgrinfo_get_appinfo(real_appid, uid, filter, handle);
251 pkgmgrinfo_appinfo_filter_destroy(filter);
255 API int pkgmgrinfo_appinfo_get_appinfo(
256 const char *appid, pkgmgrinfo_appinfo_h *handle)
258 return pkgmgrinfo_appinfo_get_usr_appinfo(appid, _getuid(), handle);
261 API int pkgmgrinfo_appinfo_get_usr_all_appinfo(const char *appid, uid_t uid,
262 pkgmgrinfo_appinfo_h *handle)
265 pkgmgrinfo_appinfo_filter_h filter;
267 if (appid == NULL || handle == NULL) {
268 LOGE("invalid parameter");
269 return PMINFO_R_EINVAL;
272 ret = pkgmgrinfo_appinfo_filter_create(&filter);
273 if (ret != PMINFO_R_OK)
276 ret = pkgmgrinfo_appinfo_filter_add_string(filter,
277 PMINFO_APPINFO_PROP_APP_ID, appid);
278 if (ret != PMINFO_R_OK) {
279 pkgmgrinfo_appinfo_filter_destroy(filter);
280 return PMINFO_R_ERROR;
283 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
284 PMINFO_APPINFO_PROP_APP_CHECK_STORAGE, false);
285 if (ret != PMINFO_R_OK) {
286 pkgmgrinfo_appinfo_filter_destroy(filter);
287 return PMINFO_R_ERROR;
290 ret = _pkgmgrinfo_get_appinfo(appid, uid, filter, handle);
291 pkgmgrinfo_appinfo_filter_destroy(filter);
296 API int pkgmgrinfo_appinfo_get_all_appinfo(
297 const char *appid, pkgmgrinfo_appinfo_h *handle)
299 return pkgmgrinfo_appinfo_get_usr_all_appinfo(appid, _getuid(), handle);
302 static gpointer __copy_str(gconstpointer src, gpointer data)
304 const char *tmp = (const char *)src;
307 buffer = strdup(tmp);
308 if (buffer == NULL) {
309 LOGE("memory alloc failed");
317 static gpointer __copy_label(gconstpointer src, gpointer data)
319 label_x *tmp = (label_x *)src;
322 label = calloc(1, sizeof(label_x));
324 LOGE("memory alloc failed");
330 label->name = strdup(tmp->name);
332 label->text = strdup(tmp->text);
334 label->lang = strdup(tmp->lang);
339 static gpointer __copy_icon(gconstpointer src, gpointer data)
341 icon_x *tmp = (icon_x *)src;
344 icon = calloc(1, sizeof(icon_x));
346 LOGE("memory alloc failed");
352 icon->text = strdup(tmp->text);
354 icon->lang = strdup(tmp->lang);
356 icon->section = strdup(tmp->section);
358 icon->size = strdup(tmp->size);
360 icon->resolution = strdup(tmp->resolution);
365 static gpointer __copy_metadata(gconstpointer src, gpointer data)
367 metadata_x *tmp = (metadata_x *)src;
368 metadata_x *metadata;
370 metadata = calloc(1, sizeof(metadata_x));
371 if (metadata == NULL) {
372 LOGE("memory alloc failed");
378 metadata->key = strdup(tmp->key);
380 metadata->value = strdup(tmp->value);
385 static gpointer __copy_datacontrol(gconstpointer src, gpointer data)
387 datacontrol_x *tmp = (datacontrol_x *)src;
388 datacontrol_x *datacontrol;
390 datacontrol = calloc(1, sizeof(datacontrol_x));
391 if (datacontrol == NULL) {
392 LOGE("memory alloc failed");
398 datacontrol->providerid = strdup(tmp->providerid);
400 datacontrol->access = strdup(tmp->access);
402 datacontrol->type = strdup(tmp->type);
404 datacontrol->trusted = strdup(tmp->trusted);
409 static gpointer __copy_appcontrol(gconstpointer src, gpointer data)
411 appcontrol_x *tmp = (appcontrol_x *)src;
412 appcontrol_x *appcontrol;
414 appcontrol = calloc(1, sizeof(appcontrol_x));
415 if (appcontrol == NULL) {
416 LOGE("memory alloc failed");
422 appcontrol->operation = strdup(tmp->operation);
424 appcontrol->uri = strdup(tmp->uri);
426 appcontrol->mime = strdup(tmp->mime);
431 static gpointer __copy_splashscreens(gconstpointer src, gpointer data)
433 splashscreen_x *tmp = (splashscreen_x *)src;
434 splashscreen_x *splashscreen;
436 splashscreen = (splashscreen_x *)calloc(1, sizeof(splashscreen_x));
437 if (splashscreen == NULL) {
438 LOGE("memory alloc failed");
444 splashscreen->src = strdup(tmp->src);
446 splashscreen->type = strdup(tmp->type);
447 if (tmp->orientation)
448 splashscreen->orientation = strdup(tmp->orientation);
449 if (tmp->indicatordisplay)
450 splashscreen->indicatordisplay = strdup(tmp->indicatordisplay);
452 splashscreen->operation = strdup(tmp->operation);
453 if (tmp->color_depth)
454 splashscreen->color_depth = strdup(tmp->color_depth);
459 static gpointer __copy_res_control(gconstpointer src, gpointer data)
461 res_control_x *tmp = (res_control_x *)src;
462 res_control_x *res_control;
464 res_control = (res_control_x *)calloc(1, sizeof(res_control_x));
465 if (res_control == NULL) {
466 LOGE("memory alloc failed");
472 res_control->res_type = strdup(tmp->res_type);
473 if (tmp->min_res_version)
474 res_control->min_res_version = strdup(tmp->min_res_version);
475 if (tmp->max_res_version)
476 res_control->max_res_version = strdup(tmp->max_res_version);
478 res_control->auto_close = strdup(tmp->auto_close);
483 static int _appinfo_copy_appinfo(
484 application_x **application, application_x *data)
486 application_x *app_info;
489 app_info = calloc(1, sizeof(application_x));
490 if (app_info == NULL) {
491 LOGE("memory alloc failed");
492 return PMINFO_R_ERROR;
495 if (data->appid != NULL)
496 app_info->appid = strdup(data->appid);
497 if (data->exec != NULL)
498 app_info->exec = strdup(data->exec);
499 if (data->nodisplay != NULL)
500 app_info->nodisplay = strdup(data->nodisplay);
501 if (data->multiple != NULL)
502 app_info->multiple = strdup(data->multiple);
503 if (data->taskmanage != NULL)
504 app_info->taskmanage = strdup(data->taskmanage);
505 if (data->type != NULL)
506 app_info->type = strdup(data->type);
507 if (data->categories != NULL)
508 app_info->categories = strdup(data->categories);
509 if (data->hwacceleration != NULL)
510 app_info->hwacceleration = strdup(data->hwacceleration);
511 if (data->screenreader != NULL)
512 app_info->screenreader = strdup(data->screenreader);
513 if (data->mainapp != NULL)
514 app_info->mainapp = strdup(data->mainapp);
515 if (data->package != NULL)
516 app_info->package = strdup(data->package);
517 if (data->recentimage != NULL)
518 app_info->recentimage = strdup(data->recentimage);
519 if (data->launchcondition != NULL)
520 app_info->launchcondition = strdup(data->launchcondition);
521 if (data->indicatordisplay != NULL)
522 app_info->indicatordisplay = strdup(data->indicatordisplay);
523 if (data->portraitimg != NULL)
524 app_info->portraitimg = strdup(data->portraitimg);
525 if (data->landscapeimg != NULL)
526 app_info->landscapeimg = strdup(data->landscapeimg);
527 if (data->guestmode_visibility != NULL)
528 app_info->guestmode_visibility =
529 strdup(data->guestmode_visibility);
530 if (data->component != NULL)
531 app_info->component = strdup(data->component);
532 if (data->permission_type != NULL)
533 app_info->permission_type = strdup(data->permission_type);
534 if (data->component_type != NULL)
535 app_info->component_type = strdup(data->component_type);
536 if (data->preload != NULL)
537 app_info->preload = strdup(data->preload);
538 if (data->submode != NULL)
539 app_info->submode = strdup(data->submode);
540 if (data->submode_mainid != NULL)
541 app_info->submode_mainid = strdup(data->submode_mainid);
542 if (data->process_pool != NULL)
543 app_info->process_pool = strdup(data->process_pool);
544 if (data->installed_storage != NULL)
545 app_info->installed_storage = strdup(data->installed_storage);
546 if (data->autorestart != NULL)
547 app_info->autorestart = strdup(data->autorestart);
548 if (data->onboot != NULL)
549 app_info->onboot = strdup(data->onboot);
550 if (data->support_disable != NULL)
551 app_info->support_disable = strdup(data->support_disable);
552 if (data->ui_gadget != NULL)
553 app_info->ui_gadget = strdup(data->ui_gadget);
554 if (data->launch_mode != NULL)
555 app_info->launch_mode = strdup(data->launch_mode);
556 if (data->package_type != NULL)
557 app_info->package_type = strdup(data->package_type);
558 if (data->effective_appid != NULL)
559 app_info->effective_appid = strdup(data->effective_appid);
560 if (data->splash_screen_display != NULL)
561 app_info->splash_screen_display =
562 strdup(data->splash_screen_display);
566 app_info->label = g_list_copy_deep(data->label, __copy_label, &ret);
568 LOGE("memory alloc failed");
569 pkgmgrinfo_basic_free_application(app_info);
570 return PMINFO_R_ERROR;
574 app_info->icon = g_list_copy_deep(data->icon, __copy_icon, &ret);
576 LOGE("memory alloc failed");
577 pkgmgrinfo_basic_free_application(app_info);
578 return PMINFO_R_ERROR;
582 app_info->category = g_list_copy_deep(data->category, __copy_str, &ret);
584 LOGE("memory alloc failed");
585 pkgmgrinfo_basic_free_application(app_info);
586 return PMINFO_R_ERROR;
590 app_info->metadata = g_list_copy_deep(data->metadata,
591 __copy_metadata, &ret);
593 LOGE("memory alloc failed");
594 pkgmgrinfo_basic_free_application(app_info);
595 return PMINFO_R_ERROR;
599 app_info->datacontrol = g_list_copy_deep(data->datacontrol,
600 __copy_datacontrol, &ret);
602 LOGE("memory alloc failed");
603 pkgmgrinfo_basic_free_application(app_info);
604 return PMINFO_R_ERROR;
608 app_info->appcontrol = g_list_copy_deep(data->appcontrol,
609 __copy_appcontrol, &ret);
611 LOGE("memory alloc failed");
612 pkgmgrinfo_basic_free_application(app_info);
613 return PMINFO_R_ERROR;
617 app_info->background_category =
618 g_list_copy_deep(data->background_category,
621 LOGE("memory alloc failed");
622 pkgmgrinfo_basic_free_application(app_info);
623 return PMINFO_R_ERROR;
627 app_info->splashscreens = g_list_copy_deep(data->splashscreens,
628 __copy_splashscreens, &ret);
630 LOGE("memory alloc failed");
631 pkgmgrinfo_basic_free_application(app_info);
632 return PMINFO_R_ERROR;
636 app_info->res_control = g_list_copy_deep(data->res_control, __copy_res_control, &ret);
638 LOGE("memory alloc failed");
639 pkgmgrinfo_basic_free_application(app_info);
640 return PMINFO_R_ERROR;
643 *application = app_info;
648 API int pkgmgrinfo_appinfo_clone_appinfo(pkgmgrinfo_appinfo_h handle,
649 pkgmgrinfo_appinfo_h *clone)
651 pkgmgr_appinfo_x *info;
652 pkgmgr_appinfo_x *temp = (pkgmgr_appinfo_x *)handle;
655 return PMINFO_R_EINVAL;
657 info = calloc(1, sizeof(pkgmgr_appinfo_x));
659 LOGE("memory alloc failed");
660 return PMINFO_R_ERROR;
663 if (temp->package != NULL)
664 info->package = strdup(temp->package);
665 if (temp->locale != NULL)
666 info->locale = strdup(temp->locale);
668 info->app_component = temp->app_component;
670 if (_appinfo_copy_appinfo(&info->app_info, temp->app_info) < 0) {
671 LOGE("appinfo copy failed");
673 free((void *)info->package);
677 return PMINFO_R_ERROR;
685 static int _appinfo_get_filtered_foreach_appinfo(uid_t uid,
686 pkgmgrinfo_filter_x *filter, int flag,
687 pkgmgrinfo_app_list_cb app_list_cb,
691 pkgmgr_appinfo_x info;
697 list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
698 __free_applications);
700 return PMINFO_R_ERROR;
702 ret = _appinfo_get_applications(uid, filter,
703 flag | PMINFO_APPINFO_GET_BASICINFO, list);
704 if (ret == PMINFO_R_ERROR) {
705 g_hash_table_destroy(list);
709 g_hash_table_iter_init(&iter, list);
710 while (g_hash_table_iter_next(&iter, NULL, &value)) {
711 app = (application_x *)value;
713 info.locale = info.app_info->locale;
714 info.package = app->package;
715 if (app_list_cb(&info, user_data) < 0)
718 g_hash_table_destroy(list);
723 static const char *__appcomponent_str(pkgmgrinfo_app_component comp);
725 API int pkgmgrinfo_appinfo_get_usr_list(pkgmgrinfo_pkginfo_h handle,
726 pkgmgrinfo_app_component component,
727 pkgmgrinfo_app_list_cb app_func, void *user_data, uid_t uid)
730 pkgmgrinfo_appinfo_filter_h filter;
732 const char *comp_str = NULL;
734 if (handle == NULL || app_func == NULL) {
735 LOGE("invalid parameter");
736 return PMINFO_R_EINVAL;
739 if (pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid)) {
740 LOGE("invalid parameter");
741 return PMINFO_R_EINVAL;
744 if (pkgmgrinfo_appinfo_filter_create(&filter))
745 return PMINFO_R_ERROR;
747 if (pkgmgrinfo_appinfo_filter_add_string(filter,
748 PMINFO_APPINFO_PROP_APP_PACKAGE, pkgid)) {
749 pkgmgrinfo_appinfo_filter_destroy(filter);
750 return PMINFO_R_ERROR;
753 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
754 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
755 pkgmgrinfo_appinfo_filter_destroy(filter);
756 return PMINFO_R_ERROR;
759 comp_str = __appcomponent_str(component);
762 if (pkgmgrinfo_appinfo_filter_add_string(filter,
763 PMINFO_APPINFO_PROP_APP_COMPONENT,
765 pkgmgrinfo_appinfo_filter_destroy(filter);
766 return PMINFO_R_ERROR;
770 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter,
771 PMINFO_APPINFO_GET_ALL, app_func, user_data);
773 pkgmgrinfo_appinfo_filter_destroy(filter);
778 API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle,
779 pkgmgrinfo_app_component component,
780 pkgmgrinfo_app_list_cb app_func, void *user_data)
782 return pkgmgrinfo_appinfo_get_usr_list(handle,
783 component, app_func, user_data, _getuid());
786 API int pkgmgrinfo_appinfo_get_usr_installed_list_full(
787 pkgmgrinfo_app_list_cb app_func, uid_t uid, int flag,
791 pkgmgrinfo_appinfo_filter_h filter;
793 if (app_func == NULL) {
794 LOGE("invalid parameter");
795 return PMINFO_R_EINVAL;
798 if (pkgmgrinfo_appinfo_filter_create(&filter))
799 return PMINFO_R_ERROR;
801 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
802 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
803 pkgmgrinfo_appinfo_filter_destroy(filter);
804 return PMINFO_R_ERROR;
807 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
808 PMINFO_APPINFO_PROP_PKG_DISABLE, false)) {
809 pkgmgrinfo_appinfo_filter_destroy(filter);
810 return PMINFO_R_ERROR;
813 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
814 PMINFO_APPINFO_PROP_APP_CHECK_STORAGE, false)) {
815 pkgmgrinfo_appinfo_filter_destroy(filter);
816 return PMINFO_R_ERROR;
819 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter, flag, app_func,
822 pkgmgrinfo_appinfo_filter_destroy(filter);
827 API int pkgmgrinfo_appinfo_get_installed_list_full(
828 pkgmgrinfo_app_list_cb app_func, int flag, void *user_data)
830 return pkgmgrinfo_appinfo_get_usr_installed_list_full(app_func,
831 _getuid(), flag, user_data);
834 API int pkgmgrinfo_appinfo_get_usr_installed_list(
835 pkgmgrinfo_app_list_cb app_func, uid_t uid, void *user_data)
838 pkgmgrinfo_appinfo_filter_h filter;
840 if (app_func == NULL) {
841 LOGE("invalid parameter");
842 return PMINFO_R_EINVAL;
845 /* create an empty filter */
846 ret = pkgmgrinfo_appinfo_filter_create(&filter);
847 if (ret != PMINFO_R_OK)
850 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
851 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
852 pkgmgrinfo_appinfo_filter_destroy(filter);
853 return PMINFO_R_ERROR;
856 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
857 PMINFO_APPINFO_PROP_PKG_DISABLE, false)) {
858 pkgmgrinfo_appinfo_filter_destroy(filter);
859 return PMINFO_R_ERROR;
862 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter,
863 PMINFO_APPINFO_GET_ALL, app_func, user_data);
865 pkgmgrinfo_appinfo_filter_destroy(filter);
870 API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func,
873 return pkgmgrinfo_appinfo_get_usr_installed_list(app_func, _getuid(),
877 API int pkgmgrinfo_appinfo_get_appid(pkgmgrinfo_appinfo_h handle, char **appid)
879 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
881 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
882 retvm_if(appid == NULL, PMINFO_R_EINVAL,
883 "Argument supplied to hold return value is NULL");
885 if (info->app_info == NULL || info->app_info->appid == NULL)
886 return PMINFO_R_ERROR;
887 *appid = (char *)info->app_info->appid;
892 API int pkgmgrinfo_appinfo_get_pkgname(
893 pkgmgrinfo_appinfo_h handle, char **pkg_name)
895 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
897 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
898 retvm_if(pkg_name == NULL, PMINFO_R_EINVAL,
899 "Argument supplied to hold return value is NULL");
901 if (info->package == NULL)
902 return PMINFO_R_ERROR;
904 *pkg_name = (char *)info->package;
909 API int pkgmgrinfo_appinfo_get_pkgid(pkgmgrinfo_appinfo_h handle, char **pkgid)
911 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
913 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
914 retvm_if(pkgid == NULL, PMINFO_R_EINVAL,
915 "Argument supplied to hold return value is NULL");
917 if (info->package == NULL)
918 return PMINFO_R_ERROR;
920 *pkgid = (char *)info->package;
925 API int pkgmgrinfo_appinfo_get_pkgtype(
926 pkgmgrinfo_appinfo_h handle, char **pkgtype)
928 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
929 retvm_if(pkgtype == NULL, PMINFO_R_EINVAL,
930 "Argument supplied to hold return value is NULL");
931 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
933 *pkgtype = (char *)info->app_info->package_type;
938 API int pkgmgrinfo_appinfo_get_exec(pkgmgrinfo_appinfo_h handle, char **exec)
940 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
942 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
943 retvm_if(exec == NULL, PMINFO_R_EINVAL,
944 "Argument supplied to hold return value is NULL");
946 if (info->app_info == NULL || info->app_info->exec == NULL)
947 return PMINFO_R_ERROR;
948 *exec = (char *)info->app_info->exec;
954 API int pkgmgrinfo_appinfo_get_icon(pkgmgrinfo_appinfo_h handle, char **icon)
957 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
959 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
960 retvm_if(icon == NULL, PMINFO_R_EINVAL,
961 "Argument supplied to hold return value is NULL");
963 if (info->app_info == NULL)
964 return PMINFO_R_ERROR;
966 if (info->app_info->icon == NULL) {
971 ptr = (icon_x *)info->app_info->icon->data;
973 return PMINFO_R_ERROR;
975 if (ptr->text == NULL)
976 return PMINFO_R_ERROR;
984 API int pkgmgrinfo_appinfo_get_label(pkgmgrinfo_appinfo_h handle, char **label)
987 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
992 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
993 retvm_if(label == NULL, PMINFO_R_EINVAL,
994 "Argument supplied to hold return value is NULL");
996 if (info->app_info == NULL)
997 return PMINFO_R_ERROR;
999 locale = info->locale;
1001 locale = DEFAULT_LOCALE;
1003 for (tmp = info->app_info->label; tmp; tmp = tmp->next) {
1004 ptr = (label_x *)tmp->data;
1005 if (ptr == NULL || strcmp(locale, ptr->lang) != 0)
1016 for (tmp = info->app_info->label; tmp; tmp = tmp->next) {
1017 ptr = (label_x *)tmp->data;
1018 if (ptr == NULL || strcmp(DEFAULT_LOCALE, ptr->lang) != 0)
1024 *label = lbl ? lbl : "";
1029 API int pkgmgrinfo_appinfo_usr_get_localed_label(const char *appid,
1030 const char *locale, uid_t uid, char **label)
1034 retvm_if(appid == NULL || locale == NULL || label == NULL,
1035 PMINFO_R_EINVAL, "Argument is NULL");
1036 val = _appinfo_get_localed_label(appid, locale, uid);
1038 return PMINFO_R_ERROR;
1044 API int pkgmgrinfo_appinfo_get_localed_label(
1045 const char *appid, const char *locale, char **label)
1047 return pkgmgrinfo_appinfo_usr_get_localed_label(
1048 appid, locale, _getuid(), label);
1051 API int pkgmgrinfo_appinfo_get_metadata_value(
1052 pkgmgrinfo_appinfo_h handle, const char *metadata_key,
1053 char **metadata_value)
1055 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1056 retvm_if(metadata_key == NULL, PMINFO_R_EINVAL, "metadata_key is NULL");
1057 retvm_if(metadata_value == NULL, PMINFO_R_EINVAL,
1058 "metadata_value is NULL");
1060 GList *list_md = NULL;
1061 metadata_x *metadata = NULL;
1062 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1064 list_md = info->app_info->metadata;
1066 for (; list_md; list_md = list_md->next) {
1067 metadata = (metadata_x *)list_md->data;
1068 if (metadata && metadata->key) {
1069 if (strcasecmp(metadata->key, metadata_key) == 0) {
1070 if (metadata->value == NULL)
1071 *metadata_value = "";
1074 (char *)metadata->value;
1080 return PMINFO_R_EINVAL;
1083 static pkgmgrinfo_app_component __appcomponent_convert(const char *comp)
1085 if (strcasecmp(comp, "uiapp") == 0)
1086 return PMINFO_UI_APP;
1087 else if (strcasecmp(comp, "svcapp") == 0)
1088 return PMINFO_SVC_APP;
1089 else if (strcasecmp(comp, "widgetapp") == 0)
1090 return PMINFO_WIDGET_APP;
1091 else if (strcasecmp(comp, "watchapp") == 0)
1092 return PMINFO_WATCH_APP;
1093 else if (strcasecmp(comp, "componentbasedapp") == 0)
1094 return PMINFO_COMPONENT_BASED_APP;
1099 static const char *__appcomponent_str(pkgmgrinfo_app_component comp)
1104 case PMINFO_SVC_APP:
1106 case PMINFO_WIDGET_APP:
1108 case PMINFO_WATCH_APP:
1110 case PMINFO_COMPONENT_BASED_APP:
1111 return "componentbasedapp";
1117 API int pkgmgrinfo_appinfo_get_component(
1118 pkgmgrinfo_appinfo_h handle,
1119 pkgmgrinfo_app_component *component)
1121 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1124 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1125 retvm_if(component == NULL, PMINFO_R_EINVAL,
1126 "Argument supplied to hold return value is NULL");
1128 if (info->app_info == NULL)
1129 return PMINFO_R_ERROR;
1131 comp = __appcomponent_convert(info->app_info->component);
1133 return PMINFO_R_ERROR;
1140 API int pkgmgrinfo_appinfo_get_apptype(
1141 pkgmgrinfo_appinfo_h handle, char **app_type)
1143 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1145 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1146 retvm_if(app_type == NULL, PMINFO_R_EINVAL,
1147 "Argument supplied to hold return value is NULL");
1149 if (info->app_info == NULL || info->app_info->type == NULL)
1150 return PMINFO_R_ERROR;
1151 *app_type = (char *)info->app_info->type;
1156 API int pkgmgrinfo_appinfo_get_notification_icon(
1157 pkgmgrinfo_appinfo_h handle, char **icon)
1162 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1164 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1165 retvm_if(icon == NULL, PMINFO_R_EINVAL,
1166 "Argument supplied to hold return value is NULL\n");
1168 if (info->app_info == NULL)
1169 return PMINFO_R_ERROR;
1171 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1172 ptr = (icon_x *)tmp->data;
1173 if (ptr == NULL || ptr->section == NULL)
1176 val = (char *)ptr->section;
1177 if (val && strcmp(val, "notification") == 0) {
1178 *icon = (char *)ptr->text;
1183 return PMINFO_R_ERROR;
1186 API int pkgmgrinfo_appinfo_get_recent_image_type(
1187 pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_recentimage *type)
1190 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1192 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1193 retvm_if(type == NULL, PMINFO_R_EINVAL,
1194 "Argument supplied to hold return value is NULL");
1196 if (info->app_info == NULL || info->app_info->recentimage == NULL)
1197 return PMINFO_R_ERROR;
1199 val = (char *)info->app_info->recentimage;
1200 if (strcasecmp(val, "capture") == 0)
1201 *type = PMINFO_RECENTIMAGE_USE_CAPTURE;
1202 else if (strcasecmp(val, "icon") == 0)
1203 *type = PMINFO_RECENTIMAGE_USE_ICON;
1205 *type = PMINFO_RECENTIMAGE_USE_NOTHING;
1210 API int pkgmgrinfo_appinfo_get_preview_image(
1211 pkgmgrinfo_appinfo_h handle, char **preview_img)
1216 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1218 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1219 retvm_if(preview_img == NULL, PMINFO_R_EINVAL,
1220 "Argument supplied to hold return value is NULL\n");
1222 if (info->app_info == NULL)
1223 return PMINFO_R_ERROR;
1225 for (tmp = info->app_info->image; tmp; tmp = tmp->next) {
1226 ptr = (image_x *)tmp->data;
1227 if (ptr == NULL || ptr->section == NULL)
1230 val = (char *)ptr->section;
1231 if (val && strcmp(val, "preview") == 0) {
1232 *preview_img = (char *)ptr->text;
1237 return PMINFO_R_ERROR;
1240 API int pkgmgrinfo_appinfo_get_permission_type(
1241 pkgmgrinfo_appinfo_h handle,
1242 pkgmgrinfo_permission_type *permission)
1245 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1247 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1248 retvm_if(permission == NULL, PMINFO_R_EINVAL,
1249 "Argument supplied to hold return value is NULL\n");
1251 val = info->app_info->permission_type;
1253 return PMINFO_R_ERROR;
1255 if (strcmp(val, "signature") == 0)
1256 *permission = PMINFO_PERMISSION_SIGNATURE;
1257 else if (strcmp(val, "privilege") == 0)
1258 *permission = PMINFO_PERMISSION_PRIVILEGE;
1260 *permission = PMINFO_PERMISSION_NORMAL;
1265 API int pkgmgrinfo_appinfo_get_component_type(
1266 pkgmgrinfo_appinfo_h handle, char **component_type)
1268 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1270 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1271 retvm_if(component_type == NULL, PMINFO_R_EINVAL,
1272 "Argument supplied to hold return value is NULL");
1274 if (info->app_info == NULL || info->app_info->component_type == NULL)
1275 return PMINFO_R_ERROR;
1277 *component_type = (char *)info->app_info->component_type;
1282 API int pkgmgrinfo_appinfo_get_hwacceleration(
1283 pkgmgrinfo_appinfo_h handle,
1284 pkgmgrinfo_app_hwacceleration *hwacceleration)
1287 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1289 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1290 retvm_if(hwacceleration == NULL, PMINFO_R_EINVAL,
1291 "Argument supplied to hold return value is NULL");
1293 if (info->app_info == NULL || info->app_info->hwacceleration == NULL)
1294 return PMINFO_R_ERROR;
1296 val = (char *)info->app_info->hwacceleration;
1297 if (strcasecmp(val, "off") == 0)
1298 *hwacceleration = PMINFO_HWACCELERATION_OFF;
1299 else if (strcasecmp(val, "on") == 0)
1300 *hwacceleration = PMINFO_HWACCELERATION_ON;
1302 *hwacceleration = PMINFO_HWACCELERATION_DEFAULT;
1307 API int pkgmgrinfo_appinfo_get_screenreader(
1308 pkgmgrinfo_appinfo_h handle,
1309 pkgmgrinfo_app_screenreader *screenreader)
1312 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1314 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1315 retvm_if(screenreader == NULL, PMINFO_R_EINVAL,
1316 "Argument supplied to hold return value is NULL");
1318 if (info->app_info == NULL || info->app_info->screenreader == NULL)
1319 return PMINFO_R_ERROR;
1321 val = (char *)info->app_info->screenreader;
1322 if (strcasecmp(val, "screenreader-off") == 0)
1323 *screenreader = PMINFO_SCREENREADER_OFF;
1324 else if (strcasecmp(val, "screenreader-on") == 0)
1325 *screenreader = PMINFO_SCREENREADER_ON;
1327 *screenreader = PMINFO_SCREENREADER_USE_SYSTEM_SETTING;
1332 API int pkgmgrinfo_appinfo_get_effectimage(
1333 pkgmgrinfo_appinfo_h handle, char **portrait_img,
1334 char **landscape_img)
1336 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1338 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1339 retvm_if(portrait_img == NULL, PMINFO_R_EINVAL,
1340 "Argument supplied to hold return value is NULL");
1341 retvm_if(landscape_img == NULL, PMINFO_R_EINVAL,
1342 "Argument supplied to hold return value is NULL");
1344 if (info->app_info == NULL)
1345 return PMINFO_R_ERROR;
1347 if (info->app_info->portraitimg == NULL)
1350 *portrait_img = (char *)info->app_info->portraitimg;
1352 if (info->app_info->landscapeimg == NULL)
1353 *landscape_img = "";
1355 *landscape_img = (char *)info->app_info->landscapeimg;
1360 API int pkgmgrinfo_appinfo_get_effectimage_type(
1361 pkgmgrinfo_appinfo_h handle, char **effectimage_type)
1363 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1365 if (handle == NULL || effectimage_type == NULL) {
1366 LOGE("invalid parameter");
1367 return PMINFO_R_EINVAL;
1370 if (info->app_info == NULL || info->app_info->effectimage_type == NULL)
1371 return PMINFO_R_ERROR;
1373 *effectimage_type = (char *)info->app_info->effectimage_type;
1378 API int pkgmgrinfo_appinfo_get_submode_mainid(
1379 pkgmgrinfo_appinfo_h handle, char **submode_mainid)
1381 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1383 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1384 retvm_if(submode_mainid == NULL, PMINFO_R_EINVAL,
1385 "Argument supplied to hold return value is NULL");
1387 if (info->app_info == NULL)
1388 return PMINFO_R_ERROR;
1390 if (info->app_info->submode_mainid == NULL)
1391 *submode_mainid = "";
1393 *submode_mainid = (char *)info->app_info->submode_mainid;
1398 API int pkgmgrinfo_appinfo_get_installed_storage_location(
1399 pkgmgrinfo_appinfo_h handle,
1400 pkgmgrinfo_installed_storage *storage)
1402 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1403 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1405 if (info->app_info && info->app_info->installed_storage) {
1406 if (strcmp(info->app_info->installed_storage,
1407 "installed_internal") == 0)
1408 *storage = PMINFO_INTERNAL_STORAGE;
1409 else if (strcmp(info->app_info->installed_storage,
1410 "installed_external") == 0)
1411 *storage = PMINFO_EXTERNAL_STORAGE;
1413 return PMINFO_R_ERROR;
1415 return PMINFO_R_ERROR;
1421 API int pkgmgrinfo_appinfo_get_launch_mode(
1422 pkgmgrinfo_appinfo_h handle, char **mode)
1424 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1426 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1427 retvm_if(mode == NULL, PMINFO_R_EINVAL,
1428 "Argument supplied to hold return value is NULL\n");
1430 if (info->app_info->launch_mode == NULL)
1431 return PMINFO_R_ERROR;
1433 *mode = (char *)(info->app_info->launch_mode);
1438 API int pkgmgrinfo_appinfo_get_alias_appid(
1439 pkgmgrinfo_appinfo_h handle, char **alias_appid)
1441 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1443 if (handle == NULL || alias_appid == NULL) {
1444 LOGE("invalid parameter");
1445 return PMINFO_R_EINVAL;
1448 if (info->app_info == NULL || info->app_info->alias_appid == NULL)
1449 return PMINFO_R_ERROR;
1451 *alias_appid = (char *)info->app_info->alias_appid;
1456 API int pkgmgrinfo_appinfo_get_effective_appid(
1457 pkgmgrinfo_appinfo_h handle, char **effective_appid)
1459 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1461 if (handle == NULL || effective_appid == NULL) {
1462 LOGE("invalid parameter");
1463 return PMINFO_R_EINVAL;
1466 if (info->app_info == NULL)
1467 return PMINFO_R_ERROR;
1469 if (info->app_info->effective_appid == NULL)
1470 *effective_appid = "";
1472 *effective_appid = (char *)info->app_info->effective_appid;
1477 API int pkgmgrinfo_appinfo_get_tep_name(
1478 pkgmgrinfo_appinfo_h handle, char **tep_name)
1480 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1482 if (handle == NULL || tep_name == NULL) {
1483 LOGE("invalid parameter");
1484 return PMINFO_R_EINVAL;
1487 if (info->app_info == NULL)
1488 return PMINFO_R_ERROR;
1490 if (info->app_info->tep_name == NULL)
1493 *tep_name = (char *)info->app_info->tep_name;
1498 API int pkgmgrinfo_appinfo_get_zip_mount_file(
1499 pkgmgrinfo_appinfo_h handle, char **zip_mount_file)
1501 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1503 if (handle == NULL || zip_mount_file == NULL) {
1504 LOGE("invalid parameter");
1505 return PMINFO_R_EINVAL;
1508 if (info->app_info == NULL)
1509 return PMINFO_R_ERROR;
1511 if (info->app_info->zip_mount_file == NULL)
1512 *zip_mount_file = "";
1514 *zip_mount_file = (char *)info->app_info->zip_mount_file;
1519 API int pkgmgrinfo_appinfo_get_root_path(
1520 pkgmgrinfo_appinfo_h handle, char **root_path)
1522 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1524 if (handle == NULL || root_path == NULL) {
1525 LOGE("invalid parameter");
1526 return PMINFO_R_EINVAL;
1529 if (info->app_info == NULL || info->app_info->root_path == NULL)
1530 return PMINFO_R_ERROR;
1532 *root_path = (char *)info->app_info->root_path;
1537 API int pkgmgrinfo_appinfo_get_api_version(
1538 pkgmgrinfo_appinfo_h handle, char **api_version)
1540 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1542 if (handle == NULL || api_version == NULL) {
1543 LOGE("invalid parameter");
1544 return PMINFO_R_EINVAL;
1547 if (info->app_info == NULL || info->app_info->api_version == NULL)
1548 return PMINFO_R_ERROR;
1550 *api_version = (char *)info->app_info->api_version;
1555 API int pkgmgrinfo_appinfo_get_installed_time(
1556 pkgmgrinfo_appinfo_h handle, int *installed_time)
1558 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1560 if (handle == NULL || installed_time == NULL) {
1561 LOGE("invalid parameter");
1562 return PMINFO_R_EINVAL;
1565 if (info->app_info == NULL ||
1566 info->app_info->package_installed_time == NULL)
1567 return PMINFO_R_ERROR;
1569 *installed_time = atoi(info->app_info->package_installed_time);
1574 API int pkgmgrinfo_appinfo_usr_get_datacontrol_info(const char *providerid,
1575 const char *type, uid_t uid, char **appid, char **access)
1579 if (providerid == NULL || type == NULL || appid == NULL ||
1581 LOGE("invalid parameter");
1582 return PMINFO_R_EINVAL;
1585 ret = _appinfo_get_datacontrol_info(
1586 providerid, type, uid, appid, access);
1587 /* FIXME: It should return PMINFO_R_ENOENT but to keep previous
1588 * implementation, return PMINFO_R_ERROR. This should be
1591 if (ret == PMINFO_R_ENOENT) {
1592 LOGE("no datacontrol info of %s", providerid);
1593 ret = PMINFO_R_ERROR;
1599 API int pkgmgrinfo_appinfo_get_datacontrol_info(const char *providerid,
1600 const char *type, char **appid, char **access)
1602 return pkgmgrinfo_appinfo_usr_get_datacontrol_info(providerid,
1603 type, _getuid(), appid, access);
1606 API int pkgmgrinfo_appinfo_usr_get_datacontrol_appid(const char *providerid,
1607 uid_t uid, char **appid)
1611 if (providerid == NULL || appid == NULL) {
1612 LOGE("invalid parameter");
1613 return PMINFO_R_EINVAL;
1616 ret = _appinfo_get_datacontrol_appid(providerid, uid, appid);
1617 /* FIXME: It should return PMINFO_R_ENOENT but to keep previous
1618 * implementation, return PMINFO_R_ERROR. This should be
1621 if (ret == PMINFO_R_ENOENT) {
1622 LOGE("no datacontrol appid of %s", providerid);
1623 ret = PMINFO_R_ERROR;
1629 API int pkgmgrinfo_appinfo_get_datacontrol_appid(
1630 const char *providerid, char **appid)
1632 return pkgmgrinfo_appinfo_usr_get_datacontrol_appid(
1633 providerid, _getuid(), appid);
1636 API int pkgmgrinfo_appinfo_usr_get_datacontrol_trusted_info(
1637 const char *providerid, const char *type, uid_t uid,
1638 char **appid, bool *is_trusted)
1641 char *trusted = NULL;
1643 if (providerid == NULL || type == NULL || appid == NULL ||
1644 is_trusted == NULL) {
1645 LOGE("invalid parameter");
1646 return PMINFO_R_EINVAL;
1649 ret = _appinfo_get_datacontrol_trusted_info(providerid, type, uid,
1652 /* FIXME: It should return PMINFO_R_ENOENT but to keep previous
1653 * implementation, return PMINFO_R_ERROR. This should be
1656 if (ret == PMINFO_R_ENOENT) {
1657 LOGE("no datacontrol trusted info of %s", providerid);
1658 ret = PMINFO_R_ERROR;
1660 *is_trusted = _get_bool_value(trusted);
1666 API int pkgmgrinfo_appinfo_get_datacontrol_trsuted_info(const char *providerid,
1667 const char *type, char **appid, bool *is_trusted)
1669 return pkgmgrinfo_appinfo_usr_get_datacontrol_trusted_info(providerid,
1670 type, _getuid(), appid, is_trusted);
1673 API int pkgmgrinfo_appinfo_usr_foreach_datacontrol_privileges(
1674 const char *providerid, const char *type,
1675 pkgmgrinfo_pkg_privilege_list_cb privilege_func,
1676 void *user_data, uid_t uid)
1683 if (providerid == NULL || type == NULL || privilege_func == NULL) {
1684 LOGE("invalid parameter");
1685 return PMINFO_R_EINVAL;
1688 ret = _appinfo_get_datacontrol_privileges(providerid, type, uid, &list);
1689 if (ret == PMINFO_R_ERROR) {
1690 g_list_free_full(list, free);
1694 for (tmp = list; tmp != NULL; tmp = g_list_next(tmp)) {
1696 ret = privilege_func((char *)tmp->data, user_data);
1701 g_list_free_full(list, free);
1705 API int pkgmgrinfo_appinfo_foreach_datacontrol_privileges(
1706 const char *providerid, const char *type,
1707 pkgmgrinfo_pkg_privilege_list_cb privilege_func,
1710 return pkgmgrinfo_appinfo_usr_foreach_datacontrol_privileges(
1711 providerid, type, privilege_func, user_data, _getuid());
1714 API int pkgmgrinfo_appinfo_get_support_mode(
1715 pkgmgrinfo_appinfo_h handle, int *support_mode)
1717 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1718 retvm_if(support_mode == NULL, PMINFO_R_EINVAL,
1719 "Argument supplied to hold return value is NULL");
1721 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1723 if (info->app_info->support_mode)
1724 *support_mode = atoi(info->app_info->support_mode);
1731 API int pkgmgrinfo_appinfo_foreach_category(pkgmgrinfo_appinfo_h handle,
1732 pkgmgrinfo_app_category_list_cb category_func, void *user_data)
1734 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1735 retvm_if(category_func == NULL, PMINFO_R_EINVAL,
1736 "Callback function is NULL");
1738 const char *category;
1740 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1742 if (info->app_info == NULL)
1743 return PMINFO_R_ERROR;
1745 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
1746 category = (const char *)tmp->data;
1748 ret = category_func(category, user_data);
1756 API int pkgmgrinfo_appinfo_foreach_metadata(pkgmgrinfo_appinfo_h handle,
1757 pkgmgrinfo_app_metadata_list_cb metadata_func, void *user_data)
1759 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1760 retvm_if(metadata_func == NULL, PMINFO_R_EINVAL,
1761 "Callback function is NULL");
1765 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1767 if (info->app_info == NULL)
1768 return PMINFO_R_ERROR;
1770 for (tmp = info->app_info->metadata; tmp; tmp = tmp->next) {
1771 ptr = (metadata_x *)tmp->data;
1775 ret = metadata_func(ptr->key, ptr->value ?
1776 ptr->value : "", user_data);
1784 API int pkgmgrinfo_appinfo_usr_foreach_appcontrol_privileges(const char *appid,
1785 const char *operation,
1786 pkgmgrinfo_pkg_privilege_list_cb privilege_func,
1787 void *user_data, uid_t uid)
1790 GList *privilege_list = NULL;
1793 if (appid == NULL || operation == NULL || privilege_func == NULL) {
1794 LOGE("invalid parameter");
1795 return PMINFO_R_EINVAL;
1798 ret = _appinfo_get_appcontrol_privileges(appid, operation, uid,
1800 if (ret == PMINFO_R_ENOENT) {
1802 } else if (ret != PMINFO_R_OK) {
1803 g_list_free_full(privilege_list, free);
1807 for (tmp_list = privilege_list; tmp_list != NULL;
1808 tmp_list = g_list_next(tmp_list)) {
1809 ret = privilege_func((char *)tmp_list->data, user_data);
1814 g_list_free_full(privilege_list, free);
1818 API int pkgmgrinfo_appinfo_foreach_appcontrol_privileges(const char *appid,
1819 const char *operation,
1820 pkgmgrinfo_pkg_privilege_list_cb privilege_func,
1823 return pkgmgrinfo_appinfo_usr_foreach_appcontrol_privileges(appid,
1824 operation, privilege_func, user_data, _getuid());
1827 API int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
1828 pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
1830 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1831 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL,
1832 "Callback function is NULL");
1834 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1835 appcontrol_x *appcontrol;
1838 if (info->app_info == NULL)
1839 return PMINFO_R_ERROR;
1841 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
1842 appcontrol = (appcontrol_x *)tmp->data;
1843 if (appcontrol == NULL || !strcasecmp(
1844 appcontrol->visibility, "remote-only"))
1846 ret = appcontrol_func(appcontrol->operation,
1847 appcontrol->uri, appcontrol->mime, user_data);
1855 API int pkgmgrinfo_appinfo_foreach_remote_appcontrol(
1856 pkgmgrinfo_appinfo_h handle,
1857 pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
1859 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1860 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL,
1861 "Callback function is NULL");
1863 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1864 appcontrol_x *appcontrol;
1867 if (info->app_info == NULL)
1868 return PMINFO_R_ERROR;
1870 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
1871 appcontrol = (appcontrol_x *)tmp->data;
1872 if (appcontrol == NULL || !strcasecmp(
1873 appcontrol->visibility, "local-only"))
1875 ret = appcontrol_func(appcontrol->operation, appcontrol->uri,
1876 appcontrol->mime, user_data);
1884 API int pkgmgrinfo_appinfo_foreach_background_category(
1885 pkgmgrinfo_appinfo_h handle,
1886 pkgmgrinfo_app_background_category_list_cb category_func,
1889 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1893 if (handle == NULL || category_func == NULL || info->app_info == NULL) {
1894 LOGE("invalid parameter");
1895 return PMINFO_R_EINVAL;
1898 for (tmp = info->app_info->background_category; tmp; tmp = tmp->next) {
1899 category = (char *)tmp->data;
1900 if (category == NULL)
1903 if (category_func(category, user_data) < 0)
1910 API int pkgmgrinfo_appinfo_foreach_splash_screen(pkgmgrinfo_appinfo_h handle,
1911 pkgmgrinfo_app_splash_screen_list_cb splash_screen_func,
1914 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1915 splashscreen_x *splashscreen;
1919 if (info == NULL || info->app_info == NULL
1920 || splash_screen_func == NULL) {
1921 LOGE("invalid parameter");
1922 return PMINFO_R_EINVAL;
1925 for (tmp = info->app_info->splashscreens; tmp; tmp = tmp->next) {
1926 splashscreen = (splashscreen_x *)tmp->data;
1927 if (splashscreen == NULL)
1929 ret = splash_screen_func(splashscreen->src,
1931 splashscreen->orientation,
1932 splashscreen->indicatordisplay,
1933 splashscreen->operation,
1934 splashscreen->color_depth,
1943 API int pkgmgrinfo_appinfo_foreach_res_control(pkgmgrinfo_appinfo_h handle,
1944 pkgmgrinfo_app_res_control_list_cb res_control_func,
1947 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1948 retvm_if(res_control_func == NULL, PMINFO_R_EINVAL,
1949 "Callback function is NULL");
1951 res_control_x *res_control;
1953 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1955 if (info->app_info == NULL)
1956 return PMINFO_R_ERROR;
1958 for (tmp = info->app_info->res_control; tmp; tmp = tmp->next) {
1959 res_control = (res_control_x *)tmp->data;
1960 if (res_control == NULL)
1962 ret = res_control_func(res_control->res_type,
1963 res_control->min_res_version,
1964 res_control->max_res_version,
1965 res_control->auto_close,
1973 API int pkgmgrinfo_appinfo_is_nodisplay(
1974 pkgmgrinfo_appinfo_h handle, bool *nodisplay)
1976 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1977 retvm_if(nodisplay == NULL, PMINFO_R_EINVAL,
1978 "Argument supplied to hold return value is NULL");
1979 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1981 if (info->app_info == NULL || info->app_info->nodisplay == NULL)
1982 return PMINFO_R_ERROR;
1984 *nodisplay = _get_bool_value(info->app_info->nodisplay);
1989 API int pkgmgrinfo_appinfo_is_multiple(
1990 pkgmgrinfo_appinfo_h handle, bool *multiple)
1992 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1993 retvm_if(multiple == NULL, PMINFO_R_EINVAL,
1994 "Argument supplied to hold return value is NULL");
1995 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1997 if (info->app_info == NULL || info->app_info->multiple == NULL)
1998 return PMINFO_R_ERROR;
2000 *multiple = _get_bool_value(info->app_info->multiple);
2005 API int pkgmgrinfo_appinfo_is_indicator_display_allowed(
2006 pkgmgrinfo_appinfo_h handle, bool *indicator_disp)
2008 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2009 retvm_if(indicator_disp == NULL, PMINFO_R_EINVAL,
2010 "Argument supplied to hold return value is NULL");
2011 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2013 if (info->app_info == NULL || info->app_info->indicatordisplay == NULL)
2014 return PMINFO_R_ERROR;
2016 *indicator_disp = _get_bool_value(info->app_info->indicatordisplay);
2021 API int pkgmgrinfo_appinfo_is_taskmanage(
2022 pkgmgrinfo_appinfo_h handle, bool *taskmanage)
2024 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2025 retvm_if(taskmanage == NULL, PMINFO_R_EINVAL,
2026 "Argument supplied to hold return value is NULL");
2027 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2029 if (info->app_info == NULL || info->app_info->taskmanage == NULL)
2030 return PMINFO_R_ERROR;
2032 *taskmanage = _get_bool_value(info->app_info->taskmanage);
2037 API int pkgmgrinfo_appinfo_is_enabled(
2038 pkgmgrinfo_appinfo_h handle, bool *enabled)
2040 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2041 retvm_if(enabled == NULL, PMINFO_R_EINVAL,
2042 "Argument supplied to hold return value is NULL");
2043 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2045 if (info->app_info == NULL || info->app_info->is_disabled == NULL)
2046 return PMINFO_R_ERROR;
2048 *enabled = !_get_bool_value(info->app_info->is_disabled);
2053 API int pkgmgrinfo_appinfo_is_onboot(
2054 pkgmgrinfo_appinfo_h handle, bool *onboot)
2056 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2057 retvm_if(onboot == NULL, PMINFO_R_EINVAL,
2058 "Argument supplied to hold return value is NULL");
2059 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2061 if (info->app_info == NULL || info->app_info->onboot == NULL)
2062 return PMINFO_R_ERROR;
2064 *onboot = _get_bool_value(info->app_info->onboot);
2069 API int pkgmgrinfo_appinfo_is_autorestart(
2070 pkgmgrinfo_appinfo_h handle, bool *autorestart)
2072 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2073 retvm_if(autorestart == NULL, PMINFO_R_EINVAL,
2074 "Argument supplied to hold return value is NULL");
2075 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2077 if (info->app_info == NULL || info->app_info->autorestart == NULL)
2078 return PMINFO_R_ERROR;
2080 *autorestart = _get_bool_value(info->app_info->autorestart);
2085 API int pkgmgrinfo_appinfo_is_mainapp(
2086 pkgmgrinfo_appinfo_h handle, bool *mainapp)
2088 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2089 retvm_if(mainapp == NULL, PMINFO_R_EINVAL,
2090 "Argument supplied to hold return value is NULL");
2091 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2093 if (info->app_info == NULL || info->app_info->mainapp == NULL)
2094 return PMINFO_R_ERROR;
2096 *mainapp = _get_bool_value(info->app_info->mainapp);
2101 API int pkgmgrinfo_appinfo_is_preload(
2102 pkgmgrinfo_appinfo_h handle, bool *preload)
2104 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2105 retvm_if(preload == NULL, PMINFO_R_EINVAL,
2106 "Argument supplied to hold return value is NULL\n");
2107 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2109 if (info->app_info == NULL || info->app_info->preload == NULL)
2110 return PMINFO_R_ERROR;
2112 *preload = _get_bool_value(info->app_info->preload);
2117 API int pkgmgrinfo_appinfo_is_submode(
2118 pkgmgrinfo_appinfo_h handle, bool *submode)
2120 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2121 retvm_if(submode == NULL, PMINFO_R_EINVAL,
2122 "Argument supplied to hold return value is NULL\n");
2123 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2125 if (info->app_info == NULL || info->app_info->submode == NULL)
2126 return PMINFO_R_ERROR;
2128 *submode = _get_bool_value(info->app_info->submode);
2133 API int pkgmgrinfo_appinfo_is_process_pool(
2134 pkgmgrinfo_appinfo_h handle, bool *process_pool)
2136 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2138 if (handle == NULL || process_pool == NULL) {
2139 LOGE("invalid parameter");
2140 return PMINFO_R_EINVAL;
2143 if (info->app_info == NULL)
2144 return PMINFO_R_ERROR;
2146 *process_pool = _get_bool_value(info->app_info->process_pool);
2151 API int pkgmgrinfo_appinfo_is_category_exist(
2152 pkgmgrinfo_appinfo_h handle, const char *category, bool *exist)
2154 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2155 retvm_if(category == NULL, PMINFO_R_EINVAL, "category is NULL");
2156 retvm_if(exist == NULL, PMINFO_R_EINVAL, "exist is NULL");
2160 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2162 if (info->app_info == NULL)
2163 return PMINFO_R_ERROR;
2166 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
2167 val = (const char *)tmp->data;
2170 if (strcasecmp(val, category) == 0) {
2179 API int pkgmgrinfo_appinfo_is_ui_gadget(pkgmgrinfo_appinfo_h handle,
2182 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2184 if (info == NULL || info->app_info == NULL || ui_gadget == NULL) {
2185 _LOGE("invalid parameter");
2186 return PMINFO_R_EINVAL;
2188 if (info->app_info->ui_gadget == NULL)
2189 info->app_info->ui_gadget = strdup("false");
2191 *ui_gadget = _get_bool_value(info->app_info->ui_gadget);
2196 API int pkgmgrinfo_appinfo_is_support_disable(pkgmgrinfo_appinfo_h handle,
2197 bool *support_disable)
2199 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2201 if (info == NULL || info->app_info == NULL || support_disable == NULL) {
2202 _LOGE("invalid parameter");
2203 return PMINFO_R_EINVAL;
2206 *support_disable = _get_bool_value(info->app_info->support_disable);
2211 API int pkgmgrinfo_appinfo_is_removable(pkgmgrinfo_appinfo_h handle,
2214 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2216 if (info == NULL || info->app_info == NULL || removable == NULL) {
2217 _LOGE("invalid parameter");
2218 return PMINFO_R_EINVAL;
2221 *removable = _get_bool_value(info->app_info->removable);
2226 API int pkgmgrinfo_appinfo_is_system(pkgmgrinfo_appinfo_h handle, bool *system)
2228 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2230 if (info == NULL || info->app_info == NULL || system == NULL) {
2231 _LOGE("invalid parameter");
2232 return PMINFO_R_EINVAL;
2235 *system = _get_bool_value(info->app_info->package_system);
2240 API int pkgmgrinfo_appinfo_is_disabled(
2241 pkgmgrinfo_appinfo_h handle, bool *disabled)
2243 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2244 retvm_if(disabled == NULL, PMINFO_R_EINVAL,
2245 "Argument supplied to hold return value is NULL");
2246 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2248 if (info->app_info == NULL || info->app_info->is_disabled == NULL)
2249 return PMINFO_R_ERROR;
2251 *disabled = _get_bool_value(info->app_info->is_disabled);
2256 API int pkgmgrinfo_appinfo_is_global(pkgmgrinfo_appinfo_h handle, bool *global)
2258 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2260 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2261 retvm_if(global == NULL, PMINFO_R_EINVAL,
2262 "Argument supplied to hold return value is NULL\n");
2264 if (info->app_info == NULL || info->app_info->for_all_users == NULL)
2265 return PMINFO_R_ERROR;
2267 *global = _get_bool_value(info->app_info->for_all_users);
2272 API int pkgmgrinfo_appinfo_get_splash_screen_display(
2273 pkgmgrinfo_appinfo_h handle, bool *splash_screen_display)
2275 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2277 if (info == NULL || splash_screen_display == NULL) {
2278 _LOGE("Invalid parameter");
2279 return PMINFO_R_EINVAL;
2282 if (info->app_info == NULL ||
2283 info->app_info->splash_screen_display == NULL)
2284 return PMINFO_R_ERROR;
2286 *splash_screen_display =
2287 _get_bool_value(info->app_info->splash_screen_display);
2292 API int pkgmgrinfo_appinfo_get_setup_appid(
2293 pkgmgrinfo_appinfo_h handle, char **setup_appid)
2295 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2297 if (info == NULL || setup_appid == NULL) {
2298 _LOGE("Invalid parameter");
2299 return PMINFO_R_EINVAL;
2302 if (info->app_info == NULL || info->app_info->setup_appid == NULL)
2303 return PMINFO_R_ERROR;
2305 *setup_appid = info->app_info->setup_appid;
2309 API int pkgmgrinfo_appinfo_is_support_ambient(pkgmgrinfo_appinfo_h handle,
2310 bool *support_ambient)
2312 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2314 if (info == NULL || support_ambient == NULL) {
2315 _LOGE("Invalid parameter");
2316 return PMINFO_R_EINVAL;
2319 if (info->app_info == NULL || info->app_info->support_ambient == NULL)
2320 return PMINFO_R_ERROR;
2322 *support_ambient = _get_bool_value(info->app_info->support_ambient);
2327 API int pkgmgrinfo_appinfo_get_light_user_switch_mode(
2328 pkgmgrinfo_appinfo_h handle, char **mode)
2330 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2332 if (info == NULL || mode == NULL) {
2333 _LOGE("Invalid parameter");
2334 return PMINFO_R_EINVAL;
2337 if (info->app_info == NULL || info->app_info->light_user_switch_mode == NULL)
2338 return PMINFO_R_ERROR;
2340 *mode = info->app_info->light_user_switch_mode;
2345 API int pkgmgrinfo_appinfo_destroy_appinfo(pkgmgrinfo_appinfo_h handle)
2347 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2348 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2350 __cleanup_appinfo(info);
2354 API int pkgmgrinfo_appinfo_filter_create(pkgmgrinfo_appinfo_filter_h *handle)
2356 return pkgmgrinfo_pkginfo_filter_create(handle);
2359 API int pkgmgrinfo_appinfo_filter_destroy(pkgmgrinfo_appinfo_filter_h handle)
2361 return pkgmgrinfo_pkginfo_filter_destroy(handle);
2364 static gint __compare_func(gconstpointer data1, gconstpointer data2)
2366 pkgmgrinfo_node_x *node1 = (pkgmgrinfo_node_x *)data1;
2367 pkgmgrinfo_node_x *node2 = (pkgmgrinfo_node_x *)data2;
2369 if (node1->prop == node2->prop)
2371 else if (node1->prop > node2->prop)
2377 API int pkgmgrinfo_appinfo_filter_add_int(pkgmgrinfo_appinfo_filter_h handle,
2378 const char *property, const int value)
2380 retvm_if(handle == NULL, PMINFO_R_EINVAL,
2381 "Filter handle input parameter is NULL\n");
2382 retvm_if(property == NULL, PMINFO_R_EINVAL,
2383 "Filter handle input parameter is NULL\n");
2384 char buf[PKG_VALUE_STRING_LEN_MAX] = {'\0'};
2386 GSList *link = NULL;
2389 prop = _pminfo_appinfo_convert_to_prop_int(property);
2390 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_INT ||
2391 prop > E_PMINFO_APPINFO_PROP_APP_MAX_INT) {
2392 _LOGE("Invalid Integer Property\n");
2393 return PMINFO_R_EINVAL;
2395 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2396 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1,
2397 sizeof(pkgmgrinfo_node_x));
2399 _LOGE("Out of Memory!!!\n");
2400 return PMINFO_R_ERROR;
2402 snprintf(buf, PKG_VALUE_STRING_LEN_MAX - 1, "%d", value);
2403 val = strndup(buf, PKG_VALUE_STRING_LEN_MAX - 1);
2405 _LOGE("Out of Memory\n");
2408 return PMINFO_R_ERROR;
2414 * If API is called multiple times for same property,
2415 * we should override the previous values.
2416 * Last value set will be used for filtering.
2418 link = g_slist_find_custom(filter->list,
2419 (gconstpointer)node, __compare_func);
2421 _pkgmgrinfo_node_destroy(link->data);
2422 filter->list = g_slist_delete_link(filter->list, link);
2424 filter->list = g_slist_append(filter->list, (gpointer)node);
2429 API int pkgmgrinfo_appinfo_filter_add_bool(pkgmgrinfo_appinfo_filter_h handle,
2430 const char *property, const bool value)
2432 retvm_if(handle == NULL, PMINFO_R_EINVAL,
2433 "Filter handle input parameter is NULL\n");
2434 retvm_if(property == NULL, PMINFO_R_EINVAL,
2435 "Filter handle input parameter is NULL\n");
2437 GSList *link = NULL;
2440 prop = _pminfo_appinfo_convert_to_prop_bool(property);
2441 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_BOOL ||
2442 prop > E_PMINFO_APPINFO_PROP_APP_MAX_BOOL) {
2443 _LOGE("Invalid Boolean Property\n");
2444 return PMINFO_R_EINVAL;
2446 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2447 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1,
2448 sizeof(pkgmgrinfo_node_x));
2450 _LOGE("Out of Memory!!!\n");
2451 return PMINFO_R_ERROR;
2454 val = strndup("true", 4);
2456 val = strndup("false", 5);
2458 _LOGE("Out of Memory\n");
2461 return PMINFO_R_ERROR;
2466 * If API is called multiple times for same property,
2467 * we should override the previous values.
2468 * Last value set will be used for filtering.
2470 link = g_slist_find_custom(filter->list,
2471 (gconstpointer)node, __compare_func);
2473 _pkgmgrinfo_node_destroy(link->data);
2474 filter->list = g_slist_delete_link(filter->list, link);
2476 filter->list = g_slist_append(filter->list, (gpointer)node);
2481 API int pkgmgrinfo_appinfo_filter_add_string(pkgmgrinfo_appinfo_filter_h handle,
2482 const char *property, const char *value)
2484 retvm_if(handle == NULL, PMINFO_R_EINVAL,
2485 "Filter handle input parameter is NULL\n");
2486 retvm_if(property == NULL, PMINFO_R_EINVAL,
2487 "Filter handle input parameter is NULL\n");
2488 retvm_if(value == NULL, PMINFO_R_EINVAL,
2489 "Filter handle input parameter is NULL\n");
2491 pkgmgrinfo_node_x *ptr = NULL;
2492 char prev[PKG_STRING_LEN_MAX] = {'\0'};
2493 char temp[PKG_STRING_LEN_MAX] = {'\0'};
2494 GSList *link = NULL;
2498 prop = _pminfo_appinfo_convert_to_prop_str(property);
2499 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_STR ||
2500 prop > E_PMINFO_APPINFO_PROP_APP_MAX_STR) {
2501 _LOGE("Invalid String Property\n");
2502 return PMINFO_R_EINVAL;
2504 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2505 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1,
2506 sizeof(pkgmgrinfo_node_x));
2508 _LOGE("Out of Memory!!!\n");
2509 return PMINFO_R_ERROR;
2513 case E_PMINFO_APPINFO_PROP_APP_COMPONENT:
2514 node->value = strdup(value);
2515 link = g_slist_find_custom(filter->list,
2516 (gconstpointer)node, __compare_func);
2518 _pkgmgrinfo_node_destroy(link->data);
2519 filter->list = g_slist_delete_link(filter->list, link);
2521 filter->list = g_slist_append(filter->list, (gpointer)node);
2523 case E_PMINFO_APPINFO_PROP_APP_CATEGORY:
2524 val = (char *)calloc(1, PKG_STRING_LEN_MAX);
2526 _LOGE("Out of Memory\n");
2529 return PMINFO_R_ERROR;
2531 link = g_slist_find_custom(filter->list,
2532 (gconstpointer)node, __compare_func);
2534 ptr = (pkgmgrinfo_node_x *)link->data;
2535 strncpy(prev, ptr->value, PKG_STRING_LEN_MAX - 1);
2536 _LOGI("Previous value is %s\n", prev);
2537 _pkgmgrinfo_node_destroy(ptr);
2538 filter->list = g_slist_delete_link(filter->list, link);
2539 ret = snprintf(temp, PKG_STRING_LEN_MAX - 1,
2540 "%s,%s", prev, value);
2541 if (ret < 0 || ret > PKG_STRING_LEN_MAX - 1) {
2542 _LOGE("snprintf fail\n");
2545 return PMINFO_R_ERROR;
2547 strncpy(val, temp, PKG_STRING_LEN_MAX);
2548 _LOGI("New value is %s\n", val);
2550 filter->list = g_slist_append(
2551 filter->list, (gpointer)node);
2552 memset(temp, '\0', PKG_STRING_LEN_MAX);
2554 snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s", value);
2555 strncpy(val, temp, PKG_STRING_LEN_MAX);
2556 _LOGI("First value is %s\n", val);
2558 filter->list = g_slist_append(
2559 filter->list, (gpointer)node);
2560 memset(temp, '\0', PKG_STRING_LEN_MAX);
2564 node->value = strndup(value, PKG_STRING_LEN_MAX - 1);
2565 link = g_slist_find_custom(filter->list,
2566 (gconstpointer)node, __compare_func);
2568 _pkgmgrinfo_node_destroy(link->data);
2569 filter->list = g_slist_delete_link(filter->list, link);
2571 filter->list = g_slist_append(filter->list, (gpointer)node);
2577 API int pkgmgrinfo_appinfo_usr_filter_count(
2578 pkgmgrinfo_appinfo_filter_h handle, int *count, uid_t uid)
2583 pkgmgrinfo_filter_x *filter;
2585 if (handle == NULL || count == NULL) {
2586 _LOGE("invalid parameter");
2587 return PMINFO_R_EINVAL;
2590 filter = (pkgmgrinfo_filter_x *)handle;
2591 list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
2592 __free_applications);
2594 return PMINFO_R_ERROR;
2596 if (__check_disable_filter_exist(
2597 handle, E_APPINFO_DISABLE_TYPE_APP) == false) {
2598 if (pkgmgrinfo_appinfo_filter_add_bool(handle,
2599 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
2600 g_hash_table_destroy(list);
2601 return PMINFO_R_ERROR;
2605 if (__check_disable_filter_exist(
2606 handle, E_APPINFO_DISABLE_TYPE_PKG) == false) {
2607 if (pkgmgrinfo_appinfo_filter_add_bool(handle,
2608 PMINFO_APPINFO_PROP_PKG_DISABLE, false)) {
2609 g_hash_table_destroy(list);
2610 return PMINFO_R_ERROR;
2614 ret = _appinfo_get_applications(uid, filter, 0, list);
2615 query_count = g_hash_table_size(list);
2616 g_hash_table_destroy(list);
2617 if (ret == PMINFO_R_ERROR)
2620 *count = query_count;
2624 API int pkgmgrinfo_appinfo_filter_count(
2625 pkgmgrinfo_appinfo_filter_h handle, int *count)
2627 return pkgmgrinfo_appinfo_usr_filter_count(handle, count, _getuid());
2630 API int pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(
2631 pkgmgrinfo_appinfo_filter_h handle,
2632 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
2634 if (handle == NULL || app_cb == NULL) {
2635 LOGE("invalid parameter");
2636 return PMINFO_R_EINVAL;
2639 if (__check_disable_filter_exist(
2640 handle, E_APPINFO_DISABLE_TYPE_APP) == false) {
2641 if (pkgmgrinfo_appinfo_filter_add_bool(handle,
2642 PMINFO_APPINFO_PROP_APP_DISABLE, false))
2643 return PMINFO_R_ERROR;
2646 if (__check_disable_filter_exist(
2647 handle, E_APPINFO_DISABLE_TYPE_PKG) == false) {
2648 if (pkgmgrinfo_appinfo_filter_add_bool(handle,
2649 PMINFO_APPINFO_PROP_PKG_DISABLE, false))
2650 return PMINFO_R_ERROR;
2653 return _appinfo_get_filtered_foreach_appinfo(uid,
2654 handle, PMINFO_APPINFO_GET_ALL, app_cb, user_data);
2657 API int pkgmgrinfo_appinfo_filter_foreach_appinfo(
2658 pkgmgrinfo_appinfo_filter_h handle,
2659 pkgmgrinfo_app_list_cb app_cb, void *user_data)
2661 return pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(
2662 handle, app_cb, user_data, _getuid());
2665 API int pkgmgrinfo_appinfo_metadata_filter_create(
2666 pkgmgrinfo_appinfo_metadata_filter_h *handle)
2668 return pkgmgrinfo_pkginfo_filter_create(handle);
2671 API int pkgmgrinfo_appinfo_metadata_filter_destroy(
2672 pkgmgrinfo_appinfo_metadata_filter_h handle)
2674 return pkgmgrinfo_pkginfo_filter_destroy(handle);
2677 API int pkgmgrinfo_appinfo_metadata_filter_add(
2678 pkgmgrinfo_appinfo_metadata_filter_h handle,
2679 const char *key, const char *value)
2681 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2682 pkgmgrinfo_metadata_node_x *node;
2684 /* value can be NULL.
2685 * In that case all apps with specified key should be displayed
2688 LOGE("invalid parameter");
2689 return PMINFO_R_EINVAL;
2692 node = calloc(1, sizeof(pkgmgrinfo_metadata_node_x));
2694 LOGE("out of memory");
2695 return PMINFO_R_ERROR;
2698 node->key = strdup(key);
2699 if (value && strlen(value))
2700 node->value = strdup(value);
2702 filter->list_metadata = g_slist_append(filter->list_metadata,
2708 API int pkgmgrinfo_appinfo_usr_metadata_filter_foreach(
2709 pkgmgrinfo_appinfo_metadata_filter_h handle,
2710 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
2712 if (handle == NULL || app_cb == NULL) {
2713 LOGE("invalid parameter");
2714 return PMINFO_R_EINVAL;
2717 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2719 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
2720 PMINFO_APPINFO_PROP_APP_DISABLE, false))
2721 return PMINFO_R_ERROR;
2723 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
2724 PMINFO_APPINFO_PROP_PKG_DISABLE, false))
2725 return PMINFO_R_ERROR;
2727 return _appinfo_get_filtered_foreach_appinfo(uid, handle,
2728 PMINFO_APPINFO_GET_ALL, app_cb,
2732 API int pkgmgrinfo_appinfo_metadata_filter_foreach(
2733 pkgmgrinfo_appinfo_metadata_filter_h handle,
2734 pkgmgrinfo_app_list_cb app_cb, void *user_data)
2736 return pkgmgrinfo_appinfo_usr_metadata_filter_foreach(handle, app_cb,
2737 user_data, _getuid());
2740 API int pkgmgrinfo_appinfo_is_guestmode_visibility(
2741 pkgmgrinfo_appinfo_h handle, bool *status)
2744 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2746 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2747 retvm_if(status == NULL, PMINFO_R_EINVAL,
2748 "Argument supplied to hold return value is NULL\n");
2750 val = info->app_info->guestmode_visibility;
2751 *status = _get_bool_value(val);
2755 API int pkgmgrinfo_appinfo_foreach_appcontrol_v2(pkgmgrinfo_appinfo_h handle,
2756 pkgmgrinfo_app_control_list_cb_v2 appcontrol_func,
2759 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2760 retvm_if(appcontrol_func == NULL,
2761 PMINFO_R_EINVAL, "Callback function is NULL");
2763 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2764 appcontrol_x *appcontrol;
2767 if (info->app_info == NULL)
2768 return PMINFO_R_ERROR;
2770 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
2771 appcontrol = (appcontrol_x *)tmp->data;
2772 if (appcontrol == NULL ||
2773 !strcasecmp(appcontrol->visibility,
2776 ret = appcontrol_func(appcontrol->operation, appcontrol->uri,
2777 appcontrol->mime, appcontrol->id, user_data);
2785 API int pkgmgrinfo_appinfo_foreach_remote_appcontrol_v2(
2786 pkgmgrinfo_appinfo_h handle,
2787 pkgmgrinfo_app_control_list_cb_v2 appcontrol_func,
2790 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2791 retvm_if(appcontrol_func == NULL,
2792 PMINFO_R_EINVAL, "Callback function is NULL");
2794 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2795 appcontrol_x *appcontrol;
2798 if (info->app_info == NULL)
2799 return PMINFO_R_ERROR;
2801 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
2802 appcontrol = (appcontrol_x *)tmp->data;
2803 if (appcontrol == NULL ||
2804 !strcasecmp(appcontrol->visibility,
2807 ret = appcontrol_func(appcontrol->operation, appcontrol->uri,
2808 appcontrol->mime, appcontrol->id, user_data);