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");
127 g_hash_table_destroy(list);
129 return PMINFO_R_ERROR;
132 /* just free list only */
133 g_hash_table_steal(list, (gconstpointer)appid);
134 g_hash_table_destroy(list);
141 API int pkgmgrinfo_appinfo_get_usr_disabled_appinfo(const char *appid, uid_t uid,
142 pkgmgrinfo_appinfo_h *handle)
145 pkgmgrinfo_appinfo_filter_h filter;
147 if (appid == NULL || handle == NULL) {
148 LOGE("invalid parameter");
149 return PMINFO_R_EINVAL;
152 ret = pkgmgrinfo_appinfo_filter_create(&filter);
153 if (ret != PMINFO_R_OK)
156 ret = pkgmgrinfo_appinfo_filter_add_string(filter,
157 PMINFO_APPINFO_PROP_APP_ID, appid);
158 if (ret != PMINFO_R_OK) {
159 pkgmgrinfo_appinfo_filter_destroy(filter);
160 return PMINFO_R_ERROR;
163 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
164 PMINFO_APPINFO_PROP_APP_DISABLE, true);
165 if (ret != PMINFO_R_OK) {
166 pkgmgrinfo_appinfo_filter_destroy(filter);
167 return PMINFO_R_ERROR;
170 ret = _pkgmgrinfo_get_appinfo(appid, uid, filter, handle);
171 pkgmgrinfo_appinfo_filter_destroy(filter);
176 API int pkgmgrinfo_appinfo_get_disabled_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
178 return pkgmgrinfo_appinfo_get_usr_disabled_appinfo(appid, _getuid(), handle);
181 API int pkgmgrinfo_appinfo_get_usr_appinfo(const char *appid, uid_t uid,
182 pkgmgrinfo_appinfo_h *handle)
185 pkgmgrinfo_appinfo_filter_h filter;
187 if (appid == NULL || handle == NULL) {
188 LOGE("invalid parameter");
189 return PMINFO_R_EINVAL;
192 ret = pkgmgrinfo_appinfo_filter_create(&filter);
193 if (ret != PMINFO_R_OK)
196 ret = pkgmgrinfo_appinfo_filter_add_string(filter,
197 PMINFO_APPINFO_PROP_APP_ID, appid);
198 if (ret != PMINFO_R_OK) {
199 pkgmgrinfo_appinfo_filter_destroy(filter);
200 return PMINFO_R_ERROR;
203 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
204 PMINFO_APPINFO_PROP_APP_DISABLE, false);
205 if (ret != PMINFO_R_OK) {
206 pkgmgrinfo_appinfo_filter_destroy(filter);
207 return PMINFO_R_ERROR;
210 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
211 PMINFO_APPINFO_PROP_PKG_DISABLE, false);
212 if (ret != PMINFO_R_OK) {
213 pkgmgrinfo_appinfo_filter_destroy(filter);
214 return PMINFO_R_ERROR;
217 ret = _pkgmgrinfo_get_appinfo(appid, uid, filter, handle);
218 pkgmgrinfo_appinfo_filter_destroy(filter);
222 API int pkgmgrinfo_appinfo_get_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
224 return pkgmgrinfo_appinfo_get_usr_appinfo(appid, _getuid(), handle);
227 API int pkgmgrinfo_appinfo_get_usr_all_appinfo(const char *appid, uid_t uid,
228 pkgmgrinfo_appinfo_h *handle)
231 pkgmgrinfo_appinfo_filter_h filter;
233 if (appid == NULL || handle == NULL) {
234 LOGE("invalid parameter");
235 return PMINFO_R_EINVAL;
238 ret = pkgmgrinfo_appinfo_filter_create(&filter);
239 if (ret != PMINFO_R_OK)
242 ret = pkgmgrinfo_appinfo_filter_add_string(filter,
243 PMINFO_APPINFO_PROP_APP_ID, appid);
244 if (ret != PMINFO_R_OK) {
245 pkgmgrinfo_appinfo_filter_destroy(filter);
246 return PMINFO_R_ERROR;
249 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
250 PMINFO_APPINFO_PROP_APP_CHECK_STORAGE, false);
251 if (ret != PMINFO_R_OK) {
252 pkgmgrinfo_appinfo_filter_destroy(filter);
253 return PMINFO_R_ERROR;
256 ret = _pkgmgrinfo_get_appinfo(appid, uid, filter, handle);
257 pkgmgrinfo_appinfo_filter_destroy(filter);
262 API int pkgmgrinfo_appinfo_get_all_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
264 return pkgmgrinfo_appinfo_get_usr_all_appinfo(appid, _getuid(), handle);
267 static gpointer __copy_str(gconstpointer src, gpointer data)
269 const char *tmp = (const char *)src;
272 buffer = strdup(tmp);
273 if (buffer == NULL) {
274 LOGE("memory alloc failed");
282 static gpointer __copy_label(gconstpointer src, gpointer data)
284 label_x *tmp = (label_x *)src;
287 label = calloc(1, sizeof(label_x));
289 LOGE("memory alloc failed");
295 label->name = strdup(tmp->name);
297 label->text = strdup(tmp->text);
299 label->lang = strdup(tmp->lang);
304 static gpointer __copy_icon(gconstpointer src, gpointer data)
306 icon_x *tmp = (icon_x *)src;
309 icon = calloc(1, sizeof(icon_x));
311 LOGE("memory alloc failed");
317 icon->text = strdup(tmp->text);
319 icon->lang = strdup(tmp->lang);
321 icon->section = strdup(tmp->section);
323 icon->size = strdup(tmp->size);
325 icon->resolution = strdup(tmp->resolution);
330 static gpointer __copy_metadata(gconstpointer src, gpointer data)
332 metadata_x *tmp = (metadata_x *)src;
333 metadata_x *metadata;
335 metadata = calloc(1, sizeof(metadata_x));
336 if (metadata == NULL) {
337 LOGE("memory alloc failed");
343 metadata->key = strdup(tmp->key);
345 metadata->value = strdup(tmp->value);
350 static gpointer __copy_datacontrol(gconstpointer src, gpointer data)
352 datacontrol_x *tmp = (datacontrol_x *)src;
353 datacontrol_x *datacontrol;
355 datacontrol = calloc(1, sizeof(datacontrol_x));
356 if (datacontrol == NULL) {
357 LOGE("memory alloc failed");
363 datacontrol->providerid = strdup(tmp->providerid);
365 datacontrol->access = strdup(tmp->access);
367 datacontrol->type = strdup(tmp->type);
369 datacontrol->trusted = strdup(tmp->trusted);
374 static gpointer __copy_appcontrol(gconstpointer src, gpointer data)
376 appcontrol_x *tmp = (appcontrol_x *)src;
377 appcontrol_x *appcontrol;
379 appcontrol = calloc(1, sizeof(appcontrol_x));
380 if (appcontrol == NULL) {
381 LOGE("memory alloc failed");
387 appcontrol->operation = strdup(tmp->operation);
389 appcontrol->uri = strdup(tmp->uri);
391 appcontrol->mime = strdup(tmp->mime);
396 static gpointer __copy_splashscreens(gconstpointer src, gpointer data)
398 splashscreen_x *tmp = (splashscreen_x *)src;
399 splashscreen_x *splashscreen;
401 splashscreen = (splashscreen_x *)calloc(1, sizeof(splashscreen_x));
402 if (splashscreen == NULL) {
403 LOGE("memory alloc failed");
409 splashscreen->src = strdup(tmp->src);
411 splashscreen->type = strdup(tmp->type);
412 if (tmp->orientation)
413 splashscreen->orientation = strdup(tmp->orientation);
414 if (tmp->indicatordisplay)
415 splashscreen->indicatordisplay = strdup(tmp->indicatordisplay);
417 splashscreen->operation = strdup(tmp->operation);
418 if (tmp->color_depth)
419 splashscreen->color_depth = strdup(tmp->color_depth);
424 static int _appinfo_copy_appinfo(application_x **application, application_x *data)
426 application_x *app_info;
429 app_info = calloc(1, sizeof(application_x));
430 if (app_info == NULL) {
431 LOGE("memory alloc failed");
432 return PMINFO_R_ERROR;
435 if (data->appid != NULL)
436 app_info->appid = strdup(data->appid);
437 if (data->exec != NULL)
438 app_info->exec = strdup(data->exec);
439 if (data->nodisplay != NULL)
440 app_info->nodisplay = strdup(data->nodisplay);
441 if (data->multiple != NULL)
442 app_info->multiple = strdup(data->multiple);
443 if (data->taskmanage != NULL)
444 app_info->taskmanage = strdup(data->taskmanage);
445 if (data->type != NULL)
446 app_info->type = strdup(data->type);
447 if (data->categories != NULL)
448 app_info->categories = strdup(data->categories);
449 if (data->hwacceleration != NULL)
450 app_info->hwacceleration = strdup(data->hwacceleration);
451 if (data->screenreader != NULL)
452 app_info->screenreader = strdup(data->screenreader);
453 if (data->mainapp != NULL)
454 app_info->mainapp = strdup(data->mainapp);
455 if (data->package != NULL)
456 app_info->package = strdup(data->package);
457 if (data->recentimage != NULL)
458 app_info->recentimage = strdup(data->recentimage);
459 if (data->launchcondition != NULL)
460 app_info->launchcondition = strdup(data->launchcondition);
461 if (data->indicatordisplay != NULL)
462 app_info->indicatordisplay = strdup(data->indicatordisplay);
463 if (data->portraitimg != NULL)
464 app_info->portraitimg = strdup(data->portraitimg);
465 if (data->landscapeimg != NULL)
466 app_info->landscapeimg = strdup(data->landscapeimg);
467 if (data->guestmode_visibility != NULL)
468 app_info->guestmode_visibility = strdup(data->guestmode_visibility);
469 if (data->component != NULL)
470 app_info->component = strdup(data->component);
471 if (data->permission_type != NULL)
472 app_info->permission_type = strdup(data->permission_type);
473 if (data->component_type != NULL)
474 app_info->component_type = strdup(data->component_type);
475 if (data->preload != NULL)
476 app_info->preload = strdup(data->preload);
477 if (data->submode != NULL)
478 app_info->submode = strdup(data->submode);
479 if (data->submode_mainid != NULL)
480 app_info->submode_mainid = strdup(data->submode_mainid);
481 if (data->process_pool != NULL)
482 app_info->process_pool = strdup(data->process_pool);
483 if (data->installed_storage != NULL)
484 app_info->installed_storage = strdup(data->installed_storage);
485 if (data->autorestart != NULL)
486 app_info->autorestart = strdup(data->autorestart);
487 if (data->onboot != NULL)
488 app_info->onboot = strdup(data->onboot);
489 if (data->support_disable != NULL)
490 app_info->support_disable = strdup(data->support_disable);
491 if (data->ui_gadget != NULL)
492 app_info->ui_gadget = strdup(data->ui_gadget);
493 if (data->launch_mode != NULL)
494 app_info->launch_mode = strdup(data->launch_mode);
495 if (data->package_type != NULL)
496 app_info->package_type = strdup(data->package_type);
497 if (data->effective_appid != NULL)
498 app_info->effective_appid = strdup(data->effective_appid);
499 if (data->splash_screen_display != NULL)
500 app_info->splash_screen_display = strdup(data->splash_screen_display);
504 app_info->label = g_list_copy_deep(data->label, __copy_label, &ret);
506 LOGE("memory alloc failed");
507 pkgmgrinfo_basic_free_application(app_info);
508 return PMINFO_R_ERROR;
512 app_info->icon = g_list_copy_deep(data->icon, __copy_icon, &ret);
514 LOGE("memory alloc failed");
515 pkgmgrinfo_basic_free_application(app_info);
516 return PMINFO_R_ERROR;
520 app_info->category = g_list_copy_deep(data->category, __copy_str, &ret);
522 LOGE("memory alloc failed");
523 pkgmgrinfo_basic_free_application(app_info);
524 return PMINFO_R_ERROR;
528 app_info->metadata = g_list_copy_deep(data->metadata, __copy_metadata, &ret);
530 LOGE("memory alloc failed");
531 pkgmgrinfo_basic_free_application(app_info);
532 return PMINFO_R_ERROR;
536 app_info->datacontrol = g_list_copy_deep(data->datacontrol, __copy_datacontrol, &ret);
538 LOGE("memory alloc failed");
539 pkgmgrinfo_basic_free_application(app_info);
540 return PMINFO_R_ERROR;
544 app_info->appcontrol = g_list_copy_deep(data->appcontrol, __copy_appcontrol, &ret);
546 LOGE("memory alloc failed");
547 pkgmgrinfo_basic_free_application(app_info);
548 return PMINFO_R_ERROR;
552 app_info->background_category = g_list_copy_deep(data->background_category, __copy_str, &ret);
554 LOGE("memory alloc failed");
555 pkgmgrinfo_basic_free_application(app_info);
556 return PMINFO_R_ERROR;
560 app_info->splashscreens = g_list_copy_deep(data->splashscreens, __copy_splashscreens, &ret);
562 LOGE("memory alloc failed");
563 pkgmgrinfo_basic_free_application(app_info);
564 return PMINFO_R_ERROR;
567 *application = app_info;
572 API int pkgmgrinfo_appinfo_clone_appinfo(pkgmgrinfo_appinfo_h handle,
573 pkgmgrinfo_appinfo_h *clone)
575 pkgmgr_appinfo_x *info;
576 pkgmgr_appinfo_x *temp = (pkgmgr_appinfo_x *)handle;
579 return PMINFO_R_EINVAL;
581 info = calloc(1, sizeof(pkgmgr_appinfo_x));
583 LOGE("memory alloc failed");
584 return PMINFO_R_ERROR;
587 if (temp->package != NULL)
588 info->package = strdup(temp->package);
589 if (temp->locale != NULL)
590 info->locale = strdup(temp->locale);
592 info->app_component = temp->app_component;
594 if (_appinfo_copy_appinfo(&info->app_info, temp->app_info) < 0) {
595 LOGE("appinfo copy failed");
597 free((void *)info->package);
601 return PMINFO_R_ERROR;
609 static int _appinfo_get_filtered_foreach_appinfo(uid_t uid,
610 pkgmgrinfo_filter_x *filter, int flag, pkgmgrinfo_app_list_cb app_list_cb,
614 pkgmgr_appinfo_x info;
620 list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
621 __free_applications);
623 return PMINFO_R_ERROR;
625 ret = _appinfo_get_applications(uid, uid, filter,
626 flag | PMINFO_APPINFO_GET_BASICINFO, list);
627 if (ret != PMINFO_R_OK) {
628 g_hash_table_destroy(list);
632 g_hash_table_iter_init(&iter, list);
633 while (g_hash_table_iter_next(&iter, NULL, &value)) {
634 app = (application_x *)value;
636 info.locale = info.app_info->locale;
637 info.package = app->package;
638 if (app_list_cb(&info, user_data) < 0)
641 g_hash_table_destroy(list);
646 static const char *__appcomponent_str(pkgmgrinfo_app_component comp);
648 API int pkgmgrinfo_appinfo_get_usr_list(pkgmgrinfo_pkginfo_h handle,
649 pkgmgrinfo_app_component component,
650 pkgmgrinfo_app_list_cb app_func, void *user_data, uid_t uid)
653 pkgmgrinfo_appinfo_filter_h filter;
655 const char *comp_str = NULL;
657 if (handle == NULL || app_func == NULL) {
658 LOGE("invalid parameter");
659 return PMINFO_R_EINVAL;
662 if (pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid)) {
663 LOGE("invalid parameter");
664 return PMINFO_R_EINVAL;
667 if (pkgmgrinfo_appinfo_filter_create(&filter))
668 return PMINFO_R_ERROR;
670 if (pkgmgrinfo_appinfo_filter_add_string(filter,
671 PMINFO_APPINFO_PROP_APP_PACKAGE, pkgid)) {
672 pkgmgrinfo_appinfo_filter_destroy(filter);
673 return PMINFO_R_ERROR;
676 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
677 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
678 pkgmgrinfo_appinfo_filter_destroy(filter);
679 return PMINFO_R_ERROR;
682 comp_str = __appcomponent_str(component);
685 if (pkgmgrinfo_appinfo_filter_add_string(filter,
686 PMINFO_APPINFO_PROP_APP_COMPONENT,
688 pkgmgrinfo_appinfo_filter_destroy(filter);
689 return PMINFO_R_ERROR;
693 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter,
694 PMINFO_APPINFO_GET_ALL, app_func, user_data);
696 pkgmgrinfo_appinfo_filter_destroy(filter);
701 API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle,
702 pkgmgrinfo_app_component component,
703 pkgmgrinfo_app_list_cb app_func, void *user_data)
705 return pkgmgrinfo_appinfo_get_usr_list(handle, component, app_func, user_data, _getuid());
708 API int pkgmgrinfo_appinfo_get_usr_installed_list_full(
709 pkgmgrinfo_app_list_cb app_func, uid_t uid, int flag,
713 pkgmgrinfo_appinfo_filter_h filter;
715 if (app_func == NULL) {
716 LOGE("invalid parameter");
717 return PMINFO_R_EINVAL;
720 if (pkgmgrinfo_appinfo_filter_create(&filter))
721 return PMINFO_R_ERROR;
723 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
724 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
725 pkgmgrinfo_appinfo_filter_destroy(filter);
726 return PMINFO_R_ERROR;
729 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
730 PMINFO_APPINFO_PROP_PKG_DISABLE, false)) {
731 pkgmgrinfo_appinfo_filter_destroy(filter);
732 return PMINFO_R_ERROR;
735 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
736 PMINFO_APPINFO_PROP_APP_CHECK_STORAGE, false)) {
737 pkgmgrinfo_appinfo_filter_destroy(filter);
738 return PMINFO_R_ERROR;
741 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter, flag, app_func,
744 pkgmgrinfo_appinfo_filter_destroy(filter);
749 API int pkgmgrinfo_appinfo_get_installed_list_full(
750 pkgmgrinfo_app_list_cb app_func, int flag, void *user_data)
752 return pkgmgrinfo_appinfo_get_usr_installed_list_full(app_func,
753 _getuid(), flag, user_data);
756 API int pkgmgrinfo_appinfo_get_usr_installed_list(
757 pkgmgrinfo_app_list_cb app_func, uid_t uid, void *user_data)
760 pkgmgrinfo_appinfo_filter_h filter;
762 if (app_func == NULL) {
763 LOGE("invalid parameter");
764 return PMINFO_R_EINVAL;
767 /* create an empty filter */
768 ret = pkgmgrinfo_appinfo_filter_create(&filter);
769 if (ret != PMINFO_R_OK)
772 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
773 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
774 pkgmgrinfo_appinfo_filter_destroy(filter);
775 return PMINFO_R_ERROR;
778 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
779 PMINFO_APPINFO_PROP_PKG_DISABLE, false)) {
780 pkgmgrinfo_appinfo_filter_destroy(filter);
781 return PMINFO_R_ERROR;
784 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter,
785 PMINFO_APPINFO_GET_ALL, app_func, user_data);
787 pkgmgrinfo_appinfo_filter_destroy(filter);
792 API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func,
795 return pkgmgrinfo_appinfo_get_usr_installed_list(app_func, _getuid(),
799 API int pkgmgrinfo_appinfo_get_appid(pkgmgrinfo_appinfo_h handle, char **appid)
801 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
803 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
804 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
806 if (info->app_info == NULL || info->app_info->appid == NULL)
807 return PMINFO_R_ERROR;
808 *appid = (char *)info->app_info->appid;
813 API int pkgmgrinfo_appinfo_get_pkgname(pkgmgrinfo_appinfo_h handle, char **pkg_name)
815 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
817 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
818 retvm_if(pkg_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
820 if (info->package == NULL)
821 return PMINFO_R_ERROR;
823 *pkg_name = (char *)info->package;
828 API int pkgmgrinfo_appinfo_get_pkgid(pkgmgrinfo_appinfo_h handle, char **pkgid)
830 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
832 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
833 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
835 if (info->package == NULL)
836 return PMINFO_R_ERROR;
838 *pkgid = (char *)info->package;
843 API int pkgmgrinfo_appinfo_get_pkgtype(pkgmgrinfo_appinfo_h handle, char **pkgtype)
845 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
846 retvm_if(pkgtype == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
847 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
849 *pkgtype = (char *)info->app_info->package_type;
854 API int pkgmgrinfo_appinfo_get_exec(pkgmgrinfo_appinfo_h handle, char **exec)
856 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
858 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
859 retvm_if(exec == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
861 if (info->app_info == NULL || info->app_info->exec == NULL)
862 return PMINFO_R_ERROR;
863 *exec = (char *)info->app_info->exec;
869 API int pkgmgrinfo_appinfo_get_icon(pkgmgrinfo_appinfo_h handle, char **icon)
872 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
874 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
875 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
877 if (info->app_info == NULL)
878 return PMINFO_R_ERROR;
880 if (info->app_info->icon == NULL) {
885 ptr = (icon_x *)info->app_info->icon->data;
887 return PMINFO_R_ERROR;
889 if (ptr->text == NULL)
890 return PMINFO_R_ERROR;
898 API int pkgmgrinfo_appinfo_get_label(pkgmgrinfo_appinfo_h handle, char **label)
901 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
906 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
907 retvm_if(label == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
909 if (info->app_info == NULL)
910 return PMINFO_R_ERROR;
912 locale = info->locale;
914 locale = DEFAULT_LOCALE;
916 for (tmp = info->app_info->label; tmp; tmp = tmp->next) {
917 ptr = (label_x *)tmp->data;
918 if (ptr == NULL || strcmp(locale, ptr->lang) != 0)
929 for (tmp = info->app_info->label; tmp; tmp = tmp->next) {
930 ptr = (label_x *)tmp->data;
931 if (ptr == NULL || strcmp(DEFAULT_LOCALE, ptr->lang) != 0)
937 *label = lbl ? lbl : "";
942 API int pkgmgrinfo_appinfo_usr_get_localed_label(const char *appid, const char *locale, uid_t uid, char **label)
946 retvm_if(appid == NULL || locale == NULL || label == NULL, PMINFO_R_EINVAL, "Argument is NULL");
947 val = _appinfo_get_localed_label(appid, locale, uid);
949 return PMINFO_R_ERROR;
955 API int pkgmgrinfo_appinfo_get_localed_label(const char *appid, const char *locale, char **label)
957 return pkgmgrinfo_appinfo_usr_get_localed_label(appid, locale, _getuid(), label);
960 API int pkgmgrinfo_appinfo_get_metadata_value(pkgmgrinfo_appinfo_h handle, const char *metadata_key, char **metadata_value)
962 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
963 retvm_if(metadata_key == NULL, PMINFO_R_EINVAL, "metadata_key is NULL");
964 retvm_if(metadata_value == NULL, PMINFO_R_EINVAL, "metadata_value is NULL");
966 GList *list_md = NULL;
967 metadata_x *metadata = NULL;
968 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
970 list_md = info->app_info->metadata;
972 for (; list_md; list_md = list_md->next) {
973 metadata = (metadata_x *)list_md->data;
974 if (metadata && metadata->key) {
975 if (strcasecmp(metadata->key, metadata_key) == 0) {
976 if (metadata->value == NULL)
977 *metadata_value = "";
979 *metadata_value = (char *)metadata->value;
985 return PMINFO_R_EINVAL;
988 static pkgmgrinfo_app_component __appcomponent_convert(const char *comp)
990 if (strcasecmp(comp, "uiapp") == 0)
991 return PMINFO_UI_APP;
992 else if (strcasecmp(comp, "svcapp") == 0)
993 return PMINFO_SVC_APP;
994 else if (strcasecmp(comp, "widgetapp") == 0)
995 return PMINFO_WIDGET_APP;
996 else if (strcasecmp(comp, "watchapp") == 0)
997 return PMINFO_WATCH_APP;
998 else if (strcasecmp(comp, "componentbasedapp") == 0)
999 return PMINFO_COMPONENT_BASED_APP;
1004 static const char *__appcomponent_str(pkgmgrinfo_app_component comp)
1009 case PMINFO_SVC_APP:
1011 case PMINFO_WIDGET_APP:
1013 case PMINFO_WATCH_APP:
1015 case PMINFO_COMPONENT_BASED_APP:
1016 return "componentbasedapp";
1022 API int pkgmgrinfo_appinfo_get_component(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_component *component)
1024 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1027 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1028 retvm_if(component == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1030 if (info->app_info == NULL)
1031 return PMINFO_R_ERROR;
1033 comp = __appcomponent_convert(info->app_info->component);
1035 return PMINFO_R_ERROR;
1042 API int pkgmgrinfo_appinfo_get_apptype(pkgmgrinfo_appinfo_h handle, char **app_type)
1044 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1046 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1047 retvm_if(app_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1049 if (info->app_info == NULL || info->app_info->type == NULL)
1050 return PMINFO_R_ERROR;
1051 *app_type = (char *)info->app_info->type;
1056 API int pkgmgrinfo_appinfo_get_notification_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1061 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1063 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1064 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1066 if (info->app_info == NULL)
1067 return PMINFO_R_ERROR;
1069 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1070 ptr = (icon_x *)tmp->data;
1071 if (ptr == NULL || ptr->section == NULL)
1074 val = (char *)ptr->section;
1075 if (val && strcmp(val, "notification") == 0) {
1076 *icon = (char *)ptr->text;
1081 return PMINFO_R_ERROR;
1084 API int pkgmgrinfo_appinfo_get_recent_image_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_recentimage *type)
1087 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1089 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1090 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1092 if (info->app_info == NULL || info->app_info->recentimage == NULL)
1093 return PMINFO_R_ERROR;
1095 val = (char *)info->app_info->recentimage;
1096 if (strcasecmp(val, "capture") == 0)
1097 *type = PMINFO_RECENTIMAGE_USE_CAPTURE;
1098 else if (strcasecmp(val, "icon") == 0)
1099 *type = PMINFO_RECENTIMAGE_USE_ICON;
1101 *type = PMINFO_RECENTIMAGE_USE_NOTHING;
1106 API int pkgmgrinfo_appinfo_get_preview_image(pkgmgrinfo_appinfo_h handle, char **preview_img)
1111 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1113 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1114 retvm_if(preview_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1116 if (info->app_info == NULL)
1117 return PMINFO_R_ERROR;
1119 for (tmp = info->app_info->image; tmp; tmp = tmp->next) {
1120 ptr = (image_x *)tmp->data;
1121 if (ptr == NULL || ptr->section == NULL)
1124 val = (char *)ptr->section;
1125 if (val && strcmp(val, "preview") == 0) {
1126 *preview_img = (char *)ptr->text;
1131 return PMINFO_R_ERROR;
1134 API int pkgmgrinfo_appinfo_get_permission_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_permission_type *permission)
1137 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1139 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1140 retvm_if(permission == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1142 val = info->app_info->permission_type;
1144 return PMINFO_R_ERROR;
1146 if (strcmp(val, "signature") == 0)
1147 *permission = PMINFO_PERMISSION_SIGNATURE;
1148 else if (strcmp(val, "privilege") == 0)
1149 *permission = PMINFO_PERMISSION_PRIVILEGE;
1151 *permission = PMINFO_PERMISSION_NORMAL;
1156 API int pkgmgrinfo_appinfo_get_component_type(pkgmgrinfo_appinfo_h handle, char **component_type)
1158 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1160 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1161 retvm_if(component_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1163 if (info->app_info == NULL || info->app_info->component_type == NULL)
1164 return PMINFO_R_ERROR;
1166 *component_type = (char *)info->app_info->component_type;
1171 API int pkgmgrinfo_appinfo_get_hwacceleration(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_hwacceleration *hwacceleration)
1174 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1176 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1177 retvm_if(hwacceleration == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1179 if (info->app_info == NULL || info->app_info->hwacceleration == NULL)
1180 return PMINFO_R_ERROR;
1182 val = (char *)info->app_info->hwacceleration;
1183 if (strcasecmp(val, "off") == 0)
1184 *hwacceleration = PMINFO_HWACCELERATION_OFF;
1185 else if (strcasecmp(val, "on") == 0)
1186 *hwacceleration = PMINFO_HWACCELERATION_ON;
1188 *hwacceleration = PMINFO_HWACCELERATION_DEFAULT;
1193 API int pkgmgrinfo_appinfo_get_screenreader(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_screenreader *screenreader)
1196 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1198 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1199 retvm_if(screenreader == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1201 if (info->app_info == NULL || info->app_info->screenreader == NULL)
1202 return PMINFO_R_ERROR;
1204 val = (char *)info->app_info->screenreader;
1205 if (strcasecmp(val, "screenreader-off") == 0)
1206 *screenreader = PMINFO_SCREENREADER_OFF;
1207 else if (strcasecmp(val, "screenreader-on") == 0)
1208 *screenreader = PMINFO_SCREENREADER_ON;
1210 *screenreader = PMINFO_SCREENREADER_USE_SYSTEM_SETTING;
1215 API int pkgmgrinfo_appinfo_get_effectimage(pkgmgrinfo_appinfo_h handle, char **portrait_img, char **landscape_img)
1217 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1219 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1220 retvm_if(portrait_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1221 retvm_if(landscape_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1223 if (info->app_info == NULL)
1224 return PMINFO_R_ERROR;
1226 if (info->app_info->portraitimg == NULL)
1229 *portrait_img = (char *)info->app_info->portraitimg;
1231 if (info->app_info->landscapeimg == NULL)
1232 *landscape_img = "";
1234 *landscape_img = (char *)info->app_info->landscapeimg;
1239 API int pkgmgrinfo_appinfo_get_effectimage_type(pkgmgrinfo_appinfo_h handle, char **effectimage_type)
1241 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1243 if (handle == NULL || effectimage_type == NULL) {
1244 LOGE("invalid parameter");
1245 return PMINFO_R_EINVAL;
1248 if (info->app_info == NULL || info->app_info->effectimage_type == NULL)
1249 return PMINFO_R_ERROR;
1251 *effectimage_type = (char *)info->app_info->effectimage_type;
1256 API int pkgmgrinfo_appinfo_get_submode_mainid(pkgmgrinfo_appinfo_h handle, char **submode_mainid)
1258 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1260 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1261 retvm_if(submode_mainid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1263 if (info->app_info == NULL)
1264 return PMINFO_R_ERROR;
1266 if (info->app_info->submode_mainid == NULL)
1267 *submode_mainid = "";
1269 *submode_mainid = (char *)info->app_info->submode_mainid;
1274 API int pkgmgrinfo_appinfo_get_installed_storage_location(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_installed_storage *storage)
1276 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1277 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1279 if (info->app_info && info->app_info->installed_storage) {
1280 if (strcmp(info->app_info->installed_storage, "installed_internal") == 0)
1281 *storage = PMINFO_INTERNAL_STORAGE;
1282 else if (strcmp(info->app_info->installed_storage, "installed_external") == 0)
1283 *storage = PMINFO_EXTERNAL_STORAGE;
1285 return PMINFO_R_ERROR;
1287 return PMINFO_R_ERROR;
1293 API int pkgmgrinfo_appinfo_get_launch_mode(pkgmgrinfo_appinfo_h handle, char **mode)
1295 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1297 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1298 retvm_if(mode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1300 if (info->app_info->launch_mode == NULL)
1301 return PMINFO_R_ERROR;
1303 *mode = (char *)(info->app_info->launch_mode);
1308 API int pkgmgrinfo_appinfo_get_alias_appid(pkgmgrinfo_appinfo_h handle, char **alias_appid)
1310 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1312 if (handle == NULL || alias_appid == NULL) {
1313 LOGE("invalid parameter");
1314 return PMINFO_R_EINVAL;
1317 if (info->app_info == NULL || info->app_info->alias_appid == NULL)
1318 return PMINFO_R_ERROR;
1320 *alias_appid = (char *)info->app_info->alias_appid;
1325 API int pkgmgrinfo_appinfo_get_effective_appid(pkgmgrinfo_appinfo_h handle, char **effective_appid)
1327 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1329 if (handle == NULL || effective_appid == NULL) {
1330 LOGE("invalid parameter");
1331 return PMINFO_R_EINVAL;
1334 if (info->app_info == NULL)
1335 return PMINFO_R_ERROR;
1337 if (info->app_info->effective_appid == NULL)
1338 *effective_appid = "";
1340 *effective_appid = (char *)info->app_info->effective_appid;
1345 API int pkgmgrinfo_appinfo_get_tep_name(pkgmgrinfo_appinfo_h handle, char **tep_name)
1347 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1349 if (handle == NULL || tep_name == NULL) {
1350 LOGE("invalid parameter");
1351 return PMINFO_R_EINVAL;
1354 if (info->app_info == NULL)
1355 return PMINFO_R_ERROR;
1357 if (info->app_info->tep_name == NULL)
1360 *tep_name = (char *)info->app_info->tep_name;
1365 API int pkgmgrinfo_appinfo_get_zip_mount_file(pkgmgrinfo_appinfo_h handle, char **zip_mount_file)
1367 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1369 if (handle == NULL || zip_mount_file == NULL) {
1370 LOGE("invalid parameter");
1371 return PMINFO_R_EINVAL;
1374 if (info->app_info == NULL)
1375 return PMINFO_R_ERROR;
1377 if (info->app_info->zip_mount_file == NULL)
1378 *zip_mount_file = "";
1380 *zip_mount_file = (char *)info->app_info->zip_mount_file;
1385 API int pkgmgrinfo_appinfo_get_root_path(pkgmgrinfo_appinfo_h handle, char **root_path)
1387 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1389 if (handle == NULL || root_path == NULL) {
1390 LOGE("invalid parameter");
1391 return PMINFO_R_EINVAL;
1394 if (info->app_info == NULL || info->app_info->root_path == NULL)
1395 return PMINFO_R_ERROR;
1397 *root_path = (char *)info->app_info->root_path;
1402 API int pkgmgrinfo_appinfo_get_api_version(pkgmgrinfo_appinfo_h handle, char **api_version)
1404 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1406 if (handle == NULL || api_version == NULL) {
1407 LOGE("invalid parameter");
1408 return PMINFO_R_EINVAL;
1411 if (info->app_info == NULL || info->app_info->api_version == NULL)
1412 return PMINFO_R_ERROR;
1414 *api_version = (char *)info->app_info->api_version;
1419 API int pkgmgrinfo_appinfo_get_installed_time(pkgmgrinfo_appinfo_h handle, int *installed_time)
1421 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1423 if (handle == NULL || installed_time == NULL) {
1424 LOGE("invalid parameter");
1425 return PMINFO_R_EINVAL;
1428 if (info->app_info == NULL || info->app_info->package_installed_time == NULL)
1429 return PMINFO_R_ERROR;
1431 *installed_time = atoi(info->app_info->package_installed_time);
1436 API int pkgmgrinfo_appinfo_usr_get_datacontrol_info(const char *providerid,
1437 const char *type, uid_t uid, char **appid, char **access)
1441 if (providerid == NULL || type == NULL || appid == NULL ||
1443 LOGE("invalid parameter");
1444 return PMINFO_R_EINVAL;
1447 ret = _appinfo_get_datacontrol_info(providerid, type, uid, appid, access);
1448 /* FIXME: It should return PMINFO_R_ENOENT but to keep previous
1449 * implementation, return PMINFO_R_ERROR. This should be
1452 if (ret == PMINFO_R_ENOENT) {
1453 LOGE("no datacontrol info of %s", providerid);
1454 ret = PMINFO_R_ERROR;
1460 API int pkgmgrinfo_appinfo_get_datacontrol_info(const char *providerid,
1461 const char *type, char **appid, char **access)
1463 return pkgmgrinfo_appinfo_usr_get_datacontrol_info(providerid,
1464 type, _getuid(), appid, access);
1467 API int pkgmgrinfo_appinfo_usr_get_datacontrol_appid(const char *providerid,
1468 uid_t uid, char **appid)
1471 if (providerid == NULL || appid == NULL) {
1472 LOGE("invalid parameter");
1473 return PMINFO_R_EINVAL;
1476 ret = _appinfo_get_datacontrol_appid(providerid, uid, appid);
1477 /* FIXME: It should return PMINFO_R_ENOENT but to keep previous
1478 * implementation, return PMINFO_R_ERROR. This should be
1481 if (ret == PMINFO_R_ENOENT) {
1482 LOGE("no datacontrol appid of %s", providerid);
1483 ret = PMINFO_R_ERROR;
1489 API int pkgmgrinfo_appinfo_get_datacontrol_appid(const char *providerid, char **appid)
1491 return pkgmgrinfo_appinfo_usr_get_datacontrol_appid(providerid, _getuid(), appid);
1494 API int pkgmgrinfo_appinfo_usr_get_datacontrol_trusted_info(
1495 const char *providerid, const char *type, uid_t uid,
1496 char **appid, bool *is_trusted)
1499 char *trusted = NULL;
1500 if (providerid == NULL || type == NULL || appid == NULL ||
1501 is_trusted == NULL) {
1502 LOGE("invalid parameter");
1503 return PMINFO_R_EINVAL;
1506 ret = _appinfo_get_datacontrol_trusted_info(providerid, type, uid,
1509 /* FIXME: It should return PMINFO_R_ENOENT but to keep previous
1510 * implementation, return PMINFO_R_ERROR. This should be
1513 if (ret == PMINFO_R_ENOENT) {
1514 LOGE("no datacontrol trusted info of %s", providerid);
1515 ret = PMINFO_R_ERROR;
1517 *is_trusted = _get_bool_value(trusted);
1523 API int pkgmgrinfo_appinfo_get_datacontrol_trsuted_info(const char *providerid,
1524 const char *type, char **appid, bool *is_trusted)
1526 return pkgmgrinfo_appinfo_usr_get_datacontrol_trusted_info(providerid,
1527 type, _getuid(), appid, is_trusted);
1530 API int pkgmgrinfo_appinfo_usr_foreach_datacontrol_privileges(
1531 const char *providerid, const char *type,
1532 pkgmgrinfo_pkg_privilege_list_cb privilege_func,
1533 void *user_data, uid_t uid)
1539 if (providerid == NULL || type == NULL || privilege_func == NULL) {
1540 LOGE("invalid parameter");
1541 return PMINFO_R_EINVAL;
1544 ret = _appinfo_get_datacontrol_privileges(providerid, type, uid, &list);
1545 if (PMINFO_R_ERROR) {
1546 g_list_free_full(list, free);
1550 for (tmp = list; tmp != NULL; tmp = g_list_next(tmp)) {
1552 ret = privilege_func((char *)tmp->data, user_data);
1557 g_list_free_full(list, free);
1561 API int pkgmgrinfo_appinfo_foreach_datacontrol_privileges(
1562 const char *providerid, const char *type,
1563 pkgmgrinfo_pkg_privilege_list_cb privilege_func,
1566 return pkgmgrinfo_appinfo_usr_foreach_datacontrol_privileges(
1567 providerid, type, privilege_func, user_data, _getuid());
1570 API int pkgmgrinfo_appinfo_get_support_mode(pkgmgrinfo_appinfo_h handle, int *support_mode)
1572 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1573 retvm_if(support_mode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1575 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1576 if (info->app_info->support_mode)
1577 *support_mode = atoi(info->app_info->support_mode);
1584 API int pkgmgrinfo_appinfo_foreach_category(pkgmgrinfo_appinfo_h handle,
1585 pkgmgrinfo_app_category_list_cb category_func, void *user_data)
1587 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1588 retvm_if(category_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
1590 const char *category;
1592 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1594 if (info->app_info == NULL)
1595 return PMINFO_R_ERROR;
1597 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
1598 category = (const char *)tmp->data;
1600 ret = category_func(category, user_data);
1608 API int pkgmgrinfo_appinfo_foreach_metadata(pkgmgrinfo_appinfo_h handle,
1609 pkgmgrinfo_app_metadata_list_cb metadata_func, void *user_data)
1611 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1612 retvm_if(metadata_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
1616 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1618 if (info->app_info == NULL)
1619 return PMINFO_R_ERROR;
1621 for (tmp = info->app_info->metadata; tmp; tmp = tmp->next) {
1622 ptr = (metadata_x *)tmp->data;
1626 ret = metadata_func(ptr->key, ptr->value ? ptr->value : "", user_data);
1634 API int pkgmgrinfo_appinfo_usr_foreach_appcontrol_privileges(const char *appid,
1635 const char *operation,
1636 pkgmgrinfo_pkg_privilege_list_cb privilege_func,
1637 void *user_data, uid_t uid)
1640 GList *privilege_list = NULL;
1643 if (appid == NULL || operation == NULL || privilege_func == NULL) {
1644 LOGE("invalid parameter");
1645 return PMINFO_R_EINVAL;
1648 ret = _appinfo_get_appcontrol_privileges(appid, operation, uid,
1650 if (ret == PMINFO_R_ENOENT) {
1652 } else if (ret != PMINFO_R_OK) {
1653 g_list_free_full(privilege_list, free);
1657 for (tmp_list = privilege_list; tmp_list != NULL;
1658 tmp_list = g_list_next(tmp_list)) {
1659 ret = privilege_func((char *)tmp_list->data, user_data);
1664 g_list_free_full(privilege_list, free);
1668 API int pkgmgrinfo_appinfo_foreach_appcontrol_privileges(const char *appid,
1669 const char *operation,
1670 pkgmgrinfo_pkg_privilege_list_cb privilege_func,
1673 return pkgmgrinfo_appinfo_usr_foreach_appcontrol_privileges(appid,
1674 operation, privilege_func, user_data, _getuid());
1677 API int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
1678 pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
1680 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1681 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
1683 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1684 appcontrol_x *appcontrol;
1687 if (info->app_info == NULL)
1688 return PMINFO_R_ERROR;
1690 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
1691 appcontrol = (appcontrol_x *)tmp->data;
1692 if (appcontrol == NULL || !strcasecmp(appcontrol->visibility, "remote-only"))
1694 ret = appcontrol_func(appcontrol->operation, appcontrol->uri, appcontrol->mime, user_data);
1702 API int pkgmgrinfo_appinfo_foreach_remote_appcontrol(pkgmgrinfo_appinfo_h handle,
1703 pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
1705 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1706 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
1708 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1709 appcontrol_x *appcontrol;
1712 if (info->app_info == NULL)
1713 return PMINFO_R_ERROR;
1715 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
1716 appcontrol = (appcontrol_x *)tmp->data;
1717 if (appcontrol == NULL || !strcasecmp(appcontrol->visibility, "local-only"))
1719 ret = appcontrol_func(appcontrol->operation, appcontrol->uri, appcontrol->mime, user_data);
1727 API int pkgmgrinfo_appinfo_foreach_background_category(
1728 pkgmgrinfo_appinfo_h handle,
1729 pkgmgrinfo_app_background_category_list_cb category_func,
1732 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1736 if (handle == NULL || category_func == NULL || info->app_info == NULL) {
1737 LOGE("invalid parameter");
1738 return PMINFO_R_EINVAL;
1741 for (tmp = info->app_info->background_category; tmp; tmp = tmp->next) {
1742 category = (char *)tmp->data;
1743 if (category == NULL)
1746 if (category_func(category, user_data) < 0)
1753 API int pkgmgrinfo_appinfo_foreach_splash_screen(pkgmgrinfo_appinfo_h handle,
1754 pkgmgrinfo_app_splash_screen_list_cb splash_screen_func,
1757 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1758 splashscreen_x *splashscreen;
1762 if (info == NULL || info->app_info == NULL
1763 || splash_screen_func == NULL) {
1764 LOGE("invalid parameter");
1765 return PMINFO_R_EINVAL;
1768 for (tmp = info->app_info->splashscreens; tmp; tmp = tmp->next) {
1769 splashscreen = (splashscreen_x *)tmp->data;
1770 if (splashscreen == NULL)
1772 ret = splash_screen_func(splashscreen->src,
1774 splashscreen->orientation,
1775 splashscreen->indicatordisplay,
1776 splashscreen->operation,
1777 splashscreen->color_depth,
1786 API int pkgmgrinfo_appinfo_is_nodisplay(pkgmgrinfo_appinfo_h handle, bool *nodisplay)
1788 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1789 retvm_if(nodisplay == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1790 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1792 if (info->app_info == NULL || info->app_info->nodisplay == NULL)
1793 return PMINFO_R_ERROR;
1795 *nodisplay = _get_bool_value(info->app_info->nodisplay);
1800 API int pkgmgrinfo_appinfo_is_multiple(pkgmgrinfo_appinfo_h handle, bool *multiple)
1802 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1803 retvm_if(multiple == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1804 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1806 if (info->app_info == NULL || info->app_info->multiple == NULL)
1807 return PMINFO_R_ERROR;
1809 *multiple = _get_bool_value(info->app_info->multiple);
1814 API int pkgmgrinfo_appinfo_is_indicator_display_allowed(pkgmgrinfo_appinfo_h handle, bool *indicator_disp)
1816 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1817 retvm_if(indicator_disp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1818 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1820 if (info->app_info == NULL || info->app_info->indicatordisplay == NULL)
1821 return PMINFO_R_ERROR;
1823 *indicator_disp = _get_bool_value(info->app_info->indicatordisplay);
1828 API int pkgmgrinfo_appinfo_is_taskmanage(pkgmgrinfo_appinfo_h handle, bool *taskmanage)
1830 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1831 retvm_if(taskmanage == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1832 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1834 if (info->app_info == NULL || info->app_info->taskmanage == NULL)
1835 return PMINFO_R_ERROR;
1837 *taskmanage = _get_bool_value(info->app_info->taskmanage);
1842 API int pkgmgrinfo_appinfo_is_enabled(pkgmgrinfo_appinfo_h handle, bool *enabled)
1844 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1845 retvm_if(enabled == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1846 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1848 if (info->app_info == NULL || info->app_info->is_disabled == NULL)
1849 return PMINFO_R_ERROR;
1851 *enabled = !_get_bool_value(info->app_info->is_disabled);
1856 API int pkgmgrinfo_appinfo_is_onboot(pkgmgrinfo_appinfo_h handle, bool *onboot)
1858 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1859 retvm_if(onboot == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1860 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1862 if (info->app_info == NULL || info->app_info->onboot == NULL)
1863 return PMINFO_R_ERROR;
1865 *onboot = _get_bool_value(info->app_info->onboot);
1870 API int pkgmgrinfo_appinfo_is_autorestart(pkgmgrinfo_appinfo_h handle, bool *autorestart)
1872 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1873 retvm_if(autorestart == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1874 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1876 if (info->app_info == NULL || info->app_info->autorestart == NULL)
1877 return PMINFO_R_ERROR;
1879 *autorestart = _get_bool_value(info->app_info->autorestart);
1884 API int pkgmgrinfo_appinfo_is_mainapp(pkgmgrinfo_appinfo_h handle, bool *mainapp)
1886 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1887 retvm_if(mainapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1888 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1890 if (info->app_info == NULL || info->app_info->mainapp == NULL)
1891 return PMINFO_R_ERROR;
1893 *mainapp = _get_bool_value(info->app_info->mainapp);
1898 API int pkgmgrinfo_appinfo_is_preload(pkgmgrinfo_appinfo_h handle, bool *preload)
1900 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1901 retvm_if(preload == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1902 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1904 if (info->app_info == NULL || info->app_info->preload == NULL)
1905 return PMINFO_R_ERROR;
1907 *preload = _get_bool_value(info->app_info->preload);
1912 API int pkgmgrinfo_appinfo_is_submode(pkgmgrinfo_appinfo_h handle, bool *submode)
1914 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1915 retvm_if(submode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1916 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1918 if (info->app_info == NULL || info->app_info->submode == NULL)
1919 return PMINFO_R_ERROR;
1921 *submode = _get_bool_value(info->app_info->submode);
1926 API int pkgmgrinfo_appinfo_is_process_pool(pkgmgrinfo_appinfo_h handle, bool *process_pool)
1928 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1930 if (handle == NULL || process_pool == NULL) {
1931 LOGE("invalid parameter");
1932 return PMINFO_R_EINVAL;
1935 if (info->app_info == NULL)
1936 return PMINFO_R_ERROR;
1938 *process_pool = _get_bool_value(info->app_info->process_pool);
1943 API int pkgmgrinfo_appinfo_is_category_exist(pkgmgrinfo_appinfo_h handle, const char *category, bool *exist)
1945 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1946 retvm_if(category == NULL, PMINFO_R_EINVAL, "category is NULL");
1947 retvm_if(exist == NULL, PMINFO_R_EINVAL, "exist is NULL");
1951 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1953 if (info->app_info == NULL)
1954 return PMINFO_R_ERROR;
1957 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
1958 val = (const char *)tmp->data;
1961 if (strcasecmp(val, category) == 0) {
1970 API int pkgmgrinfo_appinfo_is_ui_gadget(pkgmgrinfo_appinfo_h handle,
1973 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1975 if (info == NULL || info->app_info == NULL || ui_gadget == NULL) {
1976 _LOGE("invalid parameter");
1977 return PMINFO_R_EINVAL;
1979 if (info->app_info->ui_gadget == NULL)
1980 info->app_info->ui_gadget = strdup("false");
1982 *ui_gadget = _get_bool_value(info->app_info->ui_gadget);
1987 API int pkgmgrinfo_appinfo_is_support_disable(pkgmgrinfo_appinfo_h handle,
1988 bool *support_disable)
1990 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1992 if (info == NULL || info->app_info == NULL || support_disable == NULL) {
1993 _LOGE("invalid parameter");
1994 return PMINFO_R_EINVAL;
1997 *support_disable = _get_bool_value(info->app_info->support_disable);
2002 API int pkgmgrinfo_appinfo_is_removable(pkgmgrinfo_appinfo_h handle,
2005 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2007 if (info == NULL || info->app_info == NULL || removable == NULL) {
2008 _LOGE("invalid parameter");
2009 return PMINFO_R_EINVAL;
2012 *removable = _get_bool_value(info->app_info->removable);
2017 API int pkgmgrinfo_appinfo_is_system(pkgmgrinfo_appinfo_h handle, bool *system)
2019 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2021 if (info == NULL || info->app_info == NULL || system == NULL) {
2022 _LOGE("invalid parameter");
2023 return PMINFO_R_EINVAL;
2026 *system = _get_bool_value(info->app_info->package_system);
2031 API int pkgmgrinfo_appinfo_is_disabled(pkgmgrinfo_appinfo_h handle, bool *disabled)
2033 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2034 retvm_if(disabled == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2035 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2037 if (info->app_info == NULL || info->app_info->is_disabled == NULL)
2038 return PMINFO_R_ERROR;
2040 *disabled = _get_bool_value(info->app_info->is_disabled);
2045 API int pkgmgrinfo_appinfo_is_global(pkgmgrinfo_appinfo_h handle, bool *global)
2047 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2049 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2050 retvm_if(global == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2052 if (info->app_info == NULL || info->app_info->for_all_users == NULL)
2053 return PMINFO_R_ERROR;
2055 *global = _get_bool_value(info->app_info->for_all_users);
2060 API int pkgmgrinfo_appinfo_get_splash_screen_display(pkgmgrinfo_appinfo_h handle, bool *splash_screen_display)
2062 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2064 if (info == NULL || splash_screen_display == NULL) {
2065 _LOGE("Invalid parameter");
2066 return PMINFO_R_EINVAL;
2069 if (info->app_info == NULL || info->app_info->splash_screen_display == NULL)
2070 return PMINFO_R_ERROR;
2072 *splash_screen_display = _get_bool_value(info->app_info->splash_screen_display);
2077 API int pkgmgrinfo_appinfo_get_setup_appid(pkgmgrinfo_appinfo_h handle, char **setup_appid)
2079 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2081 if (info == NULL || setup_appid == NULL) {
2082 _LOGE("Invalid parameter");
2083 return PMINFO_R_EINVAL;
2086 if (info->app_info == NULL || info->app_info->setup_appid == NULL)
2087 return PMINFO_R_ERROR;
2089 *setup_appid = info->app_info->setup_appid;
2093 API int pkgmgrinfo_appinfo_is_support_ambient(pkgmgrinfo_appinfo_h handle,
2094 bool *support_ambient)
2096 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2098 if (info == NULL || support_ambient == NULL) {
2099 _LOGE("Invalid parameter");
2100 return PMINFO_R_EINVAL;
2103 if (info->app_info == NULL || info->app_info->support_ambient == NULL)
2104 return PMINFO_R_ERROR;
2106 *support_ambient = _get_bool_value(info->app_info->support_ambient);
2111 API int pkgmgrinfo_appinfo_destroy_appinfo(pkgmgrinfo_appinfo_h handle)
2113 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2114 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2115 __cleanup_appinfo(info);
2119 API int pkgmgrinfo_appinfo_filter_create(pkgmgrinfo_appinfo_filter_h *handle)
2121 return (pkgmgrinfo_pkginfo_filter_create(handle));
2124 API int pkgmgrinfo_appinfo_filter_destroy(pkgmgrinfo_appinfo_filter_h handle)
2126 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
2129 static gint __compare_func(gconstpointer data1, gconstpointer data2)
2131 pkgmgrinfo_node_x *node1 = (pkgmgrinfo_node_x *)data1;
2132 pkgmgrinfo_node_x *node2 = (pkgmgrinfo_node_x *)data2;
2133 if (node1->prop == node2->prop)
2135 else if (node1->prop > node2->prop)
2141 API int pkgmgrinfo_appinfo_filter_add_int(pkgmgrinfo_appinfo_filter_h handle,
2142 const char *property, const int value)
2144 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2145 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2146 char buf[PKG_VALUE_STRING_LEN_MAX] = {'\0'};
2148 GSList *link = NULL;
2150 prop = _pminfo_appinfo_convert_to_prop_int(property);
2151 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_INT ||
2152 prop > E_PMINFO_APPINFO_PROP_APP_MAX_INT) {
2153 _LOGE("Invalid Integer Property\n");
2154 return PMINFO_R_EINVAL;
2156 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2157 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1, sizeof(pkgmgrinfo_node_x));
2159 _LOGE("Out of Memory!!!\n");
2160 return PMINFO_R_ERROR;
2162 snprintf(buf, PKG_VALUE_STRING_LEN_MAX - 1, "%d", value);
2163 val = strndup(buf, PKG_VALUE_STRING_LEN_MAX - 1);
2165 _LOGE("Out of Memory\n");
2168 return PMINFO_R_ERROR;
2172 /*If API is called multiple times for same property, we should override the previous values.
2173 Last value set will be used for filtering.*/
2174 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2176 filter->list = g_slist_delete_link(filter->list, link);
2177 filter->list = g_slist_append(filter->list, (gpointer)node);
2182 API int pkgmgrinfo_appinfo_filter_add_bool(pkgmgrinfo_appinfo_filter_h handle,
2183 const char *property, const bool value)
2185 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2186 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2188 GSList *link = NULL;
2190 prop = _pminfo_appinfo_convert_to_prop_bool(property);
2191 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_BOOL ||
2192 prop > E_PMINFO_APPINFO_PROP_APP_MAX_BOOL) {
2193 _LOGE("Invalid Boolean Property\n");
2194 return PMINFO_R_EINVAL;
2196 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2197 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1, sizeof(pkgmgrinfo_node_x));
2199 _LOGE("Out of Memory!!!\n");
2200 return PMINFO_R_ERROR;
2203 val = strndup("true", 4);
2205 val = strndup("false", 5);
2207 _LOGE("Out of Memory\n");
2210 return PMINFO_R_ERROR;
2214 /*If API is called multiple times for same property, we should override the previous values.
2215 Last value set will be used for filtering.*/
2216 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2218 filter->list = g_slist_delete_link(filter->list, link);
2219 filter->list = g_slist_append(filter->list, (gpointer)node);
2224 API int pkgmgrinfo_appinfo_filter_add_string(pkgmgrinfo_appinfo_filter_h handle,
2225 const char *property, const char *value)
2227 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2228 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2229 retvm_if(value == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2231 pkgmgrinfo_node_x *ptr = NULL;
2232 char prev[PKG_STRING_LEN_MAX] = {'\0'};
2233 char temp[PKG_STRING_LEN_MAX] = {'\0'};
2234 GSList *link = NULL;
2237 prop = _pminfo_appinfo_convert_to_prop_str(property);
2238 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_STR ||
2239 prop > E_PMINFO_APPINFO_PROP_APP_MAX_STR) {
2240 _LOGE("Invalid String Property\n");
2241 return PMINFO_R_EINVAL;
2243 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2244 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1, sizeof(pkgmgrinfo_node_x));
2246 _LOGE("Out of Memory!!!\n");
2247 return PMINFO_R_ERROR;
2251 case E_PMINFO_APPINFO_PROP_APP_COMPONENT:
2252 node->value = strdup(value);
2253 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2255 filter->list = g_slist_delete_link(filter->list, link);
2256 filter->list = g_slist_append(filter->list, (gpointer)node);
2258 case E_PMINFO_APPINFO_PROP_APP_CATEGORY:
2259 val = (char *)calloc(1, PKG_STRING_LEN_MAX);
2261 _LOGE("Out of Memory\n");
2264 return PMINFO_R_ERROR;
2266 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2268 ptr = (pkgmgrinfo_node_x *)link->data;
2269 strncpy(prev, ptr->value, PKG_STRING_LEN_MAX - 1);
2270 _LOGI("Previous value is %s\n", prev);
2271 filter->list = g_slist_delete_link(filter->list, link);
2272 ret = snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s,%s", prev, value);
2273 if (ret < 0 || ret > PKG_STRING_LEN_MAX - 1) {
2274 _LOGE("snprintf fail\n");
2277 return PMINFO_R_ERROR;
2279 strncpy(val, temp, PKG_STRING_LEN_MAX);
2280 _LOGI("New value is %s\n", val);
2282 filter->list = g_slist_append(filter->list, (gpointer)node);
2283 memset(temp, '\0', PKG_STRING_LEN_MAX);
2285 snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s", value);
2286 strncpy(val, temp, PKG_STRING_LEN_MAX);
2287 _LOGI("First value is %s\n", val);
2289 filter->list = g_slist_append(filter->list, (gpointer)node);
2290 memset(temp, '\0', PKG_STRING_LEN_MAX);
2294 node->value = strndup(value, PKG_STRING_LEN_MAX - 1);
2295 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2297 filter->list = g_slist_delete_link(filter->list, link);
2298 filter->list = g_slist_append(filter->list, (gpointer)node);
2304 API int pkgmgrinfo_appinfo_usr_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count, uid_t uid)
2308 if (handle == NULL || count == NULL) {
2309 _LOGE("invalid parameter");
2310 return PMINFO_R_EINVAL;
2313 list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
2314 __free_applications);
2316 return PMINFO_R_ERROR;
2318 if (__check_disable_filter_exist(
2319 handle, E_APPINFO_DISABLE_TYPE_APP) == false) {
2320 if (pkgmgrinfo_appinfo_filter_add_bool(handle,
2321 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
2322 g_hash_table_destroy(list);
2323 return PMINFO_R_ERROR;
2327 if (__check_disable_filter_exist(
2328 handle, E_APPINFO_DISABLE_TYPE_PKG) == false) {
2329 if (pkgmgrinfo_appinfo_filter_add_bool(handle,
2330 PMINFO_APPINFO_PROP_PKG_DISABLE, false)) {
2331 g_hash_table_destroy(list);
2332 return PMINFO_R_ERROR;
2336 // TODO: use pkginfo-client APIs
2337 *count = g_hash_table_size(list);
2338 g_hash_table_destroy(list);
2343 API int pkgmgrinfo_appinfo_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count)
2345 return pkgmgrinfo_appinfo_usr_filter_count(handle, count, _getuid());
2348 API int pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(
2349 pkgmgrinfo_appinfo_filter_h handle,
2350 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
2352 if (handle == NULL || app_cb == NULL) {
2353 LOGE("invalid parameter");
2354 return PMINFO_R_EINVAL;
2357 if (__check_disable_filter_exist(
2358 handle, E_APPINFO_DISABLE_TYPE_APP) == false) {
2359 if (pkgmgrinfo_appinfo_filter_add_bool(handle,
2360 PMINFO_APPINFO_PROP_APP_DISABLE, false))
2361 return PMINFO_R_ERROR;
2364 if (__check_disable_filter_exist(
2365 handle, E_APPINFO_DISABLE_TYPE_PKG) == false) {
2366 if (pkgmgrinfo_appinfo_filter_add_bool(handle,
2367 PMINFO_APPINFO_PROP_PKG_DISABLE, false))
2368 return PMINFO_R_ERROR;
2371 return _appinfo_get_filtered_foreach_appinfo(uid, handle, PMINFO_APPINFO_GET_ALL, app_cb,
2375 API int pkgmgrinfo_appinfo_filter_foreach_appinfo(pkgmgrinfo_appinfo_filter_h handle,
2376 pkgmgrinfo_app_list_cb app_cb, void *user_data)
2378 return pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(handle, app_cb, user_data, _getuid());
2381 API int pkgmgrinfo_appinfo_metadata_filter_create(pkgmgrinfo_appinfo_metadata_filter_h *handle)
2383 return (pkgmgrinfo_pkginfo_filter_create(handle));
2386 API int pkgmgrinfo_appinfo_metadata_filter_destroy(pkgmgrinfo_appinfo_metadata_filter_h handle)
2388 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
2391 API int pkgmgrinfo_appinfo_metadata_filter_add(
2392 pkgmgrinfo_appinfo_metadata_filter_h handle,
2393 const char *key, const char *value)
2395 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2396 pkgmgrinfo_metadata_node_x *node;
2398 /* value can be NULL.
2399 * In that case all apps with specified key should be displayed
2402 LOGE("invalid parameter");
2403 return PMINFO_R_EINVAL;
2406 node = calloc(1, sizeof(pkgmgrinfo_metadata_node_x));
2408 LOGE("out of memory");
2409 return PMINFO_R_ERROR;
2412 node->key = strdup(key);
2413 if (value && strlen(value))
2414 node->value = strdup(value);
2416 filter->list_metadata = g_slist_append(filter->list_metadata,
2422 API int pkgmgrinfo_appinfo_usr_metadata_filter_foreach(
2423 pkgmgrinfo_appinfo_metadata_filter_h handle,
2424 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
2426 if (handle == NULL || app_cb == NULL) {
2427 LOGE("invalid parameter");
2428 return PMINFO_R_EINVAL;
2431 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2432 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
2433 PMINFO_APPINFO_PROP_APP_DISABLE, false))
2434 return PMINFO_R_ERROR;
2436 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
2437 PMINFO_APPINFO_PROP_PKG_DISABLE, false))
2438 return PMINFO_R_ERROR;
2440 return _appinfo_get_filtered_foreach_appinfo(uid, handle, PMINFO_APPINFO_GET_ALL, app_cb,
2444 API int pkgmgrinfo_appinfo_metadata_filter_foreach(
2445 pkgmgrinfo_appinfo_metadata_filter_h handle,
2446 pkgmgrinfo_app_list_cb app_cb, void *user_data)
2448 return pkgmgrinfo_appinfo_usr_metadata_filter_foreach(handle, app_cb,
2449 user_data, _getuid());
2452 API int pkgmgrinfo_appinfo_is_guestmode_visibility(pkgmgrinfo_appinfo_h handle, bool *status)
2455 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2457 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2458 retvm_if(status == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2460 val = info->app_info->guestmode_visibility;
2461 *status = _get_bool_value(val);
2465 API int pkgmgrinfo_appinfo_foreach_appcontrol_v2(pkgmgrinfo_appinfo_h handle,
2466 pkgmgrinfo_app_control_list_cb_v2 appcontrol_func,
2469 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2470 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2472 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2473 appcontrol_x *appcontrol;
2476 if (info->app_info == NULL)
2477 return PMINFO_R_ERROR;
2479 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
2480 appcontrol = (appcontrol_x *)tmp->data;
2481 if (appcontrol == NULL ||
2482 !strcasecmp(appcontrol->visibility, "remote-only"))
2484 ret = appcontrol_func(appcontrol->operation, appcontrol->uri,
2485 appcontrol->mime, appcontrol->id, user_data);
2493 API int pkgmgrinfo_appinfo_foreach_remote_appcontrol_v2(
2494 pkgmgrinfo_appinfo_h handle,
2495 pkgmgrinfo_app_control_list_cb_v2 appcontrol_func,
2498 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2499 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2501 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2502 appcontrol_x *appcontrol;
2505 if (info->app_info == NULL)
2506 return PMINFO_R_ERROR;
2508 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
2509 appcontrol = (appcontrol_x *)tmp->data;
2510 if (appcontrol == NULL ||
2511 !strcasecmp(appcontrol->visibility, "local-only"))
2513 ret = appcontrol_func(appcontrol->operation, appcontrol->uri,
2514 appcontrol->mime, appcontrol->id, user_data);