13 #include "pkgmgr-info.h"
14 #include "pkgmgrinfo_debug.h"
15 #include "pkgmgrinfo_private.h"
16 #include "pkgmgr_parser.h"
18 static bool _get_bool_value(const char *str)
22 else if (!strcasecmp(str, "true"))
28 static void __cleanup_appinfo(pkgmgr_appinfo_x *data)
30 pkgmgr_appinfo_x *info = data;
31 pkgmgr_appinfo_x *tmp;
33 while (info != NULL) {
36 free((void *)info->package);
38 free((void *)info->locale);
40 pkgmgrinfo_basic_free_application(info->app_info);
47 static char *_get_filtered_query(const char *query_raw,
48 pkgmgrinfo_filter_x *filter)
50 char buf[MAX_QUERY_LEN] = { 0, };
59 strncat(buf, query_raw, MAX_QUERY_LEN - 1);
61 for (list = head; list; list = list->next) {
62 /* TODO: revise condition getter function */
63 __get_filter_condition(list->data, &condition);
64 if (condition == NULL)
66 if (buf[strlen(query_raw)] == '\0') {
67 len += strlen(" WHERE ");
68 strncat(buf, " WHERE ", MAX_QUERY_LEN - len - 1);
70 len += strlen(" AND ");
71 strncat(buf, " AND ", MAX_QUERY_LEN -len - 1);
73 len += strlen(condition);
74 strncat(buf, condition, sizeof(buf) - len - 1);
82 static gint __list_strcmp(gconstpointer a, gconstpointer b)
84 return strcmp((char *)a, (char *)b);
87 static gint _appinfo_get_list(sqlite3 *db, const char *locale,
88 pkgmgrinfo_filter_x *filter, GList **list)
90 static const char query_raw[] =
91 "SELECT DISTINCT package_app_info.app_id FROM package_app_info"
92 " LEFT OUTER JOIN package_app_localized_info"
93 " ON package_app_info.app_id=package_app_localized_info.app_id"
94 " AND package_app_localized_info.app_locale=%Q"
95 " LEFT OUTER JOIN package_app_app_category"
96 " ON package_app_info.app_id=package_app_app_category.app_id"
97 " LEFT OUTER JOIN package_app_app_control"
98 " ON package_app_info.app_id=package_app_app_control.app_id"
99 " LEFT OUTER JOIN package_app_app_metadata"
100 " ON package_app_info.app_id=package_app_app_metadata.app_id ";
103 char *query_localized;
107 query = _get_filtered_query(query_raw, filter);
109 return PMINFO_R_ERROR;
110 query_localized = sqlite3_mprintf(query, locale);
112 if (query_localized == NULL)
113 return PMINFO_R_ERROR;
115 ret = sqlite3_prepare_v2(db, query_localized,
116 strlen(query_localized), &stmt, NULL);
117 sqlite3_free(query_localized);
118 if (ret != SQLITE_OK) {
119 LOGE("prepare failed: %s", sqlite3_errmsg(db));
120 return PMINFO_R_ERROR;
123 while (sqlite3_step(stmt) == SQLITE_ROW) {
124 _save_column_str(stmt, 0, (const char **)&appid);
126 *list = g_list_insert_sorted(*list, appid,
130 sqlite3_finalize(stmt);
135 static int _appinfo_get_filtered_list(pkgmgrinfo_filter_x *filter, uid_t uid,
145 locale = _get_system_locale();
147 return PMINFO_R_ERROR;
149 dbpath = getUserPkgParserDBPathUID(uid);
150 if (dbpath == NULL) {
152 return PMINFO_R_ERROR;
155 ret = sqlite3_open_v2(dbpath, &db, SQLITE_OPEN_READONLY, NULL);
156 if (ret != SQLITE_OK) {
157 _LOGE("failed to open db: %d", ret);
159 return PMINFO_R_ERROR;
162 if (_appinfo_get_list(db, locale, filter, list)) {
164 sqlite3_close_v2(db);
165 return PMINFO_R_ERROR;
167 sqlite3_close_v2(db);
169 if (uid == GLOBAL_USER) {
174 /* search again from global */
175 dbpath = getUserPkgParserDBPathUID(GLOBAL_USER);
176 if (dbpath == NULL) {
178 return PMINFO_R_ERROR;
181 ret = sqlite3_open_v2(dbpath, &db, SQLITE_OPEN_READONLY, NULL);
182 if (ret != SQLITE_OK) {
183 _LOGE("failed to open db: %d", ret);
185 return PMINFO_R_ERROR;
188 if (_appinfo_get_list(db, locale, filter, list)) {
190 sqlite3_close_v2(db);
191 return PMINFO_R_ERROR;
193 sqlite3_close_v2(db);
195 /* remove duplicate element:
196 * since the list is sorted, we can remove duplicates in linear time
198 for (tmp = *list, tmp2 = g_list_next(tmp); tmp;
199 tmp = tmp2, tmp2 = g_list_next(tmp)) {
200 if (tmp->prev == NULL || tmp->data == NULL)
202 if (strcmp((const char *)tmp->prev->data,
203 (const char *)tmp->data) == 0)
204 *list = g_list_delete_link(*list, tmp);
212 static int _appinfo_get_label(sqlite3 *db, const char *appid,
213 const char *locale, GList **label)
215 static const char query_raw[] =
216 "SELECT app_label, app_locale "
217 "FROM package_app_localized_info "
218 "WHERE app_id=%Q AND app_locale IN (%Q, %Q)";
225 query = sqlite3_mprintf(query_raw, appid, locale, DEFAULT_LOCALE);
227 LOGE("out of memory");
228 return PMINFO_R_ERROR;
231 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
233 if (ret != SQLITE_OK) {
234 LOGE("prepare failed: %s", sqlite3_errmsg(db));
235 return PMINFO_R_ERROR;
238 while (sqlite3_step(stmt) == SQLITE_ROW) {
239 info = calloc(1, sizeof(label_x));
241 LOGE("out of memory");
242 sqlite3_finalize(stmt);
243 return PMINFO_R_ERROR;
246 _save_column_str(stmt, idx++, &info->text);
247 _save_column_str(stmt, idx++, &info->lang);
248 *label = g_list_append(*label, info);
251 sqlite3_finalize(stmt);
256 static void _appinfo_modify_icon(const char *appid, const char **icon)
258 char buf[PKG_VALUE_STRING_LEN_MAX];
261 if (*icon == NULL || (*icon)[0] == '/' || !strcasecmp(*icon, "(null)"))
265 snprintf(buf, sizeof(buf), "%s%s.png", getIconPath(getuid()), appid);
270 static int _appinfo_get_icon(sqlite3 *db, const char *appid, const char *locale,
273 static const char query_raw[] =
274 "SELECT app_icon, app_locale "
275 "FROM package_app_localized_info "
276 "WHERE app_id=%Q AND app_locale IN (%Q, %Q)";
283 query = sqlite3_mprintf(query_raw, appid, locale, DEFAULT_LOCALE);
285 LOGE("out of memory");
286 return PMINFO_R_ERROR;
289 ret = sqlite3_prepare_v2(db, query, strlen(query),
292 if (ret != SQLITE_OK) {
293 LOGE("prepare failed: %s", sqlite3_errmsg(db));
294 return PMINFO_R_ERROR;
297 while (sqlite3_step(stmt) == SQLITE_ROW) {
298 info = calloc(1, sizeof(icon_x));
300 LOGE("out of memory");
301 sqlite3_finalize(stmt);
302 return PMINFO_R_ERROR;
305 _save_column_str(stmt, idx++, &info->text);
306 /* FIXME: this is a workaround. this must be removed later */
307 _appinfo_modify_icon(appid, &info->text);
308 _save_column_str(stmt, idx++, &info->lang);
309 *icon = g_list_append(*icon, info);
312 sqlite3_finalize(stmt);
317 static int _appinfo_get_category(sqlite3 *db, const char *appid,
320 static const char query_raw[] =
321 "SELECT category FROM package_app_app_category WHERE app_id=%Q";
327 query = sqlite3_mprintf(query_raw, appid);
329 LOGE("out of memory");
330 return PMINFO_R_ERROR;
333 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
335 if (ret != SQLITE_OK) {
336 LOGE("prepare failed: %s", sqlite3_errmsg(db));
337 return PMINFO_R_ERROR;
340 while (sqlite3_step(stmt) == SQLITE_ROW) {
342 _save_column_str(stmt, 0, &val);
344 *category = g_list_append(*category, (gpointer)val);
347 sqlite3_finalize(stmt);
352 static void __parse_appcontrol(GList **appcontrol, char *appcontrol_str)
359 if (appcontrol_str == NULL)
362 dup = strdup(appcontrol_str);
364 ac = calloc(1, sizeof(appcontrol_x));
366 _LOGE("out of memory");
369 token = strtok_r(dup, "|", &ptr);
370 if (token && strcmp(token, "NULL"))
371 ac->operation = strdup(token);
372 token = strtok_r(NULL, "|", &ptr);
373 if (token && strcmp(token, "NULL"))
374 ac->uri = strdup(token);
375 token = strtok_r(NULL, "|", &ptr);
376 if (token && strcmp(token, "NULL"))
377 ac->mime = strdup(token);
378 *appcontrol = g_list_append(*appcontrol, ac);
379 } while ((token = strtok_r(NULL, ";", &ptr)));
384 static int _appinfo_get_app_control(sqlite3 *db, const char *appid,
387 static const char query_raw[] =
388 "SELECT app_control FROM package_app_app_control "
395 query = sqlite3_mprintf(query_raw, appid);
397 LOGE("out of memory");
398 return PMINFO_R_ERROR;
401 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
403 if (ret != SQLITE_OK) {
404 LOGE("prepare failed: %s", sqlite3_errmsg(db));
405 return PMINFO_R_ERROR;
408 while (sqlite3_step(stmt) == SQLITE_ROW) {
410 _save_column_str(stmt, 0, (const char **)&str);
412 __parse_appcontrol(appcontrol, str);
416 sqlite3_finalize(stmt);
421 static int _appinfo_get_data_control(sqlite3 *db, const char *appid,
424 static const char query_raw[] =
425 "SELECT providerid, access, type "
426 "FROM package_app_data_control WHERE app_id=%Q";
433 query = sqlite3_mprintf(query_raw, appid);
435 LOGE("out of memory");
436 return PMINFO_R_ERROR;
439 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
441 if (ret != SQLITE_OK) {
442 LOGE("prepare failed: %s", sqlite3_errmsg(db));
443 return PMINFO_R_ERROR;
446 while (sqlite3_step(stmt) == SQLITE_ROW) {
447 info = calloc(1, sizeof(datacontrol_x));
449 LOGE("out of memory");
450 sqlite3_finalize(stmt);
451 return PMINFO_R_ERROR;
454 _save_column_str(stmt, idx++, &info->providerid);
455 _save_column_str(stmt, idx++, &info->access);
456 _save_column_str(stmt, idx++, &info->type);
457 *datacontrol = g_list_append(*datacontrol, info);
460 sqlite3_finalize(stmt);
465 static int _appinfo_get_metadata(sqlite3 *db, const char *appid,
468 static const char query_raw[] =
469 "SELECT md_key, md_value "
470 "FROM package_app_app_metadata WHERE app_id=%Q";
477 query = sqlite3_mprintf(query_raw, appid);
479 LOGE("out of memory");
480 return PMINFO_R_ERROR;
483 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
485 if (ret != SQLITE_OK) {
486 LOGE("prepare failed: %s", sqlite3_errmsg(db));
487 return PMINFO_R_ERROR;
490 while (sqlite3_step(stmt) == SQLITE_ROW) {
491 info = calloc(1, sizeof(metadata_x));
493 LOGE("out of memory");
494 sqlite3_finalize(stmt);
495 return PMINFO_R_ERROR;
498 _save_column_str(stmt, idx++, &info->key);
499 _save_column_str(stmt, idx++, &info->value);
500 *metadata = g_list_append(*metadata, info);
503 sqlite3_finalize(stmt);
509 static GList *__get_background_category(char *value)
511 GList *category_list = NULL;
512 int convert_value = 0;
513 if (!value || strlen(value) == 0)
516 convert_value = atoi(value);
517 if (convert_value < 0)
520 if (convert_value & APP_BG_CATEGORY_USER_DISABLE_TRUE_VAL)
521 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_USER_DISABLE_TRUE_STR));
523 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_USER_DISABLE_FALSE_STR));
525 if (convert_value & APP_BG_CATEGORY_MEDIA_VAL)
526 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_MEDIA_STR));
528 if (convert_value & APP_BG_CATEGORY_DOWNLOAD_VAL)
529 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_DOWNLOAD_STR));
531 if (convert_value & APP_BG_CATEGORY_BGNETWORK_VAL)
532 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_BGNETWORK_STR));
534 if (convert_value & APP_BG_CATEGORY_LOCATION_VAL)
535 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_LOCATION_STR));
537 if (convert_value & APP_BG_CATEGORY_SENSOR_VAL)
538 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_SENSOR_STR));
540 if (convert_value & APP_BG_CATEGORY_IOTCOMM_VAL)
541 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_IOTCOMM_STR));
543 if (convert_value & APP_BG_CATEGORY_SYSTEM_VAL)
544 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_SYSTEM));
546 return category_list;
550 static int _appinfo_get_application(sqlite3 *db, const char *appid,
551 const char *locale, application_x **application)
553 static const char query_raw[] =
554 "SELECT app_id, app_component, app_exec, app_nodisplay, "
555 "app_type, app_onboot, app_multiple, app_autorestart, "
556 "app_taskmanage, app_enabled, app_hwacceleration, "
557 "app_screenreader, app_mainapp, app_recentimage, "
558 "app_launchcondition, app_indicatordisplay, app_portraitimg, "
559 "app_landscapeimg, app_guestmodevisibility, "
560 "app_permissiontype, app_preload, app_submode, "
561 "app_submode_mainid, app_launch_mode, app_ui_gadget, "
562 "app_support_disable, "
563 "component_type, package, app_process_pool, app_installed_storage, "
564 "app_background_category "
565 "FROM package_app_info WHERE app_id=%Q";
571 char *bg_category_str = NULL;
573 query = sqlite3_mprintf(query_raw, appid);
575 LOGE("out of memory");
576 return PMINFO_R_ERROR;
579 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
581 if (ret != SQLITE_OK) {
582 LOGE("prepare failed: %s", sqlite3_errmsg(db));
583 return PMINFO_R_ERROR;
586 ret = sqlite3_step(stmt);
587 if (ret == SQLITE_DONE) {
588 sqlite3_finalize(stmt);
589 return PMINFO_R_ENOENT;
590 } else if (ret != SQLITE_ROW) {
591 LOGE("step failed: %s", sqlite3_errmsg(db));
592 sqlite3_finalize(stmt);
593 return PMINFO_R_ERROR;
596 info = calloc(1, sizeof(application_x));
598 LOGE("out of memory");
599 sqlite3_finalize(stmt);
600 return PMINFO_R_ERROR;
603 _save_column_str(stmt, idx++, &info->appid);
604 _save_column_str(stmt, idx++, &info->component);
605 _save_column_str(stmt, idx++, &info->exec);
606 _save_column_str(stmt, idx++, &info->nodisplay);
607 _save_column_str(stmt, idx++, &info->type);
608 _save_column_str(stmt, idx++, &info->onboot);
609 _save_column_str(stmt, idx++, &info->multiple);
610 _save_column_str(stmt, idx++, &info->autorestart);
611 _save_column_str(stmt, idx++, &info->taskmanage);
612 _save_column_str(stmt, idx++, &info->enabled);
613 _save_column_str(stmt, idx++, &info->hwacceleration);
614 _save_column_str(stmt, idx++, &info->screenreader);
615 _save_column_str(stmt, idx++, &info->mainapp);
616 _save_column_str(stmt, idx++, &info->recentimage);
617 _save_column_str(stmt, idx++, &info->launchcondition);
618 _save_column_str(stmt, idx++, &info->indicatordisplay);
619 _save_column_str(stmt, idx++, &info->portraitimg);
620 _save_column_str(stmt, idx++, &info->landscapeimg);
621 _save_column_str(stmt, idx++, &info->guestmode_visibility);
622 _save_column_str(stmt, idx++, &info->permission_type);
623 _save_column_str(stmt, idx++, &info->preload);
624 _save_column_str(stmt, idx++, &info->submode);
625 _save_column_str(stmt, idx++, &info->submode_mainid);
626 _save_column_str(stmt, idx++, &info->launch_mode);
627 _save_column_str(stmt, idx++, &info->ui_gadget);
628 _save_column_str(stmt, idx++, &info->support_disable);
629 _save_column_str(stmt, idx++, &info->component_type);
630 _save_column_str(stmt, idx++, &info->package);
631 _save_column_str(stmt, idx++, &info->process_pool);
632 _save_column_str(stmt, idx++, &info->installed_storage);
633 _save_column_str(stmt, idx++, &bg_category_str);
635 info->background_category = __get_background_category(bg_category_str);
637 if (_appinfo_get_label(db, info->appid, locale, &info->label)) {
638 pkgmgrinfo_basic_free_application(info);
639 sqlite3_finalize(stmt);
640 return PMINFO_R_ERROR;
643 if (_appinfo_get_icon(db, info->appid, locale, &info->icon)) {
644 pkgmgrinfo_basic_free_application(info);
645 sqlite3_finalize(stmt);
646 return PMINFO_R_ERROR;
649 if (_appinfo_get_category(db, info->appid, &info->category)) {
650 pkgmgrinfo_basic_free_application(info);
651 sqlite3_finalize(stmt);
652 return PMINFO_R_ERROR;
655 if (_appinfo_get_app_control(db, info->appid, &info->appcontrol)) {
656 pkgmgrinfo_basic_free_application(info);
657 sqlite3_finalize(stmt);
658 return PMINFO_R_ERROR;
661 if (_appinfo_get_data_control(db, info->appid, &info->datacontrol)) {
662 pkgmgrinfo_basic_free_application(info);
663 sqlite3_finalize(stmt);
664 return PMINFO_R_ERROR;
667 if (_appinfo_get_metadata(db, info->appid, &info->metadata)) {
668 pkgmgrinfo_basic_free_application(info);
669 sqlite3_finalize(stmt);
670 return PMINFO_R_ERROR;
675 sqlite3_finalize(stmt);
680 static int _appinfo_get_appinfo(const char *appid, uid_t uid,
681 pkgmgr_appinfo_x **appinfo)
687 pkgmgr_appinfo_x *info;
689 dbpath = getUserPkgParserDBPathUID(uid);
691 return PMINFO_R_ERROR;
693 locale = _get_system_locale();
695 return PMINFO_R_ERROR;
697 ret = sqlite3_open_v2(dbpath, &db, SQLITE_OPEN_READONLY, NULL);
698 if (ret != SQLITE_OK) {
699 _LOGE("failed to open db: %d", ret);
701 return PMINFO_R_ERROR;
704 info = calloc(1, sizeof(pkgmgr_appinfo_x));
706 _LOGE("out of memory");
708 sqlite3_close_v2(db);
709 return PMINFO_R_ERROR;
712 ret = _appinfo_get_application(db, appid, locale, &info->app_info);
713 if (ret != PMINFO_R_OK) {
716 sqlite3_close_v2(db);
720 info->locale = locale;
721 info->package = strdup(info->app_info->package);
725 sqlite3_close_v2(db);
730 API int pkgmgrinfo_appinfo_get_usr_appinfo(const char *appid, uid_t uid,
731 pkgmgrinfo_appinfo_h *handle)
735 if (appid == NULL || handle == NULL) {
736 LOGE("invalid parameter");
737 return PMINFO_R_EINVAL;
740 ret = _appinfo_get_appinfo(appid, uid, (pkgmgr_appinfo_x **)handle);
741 if (ret == PMINFO_R_ENOENT && uid != GLOBAL_USER)
742 ret = _appinfo_get_appinfo(appid, GLOBAL_USER,
743 (pkgmgr_appinfo_x **)handle);
745 if (ret != PMINFO_R_OK)
746 _LOGE("failed to get appinfo of %s for user %d", appid, uid);
751 API int pkgmgrinfo_appinfo_get_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
753 return pkgmgrinfo_appinfo_get_usr_appinfo(appid, GLOBAL_USER, handle);
756 static int _appinfo_get_filtered_foreach_appinfo(uid_t uid,
757 pkgmgrinfo_filter_x *filter, pkgmgrinfo_app_list_cb app_list_cb,
761 pkgmgr_appinfo_x *info;
767 ret = _appinfo_get_filtered_list(filter, uid, &list);
768 if (ret != PMINFO_R_OK)
769 return PMINFO_R_ERROR;
771 for (tmp = list; tmp; tmp = tmp->next) {
772 appid = (char *)tmp->data;
774 ret = _appinfo_get_appinfo(appid, uid, &info);
775 if (ret == PMINFO_R_ENOENT && uid != GLOBAL_USER)
776 ret = _appinfo_get_appinfo(appid, GLOBAL_USER,
778 if (ret != PMINFO_R_OK) {
782 if (app_list_cb(info, user_data) < 0)
784 pkgmgrinfo_appinfo_destroy_appinfo(info);
794 API int pkgmgrinfo_appinfo_get_usr_list(pkgmgrinfo_pkginfo_h handle,
795 pkgmgrinfo_app_component component,
796 pkgmgrinfo_app_list_cb app_func, void *user_data, uid_t uid)
799 pkgmgrinfo_appinfo_filter_h filter;
801 const char *comp_str = NULL;
803 if (handle == NULL || app_func == NULL) {
804 LOGE("invalied parameter");
805 return PMINFO_R_EINVAL;
808 if (pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid)) {
809 LOGE("invalid parameter");
810 return PMINFO_R_EINVAL;
813 if (pkgmgrinfo_appinfo_filter_create(&filter))
814 return PMINFO_R_ERROR;
816 if (pkgmgrinfo_appinfo_filter_add_string(filter,
817 PMINFO_APPINFO_PROP_APP_PACKAGE, pkgid)) {
818 pkgmgrinfo_appinfo_filter_destroy(filter);
819 return PMINFO_R_ERROR;
825 comp_str = PMINFO_APPINFO_UI_APP;
828 comp_str = PMINFO_APPINFO_SVC_APP;
835 if (pkgmgrinfo_appinfo_filter_add_string(filter,
836 PMINFO_APPINFO_PROP_APP_COMPONENT,
838 pkgmgrinfo_appinfo_filter_destroy(filter);
839 return PMINFO_R_ERROR;
843 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter, app_func,
846 pkgmgrinfo_appinfo_filter_destroy(filter);
851 API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_component component,
852 pkgmgrinfo_app_list_cb app_func, void *user_data)
854 return pkgmgrinfo_appinfo_get_usr_list(handle, component, app_func, user_data, GLOBAL_USER);
857 API int pkgmgrinfo_appinfo_get_usr_install_list(pkgmgrinfo_app_list_cb app_func, uid_t uid, void *user_data)
859 if (app_func == NULL) {
860 LOGE("invalid parameter");
861 return PMINFO_R_EINVAL;
864 return _appinfo_get_filtered_foreach_appinfo(uid, NULL, app_func,
868 API int pkgmgrinfo_appinfo_get_install_list(pkgmgrinfo_app_list_cb app_func, void *user_data)
870 return pkgmgrinfo_appinfo_get_usr_install_list(app_func, GLOBAL_USER, user_data);
873 API int pkgmgrinfo_appinfo_get_usr_installed_list(pkgmgrinfo_app_list_cb app_func, uid_t uid, void *user_data)
875 if (app_func == NULL) {
876 LOGE("invalid parameter");
877 return PMINFO_R_EINVAL;
880 return _appinfo_get_filtered_foreach_appinfo(uid, NULL, app_func,
884 API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func, void *user_data)
886 return pkgmgrinfo_appinfo_get_usr_installed_list(app_func, GLOBAL_USER, user_data);
889 API int pkgmgrinfo_appinfo_get_appid(pkgmgrinfo_appinfo_h handle, char **appid)
891 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
893 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
894 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
896 if (info->app_info == NULL || info->app_info->appid == NULL)
897 return PMINFO_R_ERROR;
898 *appid = (char *)info->app_info->appid;
903 API int pkgmgrinfo_appinfo_get_pkgname(pkgmgrinfo_appinfo_h handle, char **pkg_name)
905 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
907 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
908 retvm_if(pkg_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
910 if (info->package == NULL)
911 return PMINFO_R_ERROR;
913 *pkg_name = (char *)info->package;
918 API int pkgmgrinfo_appinfo_get_pkgid(pkgmgrinfo_appinfo_h handle, char **pkgid)
920 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
922 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
923 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
925 if (info->package == NULL)
926 return PMINFO_R_ERROR;
928 *pkgid = (char *)info->package;
933 API int pkgmgrinfo_appinfo_get_exec(pkgmgrinfo_appinfo_h handle, char **exec)
935 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
937 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
938 retvm_if(exec == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
940 if (info->app_info == NULL || info->app_info->exec == NULL)
941 return PMINFO_R_ERROR;
942 *exec = (char *)info->app_info->exec;
948 API int pkgmgrinfo_appinfo_get_icon(pkgmgrinfo_appinfo_h handle, char **icon)
953 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
955 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
956 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
958 locale = info->locale;
959 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
961 if (info->app_info == NULL)
962 return PMINFO_R_ERROR;
964 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
965 ptr = (icon_x *)tmp->data;
966 if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL ||
967 !strcasecmp(ptr->text, "(null)") ||
968 strcmp(ptr->lang, locale))
970 *icon = (char *)ptr->text;
974 locale = DEFAULT_LOCALE;
975 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
976 ptr = (icon_x *)tmp->data;
977 if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL ||
978 strcmp(ptr->lang, locale))
980 *icon = (char *)ptr->text;
984 return PMINFO_R_ERROR;
988 API int pkgmgrinfo_appinfo_get_label(pkgmgrinfo_appinfo_h handle, char **label)
993 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
995 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
996 retvm_if(label == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
998 locale = info->locale;
999 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
1001 if (info->app_info == NULL)
1002 return PMINFO_R_ERROR;
1004 for (tmp = info->app_info->label; tmp; tmp = tmp->next) {
1005 ptr = (label_x *)tmp->data;
1006 if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL ||
1007 strcmp(ptr->lang, locale))
1009 *label = (char *)ptr->text;
1013 locale = DEFAULT_LOCALE;
1014 for (tmp = info->app_info->label; tmp; tmp = tmp->next) {
1015 ptr = (label_x *)tmp->data;
1016 if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL ||
1017 strcmp(ptr->lang, locale))
1019 *label = (char *)ptr->text;
1023 return PMINFO_R_ERROR;
1026 static char *_get_localed_label(const char *appid, const char *locale, uid_t uid)
1028 char *result = NULL;
1030 sqlite3_stmt *stmt = NULL;
1033 const char *manifest_db;
1035 manifest_db = getUserPkgParserDBPathUID(uid);
1036 if (manifest_db == NULL) {
1037 _LOGE("Failed to get manifest db path");
1041 if (sqlite3_open_v2(manifest_db, &db, SQLITE_OPEN_READONLY, NULL) != SQLITE_OK) {
1042 _LOGE("DB open fail\n");
1046 query = sqlite3_mprintf("select app_label from package_app_localized_info where app_id=%Q and app_locale=%Q", appid, locale);
1047 if (query == NULL) {
1048 _LOGE("Out of memory");
1052 if (sqlite3_prepare_v2(db, query, -1, &stmt, NULL) != SQLITE_OK) {
1053 _LOGE("prepare_v2 fail\n");
1057 if (sqlite3_step(stmt) == SQLITE_ROW) {
1058 val = (char *)sqlite3_column_text(stmt, 0);
1060 result = strdup(val);
1064 sqlite3_finalize(stmt);
1065 sqlite3_free(query);
1071 API int pkgmgrinfo_appinfo_usr_get_localed_label(const char *appid, const char *locale, uid_t uid, char **label)
1075 retvm_if(appid == NULL || locale == NULL || label == NULL, PMINFO_R_EINVAL, "Argument is NULL");
1077 val = _get_localed_label(appid, locale, uid);
1079 val = _get_localed_label(appid, DEFAULT_LOCALE, uid);
1082 return PMINFO_R_ERROR;
1089 API int pkgmgrinfo_appinfo_get_localed_label(const char *appid, const char *locale, char **label)
1091 return pkgmgrinfo_appinfo_usr_get_localed_label(appid, locale, GLOBAL_USER, label);
1094 static pkgmgrinfo_app_component __appcomponent_convert(const char *comp)
1096 if ( strcasecmp(comp, "uiapp") == 0)
1097 return PMINFO_UI_APP;
1098 else if ( strcasecmp(comp, "svcapp") == 0)
1099 return PMINFO_SVC_APP;
1104 API int pkgmgrinfo_appinfo_get_component(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_component *component)
1106 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1109 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1110 retvm_if(component == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1112 if (info->app_info == NULL)
1113 return PMINFO_R_ERROR;
1115 comp = __appcomponent_convert(info->app_info->component);
1117 return PMINFO_R_ERROR;
1124 API int pkgmgrinfo_appinfo_get_apptype(pkgmgrinfo_appinfo_h handle, char **app_type)
1126 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1128 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1129 retvm_if(app_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1131 if (info->app_info == NULL || info->app_info->type == NULL)
1132 return PMINFO_R_ERROR;
1133 *app_type = (char *)info->app_info->type;
1138 API int pkgmgrinfo_appinfo_get_operation(pkgmgrinfo_appcontrol_h handle,
1139 int *operation_count, char ***operation)
1141 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1142 retvm_if(operation == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1143 retvm_if(operation_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1144 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1145 *operation_count = data->operation_count;
1146 *operation = data->operation;
1150 API int pkgmgrinfo_appinfo_get_uri(pkgmgrinfo_appcontrol_h handle,
1151 int *uri_count, char ***uri)
1153 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1154 retvm_if(uri == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1155 retvm_if(uri_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1156 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1157 *uri_count = data->uri_count;
1162 API int pkgmgrinfo_appinfo_get_mime(pkgmgrinfo_appcontrol_h handle,
1163 int *mime_count, char ***mime)
1165 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1166 retvm_if(mime == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1167 retvm_if(mime_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1168 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1169 *mime_count = data->mime_count;
1174 API int pkgmgrinfo_appinfo_get_subapp(pkgmgrinfo_appcontrol_h handle,
1175 int *subapp_count, char ***subapp)
1177 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1178 retvm_if(subapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1179 retvm_if(subapp_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1180 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1181 *subapp_count = data->subapp_count;
1182 *subapp = data->subapp;
1186 API int pkgmgrinfo_appinfo_get_setting_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1191 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1193 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1194 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1196 if (info->app_info == NULL)
1197 return PMINFO_R_ERROR;
1199 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1200 ptr = (icon_x *)tmp->data;
1201 if (ptr == NULL || ptr->section == NULL)
1204 val = (char *)ptr->section;
1205 if (val && strcmp(val, "setting") == 0) {
1206 *icon = (char *)ptr->text;
1211 return PMINFO_R_ERROR;
1215 API int pkgmgrinfo_appinfo_get_notification_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1220 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1222 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1223 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1225 if (info->app_info == NULL)
1226 return PMINFO_R_ERROR;
1228 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1229 ptr = (icon_x *)tmp->data;
1230 if (ptr == NULL || ptr->section == NULL)
1233 val = (char *)ptr->section;
1234 if (val && strcmp(val, "notification") == 0){
1235 *icon = (char *)ptr->text;
1240 return PMINFO_R_ERROR;
1243 API int pkgmgrinfo_appinfo_get_recent_image_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_recentimage *type)
1246 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1248 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1249 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1251 if (info->app_info == NULL || info->app_info->recentimage == NULL)
1252 return PMINFO_R_ERROR;
1254 val = (char *)info->app_info->recentimage;
1255 if (strcasecmp(val, "capture") == 0)
1256 *type = PMINFO_RECENTIMAGE_USE_CAPTURE;
1257 else if (strcasecmp(val, "icon") == 0)
1258 *type = PMINFO_RECENTIMAGE_USE_ICON;
1260 *type = PMINFO_RECENTIMAGE_USE_NOTHING;
1265 API int pkgmgrinfo_appinfo_get_preview_image(pkgmgrinfo_appinfo_h handle, char **preview_img)
1270 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1272 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1273 retvm_if(preview_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1275 if (info->app_info == NULL)
1276 return PMINFO_R_ERROR;
1278 for (tmp = info->app_info->image; tmp; tmp = tmp->next) {
1279 ptr = (image_x *)tmp->data;
1280 if (ptr == NULL || ptr->section == NULL)
1283 val = (char *)ptr->section;
1284 if (val && strcmp(val, "preview") == 0) {
1285 *preview_img = (char *)ptr->text;
1290 return PMINFO_R_ERROR;
1293 API int pkgmgrinfo_appinfo_get_permission_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_permission_type *permission)
1296 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1298 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1299 retvm_if(permission == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1301 val = info->app_info->permission_type;
1303 return PMINFO_R_ERROR;
1305 if (strcmp(val, "signature") == 0)
1306 *permission = PMINFO_PERMISSION_SIGNATURE;
1307 else if (strcmp(val, "privilege") == 0)
1308 *permission = PMINFO_PERMISSION_PRIVILEGE;
1310 *permission = PMINFO_PERMISSION_NORMAL;
1315 API int pkgmgrinfo_appinfo_get_component_type(pkgmgrinfo_appinfo_h handle, char **component_type)
1317 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1319 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1320 retvm_if(component_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1322 if (info->app_info == NULL || info->app_info->component_type == NULL)
1323 return PMINFO_R_ERROR;
1325 *component_type = (char *)info->app_info->component_type;
1330 API int pkgmgrinfo_appinfo_get_hwacceleration(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_hwacceleration *hwacceleration)
1333 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1335 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1336 retvm_if(hwacceleration == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1338 if (info->app_info == NULL || info->app_info->hwacceleration == NULL)
1339 return PMINFO_R_ERROR;
1341 val = (char *)info->app_info->hwacceleration;
1342 if (strcasecmp(val, "not-use-GL") == 0)
1343 *hwacceleration = PMINFO_HWACCELERATION_NOT_USE_GL;
1344 else if (strcasecmp(val, "use-GL") == 0)
1345 *hwacceleration = PMINFO_HWACCELERATION_USE_GL;
1347 *hwacceleration = PMINFO_HWACCELERATION_USE_SYSTEM_SETTING;
1352 API int pkgmgrinfo_appinfo_get_screenreader(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_screenreader *screenreader)
1355 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1357 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1358 retvm_if(screenreader == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1360 if (info->app_info == NULL || info->app_info->screenreader == NULL)
1361 return PMINFO_R_ERROR;
1363 val = (char *)info->app_info->screenreader;
1364 if (strcasecmp(val, "screenreader-off") == 0)
1365 *screenreader = PMINFO_SCREENREADER_OFF;
1366 else if (strcasecmp(val, "screenreader-on") == 0)
1367 *screenreader = PMINFO_SCREENREADER_ON;
1369 *screenreader = PMINFO_SCREENREADER_USE_SYSTEM_SETTING;
1374 API int pkgmgrinfo_appinfo_get_effectimage(pkgmgrinfo_appinfo_h handle, char **portrait_img, char **landscape_img)
1376 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1378 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1379 retvm_if(portrait_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1380 retvm_if(landscape_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1382 if (info->app_info == NULL || info->app_info->portraitimg ||
1383 info->app_info->landscapeimg == NULL)
1384 return PMINFO_R_ERROR;
1386 *portrait_img = (char *)info->app_info->portraitimg;
1387 *landscape_img = (char *)info->app_info->landscapeimg;
1392 API int pkgmgrinfo_appinfo_get_effectimage_type(pkgmgrinfo_appinfo_h handle, char **effectimage_type)
1394 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1396 if (handle == NULL || effectimage_type == NULL) {
1397 LOGE("invalid parameter");
1398 return PMINFO_R_EINVAL;
1401 if (info->app_info == NULL || info->app_info->effectimage_type == NULL)
1402 return PMINFO_R_ERROR;
1404 *effectimage_type = (char *)info->app_info->effectimage_type;
1409 API int pkgmgrinfo_appinfo_get_submode_mainid(pkgmgrinfo_appinfo_h handle, char **submode_mainid)
1411 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1413 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1414 retvm_if(submode_mainid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1416 if (info->app_info == NULL || info->app_info->submode_mainid == NULL)
1417 return PMINFO_R_ERROR;
1419 *submode_mainid = (char *)info->app_info->submode_mainid;
1424 API int pkgmgrinfo_appinfo_get_installed_storage_location(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_installed_storage *storage)
1426 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1427 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1429 if (info->app_info && info->app_info->installed_storage){
1430 if (strcmp(info->app_info->installed_storage,"installed_internal") == 0)
1431 *storage = PMINFO_INTERNAL_STORAGE;
1432 else if (strcmp(info->app_info->installed_storage,"installed_external") == 0)
1433 *storage = PMINFO_EXTERNAL_STORAGE;
1435 return PMINFO_R_ERROR;
1437 return PMINFO_R_ERROR;
1442 API int pkgmgrinfo_appinfo_get_launch_mode(pkgmgrinfo_appinfo_h handle, char **mode)
1444 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1446 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1447 retvm_if(mode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1449 if (info->app_info->launch_mode == NULL)
1450 return PMINFO_R_ERROR;
1452 *mode = (char *)(info->app_info->launch_mode);
1457 API int pkgmgrinfo_appinfo_get_alias_appid(pkgmgrinfo_appinfo_h handle, char **alias_appid)
1459 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1461 if (handle == NULL || alias_appid == NULL) {
1462 LOGE("invalid parameter");
1463 return PMINFO_R_EINVAL;
1466 if (info->app_info == NULL || info->app_info->alias_appid == NULL)
1467 return PMINFO_R_ERROR;
1469 *alias_appid = (char *)info->app_info->alias_appid;
1474 API int pkgmgrinfo_appinfo_get_effective_appid(pkgmgrinfo_appinfo_h handle, char **effective_appid)
1476 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1478 if (handle == NULL || effective_appid == NULL) {
1479 LOGE("invalid parameter");
1480 return PMINFO_R_EINVAL;
1483 if (info->app_info == NULL || info->app_info->effective_appid == NULL)
1484 return PMINFO_R_ERROR;
1486 *effective_appid = (char *)info->app_info->effective_appid;
1491 API int pkgmgrinfo_appinfo_usr_get_datacontrol_info(const char *providerid, const char *type, uid_t uid, char **appid, char **access)
1493 retvm_if(providerid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
1494 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
1495 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1496 retvm_if(access == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1498 int ret = PMINFO_R_OK;
1500 sqlite3_stmt *stmt = NULL;
1503 ret = __open_manifest_db(uid, true);
1504 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
1506 /*Start constructing query*/
1507 query = sqlite3_mprintf("select * from package_app_data_control where providerid=%Q and type=%Q", providerid, type);
1510 ret = sqlite3_prepare_v2(GET_DB(manifest_db), query, strlen(query), &stmt, NULL);
1511 tryvm_if(ret != PMINFO_R_OK, ret = PMINFO_R_ERROR, "sqlite3_prepare_v2 failed[%s]\n", query);
1514 ret = sqlite3_step(stmt);
1515 tryvm_if((ret != SQLITE_ROW) || (ret == SQLITE_DONE), ret = PMINFO_R_ERROR, "No records found");
1517 *appid = strdup((char *)sqlite3_column_text(stmt, 0));
1518 *access = strdup((char *)sqlite3_column_text(stmt, 2));
1523 sqlite3_free(query);
1524 sqlite3_finalize(stmt);
1525 __close_manifest_db();
1529 API int pkgmgrinfo_appinfo_get_datacontrol_info(const char *providerid, const char *type, char **appid, char **access)
1531 return pkgmgrinfo_appinfo_usr_get_datacontrol_info(providerid, type, GLOBAL_USER, appid, access);
1534 API int pkgmgrinfo_appinfo_usr_get_datacontrol_appid(const char *providerid, uid_t uid, char **appid)
1536 retvm_if(providerid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
1537 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1539 int ret = PMINFO_R_OK;
1541 sqlite3_stmt *stmt = NULL;
1544 ret = __open_manifest_db(uid, true);
1545 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
1547 /*Start constructing query*/
1548 query = sqlite3_mprintf("select * from package_app_data_control where providerid=%Q", providerid);
1551 ret = sqlite3_prepare_v2(GET_DB(manifest_db), query, strlen(query), &stmt, NULL);
1552 tryvm_if(ret != PMINFO_R_OK, ret = PMINFO_R_ERROR, "sqlite3_prepare_v2 failed[%s]\n", query);
1555 ret = sqlite3_step(stmt);
1556 tryvm_if((ret != SQLITE_ROW) || (ret == SQLITE_DONE), ret = PMINFO_R_ERROR, "No records found");
1558 *appid = strdup((char *)sqlite3_column_text(stmt, 0));
1563 sqlite3_free(query);
1564 sqlite3_finalize(stmt);
1565 __close_manifest_db();
1569 API int pkgmgrinfo_appinfo_get_datacontrol_appid(const char *providerid, char **appid)
1571 return pkgmgrinfo_appinfo_usr_get_datacontrol_appid(providerid, GLOBAL_USER, appid);
1574 API int pkgmgrinfo_appinfo_foreach_permission(pkgmgrinfo_appinfo_h handle,
1575 pkgmgrinfo_app_permission_list_cb permission_func, void *user_data)
1577 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1578 retvm_if(permission_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
1582 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1584 if (info->app_info == NULL)
1585 return PMINFO_R_ERROR;
1587 for (tmp = info->app_info->permission; tmp; tmp = tmp->next) {
1588 ptr = (permission_x *)tmp->data;
1592 ret = permission_func(ptr->value, user_data);
1600 API int pkgmgrinfo_appinfo_foreach_category(pkgmgrinfo_appinfo_h handle,
1601 pkgmgrinfo_app_category_list_cb category_func, void *user_data)
1603 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1604 retvm_if(category_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
1606 const char *category;
1608 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1610 if (info->app_info == NULL)
1611 return PMINFO_R_ERROR;
1613 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
1614 category = (const char *)tmp->data;
1616 ret = category_func(category, user_data);
1624 API int pkgmgrinfo_appinfo_foreach_metadata(pkgmgrinfo_appinfo_h handle,
1625 pkgmgrinfo_app_metadata_list_cb metadata_func, void *user_data)
1627 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1628 retvm_if(metadata_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
1632 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1634 if (info->app_info == NULL)
1635 return PMINFO_R_ERROR;
1637 for (tmp = info->app_info->metadata; tmp; tmp = tmp->next) {
1638 ptr = (metadata_x *)tmp->data;
1642 ret = metadata_func(ptr->key, ptr->value, user_data);
1650 API int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
1651 pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
1653 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1654 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
1656 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1657 appcontrol_x *appcontrol;
1660 if (info->app_info == NULL)
1661 return PMINFO_R_ERROR;
1663 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
1664 appcontrol = (appcontrol_x *)tmp->data;
1665 if (appcontrol == NULL)
1667 ret = appcontrol_func(appcontrol->operation, appcontrol->uri, appcontrol->mime, user_data);
1675 API int pkgmgrinfo_appinfo_foreach_background_category(
1676 pkgmgrinfo_appinfo_h handle,
1677 pkgmgrinfo_app_background_category_list_cb category_func,
1680 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1684 if (handle == NULL || category_func == NULL || info->app_info == NULL) {
1685 LOGE("invalid parameter");
1686 return PMINFO_R_EINVAL;
1689 for (tmp = info->app_info->background_category; tmp; tmp = tmp->next) {
1690 category = (char *)tmp->data;
1691 if (category == NULL)
1694 if (category_func(category, user_data) < 0)
1701 API int pkgmgrinfo_appinfo_is_nodisplay(pkgmgrinfo_appinfo_h handle, bool *nodisplay)
1703 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1704 retvm_if(nodisplay == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1705 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1707 if (info->app_info == NULL || info->app_info->nodisplay == NULL)
1708 return PMINFO_R_ERROR;
1710 *nodisplay = _get_bool_value(info->app_info->nodisplay);
1715 API int pkgmgrinfo_appinfo_is_multiple(pkgmgrinfo_appinfo_h handle, bool *multiple)
1717 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1718 retvm_if(multiple == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1719 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1721 if (info->app_info == NULL || info->app_info->multiple == NULL)
1722 return PMINFO_R_ERROR;
1724 *multiple = _get_bool_value(info->app_info->multiple);
1729 API int pkgmgrinfo_appinfo_is_indicator_display_allowed(pkgmgrinfo_appinfo_h handle, bool *indicator_disp)
1731 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1732 retvm_if(indicator_disp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1733 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1735 if (info->app_info == NULL || info->app_info->indicatordisplay == NULL)
1736 return PMINFO_R_ERROR;
1738 *indicator_disp = _get_bool_value(info->app_info->indicatordisplay);
1743 API int pkgmgrinfo_appinfo_is_taskmanage(pkgmgrinfo_appinfo_h handle, bool *taskmanage)
1745 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1746 retvm_if(taskmanage == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1747 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1749 if (info->app_info == NULL || info->app_info->taskmanage == NULL)
1750 return PMINFO_R_ERROR;
1752 *taskmanage = _get_bool_value(info->app_info->taskmanage);
1757 API int pkgmgrinfo_appinfo_is_enabled(pkgmgrinfo_appinfo_h handle, bool *enabled)
1759 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1760 retvm_if(enabled == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1761 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1763 if (info->app_info == NULL || info->app_info->enabled == NULL)
1764 return PMINFO_R_ERROR;
1766 *enabled = _get_bool_value(info->app_info->enabled);
1771 API int pkgmgrinfo_appinfo_is_onboot(pkgmgrinfo_appinfo_h handle, bool *onboot)
1773 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1774 retvm_if(onboot == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1775 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1777 if (info->app_info == NULL || info->app_info->onboot == NULL)
1778 return PMINFO_R_ERROR;
1780 *onboot = _get_bool_value(info->app_info->onboot);
1785 API int pkgmgrinfo_appinfo_is_autorestart(pkgmgrinfo_appinfo_h handle, bool *autorestart)
1787 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1788 retvm_if(autorestart == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1789 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1791 if (info->app_info == NULL || info->app_info->autorestart == NULL)
1792 return PMINFO_R_ERROR;
1794 *autorestart = _get_bool_value(info->app_info->autorestart);
1799 API int pkgmgrinfo_appinfo_is_mainapp(pkgmgrinfo_appinfo_h handle, bool *mainapp)
1801 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1802 retvm_if(mainapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1803 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1805 if (info->app_info == NULL || info->app_info->mainapp == NULL)
1806 return PMINFO_R_ERROR;
1808 *mainapp = _get_bool_value(info->app_info->mainapp);
1813 API int pkgmgrinfo_appinfo_is_preload(pkgmgrinfo_appinfo_h handle, bool *preload)
1815 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1816 retvm_if(preload == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1817 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1819 if (info->app_info == NULL || info->app_info->preload == NULL)
1820 return PMINFO_R_ERROR;
1822 *preload = _get_bool_value(info->app_info->preload);
1827 API int pkgmgrinfo_appinfo_is_submode(pkgmgrinfo_appinfo_h handle, bool *submode)
1829 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1830 retvm_if(submode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1831 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1833 if (info->app_info == NULL || info->app_info->submode == NULL)
1834 return PMINFO_R_ERROR;
1836 *submode = _get_bool_value(info->app_info->submode);
1841 API int pkgmgrinfo_appinfo_is_process_pool(pkgmgrinfo_appinfo_h handle, bool *process_pool)
1843 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1845 if (handle == NULL || process_pool == NULL) {
1846 LOGE("invalid parameter");
1847 return PMINFO_R_EINVAL;
1850 if (info->app_info == NULL)
1851 return PMINFO_R_ERROR;
1853 *process_pool = _get_bool_value(info->app_info->process_pool);
1858 API int pkgmgrinfo_appinfo_is_category_exist(pkgmgrinfo_appinfo_h handle, const char *category, bool *exist)
1860 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1861 retvm_if(category == NULL, PMINFO_R_EINVAL, "category is NULL");
1862 retvm_if(exist == NULL, PMINFO_R_EINVAL, "exist is NULL");
1866 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1868 if (info->app_info == NULL)
1869 return PMINFO_R_ERROR;
1872 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
1873 val = (const char *)tmp->data;
1876 if (strcasecmp(val, category) == 0) {
1885 API int pkgmgrinfo_appinfo_is_ui_gadget(pkgmgrinfo_appinfo_h handle,
1888 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1890 if (info == NULL || info->app_info == NULL || ui_gadget == NULL) {
1891 _LOGE("invalid parameter");
1892 return PMINFO_R_EINVAL;
1895 *ui_gadget = _get_bool_value(info->app_info->ui_gadget);
1900 API int pkgmgrinfo_appinfo_is_support_disable(pkgmgrinfo_appinfo_h handle,
1901 bool *support_disable)
1903 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1905 if (info == NULL || info->app_info == NULL || support_disable == NULL) {
1906 _LOGE("invalid parameter");
1907 return PMINFO_R_EINVAL;
1910 *support_disable = _get_bool_value(info->app_info->support_disable);
1915 API int pkgmgrinfo_appinfo_destroy_appinfo(pkgmgrinfo_appinfo_h handle)
1917 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1918 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1919 __cleanup_appinfo(info);
1923 API int pkgmgrinfo_appinfo_filter_create(pkgmgrinfo_appinfo_filter_h *handle)
1925 return (pkgmgrinfo_pkginfo_filter_create(handle));
1928 API int pkgmgrinfo_appinfo_filter_destroy(pkgmgrinfo_appinfo_filter_h handle)
1930 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
1933 static gint __compare_func(gconstpointer data1, gconstpointer data2)
1935 pkgmgrinfo_node_x *node1 = (pkgmgrinfo_node_x*)data1;
1936 pkgmgrinfo_node_x *node2 = (pkgmgrinfo_node_x*)data2;
1937 if (node1->prop == node2->prop)
1939 else if (node1->prop > node2->prop)
1945 API int pkgmgrinfo_appinfo_filter_add_int(pkgmgrinfo_appinfo_filter_h handle,
1946 const char *property, const int value)
1948 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
1949 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
1950 char buf[PKG_VALUE_STRING_LEN_MAX] = {'\0'};
1952 GSList *link = NULL;
1954 prop = _pminfo_appinfo_convert_to_prop_int(property);
1955 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_INT ||
1956 prop > E_PMINFO_APPINFO_PROP_APP_MAX_INT) {
1957 _LOGE("Invalid Integer Property\n");
1958 return PMINFO_R_EINVAL;
1960 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
1961 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
1963 _LOGE("Out of Memory!!!\n");
1964 return PMINFO_R_ERROR;
1966 snprintf(buf, PKG_VALUE_STRING_LEN_MAX - 1, "%d", value);
1967 val = strndup(buf, PKG_VALUE_STRING_LEN_MAX - 1);
1969 _LOGE("Out of Memory\n");
1972 return PMINFO_R_ERROR;
1976 /*If API is called multiple times for same property, we should override the previous values.
1977 Last value set will be used for filtering.*/
1978 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
1980 filter->list = g_slist_delete_link(filter->list, link);
1981 filter->list = g_slist_append(filter->list, (gpointer)node);
1986 API int pkgmgrinfo_appinfo_filter_add_bool(pkgmgrinfo_appinfo_filter_h handle,
1987 const char *property, const bool value)
1989 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
1990 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
1992 GSList *link = NULL;
1994 prop = _pminfo_appinfo_convert_to_prop_bool(property);
1995 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_BOOL ||
1996 prop > E_PMINFO_APPINFO_PROP_APP_MAX_BOOL) {
1997 _LOGE("Invalid Boolean Property\n");
1998 return PMINFO_R_EINVAL;
2000 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
2001 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
2003 _LOGE("Out of Memory!!!\n");
2004 return PMINFO_R_ERROR;
2007 val = strndup("('true','True')", 15);
2009 val = strndup("('false','False')", 17);
2011 _LOGE("Out of Memory\n");
2014 return PMINFO_R_ERROR;
2018 /*If API is called multiple times for same property, we should override the previous values.
2019 Last value set will be used for filtering.*/
2020 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2022 filter->list = g_slist_delete_link(filter->list, link);
2023 filter->list = g_slist_append(filter->list, (gpointer)node);
2028 API int pkgmgrinfo_appinfo_filter_add_string(pkgmgrinfo_appinfo_filter_h handle,
2029 const char *property, const char *value)
2031 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2032 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2033 retvm_if(value == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2035 pkgmgrinfo_node_x *ptr = NULL;
2036 char prev[PKG_STRING_LEN_MAX] = {'\0'};
2037 char temp[PKG_STRING_LEN_MAX] = {'\0'};
2038 GSList *link = NULL;
2040 prop = _pminfo_appinfo_convert_to_prop_str(property);
2041 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_STR ||
2042 prop > E_PMINFO_APPINFO_PROP_APP_MAX_STR) {
2043 _LOGE("Invalid String Property\n");
2044 return PMINFO_R_EINVAL;
2046 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
2047 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
2049 _LOGE("Out of Memory!!!\n");
2050 return PMINFO_R_ERROR;
2054 case E_PMINFO_APPINFO_PROP_APP_COMPONENT:
2055 if (strcmp(value, PMINFO_APPINFO_UI_APP) == 0)
2056 val = strndup("uiapp", PKG_STRING_LEN_MAX - 1);
2058 val = strndup("svcapp", PKG_STRING_LEN_MAX - 1);
2060 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2062 filter->list = g_slist_delete_link(filter->list, link);
2063 filter->list = g_slist_append(filter->list, (gpointer)node);
2065 case E_PMINFO_APPINFO_PROP_APP_CATEGORY:
2066 case E_PMINFO_APPINFO_PROP_APP_OPERATION:
2067 case E_PMINFO_APPINFO_PROP_APP_URI:
2068 case E_PMINFO_APPINFO_PROP_APP_MIME:
2069 val = (char *)calloc(1, PKG_STRING_LEN_MAX);
2071 _LOGE("Out of Memory\n");
2074 return PMINFO_R_ERROR;
2076 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2078 ptr = (pkgmgrinfo_node_x *)link->data;
2079 strncpy(prev, ptr->value, PKG_STRING_LEN_MAX - 1);
2080 _LOGE("Previous value is %s\n", prev);
2081 filter->list = g_slist_delete_link(filter->list, link);
2082 snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s , '%s'", prev, value);
2083 strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
2084 _LOGE("New value is %s\n", val);
2086 filter->list = g_slist_append(filter->list, (gpointer)node);
2087 memset(temp, '\0', PKG_STRING_LEN_MAX);
2089 snprintf(temp, PKG_STRING_LEN_MAX - 1, "'%s'", value);
2090 strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
2091 _LOGE("First value is %s\n", val);
2093 filter->list = g_slist_append(filter->list, (gpointer)node);
2094 memset(temp, '\0', PKG_STRING_LEN_MAX);
2098 node->value = strndup(value, PKG_STRING_LEN_MAX - 1);
2099 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2101 filter->list = g_slist_delete_link(filter->list, link);
2102 filter->list = g_slist_append(filter->list, (gpointer)node);
2108 API int pkgmgrinfo_appinfo_usr_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count, uid_t uid)
2113 if (handle == NULL || count == NULL) {
2114 _LOGE("invalid parameter");
2115 return PMINFO_R_EINVAL;
2118 ret = _appinfo_get_filtered_list(handle, uid, &list);
2119 if (ret != PMINFO_R_OK)
2120 return PMINFO_R_ERROR;
2122 *count = g_list_length(list);
2124 g_list_free_full(list, free);
2129 API int pkgmgrinfo_appinfo_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count)
2131 return pkgmgrinfo_appinfo_usr_filter_count(handle, count, GLOBAL_USER);
2134 API int pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(
2135 pkgmgrinfo_appinfo_filter_h handle,
2136 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
2138 if (handle == NULL || app_cb == NULL) {
2139 LOGE("invalid parameter");
2140 return PMINFO_R_EINVAL;
2143 return _appinfo_get_filtered_foreach_appinfo(uid, handle, app_cb,
2147 API int pkgmgrinfo_appinfo_filter_foreach_appinfo(pkgmgrinfo_appinfo_filter_h handle,
2148 pkgmgrinfo_app_list_cb app_cb, void * user_data)
2150 return pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(handle, app_cb, user_data, GLOBAL_USER);
2153 API int pkgmgrinfo_appinfo_metadata_filter_create(pkgmgrinfo_appinfo_metadata_filter_h *handle)
2155 return (pkgmgrinfo_pkginfo_filter_create(handle));
2158 API int pkgmgrinfo_appinfo_metadata_filter_destroy(pkgmgrinfo_appinfo_metadata_filter_h handle)
2160 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
2163 API int pkgmgrinfo_appinfo_metadata_filter_add(
2164 pkgmgrinfo_appinfo_metadata_filter_h handle,
2165 const char *key, const char *value)
2169 ret = pkgmgrinfo_appinfo_filter_add_string(handle,
2170 PMINFO_APPINFO_PROP_APP_METADATA_KEY, key);
2171 if (ret != PMINFO_R_OK)
2174 /* value can be NULL.
2175 * In that case all apps with specified key should be displayed
2178 ret = pkgmgrinfo_appinfo_filter_add_string(handle,
2179 PMINFO_APPINFO_PROP_APP_METADATA_VALUE, value);
2180 if (ret != PMINFO_R_OK)
2187 API int pkgmgrinfo_appinfo_usr_metadata_filter_foreach(
2188 pkgmgrinfo_appinfo_metadata_filter_h handle,
2189 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
2191 if (handle == NULL || app_cb == NULL) {
2192 LOGE("invalid parameter");
2193 return PMINFO_R_EINVAL;
2196 return _appinfo_get_filtered_foreach_appinfo(uid, handle, app_cb,
2200 API int pkgmgrinfo_appinfo_metadata_filter_foreach(
2201 pkgmgrinfo_appinfo_metadata_filter_h handle,
2202 pkgmgrinfo_app_list_cb app_cb, void *user_data)
2204 return pkgmgrinfo_appinfo_usr_metadata_filter_foreach(handle, app_cb,
2205 user_data, GLOBAL_USER);
2208 API int pkgmgrinfo_appinfo_is_guestmode_visibility(pkgmgrinfo_appinfo_h handle, bool *status)
2211 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2213 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2214 retvm_if(status == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2216 val = info->app_info->guestmode_visibility;
2217 *status = _get_bool_value(val);