13 #include "pkgmgr-info.h"
14 #include "pkgmgrinfo_debug.h"
15 #include "pkgmgrinfo_private.h"
16 #include "pkgmgr_parser.h"
17 #include "manager/pkginfo_manager.h"
19 static bool _get_bool_value(const char *str)
21 if (str && !strcmp(str, "true"))
27 static void __cleanup_appinfo(pkgmgr_appinfo_x *data)
29 pkgmgr_appinfo_x *info = data;
33 free((void *)info->package);
35 free((void *)info->locale);
37 pkgmgrinfo_basic_free_application(info->app_info);
43 static void __free_applications(gpointer data)
45 pkgmgrinfo_basic_free_application((application_x *)data);
48 static gint __disable_chk_func(gconstpointer data1, gconstpointer data2)
50 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)data1;
51 pkgmgrinfo_appinfo_disable_type value = GPOINTER_TO_INT(data2);
53 if (value == E_APPINFO_DISABLE_TYPE_PKG)
54 return (node->prop == E_PMINFO_APPINFO_PROP_PKG_DISABLE)
57 return (node->prop == E_PMINFO_APPINFO_PROP_APP_DISABLE)
61 static bool __check_disable_filter_exist(pkgmgrinfo_filter_x *filter,
62 pkgmgrinfo_appinfo_disable_type type)
69 link = g_slist_find_custom(filter->list, GINT_TO_POINTER(type), __disable_chk_func);
76 static int _pkgmgrinfo_get_appinfo(const char *appid, uid_t uid,
77 pkgmgrinfo_appinfo_filter_h filter, pkgmgrinfo_appinfo_h *handle)
79 int ret = PMINFO_R_OK;
81 pkgmgr_appinfo_x *info;
83 if (appid == NULL || filter == NULL || handle == NULL) {
84 LOGE("invalid parameter");
85 return PMINFO_R_EINVAL;
88 list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
91 return PMINFO_R_ERROR;
93 ret = _appinfo_get_applications(uid, uid, filter,
94 PMINFO_APPINFO_GET_ALL, list);
95 if (ret != PMINFO_R_OK) {
96 g_hash_table_destroy(list);
100 if (!g_hash_table_size(list)) {
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 if (!info->app_info || !info->app_info->package) {
116 _LOGD("appinfo for [%s] is not existed for user [%d]",
118 g_hash_table_destroy(list);
120 return PMINFO_R_ENOENT;
122 info->locale = strdup(info->app_info->locale);
124 _LOGE("out of memory");
125 g_hash_table_destroy(list);
127 return PMINFO_R_ERROR;
129 info->package = strdup(info->app_info->package);
130 if (!info->package) {
131 _LOGE("out of memory");
133 g_hash_table_destroy(list);
135 return PMINFO_R_ERROR;
138 /* just free list only */
139 g_hash_table_steal(list, (gconstpointer)appid);
140 g_hash_table_destroy(list);
147 API int pkgmgrinfo_appinfo_get_usr_disabled_appinfo(const char *appid, uid_t uid,
148 pkgmgrinfo_appinfo_h *handle)
151 pkgmgrinfo_appinfo_filter_h filter;
153 if (appid == NULL || handle == NULL) {
154 LOGE("invalid parameter");
155 return PMINFO_R_EINVAL;
158 ret = pkgmgrinfo_appinfo_filter_create(&filter);
159 if (ret != PMINFO_R_OK)
162 ret = pkgmgrinfo_appinfo_filter_add_string(filter,
163 PMINFO_APPINFO_PROP_APP_ID, appid);
164 if (ret != PMINFO_R_OK) {
165 pkgmgrinfo_appinfo_filter_destroy(filter);
166 return PMINFO_R_ERROR;
169 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
170 PMINFO_APPINFO_PROP_APP_DISABLE, true);
171 if (ret != PMINFO_R_OK) {
172 pkgmgrinfo_appinfo_filter_destroy(filter);
173 return PMINFO_R_ERROR;
176 ret = _pkgmgrinfo_get_appinfo(appid, uid, filter, handle);
177 pkgmgrinfo_appinfo_filter_destroy(filter);
182 API int pkgmgrinfo_appinfo_get_disabled_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
184 return pkgmgrinfo_appinfo_get_usr_disabled_appinfo(appid, _getuid(), handle);
187 API int pkgmgrinfo_appinfo_get_usr_appinfo(const char *appid, uid_t uid,
188 pkgmgrinfo_appinfo_h *handle)
191 pkgmgrinfo_appinfo_filter_h filter;
193 if (appid == NULL || handle == NULL) {
194 LOGE("invalid parameter");
195 return PMINFO_R_EINVAL;
198 ret = pkgmgrinfo_appinfo_filter_create(&filter);
199 if (ret != PMINFO_R_OK)
202 ret = pkgmgrinfo_appinfo_filter_add_string(filter,
203 PMINFO_APPINFO_PROP_APP_ID, appid);
204 if (ret != PMINFO_R_OK) {
205 pkgmgrinfo_appinfo_filter_destroy(filter);
206 return PMINFO_R_ERROR;
209 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
210 PMINFO_APPINFO_PROP_APP_DISABLE, false);
211 if (ret != PMINFO_R_OK) {
212 pkgmgrinfo_appinfo_filter_destroy(filter);
213 return PMINFO_R_ERROR;
216 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
217 PMINFO_APPINFO_PROP_PKG_DISABLE, false);
218 if (ret != PMINFO_R_OK) {
219 pkgmgrinfo_appinfo_filter_destroy(filter);
220 return PMINFO_R_ERROR;
223 ret = _pkgmgrinfo_get_appinfo(appid, uid, filter, handle);
224 pkgmgrinfo_appinfo_filter_destroy(filter);
228 API int pkgmgrinfo_appinfo_get_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
230 return pkgmgrinfo_appinfo_get_usr_appinfo(appid, _getuid(), handle);
233 API int pkgmgrinfo_appinfo_get_usr_all_appinfo(const char *appid, uid_t uid,
234 pkgmgrinfo_appinfo_h *handle)
237 pkgmgrinfo_appinfo_filter_h filter;
239 if (appid == NULL || handle == NULL) {
240 LOGE("invalid parameter");
241 return PMINFO_R_EINVAL;
244 ret = pkgmgrinfo_appinfo_filter_create(&filter);
245 if (ret != PMINFO_R_OK)
248 ret = pkgmgrinfo_appinfo_filter_add_string(filter,
249 PMINFO_APPINFO_PROP_APP_ID, appid);
250 if (ret != PMINFO_R_OK) {
251 pkgmgrinfo_appinfo_filter_destroy(filter);
252 return PMINFO_R_ERROR;
255 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
256 PMINFO_APPINFO_PROP_APP_CHECK_STORAGE, false);
257 if (ret != PMINFO_R_OK) {
258 pkgmgrinfo_appinfo_filter_destroy(filter);
259 return PMINFO_R_ERROR;
262 ret = _pkgmgrinfo_get_appinfo(appid, uid, filter, handle);
263 pkgmgrinfo_appinfo_filter_destroy(filter);
268 API int pkgmgrinfo_appinfo_get_all_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
270 return pkgmgrinfo_appinfo_get_usr_all_appinfo(appid, _getuid(), handle);
273 static gpointer __copy_str(gconstpointer src, gpointer data)
275 const char *tmp = (const char *)src;
278 buffer = strdup(tmp);
279 if (buffer == NULL) {
280 LOGE("memory alloc failed");
288 static gpointer __copy_label(gconstpointer src, gpointer data)
290 label_x *tmp = (label_x *)src;
293 label = calloc(1, sizeof(label_x));
295 LOGE("memory alloc failed");
301 label->name = strdup(tmp->name);
303 label->text = strdup(tmp->text);
305 label->lang = strdup(tmp->lang);
310 static gpointer __copy_icon(gconstpointer src, gpointer data)
312 icon_x *tmp = (icon_x *)src;
315 icon = calloc(1, sizeof(icon_x));
317 LOGE("memory alloc failed");
323 icon->text = strdup(tmp->text);
325 icon->lang = strdup(tmp->lang);
327 icon->section = strdup(tmp->section);
329 icon->size = strdup(tmp->size);
331 icon->resolution = strdup(tmp->resolution);
336 static gpointer __copy_metadata(gconstpointer src, gpointer data)
338 metadata_x *tmp = (metadata_x *)src;
339 metadata_x *metadata;
341 metadata = calloc(1, sizeof(metadata_x));
342 if (metadata == NULL) {
343 LOGE("memory alloc failed");
349 metadata->key = strdup(tmp->key);
351 metadata->value = strdup(tmp->value);
356 static gpointer __copy_datacontrol(gconstpointer src, gpointer data)
358 datacontrol_x *tmp = (datacontrol_x *)src;
359 datacontrol_x *datacontrol;
361 datacontrol = calloc(1, sizeof(datacontrol_x));
362 if (datacontrol == NULL) {
363 LOGE("memory alloc failed");
369 datacontrol->providerid = strdup(tmp->providerid);
371 datacontrol->access = strdup(tmp->access);
373 datacontrol->type = strdup(tmp->type);
375 datacontrol->trusted = strdup(tmp->trusted);
380 static gpointer __copy_appcontrol(gconstpointer src, gpointer data)
382 appcontrol_x *tmp = (appcontrol_x *)src;
383 appcontrol_x *appcontrol;
385 appcontrol = calloc(1, sizeof(appcontrol_x));
386 if (appcontrol == NULL) {
387 LOGE("memory alloc failed");
393 appcontrol->operation = strdup(tmp->operation);
395 appcontrol->uri = strdup(tmp->uri);
397 appcontrol->mime = strdup(tmp->mime);
402 static gpointer __copy_splashscreens(gconstpointer src, gpointer data)
404 splashscreen_x *tmp = (splashscreen_x *)src;
405 splashscreen_x *splashscreen;
407 splashscreen = (splashscreen_x *)calloc(1, sizeof(splashscreen_x));
408 if (splashscreen == NULL) {
409 LOGE("memory alloc failed");
415 splashscreen->src = strdup(tmp->src);
417 splashscreen->type = strdup(tmp->type);
418 if (tmp->orientation)
419 splashscreen->orientation = strdup(tmp->orientation);
420 if (tmp->indicatordisplay)
421 splashscreen->indicatordisplay = strdup(tmp->indicatordisplay);
423 splashscreen->operation = strdup(tmp->operation);
424 if (tmp->color_depth)
425 splashscreen->color_depth = strdup(tmp->color_depth);
430 static int _appinfo_copy_appinfo(application_x **application, application_x *data)
432 application_x *app_info;
435 app_info = calloc(1, sizeof(application_x));
436 if (app_info == NULL) {
437 LOGE("memory alloc failed");
438 return PMINFO_R_ERROR;
441 if (data->appid != NULL)
442 app_info->appid = strdup(data->appid);
443 if (data->exec != NULL)
444 app_info->exec = strdup(data->exec);
445 if (data->nodisplay != NULL)
446 app_info->nodisplay = strdup(data->nodisplay);
447 if (data->multiple != NULL)
448 app_info->multiple = strdup(data->multiple);
449 if (data->taskmanage != NULL)
450 app_info->taskmanage = strdup(data->taskmanage);
451 if (data->type != NULL)
452 app_info->type = strdup(data->type);
453 if (data->categories != NULL)
454 app_info->categories = strdup(data->categories);
455 if (data->hwacceleration != NULL)
456 app_info->hwacceleration = strdup(data->hwacceleration);
457 if (data->screenreader != NULL)
458 app_info->screenreader = strdup(data->screenreader);
459 if (data->mainapp != NULL)
460 app_info->mainapp = strdup(data->mainapp);
461 if (data->package != NULL)
462 app_info->package = strdup(data->package);
463 if (data->recentimage != NULL)
464 app_info->recentimage = strdup(data->recentimage);
465 if (data->launchcondition != NULL)
466 app_info->launchcondition = strdup(data->launchcondition);
467 if (data->indicatordisplay != NULL)
468 app_info->indicatordisplay = strdup(data->indicatordisplay);
469 if (data->portraitimg != NULL)
470 app_info->portraitimg = strdup(data->portraitimg);
471 if (data->landscapeimg != NULL)
472 app_info->landscapeimg = strdup(data->landscapeimg);
473 if (data->guestmode_visibility != NULL)
474 app_info->guestmode_visibility = strdup(data->guestmode_visibility);
475 if (data->component != NULL)
476 app_info->component = strdup(data->component);
477 if (data->permission_type != NULL)
478 app_info->permission_type = strdup(data->permission_type);
479 if (data->component_type != NULL)
480 app_info->component_type = strdup(data->component_type);
481 if (data->preload != NULL)
482 app_info->preload = strdup(data->preload);
483 if (data->submode != NULL)
484 app_info->submode = strdup(data->submode);
485 if (data->submode_mainid != NULL)
486 app_info->submode_mainid = strdup(data->submode_mainid);
487 if (data->process_pool != NULL)
488 app_info->process_pool = strdup(data->process_pool);
489 if (data->installed_storage != NULL)
490 app_info->installed_storage = strdup(data->installed_storage);
491 if (data->autorestart != NULL)
492 app_info->autorestart = strdup(data->autorestart);
493 if (data->onboot != NULL)
494 app_info->onboot = strdup(data->onboot);
495 if (data->support_disable != NULL)
496 app_info->support_disable = strdup(data->support_disable);
497 if (data->ui_gadget != NULL)
498 app_info->ui_gadget = strdup(data->ui_gadget);
499 if (data->launch_mode != NULL)
500 app_info->launch_mode = strdup(data->launch_mode);
501 if (data->package_type != NULL)
502 app_info->package_type = strdup(data->package_type);
503 if (data->effective_appid != NULL)
504 app_info->effective_appid = strdup(data->effective_appid);
505 if (data->splash_screen_display != NULL)
506 app_info->splash_screen_display = strdup(data->splash_screen_display);
510 app_info->label = g_list_copy_deep(data->label, __copy_label, &ret);
512 LOGE("memory alloc failed");
513 pkgmgrinfo_basic_free_application(app_info);
514 return PMINFO_R_ERROR;
518 app_info->icon = g_list_copy_deep(data->icon, __copy_icon, &ret);
520 LOGE("memory alloc failed");
521 pkgmgrinfo_basic_free_application(app_info);
522 return PMINFO_R_ERROR;
526 app_info->category = g_list_copy_deep(data->category, __copy_str, &ret);
528 LOGE("memory alloc failed");
529 pkgmgrinfo_basic_free_application(app_info);
530 return PMINFO_R_ERROR;
534 app_info->metadata = g_list_copy_deep(data->metadata, __copy_metadata, &ret);
536 LOGE("memory alloc failed");
537 pkgmgrinfo_basic_free_application(app_info);
538 return PMINFO_R_ERROR;
542 app_info->datacontrol = g_list_copy_deep(data->datacontrol, __copy_datacontrol, &ret);
544 LOGE("memory alloc failed");
545 pkgmgrinfo_basic_free_application(app_info);
546 return PMINFO_R_ERROR;
550 app_info->appcontrol = g_list_copy_deep(data->appcontrol, __copy_appcontrol, &ret);
552 LOGE("memory alloc failed");
553 pkgmgrinfo_basic_free_application(app_info);
554 return PMINFO_R_ERROR;
558 app_info->background_category = g_list_copy_deep(data->background_category, __copy_str, &ret);
560 LOGE("memory alloc failed");
561 pkgmgrinfo_basic_free_application(app_info);
562 return PMINFO_R_ERROR;
566 app_info->splashscreens = g_list_copy_deep(data->splashscreens, __copy_splashscreens, &ret);
568 LOGE("memory alloc failed");
569 pkgmgrinfo_basic_free_application(app_info);
570 return PMINFO_R_ERROR;
573 *application = app_info;
578 API int pkgmgrinfo_appinfo_clone_appinfo(pkgmgrinfo_appinfo_h handle,
579 pkgmgrinfo_appinfo_h *clone)
581 pkgmgr_appinfo_x *info;
582 pkgmgr_appinfo_x *temp = (pkgmgr_appinfo_x *)handle;
585 return PMINFO_R_EINVAL;
587 info = calloc(1, sizeof(pkgmgr_appinfo_x));
589 LOGE("memory alloc failed");
590 return PMINFO_R_ERROR;
593 if (temp->package != NULL)
594 info->package = strdup(temp->package);
595 if (temp->locale != NULL)
596 info->locale = strdup(temp->locale);
598 info->app_component = temp->app_component;
600 if (_appinfo_copy_appinfo(&info->app_info, temp->app_info) < 0) {
601 LOGE("appinfo copy failed");
603 free((void *)info->package);
607 return PMINFO_R_ERROR;
615 static int _appinfo_get_filtered_foreach_appinfo(uid_t uid,
616 pkgmgrinfo_filter_x *filter, int flag, pkgmgrinfo_app_list_cb app_list_cb,
620 pkgmgr_appinfo_x info;
626 list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
627 __free_applications);
629 return PMINFO_R_ERROR;
631 ret = _appinfo_get_applications(uid, uid, filter,
632 flag | PMINFO_APPINFO_GET_BASICINFO, list);
633 if (ret != PMINFO_R_OK) {
634 g_hash_table_destroy(list);
638 g_hash_table_iter_init(&iter, list);
639 while (g_hash_table_iter_next(&iter, NULL, &value)) {
640 app = (application_x *)value;
642 info.locale = info.app_info->locale;
643 info.package = app->package;
644 if (app_list_cb(&info, user_data) < 0)
647 g_hash_table_destroy(list);
652 static const char *__appcomponent_str(pkgmgrinfo_app_component comp);
654 API int pkgmgrinfo_appinfo_get_usr_list(pkgmgrinfo_pkginfo_h handle,
655 pkgmgrinfo_app_component component,
656 pkgmgrinfo_app_list_cb app_func, void *user_data, uid_t uid)
659 pkgmgrinfo_appinfo_filter_h filter;
661 const char *comp_str = NULL;
663 if (handle == NULL || app_func == NULL) {
664 LOGE("invalid parameter");
665 return PMINFO_R_EINVAL;
668 if (pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid)) {
669 LOGE("invalid parameter");
670 return PMINFO_R_EINVAL;
673 if (pkgmgrinfo_appinfo_filter_create(&filter))
674 return PMINFO_R_ERROR;
676 if (pkgmgrinfo_appinfo_filter_add_string(filter,
677 PMINFO_APPINFO_PROP_APP_PACKAGE, pkgid)) {
678 pkgmgrinfo_appinfo_filter_destroy(filter);
679 return PMINFO_R_ERROR;
682 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
683 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
684 pkgmgrinfo_appinfo_filter_destroy(filter);
685 return PMINFO_R_ERROR;
688 comp_str = __appcomponent_str(component);
691 if (pkgmgrinfo_appinfo_filter_add_string(filter,
692 PMINFO_APPINFO_PROP_APP_COMPONENT,
694 pkgmgrinfo_appinfo_filter_destroy(filter);
695 return PMINFO_R_ERROR;
699 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter,
700 PMINFO_APPINFO_GET_ALL, app_func, user_data);
702 pkgmgrinfo_appinfo_filter_destroy(filter);
707 API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle,
708 pkgmgrinfo_app_component component,
709 pkgmgrinfo_app_list_cb app_func, void *user_data)
711 return pkgmgrinfo_appinfo_get_usr_list(handle, component, app_func, user_data, _getuid());
714 API int pkgmgrinfo_appinfo_get_usr_installed_list_full(
715 pkgmgrinfo_app_list_cb app_func, uid_t uid, int flag,
719 pkgmgrinfo_appinfo_filter_h filter;
721 if (app_func == NULL) {
722 LOGE("invalid parameter");
723 return PMINFO_R_EINVAL;
726 if (pkgmgrinfo_appinfo_filter_create(&filter))
727 return PMINFO_R_ERROR;
729 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
730 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
731 pkgmgrinfo_appinfo_filter_destroy(filter);
732 return PMINFO_R_ERROR;
735 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
736 PMINFO_APPINFO_PROP_PKG_DISABLE, false)) {
737 pkgmgrinfo_appinfo_filter_destroy(filter);
738 return PMINFO_R_ERROR;
741 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
742 PMINFO_APPINFO_PROP_APP_CHECK_STORAGE, false)) {
743 pkgmgrinfo_appinfo_filter_destroy(filter);
744 return PMINFO_R_ERROR;
747 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter, flag, app_func,
750 pkgmgrinfo_appinfo_filter_destroy(filter);
755 API int pkgmgrinfo_appinfo_get_installed_list_full(
756 pkgmgrinfo_app_list_cb app_func, int flag, void *user_data)
758 return pkgmgrinfo_appinfo_get_usr_installed_list_full(app_func,
759 _getuid(), flag, user_data);
762 API int pkgmgrinfo_appinfo_get_usr_installed_list(
763 pkgmgrinfo_app_list_cb app_func, uid_t uid, void *user_data)
766 pkgmgrinfo_appinfo_filter_h filter;
768 if (app_func == NULL) {
769 LOGE("invalid parameter");
770 return PMINFO_R_EINVAL;
773 /* create an empty filter */
774 ret = pkgmgrinfo_appinfo_filter_create(&filter);
775 if (ret != PMINFO_R_OK)
778 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
779 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
780 pkgmgrinfo_appinfo_filter_destroy(filter);
781 return PMINFO_R_ERROR;
784 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
785 PMINFO_APPINFO_PROP_PKG_DISABLE, false)) {
786 pkgmgrinfo_appinfo_filter_destroy(filter);
787 return PMINFO_R_ERROR;
790 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter,
791 PMINFO_APPINFO_GET_ALL, app_func, user_data);
793 pkgmgrinfo_appinfo_filter_destroy(filter);
798 API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func,
801 return pkgmgrinfo_appinfo_get_usr_installed_list(app_func, _getuid(),
805 API int pkgmgrinfo_appinfo_get_appid(pkgmgrinfo_appinfo_h handle, char **appid)
807 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
809 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
810 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
812 if (info->app_info == NULL || info->app_info->appid == NULL)
813 return PMINFO_R_ERROR;
814 *appid = (char *)info->app_info->appid;
819 API int pkgmgrinfo_appinfo_get_pkgname(pkgmgrinfo_appinfo_h handle, char **pkg_name)
821 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
823 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
824 retvm_if(pkg_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
826 if (info->package == NULL)
827 return PMINFO_R_ERROR;
829 *pkg_name = (char *)info->package;
834 API int pkgmgrinfo_appinfo_get_pkgid(pkgmgrinfo_appinfo_h handle, char **pkgid)
836 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
838 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
839 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
841 if (info->package == NULL)
842 return PMINFO_R_ERROR;
844 *pkgid = (char *)info->package;
849 API int pkgmgrinfo_appinfo_get_pkgtype(pkgmgrinfo_appinfo_h handle, char **pkgtype)
851 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
852 retvm_if(pkgtype == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
853 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
855 *pkgtype = (char *)info->app_info->package_type;
860 API int pkgmgrinfo_appinfo_get_exec(pkgmgrinfo_appinfo_h handle, char **exec)
862 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
864 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
865 retvm_if(exec == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
867 if (info->app_info == NULL || info->app_info->exec == NULL)
868 return PMINFO_R_ERROR;
869 *exec = (char *)info->app_info->exec;
875 API int pkgmgrinfo_appinfo_get_icon(pkgmgrinfo_appinfo_h handle, char **icon)
878 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
880 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
881 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
883 if (info->app_info == NULL)
884 return PMINFO_R_ERROR;
886 if (info->app_info->icon == NULL) {
891 ptr = (icon_x *)info->app_info->icon->data;
893 return PMINFO_R_ERROR;
895 if (ptr->text == NULL)
896 return PMINFO_R_ERROR;
904 API int pkgmgrinfo_appinfo_get_label(pkgmgrinfo_appinfo_h handle, char **label)
907 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
912 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
913 retvm_if(label == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
915 if (info->app_info == NULL)
916 return PMINFO_R_ERROR;
918 locale = info->locale;
920 locale = DEFAULT_LOCALE;
922 for (tmp = info->app_info->label; tmp; tmp = tmp->next) {
923 ptr = (label_x *)tmp->data;
924 if (ptr == NULL || strcmp(locale, ptr->lang) != 0)
935 for (tmp = info->app_info->label; tmp; tmp = tmp->next) {
936 ptr = (label_x *)tmp->data;
937 if (ptr == NULL || strcmp(DEFAULT_LOCALE, ptr->lang) != 0)
943 *label = lbl ? lbl : "";
948 API int pkgmgrinfo_appinfo_usr_get_localed_label(const char *appid, const char *locale, uid_t uid, char **label)
952 retvm_if(appid == NULL || locale == NULL || label == NULL, PMINFO_R_EINVAL, "Argument is NULL");
953 val = _appinfo_get_localed_label(appid, locale, uid);
955 return PMINFO_R_ERROR;
961 API int pkgmgrinfo_appinfo_get_localed_label(const char *appid, const char *locale, char **label)
963 return pkgmgrinfo_appinfo_usr_get_localed_label(appid, locale, _getuid(), label);
966 API int pkgmgrinfo_appinfo_get_metadata_value(pkgmgrinfo_appinfo_h handle, const char *metadata_key, char **metadata_value)
968 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
969 retvm_if(metadata_key == NULL, PMINFO_R_EINVAL, "metadata_key is NULL");
970 retvm_if(metadata_value == NULL, PMINFO_R_EINVAL, "metadata_value is NULL");
972 GList *list_md = NULL;
973 metadata_x *metadata = NULL;
974 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
976 list_md = info->app_info->metadata;
978 for (; list_md; list_md = list_md->next) {
979 metadata = (metadata_x *)list_md->data;
980 if (metadata && metadata->key) {
981 if (strcasecmp(metadata->key, metadata_key) == 0) {
982 if (metadata->value == NULL)
983 *metadata_value = "";
985 *metadata_value = (char *)metadata->value;
991 return PMINFO_R_EINVAL;
994 static pkgmgrinfo_app_component __appcomponent_convert(const char *comp)
996 if (strcasecmp(comp, "uiapp") == 0)
997 return PMINFO_UI_APP;
998 else if (strcasecmp(comp, "svcapp") == 0)
999 return PMINFO_SVC_APP;
1000 else if (strcasecmp(comp, "widgetapp") == 0)
1001 return PMINFO_WIDGET_APP;
1002 else if (strcasecmp(comp, "watchapp") == 0)
1003 return PMINFO_WATCH_APP;
1004 else if (strcasecmp(comp, "componentbasedapp") == 0)
1005 return PMINFO_COMPONENT_BASED_APP;
1010 static const char *__appcomponent_str(pkgmgrinfo_app_component comp)
1015 case PMINFO_SVC_APP:
1017 case PMINFO_WIDGET_APP:
1019 case PMINFO_WATCH_APP:
1021 case PMINFO_COMPONENT_BASED_APP:
1022 return "componentbasedapp";
1028 API int pkgmgrinfo_appinfo_get_component(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_component *component)
1030 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1033 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1034 retvm_if(component == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1036 if (info->app_info == NULL)
1037 return PMINFO_R_ERROR;
1039 comp = __appcomponent_convert(info->app_info->component);
1041 return PMINFO_R_ERROR;
1048 API int pkgmgrinfo_appinfo_get_apptype(pkgmgrinfo_appinfo_h handle, char **app_type)
1050 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1052 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1053 retvm_if(app_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1055 if (info->app_info == NULL || info->app_info->type == NULL)
1056 return PMINFO_R_ERROR;
1057 *app_type = (char *)info->app_info->type;
1062 API int pkgmgrinfo_appinfo_get_notification_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1067 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1069 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1070 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1072 if (info->app_info == NULL)
1073 return PMINFO_R_ERROR;
1075 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1076 ptr = (icon_x *)tmp->data;
1077 if (ptr == NULL || ptr->section == NULL)
1080 val = (char *)ptr->section;
1081 if (val && strcmp(val, "notification") == 0) {
1082 *icon = (char *)ptr->text;
1087 return PMINFO_R_ERROR;
1090 API int pkgmgrinfo_appinfo_get_recent_image_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_recentimage *type)
1093 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1095 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1096 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1098 if (info->app_info == NULL || info->app_info->recentimage == NULL)
1099 return PMINFO_R_ERROR;
1101 val = (char *)info->app_info->recentimage;
1102 if (strcasecmp(val, "capture") == 0)
1103 *type = PMINFO_RECENTIMAGE_USE_CAPTURE;
1104 else if (strcasecmp(val, "icon") == 0)
1105 *type = PMINFO_RECENTIMAGE_USE_ICON;
1107 *type = PMINFO_RECENTIMAGE_USE_NOTHING;
1112 API int pkgmgrinfo_appinfo_get_preview_image(pkgmgrinfo_appinfo_h handle, char **preview_img)
1117 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1119 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1120 retvm_if(preview_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1122 if (info->app_info == NULL)
1123 return PMINFO_R_ERROR;
1125 for (tmp = info->app_info->image; tmp; tmp = tmp->next) {
1126 ptr = (image_x *)tmp->data;
1127 if (ptr == NULL || ptr->section == NULL)
1130 val = (char *)ptr->section;
1131 if (val && strcmp(val, "preview") == 0) {
1132 *preview_img = (char *)ptr->text;
1137 return PMINFO_R_ERROR;
1140 API int pkgmgrinfo_appinfo_get_permission_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_permission_type *permission)
1143 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1145 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1146 retvm_if(permission == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1148 val = info->app_info->permission_type;
1150 return PMINFO_R_ERROR;
1152 if (strcmp(val, "signature") == 0)
1153 *permission = PMINFO_PERMISSION_SIGNATURE;
1154 else if (strcmp(val, "privilege") == 0)
1155 *permission = PMINFO_PERMISSION_PRIVILEGE;
1157 *permission = PMINFO_PERMISSION_NORMAL;
1162 API int pkgmgrinfo_appinfo_get_component_type(pkgmgrinfo_appinfo_h handle, char **component_type)
1164 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1166 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1167 retvm_if(component_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1169 if (info->app_info == NULL || info->app_info->component_type == NULL)
1170 return PMINFO_R_ERROR;
1172 *component_type = (char *)info->app_info->component_type;
1177 API int pkgmgrinfo_appinfo_get_hwacceleration(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_hwacceleration *hwacceleration)
1180 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1182 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1183 retvm_if(hwacceleration == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1185 if (info->app_info == NULL || info->app_info->hwacceleration == NULL)
1186 return PMINFO_R_ERROR;
1188 val = (char *)info->app_info->hwacceleration;
1189 if (strcasecmp(val, "off") == 0)
1190 *hwacceleration = PMINFO_HWACCELERATION_OFF;
1191 else if (strcasecmp(val, "on") == 0)
1192 *hwacceleration = PMINFO_HWACCELERATION_ON;
1194 *hwacceleration = PMINFO_HWACCELERATION_DEFAULT;
1199 API int pkgmgrinfo_appinfo_get_screenreader(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_screenreader *screenreader)
1202 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1204 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1205 retvm_if(screenreader == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1207 if (info->app_info == NULL || info->app_info->screenreader == NULL)
1208 return PMINFO_R_ERROR;
1210 val = (char *)info->app_info->screenreader;
1211 if (strcasecmp(val, "screenreader-off") == 0)
1212 *screenreader = PMINFO_SCREENREADER_OFF;
1213 else if (strcasecmp(val, "screenreader-on") == 0)
1214 *screenreader = PMINFO_SCREENREADER_ON;
1216 *screenreader = PMINFO_SCREENREADER_USE_SYSTEM_SETTING;
1221 API int pkgmgrinfo_appinfo_get_effectimage(pkgmgrinfo_appinfo_h handle, char **portrait_img, char **landscape_img)
1223 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1225 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1226 retvm_if(portrait_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1227 retvm_if(landscape_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1229 if (info->app_info == NULL)
1230 return PMINFO_R_ERROR;
1232 if (info->app_info->portraitimg == NULL)
1235 *portrait_img = (char *)info->app_info->portraitimg;
1237 if (info->app_info->landscapeimg == NULL)
1238 *landscape_img = "";
1240 *landscape_img = (char *)info->app_info->landscapeimg;
1245 API int pkgmgrinfo_appinfo_get_effectimage_type(pkgmgrinfo_appinfo_h handle, char **effectimage_type)
1247 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1249 if (handle == NULL || effectimage_type == NULL) {
1250 LOGE("invalid parameter");
1251 return PMINFO_R_EINVAL;
1254 if (info->app_info == NULL || info->app_info->effectimage_type == NULL)
1255 return PMINFO_R_ERROR;
1257 *effectimage_type = (char *)info->app_info->effectimage_type;
1262 API int pkgmgrinfo_appinfo_get_submode_mainid(pkgmgrinfo_appinfo_h handle, char **submode_mainid)
1264 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1266 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1267 retvm_if(submode_mainid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1269 if (info->app_info == NULL)
1270 return PMINFO_R_ERROR;
1272 if (info->app_info->submode_mainid == NULL)
1273 *submode_mainid = "";
1275 *submode_mainid = (char *)info->app_info->submode_mainid;
1280 API int pkgmgrinfo_appinfo_get_installed_storage_location(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_installed_storage *storage)
1282 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1283 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1285 if (info->app_info && info->app_info->installed_storage) {
1286 if (strcmp(info->app_info->installed_storage, "installed_internal") == 0)
1287 *storage = PMINFO_INTERNAL_STORAGE;
1288 else if (strcmp(info->app_info->installed_storage, "installed_external") == 0)
1289 *storage = PMINFO_EXTERNAL_STORAGE;
1291 return PMINFO_R_ERROR;
1293 return PMINFO_R_ERROR;
1299 API int pkgmgrinfo_appinfo_get_launch_mode(pkgmgrinfo_appinfo_h handle, char **mode)
1301 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1303 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1304 retvm_if(mode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1306 if (info->app_info->launch_mode == NULL)
1307 return PMINFO_R_ERROR;
1309 *mode = (char *)(info->app_info->launch_mode);
1314 API int pkgmgrinfo_appinfo_get_alias_appid(pkgmgrinfo_appinfo_h handle, char **alias_appid)
1316 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1318 if (handle == NULL || alias_appid == NULL) {
1319 LOGE("invalid parameter");
1320 return PMINFO_R_EINVAL;
1323 if (info->app_info == NULL || info->app_info->alias_appid == NULL)
1324 return PMINFO_R_ERROR;
1326 *alias_appid = (char *)info->app_info->alias_appid;
1331 API int pkgmgrinfo_appinfo_get_effective_appid(pkgmgrinfo_appinfo_h handle, char **effective_appid)
1333 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1335 if (handle == NULL || effective_appid == NULL) {
1336 LOGE("invalid parameter");
1337 return PMINFO_R_EINVAL;
1340 if (info->app_info == NULL)
1341 return PMINFO_R_ERROR;
1343 if (info->app_info->effective_appid == NULL)
1344 *effective_appid = "";
1346 *effective_appid = (char *)info->app_info->effective_appid;
1351 API int pkgmgrinfo_appinfo_get_tep_name(pkgmgrinfo_appinfo_h handle, char **tep_name)
1353 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1355 if (handle == NULL || tep_name == NULL) {
1356 LOGE("invalid parameter");
1357 return PMINFO_R_EINVAL;
1360 if (info->app_info == NULL)
1361 return PMINFO_R_ERROR;
1363 if (info->app_info->tep_name == NULL)
1366 *tep_name = (char *)info->app_info->tep_name;
1371 API int pkgmgrinfo_appinfo_get_zip_mount_file(pkgmgrinfo_appinfo_h handle, char **zip_mount_file)
1373 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1375 if (handle == NULL || zip_mount_file == NULL) {
1376 LOGE("invalid parameter");
1377 return PMINFO_R_EINVAL;
1380 if (info->app_info == NULL)
1381 return PMINFO_R_ERROR;
1383 if (info->app_info->zip_mount_file == NULL)
1384 *zip_mount_file = "";
1386 *zip_mount_file = (char *)info->app_info->zip_mount_file;
1391 API int pkgmgrinfo_appinfo_get_root_path(pkgmgrinfo_appinfo_h handle, char **root_path)
1393 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1395 if (handle == NULL || root_path == NULL) {
1396 LOGE("invalid parameter");
1397 return PMINFO_R_EINVAL;
1400 if (info->app_info == NULL || info->app_info->root_path == NULL)
1401 return PMINFO_R_ERROR;
1403 *root_path = (char *)info->app_info->root_path;
1408 API int pkgmgrinfo_appinfo_get_api_version(pkgmgrinfo_appinfo_h handle, char **api_version)
1410 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1412 if (handle == NULL || api_version == NULL) {
1413 LOGE("invalid parameter");
1414 return PMINFO_R_EINVAL;
1417 if (info->app_info == NULL || info->app_info->api_version == NULL)
1418 return PMINFO_R_ERROR;
1420 *api_version = (char *)info->app_info->api_version;
1425 API int pkgmgrinfo_appinfo_get_installed_time(pkgmgrinfo_appinfo_h handle, int *installed_time)
1427 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1429 if (handle == NULL || installed_time == NULL) {
1430 LOGE("invalid parameter");
1431 return PMINFO_R_EINVAL;
1434 if (info->app_info == NULL || info->app_info->package_installed_time == NULL)
1435 return PMINFO_R_ERROR;
1437 *installed_time = atoi(info->app_info->package_installed_time);
1442 API int pkgmgrinfo_appinfo_usr_get_datacontrol_info(const char *providerid,
1443 const char *type, uid_t uid, char **appid, char **access)
1447 if (providerid == NULL || type == NULL || appid == NULL ||
1449 LOGE("invalid parameter");
1450 return PMINFO_R_EINVAL;
1453 ret = _appinfo_get_datacontrol_info(providerid, type, uid, appid, access);
1454 /* FIXME: It should return PMINFO_R_ENOENT but to keep previous
1455 * implementation, return PMINFO_R_ERROR. This should be
1458 if (ret == PMINFO_R_ENOENT) {
1459 LOGE("no datacontrol info of %s", providerid);
1460 ret = PMINFO_R_ERROR;
1466 API int pkgmgrinfo_appinfo_get_datacontrol_info(const char *providerid,
1467 const char *type, char **appid, char **access)
1469 return pkgmgrinfo_appinfo_usr_get_datacontrol_info(providerid,
1470 type, _getuid(), appid, access);
1473 API int pkgmgrinfo_appinfo_usr_get_datacontrol_appid(const char *providerid,
1474 uid_t uid, char **appid)
1477 if (providerid == NULL || appid == NULL) {
1478 LOGE("invalid parameter");
1479 return PMINFO_R_EINVAL;
1482 ret = _appinfo_get_datacontrol_appid(providerid, uid, appid);
1483 /* FIXME: It should return PMINFO_R_ENOENT but to keep previous
1484 * implementation, return PMINFO_R_ERROR. This should be
1487 if (ret == PMINFO_R_ENOENT) {
1488 LOGE("no datacontrol appid of %s", providerid);
1489 ret = PMINFO_R_ERROR;
1495 API int pkgmgrinfo_appinfo_get_datacontrol_appid(const char *providerid, char **appid)
1497 return pkgmgrinfo_appinfo_usr_get_datacontrol_appid(providerid, _getuid(), appid);
1500 API int pkgmgrinfo_appinfo_usr_get_datacontrol_trusted_info(
1501 const char *providerid, const char *type, uid_t uid,
1502 char **appid, bool *is_trusted)
1505 char *trusted = NULL;
1506 if (providerid == NULL || type == NULL || appid == NULL ||
1507 is_trusted == NULL) {
1508 LOGE("invalid parameter");
1509 return PMINFO_R_EINVAL;
1512 ret = _appinfo_get_datacontrol_trusted_info(providerid, type, uid,
1515 /* FIXME: It should return PMINFO_R_ENOENT but to keep previous
1516 * implementation, return PMINFO_R_ERROR. This should be
1519 if (ret == PMINFO_R_ENOENT) {
1520 LOGE("no datacontrol trusted info of %s", providerid);
1521 ret = PMINFO_R_ERROR;
1523 *is_trusted = _get_bool_value(trusted);
1529 API int pkgmgrinfo_appinfo_get_datacontrol_trsuted_info(const char *providerid,
1530 const char *type, char **appid, bool *is_trusted)
1532 return pkgmgrinfo_appinfo_usr_get_datacontrol_trusted_info(providerid,
1533 type, _getuid(), appid, is_trusted);
1536 API int pkgmgrinfo_appinfo_usr_foreach_datacontrol_privileges(
1537 const char *providerid, const char *type,
1538 pkgmgrinfo_pkg_privilege_list_cb privilege_func,
1539 void *user_data, uid_t uid)
1545 if (providerid == NULL || type == NULL || privilege_func == NULL) {
1546 LOGE("invalid parameter");
1547 return PMINFO_R_EINVAL;
1550 ret = _appinfo_get_datacontrol_privileges(providerid, type, uid, &list);
1551 if (ret == PMINFO_R_ERROR) {
1552 g_list_free_full(list, free);
1556 for (tmp = list; tmp != NULL; tmp = g_list_next(tmp)) {
1558 ret = privilege_func((char *)tmp->data, user_data);
1563 g_list_free_full(list, free);
1567 API int pkgmgrinfo_appinfo_foreach_datacontrol_privileges(
1568 const char *providerid, const char *type,
1569 pkgmgrinfo_pkg_privilege_list_cb privilege_func,
1572 return pkgmgrinfo_appinfo_usr_foreach_datacontrol_privileges(
1573 providerid, type, privilege_func, user_data, _getuid());
1576 API int pkgmgrinfo_appinfo_get_support_mode(pkgmgrinfo_appinfo_h handle, int *support_mode)
1578 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1579 retvm_if(support_mode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1581 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1582 if (info->app_info->support_mode)
1583 *support_mode = atoi(info->app_info->support_mode);
1590 API int pkgmgrinfo_appinfo_foreach_category(pkgmgrinfo_appinfo_h handle,
1591 pkgmgrinfo_app_category_list_cb category_func, void *user_data)
1593 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1594 retvm_if(category_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
1596 const char *category;
1598 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1600 if (info->app_info == NULL)
1601 return PMINFO_R_ERROR;
1603 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
1604 category = (const char *)tmp->data;
1606 ret = category_func(category, user_data);
1614 API int pkgmgrinfo_appinfo_foreach_metadata(pkgmgrinfo_appinfo_h handle,
1615 pkgmgrinfo_app_metadata_list_cb metadata_func, void *user_data)
1617 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1618 retvm_if(metadata_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
1622 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1624 if (info->app_info == NULL)
1625 return PMINFO_R_ERROR;
1627 for (tmp = info->app_info->metadata; tmp; tmp = tmp->next) {
1628 ptr = (metadata_x *)tmp->data;
1632 ret = metadata_func(ptr->key, ptr->value ? ptr->value : "", user_data);
1640 API int pkgmgrinfo_appinfo_usr_foreach_appcontrol_privileges(const char *appid,
1641 const char *operation,
1642 pkgmgrinfo_pkg_privilege_list_cb privilege_func,
1643 void *user_data, uid_t uid)
1646 GList *privilege_list = NULL;
1649 if (appid == NULL || operation == NULL || privilege_func == NULL) {
1650 LOGE("invalid parameter");
1651 return PMINFO_R_EINVAL;
1654 ret = _appinfo_get_appcontrol_privileges(appid, operation, uid,
1656 if (ret == PMINFO_R_ENOENT) {
1658 } else if (ret != PMINFO_R_OK) {
1659 g_list_free_full(privilege_list, free);
1663 for (tmp_list = privilege_list; tmp_list != NULL;
1664 tmp_list = g_list_next(tmp_list)) {
1665 ret = privilege_func((char *)tmp_list->data, user_data);
1670 g_list_free_full(privilege_list, free);
1674 API int pkgmgrinfo_appinfo_foreach_appcontrol_privileges(const char *appid,
1675 const char *operation,
1676 pkgmgrinfo_pkg_privilege_list_cb privilege_func,
1679 return pkgmgrinfo_appinfo_usr_foreach_appcontrol_privileges(appid,
1680 operation, privilege_func, user_data, _getuid());
1683 API int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
1684 pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
1686 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1687 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
1689 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1690 appcontrol_x *appcontrol;
1693 if (info->app_info == NULL)
1694 return PMINFO_R_ERROR;
1696 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
1697 appcontrol = (appcontrol_x *)tmp->data;
1698 if (appcontrol == NULL || !strcasecmp(appcontrol->visibility, "remote-only"))
1700 ret = appcontrol_func(appcontrol->operation, appcontrol->uri, appcontrol->mime, user_data);
1708 API int pkgmgrinfo_appinfo_foreach_remote_appcontrol(pkgmgrinfo_appinfo_h handle,
1709 pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
1711 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1712 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
1714 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1715 appcontrol_x *appcontrol;
1718 if (info->app_info == NULL)
1719 return PMINFO_R_ERROR;
1721 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
1722 appcontrol = (appcontrol_x *)tmp->data;
1723 if (appcontrol == NULL || !strcasecmp(appcontrol->visibility, "local-only"))
1725 ret = appcontrol_func(appcontrol->operation, appcontrol->uri, appcontrol->mime, user_data);
1733 API int pkgmgrinfo_appinfo_foreach_background_category(
1734 pkgmgrinfo_appinfo_h handle,
1735 pkgmgrinfo_app_background_category_list_cb category_func,
1738 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1742 if (handle == NULL || category_func == NULL || info->app_info == NULL) {
1743 LOGE("invalid parameter");
1744 return PMINFO_R_EINVAL;
1747 for (tmp = info->app_info->background_category; tmp; tmp = tmp->next) {
1748 category = (char *)tmp->data;
1749 if (category == NULL)
1752 if (category_func(category, user_data) < 0)
1759 API int pkgmgrinfo_appinfo_foreach_splash_screen(pkgmgrinfo_appinfo_h handle,
1760 pkgmgrinfo_app_splash_screen_list_cb splash_screen_func,
1763 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1764 splashscreen_x *splashscreen;
1768 if (info == NULL || info->app_info == NULL
1769 || splash_screen_func == NULL) {
1770 LOGE("invalid parameter");
1771 return PMINFO_R_EINVAL;
1774 for (tmp = info->app_info->splashscreens; tmp; tmp = tmp->next) {
1775 splashscreen = (splashscreen_x *)tmp->data;
1776 if (splashscreen == NULL)
1778 ret = splash_screen_func(splashscreen->src,
1780 splashscreen->orientation,
1781 splashscreen->indicatordisplay,
1782 splashscreen->operation,
1783 splashscreen->color_depth,
1792 API int pkgmgrinfo_appinfo_is_nodisplay(pkgmgrinfo_appinfo_h handle, bool *nodisplay)
1794 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1795 retvm_if(nodisplay == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1796 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1798 if (info->app_info == NULL || info->app_info->nodisplay == NULL)
1799 return PMINFO_R_ERROR;
1801 *nodisplay = _get_bool_value(info->app_info->nodisplay);
1806 API int pkgmgrinfo_appinfo_is_multiple(pkgmgrinfo_appinfo_h handle, bool *multiple)
1808 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1809 retvm_if(multiple == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1810 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1812 if (info->app_info == NULL || info->app_info->multiple == NULL)
1813 return PMINFO_R_ERROR;
1815 *multiple = _get_bool_value(info->app_info->multiple);
1820 API int pkgmgrinfo_appinfo_is_indicator_display_allowed(pkgmgrinfo_appinfo_h handle, bool *indicator_disp)
1822 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1823 retvm_if(indicator_disp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1824 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1826 if (info->app_info == NULL || info->app_info->indicatordisplay == NULL)
1827 return PMINFO_R_ERROR;
1829 *indicator_disp = _get_bool_value(info->app_info->indicatordisplay);
1834 API int pkgmgrinfo_appinfo_is_taskmanage(pkgmgrinfo_appinfo_h handle, bool *taskmanage)
1836 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1837 retvm_if(taskmanage == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1838 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1840 if (info->app_info == NULL || info->app_info->taskmanage == NULL)
1841 return PMINFO_R_ERROR;
1843 *taskmanage = _get_bool_value(info->app_info->taskmanage);
1848 API int pkgmgrinfo_appinfo_is_enabled(pkgmgrinfo_appinfo_h handle, bool *enabled)
1850 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1851 retvm_if(enabled == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1852 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1854 if (info->app_info == NULL || info->app_info->is_disabled == NULL)
1855 return PMINFO_R_ERROR;
1857 *enabled = !_get_bool_value(info->app_info->is_disabled);
1862 API int pkgmgrinfo_appinfo_is_onboot(pkgmgrinfo_appinfo_h handle, bool *onboot)
1864 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1865 retvm_if(onboot == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1866 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1868 if (info->app_info == NULL || info->app_info->onboot == NULL)
1869 return PMINFO_R_ERROR;
1871 *onboot = _get_bool_value(info->app_info->onboot);
1876 API int pkgmgrinfo_appinfo_is_autorestart(pkgmgrinfo_appinfo_h handle, bool *autorestart)
1878 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1879 retvm_if(autorestart == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1880 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1882 if (info->app_info == NULL || info->app_info->autorestart == NULL)
1883 return PMINFO_R_ERROR;
1885 *autorestart = _get_bool_value(info->app_info->autorestart);
1890 API int pkgmgrinfo_appinfo_is_mainapp(pkgmgrinfo_appinfo_h handle, bool *mainapp)
1892 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1893 retvm_if(mainapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1894 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1896 if (info->app_info == NULL || info->app_info->mainapp == NULL)
1897 return PMINFO_R_ERROR;
1899 *mainapp = _get_bool_value(info->app_info->mainapp);
1904 API int pkgmgrinfo_appinfo_is_preload(pkgmgrinfo_appinfo_h handle, bool *preload)
1906 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1907 retvm_if(preload == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1908 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1910 if (info->app_info == NULL || info->app_info->preload == NULL)
1911 return PMINFO_R_ERROR;
1913 *preload = _get_bool_value(info->app_info->preload);
1918 API int pkgmgrinfo_appinfo_is_submode(pkgmgrinfo_appinfo_h handle, bool *submode)
1920 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1921 retvm_if(submode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1922 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1924 if (info->app_info == NULL || info->app_info->submode == NULL)
1925 return PMINFO_R_ERROR;
1927 *submode = _get_bool_value(info->app_info->submode);
1932 API int pkgmgrinfo_appinfo_is_process_pool(pkgmgrinfo_appinfo_h handle, bool *process_pool)
1934 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1936 if (handle == NULL || process_pool == NULL) {
1937 LOGE("invalid parameter");
1938 return PMINFO_R_EINVAL;
1941 if (info->app_info == NULL)
1942 return PMINFO_R_ERROR;
1944 *process_pool = _get_bool_value(info->app_info->process_pool);
1949 API int pkgmgrinfo_appinfo_is_category_exist(pkgmgrinfo_appinfo_h handle, const char *category, bool *exist)
1951 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1952 retvm_if(category == NULL, PMINFO_R_EINVAL, "category is NULL");
1953 retvm_if(exist == NULL, PMINFO_R_EINVAL, "exist is NULL");
1957 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1959 if (info->app_info == NULL)
1960 return PMINFO_R_ERROR;
1963 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
1964 val = (const char *)tmp->data;
1967 if (strcasecmp(val, category) == 0) {
1976 API int pkgmgrinfo_appinfo_is_ui_gadget(pkgmgrinfo_appinfo_h handle,
1979 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1981 if (info == NULL || info->app_info == NULL || ui_gadget == NULL) {
1982 _LOGE("invalid parameter");
1983 return PMINFO_R_EINVAL;
1985 if (info->app_info->ui_gadget == NULL)
1986 info->app_info->ui_gadget = strdup("false");
1988 *ui_gadget = _get_bool_value(info->app_info->ui_gadget);
1993 API int pkgmgrinfo_appinfo_is_support_disable(pkgmgrinfo_appinfo_h handle,
1994 bool *support_disable)
1996 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1998 if (info == NULL || info->app_info == NULL || support_disable == NULL) {
1999 _LOGE("invalid parameter");
2000 return PMINFO_R_EINVAL;
2003 *support_disable = _get_bool_value(info->app_info->support_disable);
2008 API int pkgmgrinfo_appinfo_is_removable(pkgmgrinfo_appinfo_h handle,
2011 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2013 if (info == NULL || info->app_info == NULL || removable == NULL) {
2014 _LOGE("invalid parameter");
2015 return PMINFO_R_EINVAL;
2018 *removable = _get_bool_value(info->app_info->removable);
2023 API int pkgmgrinfo_appinfo_is_system(pkgmgrinfo_appinfo_h handle, bool *system)
2025 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2027 if (info == NULL || info->app_info == NULL || system == NULL) {
2028 _LOGE("invalid parameter");
2029 return PMINFO_R_EINVAL;
2032 *system = _get_bool_value(info->app_info->package_system);
2037 API int pkgmgrinfo_appinfo_is_disabled(pkgmgrinfo_appinfo_h handle, bool *disabled)
2039 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2040 retvm_if(disabled == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2041 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2043 if (info->app_info == NULL || info->app_info->is_disabled == NULL)
2044 return PMINFO_R_ERROR;
2046 *disabled = _get_bool_value(info->app_info->is_disabled);
2051 API int pkgmgrinfo_appinfo_is_global(pkgmgrinfo_appinfo_h handle, bool *global)
2053 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2055 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2056 retvm_if(global == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2058 if (info->app_info == NULL || info->app_info->for_all_users == NULL)
2059 return PMINFO_R_ERROR;
2061 *global = _get_bool_value(info->app_info->for_all_users);
2066 API int pkgmgrinfo_appinfo_get_splash_screen_display(pkgmgrinfo_appinfo_h handle, bool *splash_screen_display)
2068 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2070 if (info == NULL || splash_screen_display == NULL) {
2071 _LOGE("Invalid parameter");
2072 return PMINFO_R_EINVAL;
2075 if (info->app_info == NULL || info->app_info->splash_screen_display == NULL)
2076 return PMINFO_R_ERROR;
2078 *splash_screen_display = _get_bool_value(info->app_info->splash_screen_display);
2083 API int pkgmgrinfo_appinfo_get_setup_appid(pkgmgrinfo_appinfo_h handle, char **setup_appid)
2085 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2087 if (info == NULL || setup_appid == NULL) {
2088 _LOGE("Invalid parameter");
2089 return PMINFO_R_EINVAL;
2092 if (info->app_info == NULL || info->app_info->setup_appid == NULL)
2093 return PMINFO_R_ERROR;
2095 *setup_appid = info->app_info->setup_appid;
2099 API int pkgmgrinfo_appinfo_is_support_ambient(pkgmgrinfo_appinfo_h handle,
2100 bool *support_ambient)
2102 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2104 if (info == NULL || support_ambient == NULL) {
2105 _LOGE("Invalid parameter");
2106 return PMINFO_R_EINVAL;
2109 if (info->app_info == NULL || info->app_info->support_ambient == NULL)
2110 return PMINFO_R_ERROR;
2112 *support_ambient = _get_bool_value(info->app_info->support_ambient);
2117 API int pkgmgrinfo_appinfo_destroy_appinfo(pkgmgrinfo_appinfo_h handle)
2119 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2120 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2121 __cleanup_appinfo(info);
2125 API int pkgmgrinfo_appinfo_filter_create(pkgmgrinfo_appinfo_filter_h *handle)
2127 return (pkgmgrinfo_pkginfo_filter_create(handle));
2130 API int pkgmgrinfo_appinfo_filter_destroy(pkgmgrinfo_appinfo_filter_h handle)
2132 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
2135 static gint __compare_func(gconstpointer data1, gconstpointer data2)
2137 pkgmgrinfo_node_x *node1 = (pkgmgrinfo_node_x *)data1;
2138 pkgmgrinfo_node_x *node2 = (pkgmgrinfo_node_x *)data2;
2139 if (node1->prop == node2->prop)
2141 else if (node1->prop > node2->prop)
2147 API int pkgmgrinfo_appinfo_filter_add_int(pkgmgrinfo_appinfo_filter_h handle,
2148 const char *property, const int value)
2150 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2151 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2152 char buf[PKG_VALUE_STRING_LEN_MAX] = {'\0'};
2154 GSList *link = NULL;
2156 prop = _pminfo_appinfo_convert_to_prop_int(property);
2157 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_INT ||
2158 prop > E_PMINFO_APPINFO_PROP_APP_MAX_INT) {
2159 _LOGE("Invalid Integer Property\n");
2160 return PMINFO_R_EINVAL;
2162 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2163 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1, sizeof(pkgmgrinfo_node_x));
2165 _LOGE("Out of Memory!!!\n");
2166 return PMINFO_R_ERROR;
2168 snprintf(buf, PKG_VALUE_STRING_LEN_MAX - 1, "%d", value);
2169 val = strndup(buf, PKG_VALUE_STRING_LEN_MAX - 1);
2171 _LOGE("Out of Memory\n");
2174 return PMINFO_R_ERROR;
2178 /*If API is called multiple times for same property, we should override the previous values.
2179 Last value set will be used for filtering.*/
2180 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2182 filter->list = g_slist_delete_link(filter->list, link);
2183 filter->list = g_slist_append(filter->list, (gpointer)node);
2188 API int pkgmgrinfo_appinfo_filter_add_bool(pkgmgrinfo_appinfo_filter_h handle,
2189 const char *property, const bool value)
2191 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2192 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2194 GSList *link = NULL;
2196 prop = _pminfo_appinfo_convert_to_prop_bool(property);
2197 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_BOOL ||
2198 prop > E_PMINFO_APPINFO_PROP_APP_MAX_BOOL) {
2199 _LOGE("Invalid Boolean Property\n");
2200 return PMINFO_R_EINVAL;
2202 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2203 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1, sizeof(pkgmgrinfo_node_x));
2205 _LOGE("Out of Memory!!!\n");
2206 return PMINFO_R_ERROR;
2209 val = strndup("true", 4);
2211 val = strndup("false", 5);
2213 _LOGE("Out of Memory\n");
2216 return PMINFO_R_ERROR;
2220 /*If API is called multiple times for same property, we should override the previous values.
2221 Last value set will be used for filtering.*/
2222 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2224 filter->list = g_slist_delete_link(filter->list, link);
2225 filter->list = g_slist_append(filter->list, (gpointer)node);
2230 API int pkgmgrinfo_appinfo_filter_add_string(pkgmgrinfo_appinfo_filter_h handle,
2231 const char *property, const char *value)
2233 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2234 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2235 retvm_if(value == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2237 pkgmgrinfo_node_x *ptr = NULL;
2238 char prev[PKG_STRING_LEN_MAX] = {'\0'};
2239 char temp[PKG_STRING_LEN_MAX] = {'\0'};
2240 GSList *link = NULL;
2243 prop = _pminfo_appinfo_convert_to_prop_str(property);
2244 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_STR ||
2245 prop > E_PMINFO_APPINFO_PROP_APP_MAX_STR) {
2246 _LOGE("Invalid String Property\n");
2247 return PMINFO_R_EINVAL;
2249 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2250 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1, sizeof(pkgmgrinfo_node_x));
2252 _LOGE("Out of Memory!!!\n");
2253 return PMINFO_R_ERROR;
2257 case E_PMINFO_APPINFO_PROP_APP_COMPONENT:
2258 node->value = strdup(value);
2259 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2261 filter->list = g_slist_delete_link(filter->list, link);
2262 filter->list = g_slist_append(filter->list, (gpointer)node);
2264 case E_PMINFO_APPINFO_PROP_APP_CATEGORY:
2265 val = (char *)calloc(1, PKG_STRING_LEN_MAX);
2267 _LOGE("Out of Memory\n");
2270 return PMINFO_R_ERROR;
2272 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2274 ptr = (pkgmgrinfo_node_x *)link->data;
2275 strncpy(prev, ptr->value, PKG_STRING_LEN_MAX - 1);
2276 _LOGI("Previous value is %s\n", prev);
2277 filter->list = g_slist_delete_link(filter->list, link);
2278 ret = snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s,%s", prev, value);
2279 if (ret < 0 || ret > PKG_STRING_LEN_MAX - 1) {
2280 _LOGE("snprintf fail\n");
2283 return PMINFO_R_ERROR;
2285 strncpy(val, temp, PKG_STRING_LEN_MAX);
2286 _LOGI("New value is %s\n", val);
2288 filter->list = g_slist_append(filter->list, (gpointer)node);
2289 memset(temp, '\0', PKG_STRING_LEN_MAX);
2291 snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s", value);
2292 strncpy(val, temp, PKG_STRING_LEN_MAX);
2293 _LOGI("First value is %s\n", val);
2295 filter->list = g_slist_append(filter->list, (gpointer)node);
2296 memset(temp, '\0', PKG_STRING_LEN_MAX);
2300 node->value = strndup(value, PKG_STRING_LEN_MAX - 1);
2301 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2303 filter->list = g_slist_delete_link(filter->list, link);
2304 filter->list = g_slist_append(filter->list, (gpointer)node);
2310 API int pkgmgrinfo_appinfo_usr_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count, uid_t uid)
2314 pkgmgrinfo_filter_x *filter;
2316 if (handle == NULL || count == NULL) {
2317 _LOGE("invalid parameter");
2318 return PMINFO_R_EINVAL;
2321 filter = (pkgmgrinfo_filter_x *)handle;
2322 list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
2323 __free_applications);
2325 return PMINFO_R_ERROR;
2327 if (__check_disable_filter_exist(
2328 handle, E_APPINFO_DISABLE_TYPE_APP) == false) {
2329 if (pkgmgrinfo_appinfo_filter_add_bool(handle,
2330 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
2331 g_hash_table_destroy(list);
2332 return PMINFO_R_ERROR;
2336 if (__check_disable_filter_exist(
2337 handle, E_APPINFO_DISABLE_TYPE_PKG) == false) {
2338 if (pkgmgrinfo_appinfo_filter_add_bool(handle,
2339 PMINFO_APPINFO_PROP_PKG_DISABLE, false)) {
2340 g_hash_table_destroy(list);
2341 return PMINFO_R_ERROR;
2345 ret = _appinfo_get_applications(uid, uid, filter, 0, list);
2346 if (ret != PMINFO_R_OK) {
2347 g_hash_table_destroy(list);
2348 return PMINFO_R_ERROR;
2351 *count = g_hash_table_size(list);
2352 g_hash_table_destroy(list);
2357 API int pkgmgrinfo_appinfo_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count)
2359 return pkgmgrinfo_appinfo_usr_filter_count(handle, count, _getuid());
2362 API int pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(
2363 pkgmgrinfo_appinfo_filter_h handle,
2364 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
2366 if (handle == NULL || app_cb == NULL) {
2367 LOGE("invalid parameter");
2368 return PMINFO_R_EINVAL;
2371 if (__check_disable_filter_exist(
2372 handle, E_APPINFO_DISABLE_TYPE_APP) == false) {
2373 if (pkgmgrinfo_appinfo_filter_add_bool(handle,
2374 PMINFO_APPINFO_PROP_APP_DISABLE, false))
2375 return PMINFO_R_ERROR;
2378 if (__check_disable_filter_exist(
2379 handle, E_APPINFO_DISABLE_TYPE_PKG) == false) {
2380 if (pkgmgrinfo_appinfo_filter_add_bool(handle,
2381 PMINFO_APPINFO_PROP_PKG_DISABLE, false))
2382 return PMINFO_R_ERROR;
2385 return _appinfo_get_filtered_foreach_appinfo(uid, handle, PMINFO_APPINFO_GET_ALL, app_cb,
2389 API int pkgmgrinfo_appinfo_filter_foreach_appinfo(pkgmgrinfo_appinfo_filter_h handle,
2390 pkgmgrinfo_app_list_cb app_cb, void *user_data)
2392 return pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(handle, app_cb, user_data, _getuid());
2395 API int pkgmgrinfo_appinfo_metadata_filter_create(pkgmgrinfo_appinfo_metadata_filter_h *handle)
2397 return (pkgmgrinfo_pkginfo_filter_create(handle));
2400 API int pkgmgrinfo_appinfo_metadata_filter_destroy(pkgmgrinfo_appinfo_metadata_filter_h handle)
2402 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
2405 API int pkgmgrinfo_appinfo_metadata_filter_add(
2406 pkgmgrinfo_appinfo_metadata_filter_h handle,
2407 const char *key, const char *value)
2409 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2410 pkgmgrinfo_metadata_node_x *node;
2412 /* value can be NULL.
2413 * In that case all apps with specified key should be displayed
2416 LOGE("invalid parameter");
2417 return PMINFO_R_EINVAL;
2420 node = calloc(1, sizeof(pkgmgrinfo_metadata_node_x));
2422 LOGE("out of memory");
2423 return PMINFO_R_ERROR;
2426 node->key = strdup(key);
2427 if (value && strlen(value))
2428 node->value = strdup(value);
2430 filter->list_metadata = g_slist_append(filter->list_metadata,
2436 API int pkgmgrinfo_appinfo_usr_metadata_filter_foreach(
2437 pkgmgrinfo_appinfo_metadata_filter_h handle,
2438 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
2440 if (handle == NULL || app_cb == NULL) {
2441 LOGE("invalid parameter");
2442 return PMINFO_R_EINVAL;
2445 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2446 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
2447 PMINFO_APPINFO_PROP_APP_DISABLE, false))
2448 return PMINFO_R_ERROR;
2450 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
2451 PMINFO_APPINFO_PROP_PKG_DISABLE, false))
2452 return PMINFO_R_ERROR;
2454 return _appinfo_get_filtered_foreach_appinfo(uid, handle, PMINFO_APPINFO_GET_ALL, app_cb,
2458 API int pkgmgrinfo_appinfo_metadata_filter_foreach(
2459 pkgmgrinfo_appinfo_metadata_filter_h handle,
2460 pkgmgrinfo_app_list_cb app_cb, void *user_data)
2462 return pkgmgrinfo_appinfo_usr_metadata_filter_foreach(handle, app_cb,
2463 user_data, _getuid());
2466 API int pkgmgrinfo_appinfo_is_guestmode_visibility(pkgmgrinfo_appinfo_h handle, bool *status)
2469 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2471 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2472 retvm_if(status == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2474 val = info->app_info->guestmode_visibility;
2475 *status = _get_bool_value(val);
2479 API int pkgmgrinfo_appinfo_foreach_appcontrol_v2(pkgmgrinfo_appinfo_h handle,
2480 pkgmgrinfo_app_control_list_cb_v2 appcontrol_func,
2483 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2484 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2486 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2487 appcontrol_x *appcontrol;
2490 if (info->app_info == NULL)
2491 return PMINFO_R_ERROR;
2493 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
2494 appcontrol = (appcontrol_x *)tmp->data;
2495 if (appcontrol == NULL ||
2496 !strcasecmp(appcontrol->visibility, "remote-only"))
2498 ret = appcontrol_func(appcontrol->operation, appcontrol->uri,
2499 appcontrol->mime, appcontrol->id, user_data);
2507 API int pkgmgrinfo_appinfo_foreach_remote_appcontrol_v2(
2508 pkgmgrinfo_appinfo_h handle,
2509 pkgmgrinfo_app_control_list_cb_v2 appcontrol_func,
2512 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2513 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2515 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2516 appcontrol_x *appcontrol;
2519 if (info->app_info == NULL)
2520 return PMINFO_R_ERROR;
2522 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
2523 appcontrol = (appcontrol_x *)tmp->data;
2524 if (appcontrol == NULL ||
2525 !strcasecmp(appcontrol->visibility, "local-only"))
2527 ret = appcontrol_func(appcontrol->operation, appcontrol->uri,
2528 appcontrol->mime, appcontrol->id, user_data);