13 #include "pkgmgr-info.h"
14 #include "pkgmgrinfo_debug.h"
15 #include "pkgmgrinfo_private.h"
16 #include "pkgmgr_parser.h"
17 #include "manager/pkginfo_manager.h"
19 static bool _get_bool_value(const char *str)
21 if (str && !strcmp(str, "true"))
27 static void __cleanup_appinfo(pkgmgr_appinfo_x *data)
29 pkgmgr_appinfo_x *info = data;
33 free((void *)info->package);
35 free((void *)info->locale);
37 pkgmgrinfo_basic_free_application(info->app_info);
42 static void __free_applications(gpointer data)
44 pkgmgrinfo_basic_free_application((application_x *)data);
47 static gint __disable_chk_func(gconstpointer data1, gconstpointer data2)
49 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)data1;
50 pkgmgrinfo_appinfo_disable_type value = GPOINTER_TO_INT(data2);
52 if (value == E_APPINFO_DISABLE_TYPE_PKG)
53 return (node->prop == E_PMINFO_APPINFO_PROP_PKG_DISABLE)
56 return (node->prop == E_PMINFO_APPINFO_PROP_APP_DISABLE)
60 static bool __check_disable_filter_exist(pkgmgrinfo_filter_x *filter,
61 pkgmgrinfo_appinfo_disable_type type)
68 link = g_slist_find_custom(filter->list,
69 GINT_TO_POINTER(type), __disable_chk_func);
76 static int _pkgmgrinfo_get_appinfo(const char *appid, uid_t uid,
77 pkgmgrinfo_appinfo_filter_h filter, pkgmgrinfo_appinfo_h *handle)
79 int ret = PMINFO_R_OK;
81 pkgmgr_appinfo_x *info;
83 if (appid == NULL || filter == NULL || handle == NULL) {
84 LOGE("invalid parameter");
85 return PMINFO_R_EINVAL;
88 list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
91 return PMINFO_R_ERROR;
93 ret = _appinfo_get_applications(uid, filter,
94 PMINFO_APPINFO_GET_ALL, list);
95 if (ret != PMINFO_R_OK) {
96 g_hash_table_destroy(list);
100 if (!g_hash_table_size(list) || !g_hash_table_lookup(list, appid) ||
101 ((application_x *)g_hash_table_lookup(list, appid))->package == NULL) {
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 info->locale = strdup(info->app_info->locale);
118 _LOGE("out of memory");
119 g_hash_table_destroy(list);
121 return PMINFO_R_ERROR;
123 info->package = strdup(info->app_info->package);
124 if (!info->package) {
125 _LOGE("out of memory");
127 g_hash_table_destroy(list);
129 return PMINFO_R_ERROR;
132 /* just free list only */
133 g_hash_table_steal(list, (gconstpointer)appid);
134 g_hash_table_destroy(list);
141 API int pkgmgrinfo_appinfo_get_usr_disabled_appinfo(
142 const char *appid, uid_t uid, pkgmgrinfo_appinfo_h *handle)
145 pkgmgrinfo_appinfo_filter_h filter;
147 if (appid == NULL || handle == NULL) {
148 LOGE("invalid parameter");
149 return PMINFO_R_EINVAL;
152 ret = pkgmgrinfo_appinfo_filter_create(&filter);
153 if (ret != PMINFO_R_OK)
156 ret = pkgmgrinfo_appinfo_filter_add_string(filter,
157 PMINFO_APPINFO_PROP_APP_ID, appid);
158 if (ret != PMINFO_R_OK) {
159 pkgmgrinfo_appinfo_filter_destroy(filter);
160 return PMINFO_R_ERROR;
163 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
164 PMINFO_APPINFO_PROP_APP_DISABLE, true);
165 if (ret != PMINFO_R_OK) {
166 pkgmgrinfo_appinfo_filter_destroy(filter);
167 return PMINFO_R_ERROR;
170 ret = _pkgmgrinfo_get_appinfo(appid, uid, filter, handle);
171 pkgmgrinfo_appinfo_filter_destroy(filter);
176 API int pkgmgrinfo_appinfo_get_disabled_appinfo(
177 const char *appid, pkgmgrinfo_appinfo_h *handle)
179 return pkgmgrinfo_appinfo_get_usr_disabled_appinfo(
180 appid, _getuid(), handle);
183 API int pkgmgrinfo_appinfo_get_usr_appinfo(const char *appid, uid_t uid,
184 pkgmgrinfo_appinfo_h *handle)
187 pkgmgrinfo_appinfo_filter_h filter;
189 if (appid == NULL || handle == NULL) {
190 LOGE("invalid parameter");
191 return PMINFO_R_EINVAL;
194 ret = pkgmgrinfo_appinfo_filter_create(&filter);
195 if (ret != PMINFO_R_OK)
198 ret = pkgmgrinfo_appinfo_filter_add_string(filter,
199 PMINFO_APPINFO_PROP_APP_ID, appid);
200 if (ret != PMINFO_R_OK) {
201 pkgmgrinfo_appinfo_filter_destroy(filter);
202 return PMINFO_R_ERROR;
205 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
206 PMINFO_APPINFO_PROP_APP_DISABLE, false);
207 if (ret != PMINFO_R_OK) {
208 pkgmgrinfo_appinfo_filter_destroy(filter);
209 return PMINFO_R_ERROR;
212 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
213 PMINFO_APPINFO_PROP_PKG_DISABLE, false);
214 if (ret != PMINFO_R_OK) {
215 pkgmgrinfo_appinfo_filter_destroy(filter);
216 return PMINFO_R_ERROR;
219 ret = _pkgmgrinfo_get_appinfo(appid, uid, filter, handle);
220 pkgmgrinfo_appinfo_filter_destroy(filter);
224 API int pkgmgrinfo_appinfo_get_appinfo(
225 const char *appid, pkgmgrinfo_appinfo_h *handle)
227 return pkgmgrinfo_appinfo_get_usr_appinfo(appid, _getuid(), handle);
230 API int pkgmgrinfo_appinfo_get_usr_all_appinfo(const char *appid, uid_t uid,
231 pkgmgrinfo_appinfo_h *handle)
234 pkgmgrinfo_appinfo_filter_h filter;
236 if (appid == NULL || handle == NULL) {
237 LOGE("invalid parameter");
238 return PMINFO_R_EINVAL;
241 ret = pkgmgrinfo_appinfo_filter_create(&filter);
242 if (ret != PMINFO_R_OK)
245 ret = pkgmgrinfo_appinfo_filter_add_string(filter,
246 PMINFO_APPINFO_PROP_APP_ID, appid);
247 if (ret != PMINFO_R_OK) {
248 pkgmgrinfo_appinfo_filter_destroy(filter);
249 return PMINFO_R_ERROR;
252 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
253 PMINFO_APPINFO_PROP_APP_CHECK_STORAGE, false);
254 if (ret != PMINFO_R_OK) {
255 pkgmgrinfo_appinfo_filter_destroy(filter);
256 return PMINFO_R_ERROR;
259 ret = _pkgmgrinfo_get_appinfo(appid, uid, filter, handle);
260 pkgmgrinfo_appinfo_filter_destroy(filter);
265 API int pkgmgrinfo_appinfo_get_all_appinfo(
266 const char *appid, pkgmgrinfo_appinfo_h *handle)
268 return pkgmgrinfo_appinfo_get_usr_all_appinfo(appid, _getuid(), handle);
271 static gpointer __copy_str(gconstpointer src, gpointer data)
273 const char *tmp = (const char *)src;
276 buffer = strdup(tmp);
277 if (buffer == NULL) {
278 LOGE("memory alloc failed");
286 static gpointer __copy_label(gconstpointer src, gpointer data)
288 label_x *tmp = (label_x *)src;
291 label = calloc(1, sizeof(label_x));
293 LOGE("memory alloc failed");
299 label->name = strdup(tmp->name);
301 label->text = strdup(tmp->text);
303 label->lang = strdup(tmp->lang);
308 static gpointer __copy_icon(gconstpointer src, gpointer data)
310 icon_x *tmp = (icon_x *)src;
313 icon = calloc(1, sizeof(icon_x));
315 LOGE("memory alloc failed");
321 icon->text = strdup(tmp->text);
323 icon->lang = strdup(tmp->lang);
325 icon->section = strdup(tmp->section);
327 icon->size = strdup(tmp->size);
329 icon->resolution = strdup(tmp->resolution);
334 static gpointer __copy_metadata(gconstpointer src, gpointer data)
336 metadata_x *tmp = (metadata_x *)src;
337 metadata_x *metadata;
339 metadata = calloc(1, sizeof(metadata_x));
340 if (metadata == NULL) {
341 LOGE("memory alloc failed");
347 metadata->key = strdup(tmp->key);
349 metadata->value = strdup(tmp->value);
354 static gpointer __copy_datacontrol(gconstpointer src, gpointer data)
356 datacontrol_x *tmp = (datacontrol_x *)src;
357 datacontrol_x *datacontrol;
359 datacontrol = calloc(1, sizeof(datacontrol_x));
360 if (datacontrol == NULL) {
361 LOGE("memory alloc failed");
367 datacontrol->providerid = strdup(tmp->providerid);
369 datacontrol->access = strdup(tmp->access);
371 datacontrol->type = strdup(tmp->type);
373 datacontrol->trusted = strdup(tmp->trusted);
378 static gpointer __copy_appcontrol(gconstpointer src, gpointer data)
380 appcontrol_x *tmp = (appcontrol_x *)src;
381 appcontrol_x *appcontrol;
383 appcontrol = calloc(1, sizeof(appcontrol_x));
384 if (appcontrol == NULL) {
385 LOGE("memory alloc failed");
391 appcontrol->operation = strdup(tmp->operation);
393 appcontrol->uri = strdup(tmp->uri);
395 appcontrol->mime = strdup(tmp->mime);
400 static gpointer __copy_splashscreens(gconstpointer src, gpointer data)
402 splashscreen_x *tmp = (splashscreen_x *)src;
403 splashscreen_x *splashscreen;
405 splashscreen = (splashscreen_x *)calloc(1, sizeof(splashscreen_x));
406 if (splashscreen == NULL) {
407 LOGE("memory alloc failed");
413 splashscreen->src = strdup(tmp->src);
415 splashscreen->type = strdup(tmp->type);
416 if (tmp->orientation)
417 splashscreen->orientation = strdup(tmp->orientation);
418 if (tmp->indicatordisplay)
419 splashscreen->indicatordisplay = strdup(tmp->indicatordisplay);
421 splashscreen->operation = strdup(tmp->operation);
422 if (tmp->color_depth)
423 splashscreen->color_depth = strdup(tmp->color_depth);
428 static gpointer __copy_res_control(gconstpointer src, gpointer data)
430 res_control_x *tmp = (res_control_x *)src;
431 res_control_x *res_control;
433 res_control = (res_control_x *)calloc(1, sizeof(res_control_x));
434 if (res_control == NULL) {
435 LOGE("memory alloc failed");
441 res_control->res_type = strdup(tmp->res_type);
442 if (tmp->min_res_version)
443 res_control->min_res_version = strdup(tmp->min_res_version);
444 if (tmp->max_res_version)
445 res_control->max_res_version = strdup(tmp->max_res_version);
447 res_control->auto_close = strdup(tmp->auto_close);
452 static int _appinfo_copy_appinfo(
453 application_x **application, application_x *data)
455 application_x *app_info;
458 app_info = calloc(1, sizeof(application_x));
459 if (app_info == NULL) {
460 LOGE("memory alloc failed");
461 return PMINFO_R_ERROR;
464 if (data->appid != NULL)
465 app_info->appid = strdup(data->appid);
466 if (data->exec != NULL)
467 app_info->exec = strdup(data->exec);
468 if (data->nodisplay != NULL)
469 app_info->nodisplay = strdup(data->nodisplay);
470 if (data->multiple != NULL)
471 app_info->multiple = strdup(data->multiple);
472 if (data->taskmanage != NULL)
473 app_info->taskmanage = strdup(data->taskmanage);
474 if (data->type != NULL)
475 app_info->type = strdup(data->type);
476 if (data->categories != NULL)
477 app_info->categories = strdup(data->categories);
478 if (data->hwacceleration != NULL)
479 app_info->hwacceleration = strdup(data->hwacceleration);
480 if (data->screenreader != NULL)
481 app_info->screenreader = strdup(data->screenreader);
482 if (data->mainapp != NULL)
483 app_info->mainapp = strdup(data->mainapp);
484 if (data->package != NULL)
485 app_info->package = strdup(data->package);
486 if (data->recentimage != NULL)
487 app_info->recentimage = strdup(data->recentimage);
488 if (data->launchcondition != NULL)
489 app_info->launchcondition = strdup(data->launchcondition);
490 if (data->indicatordisplay != NULL)
491 app_info->indicatordisplay = strdup(data->indicatordisplay);
492 if (data->portraitimg != NULL)
493 app_info->portraitimg = strdup(data->portraitimg);
494 if (data->landscapeimg != NULL)
495 app_info->landscapeimg = strdup(data->landscapeimg);
496 if (data->guestmode_visibility != NULL)
497 app_info->guestmode_visibility =
498 strdup(data->guestmode_visibility);
499 if (data->component != NULL)
500 app_info->component = strdup(data->component);
501 if (data->permission_type != NULL)
502 app_info->permission_type = strdup(data->permission_type);
503 if (data->component_type != NULL)
504 app_info->component_type = strdup(data->component_type);
505 if (data->preload != NULL)
506 app_info->preload = strdup(data->preload);
507 if (data->submode != NULL)
508 app_info->submode = strdup(data->submode);
509 if (data->submode_mainid != NULL)
510 app_info->submode_mainid = strdup(data->submode_mainid);
511 if (data->process_pool != NULL)
512 app_info->process_pool = strdup(data->process_pool);
513 if (data->installed_storage != NULL)
514 app_info->installed_storage = strdup(data->installed_storage);
515 if (data->autorestart != NULL)
516 app_info->autorestart = strdup(data->autorestart);
517 if (data->onboot != NULL)
518 app_info->onboot = strdup(data->onboot);
519 if (data->support_disable != NULL)
520 app_info->support_disable = strdup(data->support_disable);
521 if (data->ui_gadget != NULL)
522 app_info->ui_gadget = strdup(data->ui_gadget);
523 if (data->launch_mode != NULL)
524 app_info->launch_mode = strdup(data->launch_mode);
525 if (data->package_type != NULL)
526 app_info->package_type = strdup(data->package_type);
527 if (data->effective_appid != NULL)
528 app_info->effective_appid = strdup(data->effective_appid);
529 if (data->splash_screen_display != NULL)
530 app_info->splash_screen_display =
531 strdup(data->splash_screen_display);
535 app_info->label = g_list_copy_deep(data->label, __copy_label, &ret);
537 LOGE("memory alloc failed");
538 pkgmgrinfo_basic_free_application(app_info);
539 return PMINFO_R_ERROR;
543 app_info->icon = g_list_copy_deep(data->icon, __copy_icon, &ret);
545 LOGE("memory alloc failed");
546 pkgmgrinfo_basic_free_application(app_info);
547 return PMINFO_R_ERROR;
551 app_info->category = g_list_copy_deep(data->category, __copy_str, &ret);
553 LOGE("memory alloc failed");
554 pkgmgrinfo_basic_free_application(app_info);
555 return PMINFO_R_ERROR;
559 app_info->metadata = g_list_copy_deep(data->metadata,
560 __copy_metadata, &ret);
562 LOGE("memory alloc failed");
563 pkgmgrinfo_basic_free_application(app_info);
564 return PMINFO_R_ERROR;
568 app_info->datacontrol = g_list_copy_deep(data->datacontrol,
569 __copy_datacontrol, &ret);
571 LOGE("memory alloc failed");
572 pkgmgrinfo_basic_free_application(app_info);
573 return PMINFO_R_ERROR;
577 app_info->appcontrol = g_list_copy_deep(data->appcontrol,
578 __copy_appcontrol, &ret);
580 LOGE("memory alloc failed");
581 pkgmgrinfo_basic_free_application(app_info);
582 return PMINFO_R_ERROR;
586 app_info->background_category =
587 g_list_copy_deep(data->background_category,
590 LOGE("memory alloc failed");
591 pkgmgrinfo_basic_free_application(app_info);
592 return PMINFO_R_ERROR;
596 app_info->splashscreens = g_list_copy_deep(data->splashscreens,
597 __copy_splashscreens, &ret);
599 LOGE("memory alloc failed");
600 pkgmgrinfo_basic_free_application(app_info);
601 return PMINFO_R_ERROR;
605 app_info->res_control = g_list_copy_deep(data->res_control, __copy_res_control, &ret);
607 LOGE("memory alloc failed");
608 pkgmgrinfo_basic_free_application(app_info);
609 return PMINFO_R_ERROR;
612 *application = app_info;
617 API int pkgmgrinfo_appinfo_clone_appinfo(pkgmgrinfo_appinfo_h handle,
618 pkgmgrinfo_appinfo_h *clone)
620 pkgmgr_appinfo_x *info;
621 pkgmgr_appinfo_x *temp = (pkgmgr_appinfo_x *)handle;
624 return PMINFO_R_EINVAL;
626 info = calloc(1, sizeof(pkgmgr_appinfo_x));
628 LOGE("memory alloc failed");
629 return PMINFO_R_ERROR;
632 if (temp->package != NULL)
633 info->package = strdup(temp->package);
634 if (temp->locale != NULL)
635 info->locale = strdup(temp->locale);
637 info->app_component = temp->app_component;
639 if (_appinfo_copy_appinfo(&info->app_info, temp->app_info) < 0) {
640 LOGE("appinfo copy failed");
642 free((void *)info->package);
646 return PMINFO_R_ERROR;
654 static int _appinfo_get_filtered_foreach_appinfo(uid_t uid,
655 pkgmgrinfo_filter_x *filter, int flag,
656 pkgmgrinfo_app_list_cb app_list_cb,
660 pkgmgr_appinfo_x info;
666 list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
667 __free_applications);
669 return PMINFO_R_ERROR;
671 ret = _appinfo_get_applications(uid, filter,
672 flag | PMINFO_APPINFO_GET_BASICINFO, list);
673 if (ret == PMINFO_R_ERROR) {
674 g_hash_table_destroy(list);
678 g_hash_table_iter_init(&iter, list);
679 while (g_hash_table_iter_next(&iter, NULL, &value)) {
680 app = (application_x *)value;
682 info.locale = info.app_info->locale;
683 info.package = app->package;
684 if (app_list_cb(&info, user_data) < 0)
687 g_hash_table_destroy(list);
692 static const char *__appcomponent_str(pkgmgrinfo_app_component comp);
694 API int pkgmgrinfo_appinfo_get_usr_list(pkgmgrinfo_pkginfo_h handle,
695 pkgmgrinfo_app_component component,
696 pkgmgrinfo_app_list_cb app_func, void *user_data, uid_t uid)
699 pkgmgrinfo_appinfo_filter_h filter;
701 const char *comp_str = NULL;
703 if (handle == NULL || app_func == NULL) {
704 LOGE("invalid parameter");
705 return PMINFO_R_EINVAL;
708 if (pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid)) {
709 LOGE("invalid parameter");
710 return PMINFO_R_EINVAL;
713 if (pkgmgrinfo_appinfo_filter_create(&filter))
714 return PMINFO_R_ERROR;
716 if (pkgmgrinfo_appinfo_filter_add_string(filter,
717 PMINFO_APPINFO_PROP_APP_PACKAGE, pkgid)) {
718 pkgmgrinfo_appinfo_filter_destroy(filter);
719 return PMINFO_R_ERROR;
722 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
723 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
724 pkgmgrinfo_appinfo_filter_destroy(filter);
725 return PMINFO_R_ERROR;
728 comp_str = __appcomponent_str(component);
731 if (pkgmgrinfo_appinfo_filter_add_string(filter,
732 PMINFO_APPINFO_PROP_APP_COMPONENT,
734 pkgmgrinfo_appinfo_filter_destroy(filter);
735 return PMINFO_R_ERROR;
739 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter,
740 PMINFO_APPINFO_GET_ALL, app_func, user_data);
742 pkgmgrinfo_appinfo_filter_destroy(filter);
747 API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle,
748 pkgmgrinfo_app_component component,
749 pkgmgrinfo_app_list_cb app_func, void *user_data)
751 return pkgmgrinfo_appinfo_get_usr_list(handle,
752 component, app_func, user_data, _getuid());
755 API int pkgmgrinfo_appinfo_get_usr_installed_list_full(
756 pkgmgrinfo_app_list_cb app_func, uid_t uid, int flag,
760 pkgmgrinfo_appinfo_filter_h filter;
762 if (app_func == NULL) {
763 LOGE("invalid parameter");
764 return PMINFO_R_EINVAL;
767 if (pkgmgrinfo_appinfo_filter_create(&filter))
768 return PMINFO_R_ERROR;
770 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
771 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
772 pkgmgrinfo_appinfo_filter_destroy(filter);
773 return PMINFO_R_ERROR;
776 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
777 PMINFO_APPINFO_PROP_PKG_DISABLE, false)) {
778 pkgmgrinfo_appinfo_filter_destroy(filter);
779 return PMINFO_R_ERROR;
782 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
783 PMINFO_APPINFO_PROP_APP_CHECK_STORAGE, false)) {
784 pkgmgrinfo_appinfo_filter_destroy(filter);
785 return PMINFO_R_ERROR;
788 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter, flag, app_func,
791 pkgmgrinfo_appinfo_filter_destroy(filter);
796 API int pkgmgrinfo_appinfo_get_installed_list_full(
797 pkgmgrinfo_app_list_cb app_func, int flag, void *user_data)
799 return pkgmgrinfo_appinfo_get_usr_installed_list_full(app_func,
800 _getuid(), flag, user_data);
803 API int pkgmgrinfo_appinfo_get_usr_installed_list(
804 pkgmgrinfo_app_list_cb app_func, uid_t uid, void *user_data)
807 pkgmgrinfo_appinfo_filter_h filter;
809 if (app_func == NULL) {
810 LOGE("invalid parameter");
811 return PMINFO_R_EINVAL;
814 /* create an empty filter */
815 ret = pkgmgrinfo_appinfo_filter_create(&filter);
816 if (ret != PMINFO_R_OK)
819 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
820 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
821 pkgmgrinfo_appinfo_filter_destroy(filter);
822 return PMINFO_R_ERROR;
825 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
826 PMINFO_APPINFO_PROP_PKG_DISABLE, false)) {
827 pkgmgrinfo_appinfo_filter_destroy(filter);
828 return PMINFO_R_ERROR;
831 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter,
832 PMINFO_APPINFO_GET_ALL, app_func, user_data);
834 pkgmgrinfo_appinfo_filter_destroy(filter);
839 API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func,
842 return pkgmgrinfo_appinfo_get_usr_installed_list(app_func, _getuid(),
846 API int pkgmgrinfo_appinfo_get_appid(pkgmgrinfo_appinfo_h handle, char **appid)
848 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
850 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
851 retvm_if(appid == NULL, PMINFO_R_EINVAL,
852 "Argument supplied to hold return value is NULL");
854 if (info->app_info == NULL || info->app_info->appid == NULL)
855 return PMINFO_R_ERROR;
856 *appid = (char *)info->app_info->appid;
861 API int pkgmgrinfo_appinfo_get_pkgname(
862 pkgmgrinfo_appinfo_h handle, char **pkg_name)
864 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
866 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
867 retvm_if(pkg_name == NULL, PMINFO_R_EINVAL,
868 "Argument supplied to hold return value is NULL");
870 if (info->package == NULL)
871 return PMINFO_R_ERROR;
873 *pkg_name = (char *)info->package;
878 API int pkgmgrinfo_appinfo_get_pkgid(pkgmgrinfo_appinfo_h handle, char **pkgid)
880 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
882 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
883 retvm_if(pkgid == NULL, PMINFO_R_EINVAL,
884 "Argument supplied to hold return value is NULL");
886 if (info->package == NULL)
887 return PMINFO_R_ERROR;
889 *pkgid = (char *)info->package;
894 API int pkgmgrinfo_appinfo_get_pkgtype(
895 pkgmgrinfo_appinfo_h handle, char **pkgtype)
897 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
898 retvm_if(pkgtype == NULL, PMINFO_R_EINVAL,
899 "Argument supplied to hold return value is NULL");
900 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
902 *pkgtype = (char *)info->app_info->package_type;
907 API int pkgmgrinfo_appinfo_get_exec(pkgmgrinfo_appinfo_h handle, char **exec)
909 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
911 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
912 retvm_if(exec == NULL, PMINFO_R_EINVAL,
913 "Argument supplied to hold return value is NULL");
915 if (info->app_info == NULL || info->app_info->exec == NULL)
916 return PMINFO_R_ERROR;
917 *exec = (char *)info->app_info->exec;
923 API int pkgmgrinfo_appinfo_get_icon(pkgmgrinfo_appinfo_h handle, char **icon)
926 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
928 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
929 retvm_if(icon == NULL, PMINFO_R_EINVAL,
930 "Argument supplied to hold return value is NULL");
932 if (info->app_info == NULL)
933 return PMINFO_R_ERROR;
935 if (info->app_info->icon == NULL) {
940 ptr = (icon_x *)info->app_info->icon->data;
942 return PMINFO_R_ERROR;
944 if (ptr->text == NULL)
945 return PMINFO_R_ERROR;
953 API int pkgmgrinfo_appinfo_get_label(pkgmgrinfo_appinfo_h handle, char **label)
956 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
961 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
962 retvm_if(label == NULL, PMINFO_R_EINVAL,
963 "Argument supplied to hold return value is NULL");
965 if (info->app_info == NULL)
966 return PMINFO_R_ERROR;
968 locale = info->locale;
970 locale = DEFAULT_LOCALE;
972 for (tmp = info->app_info->label; tmp; tmp = tmp->next) {
973 ptr = (label_x *)tmp->data;
974 if (ptr == NULL || strcmp(locale, ptr->lang) != 0)
985 for (tmp = info->app_info->label; tmp; tmp = tmp->next) {
986 ptr = (label_x *)tmp->data;
987 if (ptr == NULL || strcmp(DEFAULT_LOCALE, ptr->lang) != 0)
993 *label = lbl ? lbl : "";
998 API int pkgmgrinfo_appinfo_usr_get_localed_label(const char *appid,
999 const char *locale, uid_t uid, char **label)
1003 retvm_if(appid == NULL || locale == NULL || label == NULL,
1004 PMINFO_R_EINVAL, "Argument is NULL");
1005 val = _appinfo_get_localed_label(appid, locale, uid);
1007 return PMINFO_R_ERROR;
1013 API int pkgmgrinfo_appinfo_get_localed_label(
1014 const char *appid, const char *locale, char **label)
1016 return pkgmgrinfo_appinfo_usr_get_localed_label(
1017 appid, locale, _getuid(), label);
1020 API int pkgmgrinfo_appinfo_get_metadata_value(
1021 pkgmgrinfo_appinfo_h handle, const char *metadata_key,
1022 char **metadata_value)
1024 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1025 retvm_if(metadata_key == NULL, PMINFO_R_EINVAL, "metadata_key is NULL");
1026 retvm_if(metadata_value == NULL, PMINFO_R_EINVAL,
1027 "metadata_value is NULL");
1029 GList *list_md = NULL;
1030 metadata_x *metadata = NULL;
1031 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1033 list_md = info->app_info->metadata;
1035 for (; list_md; list_md = list_md->next) {
1036 metadata = (metadata_x *)list_md->data;
1037 if (metadata && metadata->key) {
1038 if (strcasecmp(metadata->key, metadata_key) == 0) {
1039 if (metadata->value == NULL)
1040 *metadata_value = "";
1043 (char *)metadata->value;
1049 return PMINFO_R_EINVAL;
1052 static pkgmgrinfo_app_component __appcomponent_convert(const char *comp)
1054 if (strcasecmp(comp, "uiapp") == 0)
1055 return PMINFO_UI_APP;
1056 else if (strcasecmp(comp, "svcapp") == 0)
1057 return PMINFO_SVC_APP;
1058 else if (strcasecmp(comp, "widgetapp") == 0)
1059 return PMINFO_WIDGET_APP;
1060 else if (strcasecmp(comp, "watchapp") == 0)
1061 return PMINFO_WATCH_APP;
1062 else if (strcasecmp(comp, "componentbasedapp") == 0)
1063 return PMINFO_COMPONENT_BASED_APP;
1068 static const char *__appcomponent_str(pkgmgrinfo_app_component comp)
1073 case PMINFO_SVC_APP:
1075 case PMINFO_WIDGET_APP:
1077 case PMINFO_WATCH_APP:
1079 case PMINFO_COMPONENT_BASED_APP:
1080 return "componentbasedapp";
1086 API int pkgmgrinfo_appinfo_get_component(
1087 pkgmgrinfo_appinfo_h handle,
1088 pkgmgrinfo_app_component *component)
1090 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1093 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1094 retvm_if(component == NULL, PMINFO_R_EINVAL,
1095 "Argument supplied to hold return value is NULL");
1097 if (info->app_info == NULL)
1098 return PMINFO_R_ERROR;
1100 comp = __appcomponent_convert(info->app_info->component);
1102 return PMINFO_R_ERROR;
1109 API int pkgmgrinfo_appinfo_get_apptype(
1110 pkgmgrinfo_appinfo_h handle, char **app_type)
1112 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1114 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1115 retvm_if(app_type == NULL, PMINFO_R_EINVAL,
1116 "Argument supplied to hold return value is NULL");
1118 if (info->app_info == NULL || info->app_info->type == NULL)
1119 return PMINFO_R_ERROR;
1120 *app_type = (char *)info->app_info->type;
1125 API int pkgmgrinfo_appinfo_get_notification_icon(
1126 pkgmgrinfo_appinfo_h handle, char **icon)
1131 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1133 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1134 retvm_if(icon == NULL, PMINFO_R_EINVAL,
1135 "Argument supplied to hold return value is NULL\n");
1137 if (info->app_info == NULL)
1138 return PMINFO_R_ERROR;
1140 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1141 ptr = (icon_x *)tmp->data;
1142 if (ptr == NULL || ptr->section == NULL)
1145 val = (char *)ptr->section;
1146 if (val && strcmp(val, "notification") == 0) {
1147 *icon = (char *)ptr->text;
1152 return PMINFO_R_ERROR;
1155 API int pkgmgrinfo_appinfo_get_recent_image_type(
1156 pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_recentimage *type)
1159 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1161 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1162 retvm_if(type == NULL, PMINFO_R_EINVAL,
1163 "Argument supplied to hold return value is NULL");
1165 if (info->app_info == NULL || info->app_info->recentimage == NULL)
1166 return PMINFO_R_ERROR;
1168 val = (char *)info->app_info->recentimage;
1169 if (strcasecmp(val, "capture") == 0)
1170 *type = PMINFO_RECENTIMAGE_USE_CAPTURE;
1171 else if (strcasecmp(val, "icon") == 0)
1172 *type = PMINFO_RECENTIMAGE_USE_ICON;
1174 *type = PMINFO_RECENTIMAGE_USE_NOTHING;
1179 API int pkgmgrinfo_appinfo_get_preview_image(
1180 pkgmgrinfo_appinfo_h handle, char **preview_img)
1185 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1187 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1188 retvm_if(preview_img == NULL, PMINFO_R_EINVAL,
1189 "Argument supplied to hold return value is NULL\n");
1191 if (info->app_info == NULL)
1192 return PMINFO_R_ERROR;
1194 for (tmp = info->app_info->image; tmp; tmp = tmp->next) {
1195 ptr = (image_x *)tmp->data;
1196 if (ptr == NULL || ptr->section == NULL)
1199 val = (char *)ptr->section;
1200 if (val && strcmp(val, "preview") == 0) {
1201 *preview_img = (char *)ptr->text;
1206 return PMINFO_R_ERROR;
1209 API int pkgmgrinfo_appinfo_get_permission_type(
1210 pkgmgrinfo_appinfo_h handle,
1211 pkgmgrinfo_permission_type *permission)
1214 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1216 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1217 retvm_if(permission == NULL, PMINFO_R_EINVAL,
1218 "Argument supplied to hold return value is NULL\n");
1220 val = info->app_info->permission_type;
1222 return PMINFO_R_ERROR;
1224 if (strcmp(val, "signature") == 0)
1225 *permission = PMINFO_PERMISSION_SIGNATURE;
1226 else if (strcmp(val, "privilege") == 0)
1227 *permission = PMINFO_PERMISSION_PRIVILEGE;
1229 *permission = PMINFO_PERMISSION_NORMAL;
1234 API int pkgmgrinfo_appinfo_get_component_type(
1235 pkgmgrinfo_appinfo_h handle, char **component_type)
1237 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1239 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1240 retvm_if(component_type == NULL, PMINFO_R_EINVAL,
1241 "Argument supplied to hold return value is NULL");
1243 if (info->app_info == NULL || info->app_info->component_type == NULL)
1244 return PMINFO_R_ERROR;
1246 *component_type = (char *)info->app_info->component_type;
1251 API int pkgmgrinfo_appinfo_get_hwacceleration(
1252 pkgmgrinfo_appinfo_h handle,
1253 pkgmgrinfo_app_hwacceleration *hwacceleration)
1256 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1258 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1259 retvm_if(hwacceleration == NULL, PMINFO_R_EINVAL,
1260 "Argument supplied to hold return value is NULL");
1262 if (info->app_info == NULL || info->app_info->hwacceleration == NULL)
1263 return PMINFO_R_ERROR;
1265 val = (char *)info->app_info->hwacceleration;
1266 if (strcasecmp(val, "off") == 0)
1267 *hwacceleration = PMINFO_HWACCELERATION_OFF;
1268 else if (strcasecmp(val, "on") == 0)
1269 *hwacceleration = PMINFO_HWACCELERATION_ON;
1271 *hwacceleration = PMINFO_HWACCELERATION_DEFAULT;
1276 API int pkgmgrinfo_appinfo_get_screenreader(
1277 pkgmgrinfo_appinfo_h handle,
1278 pkgmgrinfo_app_screenreader *screenreader)
1281 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1283 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1284 retvm_if(screenreader == NULL, PMINFO_R_EINVAL,
1285 "Argument supplied to hold return value is NULL");
1287 if (info->app_info == NULL || info->app_info->screenreader == NULL)
1288 return PMINFO_R_ERROR;
1290 val = (char *)info->app_info->screenreader;
1291 if (strcasecmp(val, "screenreader-off") == 0)
1292 *screenreader = PMINFO_SCREENREADER_OFF;
1293 else if (strcasecmp(val, "screenreader-on") == 0)
1294 *screenreader = PMINFO_SCREENREADER_ON;
1296 *screenreader = PMINFO_SCREENREADER_USE_SYSTEM_SETTING;
1301 API int pkgmgrinfo_appinfo_get_effectimage(
1302 pkgmgrinfo_appinfo_h handle, char **portrait_img,
1303 char **landscape_img)
1305 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1307 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1308 retvm_if(portrait_img == NULL, PMINFO_R_EINVAL,
1309 "Argument supplied to hold return value is NULL");
1310 retvm_if(landscape_img == NULL, PMINFO_R_EINVAL,
1311 "Argument supplied to hold return value is NULL");
1313 if (info->app_info == NULL)
1314 return PMINFO_R_ERROR;
1316 if (info->app_info->portraitimg == NULL)
1319 *portrait_img = (char *)info->app_info->portraitimg;
1321 if (info->app_info->landscapeimg == NULL)
1322 *landscape_img = "";
1324 *landscape_img = (char *)info->app_info->landscapeimg;
1329 API int pkgmgrinfo_appinfo_get_effectimage_type(
1330 pkgmgrinfo_appinfo_h handle, char **effectimage_type)
1332 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1334 if (handle == NULL || effectimage_type == NULL) {
1335 LOGE("invalid parameter");
1336 return PMINFO_R_EINVAL;
1339 if (info->app_info == NULL || info->app_info->effectimage_type == NULL)
1340 return PMINFO_R_ERROR;
1342 *effectimage_type = (char *)info->app_info->effectimage_type;
1347 API int pkgmgrinfo_appinfo_get_submode_mainid(
1348 pkgmgrinfo_appinfo_h handle, char **submode_mainid)
1350 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1352 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1353 retvm_if(submode_mainid == NULL, PMINFO_R_EINVAL,
1354 "Argument supplied to hold return value is NULL");
1356 if (info->app_info == NULL)
1357 return PMINFO_R_ERROR;
1359 if (info->app_info->submode_mainid == NULL)
1360 *submode_mainid = "";
1362 *submode_mainid = (char *)info->app_info->submode_mainid;
1367 API int pkgmgrinfo_appinfo_get_installed_storage_location(
1368 pkgmgrinfo_appinfo_h handle,
1369 pkgmgrinfo_installed_storage *storage)
1371 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1372 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1374 if (info->app_info && info->app_info->installed_storage) {
1375 if (strcmp(info->app_info->installed_storage,
1376 "installed_internal") == 0)
1377 *storage = PMINFO_INTERNAL_STORAGE;
1378 else if (strcmp(info->app_info->installed_storage,
1379 "installed_external") == 0)
1380 *storage = PMINFO_EXTERNAL_STORAGE;
1382 return PMINFO_R_ERROR;
1384 return PMINFO_R_ERROR;
1390 API int pkgmgrinfo_appinfo_get_launch_mode(
1391 pkgmgrinfo_appinfo_h handle, char **mode)
1393 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1395 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1396 retvm_if(mode == NULL, PMINFO_R_EINVAL,
1397 "Argument supplied to hold return value is NULL\n");
1399 if (info->app_info->launch_mode == NULL)
1400 return PMINFO_R_ERROR;
1402 *mode = (char *)(info->app_info->launch_mode);
1407 API int pkgmgrinfo_appinfo_get_alias_appid(
1408 pkgmgrinfo_appinfo_h handle, char **alias_appid)
1410 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1412 if (handle == NULL || alias_appid == NULL) {
1413 LOGE("invalid parameter");
1414 return PMINFO_R_EINVAL;
1417 if (info->app_info == NULL || info->app_info->alias_appid == NULL)
1418 return PMINFO_R_ERROR;
1420 *alias_appid = (char *)info->app_info->alias_appid;
1425 API int pkgmgrinfo_appinfo_get_effective_appid(
1426 pkgmgrinfo_appinfo_h handle, char **effective_appid)
1428 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1430 if (handle == NULL || effective_appid == NULL) {
1431 LOGE("invalid parameter");
1432 return PMINFO_R_EINVAL;
1435 if (info->app_info == NULL)
1436 return PMINFO_R_ERROR;
1438 if (info->app_info->effective_appid == NULL)
1439 *effective_appid = "";
1441 *effective_appid = (char *)info->app_info->effective_appid;
1446 API int pkgmgrinfo_appinfo_get_tep_name(
1447 pkgmgrinfo_appinfo_h handle, char **tep_name)
1449 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1451 if (handle == NULL || tep_name == NULL) {
1452 LOGE("invalid parameter");
1453 return PMINFO_R_EINVAL;
1456 if (info->app_info == NULL)
1457 return PMINFO_R_ERROR;
1459 if (info->app_info->tep_name == NULL)
1462 *tep_name = (char *)info->app_info->tep_name;
1467 API int pkgmgrinfo_appinfo_get_zip_mount_file(
1468 pkgmgrinfo_appinfo_h handle, char **zip_mount_file)
1470 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1472 if (handle == NULL || zip_mount_file == NULL) {
1473 LOGE("invalid parameter");
1474 return PMINFO_R_EINVAL;
1477 if (info->app_info == NULL)
1478 return PMINFO_R_ERROR;
1480 if (info->app_info->zip_mount_file == NULL)
1481 *zip_mount_file = "";
1483 *zip_mount_file = (char *)info->app_info->zip_mount_file;
1488 API int pkgmgrinfo_appinfo_get_root_path(
1489 pkgmgrinfo_appinfo_h handle, char **root_path)
1491 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1493 if (handle == NULL || root_path == NULL) {
1494 LOGE("invalid parameter");
1495 return PMINFO_R_EINVAL;
1498 if (info->app_info == NULL || info->app_info->root_path == NULL)
1499 return PMINFO_R_ERROR;
1501 *root_path = (char *)info->app_info->root_path;
1506 API int pkgmgrinfo_appinfo_get_api_version(
1507 pkgmgrinfo_appinfo_h handle, char **api_version)
1509 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1511 if (handle == NULL || api_version == NULL) {
1512 LOGE("invalid parameter");
1513 return PMINFO_R_EINVAL;
1516 if (info->app_info == NULL || info->app_info->api_version == NULL)
1517 return PMINFO_R_ERROR;
1519 *api_version = (char *)info->app_info->api_version;
1524 API int pkgmgrinfo_appinfo_get_installed_time(
1525 pkgmgrinfo_appinfo_h handle, int *installed_time)
1527 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1529 if (handle == NULL || installed_time == NULL) {
1530 LOGE("invalid parameter");
1531 return PMINFO_R_EINVAL;
1534 if (info->app_info == NULL ||
1535 info->app_info->package_installed_time == NULL)
1536 return PMINFO_R_ERROR;
1538 *installed_time = atoi(info->app_info->package_installed_time);
1543 API int pkgmgrinfo_appinfo_usr_get_datacontrol_info(const char *providerid,
1544 const char *type, uid_t uid, char **appid, char **access)
1548 if (providerid == NULL || type == NULL || appid == NULL ||
1550 LOGE("invalid parameter");
1551 return PMINFO_R_EINVAL;
1554 ret = _appinfo_get_datacontrol_info(
1555 providerid, type, uid, appid, access);
1556 /* FIXME: It should return PMINFO_R_ENOENT but to keep previous
1557 * implementation, return PMINFO_R_ERROR. This should be
1560 if (ret == PMINFO_R_ENOENT) {
1561 LOGE("no datacontrol info of %s", providerid);
1562 ret = PMINFO_R_ERROR;
1568 API int pkgmgrinfo_appinfo_get_datacontrol_info(const char *providerid,
1569 const char *type, char **appid, char **access)
1571 return pkgmgrinfo_appinfo_usr_get_datacontrol_info(providerid,
1572 type, _getuid(), appid, access);
1575 API int pkgmgrinfo_appinfo_usr_get_datacontrol_appid(const char *providerid,
1576 uid_t uid, char **appid)
1580 if (providerid == NULL || appid == NULL) {
1581 LOGE("invalid parameter");
1582 return PMINFO_R_EINVAL;
1585 ret = _appinfo_get_datacontrol_appid(providerid, uid, appid);
1586 /* FIXME: It should return PMINFO_R_ENOENT but to keep previous
1587 * implementation, return PMINFO_R_ERROR. This should be
1590 if (ret == PMINFO_R_ENOENT) {
1591 LOGE("no datacontrol appid of %s", providerid);
1592 ret = PMINFO_R_ERROR;
1598 API int pkgmgrinfo_appinfo_get_datacontrol_appid(
1599 const char *providerid, char **appid)
1601 return pkgmgrinfo_appinfo_usr_get_datacontrol_appid(
1602 providerid, _getuid(), appid);
1605 API int pkgmgrinfo_appinfo_usr_get_datacontrol_trusted_info(
1606 const char *providerid, const char *type, uid_t uid,
1607 char **appid, bool *is_trusted)
1610 char *trusted = NULL;
1612 if (providerid == NULL || type == NULL || appid == NULL ||
1613 is_trusted == NULL) {
1614 LOGE("invalid parameter");
1615 return PMINFO_R_EINVAL;
1618 ret = _appinfo_get_datacontrol_trusted_info(providerid, type, uid,
1621 /* FIXME: It should return PMINFO_R_ENOENT but to keep previous
1622 * implementation, return PMINFO_R_ERROR. This should be
1625 if (ret == PMINFO_R_ENOENT) {
1626 LOGE("no datacontrol trusted info of %s", providerid);
1627 ret = PMINFO_R_ERROR;
1629 *is_trusted = _get_bool_value(trusted);
1635 API int pkgmgrinfo_appinfo_get_datacontrol_trsuted_info(const char *providerid,
1636 const char *type, char **appid, bool *is_trusted)
1638 return pkgmgrinfo_appinfo_usr_get_datacontrol_trusted_info(providerid,
1639 type, _getuid(), appid, is_trusted);
1642 API int pkgmgrinfo_appinfo_usr_foreach_datacontrol_privileges(
1643 const char *providerid, const char *type,
1644 pkgmgrinfo_pkg_privilege_list_cb privilege_func,
1645 void *user_data, uid_t uid)
1652 if (providerid == NULL || type == NULL || privilege_func == NULL) {
1653 LOGE("invalid parameter");
1654 return PMINFO_R_EINVAL;
1657 ret = _appinfo_get_datacontrol_privileges(providerid, type, uid, &list);
1658 if (ret == PMINFO_R_ERROR) {
1659 g_list_free_full(list, free);
1663 for (tmp = list; tmp != NULL; tmp = g_list_next(tmp)) {
1665 ret = privilege_func((char *)tmp->data, user_data);
1670 g_list_free_full(list, free);
1674 API int pkgmgrinfo_appinfo_foreach_datacontrol_privileges(
1675 const char *providerid, const char *type,
1676 pkgmgrinfo_pkg_privilege_list_cb privilege_func,
1679 return pkgmgrinfo_appinfo_usr_foreach_datacontrol_privileges(
1680 providerid, type, privilege_func, user_data, _getuid());
1683 API int pkgmgrinfo_appinfo_get_support_mode(
1684 pkgmgrinfo_appinfo_h handle, int *support_mode)
1686 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1687 retvm_if(support_mode == NULL, PMINFO_R_EINVAL,
1688 "Argument supplied to hold return value is NULL");
1690 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1692 if (info->app_info->support_mode)
1693 *support_mode = atoi(info->app_info->support_mode);
1700 API int pkgmgrinfo_appinfo_foreach_category(pkgmgrinfo_appinfo_h handle,
1701 pkgmgrinfo_app_category_list_cb category_func, void *user_data)
1703 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1704 retvm_if(category_func == NULL, PMINFO_R_EINVAL,
1705 "Callback function is NULL");
1707 const char *category;
1709 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1711 if (info->app_info == NULL)
1712 return PMINFO_R_ERROR;
1714 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
1715 category = (const char *)tmp->data;
1717 ret = category_func(category, user_data);
1725 API int pkgmgrinfo_appinfo_foreach_metadata(pkgmgrinfo_appinfo_h handle,
1726 pkgmgrinfo_app_metadata_list_cb metadata_func, void *user_data)
1728 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1729 retvm_if(metadata_func == NULL, PMINFO_R_EINVAL,
1730 "Callback function is NULL");
1734 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1736 if (info->app_info == NULL)
1737 return PMINFO_R_ERROR;
1739 for (tmp = info->app_info->metadata; tmp; tmp = tmp->next) {
1740 ptr = (metadata_x *)tmp->data;
1744 ret = metadata_func(ptr->key, ptr->value ?
1745 ptr->value : "", user_data);
1753 API int pkgmgrinfo_appinfo_usr_foreach_appcontrol_privileges(const char *appid,
1754 const char *operation,
1755 pkgmgrinfo_pkg_privilege_list_cb privilege_func,
1756 void *user_data, uid_t uid)
1759 GList *privilege_list = NULL;
1762 if (appid == NULL || operation == NULL || privilege_func == NULL) {
1763 LOGE("invalid parameter");
1764 return PMINFO_R_EINVAL;
1767 ret = _appinfo_get_appcontrol_privileges(appid, operation, uid,
1769 if (ret == PMINFO_R_ENOENT) {
1771 } else if (ret != PMINFO_R_OK) {
1772 g_list_free_full(privilege_list, free);
1776 for (tmp_list = privilege_list; tmp_list != NULL;
1777 tmp_list = g_list_next(tmp_list)) {
1778 ret = privilege_func((char *)tmp_list->data, user_data);
1783 g_list_free_full(privilege_list, free);
1787 API int pkgmgrinfo_appinfo_foreach_appcontrol_privileges(const char *appid,
1788 const char *operation,
1789 pkgmgrinfo_pkg_privilege_list_cb privilege_func,
1792 return pkgmgrinfo_appinfo_usr_foreach_appcontrol_privileges(appid,
1793 operation, privilege_func, user_data, _getuid());
1796 API int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
1797 pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
1799 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1800 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL,
1801 "Callback function is NULL");
1803 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1804 appcontrol_x *appcontrol;
1807 if (info->app_info == NULL)
1808 return PMINFO_R_ERROR;
1810 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
1811 appcontrol = (appcontrol_x *)tmp->data;
1812 if (appcontrol == NULL || !strcasecmp(
1813 appcontrol->visibility, "remote-only"))
1815 ret = appcontrol_func(appcontrol->operation,
1816 appcontrol->uri, appcontrol->mime, user_data);
1824 API int pkgmgrinfo_appinfo_foreach_remote_appcontrol(
1825 pkgmgrinfo_appinfo_h handle,
1826 pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
1828 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1829 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL,
1830 "Callback function is NULL");
1832 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1833 appcontrol_x *appcontrol;
1836 if (info->app_info == NULL)
1837 return PMINFO_R_ERROR;
1839 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
1840 appcontrol = (appcontrol_x *)tmp->data;
1841 if (appcontrol == NULL || !strcasecmp(
1842 appcontrol->visibility, "local-only"))
1844 ret = appcontrol_func(appcontrol->operation, appcontrol->uri,
1845 appcontrol->mime, user_data);
1853 API int pkgmgrinfo_appinfo_foreach_background_category(
1854 pkgmgrinfo_appinfo_h handle,
1855 pkgmgrinfo_app_background_category_list_cb category_func,
1858 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1862 if (handle == NULL || category_func == NULL || info->app_info == NULL) {
1863 LOGE("invalid parameter");
1864 return PMINFO_R_EINVAL;
1867 for (tmp = info->app_info->background_category; tmp; tmp = tmp->next) {
1868 category = (char *)tmp->data;
1869 if (category == NULL)
1872 if (category_func(category, user_data) < 0)
1879 API int pkgmgrinfo_appinfo_foreach_splash_screen(pkgmgrinfo_appinfo_h handle,
1880 pkgmgrinfo_app_splash_screen_list_cb splash_screen_func,
1883 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1884 splashscreen_x *splashscreen;
1888 if (info == NULL || info->app_info == NULL
1889 || splash_screen_func == NULL) {
1890 LOGE("invalid parameter");
1891 return PMINFO_R_EINVAL;
1894 for (tmp = info->app_info->splashscreens; tmp; tmp = tmp->next) {
1895 splashscreen = (splashscreen_x *)tmp->data;
1896 if (splashscreen == NULL)
1898 ret = splash_screen_func(splashscreen->src,
1900 splashscreen->orientation,
1901 splashscreen->indicatordisplay,
1902 splashscreen->operation,
1903 splashscreen->color_depth,
1912 API int pkgmgrinfo_appinfo_foreach_res_control(pkgmgrinfo_appinfo_h handle,
1913 pkgmgrinfo_app_res_control_list_cb res_control_func,
1916 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1917 retvm_if(res_control_func == NULL, PMINFO_R_EINVAL,
1918 "Callback function is NULL");
1920 res_control_x *res_control;
1922 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1924 if (info->app_info == NULL)
1925 return PMINFO_R_ERROR;
1927 for (tmp = info->app_info->res_control; tmp; tmp = tmp->next) {
1928 res_control = (res_control_x *)tmp->data;
1929 if (res_control == NULL)
1931 ret = res_control_func(res_control->res_type,
1932 res_control->min_res_version,
1933 res_control->max_res_version,
1934 res_control->auto_close,
1942 API int pkgmgrinfo_appinfo_is_nodisplay(
1943 pkgmgrinfo_appinfo_h handle, bool *nodisplay)
1945 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1946 retvm_if(nodisplay == NULL, PMINFO_R_EINVAL,
1947 "Argument supplied to hold return value is NULL");
1948 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1950 if (info->app_info == NULL || info->app_info->nodisplay == NULL)
1951 return PMINFO_R_ERROR;
1953 *nodisplay = _get_bool_value(info->app_info->nodisplay);
1958 API int pkgmgrinfo_appinfo_is_multiple(
1959 pkgmgrinfo_appinfo_h handle, bool *multiple)
1961 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1962 retvm_if(multiple == NULL, PMINFO_R_EINVAL,
1963 "Argument supplied to hold return value is NULL");
1964 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1966 if (info->app_info == NULL || info->app_info->multiple == NULL)
1967 return PMINFO_R_ERROR;
1969 *multiple = _get_bool_value(info->app_info->multiple);
1974 API int pkgmgrinfo_appinfo_is_indicator_display_allowed(
1975 pkgmgrinfo_appinfo_h handle, bool *indicator_disp)
1977 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1978 retvm_if(indicator_disp == NULL, PMINFO_R_EINVAL,
1979 "Argument supplied to hold return value is NULL");
1980 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1982 if (info->app_info == NULL || info->app_info->indicatordisplay == NULL)
1983 return PMINFO_R_ERROR;
1985 *indicator_disp = _get_bool_value(info->app_info->indicatordisplay);
1990 API int pkgmgrinfo_appinfo_is_taskmanage(
1991 pkgmgrinfo_appinfo_h handle, bool *taskmanage)
1993 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1994 retvm_if(taskmanage == NULL, PMINFO_R_EINVAL,
1995 "Argument supplied to hold return value is NULL");
1996 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1998 if (info->app_info == NULL || info->app_info->taskmanage == NULL)
1999 return PMINFO_R_ERROR;
2001 *taskmanage = _get_bool_value(info->app_info->taskmanage);
2006 API int pkgmgrinfo_appinfo_is_enabled(
2007 pkgmgrinfo_appinfo_h handle, bool *enabled)
2009 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2010 retvm_if(enabled == NULL, PMINFO_R_EINVAL,
2011 "Argument supplied to hold return value is NULL");
2012 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2014 if (info->app_info == NULL || info->app_info->is_disabled == NULL)
2015 return PMINFO_R_ERROR;
2017 *enabled = !_get_bool_value(info->app_info->is_disabled);
2022 API int pkgmgrinfo_appinfo_is_onboot(
2023 pkgmgrinfo_appinfo_h handle, bool *onboot)
2025 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2026 retvm_if(onboot == NULL, PMINFO_R_EINVAL,
2027 "Argument supplied to hold return value is NULL");
2028 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2030 if (info->app_info == NULL || info->app_info->onboot == NULL)
2031 return PMINFO_R_ERROR;
2033 *onboot = _get_bool_value(info->app_info->onboot);
2038 API int pkgmgrinfo_appinfo_is_autorestart(
2039 pkgmgrinfo_appinfo_h handle, bool *autorestart)
2041 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2042 retvm_if(autorestart == NULL, PMINFO_R_EINVAL,
2043 "Argument supplied to hold return value is NULL");
2044 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2046 if (info->app_info == NULL || info->app_info->autorestart == NULL)
2047 return PMINFO_R_ERROR;
2049 *autorestart = _get_bool_value(info->app_info->autorestart);
2054 API int pkgmgrinfo_appinfo_is_mainapp(
2055 pkgmgrinfo_appinfo_h handle, bool *mainapp)
2057 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2058 retvm_if(mainapp == NULL, PMINFO_R_EINVAL,
2059 "Argument supplied to hold return value is NULL");
2060 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2062 if (info->app_info == NULL || info->app_info->mainapp == NULL)
2063 return PMINFO_R_ERROR;
2065 *mainapp = _get_bool_value(info->app_info->mainapp);
2070 API int pkgmgrinfo_appinfo_is_preload(
2071 pkgmgrinfo_appinfo_h handle, bool *preload)
2073 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2074 retvm_if(preload == NULL, PMINFO_R_EINVAL,
2075 "Argument supplied to hold return value is NULL\n");
2076 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2078 if (info->app_info == NULL || info->app_info->preload == NULL)
2079 return PMINFO_R_ERROR;
2081 *preload = _get_bool_value(info->app_info->preload);
2086 API int pkgmgrinfo_appinfo_is_submode(
2087 pkgmgrinfo_appinfo_h handle, bool *submode)
2089 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2090 retvm_if(submode == NULL, PMINFO_R_EINVAL,
2091 "Argument supplied to hold return value is NULL\n");
2092 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2094 if (info->app_info == NULL || info->app_info->submode == NULL)
2095 return PMINFO_R_ERROR;
2097 *submode = _get_bool_value(info->app_info->submode);
2102 API int pkgmgrinfo_appinfo_is_process_pool(
2103 pkgmgrinfo_appinfo_h handle, bool *process_pool)
2105 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2107 if (handle == NULL || process_pool == NULL) {
2108 LOGE("invalid parameter");
2109 return PMINFO_R_EINVAL;
2112 if (info->app_info == NULL)
2113 return PMINFO_R_ERROR;
2115 *process_pool = _get_bool_value(info->app_info->process_pool);
2120 API int pkgmgrinfo_appinfo_is_category_exist(
2121 pkgmgrinfo_appinfo_h handle, const char *category, bool *exist)
2123 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2124 retvm_if(category == NULL, PMINFO_R_EINVAL, "category is NULL");
2125 retvm_if(exist == NULL, PMINFO_R_EINVAL, "exist is NULL");
2129 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2131 if (info->app_info == NULL)
2132 return PMINFO_R_ERROR;
2135 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
2136 val = (const char *)tmp->data;
2139 if (strcasecmp(val, category) == 0) {
2148 API int pkgmgrinfo_appinfo_is_ui_gadget(pkgmgrinfo_appinfo_h handle,
2151 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2153 if (info == NULL || info->app_info == NULL || ui_gadget == NULL) {
2154 _LOGE("invalid parameter");
2155 return PMINFO_R_EINVAL;
2157 if (info->app_info->ui_gadget == NULL)
2158 info->app_info->ui_gadget = strdup("false");
2160 *ui_gadget = _get_bool_value(info->app_info->ui_gadget);
2165 API int pkgmgrinfo_appinfo_is_support_disable(pkgmgrinfo_appinfo_h handle,
2166 bool *support_disable)
2168 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2170 if (info == NULL || info->app_info == NULL || support_disable == NULL) {
2171 _LOGE("invalid parameter");
2172 return PMINFO_R_EINVAL;
2175 *support_disable = _get_bool_value(info->app_info->support_disable);
2180 API int pkgmgrinfo_appinfo_is_removable(pkgmgrinfo_appinfo_h handle,
2183 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2185 if (info == NULL || info->app_info == NULL || removable == NULL) {
2186 _LOGE("invalid parameter");
2187 return PMINFO_R_EINVAL;
2190 *removable = _get_bool_value(info->app_info->removable);
2195 API int pkgmgrinfo_appinfo_is_system(pkgmgrinfo_appinfo_h handle, bool *system)
2197 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2199 if (info == NULL || info->app_info == NULL || system == NULL) {
2200 _LOGE("invalid parameter");
2201 return PMINFO_R_EINVAL;
2204 *system = _get_bool_value(info->app_info->package_system);
2209 API int pkgmgrinfo_appinfo_is_disabled(
2210 pkgmgrinfo_appinfo_h handle, bool *disabled)
2212 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2213 retvm_if(disabled == NULL, PMINFO_R_EINVAL,
2214 "Argument supplied to hold return value is NULL");
2215 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2217 if (info->app_info == NULL || info->app_info->is_disabled == NULL)
2218 return PMINFO_R_ERROR;
2220 *disabled = _get_bool_value(info->app_info->is_disabled);
2225 API int pkgmgrinfo_appinfo_is_global(pkgmgrinfo_appinfo_h handle, bool *global)
2227 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2229 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2230 retvm_if(global == NULL, PMINFO_R_EINVAL,
2231 "Argument supplied to hold return value is NULL\n");
2233 if (info->app_info == NULL || info->app_info->for_all_users == NULL)
2234 return PMINFO_R_ERROR;
2236 *global = _get_bool_value(info->app_info->for_all_users);
2241 API int pkgmgrinfo_appinfo_get_splash_screen_display(
2242 pkgmgrinfo_appinfo_h handle, bool *splash_screen_display)
2244 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2246 if (info == NULL || splash_screen_display == NULL) {
2247 _LOGE("Invalid parameter");
2248 return PMINFO_R_EINVAL;
2251 if (info->app_info == NULL ||
2252 info->app_info->splash_screen_display == NULL)
2253 return PMINFO_R_ERROR;
2255 *splash_screen_display =
2256 _get_bool_value(info->app_info->splash_screen_display);
2261 API int pkgmgrinfo_appinfo_get_setup_appid(
2262 pkgmgrinfo_appinfo_h handle, char **setup_appid)
2264 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2266 if (info == NULL || setup_appid == NULL) {
2267 _LOGE("Invalid parameter");
2268 return PMINFO_R_EINVAL;
2271 if (info->app_info == NULL || info->app_info->setup_appid == NULL)
2272 return PMINFO_R_ERROR;
2274 *setup_appid = info->app_info->setup_appid;
2278 API int pkgmgrinfo_appinfo_is_support_ambient(pkgmgrinfo_appinfo_h handle,
2279 bool *support_ambient)
2281 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2283 if (info == NULL || support_ambient == NULL) {
2284 _LOGE("Invalid parameter");
2285 return PMINFO_R_EINVAL;
2288 if (info->app_info == NULL || info->app_info->support_ambient == NULL)
2289 return PMINFO_R_ERROR;
2291 *support_ambient = _get_bool_value(info->app_info->support_ambient);
2296 API int pkgmgrinfo_appinfo_destroy_appinfo(pkgmgrinfo_appinfo_h handle)
2298 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2299 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2301 __cleanup_appinfo(info);
2305 API int pkgmgrinfo_appinfo_filter_create(pkgmgrinfo_appinfo_filter_h *handle)
2307 return pkgmgrinfo_pkginfo_filter_create(handle);
2310 API int pkgmgrinfo_appinfo_filter_destroy(pkgmgrinfo_appinfo_filter_h handle)
2312 return pkgmgrinfo_pkginfo_filter_destroy(handle);
2315 static gint __compare_func(gconstpointer data1, gconstpointer data2)
2317 pkgmgrinfo_node_x *node1 = (pkgmgrinfo_node_x *)data1;
2318 pkgmgrinfo_node_x *node2 = (pkgmgrinfo_node_x *)data2;
2320 if (node1->prop == node2->prop)
2322 else if (node1->prop > node2->prop)
2328 API int pkgmgrinfo_appinfo_filter_add_int(pkgmgrinfo_appinfo_filter_h handle,
2329 const char *property, const int value)
2331 retvm_if(handle == NULL, PMINFO_R_EINVAL,
2332 "Filter handle input parameter is NULL\n");
2333 retvm_if(property == NULL, PMINFO_R_EINVAL,
2334 "Filter handle input parameter is NULL\n");
2335 char buf[PKG_VALUE_STRING_LEN_MAX] = {'\0'};
2337 GSList *link = NULL;
2340 prop = _pminfo_appinfo_convert_to_prop_int(property);
2341 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_INT ||
2342 prop > E_PMINFO_APPINFO_PROP_APP_MAX_INT) {
2343 _LOGE("Invalid Integer Property\n");
2344 return PMINFO_R_EINVAL;
2346 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2347 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1,
2348 sizeof(pkgmgrinfo_node_x));
2350 _LOGE("Out of Memory!!!\n");
2351 return PMINFO_R_ERROR;
2353 snprintf(buf, PKG_VALUE_STRING_LEN_MAX - 1, "%d", value);
2354 val = strndup(buf, PKG_VALUE_STRING_LEN_MAX - 1);
2356 _LOGE("Out of Memory\n");
2359 return PMINFO_R_ERROR;
2365 * If API is called multiple times for same property,
2366 * we should override the previous values.
2367 * Last value set will be used for filtering.
2369 link = g_slist_find_custom(filter->list,
2370 (gconstpointer)node, __compare_func);
2372 _pkgmgrinfo_node_destroy(link->data);
2373 filter->list = g_slist_delete_link(filter->list, link);
2375 filter->list = g_slist_append(filter->list, (gpointer)node);
2380 API int pkgmgrinfo_appinfo_filter_add_bool(pkgmgrinfo_appinfo_filter_h handle,
2381 const char *property, const bool value)
2383 retvm_if(handle == NULL, PMINFO_R_EINVAL,
2384 "Filter handle input parameter is NULL\n");
2385 retvm_if(property == NULL, PMINFO_R_EINVAL,
2386 "Filter handle input parameter is NULL\n");
2388 GSList *link = NULL;
2391 prop = _pminfo_appinfo_convert_to_prop_bool(property);
2392 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_BOOL ||
2393 prop > E_PMINFO_APPINFO_PROP_APP_MAX_BOOL) {
2394 _LOGE("Invalid Boolean Property\n");
2395 return PMINFO_R_EINVAL;
2397 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2398 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1,
2399 sizeof(pkgmgrinfo_node_x));
2401 _LOGE("Out of Memory!!!\n");
2402 return PMINFO_R_ERROR;
2405 val = strndup("true", 4);
2407 val = strndup("false", 5);
2409 _LOGE("Out of Memory\n");
2412 return PMINFO_R_ERROR;
2417 * If API is called multiple times for same property,
2418 * we should override the previous values.
2419 * Last value set will be used for filtering.
2421 link = g_slist_find_custom(filter->list,
2422 (gconstpointer)node, __compare_func);
2424 _pkgmgrinfo_node_destroy(link->data);
2425 filter->list = g_slist_delete_link(filter->list, link);
2427 filter->list = g_slist_append(filter->list, (gpointer)node);
2432 API int pkgmgrinfo_appinfo_filter_add_string(pkgmgrinfo_appinfo_filter_h handle,
2433 const char *property, const char *value)
2435 retvm_if(handle == NULL, PMINFO_R_EINVAL,
2436 "Filter handle input parameter is NULL\n");
2437 retvm_if(property == NULL, PMINFO_R_EINVAL,
2438 "Filter handle input parameter is NULL\n");
2439 retvm_if(value == NULL, PMINFO_R_EINVAL,
2440 "Filter handle input parameter is NULL\n");
2442 pkgmgrinfo_node_x *ptr = NULL;
2443 char prev[PKG_STRING_LEN_MAX] = {'\0'};
2444 char temp[PKG_STRING_LEN_MAX] = {'\0'};
2445 GSList *link = NULL;
2449 prop = _pminfo_appinfo_convert_to_prop_str(property);
2450 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_STR ||
2451 prop > E_PMINFO_APPINFO_PROP_APP_MAX_STR) {
2452 _LOGE("Invalid String Property\n");
2453 return PMINFO_R_EINVAL;
2455 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2456 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1,
2457 sizeof(pkgmgrinfo_node_x));
2459 _LOGE("Out of Memory!!!\n");
2460 return PMINFO_R_ERROR;
2464 case E_PMINFO_APPINFO_PROP_APP_COMPONENT:
2465 node->value = strdup(value);
2466 link = g_slist_find_custom(filter->list,
2467 (gconstpointer)node, __compare_func);
2469 _pkgmgrinfo_node_destroy(link->data);
2470 filter->list = g_slist_delete_link(filter->list, link);
2472 filter->list = g_slist_append(filter->list, (gpointer)node);
2474 case E_PMINFO_APPINFO_PROP_APP_CATEGORY:
2475 val = (char *)calloc(1, PKG_STRING_LEN_MAX);
2477 _LOGE("Out of Memory\n");
2480 return PMINFO_R_ERROR;
2482 link = g_slist_find_custom(filter->list,
2483 (gconstpointer)node, __compare_func);
2485 ptr = (pkgmgrinfo_node_x *)link->data;
2486 strncpy(prev, ptr->value, PKG_STRING_LEN_MAX - 1);
2487 _LOGI("Previous value is %s\n", prev);
2488 _pkgmgrinfo_node_destroy(ptr);
2489 filter->list = g_slist_delete_link(filter->list, link);
2490 ret = snprintf(temp, PKG_STRING_LEN_MAX - 1,
2491 "%s,%s", prev, value);
2492 if (ret < 0 || ret > PKG_STRING_LEN_MAX - 1) {
2493 _LOGE("snprintf fail\n");
2496 return PMINFO_R_ERROR;
2498 strncpy(val, temp, PKG_STRING_LEN_MAX);
2499 _LOGI("New value is %s\n", val);
2501 filter->list = g_slist_append(
2502 filter->list, (gpointer)node);
2503 memset(temp, '\0', PKG_STRING_LEN_MAX);
2505 snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s", value);
2506 strncpy(val, temp, PKG_STRING_LEN_MAX);
2507 _LOGI("First value is %s\n", val);
2509 filter->list = g_slist_append(
2510 filter->list, (gpointer)node);
2511 memset(temp, '\0', PKG_STRING_LEN_MAX);
2515 node->value = strndup(value, PKG_STRING_LEN_MAX - 1);
2516 link = g_slist_find_custom(filter->list,
2517 (gconstpointer)node, __compare_func);
2519 _pkgmgrinfo_node_destroy(link->data);
2520 filter->list = g_slist_delete_link(filter->list, link);
2522 filter->list = g_slist_append(filter->list, (gpointer)node);
2528 API int pkgmgrinfo_appinfo_usr_filter_count(
2529 pkgmgrinfo_appinfo_filter_h handle, int *count, uid_t uid)
2534 pkgmgrinfo_filter_x *filter;
2536 if (handle == NULL || count == NULL) {
2537 _LOGE("invalid parameter");
2538 return PMINFO_R_EINVAL;
2541 filter = (pkgmgrinfo_filter_x *)handle;
2542 list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
2543 __free_applications);
2545 return PMINFO_R_ERROR;
2547 if (__check_disable_filter_exist(
2548 handle, E_APPINFO_DISABLE_TYPE_APP) == false) {
2549 if (pkgmgrinfo_appinfo_filter_add_bool(handle,
2550 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
2551 g_hash_table_destroy(list);
2552 return PMINFO_R_ERROR;
2556 if (__check_disable_filter_exist(
2557 handle, E_APPINFO_DISABLE_TYPE_PKG) == false) {
2558 if (pkgmgrinfo_appinfo_filter_add_bool(handle,
2559 PMINFO_APPINFO_PROP_PKG_DISABLE, false)) {
2560 g_hash_table_destroy(list);
2561 return PMINFO_R_ERROR;
2565 ret = _appinfo_get_applications(uid, filter, 0, list);
2566 query_count = g_hash_table_size(list);
2567 g_hash_table_destroy(list);
2568 if (ret == PMINFO_R_ERROR)
2571 *count = query_count;
2575 API int pkgmgrinfo_appinfo_filter_count(
2576 pkgmgrinfo_appinfo_filter_h handle, int *count)
2578 return pkgmgrinfo_appinfo_usr_filter_count(handle, count, _getuid());
2581 API int pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(
2582 pkgmgrinfo_appinfo_filter_h handle,
2583 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
2585 if (handle == NULL || app_cb == NULL) {
2586 LOGE("invalid parameter");
2587 return PMINFO_R_EINVAL;
2590 if (__check_disable_filter_exist(
2591 handle, E_APPINFO_DISABLE_TYPE_APP) == false) {
2592 if (pkgmgrinfo_appinfo_filter_add_bool(handle,
2593 PMINFO_APPINFO_PROP_APP_DISABLE, false))
2594 return PMINFO_R_ERROR;
2597 if (__check_disable_filter_exist(
2598 handle, E_APPINFO_DISABLE_TYPE_PKG) == false) {
2599 if (pkgmgrinfo_appinfo_filter_add_bool(handle,
2600 PMINFO_APPINFO_PROP_PKG_DISABLE, false))
2601 return PMINFO_R_ERROR;
2604 return _appinfo_get_filtered_foreach_appinfo(uid,
2605 handle, PMINFO_APPINFO_GET_ALL, app_cb, user_data);
2608 API int pkgmgrinfo_appinfo_filter_foreach_appinfo(
2609 pkgmgrinfo_appinfo_filter_h handle,
2610 pkgmgrinfo_app_list_cb app_cb, void *user_data)
2612 return pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(
2613 handle, app_cb, user_data, _getuid());
2616 API int pkgmgrinfo_appinfo_metadata_filter_create(
2617 pkgmgrinfo_appinfo_metadata_filter_h *handle)
2619 return pkgmgrinfo_pkginfo_filter_create(handle);
2622 API int pkgmgrinfo_appinfo_metadata_filter_destroy(
2623 pkgmgrinfo_appinfo_metadata_filter_h handle)
2625 return pkgmgrinfo_pkginfo_filter_destroy(handle);
2628 API int pkgmgrinfo_appinfo_metadata_filter_add(
2629 pkgmgrinfo_appinfo_metadata_filter_h handle,
2630 const char *key, const char *value)
2632 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2633 pkgmgrinfo_metadata_node_x *node;
2635 /* value can be NULL.
2636 * In that case all apps with specified key should be displayed
2639 LOGE("invalid parameter");
2640 return PMINFO_R_EINVAL;
2643 node = calloc(1, sizeof(pkgmgrinfo_metadata_node_x));
2645 LOGE("out of memory");
2646 return PMINFO_R_ERROR;
2649 node->key = strdup(key);
2650 if (value && strlen(value))
2651 node->value = strdup(value);
2653 filter->list_metadata = g_slist_append(filter->list_metadata,
2659 API int pkgmgrinfo_appinfo_usr_metadata_filter_foreach(
2660 pkgmgrinfo_appinfo_metadata_filter_h handle,
2661 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
2663 if (handle == NULL || app_cb == NULL) {
2664 LOGE("invalid parameter");
2665 return PMINFO_R_EINVAL;
2668 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2670 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
2671 PMINFO_APPINFO_PROP_APP_DISABLE, false))
2672 return PMINFO_R_ERROR;
2674 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
2675 PMINFO_APPINFO_PROP_PKG_DISABLE, false))
2676 return PMINFO_R_ERROR;
2678 return _appinfo_get_filtered_foreach_appinfo(uid, handle,
2679 PMINFO_APPINFO_GET_ALL, app_cb,
2683 API int pkgmgrinfo_appinfo_metadata_filter_foreach(
2684 pkgmgrinfo_appinfo_metadata_filter_h handle,
2685 pkgmgrinfo_app_list_cb app_cb, void *user_data)
2687 return pkgmgrinfo_appinfo_usr_metadata_filter_foreach(handle, app_cb,
2688 user_data, _getuid());
2691 API int pkgmgrinfo_appinfo_is_guestmode_visibility(
2692 pkgmgrinfo_appinfo_h handle, bool *status)
2695 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2697 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2698 retvm_if(status == NULL, PMINFO_R_EINVAL,
2699 "Argument supplied to hold return value is NULL\n");
2701 val = info->app_info->guestmode_visibility;
2702 *status = _get_bool_value(val);
2706 API int pkgmgrinfo_appinfo_foreach_appcontrol_v2(pkgmgrinfo_appinfo_h handle,
2707 pkgmgrinfo_app_control_list_cb_v2 appcontrol_func,
2710 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2711 retvm_if(appcontrol_func == NULL,
2712 PMINFO_R_EINVAL, "Callback function is NULL");
2714 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2715 appcontrol_x *appcontrol;
2718 if (info->app_info == NULL)
2719 return PMINFO_R_ERROR;
2721 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
2722 appcontrol = (appcontrol_x *)tmp->data;
2723 if (appcontrol == NULL ||
2724 !strcasecmp(appcontrol->visibility,
2727 ret = appcontrol_func(appcontrol->operation, appcontrol->uri,
2728 appcontrol->mime, appcontrol->id, user_data);
2736 API int pkgmgrinfo_appinfo_foreach_remote_appcontrol_v2(
2737 pkgmgrinfo_appinfo_h handle,
2738 pkgmgrinfo_app_control_list_cb_v2 appcontrol_func,
2741 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2742 retvm_if(appcontrol_func == NULL,
2743 PMINFO_R_EINVAL, "Callback function is NULL");
2745 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2746 appcontrol_x *appcontrol;
2749 if (info->app_info == NULL)
2750 return PMINFO_R_ERROR;
2752 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
2753 appcontrol = (appcontrol_x *)tmp->data;
2754 if (appcontrol == NULL ||
2755 !strcasecmp(appcontrol->visibility,
2758 ret = appcontrol_func(appcontrol->operation, appcontrol->uri,
2759 appcontrol->mime, appcontrol->id, user_data);