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 int _appinfo_get_icon(sqlite3 *db, const char *appid, const char *locale,
259 static const char query_raw[] =
260 "SELECT app_icon, app_locale "
261 "FROM package_app_localized_info "
262 "WHERE app_id=%Q AND app_locale IN (%Q, %Q)";
269 query = sqlite3_mprintf(query_raw, appid, locale, DEFAULT_LOCALE);
271 LOGE("out of memory");
272 return PMINFO_R_ERROR;
275 ret = sqlite3_prepare_v2(db, query, strlen(query),
278 if (ret != SQLITE_OK) {
279 LOGE("prepare failed: %s", sqlite3_errmsg(db));
280 return PMINFO_R_ERROR;
283 while (sqlite3_step(stmt) == SQLITE_ROW) {
284 info = calloc(1, sizeof(icon_x));
286 LOGE("out of memory");
287 sqlite3_finalize(stmt);
288 return PMINFO_R_ERROR;
291 _save_column_str(stmt, idx++, &info->text);
292 _save_column_str(stmt, idx++, &info->lang);
293 *icon = g_list_append(*icon, info);
296 sqlite3_finalize(stmt);
301 static int _appinfo_get_category(sqlite3 *db, const char *appid,
304 static const char query_raw[] =
305 "SELECT category FROM package_app_app_category WHERE app_id=%Q";
311 query = sqlite3_mprintf(query_raw, appid);
313 LOGE("out of memory");
314 return PMINFO_R_ERROR;
317 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
319 if (ret != SQLITE_OK) {
320 LOGE("prepare failed: %s", sqlite3_errmsg(db));
321 return PMINFO_R_ERROR;
324 while (sqlite3_step(stmt) == SQLITE_ROW) {
326 _save_column_str(stmt, 0, &val);
328 *category = g_list_append(*category, (gpointer)val);
331 sqlite3_finalize(stmt);
336 static void __parse_appcontrol(GList **appcontrol, char *appcontrol_str)
343 if (appcontrol_str == NULL)
346 dup = strdup(appcontrol_str);
348 ac = calloc(1, sizeof(appcontrol_x));
350 _LOGE("out of memory");
353 token = strtok_r(dup, "|", &ptr);
354 if (token && strcmp(token, "NULL"))
355 ac->operation = strdup(token);
356 token = strtok_r(NULL, "|", &ptr);
357 if (token && strcmp(token, "NULL"))
358 ac->uri = strdup(token);
359 token = strtok_r(NULL, "|", &ptr);
360 if (token && strcmp(token, "NULL"))
361 ac->mime = strdup(token);
362 *appcontrol = g_list_append(*appcontrol, ac);
363 } while ((token = strtok_r(NULL, ";", &ptr)));
368 static int _appinfo_get_app_control(sqlite3 *db, const char *appid,
371 static const char query_raw[] =
372 "SELECT app_control FROM package_app_app_control "
379 query = sqlite3_mprintf(query_raw, appid);
381 LOGE("out of memory");
382 return PMINFO_R_ERROR;
385 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
387 if (ret != SQLITE_OK) {
388 LOGE("prepare failed: %s", sqlite3_errmsg(db));
389 return PMINFO_R_ERROR;
392 while (sqlite3_step(stmt) == SQLITE_ROW) {
394 _save_column_str(stmt, 0, (const char **)&str);
396 __parse_appcontrol(appcontrol, str);
400 sqlite3_finalize(stmt);
405 static int _appinfo_get_data_control(sqlite3 *db, const char *appid,
408 static const char query_raw[] =
409 "SELECT providerid, access, type "
410 "FROM package_app_data_control WHERE app_id=%Q";
417 query = sqlite3_mprintf(query_raw, appid);
419 LOGE("out of memory");
420 return PMINFO_R_ERROR;
423 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
425 if (ret != SQLITE_OK) {
426 LOGE("prepare failed: %s", sqlite3_errmsg(db));
427 return PMINFO_R_ERROR;
430 while (sqlite3_step(stmt) == SQLITE_ROW) {
431 info = calloc(1, sizeof(datacontrol_x));
433 LOGE("out of memory");
434 sqlite3_finalize(stmt);
435 return PMINFO_R_ERROR;
438 _save_column_str(stmt, idx++, &info->providerid);
439 _save_column_str(stmt, idx++, &info->access);
440 _save_column_str(stmt, idx++, &info->type);
441 *datacontrol = g_list_append(*datacontrol, info);
444 sqlite3_finalize(stmt);
449 static int _appinfo_get_metadata(sqlite3 *db, const char *appid,
452 static const char query_raw[] =
453 "SELECT md_key, md_value "
454 "FROM package_app_app_metadata WHERE app_id=%Q";
461 query = sqlite3_mprintf(query_raw, appid);
463 LOGE("out of memory");
464 return PMINFO_R_ERROR;
467 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
469 if (ret != SQLITE_OK) {
470 LOGE("prepare failed: %s", sqlite3_errmsg(db));
471 return PMINFO_R_ERROR;
474 while (sqlite3_step(stmt) == SQLITE_ROW) {
475 info = calloc(1, sizeof(metadata_x));
477 LOGE("out of memory");
478 sqlite3_finalize(stmt);
479 return PMINFO_R_ERROR;
482 _save_column_str(stmt, idx++, &info->key);
483 _save_column_str(stmt, idx++, &info->value);
484 *metadata = g_list_append(*metadata, info);
487 sqlite3_finalize(stmt);
493 static GList *__get_background_category(char *value)
495 GList *category_list = NULL;
496 int convert_value = 0;
497 if (!value || strlen(value) == 0)
500 convert_value = atoi(value);
501 if (convert_value < 0)
504 if (convert_value & APP_BG_CATEGORY_USER_DISABLE_TRUE_VAL)
505 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_USER_DISABLE_TRUE_STR));
507 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_USER_DISABLE_FALSE_STR));
509 if (convert_value & APP_BG_CATEGORY_MEDIA_VAL)
510 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_MEDIA_STR));
512 if (convert_value & APP_BG_CATEGORY_DOWNLOAD_VAL)
513 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_DOWNLOAD_STR));
515 if (convert_value & APP_BG_CATEGORY_BGNETWORK_VAL)
516 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_BGNETWORK_STR));
518 if (convert_value & APP_BG_CATEGORY_LOCATION_VAL)
519 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_LOCATION_STR));
521 if (convert_value & APP_BG_CATEGORY_SENSOR_VAL)
522 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_SENSOR_STR));
524 if (convert_value & APP_BG_CATEGORY_IOTCOMM_VAL)
525 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_IOTCOMM_STR));
527 if (convert_value & APP_BG_CATEGORY_SYSTEM_VAL)
528 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_SYSTEM));
530 return category_list;
534 static int _appinfo_get_application(sqlite3 *db, const char *appid,
535 const char *locale, application_x **application)
537 static const char query_raw[] =
538 "SELECT app_id, app_component, app_exec, app_nodisplay, "
539 "app_type, app_onboot, app_multiple, app_autorestart, "
540 "app_taskmanage, app_enabled, app_hwacceleration, "
541 "app_screenreader, app_mainapp, app_recentimage, "
542 "app_launchcondition, app_indicatordisplay, app_portraitimg, "
543 "app_landscapeimg, app_guestmodevisibility, "
544 "app_permissiontype, app_preload, app_submode, "
545 "app_submode_mainid, app_launch_mode, app_ui_gadget, "
546 "app_support_disable, "
547 "component_type, package, app_process_pool, app_installed_storage, "
548 "app_background_category "
549 "FROM package_app_info WHERE app_id=%Q";
555 char *bg_category_str = NULL;
557 query = sqlite3_mprintf(query_raw, appid);
559 LOGE("out of memory");
560 return PMINFO_R_ERROR;
563 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
565 if (ret != SQLITE_OK) {
566 LOGE("prepare failed: %s", sqlite3_errmsg(db));
567 return PMINFO_R_ERROR;
570 ret = sqlite3_step(stmt);
571 if (ret == SQLITE_DONE) {
572 sqlite3_finalize(stmt);
573 return PMINFO_R_ENOENT;
574 } else if (ret != SQLITE_ROW) {
575 LOGE("step failed: %s", sqlite3_errmsg(db));
576 sqlite3_finalize(stmt);
577 return PMINFO_R_ERROR;
580 info = calloc(1, sizeof(application_x));
582 LOGE("out of memory");
583 sqlite3_finalize(stmt);
584 return PMINFO_R_ERROR;
587 _save_column_str(stmt, idx++, &info->appid);
588 _save_column_str(stmt, idx++, &info->component);
589 _save_column_str(stmt, idx++, &info->exec);
590 _save_column_str(stmt, idx++, &info->nodisplay);
591 _save_column_str(stmt, idx++, &info->type);
592 _save_column_str(stmt, idx++, &info->onboot);
593 _save_column_str(stmt, idx++, &info->multiple);
594 _save_column_str(stmt, idx++, &info->autorestart);
595 _save_column_str(stmt, idx++, &info->taskmanage);
596 _save_column_str(stmt, idx++, &info->enabled);
597 _save_column_str(stmt, idx++, &info->hwacceleration);
598 _save_column_str(stmt, idx++, &info->screenreader);
599 _save_column_str(stmt, idx++, &info->mainapp);
600 _save_column_str(stmt, idx++, &info->recentimage);
601 _save_column_str(stmt, idx++, &info->launchcondition);
602 _save_column_str(stmt, idx++, &info->indicatordisplay);
603 _save_column_str(stmt, idx++, &info->portraitimg);
604 _save_column_str(stmt, idx++, &info->landscapeimg);
605 _save_column_str(stmt, idx++, &info->guestmode_visibility);
606 _save_column_str(stmt, idx++, &info->permission_type);
607 _save_column_str(stmt, idx++, &info->preload);
608 _save_column_str(stmt, idx++, &info->submode);
609 _save_column_str(stmt, idx++, &info->submode_mainid);
610 _save_column_str(stmt, idx++, &info->launch_mode);
611 _save_column_str(stmt, idx++, &info->ui_gadget);
612 _save_column_str(stmt, idx++, &info->support_disable);
613 _save_column_str(stmt, idx++, &info->component_type);
614 _save_column_str(stmt, idx++, &info->package);
615 _save_column_str(stmt, idx++, &info->process_pool);
616 _save_column_str(stmt, idx++, &info->installed_storage);
617 _save_column_str(stmt, idx++, &bg_category_str);
619 info->background_category = __get_background_category(bg_category_str);
621 if (_appinfo_get_label(db, info->appid, locale, &info->label)) {
622 pkgmgrinfo_basic_free_application(info);
623 sqlite3_finalize(stmt);
624 return PMINFO_R_ERROR;
627 if (_appinfo_get_icon(db, info->appid, locale, &info->icon)) {
628 pkgmgrinfo_basic_free_application(info);
629 sqlite3_finalize(stmt);
630 return PMINFO_R_ERROR;
633 if (_appinfo_get_category(db, info->appid, &info->category)) {
634 pkgmgrinfo_basic_free_application(info);
635 sqlite3_finalize(stmt);
636 return PMINFO_R_ERROR;
639 if (_appinfo_get_app_control(db, info->appid, &info->appcontrol)) {
640 pkgmgrinfo_basic_free_application(info);
641 sqlite3_finalize(stmt);
642 return PMINFO_R_ERROR;
645 if (_appinfo_get_data_control(db, info->appid, &info->datacontrol)) {
646 pkgmgrinfo_basic_free_application(info);
647 sqlite3_finalize(stmt);
648 return PMINFO_R_ERROR;
651 if (_appinfo_get_metadata(db, info->appid, &info->metadata)) {
652 pkgmgrinfo_basic_free_application(info);
653 sqlite3_finalize(stmt);
654 return PMINFO_R_ERROR;
659 sqlite3_finalize(stmt);
664 static int _appinfo_get_appinfo(const char *appid, uid_t uid,
665 pkgmgr_appinfo_x **appinfo)
671 pkgmgr_appinfo_x *info;
673 dbpath = getUserPkgParserDBPathUID(uid);
675 return PMINFO_R_ERROR;
677 locale = _get_system_locale();
679 return PMINFO_R_ERROR;
681 ret = sqlite3_open_v2(dbpath, &db, SQLITE_OPEN_READONLY, NULL);
682 if (ret != SQLITE_OK) {
683 _LOGE("failed to open db: %d", ret);
685 return PMINFO_R_ERROR;
688 info = calloc(1, sizeof(pkgmgr_appinfo_x));
690 _LOGE("out of memory");
692 sqlite3_close_v2(db);
693 return PMINFO_R_ERROR;
696 ret = _appinfo_get_application(db, appid, locale, &info->app_info);
697 if (ret != PMINFO_R_OK) {
700 sqlite3_close_v2(db);
704 info->locale = locale;
705 info->package = strdup(info->app_info->package);
709 sqlite3_close_v2(db);
714 API int pkgmgrinfo_appinfo_get_usr_appinfo(const char *appid, uid_t uid,
715 pkgmgrinfo_appinfo_h *handle)
719 if (appid == NULL || handle == NULL) {
720 LOGE("invalid parameter");
721 return PMINFO_R_EINVAL;
724 ret = _appinfo_get_appinfo(appid, uid, (pkgmgr_appinfo_x **)handle);
725 if (ret == PMINFO_R_ENOENT && uid != GLOBAL_USER)
726 ret = _appinfo_get_appinfo(appid, GLOBAL_USER,
727 (pkgmgr_appinfo_x **)handle);
729 if (ret != PMINFO_R_OK)
730 _LOGE("failed to get appinfo of %s for user %d", appid, uid);
735 API int pkgmgrinfo_appinfo_get_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
737 return pkgmgrinfo_appinfo_get_usr_appinfo(appid, GLOBAL_USER, handle);
740 static int _appinfo_get_filtered_foreach_appinfo(uid_t uid,
741 pkgmgrinfo_filter_x *filter, pkgmgrinfo_app_list_cb app_list_cb,
745 pkgmgr_appinfo_x *info;
751 ret = _appinfo_get_filtered_list(filter, uid, &list);
752 if (ret != PMINFO_R_OK)
753 return PMINFO_R_ERROR;
755 for (tmp = list; tmp; tmp = tmp->next) {
756 appid = (char *)tmp->data;
758 ret = _appinfo_get_appinfo(appid, uid, &info);
759 if (ret == PMINFO_R_ENOENT && uid != GLOBAL_USER)
760 ret = _appinfo_get_appinfo(appid, GLOBAL_USER,
762 if (ret != PMINFO_R_OK) {
766 if (app_list_cb(info, user_data) < 0)
768 pkgmgrinfo_appinfo_destroy_appinfo(info);
778 API int pkgmgrinfo_appinfo_get_usr_list(pkgmgrinfo_pkginfo_h handle,
779 pkgmgrinfo_app_component component,
780 pkgmgrinfo_app_list_cb app_func, void *user_data, uid_t uid)
783 pkgmgrinfo_appinfo_filter_h filter;
785 const char *comp_str = NULL;
787 if (handle == NULL || app_func == NULL) {
788 LOGE("invalied parameter");
789 return PMINFO_R_EINVAL;
792 if (pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid)) {
793 LOGE("invalid parameter");
794 return PMINFO_R_EINVAL;
797 if (pkgmgrinfo_appinfo_filter_create(&filter))
798 return PMINFO_R_ERROR;
800 if (pkgmgrinfo_appinfo_filter_add_string(filter,
801 PMINFO_APPINFO_PROP_APP_PACKAGE, pkgid)) {
802 pkgmgrinfo_appinfo_filter_destroy(filter);
803 return PMINFO_R_ERROR;
809 comp_str = PMINFO_APPINFO_UI_APP;
812 comp_str = PMINFO_APPINFO_SVC_APP;
819 if (pkgmgrinfo_appinfo_filter_add_string(filter,
820 PMINFO_APPINFO_PROP_APP_COMPONENT,
822 pkgmgrinfo_appinfo_filter_destroy(filter);
823 return PMINFO_R_ERROR;
827 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter, app_func,
830 pkgmgrinfo_appinfo_filter_destroy(filter);
835 API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_component component,
836 pkgmgrinfo_app_list_cb app_func, void *user_data)
838 return pkgmgrinfo_appinfo_get_usr_list(handle, component, app_func, user_data, GLOBAL_USER);
841 API int pkgmgrinfo_appinfo_get_usr_install_list(pkgmgrinfo_app_list_cb app_func, uid_t uid, void *user_data)
843 if (app_func == NULL) {
844 LOGE("invalid parameter");
845 return PMINFO_R_EINVAL;
848 return _appinfo_get_filtered_foreach_appinfo(uid, NULL, app_func,
852 API int pkgmgrinfo_appinfo_get_install_list(pkgmgrinfo_app_list_cb app_func, void *user_data)
854 return pkgmgrinfo_appinfo_get_usr_install_list(app_func, GLOBAL_USER, user_data);
857 API int pkgmgrinfo_appinfo_get_usr_installed_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_installed_list(pkgmgrinfo_app_list_cb app_func, void *user_data)
870 return pkgmgrinfo_appinfo_get_usr_installed_list(app_func, GLOBAL_USER, user_data);
873 API int pkgmgrinfo_appinfo_get_appid(pkgmgrinfo_appinfo_h handle, char **appid)
875 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
877 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
878 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
880 if (info->app_info == NULL || info->app_info->appid == NULL)
881 return PMINFO_R_ERROR;
882 *appid = (char *)info->app_info->appid;
887 API int pkgmgrinfo_appinfo_get_pkgname(pkgmgrinfo_appinfo_h handle, char **pkg_name)
889 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
891 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
892 retvm_if(pkg_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
894 if (info->package == NULL)
895 return PMINFO_R_ERROR;
897 *pkg_name = (char *)info->package;
902 API int pkgmgrinfo_appinfo_get_pkgid(pkgmgrinfo_appinfo_h handle, char **pkgid)
904 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
906 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
907 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
909 if (info->package == NULL)
910 return PMINFO_R_ERROR;
912 *pkgid = (char *)info->package;
917 API int pkgmgrinfo_appinfo_get_exec(pkgmgrinfo_appinfo_h handle, char **exec)
919 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
921 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
922 retvm_if(exec == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
924 if (info->app_info == NULL || info->app_info->exec == NULL)
925 return PMINFO_R_ERROR;
926 *exec = (char *)info->app_info->exec;
932 API int pkgmgrinfo_appinfo_get_icon(pkgmgrinfo_appinfo_h handle, char **icon)
937 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
939 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
940 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
942 locale = info->locale;
943 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
945 if (info->app_info == NULL)
946 return PMINFO_R_ERROR;
948 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
949 ptr = (icon_x *)tmp->data;
950 if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL ||
951 !strcasecmp(ptr->text, "(null)") ||
952 strcmp(ptr->lang, locale))
954 *icon = (char *)ptr->text;
958 locale = DEFAULT_LOCALE;
959 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
960 ptr = (icon_x *)tmp->data;
961 if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL ||
962 strcmp(ptr->lang, locale))
964 *icon = (char *)ptr->text;
968 return PMINFO_R_ERROR;
972 API int pkgmgrinfo_appinfo_get_label(pkgmgrinfo_appinfo_h handle, char **label)
977 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
979 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
980 retvm_if(label == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
982 locale = info->locale;
983 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
985 if (info->app_info == NULL)
986 return PMINFO_R_ERROR;
988 for (tmp = info->app_info->label; tmp; tmp = tmp->next) {
989 ptr = (label_x *)tmp->data;
990 if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL ||
991 strcmp(ptr->lang, locale))
993 *label = (char *)ptr->text;
997 locale = DEFAULT_LOCALE;
998 for (tmp = info->app_info->label; tmp; tmp = tmp->next) {
999 ptr = (label_x *)tmp->data;
1000 if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL ||
1001 strcmp(ptr->lang, locale))
1003 *label = (char *)ptr->text;
1007 return PMINFO_R_ERROR;
1010 static char *_get_localed_label(const char *appid, const char *locale, uid_t uid)
1012 char *result = NULL;
1014 sqlite3_stmt *stmt = NULL;
1017 const char *manifest_db;
1019 manifest_db = getUserPkgParserDBPathUID(uid);
1020 if (manifest_db == NULL) {
1021 _LOGE("Failed to get manifest db path");
1025 if (sqlite3_open_v2(manifest_db, &db, SQLITE_OPEN_READONLY, NULL) != SQLITE_OK) {
1026 _LOGE("DB open fail\n");
1030 query = sqlite3_mprintf("select app_label from package_app_localized_info where app_id=%Q and app_locale=%Q", appid, locale);
1031 if (query == NULL) {
1032 _LOGE("Out of memory");
1036 if (sqlite3_prepare_v2(db, query, -1, &stmt, NULL) != SQLITE_OK) {
1037 _LOGE("prepare_v2 fail\n");
1041 if (sqlite3_step(stmt) == SQLITE_ROW) {
1042 val = (char *)sqlite3_column_text(stmt, 0);
1044 result = strdup(val);
1048 sqlite3_finalize(stmt);
1049 sqlite3_free(query);
1055 API int pkgmgrinfo_appinfo_usr_get_localed_label(const char *appid, const char *locale, uid_t uid, char **label)
1059 retvm_if(appid == NULL || locale == NULL || label == NULL, PMINFO_R_EINVAL, "Argument is NULL");
1061 val = _get_localed_label(appid, locale, uid);
1063 val = _get_localed_label(appid, DEFAULT_LOCALE, uid);
1066 return PMINFO_R_ERROR;
1073 API int pkgmgrinfo_appinfo_get_localed_label(const char *appid, const char *locale, char **label)
1075 return pkgmgrinfo_appinfo_usr_get_localed_label(appid, locale, GLOBAL_USER, label);
1078 static pkgmgrinfo_app_component __appcomponent_convert(const char *comp)
1080 if ( strcasecmp(comp, "uiapp") == 0)
1081 return PMINFO_UI_APP;
1082 else if ( strcasecmp(comp, "svcapp") == 0)
1083 return PMINFO_SVC_APP;
1088 API int pkgmgrinfo_appinfo_get_component(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_component *component)
1090 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1093 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1094 retvm_if(component == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1096 if (info->app_info == NULL)
1097 return PMINFO_R_ERROR;
1099 comp = __appcomponent_convert(info->app_info->component);
1101 return PMINFO_R_ERROR;
1108 API int pkgmgrinfo_appinfo_get_apptype(pkgmgrinfo_appinfo_h handle, char **app_type)
1110 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1112 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1113 retvm_if(app_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1115 if (info->app_info == NULL || info->app_info->type == NULL)
1116 return PMINFO_R_ERROR;
1117 *app_type = (char *)info->app_info->type;
1122 API int pkgmgrinfo_appinfo_get_operation(pkgmgrinfo_appcontrol_h handle,
1123 int *operation_count, char ***operation)
1125 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1126 retvm_if(operation == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1127 retvm_if(operation_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1128 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1129 *operation_count = data->operation_count;
1130 *operation = data->operation;
1134 API int pkgmgrinfo_appinfo_get_uri(pkgmgrinfo_appcontrol_h handle,
1135 int *uri_count, char ***uri)
1137 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1138 retvm_if(uri == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1139 retvm_if(uri_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1140 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1141 *uri_count = data->uri_count;
1146 API int pkgmgrinfo_appinfo_get_mime(pkgmgrinfo_appcontrol_h handle,
1147 int *mime_count, char ***mime)
1149 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1150 retvm_if(mime == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1151 retvm_if(mime_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1152 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1153 *mime_count = data->mime_count;
1158 API int pkgmgrinfo_appinfo_get_subapp(pkgmgrinfo_appcontrol_h handle,
1159 int *subapp_count, char ***subapp)
1161 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1162 retvm_if(subapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1163 retvm_if(subapp_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1164 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1165 *subapp_count = data->subapp_count;
1166 *subapp = data->subapp;
1170 API int pkgmgrinfo_appinfo_get_setting_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1175 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1177 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1178 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1180 if (info->app_info == NULL)
1181 return PMINFO_R_ERROR;
1183 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1184 ptr = (icon_x *)tmp->data;
1185 if (ptr == NULL || ptr->section == NULL)
1188 val = (char *)ptr->section;
1189 if (val && strcmp(val, "setting") == 0) {
1190 *icon = (char *)ptr->text;
1195 return PMINFO_R_ERROR;
1199 API int pkgmgrinfo_appinfo_get_notification_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1204 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1206 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1207 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1209 if (info->app_info == NULL)
1210 return PMINFO_R_ERROR;
1212 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1213 ptr = (icon_x *)tmp->data;
1214 if (ptr == NULL || ptr->section == NULL)
1217 val = (char *)ptr->section;
1218 if (val && strcmp(val, "notification") == 0){
1219 *icon = (char *)ptr->text;
1224 return PMINFO_R_ERROR;
1227 API int pkgmgrinfo_appinfo_get_recent_image_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_recentimage *type)
1230 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1232 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1233 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1235 if (info->app_info == NULL || info->app_info->recentimage == NULL)
1236 return PMINFO_R_ERROR;
1238 val = (char *)info->app_info->recentimage;
1239 if (strcasecmp(val, "capture") == 0)
1240 *type = PMINFO_RECENTIMAGE_USE_CAPTURE;
1241 else if (strcasecmp(val, "icon") == 0)
1242 *type = PMINFO_RECENTIMAGE_USE_ICON;
1244 *type = PMINFO_RECENTIMAGE_USE_NOTHING;
1249 API int pkgmgrinfo_appinfo_get_preview_image(pkgmgrinfo_appinfo_h handle, char **preview_img)
1254 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1256 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1257 retvm_if(preview_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1259 if (info->app_info == NULL)
1260 return PMINFO_R_ERROR;
1262 for (tmp = info->app_info->image; tmp; tmp = tmp->next) {
1263 ptr = (image_x *)tmp->data;
1264 if (ptr == NULL || ptr->section == NULL)
1267 val = (char *)ptr->section;
1268 if (val && strcmp(val, "preview") == 0) {
1269 *preview_img = (char *)ptr->text;
1274 return PMINFO_R_ERROR;
1277 API int pkgmgrinfo_appinfo_get_permission_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_permission_type *permission)
1280 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1282 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1283 retvm_if(permission == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1285 val = info->app_info->permission_type;
1287 return PMINFO_R_ERROR;
1289 if (strcmp(val, "signature") == 0)
1290 *permission = PMINFO_PERMISSION_SIGNATURE;
1291 else if (strcmp(val, "privilege") == 0)
1292 *permission = PMINFO_PERMISSION_PRIVILEGE;
1294 *permission = PMINFO_PERMISSION_NORMAL;
1299 API int pkgmgrinfo_appinfo_get_component_type(pkgmgrinfo_appinfo_h handle, char **component_type)
1301 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1303 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1304 retvm_if(component_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1306 if (info->app_info == NULL || info->app_info->component_type == NULL)
1307 return PMINFO_R_ERROR;
1309 *component_type = (char *)info->app_info->component_type;
1314 API int pkgmgrinfo_appinfo_get_hwacceleration(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_hwacceleration *hwacceleration)
1317 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1319 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1320 retvm_if(hwacceleration == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1322 if (info->app_info == NULL || info->app_info->hwacceleration == NULL)
1323 return PMINFO_R_ERROR;
1325 val = (char *)info->app_info->hwacceleration;
1326 if (strcasecmp(val, "not-use-GL") == 0)
1327 *hwacceleration = PMINFO_HWACCELERATION_NOT_USE_GL;
1328 else if (strcasecmp(val, "use-GL") == 0)
1329 *hwacceleration = PMINFO_HWACCELERATION_USE_GL;
1331 *hwacceleration = PMINFO_HWACCELERATION_USE_SYSTEM_SETTING;
1336 API int pkgmgrinfo_appinfo_get_screenreader(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_screenreader *screenreader)
1339 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1341 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1342 retvm_if(screenreader == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1344 if (info->app_info == NULL || info->app_info->screenreader == NULL)
1345 return PMINFO_R_ERROR;
1347 val = (char *)info->app_info->screenreader;
1348 if (strcasecmp(val, "screenreader-off") == 0)
1349 *screenreader = PMINFO_SCREENREADER_OFF;
1350 else if (strcasecmp(val, "screenreader-on") == 0)
1351 *screenreader = PMINFO_SCREENREADER_ON;
1353 *screenreader = PMINFO_SCREENREADER_USE_SYSTEM_SETTING;
1358 API int pkgmgrinfo_appinfo_get_effectimage(pkgmgrinfo_appinfo_h handle, char **portrait_img, char **landscape_img)
1360 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1362 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1363 retvm_if(portrait_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1364 retvm_if(landscape_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1366 if (info->app_info == NULL || info->app_info->portraitimg ||
1367 info->app_info->landscapeimg == NULL)
1368 return PMINFO_R_ERROR;
1370 *portrait_img = (char *)info->app_info->portraitimg;
1371 *landscape_img = (char *)info->app_info->landscapeimg;
1376 API int pkgmgrinfo_appinfo_get_effectimage_type(pkgmgrinfo_appinfo_h handle, char **effectimage_type)
1378 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1380 if (handle == NULL || effectimage_type == NULL) {
1381 LOGE("invalid parameter");
1382 return PMINFO_R_EINVAL;
1385 if (info->app_info == NULL || info->app_info->effectimage_type == NULL)
1386 return PMINFO_R_ERROR;
1388 *effectimage_type = (char *)info->app_info->effectimage_type;
1393 API int pkgmgrinfo_appinfo_get_submode_mainid(pkgmgrinfo_appinfo_h handle, char **submode_mainid)
1395 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1397 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1398 retvm_if(submode_mainid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1400 if (info->app_info == NULL || info->app_info->submode_mainid == NULL)
1401 return PMINFO_R_ERROR;
1403 *submode_mainid = (char *)info->app_info->submode_mainid;
1408 API int pkgmgrinfo_appinfo_get_installed_storage_location(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_installed_storage *storage)
1410 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1411 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1413 if (info->app_info && info->app_info->installed_storage){
1414 if (strcmp(info->app_info->installed_storage,"installed_internal") == 0)
1415 *storage = PMINFO_INTERNAL_STORAGE;
1416 else if (strcmp(info->app_info->installed_storage,"installed_external") == 0)
1417 *storage = PMINFO_EXTERNAL_STORAGE;
1419 return PMINFO_R_ERROR;
1421 return PMINFO_R_ERROR;
1426 API int pkgmgrinfo_appinfo_get_launch_mode(pkgmgrinfo_appinfo_h handle, char **mode)
1428 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1430 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1431 retvm_if(mode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1433 if (info->app_info->launch_mode == NULL)
1434 return PMINFO_R_ERROR;
1436 *mode = (char *)(info->app_info->launch_mode);
1441 API int pkgmgrinfo_appinfo_get_alias_appid(pkgmgrinfo_appinfo_h handle, char **alias_appid)
1443 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1445 if (handle == NULL || alias_appid == NULL) {
1446 LOGE("invalid parameter");
1447 return PMINFO_R_EINVAL;
1450 if (info->app_info == NULL || info->app_info->alias_appid == NULL)
1451 return PMINFO_R_ERROR;
1453 *alias_appid = (char *)info->app_info->alias_appid;
1458 API int pkgmgrinfo_appinfo_get_effective_appid(pkgmgrinfo_appinfo_h handle, char **effective_appid)
1460 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1462 if (handle == NULL || effective_appid == NULL) {
1463 LOGE("invalid parameter");
1464 return PMINFO_R_EINVAL;
1467 if (info->app_info == NULL || info->app_info->effective_appid == NULL)
1468 return PMINFO_R_ERROR;
1470 *effective_appid = (char *)info->app_info->effective_appid;
1475 API int pkgmgrinfo_appinfo_usr_get_datacontrol_info(const char *providerid, const char *type, uid_t uid, char **appid, char **access)
1477 retvm_if(providerid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
1478 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
1479 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1480 retvm_if(access == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1482 int ret = PMINFO_R_OK;
1484 sqlite3_stmt *stmt = NULL;
1487 ret = __open_manifest_db(uid, true);
1488 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
1490 /*Start constructing query*/
1491 query = sqlite3_mprintf("select * from package_app_data_control where providerid=%Q and type=%Q", providerid, type);
1494 ret = sqlite3_prepare_v2(GET_DB(manifest_db), query, strlen(query), &stmt, NULL);
1495 tryvm_if(ret != PMINFO_R_OK, ret = PMINFO_R_ERROR, "sqlite3_prepare_v2 failed[%s]\n", query);
1498 ret = sqlite3_step(stmt);
1499 tryvm_if((ret != SQLITE_ROW) || (ret == SQLITE_DONE), ret = PMINFO_R_ERROR, "No records found");
1501 *appid = strdup((char *)sqlite3_column_text(stmt, 0));
1502 *access = strdup((char *)sqlite3_column_text(stmt, 2));
1507 sqlite3_free(query);
1508 sqlite3_finalize(stmt);
1509 __close_manifest_db();
1513 API int pkgmgrinfo_appinfo_get_datacontrol_info(const char *providerid, const char *type, char **appid, char **access)
1515 return pkgmgrinfo_appinfo_usr_get_datacontrol_info(providerid, type, GLOBAL_USER, appid, access);
1518 API int pkgmgrinfo_appinfo_usr_get_datacontrol_appid(const char *providerid, uid_t uid, char **appid)
1520 retvm_if(providerid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
1521 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1523 int ret = PMINFO_R_OK;
1525 sqlite3_stmt *stmt = NULL;
1528 ret = __open_manifest_db(uid, true);
1529 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
1531 /*Start constructing query*/
1532 query = sqlite3_mprintf("select * from package_app_data_control where providerid=%Q", providerid);
1535 ret = sqlite3_prepare_v2(GET_DB(manifest_db), query, strlen(query), &stmt, NULL);
1536 tryvm_if(ret != PMINFO_R_OK, ret = PMINFO_R_ERROR, "sqlite3_prepare_v2 failed[%s]\n", query);
1539 ret = sqlite3_step(stmt);
1540 tryvm_if((ret != SQLITE_ROW) || (ret == SQLITE_DONE), ret = PMINFO_R_ERROR, "No records found");
1542 *appid = strdup((char *)sqlite3_column_text(stmt, 0));
1547 sqlite3_free(query);
1548 sqlite3_finalize(stmt);
1549 __close_manifest_db();
1553 API int pkgmgrinfo_appinfo_get_datacontrol_appid(const char *providerid, char **appid)
1555 return pkgmgrinfo_appinfo_usr_get_datacontrol_appid(providerid, GLOBAL_USER, appid);
1558 API int pkgmgrinfo_appinfo_foreach_permission(pkgmgrinfo_appinfo_h handle,
1559 pkgmgrinfo_app_permission_list_cb permission_func, void *user_data)
1561 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1562 retvm_if(permission_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
1566 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1568 if (info->app_info == NULL)
1569 return PMINFO_R_ERROR;
1571 for (tmp = info->app_info->permission; tmp; tmp = tmp->next) {
1572 ptr = (permission_x *)tmp->data;
1576 ret = permission_func(ptr->value, user_data);
1584 API int pkgmgrinfo_appinfo_foreach_category(pkgmgrinfo_appinfo_h handle,
1585 pkgmgrinfo_app_category_list_cb category_func, void *user_data)
1587 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1588 retvm_if(category_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
1590 const char *category;
1592 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1594 if (info->app_info == NULL)
1595 return PMINFO_R_ERROR;
1597 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
1598 category = (const char *)tmp->data;
1600 ret = category_func(category, user_data);
1608 API int pkgmgrinfo_appinfo_foreach_metadata(pkgmgrinfo_appinfo_h handle,
1609 pkgmgrinfo_app_metadata_list_cb metadata_func, void *user_data)
1611 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1612 retvm_if(metadata_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
1616 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1618 if (info->app_info == NULL)
1619 return PMINFO_R_ERROR;
1621 for (tmp = info->app_info->metadata; tmp; tmp = tmp->next) {
1622 ptr = (metadata_x *)tmp->data;
1626 ret = metadata_func(ptr->key, ptr->value, user_data);
1634 API int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
1635 pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
1637 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1638 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
1640 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1641 appcontrol_x *appcontrol;
1644 if (info->app_info == NULL)
1645 return PMINFO_R_ERROR;
1647 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
1648 appcontrol = (appcontrol_x *)tmp->data;
1649 if (appcontrol == NULL)
1651 ret = appcontrol_func(appcontrol->operation, appcontrol->uri, appcontrol->mime, user_data);
1659 API int pkgmgrinfo_appinfo_foreach_background_category(
1660 pkgmgrinfo_appinfo_h handle,
1661 pkgmgrinfo_app_background_category_list_cb category_func,
1664 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1668 if (handle == NULL || category_func == NULL || info->app_info == NULL) {
1669 LOGE("invalid parameter");
1670 return PMINFO_R_EINVAL;
1673 for (tmp = info->app_info->background_category; tmp; tmp = tmp->next) {
1674 category = (char *)tmp->data;
1675 if (category == NULL)
1678 if (category_func(category, user_data) < 0)
1685 API int pkgmgrinfo_appinfo_is_nodisplay(pkgmgrinfo_appinfo_h handle, bool *nodisplay)
1687 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1688 retvm_if(nodisplay == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1689 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1691 if (info->app_info == NULL || info->app_info->nodisplay == NULL)
1692 return PMINFO_R_ERROR;
1694 *nodisplay = _get_bool_value(info->app_info->nodisplay);
1699 API int pkgmgrinfo_appinfo_is_multiple(pkgmgrinfo_appinfo_h handle, bool *multiple)
1701 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1702 retvm_if(multiple == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1703 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1705 if (info->app_info == NULL || info->app_info->multiple == NULL)
1706 return PMINFO_R_ERROR;
1708 *multiple = _get_bool_value(info->app_info->multiple);
1713 API int pkgmgrinfo_appinfo_is_indicator_display_allowed(pkgmgrinfo_appinfo_h handle, bool *indicator_disp)
1715 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1716 retvm_if(indicator_disp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1717 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1719 if (info->app_info == NULL || info->app_info->indicatordisplay == NULL)
1720 return PMINFO_R_ERROR;
1722 *indicator_disp = _get_bool_value(info->app_info->indicatordisplay);
1727 API int pkgmgrinfo_appinfo_is_taskmanage(pkgmgrinfo_appinfo_h handle, bool *taskmanage)
1729 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1730 retvm_if(taskmanage == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1731 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1733 if (info->app_info == NULL || info->app_info->taskmanage == NULL)
1734 return PMINFO_R_ERROR;
1736 *taskmanage = _get_bool_value(info->app_info->taskmanage);
1741 API int pkgmgrinfo_appinfo_is_enabled(pkgmgrinfo_appinfo_h handle, bool *enabled)
1743 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1744 retvm_if(enabled == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1745 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1747 if (info->app_info == NULL || info->app_info->enabled == NULL)
1748 return PMINFO_R_ERROR;
1750 *enabled = _get_bool_value(info->app_info->enabled);
1755 API int pkgmgrinfo_appinfo_is_onboot(pkgmgrinfo_appinfo_h handle, bool *onboot)
1757 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1758 retvm_if(onboot == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1759 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1761 if (info->app_info == NULL || info->app_info->onboot == NULL)
1762 return PMINFO_R_ERROR;
1764 *onboot = _get_bool_value(info->app_info->onboot);
1769 API int pkgmgrinfo_appinfo_is_autorestart(pkgmgrinfo_appinfo_h handle, bool *autorestart)
1771 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1772 retvm_if(autorestart == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1773 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1775 if (info->app_info == NULL || info->app_info->autorestart == NULL)
1776 return PMINFO_R_ERROR;
1778 *autorestart = _get_bool_value(info->app_info->autorestart);
1783 API int pkgmgrinfo_appinfo_is_mainapp(pkgmgrinfo_appinfo_h handle, bool *mainapp)
1785 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1786 retvm_if(mainapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1787 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1789 if (info->app_info == NULL || info->app_info->mainapp == NULL)
1790 return PMINFO_R_ERROR;
1792 *mainapp = _get_bool_value(info->app_info->mainapp);
1797 API int pkgmgrinfo_appinfo_is_preload(pkgmgrinfo_appinfo_h handle, bool *preload)
1799 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1800 retvm_if(preload == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1801 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1803 if (info->app_info == NULL || info->app_info->preload == NULL)
1804 return PMINFO_R_ERROR;
1806 *preload = _get_bool_value(info->app_info->preload);
1811 API int pkgmgrinfo_appinfo_is_submode(pkgmgrinfo_appinfo_h handle, bool *submode)
1813 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1814 retvm_if(submode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1815 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1817 if (info->app_info == NULL || info->app_info->submode == NULL)
1818 return PMINFO_R_ERROR;
1820 *submode = _get_bool_value(info->app_info->submode);
1825 API int pkgmgrinfo_appinfo_is_process_pool(pkgmgrinfo_appinfo_h handle, bool *process_pool)
1827 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1829 if (handle == NULL || process_pool == NULL) {
1830 LOGE("invalid parameter");
1831 return PMINFO_R_EINVAL;
1834 if (info->app_info == NULL)
1835 return PMINFO_R_ERROR;
1837 *process_pool = _get_bool_value(info->app_info->process_pool);
1842 API int pkgmgrinfo_appinfo_is_category_exist(pkgmgrinfo_appinfo_h handle, const char *category, bool *exist)
1844 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1845 retvm_if(category == NULL, PMINFO_R_EINVAL, "category is NULL");
1846 retvm_if(exist == NULL, PMINFO_R_EINVAL, "exist is NULL");
1850 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1852 if (info->app_info == NULL)
1853 return PMINFO_R_ERROR;
1856 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
1857 val = (const char *)tmp->data;
1860 if (strcasecmp(val, category) == 0) {
1869 API int pkgmgrinfo_appinfo_is_ui_gadget(pkgmgrinfo_appinfo_h handle,
1872 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1874 if (info == NULL || info->app_info == NULL || ui_gadget == NULL) {
1875 _LOGE("invalid parameter");
1876 return PMINFO_R_EINVAL;
1879 *ui_gadget = _get_bool_value(info->app_info->ui_gadget);
1884 API int pkgmgrinfo_appinfo_is_support_disable(pkgmgrinfo_appinfo_h handle,
1885 bool *support_disable)
1887 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1889 if (info == NULL || info->app_info == NULL || support_disable == NULL) {
1890 _LOGE("invalid parameter");
1891 return PMINFO_R_EINVAL;
1894 *support_disable = _get_bool_value(info->app_info->support_disable);
1899 API int pkgmgrinfo_appinfo_destroy_appinfo(pkgmgrinfo_appinfo_h handle)
1901 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1902 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1903 __cleanup_appinfo(info);
1907 API int pkgmgrinfo_appinfo_filter_create(pkgmgrinfo_appinfo_filter_h *handle)
1909 return (pkgmgrinfo_pkginfo_filter_create(handle));
1912 API int pkgmgrinfo_appinfo_filter_destroy(pkgmgrinfo_appinfo_filter_h handle)
1914 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
1917 static gint __compare_func(gconstpointer data1, gconstpointer data2)
1919 pkgmgrinfo_node_x *node1 = (pkgmgrinfo_node_x*)data1;
1920 pkgmgrinfo_node_x *node2 = (pkgmgrinfo_node_x*)data2;
1921 if (node1->prop == node2->prop)
1923 else if (node1->prop > node2->prop)
1929 API int pkgmgrinfo_appinfo_filter_add_int(pkgmgrinfo_appinfo_filter_h handle,
1930 const char *property, const int value)
1932 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
1933 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
1934 char buf[PKG_VALUE_STRING_LEN_MAX] = {'\0'};
1936 GSList *link = NULL;
1938 prop = _pminfo_appinfo_convert_to_prop_int(property);
1939 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_INT ||
1940 prop > E_PMINFO_APPINFO_PROP_APP_MAX_INT) {
1941 _LOGE("Invalid Integer Property\n");
1942 return PMINFO_R_EINVAL;
1944 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
1945 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
1947 _LOGE("Out of Memory!!!\n");
1948 return PMINFO_R_ERROR;
1950 snprintf(buf, PKG_VALUE_STRING_LEN_MAX - 1, "%d", value);
1951 val = strndup(buf, PKG_VALUE_STRING_LEN_MAX - 1);
1953 _LOGE("Out of Memory\n");
1956 return PMINFO_R_ERROR;
1960 /*If API is called multiple times for same property, we should override the previous values.
1961 Last value set will be used for filtering.*/
1962 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
1964 filter->list = g_slist_delete_link(filter->list, link);
1965 filter->list = g_slist_append(filter->list, (gpointer)node);
1970 API int pkgmgrinfo_appinfo_filter_add_bool(pkgmgrinfo_appinfo_filter_h handle,
1971 const char *property, const bool value)
1973 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
1974 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
1976 GSList *link = NULL;
1978 prop = _pminfo_appinfo_convert_to_prop_bool(property);
1979 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_BOOL ||
1980 prop > E_PMINFO_APPINFO_PROP_APP_MAX_BOOL) {
1981 _LOGE("Invalid Boolean Property\n");
1982 return PMINFO_R_EINVAL;
1984 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
1985 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
1987 _LOGE("Out of Memory!!!\n");
1988 return PMINFO_R_ERROR;
1991 val = strndup("('true','True')", 15);
1993 val = strndup("('false','False')", 17);
1995 _LOGE("Out of Memory\n");
1998 return PMINFO_R_ERROR;
2002 /*If API is called multiple times for same property, we should override the previous values.
2003 Last value set will be used for filtering.*/
2004 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2006 filter->list = g_slist_delete_link(filter->list, link);
2007 filter->list = g_slist_append(filter->list, (gpointer)node);
2012 API int pkgmgrinfo_appinfo_filter_add_string(pkgmgrinfo_appinfo_filter_h handle,
2013 const char *property, const char *value)
2015 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2016 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2017 retvm_if(value == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2019 pkgmgrinfo_node_x *ptr = NULL;
2020 char prev[PKG_STRING_LEN_MAX] = {'\0'};
2021 char temp[PKG_STRING_LEN_MAX] = {'\0'};
2022 GSList *link = NULL;
2024 prop = _pminfo_appinfo_convert_to_prop_str(property);
2025 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_STR ||
2026 prop > E_PMINFO_APPINFO_PROP_APP_MAX_STR) {
2027 _LOGE("Invalid String Property\n");
2028 return PMINFO_R_EINVAL;
2030 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
2031 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
2033 _LOGE("Out of Memory!!!\n");
2034 return PMINFO_R_ERROR;
2038 case E_PMINFO_APPINFO_PROP_APP_COMPONENT:
2039 if (strcmp(value, PMINFO_APPINFO_UI_APP) == 0)
2040 val = strndup("uiapp", PKG_STRING_LEN_MAX - 1);
2042 val = strndup("svcapp", PKG_STRING_LEN_MAX - 1);
2044 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2046 filter->list = g_slist_delete_link(filter->list, link);
2047 filter->list = g_slist_append(filter->list, (gpointer)node);
2049 case E_PMINFO_APPINFO_PROP_APP_CATEGORY:
2050 case E_PMINFO_APPINFO_PROP_APP_OPERATION:
2051 case E_PMINFO_APPINFO_PROP_APP_URI:
2052 case E_PMINFO_APPINFO_PROP_APP_MIME:
2053 val = (char *)calloc(1, PKG_STRING_LEN_MAX);
2055 _LOGE("Out of Memory\n");
2058 return PMINFO_R_ERROR;
2060 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2062 ptr = (pkgmgrinfo_node_x *)link->data;
2063 strncpy(prev, ptr->value, PKG_STRING_LEN_MAX - 1);
2064 _LOGE("Previous value is %s\n", prev);
2065 filter->list = g_slist_delete_link(filter->list, link);
2066 snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s , '%s'", prev, value);
2067 strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
2068 _LOGE("New value is %s\n", val);
2070 filter->list = g_slist_append(filter->list, (gpointer)node);
2071 memset(temp, '\0', PKG_STRING_LEN_MAX);
2073 snprintf(temp, PKG_STRING_LEN_MAX - 1, "'%s'", value);
2074 strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
2075 _LOGE("First value is %s\n", val);
2077 filter->list = g_slist_append(filter->list, (gpointer)node);
2078 memset(temp, '\0', PKG_STRING_LEN_MAX);
2082 node->value = strndup(value, PKG_STRING_LEN_MAX - 1);
2083 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2085 filter->list = g_slist_delete_link(filter->list, link);
2086 filter->list = g_slist_append(filter->list, (gpointer)node);
2092 API int pkgmgrinfo_appinfo_usr_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count, uid_t uid)
2097 if (handle == NULL || count == NULL) {
2098 _LOGE("invalid parameter");
2099 return PMINFO_R_EINVAL;
2102 ret = _appinfo_get_filtered_list(handle, uid, &list);
2103 if (ret != PMINFO_R_OK)
2104 return PMINFO_R_ERROR;
2106 *count = g_list_length(list);
2108 g_list_free_full(list, free);
2113 API int pkgmgrinfo_appinfo_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count)
2115 return pkgmgrinfo_appinfo_usr_filter_count(handle, count, GLOBAL_USER);
2118 API int pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(
2119 pkgmgrinfo_appinfo_filter_h handle,
2120 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
2122 if (handle == NULL || app_cb == NULL) {
2123 LOGE("invalid parameter");
2124 return PMINFO_R_EINVAL;
2127 return _appinfo_get_filtered_foreach_appinfo(uid, handle, app_cb,
2131 API int pkgmgrinfo_appinfo_filter_foreach_appinfo(pkgmgrinfo_appinfo_filter_h handle,
2132 pkgmgrinfo_app_list_cb app_cb, void * user_data)
2134 return pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(handle, app_cb, user_data, GLOBAL_USER);
2137 API int pkgmgrinfo_appinfo_metadata_filter_create(pkgmgrinfo_appinfo_metadata_filter_h *handle)
2139 return (pkgmgrinfo_pkginfo_filter_create(handle));
2142 API int pkgmgrinfo_appinfo_metadata_filter_destroy(pkgmgrinfo_appinfo_metadata_filter_h handle)
2144 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
2147 API int pkgmgrinfo_appinfo_metadata_filter_add(
2148 pkgmgrinfo_appinfo_metadata_filter_h handle,
2149 const char *key, const char *value)
2153 ret = pkgmgrinfo_appinfo_filter_add_string(handle,
2154 PMINFO_APPINFO_PROP_APP_METADATA_KEY, key);
2155 if (ret != PMINFO_R_OK)
2158 /* value can be NULL.
2159 * In that case all apps with specified key should be displayed
2162 ret = pkgmgrinfo_appinfo_filter_add_string(handle,
2163 PMINFO_APPINFO_PROP_APP_METADATA_VALUE, value);
2164 if (ret != PMINFO_R_OK)
2171 API int pkgmgrinfo_appinfo_usr_metadata_filter_foreach(
2172 pkgmgrinfo_appinfo_metadata_filter_h handle,
2173 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
2175 if (handle == NULL || app_cb == NULL) {
2176 LOGE("invalid parameter");
2177 return PMINFO_R_EINVAL;
2180 return _appinfo_get_filtered_foreach_appinfo(uid, handle, app_cb,
2184 API int pkgmgrinfo_appinfo_metadata_filter_foreach(
2185 pkgmgrinfo_appinfo_metadata_filter_h handle,
2186 pkgmgrinfo_app_list_cb app_cb, void *user_data)
2188 return pkgmgrinfo_appinfo_usr_metadata_filter_foreach(handle, app_cb,
2189 user_data, GLOBAL_USER);
2192 API int pkgmgrinfo_appinfo_is_guestmode_visibility(pkgmgrinfo_appinfo_h handle, bool *status)
2195 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2197 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2198 retvm_if(status == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2200 val = info->app_info->guestmode_visibility;
2201 *status = _get_bool_value(val);