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);
125 _LOGE("out of memory");
126 g_hash_table_destroy(list);
128 return PMINFO_R_ERROR;
130 info->package = strdup(info->app_info->package);
131 if (!info->package) {
132 _LOGE("out of memory");
134 g_hash_table_destroy(list);
136 return PMINFO_R_ERROR;
139 /* just free list only */
140 g_hash_table_steal(list, (gconstpointer)appid);
141 g_hash_table_destroy(list);
148 API int pkgmgrinfo_appinfo_get_usr_disabled_appinfo(const char *appid, uid_t uid,
149 pkgmgrinfo_appinfo_h *handle)
152 pkgmgrinfo_appinfo_filter_h filter;
154 if (appid == NULL || handle == NULL) {
155 LOGE("invalid parameter");
156 return PMINFO_R_EINVAL;
159 ret = pkgmgrinfo_appinfo_filter_create(&filter);
160 if (ret != PMINFO_R_OK)
163 ret = pkgmgrinfo_appinfo_filter_add_string(filter,
164 PMINFO_APPINFO_PROP_APP_ID, appid);
165 if (ret != PMINFO_R_OK) {
166 pkgmgrinfo_appinfo_filter_destroy(filter);
167 return PMINFO_R_ERROR;
170 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
171 PMINFO_APPINFO_PROP_APP_DISABLE, true);
172 if (ret != PMINFO_R_OK) {
173 pkgmgrinfo_appinfo_filter_destroy(filter);
174 return PMINFO_R_ERROR;
177 ret = _pkgmgrinfo_get_appinfo(appid, uid, filter, handle);
178 pkgmgrinfo_appinfo_filter_destroy(filter);
183 API int pkgmgrinfo_appinfo_get_disabled_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
185 return pkgmgrinfo_appinfo_get_usr_disabled_appinfo(appid, _getuid(), handle);
188 API int pkgmgrinfo_appinfo_get_usr_appinfo(const char *appid, uid_t uid,
189 pkgmgrinfo_appinfo_h *handle)
192 pkgmgrinfo_appinfo_filter_h filter;
194 if (appid == NULL || handle == NULL) {
195 LOGE("invalid parameter");
196 return PMINFO_R_EINVAL;
199 ret = pkgmgrinfo_appinfo_filter_create(&filter);
200 if (ret != PMINFO_R_OK)
203 ret = pkgmgrinfo_appinfo_filter_add_string(filter,
204 PMINFO_APPINFO_PROP_APP_ID, appid);
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_APP_DISABLE, false);
212 if (ret != PMINFO_R_OK) {
213 pkgmgrinfo_appinfo_filter_destroy(filter);
214 return PMINFO_R_ERROR;
217 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
218 PMINFO_APPINFO_PROP_PKG_DISABLE, false);
219 if (ret != PMINFO_R_OK) {
220 pkgmgrinfo_appinfo_filter_destroy(filter);
221 return PMINFO_R_ERROR;
224 ret = _pkgmgrinfo_get_appinfo(appid, uid, filter, handle);
225 pkgmgrinfo_appinfo_filter_destroy(filter);
229 API int pkgmgrinfo_appinfo_get_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
231 return pkgmgrinfo_appinfo_get_usr_appinfo(appid, _getuid(), handle);
234 API int pkgmgrinfo_appinfo_get_usr_all_appinfo(const char *appid, uid_t uid,
235 pkgmgrinfo_appinfo_h *handle)
238 pkgmgrinfo_appinfo_filter_h filter;
240 if (appid == NULL || handle == NULL) {
241 LOGE("invalid parameter");
242 return PMINFO_R_EINVAL;
245 ret = pkgmgrinfo_appinfo_filter_create(&filter);
246 if (ret != PMINFO_R_OK)
249 ret = pkgmgrinfo_appinfo_filter_add_string(filter,
250 PMINFO_APPINFO_PROP_APP_ID, appid);
251 if (ret != PMINFO_R_OK) {
252 pkgmgrinfo_appinfo_filter_destroy(filter);
253 return PMINFO_R_ERROR;
256 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
257 PMINFO_APPINFO_PROP_APP_CHECK_STORAGE, false);
258 if (ret != PMINFO_R_OK) {
259 pkgmgrinfo_appinfo_filter_destroy(filter);
260 return PMINFO_R_ERROR;
263 ret = _pkgmgrinfo_get_appinfo(appid, uid, filter, handle);
264 pkgmgrinfo_appinfo_filter_destroy(filter);
269 API int pkgmgrinfo_appinfo_get_all_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
271 return pkgmgrinfo_appinfo_get_usr_all_appinfo(appid, _getuid(), handle);
274 static gpointer __copy_str(gconstpointer src, gpointer data)
276 const char *tmp = (const char *)src;
279 buffer = strdup(tmp);
280 if (buffer == NULL) {
281 LOGE("memory alloc failed");
289 static gpointer __copy_label(gconstpointer src, gpointer data)
291 label_x *tmp = (label_x *)src;
294 label = calloc(1, sizeof(label_x));
296 LOGE("memory alloc failed");
302 label->name = strdup(tmp->name);
304 label->text = strdup(tmp->text);
306 label->lang = strdup(tmp->lang);
311 static gpointer __copy_icon(gconstpointer src, gpointer data)
313 icon_x *tmp = (icon_x *)src;
316 icon = calloc(1, sizeof(icon_x));
318 LOGE("memory alloc failed");
324 icon->text = strdup(tmp->text);
326 icon->lang = strdup(tmp->lang);
328 icon->section = strdup(tmp->section);
330 icon->size = strdup(tmp->size);
332 icon->resolution = strdup(tmp->resolution);
337 static gpointer __copy_metadata(gconstpointer src, gpointer data)
339 metadata_x *tmp = (metadata_x *)src;
340 metadata_x *metadata;
342 metadata = calloc(1, sizeof(metadata_x));
343 if (metadata == NULL) {
344 LOGE("memory alloc failed");
350 metadata->key = strdup(tmp->key);
352 metadata->value = strdup(tmp->value);
357 static gpointer __copy_datacontrol(gconstpointer src, gpointer data)
359 datacontrol_x *tmp = (datacontrol_x *)src;
360 datacontrol_x *datacontrol;
362 datacontrol = calloc(1, sizeof(datacontrol_x));
363 if (datacontrol == NULL) {
364 LOGE("memory alloc failed");
370 datacontrol->providerid = strdup(tmp->providerid);
372 datacontrol->access = strdup(tmp->access);
374 datacontrol->type = strdup(tmp->type);
376 datacontrol->trusted = strdup(tmp->trusted);
381 static gpointer __copy_appcontrol(gconstpointer src, gpointer data)
383 appcontrol_x *tmp = (appcontrol_x *)src;
384 appcontrol_x *appcontrol;
386 appcontrol = calloc(1, sizeof(appcontrol_x));
387 if (appcontrol == NULL) {
388 LOGE("memory alloc failed");
394 appcontrol->operation = strdup(tmp->operation);
396 appcontrol->uri = strdup(tmp->uri);
398 appcontrol->mime = strdup(tmp->mime);
403 static gpointer __copy_splashscreens(gconstpointer src, gpointer data)
405 splashscreen_x *tmp = (splashscreen_x *)src;
406 splashscreen_x *splashscreen;
408 splashscreen = (splashscreen_x *)calloc(1, sizeof(splashscreen_x));
409 if (splashscreen == NULL) {
410 LOGE("memory alloc failed");
416 splashscreen->src = strdup(tmp->src);
418 splashscreen->type = strdup(tmp->type);
419 if (tmp->orientation)
420 splashscreen->orientation = strdup(tmp->orientation);
421 if (tmp->indicatordisplay)
422 splashscreen->indicatordisplay = strdup(tmp->indicatordisplay);
424 splashscreen->operation = strdup(tmp->operation);
425 if (tmp->color_depth)
426 splashscreen->color_depth = strdup(tmp->color_depth);
431 static int _appinfo_copy_appinfo(application_x **application, application_x *data)
433 application_x *app_info;
436 app_info = calloc(1, sizeof(application_x));
437 if (app_info == NULL) {
438 LOGE("memory alloc failed");
439 return PMINFO_R_ERROR;
442 if (data->appid != NULL)
443 app_info->appid = strdup(data->appid);
444 if (data->exec != NULL)
445 app_info->exec = strdup(data->exec);
446 if (data->nodisplay != NULL)
447 app_info->nodisplay = strdup(data->nodisplay);
448 if (data->multiple != NULL)
449 app_info->multiple = strdup(data->multiple);
450 if (data->taskmanage != NULL)
451 app_info->taskmanage = strdup(data->taskmanage);
452 if (data->type != NULL)
453 app_info->type = strdup(data->type);
454 if (data->categories != NULL)
455 app_info->categories = strdup(data->categories);
456 if (data->hwacceleration != NULL)
457 app_info->hwacceleration = strdup(data->hwacceleration);
458 if (data->screenreader != NULL)
459 app_info->screenreader = strdup(data->screenreader);
460 if (data->mainapp != NULL)
461 app_info->mainapp = strdup(data->mainapp);
462 if (data->package != NULL)
463 app_info->package = strdup(data->package);
464 if (data->recentimage != NULL)
465 app_info->recentimage = strdup(data->recentimage);
466 if (data->launchcondition != NULL)
467 app_info->launchcondition = strdup(data->launchcondition);
468 if (data->indicatordisplay != NULL)
469 app_info->indicatordisplay = strdup(data->indicatordisplay);
470 if (data->portraitimg != NULL)
471 app_info->portraitimg = strdup(data->portraitimg);
472 if (data->landscapeimg != NULL)
473 app_info->landscapeimg = strdup(data->landscapeimg);
474 if (data->guestmode_visibility != NULL)
475 app_info->guestmode_visibility = strdup(data->guestmode_visibility);
476 if (data->component != NULL)
477 app_info->component = strdup(data->component);
478 if (data->permission_type != NULL)
479 app_info->permission_type = strdup(data->permission_type);
480 if (data->component_type != NULL)
481 app_info->component_type = strdup(data->component_type);
482 if (data->preload != NULL)
483 app_info->preload = strdup(data->preload);
484 if (data->submode != NULL)
485 app_info->submode = strdup(data->submode);
486 if (data->submode_mainid != NULL)
487 app_info->submode_mainid = strdup(data->submode_mainid);
488 if (data->process_pool != NULL)
489 app_info->process_pool = strdup(data->process_pool);
490 if (data->installed_storage != NULL)
491 app_info->installed_storage = strdup(data->installed_storage);
492 if (data->autorestart != NULL)
493 app_info->autorestart = strdup(data->autorestart);
494 if (data->onboot != NULL)
495 app_info->onboot = strdup(data->onboot);
496 if (data->support_disable != NULL)
497 app_info->support_disable = strdup(data->support_disable);
498 if (data->ui_gadget != NULL)
499 app_info->ui_gadget = strdup(data->ui_gadget);
500 if (data->launch_mode != NULL)
501 app_info->launch_mode = strdup(data->launch_mode);
502 if (data->package_type != NULL)
503 app_info->package_type = strdup(data->package_type);
504 if (data->effective_appid != NULL)
505 app_info->effective_appid = strdup(data->effective_appid);
506 if (data->splash_screen_display != NULL)
507 app_info->splash_screen_display = strdup(data->splash_screen_display);
511 app_info->label = g_list_copy_deep(data->label, __copy_label, &ret);
513 LOGE("memory alloc failed");
514 pkgmgrinfo_basic_free_application(app_info);
515 return PMINFO_R_ERROR;
519 app_info->icon = g_list_copy_deep(data->icon, __copy_icon, &ret);
521 LOGE("memory alloc failed");
522 pkgmgrinfo_basic_free_application(app_info);
523 return PMINFO_R_ERROR;
527 app_info->category = g_list_copy_deep(data->category, __copy_str, &ret);
529 LOGE("memory alloc failed");
530 pkgmgrinfo_basic_free_application(app_info);
531 return PMINFO_R_ERROR;
535 app_info->metadata = g_list_copy_deep(data->metadata, __copy_metadata, &ret);
537 LOGE("memory alloc failed");
538 pkgmgrinfo_basic_free_application(app_info);
539 return PMINFO_R_ERROR;
543 app_info->datacontrol = g_list_copy_deep(data->datacontrol, __copy_datacontrol, &ret);
545 LOGE("memory alloc failed");
546 pkgmgrinfo_basic_free_application(app_info);
547 return PMINFO_R_ERROR;
551 app_info->appcontrol = g_list_copy_deep(data->appcontrol, __copy_appcontrol, &ret);
553 LOGE("memory alloc failed");
554 pkgmgrinfo_basic_free_application(app_info);
555 return PMINFO_R_ERROR;
559 app_info->background_category = g_list_copy_deep(data->background_category, __copy_str, &ret);
561 LOGE("memory alloc failed");
562 pkgmgrinfo_basic_free_application(app_info);
563 return PMINFO_R_ERROR;
567 app_info->splashscreens = g_list_copy_deep(data->splashscreens, __copy_splashscreens, &ret);
569 LOGE("memory alloc failed");
570 pkgmgrinfo_basic_free_application(app_info);
571 return PMINFO_R_ERROR;
574 *application = app_info;
579 API int pkgmgrinfo_appinfo_clone_appinfo(pkgmgrinfo_appinfo_h handle,
580 pkgmgrinfo_appinfo_h *clone)
582 pkgmgr_appinfo_x *info;
583 pkgmgr_appinfo_x *temp = (pkgmgr_appinfo_x *)handle;
586 return PMINFO_R_EINVAL;
588 info = calloc(1, sizeof(pkgmgr_appinfo_x));
590 LOGE("memory alloc failed");
591 return PMINFO_R_ERROR;
594 if (temp->package != NULL)
595 info->package = strdup(temp->package);
596 if (temp->locale != NULL)
597 info->locale = strdup(temp->locale);
599 info->app_component = temp->app_component;
601 if (_appinfo_copy_appinfo(&info->app_info, temp->app_info) < 0) {
602 LOGE("appinfo copy failed");
604 free((void *)info->package);
608 return PMINFO_R_ERROR;
616 static int _appinfo_get_filtered_foreach_appinfo(uid_t uid,
617 pkgmgrinfo_filter_x *filter, int flag, pkgmgrinfo_app_list_cb app_list_cb,
621 pkgmgr_appinfo_x info;
627 list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
628 __free_applications);
630 return PMINFO_R_ERROR;
632 ret = _appinfo_get_applications(uid, uid, filter,
633 flag | PMINFO_APPINFO_GET_BASICINFO, list);
634 if (ret != PMINFO_R_OK) {
635 g_hash_table_destroy(list);
639 g_hash_table_iter_init(&iter, list);
640 while (g_hash_table_iter_next(&iter, NULL, &value)) {
641 app = (application_x *)value;
643 info.locale = info.app_info->locale;
644 info.package = app->package;
645 if (app_list_cb(&info, user_data) < 0)
648 g_hash_table_destroy(list);
653 static const char *__appcomponent_str(pkgmgrinfo_app_component comp);
655 API int pkgmgrinfo_appinfo_get_usr_list(pkgmgrinfo_pkginfo_h handle,
656 pkgmgrinfo_app_component component,
657 pkgmgrinfo_app_list_cb app_func, void *user_data, uid_t uid)
660 pkgmgrinfo_appinfo_filter_h filter;
662 const char *comp_str = NULL;
664 if (handle == NULL || app_func == NULL) {
665 LOGE("invalid parameter");
666 return PMINFO_R_EINVAL;
669 if (pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid)) {
670 LOGE("invalid parameter");
671 return PMINFO_R_EINVAL;
674 if (pkgmgrinfo_appinfo_filter_create(&filter))
675 return PMINFO_R_ERROR;
677 if (pkgmgrinfo_appinfo_filter_add_string(filter,
678 PMINFO_APPINFO_PROP_APP_PACKAGE, pkgid)) {
679 pkgmgrinfo_appinfo_filter_destroy(filter);
680 return PMINFO_R_ERROR;
683 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
684 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
685 pkgmgrinfo_appinfo_filter_destroy(filter);
686 return PMINFO_R_ERROR;
689 comp_str = __appcomponent_str(component);
692 if (pkgmgrinfo_appinfo_filter_add_string(filter,
693 PMINFO_APPINFO_PROP_APP_COMPONENT,
695 pkgmgrinfo_appinfo_filter_destroy(filter);
696 return PMINFO_R_ERROR;
700 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter,
701 PMINFO_APPINFO_GET_ALL, app_func, user_data);
703 pkgmgrinfo_appinfo_filter_destroy(filter);
708 API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle,
709 pkgmgrinfo_app_component component,
710 pkgmgrinfo_app_list_cb app_func, void *user_data)
712 return pkgmgrinfo_appinfo_get_usr_list(handle, component, app_func, user_data, _getuid());
715 API int pkgmgrinfo_appinfo_get_usr_installed_list_full(
716 pkgmgrinfo_app_list_cb app_func, uid_t uid, int flag,
720 pkgmgrinfo_appinfo_filter_h filter;
722 if (app_func == NULL) {
723 LOGE("invalid parameter");
724 return PMINFO_R_EINVAL;
727 if (pkgmgrinfo_appinfo_filter_create(&filter))
728 return PMINFO_R_ERROR;
730 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
731 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
732 pkgmgrinfo_appinfo_filter_destroy(filter);
733 return PMINFO_R_ERROR;
736 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
737 PMINFO_APPINFO_PROP_PKG_DISABLE, false)) {
738 pkgmgrinfo_appinfo_filter_destroy(filter);
739 return PMINFO_R_ERROR;
742 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
743 PMINFO_APPINFO_PROP_APP_CHECK_STORAGE, false)) {
744 pkgmgrinfo_appinfo_filter_destroy(filter);
745 return PMINFO_R_ERROR;
748 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter, flag, app_func,
751 pkgmgrinfo_appinfo_filter_destroy(filter);
756 API int pkgmgrinfo_appinfo_get_installed_list_full(
757 pkgmgrinfo_app_list_cb app_func, int flag, void *user_data)
759 return pkgmgrinfo_appinfo_get_usr_installed_list_full(app_func,
760 _getuid(), flag, user_data);
763 API int pkgmgrinfo_appinfo_get_usr_installed_list(
764 pkgmgrinfo_app_list_cb app_func, uid_t uid, void *user_data)
767 pkgmgrinfo_appinfo_filter_h filter;
769 if (app_func == NULL) {
770 LOGE("invalid parameter");
771 return PMINFO_R_EINVAL;
774 /* create an empty filter */
775 ret = pkgmgrinfo_appinfo_filter_create(&filter);
776 if (ret != PMINFO_R_OK)
779 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
780 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
781 pkgmgrinfo_appinfo_filter_destroy(filter);
782 return PMINFO_R_ERROR;
785 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
786 PMINFO_APPINFO_PROP_PKG_DISABLE, false)) {
787 pkgmgrinfo_appinfo_filter_destroy(filter);
788 return PMINFO_R_ERROR;
791 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter,
792 PMINFO_APPINFO_GET_ALL, app_func, user_data);
794 pkgmgrinfo_appinfo_filter_destroy(filter);
799 API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func,
802 return pkgmgrinfo_appinfo_get_usr_installed_list(app_func, _getuid(),
806 API int pkgmgrinfo_appinfo_get_appid(pkgmgrinfo_appinfo_h handle, char **appid)
808 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
810 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
811 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
813 if (info->app_info == NULL || info->app_info->appid == NULL)
814 return PMINFO_R_ERROR;
815 *appid = (char *)info->app_info->appid;
820 API int pkgmgrinfo_appinfo_get_pkgname(pkgmgrinfo_appinfo_h handle, char **pkg_name)
822 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
824 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
825 retvm_if(pkg_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
827 if (info->package == NULL)
828 return PMINFO_R_ERROR;
830 *pkg_name = (char *)info->package;
835 API int pkgmgrinfo_appinfo_get_pkgid(pkgmgrinfo_appinfo_h handle, char **pkgid)
837 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
839 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
840 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
842 if (info->package == NULL)
843 return PMINFO_R_ERROR;
845 *pkgid = (char *)info->package;
850 API int pkgmgrinfo_appinfo_get_pkgtype(pkgmgrinfo_appinfo_h handle, char **pkgtype)
852 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
853 retvm_if(pkgtype == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
854 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
856 *pkgtype = (char *)info->app_info->package_type;
861 API int pkgmgrinfo_appinfo_get_exec(pkgmgrinfo_appinfo_h handle, char **exec)
863 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
865 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
866 retvm_if(exec == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
868 if (info->app_info == NULL || info->app_info->exec == NULL)
869 return PMINFO_R_ERROR;
870 *exec = (char *)info->app_info->exec;
876 API int pkgmgrinfo_appinfo_get_icon(pkgmgrinfo_appinfo_h handle, char **icon)
879 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
881 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
882 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
884 if (info->app_info == NULL)
885 return PMINFO_R_ERROR;
887 if (info->app_info->icon == NULL) {
892 ptr = (icon_x *)info->app_info->icon->data;
894 return PMINFO_R_ERROR;
896 if (ptr->text == NULL)
897 return PMINFO_R_ERROR;
905 API int pkgmgrinfo_appinfo_get_label(pkgmgrinfo_appinfo_h handle, char **label)
908 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
913 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
914 retvm_if(label == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
916 if (info->app_info == NULL)
917 return PMINFO_R_ERROR;
919 locale = info->locale;
921 locale = DEFAULT_LOCALE;
923 for (tmp = info->app_info->label; tmp; tmp = tmp->next) {
924 ptr = (label_x *)tmp->data;
925 if (ptr == NULL || strcmp(locale, ptr->lang) != 0)
936 for (tmp = info->app_info->label; tmp; tmp = tmp->next) {
937 ptr = (label_x *)tmp->data;
938 if (ptr == NULL || strcmp(DEFAULT_LOCALE, ptr->lang) != 0)
944 *label = lbl ? lbl : "";
949 API int pkgmgrinfo_appinfo_usr_get_localed_label(const char *appid, const char *locale, uid_t uid, char **label)
953 retvm_if(appid == NULL || locale == NULL || label == NULL, PMINFO_R_EINVAL, "Argument is NULL");
954 val = _appinfo_get_localed_label(appid, locale, uid);
956 return PMINFO_R_ERROR;
962 API int pkgmgrinfo_appinfo_get_localed_label(const char *appid, const char *locale, char **label)
964 return pkgmgrinfo_appinfo_usr_get_localed_label(appid, locale, _getuid(), label);
967 API int pkgmgrinfo_appinfo_get_metadata_value(pkgmgrinfo_appinfo_h handle, const char *metadata_key, char **metadata_value)
969 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
970 retvm_if(metadata_key == NULL, PMINFO_R_EINVAL, "metadata_key is NULL");
971 retvm_if(metadata_value == NULL, PMINFO_R_EINVAL, "metadata_value is NULL");
973 GList *list_md = NULL;
974 metadata_x *metadata = NULL;
975 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
977 list_md = info->app_info->metadata;
979 for (; list_md; list_md = list_md->next) {
980 metadata = (metadata_x *)list_md->data;
981 if (metadata && metadata->key) {
982 if (strcasecmp(metadata->key, metadata_key) == 0) {
983 if (metadata->value == NULL)
984 *metadata_value = "";
986 *metadata_value = (char *)metadata->value;
992 return PMINFO_R_EINVAL;
995 static pkgmgrinfo_app_component __appcomponent_convert(const char *comp)
997 if (strcasecmp(comp, "uiapp") == 0)
998 return PMINFO_UI_APP;
999 else if (strcasecmp(comp, "svcapp") == 0)
1000 return PMINFO_SVC_APP;
1001 else if (strcasecmp(comp, "widgetapp") == 0)
1002 return PMINFO_WIDGET_APP;
1003 else if (strcasecmp(comp, "watchapp") == 0)
1004 return PMINFO_WATCH_APP;
1005 else if (strcasecmp(comp, "componentbasedapp") == 0)
1006 return PMINFO_COMPONENT_BASED_APP;
1011 static const char *__appcomponent_str(pkgmgrinfo_app_component comp)
1016 case PMINFO_SVC_APP:
1018 case PMINFO_WIDGET_APP:
1020 case PMINFO_WATCH_APP:
1022 case PMINFO_COMPONENT_BASED_APP:
1023 return "componentbasedapp";
1029 API int pkgmgrinfo_appinfo_get_component(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_component *component)
1031 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1034 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1035 retvm_if(component == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1037 if (info->app_info == NULL)
1038 return PMINFO_R_ERROR;
1040 comp = __appcomponent_convert(info->app_info->component);
1042 return PMINFO_R_ERROR;
1049 API int pkgmgrinfo_appinfo_get_apptype(pkgmgrinfo_appinfo_h handle, char **app_type)
1051 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1053 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1054 retvm_if(app_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1056 if (info->app_info == NULL || info->app_info->type == NULL)
1057 return PMINFO_R_ERROR;
1058 *app_type = (char *)info->app_info->type;
1063 API int pkgmgrinfo_appinfo_get_notification_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1068 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1070 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1071 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1073 if (info->app_info == NULL)
1074 return PMINFO_R_ERROR;
1076 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1077 ptr = (icon_x *)tmp->data;
1078 if (ptr == NULL || ptr->section == NULL)
1081 val = (char *)ptr->section;
1082 if (val && strcmp(val, "notification") == 0) {
1083 *icon = (char *)ptr->text;
1088 return PMINFO_R_ERROR;
1091 API int pkgmgrinfo_appinfo_get_recent_image_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_recentimage *type)
1094 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1096 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1097 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1099 if (info->app_info == NULL || info->app_info->recentimage == NULL)
1100 return PMINFO_R_ERROR;
1102 val = (char *)info->app_info->recentimage;
1103 if (strcasecmp(val, "capture") == 0)
1104 *type = PMINFO_RECENTIMAGE_USE_CAPTURE;
1105 else if (strcasecmp(val, "icon") == 0)
1106 *type = PMINFO_RECENTIMAGE_USE_ICON;
1108 *type = PMINFO_RECENTIMAGE_USE_NOTHING;
1113 API int pkgmgrinfo_appinfo_get_preview_image(pkgmgrinfo_appinfo_h handle, char **preview_img)
1118 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1120 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1121 retvm_if(preview_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1123 if (info->app_info == NULL)
1124 return PMINFO_R_ERROR;
1126 for (tmp = info->app_info->image; tmp; tmp = tmp->next) {
1127 ptr = (image_x *)tmp->data;
1128 if (ptr == NULL || ptr->section == NULL)
1131 val = (char *)ptr->section;
1132 if (val && strcmp(val, "preview") == 0) {
1133 *preview_img = (char *)ptr->text;
1138 return PMINFO_R_ERROR;
1141 API int pkgmgrinfo_appinfo_get_permission_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_permission_type *permission)
1144 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1146 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1147 retvm_if(permission == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1149 val = info->app_info->permission_type;
1151 return PMINFO_R_ERROR;
1153 if (strcmp(val, "signature") == 0)
1154 *permission = PMINFO_PERMISSION_SIGNATURE;
1155 else if (strcmp(val, "privilege") == 0)
1156 *permission = PMINFO_PERMISSION_PRIVILEGE;
1158 *permission = PMINFO_PERMISSION_NORMAL;
1163 API int pkgmgrinfo_appinfo_get_component_type(pkgmgrinfo_appinfo_h handle, char **component_type)
1165 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1167 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1168 retvm_if(component_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1170 if (info->app_info == NULL || info->app_info->component_type == NULL)
1171 return PMINFO_R_ERROR;
1173 *component_type = (char *)info->app_info->component_type;
1178 API int pkgmgrinfo_appinfo_get_hwacceleration(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_hwacceleration *hwacceleration)
1181 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1183 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1184 retvm_if(hwacceleration == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1186 if (info->app_info == NULL || info->app_info->hwacceleration == NULL)
1187 return PMINFO_R_ERROR;
1189 val = (char *)info->app_info->hwacceleration;
1190 if (strcasecmp(val, "off") == 0)
1191 *hwacceleration = PMINFO_HWACCELERATION_OFF;
1192 else if (strcasecmp(val, "on") == 0)
1193 *hwacceleration = PMINFO_HWACCELERATION_ON;
1195 *hwacceleration = PMINFO_HWACCELERATION_DEFAULT;
1200 API int pkgmgrinfo_appinfo_get_screenreader(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_screenreader *screenreader)
1203 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1205 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1206 retvm_if(screenreader == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1208 if (info->app_info == NULL || info->app_info->screenreader == NULL)
1209 return PMINFO_R_ERROR;
1211 val = (char *)info->app_info->screenreader;
1212 if (strcasecmp(val, "screenreader-off") == 0)
1213 *screenreader = PMINFO_SCREENREADER_OFF;
1214 else if (strcasecmp(val, "screenreader-on") == 0)
1215 *screenreader = PMINFO_SCREENREADER_ON;
1217 *screenreader = PMINFO_SCREENREADER_USE_SYSTEM_SETTING;
1222 API int pkgmgrinfo_appinfo_get_effectimage(pkgmgrinfo_appinfo_h handle, char **portrait_img, char **landscape_img)
1224 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1226 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1227 retvm_if(portrait_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1228 retvm_if(landscape_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1230 if (info->app_info == NULL)
1231 return PMINFO_R_ERROR;
1233 if (info->app_info->portraitimg == NULL)
1236 *portrait_img = (char *)info->app_info->portraitimg;
1238 if (info->app_info->landscapeimg == NULL)
1239 *landscape_img = "";
1241 *landscape_img = (char *)info->app_info->landscapeimg;
1246 API int pkgmgrinfo_appinfo_get_effectimage_type(pkgmgrinfo_appinfo_h handle, char **effectimage_type)
1248 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1250 if (handle == NULL || effectimage_type == NULL) {
1251 LOGE("invalid parameter");
1252 return PMINFO_R_EINVAL;
1255 if (info->app_info == NULL || info->app_info->effectimage_type == NULL)
1256 return PMINFO_R_ERROR;
1258 *effectimage_type = (char *)info->app_info->effectimage_type;
1263 API int pkgmgrinfo_appinfo_get_submode_mainid(pkgmgrinfo_appinfo_h handle, char **submode_mainid)
1265 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1267 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1268 retvm_if(submode_mainid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1270 if (info->app_info == NULL)
1271 return PMINFO_R_ERROR;
1273 if (info->app_info->submode_mainid == NULL)
1274 *submode_mainid = "";
1276 *submode_mainid = (char *)info->app_info->submode_mainid;
1281 API int pkgmgrinfo_appinfo_get_installed_storage_location(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_installed_storage *storage)
1283 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1284 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1286 if (info->app_info && info->app_info->installed_storage) {
1287 if (strcmp(info->app_info->installed_storage, "installed_internal") == 0)
1288 *storage = PMINFO_INTERNAL_STORAGE;
1289 else if (strcmp(info->app_info->installed_storage, "installed_external") == 0)
1290 *storage = PMINFO_EXTERNAL_STORAGE;
1292 return PMINFO_R_ERROR;
1294 return PMINFO_R_ERROR;
1300 API int pkgmgrinfo_appinfo_get_launch_mode(pkgmgrinfo_appinfo_h handle, char **mode)
1302 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1304 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1305 retvm_if(mode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1307 if (info->app_info->launch_mode == NULL)
1308 return PMINFO_R_ERROR;
1310 *mode = (char *)(info->app_info->launch_mode);
1315 API int pkgmgrinfo_appinfo_get_alias_appid(pkgmgrinfo_appinfo_h handle, char **alias_appid)
1317 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1319 if (handle == NULL || alias_appid == NULL) {
1320 LOGE("invalid parameter");
1321 return PMINFO_R_EINVAL;
1324 if (info->app_info == NULL || info->app_info->alias_appid == NULL)
1325 return PMINFO_R_ERROR;
1327 *alias_appid = (char *)info->app_info->alias_appid;
1332 API int pkgmgrinfo_appinfo_get_effective_appid(pkgmgrinfo_appinfo_h handle, char **effective_appid)
1334 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1336 if (handle == NULL || effective_appid == NULL) {
1337 LOGE("invalid parameter");
1338 return PMINFO_R_EINVAL;
1341 if (info->app_info == NULL)
1342 return PMINFO_R_ERROR;
1344 if (info->app_info->effective_appid == NULL)
1345 *effective_appid = "";
1347 *effective_appid = (char *)info->app_info->effective_appid;
1352 API int pkgmgrinfo_appinfo_get_tep_name(pkgmgrinfo_appinfo_h handle, char **tep_name)
1354 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1356 if (handle == NULL || tep_name == NULL) {
1357 LOGE("invalid parameter");
1358 return PMINFO_R_EINVAL;
1361 if (info->app_info == NULL)
1362 return PMINFO_R_ERROR;
1364 if (info->app_info->tep_name == NULL)
1367 *tep_name = (char *)info->app_info->tep_name;
1372 API int pkgmgrinfo_appinfo_get_zip_mount_file(pkgmgrinfo_appinfo_h handle, char **zip_mount_file)
1374 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1376 if (handle == NULL || zip_mount_file == NULL) {
1377 LOGE("invalid parameter");
1378 return PMINFO_R_EINVAL;
1381 if (info->app_info == NULL)
1382 return PMINFO_R_ERROR;
1384 if (info->app_info->zip_mount_file == NULL)
1385 *zip_mount_file = "";
1387 *zip_mount_file = (char *)info->app_info->zip_mount_file;
1392 API int pkgmgrinfo_appinfo_get_root_path(pkgmgrinfo_appinfo_h handle, char **root_path)
1394 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1396 if (handle == NULL || root_path == NULL) {
1397 LOGE("invalid parameter");
1398 return PMINFO_R_EINVAL;
1401 if (info->app_info == NULL || info->app_info->root_path == NULL)
1402 return PMINFO_R_ERROR;
1404 *root_path = (char *)info->app_info->root_path;
1409 API int pkgmgrinfo_appinfo_get_api_version(pkgmgrinfo_appinfo_h handle, char **api_version)
1411 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1413 if (handle == NULL || api_version == NULL) {
1414 LOGE("invalid parameter");
1415 return PMINFO_R_EINVAL;
1418 if (info->app_info == NULL || info->app_info->api_version == NULL)
1419 return PMINFO_R_ERROR;
1421 *api_version = (char *)info->app_info->api_version;
1426 API int pkgmgrinfo_appinfo_get_installed_time(pkgmgrinfo_appinfo_h handle, int *installed_time)
1428 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1430 if (handle == NULL || installed_time == NULL) {
1431 LOGE("invalid parameter");
1432 return PMINFO_R_EINVAL;
1435 if (info->app_info == NULL || info->app_info->package_installed_time == NULL)
1436 return PMINFO_R_ERROR;
1438 *installed_time = atoi(info->app_info->package_installed_time);
1443 API int pkgmgrinfo_appinfo_usr_get_datacontrol_info(const char *providerid,
1444 const char *type, uid_t uid, char **appid, char **access)
1448 if (providerid == NULL || type == NULL || appid == NULL ||
1450 LOGE("invalid parameter");
1451 return PMINFO_R_EINVAL;
1454 ret = _appinfo_get_datacontrol_info(providerid, type, uid, appid, access);
1455 /* FIXME: It should return PMINFO_R_ENOENT but to keep previous
1456 * implementation, return PMINFO_R_ERROR. This should be
1459 if (ret == PMINFO_R_ENOENT) {
1460 LOGE("no datacontrol info of %s", providerid);
1461 ret = PMINFO_R_ERROR;
1467 API int pkgmgrinfo_appinfo_get_datacontrol_info(const char *providerid,
1468 const char *type, char **appid, char **access)
1470 return pkgmgrinfo_appinfo_usr_get_datacontrol_info(providerid,
1471 type, _getuid(), appid, access);
1474 API int pkgmgrinfo_appinfo_usr_get_datacontrol_appid(const char *providerid,
1475 uid_t uid, char **appid)
1478 if (providerid == NULL || appid == NULL) {
1479 LOGE("invalid parameter");
1480 return PMINFO_R_EINVAL;
1483 ret = _appinfo_get_datacontrol_appid(providerid, uid, appid);
1484 /* FIXME: It should return PMINFO_R_ENOENT but to keep previous
1485 * implementation, return PMINFO_R_ERROR. This should be
1488 if (ret == PMINFO_R_ENOENT) {
1489 LOGE("no datacontrol appid of %s", providerid);
1490 ret = PMINFO_R_ERROR;
1496 API int pkgmgrinfo_appinfo_get_datacontrol_appid(const char *providerid, char **appid)
1498 return pkgmgrinfo_appinfo_usr_get_datacontrol_appid(providerid, _getuid(), appid);
1501 API int pkgmgrinfo_appinfo_usr_get_datacontrol_trusted_info(
1502 const char *providerid, const char *type, uid_t uid,
1503 char **appid, bool *is_trusted)
1506 char *trusted = NULL;
1507 if (providerid == NULL || type == NULL || appid == NULL ||
1508 is_trusted == NULL) {
1509 LOGE("invalid parameter");
1510 return PMINFO_R_EINVAL;
1513 ret = _appinfo_get_datacontrol_trusted_info(providerid, type, uid,
1516 /* FIXME: It should return PMINFO_R_ENOENT but to keep previous
1517 * implementation, return PMINFO_R_ERROR. This should be
1520 if (ret == PMINFO_R_ENOENT) {
1521 LOGE("no datacontrol trusted info of %s", providerid);
1522 ret = PMINFO_R_ERROR;
1524 *is_trusted = _get_bool_value(trusted);
1530 API int pkgmgrinfo_appinfo_get_datacontrol_trsuted_info(const char *providerid,
1531 const char *type, char **appid, bool *is_trusted)
1533 return pkgmgrinfo_appinfo_usr_get_datacontrol_trusted_info(providerid,
1534 type, _getuid(), appid, is_trusted);
1537 API int pkgmgrinfo_appinfo_usr_foreach_datacontrol_privileges(
1538 const char *providerid, const char *type,
1539 pkgmgrinfo_pkg_privilege_list_cb privilege_func,
1540 void *user_data, uid_t uid)
1546 if (providerid == NULL || type == NULL || privilege_func == NULL) {
1547 LOGE("invalid parameter");
1548 return PMINFO_R_EINVAL;
1551 ret = _appinfo_get_datacontrol_privileges(providerid, type, uid, &list);
1552 if (PMINFO_R_ERROR) {
1553 g_list_free_full(list, free);
1557 for (tmp = list; tmp != NULL; tmp = g_list_next(tmp)) {
1559 ret = privilege_func((char *)tmp->data, user_data);
1564 g_list_free_full(list, free);
1568 API int pkgmgrinfo_appinfo_foreach_datacontrol_privileges(
1569 const char *providerid, const char *type,
1570 pkgmgrinfo_pkg_privilege_list_cb privilege_func,
1573 return pkgmgrinfo_appinfo_usr_foreach_datacontrol_privileges(
1574 providerid, type, privilege_func, user_data, _getuid());
1577 API int pkgmgrinfo_appinfo_get_support_mode(pkgmgrinfo_appinfo_h handle, int *support_mode)
1579 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1580 retvm_if(support_mode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1582 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1583 if (info->app_info->support_mode)
1584 *support_mode = atoi(info->app_info->support_mode);
1591 API int pkgmgrinfo_appinfo_foreach_category(pkgmgrinfo_appinfo_h handle,
1592 pkgmgrinfo_app_category_list_cb category_func, void *user_data)
1594 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1595 retvm_if(category_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
1597 const char *category;
1599 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1601 if (info->app_info == NULL)
1602 return PMINFO_R_ERROR;
1604 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
1605 category = (const char *)tmp->data;
1607 ret = category_func(category, user_data);
1615 API int pkgmgrinfo_appinfo_foreach_metadata(pkgmgrinfo_appinfo_h handle,
1616 pkgmgrinfo_app_metadata_list_cb metadata_func, void *user_data)
1618 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1619 retvm_if(metadata_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
1623 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1625 if (info->app_info == NULL)
1626 return PMINFO_R_ERROR;
1628 for (tmp = info->app_info->metadata; tmp; tmp = tmp->next) {
1629 ptr = (metadata_x *)tmp->data;
1633 ret = metadata_func(ptr->key, ptr->value ? ptr->value : "", user_data);
1641 API int pkgmgrinfo_appinfo_usr_foreach_appcontrol_privileges(const char *appid,
1642 const char *operation,
1643 pkgmgrinfo_pkg_privilege_list_cb privilege_func,
1644 void *user_data, uid_t uid)
1647 GList *privilege_list = NULL;
1650 if (appid == NULL || operation == NULL || privilege_func == NULL) {
1651 LOGE("invalid parameter");
1652 return PMINFO_R_EINVAL;
1655 ret = _appinfo_get_appcontrol_privileges(appid, operation, uid,
1657 if (ret == PMINFO_R_ENOENT) {
1659 } else if (ret != PMINFO_R_OK) {
1660 g_list_free_full(privilege_list, free);
1664 for (tmp_list = privilege_list; tmp_list != NULL;
1665 tmp_list = g_list_next(tmp_list)) {
1666 ret = privilege_func((char *)tmp_list->data, user_data);
1671 g_list_free_full(privilege_list, free);
1675 API int pkgmgrinfo_appinfo_foreach_appcontrol_privileges(const char *appid,
1676 const char *operation,
1677 pkgmgrinfo_pkg_privilege_list_cb privilege_func,
1680 return pkgmgrinfo_appinfo_usr_foreach_appcontrol_privileges(appid,
1681 operation, privilege_func, user_data, _getuid());
1684 API int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
1685 pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
1687 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1688 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
1690 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1691 appcontrol_x *appcontrol;
1694 if (info->app_info == NULL)
1695 return PMINFO_R_ERROR;
1697 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
1698 appcontrol = (appcontrol_x *)tmp->data;
1699 if (appcontrol == NULL || !strcasecmp(appcontrol->visibility, "remote-only"))
1701 ret = appcontrol_func(appcontrol->operation, appcontrol->uri, appcontrol->mime, user_data);
1709 API int pkgmgrinfo_appinfo_foreach_remote_appcontrol(pkgmgrinfo_appinfo_h handle,
1710 pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
1712 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1713 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
1715 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1716 appcontrol_x *appcontrol;
1719 if (info->app_info == NULL)
1720 return PMINFO_R_ERROR;
1722 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
1723 appcontrol = (appcontrol_x *)tmp->data;
1724 if (appcontrol == NULL || !strcasecmp(appcontrol->visibility, "local-only"))
1726 ret = appcontrol_func(appcontrol->operation, appcontrol->uri, appcontrol->mime, user_data);
1734 API int pkgmgrinfo_appinfo_foreach_background_category(
1735 pkgmgrinfo_appinfo_h handle,
1736 pkgmgrinfo_app_background_category_list_cb category_func,
1739 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1743 if (handle == NULL || category_func == NULL || info->app_info == NULL) {
1744 LOGE("invalid parameter");
1745 return PMINFO_R_EINVAL;
1748 for (tmp = info->app_info->background_category; tmp; tmp = tmp->next) {
1749 category = (char *)tmp->data;
1750 if (category == NULL)
1753 if (category_func(category, user_data) < 0)
1760 API int pkgmgrinfo_appinfo_foreach_splash_screen(pkgmgrinfo_appinfo_h handle,
1761 pkgmgrinfo_app_splash_screen_list_cb splash_screen_func,
1764 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1765 splashscreen_x *splashscreen;
1769 if (info == NULL || info->app_info == NULL
1770 || splash_screen_func == NULL) {
1771 LOGE("invalid parameter");
1772 return PMINFO_R_EINVAL;
1775 for (tmp = info->app_info->splashscreens; tmp; tmp = tmp->next) {
1776 splashscreen = (splashscreen_x *)tmp->data;
1777 if (splashscreen == NULL)
1779 ret = splash_screen_func(splashscreen->src,
1781 splashscreen->orientation,
1782 splashscreen->indicatordisplay,
1783 splashscreen->operation,
1784 splashscreen->color_depth,
1793 API int pkgmgrinfo_appinfo_is_nodisplay(pkgmgrinfo_appinfo_h handle, bool *nodisplay)
1795 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1796 retvm_if(nodisplay == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1797 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1799 if (info->app_info == NULL || info->app_info->nodisplay == NULL)
1800 return PMINFO_R_ERROR;
1802 *nodisplay = _get_bool_value(info->app_info->nodisplay);
1807 API int pkgmgrinfo_appinfo_is_multiple(pkgmgrinfo_appinfo_h handle, bool *multiple)
1809 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1810 retvm_if(multiple == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1811 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1813 if (info->app_info == NULL || info->app_info->multiple == NULL)
1814 return PMINFO_R_ERROR;
1816 *multiple = _get_bool_value(info->app_info->multiple);
1821 API int pkgmgrinfo_appinfo_is_indicator_display_allowed(pkgmgrinfo_appinfo_h handle, bool *indicator_disp)
1823 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1824 retvm_if(indicator_disp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1825 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1827 if (info->app_info == NULL || info->app_info->indicatordisplay == NULL)
1828 return PMINFO_R_ERROR;
1830 *indicator_disp = _get_bool_value(info->app_info->indicatordisplay);
1835 API int pkgmgrinfo_appinfo_is_taskmanage(pkgmgrinfo_appinfo_h handle, bool *taskmanage)
1837 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1838 retvm_if(taskmanage == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1839 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1841 if (info->app_info == NULL || info->app_info->taskmanage == NULL)
1842 return PMINFO_R_ERROR;
1844 *taskmanage = _get_bool_value(info->app_info->taskmanage);
1849 API int pkgmgrinfo_appinfo_is_enabled(pkgmgrinfo_appinfo_h handle, bool *enabled)
1851 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1852 retvm_if(enabled == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1853 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1855 if (info->app_info == NULL || info->app_info->is_disabled == NULL)
1856 return PMINFO_R_ERROR;
1858 *enabled = !_get_bool_value(info->app_info->is_disabled);
1863 API int pkgmgrinfo_appinfo_is_onboot(pkgmgrinfo_appinfo_h handle, bool *onboot)
1865 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1866 retvm_if(onboot == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1867 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1869 if (info->app_info == NULL || info->app_info->onboot == NULL)
1870 return PMINFO_R_ERROR;
1872 *onboot = _get_bool_value(info->app_info->onboot);
1877 API int pkgmgrinfo_appinfo_is_autorestart(pkgmgrinfo_appinfo_h handle, bool *autorestart)
1879 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1880 retvm_if(autorestart == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1881 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1883 if (info->app_info == NULL || info->app_info->autorestart == NULL)
1884 return PMINFO_R_ERROR;
1886 *autorestart = _get_bool_value(info->app_info->autorestart);
1891 API int pkgmgrinfo_appinfo_is_mainapp(pkgmgrinfo_appinfo_h handle, bool *mainapp)
1893 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1894 retvm_if(mainapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1895 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1897 if (info->app_info == NULL || info->app_info->mainapp == NULL)
1898 return PMINFO_R_ERROR;
1900 *mainapp = _get_bool_value(info->app_info->mainapp);
1905 API int pkgmgrinfo_appinfo_is_preload(pkgmgrinfo_appinfo_h handle, bool *preload)
1907 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1908 retvm_if(preload == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1909 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1911 if (info->app_info == NULL || info->app_info->preload == NULL)
1912 return PMINFO_R_ERROR;
1914 *preload = _get_bool_value(info->app_info->preload);
1919 API int pkgmgrinfo_appinfo_is_submode(pkgmgrinfo_appinfo_h handle, bool *submode)
1921 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1922 retvm_if(submode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1923 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1925 if (info->app_info == NULL || info->app_info->submode == NULL)
1926 return PMINFO_R_ERROR;
1928 *submode = _get_bool_value(info->app_info->submode);
1933 API int pkgmgrinfo_appinfo_is_process_pool(pkgmgrinfo_appinfo_h handle, bool *process_pool)
1935 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1937 if (handle == NULL || process_pool == NULL) {
1938 LOGE("invalid parameter");
1939 return PMINFO_R_EINVAL;
1942 if (info->app_info == NULL)
1943 return PMINFO_R_ERROR;
1945 *process_pool = _get_bool_value(info->app_info->process_pool);
1950 API int pkgmgrinfo_appinfo_is_category_exist(pkgmgrinfo_appinfo_h handle, const char *category, bool *exist)
1952 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1953 retvm_if(category == NULL, PMINFO_R_EINVAL, "category is NULL");
1954 retvm_if(exist == NULL, PMINFO_R_EINVAL, "exist is NULL");
1958 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1960 if (info->app_info == NULL)
1961 return PMINFO_R_ERROR;
1964 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
1965 val = (const char *)tmp->data;
1968 if (strcasecmp(val, category) == 0) {
1977 API int pkgmgrinfo_appinfo_is_ui_gadget(pkgmgrinfo_appinfo_h handle,
1980 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1982 if (info == NULL || info->app_info == NULL || ui_gadget == NULL) {
1983 _LOGE("invalid parameter");
1984 return PMINFO_R_EINVAL;
1986 if (info->app_info->ui_gadget == NULL)
1987 info->app_info->ui_gadget = strdup("false");
1989 *ui_gadget = _get_bool_value(info->app_info->ui_gadget);
1994 API int pkgmgrinfo_appinfo_is_support_disable(pkgmgrinfo_appinfo_h handle,
1995 bool *support_disable)
1997 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1999 if (info == NULL || info->app_info == NULL || support_disable == NULL) {
2000 _LOGE("invalid parameter");
2001 return PMINFO_R_EINVAL;
2004 *support_disable = _get_bool_value(info->app_info->support_disable);
2009 API int pkgmgrinfo_appinfo_is_removable(pkgmgrinfo_appinfo_h handle,
2012 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2014 if (info == NULL || info->app_info == NULL || removable == NULL) {
2015 _LOGE("invalid parameter");
2016 return PMINFO_R_EINVAL;
2019 *removable = _get_bool_value(info->app_info->removable);
2024 API int pkgmgrinfo_appinfo_is_system(pkgmgrinfo_appinfo_h handle, bool *system)
2026 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2028 if (info == NULL || info->app_info == NULL || system == NULL) {
2029 _LOGE("invalid parameter");
2030 return PMINFO_R_EINVAL;
2033 *system = _get_bool_value(info->app_info->package_system);
2038 API int pkgmgrinfo_appinfo_is_disabled(pkgmgrinfo_appinfo_h handle, bool *disabled)
2040 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2041 retvm_if(disabled == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2042 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2044 if (info->app_info == NULL || info->app_info->is_disabled == NULL)
2045 return PMINFO_R_ERROR;
2047 *disabled = _get_bool_value(info->app_info->is_disabled);
2052 API int pkgmgrinfo_appinfo_is_global(pkgmgrinfo_appinfo_h handle, bool *global)
2054 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2056 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2057 retvm_if(global == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2059 if (info->app_info == NULL || info->app_info->for_all_users == NULL)
2060 return PMINFO_R_ERROR;
2062 *global = _get_bool_value(info->app_info->for_all_users);
2067 API int pkgmgrinfo_appinfo_get_splash_screen_display(pkgmgrinfo_appinfo_h handle, bool *splash_screen_display)
2069 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2071 if (info == NULL || splash_screen_display == NULL) {
2072 _LOGE("Invalid parameter");
2073 return PMINFO_R_EINVAL;
2076 if (info->app_info == NULL || info->app_info->splash_screen_display == NULL)
2077 return PMINFO_R_ERROR;
2079 *splash_screen_display = _get_bool_value(info->app_info->splash_screen_display);
2084 API int pkgmgrinfo_appinfo_get_setup_appid(pkgmgrinfo_appinfo_h handle, char **setup_appid)
2086 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2088 if (info == NULL || setup_appid == NULL) {
2089 _LOGE("Invalid parameter");
2090 return PMINFO_R_EINVAL;
2093 if (info->app_info == NULL || info->app_info->setup_appid == NULL)
2094 return PMINFO_R_ERROR;
2096 *setup_appid = info->app_info->setup_appid;
2100 API int pkgmgrinfo_appinfo_is_support_ambient(pkgmgrinfo_appinfo_h handle,
2101 bool *support_ambient)
2103 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2105 if (info == NULL || support_ambient == NULL) {
2106 _LOGE("Invalid parameter");
2107 return PMINFO_R_EINVAL;
2110 if (info->app_info == NULL || info->app_info->support_ambient == NULL)
2111 return PMINFO_R_ERROR;
2113 *support_ambient = _get_bool_value(info->app_info->support_ambient);
2118 API int pkgmgrinfo_appinfo_destroy_appinfo(pkgmgrinfo_appinfo_h handle)
2120 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2121 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2122 __cleanup_appinfo(info);
2126 API int pkgmgrinfo_appinfo_filter_create(pkgmgrinfo_appinfo_filter_h *handle)
2128 return (pkgmgrinfo_pkginfo_filter_create(handle));
2131 API int pkgmgrinfo_appinfo_filter_destroy(pkgmgrinfo_appinfo_filter_h handle)
2133 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
2136 static gint __compare_func(gconstpointer data1, gconstpointer data2)
2138 pkgmgrinfo_node_x *node1 = (pkgmgrinfo_node_x *)data1;
2139 pkgmgrinfo_node_x *node2 = (pkgmgrinfo_node_x *)data2;
2140 if (node1->prop == node2->prop)
2142 else if (node1->prop > node2->prop)
2148 API int pkgmgrinfo_appinfo_filter_add_int(pkgmgrinfo_appinfo_filter_h handle,
2149 const char *property, const int value)
2151 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2152 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2153 char buf[PKG_VALUE_STRING_LEN_MAX] = {'\0'};
2155 GSList *link = NULL;
2157 prop = _pminfo_appinfo_convert_to_prop_int(property);
2158 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_INT ||
2159 prop > E_PMINFO_APPINFO_PROP_APP_MAX_INT) {
2160 _LOGE("Invalid Integer Property\n");
2161 return PMINFO_R_EINVAL;
2163 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2164 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1, sizeof(pkgmgrinfo_node_x));
2166 _LOGE("Out of Memory!!!\n");
2167 return PMINFO_R_ERROR;
2169 snprintf(buf, PKG_VALUE_STRING_LEN_MAX - 1, "%d", value);
2170 val = strndup(buf, PKG_VALUE_STRING_LEN_MAX - 1);
2172 _LOGE("Out of Memory\n");
2175 return PMINFO_R_ERROR;
2179 /*If API is called multiple times for same property, we should override the previous values.
2180 Last value set will be used for filtering.*/
2181 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2183 filter->list = g_slist_delete_link(filter->list, link);
2184 filter->list = g_slist_append(filter->list, (gpointer)node);
2189 API int pkgmgrinfo_appinfo_filter_add_bool(pkgmgrinfo_appinfo_filter_h handle,
2190 const char *property, const bool value)
2192 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2193 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2195 GSList *link = NULL;
2197 prop = _pminfo_appinfo_convert_to_prop_bool(property);
2198 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_BOOL ||
2199 prop > E_PMINFO_APPINFO_PROP_APP_MAX_BOOL) {
2200 _LOGE("Invalid Boolean Property\n");
2201 return PMINFO_R_EINVAL;
2203 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2204 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1, sizeof(pkgmgrinfo_node_x));
2206 _LOGE("Out of Memory!!!\n");
2207 return PMINFO_R_ERROR;
2210 val = strndup("true", 4);
2212 val = strndup("false", 5);
2214 _LOGE("Out of Memory\n");
2217 return PMINFO_R_ERROR;
2221 /*If API is called multiple times for same property, we should override the previous values.
2222 Last value set will be used for filtering.*/
2223 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2225 filter->list = g_slist_delete_link(filter->list, link);
2226 filter->list = g_slist_append(filter->list, (gpointer)node);
2231 API int pkgmgrinfo_appinfo_filter_add_string(pkgmgrinfo_appinfo_filter_h handle,
2232 const char *property, const char *value)
2234 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2235 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2236 retvm_if(value == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2238 pkgmgrinfo_node_x *ptr = NULL;
2239 char prev[PKG_STRING_LEN_MAX] = {'\0'};
2240 char temp[PKG_STRING_LEN_MAX] = {'\0'};
2241 GSList *link = NULL;
2244 prop = _pminfo_appinfo_convert_to_prop_str(property);
2245 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_STR ||
2246 prop > E_PMINFO_APPINFO_PROP_APP_MAX_STR) {
2247 _LOGE("Invalid String Property\n");
2248 return PMINFO_R_EINVAL;
2250 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2251 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1, sizeof(pkgmgrinfo_node_x));
2253 _LOGE("Out of Memory!!!\n");
2254 return PMINFO_R_ERROR;
2258 case E_PMINFO_APPINFO_PROP_APP_COMPONENT:
2259 node->value = strdup(value);
2260 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2262 filter->list = g_slist_delete_link(filter->list, link);
2263 filter->list = g_slist_append(filter->list, (gpointer)node);
2265 case E_PMINFO_APPINFO_PROP_APP_CATEGORY:
2266 val = (char *)calloc(1, PKG_STRING_LEN_MAX);
2268 _LOGE("Out of Memory\n");
2271 return PMINFO_R_ERROR;
2273 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2275 ptr = (pkgmgrinfo_node_x *)link->data;
2276 strncpy(prev, ptr->value, PKG_STRING_LEN_MAX - 1);
2277 _LOGI("Previous value is %s\n", prev);
2278 filter->list = g_slist_delete_link(filter->list, link);
2279 ret = snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s,%s", prev, value);
2280 if (ret < 0 || ret > PKG_STRING_LEN_MAX - 1) {
2281 _LOGE("snprintf fail\n");
2284 return PMINFO_R_ERROR;
2286 strncpy(val, temp, PKG_STRING_LEN_MAX);
2287 _LOGI("New value is %s\n", val);
2289 filter->list = g_slist_append(filter->list, (gpointer)node);
2290 memset(temp, '\0', PKG_STRING_LEN_MAX);
2292 snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s", value);
2293 strncpy(val, temp, PKG_STRING_LEN_MAX);
2294 _LOGI("First value is %s\n", val);
2296 filter->list = g_slist_append(filter->list, (gpointer)node);
2297 memset(temp, '\0', PKG_STRING_LEN_MAX);
2301 node->value = strndup(value, PKG_STRING_LEN_MAX - 1);
2302 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2304 filter->list = g_slist_delete_link(filter->list, link);
2305 filter->list = g_slist_append(filter->list, (gpointer)node);
2311 API int pkgmgrinfo_appinfo_usr_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count, uid_t uid)
2315 if (handle == NULL || count == NULL) {
2316 _LOGE("invalid parameter");
2317 return PMINFO_R_EINVAL;
2320 list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
2321 __free_applications);
2323 return PMINFO_R_ERROR;
2325 if (__check_disable_filter_exist(
2326 handle, E_APPINFO_DISABLE_TYPE_APP) == false) {
2327 if (pkgmgrinfo_appinfo_filter_add_bool(handle,
2328 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
2329 g_hash_table_destroy(list);
2330 return PMINFO_R_ERROR;
2334 if (__check_disable_filter_exist(
2335 handle, E_APPINFO_DISABLE_TYPE_PKG) == false) {
2336 if (pkgmgrinfo_appinfo_filter_add_bool(handle,
2337 PMINFO_APPINFO_PROP_PKG_DISABLE, false)) {
2338 g_hash_table_destroy(list);
2339 return PMINFO_R_ERROR;
2343 // TODO: use pkginfo-client APIs
2344 *count = g_hash_table_size(list);
2345 g_hash_table_destroy(list);
2350 API int pkgmgrinfo_appinfo_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count)
2352 return pkgmgrinfo_appinfo_usr_filter_count(handle, count, _getuid());
2355 API int pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(
2356 pkgmgrinfo_appinfo_filter_h handle,
2357 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
2359 if (handle == NULL || app_cb == NULL) {
2360 LOGE("invalid parameter");
2361 return PMINFO_R_EINVAL;
2364 if (__check_disable_filter_exist(
2365 handle, E_APPINFO_DISABLE_TYPE_APP) == false) {
2366 if (pkgmgrinfo_appinfo_filter_add_bool(handle,
2367 PMINFO_APPINFO_PROP_APP_DISABLE, false))
2368 return PMINFO_R_ERROR;
2371 if (__check_disable_filter_exist(
2372 handle, E_APPINFO_DISABLE_TYPE_PKG) == false) {
2373 if (pkgmgrinfo_appinfo_filter_add_bool(handle,
2374 PMINFO_APPINFO_PROP_PKG_DISABLE, false))
2375 return PMINFO_R_ERROR;
2378 return _appinfo_get_filtered_foreach_appinfo(uid, handle, PMINFO_APPINFO_GET_ALL, app_cb,
2382 API int pkgmgrinfo_appinfo_filter_foreach_appinfo(pkgmgrinfo_appinfo_filter_h handle,
2383 pkgmgrinfo_app_list_cb app_cb, void *user_data)
2385 return pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(handle, app_cb, user_data, _getuid());
2388 API int pkgmgrinfo_appinfo_metadata_filter_create(pkgmgrinfo_appinfo_metadata_filter_h *handle)
2390 return (pkgmgrinfo_pkginfo_filter_create(handle));
2393 API int pkgmgrinfo_appinfo_metadata_filter_destroy(pkgmgrinfo_appinfo_metadata_filter_h handle)
2395 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
2398 API int pkgmgrinfo_appinfo_metadata_filter_add(
2399 pkgmgrinfo_appinfo_metadata_filter_h handle,
2400 const char *key, const char *value)
2402 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2403 pkgmgrinfo_metadata_node_x *node;
2405 /* value can be NULL.
2406 * In that case all apps with specified key should be displayed
2409 LOGE("invalid parameter");
2410 return PMINFO_R_EINVAL;
2413 node = calloc(1, sizeof(pkgmgrinfo_metadata_node_x));
2415 LOGE("out of memory");
2416 return PMINFO_R_ERROR;
2419 node->key = strdup(key);
2420 if (value && strlen(value))
2421 node->value = strdup(value);
2423 filter->list_metadata = g_slist_append(filter->list_metadata,
2429 API int pkgmgrinfo_appinfo_usr_metadata_filter_foreach(
2430 pkgmgrinfo_appinfo_metadata_filter_h handle,
2431 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
2433 if (handle == NULL || app_cb == NULL) {
2434 LOGE("invalid parameter");
2435 return PMINFO_R_EINVAL;
2438 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2439 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
2440 PMINFO_APPINFO_PROP_APP_DISABLE, false))
2441 return PMINFO_R_ERROR;
2443 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
2444 PMINFO_APPINFO_PROP_PKG_DISABLE, false))
2445 return PMINFO_R_ERROR;
2447 return _appinfo_get_filtered_foreach_appinfo(uid, handle, PMINFO_APPINFO_GET_ALL, app_cb,
2451 API int pkgmgrinfo_appinfo_metadata_filter_foreach(
2452 pkgmgrinfo_appinfo_metadata_filter_h handle,
2453 pkgmgrinfo_app_list_cb app_cb, void *user_data)
2455 return pkgmgrinfo_appinfo_usr_metadata_filter_foreach(handle, app_cb,
2456 user_data, _getuid());
2459 API int pkgmgrinfo_appinfo_is_guestmode_visibility(pkgmgrinfo_appinfo_h handle, bool *status)
2462 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2464 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2465 retvm_if(status == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2467 val = info->app_info->guestmode_visibility;
2468 *status = _get_bool_value(val);
2472 API int pkgmgrinfo_appinfo_foreach_appcontrol_v2(pkgmgrinfo_appinfo_h handle,
2473 pkgmgrinfo_app_control_list_cb_v2 appcontrol_func,
2476 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2477 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2479 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2480 appcontrol_x *appcontrol;
2483 if (info->app_info == NULL)
2484 return PMINFO_R_ERROR;
2486 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
2487 appcontrol = (appcontrol_x *)tmp->data;
2488 if (appcontrol == NULL ||
2489 !strcasecmp(appcontrol->visibility, "remote-only"))
2491 ret = appcontrol_func(appcontrol->operation, appcontrol->uri,
2492 appcontrol->mime, appcontrol->id, user_data);
2500 API int pkgmgrinfo_appinfo_foreach_remote_appcontrol_v2(
2501 pkgmgrinfo_appinfo_h handle,
2502 pkgmgrinfo_app_control_list_cb_v2 appcontrol_func,
2505 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2506 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2508 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2509 appcontrol_x *appcontrol;
2512 if (info->app_info == NULL)
2513 return PMINFO_R_ERROR;
2515 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
2516 appcontrol = (appcontrol_x *)tmp->data;
2517 if (appcontrol == NULL ||
2518 !strcasecmp(appcontrol->visibility, "local-only"))
2520 ret = appcontrol_func(appcontrol->operation, appcontrol->uri,
2521 appcontrol->mime, appcontrol->id, user_data);