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)) {
100 _LOGD("appinfo for [%s] is not existed for user [%d]",
102 g_hash_table_destroy(list);
103 return PMINFO_R_ENOENT;
106 info = calloc(1, sizeof(pkgmgr_appinfo_x));
108 _LOGE("out of memory");
109 g_hash_table_destroy(list);
110 return PMINFO_R_ERROR;
113 info->app_info = (application_x *)g_hash_table_lookup(list, appid);
114 if (!info->app_info || !info->app_info->package) {
115 _LOGD("appinfo for [%s] is not existed for user [%d]",
117 g_hash_table_destroy(list);
119 return PMINFO_R_ENOENT;
121 info->locale = strdup(info->app_info->locale);
123 _LOGE("out of memory");
124 g_hash_table_destroy(list);
126 return PMINFO_R_ERROR;
128 info->package = strdup(info->app_info->package);
129 if (!info->package) {
130 _LOGE("out of memory");
132 g_hash_table_destroy(list);
134 return PMINFO_R_ERROR;
137 /* just free list only */
138 g_hash_table_steal(list, (gconstpointer)appid);
139 g_hash_table_destroy(list);
146 API int pkgmgrinfo_appinfo_get_usr_disabled_appinfo(
147 const char *appid, uid_t uid, pkgmgrinfo_appinfo_h *handle)
150 pkgmgrinfo_appinfo_filter_h filter;
152 if (appid == NULL || handle == NULL) {
153 LOGE("invalid parameter");
154 return PMINFO_R_EINVAL;
157 ret = pkgmgrinfo_appinfo_filter_create(&filter);
158 if (ret != PMINFO_R_OK)
161 ret = pkgmgrinfo_appinfo_filter_add_string(filter,
162 PMINFO_APPINFO_PROP_APP_ID, appid);
163 if (ret != PMINFO_R_OK) {
164 pkgmgrinfo_appinfo_filter_destroy(filter);
165 return PMINFO_R_ERROR;
168 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
169 PMINFO_APPINFO_PROP_APP_DISABLE, true);
170 if (ret != PMINFO_R_OK) {
171 pkgmgrinfo_appinfo_filter_destroy(filter);
172 return PMINFO_R_ERROR;
175 ret = _pkgmgrinfo_get_appinfo(appid, uid, filter, handle);
176 pkgmgrinfo_appinfo_filter_destroy(filter);
181 API int pkgmgrinfo_appinfo_get_disabled_appinfo(
182 const char *appid, pkgmgrinfo_appinfo_h *handle)
184 return pkgmgrinfo_appinfo_get_usr_disabled_appinfo(
185 appid, _getuid(), handle);
188 API int pkgmgrinfo_appinfo_get_usr_appinfo(const char *appid, uid_t uid,
189 pkgmgrinfo_appinfo_h *handle)
192 pkgmgrinfo_appinfo_filter_h filter;
194 if (appid == NULL || handle == NULL) {
195 LOGE("invalid parameter");
196 return PMINFO_R_EINVAL;
199 ret = pkgmgrinfo_appinfo_filter_create(&filter);
200 if (ret != PMINFO_R_OK)
203 ret = pkgmgrinfo_appinfo_filter_add_string(filter,
204 PMINFO_APPINFO_PROP_APP_ID, appid);
205 if (ret != PMINFO_R_OK) {
206 pkgmgrinfo_appinfo_filter_destroy(filter);
207 return PMINFO_R_ERROR;
210 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
211 PMINFO_APPINFO_PROP_APP_DISABLE, false);
212 if (ret != PMINFO_R_OK) {
213 pkgmgrinfo_appinfo_filter_destroy(filter);
214 return PMINFO_R_ERROR;
217 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
218 PMINFO_APPINFO_PROP_PKG_DISABLE, false);
219 if (ret != PMINFO_R_OK) {
220 pkgmgrinfo_appinfo_filter_destroy(filter);
221 return PMINFO_R_ERROR;
224 ret = _pkgmgrinfo_get_appinfo(appid, uid, filter, handle);
225 pkgmgrinfo_appinfo_filter_destroy(filter);
229 API int pkgmgrinfo_appinfo_get_appinfo(
230 const char *appid, pkgmgrinfo_appinfo_h *handle)
232 return pkgmgrinfo_appinfo_get_usr_appinfo(appid, _getuid(), handle);
235 API int pkgmgrinfo_appinfo_get_usr_all_appinfo(const char *appid, uid_t uid,
236 pkgmgrinfo_appinfo_h *handle)
239 pkgmgrinfo_appinfo_filter_h filter;
241 if (appid == NULL || handle == NULL) {
242 LOGE("invalid parameter");
243 return PMINFO_R_EINVAL;
246 ret = pkgmgrinfo_appinfo_filter_create(&filter);
247 if (ret != PMINFO_R_OK)
250 ret = pkgmgrinfo_appinfo_filter_add_string(filter,
251 PMINFO_APPINFO_PROP_APP_ID, appid);
252 if (ret != PMINFO_R_OK) {
253 pkgmgrinfo_appinfo_filter_destroy(filter);
254 return PMINFO_R_ERROR;
257 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
258 PMINFO_APPINFO_PROP_APP_CHECK_STORAGE, false);
259 if (ret != PMINFO_R_OK) {
260 pkgmgrinfo_appinfo_filter_destroy(filter);
261 return PMINFO_R_ERROR;
264 ret = _pkgmgrinfo_get_appinfo(appid, uid, filter, handle);
265 pkgmgrinfo_appinfo_filter_destroy(filter);
270 API int pkgmgrinfo_appinfo_get_all_appinfo(
271 const char *appid, pkgmgrinfo_appinfo_h *handle)
273 return pkgmgrinfo_appinfo_get_usr_all_appinfo(appid, _getuid(), handle);
276 static gpointer __copy_str(gconstpointer src, gpointer data)
278 const char *tmp = (const char *)src;
281 buffer = strdup(tmp);
282 if (buffer == NULL) {
283 LOGE("memory alloc failed");
291 static gpointer __copy_label(gconstpointer src, gpointer data)
293 label_x *tmp = (label_x *)src;
296 label = calloc(1, sizeof(label_x));
298 LOGE("memory alloc failed");
304 label->name = strdup(tmp->name);
306 label->text = strdup(tmp->text);
308 label->lang = strdup(tmp->lang);
313 static gpointer __copy_icon(gconstpointer src, gpointer data)
315 icon_x *tmp = (icon_x *)src;
318 icon = calloc(1, sizeof(icon_x));
320 LOGE("memory alloc failed");
326 icon->text = strdup(tmp->text);
328 icon->lang = strdup(tmp->lang);
330 icon->section = strdup(tmp->section);
332 icon->size = strdup(tmp->size);
334 icon->resolution = strdup(tmp->resolution);
339 static gpointer __copy_metadata(gconstpointer src, gpointer data)
341 metadata_x *tmp = (metadata_x *)src;
342 metadata_x *metadata;
344 metadata = calloc(1, sizeof(metadata_x));
345 if (metadata == NULL) {
346 LOGE("memory alloc failed");
352 metadata->key = strdup(tmp->key);
354 metadata->value = strdup(tmp->value);
359 static gpointer __copy_datacontrol(gconstpointer src, gpointer data)
361 datacontrol_x *tmp = (datacontrol_x *)src;
362 datacontrol_x *datacontrol;
364 datacontrol = calloc(1, sizeof(datacontrol_x));
365 if (datacontrol == NULL) {
366 LOGE("memory alloc failed");
372 datacontrol->providerid = strdup(tmp->providerid);
374 datacontrol->access = strdup(tmp->access);
376 datacontrol->type = strdup(tmp->type);
378 datacontrol->trusted = strdup(tmp->trusted);
383 static gpointer __copy_appcontrol(gconstpointer src, gpointer data)
385 appcontrol_x *tmp = (appcontrol_x *)src;
386 appcontrol_x *appcontrol;
388 appcontrol = calloc(1, sizeof(appcontrol_x));
389 if (appcontrol == NULL) {
390 LOGE("memory alloc failed");
396 appcontrol->operation = strdup(tmp->operation);
398 appcontrol->uri = strdup(tmp->uri);
400 appcontrol->mime = strdup(tmp->mime);
405 static gpointer __copy_splashscreens(gconstpointer src, gpointer data)
407 splashscreen_x *tmp = (splashscreen_x *)src;
408 splashscreen_x *splashscreen;
410 splashscreen = (splashscreen_x *)calloc(1, sizeof(splashscreen_x));
411 if (splashscreen == NULL) {
412 LOGE("memory alloc failed");
418 splashscreen->src = strdup(tmp->src);
420 splashscreen->type = strdup(tmp->type);
421 if (tmp->orientation)
422 splashscreen->orientation = strdup(tmp->orientation);
423 if (tmp->indicatordisplay)
424 splashscreen->indicatordisplay = strdup(tmp->indicatordisplay);
426 splashscreen->operation = strdup(tmp->operation);
427 if (tmp->color_depth)
428 splashscreen->color_depth = strdup(tmp->color_depth);
433 static int _appinfo_copy_appinfo(
434 application_x **application, application_x *data)
436 application_x *app_info;
439 app_info = calloc(1, sizeof(application_x));
440 if (app_info == NULL) {
441 LOGE("memory alloc failed");
442 return PMINFO_R_ERROR;
445 if (data->appid != NULL)
446 app_info->appid = strdup(data->appid);
447 if (data->exec != NULL)
448 app_info->exec = strdup(data->exec);
449 if (data->nodisplay != NULL)
450 app_info->nodisplay = strdup(data->nodisplay);
451 if (data->multiple != NULL)
452 app_info->multiple = strdup(data->multiple);
453 if (data->taskmanage != NULL)
454 app_info->taskmanage = strdup(data->taskmanage);
455 if (data->type != NULL)
456 app_info->type = strdup(data->type);
457 if (data->categories != NULL)
458 app_info->categories = strdup(data->categories);
459 if (data->hwacceleration != NULL)
460 app_info->hwacceleration = strdup(data->hwacceleration);
461 if (data->screenreader != NULL)
462 app_info->screenreader = strdup(data->screenreader);
463 if (data->mainapp != NULL)
464 app_info->mainapp = strdup(data->mainapp);
465 if (data->package != NULL)
466 app_info->package = strdup(data->package);
467 if (data->recentimage != NULL)
468 app_info->recentimage = strdup(data->recentimage);
469 if (data->launchcondition != NULL)
470 app_info->launchcondition = strdup(data->launchcondition);
471 if (data->indicatordisplay != NULL)
472 app_info->indicatordisplay = strdup(data->indicatordisplay);
473 if (data->portraitimg != NULL)
474 app_info->portraitimg = strdup(data->portraitimg);
475 if (data->landscapeimg != NULL)
476 app_info->landscapeimg = strdup(data->landscapeimg);
477 if (data->guestmode_visibility != NULL)
478 app_info->guestmode_visibility =
479 strdup(data->guestmode_visibility);
480 if (data->component != NULL)
481 app_info->component = strdup(data->component);
482 if (data->permission_type != NULL)
483 app_info->permission_type = strdup(data->permission_type);
484 if (data->component_type != NULL)
485 app_info->component_type = strdup(data->component_type);
486 if (data->preload != NULL)
487 app_info->preload = strdup(data->preload);
488 if (data->submode != NULL)
489 app_info->submode = strdup(data->submode);
490 if (data->submode_mainid != NULL)
491 app_info->submode_mainid = strdup(data->submode_mainid);
492 if (data->process_pool != NULL)
493 app_info->process_pool = strdup(data->process_pool);
494 if (data->installed_storage != NULL)
495 app_info->installed_storage = strdup(data->installed_storage);
496 if (data->autorestart != NULL)
497 app_info->autorestart = strdup(data->autorestart);
498 if (data->onboot != NULL)
499 app_info->onboot = strdup(data->onboot);
500 if (data->support_disable != NULL)
501 app_info->support_disable = strdup(data->support_disable);
502 if (data->ui_gadget != NULL)
503 app_info->ui_gadget = strdup(data->ui_gadget);
504 if (data->launch_mode != NULL)
505 app_info->launch_mode = strdup(data->launch_mode);
506 if (data->package_type != NULL)
507 app_info->package_type = strdup(data->package_type);
508 if (data->effective_appid != NULL)
509 app_info->effective_appid = strdup(data->effective_appid);
510 if (data->splash_screen_display != NULL)
511 app_info->splash_screen_display =
512 strdup(data->splash_screen_display);
516 app_info->label = g_list_copy_deep(data->label, __copy_label, &ret);
518 LOGE("memory alloc failed");
519 pkgmgrinfo_basic_free_application(app_info);
520 return PMINFO_R_ERROR;
524 app_info->icon = g_list_copy_deep(data->icon, __copy_icon, &ret);
526 LOGE("memory alloc failed");
527 pkgmgrinfo_basic_free_application(app_info);
528 return PMINFO_R_ERROR;
532 app_info->category = g_list_copy_deep(data->category, __copy_str, &ret);
534 LOGE("memory alloc failed");
535 pkgmgrinfo_basic_free_application(app_info);
536 return PMINFO_R_ERROR;
540 app_info->metadata = g_list_copy_deep(data->metadata,
541 __copy_metadata, &ret);
543 LOGE("memory alloc failed");
544 pkgmgrinfo_basic_free_application(app_info);
545 return PMINFO_R_ERROR;
549 app_info->datacontrol = g_list_copy_deep(data->datacontrol,
550 __copy_datacontrol, &ret);
552 LOGE("memory alloc failed");
553 pkgmgrinfo_basic_free_application(app_info);
554 return PMINFO_R_ERROR;
558 app_info->appcontrol = g_list_copy_deep(data->appcontrol,
559 __copy_appcontrol, &ret);
561 LOGE("memory alloc failed");
562 pkgmgrinfo_basic_free_application(app_info);
563 return PMINFO_R_ERROR;
567 app_info->background_category =
568 g_list_copy_deep(data->background_category,
571 LOGE("memory alloc failed");
572 pkgmgrinfo_basic_free_application(app_info);
573 return PMINFO_R_ERROR;
577 app_info->splashscreens = g_list_copy_deep(data->splashscreens,
578 __copy_splashscreens, &ret);
580 LOGE("memory alloc failed");
581 pkgmgrinfo_basic_free_application(app_info);
582 return PMINFO_R_ERROR;
585 *application = app_info;
590 API int pkgmgrinfo_appinfo_clone_appinfo(pkgmgrinfo_appinfo_h handle,
591 pkgmgrinfo_appinfo_h *clone)
593 pkgmgr_appinfo_x *info;
594 pkgmgr_appinfo_x *temp = (pkgmgr_appinfo_x *)handle;
597 return PMINFO_R_EINVAL;
599 info = calloc(1, sizeof(pkgmgr_appinfo_x));
601 LOGE("memory alloc failed");
602 return PMINFO_R_ERROR;
605 if (temp->package != NULL)
606 info->package = strdup(temp->package);
607 if (temp->locale != NULL)
608 info->locale = strdup(temp->locale);
610 info->app_component = temp->app_component;
612 if (_appinfo_copy_appinfo(&info->app_info, temp->app_info) < 0) {
613 LOGE("appinfo copy failed");
615 free((void *)info->package);
619 return PMINFO_R_ERROR;
627 static int _appinfo_get_filtered_foreach_appinfo(uid_t uid,
628 pkgmgrinfo_filter_x *filter, int flag,
629 pkgmgrinfo_app_list_cb app_list_cb,
633 pkgmgr_appinfo_x info;
639 list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
640 __free_applications);
642 return PMINFO_R_ERROR;
644 ret = _appinfo_get_applications(uid, filter,
645 flag | PMINFO_APPINFO_GET_BASICINFO, list);
646 if (ret == PMINFO_R_ERROR) {
647 g_hash_table_destroy(list);
651 g_hash_table_iter_init(&iter, list);
652 while (g_hash_table_iter_next(&iter, NULL, &value)) {
653 app = (application_x *)value;
655 info.locale = info.app_info->locale;
656 info.package = app->package;
657 if (app_list_cb(&info, user_data) < 0)
660 g_hash_table_destroy(list);
665 static const char *__appcomponent_str(pkgmgrinfo_app_component comp);
667 API int pkgmgrinfo_appinfo_get_usr_list(pkgmgrinfo_pkginfo_h handle,
668 pkgmgrinfo_app_component component,
669 pkgmgrinfo_app_list_cb app_func, void *user_data, uid_t uid)
672 pkgmgrinfo_appinfo_filter_h filter;
674 const char *comp_str = NULL;
676 if (handle == NULL || app_func == NULL) {
677 LOGE("invalid parameter");
678 return PMINFO_R_EINVAL;
681 if (pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid)) {
682 LOGE("invalid parameter");
683 return PMINFO_R_EINVAL;
686 if (pkgmgrinfo_appinfo_filter_create(&filter))
687 return PMINFO_R_ERROR;
689 if (pkgmgrinfo_appinfo_filter_add_string(filter,
690 PMINFO_APPINFO_PROP_APP_PACKAGE, pkgid)) {
691 pkgmgrinfo_appinfo_filter_destroy(filter);
692 return PMINFO_R_ERROR;
695 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
696 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
697 pkgmgrinfo_appinfo_filter_destroy(filter);
698 return PMINFO_R_ERROR;
701 comp_str = __appcomponent_str(component);
704 if (pkgmgrinfo_appinfo_filter_add_string(filter,
705 PMINFO_APPINFO_PROP_APP_COMPONENT,
707 pkgmgrinfo_appinfo_filter_destroy(filter);
708 return PMINFO_R_ERROR;
712 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter,
713 PMINFO_APPINFO_GET_ALL, app_func, user_data);
715 pkgmgrinfo_appinfo_filter_destroy(filter);
720 API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle,
721 pkgmgrinfo_app_component component,
722 pkgmgrinfo_app_list_cb app_func, void *user_data)
724 return pkgmgrinfo_appinfo_get_usr_list(handle,
725 component, app_func, user_data, _getuid());
728 API int pkgmgrinfo_appinfo_get_usr_installed_list_full(
729 pkgmgrinfo_app_list_cb app_func, uid_t uid, int flag,
733 pkgmgrinfo_appinfo_filter_h filter;
735 if (app_func == NULL) {
736 LOGE("invalid parameter");
737 return PMINFO_R_EINVAL;
740 if (pkgmgrinfo_appinfo_filter_create(&filter))
741 return PMINFO_R_ERROR;
743 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
744 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
745 pkgmgrinfo_appinfo_filter_destroy(filter);
746 return PMINFO_R_ERROR;
749 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
750 PMINFO_APPINFO_PROP_PKG_DISABLE, false)) {
751 pkgmgrinfo_appinfo_filter_destroy(filter);
752 return PMINFO_R_ERROR;
755 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
756 PMINFO_APPINFO_PROP_APP_CHECK_STORAGE, false)) {
757 pkgmgrinfo_appinfo_filter_destroy(filter);
758 return PMINFO_R_ERROR;
761 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter, flag, app_func,
764 pkgmgrinfo_appinfo_filter_destroy(filter);
769 API int pkgmgrinfo_appinfo_get_installed_list_full(
770 pkgmgrinfo_app_list_cb app_func, int flag, void *user_data)
772 return pkgmgrinfo_appinfo_get_usr_installed_list_full(app_func,
773 _getuid(), flag, user_data);
776 API int pkgmgrinfo_appinfo_get_usr_installed_list(
777 pkgmgrinfo_app_list_cb app_func, uid_t uid, void *user_data)
780 pkgmgrinfo_appinfo_filter_h filter;
782 if (app_func == NULL) {
783 LOGE("invalid parameter");
784 return PMINFO_R_EINVAL;
787 /* create an empty filter */
788 ret = pkgmgrinfo_appinfo_filter_create(&filter);
789 if (ret != PMINFO_R_OK)
792 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
793 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
794 pkgmgrinfo_appinfo_filter_destroy(filter);
795 return PMINFO_R_ERROR;
798 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
799 PMINFO_APPINFO_PROP_PKG_DISABLE, false)) {
800 pkgmgrinfo_appinfo_filter_destroy(filter);
801 return PMINFO_R_ERROR;
804 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter,
805 PMINFO_APPINFO_GET_ALL, app_func, user_data);
807 pkgmgrinfo_appinfo_filter_destroy(filter);
812 API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func,
815 return pkgmgrinfo_appinfo_get_usr_installed_list(app_func, _getuid(),
819 API int pkgmgrinfo_appinfo_get_appid(pkgmgrinfo_appinfo_h handle, char **appid)
821 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
823 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
824 retvm_if(appid == NULL, PMINFO_R_EINVAL,
825 "Argument supplied to hold return value is NULL");
827 if (info->app_info == NULL || info->app_info->appid == NULL)
828 return PMINFO_R_ERROR;
829 *appid = (char *)info->app_info->appid;
834 API int pkgmgrinfo_appinfo_get_pkgname(
835 pkgmgrinfo_appinfo_h handle, char **pkg_name)
837 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
839 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
840 retvm_if(pkg_name == NULL, PMINFO_R_EINVAL,
841 "Argument supplied to hold return value is NULL");
843 if (info->package == NULL)
844 return PMINFO_R_ERROR;
846 *pkg_name = (char *)info->package;
851 API int pkgmgrinfo_appinfo_get_pkgid(pkgmgrinfo_appinfo_h handle, char **pkgid)
853 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
855 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
856 retvm_if(pkgid == NULL, PMINFO_R_EINVAL,
857 "Argument supplied to hold return value is NULL");
859 if (info->package == NULL)
860 return PMINFO_R_ERROR;
862 *pkgid = (char *)info->package;
867 API int pkgmgrinfo_appinfo_get_pkgtype(
868 pkgmgrinfo_appinfo_h handle, char **pkgtype)
870 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
871 retvm_if(pkgtype == NULL, PMINFO_R_EINVAL,
872 "Argument supplied to hold return value is NULL");
873 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
875 *pkgtype = (char *)info->app_info->package_type;
880 API int pkgmgrinfo_appinfo_get_exec(pkgmgrinfo_appinfo_h handle, char **exec)
882 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
884 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
885 retvm_if(exec == NULL, PMINFO_R_EINVAL,
886 "Argument supplied to hold return value is NULL");
888 if (info->app_info == NULL || info->app_info->exec == NULL)
889 return PMINFO_R_ERROR;
890 *exec = (char *)info->app_info->exec;
896 API int pkgmgrinfo_appinfo_get_icon(pkgmgrinfo_appinfo_h handle, char **icon)
899 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
901 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
902 retvm_if(icon == NULL, PMINFO_R_EINVAL,
903 "Argument supplied to hold return value is NULL");
905 if (info->app_info == NULL)
906 return PMINFO_R_ERROR;
908 if (info->app_info->icon == NULL) {
913 ptr = (icon_x *)info->app_info->icon->data;
915 return PMINFO_R_ERROR;
917 if (ptr->text == NULL)
918 return PMINFO_R_ERROR;
926 API int pkgmgrinfo_appinfo_get_label(pkgmgrinfo_appinfo_h handle, char **label)
929 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
934 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
935 retvm_if(label == NULL, PMINFO_R_EINVAL,
936 "Argument supplied to hold return value is NULL");
938 if (info->app_info == NULL)
939 return PMINFO_R_ERROR;
941 locale = info->locale;
943 locale = DEFAULT_LOCALE;
945 for (tmp = info->app_info->label; tmp; tmp = tmp->next) {
946 ptr = (label_x *)tmp->data;
947 if (ptr == NULL || strcmp(locale, ptr->lang) != 0)
958 for (tmp = info->app_info->label; tmp; tmp = tmp->next) {
959 ptr = (label_x *)tmp->data;
960 if (ptr == NULL || strcmp(DEFAULT_LOCALE, ptr->lang) != 0)
966 *label = lbl ? lbl : "";
971 API int pkgmgrinfo_appinfo_usr_get_localed_label(const char *appid,
972 const char *locale, uid_t uid, char **label)
976 retvm_if(appid == NULL || locale == NULL || label == NULL,
977 PMINFO_R_EINVAL, "Argument is NULL");
978 val = _appinfo_get_localed_label(appid, locale, uid);
980 return PMINFO_R_ERROR;
986 API int pkgmgrinfo_appinfo_get_localed_label(
987 const char *appid, const char *locale, char **label)
989 return pkgmgrinfo_appinfo_usr_get_localed_label(
990 appid, locale, _getuid(), label);
993 API int pkgmgrinfo_appinfo_get_metadata_value(
994 pkgmgrinfo_appinfo_h handle, const char *metadata_key,
995 char **metadata_value)
997 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
998 retvm_if(metadata_key == NULL, PMINFO_R_EINVAL, "metadata_key is NULL");
999 retvm_if(metadata_value == NULL, PMINFO_R_EINVAL,
1000 "metadata_value is NULL");
1002 GList *list_md = NULL;
1003 metadata_x *metadata = NULL;
1004 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1006 list_md = info->app_info->metadata;
1008 for (; list_md; list_md = list_md->next) {
1009 metadata = (metadata_x *)list_md->data;
1010 if (metadata && metadata->key) {
1011 if (strcasecmp(metadata->key, metadata_key) == 0) {
1012 if (metadata->value == NULL)
1013 *metadata_value = "";
1016 (char *)metadata->value;
1022 return PMINFO_R_EINVAL;
1025 static pkgmgrinfo_app_component __appcomponent_convert(const char *comp)
1027 if (strcasecmp(comp, "uiapp") == 0)
1028 return PMINFO_UI_APP;
1029 else if (strcasecmp(comp, "svcapp") == 0)
1030 return PMINFO_SVC_APP;
1031 else if (strcasecmp(comp, "widgetapp") == 0)
1032 return PMINFO_WIDGET_APP;
1033 else if (strcasecmp(comp, "watchapp") == 0)
1034 return PMINFO_WATCH_APP;
1035 else if (strcasecmp(comp, "componentbasedapp") == 0)
1036 return PMINFO_COMPONENT_BASED_APP;
1041 static const char *__appcomponent_str(pkgmgrinfo_app_component comp)
1046 case PMINFO_SVC_APP:
1048 case PMINFO_WIDGET_APP:
1050 case PMINFO_WATCH_APP:
1052 case PMINFO_COMPONENT_BASED_APP:
1053 return "componentbasedapp";
1059 API int pkgmgrinfo_appinfo_get_component(
1060 pkgmgrinfo_appinfo_h handle,
1061 pkgmgrinfo_app_component *component)
1063 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1066 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1067 retvm_if(component == NULL, PMINFO_R_EINVAL,
1068 "Argument supplied to hold return value is NULL");
1070 if (info->app_info == NULL)
1071 return PMINFO_R_ERROR;
1073 comp = __appcomponent_convert(info->app_info->component);
1075 return PMINFO_R_ERROR;
1082 API int pkgmgrinfo_appinfo_get_apptype(
1083 pkgmgrinfo_appinfo_h handle, char **app_type)
1085 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1087 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1088 retvm_if(app_type == NULL, PMINFO_R_EINVAL,
1089 "Argument supplied to hold return value is NULL");
1091 if (info->app_info == NULL || info->app_info->type == NULL)
1092 return PMINFO_R_ERROR;
1093 *app_type = (char *)info->app_info->type;
1098 API int pkgmgrinfo_appinfo_get_notification_icon(
1099 pkgmgrinfo_appinfo_h handle, char **icon)
1104 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1106 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1107 retvm_if(icon == NULL, PMINFO_R_EINVAL,
1108 "Argument supplied to hold return value is NULL\n");
1110 if (info->app_info == NULL)
1111 return PMINFO_R_ERROR;
1113 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1114 ptr = (icon_x *)tmp->data;
1115 if (ptr == NULL || ptr->section == NULL)
1118 val = (char *)ptr->section;
1119 if (val && strcmp(val, "notification") == 0) {
1120 *icon = (char *)ptr->text;
1125 return PMINFO_R_ERROR;
1128 API int pkgmgrinfo_appinfo_get_recent_image_type(
1129 pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_recentimage *type)
1132 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1134 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1135 retvm_if(type == NULL, PMINFO_R_EINVAL,
1136 "Argument supplied to hold return value is NULL");
1138 if (info->app_info == NULL || info->app_info->recentimage == NULL)
1139 return PMINFO_R_ERROR;
1141 val = (char *)info->app_info->recentimage;
1142 if (strcasecmp(val, "capture") == 0)
1143 *type = PMINFO_RECENTIMAGE_USE_CAPTURE;
1144 else if (strcasecmp(val, "icon") == 0)
1145 *type = PMINFO_RECENTIMAGE_USE_ICON;
1147 *type = PMINFO_RECENTIMAGE_USE_NOTHING;
1152 API int pkgmgrinfo_appinfo_get_preview_image(
1153 pkgmgrinfo_appinfo_h handle, char **preview_img)
1158 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1160 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1161 retvm_if(preview_img == NULL, PMINFO_R_EINVAL,
1162 "Argument supplied to hold return value is NULL\n");
1164 if (info->app_info == NULL)
1165 return PMINFO_R_ERROR;
1167 for (tmp = info->app_info->image; tmp; tmp = tmp->next) {
1168 ptr = (image_x *)tmp->data;
1169 if (ptr == NULL || ptr->section == NULL)
1172 val = (char *)ptr->section;
1173 if (val && strcmp(val, "preview") == 0) {
1174 *preview_img = (char *)ptr->text;
1179 return PMINFO_R_ERROR;
1182 API int pkgmgrinfo_appinfo_get_permission_type(
1183 pkgmgrinfo_appinfo_h handle,
1184 pkgmgrinfo_permission_type *permission)
1187 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1189 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1190 retvm_if(permission == NULL, PMINFO_R_EINVAL,
1191 "Argument supplied to hold return value is NULL\n");
1193 val = info->app_info->permission_type;
1195 return PMINFO_R_ERROR;
1197 if (strcmp(val, "signature") == 0)
1198 *permission = PMINFO_PERMISSION_SIGNATURE;
1199 else if (strcmp(val, "privilege") == 0)
1200 *permission = PMINFO_PERMISSION_PRIVILEGE;
1202 *permission = PMINFO_PERMISSION_NORMAL;
1207 API int pkgmgrinfo_appinfo_get_component_type(
1208 pkgmgrinfo_appinfo_h handle, char **component_type)
1210 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1212 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1213 retvm_if(component_type == NULL, PMINFO_R_EINVAL,
1214 "Argument supplied to hold return value is NULL");
1216 if (info->app_info == NULL || info->app_info->component_type == NULL)
1217 return PMINFO_R_ERROR;
1219 *component_type = (char *)info->app_info->component_type;
1224 API int pkgmgrinfo_appinfo_get_hwacceleration(
1225 pkgmgrinfo_appinfo_h handle,
1226 pkgmgrinfo_app_hwacceleration *hwacceleration)
1229 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1231 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1232 retvm_if(hwacceleration == NULL, PMINFO_R_EINVAL,
1233 "Argument supplied to hold return value is NULL");
1235 if (info->app_info == NULL || info->app_info->hwacceleration == NULL)
1236 return PMINFO_R_ERROR;
1238 val = (char *)info->app_info->hwacceleration;
1239 if (strcasecmp(val, "off") == 0)
1240 *hwacceleration = PMINFO_HWACCELERATION_OFF;
1241 else if (strcasecmp(val, "on") == 0)
1242 *hwacceleration = PMINFO_HWACCELERATION_ON;
1244 *hwacceleration = PMINFO_HWACCELERATION_DEFAULT;
1249 API int pkgmgrinfo_appinfo_get_screenreader(
1250 pkgmgrinfo_appinfo_h handle,
1251 pkgmgrinfo_app_screenreader *screenreader)
1254 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1256 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1257 retvm_if(screenreader == NULL, PMINFO_R_EINVAL,
1258 "Argument supplied to hold return value is NULL");
1260 if (info->app_info == NULL || info->app_info->screenreader == NULL)
1261 return PMINFO_R_ERROR;
1263 val = (char *)info->app_info->screenreader;
1264 if (strcasecmp(val, "screenreader-off") == 0)
1265 *screenreader = PMINFO_SCREENREADER_OFF;
1266 else if (strcasecmp(val, "screenreader-on") == 0)
1267 *screenreader = PMINFO_SCREENREADER_ON;
1269 *screenreader = PMINFO_SCREENREADER_USE_SYSTEM_SETTING;
1274 API int pkgmgrinfo_appinfo_get_effectimage(
1275 pkgmgrinfo_appinfo_h handle, char **portrait_img,
1276 char **landscape_img)
1278 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1280 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1281 retvm_if(portrait_img == NULL, PMINFO_R_EINVAL,
1282 "Argument supplied to hold return value is NULL");
1283 retvm_if(landscape_img == NULL, PMINFO_R_EINVAL,
1284 "Argument supplied to hold return value is NULL");
1286 if (info->app_info == NULL)
1287 return PMINFO_R_ERROR;
1289 if (info->app_info->portraitimg == NULL)
1292 *portrait_img = (char *)info->app_info->portraitimg;
1294 if (info->app_info->landscapeimg == NULL)
1295 *landscape_img = "";
1297 *landscape_img = (char *)info->app_info->landscapeimg;
1302 API int pkgmgrinfo_appinfo_get_effectimage_type(
1303 pkgmgrinfo_appinfo_h handle, char **effectimage_type)
1305 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1307 if (handle == NULL || effectimage_type == NULL) {
1308 LOGE("invalid parameter");
1309 return PMINFO_R_EINVAL;
1312 if (info->app_info == NULL || info->app_info->effectimage_type == NULL)
1313 return PMINFO_R_ERROR;
1315 *effectimage_type = (char *)info->app_info->effectimage_type;
1320 API int pkgmgrinfo_appinfo_get_submode_mainid(
1321 pkgmgrinfo_appinfo_h handle, char **submode_mainid)
1323 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1325 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1326 retvm_if(submode_mainid == NULL, PMINFO_R_EINVAL,
1327 "Argument supplied to hold return value is NULL");
1329 if (info->app_info == NULL)
1330 return PMINFO_R_ERROR;
1332 if (info->app_info->submode_mainid == NULL)
1333 *submode_mainid = "";
1335 *submode_mainid = (char *)info->app_info->submode_mainid;
1340 API int pkgmgrinfo_appinfo_get_installed_storage_location(
1341 pkgmgrinfo_appinfo_h handle,
1342 pkgmgrinfo_installed_storage *storage)
1344 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1345 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1347 if (info->app_info && info->app_info->installed_storage) {
1348 if (strcmp(info->app_info->installed_storage,
1349 "installed_internal") == 0)
1350 *storage = PMINFO_INTERNAL_STORAGE;
1351 else if (strcmp(info->app_info->installed_storage,
1352 "installed_external") == 0)
1353 *storage = PMINFO_EXTERNAL_STORAGE;
1355 return PMINFO_R_ERROR;
1357 return PMINFO_R_ERROR;
1363 API int pkgmgrinfo_appinfo_get_launch_mode(
1364 pkgmgrinfo_appinfo_h handle, char **mode)
1366 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1368 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1369 retvm_if(mode == NULL, PMINFO_R_EINVAL,
1370 "Argument supplied to hold return value is NULL\n");
1372 if (info->app_info->launch_mode == NULL)
1373 return PMINFO_R_ERROR;
1375 *mode = (char *)(info->app_info->launch_mode);
1380 API int pkgmgrinfo_appinfo_get_alias_appid(
1381 pkgmgrinfo_appinfo_h handle, char **alias_appid)
1383 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1385 if (handle == NULL || alias_appid == NULL) {
1386 LOGE("invalid parameter");
1387 return PMINFO_R_EINVAL;
1390 if (info->app_info == NULL || info->app_info->alias_appid == NULL)
1391 return PMINFO_R_ERROR;
1393 *alias_appid = (char *)info->app_info->alias_appid;
1398 API int pkgmgrinfo_appinfo_get_effective_appid(
1399 pkgmgrinfo_appinfo_h handle, char **effective_appid)
1401 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1403 if (handle == NULL || effective_appid == NULL) {
1404 LOGE("invalid parameter");
1405 return PMINFO_R_EINVAL;
1408 if (info->app_info == NULL)
1409 return PMINFO_R_ERROR;
1411 if (info->app_info->effective_appid == NULL)
1412 *effective_appid = "";
1414 *effective_appid = (char *)info->app_info->effective_appid;
1419 API int pkgmgrinfo_appinfo_get_tep_name(
1420 pkgmgrinfo_appinfo_h handle, char **tep_name)
1422 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1424 if (handle == NULL || tep_name == NULL) {
1425 LOGE("invalid parameter");
1426 return PMINFO_R_EINVAL;
1429 if (info->app_info == NULL)
1430 return PMINFO_R_ERROR;
1432 if (info->app_info->tep_name == NULL)
1435 *tep_name = (char *)info->app_info->tep_name;
1440 API int pkgmgrinfo_appinfo_get_zip_mount_file(
1441 pkgmgrinfo_appinfo_h handle, char **zip_mount_file)
1443 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1445 if (handle == NULL || zip_mount_file == NULL) {
1446 LOGE("invalid parameter");
1447 return PMINFO_R_EINVAL;
1450 if (info->app_info == NULL)
1451 return PMINFO_R_ERROR;
1453 if (info->app_info->zip_mount_file == NULL)
1454 *zip_mount_file = "";
1456 *zip_mount_file = (char *)info->app_info->zip_mount_file;
1461 API int pkgmgrinfo_appinfo_get_root_path(
1462 pkgmgrinfo_appinfo_h handle, char **root_path)
1464 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1466 if (handle == NULL || root_path == NULL) {
1467 LOGE("invalid parameter");
1468 return PMINFO_R_EINVAL;
1471 if (info->app_info == NULL || info->app_info->root_path == NULL)
1472 return PMINFO_R_ERROR;
1474 *root_path = (char *)info->app_info->root_path;
1479 API int pkgmgrinfo_appinfo_get_api_version(
1480 pkgmgrinfo_appinfo_h handle, char **api_version)
1482 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1484 if (handle == NULL || api_version == NULL) {
1485 LOGE("invalid parameter");
1486 return PMINFO_R_EINVAL;
1489 if (info->app_info == NULL || info->app_info->api_version == NULL)
1490 return PMINFO_R_ERROR;
1492 *api_version = (char *)info->app_info->api_version;
1497 API int pkgmgrinfo_appinfo_get_installed_time(
1498 pkgmgrinfo_appinfo_h handle, int *installed_time)
1500 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1502 if (handle == NULL || installed_time == NULL) {
1503 LOGE("invalid parameter");
1504 return PMINFO_R_EINVAL;
1507 if (info->app_info == NULL ||
1508 info->app_info->package_installed_time == NULL)
1509 return PMINFO_R_ERROR;
1511 *installed_time = atoi(info->app_info->package_installed_time);
1516 API int pkgmgrinfo_appinfo_usr_get_datacontrol_info(const char *providerid,
1517 const char *type, uid_t uid, char **appid, char **access)
1521 if (providerid == NULL || type == NULL || appid == NULL ||
1523 LOGE("invalid parameter");
1524 return PMINFO_R_EINVAL;
1527 ret = _appinfo_get_datacontrol_info(
1528 providerid, type, uid, appid, access);
1529 /* FIXME: It should return PMINFO_R_ENOENT but to keep previous
1530 * implementation, return PMINFO_R_ERROR. This should be
1533 if (ret == PMINFO_R_ENOENT) {
1534 LOGE("no datacontrol info of %s", providerid);
1535 ret = PMINFO_R_ERROR;
1541 API int pkgmgrinfo_appinfo_get_datacontrol_info(const char *providerid,
1542 const char *type, char **appid, char **access)
1544 return pkgmgrinfo_appinfo_usr_get_datacontrol_info(providerid,
1545 type, _getuid(), appid, access);
1548 API int pkgmgrinfo_appinfo_usr_get_datacontrol_appid(const char *providerid,
1549 uid_t uid, char **appid)
1553 if (providerid == NULL || appid == NULL) {
1554 LOGE("invalid parameter");
1555 return PMINFO_R_EINVAL;
1558 ret = _appinfo_get_datacontrol_appid(providerid, uid, appid);
1559 /* FIXME: It should return PMINFO_R_ENOENT but to keep previous
1560 * implementation, return PMINFO_R_ERROR. This should be
1563 if (ret == PMINFO_R_ENOENT) {
1564 LOGE("no datacontrol appid of %s", providerid);
1565 ret = PMINFO_R_ERROR;
1571 API int pkgmgrinfo_appinfo_get_datacontrol_appid(
1572 const char *providerid, char **appid)
1574 return pkgmgrinfo_appinfo_usr_get_datacontrol_appid(
1575 providerid, _getuid(), appid);
1578 API int pkgmgrinfo_appinfo_usr_get_datacontrol_trusted_info(
1579 const char *providerid, const char *type, uid_t uid,
1580 char **appid, bool *is_trusted)
1583 char *trusted = NULL;
1585 if (providerid == NULL || type == NULL || appid == NULL ||
1586 is_trusted == NULL) {
1587 LOGE("invalid parameter");
1588 return PMINFO_R_EINVAL;
1591 ret = _appinfo_get_datacontrol_trusted_info(providerid, type, uid,
1594 /* FIXME: It should return PMINFO_R_ENOENT but to keep previous
1595 * implementation, return PMINFO_R_ERROR. This should be
1598 if (ret == PMINFO_R_ENOENT) {
1599 LOGE("no datacontrol trusted info of %s", providerid);
1600 ret = PMINFO_R_ERROR;
1602 *is_trusted = _get_bool_value(trusted);
1608 API int pkgmgrinfo_appinfo_get_datacontrol_trsuted_info(const char *providerid,
1609 const char *type, char **appid, bool *is_trusted)
1611 return pkgmgrinfo_appinfo_usr_get_datacontrol_trusted_info(providerid,
1612 type, _getuid(), appid, is_trusted);
1615 API int pkgmgrinfo_appinfo_usr_foreach_datacontrol_privileges(
1616 const char *providerid, const char *type,
1617 pkgmgrinfo_pkg_privilege_list_cb privilege_func,
1618 void *user_data, uid_t uid)
1625 if (providerid == NULL || type == NULL || privilege_func == NULL) {
1626 LOGE("invalid parameter");
1627 return PMINFO_R_EINVAL;
1630 ret = _appinfo_get_datacontrol_privileges(providerid, type, uid, &list);
1631 if (ret == PMINFO_R_ERROR) {
1632 g_list_free_full(list, free);
1636 for (tmp = list; tmp != NULL; tmp = g_list_next(tmp)) {
1638 ret = privilege_func((char *)tmp->data, user_data);
1643 g_list_free_full(list, free);
1647 API int pkgmgrinfo_appinfo_foreach_datacontrol_privileges(
1648 const char *providerid, const char *type,
1649 pkgmgrinfo_pkg_privilege_list_cb privilege_func,
1652 return pkgmgrinfo_appinfo_usr_foreach_datacontrol_privileges(
1653 providerid, type, privilege_func, user_data, _getuid());
1656 API int pkgmgrinfo_appinfo_get_support_mode(
1657 pkgmgrinfo_appinfo_h handle, int *support_mode)
1659 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1660 retvm_if(support_mode == NULL, PMINFO_R_EINVAL,
1661 "Argument supplied to hold return value is NULL");
1663 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1665 if (info->app_info->support_mode)
1666 *support_mode = atoi(info->app_info->support_mode);
1673 API int pkgmgrinfo_appinfo_foreach_category(pkgmgrinfo_appinfo_h handle,
1674 pkgmgrinfo_app_category_list_cb category_func, void *user_data)
1676 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1677 retvm_if(category_func == NULL, PMINFO_R_EINVAL,
1678 "Callback function is NULL");
1680 const char *category;
1682 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1684 if (info->app_info == NULL)
1685 return PMINFO_R_ERROR;
1687 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
1688 category = (const char *)tmp->data;
1690 ret = category_func(category, user_data);
1698 API int pkgmgrinfo_appinfo_foreach_metadata(pkgmgrinfo_appinfo_h handle,
1699 pkgmgrinfo_app_metadata_list_cb metadata_func, void *user_data)
1701 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1702 retvm_if(metadata_func == NULL, PMINFO_R_EINVAL,
1703 "Callback function is NULL");
1707 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1709 if (info->app_info == NULL)
1710 return PMINFO_R_ERROR;
1712 for (tmp = info->app_info->metadata; tmp; tmp = tmp->next) {
1713 ptr = (metadata_x *)tmp->data;
1717 ret = metadata_func(ptr->key, ptr->value ?
1718 ptr->value : "", user_data);
1726 API int pkgmgrinfo_appinfo_usr_foreach_appcontrol_privileges(const char *appid,
1727 const char *operation,
1728 pkgmgrinfo_pkg_privilege_list_cb privilege_func,
1729 void *user_data, uid_t uid)
1732 GList *privilege_list = NULL;
1735 if (appid == NULL || operation == NULL || privilege_func == NULL) {
1736 LOGE("invalid parameter");
1737 return PMINFO_R_EINVAL;
1740 ret = _appinfo_get_appcontrol_privileges(appid, operation, uid,
1742 if (ret == PMINFO_R_ENOENT) {
1744 } else if (ret != PMINFO_R_OK) {
1745 g_list_free_full(privilege_list, free);
1749 for (tmp_list = privilege_list; tmp_list != NULL;
1750 tmp_list = g_list_next(tmp_list)) {
1751 ret = privilege_func((char *)tmp_list->data, user_data);
1756 g_list_free_full(privilege_list, free);
1760 API int pkgmgrinfo_appinfo_foreach_appcontrol_privileges(const char *appid,
1761 const char *operation,
1762 pkgmgrinfo_pkg_privilege_list_cb privilege_func,
1765 return pkgmgrinfo_appinfo_usr_foreach_appcontrol_privileges(appid,
1766 operation, privilege_func, user_data, _getuid());
1769 API int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
1770 pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
1772 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1773 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL,
1774 "Callback function is NULL");
1776 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1777 appcontrol_x *appcontrol;
1780 if (info->app_info == NULL)
1781 return PMINFO_R_ERROR;
1783 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
1784 appcontrol = (appcontrol_x *)tmp->data;
1785 if (appcontrol == NULL || !strcasecmp(
1786 appcontrol->visibility, "remote-only"))
1788 ret = appcontrol_func(appcontrol->operation,
1789 appcontrol->uri, appcontrol->mime, user_data);
1797 API int pkgmgrinfo_appinfo_foreach_remote_appcontrol(
1798 pkgmgrinfo_appinfo_h handle,
1799 pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
1801 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1802 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL,
1803 "Callback function is NULL");
1805 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1806 appcontrol_x *appcontrol;
1809 if (info->app_info == NULL)
1810 return PMINFO_R_ERROR;
1812 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
1813 appcontrol = (appcontrol_x *)tmp->data;
1814 if (appcontrol == NULL || !strcasecmp(
1815 appcontrol->visibility, "local-only"))
1817 ret = appcontrol_func(appcontrol->operation, appcontrol->uri,
1818 appcontrol->mime, user_data);
1826 API int pkgmgrinfo_appinfo_foreach_background_category(
1827 pkgmgrinfo_appinfo_h handle,
1828 pkgmgrinfo_app_background_category_list_cb category_func,
1831 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1835 if (handle == NULL || category_func == NULL || info->app_info == NULL) {
1836 LOGE("invalid parameter");
1837 return PMINFO_R_EINVAL;
1840 for (tmp = info->app_info->background_category; tmp; tmp = tmp->next) {
1841 category = (char *)tmp->data;
1842 if (category == NULL)
1845 if (category_func(category, user_data) < 0)
1852 API int pkgmgrinfo_appinfo_foreach_splash_screen(pkgmgrinfo_appinfo_h handle,
1853 pkgmgrinfo_app_splash_screen_list_cb splash_screen_func,
1856 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1857 splashscreen_x *splashscreen;
1861 if (info == NULL || info->app_info == NULL
1862 || splash_screen_func == NULL) {
1863 LOGE("invalid parameter");
1864 return PMINFO_R_EINVAL;
1867 for (tmp = info->app_info->splashscreens; tmp; tmp = tmp->next) {
1868 splashscreen = (splashscreen_x *)tmp->data;
1869 if (splashscreen == NULL)
1871 ret = splash_screen_func(splashscreen->src,
1873 splashscreen->orientation,
1874 splashscreen->indicatordisplay,
1875 splashscreen->operation,
1876 splashscreen->color_depth,
1885 API int pkgmgrinfo_appinfo_is_nodisplay(
1886 pkgmgrinfo_appinfo_h handle, bool *nodisplay)
1888 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1889 retvm_if(nodisplay == NULL, PMINFO_R_EINVAL,
1890 "Argument supplied to hold return value is NULL");
1891 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1893 if (info->app_info == NULL || info->app_info->nodisplay == NULL)
1894 return PMINFO_R_ERROR;
1896 *nodisplay = _get_bool_value(info->app_info->nodisplay);
1901 API int pkgmgrinfo_appinfo_is_multiple(
1902 pkgmgrinfo_appinfo_h handle, bool *multiple)
1904 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1905 retvm_if(multiple == NULL, PMINFO_R_EINVAL,
1906 "Argument supplied to hold return value is NULL");
1907 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1909 if (info->app_info == NULL || info->app_info->multiple == NULL)
1910 return PMINFO_R_ERROR;
1912 *multiple = _get_bool_value(info->app_info->multiple);
1917 API int pkgmgrinfo_appinfo_is_indicator_display_allowed(
1918 pkgmgrinfo_appinfo_h handle, bool *indicator_disp)
1920 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1921 retvm_if(indicator_disp == NULL, PMINFO_R_EINVAL,
1922 "Argument supplied to hold return value is NULL");
1923 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1925 if (info->app_info == NULL || info->app_info->indicatordisplay == NULL)
1926 return PMINFO_R_ERROR;
1928 *indicator_disp = _get_bool_value(info->app_info->indicatordisplay);
1933 API int pkgmgrinfo_appinfo_is_taskmanage(
1934 pkgmgrinfo_appinfo_h handle, bool *taskmanage)
1936 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1937 retvm_if(taskmanage == NULL, PMINFO_R_EINVAL,
1938 "Argument supplied to hold return value is NULL");
1939 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1941 if (info->app_info == NULL || info->app_info->taskmanage == NULL)
1942 return PMINFO_R_ERROR;
1944 *taskmanage = _get_bool_value(info->app_info->taskmanage);
1949 API int pkgmgrinfo_appinfo_is_enabled(
1950 pkgmgrinfo_appinfo_h handle, bool *enabled)
1952 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1953 retvm_if(enabled == NULL, PMINFO_R_EINVAL,
1954 "Argument supplied to hold return value is NULL");
1955 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1957 if (info->app_info == NULL || info->app_info->is_disabled == NULL)
1958 return PMINFO_R_ERROR;
1960 *enabled = !_get_bool_value(info->app_info->is_disabled);
1965 API int pkgmgrinfo_appinfo_is_onboot(
1966 pkgmgrinfo_appinfo_h handle, bool *onboot)
1968 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1969 retvm_if(onboot == NULL, PMINFO_R_EINVAL,
1970 "Argument supplied to hold return value is NULL");
1971 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1973 if (info->app_info == NULL || info->app_info->onboot == NULL)
1974 return PMINFO_R_ERROR;
1976 *onboot = _get_bool_value(info->app_info->onboot);
1981 API int pkgmgrinfo_appinfo_is_autorestart(
1982 pkgmgrinfo_appinfo_h handle, bool *autorestart)
1984 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1985 retvm_if(autorestart == NULL, PMINFO_R_EINVAL,
1986 "Argument supplied to hold return value is NULL");
1987 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1989 if (info->app_info == NULL || info->app_info->autorestart == NULL)
1990 return PMINFO_R_ERROR;
1992 *autorestart = _get_bool_value(info->app_info->autorestart);
1997 API int pkgmgrinfo_appinfo_is_mainapp(
1998 pkgmgrinfo_appinfo_h handle, bool *mainapp)
2000 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2001 retvm_if(mainapp == NULL, PMINFO_R_EINVAL,
2002 "Argument supplied to hold return value is NULL");
2003 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2005 if (info->app_info == NULL || info->app_info->mainapp == NULL)
2006 return PMINFO_R_ERROR;
2008 *mainapp = _get_bool_value(info->app_info->mainapp);
2013 API int pkgmgrinfo_appinfo_is_preload(
2014 pkgmgrinfo_appinfo_h handle, bool *preload)
2016 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2017 retvm_if(preload == NULL, PMINFO_R_EINVAL,
2018 "Argument supplied to hold return value is NULL\n");
2019 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2021 if (info->app_info == NULL || info->app_info->preload == NULL)
2022 return PMINFO_R_ERROR;
2024 *preload = _get_bool_value(info->app_info->preload);
2029 API int pkgmgrinfo_appinfo_is_submode(
2030 pkgmgrinfo_appinfo_h handle, bool *submode)
2032 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2033 retvm_if(submode == NULL, PMINFO_R_EINVAL,
2034 "Argument supplied to hold return value is NULL\n");
2035 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2037 if (info->app_info == NULL || info->app_info->submode == NULL)
2038 return PMINFO_R_ERROR;
2040 *submode = _get_bool_value(info->app_info->submode);
2045 API int pkgmgrinfo_appinfo_is_process_pool(
2046 pkgmgrinfo_appinfo_h handle, bool *process_pool)
2048 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2050 if (handle == NULL || process_pool == NULL) {
2051 LOGE("invalid parameter");
2052 return PMINFO_R_EINVAL;
2055 if (info->app_info == NULL)
2056 return PMINFO_R_ERROR;
2058 *process_pool = _get_bool_value(info->app_info->process_pool);
2063 API int pkgmgrinfo_appinfo_is_category_exist(
2064 pkgmgrinfo_appinfo_h handle, const char *category, bool *exist)
2066 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2067 retvm_if(category == NULL, PMINFO_R_EINVAL, "category is NULL");
2068 retvm_if(exist == NULL, PMINFO_R_EINVAL, "exist is NULL");
2072 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2074 if (info->app_info == NULL)
2075 return PMINFO_R_ERROR;
2078 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
2079 val = (const char *)tmp->data;
2082 if (strcasecmp(val, category) == 0) {
2091 API int pkgmgrinfo_appinfo_is_ui_gadget(pkgmgrinfo_appinfo_h handle,
2094 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2096 if (info == NULL || info->app_info == NULL || ui_gadget == NULL) {
2097 _LOGE("invalid parameter");
2098 return PMINFO_R_EINVAL;
2100 if (info->app_info->ui_gadget == NULL)
2101 info->app_info->ui_gadget = strdup("false");
2103 *ui_gadget = _get_bool_value(info->app_info->ui_gadget);
2108 API int pkgmgrinfo_appinfo_is_support_disable(pkgmgrinfo_appinfo_h handle,
2109 bool *support_disable)
2111 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2113 if (info == NULL || info->app_info == NULL || support_disable == NULL) {
2114 _LOGE("invalid parameter");
2115 return PMINFO_R_EINVAL;
2118 *support_disable = _get_bool_value(info->app_info->support_disable);
2123 API int pkgmgrinfo_appinfo_is_removable(pkgmgrinfo_appinfo_h handle,
2126 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2128 if (info == NULL || info->app_info == NULL || removable == NULL) {
2129 _LOGE("invalid parameter");
2130 return PMINFO_R_EINVAL;
2133 *removable = _get_bool_value(info->app_info->removable);
2138 API int pkgmgrinfo_appinfo_is_system(pkgmgrinfo_appinfo_h handle, bool *system)
2140 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2142 if (info == NULL || info->app_info == NULL || system == NULL) {
2143 _LOGE("invalid parameter");
2144 return PMINFO_R_EINVAL;
2147 *system = _get_bool_value(info->app_info->package_system);
2152 API int pkgmgrinfo_appinfo_is_disabled(
2153 pkgmgrinfo_appinfo_h handle, bool *disabled)
2155 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2156 retvm_if(disabled == NULL, PMINFO_R_EINVAL,
2157 "Argument supplied to hold return value is NULL");
2158 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2160 if (info->app_info == NULL || info->app_info->is_disabled == NULL)
2161 return PMINFO_R_ERROR;
2163 *disabled = _get_bool_value(info->app_info->is_disabled);
2168 API int pkgmgrinfo_appinfo_is_global(pkgmgrinfo_appinfo_h handle, bool *global)
2170 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2172 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2173 retvm_if(global == NULL, PMINFO_R_EINVAL,
2174 "Argument supplied to hold return value is NULL\n");
2176 if (info->app_info == NULL || info->app_info->for_all_users == NULL)
2177 return PMINFO_R_ERROR;
2179 *global = _get_bool_value(info->app_info->for_all_users);
2184 API int pkgmgrinfo_appinfo_get_splash_screen_display(
2185 pkgmgrinfo_appinfo_h handle, bool *splash_screen_display)
2187 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2189 if (info == NULL || splash_screen_display == NULL) {
2190 _LOGE("Invalid parameter");
2191 return PMINFO_R_EINVAL;
2194 if (info->app_info == NULL ||
2195 info->app_info->splash_screen_display == NULL)
2196 return PMINFO_R_ERROR;
2198 *splash_screen_display =
2199 _get_bool_value(info->app_info->splash_screen_display);
2204 API int pkgmgrinfo_appinfo_get_setup_appid(
2205 pkgmgrinfo_appinfo_h handle, char **setup_appid)
2207 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2209 if (info == NULL || setup_appid == NULL) {
2210 _LOGE("Invalid parameter");
2211 return PMINFO_R_EINVAL;
2214 if (info->app_info == NULL || info->app_info->setup_appid == NULL)
2215 return PMINFO_R_ERROR;
2217 *setup_appid = info->app_info->setup_appid;
2221 API int pkgmgrinfo_appinfo_is_support_ambient(pkgmgrinfo_appinfo_h handle,
2222 bool *support_ambient)
2224 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2226 if (info == NULL || support_ambient == NULL) {
2227 _LOGE("Invalid parameter");
2228 return PMINFO_R_EINVAL;
2231 if (info->app_info == NULL || info->app_info->support_ambient == NULL)
2232 return PMINFO_R_ERROR;
2234 *support_ambient = _get_bool_value(info->app_info->support_ambient);
2239 API int pkgmgrinfo_appinfo_destroy_appinfo(pkgmgrinfo_appinfo_h handle)
2241 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2242 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2244 __cleanup_appinfo(info);
2248 API int pkgmgrinfo_appinfo_filter_create(pkgmgrinfo_appinfo_filter_h *handle)
2250 return pkgmgrinfo_pkginfo_filter_create(handle);
2253 API int pkgmgrinfo_appinfo_filter_destroy(pkgmgrinfo_appinfo_filter_h handle)
2255 return pkgmgrinfo_pkginfo_filter_destroy(handle);
2258 static gint __compare_func(gconstpointer data1, gconstpointer data2)
2260 pkgmgrinfo_node_x *node1 = (pkgmgrinfo_node_x *)data1;
2261 pkgmgrinfo_node_x *node2 = (pkgmgrinfo_node_x *)data2;
2263 if (node1->prop == node2->prop)
2265 else if (node1->prop > node2->prop)
2271 API int pkgmgrinfo_appinfo_filter_add_int(pkgmgrinfo_appinfo_filter_h handle,
2272 const char *property, const int value)
2274 retvm_if(handle == NULL, PMINFO_R_EINVAL,
2275 "Filter handle input parameter is NULL\n");
2276 retvm_if(property == NULL, PMINFO_R_EINVAL,
2277 "Filter handle input parameter is NULL\n");
2278 char buf[PKG_VALUE_STRING_LEN_MAX] = {'\0'};
2280 GSList *link = NULL;
2283 prop = _pminfo_appinfo_convert_to_prop_int(property);
2284 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_INT ||
2285 prop > E_PMINFO_APPINFO_PROP_APP_MAX_INT) {
2286 _LOGE("Invalid Integer Property\n");
2287 return PMINFO_R_EINVAL;
2289 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2290 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1,
2291 sizeof(pkgmgrinfo_node_x));
2293 _LOGE("Out of Memory!!!\n");
2294 return PMINFO_R_ERROR;
2296 snprintf(buf, PKG_VALUE_STRING_LEN_MAX - 1, "%d", value);
2297 val = strndup(buf, PKG_VALUE_STRING_LEN_MAX - 1);
2299 _LOGE("Out of Memory\n");
2302 return PMINFO_R_ERROR;
2308 * If API is called multiple times for same property,
2309 * we should override the previous values.
2310 * Last value set will be used for filtering.
2312 link = g_slist_find_custom(filter->list,
2313 (gconstpointer)node, __compare_func);
2315 filter->list = g_slist_delete_link(filter->list, link);
2316 filter->list = g_slist_append(filter->list, (gpointer)node);
2321 API int pkgmgrinfo_appinfo_filter_add_bool(pkgmgrinfo_appinfo_filter_h handle,
2322 const char *property, const bool value)
2324 retvm_if(handle == NULL, PMINFO_R_EINVAL,
2325 "Filter handle input parameter is NULL\n");
2326 retvm_if(property == NULL, PMINFO_R_EINVAL,
2327 "Filter handle input parameter is NULL\n");
2329 GSList *link = NULL;
2332 prop = _pminfo_appinfo_convert_to_prop_bool(property);
2333 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_BOOL ||
2334 prop > E_PMINFO_APPINFO_PROP_APP_MAX_BOOL) {
2335 _LOGE("Invalid Boolean Property\n");
2336 return PMINFO_R_EINVAL;
2338 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2339 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1,
2340 sizeof(pkgmgrinfo_node_x));
2342 _LOGE("Out of Memory!!!\n");
2343 return PMINFO_R_ERROR;
2346 val = strndup("true", 4);
2348 val = strndup("false", 5);
2350 _LOGE("Out of Memory\n");
2353 return PMINFO_R_ERROR;
2358 * If API is called multiple times for same property,
2359 * we should override the previous values.
2360 * Last value set will be used for filtering.
2362 link = g_slist_find_custom(filter->list,
2363 (gconstpointer)node, __compare_func);
2365 filter->list = g_slist_delete_link(filter->list, link);
2366 filter->list = g_slist_append(filter->list, (gpointer)node);
2371 API int pkgmgrinfo_appinfo_filter_add_string(pkgmgrinfo_appinfo_filter_h handle,
2372 const char *property, const char *value)
2374 retvm_if(handle == NULL, PMINFO_R_EINVAL,
2375 "Filter handle input parameter is NULL\n");
2376 retvm_if(property == NULL, PMINFO_R_EINVAL,
2377 "Filter handle input parameter is NULL\n");
2378 retvm_if(value == NULL, PMINFO_R_EINVAL,
2379 "Filter handle input parameter is NULL\n");
2381 pkgmgrinfo_node_x *ptr = NULL;
2382 char prev[PKG_STRING_LEN_MAX] = {'\0'};
2383 char temp[PKG_STRING_LEN_MAX] = {'\0'};
2384 GSList *link = NULL;
2388 prop = _pminfo_appinfo_convert_to_prop_str(property);
2389 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_STR ||
2390 prop > E_PMINFO_APPINFO_PROP_APP_MAX_STR) {
2391 _LOGE("Invalid String Property\n");
2392 return PMINFO_R_EINVAL;
2394 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2395 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1,
2396 sizeof(pkgmgrinfo_node_x));
2398 _LOGE("Out of Memory!!!\n");
2399 return PMINFO_R_ERROR;
2403 case E_PMINFO_APPINFO_PROP_APP_COMPONENT:
2404 node->value = strdup(value);
2405 link = g_slist_find_custom(filter->list,
2406 (gconstpointer)node, __compare_func);
2408 filter->list = g_slist_delete_link(filter->list, link);
2409 filter->list = g_slist_append(filter->list, (gpointer)node);
2411 case E_PMINFO_APPINFO_PROP_APP_CATEGORY:
2412 val = (char *)calloc(1, PKG_STRING_LEN_MAX);
2414 _LOGE("Out of Memory\n");
2417 return PMINFO_R_ERROR;
2419 link = g_slist_find_custom(filter->list,
2420 (gconstpointer)node, __compare_func);
2422 ptr = (pkgmgrinfo_node_x *)link->data;
2423 strncpy(prev, ptr->value, PKG_STRING_LEN_MAX - 1);
2424 _LOGI("Previous value is %s\n", prev);
2425 filter->list = g_slist_delete_link(filter->list, link);
2426 ret = snprintf(temp, PKG_STRING_LEN_MAX - 1,
2427 "%s,%s", prev, value);
2428 if (ret < 0 || ret > PKG_STRING_LEN_MAX - 1) {
2429 _LOGE("snprintf fail\n");
2432 return PMINFO_R_ERROR;
2434 strncpy(val, temp, PKG_STRING_LEN_MAX);
2435 _LOGI("New value is %s\n", val);
2437 filter->list = g_slist_append(
2438 filter->list, (gpointer)node);
2439 memset(temp, '\0', PKG_STRING_LEN_MAX);
2441 snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s", value);
2442 strncpy(val, temp, PKG_STRING_LEN_MAX);
2443 _LOGI("First value is %s\n", val);
2445 filter->list = g_slist_append(
2446 filter->list, (gpointer)node);
2447 memset(temp, '\0', PKG_STRING_LEN_MAX);
2451 node->value = strndup(value, PKG_STRING_LEN_MAX - 1);
2452 link = g_slist_find_custom(filter->list,
2453 (gconstpointer)node, __compare_func);
2455 filter->list = g_slist_delete_link(filter->list, link);
2456 filter->list = g_slist_append(filter->list, (gpointer)node);
2462 API int pkgmgrinfo_appinfo_usr_filter_count(
2463 pkgmgrinfo_appinfo_filter_h handle, int *count, uid_t uid)
2468 pkgmgrinfo_filter_x *filter;
2470 if (handle == NULL || count == NULL) {
2471 _LOGE("invalid parameter");
2472 return PMINFO_R_EINVAL;
2475 filter = (pkgmgrinfo_filter_x *)handle;
2476 list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
2477 __free_applications);
2479 return PMINFO_R_ERROR;
2481 if (__check_disable_filter_exist(
2482 handle, E_APPINFO_DISABLE_TYPE_APP) == false) {
2483 if (pkgmgrinfo_appinfo_filter_add_bool(handle,
2484 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
2485 g_hash_table_destroy(list);
2486 return PMINFO_R_ERROR;
2490 if (__check_disable_filter_exist(
2491 handle, E_APPINFO_DISABLE_TYPE_PKG) == false) {
2492 if (pkgmgrinfo_appinfo_filter_add_bool(handle,
2493 PMINFO_APPINFO_PROP_PKG_DISABLE, false)) {
2494 g_hash_table_destroy(list);
2495 return PMINFO_R_ERROR;
2499 ret = _appinfo_get_applications(uid, filter, 0, list);
2500 query_count = g_hash_table_size(list);
2501 g_hash_table_destroy(list);
2502 if (ret == PMINFO_R_ERROR)
2505 *count = query_count;
2509 API int pkgmgrinfo_appinfo_filter_count(
2510 pkgmgrinfo_appinfo_filter_h handle, int *count)
2512 return pkgmgrinfo_appinfo_usr_filter_count(handle, count, _getuid());
2515 API int pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(
2516 pkgmgrinfo_appinfo_filter_h handle,
2517 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
2519 if (handle == NULL || app_cb == NULL) {
2520 LOGE("invalid parameter");
2521 return PMINFO_R_EINVAL;
2524 if (__check_disable_filter_exist(
2525 handle, E_APPINFO_DISABLE_TYPE_APP) == false) {
2526 if (pkgmgrinfo_appinfo_filter_add_bool(handle,
2527 PMINFO_APPINFO_PROP_APP_DISABLE, false))
2528 return PMINFO_R_ERROR;
2531 if (__check_disable_filter_exist(
2532 handle, E_APPINFO_DISABLE_TYPE_PKG) == false) {
2533 if (pkgmgrinfo_appinfo_filter_add_bool(handle,
2534 PMINFO_APPINFO_PROP_PKG_DISABLE, false))
2535 return PMINFO_R_ERROR;
2538 return _appinfo_get_filtered_foreach_appinfo(uid,
2539 handle, PMINFO_APPINFO_GET_ALL, app_cb, user_data);
2542 API int pkgmgrinfo_appinfo_filter_foreach_appinfo(
2543 pkgmgrinfo_appinfo_filter_h handle,
2544 pkgmgrinfo_app_list_cb app_cb, void *user_data)
2546 return pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(
2547 handle, app_cb, user_data, _getuid());
2550 API int pkgmgrinfo_appinfo_metadata_filter_create(
2551 pkgmgrinfo_appinfo_metadata_filter_h *handle)
2553 return pkgmgrinfo_pkginfo_filter_create(handle);
2556 API int pkgmgrinfo_appinfo_metadata_filter_destroy(
2557 pkgmgrinfo_appinfo_metadata_filter_h handle)
2559 return pkgmgrinfo_pkginfo_filter_destroy(handle);
2562 API int pkgmgrinfo_appinfo_metadata_filter_add(
2563 pkgmgrinfo_appinfo_metadata_filter_h handle,
2564 const char *key, const char *value)
2566 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2567 pkgmgrinfo_metadata_node_x *node;
2569 /* value can be NULL.
2570 * In that case all apps with specified key should be displayed
2573 LOGE("invalid parameter");
2574 return PMINFO_R_EINVAL;
2577 node = calloc(1, sizeof(pkgmgrinfo_metadata_node_x));
2579 LOGE("out of memory");
2580 return PMINFO_R_ERROR;
2583 node->key = strdup(key);
2584 if (value && strlen(value))
2585 node->value = strdup(value);
2587 filter->list_metadata = g_slist_append(filter->list_metadata,
2593 API int pkgmgrinfo_appinfo_usr_metadata_filter_foreach(
2594 pkgmgrinfo_appinfo_metadata_filter_h handle,
2595 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
2597 if (handle == NULL || app_cb == NULL) {
2598 LOGE("invalid parameter");
2599 return PMINFO_R_EINVAL;
2602 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2604 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
2605 PMINFO_APPINFO_PROP_APP_DISABLE, false))
2606 return PMINFO_R_ERROR;
2608 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
2609 PMINFO_APPINFO_PROP_PKG_DISABLE, false))
2610 return PMINFO_R_ERROR;
2612 return _appinfo_get_filtered_foreach_appinfo(uid, handle,
2613 PMINFO_APPINFO_GET_ALL, app_cb,
2617 API int pkgmgrinfo_appinfo_metadata_filter_foreach(
2618 pkgmgrinfo_appinfo_metadata_filter_h handle,
2619 pkgmgrinfo_app_list_cb app_cb, void *user_data)
2621 return pkgmgrinfo_appinfo_usr_metadata_filter_foreach(handle, app_cb,
2622 user_data, _getuid());
2625 API int pkgmgrinfo_appinfo_is_guestmode_visibility(
2626 pkgmgrinfo_appinfo_h handle, bool *status)
2629 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2631 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2632 retvm_if(status == NULL, PMINFO_R_EINVAL,
2633 "Argument supplied to hold return value is NULL\n");
2635 val = info->app_info->guestmode_visibility;
2636 *status = _get_bool_value(val);
2640 API int pkgmgrinfo_appinfo_foreach_appcontrol_v2(pkgmgrinfo_appinfo_h handle,
2641 pkgmgrinfo_app_control_list_cb_v2 appcontrol_func,
2644 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2645 retvm_if(appcontrol_func == NULL,
2646 PMINFO_R_EINVAL, "Callback function is NULL");
2648 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2649 appcontrol_x *appcontrol;
2652 if (info->app_info == NULL)
2653 return PMINFO_R_ERROR;
2655 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
2656 appcontrol = (appcontrol_x *)tmp->data;
2657 if (appcontrol == NULL ||
2658 !strcasecmp(appcontrol->visibility,
2661 ret = appcontrol_func(appcontrol->operation, appcontrol->uri,
2662 appcontrol->mime, appcontrol->id, user_data);
2670 API int pkgmgrinfo_appinfo_foreach_remote_appcontrol_v2(
2671 pkgmgrinfo_appinfo_h handle,
2672 pkgmgrinfo_app_control_list_cb_v2 appcontrol_func,
2675 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2676 retvm_if(appcontrol_func == NULL,
2677 PMINFO_R_EINVAL, "Callback function is NULL");
2679 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2680 appcontrol_x *appcontrol;
2683 if (info->app_info == NULL)
2684 return PMINFO_R_ERROR;
2686 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
2687 appcontrol = (appcontrol_x *)tmp->data;
2688 if (appcontrol == NULL ||
2689 !strcasecmp(appcontrol->visibility,
2692 ret = appcontrol_func(appcontrol->operation, appcontrol->uri,
2693 appcontrol->mime, appcontrol->id, user_data);