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 return PMINFO_R_ERROR;
224 ret = pkgmgrinfo_appinfo_filter_add_string(filter,
225 PMINFO_APPINFO_PROP_APP_ID, real_appid);
226 if (ret != PMINFO_R_OK) {
227 pkgmgrinfo_appinfo_filter_destroy(filter);
229 return PMINFO_R_ERROR;
232 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
233 PMINFO_APPINFO_PROP_APP_DISABLE, false);
234 if (ret != PMINFO_R_OK) {
235 pkgmgrinfo_appinfo_filter_destroy(filter);
237 return PMINFO_R_ERROR;
240 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
241 PMINFO_APPINFO_PROP_PKG_DISABLE, false);
242 if (ret != PMINFO_R_OK) {
243 pkgmgrinfo_appinfo_filter_destroy(filter);
245 return PMINFO_R_ERROR;
248 ret = _pkgmgrinfo_get_appinfo(real_appid, uid, filter, handle);
250 pkgmgrinfo_appinfo_filter_destroy(filter);
254 API int pkgmgrinfo_appinfo_get_appinfo(
255 const char *appid, pkgmgrinfo_appinfo_h *handle)
257 return pkgmgrinfo_appinfo_get_usr_appinfo(appid, _getuid(), handle);
260 API int pkgmgrinfo_appinfo_get_usr_all_appinfo(const char *appid, uid_t uid,
261 pkgmgrinfo_appinfo_h *handle)
264 pkgmgrinfo_appinfo_filter_h filter;
266 if (appid == NULL || handle == NULL) {
267 LOGE("invalid parameter");
268 return PMINFO_R_EINVAL;
271 ret = pkgmgrinfo_appinfo_filter_create(&filter);
272 if (ret != PMINFO_R_OK)
275 ret = pkgmgrinfo_appinfo_filter_add_string(filter,
276 PMINFO_APPINFO_PROP_APP_ID, appid);
277 if (ret != PMINFO_R_OK) {
278 pkgmgrinfo_appinfo_filter_destroy(filter);
279 return PMINFO_R_ERROR;
282 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
283 PMINFO_APPINFO_PROP_APP_CHECK_STORAGE, false);
284 if (ret != PMINFO_R_OK) {
285 pkgmgrinfo_appinfo_filter_destroy(filter);
286 return PMINFO_R_ERROR;
289 ret = _pkgmgrinfo_get_appinfo(appid, uid, filter, handle);
290 pkgmgrinfo_appinfo_filter_destroy(filter);
295 API int pkgmgrinfo_appinfo_get_all_appinfo(
296 const char *appid, pkgmgrinfo_appinfo_h *handle)
298 return pkgmgrinfo_appinfo_get_usr_all_appinfo(appid, _getuid(), handle);
301 static gpointer __copy_str(gconstpointer src, gpointer data)
303 const char *tmp = (const char *)src;
306 buffer = strdup(tmp);
307 if (buffer == NULL) {
308 LOGE("memory alloc failed");
316 static gpointer __copy_label(gconstpointer src, gpointer data)
318 label_x *tmp = (label_x *)src;
321 label = calloc(1, sizeof(label_x));
323 LOGE("memory alloc failed");
329 label->name = strdup(tmp->name);
331 label->text = strdup(tmp->text);
333 label->lang = strdup(tmp->lang);
338 static gpointer __copy_icon(gconstpointer src, gpointer data)
340 icon_x *tmp = (icon_x *)src;
343 icon = calloc(1, sizeof(icon_x));
345 LOGE("memory alloc failed");
351 icon->text = strdup(tmp->text);
353 icon->lang = strdup(tmp->lang);
355 icon->section = strdup(tmp->section);
357 icon->size = strdup(tmp->size);
359 icon->resolution = strdup(tmp->resolution);
364 static gpointer __copy_metadata(gconstpointer src, gpointer data)
366 metadata_x *tmp = (metadata_x *)src;
367 metadata_x *metadata;
369 metadata = calloc(1, sizeof(metadata_x));
370 if (metadata == NULL) {
371 LOGE("memory alloc failed");
377 metadata->key = strdup(tmp->key);
379 metadata->value = strdup(tmp->value);
384 static gpointer __copy_datacontrol(gconstpointer src, gpointer data)
386 datacontrol_x *tmp = (datacontrol_x *)src;
387 datacontrol_x *datacontrol;
389 datacontrol = calloc(1, sizeof(datacontrol_x));
390 if (datacontrol == NULL) {
391 LOGE("memory alloc failed");
397 datacontrol->providerid = strdup(tmp->providerid);
399 datacontrol->access = strdup(tmp->access);
401 datacontrol->type = strdup(tmp->type);
403 datacontrol->trusted = strdup(tmp->trusted);
408 static gpointer __copy_appcontrol(gconstpointer src, gpointer data)
410 appcontrol_x *tmp = (appcontrol_x *)src;
411 appcontrol_x *appcontrol;
413 appcontrol = calloc(1, sizeof(appcontrol_x));
414 if (appcontrol == NULL) {
415 LOGE("memory alloc failed");
421 appcontrol->operation = strdup(tmp->operation);
423 appcontrol->uri = strdup(tmp->uri);
425 appcontrol->mime = strdup(tmp->mime);
430 static gpointer __copy_splashscreens(gconstpointer src, gpointer data)
432 splashscreen_x *tmp = (splashscreen_x *)src;
433 splashscreen_x *splashscreen;
435 splashscreen = (splashscreen_x *)calloc(1, sizeof(splashscreen_x));
436 if (splashscreen == NULL) {
437 LOGE("memory alloc failed");
443 splashscreen->src = strdup(tmp->src);
445 splashscreen->type = strdup(tmp->type);
446 if (tmp->orientation)
447 splashscreen->orientation = strdup(tmp->orientation);
448 if (tmp->indicatordisplay)
449 splashscreen->indicatordisplay = strdup(tmp->indicatordisplay);
451 splashscreen->operation = strdup(tmp->operation);
452 if (tmp->color_depth)
453 splashscreen->color_depth = strdup(tmp->color_depth);
458 static gpointer __copy_res_control(gconstpointer src, gpointer data)
460 res_control_x *tmp = (res_control_x *)src;
461 res_control_x *res_control;
463 res_control = (res_control_x *)calloc(1, sizeof(res_control_x));
464 if (res_control == NULL) {
465 LOGE("memory alloc failed");
471 res_control->res_type = strdup(tmp->res_type);
472 if (tmp->min_res_version)
473 res_control->min_res_version = strdup(tmp->min_res_version);
474 if (tmp->max_res_version)
475 res_control->max_res_version = strdup(tmp->max_res_version);
477 res_control->auto_close = strdup(tmp->auto_close);
482 static int _appinfo_copy_appinfo(
483 application_x **application, application_x *data)
485 application_x *app_info;
488 app_info = calloc(1, sizeof(application_x));
489 if (app_info == NULL) {
490 LOGE("memory alloc failed");
491 return PMINFO_R_ERROR;
494 if (data->appid != NULL)
495 app_info->appid = strdup(data->appid);
496 if (data->exec != NULL)
497 app_info->exec = strdup(data->exec);
498 if (data->nodisplay != NULL)
499 app_info->nodisplay = strdup(data->nodisplay);
500 if (data->multiple != NULL)
501 app_info->multiple = strdup(data->multiple);
502 if (data->taskmanage != NULL)
503 app_info->taskmanage = strdup(data->taskmanage);
504 if (data->type != NULL)
505 app_info->type = strdup(data->type);
506 if (data->categories != NULL)
507 app_info->categories = strdup(data->categories);
508 if (data->hwacceleration != NULL)
509 app_info->hwacceleration = strdup(data->hwacceleration);
510 if (data->screenreader != NULL)
511 app_info->screenreader = strdup(data->screenreader);
512 if (data->mainapp != NULL)
513 app_info->mainapp = strdup(data->mainapp);
514 if (data->package != NULL)
515 app_info->package = strdup(data->package);
516 if (data->recentimage != NULL)
517 app_info->recentimage = strdup(data->recentimage);
518 if (data->launchcondition != NULL)
519 app_info->launchcondition = strdup(data->launchcondition);
520 if (data->indicatordisplay != NULL)
521 app_info->indicatordisplay = strdup(data->indicatordisplay);
522 if (data->portraitimg != NULL)
523 app_info->portraitimg = strdup(data->portraitimg);
524 if (data->landscapeimg != NULL)
525 app_info->landscapeimg = strdup(data->landscapeimg);
526 if (data->guestmode_visibility != NULL)
527 app_info->guestmode_visibility =
528 strdup(data->guestmode_visibility);
529 if (data->component != NULL)
530 app_info->component = strdup(data->component);
531 if (data->permission_type != NULL)
532 app_info->permission_type = strdup(data->permission_type);
533 if (data->component_type != NULL)
534 app_info->component_type = strdup(data->component_type);
535 if (data->preload != NULL)
536 app_info->preload = strdup(data->preload);
537 if (data->submode != NULL)
538 app_info->submode = strdup(data->submode);
539 if (data->submode_mainid != NULL)
540 app_info->submode_mainid = strdup(data->submode_mainid);
541 if (data->process_pool != NULL)
542 app_info->process_pool = strdup(data->process_pool);
543 if (data->installed_storage != NULL)
544 app_info->installed_storage = strdup(data->installed_storage);
545 if (data->autorestart != NULL)
546 app_info->autorestart = strdup(data->autorestart);
547 if (data->onboot != NULL)
548 app_info->onboot = strdup(data->onboot);
549 if (data->support_disable != NULL)
550 app_info->support_disable = strdup(data->support_disable);
551 if (data->ui_gadget != NULL)
552 app_info->ui_gadget = strdup(data->ui_gadget);
553 if (data->launch_mode != NULL)
554 app_info->launch_mode = strdup(data->launch_mode);
555 if (data->package_type != NULL)
556 app_info->package_type = strdup(data->package_type);
557 if (data->effective_appid != NULL)
558 app_info->effective_appid = strdup(data->effective_appid);
559 if (data->splash_screen_display != NULL)
560 app_info->splash_screen_display =
561 strdup(data->splash_screen_display);
565 app_info->label = g_list_copy_deep(data->label, __copy_label, &ret);
567 LOGE("memory alloc failed");
568 pkgmgrinfo_basic_free_application(app_info);
569 return PMINFO_R_ERROR;
573 app_info->icon = g_list_copy_deep(data->icon, __copy_icon, &ret);
575 LOGE("memory alloc failed");
576 pkgmgrinfo_basic_free_application(app_info);
577 return PMINFO_R_ERROR;
581 app_info->category = g_list_copy_deep(data->category, __copy_str, &ret);
583 LOGE("memory alloc failed");
584 pkgmgrinfo_basic_free_application(app_info);
585 return PMINFO_R_ERROR;
589 app_info->metadata = g_list_copy_deep(data->metadata,
590 __copy_metadata, &ret);
592 LOGE("memory alloc failed");
593 pkgmgrinfo_basic_free_application(app_info);
594 return PMINFO_R_ERROR;
598 app_info->datacontrol = g_list_copy_deep(data->datacontrol,
599 __copy_datacontrol, &ret);
601 LOGE("memory alloc failed");
602 pkgmgrinfo_basic_free_application(app_info);
603 return PMINFO_R_ERROR;
607 app_info->appcontrol = g_list_copy_deep(data->appcontrol,
608 __copy_appcontrol, &ret);
610 LOGE("memory alloc failed");
611 pkgmgrinfo_basic_free_application(app_info);
612 return PMINFO_R_ERROR;
616 app_info->background_category =
617 g_list_copy_deep(data->background_category,
620 LOGE("memory alloc failed");
621 pkgmgrinfo_basic_free_application(app_info);
622 return PMINFO_R_ERROR;
626 app_info->splashscreens = g_list_copy_deep(data->splashscreens,
627 __copy_splashscreens, &ret);
629 LOGE("memory alloc failed");
630 pkgmgrinfo_basic_free_application(app_info);
631 return PMINFO_R_ERROR;
635 app_info->res_control = g_list_copy_deep(data->res_control, __copy_res_control, &ret);
637 LOGE("memory alloc failed");
638 pkgmgrinfo_basic_free_application(app_info);
639 return PMINFO_R_ERROR;
642 *application = app_info;
647 API int pkgmgrinfo_appinfo_clone_appinfo(pkgmgrinfo_appinfo_h handle,
648 pkgmgrinfo_appinfo_h *clone)
650 pkgmgr_appinfo_x *info;
651 pkgmgr_appinfo_x *temp = (pkgmgr_appinfo_x *)handle;
654 return PMINFO_R_EINVAL;
656 info = calloc(1, sizeof(pkgmgr_appinfo_x));
658 LOGE("memory alloc failed");
659 return PMINFO_R_ERROR;
662 if (temp->package != NULL)
663 info->package = strdup(temp->package);
664 if (temp->locale != NULL)
665 info->locale = strdup(temp->locale);
667 info->app_component = temp->app_component;
669 if (_appinfo_copy_appinfo(&info->app_info, temp->app_info) < 0) {
670 LOGE("appinfo copy failed");
672 free((void *)info->package);
676 return PMINFO_R_ERROR;
684 static int _appinfo_get_filtered_foreach_appinfo(uid_t uid,
685 pkgmgrinfo_filter_x *filter, int flag,
686 pkgmgrinfo_app_list_cb app_list_cb,
690 pkgmgr_appinfo_x info;
696 list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
697 __free_applications);
699 return PMINFO_R_ERROR;
701 ret = _appinfo_get_applications(uid, filter,
702 flag | PMINFO_APPINFO_GET_BASICINFO, list);
703 if (ret == PMINFO_R_ERROR) {
704 g_hash_table_destroy(list);
708 g_hash_table_iter_init(&iter, list);
709 while (g_hash_table_iter_next(&iter, NULL, &value)) {
710 app = (application_x *)value;
712 info.locale = info.app_info->locale;
713 info.package = app->package;
714 if (app_list_cb(&info, user_data) < 0)
717 g_hash_table_destroy(list);
722 static const char *__appcomponent_str(pkgmgrinfo_app_component comp);
724 API int pkgmgrinfo_appinfo_get_usr_list(pkgmgrinfo_pkginfo_h handle,
725 pkgmgrinfo_app_component component,
726 pkgmgrinfo_app_list_cb app_func, void *user_data, uid_t uid)
729 pkgmgrinfo_appinfo_filter_h filter;
731 const char *comp_str = NULL;
733 if (handle == NULL || app_func == NULL) {
734 LOGE("invalid parameter");
735 return PMINFO_R_EINVAL;
738 if (pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid)) {
739 LOGE("invalid parameter");
740 return PMINFO_R_EINVAL;
743 if (pkgmgrinfo_appinfo_filter_create(&filter))
744 return PMINFO_R_ERROR;
746 if (pkgmgrinfo_appinfo_filter_add_string(filter,
747 PMINFO_APPINFO_PROP_APP_PACKAGE, pkgid)) {
748 pkgmgrinfo_appinfo_filter_destroy(filter);
749 return PMINFO_R_ERROR;
752 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
753 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
754 pkgmgrinfo_appinfo_filter_destroy(filter);
755 return PMINFO_R_ERROR;
758 comp_str = __appcomponent_str(component);
761 if (pkgmgrinfo_appinfo_filter_add_string(filter,
762 PMINFO_APPINFO_PROP_APP_COMPONENT,
764 pkgmgrinfo_appinfo_filter_destroy(filter);
765 return PMINFO_R_ERROR;
769 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter,
770 PMINFO_APPINFO_GET_ALL, app_func, user_data);
772 pkgmgrinfo_appinfo_filter_destroy(filter);
777 API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle,
778 pkgmgrinfo_app_component component,
779 pkgmgrinfo_app_list_cb app_func, void *user_data)
781 return pkgmgrinfo_appinfo_get_usr_list(handle,
782 component, app_func, user_data, _getuid());
785 API int pkgmgrinfo_appinfo_get_usr_installed_list_full(
786 pkgmgrinfo_app_list_cb app_func, uid_t uid, int flag,
790 pkgmgrinfo_appinfo_filter_h filter;
792 if (app_func == NULL) {
793 LOGE("invalid parameter");
794 return PMINFO_R_EINVAL;
797 if (pkgmgrinfo_appinfo_filter_create(&filter))
798 return PMINFO_R_ERROR;
800 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
801 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
802 pkgmgrinfo_appinfo_filter_destroy(filter);
803 return PMINFO_R_ERROR;
806 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
807 PMINFO_APPINFO_PROP_PKG_DISABLE, false)) {
808 pkgmgrinfo_appinfo_filter_destroy(filter);
809 return PMINFO_R_ERROR;
812 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
813 PMINFO_APPINFO_PROP_APP_CHECK_STORAGE, false)) {
814 pkgmgrinfo_appinfo_filter_destroy(filter);
815 return PMINFO_R_ERROR;
818 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter, flag, app_func,
821 pkgmgrinfo_appinfo_filter_destroy(filter);
826 API int pkgmgrinfo_appinfo_get_installed_list_full(
827 pkgmgrinfo_app_list_cb app_func, int flag, void *user_data)
829 return pkgmgrinfo_appinfo_get_usr_installed_list_full(app_func,
830 _getuid(), flag, user_data);
833 API int pkgmgrinfo_appinfo_get_usr_installed_list(
834 pkgmgrinfo_app_list_cb app_func, uid_t uid, void *user_data)
837 pkgmgrinfo_appinfo_filter_h filter;
839 if (app_func == NULL) {
840 LOGE("invalid parameter");
841 return PMINFO_R_EINVAL;
844 /* create an empty filter */
845 ret = pkgmgrinfo_appinfo_filter_create(&filter);
846 if (ret != PMINFO_R_OK)
849 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
850 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
851 pkgmgrinfo_appinfo_filter_destroy(filter);
852 return PMINFO_R_ERROR;
855 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
856 PMINFO_APPINFO_PROP_PKG_DISABLE, false)) {
857 pkgmgrinfo_appinfo_filter_destroy(filter);
858 return PMINFO_R_ERROR;
861 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter,
862 PMINFO_APPINFO_GET_ALL, app_func, user_data);
864 pkgmgrinfo_appinfo_filter_destroy(filter);
869 API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func,
872 return pkgmgrinfo_appinfo_get_usr_installed_list(app_func, _getuid(),
876 API int pkgmgrinfo_appinfo_get_appid(pkgmgrinfo_appinfo_h handle, char **appid)
878 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
880 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
881 retvm_if(appid == NULL, PMINFO_R_EINVAL,
882 "Argument supplied to hold return value is NULL");
884 if (info->app_info == NULL || info->app_info->appid == NULL)
885 return PMINFO_R_ERROR;
886 *appid = (char *)info->app_info->appid;
891 API int pkgmgrinfo_appinfo_get_pkgname(
892 pkgmgrinfo_appinfo_h handle, char **pkg_name)
894 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
896 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
897 retvm_if(pkg_name == NULL, PMINFO_R_EINVAL,
898 "Argument supplied to hold return value is NULL");
900 if (info->package == NULL)
901 return PMINFO_R_ERROR;
903 *pkg_name = (char *)info->package;
908 API int pkgmgrinfo_appinfo_get_pkgid(pkgmgrinfo_appinfo_h handle, char **pkgid)
910 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
912 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
913 retvm_if(pkgid == NULL, PMINFO_R_EINVAL,
914 "Argument supplied to hold return value is NULL");
916 if (info->package == NULL)
917 return PMINFO_R_ERROR;
919 *pkgid = (char *)info->package;
924 API int pkgmgrinfo_appinfo_get_pkgtype(
925 pkgmgrinfo_appinfo_h handle, char **pkgtype)
927 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
928 retvm_if(pkgtype == NULL, PMINFO_R_EINVAL,
929 "Argument supplied to hold return value is NULL");
930 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
932 *pkgtype = (char *)info->app_info->package_type;
937 API int pkgmgrinfo_appinfo_get_exec(pkgmgrinfo_appinfo_h handle, char **exec)
939 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
941 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
942 retvm_if(exec == NULL, PMINFO_R_EINVAL,
943 "Argument supplied to hold return value is NULL");
945 if (info->app_info == NULL || info->app_info->exec == NULL)
946 return PMINFO_R_ERROR;
947 *exec = (char *)info->app_info->exec;
953 API int pkgmgrinfo_appinfo_get_icon(pkgmgrinfo_appinfo_h handle, char **icon)
956 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
958 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
959 retvm_if(icon == NULL, PMINFO_R_EINVAL,
960 "Argument supplied to hold return value is NULL");
962 if (info->app_info == NULL)
963 return PMINFO_R_ERROR;
965 if (info->app_info->icon == NULL) {
970 ptr = (icon_x *)info->app_info->icon->data;
972 return PMINFO_R_ERROR;
974 if (ptr->text == NULL)
975 return PMINFO_R_ERROR;
983 API int pkgmgrinfo_appinfo_get_label(pkgmgrinfo_appinfo_h handle, char **label)
986 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
991 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
992 retvm_if(label == NULL, PMINFO_R_EINVAL,
993 "Argument supplied to hold return value is NULL");
995 if (info->app_info == NULL)
996 return PMINFO_R_ERROR;
998 locale = info->locale;
1000 locale = DEFAULT_LOCALE;
1002 for (tmp = info->app_info->label; tmp; tmp = tmp->next) {
1003 ptr = (label_x *)tmp->data;
1004 if (ptr == NULL || strcmp(locale, ptr->lang) != 0)
1015 for (tmp = info->app_info->label; tmp; tmp = tmp->next) {
1016 ptr = (label_x *)tmp->data;
1017 if (ptr == NULL || strcmp(DEFAULT_LOCALE, ptr->lang) != 0)
1023 *label = lbl ? lbl : "";
1028 API int pkgmgrinfo_appinfo_usr_get_localed_label(const char *appid,
1029 const char *locale, uid_t uid, char **label)
1033 retvm_if(appid == NULL || locale == NULL || label == NULL,
1034 PMINFO_R_EINVAL, "Argument is NULL");
1035 val = _appinfo_get_localed_label(appid, locale, uid);
1037 return PMINFO_R_ERROR;
1043 API int pkgmgrinfo_appinfo_get_localed_label(
1044 const char *appid, const char *locale, char **label)
1046 return pkgmgrinfo_appinfo_usr_get_localed_label(
1047 appid, locale, _getuid(), label);
1050 API int pkgmgrinfo_appinfo_get_metadata_value(
1051 pkgmgrinfo_appinfo_h handle, const char *metadata_key,
1052 char **metadata_value)
1054 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1055 retvm_if(metadata_key == NULL, PMINFO_R_EINVAL, "metadata_key is NULL");
1056 retvm_if(metadata_value == NULL, PMINFO_R_EINVAL,
1057 "metadata_value is NULL");
1059 GList *list_md = NULL;
1060 metadata_x *metadata = NULL;
1061 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1063 list_md = info->app_info->metadata;
1065 for (; list_md; list_md = list_md->next) {
1066 metadata = (metadata_x *)list_md->data;
1067 if (metadata && metadata->key) {
1068 if (strcasecmp(metadata->key, metadata_key) == 0) {
1069 if (metadata->value == NULL)
1070 *metadata_value = "";
1073 (char *)metadata->value;
1079 return PMINFO_R_EINVAL;
1082 static pkgmgrinfo_app_component __appcomponent_convert(const char *comp)
1084 if (strcasecmp(comp, "uiapp") == 0)
1085 return PMINFO_UI_APP;
1086 else if (strcasecmp(comp, "svcapp") == 0)
1087 return PMINFO_SVC_APP;
1088 else if (strcasecmp(comp, "widgetapp") == 0)
1089 return PMINFO_WIDGET_APP;
1090 else if (strcasecmp(comp, "watchapp") == 0)
1091 return PMINFO_WATCH_APP;
1092 else if (strcasecmp(comp, "componentbasedapp") == 0)
1093 return PMINFO_COMPONENT_BASED_APP;
1098 static const char *__appcomponent_str(pkgmgrinfo_app_component comp)
1103 case PMINFO_SVC_APP:
1105 case PMINFO_WIDGET_APP:
1107 case PMINFO_WATCH_APP:
1109 case PMINFO_COMPONENT_BASED_APP:
1110 return "componentbasedapp";
1116 API int pkgmgrinfo_appinfo_get_component(
1117 pkgmgrinfo_appinfo_h handle,
1118 pkgmgrinfo_app_component *component)
1120 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1123 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1124 retvm_if(component == NULL, PMINFO_R_EINVAL,
1125 "Argument supplied to hold return value is NULL");
1127 if (info->app_info == NULL)
1128 return PMINFO_R_ERROR;
1130 comp = __appcomponent_convert(info->app_info->component);
1132 return PMINFO_R_ERROR;
1139 API int pkgmgrinfo_appinfo_get_apptype(
1140 pkgmgrinfo_appinfo_h handle, char **app_type)
1142 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1144 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1145 retvm_if(app_type == NULL, PMINFO_R_EINVAL,
1146 "Argument supplied to hold return value is NULL");
1148 if (info->app_info == NULL || info->app_info->type == NULL)
1149 return PMINFO_R_ERROR;
1150 *app_type = (char *)info->app_info->type;
1155 API int pkgmgrinfo_appinfo_get_notification_icon(
1156 pkgmgrinfo_appinfo_h handle, char **icon)
1161 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1163 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1164 retvm_if(icon == NULL, PMINFO_R_EINVAL,
1165 "Argument supplied to hold return value is NULL\n");
1167 if (info->app_info == NULL)
1168 return PMINFO_R_ERROR;
1170 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1171 ptr = (icon_x *)tmp->data;
1172 if (ptr == NULL || ptr->section == NULL)
1175 val = (char *)ptr->section;
1176 if (val && strcmp(val, "notification") == 0) {
1177 *icon = (char *)ptr->text;
1182 return PMINFO_R_ERROR;
1185 API int pkgmgrinfo_appinfo_get_recent_image_type(
1186 pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_recentimage *type)
1189 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1191 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1192 retvm_if(type == NULL, PMINFO_R_EINVAL,
1193 "Argument supplied to hold return value is NULL");
1195 if (info->app_info == NULL || info->app_info->recentimage == NULL)
1196 return PMINFO_R_ERROR;
1198 val = (char *)info->app_info->recentimage;
1199 if (strcasecmp(val, "capture") == 0)
1200 *type = PMINFO_RECENTIMAGE_USE_CAPTURE;
1201 else if (strcasecmp(val, "icon") == 0)
1202 *type = PMINFO_RECENTIMAGE_USE_ICON;
1204 *type = PMINFO_RECENTIMAGE_USE_NOTHING;
1209 API int pkgmgrinfo_appinfo_get_preview_image(
1210 pkgmgrinfo_appinfo_h handle, char **preview_img)
1215 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1217 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1218 retvm_if(preview_img == NULL, PMINFO_R_EINVAL,
1219 "Argument supplied to hold return value is NULL\n");
1221 if (info->app_info == NULL)
1222 return PMINFO_R_ERROR;
1224 for (tmp = info->app_info->image; tmp; tmp = tmp->next) {
1225 ptr = (image_x *)tmp->data;
1226 if (ptr == NULL || ptr->section == NULL)
1229 val = (char *)ptr->section;
1230 if (val && strcmp(val, "preview") == 0) {
1231 *preview_img = (char *)ptr->text;
1236 return PMINFO_R_ERROR;
1239 API int pkgmgrinfo_appinfo_get_permission_type(
1240 pkgmgrinfo_appinfo_h handle,
1241 pkgmgrinfo_permission_type *permission)
1244 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1246 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1247 retvm_if(permission == NULL, PMINFO_R_EINVAL,
1248 "Argument supplied to hold return value is NULL\n");
1250 val = info->app_info->permission_type;
1252 return PMINFO_R_ERROR;
1254 if (strcmp(val, "signature") == 0)
1255 *permission = PMINFO_PERMISSION_SIGNATURE;
1256 else if (strcmp(val, "privilege") == 0)
1257 *permission = PMINFO_PERMISSION_PRIVILEGE;
1259 *permission = PMINFO_PERMISSION_NORMAL;
1264 API int pkgmgrinfo_appinfo_get_component_type(
1265 pkgmgrinfo_appinfo_h handle, char **component_type)
1267 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1269 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1270 retvm_if(component_type == NULL, PMINFO_R_EINVAL,
1271 "Argument supplied to hold return value is NULL");
1273 if (info->app_info == NULL || info->app_info->component_type == NULL)
1274 return PMINFO_R_ERROR;
1276 *component_type = (char *)info->app_info->component_type;
1281 API int pkgmgrinfo_appinfo_get_hwacceleration(
1282 pkgmgrinfo_appinfo_h handle,
1283 pkgmgrinfo_app_hwacceleration *hwacceleration)
1286 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1288 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1289 retvm_if(hwacceleration == NULL, PMINFO_R_EINVAL,
1290 "Argument supplied to hold return value is NULL");
1292 if (info->app_info == NULL || info->app_info->hwacceleration == NULL)
1293 return PMINFO_R_ERROR;
1295 val = (char *)info->app_info->hwacceleration;
1296 if (strcasecmp(val, "off") == 0)
1297 *hwacceleration = PMINFO_HWACCELERATION_OFF;
1298 else if (strcasecmp(val, "on") == 0)
1299 *hwacceleration = PMINFO_HWACCELERATION_ON;
1301 *hwacceleration = PMINFO_HWACCELERATION_DEFAULT;
1306 API int pkgmgrinfo_appinfo_get_screenreader(
1307 pkgmgrinfo_appinfo_h handle,
1308 pkgmgrinfo_app_screenreader *screenreader)
1311 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1313 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1314 retvm_if(screenreader == NULL, PMINFO_R_EINVAL,
1315 "Argument supplied to hold return value is NULL");
1317 if (info->app_info == NULL || info->app_info->screenreader == NULL)
1318 return PMINFO_R_ERROR;
1320 val = (char *)info->app_info->screenreader;
1321 if (strcasecmp(val, "screenreader-off") == 0)
1322 *screenreader = PMINFO_SCREENREADER_OFF;
1323 else if (strcasecmp(val, "screenreader-on") == 0)
1324 *screenreader = PMINFO_SCREENREADER_ON;
1326 *screenreader = PMINFO_SCREENREADER_USE_SYSTEM_SETTING;
1331 API int pkgmgrinfo_appinfo_get_effectimage(
1332 pkgmgrinfo_appinfo_h handle, char **portrait_img,
1333 char **landscape_img)
1335 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1337 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1338 retvm_if(portrait_img == NULL, PMINFO_R_EINVAL,
1339 "Argument supplied to hold return value is NULL");
1340 retvm_if(landscape_img == NULL, PMINFO_R_EINVAL,
1341 "Argument supplied to hold return value is NULL");
1343 if (info->app_info == NULL)
1344 return PMINFO_R_ERROR;
1346 if (info->app_info->portraitimg == NULL)
1349 *portrait_img = (char *)info->app_info->portraitimg;
1351 if (info->app_info->landscapeimg == NULL)
1352 *landscape_img = "";
1354 *landscape_img = (char *)info->app_info->landscapeimg;
1359 API int pkgmgrinfo_appinfo_get_effectimage_type(
1360 pkgmgrinfo_appinfo_h handle, char **effectimage_type)
1362 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1364 if (handle == NULL || effectimage_type == NULL) {
1365 LOGE("invalid parameter");
1366 return PMINFO_R_EINVAL;
1369 if (info->app_info == NULL || info->app_info->effectimage_type == NULL)
1370 return PMINFO_R_ERROR;
1372 *effectimage_type = (char *)info->app_info->effectimage_type;
1377 API int pkgmgrinfo_appinfo_get_submode_mainid(
1378 pkgmgrinfo_appinfo_h handle, char **submode_mainid)
1380 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1382 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1383 retvm_if(submode_mainid == NULL, PMINFO_R_EINVAL,
1384 "Argument supplied to hold return value is NULL");
1386 if (info->app_info == NULL)
1387 return PMINFO_R_ERROR;
1389 if (info->app_info->submode_mainid == NULL)
1390 *submode_mainid = "";
1392 *submode_mainid = (char *)info->app_info->submode_mainid;
1397 API int pkgmgrinfo_appinfo_get_installed_storage_location(
1398 pkgmgrinfo_appinfo_h handle,
1399 pkgmgrinfo_installed_storage *storage)
1401 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1402 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1404 if (info->app_info && info->app_info->installed_storage) {
1405 if (strcmp(info->app_info->installed_storage,
1406 "installed_internal") == 0)
1407 *storage = PMINFO_INTERNAL_STORAGE;
1408 else if (strcmp(info->app_info->installed_storage,
1409 "installed_external") == 0)
1410 *storage = PMINFO_EXTERNAL_STORAGE;
1412 return PMINFO_R_ERROR;
1414 return PMINFO_R_ERROR;
1420 API int pkgmgrinfo_appinfo_get_launch_mode(
1421 pkgmgrinfo_appinfo_h handle, char **mode)
1423 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1425 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1426 retvm_if(mode == NULL, PMINFO_R_EINVAL,
1427 "Argument supplied to hold return value is NULL\n");
1429 if (info->app_info->launch_mode == NULL)
1430 return PMINFO_R_ERROR;
1432 *mode = (char *)(info->app_info->launch_mode);
1437 API int pkgmgrinfo_appinfo_get_alias_appid(
1438 pkgmgrinfo_appinfo_h handle, char **alias_appid)
1440 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1442 if (handle == NULL || alias_appid == NULL) {
1443 LOGE("invalid parameter");
1444 return PMINFO_R_EINVAL;
1447 if (info->app_info == NULL || info->app_info->alias_appid == NULL)
1448 return PMINFO_R_ERROR;
1450 *alias_appid = (char *)info->app_info->alias_appid;
1455 API int pkgmgrinfo_appinfo_get_effective_appid(
1456 pkgmgrinfo_appinfo_h handle, char **effective_appid)
1458 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1460 if (handle == NULL || effective_appid == NULL) {
1461 LOGE("invalid parameter");
1462 return PMINFO_R_EINVAL;
1465 if (info->app_info == NULL)
1466 return PMINFO_R_ERROR;
1468 if (info->app_info->effective_appid == NULL)
1469 *effective_appid = "";
1471 *effective_appid = (char *)info->app_info->effective_appid;
1476 API int pkgmgrinfo_appinfo_get_tep_name(
1477 pkgmgrinfo_appinfo_h handle, char **tep_name)
1479 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1481 if (handle == NULL || tep_name == NULL) {
1482 LOGE("invalid parameter");
1483 return PMINFO_R_EINVAL;
1486 if (info->app_info == NULL)
1487 return PMINFO_R_ERROR;
1489 if (info->app_info->tep_name == NULL)
1492 *tep_name = (char *)info->app_info->tep_name;
1497 API int pkgmgrinfo_appinfo_get_zip_mount_file(
1498 pkgmgrinfo_appinfo_h handle, char **zip_mount_file)
1500 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1502 if (handle == NULL || zip_mount_file == NULL) {
1503 LOGE("invalid parameter");
1504 return PMINFO_R_EINVAL;
1507 if (info->app_info == NULL)
1508 return PMINFO_R_ERROR;
1510 if (info->app_info->zip_mount_file == NULL)
1511 *zip_mount_file = "";
1513 *zip_mount_file = (char *)info->app_info->zip_mount_file;
1518 API int pkgmgrinfo_appinfo_get_root_path(
1519 pkgmgrinfo_appinfo_h handle, char **root_path)
1521 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1523 if (handle == NULL || root_path == NULL) {
1524 LOGE("invalid parameter");
1525 return PMINFO_R_EINVAL;
1528 if (info->app_info == NULL || info->app_info->root_path == NULL)
1529 return PMINFO_R_ERROR;
1531 *root_path = (char *)info->app_info->root_path;
1536 API int pkgmgrinfo_appinfo_get_api_version(
1537 pkgmgrinfo_appinfo_h handle, char **api_version)
1539 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1541 if (handle == NULL || api_version == NULL) {
1542 LOGE("invalid parameter");
1543 return PMINFO_R_EINVAL;
1546 if (info->app_info == NULL || info->app_info->api_version == NULL)
1547 return PMINFO_R_ERROR;
1549 *api_version = (char *)info->app_info->api_version;
1554 API int pkgmgrinfo_appinfo_get_installed_time(
1555 pkgmgrinfo_appinfo_h handle, int *installed_time)
1557 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1559 if (handle == NULL || installed_time == NULL) {
1560 LOGE("invalid parameter");
1561 return PMINFO_R_EINVAL;
1564 if (info->app_info == NULL ||
1565 info->app_info->package_installed_time == NULL)
1566 return PMINFO_R_ERROR;
1568 *installed_time = atoi(info->app_info->package_installed_time);
1573 API int pkgmgrinfo_appinfo_usr_get_datacontrol_info(const char *providerid,
1574 const char *type, uid_t uid, char **appid, char **access)
1578 if (providerid == NULL || type == NULL || appid == NULL ||
1580 LOGE("invalid parameter");
1581 return PMINFO_R_EINVAL;
1584 ret = _appinfo_get_datacontrol_info(
1585 providerid, type, uid, appid, access);
1586 /* FIXME: It should return PMINFO_R_ENOENT but to keep previous
1587 * implementation, return PMINFO_R_ERROR. This should be
1590 if (ret == PMINFO_R_ENOENT) {
1591 LOGE("no datacontrol info of %s", providerid);
1592 ret = PMINFO_R_ERROR;
1598 API int pkgmgrinfo_appinfo_get_datacontrol_info(const char *providerid,
1599 const char *type, char **appid, char **access)
1601 return pkgmgrinfo_appinfo_usr_get_datacontrol_info(providerid,
1602 type, _getuid(), appid, access);
1605 API int pkgmgrinfo_appinfo_usr_get_datacontrol_appid(const char *providerid,
1606 uid_t uid, char **appid)
1610 if (providerid == NULL || appid == NULL) {
1611 LOGE("invalid parameter");
1612 return PMINFO_R_EINVAL;
1615 ret = _appinfo_get_datacontrol_appid(providerid, uid, appid);
1616 /* FIXME: It should return PMINFO_R_ENOENT but to keep previous
1617 * implementation, return PMINFO_R_ERROR. This should be
1620 if (ret == PMINFO_R_ENOENT) {
1621 LOGE("no datacontrol appid of %s", providerid);
1622 ret = PMINFO_R_ERROR;
1628 API int pkgmgrinfo_appinfo_get_datacontrol_appid(
1629 const char *providerid, char **appid)
1631 return pkgmgrinfo_appinfo_usr_get_datacontrol_appid(
1632 providerid, _getuid(), appid);
1635 API int pkgmgrinfo_appinfo_usr_get_datacontrol_trusted_info(
1636 const char *providerid, const char *type, uid_t uid,
1637 char **appid, bool *is_trusted)
1640 char *trusted = NULL;
1642 if (providerid == NULL || type == NULL || appid == NULL ||
1643 is_trusted == NULL) {
1644 LOGE("invalid parameter");
1645 return PMINFO_R_EINVAL;
1648 ret = _appinfo_get_datacontrol_trusted_info(providerid, type, uid,
1651 /* FIXME: It should return PMINFO_R_ENOENT but to keep previous
1652 * implementation, return PMINFO_R_ERROR. This should be
1655 if (ret == PMINFO_R_ENOENT) {
1656 LOGE("no datacontrol trusted info of %s", providerid);
1657 ret = PMINFO_R_ERROR;
1659 *is_trusted = _get_bool_value(trusted);
1665 API int pkgmgrinfo_appinfo_get_datacontrol_trsuted_info(const char *providerid,
1666 const char *type, char **appid, bool *is_trusted)
1668 return pkgmgrinfo_appinfo_usr_get_datacontrol_trusted_info(providerid,
1669 type, _getuid(), appid, is_trusted);
1672 API int pkgmgrinfo_appinfo_usr_foreach_datacontrol_privileges(
1673 const char *providerid, const char *type,
1674 pkgmgrinfo_pkg_privilege_list_cb privilege_func,
1675 void *user_data, uid_t uid)
1682 if (providerid == NULL || type == NULL || privilege_func == NULL) {
1683 LOGE("invalid parameter");
1684 return PMINFO_R_EINVAL;
1687 ret = _appinfo_get_datacontrol_privileges(providerid, type, uid, &list);
1688 if (ret == PMINFO_R_ERROR) {
1689 g_list_free_full(list, free);
1693 for (tmp = list; tmp != NULL; tmp = g_list_next(tmp)) {
1695 ret = privilege_func((char *)tmp->data, user_data);
1700 g_list_free_full(list, free);
1704 API int pkgmgrinfo_appinfo_foreach_datacontrol_privileges(
1705 const char *providerid, const char *type,
1706 pkgmgrinfo_pkg_privilege_list_cb privilege_func,
1709 return pkgmgrinfo_appinfo_usr_foreach_datacontrol_privileges(
1710 providerid, type, privilege_func, user_data, _getuid());
1713 API int pkgmgrinfo_appinfo_get_support_mode(
1714 pkgmgrinfo_appinfo_h handle, int *support_mode)
1716 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1717 retvm_if(support_mode == NULL, PMINFO_R_EINVAL,
1718 "Argument supplied to hold return value is NULL");
1720 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1722 if (info->app_info->support_mode)
1723 *support_mode = atoi(info->app_info->support_mode);
1730 API int pkgmgrinfo_appinfo_foreach_category(pkgmgrinfo_appinfo_h handle,
1731 pkgmgrinfo_app_category_list_cb category_func, void *user_data)
1733 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1734 retvm_if(category_func == NULL, PMINFO_R_EINVAL,
1735 "Callback function is NULL");
1737 const char *category;
1739 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1741 if (info->app_info == NULL)
1742 return PMINFO_R_ERROR;
1744 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
1745 category = (const char *)tmp->data;
1747 ret = category_func(category, user_data);
1755 API int pkgmgrinfo_appinfo_foreach_metadata(pkgmgrinfo_appinfo_h handle,
1756 pkgmgrinfo_app_metadata_list_cb metadata_func, void *user_data)
1758 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1759 retvm_if(metadata_func == NULL, PMINFO_R_EINVAL,
1760 "Callback function is NULL");
1764 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1766 if (info->app_info == NULL)
1767 return PMINFO_R_ERROR;
1769 for (tmp = info->app_info->metadata; tmp; tmp = tmp->next) {
1770 ptr = (metadata_x *)tmp->data;
1774 ret = metadata_func(ptr->key, ptr->value ?
1775 ptr->value : "", user_data);
1783 API int pkgmgrinfo_appinfo_usr_foreach_appcontrol_privileges(const char *appid,
1784 const char *operation,
1785 pkgmgrinfo_pkg_privilege_list_cb privilege_func,
1786 void *user_data, uid_t uid)
1789 GList *privilege_list = NULL;
1792 if (appid == NULL || operation == NULL || privilege_func == NULL) {
1793 LOGE("invalid parameter");
1794 return PMINFO_R_EINVAL;
1797 ret = _appinfo_get_appcontrol_privileges(appid, operation, uid,
1799 if (ret == PMINFO_R_ENOENT) {
1801 } else if (ret != PMINFO_R_OK) {
1802 g_list_free_full(privilege_list, free);
1806 for (tmp_list = privilege_list; tmp_list != NULL;
1807 tmp_list = g_list_next(tmp_list)) {
1808 ret = privilege_func((char *)tmp_list->data, user_data);
1813 g_list_free_full(privilege_list, free);
1817 API int pkgmgrinfo_appinfo_foreach_appcontrol_privileges(const char *appid,
1818 const char *operation,
1819 pkgmgrinfo_pkg_privilege_list_cb privilege_func,
1822 return pkgmgrinfo_appinfo_usr_foreach_appcontrol_privileges(appid,
1823 operation, privilege_func, user_data, _getuid());
1826 API int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
1827 pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
1829 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1830 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL,
1831 "Callback function is NULL");
1833 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1834 appcontrol_x *appcontrol;
1837 if (info->app_info == NULL)
1838 return PMINFO_R_ERROR;
1840 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
1841 appcontrol = (appcontrol_x *)tmp->data;
1842 if (appcontrol == NULL || !strcasecmp(
1843 appcontrol->visibility, "remote-only"))
1845 ret = appcontrol_func(appcontrol->operation,
1846 appcontrol->uri, appcontrol->mime, user_data);
1854 API int pkgmgrinfo_appinfo_foreach_remote_appcontrol(
1855 pkgmgrinfo_appinfo_h handle,
1856 pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
1858 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1859 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL,
1860 "Callback function is NULL");
1862 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1863 appcontrol_x *appcontrol;
1866 if (info->app_info == NULL)
1867 return PMINFO_R_ERROR;
1869 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
1870 appcontrol = (appcontrol_x *)tmp->data;
1871 if (appcontrol == NULL || !strcasecmp(
1872 appcontrol->visibility, "local-only"))
1874 ret = appcontrol_func(appcontrol->operation, appcontrol->uri,
1875 appcontrol->mime, user_data);
1883 API int pkgmgrinfo_appinfo_foreach_background_category(
1884 pkgmgrinfo_appinfo_h handle,
1885 pkgmgrinfo_app_background_category_list_cb category_func,
1888 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1892 if (handle == NULL || category_func == NULL || info->app_info == NULL) {
1893 LOGE("invalid parameter");
1894 return PMINFO_R_EINVAL;
1897 for (tmp = info->app_info->background_category; tmp; tmp = tmp->next) {
1898 category = (char *)tmp->data;
1899 if (category == NULL)
1902 if (category_func(category, user_data) < 0)
1909 API int pkgmgrinfo_appinfo_foreach_splash_screen(pkgmgrinfo_appinfo_h handle,
1910 pkgmgrinfo_app_splash_screen_list_cb splash_screen_func,
1913 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1914 splashscreen_x *splashscreen;
1918 if (info == NULL || info->app_info == NULL
1919 || splash_screen_func == NULL) {
1920 LOGE("invalid parameter");
1921 return PMINFO_R_EINVAL;
1924 for (tmp = info->app_info->splashscreens; tmp; tmp = tmp->next) {
1925 splashscreen = (splashscreen_x *)tmp->data;
1926 if (splashscreen == NULL)
1928 ret = splash_screen_func(splashscreen->src,
1930 splashscreen->orientation,
1931 splashscreen->indicatordisplay,
1932 splashscreen->operation,
1933 splashscreen->color_depth,
1942 API int pkgmgrinfo_appinfo_foreach_res_control(pkgmgrinfo_appinfo_h handle,
1943 pkgmgrinfo_app_res_control_list_cb res_control_func,
1946 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1947 retvm_if(res_control_func == NULL, PMINFO_R_EINVAL,
1948 "Callback function is NULL");
1950 res_control_x *res_control;
1952 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1954 if (info->app_info == NULL)
1955 return PMINFO_R_ERROR;
1957 for (tmp = info->app_info->res_control; tmp; tmp = tmp->next) {
1958 res_control = (res_control_x *)tmp->data;
1959 if (res_control == NULL)
1961 ret = res_control_func(res_control->res_type,
1962 res_control->min_res_version,
1963 res_control->max_res_version,
1964 res_control->auto_close,
1972 API int pkgmgrinfo_appinfo_is_nodisplay(
1973 pkgmgrinfo_appinfo_h handle, bool *nodisplay)
1975 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1976 retvm_if(nodisplay == NULL, PMINFO_R_EINVAL,
1977 "Argument supplied to hold return value is NULL");
1978 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1980 if (info->app_info == NULL || info->app_info->nodisplay == NULL)
1981 return PMINFO_R_ERROR;
1983 *nodisplay = _get_bool_value(info->app_info->nodisplay);
1988 API int pkgmgrinfo_appinfo_is_multiple(
1989 pkgmgrinfo_appinfo_h handle, bool *multiple)
1991 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1992 retvm_if(multiple == NULL, PMINFO_R_EINVAL,
1993 "Argument supplied to hold return value is NULL");
1994 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1996 if (info->app_info == NULL || info->app_info->multiple == NULL)
1997 return PMINFO_R_ERROR;
1999 *multiple = _get_bool_value(info->app_info->multiple);
2004 API int pkgmgrinfo_appinfo_is_indicator_display_allowed(
2005 pkgmgrinfo_appinfo_h handle, bool *indicator_disp)
2007 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2008 retvm_if(indicator_disp == NULL, PMINFO_R_EINVAL,
2009 "Argument supplied to hold return value is NULL");
2010 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2012 if (info->app_info == NULL || info->app_info->indicatordisplay == NULL)
2013 return PMINFO_R_ERROR;
2015 *indicator_disp = _get_bool_value(info->app_info->indicatordisplay);
2020 API int pkgmgrinfo_appinfo_is_taskmanage(
2021 pkgmgrinfo_appinfo_h handle, bool *taskmanage)
2023 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2024 retvm_if(taskmanage == NULL, PMINFO_R_EINVAL,
2025 "Argument supplied to hold return value is NULL");
2026 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2028 if (info->app_info == NULL || info->app_info->taskmanage == NULL)
2029 return PMINFO_R_ERROR;
2031 *taskmanage = _get_bool_value(info->app_info->taskmanage);
2036 API int pkgmgrinfo_appinfo_is_enabled(
2037 pkgmgrinfo_appinfo_h handle, bool *enabled)
2039 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2040 retvm_if(enabled == NULL, PMINFO_R_EINVAL,
2041 "Argument supplied to hold return value is NULL");
2042 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2044 if (info->app_info == NULL || info->app_info->is_disabled == NULL)
2045 return PMINFO_R_ERROR;
2047 *enabled = !_get_bool_value(info->app_info->is_disabled);
2052 API int pkgmgrinfo_appinfo_is_onboot(
2053 pkgmgrinfo_appinfo_h handle, bool *onboot)
2055 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2056 retvm_if(onboot == NULL, PMINFO_R_EINVAL,
2057 "Argument supplied to hold return value is NULL");
2058 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2060 if (info->app_info == NULL || info->app_info->onboot == NULL)
2061 return PMINFO_R_ERROR;
2063 *onboot = _get_bool_value(info->app_info->onboot);
2068 API int pkgmgrinfo_appinfo_is_autorestart(
2069 pkgmgrinfo_appinfo_h handle, bool *autorestart)
2071 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2072 retvm_if(autorestart == NULL, PMINFO_R_EINVAL,
2073 "Argument supplied to hold return value is NULL");
2074 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2076 if (info->app_info == NULL || info->app_info->autorestart == NULL)
2077 return PMINFO_R_ERROR;
2079 *autorestart = _get_bool_value(info->app_info->autorestart);
2084 API int pkgmgrinfo_appinfo_is_mainapp(
2085 pkgmgrinfo_appinfo_h handle, bool *mainapp)
2087 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2088 retvm_if(mainapp == NULL, PMINFO_R_EINVAL,
2089 "Argument supplied to hold return value is NULL");
2090 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2092 if (info->app_info == NULL || info->app_info->mainapp == NULL)
2093 return PMINFO_R_ERROR;
2095 *mainapp = _get_bool_value(info->app_info->mainapp);
2100 API int pkgmgrinfo_appinfo_is_preload(
2101 pkgmgrinfo_appinfo_h handle, bool *preload)
2103 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2104 retvm_if(preload == NULL, PMINFO_R_EINVAL,
2105 "Argument supplied to hold return value is NULL\n");
2106 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2108 if (info->app_info == NULL || info->app_info->preload == NULL)
2109 return PMINFO_R_ERROR;
2111 *preload = _get_bool_value(info->app_info->preload);
2116 API int pkgmgrinfo_appinfo_is_submode(
2117 pkgmgrinfo_appinfo_h handle, bool *submode)
2119 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2120 retvm_if(submode == NULL, PMINFO_R_EINVAL,
2121 "Argument supplied to hold return value is NULL\n");
2122 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2124 if (info->app_info == NULL || info->app_info->submode == NULL)
2125 return PMINFO_R_ERROR;
2127 *submode = _get_bool_value(info->app_info->submode);
2132 API int pkgmgrinfo_appinfo_is_process_pool(
2133 pkgmgrinfo_appinfo_h handle, bool *process_pool)
2135 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2137 if (handle == NULL || process_pool == NULL) {
2138 LOGE("invalid parameter");
2139 return PMINFO_R_EINVAL;
2142 if (info->app_info == NULL)
2143 return PMINFO_R_ERROR;
2145 *process_pool = _get_bool_value(info->app_info->process_pool);
2150 API int pkgmgrinfo_appinfo_is_category_exist(
2151 pkgmgrinfo_appinfo_h handle, const char *category, bool *exist)
2153 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2154 retvm_if(category == NULL, PMINFO_R_EINVAL, "category is NULL");
2155 retvm_if(exist == NULL, PMINFO_R_EINVAL, "exist is NULL");
2159 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2161 if (info->app_info == NULL)
2162 return PMINFO_R_ERROR;
2165 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
2166 val = (const char *)tmp->data;
2169 if (strcasecmp(val, category) == 0) {
2178 API int pkgmgrinfo_appinfo_is_ui_gadget(pkgmgrinfo_appinfo_h handle,
2181 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2183 if (info == NULL || info->app_info == NULL || ui_gadget == NULL) {
2184 _LOGE("invalid parameter");
2185 return PMINFO_R_EINVAL;
2187 if (info->app_info->ui_gadget == NULL)
2188 info->app_info->ui_gadget = strdup("false");
2190 *ui_gadget = _get_bool_value(info->app_info->ui_gadget);
2195 API int pkgmgrinfo_appinfo_is_support_disable(pkgmgrinfo_appinfo_h handle,
2196 bool *support_disable)
2198 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2200 if (info == NULL || info->app_info == NULL || support_disable == NULL) {
2201 _LOGE("invalid parameter");
2202 return PMINFO_R_EINVAL;
2205 *support_disable = _get_bool_value(info->app_info->support_disable);
2210 API int pkgmgrinfo_appinfo_is_removable(pkgmgrinfo_appinfo_h handle,
2213 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2215 if (info == NULL || info->app_info == NULL || removable == NULL) {
2216 _LOGE("invalid parameter");
2217 return PMINFO_R_EINVAL;
2220 *removable = _get_bool_value(info->app_info->removable);
2225 API int pkgmgrinfo_appinfo_is_system(pkgmgrinfo_appinfo_h handle, bool *system)
2227 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2229 if (info == NULL || info->app_info == NULL || system == NULL) {
2230 _LOGE("invalid parameter");
2231 return PMINFO_R_EINVAL;
2234 *system = _get_bool_value(info->app_info->package_system);
2239 API int pkgmgrinfo_appinfo_is_disabled(
2240 pkgmgrinfo_appinfo_h handle, bool *disabled)
2242 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2243 retvm_if(disabled == NULL, PMINFO_R_EINVAL,
2244 "Argument supplied to hold return value is NULL");
2245 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2247 if (info->app_info == NULL || info->app_info->is_disabled == NULL)
2248 return PMINFO_R_ERROR;
2250 *disabled = _get_bool_value(info->app_info->is_disabled);
2255 API int pkgmgrinfo_appinfo_is_global(pkgmgrinfo_appinfo_h handle, bool *global)
2257 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2259 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2260 retvm_if(global == NULL, PMINFO_R_EINVAL,
2261 "Argument supplied to hold return value is NULL\n");
2263 if (info->app_info == NULL || info->app_info->for_all_users == NULL)
2264 return PMINFO_R_ERROR;
2266 *global = _get_bool_value(info->app_info->for_all_users);
2271 API int pkgmgrinfo_appinfo_get_splash_screen_display(
2272 pkgmgrinfo_appinfo_h handle, bool *splash_screen_display)
2274 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2276 if (info == NULL || splash_screen_display == NULL) {
2277 _LOGE("Invalid parameter");
2278 return PMINFO_R_EINVAL;
2281 if (info->app_info == NULL ||
2282 info->app_info->splash_screen_display == NULL)
2283 return PMINFO_R_ERROR;
2285 *splash_screen_display =
2286 _get_bool_value(info->app_info->splash_screen_display);
2291 API int pkgmgrinfo_appinfo_get_setup_appid(
2292 pkgmgrinfo_appinfo_h handle, char **setup_appid)
2294 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2296 if (info == NULL || setup_appid == NULL) {
2297 _LOGE("Invalid parameter");
2298 return PMINFO_R_EINVAL;
2301 if (info->app_info == NULL || info->app_info->setup_appid == NULL)
2302 return PMINFO_R_ERROR;
2304 *setup_appid = info->app_info->setup_appid;
2308 API int pkgmgrinfo_appinfo_is_support_ambient(pkgmgrinfo_appinfo_h handle,
2309 bool *support_ambient)
2311 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2313 if (info == NULL || support_ambient == NULL) {
2314 _LOGE("Invalid parameter");
2315 return PMINFO_R_EINVAL;
2318 if (info->app_info == NULL || info->app_info->support_ambient == NULL)
2319 return PMINFO_R_ERROR;
2321 *support_ambient = _get_bool_value(info->app_info->support_ambient);
2326 API int pkgmgrinfo_appinfo_get_light_user_switch_mode(
2327 pkgmgrinfo_appinfo_h handle, char **mode)
2329 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2331 if (info == NULL || mode == NULL) {
2332 _LOGE("Invalid parameter");
2333 return PMINFO_R_EINVAL;
2336 if (info->app_info == NULL || info->app_info->light_user_switch_mode == NULL)
2337 return PMINFO_R_ERROR;
2339 *mode = info->app_info->light_user_switch_mode;
2344 API int pkgmgrinfo_appinfo_destroy_appinfo(pkgmgrinfo_appinfo_h handle)
2346 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2347 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2349 __cleanup_appinfo(info);
2353 API int pkgmgrinfo_appinfo_filter_create(pkgmgrinfo_appinfo_filter_h *handle)
2355 return pkgmgrinfo_pkginfo_filter_create(handle);
2358 API int pkgmgrinfo_appinfo_filter_destroy(pkgmgrinfo_appinfo_filter_h handle)
2360 return pkgmgrinfo_pkginfo_filter_destroy(handle);
2363 static gint __compare_func(gconstpointer data1, gconstpointer data2)
2365 pkgmgrinfo_node_x *node1 = (pkgmgrinfo_node_x *)data1;
2366 pkgmgrinfo_node_x *node2 = (pkgmgrinfo_node_x *)data2;
2368 if (node1->prop == node2->prop)
2370 else if (node1->prop > node2->prop)
2376 API int pkgmgrinfo_appinfo_filter_add_int(pkgmgrinfo_appinfo_filter_h handle,
2377 const char *property, const int value)
2379 retvm_if(handle == NULL, PMINFO_R_EINVAL,
2380 "Filter handle input parameter is NULL\n");
2381 retvm_if(property == NULL, PMINFO_R_EINVAL,
2382 "Filter handle input parameter is NULL\n");
2383 char buf[PKG_VALUE_STRING_LEN_MAX] = {'\0'};
2385 GSList *link = NULL;
2388 prop = _pminfo_appinfo_convert_to_prop_int(property);
2389 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_INT ||
2390 prop > E_PMINFO_APPINFO_PROP_APP_MAX_INT) {
2391 _LOGE("Invalid Integer Property\n");
2392 return PMINFO_R_EINVAL;
2394 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2395 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1,
2396 sizeof(pkgmgrinfo_node_x));
2398 _LOGE("Out of Memory!!!\n");
2399 return PMINFO_R_ERROR;
2401 snprintf(buf, PKG_VALUE_STRING_LEN_MAX - 1, "%d", value);
2402 val = strndup(buf, PKG_VALUE_STRING_LEN_MAX - 1);
2404 _LOGE("Out of Memory\n");
2407 return PMINFO_R_ERROR;
2413 * If API is called multiple times for same property,
2414 * we should override the previous values.
2415 * Last value set will be used for filtering.
2417 link = g_slist_find_custom(filter->list,
2418 (gconstpointer)node, __compare_func);
2420 _pkgmgrinfo_node_destroy(link->data);
2421 filter->list = g_slist_delete_link(filter->list, link);
2423 filter->list = g_slist_append(filter->list, (gpointer)node);
2428 API int pkgmgrinfo_appinfo_filter_add_bool(pkgmgrinfo_appinfo_filter_h handle,
2429 const char *property, const bool value)
2431 retvm_if(handle == NULL, PMINFO_R_EINVAL,
2432 "Filter handle input parameter is NULL\n");
2433 retvm_if(property == NULL, PMINFO_R_EINVAL,
2434 "Filter handle input parameter is NULL\n");
2436 GSList *link = NULL;
2439 prop = _pminfo_appinfo_convert_to_prop_bool(property);
2440 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_BOOL ||
2441 prop > E_PMINFO_APPINFO_PROP_APP_MAX_BOOL) {
2442 _LOGE("Invalid Boolean Property\n");
2443 return PMINFO_R_EINVAL;
2445 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2446 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1,
2447 sizeof(pkgmgrinfo_node_x));
2449 _LOGE("Out of Memory!!!\n");
2450 return PMINFO_R_ERROR;
2453 val = strndup("true", 4);
2455 val = strndup("false", 5);
2457 _LOGE("Out of Memory\n");
2460 return PMINFO_R_ERROR;
2465 * If API is called multiple times for same property,
2466 * we should override the previous values.
2467 * Last value set will be used for filtering.
2469 link = g_slist_find_custom(filter->list,
2470 (gconstpointer)node, __compare_func);
2472 _pkgmgrinfo_node_destroy(link->data);
2473 filter->list = g_slist_delete_link(filter->list, link);
2475 filter->list = g_slist_append(filter->list, (gpointer)node);
2480 API int pkgmgrinfo_appinfo_filter_add_string(pkgmgrinfo_appinfo_filter_h handle,
2481 const char *property, const char *value)
2483 retvm_if(handle == NULL, PMINFO_R_EINVAL,
2484 "Filter handle input parameter is NULL\n");
2485 retvm_if(property == NULL, PMINFO_R_EINVAL,
2486 "Filter handle input parameter is NULL\n");
2487 retvm_if(value == NULL, PMINFO_R_EINVAL,
2488 "Filter handle input parameter is NULL\n");
2490 pkgmgrinfo_node_x *ptr = NULL;
2491 char prev[PKG_STRING_LEN_MAX] = {'\0'};
2492 char temp[PKG_STRING_LEN_MAX] = {'\0'};
2493 GSList *link = NULL;
2497 prop = _pminfo_appinfo_convert_to_prop_str(property);
2498 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_STR ||
2499 prop > E_PMINFO_APPINFO_PROP_APP_MAX_STR) {
2500 _LOGE("Invalid String Property\n");
2501 return PMINFO_R_EINVAL;
2503 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2504 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1,
2505 sizeof(pkgmgrinfo_node_x));
2507 _LOGE("Out of Memory!!!\n");
2508 return PMINFO_R_ERROR;
2512 case E_PMINFO_APPINFO_PROP_APP_COMPONENT:
2513 node->value = strdup(value);
2514 link = g_slist_find_custom(filter->list,
2515 (gconstpointer)node, __compare_func);
2517 _pkgmgrinfo_node_destroy(link->data);
2518 filter->list = g_slist_delete_link(filter->list, link);
2520 filter->list = g_slist_append(filter->list, (gpointer)node);
2522 case E_PMINFO_APPINFO_PROP_APP_CATEGORY:
2523 val = (char *)calloc(1, PKG_STRING_LEN_MAX);
2525 _LOGE("Out of Memory\n");
2528 return PMINFO_R_ERROR;
2530 link = g_slist_find_custom(filter->list,
2531 (gconstpointer)node, __compare_func);
2533 ptr = (pkgmgrinfo_node_x *)link->data;
2534 strncpy(prev, ptr->value, PKG_STRING_LEN_MAX - 1);
2535 _LOGI("Previous value is %s\n", prev);
2536 _pkgmgrinfo_node_destroy(ptr);
2537 filter->list = g_slist_delete_link(filter->list, link);
2538 ret = snprintf(temp, PKG_STRING_LEN_MAX - 1,
2539 "%s,%s", prev, value);
2540 if (ret < 0 || ret > PKG_STRING_LEN_MAX - 1) {
2541 _LOGE("snprintf fail\n");
2544 return PMINFO_R_ERROR;
2546 strncpy(val, temp, PKG_STRING_LEN_MAX);
2547 _LOGI("New value is %s\n", val);
2549 filter->list = g_slist_append(
2550 filter->list, (gpointer)node);
2551 memset(temp, '\0', PKG_STRING_LEN_MAX);
2553 snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s", value);
2554 strncpy(val, temp, PKG_STRING_LEN_MAX);
2555 _LOGI("First value is %s\n", val);
2557 filter->list = g_slist_append(
2558 filter->list, (gpointer)node);
2559 memset(temp, '\0', PKG_STRING_LEN_MAX);
2563 node->value = strndup(value, PKG_STRING_LEN_MAX - 1);
2564 link = g_slist_find_custom(filter->list,
2565 (gconstpointer)node, __compare_func);
2567 _pkgmgrinfo_node_destroy(link->data);
2568 filter->list = g_slist_delete_link(filter->list, link);
2570 filter->list = g_slist_append(filter->list, (gpointer)node);
2576 API int pkgmgrinfo_appinfo_usr_filter_count(
2577 pkgmgrinfo_appinfo_filter_h handle, int *count, uid_t uid)
2582 pkgmgrinfo_filter_x *filter;
2584 if (handle == NULL || count == NULL) {
2585 _LOGE("invalid parameter");
2586 return PMINFO_R_EINVAL;
2589 filter = (pkgmgrinfo_filter_x *)handle;
2590 list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
2591 __free_applications);
2593 return PMINFO_R_ERROR;
2595 if (__check_disable_filter_exist(
2596 handle, E_APPINFO_DISABLE_TYPE_APP) == false) {
2597 if (pkgmgrinfo_appinfo_filter_add_bool(handle,
2598 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
2599 g_hash_table_destroy(list);
2600 return PMINFO_R_ERROR;
2604 if (__check_disable_filter_exist(
2605 handle, E_APPINFO_DISABLE_TYPE_PKG) == false) {
2606 if (pkgmgrinfo_appinfo_filter_add_bool(handle,
2607 PMINFO_APPINFO_PROP_PKG_DISABLE, false)) {
2608 g_hash_table_destroy(list);
2609 return PMINFO_R_ERROR;
2613 ret = _appinfo_get_applications(uid, filter, 0, list);
2614 query_count = g_hash_table_size(list);
2615 g_hash_table_destroy(list);
2616 if (ret == PMINFO_R_ERROR)
2619 *count = query_count;
2623 API int pkgmgrinfo_appinfo_filter_count(
2624 pkgmgrinfo_appinfo_filter_h handle, int *count)
2626 return pkgmgrinfo_appinfo_usr_filter_count(handle, count, _getuid());
2629 API int pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(
2630 pkgmgrinfo_appinfo_filter_h handle,
2631 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
2633 if (handle == NULL || app_cb == NULL) {
2634 LOGE("invalid parameter");
2635 return PMINFO_R_EINVAL;
2638 if (__check_disable_filter_exist(
2639 handle, E_APPINFO_DISABLE_TYPE_APP) == false) {
2640 if (pkgmgrinfo_appinfo_filter_add_bool(handle,
2641 PMINFO_APPINFO_PROP_APP_DISABLE, false))
2642 return PMINFO_R_ERROR;
2645 if (__check_disable_filter_exist(
2646 handle, E_APPINFO_DISABLE_TYPE_PKG) == false) {
2647 if (pkgmgrinfo_appinfo_filter_add_bool(handle,
2648 PMINFO_APPINFO_PROP_PKG_DISABLE, false))
2649 return PMINFO_R_ERROR;
2652 return _appinfo_get_filtered_foreach_appinfo(uid,
2653 handle, PMINFO_APPINFO_GET_ALL, app_cb, user_data);
2656 API int pkgmgrinfo_appinfo_filter_foreach_appinfo(
2657 pkgmgrinfo_appinfo_filter_h handle,
2658 pkgmgrinfo_app_list_cb app_cb, void *user_data)
2660 return pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(
2661 handle, app_cb, user_data, _getuid());
2664 API int pkgmgrinfo_appinfo_metadata_filter_create(
2665 pkgmgrinfo_appinfo_metadata_filter_h *handle)
2667 return pkgmgrinfo_pkginfo_filter_create(handle);
2670 API int pkgmgrinfo_appinfo_metadata_filter_destroy(
2671 pkgmgrinfo_appinfo_metadata_filter_h handle)
2673 return pkgmgrinfo_pkginfo_filter_destroy(handle);
2676 API int pkgmgrinfo_appinfo_metadata_filter_add(
2677 pkgmgrinfo_appinfo_metadata_filter_h handle,
2678 const char *key, const char *value)
2680 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2681 pkgmgrinfo_metadata_node_x *node;
2683 /* value can be NULL.
2684 * In that case all apps with specified key should be displayed
2687 LOGE("invalid parameter");
2688 return PMINFO_R_EINVAL;
2691 node = calloc(1, sizeof(pkgmgrinfo_metadata_node_x));
2693 LOGE("out of memory");
2694 return PMINFO_R_ERROR;
2697 node->key = strdup(key);
2698 if (value && strlen(value))
2699 node->value = strdup(value);
2701 filter->list_metadata = g_slist_append(filter->list_metadata,
2707 API int pkgmgrinfo_appinfo_usr_metadata_filter_foreach(
2708 pkgmgrinfo_appinfo_metadata_filter_h handle,
2709 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
2711 if (handle == NULL || app_cb == NULL) {
2712 LOGE("invalid parameter");
2713 return PMINFO_R_EINVAL;
2716 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2718 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
2719 PMINFO_APPINFO_PROP_APP_DISABLE, false))
2720 return PMINFO_R_ERROR;
2722 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
2723 PMINFO_APPINFO_PROP_PKG_DISABLE, false))
2724 return PMINFO_R_ERROR;
2726 return _appinfo_get_filtered_foreach_appinfo(uid, handle,
2727 PMINFO_APPINFO_GET_ALL, app_cb,
2731 API int pkgmgrinfo_appinfo_metadata_filter_foreach(
2732 pkgmgrinfo_appinfo_metadata_filter_h handle,
2733 pkgmgrinfo_app_list_cb app_cb, void *user_data)
2735 return pkgmgrinfo_appinfo_usr_metadata_filter_foreach(handle, app_cb,
2736 user_data, _getuid());
2739 API int pkgmgrinfo_appinfo_is_guestmode_visibility(
2740 pkgmgrinfo_appinfo_h handle, bool *status)
2743 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2745 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2746 retvm_if(status == NULL, PMINFO_R_EINVAL,
2747 "Argument supplied to hold return value is NULL\n");
2749 val = info->app_info->guestmode_visibility;
2750 *status = _get_bool_value(val);
2754 API int pkgmgrinfo_appinfo_foreach_appcontrol_v2(pkgmgrinfo_appinfo_h handle,
2755 pkgmgrinfo_app_control_list_cb_v2 appcontrol_func,
2758 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2759 retvm_if(appcontrol_func == NULL,
2760 PMINFO_R_EINVAL, "Callback function is NULL");
2762 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2763 appcontrol_x *appcontrol;
2766 if (info->app_info == NULL)
2767 return PMINFO_R_ERROR;
2769 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
2770 appcontrol = (appcontrol_x *)tmp->data;
2771 if (appcontrol == NULL ||
2772 !strcasecmp(appcontrol->visibility,
2775 ret = appcontrol_func(appcontrol->operation, appcontrol->uri,
2776 appcontrol->mime, appcontrol->id, user_data);
2784 API int pkgmgrinfo_appinfo_foreach_remote_appcontrol_v2(
2785 pkgmgrinfo_appinfo_h handle,
2786 pkgmgrinfo_app_control_list_cb_v2 appcontrol_func,
2789 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2790 retvm_if(appcontrol_func == NULL,
2791 PMINFO_R_EINVAL, "Callback function is NULL");
2793 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2794 appcontrol_x *appcontrol;
2797 if (info->app_info == NULL)
2798 return PMINFO_R_ERROR;
2800 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
2801 appcontrol = (appcontrol_x *)tmp->data;
2802 if (appcontrol == NULL ||
2803 !strcasecmp(appcontrol->visibility,
2806 ret = appcontrol_func(appcontrol->operation, appcontrol->uri,
2807 appcontrol->mime, appcontrol->id, user_data);