12 #include "pkgmgr-info.h"
13 #include "pkgmgrinfo_debug.h"
14 #include "pkgmgrinfo_private.h"
15 #include "pkgmgr_parser.h"
16 #include "manager/pkginfo_manager.h"
18 static bool _get_bool_value(const char *str)
20 if (str && !strcmp(str, "true"))
26 static void __cleanup_appinfo(pkgmgr_appinfo_x *data)
28 pkgmgr_appinfo_x *info = data;
32 free((void *)info->package);
34 free((void *)info->locale);
36 pkgmgrinfo_basic_free_application(info->app_info);
41 static void __free_applications(gpointer data)
43 pkgmgrinfo_basic_free_application((application_x *)data);
46 static gint __disable_chk_func(gconstpointer data1, gconstpointer data2)
48 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)data1;
49 pkgmgrinfo_appinfo_disable_type value = GPOINTER_TO_INT(data2);
51 if (value == E_APPINFO_DISABLE_TYPE_PKG)
52 return (node->prop == E_PMINFO_APPINFO_PROP_PKG_DISABLE)
55 return (node->prop == E_PMINFO_APPINFO_PROP_APP_DISABLE)
59 static bool __check_disable_filter_exist(pkgmgrinfo_filter_x *filter,
60 pkgmgrinfo_appinfo_disable_type type)
67 link = g_slist_find_custom(filter->list,
68 GINT_TO_POINTER(type), __disable_chk_func);
75 static int _pkgmgrinfo_get_appinfo(const char *appid, uid_t uid,
76 pkgmgrinfo_appinfo_filter_h filter, pkgmgrinfo_appinfo_h *handle)
78 int ret = PMINFO_R_OK;
80 pkgmgr_appinfo_x *info;
82 if (appid == NULL || filter == NULL || handle == NULL) {
83 LOGE("invalid parameter");
84 return PMINFO_R_EINVAL;
87 list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
90 return PMINFO_R_ERROR;
92 ret = _appinfo_get_applications(uid, filter,
93 PMINFO_APPINFO_GET_ALL, list);
94 if (ret != PMINFO_R_OK) {
95 g_hash_table_destroy(list);
99 if (!g_hash_table_size(list) || !g_hash_table_lookup(list, appid) ||
100 ((application_x *)g_hash_table_lookup(list, appid))->package == NULL) {
101 _LOGD("appinfo for [%s] is not existed for user [%d]",
103 g_hash_table_destroy(list);
104 return PMINFO_R_ENOENT;
107 info = calloc(1, sizeof(pkgmgr_appinfo_x));
109 _LOGE("out of memory");
110 g_hash_table_destroy(list);
111 return PMINFO_R_ERROR;
114 info->app_info = (application_x *)g_hash_table_lookup(list, appid);
115 info->locale = strdup(info->app_info->locale);
117 _LOGE("out of memory");
118 g_hash_table_destroy(list);
120 return PMINFO_R_ERROR;
122 info->package = strdup(info->app_info->package);
123 if (!info->package) {
124 _LOGE("out of memory");
126 g_hash_table_destroy(list);
128 return PMINFO_R_ERROR;
131 /* just free list only */
132 g_hash_table_steal(list, (gconstpointer)appid);
133 g_hash_table_destroy(list);
140 API int pkgmgrinfo_appinfo_get_usr_disabled_appinfo(
141 const char *appid, uid_t uid, pkgmgrinfo_appinfo_h *handle)
144 pkgmgrinfo_appinfo_filter_h filter;
146 if (appid == NULL || handle == NULL) {
147 LOGE("invalid parameter");
148 return PMINFO_R_EINVAL;
151 ret = pkgmgrinfo_appinfo_filter_create(&filter);
152 if (ret != PMINFO_R_OK)
155 ret = pkgmgrinfo_appinfo_filter_add_string(filter,
156 PMINFO_APPINFO_PROP_APP_ID, appid);
157 if (ret != PMINFO_R_OK) {
158 pkgmgrinfo_appinfo_filter_destroy(filter);
159 return PMINFO_R_ERROR;
162 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
163 PMINFO_APPINFO_PROP_APP_DISABLE, true);
164 if (ret != PMINFO_R_OK) {
165 pkgmgrinfo_appinfo_filter_destroy(filter);
166 return PMINFO_R_ERROR;
169 ret = _pkgmgrinfo_get_appinfo(appid, uid, filter, handle);
170 pkgmgrinfo_appinfo_filter_destroy(filter);
175 API int pkgmgrinfo_appinfo_get_disabled_appinfo(
176 const char *appid, pkgmgrinfo_appinfo_h *handle)
178 return pkgmgrinfo_appinfo_get_usr_disabled_appinfo(
179 appid, _getuid(), handle);
182 API int pkgmgrinfo_appinfo_get_usr_appinfo(const char *appid, uid_t uid,
183 pkgmgrinfo_appinfo_h *handle)
186 pkgmgrinfo_appinfo_filter_h filter;
188 if (appid == NULL || handle == NULL) {
189 LOGE("invalid parameter");
190 return PMINFO_R_EINVAL;
193 ret = pkgmgrinfo_appinfo_filter_create(&filter);
194 if (ret != PMINFO_R_OK)
197 ret = pkgmgrinfo_appinfo_filter_add_string(filter,
198 PMINFO_APPINFO_PROP_APP_ID, appid);
199 if (ret != PMINFO_R_OK) {
200 pkgmgrinfo_appinfo_filter_destroy(filter);
201 return PMINFO_R_ERROR;
204 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
205 PMINFO_APPINFO_PROP_APP_DISABLE, false);
206 if (ret != PMINFO_R_OK) {
207 pkgmgrinfo_appinfo_filter_destroy(filter);
208 return PMINFO_R_ERROR;
211 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
212 PMINFO_APPINFO_PROP_PKG_DISABLE, false);
213 if (ret != PMINFO_R_OK) {
214 pkgmgrinfo_appinfo_filter_destroy(filter);
215 return PMINFO_R_ERROR;
218 ret = _pkgmgrinfo_get_appinfo(appid, uid, filter, handle);
219 pkgmgrinfo_appinfo_filter_destroy(filter);
223 API int pkgmgrinfo_appinfo_get_appinfo(
224 const char *appid, pkgmgrinfo_appinfo_h *handle)
226 return pkgmgrinfo_appinfo_get_usr_appinfo(appid, _getuid(), handle);
229 API int pkgmgrinfo_appinfo_get_usr_all_appinfo(const char *appid, uid_t uid,
230 pkgmgrinfo_appinfo_h *handle)
233 pkgmgrinfo_appinfo_filter_h filter;
235 if (appid == NULL || handle == NULL) {
236 LOGE("invalid parameter");
237 return PMINFO_R_EINVAL;
240 ret = pkgmgrinfo_appinfo_filter_create(&filter);
241 if (ret != PMINFO_R_OK)
244 ret = pkgmgrinfo_appinfo_filter_add_string(filter,
245 PMINFO_APPINFO_PROP_APP_ID, appid);
246 if (ret != PMINFO_R_OK) {
247 pkgmgrinfo_appinfo_filter_destroy(filter);
248 return PMINFO_R_ERROR;
251 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
252 PMINFO_APPINFO_PROP_APP_CHECK_STORAGE, false);
253 if (ret != PMINFO_R_OK) {
254 pkgmgrinfo_appinfo_filter_destroy(filter);
255 return PMINFO_R_ERROR;
258 ret = _pkgmgrinfo_get_appinfo(appid, uid, filter, handle);
259 pkgmgrinfo_appinfo_filter_destroy(filter);
264 API int pkgmgrinfo_appinfo_get_all_appinfo(
265 const char *appid, pkgmgrinfo_appinfo_h *handle)
267 return pkgmgrinfo_appinfo_get_usr_all_appinfo(appid, _getuid(), handle);
270 static gpointer __copy_str(gconstpointer src, gpointer data)
272 const char *tmp = (const char *)src;
275 buffer = strdup(tmp);
276 if (buffer == NULL) {
277 LOGE("memory alloc failed");
285 static gpointer __copy_label(gconstpointer src, gpointer data)
287 label_x *tmp = (label_x *)src;
290 label = calloc(1, sizeof(label_x));
292 LOGE("memory alloc failed");
298 label->name = strdup(tmp->name);
300 label->text = strdup(tmp->text);
302 label->lang = strdup(tmp->lang);
307 static gpointer __copy_icon(gconstpointer src, gpointer data)
309 icon_x *tmp = (icon_x *)src;
312 icon = calloc(1, sizeof(icon_x));
314 LOGE("memory alloc failed");
320 icon->text = strdup(tmp->text);
322 icon->lang = strdup(tmp->lang);
324 icon->section = strdup(tmp->section);
326 icon->size = strdup(tmp->size);
328 icon->resolution = strdup(tmp->resolution);
333 static gpointer __copy_metadata(gconstpointer src, gpointer data)
335 metadata_x *tmp = (metadata_x *)src;
336 metadata_x *metadata;
338 metadata = calloc(1, sizeof(metadata_x));
339 if (metadata == NULL) {
340 LOGE("memory alloc failed");
346 metadata->key = strdup(tmp->key);
348 metadata->value = strdup(tmp->value);
353 static gpointer __copy_datacontrol(gconstpointer src, gpointer data)
355 datacontrol_x *tmp = (datacontrol_x *)src;
356 datacontrol_x *datacontrol;
358 datacontrol = calloc(1, sizeof(datacontrol_x));
359 if (datacontrol == NULL) {
360 LOGE("memory alloc failed");
366 datacontrol->providerid = strdup(tmp->providerid);
368 datacontrol->access = strdup(tmp->access);
370 datacontrol->type = strdup(tmp->type);
372 datacontrol->trusted = strdup(tmp->trusted);
377 static gpointer __copy_appcontrol(gconstpointer src, gpointer data)
379 appcontrol_x *tmp = (appcontrol_x *)src;
380 appcontrol_x *appcontrol;
382 appcontrol = calloc(1, sizeof(appcontrol_x));
383 if (appcontrol == NULL) {
384 LOGE("memory alloc failed");
390 appcontrol->operation = strdup(tmp->operation);
392 appcontrol->uri = strdup(tmp->uri);
394 appcontrol->mime = strdup(tmp->mime);
399 static gpointer __copy_splashscreens(gconstpointer src, gpointer data)
401 splashscreen_x *tmp = (splashscreen_x *)src;
402 splashscreen_x *splashscreen;
404 splashscreen = (splashscreen_x *)calloc(1, sizeof(splashscreen_x));
405 if (splashscreen == NULL) {
406 LOGE("memory alloc failed");
412 splashscreen->src = strdup(tmp->src);
414 splashscreen->type = strdup(tmp->type);
415 if (tmp->orientation)
416 splashscreen->orientation = strdup(tmp->orientation);
417 if (tmp->indicatordisplay)
418 splashscreen->indicatordisplay = strdup(tmp->indicatordisplay);
420 splashscreen->operation = strdup(tmp->operation);
421 if (tmp->color_depth)
422 splashscreen->color_depth = strdup(tmp->color_depth);
427 static gpointer __copy_res_control(gconstpointer src, gpointer data)
429 res_control_x *tmp = (res_control_x *)src;
430 res_control_x *res_control;
432 res_control = (res_control_x *)calloc(1, sizeof(res_control_x));
433 if (res_control == NULL) {
434 LOGE("memory alloc failed");
440 res_control->res_type = strdup(tmp->res_type);
441 if (tmp->min_res_version)
442 res_control->min_res_version = strdup(tmp->min_res_version);
443 if (tmp->max_res_version)
444 res_control->max_res_version = strdup(tmp->max_res_version);
446 res_control->auto_close = strdup(tmp->auto_close);
451 static int _appinfo_copy_appinfo(
452 application_x **application, application_x *data)
454 application_x *app_info;
457 app_info = calloc(1, sizeof(application_x));
458 if (app_info == NULL) {
459 LOGE("memory alloc failed");
460 return PMINFO_R_ERROR;
463 if (data->appid != NULL)
464 app_info->appid = strdup(data->appid);
465 if (data->exec != NULL)
466 app_info->exec = strdup(data->exec);
467 if (data->nodisplay != NULL)
468 app_info->nodisplay = strdup(data->nodisplay);
469 if (data->multiple != NULL)
470 app_info->multiple = strdup(data->multiple);
471 if (data->taskmanage != NULL)
472 app_info->taskmanage = strdup(data->taskmanage);
473 if (data->type != NULL)
474 app_info->type = strdup(data->type);
475 if (data->categories != NULL)
476 app_info->categories = strdup(data->categories);
477 if (data->hwacceleration != NULL)
478 app_info->hwacceleration = strdup(data->hwacceleration);
479 if (data->screenreader != NULL)
480 app_info->screenreader = strdup(data->screenreader);
481 if (data->mainapp != NULL)
482 app_info->mainapp = strdup(data->mainapp);
483 if (data->package != NULL)
484 app_info->package = strdup(data->package);
485 if (data->recentimage != NULL)
486 app_info->recentimage = strdup(data->recentimage);
487 if (data->launchcondition != NULL)
488 app_info->launchcondition = strdup(data->launchcondition);
489 if (data->indicatordisplay != NULL)
490 app_info->indicatordisplay = strdup(data->indicatordisplay);
491 if (data->portraitimg != NULL)
492 app_info->portraitimg = strdup(data->portraitimg);
493 if (data->landscapeimg != NULL)
494 app_info->landscapeimg = strdup(data->landscapeimg);
495 if (data->guestmode_visibility != NULL)
496 app_info->guestmode_visibility =
497 strdup(data->guestmode_visibility);
498 if (data->component != NULL)
499 app_info->component = strdup(data->component);
500 if (data->permission_type != NULL)
501 app_info->permission_type = strdup(data->permission_type);
502 if (data->component_type != NULL)
503 app_info->component_type = strdup(data->component_type);
504 if (data->preload != NULL)
505 app_info->preload = strdup(data->preload);
506 if (data->submode != NULL)
507 app_info->submode = strdup(data->submode);
508 if (data->submode_mainid != NULL)
509 app_info->submode_mainid = strdup(data->submode_mainid);
510 if (data->process_pool != NULL)
511 app_info->process_pool = strdup(data->process_pool);
512 if (data->installed_storage != NULL)
513 app_info->installed_storage = strdup(data->installed_storage);
514 if (data->autorestart != NULL)
515 app_info->autorestart = strdup(data->autorestart);
516 if (data->onboot != NULL)
517 app_info->onboot = strdup(data->onboot);
518 if (data->support_disable != NULL)
519 app_info->support_disable = strdup(data->support_disable);
520 if (data->ui_gadget != NULL)
521 app_info->ui_gadget = strdup(data->ui_gadget);
522 if (data->launch_mode != NULL)
523 app_info->launch_mode = strdup(data->launch_mode);
524 if (data->package_type != NULL)
525 app_info->package_type = strdup(data->package_type);
526 if (data->effective_appid != NULL)
527 app_info->effective_appid = strdup(data->effective_appid);
528 if (data->splash_screen_display != NULL)
529 app_info->splash_screen_display =
530 strdup(data->splash_screen_display);
534 app_info->label = g_list_copy_deep(data->label, __copy_label, &ret);
536 LOGE("memory alloc failed");
537 pkgmgrinfo_basic_free_application(app_info);
538 return PMINFO_R_ERROR;
542 app_info->icon = g_list_copy_deep(data->icon, __copy_icon, &ret);
544 LOGE("memory alloc failed");
545 pkgmgrinfo_basic_free_application(app_info);
546 return PMINFO_R_ERROR;
550 app_info->category = g_list_copy_deep(data->category, __copy_str, &ret);
552 LOGE("memory alloc failed");
553 pkgmgrinfo_basic_free_application(app_info);
554 return PMINFO_R_ERROR;
558 app_info->metadata = g_list_copy_deep(data->metadata,
559 __copy_metadata, &ret);
561 LOGE("memory alloc failed");
562 pkgmgrinfo_basic_free_application(app_info);
563 return PMINFO_R_ERROR;
567 app_info->datacontrol = g_list_copy_deep(data->datacontrol,
568 __copy_datacontrol, &ret);
570 LOGE("memory alloc failed");
571 pkgmgrinfo_basic_free_application(app_info);
572 return PMINFO_R_ERROR;
576 app_info->appcontrol = g_list_copy_deep(data->appcontrol,
577 __copy_appcontrol, &ret);
579 LOGE("memory alloc failed");
580 pkgmgrinfo_basic_free_application(app_info);
581 return PMINFO_R_ERROR;
585 app_info->background_category =
586 g_list_copy_deep(data->background_category,
589 LOGE("memory alloc failed");
590 pkgmgrinfo_basic_free_application(app_info);
591 return PMINFO_R_ERROR;
595 app_info->splashscreens = g_list_copy_deep(data->splashscreens,
596 __copy_splashscreens, &ret);
598 LOGE("memory alloc failed");
599 pkgmgrinfo_basic_free_application(app_info);
600 return PMINFO_R_ERROR;
604 app_info->res_control = g_list_copy_deep(data->res_control, __copy_res_control, &ret);
606 LOGE("memory alloc failed");
607 pkgmgrinfo_basic_free_application(app_info);
608 return PMINFO_R_ERROR;
611 *application = app_info;
616 API int pkgmgrinfo_appinfo_clone_appinfo(pkgmgrinfo_appinfo_h handle,
617 pkgmgrinfo_appinfo_h *clone)
619 pkgmgr_appinfo_x *info;
620 pkgmgr_appinfo_x *temp = (pkgmgr_appinfo_x *)handle;
623 return PMINFO_R_EINVAL;
625 info = calloc(1, sizeof(pkgmgr_appinfo_x));
627 LOGE("memory alloc failed");
628 return PMINFO_R_ERROR;
631 if (temp->package != NULL)
632 info->package = strdup(temp->package);
633 if (temp->locale != NULL)
634 info->locale = strdup(temp->locale);
636 info->app_component = temp->app_component;
638 if (_appinfo_copy_appinfo(&info->app_info, temp->app_info) < 0) {
639 LOGE("appinfo copy failed");
641 free((void *)info->package);
645 return PMINFO_R_ERROR;
653 static int _appinfo_get_filtered_foreach_appinfo(uid_t uid,
654 pkgmgrinfo_filter_x *filter, int flag,
655 pkgmgrinfo_app_list_cb app_list_cb,
659 pkgmgr_appinfo_x info;
665 list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
666 __free_applications);
668 return PMINFO_R_ERROR;
670 ret = _appinfo_get_applications(uid, filter,
671 flag | PMINFO_APPINFO_GET_BASICINFO, list);
672 if (ret == PMINFO_R_ERROR) {
673 g_hash_table_destroy(list);
677 g_hash_table_iter_init(&iter, list);
678 while (g_hash_table_iter_next(&iter, NULL, &value)) {
679 app = (application_x *)value;
681 info.locale = info.app_info->locale;
682 info.package = app->package;
683 if (app_list_cb(&info, user_data) < 0)
686 g_hash_table_destroy(list);
691 static const char *__appcomponent_str(pkgmgrinfo_app_component comp);
693 API int pkgmgrinfo_appinfo_get_usr_list(pkgmgrinfo_pkginfo_h handle,
694 pkgmgrinfo_app_component component,
695 pkgmgrinfo_app_list_cb app_func, void *user_data, uid_t uid)
698 pkgmgrinfo_appinfo_filter_h filter;
700 const char *comp_str = NULL;
702 if (handle == NULL || app_func == NULL) {
703 LOGE("invalid parameter");
704 return PMINFO_R_EINVAL;
707 if (pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid)) {
708 LOGE("invalid parameter");
709 return PMINFO_R_EINVAL;
712 if (pkgmgrinfo_appinfo_filter_create(&filter))
713 return PMINFO_R_ERROR;
715 if (pkgmgrinfo_appinfo_filter_add_string(filter,
716 PMINFO_APPINFO_PROP_APP_PACKAGE, pkgid)) {
717 pkgmgrinfo_appinfo_filter_destroy(filter);
718 return PMINFO_R_ERROR;
721 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
722 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
723 pkgmgrinfo_appinfo_filter_destroy(filter);
724 return PMINFO_R_ERROR;
727 comp_str = __appcomponent_str(component);
730 if (pkgmgrinfo_appinfo_filter_add_string(filter,
731 PMINFO_APPINFO_PROP_APP_COMPONENT,
733 pkgmgrinfo_appinfo_filter_destroy(filter);
734 return PMINFO_R_ERROR;
738 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter,
739 PMINFO_APPINFO_GET_ALL, app_func, user_data);
741 pkgmgrinfo_appinfo_filter_destroy(filter);
746 API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle,
747 pkgmgrinfo_app_component component,
748 pkgmgrinfo_app_list_cb app_func, void *user_data)
750 return pkgmgrinfo_appinfo_get_usr_list(handle,
751 component, app_func, user_data, _getuid());
754 API int pkgmgrinfo_appinfo_get_usr_installed_list_full(
755 pkgmgrinfo_app_list_cb app_func, uid_t uid, int flag,
759 pkgmgrinfo_appinfo_filter_h filter;
761 if (app_func == NULL) {
762 LOGE("invalid parameter");
763 return PMINFO_R_EINVAL;
766 if (pkgmgrinfo_appinfo_filter_create(&filter))
767 return PMINFO_R_ERROR;
769 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
770 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
771 pkgmgrinfo_appinfo_filter_destroy(filter);
772 return PMINFO_R_ERROR;
775 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
776 PMINFO_APPINFO_PROP_PKG_DISABLE, false)) {
777 pkgmgrinfo_appinfo_filter_destroy(filter);
778 return PMINFO_R_ERROR;
781 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
782 PMINFO_APPINFO_PROP_APP_CHECK_STORAGE, false)) {
783 pkgmgrinfo_appinfo_filter_destroy(filter);
784 return PMINFO_R_ERROR;
787 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter, flag, app_func,
790 pkgmgrinfo_appinfo_filter_destroy(filter);
795 API int pkgmgrinfo_appinfo_get_installed_list_full(
796 pkgmgrinfo_app_list_cb app_func, int flag, void *user_data)
798 return pkgmgrinfo_appinfo_get_usr_installed_list_full(app_func,
799 _getuid(), flag, user_data);
802 API int pkgmgrinfo_appinfo_get_usr_installed_list(
803 pkgmgrinfo_app_list_cb app_func, uid_t uid, void *user_data)
806 pkgmgrinfo_appinfo_filter_h filter;
808 if (app_func == NULL) {
809 LOGE("invalid parameter");
810 return PMINFO_R_EINVAL;
813 /* create an empty filter */
814 ret = pkgmgrinfo_appinfo_filter_create(&filter);
815 if (ret != PMINFO_R_OK)
818 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
819 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
820 pkgmgrinfo_appinfo_filter_destroy(filter);
821 return PMINFO_R_ERROR;
824 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
825 PMINFO_APPINFO_PROP_PKG_DISABLE, false)) {
826 pkgmgrinfo_appinfo_filter_destroy(filter);
827 return PMINFO_R_ERROR;
830 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter,
831 PMINFO_APPINFO_GET_ALL, app_func, user_data);
833 pkgmgrinfo_appinfo_filter_destroy(filter);
838 API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func,
841 return pkgmgrinfo_appinfo_get_usr_installed_list(app_func, _getuid(),
845 API int pkgmgrinfo_appinfo_get_appid(pkgmgrinfo_appinfo_h handle, char **appid)
847 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
849 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
850 retvm_if(appid == NULL, PMINFO_R_EINVAL,
851 "Argument supplied to hold return value is NULL");
853 if (info->app_info == NULL || info->app_info->appid == NULL)
854 return PMINFO_R_ERROR;
855 *appid = (char *)info->app_info->appid;
860 API int pkgmgrinfo_appinfo_get_pkgname(
861 pkgmgrinfo_appinfo_h handle, char **pkg_name)
863 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
865 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
866 retvm_if(pkg_name == NULL, PMINFO_R_EINVAL,
867 "Argument supplied to hold return value is NULL");
869 if (info->package == NULL)
870 return PMINFO_R_ERROR;
872 *pkg_name = (char *)info->package;
877 API int pkgmgrinfo_appinfo_get_pkgid(pkgmgrinfo_appinfo_h handle, char **pkgid)
879 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
881 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
882 retvm_if(pkgid == NULL, PMINFO_R_EINVAL,
883 "Argument supplied to hold return value is NULL");
885 if (info->package == NULL)
886 return PMINFO_R_ERROR;
888 *pkgid = (char *)info->package;
893 API int pkgmgrinfo_appinfo_get_pkgtype(
894 pkgmgrinfo_appinfo_h handle, char **pkgtype)
896 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
897 retvm_if(pkgtype == NULL, PMINFO_R_EINVAL,
898 "Argument supplied to hold return value is NULL");
899 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
901 *pkgtype = (char *)info->app_info->package_type;
906 API int pkgmgrinfo_appinfo_get_exec(pkgmgrinfo_appinfo_h handle, char **exec)
908 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
910 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
911 retvm_if(exec == NULL, PMINFO_R_EINVAL,
912 "Argument supplied to hold return value is NULL");
914 if (info->app_info == NULL || info->app_info->exec == NULL)
915 return PMINFO_R_ERROR;
916 *exec = (char *)info->app_info->exec;
922 API int pkgmgrinfo_appinfo_get_icon(pkgmgrinfo_appinfo_h handle, char **icon)
925 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
927 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
928 retvm_if(icon == NULL, PMINFO_R_EINVAL,
929 "Argument supplied to hold return value is NULL");
931 if (info->app_info == NULL)
932 return PMINFO_R_ERROR;
934 if (info->app_info->icon == NULL) {
939 ptr = (icon_x *)info->app_info->icon->data;
941 return PMINFO_R_ERROR;
943 if (ptr->text == NULL)
944 return PMINFO_R_ERROR;
952 API int pkgmgrinfo_appinfo_get_label(pkgmgrinfo_appinfo_h handle, char **label)
955 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
960 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
961 retvm_if(label == NULL, PMINFO_R_EINVAL,
962 "Argument supplied to hold return value is NULL");
964 if (info->app_info == NULL)
965 return PMINFO_R_ERROR;
967 locale = info->locale;
969 locale = DEFAULT_LOCALE;
971 for (tmp = info->app_info->label; tmp; tmp = tmp->next) {
972 ptr = (label_x *)tmp->data;
973 if (ptr == NULL || strcmp(locale, ptr->lang) != 0)
984 for (tmp = info->app_info->label; tmp; tmp = tmp->next) {
985 ptr = (label_x *)tmp->data;
986 if (ptr == NULL || strcmp(DEFAULT_LOCALE, ptr->lang) != 0)
992 *label = lbl ? lbl : "";
997 API int pkgmgrinfo_appinfo_usr_get_localed_label(const char *appid,
998 const char *locale, uid_t uid, char **label)
1002 retvm_if(appid == NULL || locale == NULL || label == NULL,
1003 PMINFO_R_EINVAL, "Argument is NULL");
1004 val = _appinfo_get_localed_label(appid, locale, uid);
1006 return PMINFO_R_ERROR;
1012 API int pkgmgrinfo_appinfo_get_localed_label(
1013 const char *appid, const char *locale, char **label)
1015 return pkgmgrinfo_appinfo_usr_get_localed_label(
1016 appid, locale, _getuid(), label);
1019 API int pkgmgrinfo_appinfo_get_metadata_value(
1020 pkgmgrinfo_appinfo_h handle, const char *metadata_key,
1021 char **metadata_value)
1023 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1024 retvm_if(metadata_key == NULL, PMINFO_R_EINVAL, "metadata_key is NULL");
1025 retvm_if(metadata_value == NULL, PMINFO_R_EINVAL,
1026 "metadata_value is NULL");
1028 GList *list_md = NULL;
1029 metadata_x *metadata = NULL;
1030 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1032 list_md = info->app_info->metadata;
1034 for (; list_md; list_md = list_md->next) {
1035 metadata = (metadata_x *)list_md->data;
1036 if (metadata && metadata->key) {
1037 if (strcasecmp(metadata->key, metadata_key) == 0) {
1038 if (metadata->value == NULL)
1039 *metadata_value = "";
1042 (char *)metadata->value;
1048 return PMINFO_R_EINVAL;
1051 static pkgmgrinfo_app_component __appcomponent_convert(const char *comp)
1053 if (strcasecmp(comp, "uiapp") == 0)
1054 return PMINFO_UI_APP;
1055 else if (strcasecmp(comp, "svcapp") == 0)
1056 return PMINFO_SVC_APP;
1057 else if (strcasecmp(comp, "widgetapp") == 0)
1058 return PMINFO_WIDGET_APP;
1059 else if (strcasecmp(comp, "watchapp") == 0)
1060 return PMINFO_WATCH_APP;
1061 else if (strcasecmp(comp, "componentbasedapp") == 0)
1062 return PMINFO_COMPONENT_BASED_APP;
1067 static const char *__appcomponent_str(pkgmgrinfo_app_component comp)
1072 case PMINFO_SVC_APP:
1074 case PMINFO_WIDGET_APP:
1076 case PMINFO_WATCH_APP:
1078 case PMINFO_COMPONENT_BASED_APP:
1079 return "componentbasedapp";
1085 API int pkgmgrinfo_appinfo_get_component(
1086 pkgmgrinfo_appinfo_h handle,
1087 pkgmgrinfo_app_component *component)
1089 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1092 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1093 retvm_if(component == NULL, PMINFO_R_EINVAL,
1094 "Argument supplied to hold return value is NULL");
1096 if (info->app_info == NULL)
1097 return PMINFO_R_ERROR;
1099 comp = __appcomponent_convert(info->app_info->component);
1101 return PMINFO_R_ERROR;
1108 API int pkgmgrinfo_appinfo_get_apptype(
1109 pkgmgrinfo_appinfo_h handle, char **app_type)
1111 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1113 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1114 retvm_if(app_type == NULL, PMINFO_R_EINVAL,
1115 "Argument supplied to hold return value is NULL");
1117 if (info->app_info == NULL || info->app_info->type == NULL)
1118 return PMINFO_R_ERROR;
1119 *app_type = (char *)info->app_info->type;
1124 API int pkgmgrinfo_appinfo_get_notification_icon(
1125 pkgmgrinfo_appinfo_h handle, char **icon)
1130 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1132 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1133 retvm_if(icon == NULL, PMINFO_R_EINVAL,
1134 "Argument supplied to hold return value is NULL\n");
1136 if (info->app_info == NULL)
1137 return PMINFO_R_ERROR;
1139 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1140 ptr = (icon_x *)tmp->data;
1141 if (ptr == NULL || ptr->section == NULL)
1144 val = (char *)ptr->section;
1145 if (val && strcmp(val, "notification") == 0) {
1146 *icon = (char *)ptr->text;
1151 return PMINFO_R_ERROR;
1154 API int pkgmgrinfo_appinfo_get_recent_image_type(
1155 pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_recentimage *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(type == NULL, PMINFO_R_EINVAL,
1162 "Argument supplied to hold return value is NULL");
1164 if (info->app_info == NULL || info->app_info->recentimage == NULL)
1165 return PMINFO_R_ERROR;
1167 val = (char *)info->app_info->recentimage;
1168 if (strcasecmp(val, "capture") == 0)
1169 *type = PMINFO_RECENTIMAGE_USE_CAPTURE;
1170 else if (strcasecmp(val, "icon") == 0)
1171 *type = PMINFO_RECENTIMAGE_USE_ICON;
1173 *type = PMINFO_RECENTIMAGE_USE_NOTHING;
1178 API int pkgmgrinfo_appinfo_get_preview_image(
1179 pkgmgrinfo_appinfo_h handle, char **preview_img)
1184 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1186 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1187 retvm_if(preview_img == NULL, PMINFO_R_EINVAL,
1188 "Argument supplied to hold return value is NULL\n");
1190 if (info->app_info == NULL)
1191 return PMINFO_R_ERROR;
1193 for (tmp = info->app_info->image; tmp; tmp = tmp->next) {
1194 ptr = (image_x *)tmp->data;
1195 if (ptr == NULL || ptr->section == NULL)
1198 val = (char *)ptr->section;
1199 if (val && strcmp(val, "preview") == 0) {
1200 *preview_img = (char *)ptr->text;
1205 return PMINFO_R_ERROR;
1208 API int pkgmgrinfo_appinfo_get_permission_type(
1209 pkgmgrinfo_appinfo_h handle,
1210 pkgmgrinfo_permission_type *permission)
1213 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1215 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1216 retvm_if(permission == NULL, PMINFO_R_EINVAL,
1217 "Argument supplied to hold return value is NULL\n");
1219 val = info->app_info->permission_type;
1221 return PMINFO_R_ERROR;
1223 if (strcmp(val, "signature") == 0)
1224 *permission = PMINFO_PERMISSION_SIGNATURE;
1225 else if (strcmp(val, "privilege") == 0)
1226 *permission = PMINFO_PERMISSION_PRIVILEGE;
1228 *permission = PMINFO_PERMISSION_NORMAL;
1233 API int pkgmgrinfo_appinfo_get_component_type(
1234 pkgmgrinfo_appinfo_h handle, char **component_type)
1236 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1238 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1239 retvm_if(component_type == NULL, PMINFO_R_EINVAL,
1240 "Argument supplied to hold return value is NULL");
1242 if (info->app_info == NULL || info->app_info->component_type == NULL)
1243 return PMINFO_R_ERROR;
1245 *component_type = (char *)info->app_info->component_type;
1250 API int pkgmgrinfo_appinfo_get_hwacceleration(
1251 pkgmgrinfo_appinfo_h handle,
1252 pkgmgrinfo_app_hwacceleration *hwacceleration)
1255 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1257 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1258 retvm_if(hwacceleration == NULL, PMINFO_R_EINVAL,
1259 "Argument supplied to hold return value is NULL");
1261 if (info->app_info == NULL || info->app_info->hwacceleration == NULL)
1262 return PMINFO_R_ERROR;
1264 val = (char *)info->app_info->hwacceleration;
1265 if (strcasecmp(val, "off") == 0)
1266 *hwacceleration = PMINFO_HWACCELERATION_OFF;
1267 else if (strcasecmp(val, "on") == 0)
1268 *hwacceleration = PMINFO_HWACCELERATION_ON;
1270 *hwacceleration = PMINFO_HWACCELERATION_DEFAULT;
1275 API int pkgmgrinfo_appinfo_get_screenreader(
1276 pkgmgrinfo_appinfo_h handle,
1277 pkgmgrinfo_app_screenreader *screenreader)
1280 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1282 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1283 retvm_if(screenreader == NULL, PMINFO_R_EINVAL,
1284 "Argument supplied to hold return value is NULL");
1286 if (info->app_info == NULL || info->app_info->screenreader == NULL)
1287 return PMINFO_R_ERROR;
1289 val = (char *)info->app_info->screenreader;
1290 if (strcasecmp(val, "screenreader-off") == 0)
1291 *screenreader = PMINFO_SCREENREADER_OFF;
1292 else if (strcasecmp(val, "screenreader-on") == 0)
1293 *screenreader = PMINFO_SCREENREADER_ON;
1295 *screenreader = PMINFO_SCREENREADER_USE_SYSTEM_SETTING;
1300 API int pkgmgrinfo_appinfo_get_effectimage(
1301 pkgmgrinfo_appinfo_h handle, char **portrait_img,
1302 char **landscape_img)
1304 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1306 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1307 retvm_if(portrait_img == NULL, PMINFO_R_EINVAL,
1308 "Argument supplied to hold return value is NULL");
1309 retvm_if(landscape_img == NULL, PMINFO_R_EINVAL,
1310 "Argument supplied to hold return value is NULL");
1312 if (info->app_info == NULL)
1313 return PMINFO_R_ERROR;
1315 if (info->app_info->portraitimg == NULL)
1318 *portrait_img = (char *)info->app_info->portraitimg;
1320 if (info->app_info->landscapeimg == NULL)
1321 *landscape_img = "";
1323 *landscape_img = (char *)info->app_info->landscapeimg;
1328 API int pkgmgrinfo_appinfo_get_effectimage_type(
1329 pkgmgrinfo_appinfo_h handle, char **effectimage_type)
1331 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1333 if (handle == NULL || effectimage_type == NULL) {
1334 LOGE("invalid parameter");
1335 return PMINFO_R_EINVAL;
1338 if (info->app_info == NULL || info->app_info->effectimage_type == NULL)
1339 return PMINFO_R_ERROR;
1341 *effectimage_type = (char *)info->app_info->effectimage_type;
1346 API int pkgmgrinfo_appinfo_get_submode_mainid(
1347 pkgmgrinfo_appinfo_h handle, char **submode_mainid)
1349 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1351 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1352 retvm_if(submode_mainid == NULL, PMINFO_R_EINVAL,
1353 "Argument supplied to hold return value is NULL");
1355 if (info->app_info == NULL)
1356 return PMINFO_R_ERROR;
1358 if (info->app_info->submode_mainid == NULL)
1359 *submode_mainid = "";
1361 *submode_mainid = (char *)info->app_info->submode_mainid;
1366 API int pkgmgrinfo_appinfo_get_installed_storage_location(
1367 pkgmgrinfo_appinfo_h handle,
1368 pkgmgrinfo_installed_storage *storage)
1370 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1371 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1373 if (info->app_info && info->app_info->installed_storage) {
1374 if (strcmp(info->app_info->installed_storage,
1375 "installed_internal") == 0)
1376 *storage = PMINFO_INTERNAL_STORAGE;
1377 else if (strcmp(info->app_info->installed_storage,
1378 "installed_external") == 0)
1379 *storage = PMINFO_EXTERNAL_STORAGE;
1381 return PMINFO_R_ERROR;
1383 return PMINFO_R_ERROR;
1389 API int pkgmgrinfo_appinfo_get_launch_mode(
1390 pkgmgrinfo_appinfo_h handle, char **mode)
1392 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1394 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1395 retvm_if(mode == NULL, PMINFO_R_EINVAL,
1396 "Argument supplied to hold return value is NULL\n");
1398 if (info->app_info->launch_mode == NULL)
1399 return PMINFO_R_ERROR;
1401 *mode = (char *)(info->app_info->launch_mode);
1406 API int pkgmgrinfo_appinfo_get_alias_appid(
1407 pkgmgrinfo_appinfo_h handle, char **alias_appid)
1409 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1411 if (handle == NULL || alias_appid == NULL) {
1412 LOGE("invalid parameter");
1413 return PMINFO_R_EINVAL;
1416 if (info->app_info == NULL || info->app_info->alias_appid == NULL)
1417 return PMINFO_R_ERROR;
1419 *alias_appid = (char *)info->app_info->alias_appid;
1424 API int pkgmgrinfo_appinfo_get_effective_appid(
1425 pkgmgrinfo_appinfo_h handle, char **effective_appid)
1427 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1429 if (handle == NULL || effective_appid == NULL) {
1430 LOGE("invalid parameter");
1431 return PMINFO_R_EINVAL;
1434 if (info->app_info == NULL)
1435 return PMINFO_R_ERROR;
1437 if (info->app_info->effective_appid == NULL)
1438 *effective_appid = "";
1440 *effective_appid = (char *)info->app_info->effective_appid;
1445 API int pkgmgrinfo_appinfo_get_tep_name(
1446 pkgmgrinfo_appinfo_h handle, char **tep_name)
1448 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1450 if (handle == NULL || tep_name == NULL) {
1451 LOGE("invalid parameter");
1452 return PMINFO_R_EINVAL;
1455 if (info->app_info == NULL)
1456 return PMINFO_R_ERROR;
1458 if (info->app_info->tep_name == NULL)
1461 *tep_name = (char *)info->app_info->tep_name;
1466 API int pkgmgrinfo_appinfo_get_zip_mount_file(
1467 pkgmgrinfo_appinfo_h handle, char **zip_mount_file)
1469 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1471 if (handle == NULL || zip_mount_file == NULL) {
1472 LOGE("invalid parameter");
1473 return PMINFO_R_EINVAL;
1476 if (info->app_info == NULL)
1477 return PMINFO_R_ERROR;
1479 if (info->app_info->zip_mount_file == NULL)
1480 *zip_mount_file = "";
1482 *zip_mount_file = (char *)info->app_info->zip_mount_file;
1487 API int pkgmgrinfo_appinfo_get_root_path(
1488 pkgmgrinfo_appinfo_h handle, char **root_path)
1490 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1492 if (handle == NULL || root_path == NULL) {
1493 LOGE("invalid parameter");
1494 return PMINFO_R_EINVAL;
1497 if (info->app_info == NULL || info->app_info->root_path == NULL)
1498 return PMINFO_R_ERROR;
1500 *root_path = (char *)info->app_info->root_path;
1505 API int pkgmgrinfo_appinfo_get_api_version(
1506 pkgmgrinfo_appinfo_h handle, char **api_version)
1508 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1510 if (handle == NULL || api_version == NULL) {
1511 LOGE("invalid parameter");
1512 return PMINFO_R_EINVAL;
1515 if (info->app_info == NULL || info->app_info->api_version == NULL)
1516 return PMINFO_R_ERROR;
1518 *api_version = (char *)info->app_info->api_version;
1523 API int pkgmgrinfo_appinfo_get_installed_time(
1524 pkgmgrinfo_appinfo_h handle, int *installed_time)
1526 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1528 if (handle == NULL || installed_time == NULL) {
1529 LOGE("invalid parameter");
1530 return PMINFO_R_EINVAL;
1533 if (info->app_info == NULL ||
1534 info->app_info->package_installed_time == NULL)
1535 return PMINFO_R_ERROR;
1537 *installed_time = atoi(info->app_info->package_installed_time);
1542 API int pkgmgrinfo_appinfo_usr_get_datacontrol_info(const char *providerid,
1543 const char *type, uid_t uid, char **appid, char **access)
1547 if (providerid == NULL || type == NULL || appid == NULL ||
1549 LOGE("invalid parameter");
1550 return PMINFO_R_EINVAL;
1553 ret = _appinfo_get_datacontrol_info(
1554 providerid, type, uid, appid, access);
1555 /* FIXME: It should return PMINFO_R_ENOENT but to keep previous
1556 * implementation, return PMINFO_R_ERROR. This should be
1559 if (ret == PMINFO_R_ENOENT) {
1560 LOGE("no datacontrol info of %s", providerid);
1561 ret = PMINFO_R_ERROR;
1567 API int pkgmgrinfo_appinfo_get_datacontrol_info(const char *providerid,
1568 const char *type, char **appid, char **access)
1570 return pkgmgrinfo_appinfo_usr_get_datacontrol_info(providerid,
1571 type, _getuid(), appid, access);
1574 API int pkgmgrinfo_appinfo_usr_get_datacontrol_appid(const char *providerid,
1575 uid_t uid, char **appid)
1579 if (providerid == NULL || appid == NULL) {
1580 LOGE("invalid parameter");
1581 return PMINFO_R_EINVAL;
1584 ret = _appinfo_get_datacontrol_appid(providerid, uid, appid);
1585 /* FIXME: It should return PMINFO_R_ENOENT but to keep previous
1586 * implementation, return PMINFO_R_ERROR. This should be
1589 if (ret == PMINFO_R_ENOENT) {
1590 LOGE("no datacontrol appid of %s", providerid);
1591 ret = PMINFO_R_ERROR;
1597 API int pkgmgrinfo_appinfo_get_datacontrol_appid(
1598 const char *providerid, char **appid)
1600 return pkgmgrinfo_appinfo_usr_get_datacontrol_appid(
1601 providerid, _getuid(), appid);
1604 API int pkgmgrinfo_appinfo_usr_get_datacontrol_trusted_info(
1605 const char *providerid, const char *type, uid_t uid,
1606 char **appid, bool *is_trusted)
1609 char *trusted = NULL;
1611 if (providerid == NULL || type == NULL || appid == NULL ||
1612 is_trusted == NULL) {
1613 LOGE("invalid parameter");
1614 return PMINFO_R_EINVAL;
1617 ret = _appinfo_get_datacontrol_trusted_info(providerid, type, uid,
1620 /* FIXME: It should return PMINFO_R_ENOENT but to keep previous
1621 * implementation, return PMINFO_R_ERROR. This should be
1624 if (ret == PMINFO_R_ENOENT) {
1625 LOGE("no datacontrol trusted info of %s", providerid);
1626 ret = PMINFO_R_ERROR;
1628 *is_trusted = _get_bool_value(trusted);
1634 API int pkgmgrinfo_appinfo_get_datacontrol_trsuted_info(const char *providerid,
1635 const char *type, char **appid, bool *is_trusted)
1637 return pkgmgrinfo_appinfo_usr_get_datacontrol_trusted_info(providerid,
1638 type, _getuid(), appid, is_trusted);
1641 API int pkgmgrinfo_appinfo_usr_foreach_datacontrol_privileges(
1642 const char *providerid, const char *type,
1643 pkgmgrinfo_pkg_privilege_list_cb privilege_func,
1644 void *user_data, uid_t uid)
1651 if (providerid == NULL || type == NULL || privilege_func == NULL) {
1652 LOGE("invalid parameter");
1653 return PMINFO_R_EINVAL;
1656 ret = _appinfo_get_datacontrol_privileges(providerid, type, uid, &list);
1657 if (ret == PMINFO_R_ERROR) {
1658 g_list_free_full(list, free);
1662 for (tmp = list; tmp != NULL; tmp = g_list_next(tmp)) {
1664 ret = privilege_func((char *)tmp->data, user_data);
1669 g_list_free_full(list, free);
1673 API int pkgmgrinfo_appinfo_foreach_datacontrol_privileges(
1674 const char *providerid, const char *type,
1675 pkgmgrinfo_pkg_privilege_list_cb privilege_func,
1678 return pkgmgrinfo_appinfo_usr_foreach_datacontrol_privileges(
1679 providerid, type, privilege_func, user_data, _getuid());
1682 API int pkgmgrinfo_appinfo_get_support_mode(
1683 pkgmgrinfo_appinfo_h handle, int *support_mode)
1685 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1686 retvm_if(support_mode == NULL, PMINFO_R_EINVAL,
1687 "Argument supplied to hold return value is NULL");
1689 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1691 if (info->app_info->support_mode)
1692 *support_mode = atoi(info->app_info->support_mode);
1699 API int pkgmgrinfo_appinfo_foreach_category(pkgmgrinfo_appinfo_h handle,
1700 pkgmgrinfo_app_category_list_cb category_func, void *user_data)
1702 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1703 retvm_if(category_func == NULL, PMINFO_R_EINVAL,
1704 "Callback function is NULL");
1706 const char *category;
1708 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1710 if (info->app_info == NULL)
1711 return PMINFO_R_ERROR;
1713 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
1714 category = (const char *)tmp->data;
1716 ret = category_func(category, user_data);
1724 API int pkgmgrinfo_appinfo_foreach_metadata(pkgmgrinfo_appinfo_h handle,
1725 pkgmgrinfo_app_metadata_list_cb metadata_func, void *user_data)
1727 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1728 retvm_if(metadata_func == NULL, PMINFO_R_EINVAL,
1729 "Callback function is NULL");
1733 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1735 if (info->app_info == NULL)
1736 return PMINFO_R_ERROR;
1738 for (tmp = info->app_info->metadata; tmp; tmp = tmp->next) {
1739 ptr = (metadata_x *)tmp->data;
1743 ret = metadata_func(ptr->key, ptr->value ?
1744 ptr->value : "", user_data);
1752 API int pkgmgrinfo_appinfo_usr_foreach_appcontrol_privileges(const char *appid,
1753 const char *operation,
1754 pkgmgrinfo_pkg_privilege_list_cb privilege_func,
1755 void *user_data, uid_t uid)
1758 GList *privilege_list = NULL;
1761 if (appid == NULL || operation == NULL || privilege_func == NULL) {
1762 LOGE("invalid parameter");
1763 return PMINFO_R_EINVAL;
1766 ret = _appinfo_get_appcontrol_privileges(appid, operation, uid,
1768 if (ret == PMINFO_R_ENOENT) {
1770 } else if (ret != PMINFO_R_OK) {
1771 g_list_free_full(privilege_list, free);
1775 for (tmp_list = privilege_list; tmp_list != NULL;
1776 tmp_list = g_list_next(tmp_list)) {
1777 ret = privilege_func((char *)tmp_list->data, user_data);
1782 g_list_free_full(privilege_list, free);
1786 API int pkgmgrinfo_appinfo_foreach_appcontrol_privileges(const char *appid,
1787 const char *operation,
1788 pkgmgrinfo_pkg_privilege_list_cb privilege_func,
1791 return pkgmgrinfo_appinfo_usr_foreach_appcontrol_privileges(appid,
1792 operation, privilege_func, user_data, _getuid());
1795 API int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
1796 pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
1798 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1799 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL,
1800 "Callback function is NULL");
1802 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1803 appcontrol_x *appcontrol;
1806 if (info->app_info == NULL)
1807 return PMINFO_R_ERROR;
1809 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
1810 appcontrol = (appcontrol_x *)tmp->data;
1811 if (appcontrol == NULL || !strcasecmp(
1812 appcontrol->visibility, "remote-only"))
1814 ret = appcontrol_func(appcontrol->operation,
1815 appcontrol->uri, appcontrol->mime, user_data);
1823 API int pkgmgrinfo_appinfo_foreach_remote_appcontrol(
1824 pkgmgrinfo_appinfo_h handle,
1825 pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
1827 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1828 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL,
1829 "Callback function is NULL");
1831 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1832 appcontrol_x *appcontrol;
1835 if (info->app_info == NULL)
1836 return PMINFO_R_ERROR;
1838 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
1839 appcontrol = (appcontrol_x *)tmp->data;
1840 if (appcontrol == NULL || !strcasecmp(
1841 appcontrol->visibility, "local-only"))
1843 ret = appcontrol_func(appcontrol->operation, appcontrol->uri,
1844 appcontrol->mime, user_data);
1852 API int pkgmgrinfo_appinfo_foreach_background_category(
1853 pkgmgrinfo_appinfo_h handle,
1854 pkgmgrinfo_app_background_category_list_cb category_func,
1857 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1861 if (handle == NULL || category_func == NULL || info->app_info == NULL) {
1862 LOGE("invalid parameter");
1863 return PMINFO_R_EINVAL;
1866 for (tmp = info->app_info->background_category; tmp; tmp = tmp->next) {
1867 category = (char *)tmp->data;
1868 if (category == NULL)
1871 if (category_func(category, user_data) < 0)
1878 API int pkgmgrinfo_appinfo_foreach_splash_screen(pkgmgrinfo_appinfo_h handle,
1879 pkgmgrinfo_app_splash_screen_list_cb splash_screen_func,
1882 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1883 splashscreen_x *splashscreen;
1887 if (info == NULL || info->app_info == NULL
1888 || splash_screen_func == NULL) {
1889 LOGE("invalid parameter");
1890 return PMINFO_R_EINVAL;
1893 for (tmp = info->app_info->splashscreens; tmp; tmp = tmp->next) {
1894 splashscreen = (splashscreen_x *)tmp->data;
1895 if (splashscreen == NULL)
1897 ret = splash_screen_func(splashscreen->src,
1899 splashscreen->orientation,
1900 splashscreen->indicatordisplay,
1901 splashscreen->operation,
1902 splashscreen->color_depth,
1911 API int pkgmgrinfo_appinfo_foreach_res_control(pkgmgrinfo_appinfo_h handle,
1912 pkgmgrinfo_app_res_control_list_cb res_control_func,
1915 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1916 retvm_if(res_control_func == NULL, PMINFO_R_EINVAL,
1917 "Callback function is NULL");
1919 res_control_x *res_control;
1921 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1923 if (info->app_info == NULL)
1924 return PMINFO_R_ERROR;
1926 for (tmp = info->app_info->res_control; tmp; tmp = tmp->next) {
1927 res_control = (res_control_x *)tmp->data;
1928 if (res_control == NULL)
1930 ret = res_control_func(res_control->res_type,
1931 res_control->min_res_version,
1932 res_control->max_res_version,
1933 res_control->auto_close,
1941 API int pkgmgrinfo_appinfo_is_nodisplay(
1942 pkgmgrinfo_appinfo_h handle, bool *nodisplay)
1944 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1945 retvm_if(nodisplay == NULL, PMINFO_R_EINVAL,
1946 "Argument supplied to hold return value is NULL");
1947 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1949 if (info->app_info == NULL || info->app_info->nodisplay == NULL)
1950 return PMINFO_R_ERROR;
1952 *nodisplay = _get_bool_value(info->app_info->nodisplay);
1957 API int pkgmgrinfo_appinfo_is_multiple(
1958 pkgmgrinfo_appinfo_h handle, bool *multiple)
1960 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1961 retvm_if(multiple == NULL, PMINFO_R_EINVAL,
1962 "Argument supplied to hold return value is NULL");
1963 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1965 if (info->app_info == NULL || info->app_info->multiple == NULL)
1966 return PMINFO_R_ERROR;
1968 *multiple = _get_bool_value(info->app_info->multiple);
1973 API int pkgmgrinfo_appinfo_is_indicator_display_allowed(
1974 pkgmgrinfo_appinfo_h handle, bool *indicator_disp)
1976 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1977 retvm_if(indicator_disp == NULL, PMINFO_R_EINVAL,
1978 "Argument supplied to hold return value is NULL");
1979 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1981 if (info->app_info == NULL || info->app_info->indicatordisplay == NULL)
1982 return PMINFO_R_ERROR;
1984 *indicator_disp = _get_bool_value(info->app_info->indicatordisplay);
1989 API int pkgmgrinfo_appinfo_is_taskmanage(
1990 pkgmgrinfo_appinfo_h handle, bool *taskmanage)
1992 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1993 retvm_if(taskmanage == NULL, PMINFO_R_EINVAL,
1994 "Argument supplied to hold return value is NULL");
1995 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1997 if (info->app_info == NULL || info->app_info->taskmanage == NULL)
1998 return PMINFO_R_ERROR;
2000 *taskmanage = _get_bool_value(info->app_info->taskmanage);
2005 API int pkgmgrinfo_appinfo_is_enabled(
2006 pkgmgrinfo_appinfo_h handle, bool *enabled)
2008 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2009 retvm_if(enabled == NULL, PMINFO_R_EINVAL,
2010 "Argument supplied to hold return value is NULL");
2011 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2013 if (info->app_info == NULL || info->app_info->is_disabled == NULL)
2014 return PMINFO_R_ERROR;
2016 *enabled = !_get_bool_value(info->app_info->is_disabled);
2021 API int pkgmgrinfo_appinfo_is_onboot(
2022 pkgmgrinfo_appinfo_h handle, bool *onboot)
2024 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2025 retvm_if(onboot == NULL, PMINFO_R_EINVAL,
2026 "Argument supplied to hold return value is NULL");
2027 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2029 if (info->app_info == NULL || info->app_info->onboot == NULL)
2030 return PMINFO_R_ERROR;
2032 *onboot = _get_bool_value(info->app_info->onboot);
2037 API int pkgmgrinfo_appinfo_is_autorestart(
2038 pkgmgrinfo_appinfo_h handle, bool *autorestart)
2040 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2041 retvm_if(autorestart == NULL, PMINFO_R_EINVAL,
2042 "Argument supplied to hold return value is NULL");
2043 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2045 if (info->app_info == NULL || info->app_info->autorestart == NULL)
2046 return PMINFO_R_ERROR;
2048 *autorestart = _get_bool_value(info->app_info->autorestart);
2053 API int pkgmgrinfo_appinfo_is_mainapp(
2054 pkgmgrinfo_appinfo_h handle, bool *mainapp)
2056 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2057 retvm_if(mainapp == NULL, PMINFO_R_EINVAL,
2058 "Argument supplied to hold return value is NULL");
2059 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2061 if (info->app_info == NULL || info->app_info->mainapp == NULL)
2062 return PMINFO_R_ERROR;
2064 *mainapp = _get_bool_value(info->app_info->mainapp);
2069 API int pkgmgrinfo_appinfo_is_preload(
2070 pkgmgrinfo_appinfo_h handle, bool *preload)
2072 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2073 retvm_if(preload == NULL, PMINFO_R_EINVAL,
2074 "Argument supplied to hold return value is NULL\n");
2075 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2077 if (info->app_info == NULL || info->app_info->preload == NULL)
2078 return PMINFO_R_ERROR;
2080 *preload = _get_bool_value(info->app_info->preload);
2085 API int pkgmgrinfo_appinfo_is_submode(
2086 pkgmgrinfo_appinfo_h handle, bool *submode)
2088 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2089 retvm_if(submode == NULL, PMINFO_R_EINVAL,
2090 "Argument supplied to hold return value is NULL\n");
2091 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2093 if (info->app_info == NULL || info->app_info->submode == NULL)
2094 return PMINFO_R_ERROR;
2096 *submode = _get_bool_value(info->app_info->submode);
2101 API int pkgmgrinfo_appinfo_is_process_pool(
2102 pkgmgrinfo_appinfo_h handle, bool *process_pool)
2104 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2106 if (handle == NULL || process_pool == NULL) {
2107 LOGE("invalid parameter");
2108 return PMINFO_R_EINVAL;
2111 if (info->app_info == NULL)
2112 return PMINFO_R_ERROR;
2114 *process_pool = _get_bool_value(info->app_info->process_pool);
2119 API int pkgmgrinfo_appinfo_is_category_exist(
2120 pkgmgrinfo_appinfo_h handle, const char *category, bool *exist)
2122 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2123 retvm_if(category == NULL, PMINFO_R_EINVAL, "category is NULL");
2124 retvm_if(exist == NULL, PMINFO_R_EINVAL, "exist is NULL");
2128 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2130 if (info->app_info == NULL)
2131 return PMINFO_R_ERROR;
2134 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
2135 val = (const char *)tmp->data;
2138 if (strcasecmp(val, category) == 0) {
2147 API int pkgmgrinfo_appinfo_is_ui_gadget(pkgmgrinfo_appinfo_h handle,
2150 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2152 if (info == NULL || info->app_info == NULL || ui_gadget == NULL) {
2153 _LOGE("invalid parameter");
2154 return PMINFO_R_EINVAL;
2156 if (info->app_info->ui_gadget == NULL)
2157 info->app_info->ui_gadget = strdup("false");
2159 *ui_gadget = _get_bool_value(info->app_info->ui_gadget);
2164 API int pkgmgrinfo_appinfo_is_support_disable(pkgmgrinfo_appinfo_h handle,
2165 bool *support_disable)
2167 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2169 if (info == NULL || info->app_info == NULL || support_disable == NULL) {
2170 _LOGE("invalid parameter");
2171 return PMINFO_R_EINVAL;
2174 *support_disable = _get_bool_value(info->app_info->support_disable);
2179 API int pkgmgrinfo_appinfo_is_removable(pkgmgrinfo_appinfo_h handle,
2182 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2184 if (info == NULL || info->app_info == NULL || removable == NULL) {
2185 _LOGE("invalid parameter");
2186 return PMINFO_R_EINVAL;
2189 *removable = _get_bool_value(info->app_info->removable);
2194 API int pkgmgrinfo_appinfo_is_system(pkgmgrinfo_appinfo_h handle, bool *system)
2196 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2198 if (info == NULL || info->app_info == NULL || system == NULL) {
2199 _LOGE("invalid parameter");
2200 return PMINFO_R_EINVAL;
2203 *system = _get_bool_value(info->app_info->package_system);
2208 API int pkgmgrinfo_appinfo_is_disabled(
2209 pkgmgrinfo_appinfo_h handle, bool *disabled)
2211 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2212 retvm_if(disabled == NULL, PMINFO_R_EINVAL,
2213 "Argument supplied to hold return value is NULL");
2214 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2216 if (info->app_info == NULL || info->app_info->is_disabled == NULL)
2217 return PMINFO_R_ERROR;
2219 *disabled = _get_bool_value(info->app_info->is_disabled);
2224 API int pkgmgrinfo_appinfo_is_global(pkgmgrinfo_appinfo_h handle, bool *global)
2226 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2228 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2229 retvm_if(global == NULL, PMINFO_R_EINVAL,
2230 "Argument supplied to hold return value is NULL\n");
2232 if (info->app_info == NULL || info->app_info->for_all_users == NULL)
2233 return PMINFO_R_ERROR;
2235 *global = _get_bool_value(info->app_info->for_all_users);
2240 API int pkgmgrinfo_appinfo_get_splash_screen_display(
2241 pkgmgrinfo_appinfo_h handle, bool *splash_screen_display)
2243 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2245 if (info == NULL || splash_screen_display == NULL) {
2246 _LOGE("Invalid parameter");
2247 return PMINFO_R_EINVAL;
2250 if (info->app_info == NULL ||
2251 info->app_info->splash_screen_display == NULL)
2252 return PMINFO_R_ERROR;
2254 *splash_screen_display =
2255 _get_bool_value(info->app_info->splash_screen_display);
2260 API int pkgmgrinfo_appinfo_get_setup_appid(
2261 pkgmgrinfo_appinfo_h handle, char **setup_appid)
2263 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2265 if (info == NULL || setup_appid == NULL) {
2266 _LOGE("Invalid parameter");
2267 return PMINFO_R_EINVAL;
2270 if (info->app_info == NULL || info->app_info->setup_appid == NULL)
2271 return PMINFO_R_ERROR;
2273 *setup_appid = info->app_info->setup_appid;
2277 API int pkgmgrinfo_appinfo_is_support_ambient(pkgmgrinfo_appinfo_h handle,
2278 bool *support_ambient)
2280 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2282 if (info == NULL || support_ambient == NULL) {
2283 _LOGE("Invalid parameter");
2284 return PMINFO_R_EINVAL;
2287 if (info->app_info == NULL || info->app_info->support_ambient == NULL)
2288 return PMINFO_R_ERROR;
2290 *support_ambient = _get_bool_value(info->app_info->support_ambient);
2295 API int pkgmgrinfo_appinfo_get_light_user_switch_mode(
2296 pkgmgrinfo_appinfo_h handle, char **mode)
2298 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2300 if (info == NULL || mode == NULL) {
2301 _LOGE("Invalid parameter");
2302 return PMINFO_R_EINVAL;
2305 if (info->app_info == NULL || info->app_info->light_user_switch_mode == NULL)
2306 return PMINFO_R_ERROR;
2308 *mode = info->app_info->light_user_switch_mode;
2313 API int pkgmgrinfo_appinfo_destroy_appinfo(pkgmgrinfo_appinfo_h handle)
2315 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2316 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2318 __cleanup_appinfo(info);
2322 API int pkgmgrinfo_appinfo_filter_create(pkgmgrinfo_appinfo_filter_h *handle)
2324 return pkgmgrinfo_pkginfo_filter_create(handle);
2327 API int pkgmgrinfo_appinfo_filter_destroy(pkgmgrinfo_appinfo_filter_h handle)
2329 return pkgmgrinfo_pkginfo_filter_destroy(handle);
2332 static gint __compare_func(gconstpointer data1, gconstpointer data2)
2334 pkgmgrinfo_node_x *node1 = (pkgmgrinfo_node_x *)data1;
2335 pkgmgrinfo_node_x *node2 = (pkgmgrinfo_node_x *)data2;
2337 if (node1->prop == node2->prop)
2339 else if (node1->prop > node2->prop)
2345 API int pkgmgrinfo_appinfo_filter_add_int(pkgmgrinfo_appinfo_filter_h handle,
2346 const char *property, const int value)
2348 retvm_if(handle == NULL, PMINFO_R_EINVAL,
2349 "Filter handle input parameter is NULL\n");
2350 retvm_if(property == NULL, PMINFO_R_EINVAL,
2351 "Filter handle input parameter is NULL\n");
2352 char buf[PKG_VALUE_STRING_LEN_MAX] = {'\0'};
2354 GSList *link = NULL;
2357 prop = _pminfo_appinfo_convert_to_prop_int(property);
2358 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_INT ||
2359 prop > E_PMINFO_APPINFO_PROP_APP_MAX_INT) {
2360 _LOGE("Invalid Integer Property\n");
2361 return PMINFO_R_EINVAL;
2363 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2364 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1,
2365 sizeof(pkgmgrinfo_node_x));
2367 _LOGE("Out of Memory!!!\n");
2368 return PMINFO_R_ERROR;
2370 snprintf(buf, PKG_VALUE_STRING_LEN_MAX - 1, "%d", value);
2371 val = strndup(buf, PKG_VALUE_STRING_LEN_MAX - 1);
2373 _LOGE("Out of Memory\n");
2376 return PMINFO_R_ERROR;
2382 * If API is called multiple times for same property,
2383 * we should override the previous values.
2384 * Last value set will be used for filtering.
2386 link = g_slist_find_custom(filter->list,
2387 (gconstpointer)node, __compare_func);
2389 _pkgmgrinfo_node_destroy(link->data);
2390 filter->list = g_slist_delete_link(filter->list, link);
2392 filter->list = g_slist_append(filter->list, (gpointer)node);
2397 API int pkgmgrinfo_appinfo_filter_add_bool(pkgmgrinfo_appinfo_filter_h handle,
2398 const char *property, const bool value)
2400 retvm_if(handle == NULL, PMINFO_R_EINVAL,
2401 "Filter handle input parameter is NULL\n");
2402 retvm_if(property == NULL, PMINFO_R_EINVAL,
2403 "Filter handle input parameter is NULL\n");
2405 GSList *link = NULL;
2408 prop = _pminfo_appinfo_convert_to_prop_bool(property);
2409 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_BOOL ||
2410 prop > E_PMINFO_APPINFO_PROP_APP_MAX_BOOL) {
2411 _LOGE("Invalid Boolean Property\n");
2412 return PMINFO_R_EINVAL;
2414 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2415 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1,
2416 sizeof(pkgmgrinfo_node_x));
2418 _LOGE("Out of Memory!!!\n");
2419 return PMINFO_R_ERROR;
2422 val = strndup("true", 4);
2424 val = strndup("false", 5);
2426 _LOGE("Out of Memory\n");
2429 return PMINFO_R_ERROR;
2434 * If API is called multiple times for same property,
2435 * we should override the previous values.
2436 * Last value set will be used for filtering.
2438 link = g_slist_find_custom(filter->list,
2439 (gconstpointer)node, __compare_func);
2441 _pkgmgrinfo_node_destroy(link->data);
2442 filter->list = g_slist_delete_link(filter->list, link);
2444 filter->list = g_slist_append(filter->list, (gpointer)node);
2449 API int pkgmgrinfo_appinfo_filter_add_string(pkgmgrinfo_appinfo_filter_h handle,
2450 const char *property, const char *value)
2452 retvm_if(handle == NULL, PMINFO_R_EINVAL,
2453 "Filter handle input parameter is NULL\n");
2454 retvm_if(property == NULL, PMINFO_R_EINVAL,
2455 "Filter handle input parameter is NULL\n");
2456 retvm_if(value == NULL, PMINFO_R_EINVAL,
2457 "Filter handle input parameter is NULL\n");
2459 pkgmgrinfo_node_x *ptr = NULL;
2460 char prev[PKG_STRING_LEN_MAX] = {'\0'};
2461 char temp[PKG_STRING_LEN_MAX] = {'\0'};
2462 GSList *link = NULL;
2466 prop = _pminfo_appinfo_convert_to_prop_str(property);
2467 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_STR ||
2468 prop > E_PMINFO_APPINFO_PROP_APP_MAX_STR) {
2469 _LOGE("Invalid String Property\n");
2470 return PMINFO_R_EINVAL;
2472 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2473 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1,
2474 sizeof(pkgmgrinfo_node_x));
2476 _LOGE("Out of Memory!!!\n");
2477 return PMINFO_R_ERROR;
2481 case E_PMINFO_APPINFO_PROP_APP_COMPONENT:
2482 node->value = strdup(value);
2483 link = g_slist_find_custom(filter->list,
2484 (gconstpointer)node, __compare_func);
2486 _pkgmgrinfo_node_destroy(link->data);
2487 filter->list = g_slist_delete_link(filter->list, link);
2489 filter->list = g_slist_append(filter->list, (gpointer)node);
2491 case E_PMINFO_APPINFO_PROP_APP_CATEGORY:
2492 val = (char *)calloc(1, PKG_STRING_LEN_MAX);
2494 _LOGE("Out of Memory\n");
2497 return PMINFO_R_ERROR;
2499 link = g_slist_find_custom(filter->list,
2500 (gconstpointer)node, __compare_func);
2502 ptr = (pkgmgrinfo_node_x *)link->data;
2503 strncpy(prev, ptr->value, PKG_STRING_LEN_MAX - 1);
2504 _LOGI("Previous value is %s\n", prev);
2505 _pkgmgrinfo_node_destroy(ptr);
2506 filter->list = g_slist_delete_link(filter->list, link);
2507 ret = snprintf(temp, PKG_STRING_LEN_MAX - 1,
2508 "%s,%s", prev, value);
2509 if (ret < 0 || ret > PKG_STRING_LEN_MAX - 1) {
2510 _LOGE("snprintf fail\n");
2513 return PMINFO_R_ERROR;
2515 strncpy(val, temp, PKG_STRING_LEN_MAX);
2516 _LOGI("New value is %s\n", val);
2518 filter->list = g_slist_append(
2519 filter->list, (gpointer)node);
2520 memset(temp, '\0', PKG_STRING_LEN_MAX);
2522 snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s", value);
2523 strncpy(val, temp, PKG_STRING_LEN_MAX);
2524 _LOGI("First value is %s\n", val);
2526 filter->list = g_slist_append(
2527 filter->list, (gpointer)node);
2528 memset(temp, '\0', PKG_STRING_LEN_MAX);
2532 node->value = strndup(value, PKG_STRING_LEN_MAX - 1);
2533 link = g_slist_find_custom(filter->list,
2534 (gconstpointer)node, __compare_func);
2536 _pkgmgrinfo_node_destroy(link->data);
2537 filter->list = g_slist_delete_link(filter->list, link);
2539 filter->list = g_slist_append(filter->list, (gpointer)node);
2545 API int pkgmgrinfo_appinfo_usr_filter_count(
2546 pkgmgrinfo_appinfo_filter_h handle, int *count, uid_t uid)
2551 pkgmgrinfo_filter_x *filter;
2553 if (handle == NULL || count == NULL) {
2554 _LOGE("invalid parameter");
2555 return PMINFO_R_EINVAL;
2558 filter = (pkgmgrinfo_filter_x *)handle;
2559 list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
2560 __free_applications);
2562 return PMINFO_R_ERROR;
2564 if (__check_disable_filter_exist(
2565 handle, E_APPINFO_DISABLE_TYPE_APP) == false) {
2566 if (pkgmgrinfo_appinfo_filter_add_bool(handle,
2567 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
2568 g_hash_table_destroy(list);
2569 return PMINFO_R_ERROR;
2573 if (__check_disable_filter_exist(
2574 handle, E_APPINFO_DISABLE_TYPE_PKG) == false) {
2575 if (pkgmgrinfo_appinfo_filter_add_bool(handle,
2576 PMINFO_APPINFO_PROP_PKG_DISABLE, false)) {
2577 g_hash_table_destroy(list);
2578 return PMINFO_R_ERROR;
2582 ret = _appinfo_get_applications(uid, filter, 0, list);
2583 query_count = g_hash_table_size(list);
2584 g_hash_table_destroy(list);
2585 if (ret == PMINFO_R_ERROR)
2588 *count = query_count;
2592 API int pkgmgrinfo_appinfo_filter_count(
2593 pkgmgrinfo_appinfo_filter_h handle, int *count)
2595 return pkgmgrinfo_appinfo_usr_filter_count(handle, count, _getuid());
2598 API int pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(
2599 pkgmgrinfo_appinfo_filter_h handle,
2600 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
2602 if (handle == NULL || app_cb == NULL) {
2603 LOGE("invalid parameter");
2604 return PMINFO_R_EINVAL;
2607 if (__check_disable_filter_exist(
2608 handle, E_APPINFO_DISABLE_TYPE_APP) == false) {
2609 if (pkgmgrinfo_appinfo_filter_add_bool(handle,
2610 PMINFO_APPINFO_PROP_APP_DISABLE, false))
2611 return PMINFO_R_ERROR;
2614 if (__check_disable_filter_exist(
2615 handle, E_APPINFO_DISABLE_TYPE_PKG) == false) {
2616 if (pkgmgrinfo_appinfo_filter_add_bool(handle,
2617 PMINFO_APPINFO_PROP_PKG_DISABLE, false))
2618 return PMINFO_R_ERROR;
2621 return _appinfo_get_filtered_foreach_appinfo(uid,
2622 handle, PMINFO_APPINFO_GET_ALL, app_cb, user_data);
2625 API int pkgmgrinfo_appinfo_filter_foreach_appinfo(
2626 pkgmgrinfo_appinfo_filter_h handle,
2627 pkgmgrinfo_app_list_cb app_cb, void *user_data)
2629 return pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(
2630 handle, app_cb, user_data, _getuid());
2633 API int pkgmgrinfo_appinfo_metadata_filter_create(
2634 pkgmgrinfo_appinfo_metadata_filter_h *handle)
2636 return pkgmgrinfo_pkginfo_filter_create(handle);
2639 API int pkgmgrinfo_appinfo_metadata_filter_destroy(
2640 pkgmgrinfo_appinfo_metadata_filter_h handle)
2642 return pkgmgrinfo_pkginfo_filter_destroy(handle);
2645 API int pkgmgrinfo_appinfo_metadata_filter_add(
2646 pkgmgrinfo_appinfo_metadata_filter_h handle,
2647 const char *key, const char *value)
2649 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2650 pkgmgrinfo_metadata_node_x *node;
2652 /* value can be NULL.
2653 * In that case all apps with specified key should be displayed
2656 LOGE("invalid parameter");
2657 return PMINFO_R_EINVAL;
2660 node = calloc(1, sizeof(pkgmgrinfo_metadata_node_x));
2662 LOGE("out of memory");
2663 return PMINFO_R_ERROR;
2666 node->key = strdup(key);
2667 if (value && strlen(value))
2668 node->value = strdup(value);
2670 filter->list_metadata = g_slist_append(filter->list_metadata,
2676 API int pkgmgrinfo_appinfo_usr_metadata_filter_foreach(
2677 pkgmgrinfo_appinfo_metadata_filter_h handle,
2678 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
2680 if (handle == NULL || app_cb == NULL) {
2681 LOGE("invalid parameter");
2682 return PMINFO_R_EINVAL;
2685 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2687 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
2688 PMINFO_APPINFO_PROP_APP_DISABLE, false))
2689 return PMINFO_R_ERROR;
2691 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
2692 PMINFO_APPINFO_PROP_PKG_DISABLE, false))
2693 return PMINFO_R_ERROR;
2695 return _appinfo_get_filtered_foreach_appinfo(uid, handle,
2696 PMINFO_APPINFO_GET_ALL, app_cb,
2700 API int pkgmgrinfo_appinfo_metadata_filter_foreach(
2701 pkgmgrinfo_appinfo_metadata_filter_h handle,
2702 pkgmgrinfo_app_list_cb app_cb, void *user_data)
2704 return pkgmgrinfo_appinfo_usr_metadata_filter_foreach(handle, app_cb,
2705 user_data, _getuid());
2708 API int pkgmgrinfo_appinfo_is_guestmode_visibility(
2709 pkgmgrinfo_appinfo_h handle, bool *status)
2712 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2714 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2715 retvm_if(status == NULL, PMINFO_R_EINVAL,
2716 "Argument supplied to hold return value is NULL\n");
2718 val = info->app_info->guestmode_visibility;
2719 *status = _get_bool_value(val);
2723 API int pkgmgrinfo_appinfo_foreach_appcontrol_v2(pkgmgrinfo_appinfo_h handle,
2724 pkgmgrinfo_app_control_list_cb_v2 appcontrol_func,
2727 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2728 retvm_if(appcontrol_func == NULL,
2729 PMINFO_R_EINVAL, "Callback function is NULL");
2731 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2732 appcontrol_x *appcontrol;
2735 if (info->app_info == NULL)
2736 return PMINFO_R_ERROR;
2738 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
2739 appcontrol = (appcontrol_x *)tmp->data;
2740 if (appcontrol == NULL ||
2741 !strcasecmp(appcontrol->visibility,
2744 ret = appcontrol_func(appcontrol->operation, appcontrol->uri,
2745 appcontrol->mime, appcontrol->id, user_data);
2753 API int pkgmgrinfo_appinfo_foreach_remote_appcontrol_v2(
2754 pkgmgrinfo_appinfo_h handle,
2755 pkgmgrinfo_app_control_list_cb_v2 appcontrol_func,
2758 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2759 retvm_if(appcontrol_func == NULL,
2760 PMINFO_R_EINVAL, "Callback function is NULL");
2762 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2763 appcontrol_x *appcontrol;
2766 if (info->app_info == NULL)
2767 return PMINFO_R_ERROR;
2769 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
2770 appcontrol = (appcontrol_x *)tmp->data;
2771 if (appcontrol == NULL ||
2772 !strcasecmp(appcontrol->visibility,
2775 ret = appcontrol_func(appcontrol->operation, appcontrol->uri,
2776 appcontrol->mime, appcontrol->id, user_data);