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 // TODO: need to use pkginfo-client APIs
94 ret = _appinfo_get_applications(uid, uid, filter,
95 PMINFO_APPINFO_GET_ALL, list);
96 if (ret != PMINFO_R_OK) {
97 g_hash_table_destroy(list);
101 if (!g_hash_table_size(list)) {
102 _LOGD("appinfo for [%s] is not existed for user [%d]",
104 g_hash_table_destroy(list);
105 return PMINFO_R_ENOENT;
108 info = calloc(1, sizeof(pkgmgr_appinfo_x));
110 _LOGE("out of memory");
111 g_hash_table_destroy(list);
112 return PMINFO_R_ERROR;
115 info->app_info = (application_x *)g_hash_table_lookup(list, appid);
116 if (!info->app_info || !info->app_info->package) {
117 _LOGD("appinfo for [%s] is not existed for user [%d]",
119 g_hash_table_destroy(list);
121 return PMINFO_R_ENOENT;
123 info->locale = strdup(info->app_info->locale);
124 info->package = strdup(info->app_info->package);
125 if (!info->package || !info->locale) {
126 _LOGE("out of memory");
129 g_hash_table_destroy(list);
131 return PMINFO_R_ERROR;
134 /* just free list only */
135 g_hash_table_steal(list, (gconstpointer)appid);
136 g_hash_table_destroy(list);
143 API int pkgmgrinfo_appinfo_get_usr_disabled_appinfo(const char *appid, uid_t uid,
144 pkgmgrinfo_appinfo_h *handle)
147 pkgmgrinfo_appinfo_filter_h filter;
149 if (appid == NULL || handle == NULL) {
150 LOGE("invalid parameter");
151 return PMINFO_R_EINVAL;
154 ret = pkgmgrinfo_appinfo_filter_create(&filter);
155 if (ret != PMINFO_R_OK)
158 ret = pkgmgrinfo_appinfo_filter_add_string(filter,
159 PMINFO_APPINFO_PROP_APP_ID, appid);
160 if (ret != PMINFO_R_OK) {
161 pkgmgrinfo_appinfo_filter_destroy(filter);
162 return PMINFO_R_ERROR;
165 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
166 PMINFO_APPINFO_PROP_APP_DISABLE, true);
167 if (ret != PMINFO_R_OK) {
168 pkgmgrinfo_appinfo_filter_destroy(filter);
169 return PMINFO_R_ERROR;
172 ret = _pkgmgrinfo_get_appinfo(appid, uid, filter, handle);
173 pkgmgrinfo_appinfo_filter_destroy(filter);
178 API int pkgmgrinfo_appinfo_get_disabled_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
180 return pkgmgrinfo_appinfo_get_usr_disabled_appinfo(appid, _getuid(), handle);
183 API int pkgmgrinfo_appinfo_get_usr_appinfo(const char *appid, uid_t uid,
184 pkgmgrinfo_appinfo_h *handle)
187 pkgmgrinfo_appinfo_filter_h filter;
189 if (appid == NULL || handle == NULL) {
190 LOGE("invalid parameter");
191 return PMINFO_R_EINVAL;
194 ret = pkgmgrinfo_appinfo_filter_create(&filter);
195 if (ret != PMINFO_R_OK)
198 ret = pkgmgrinfo_appinfo_filter_add_string(filter,
199 PMINFO_APPINFO_PROP_APP_ID, appid);
200 if (ret != PMINFO_R_OK) {
201 pkgmgrinfo_appinfo_filter_destroy(filter);
202 return PMINFO_R_ERROR;
205 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
206 PMINFO_APPINFO_PROP_APP_DISABLE, false);
207 if (ret != PMINFO_R_OK) {
208 pkgmgrinfo_appinfo_filter_destroy(filter);
209 return PMINFO_R_ERROR;
212 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
213 PMINFO_APPINFO_PROP_PKG_DISABLE, false);
214 if (ret != PMINFO_R_OK) {
215 pkgmgrinfo_appinfo_filter_destroy(filter);
216 return PMINFO_R_ERROR;
219 ret = _pkgmgrinfo_get_appinfo(appid, uid, filter, handle);
220 pkgmgrinfo_appinfo_filter_destroy(filter);
224 API int pkgmgrinfo_appinfo_get_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
226 return pkgmgrinfo_appinfo_get_usr_appinfo(appid, _getuid(), handle);
229 API int pkgmgrinfo_appinfo_get_usr_all_appinfo(const char *appid, uid_t uid,
230 pkgmgrinfo_appinfo_h *handle)
233 pkgmgrinfo_appinfo_filter_h filter;
235 if (appid == NULL || handle == NULL) {
236 LOGE("invalid parameter");
237 return PMINFO_R_EINVAL;
240 ret = pkgmgrinfo_appinfo_filter_create(&filter);
241 if (ret != PMINFO_R_OK)
244 ret = pkgmgrinfo_appinfo_filter_add_string(filter,
245 PMINFO_APPINFO_PROP_APP_ID, appid);
246 if (ret != PMINFO_R_OK) {
247 pkgmgrinfo_appinfo_filter_destroy(filter);
248 return PMINFO_R_ERROR;
251 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
252 PMINFO_APPINFO_PROP_APP_CHECK_STORAGE, false);
253 if (ret != PMINFO_R_OK) {
254 pkgmgrinfo_appinfo_filter_destroy(filter);
255 return PMINFO_R_ERROR;
258 ret = _pkgmgrinfo_get_appinfo(appid, uid, filter, handle);
259 pkgmgrinfo_appinfo_filter_destroy(filter);
264 API int pkgmgrinfo_appinfo_get_all_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
266 return pkgmgrinfo_appinfo_get_usr_all_appinfo(appid, _getuid(), handle);
269 static gpointer __copy_str(gconstpointer src, gpointer data)
271 const char *tmp = (const char *)src;
274 buffer = strdup(tmp);
275 if (buffer == NULL) {
276 LOGE("memory alloc failed");
284 static gpointer __copy_label(gconstpointer src, gpointer data)
286 label_x *tmp = (label_x *)src;
289 label = calloc(1, sizeof(label_x));
291 LOGE("memory alloc failed");
297 label->name = strdup(tmp->name);
299 label->text = strdup(tmp->text);
301 label->lang = strdup(tmp->lang);
306 static gpointer __copy_icon(gconstpointer src, gpointer data)
308 icon_x *tmp = (icon_x *)src;
311 icon = calloc(1, sizeof(icon_x));
313 LOGE("memory alloc failed");
319 icon->text = strdup(tmp->text);
321 icon->lang = strdup(tmp->lang);
323 icon->section = strdup(tmp->section);
325 icon->size = strdup(tmp->size);
327 icon->resolution = strdup(tmp->resolution);
332 static gpointer __copy_metadata(gconstpointer src, gpointer data)
334 metadata_x *tmp = (metadata_x *)src;
335 metadata_x *metadata;
337 metadata = calloc(1, sizeof(metadata_x));
338 if (metadata == NULL) {
339 LOGE("memory alloc failed");
345 metadata->key = strdup(tmp->key);
347 metadata->value = strdup(tmp->value);
352 static gpointer __copy_datacontrol(gconstpointer src, gpointer data)
354 datacontrol_x *tmp = (datacontrol_x *)src;
355 datacontrol_x *datacontrol;
357 datacontrol = calloc(1, sizeof(datacontrol_x));
358 if (datacontrol == NULL) {
359 LOGE("memory alloc failed");
365 datacontrol->providerid = strdup(tmp->providerid);
367 datacontrol->access = strdup(tmp->access);
369 datacontrol->type = strdup(tmp->type);
371 datacontrol->trusted = strdup(tmp->trusted);
376 static gpointer __copy_appcontrol(gconstpointer src, gpointer data)
378 appcontrol_x *tmp = (appcontrol_x *)src;
379 appcontrol_x *appcontrol;
381 appcontrol = calloc(1, sizeof(appcontrol_x));
382 if (appcontrol == NULL) {
383 LOGE("memory alloc failed");
389 appcontrol->operation = strdup(tmp->operation);
391 appcontrol->uri = strdup(tmp->uri);
393 appcontrol->mime = strdup(tmp->mime);
398 static gpointer __copy_splashscreens(gconstpointer src, gpointer data)
400 splashscreen_x *tmp = (splashscreen_x *)src;
401 splashscreen_x *splashscreen;
403 splashscreen = (splashscreen_x *)calloc(1, sizeof(splashscreen_x));
404 if (splashscreen == NULL) {
405 LOGE("memory alloc failed");
411 splashscreen->src = strdup(tmp->src);
413 splashscreen->type = strdup(tmp->type);
414 if (tmp->orientation)
415 splashscreen->orientation = strdup(tmp->orientation);
416 if (tmp->indicatordisplay)
417 splashscreen->indicatordisplay = strdup(tmp->indicatordisplay);
419 splashscreen->operation = strdup(tmp->operation);
420 if (tmp->color_depth)
421 splashscreen->color_depth = strdup(tmp->color_depth);
426 static int _appinfo_copy_appinfo(application_x **application, application_x *data)
428 application_x *app_info;
431 app_info = calloc(1, sizeof(application_x));
432 if (app_info == NULL) {
433 LOGE("memory alloc failed");
434 return PMINFO_R_ERROR;
437 if (data->appid != NULL)
438 app_info->appid = strdup(data->appid);
439 if (data->exec != NULL)
440 app_info->exec = strdup(data->exec);
441 if (data->nodisplay != NULL)
442 app_info->nodisplay = strdup(data->nodisplay);
443 if (data->multiple != NULL)
444 app_info->multiple = strdup(data->multiple);
445 if (data->taskmanage != NULL)
446 app_info->taskmanage = strdup(data->taskmanage);
447 if (data->type != NULL)
448 app_info->type = strdup(data->type);
449 if (data->categories != NULL)
450 app_info->categories = strdup(data->categories);
451 if (data->hwacceleration != NULL)
452 app_info->hwacceleration = strdup(data->hwacceleration);
453 if (data->screenreader != NULL)
454 app_info->screenreader = strdup(data->screenreader);
455 if (data->mainapp != NULL)
456 app_info->mainapp = strdup(data->mainapp);
457 if (data->package != NULL)
458 app_info->package = strdup(data->package);
459 if (data->recentimage != NULL)
460 app_info->recentimage = strdup(data->recentimage);
461 if (data->launchcondition != NULL)
462 app_info->launchcondition = strdup(data->launchcondition);
463 if (data->indicatordisplay != NULL)
464 app_info->indicatordisplay = strdup(data->indicatordisplay);
465 if (data->portraitimg != NULL)
466 app_info->portraitimg = strdup(data->portraitimg);
467 if (data->landscapeimg != NULL)
468 app_info->landscapeimg = strdup(data->landscapeimg);
469 if (data->guestmode_visibility != NULL)
470 app_info->guestmode_visibility = strdup(data->guestmode_visibility);
471 if (data->component != NULL)
472 app_info->component = strdup(data->component);
473 if (data->permission_type != NULL)
474 app_info->permission_type = strdup(data->permission_type);
475 if (data->component_type != NULL)
476 app_info->component_type = strdup(data->component_type);
477 if (data->preload != NULL)
478 app_info->preload = strdup(data->preload);
479 if (data->submode != NULL)
480 app_info->submode = strdup(data->submode);
481 if (data->submode_mainid != NULL)
482 app_info->submode_mainid = strdup(data->submode_mainid);
483 if (data->process_pool != NULL)
484 app_info->process_pool = strdup(data->process_pool);
485 if (data->installed_storage != NULL)
486 app_info->installed_storage = strdup(data->installed_storage);
487 if (data->autorestart != NULL)
488 app_info->autorestart = strdup(data->autorestart);
489 if (data->onboot != NULL)
490 app_info->onboot = strdup(data->onboot);
491 if (data->support_disable != NULL)
492 app_info->support_disable = strdup(data->support_disable);
493 if (data->ui_gadget != NULL)
494 app_info->ui_gadget = strdup(data->ui_gadget);
495 if (data->launch_mode != NULL)
496 app_info->launch_mode = strdup(data->launch_mode);
497 if (data->package_type != NULL)
498 app_info->package_type = strdup(data->package_type);
499 if (data->effective_appid != NULL)
500 app_info->effective_appid = strdup(data->effective_appid);
501 if (data->splash_screen_display != NULL)
502 app_info->splash_screen_display = strdup(data->splash_screen_display);
506 app_info->label = g_list_copy_deep(data->label, __copy_label, &ret);
508 LOGE("memory alloc failed");
509 pkgmgrinfo_basic_free_application(app_info);
510 return PMINFO_R_ERROR;
514 app_info->icon = g_list_copy_deep(data->icon, __copy_icon, &ret);
516 LOGE("memory alloc failed");
517 pkgmgrinfo_basic_free_application(app_info);
518 return PMINFO_R_ERROR;
522 app_info->category = g_list_copy_deep(data->category, __copy_str, &ret);
524 LOGE("memory alloc failed");
525 pkgmgrinfo_basic_free_application(app_info);
526 return PMINFO_R_ERROR;
530 app_info->metadata = g_list_copy_deep(data->metadata, __copy_metadata, &ret);
532 LOGE("memory alloc failed");
533 pkgmgrinfo_basic_free_application(app_info);
534 return PMINFO_R_ERROR;
538 app_info->datacontrol = g_list_copy_deep(data->datacontrol, __copy_datacontrol, &ret);
540 LOGE("memory alloc failed");
541 pkgmgrinfo_basic_free_application(app_info);
542 return PMINFO_R_ERROR;
546 app_info->appcontrol = g_list_copy_deep(data->appcontrol, __copy_appcontrol, &ret);
548 LOGE("memory alloc failed");
549 pkgmgrinfo_basic_free_application(app_info);
550 return PMINFO_R_ERROR;
554 app_info->background_category = g_list_copy_deep(data->background_category, __copy_str, &ret);
556 LOGE("memory alloc failed");
557 pkgmgrinfo_basic_free_application(app_info);
558 return PMINFO_R_ERROR;
562 app_info->splashscreens = g_list_copy_deep(data->splashscreens, __copy_splashscreens, &ret);
564 LOGE("memory alloc failed");
565 pkgmgrinfo_basic_free_application(app_info);
566 return PMINFO_R_ERROR;
569 *application = app_info;
574 API int pkgmgrinfo_appinfo_clone_appinfo(pkgmgrinfo_appinfo_h handle,
575 pkgmgrinfo_appinfo_h *clone)
577 pkgmgr_appinfo_x *info;
578 pkgmgr_appinfo_x *temp = (pkgmgr_appinfo_x *)handle;
581 return PMINFO_R_EINVAL;
583 info = calloc(1, sizeof(pkgmgr_appinfo_x));
585 LOGE("memory alloc failed");
586 return PMINFO_R_ERROR;
589 if (temp->package != NULL)
590 info->package = strdup(temp->package);
591 if (temp->locale != NULL)
592 info->locale = strdup(temp->locale);
594 info->app_component = temp->app_component;
596 if (_appinfo_copy_appinfo(&info->app_info, temp->app_info) < 0) {
597 LOGE("appinfo copy failed");
599 free((void *)info->package);
603 return PMINFO_R_ERROR;
611 static int _appinfo_get_filtered_foreach_appinfo(uid_t uid,
612 pkgmgrinfo_filter_x *filter, int flag, pkgmgrinfo_app_list_cb app_list_cb,
616 pkgmgr_appinfo_x info;
622 list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
623 __free_applications);
625 return PMINFO_R_ERROR;
627 ret = _appinfo_get_applications(uid, uid, filter,
628 flag | PMINFO_APPINFO_GET_BASICINFO, list);
629 if (ret != PMINFO_R_OK) {
630 g_hash_table_destroy(list);
634 g_hash_table_iter_init(&iter, list);
635 while (g_hash_table_iter_next(&iter, NULL, &value)) {
636 app = (application_x *)value;
638 info.locale = info.app_info->locale;
639 info.package = app->package;
640 if (app_list_cb(&info, user_data) < 0)
643 g_hash_table_destroy(list);
648 static const char *__appcomponent_str(pkgmgrinfo_app_component comp);
650 API int pkgmgrinfo_appinfo_get_usr_list(pkgmgrinfo_pkginfo_h handle,
651 pkgmgrinfo_app_component component,
652 pkgmgrinfo_app_list_cb app_func, void *user_data, uid_t uid)
655 pkgmgrinfo_appinfo_filter_h filter;
657 const char *comp_str = NULL;
659 if (handle == NULL || app_func == NULL) {
660 LOGE("invalid parameter");
661 return PMINFO_R_EINVAL;
664 if (pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid)) {
665 LOGE("invalid parameter");
666 return PMINFO_R_EINVAL;
669 if (pkgmgrinfo_appinfo_filter_create(&filter))
670 return PMINFO_R_ERROR;
672 if (pkgmgrinfo_appinfo_filter_add_string(filter,
673 PMINFO_APPINFO_PROP_APP_PACKAGE, pkgid)) {
674 pkgmgrinfo_appinfo_filter_destroy(filter);
675 return PMINFO_R_ERROR;
678 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
679 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
680 pkgmgrinfo_appinfo_filter_destroy(filter);
681 return PMINFO_R_ERROR;
684 comp_str = __appcomponent_str(component);
687 if (pkgmgrinfo_appinfo_filter_add_string(filter,
688 PMINFO_APPINFO_PROP_APP_COMPONENT,
690 pkgmgrinfo_appinfo_filter_destroy(filter);
691 return PMINFO_R_ERROR;
695 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter,
696 PMINFO_APPINFO_GET_ALL, app_func, user_data);
698 pkgmgrinfo_appinfo_filter_destroy(filter);
703 API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle,
704 pkgmgrinfo_app_component component,
705 pkgmgrinfo_app_list_cb app_func, void *user_data)
707 return pkgmgrinfo_appinfo_get_usr_list(handle, component, app_func, user_data, _getuid());
710 API int pkgmgrinfo_appinfo_get_usr_installed_list_full(
711 pkgmgrinfo_app_list_cb app_func, uid_t uid, int flag,
715 pkgmgrinfo_appinfo_filter_h filter;
717 if (app_func == NULL) {
718 LOGE("invalid parameter");
719 return PMINFO_R_EINVAL;
722 if (pkgmgrinfo_appinfo_filter_create(&filter))
723 return PMINFO_R_ERROR;
725 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
726 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
727 pkgmgrinfo_appinfo_filter_destroy(filter);
728 return PMINFO_R_ERROR;
731 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
732 PMINFO_APPINFO_PROP_PKG_DISABLE, false)) {
733 pkgmgrinfo_appinfo_filter_destroy(filter);
734 return PMINFO_R_ERROR;
737 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
738 PMINFO_APPINFO_PROP_APP_CHECK_STORAGE, false)) {
739 pkgmgrinfo_appinfo_filter_destroy(filter);
740 return PMINFO_R_ERROR;
743 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter, flag, app_func,
746 pkgmgrinfo_appinfo_filter_destroy(filter);
751 API int pkgmgrinfo_appinfo_get_installed_list_full(
752 pkgmgrinfo_app_list_cb app_func, int flag, void *user_data)
754 return pkgmgrinfo_appinfo_get_usr_installed_list_full(app_func,
755 _getuid(), flag, user_data);
758 API int pkgmgrinfo_appinfo_get_usr_installed_list(
759 pkgmgrinfo_app_list_cb app_func, uid_t uid, void *user_data)
762 pkgmgrinfo_appinfo_filter_h filter;
764 if (app_func == NULL) {
765 LOGE("invalid parameter");
766 return PMINFO_R_EINVAL;
769 /* create an empty filter */
770 ret = pkgmgrinfo_appinfo_filter_create(&filter);
771 if (ret != PMINFO_R_OK)
774 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
775 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
776 pkgmgrinfo_appinfo_filter_destroy(filter);
777 return PMINFO_R_ERROR;
780 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
781 PMINFO_APPINFO_PROP_PKG_DISABLE, false)) {
782 pkgmgrinfo_appinfo_filter_destroy(filter);
783 return PMINFO_R_ERROR;
786 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter,
787 PMINFO_APPINFO_GET_ALL, app_func, user_data);
789 pkgmgrinfo_appinfo_filter_destroy(filter);
794 API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func,
797 return pkgmgrinfo_appinfo_get_usr_installed_list(app_func, _getuid(),
801 API int pkgmgrinfo_appinfo_get_appid(pkgmgrinfo_appinfo_h handle, char **appid)
803 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
805 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
806 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
808 if (info->app_info == NULL || info->app_info->appid == NULL)
809 return PMINFO_R_ERROR;
810 *appid = (char *)info->app_info->appid;
815 API int pkgmgrinfo_appinfo_get_pkgname(pkgmgrinfo_appinfo_h handle, char **pkg_name)
817 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
819 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
820 retvm_if(pkg_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
822 if (info->package == NULL)
823 return PMINFO_R_ERROR;
825 *pkg_name = (char *)info->package;
830 API int pkgmgrinfo_appinfo_get_pkgid(pkgmgrinfo_appinfo_h handle, char **pkgid)
832 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
834 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
835 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
837 if (info->package == NULL)
838 return PMINFO_R_ERROR;
840 *pkgid = (char *)info->package;
845 API int pkgmgrinfo_appinfo_get_pkgtype(pkgmgrinfo_appinfo_h handle, char **pkgtype)
847 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
848 retvm_if(pkgtype == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
849 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
851 *pkgtype = (char *)info->app_info->package_type;
856 API int pkgmgrinfo_appinfo_get_exec(pkgmgrinfo_appinfo_h handle, char **exec)
858 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
860 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
861 retvm_if(exec == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
863 if (info->app_info == NULL || info->app_info->exec == NULL)
864 return PMINFO_R_ERROR;
865 *exec = (char *)info->app_info->exec;
871 API int pkgmgrinfo_appinfo_get_icon(pkgmgrinfo_appinfo_h handle, char **icon)
874 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
876 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
877 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
879 if (info->app_info == NULL)
880 return PMINFO_R_ERROR;
882 if (info->app_info->icon == NULL) {
887 ptr = (icon_x *)info->app_info->icon->data;
889 return PMINFO_R_ERROR;
891 if (ptr->text == NULL)
892 return PMINFO_R_ERROR;
900 API int pkgmgrinfo_appinfo_get_label(pkgmgrinfo_appinfo_h handle, char **label)
903 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
908 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
909 retvm_if(label == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
911 if (info->app_info == NULL)
912 return PMINFO_R_ERROR;
914 locale = info->locale;
916 locale = DEFAULT_LOCALE;
918 for (tmp = info->app_info->label; tmp; tmp = tmp->next) {
919 ptr = (label_x *)tmp->data;
920 if (ptr == NULL || strcmp(locale, ptr->lang) != 0)
931 for (tmp = info->app_info->label; tmp; tmp = tmp->next) {
932 ptr = (label_x *)tmp->data;
933 if (ptr == NULL || strcmp(DEFAULT_LOCALE, ptr->lang) != 0)
939 *label = lbl ? lbl : "";
944 API int pkgmgrinfo_appinfo_usr_get_localed_label(const char *appid, const char *locale, uid_t uid, char **label)
948 retvm_if(appid == NULL || locale == NULL || label == NULL, PMINFO_R_EINVAL, "Argument is NULL");
949 val = _appinfo_get_localed_label(appid, locale, uid);
951 return PMINFO_R_ERROR;
957 API int pkgmgrinfo_appinfo_get_localed_label(const char *appid, const char *locale, char **label)
959 return pkgmgrinfo_appinfo_usr_get_localed_label(appid, locale, _getuid(), label);
962 API int pkgmgrinfo_appinfo_get_metadata_value(pkgmgrinfo_appinfo_h handle, const char *metadata_key, char **metadata_value)
964 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
965 retvm_if(metadata_key == NULL, PMINFO_R_EINVAL, "metadata_key is NULL");
966 retvm_if(metadata_value == NULL, PMINFO_R_EINVAL, "metadata_value is NULL");
968 GList *list_md = NULL;
969 metadata_x *metadata = NULL;
970 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
972 list_md = info->app_info->metadata;
974 for (; list_md; list_md = list_md->next) {
975 metadata = (metadata_x *)list_md->data;
976 if (metadata && metadata->key) {
977 if (strcasecmp(metadata->key, metadata_key) == 0) {
978 if (metadata->value == NULL)
979 *metadata_value = "";
981 *metadata_value = (char *)metadata->value;
987 return PMINFO_R_EINVAL;
990 static pkgmgrinfo_app_component __appcomponent_convert(const char *comp)
992 if (strcasecmp(comp, "uiapp") == 0)
993 return PMINFO_UI_APP;
994 else if (strcasecmp(comp, "svcapp") == 0)
995 return PMINFO_SVC_APP;
996 else if (strcasecmp(comp, "widgetapp") == 0)
997 return PMINFO_WIDGET_APP;
998 else if (strcasecmp(comp, "watchapp") == 0)
999 return PMINFO_WATCH_APP;
1000 else if (strcasecmp(comp, "componentbasedapp") == 0)
1001 return PMINFO_COMPONENT_BASED_APP;
1006 static const char *__appcomponent_str(pkgmgrinfo_app_component comp)
1011 case PMINFO_SVC_APP:
1013 case PMINFO_WIDGET_APP:
1015 case PMINFO_WATCH_APP:
1017 case PMINFO_COMPONENT_BASED_APP:
1018 return "componentbasedapp";
1024 API int pkgmgrinfo_appinfo_get_component(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_component *component)
1026 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1029 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1030 retvm_if(component == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1032 if (info->app_info == NULL)
1033 return PMINFO_R_ERROR;
1035 comp = __appcomponent_convert(info->app_info->component);
1037 return PMINFO_R_ERROR;
1044 API int pkgmgrinfo_appinfo_get_apptype(pkgmgrinfo_appinfo_h handle, char **app_type)
1046 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1048 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1049 retvm_if(app_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1051 if (info->app_info == NULL || info->app_info->type == NULL)
1052 return PMINFO_R_ERROR;
1053 *app_type = (char *)info->app_info->type;
1058 API int pkgmgrinfo_appinfo_get_notification_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1063 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1065 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1066 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1068 if (info->app_info == NULL)
1069 return PMINFO_R_ERROR;
1071 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1072 ptr = (icon_x *)tmp->data;
1073 if (ptr == NULL || ptr->section == NULL)
1076 val = (char *)ptr->section;
1077 if (val && strcmp(val, "notification") == 0) {
1078 *icon = (char *)ptr->text;
1083 return PMINFO_R_ERROR;
1086 API int pkgmgrinfo_appinfo_get_recent_image_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_recentimage *type)
1089 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1091 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1092 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1094 if (info->app_info == NULL || info->app_info->recentimage == NULL)
1095 return PMINFO_R_ERROR;
1097 val = (char *)info->app_info->recentimage;
1098 if (strcasecmp(val, "capture") == 0)
1099 *type = PMINFO_RECENTIMAGE_USE_CAPTURE;
1100 else if (strcasecmp(val, "icon") == 0)
1101 *type = PMINFO_RECENTIMAGE_USE_ICON;
1103 *type = PMINFO_RECENTIMAGE_USE_NOTHING;
1108 API int pkgmgrinfo_appinfo_get_preview_image(pkgmgrinfo_appinfo_h handle, char **preview_img)
1113 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1115 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1116 retvm_if(preview_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1118 if (info->app_info == NULL)
1119 return PMINFO_R_ERROR;
1121 for (tmp = info->app_info->image; tmp; tmp = tmp->next) {
1122 ptr = (image_x *)tmp->data;
1123 if (ptr == NULL || ptr->section == NULL)
1126 val = (char *)ptr->section;
1127 if (val && strcmp(val, "preview") == 0) {
1128 *preview_img = (char *)ptr->text;
1133 return PMINFO_R_ERROR;
1136 API int pkgmgrinfo_appinfo_get_permission_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_permission_type *permission)
1139 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1141 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1142 retvm_if(permission == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1144 val = info->app_info->permission_type;
1146 return PMINFO_R_ERROR;
1148 if (strcmp(val, "signature") == 0)
1149 *permission = PMINFO_PERMISSION_SIGNATURE;
1150 else if (strcmp(val, "privilege") == 0)
1151 *permission = PMINFO_PERMISSION_PRIVILEGE;
1153 *permission = PMINFO_PERMISSION_NORMAL;
1158 API int pkgmgrinfo_appinfo_get_component_type(pkgmgrinfo_appinfo_h handle, char **component_type)
1160 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1162 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1163 retvm_if(component_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1165 if (info->app_info == NULL || info->app_info->component_type == NULL)
1166 return PMINFO_R_ERROR;
1168 *component_type = (char *)info->app_info->component_type;
1173 API int pkgmgrinfo_appinfo_get_hwacceleration(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_hwacceleration *hwacceleration)
1176 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1178 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1179 retvm_if(hwacceleration == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1181 if (info->app_info == NULL || info->app_info->hwacceleration == NULL)
1182 return PMINFO_R_ERROR;
1184 val = (char *)info->app_info->hwacceleration;
1185 if (strcasecmp(val, "off") == 0)
1186 *hwacceleration = PMINFO_HWACCELERATION_OFF;
1187 else if (strcasecmp(val, "on") == 0)
1188 *hwacceleration = PMINFO_HWACCELERATION_ON;
1190 *hwacceleration = PMINFO_HWACCELERATION_DEFAULT;
1195 API int pkgmgrinfo_appinfo_get_screenreader(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_screenreader *screenreader)
1198 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1200 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1201 retvm_if(screenreader == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1203 if (info->app_info == NULL || info->app_info->screenreader == NULL)
1204 return PMINFO_R_ERROR;
1206 val = (char *)info->app_info->screenreader;
1207 if (strcasecmp(val, "screenreader-off") == 0)
1208 *screenreader = PMINFO_SCREENREADER_OFF;
1209 else if (strcasecmp(val, "screenreader-on") == 0)
1210 *screenreader = PMINFO_SCREENREADER_ON;
1212 *screenreader = PMINFO_SCREENREADER_USE_SYSTEM_SETTING;
1217 API int pkgmgrinfo_appinfo_get_effectimage(pkgmgrinfo_appinfo_h handle, char **portrait_img, char **landscape_img)
1219 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1221 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1222 retvm_if(portrait_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1223 retvm_if(landscape_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1225 if (info->app_info == NULL)
1226 return PMINFO_R_ERROR;
1228 if (info->app_info->portraitimg == NULL)
1231 *portrait_img = (char *)info->app_info->portraitimg;
1233 if (info->app_info->landscapeimg == NULL)
1234 *landscape_img = "";
1236 *landscape_img = (char *)info->app_info->landscapeimg;
1241 API int pkgmgrinfo_appinfo_get_effectimage_type(pkgmgrinfo_appinfo_h handle, char **effectimage_type)
1243 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1245 if (handle == NULL || effectimage_type == NULL) {
1246 LOGE("invalid parameter");
1247 return PMINFO_R_EINVAL;
1250 if (info->app_info == NULL || info->app_info->effectimage_type == NULL)
1251 return PMINFO_R_ERROR;
1253 *effectimage_type = (char *)info->app_info->effectimage_type;
1258 API int pkgmgrinfo_appinfo_get_submode_mainid(pkgmgrinfo_appinfo_h handle, char **submode_mainid)
1260 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1262 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1263 retvm_if(submode_mainid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1265 if (info->app_info == NULL)
1266 return PMINFO_R_ERROR;
1268 if (info->app_info->submode_mainid == NULL)
1269 *submode_mainid = "";
1271 *submode_mainid = (char *)info->app_info->submode_mainid;
1276 API int pkgmgrinfo_appinfo_get_installed_storage_location(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_installed_storage *storage)
1278 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1279 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1281 if (info->app_info && info->app_info->installed_storage) {
1282 if (strcmp(info->app_info->installed_storage, "installed_internal") == 0)
1283 *storage = PMINFO_INTERNAL_STORAGE;
1284 else if (strcmp(info->app_info->installed_storage, "installed_external") == 0)
1285 *storage = PMINFO_EXTERNAL_STORAGE;
1287 return PMINFO_R_ERROR;
1289 return PMINFO_R_ERROR;
1295 API int pkgmgrinfo_appinfo_get_launch_mode(pkgmgrinfo_appinfo_h handle, char **mode)
1297 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1299 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1300 retvm_if(mode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1302 if (info->app_info->launch_mode == NULL)
1303 return PMINFO_R_ERROR;
1305 *mode = (char *)(info->app_info->launch_mode);
1310 API int pkgmgrinfo_appinfo_get_alias_appid(pkgmgrinfo_appinfo_h handle, char **alias_appid)
1312 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1314 if (handle == NULL || alias_appid == NULL) {
1315 LOGE("invalid parameter");
1316 return PMINFO_R_EINVAL;
1319 if (info->app_info == NULL || info->app_info->alias_appid == NULL)
1320 return PMINFO_R_ERROR;
1322 *alias_appid = (char *)info->app_info->alias_appid;
1327 API int pkgmgrinfo_appinfo_get_effective_appid(pkgmgrinfo_appinfo_h handle, char **effective_appid)
1329 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1331 if (handle == NULL || effective_appid == NULL) {
1332 LOGE("invalid parameter");
1333 return PMINFO_R_EINVAL;
1336 if (info->app_info == NULL)
1337 return PMINFO_R_ERROR;
1339 if (info->app_info->effective_appid == NULL)
1340 *effective_appid = "";
1342 *effective_appid = (char *)info->app_info->effective_appid;
1347 API int pkgmgrinfo_appinfo_get_tep_name(pkgmgrinfo_appinfo_h handle, char **tep_name)
1349 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1351 if (handle == NULL || tep_name == NULL) {
1352 LOGE("invalid parameter");
1353 return PMINFO_R_EINVAL;
1356 if (info->app_info == NULL)
1357 return PMINFO_R_ERROR;
1359 if (info->app_info->tep_name == NULL)
1362 *tep_name = (char *)info->app_info->tep_name;
1367 API int pkgmgrinfo_appinfo_get_zip_mount_file(pkgmgrinfo_appinfo_h handle, char **zip_mount_file)
1369 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1371 if (handle == NULL || zip_mount_file == NULL) {
1372 LOGE("invalid parameter");
1373 return PMINFO_R_EINVAL;
1376 if (info->app_info == NULL)
1377 return PMINFO_R_ERROR;
1379 if (info->app_info->zip_mount_file == NULL)
1380 *zip_mount_file = "";
1382 *zip_mount_file = (char *)info->app_info->zip_mount_file;
1387 API int pkgmgrinfo_appinfo_get_root_path(pkgmgrinfo_appinfo_h handle, char **root_path)
1389 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1391 if (handle == NULL || root_path == NULL) {
1392 LOGE("invalid parameter");
1393 return PMINFO_R_EINVAL;
1396 if (info->app_info == NULL || info->app_info->root_path == NULL)
1397 return PMINFO_R_ERROR;
1399 *root_path = (char *)info->app_info->root_path;
1404 API int pkgmgrinfo_appinfo_get_api_version(pkgmgrinfo_appinfo_h handle, char **api_version)
1406 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1408 if (handle == NULL || api_version == NULL) {
1409 LOGE("invalid parameter");
1410 return PMINFO_R_EINVAL;
1413 if (info->app_info == NULL || info->app_info->api_version == NULL)
1414 return PMINFO_R_ERROR;
1416 *api_version = (char *)info->app_info->api_version;
1421 API int pkgmgrinfo_appinfo_get_installed_time(pkgmgrinfo_appinfo_h handle, int *installed_time)
1423 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1425 if (handle == NULL || installed_time == NULL) {
1426 LOGE("invalid parameter");
1427 return PMINFO_R_EINVAL;
1430 if (info->app_info == NULL || info->app_info->package_installed_time == NULL)
1431 return PMINFO_R_ERROR;
1433 *installed_time = atoi(info->app_info->package_installed_time);
1438 API int pkgmgrinfo_appinfo_usr_get_datacontrol_info(const char *providerid,
1439 const char *type, uid_t uid, char **appid, char **access)
1443 if (providerid == NULL || type == NULL || appid == NULL ||
1445 LOGE("invalid parameter");
1446 return PMINFO_R_EINVAL;
1449 ret = _appinfo_get_datacontrol_info(providerid, type, uid, appid, access);
1450 /* FIXME: It should return PMINFO_R_ENOENT but to keep previous
1451 * implementation, return PMINFO_R_ERROR. This should be
1454 if (ret == PMINFO_R_ENOENT) {
1455 LOGE("no datacontrol info of %s", providerid);
1456 ret = PMINFO_R_ERROR;
1462 API int pkgmgrinfo_appinfo_get_datacontrol_info(const char *providerid,
1463 const char *type, char **appid, char **access)
1465 return pkgmgrinfo_appinfo_usr_get_datacontrol_info(providerid,
1466 type, _getuid(), appid, access);
1469 API int pkgmgrinfo_appinfo_usr_get_datacontrol_appid(const char *providerid,
1470 uid_t uid, char **appid)
1473 if (providerid == NULL || appid == NULL) {
1474 LOGE("invalid parameter");
1475 return PMINFO_R_EINVAL;
1478 ret = _appinfo_get_datacontrol_appid(providerid, uid, appid);
1479 /* FIXME: It should return PMINFO_R_ENOENT but to keep previous
1480 * implementation, return PMINFO_R_ERROR. This should be
1483 if (ret == PMINFO_R_ENOENT) {
1484 LOGE("no datacontrol appid of %s", providerid);
1485 ret = PMINFO_R_ERROR;
1491 API int pkgmgrinfo_appinfo_get_datacontrol_appid(const char *providerid, char **appid)
1493 return pkgmgrinfo_appinfo_usr_get_datacontrol_appid(providerid, _getuid(), appid);
1496 API int pkgmgrinfo_appinfo_usr_get_datacontrol_trusted_info(
1497 const char *providerid, const char *type, uid_t uid,
1498 char **appid, bool *is_trusted)
1501 char *trusted = NULL;
1502 if (providerid == NULL || type == NULL || appid == NULL ||
1503 is_trusted == NULL) {
1504 LOGE("invalid parameter");
1505 return PMINFO_R_EINVAL;
1508 ret = _appinfo_get_datacontrol_trusted_info(providerid, type, uid,
1511 /* FIXME: It should return PMINFO_R_ENOENT but to keep previous
1512 * implementation, return PMINFO_R_ERROR. This should be
1515 if (ret == PMINFO_R_ENOENT) {
1516 LOGE("no datacontrol trusted info of %s", providerid);
1517 ret = PMINFO_R_ERROR;
1519 *is_trusted = _get_bool_value(trusted);
1525 API int pkgmgrinfo_appinfo_get_datacontrol_trsuted_info(const char *providerid,
1526 const char *type, char **appid, bool *is_trusted)
1528 return pkgmgrinfo_appinfo_usr_get_datacontrol_trusted_info(providerid,
1529 type, _getuid(), appid, is_trusted);
1532 API int pkgmgrinfo_appinfo_usr_foreach_datacontrol_privileges(
1533 const char *providerid, const char *type,
1534 pkgmgrinfo_pkg_privilege_list_cb privilege_func,
1535 void *user_data, uid_t uid)
1541 if (providerid == NULL || type == NULL || privilege_func == NULL) {
1542 LOGE("invalid parameter");
1543 return PMINFO_R_EINVAL;
1546 ret = _appinfo_get_datacontrol_privileges(providerid, type, uid, &list);
1547 if (PMINFO_R_ERROR) {
1548 g_list_free_full(list, free);
1552 for (tmp = list; tmp != NULL; tmp = g_list_next(tmp)) {
1554 ret = privilege_func((char *)tmp->data, user_data);
1559 g_list_free_full(list, free);
1563 API int pkgmgrinfo_appinfo_foreach_datacontrol_privileges(
1564 const char *providerid, const char *type,
1565 pkgmgrinfo_pkg_privilege_list_cb privilege_func,
1568 return pkgmgrinfo_appinfo_usr_foreach_datacontrol_privileges(
1569 providerid, type, privilege_func, user_data, _getuid());
1572 API int pkgmgrinfo_appinfo_get_support_mode(pkgmgrinfo_appinfo_h handle, int *support_mode)
1574 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1575 retvm_if(support_mode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1577 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1578 if (info->app_info->support_mode)
1579 *support_mode = atoi(info->app_info->support_mode);
1586 API int pkgmgrinfo_appinfo_foreach_category(pkgmgrinfo_appinfo_h handle,
1587 pkgmgrinfo_app_category_list_cb category_func, void *user_data)
1589 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1590 retvm_if(category_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
1592 const char *category;
1594 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1596 if (info->app_info == NULL)
1597 return PMINFO_R_ERROR;
1599 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
1600 category = (const char *)tmp->data;
1602 ret = category_func(category, user_data);
1610 API int pkgmgrinfo_appinfo_foreach_metadata(pkgmgrinfo_appinfo_h handle,
1611 pkgmgrinfo_app_metadata_list_cb metadata_func, void *user_data)
1613 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1614 retvm_if(metadata_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
1618 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1620 if (info->app_info == NULL)
1621 return PMINFO_R_ERROR;
1623 for (tmp = info->app_info->metadata; tmp; tmp = tmp->next) {
1624 ptr = (metadata_x *)tmp->data;
1628 ret = metadata_func(ptr->key, ptr->value ? ptr->value : "", user_data);
1636 API int pkgmgrinfo_appinfo_usr_foreach_appcontrol_privileges(const char *appid,
1637 const char *operation,
1638 pkgmgrinfo_pkg_privilege_list_cb privilege_func,
1639 void *user_data, uid_t uid)
1642 GList *privilege_list = NULL;
1645 if (appid == NULL || operation == NULL || privilege_func == NULL) {
1646 LOGE("invalid parameter");
1647 return PMINFO_R_EINVAL;
1650 ret = _appinfo_get_appcontrol_privileges(appid, operation, uid,
1652 if (ret == PMINFO_R_ENOENT) {
1654 } else if (ret != PMINFO_R_OK) {
1655 g_list_free_full(privilege_list, free);
1659 for (tmp_list = privilege_list; tmp_list != NULL;
1660 tmp_list = g_list_next(tmp_list)) {
1661 ret = privilege_func((char *)tmp_list->data, user_data);
1666 g_list_free_full(privilege_list, free);
1670 API int pkgmgrinfo_appinfo_foreach_appcontrol_privileges(const char *appid,
1671 const char *operation,
1672 pkgmgrinfo_pkg_privilege_list_cb privilege_func,
1675 return pkgmgrinfo_appinfo_usr_foreach_appcontrol_privileges(appid,
1676 operation, privilege_func, user_data, _getuid());
1679 API int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
1680 pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
1682 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1683 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
1685 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1686 appcontrol_x *appcontrol;
1689 if (info->app_info == NULL)
1690 return PMINFO_R_ERROR;
1692 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
1693 appcontrol = (appcontrol_x *)tmp->data;
1694 if (appcontrol == NULL || !strcasecmp(appcontrol->visibility, "remote-only"))
1696 ret = appcontrol_func(appcontrol->operation, appcontrol->uri, appcontrol->mime, user_data);
1704 API int pkgmgrinfo_appinfo_foreach_remote_appcontrol(pkgmgrinfo_appinfo_h handle,
1705 pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
1707 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1708 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
1710 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1711 appcontrol_x *appcontrol;
1714 if (info->app_info == NULL)
1715 return PMINFO_R_ERROR;
1717 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
1718 appcontrol = (appcontrol_x *)tmp->data;
1719 if (appcontrol == NULL || !strcasecmp(appcontrol->visibility, "local-only"))
1721 ret = appcontrol_func(appcontrol->operation, appcontrol->uri, appcontrol->mime, user_data);
1729 API int pkgmgrinfo_appinfo_foreach_background_category(
1730 pkgmgrinfo_appinfo_h handle,
1731 pkgmgrinfo_app_background_category_list_cb category_func,
1734 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1738 if (handle == NULL || category_func == NULL || info->app_info == NULL) {
1739 LOGE("invalid parameter");
1740 return PMINFO_R_EINVAL;
1743 for (tmp = info->app_info->background_category; tmp; tmp = tmp->next) {
1744 category = (char *)tmp->data;
1745 if (category == NULL)
1748 if (category_func(category, user_data) < 0)
1755 API int pkgmgrinfo_appinfo_foreach_splash_screen(pkgmgrinfo_appinfo_h handle,
1756 pkgmgrinfo_app_splash_screen_list_cb splash_screen_func,
1759 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1760 splashscreen_x *splashscreen;
1764 if (info == NULL || info->app_info == NULL
1765 || splash_screen_func == NULL) {
1766 LOGE("invalid parameter");
1767 return PMINFO_R_EINVAL;
1770 for (tmp = info->app_info->splashscreens; tmp; tmp = tmp->next) {
1771 splashscreen = (splashscreen_x *)tmp->data;
1772 if (splashscreen == NULL)
1774 ret = splash_screen_func(splashscreen->src,
1776 splashscreen->orientation,
1777 splashscreen->indicatordisplay,
1778 splashscreen->operation,
1779 splashscreen->color_depth,
1788 API int pkgmgrinfo_appinfo_is_nodisplay(pkgmgrinfo_appinfo_h handle, bool *nodisplay)
1790 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1791 retvm_if(nodisplay == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1792 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1794 if (info->app_info == NULL || info->app_info->nodisplay == NULL)
1795 return PMINFO_R_ERROR;
1797 *nodisplay = _get_bool_value(info->app_info->nodisplay);
1802 API int pkgmgrinfo_appinfo_is_multiple(pkgmgrinfo_appinfo_h handle, bool *multiple)
1804 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1805 retvm_if(multiple == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1806 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1808 if (info->app_info == NULL || info->app_info->multiple == NULL)
1809 return PMINFO_R_ERROR;
1811 *multiple = _get_bool_value(info->app_info->multiple);
1816 API int pkgmgrinfo_appinfo_is_indicator_display_allowed(pkgmgrinfo_appinfo_h handle, bool *indicator_disp)
1818 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1819 retvm_if(indicator_disp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1820 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1822 if (info->app_info == NULL || info->app_info->indicatordisplay == NULL)
1823 return PMINFO_R_ERROR;
1825 *indicator_disp = _get_bool_value(info->app_info->indicatordisplay);
1830 API int pkgmgrinfo_appinfo_is_taskmanage(pkgmgrinfo_appinfo_h handle, bool *taskmanage)
1832 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1833 retvm_if(taskmanage == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1834 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1836 if (info->app_info == NULL || info->app_info->taskmanage == NULL)
1837 return PMINFO_R_ERROR;
1839 *taskmanage = _get_bool_value(info->app_info->taskmanage);
1844 API int pkgmgrinfo_appinfo_is_enabled(pkgmgrinfo_appinfo_h handle, bool *enabled)
1846 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1847 retvm_if(enabled == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1848 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1850 if (info->app_info == NULL || info->app_info->is_disabled == NULL)
1851 return PMINFO_R_ERROR;
1853 *enabled = !_get_bool_value(info->app_info->is_disabled);
1858 API int pkgmgrinfo_appinfo_is_onboot(pkgmgrinfo_appinfo_h handle, bool *onboot)
1860 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1861 retvm_if(onboot == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1862 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1864 if (info->app_info == NULL || info->app_info->onboot == NULL)
1865 return PMINFO_R_ERROR;
1867 *onboot = _get_bool_value(info->app_info->onboot);
1872 API int pkgmgrinfo_appinfo_is_autorestart(pkgmgrinfo_appinfo_h handle, bool *autorestart)
1874 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1875 retvm_if(autorestart == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1876 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1878 if (info->app_info == NULL || info->app_info->autorestart == NULL)
1879 return PMINFO_R_ERROR;
1881 *autorestart = _get_bool_value(info->app_info->autorestart);
1886 API int pkgmgrinfo_appinfo_is_mainapp(pkgmgrinfo_appinfo_h handle, bool *mainapp)
1888 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1889 retvm_if(mainapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1890 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1892 if (info->app_info == NULL || info->app_info->mainapp == NULL)
1893 return PMINFO_R_ERROR;
1895 *mainapp = _get_bool_value(info->app_info->mainapp);
1900 API int pkgmgrinfo_appinfo_is_preload(pkgmgrinfo_appinfo_h handle, bool *preload)
1902 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1903 retvm_if(preload == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1904 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1906 if (info->app_info == NULL || info->app_info->preload == NULL)
1907 return PMINFO_R_ERROR;
1909 *preload = _get_bool_value(info->app_info->preload);
1914 API int pkgmgrinfo_appinfo_is_submode(pkgmgrinfo_appinfo_h handle, bool *submode)
1916 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1917 retvm_if(submode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1918 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1920 if (info->app_info == NULL || info->app_info->submode == NULL)
1921 return PMINFO_R_ERROR;
1923 *submode = _get_bool_value(info->app_info->submode);
1928 API int pkgmgrinfo_appinfo_is_process_pool(pkgmgrinfo_appinfo_h handle, bool *process_pool)
1930 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1932 if (handle == NULL || process_pool == NULL) {
1933 LOGE("invalid parameter");
1934 return PMINFO_R_EINVAL;
1937 if (info->app_info == NULL)
1938 return PMINFO_R_ERROR;
1940 *process_pool = _get_bool_value(info->app_info->process_pool);
1945 API int pkgmgrinfo_appinfo_is_category_exist(pkgmgrinfo_appinfo_h handle, const char *category, bool *exist)
1947 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1948 retvm_if(category == NULL, PMINFO_R_EINVAL, "category is NULL");
1949 retvm_if(exist == NULL, PMINFO_R_EINVAL, "exist is NULL");
1953 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1955 if (info->app_info == NULL)
1956 return PMINFO_R_ERROR;
1959 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
1960 val = (const char *)tmp->data;
1963 if (strcasecmp(val, category) == 0) {
1972 API int pkgmgrinfo_appinfo_is_ui_gadget(pkgmgrinfo_appinfo_h handle,
1975 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1977 if (info == NULL || info->app_info == NULL || ui_gadget == NULL) {
1978 _LOGE("invalid parameter");
1979 return PMINFO_R_EINVAL;
1981 if (info->app_info->ui_gadget == NULL)
1982 info->app_info->ui_gadget = strdup("false");
1984 *ui_gadget = _get_bool_value(info->app_info->ui_gadget);
1989 API int pkgmgrinfo_appinfo_is_support_disable(pkgmgrinfo_appinfo_h handle,
1990 bool *support_disable)
1992 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1994 if (info == NULL || info->app_info == NULL || support_disable == NULL) {
1995 _LOGE("invalid parameter");
1996 return PMINFO_R_EINVAL;
1999 *support_disable = _get_bool_value(info->app_info->support_disable);
2004 API int pkgmgrinfo_appinfo_is_removable(pkgmgrinfo_appinfo_h handle,
2007 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2009 if (info == NULL || info->app_info == NULL || removable == NULL) {
2010 _LOGE("invalid parameter");
2011 return PMINFO_R_EINVAL;
2014 *removable = _get_bool_value(info->app_info->removable);
2019 API int pkgmgrinfo_appinfo_is_system(pkgmgrinfo_appinfo_h handle, bool *system)
2021 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2023 if (info == NULL || info->app_info == NULL || system == NULL) {
2024 _LOGE("invalid parameter");
2025 return PMINFO_R_EINVAL;
2028 *system = _get_bool_value(info->app_info->package_system);
2033 API int pkgmgrinfo_appinfo_is_disabled(pkgmgrinfo_appinfo_h handle, bool *disabled)
2035 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2036 retvm_if(disabled == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2037 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2039 if (info->app_info == NULL || info->app_info->is_disabled == NULL)
2040 return PMINFO_R_ERROR;
2042 *disabled = _get_bool_value(info->app_info->is_disabled);
2047 API int pkgmgrinfo_appinfo_is_global(pkgmgrinfo_appinfo_h handle, bool *global)
2049 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2051 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2052 retvm_if(global == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2054 if (info->app_info == NULL || info->app_info->for_all_users == NULL)
2055 return PMINFO_R_ERROR;
2057 *global = _get_bool_value(info->app_info->for_all_users);
2062 API int pkgmgrinfo_appinfo_get_splash_screen_display(pkgmgrinfo_appinfo_h handle, bool *splash_screen_display)
2064 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2066 if (info == NULL || splash_screen_display == NULL) {
2067 _LOGE("Invalid parameter");
2068 return PMINFO_R_EINVAL;
2071 if (info->app_info == NULL || info->app_info->splash_screen_display == NULL)
2072 return PMINFO_R_ERROR;
2074 *splash_screen_display = _get_bool_value(info->app_info->splash_screen_display);
2079 API int pkgmgrinfo_appinfo_get_setup_appid(pkgmgrinfo_appinfo_h handle, char **setup_appid)
2081 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2083 if (info == NULL || setup_appid == NULL) {
2084 _LOGE("Invalid parameter");
2085 return PMINFO_R_EINVAL;
2088 if (info->app_info == NULL || info->app_info->setup_appid == NULL)
2089 return PMINFO_R_ERROR;
2091 *setup_appid = info->app_info->setup_appid;
2095 API int pkgmgrinfo_appinfo_is_support_ambient(pkgmgrinfo_appinfo_h handle,
2096 bool *support_ambient)
2098 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2100 if (info == NULL || support_ambient == NULL) {
2101 _LOGE("Invalid parameter");
2102 return PMINFO_R_EINVAL;
2105 if (info->app_info == NULL || info->app_info->support_ambient == NULL)
2106 return PMINFO_R_ERROR;
2108 *support_ambient = _get_bool_value(info->app_info->support_ambient);
2113 API int pkgmgrinfo_appinfo_destroy_appinfo(pkgmgrinfo_appinfo_h handle)
2115 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2116 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2117 __cleanup_appinfo(info);
2121 API int pkgmgrinfo_appinfo_filter_create(pkgmgrinfo_appinfo_filter_h *handle)
2123 return (pkgmgrinfo_pkginfo_filter_create(handle));
2126 API int pkgmgrinfo_appinfo_filter_destroy(pkgmgrinfo_appinfo_filter_h handle)
2128 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
2131 static gint __compare_func(gconstpointer data1, gconstpointer data2)
2133 pkgmgrinfo_node_x *node1 = (pkgmgrinfo_node_x *)data1;
2134 pkgmgrinfo_node_x *node2 = (pkgmgrinfo_node_x *)data2;
2135 if (node1->prop == node2->prop)
2137 else if (node1->prop > node2->prop)
2143 API int pkgmgrinfo_appinfo_filter_add_int(pkgmgrinfo_appinfo_filter_h handle,
2144 const char *property, const int value)
2146 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2147 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2148 char buf[PKG_VALUE_STRING_LEN_MAX] = {'\0'};
2150 GSList *link = NULL;
2152 prop = _pminfo_appinfo_convert_to_prop_int(property);
2153 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_INT ||
2154 prop > E_PMINFO_APPINFO_PROP_APP_MAX_INT) {
2155 _LOGE("Invalid Integer Property\n");
2156 return PMINFO_R_EINVAL;
2158 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2159 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1, sizeof(pkgmgrinfo_node_x));
2161 _LOGE("Out of Memory!!!\n");
2162 return PMINFO_R_ERROR;
2164 snprintf(buf, PKG_VALUE_STRING_LEN_MAX - 1, "%d", value);
2165 val = strndup(buf, PKG_VALUE_STRING_LEN_MAX - 1);
2167 _LOGE("Out of Memory\n");
2170 return PMINFO_R_ERROR;
2174 /*If API is called multiple times for same property, we should override the previous values.
2175 Last value set will be used for filtering.*/
2176 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2178 filter->list = g_slist_delete_link(filter->list, link);
2179 filter->list = g_slist_append(filter->list, (gpointer)node);
2184 API int pkgmgrinfo_appinfo_filter_add_bool(pkgmgrinfo_appinfo_filter_h handle,
2185 const char *property, const bool value)
2187 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2188 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2190 GSList *link = NULL;
2192 prop = _pminfo_appinfo_convert_to_prop_bool(property);
2193 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_BOOL ||
2194 prop > E_PMINFO_APPINFO_PROP_APP_MAX_BOOL) {
2195 _LOGE("Invalid Boolean Property\n");
2196 return PMINFO_R_EINVAL;
2198 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2199 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1, sizeof(pkgmgrinfo_node_x));
2201 _LOGE("Out of Memory!!!\n");
2202 return PMINFO_R_ERROR;
2205 val = strndup("true", 4);
2207 val = strndup("false", 5);
2209 _LOGE("Out of Memory\n");
2212 return PMINFO_R_ERROR;
2216 /*If API is called multiple times for same property, we should override the previous values.
2217 Last value set will be used for filtering.*/
2218 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2220 filter->list = g_slist_delete_link(filter->list, link);
2221 filter->list = g_slist_append(filter->list, (gpointer)node);
2226 API int pkgmgrinfo_appinfo_filter_add_string(pkgmgrinfo_appinfo_filter_h handle,
2227 const char *property, const char *value)
2229 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2230 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2231 retvm_if(value == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2233 pkgmgrinfo_node_x *ptr = NULL;
2234 char prev[PKG_STRING_LEN_MAX] = {'\0'};
2235 char temp[PKG_STRING_LEN_MAX] = {'\0'};
2236 GSList *link = NULL;
2239 prop = _pminfo_appinfo_convert_to_prop_str(property);
2240 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_STR ||
2241 prop > E_PMINFO_APPINFO_PROP_APP_MAX_STR) {
2242 _LOGE("Invalid String Property\n");
2243 return PMINFO_R_EINVAL;
2245 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2246 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1, sizeof(pkgmgrinfo_node_x));
2248 _LOGE("Out of Memory!!!\n");
2249 return PMINFO_R_ERROR;
2253 case E_PMINFO_APPINFO_PROP_APP_COMPONENT:
2254 node->value = strdup(value);
2255 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2257 filter->list = g_slist_delete_link(filter->list, link);
2258 filter->list = g_slist_append(filter->list, (gpointer)node);
2260 case E_PMINFO_APPINFO_PROP_APP_CATEGORY:
2261 val = (char *)calloc(1, PKG_STRING_LEN_MAX);
2263 _LOGE("Out of Memory\n");
2266 return PMINFO_R_ERROR;
2268 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2270 ptr = (pkgmgrinfo_node_x *)link->data;
2271 strncpy(prev, ptr->value, PKG_STRING_LEN_MAX - 1);
2272 _LOGI("Previous value is %s\n", prev);
2273 filter->list = g_slist_delete_link(filter->list, link);
2274 ret = snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s,%s", prev, value);
2275 if (ret < 0 || ret > PKG_STRING_LEN_MAX - 1) {
2276 _LOGE("snprintf fail\n");
2279 return PMINFO_R_ERROR;
2281 strncpy(val, temp, PKG_STRING_LEN_MAX);
2282 _LOGI("New value is %s\n", val);
2284 filter->list = g_slist_append(filter->list, (gpointer)node);
2285 memset(temp, '\0', PKG_STRING_LEN_MAX);
2287 snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s", value);
2288 strncpy(val, temp, PKG_STRING_LEN_MAX);
2289 _LOGI("First value is %s\n", val);
2291 filter->list = g_slist_append(filter->list, (gpointer)node);
2292 memset(temp, '\0', PKG_STRING_LEN_MAX);
2296 node->value = strndup(value, PKG_STRING_LEN_MAX - 1);
2297 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2299 filter->list = g_slist_delete_link(filter->list, link);
2300 filter->list = g_slist_append(filter->list, (gpointer)node);
2306 API int pkgmgrinfo_appinfo_usr_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count, uid_t uid)
2310 if (handle == NULL || count == NULL) {
2311 _LOGE("invalid parameter");
2312 return PMINFO_R_EINVAL;
2315 list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
2316 __free_applications);
2318 return PMINFO_R_ERROR;
2320 if (__check_disable_filter_exist(
2321 handle, E_APPINFO_DISABLE_TYPE_APP) == false) {
2322 if (pkgmgrinfo_appinfo_filter_add_bool(handle,
2323 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
2324 g_hash_table_destroy(list);
2325 return PMINFO_R_ERROR;
2329 if (__check_disable_filter_exist(
2330 handle, E_APPINFO_DISABLE_TYPE_PKG) == false) {
2331 if (pkgmgrinfo_appinfo_filter_add_bool(handle,
2332 PMINFO_APPINFO_PROP_PKG_DISABLE, false)) {
2333 g_hash_table_destroy(list);
2334 return PMINFO_R_ERROR;
2338 // TODO: use pkginfo-client APIs
2339 *count = g_hash_table_size(list);
2340 g_hash_table_destroy(list);
2345 API int pkgmgrinfo_appinfo_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count)
2347 return pkgmgrinfo_appinfo_usr_filter_count(handle, count, _getuid());
2350 API int pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(
2351 pkgmgrinfo_appinfo_filter_h handle,
2352 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
2354 if (handle == NULL || app_cb == NULL) {
2355 LOGE("invalid parameter");
2356 return PMINFO_R_EINVAL;
2359 if (__check_disable_filter_exist(
2360 handle, E_APPINFO_DISABLE_TYPE_APP) == false) {
2361 if (pkgmgrinfo_appinfo_filter_add_bool(handle,
2362 PMINFO_APPINFO_PROP_APP_DISABLE, false))
2363 return PMINFO_R_ERROR;
2366 if (__check_disable_filter_exist(
2367 handle, E_APPINFO_DISABLE_TYPE_PKG) == false) {
2368 if (pkgmgrinfo_appinfo_filter_add_bool(handle,
2369 PMINFO_APPINFO_PROP_PKG_DISABLE, false))
2370 return PMINFO_R_ERROR;
2373 return _appinfo_get_filtered_foreach_appinfo(uid, handle, PMINFO_APPINFO_GET_ALL, app_cb,
2377 API int pkgmgrinfo_appinfo_filter_foreach_appinfo(pkgmgrinfo_appinfo_filter_h handle,
2378 pkgmgrinfo_app_list_cb app_cb, void *user_data)
2380 return pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(handle, app_cb, user_data, _getuid());
2383 API int pkgmgrinfo_appinfo_metadata_filter_create(pkgmgrinfo_appinfo_metadata_filter_h *handle)
2385 return (pkgmgrinfo_pkginfo_filter_create(handle));
2388 API int pkgmgrinfo_appinfo_metadata_filter_destroy(pkgmgrinfo_appinfo_metadata_filter_h handle)
2390 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
2393 API int pkgmgrinfo_appinfo_metadata_filter_add(
2394 pkgmgrinfo_appinfo_metadata_filter_h handle,
2395 const char *key, const char *value)
2397 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2398 pkgmgrinfo_metadata_node_x *node;
2400 /* value can be NULL.
2401 * In that case all apps with specified key should be displayed
2404 LOGE("invalid parameter");
2405 return PMINFO_R_EINVAL;
2408 node = calloc(1, sizeof(pkgmgrinfo_metadata_node_x));
2410 LOGE("out of memory");
2411 return PMINFO_R_ERROR;
2414 node->key = strdup(key);
2415 if (value && strlen(value))
2416 node->value = strdup(value);
2418 filter->list_metadata = g_slist_append(filter->list_metadata,
2424 API int pkgmgrinfo_appinfo_usr_metadata_filter_foreach(
2425 pkgmgrinfo_appinfo_metadata_filter_h handle,
2426 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
2428 if (handle == NULL || app_cb == NULL) {
2429 LOGE("invalid parameter");
2430 return PMINFO_R_EINVAL;
2433 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2434 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
2435 PMINFO_APPINFO_PROP_APP_DISABLE, false))
2436 return PMINFO_R_ERROR;
2438 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
2439 PMINFO_APPINFO_PROP_PKG_DISABLE, false))
2440 return PMINFO_R_ERROR;
2442 return _appinfo_get_filtered_foreach_appinfo(uid, handle, PMINFO_APPINFO_GET_ALL, app_cb,
2446 API int pkgmgrinfo_appinfo_metadata_filter_foreach(
2447 pkgmgrinfo_appinfo_metadata_filter_h handle,
2448 pkgmgrinfo_app_list_cb app_cb, void *user_data)
2450 return pkgmgrinfo_appinfo_usr_metadata_filter_foreach(handle, app_cb,
2451 user_data, _getuid());
2454 API int pkgmgrinfo_appinfo_is_guestmode_visibility(pkgmgrinfo_appinfo_h handle, bool *status)
2457 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2459 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2460 retvm_if(status == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2462 val = info->app_info->guestmode_visibility;
2463 *status = _get_bool_value(val);
2467 API int pkgmgrinfo_appinfo_foreach_appcontrol_v2(pkgmgrinfo_appinfo_h handle,
2468 pkgmgrinfo_app_control_list_cb_v2 appcontrol_func,
2471 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2472 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2474 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2475 appcontrol_x *appcontrol;
2478 if (info->app_info == NULL)
2479 return PMINFO_R_ERROR;
2481 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
2482 appcontrol = (appcontrol_x *)tmp->data;
2483 if (appcontrol == NULL ||
2484 !strcasecmp(appcontrol->visibility, "remote-only"))
2486 ret = appcontrol_func(appcontrol->operation, appcontrol->uri,
2487 appcontrol->mime, appcontrol->id, user_data);
2495 API int pkgmgrinfo_appinfo_foreach_remote_appcontrol_v2(
2496 pkgmgrinfo_appinfo_h handle,
2497 pkgmgrinfo_app_control_list_cb_v2 appcontrol_func,
2500 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2501 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2503 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2504 appcontrol_x *appcontrol;
2507 if (info->app_info == NULL)
2508 return PMINFO_R_ERROR;
2510 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
2511 appcontrol = (appcontrol_x *)tmp->data;
2512 if (appcontrol == NULL ||
2513 !strcasecmp(appcontrol->visibility, "local-only"))
2515 ret = appcontrol_func(appcontrol->operation, appcontrol->uri,
2516 appcontrol->mime, appcontrol->id, user_data);