13 #include "pkgmgr-info.h"
14 #include "pkgmgrinfo_debug.h"
15 #include "pkgmgrinfo_private.h"
16 #include "pkgmgr_parser.h"
17 #include "manager/pkginfo_manager.h"
19 static bool _get_bool_value(const char *str)
21 if (str && !strcmp(str, "true"))
27 static void __cleanup_appinfo(pkgmgr_appinfo_x *data)
29 pkgmgr_appinfo_x *info = data;
33 free((void *)info->package);
35 free((void *)info->locale);
37 pkgmgrinfo_basic_free_application(info->app_info);
42 static void __free_applications(gpointer data)
44 pkgmgrinfo_basic_free_application((application_x *)data);
47 static gint __disable_chk_func(gconstpointer data1, gconstpointer data2)
49 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)data1;
50 pkgmgrinfo_appinfo_disable_type value = GPOINTER_TO_INT(data2);
52 if (value == E_APPINFO_DISABLE_TYPE_PKG)
53 return (node->prop == E_PMINFO_APPINFO_PROP_PKG_DISABLE)
56 return (node->prop == E_PMINFO_APPINFO_PROP_APP_DISABLE)
60 static bool __check_disable_filter_exist(pkgmgrinfo_filter_x *filter,
61 pkgmgrinfo_appinfo_disable_type type)
68 link = g_slist_find_custom(filter->list,
69 GINT_TO_POINTER(type), __disable_chk_func);
76 static int _pkgmgrinfo_get_appinfo(const char *appid, uid_t uid,
77 pkgmgrinfo_appinfo_filter_h filter, pkgmgrinfo_appinfo_h *handle)
79 int ret = PMINFO_R_OK;
81 pkgmgr_appinfo_x *info;
83 if (appid == NULL || filter == NULL || handle == NULL) {
84 LOGE("invalid parameter");
85 return PMINFO_R_EINVAL;
88 list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
91 return PMINFO_R_ERROR;
93 ret = _appinfo_get_applications(uid, 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(
148 const char *appid, uid_t uid, 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(
183 const char *appid, pkgmgrinfo_appinfo_h *handle)
185 return pkgmgrinfo_appinfo_get_usr_disabled_appinfo(
186 appid, _getuid(), handle);
189 API int pkgmgrinfo_appinfo_get_usr_appinfo(const char *appid, uid_t uid,
190 pkgmgrinfo_appinfo_h *handle)
193 pkgmgrinfo_appinfo_filter_h filter;
195 if (appid == NULL || handle == NULL) {
196 LOGE("invalid parameter");
197 return PMINFO_R_EINVAL;
200 ret = pkgmgrinfo_appinfo_filter_create(&filter);
201 if (ret != PMINFO_R_OK)
204 ret = pkgmgrinfo_appinfo_filter_add_string(filter,
205 PMINFO_APPINFO_PROP_APP_ID, appid);
206 if (ret != PMINFO_R_OK) {
207 pkgmgrinfo_appinfo_filter_destroy(filter);
208 return PMINFO_R_ERROR;
211 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
212 PMINFO_APPINFO_PROP_APP_DISABLE, false);
213 if (ret != PMINFO_R_OK) {
214 pkgmgrinfo_appinfo_filter_destroy(filter);
215 return PMINFO_R_ERROR;
218 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
219 PMINFO_APPINFO_PROP_PKG_DISABLE, false);
220 if (ret != PMINFO_R_OK) {
221 pkgmgrinfo_appinfo_filter_destroy(filter);
222 return PMINFO_R_ERROR;
225 ret = _pkgmgrinfo_get_appinfo(appid, uid, filter, handle);
226 pkgmgrinfo_appinfo_filter_destroy(filter);
230 API int pkgmgrinfo_appinfo_get_appinfo(
231 const char *appid, pkgmgrinfo_appinfo_h *handle)
233 return pkgmgrinfo_appinfo_get_usr_appinfo(appid, _getuid(), handle);
236 API int pkgmgrinfo_appinfo_get_usr_all_appinfo(const char *appid, uid_t uid,
237 pkgmgrinfo_appinfo_h *handle)
240 pkgmgrinfo_appinfo_filter_h filter;
242 if (appid == NULL || handle == NULL) {
243 LOGE("invalid parameter");
244 return PMINFO_R_EINVAL;
247 ret = pkgmgrinfo_appinfo_filter_create(&filter);
248 if (ret != PMINFO_R_OK)
251 ret = pkgmgrinfo_appinfo_filter_add_string(filter,
252 PMINFO_APPINFO_PROP_APP_ID, appid);
253 if (ret != PMINFO_R_OK) {
254 pkgmgrinfo_appinfo_filter_destroy(filter);
255 return PMINFO_R_ERROR;
258 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
259 PMINFO_APPINFO_PROP_APP_CHECK_STORAGE, false);
260 if (ret != PMINFO_R_OK) {
261 pkgmgrinfo_appinfo_filter_destroy(filter);
262 return PMINFO_R_ERROR;
265 ret = _pkgmgrinfo_get_appinfo(appid, uid, filter, handle);
266 pkgmgrinfo_appinfo_filter_destroy(filter);
271 API int pkgmgrinfo_appinfo_get_all_appinfo(
272 const char *appid, pkgmgrinfo_appinfo_h *handle)
274 return pkgmgrinfo_appinfo_get_usr_all_appinfo(appid, _getuid(), handle);
277 static gpointer __copy_str(gconstpointer src, gpointer data)
279 const char *tmp = (const char *)src;
282 buffer = strdup(tmp);
283 if (buffer == NULL) {
284 LOGE("memory alloc failed");
292 static gpointer __copy_label(gconstpointer src, gpointer data)
294 label_x *tmp = (label_x *)src;
297 label = calloc(1, sizeof(label_x));
299 LOGE("memory alloc failed");
305 label->name = strdup(tmp->name);
307 label->text = strdup(tmp->text);
309 label->lang = strdup(tmp->lang);
314 static gpointer __copy_icon(gconstpointer src, gpointer data)
316 icon_x *tmp = (icon_x *)src;
319 icon = calloc(1, sizeof(icon_x));
321 LOGE("memory alloc failed");
327 icon->text = strdup(tmp->text);
329 icon->lang = strdup(tmp->lang);
331 icon->section = strdup(tmp->section);
333 icon->size = strdup(tmp->size);
335 icon->resolution = strdup(tmp->resolution);
340 static gpointer __copy_metadata(gconstpointer src, gpointer data)
342 metadata_x *tmp = (metadata_x *)src;
343 metadata_x *metadata;
345 metadata = calloc(1, sizeof(metadata_x));
346 if (metadata == NULL) {
347 LOGE("memory alloc failed");
353 metadata->key = strdup(tmp->key);
355 metadata->value = strdup(tmp->value);
360 static gpointer __copy_datacontrol(gconstpointer src, gpointer data)
362 datacontrol_x *tmp = (datacontrol_x *)src;
363 datacontrol_x *datacontrol;
365 datacontrol = calloc(1, sizeof(datacontrol_x));
366 if (datacontrol == NULL) {
367 LOGE("memory alloc failed");
373 datacontrol->providerid = strdup(tmp->providerid);
375 datacontrol->access = strdup(tmp->access);
377 datacontrol->type = strdup(tmp->type);
379 datacontrol->trusted = strdup(tmp->trusted);
384 static gpointer __copy_appcontrol(gconstpointer src, gpointer data)
386 appcontrol_x *tmp = (appcontrol_x *)src;
387 appcontrol_x *appcontrol;
389 appcontrol = calloc(1, sizeof(appcontrol_x));
390 if (appcontrol == NULL) {
391 LOGE("memory alloc failed");
397 appcontrol->operation = strdup(tmp->operation);
399 appcontrol->uri = strdup(tmp->uri);
401 appcontrol->mime = strdup(tmp->mime);
406 static gpointer __copy_splashscreens(gconstpointer src, gpointer data)
408 splashscreen_x *tmp = (splashscreen_x *)src;
409 splashscreen_x *splashscreen;
411 splashscreen = (splashscreen_x *)calloc(1, sizeof(splashscreen_x));
412 if (splashscreen == NULL) {
413 LOGE("memory alloc failed");
419 splashscreen->src = strdup(tmp->src);
421 splashscreen->type = strdup(tmp->type);
422 if (tmp->orientation)
423 splashscreen->orientation = strdup(tmp->orientation);
424 if (tmp->indicatordisplay)
425 splashscreen->indicatordisplay = strdup(tmp->indicatordisplay);
427 splashscreen->operation = strdup(tmp->operation);
428 if (tmp->color_depth)
429 splashscreen->color_depth = strdup(tmp->color_depth);
434 static int _appinfo_copy_appinfo(
435 application_x **application, application_x *data)
437 application_x *app_info;
440 app_info = calloc(1, sizeof(application_x));
441 if (app_info == NULL) {
442 LOGE("memory alloc failed");
443 return PMINFO_R_ERROR;
446 if (data->appid != NULL)
447 app_info->appid = strdup(data->appid);
448 if (data->exec != NULL)
449 app_info->exec = strdup(data->exec);
450 if (data->nodisplay != NULL)
451 app_info->nodisplay = strdup(data->nodisplay);
452 if (data->multiple != NULL)
453 app_info->multiple = strdup(data->multiple);
454 if (data->taskmanage != NULL)
455 app_info->taskmanage = strdup(data->taskmanage);
456 if (data->type != NULL)
457 app_info->type = strdup(data->type);
458 if (data->categories != NULL)
459 app_info->categories = strdup(data->categories);
460 if (data->hwacceleration != NULL)
461 app_info->hwacceleration = strdup(data->hwacceleration);
462 if (data->screenreader != NULL)
463 app_info->screenreader = strdup(data->screenreader);
464 if (data->mainapp != NULL)
465 app_info->mainapp = strdup(data->mainapp);
466 if (data->package != NULL)
467 app_info->package = strdup(data->package);
468 if (data->recentimage != NULL)
469 app_info->recentimage = strdup(data->recentimage);
470 if (data->launchcondition != NULL)
471 app_info->launchcondition = strdup(data->launchcondition);
472 if (data->indicatordisplay != NULL)
473 app_info->indicatordisplay = strdup(data->indicatordisplay);
474 if (data->portraitimg != NULL)
475 app_info->portraitimg = strdup(data->portraitimg);
476 if (data->landscapeimg != NULL)
477 app_info->landscapeimg = strdup(data->landscapeimg);
478 if (data->guestmode_visibility != NULL)
479 app_info->guestmode_visibility =
480 strdup(data->guestmode_visibility);
481 if (data->component != NULL)
482 app_info->component = strdup(data->component);
483 if (data->permission_type != NULL)
484 app_info->permission_type = strdup(data->permission_type);
485 if (data->component_type != NULL)
486 app_info->component_type = strdup(data->component_type);
487 if (data->preload != NULL)
488 app_info->preload = strdup(data->preload);
489 if (data->submode != NULL)
490 app_info->submode = strdup(data->submode);
491 if (data->submode_mainid != NULL)
492 app_info->submode_mainid = strdup(data->submode_mainid);
493 if (data->process_pool != NULL)
494 app_info->process_pool = strdup(data->process_pool);
495 if (data->installed_storage != NULL)
496 app_info->installed_storage = strdup(data->installed_storage);
497 if (data->autorestart != NULL)
498 app_info->autorestart = strdup(data->autorestart);
499 if (data->onboot != NULL)
500 app_info->onboot = strdup(data->onboot);
501 if (data->support_disable != NULL)
502 app_info->support_disable = strdup(data->support_disable);
503 if (data->ui_gadget != NULL)
504 app_info->ui_gadget = strdup(data->ui_gadget);
505 if (data->launch_mode != NULL)
506 app_info->launch_mode = strdup(data->launch_mode);
507 if (data->package_type != NULL)
508 app_info->package_type = strdup(data->package_type);
509 if (data->effective_appid != NULL)
510 app_info->effective_appid = strdup(data->effective_appid);
511 if (data->splash_screen_display != NULL)
512 app_info->splash_screen_display =
513 strdup(data->splash_screen_display);
517 app_info->label = g_list_copy_deep(data->label, __copy_label, &ret);
519 LOGE("memory alloc failed");
520 pkgmgrinfo_basic_free_application(app_info);
521 return PMINFO_R_ERROR;
525 app_info->icon = g_list_copy_deep(data->icon, __copy_icon, &ret);
527 LOGE("memory alloc failed");
528 pkgmgrinfo_basic_free_application(app_info);
529 return PMINFO_R_ERROR;
533 app_info->category = g_list_copy_deep(data->category, __copy_str, &ret);
535 LOGE("memory alloc failed");
536 pkgmgrinfo_basic_free_application(app_info);
537 return PMINFO_R_ERROR;
541 app_info->metadata = g_list_copy_deep(data->metadata,
542 __copy_metadata, &ret);
544 LOGE("memory alloc failed");
545 pkgmgrinfo_basic_free_application(app_info);
546 return PMINFO_R_ERROR;
550 app_info->datacontrol = g_list_copy_deep(data->datacontrol,
551 __copy_datacontrol, &ret);
553 LOGE("memory alloc failed");
554 pkgmgrinfo_basic_free_application(app_info);
555 return PMINFO_R_ERROR;
559 app_info->appcontrol = g_list_copy_deep(data->appcontrol,
560 __copy_appcontrol, &ret);
562 LOGE("memory alloc failed");
563 pkgmgrinfo_basic_free_application(app_info);
564 return PMINFO_R_ERROR;
568 app_info->background_category =
569 g_list_copy_deep(data->background_category,
572 LOGE("memory alloc failed");
573 pkgmgrinfo_basic_free_application(app_info);
574 return PMINFO_R_ERROR;
578 app_info->splashscreens = g_list_copy_deep(data->splashscreens,
579 __copy_splashscreens, &ret);
581 LOGE("memory alloc failed");
582 pkgmgrinfo_basic_free_application(app_info);
583 return PMINFO_R_ERROR;
586 *application = app_info;
591 API int pkgmgrinfo_appinfo_clone_appinfo(pkgmgrinfo_appinfo_h handle,
592 pkgmgrinfo_appinfo_h *clone)
594 pkgmgr_appinfo_x *info;
595 pkgmgr_appinfo_x *temp = (pkgmgr_appinfo_x *)handle;
598 return PMINFO_R_EINVAL;
600 info = calloc(1, sizeof(pkgmgr_appinfo_x));
602 LOGE("memory alloc failed");
603 return PMINFO_R_ERROR;
606 if (temp->package != NULL)
607 info->package = strdup(temp->package);
608 if (temp->locale != NULL)
609 info->locale = strdup(temp->locale);
611 info->app_component = temp->app_component;
613 if (_appinfo_copy_appinfo(&info->app_info, temp->app_info) < 0) {
614 LOGE("appinfo copy failed");
616 free((void *)info->package);
620 return PMINFO_R_ERROR;
628 static int _appinfo_get_filtered_foreach_appinfo(uid_t uid,
629 pkgmgrinfo_filter_x *filter, int flag,
630 pkgmgrinfo_app_list_cb app_list_cb,
634 pkgmgr_appinfo_x info;
640 list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
641 __free_applications);
643 return PMINFO_R_ERROR;
645 ret = _appinfo_get_applications(uid, uid, filter,
646 flag | PMINFO_APPINFO_GET_BASICINFO, list);
647 if (ret == PMINFO_R_ERROR) {
648 g_hash_table_destroy(list);
652 g_hash_table_iter_init(&iter, list);
653 while (g_hash_table_iter_next(&iter, NULL, &value)) {
654 app = (application_x *)value;
656 info.locale = info.app_info->locale;
657 info.package = app->package;
658 if (app_list_cb(&info, user_data) < 0)
661 g_hash_table_destroy(list);
666 static const char *__appcomponent_str(pkgmgrinfo_app_component comp);
668 API int pkgmgrinfo_appinfo_get_usr_list(pkgmgrinfo_pkginfo_h handle,
669 pkgmgrinfo_app_component component,
670 pkgmgrinfo_app_list_cb app_func, void *user_data, uid_t uid)
673 pkgmgrinfo_appinfo_filter_h filter;
675 const char *comp_str = NULL;
677 if (handle == NULL || app_func == NULL) {
678 LOGE("invalid parameter");
679 return PMINFO_R_EINVAL;
682 if (pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid)) {
683 LOGE("invalid parameter");
684 return PMINFO_R_EINVAL;
687 if (pkgmgrinfo_appinfo_filter_create(&filter))
688 return PMINFO_R_ERROR;
690 if (pkgmgrinfo_appinfo_filter_add_string(filter,
691 PMINFO_APPINFO_PROP_APP_PACKAGE, pkgid)) {
692 pkgmgrinfo_appinfo_filter_destroy(filter);
693 return PMINFO_R_ERROR;
696 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
697 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
698 pkgmgrinfo_appinfo_filter_destroy(filter);
699 return PMINFO_R_ERROR;
702 comp_str = __appcomponent_str(component);
705 if (pkgmgrinfo_appinfo_filter_add_string(filter,
706 PMINFO_APPINFO_PROP_APP_COMPONENT,
708 pkgmgrinfo_appinfo_filter_destroy(filter);
709 return PMINFO_R_ERROR;
713 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter,
714 PMINFO_APPINFO_GET_ALL, app_func, user_data);
716 pkgmgrinfo_appinfo_filter_destroy(filter);
721 API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle,
722 pkgmgrinfo_app_component component,
723 pkgmgrinfo_app_list_cb app_func, void *user_data)
725 return pkgmgrinfo_appinfo_get_usr_list(handle,
726 component, app_func, user_data, _getuid());
729 API int pkgmgrinfo_appinfo_get_usr_installed_list_full(
730 pkgmgrinfo_app_list_cb app_func, uid_t uid, int flag,
734 pkgmgrinfo_appinfo_filter_h filter;
736 if (app_func == NULL) {
737 LOGE("invalid parameter");
738 return PMINFO_R_EINVAL;
741 if (pkgmgrinfo_appinfo_filter_create(&filter))
742 return PMINFO_R_ERROR;
744 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
745 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
746 pkgmgrinfo_appinfo_filter_destroy(filter);
747 return PMINFO_R_ERROR;
750 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
751 PMINFO_APPINFO_PROP_PKG_DISABLE, false)) {
752 pkgmgrinfo_appinfo_filter_destroy(filter);
753 return PMINFO_R_ERROR;
756 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
757 PMINFO_APPINFO_PROP_APP_CHECK_STORAGE, false)) {
758 pkgmgrinfo_appinfo_filter_destroy(filter);
759 return PMINFO_R_ERROR;
762 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter, flag, app_func,
765 pkgmgrinfo_appinfo_filter_destroy(filter);
770 API int pkgmgrinfo_appinfo_get_installed_list_full(
771 pkgmgrinfo_app_list_cb app_func, int flag, void *user_data)
773 return pkgmgrinfo_appinfo_get_usr_installed_list_full(app_func,
774 _getuid(), flag, user_data);
777 API int pkgmgrinfo_appinfo_get_usr_installed_list(
778 pkgmgrinfo_app_list_cb app_func, uid_t uid, void *user_data)
781 pkgmgrinfo_appinfo_filter_h filter;
783 if (app_func == NULL) {
784 LOGE("invalid parameter");
785 return PMINFO_R_EINVAL;
788 /* create an empty filter */
789 ret = pkgmgrinfo_appinfo_filter_create(&filter);
790 if (ret != PMINFO_R_OK)
793 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
794 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
795 pkgmgrinfo_appinfo_filter_destroy(filter);
796 return PMINFO_R_ERROR;
799 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
800 PMINFO_APPINFO_PROP_PKG_DISABLE, false)) {
801 pkgmgrinfo_appinfo_filter_destroy(filter);
802 return PMINFO_R_ERROR;
805 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter,
806 PMINFO_APPINFO_GET_ALL, app_func, user_data);
808 pkgmgrinfo_appinfo_filter_destroy(filter);
813 API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func,
816 return pkgmgrinfo_appinfo_get_usr_installed_list(app_func, _getuid(),
820 API int pkgmgrinfo_appinfo_get_appid(pkgmgrinfo_appinfo_h handle, char **appid)
822 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
824 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
825 retvm_if(appid == NULL, PMINFO_R_EINVAL,
826 "Argument supplied to hold return value is NULL");
828 if (info->app_info == NULL || info->app_info->appid == NULL)
829 return PMINFO_R_ERROR;
830 *appid = (char *)info->app_info->appid;
835 API int pkgmgrinfo_appinfo_get_pkgname(
836 pkgmgrinfo_appinfo_h handle, char **pkg_name)
838 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
840 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
841 retvm_if(pkg_name == NULL, PMINFO_R_EINVAL,
842 "Argument supplied to hold return value is NULL");
844 if (info->package == NULL)
845 return PMINFO_R_ERROR;
847 *pkg_name = (char *)info->package;
852 API int pkgmgrinfo_appinfo_get_pkgid(pkgmgrinfo_appinfo_h handle, char **pkgid)
854 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
856 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
857 retvm_if(pkgid == NULL, PMINFO_R_EINVAL,
858 "Argument supplied to hold return value is NULL");
860 if (info->package == NULL)
861 return PMINFO_R_ERROR;
863 *pkgid = (char *)info->package;
868 API int pkgmgrinfo_appinfo_get_pkgtype(
869 pkgmgrinfo_appinfo_h handle, char **pkgtype)
871 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
872 retvm_if(pkgtype == NULL, PMINFO_R_EINVAL,
873 "Argument supplied to hold return value is NULL");
874 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
876 *pkgtype = (char *)info->app_info->package_type;
881 API int pkgmgrinfo_appinfo_get_exec(pkgmgrinfo_appinfo_h handle, char **exec)
883 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
885 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
886 retvm_if(exec == NULL, PMINFO_R_EINVAL,
887 "Argument supplied to hold return value is NULL");
889 if (info->app_info == NULL || info->app_info->exec == NULL)
890 return PMINFO_R_ERROR;
891 *exec = (char *)info->app_info->exec;
897 API int pkgmgrinfo_appinfo_get_icon(pkgmgrinfo_appinfo_h handle, char **icon)
900 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
902 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
903 retvm_if(icon == NULL, PMINFO_R_EINVAL,
904 "Argument supplied to hold return value is NULL");
906 if (info->app_info == NULL)
907 return PMINFO_R_ERROR;
909 if (info->app_info->icon == NULL) {
914 ptr = (icon_x *)info->app_info->icon->data;
916 return PMINFO_R_ERROR;
918 if (ptr->text == NULL)
919 return PMINFO_R_ERROR;
927 API int pkgmgrinfo_appinfo_get_label(pkgmgrinfo_appinfo_h handle, char **label)
930 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
935 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
936 retvm_if(label == NULL, PMINFO_R_EINVAL,
937 "Argument supplied to hold return value is NULL");
939 if (info->app_info == NULL)
940 return PMINFO_R_ERROR;
942 locale = info->locale;
944 locale = DEFAULT_LOCALE;
946 for (tmp = info->app_info->label; tmp; tmp = tmp->next) {
947 ptr = (label_x *)tmp->data;
948 if (ptr == NULL || strcmp(locale, ptr->lang) != 0)
959 for (tmp = info->app_info->label; tmp; tmp = tmp->next) {
960 ptr = (label_x *)tmp->data;
961 if (ptr == NULL || strcmp(DEFAULT_LOCALE, ptr->lang) != 0)
967 *label = lbl ? lbl : "";
972 API int pkgmgrinfo_appinfo_usr_get_localed_label(const char *appid,
973 const char *locale, uid_t uid, char **label)
977 retvm_if(appid == NULL || locale == NULL || label == NULL,
978 PMINFO_R_EINVAL, "Argument is NULL");
979 val = _appinfo_get_localed_label(appid, locale, uid);
981 return PMINFO_R_ERROR;
987 API int pkgmgrinfo_appinfo_get_localed_label(
988 const char *appid, const char *locale, char **label)
990 return pkgmgrinfo_appinfo_usr_get_localed_label(
991 appid, locale, _getuid(), label);
994 API int pkgmgrinfo_appinfo_get_metadata_value(
995 pkgmgrinfo_appinfo_h handle, const char *metadata_key,
996 char **metadata_value)
998 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
999 retvm_if(metadata_key == NULL, PMINFO_R_EINVAL, "metadata_key is NULL");
1000 retvm_if(metadata_value == NULL, PMINFO_R_EINVAL,
1001 "metadata_value is NULL");
1003 GList *list_md = NULL;
1004 metadata_x *metadata = NULL;
1005 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1007 list_md = info->app_info->metadata;
1009 for (; list_md; list_md = list_md->next) {
1010 metadata = (metadata_x *)list_md->data;
1011 if (metadata && metadata->key) {
1012 if (strcasecmp(metadata->key, metadata_key) == 0) {
1013 if (metadata->value == NULL)
1014 *metadata_value = "";
1017 (char *)metadata->value;
1023 return PMINFO_R_EINVAL;
1026 static pkgmgrinfo_app_component __appcomponent_convert(const char *comp)
1028 if (strcasecmp(comp, "uiapp") == 0)
1029 return PMINFO_UI_APP;
1030 else if (strcasecmp(comp, "svcapp") == 0)
1031 return PMINFO_SVC_APP;
1032 else if (strcasecmp(comp, "widgetapp") == 0)
1033 return PMINFO_WIDGET_APP;
1034 else if (strcasecmp(comp, "watchapp") == 0)
1035 return PMINFO_WATCH_APP;
1036 else if (strcasecmp(comp, "componentbasedapp") == 0)
1037 return PMINFO_COMPONENT_BASED_APP;
1042 static const char *__appcomponent_str(pkgmgrinfo_app_component comp)
1047 case PMINFO_SVC_APP:
1049 case PMINFO_WIDGET_APP:
1051 case PMINFO_WATCH_APP:
1053 case PMINFO_COMPONENT_BASED_APP:
1054 return "componentbasedapp";
1060 API int pkgmgrinfo_appinfo_get_component(
1061 pkgmgrinfo_appinfo_h handle,
1062 pkgmgrinfo_app_component *component)
1064 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1067 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1068 retvm_if(component == NULL, PMINFO_R_EINVAL,
1069 "Argument supplied to hold return value is NULL");
1071 if (info->app_info == NULL)
1072 return PMINFO_R_ERROR;
1074 comp = __appcomponent_convert(info->app_info->component);
1076 return PMINFO_R_ERROR;
1083 API int pkgmgrinfo_appinfo_get_apptype(
1084 pkgmgrinfo_appinfo_h handle, char **app_type)
1086 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1088 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1089 retvm_if(app_type == NULL, PMINFO_R_EINVAL,
1090 "Argument supplied to hold return value is NULL");
1092 if (info->app_info == NULL || info->app_info->type == NULL)
1093 return PMINFO_R_ERROR;
1094 *app_type = (char *)info->app_info->type;
1099 API int pkgmgrinfo_appinfo_get_notification_icon(
1100 pkgmgrinfo_appinfo_h handle, char **icon)
1105 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1107 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1108 retvm_if(icon == NULL, PMINFO_R_EINVAL,
1109 "Argument supplied to hold return value is NULL\n");
1111 if (info->app_info == NULL)
1112 return PMINFO_R_ERROR;
1114 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1115 ptr = (icon_x *)tmp->data;
1116 if (ptr == NULL || ptr->section == NULL)
1119 val = (char *)ptr->section;
1120 if (val && strcmp(val, "notification") == 0) {
1121 *icon = (char *)ptr->text;
1126 return PMINFO_R_ERROR;
1129 API int pkgmgrinfo_appinfo_get_recent_image_type(
1130 pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_recentimage *type)
1133 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1135 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1136 retvm_if(type == NULL, PMINFO_R_EINVAL,
1137 "Argument supplied to hold return value is NULL");
1139 if (info->app_info == NULL || info->app_info->recentimage == NULL)
1140 return PMINFO_R_ERROR;
1142 val = (char *)info->app_info->recentimage;
1143 if (strcasecmp(val, "capture") == 0)
1144 *type = PMINFO_RECENTIMAGE_USE_CAPTURE;
1145 else if (strcasecmp(val, "icon") == 0)
1146 *type = PMINFO_RECENTIMAGE_USE_ICON;
1148 *type = PMINFO_RECENTIMAGE_USE_NOTHING;
1153 API int pkgmgrinfo_appinfo_get_preview_image(
1154 pkgmgrinfo_appinfo_h handle, char **preview_img)
1159 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1161 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1162 retvm_if(preview_img == NULL, PMINFO_R_EINVAL,
1163 "Argument supplied to hold return value is NULL\n");
1165 if (info->app_info == NULL)
1166 return PMINFO_R_ERROR;
1168 for (tmp = info->app_info->image; tmp; tmp = tmp->next) {
1169 ptr = (image_x *)tmp->data;
1170 if (ptr == NULL || ptr->section == NULL)
1173 val = (char *)ptr->section;
1174 if (val && strcmp(val, "preview") == 0) {
1175 *preview_img = (char *)ptr->text;
1180 return PMINFO_R_ERROR;
1183 API int pkgmgrinfo_appinfo_get_permission_type(
1184 pkgmgrinfo_appinfo_h handle,
1185 pkgmgrinfo_permission_type *permission)
1188 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1190 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1191 retvm_if(permission == NULL, PMINFO_R_EINVAL,
1192 "Argument supplied to hold return value is NULL\n");
1194 val = info->app_info->permission_type;
1196 return PMINFO_R_ERROR;
1198 if (strcmp(val, "signature") == 0)
1199 *permission = PMINFO_PERMISSION_SIGNATURE;
1200 else if (strcmp(val, "privilege") == 0)
1201 *permission = PMINFO_PERMISSION_PRIVILEGE;
1203 *permission = PMINFO_PERMISSION_NORMAL;
1208 API int pkgmgrinfo_appinfo_get_component_type(
1209 pkgmgrinfo_appinfo_h handle, char **component_type)
1211 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1213 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1214 retvm_if(component_type == NULL, PMINFO_R_EINVAL,
1215 "Argument supplied to hold return value is NULL");
1217 if (info->app_info == NULL || info->app_info->component_type == NULL)
1218 return PMINFO_R_ERROR;
1220 *component_type = (char *)info->app_info->component_type;
1225 API int pkgmgrinfo_appinfo_get_hwacceleration(
1226 pkgmgrinfo_appinfo_h handle,
1227 pkgmgrinfo_app_hwacceleration *hwacceleration)
1230 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1232 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1233 retvm_if(hwacceleration == NULL, PMINFO_R_EINVAL,
1234 "Argument supplied to hold return value is NULL");
1236 if (info->app_info == NULL || info->app_info->hwacceleration == NULL)
1237 return PMINFO_R_ERROR;
1239 val = (char *)info->app_info->hwacceleration;
1240 if (strcasecmp(val, "off") == 0)
1241 *hwacceleration = PMINFO_HWACCELERATION_OFF;
1242 else if (strcasecmp(val, "on") == 0)
1243 *hwacceleration = PMINFO_HWACCELERATION_ON;
1245 *hwacceleration = PMINFO_HWACCELERATION_DEFAULT;
1250 API int pkgmgrinfo_appinfo_get_screenreader(
1251 pkgmgrinfo_appinfo_h handle,
1252 pkgmgrinfo_app_screenreader *screenreader)
1255 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1257 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1258 retvm_if(screenreader == NULL, PMINFO_R_EINVAL,
1259 "Argument supplied to hold return value is NULL");
1261 if (info->app_info == NULL || info->app_info->screenreader == NULL)
1262 return PMINFO_R_ERROR;
1264 val = (char *)info->app_info->screenreader;
1265 if (strcasecmp(val, "screenreader-off") == 0)
1266 *screenreader = PMINFO_SCREENREADER_OFF;
1267 else if (strcasecmp(val, "screenreader-on") == 0)
1268 *screenreader = PMINFO_SCREENREADER_ON;
1270 *screenreader = PMINFO_SCREENREADER_USE_SYSTEM_SETTING;
1275 API int pkgmgrinfo_appinfo_get_effectimage(
1276 pkgmgrinfo_appinfo_h handle, char **portrait_img,
1277 char **landscape_img)
1279 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1281 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1282 retvm_if(portrait_img == NULL, PMINFO_R_EINVAL,
1283 "Argument supplied to hold return value is NULL");
1284 retvm_if(landscape_img == NULL, PMINFO_R_EINVAL,
1285 "Argument supplied to hold return value is NULL");
1287 if (info->app_info == NULL)
1288 return PMINFO_R_ERROR;
1290 if (info->app_info->portraitimg == NULL)
1293 *portrait_img = (char *)info->app_info->portraitimg;
1295 if (info->app_info->landscapeimg == NULL)
1296 *landscape_img = "";
1298 *landscape_img = (char *)info->app_info->landscapeimg;
1303 API int pkgmgrinfo_appinfo_get_effectimage_type(
1304 pkgmgrinfo_appinfo_h handle, char **effectimage_type)
1306 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1308 if (handle == NULL || effectimage_type == NULL) {
1309 LOGE("invalid parameter");
1310 return PMINFO_R_EINVAL;
1313 if (info->app_info == NULL || info->app_info->effectimage_type == NULL)
1314 return PMINFO_R_ERROR;
1316 *effectimage_type = (char *)info->app_info->effectimage_type;
1321 API int pkgmgrinfo_appinfo_get_submode_mainid(
1322 pkgmgrinfo_appinfo_h handle, char **submode_mainid)
1324 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1326 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1327 retvm_if(submode_mainid == NULL, PMINFO_R_EINVAL,
1328 "Argument supplied to hold return value is NULL");
1330 if (info->app_info == NULL)
1331 return PMINFO_R_ERROR;
1333 if (info->app_info->submode_mainid == NULL)
1334 *submode_mainid = "";
1336 *submode_mainid = (char *)info->app_info->submode_mainid;
1341 API int pkgmgrinfo_appinfo_get_installed_storage_location(
1342 pkgmgrinfo_appinfo_h handle,
1343 pkgmgrinfo_installed_storage *storage)
1345 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1346 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1348 if (info->app_info && info->app_info->installed_storage) {
1349 if (strcmp(info->app_info->installed_storage,
1350 "installed_internal") == 0)
1351 *storage = PMINFO_INTERNAL_STORAGE;
1352 else if (strcmp(info->app_info->installed_storage,
1353 "installed_external") == 0)
1354 *storage = PMINFO_EXTERNAL_STORAGE;
1356 return PMINFO_R_ERROR;
1358 return PMINFO_R_ERROR;
1364 API int pkgmgrinfo_appinfo_get_launch_mode(
1365 pkgmgrinfo_appinfo_h handle, char **mode)
1367 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1369 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1370 retvm_if(mode == NULL, PMINFO_R_EINVAL,
1371 "Argument supplied to hold return value is NULL\n");
1373 if (info->app_info->launch_mode == NULL)
1374 return PMINFO_R_ERROR;
1376 *mode = (char *)(info->app_info->launch_mode);
1381 API int pkgmgrinfo_appinfo_get_alias_appid(
1382 pkgmgrinfo_appinfo_h handle, char **alias_appid)
1384 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1386 if (handle == NULL || alias_appid == NULL) {
1387 LOGE("invalid parameter");
1388 return PMINFO_R_EINVAL;
1391 if (info->app_info == NULL || info->app_info->alias_appid == NULL)
1392 return PMINFO_R_ERROR;
1394 *alias_appid = (char *)info->app_info->alias_appid;
1399 API int pkgmgrinfo_appinfo_get_effective_appid(
1400 pkgmgrinfo_appinfo_h handle, char **effective_appid)
1402 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1404 if (handle == NULL || effective_appid == NULL) {
1405 LOGE("invalid parameter");
1406 return PMINFO_R_EINVAL;
1409 if (info->app_info == NULL)
1410 return PMINFO_R_ERROR;
1412 if (info->app_info->effective_appid == NULL)
1413 *effective_appid = "";
1415 *effective_appid = (char *)info->app_info->effective_appid;
1420 API int pkgmgrinfo_appinfo_get_tep_name(
1421 pkgmgrinfo_appinfo_h handle, char **tep_name)
1423 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1425 if (handle == NULL || tep_name == NULL) {
1426 LOGE("invalid parameter");
1427 return PMINFO_R_EINVAL;
1430 if (info->app_info == NULL)
1431 return PMINFO_R_ERROR;
1433 if (info->app_info->tep_name == NULL)
1436 *tep_name = (char *)info->app_info->tep_name;
1441 API int pkgmgrinfo_appinfo_get_zip_mount_file(
1442 pkgmgrinfo_appinfo_h handle, char **zip_mount_file)
1444 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1446 if (handle == NULL || zip_mount_file == NULL) {
1447 LOGE("invalid parameter");
1448 return PMINFO_R_EINVAL;
1451 if (info->app_info == NULL)
1452 return PMINFO_R_ERROR;
1454 if (info->app_info->zip_mount_file == NULL)
1455 *zip_mount_file = "";
1457 *zip_mount_file = (char *)info->app_info->zip_mount_file;
1462 API int pkgmgrinfo_appinfo_get_root_path(
1463 pkgmgrinfo_appinfo_h handle, char **root_path)
1465 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1467 if (handle == NULL || root_path == NULL) {
1468 LOGE("invalid parameter");
1469 return PMINFO_R_EINVAL;
1472 if (info->app_info == NULL || info->app_info->root_path == NULL)
1473 return PMINFO_R_ERROR;
1475 *root_path = (char *)info->app_info->root_path;
1480 API int pkgmgrinfo_appinfo_get_api_version(
1481 pkgmgrinfo_appinfo_h handle, char **api_version)
1483 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1485 if (handle == NULL || api_version == NULL) {
1486 LOGE("invalid parameter");
1487 return PMINFO_R_EINVAL;
1490 if (info->app_info == NULL || info->app_info->api_version == NULL)
1491 return PMINFO_R_ERROR;
1493 *api_version = (char *)info->app_info->api_version;
1498 API int pkgmgrinfo_appinfo_get_installed_time(
1499 pkgmgrinfo_appinfo_h handle, int *installed_time)
1501 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1503 if (handle == NULL || installed_time == NULL) {
1504 LOGE("invalid parameter");
1505 return PMINFO_R_EINVAL;
1508 if (info->app_info == NULL ||
1509 info->app_info->package_installed_time == NULL)
1510 return PMINFO_R_ERROR;
1512 *installed_time = atoi(info->app_info->package_installed_time);
1517 API int pkgmgrinfo_appinfo_usr_get_datacontrol_info(const char *providerid,
1518 const char *type, uid_t uid, char **appid, char **access)
1522 if (providerid == NULL || type == NULL || appid == NULL ||
1524 LOGE("invalid parameter");
1525 return PMINFO_R_EINVAL;
1528 ret = _appinfo_get_datacontrol_info(
1529 providerid, type, uid, appid, access);
1530 /* FIXME: It should return PMINFO_R_ENOENT but to keep previous
1531 * implementation, return PMINFO_R_ERROR. This should be
1534 if (ret == PMINFO_R_ENOENT) {
1535 LOGE("no datacontrol info of %s", providerid);
1536 ret = PMINFO_R_ERROR;
1542 API int pkgmgrinfo_appinfo_get_datacontrol_info(const char *providerid,
1543 const char *type, char **appid, char **access)
1545 return pkgmgrinfo_appinfo_usr_get_datacontrol_info(providerid,
1546 type, _getuid(), appid, access);
1549 API int pkgmgrinfo_appinfo_usr_get_datacontrol_appid(const char *providerid,
1550 uid_t uid, char **appid)
1554 if (providerid == NULL || appid == NULL) {
1555 LOGE("invalid parameter");
1556 return PMINFO_R_EINVAL;
1559 ret = _appinfo_get_datacontrol_appid(providerid, uid, appid);
1560 /* FIXME: It should return PMINFO_R_ENOENT but to keep previous
1561 * implementation, return PMINFO_R_ERROR. This should be
1564 if (ret == PMINFO_R_ENOENT) {
1565 LOGE("no datacontrol appid of %s", providerid);
1566 ret = PMINFO_R_ERROR;
1572 API int pkgmgrinfo_appinfo_get_datacontrol_appid(
1573 const char *providerid, char **appid)
1575 return pkgmgrinfo_appinfo_usr_get_datacontrol_appid(
1576 providerid, _getuid(), appid);
1579 API int pkgmgrinfo_appinfo_usr_get_datacontrol_trusted_info(
1580 const char *providerid, const char *type, uid_t uid,
1581 char **appid, bool *is_trusted)
1584 char *trusted = NULL;
1586 if (providerid == NULL || type == NULL || appid == NULL ||
1587 is_trusted == NULL) {
1588 LOGE("invalid parameter");
1589 return PMINFO_R_EINVAL;
1592 ret = _appinfo_get_datacontrol_trusted_info(providerid, type, uid,
1595 /* FIXME: It should return PMINFO_R_ENOENT but to keep previous
1596 * implementation, return PMINFO_R_ERROR. This should be
1599 if (ret == PMINFO_R_ENOENT) {
1600 LOGE("no datacontrol trusted info of %s", providerid);
1601 ret = PMINFO_R_ERROR;
1603 *is_trusted = _get_bool_value(trusted);
1609 API int pkgmgrinfo_appinfo_get_datacontrol_trsuted_info(const char *providerid,
1610 const char *type, char **appid, bool *is_trusted)
1612 return pkgmgrinfo_appinfo_usr_get_datacontrol_trusted_info(providerid,
1613 type, _getuid(), appid, is_trusted);
1616 API int pkgmgrinfo_appinfo_usr_foreach_datacontrol_privileges(
1617 const char *providerid, const char *type,
1618 pkgmgrinfo_pkg_privilege_list_cb privilege_func,
1619 void *user_data, uid_t uid)
1626 if (providerid == NULL || type == NULL || privilege_func == NULL) {
1627 LOGE("invalid parameter");
1628 return PMINFO_R_EINVAL;
1631 ret = _appinfo_get_datacontrol_privileges(providerid, type, uid, &list);
1632 if (ret == PMINFO_R_ERROR) {
1633 g_list_free_full(list, free);
1637 for (tmp = list; tmp != NULL; tmp = g_list_next(tmp)) {
1639 ret = privilege_func((char *)tmp->data, user_data);
1644 g_list_free_full(list, free);
1648 API int pkgmgrinfo_appinfo_foreach_datacontrol_privileges(
1649 const char *providerid, const char *type,
1650 pkgmgrinfo_pkg_privilege_list_cb privilege_func,
1653 return pkgmgrinfo_appinfo_usr_foreach_datacontrol_privileges(
1654 providerid, type, privilege_func, user_data, _getuid());
1657 API int pkgmgrinfo_appinfo_get_support_mode(
1658 pkgmgrinfo_appinfo_h handle, int *support_mode)
1660 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1661 retvm_if(support_mode == NULL, PMINFO_R_EINVAL,
1662 "Argument supplied to hold return value is NULL");
1664 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1666 if (info->app_info->support_mode)
1667 *support_mode = atoi(info->app_info->support_mode);
1674 API int pkgmgrinfo_appinfo_foreach_category(pkgmgrinfo_appinfo_h handle,
1675 pkgmgrinfo_app_category_list_cb category_func, void *user_data)
1677 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1678 retvm_if(category_func == NULL, PMINFO_R_EINVAL,
1679 "Callback function is NULL");
1681 const char *category;
1683 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1685 if (info->app_info == NULL)
1686 return PMINFO_R_ERROR;
1688 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
1689 category = (const char *)tmp->data;
1691 ret = category_func(category, user_data);
1699 API int pkgmgrinfo_appinfo_foreach_metadata(pkgmgrinfo_appinfo_h handle,
1700 pkgmgrinfo_app_metadata_list_cb metadata_func, void *user_data)
1702 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1703 retvm_if(metadata_func == NULL, PMINFO_R_EINVAL,
1704 "Callback function is NULL");
1708 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1710 if (info->app_info == NULL)
1711 return PMINFO_R_ERROR;
1713 for (tmp = info->app_info->metadata; tmp; tmp = tmp->next) {
1714 ptr = (metadata_x *)tmp->data;
1718 ret = metadata_func(ptr->key, ptr->value ?
1719 ptr->value : "", user_data);
1727 API int pkgmgrinfo_appinfo_usr_foreach_appcontrol_privileges(const char *appid,
1728 const char *operation,
1729 pkgmgrinfo_pkg_privilege_list_cb privilege_func,
1730 void *user_data, uid_t uid)
1733 GList *privilege_list = NULL;
1736 if (appid == NULL || operation == NULL || privilege_func == NULL) {
1737 LOGE("invalid parameter");
1738 return PMINFO_R_EINVAL;
1741 ret = _appinfo_get_appcontrol_privileges(appid, operation, uid,
1743 if (ret == PMINFO_R_ENOENT) {
1745 } else if (ret != PMINFO_R_OK) {
1746 g_list_free_full(privilege_list, free);
1750 for (tmp_list = privilege_list; tmp_list != NULL;
1751 tmp_list = g_list_next(tmp_list)) {
1752 ret = privilege_func((char *)tmp_list->data, user_data);
1757 g_list_free_full(privilege_list, free);
1761 API int pkgmgrinfo_appinfo_foreach_appcontrol_privileges(const char *appid,
1762 const char *operation,
1763 pkgmgrinfo_pkg_privilege_list_cb privilege_func,
1766 return pkgmgrinfo_appinfo_usr_foreach_appcontrol_privileges(appid,
1767 operation, privilege_func, user_data, _getuid());
1770 API int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
1771 pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
1773 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1774 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL,
1775 "Callback function is NULL");
1777 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1778 appcontrol_x *appcontrol;
1781 if (info->app_info == NULL)
1782 return PMINFO_R_ERROR;
1784 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
1785 appcontrol = (appcontrol_x *)tmp->data;
1786 if (appcontrol == NULL || !strcasecmp(
1787 appcontrol->visibility, "remote-only"))
1789 ret = appcontrol_func(appcontrol->operation,
1790 appcontrol->uri, appcontrol->mime, user_data);
1798 API int pkgmgrinfo_appinfo_foreach_remote_appcontrol(
1799 pkgmgrinfo_appinfo_h handle,
1800 pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
1802 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1803 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL,
1804 "Callback function is NULL");
1806 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1807 appcontrol_x *appcontrol;
1810 if (info->app_info == NULL)
1811 return PMINFO_R_ERROR;
1813 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
1814 appcontrol = (appcontrol_x *)tmp->data;
1815 if (appcontrol == NULL || !strcasecmp(
1816 appcontrol->visibility, "local-only"))
1818 ret = appcontrol_func(appcontrol->operation, appcontrol->uri,
1819 appcontrol->mime, user_data);
1827 API int pkgmgrinfo_appinfo_foreach_background_category(
1828 pkgmgrinfo_appinfo_h handle,
1829 pkgmgrinfo_app_background_category_list_cb category_func,
1832 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1836 if (handle == NULL || category_func == NULL || info->app_info == NULL) {
1837 LOGE("invalid parameter");
1838 return PMINFO_R_EINVAL;
1841 for (tmp = info->app_info->background_category; tmp; tmp = tmp->next) {
1842 category = (char *)tmp->data;
1843 if (category == NULL)
1846 if (category_func(category, user_data) < 0)
1853 API int pkgmgrinfo_appinfo_foreach_splash_screen(pkgmgrinfo_appinfo_h handle,
1854 pkgmgrinfo_app_splash_screen_list_cb splash_screen_func,
1857 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1858 splashscreen_x *splashscreen;
1862 if (info == NULL || info->app_info == NULL
1863 || splash_screen_func == NULL) {
1864 LOGE("invalid parameter");
1865 return PMINFO_R_EINVAL;
1868 for (tmp = info->app_info->splashscreens; tmp; tmp = tmp->next) {
1869 splashscreen = (splashscreen_x *)tmp->data;
1870 if (splashscreen == NULL)
1872 ret = splash_screen_func(splashscreen->src,
1874 splashscreen->orientation,
1875 splashscreen->indicatordisplay,
1876 splashscreen->operation,
1877 splashscreen->color_depth,
1886 API int pkgmgrinfo_appinfo_is_nodisplay(
1887 pkgmgrinfo_appinfo_h handle, bool *nodisplay)
1889 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1890 retvm_if(nodisplay == NULL, PMINFO_R_EINVAL,
1891 "Argument supplied to hold return value is NULL");
1892 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1894 if (info->app_info == NULL || info->app_info->nodisplay == NULL)
1895 return PMINFO_R_ERROR;
1897 *nodisplay = _get_bool_value(info->app_info->nodisplay);
1902 API int pkgmgrinfo_appinfo_is_multiple(
1903 pkgmgrinfo_appinfo_h handle, bool *multiple)
1905 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1906 retvm_if(multiple == NULL, PMINFO_R_EINVAL,
1907 "Argument supplied to hold return value is NULL");
1908 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1910 if (info->app_info == NULL || info->app_info->multiple == NULL)
1911 return PMINFO_R_ERROR;
1913 *multiple = _get_bool_value(info->app_info->multiple);
1918 API int pkgmgrinfo_appinfo_is_indicator_display_allowed(
1919 pkgmgrinfo_appinfo_h handle, bool *indicator_disp)
1921 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1922 retvm_if(indicator_disp == NULL, PMINFO_R_EINVAL,
1923 "Argument supplied to hold return value is NULL");
1924 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1926 if (info->app_info == NULL || info->app_info->indicatordisplay == NULL)
1927 return PMINFO_R_ERROR;
1929 *indicator_disp = _get_bool_value(info->app_info->indicatordisplay);
1934 API int pkgmgrinfo_appinfo_is_taskmanage(
1935 pkgmgrinfo_appinfo_h handle, bool *taskmanage)
1937 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1938 retvm_if(taskmanage == NULL, PMINFO_R_EINVAL,
1939 "Argument supplied to hold return value is NULL");
1940 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1942 if (info->app_info == NULL || info->app_info->taskmanage == NULL)
1943 return PMINFO_R_ERROR;
1945 *taskmanage = _get_bool_value(info->app_info->taskmanage);
1950 API int pkgmgrinfo_appinfo_is_enabled(
1951 pkgmgrinfo_appinfo_h handle, bool *enabled)
1953 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1954 retvm_if(enabled == NULL, PMINFO_R_EINVAL,
1955 "Argument supplied to hold return value is NULL");
1956 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1958 if (info->app_info == NULL || info->app_info->is_disabled == NULL)
1959 return PMINFO_R_ERROR;
1961 *enabled = !_get_bool_value(info->app_info->is_disabled);
1966 API int pkgmgrinfo_appinfo_is_onboot(
1967 pkgmgrinfo_appinfo_h handle, bool *onboot)
1969 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1970 retvm_if(onboot == NULL, PMINFO_R_EINVAL,
1971 "Argument supplied to hold return value is NULL");
1972 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1974 if (info->app_info == NULL || info->app_info->onboot == NULL)
1975 return PMINFO_R_ERROR;
1977 *onboot = _get_bool_value(info->app_info->onboot);
1982 API int pkgmgrinfo_appinfo_is_autorestart(
1983 pkgmgrinfo_appinfo_h handle, bool *autorestart)
1985 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1986 retvm_if(autorestart == NULL, PMINFO_R_EINVAL,
1987 "Argument supplied to hold return value is NULL");
1988 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1990 if (info->app_info == NULL || info->app_info->autorestart == NULL)
1991 return PMINFO_R_ERROR;
1993 *autorestart = _get_bool_value(info->app_info->autorestart);
1998 API int pkgmgrinfo_appinfo_is_mainapp(
1999 pkgmgrinfo_appinfo_h handle, bool *mainapp)
2001 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2002 retvm_if(mainapp == NULL, PMINFO_R_EINVAL,
2003 "Argument supplied to hold return value is NULL");
2004 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2006 if (info->app_info == NULL || info->app_info->mainapp == NULL)
2007 return PMINFO_R_ERROR;
2009 *mainapp = _get_bool_value(info->app_info->mainapp);
2014 API int pkgmgrinfo_appinfo_is_preload(
2015 pkgmgrinfo_appinfo_h handle, bool *preload)
2017 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2018 retvm_if(preload == NULL, PMINFO_R_EINVAL,
2019 "Argument supplied to hold return value is NULL\n");
2020 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2022 if (info->app_info == NULL || info->app_info->preload == NULL)
2023 return PMINFO_R_ERROR;
2025 *preload = _get_bool_value(info->app_info->preload);
2030 API int pkgmgrinfo_appinfo_is_submode(
2031 pkgmgrinfo_appinfo_h handle, bool *submode)
2033 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2034 retvm_if(submode == NULL, PMINFO_R_EINVAL,
2035 "Argument supplied to hold return value is NULL\n");
2036 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2038 if (info->app_info == NULL || info->app_info->submode == NULL)
2039 return PMINFO_R_ERROR;
2041 *submode = _get_bool_value(info->app_info->submode);
2046 API int pkgmgrinfo_appinfo_is_process_pool(
2047 pkgmgrinfo_appinfo_h handle, bool *process_pool)
2049 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2051 if (handle == NULL || process_pool == NULL) {
2052 LOGE("invalid parameter");
2053 return PMINFO_R_EINVAL;
2056 if (info->app_info == NULL)
2057 return PMINFO_R_ERROR;
2059 *process_pool = _get_bool_value(info->app_info->process_pool);
2064 API int pkgmgrinfo_appinfo_is_category_exist(
2065 pkgmgrinfo_appinfo_h handle, const char *category, bool *exist)
2067 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2068 retvm_if(category == NULL, PMINFO_R_EINVAL, "category is NULL");
2069 retvm_if(exist == NULL, PMINFO_R_EINVAL, "exist is NULL");
2073 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2075 if (info->app_info == NULL)
2076 return PMINFO_R_ERROR;
2079 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
2080 val = (const char *)tmp->data;
2083 if (strcasecmp(val, category) == 0) {
2092 API int pkgmgrinfo_appinfo_is_ui_gadget(pkgmgrinfo_appinfo_h handle,
2095 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2097 if (info == NULL || info->app_info == NULL || ui_gadget == NULL) {
2098 _LOGE("invalid parameter");
2099 return PMINFO_R_EINVAL;
2101 if (info->app_info->ui_gadget == NULL)
2102 info->app_info->ui_gadget = strdup("false");
2104 *ui_gadget = _get_bool_value(info->app_info->ui_gadget);
2109 API int pkgmgrinfo_appinfo_is_support_disable(pkgmgrinfo_appinfo_h handle,
2110 bool *support_disable)
2112 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2114 if (info == NULL || info->app_info == NULL || support_disable == NULL) {
2115 _LOGE("invalid parameter");
2116 return PMINFO_R_EINVAL;
2119 *support_disable = _get_bool_value(info->app_info->support_disable);
2124 API int pkgmgrinfo_appinfo_is_removable(pkgmgrinfo_appinfo_h handle,
2127 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2129 if (info == NULL || info->app_info == NULL || removable == NULL) {
2130 _LOGE("invalid parameter");
2131 return PMINFO_R_EINVAL;
2134 *removable = _get_bool_value(info->app_info->removable);
2139 API int pkgmgrinfo_appinfo_is_system(pkgmgrinfo_appinfo_h handle, bool *system)
2141 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2143 if (info == NULL || info->app_info == NULL || system == NULL) {
2144 _LOGE("invalid parameter");
2145 return PMINFO_R_EINVAL;
2148 *system = _get_bool_value(info->app_info->package_system);
2153 API int pkgmgrinfo_appinfo_is_disabled(
2154 pkgmgrinfo_appinfo_h handle, bool *disabled)
2156 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2157 retvm_if(disabled == NULL, PMINFO_R_EINVAL,
2158 "Argument supplied to hold return value is NULL");
2159 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2161 if (info->app_info == NULL || info->app_info->is_disabled == NULL)
2162 return PMINFO_R_ERROR;
2164 *disabled = _get_bool_value(info->app_info->is_disabled);
2169 API int pkgmgrinfo_appinfo_is_global(pkgmgrinfo_appinfo_h handle, bool *global)
2171 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2173 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2174 retvm_if(global == NULL, PMINFO_R_EINVAL,
2175 "Argument supplied to hold return value is NULL\n");
2177 if (info->app_info == NULL || info->app_info->for_all_users == NULL)
2178 return PMINFO_R_ERROR;
2180 *global = _get_bool_value(info->app_info->for_all_users);
2185 API int pkgmgrinfo_appinfo_get_splash_screen_display(
2186 pkgmgrinfo_appinfo_h handle, bool *splash_screen_display)
2188 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2190 if (info == NULL || splash_screen_display == NULL) {
2191 _LOGE("Invalid parameter");
2192 return PMINFO_R_EINVAL;
2195 if (info->app_info == NULL ||
2196 info->app_info->splash_screen_display == NULL)
2197 return PMINFO_R_ERROR;
2199 *splash_screen_display =
2200 _get_bool_value(info->app_info->splash_screen_display);
2205 API int pkgmgrinfo_appinfo_get_setup_appid(
2206 pkgmgrinfo_appinfo_h handle, char **setup_appid)
2208 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2210 if (info == NULL || setup_appid == NULL) {
2211 _LOGE("Invalid parameter");
2212 return PMINFO_R_EINVAL;
2215 if (info->app_info == NULL || info->app_info->setup_appid == NULL)
2216 return PMINFO_R_ERROR;
2218 *setup_appid = info->app_info->setup_appid;
2222 API int pkgmgrinfo_appinfo_is_support_ambient(pkgmgrinfo_appinfo_h handle,
2223 bool *support_ambient)
2225 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2227 if (info == NULL || support_ambient == NULL) {
2228 _LOGE("Invalid parameter");
2229 return PMINFO_R_EINVAL;
2232 if (info->app_info == NULL || info->app_info->support_ambient == NULL)
2233 return PMINFO_R_ERROR;
2235 *support_ambient = _get_bool_value(info->app_info->support_ambient);
2240 API int pkgmgrinfo_appinfo_destroy_appinfo(pkgmgrinfo_appinfo_h handle)
2242 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2243 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2245 __cleanup_appinfo(info);
2249 API int pkgmgrinfo_appinfo_filter_create(pkgmgrinfo_appinfo_filter_h *handle)
2251 return pkgmgrinfo_pkginfo_filter_create(handle);
2254 API int pkgmgrinfo_appinfo_filter_destroy(pkgmgrinfo_appinfo_filter_h handle)
2256 return pkgmgrinfo_pkginfo_filter_destroy(handle);
2259 static gint __compare_func(gconstpointer data1, gconstpointer data2)
2261 pkgmgrinfo_node_x *node1 = (pkgmgrinfo_node_x *)data1;
2262 pkgmgrinfo_node_x *node2 = (pkgmgrinfo_node_x *)data2;
2264 if (node1->prop == node2->prop)
2266 else if (node1->prop > node2->prop)
2272 API int pkgmgrinfo_appinfo_filter_add_int(pkgmgrinfo_appinfo_filter_h handle,
2273 const char *property, const int value)
2275 retvm_if(handle == NULL, PMINFO_R_EINVAL,
2276 "Filter handle input parameter is NULL\n");
2277 retvm_if(property == NULL, PMINFO_R_EINVAL,
2278 "Filter handle input parameter is NULL\n");
2279 char buf[PKG_VALUE_STRING_LEN_MAX] = {'\0'};
2281 GSList *link = NULL;
2284 prop = _pminfo_appinfo_convert_to_prop_int(property);
2285 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_INT ||
2286 prop > E_PMINFO_APPINFO_PROP_APP_MAX_INT) {
2287 _LOGE("Invalid Integer Property\n");
2288 return PMINFO_R_EINVAL;
2290 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2291 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1,
2292 sizeof(pkgmgrinfo_node_x));
2294 _LOGE("Out of Memory!!!\n");
2295 return PMINFO_R_ERROR;
2297 snprintf(buf, PKG_VALUE_STRING_LEN_MAX - 1, "%d", value);
2298 val = strndup(buf, PKG_VALUE_STRING_LEN_MAX - 1);
2300 _LOGE("Out of Memory\n");
2303 return PMINFO_R_ERROR;
2309 * If API is called multiple times for same property,
2310 * we should override the previous values.
2311 * Last value set will be used for filtering.
2313 link = g_slist_find_custom(filter->list,
2314 (gconstpointer)node, __compare_func);
2316 filter->list = g_slist_delete_link(filter->list, link);
2317 filter->list = g_slist_append(filter->list, (gpointer)node);
2322 API int pkgmgrinfo_appinfo_filter_add_bool(pkgmgrinfo_appinfo_filter_h handle,
2323 const char *property, const bool value)
2325 retvm_if(handle == NULL, PMINFO_R_EINVAL,
2326 "Filter handle input parameter is NULL\n");
2327 retvm_if(property == NULL, PMINFO_R_EINVAL,
2328 "Filter handle input parameter is NULL\n");
2330 GSList *link = NULL;
2333 prop = _pminfo_appinfo_convert_to_prop_bool(property);
2334 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_BOOL ||
2335 prop > E_PMINFO_APPINFO_PROP_APP_MAX_BOOL) {
2336 _LOGE("Invalid Boolean Property\n");
2337 return PMINFO_R_EINVAL;
2339 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2340 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1,
2341 sizeof(pkgmgrinfo_node_x));
2343 _LOGE("Out of Memory!!!\n");
2344 return PMINFO_R_ERROR;
2347 val = strndup("true", 4);
2349 val = strndup("false", 5);
2351 _LOGE("Out of Memory\n");
2354 return PMINFO_R_ERROR;
2359 * If API is called multiple times for same property,
2360 * we should override the previous values.
2361 * Last value set will be used for filtering.
2363 link = g_slist_find_custom(filter->list,
2364 (gconstpointer)node, __compare_func);
2366 filter->list = g_slist_delete_link(filter->list, link);
2367 filter->list = g_slist_append(filter->list, (gpointer)node);
2372 API int pkgmgrinfo_appinfo_filter_add_string(pkgmgrinfo_appinfo_filter_h handle,
2373 const char *property, const char *value)
2375 retvm_if(handle == NULL, PMINFO_R_EINVAL,
2376 "Filter handle input parameter is NULL\n");
2377 retvm_if(property == NULL, PMINFO_R_EINVAL,
2378 "Filter handle input parameter is NULL\n");
2379 retvm_if(value == NULL, PMINFO_R_EINVAL,
2380 "Filter handle input parameter is NULL\n");
2382 pkgmgrinfo_node_x *ptr = NULL;
2383 char prev[PKG_STRING_LEN_MAX] = {'\0'};
2384 char temp[PKG_STRING_LEN_MAX] = {'\0'};
2385 GSList *link = NULL;
2389 prop = _pminfo_appinfo_convert_to_prop_str(property);
2390 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_STR ||
2391 prop > E_PMINFO_APPINFO_PROP_APP_MAX_STR) {
2392 _LOGE("Invalid String Property\n");
2393 return PMINFO_R_EINVAL;
2395 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2396 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1,
2397 sizeof(pkgmgrinfo_node_x));
2399 _LOGE("Out of Memory!!!\n");
2400 return PMINFO_R_ERROR;
2404 case E_PMINFO_APPINFO_PROP_APP_COMPONENT:
2405 node->value = strdup(value);
2406 link = g_slist_find_custom(filter->list,
2407 (gconstpointer)node, __compare_func);
2409 filter->list = g_slist_delete_link(filter->list, link);
2410 filter->list = g_slist_append(filter->list, (gpointer)node);
2412 case E_PMINFO_APPINFO_PROP_APP_CATEGORY:
2413 val = (char *)calloc(1, PKG_STRING_LEN_MAX);
2415 _LOGE("Out of Memory\n");
2418 return PMINFO_R_ERROR;
2420 link = g_slist_find_custom(filter->list,
2421 (gconstpointer)node, __compare_func);
2423 ptr = (pkgmgrinfo_node_x *)link->data;
2424 strncpy(prev, ptr->value, PKG_STRING_LEN_MAX - 1);
2425 _LOGI("Previous value is %s\n", prev);
2426 filter->list = g_slist_delete_link(filter->list, link);
2427 ret = snprintf(temp, PKG_STRING_LEN_MAX - 1,
2428 "%s,%s", prev, value);
2429 if (ret < 0 || ret > PKG_STRING_LEN_MAX - 1) {
2430 _LOGE("snprintf fail\n");
2433 return PMINFO_R_ERROR;
2435 strncpy(val, temp, PKG_STRING_LEN_MAX);
2436 _LOGI("New value is %s\n", val);
2438 filter->list = g_slist_append(
2439 filter->list, (gpointer)node);
2440 memset(temp, '\0', PKG_STRING_LEN_MAX);
2442 snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s", value);
2443 strncpy(val, temp, PKG_STRING_LEN_MAX);
2444 _LOGI("First value is %s\n", val);
2446 filter->list = g_slist_append(
2447 filter->list, (gpointer)node);
2448 memset(temp, '\0', PKG_STRING_LEN_MAX);
2452 node->value = strndup(value, PKG_STRING_LEN_MAX - 1);
2453 link = g_slist_find_custom(filter->list,
2454 (gconstpointer)node, __compare_func);
2456 filter->list = g_slist_delete_link(filter->list, link);
2457 filter->list = g_slist_append(filter->list, (gpointer)node);
2463 API int pkgmgrinfo_appinfo_usr_filter_count(
2464 pkgmgrinfo_appinfo_filter_h handle, int *count, uid_t uid)
2469 pkgmgrinfo_filter_x *filter;
2471 if (handle == NULL || count == NULL) {
2472 _LOGE("invalid parameter");
2473 return PMINFO_R_EINVAL;
2476 filter = (pkgmgrinfo_filter_x *)handle;
2477 list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
2478 __free_applications);
2480 return PMINFO_R_ERROR;
2482 if (__check_disable_filter_exist(
2483 handle, E_APPINFO_DISABLE_TYPE_APP) == false) {
2484 if (pkgmgrinfo_appinfo_filter_add_bool(handle,
2485 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
2486 g_hash_table_destroy(list);
2487 return PMINFO_R_ERROR;
2491 if (__check_disable_filter_exist(
2492 handle, E_APPINFO_DISABLE_TYPE_PKG) == false) {
2493 if (pkgmgrinfo_appinfo_filter_add_bool(handle,
2494 PMINFO_APPINFO_PROP_PKG_DISABLE, false)) {
2495 g_hash_table_destroy(list);
2496 return PMINFO_R_ERROR;
2500 ret = _appinfo_get_applications(uid, uid, filter, 0, list);
2501 query_count = g_hash_table_size(list);
2502 g_hash_table_destroy(list);
2503 if (ret == PMINFO_R_ERROR)
2506 *count = query_count;
2510 API int pkgmgrinfo_appinfo_filter_count(
2511 pkgmgrinfo_appinfo_filter_h handle, int *count)
2513 return pkgmgrinfo_appinfo_usr_filter_count(handle, count, _getuid());
2516 API int pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(
2517 pkgmgrinfo_appinfo_filter_h handle,
2518 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
2520 if (handle == NULL || app_cb == NULL) {
2521 LOGE("invalid parameter");
2522 return PMINFO_R_EINVAL;
2525 if (__check_disable_filter_exist(
2526 handle, E_APPINFO_DISABLE_TYPE_APP) == false) {
2527 if (pkgmgrinfo_appinfo_filter_add_bool(handle,
2528 PMINFO_APPINFO_PROP_APP_DISABLE, false))
2529 return PMINFO_R_ERROR;
2532 if (__check_disable_filter_exist(
2533 handle, E_APPINFO_DISABLE_TYPE_PKG) == false) {
2534 if (pkgmgrinfo_appinfo_filter_add_bool(handle,
2535 PMINFO_APPINFO_PROP_PKG_DISABLE, false))
2536 return PMINFO_R_ERROR;
2539 return _appinfo_get_filtered_foreach_appinfo(uid,
2540 handle, PMINFO_APPINFO_GET_ALL, app_cb, user_data);
2543 API int pkgmgrinfo_appinfo_filter_foreach_appinfo(
2544 pkgmgrinfo_appinfo_filter_h handle,
2545 pkgmgrinfo_app_list_cb app_cb, void *user_data)
2547 return pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(
2548 handle, app_cb, user_data, _getuid());
2551 API int pkgmgrinfo_appinfo_metadata_filter_create(
2552 pkgmgrinfo_appinfo_metadata_filter_h *handle)
2554 return pkgmgrinfo_pkginfo_filter_create(handle);
2557 API int pkgmgrinfo_appinfo_metadata_filter_destroy(
2558 pkgmgrinfo_appinfo_metadata_filter_h handle)
2560 return pkgmgrinfo_pkginfo_filter_destroy(handle);
2563 API int pkgmgrinfo_appinfo_metadata_filter_add(
2564 pkgmgrinfo_appinfo_metadata_filter_h handle,
2565 const char *key, const char *value)
2567 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2568 pkgmgrinfo_metadata_node_x *node;
2570 /* value can be NULL.
2571 * In that case all apps with specified key should be displayed
2574 LOGE("invalid parameter");
2575 return PMINFO_R_EINVAL;
2578 node = calloc(1, sizeof(pkgmgrinfo_metadata_node_x));
2580 LOGE("out of memory");
2581 return PMINFO_R_ERROR;
2584 node->key = strdup(key);
2585 if (value && strlen(value))
2586 node->value = strdup(value);
2588 filter->list_metadata = g_slist_append(filter->list_metadata,
2594 API int pkgmgrinfo_appinfo_usr_metadata_filter_foreach(
2595 pkgmgrinfo_appinfo_metadata_filter_h handle,
2596 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
2598 if (handle == NULL || app_cb == NULL) {
2599 LOGE("invalid parameter");
2600 return PMINFO_R_EINVAL;
2603 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2605 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
2606 PMINFO_APPINFO_PROP_APP_DISABLE, false))
2607 return PMINFO_R_ERROR;
2609 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
2610 PMINFO_APPINFO_PROP_PKG_DISABLE, false))
2611 return PMINFO_R_ERROR;
2613 return _appinfo_get_filtered_foreach_appinfo(uid, handle,
2614 PMINFO_APPINFO_GET_ALL, app_cb,
2618 API int pkgmgrinfo_appinfo_metadata_filter_foreach(
2619 pkgmgrinfo_appinfo_metadata_filter_h handle,
2620 pkgmgrinfo_app_list_cb app_cb, void *user_data)
2622 return pkgmgrinfo_appinfo_usr_metadata_filter_foreach(handle, app_cb,
2623 user_data, _getuid());
2626 API int pkgmgrinfo_appinfo_is_guestmode_visibility(
2627 pkgmgrinfo_appinfo_h handle, bool *status)
2630 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2632 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2633 retvm_if(status == NULL, PMINFO_R_EINVAL,
2634 "Argument supplied to hold return value is NULL\n");
2636 val = info->app_info->guestmode_visibility;
2637 *status = _get_bool_value(val);
2641 API int pkgmgrinfo_appinfo_foreach_appcontrol_v2(pkgmgrinfo_appinfo_h handle,
2642 pkgmgrinfo_app_control_list_cb_v2 appcontrol_func,
2645 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2646 retvm_if(appcontrol_func == NULL,
2647 PMINFO_R_EINVAL, "Callback function is NULL");
2649 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2650 appcontrol_x *appcontrol;
2653 if (info->app_info == NULL)
2654 return PMINFO_R_ERROR;
2656 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
2657 appcontrol = (appcontrol_x *)tmp->data;
2658 if (appcontrol == NULL ||
2659 !strcasecmp(appcontrol->visibility,
2662 ret = appcontrol_func(appcontrol->operation, appcontrol->uri,
2663 appcontrol->mime, appcontrol->id, user_data);
2671 API int pkgmgrinfo_appinfo_foreach_remote_appcontrol_v2(
2672 pkgmgrinfo_appinfo_h handle,
2673 pkgmgrinfo_app_control_list_cb_v2 appcontrol_func,
2676 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2677 retvm_if(appcontrol_func == NULL,
2678 PMINFO_R_EINVAL, "Callback function is NULL");
2680 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2681 appcontrol_x *appcontrol;
2684 if (info->app_info == NULL)
2685 return PMINFO_R_ERROR;
2687 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
2688 appcontrol = (appcontrol_x *)tmp->data;
2689 if (appcontrol == NULL ||
2690 !strcasecmp(appcontrol->visibility,
2693 ret = appcontrol_func(appcontrol->operation, appcontrol->uri,
2694 appcontrol->mime, appcontrol->id, user_data);