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;
34 free((void *)info->package);
36 free((void *)info->locale);
38 pkgmgrinfo_basic_free_application(info->app_info);
44 static const char join_localized_info[] =
45 " LEFT OUTER JOIN package_app_localized_info"
46 " ON ai.app_id=package_app_localized_info.app_id"
47 " AND package_app_localized_info.app_locale=?";
48 static const char join_category[] =
49 " LEFT OUTER JOIN package_app_app_category"
50 " ON ai.app_id=package_app_app_category.app_id";
51 static const char join_app_control[] =
52 " LEFT OUTER JOIN package_app_app_control"
53 " ON ai.app_id=package_app_app_control.app_id";
54 static const char join_metadata[] =
55 " LEFT OUTER JOIN package_app_app_metadata"
56 " ON ai.app_id=package_app_app_metadata.app_id ";
58 static int _get_filtered_query(pkgmgrinfo_filter_x *filter,
59 const char *locale, char **query, GList **bind_params)
63 char *condition = NULL;
64 char buf[MAX_QUERY_LEN] = { '\0' };
65 char tmp_query[MAX_QUERY_LEN] = { '\0' };
71 len += strlen(" WHERE 1=1");
72 strncat(buf, " WHERE 1=1", MAX_QUERY_LEN - len - 1);
73 for (list = filter->list; list; list = list->next) {
74 joined |= __get_filter_condition(list->data, &condition, bind_params);
75 if (condition == NULL)
78 len += strlen(" AND ");
79 strncat(buf, " AND ", MAX_QUERY_LEN - len - 1);
81 len += strlen(condition);
82 strncat(buf, condition, sizeof(buf) - len - 1);
87 if (joined & E_PMINFO_APPINFO_JOIN_LOCALIZED_INFO) {
88 strncat(tmp_query, join_localized_info, MAX_QUERY_LEN - len - 1);
89 len += strlen(join_localized_info);
90 *bind_params = g_list_append(*bind_params, strdup(locale));
92 if (joined & E_PMINFO_APPINFO_JOIN_CATEGORY) {
93 strncat(tmp_query, join_category, MAX_QUERY_LEN - len - 1);
94 len += strlen(join_category);
96 if (joined & E_PMINFO_APPINFO_JOIN_APP_CONTROL) {
97 strncat(tmp_query, join_app_control, MAX_QUERY_LEN - len - 1);
98 len += strlen(join_app_control);
100 if (joined & E_PMINFO_APPINFO_JOIN_METADATA) {
101 strncat(tmp_query, join_metadata, MAX_QUERY_LEN - len - 1);
102 len += strlen(join_metadata);
104 strncat(tmp_query, buf, MAX_QUERY_LEN - len - 1);
106 *query = strdup(tmp_query);
108 return PMINFO_R_ERROR;
113 static int _appinfo_get_label(sqlite3 *db, const char *appid,
114 const char *locale, GList **label)
116 static const char query_raw[] =
117 "SELECT app_label, app_locale "
118 "FROM package_app_localized_info "
119 "WHERE app_id=%Q AND app_locale IN (%Q, %Q)";
126 query = sqlite3_mprintf(query_raw, appid, locale, DEFAULT_LOCALE);
128 LOGE("out of memory");
129 return PMINFO_R_ERROR;
132 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
134 if (ret != SQLITE_OK) {
135 LOGE("prepare failed: %s", sqlite3_errmsg(db));
136 return PMINFO_R_ERROR;
139 while (sqlite3_step(stmt) == SQLITE_ROW) {
140 info = calloc(1, sizeof(label_x));
142 LOGE("out of memory");
143 sqlite3_finalize(stmt);
144 return PMINFO_R_ERROR;
147 _save_column_str(stmt, idx++, &info->text);
148 _save_column_str(stmt, idx++, &info->lang);
149 *label = g_list_append(*label, info);
152 sqlite3_finalize(stmt);
157 static int _appinfo_get_icon(sqlite3 *db, const char *appid, const char *locale,
160 static const char query_raw[] =
161 "SELECT app_icon, app_locale "
162 "FROM package_app_localized_info "
163 "WHERE app_id=%Q AND app_locale IN (%Q, %Q)";
170 query = sqlite3_mprintf(query_raw, appid, locale, DEFAULT_LOCALE);
172 LOGE("out of memory");
173 return PMINFO_R_ERROR;
176 ret = sqlite3_prepare_v2(db, query, strlen(query),
179 if (ret != SQLITE_OK) {
180 LOGE("prepare failed: %s", sqlite3_errmsg(db));
181 return PMINFO_R_ERROR;
184 while (sqlite3_step(stmt) == SQLITE_ROW) {
185 info = calloc(1, sizeof(icon_x));
187 LOGE("out of memory");
188 sqlite3_finalize(stmt);
189 return PMINFO_R_ERROR;
192 _save_column_str(stmt, idx++, &info->text);
193 _save_column_str(stmt, idx++, &info->lang);
194 *icon = g_list_append(*icon, info);
197 sqlite3_finalize(stmt);
202 static int _appinfo_get_category(sqlite3 *db, const char *appid,
205 static const char query_raw[] =
206 "SELECT category FROM package_app_app_category WHERE app_id=%Q";
212 query = sqlite3_mprintf(query_raw, appid);
214 LOGE("out of memory");
215 return PMINFO_R_ERROR;
218 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
220 if (ret != SQLITE_OK) {
221 LOGE("prepare failed: %s", sqlite3_errmsg(db));
222 return PMINFO_R_ERROR;
225 while (sqlite3_step(stmt) == SQLITE_ROW) {
227 _save_column_str(stmt, 0, &val);
229 *category = g_list_append(*category, (gpointer)val);
232 sqlite3_finalize(stmt);
237 static void __parse_appcontrol(GList **appcontrol, char *appcontrol_str)
244 if (appcontrol_str == NULL)
247 dup = strdup(appcontrol_str);
249 ac = calloc(1, sizeof(appcontrol_x));
251 _LOGE("out of memory");
254 token = strtok_r(dup, "|", &ptr);
255 if (token && strcmp(token, "NULL"))
256 ac->operation = strdup(token);
257 token = strtok_r(NULL, "|", &ptr);
258 if (token && strcmp(token, "NULL"))
259 ac->uri = strdup(token);
260 token = strtok_r(NULL, "|", &ptr);
261 if (token && strcmp(token, "NULL"))
262 ac->mime = strdup(token);
263 *appcontrol = g_list_append(*appcontrol, ac);
264 } while ((token = strtok_r(NULL, ";", &ptr)));
269 static int _appinfo_get_app_control(sqlite3 *db, const char *appid,
272 static const char query_raw[] =
273 "SELECT app_control FROM package_app_app_control "
280 query = sqlite3_mprintf(query_raw, appid);
282 LOGE("out of memory");
283 return PMINFO_R_ERROR;
286 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
288 if (ret != SQLITE_OK) {
289 LOGE("prepare failed: %s", sqlite3_errmsg(db));
290 return PMINFO_R_ERROR;
293 while (sqlite3_step(stmt) == SQLITE_ROW) {
295 _save_column_str(stmt, 0, &str);
297 __parse_appcontrol(appcontrol, str);
301 sqlite3_finalize(stmt);
306 static int _appinfo_get_data_control(sqlite3 *db, const char *appid,
309 static const char query_raw[] =
310 "SELECT providerid, access, type "
311 "FROM package_app_data_control WHERE app_id=%Q";
318 query = sqlite3_mprintf(query_raw, appid);
320 LOGE("out of memory");
321 return PMINFO_R_ERROR;
324 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
326 if (ret != SQLITE_OK) {
327 LOGE("prepare failed: %s", sqlite3_errmsg(db));
328 return PMINFO_R_ERROR;
331 while (sqlite3_step(stmt) == SQLITE_ROW) {
332 info = calloc(1, sizeof(datacontrol_x));
334 LOGE("out of memory");
335 sqlite3_finalize(stmt);
336 return PMINFO_R_ERROR;
339 _save_column_str(stmt, idx++, &info->providerid);
340 _save_column_str(stmt, idx++, &info->access);
341 _save_column_str(stmt, idx++, &info->type);
342 *datacontrol = g_list_append(*datacontrol, info);
345 sqlite3_finalize(stmt);
350 static int _appinfo_get_metadata(sqlite3 *db, const char *appid,
353 static const char query_raw[] =
354 "SELECT md_key, md_value "
355 "FROM package_app_app_metadata WHERE app_id=%Q";
362 query = sqlite3_mprintf(query_raw, appid);
364 LOGE("out of memory");
365 return PMINFO_R_ERROR;
368 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
370 if (ret != SQLITE_OK) {
371 LOGE("prepare failed: %s", sqlite3_errmsg(db));
372 return PMINFO_R_ERROR;
375 while (sqlite3_step(stmt) == SQLITE_ROW) {
376 info = calloc(1, sizeof(metadata_x));
378 LOGE("out of memory");
379 sqlite3_finalize(stmt);
380 return PMINFO_R_ERROR;
383 _save_column_str(stmt, idx++, &info->key);
384 _save_column_str(stmt, idx++, &info->value);
385 *metadata = g_list_append(*metadata, info);
388 sqlite3_finalize(stmt);
394 static int _appinfo_get_splashscreens(sqlite3 *db, const char *appid,
395 GList **splashscreens)
397 static const char query_raw[] =
398 "SELECT src, type, orientation, indicatordisplay, operation, color_depth "
399 "FROM package_app_splash_screen WHERE app_id=%Q";
404 splashscreen_x *info;
406 query = sqlite3_mprintf(query_raw, appid);
408 LOGE("out of memory");
409 return PMINFO_R_ERROR;
412 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
414 if (ret != SQLITE_OK) {
415 LOGE("prepare failed: %s", sqlite3_errmsg(db));
416 return PMINFO_R_ERROR;
419 while (sqlite3_step(stmt) == SQLITE_ROW) {
420 info = calloc(1, sizeof(splashscreen_x));
422 LOGE("out of memory");
423 sqlite3_finalize(stmt);
424 return PMINFO_R_ERROR;
427 _save_column_str(stmt, idx++, &info->src);
428 _save_column_str(stmt, idx++, &info->type);
429 _save_column_str(stmt, idx++, &info->orientation);
430 _save_column_str(stmt, idx++, &info->indicatordisplay);
431 _save_column_str(stmt, idx++, &info->operation);
432 _save_column_str(stmt, idx++, &info->color_depth);
433 *splashscreens = g_list_append(*splashscreens, info);
436 sqlite3_finalize(stmt);
441 static GList *__get_background_category(const char *value)
443 GList *category_list = NULL;
444 int convert_value = 0;
445 if (!value || strlen(value) == 0)
448 convert_value = atoi(value);
449 if (convert_value < 0)
452 if (convert_value & APP_BG_CATEGORY_USER_DISABLE_TRUE_VAL)
453 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_USER_DISABLE_TRUE_STR));
455 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_USER_DISABLE_FALSE_STR));
457 if (convert_value & APP_BG_CATEGORY_MEDIA_VAL)
458 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_MEDIA_STR));
460 if (convert_value & APP_BG_CATEGORY_DOWNLOAD_VAL)
461 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_DOWNLOAD_STR));
463 if (convert_value & APP_BG_CATEGORY_BGNETWORK_VAL)
464 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_BGNETWORK_STR));
466 if (convert_value & APP_BG_CATEGORY_LOCATION_VAL)
467 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_LOCATION_STR));
469 if (convert_value & APP_BG_CATEGORY_SENSOR_VAL)
470 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_SENSOR_STR));
472 if (convert_value & APP_BG_CATEGORY_IOTCOMM_VAL)
473 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_IOTCOMM_STR));
475 if (convert_value & APP_BG_CATEGORY_SYSTEM_VAL)
476 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_SYSTEM));
478 return category_list;
482 static void __get_splash_screen_display(sqlite3 *db, const char *appid, uid_t uid, char **value)
484 static const char query_raw[] =
485 "SELECT is_splash_screen_enabled FROM package_app_info_for_uid "
486 "WHERE app_id='%s' AND uid='%d'";
491 query = sqlite3_mprintf(query_raw, appid, uid);
493 LOGE("out of memory");
497 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
499 if (ret != SQLITE_OK) {
500 LOGE("sqlite3_prepare_v2() failed: %s", sqlite3_errmsg(db));
504 while (sqlite3_step(stmt) == SQLITE_ROW) {
507 _save_column_str(stmt, 0, value);
510 sqlite3_finalize(stmt);
513 static void __free_applications(gpointer data)
515 pkgmgrinfo_basic_free_application((application_x *)data);
518 static int __bind_params(sqlite3_stmt *stmt, GList *params)
520 GList *tmp_list = NULL;
524 if (stmt == NULL || params == NULL)
525 return PMINFO_R_EINVAL;
529 ret = sqlite3_bind_text(stmt, ++idx, (char *)tmp_list->data, -1, SQLITE_STATIC);
530 if (ret != SQLITE_OK)
531 return PMINFO_R_ERROR;
532 tmp_list = tmp_list->next;
538 static int _appinfo_get_applications(uid_t db_uid, uid_t uid,
539 const char *locale, pkgmgrinfo_filter_x *filter, int flag,
540 GHashTable *applications)
542 static const char query_raw[] =
543 "SELECT DISTINCT ai.app_id, ai.app_component, ai.app_exec, "
544 "ai.app_nodisplay, ai.app_type, ai.app_onboot, "
545 "ai.app_multiple, ai.app_autorestart, ai.app_taskmanage, "
546 "ai.app_enabled, ai.app_hwacceleration, ai.app_screenreader, "
547 "ai.app_mainapp, ai.app_recentimage, ai.app_launchcondition, "
548 "ai.app_indicatordisplay, ai.app_portraitimg, "
549 "ai.app_landscapeimg, ai.app_guestmodevisibility, "
550 "ai.app_permissiontype, ai.app_preload, ai.app_submode, "
551 "ai.app_submode_mainid, ai.app_launch_mode, ai.app_ui_gadget, "
552 "ai.app_support_disable, ai.app_process_pool, "
553 "ai.app_installed_storage, ai.app_background_category, "
554 "ai.app_package_type, ai.app_root_path, ai.app_api_version, "
555 "ai.app_effective_appid, ai.app_disable, "
556 "ai.app_splash_screen_display, ai.app_zip_mount_file, "
557 "ai.component_type, ai.package "
558 "FROM package_app_info as ai";
559 int ret = PMINFO_R_ERROR;
562 char *bg_category_str = NULL;
563 char *constraint = NULL;
564 char query[MAX_QUERY_LEN] = { '\0' };
565 application_x *info = NULL;
566 GList *bind_params = NULL;
568 sqlite3_stmt *stmt = NULL;
570 dbpath = getUserPkgParserDBPathUID(db_uid);
572 return PMINFO_R_ERROR;
574 ret = sqlite3_open_v2(dbpath, &db, SQLITE_OPEN_READONLY, NULL);
575 if (ret != SQLITE_OK) {
576 _LOGE("failed to open db: %d", ret);
577 return PMINFO_R_ERROR;
580 ret = _get_filtered_query(filter, locale, &constraint, &bind_params);
581 if (ret != PMINFO_R_OK) {
582 LOGE("Failed to get WHERE clause");
587 snprintf(query, MAX_QUERY_LEN - 1, "%s%s", query_raw, constraint);
589 snprintf(query, MAX_QUERY_LEN - 1, "%s", query_raw);
591 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
592 if (ret != SQLITE_OK) {
593 LOGE("prepare failed: %s", sqlite3_errmsg(db));
594 ret = PMINFO_R_ERROR;
598 if (g_list_length(bind_params) != 0) {
599 ret = __bind_params(stmt, bind_params);
600 if (ret != SQLITE_OK) {
601 LOGE("Failed to bind parameters");
606 while (sqlite3_step(stmt) == SQLITE_ROW) {
607 info = calloc(1, sizeof(application_x));
609 LOGE("out of memory");
610 ret = PMINFO_R_ERROR;
614 _save_column_str(stmt, idx++, &info->appid);
615 if (g_hash_table_contains(applications,
616 (gconstpointer)info->appid)) {
621 _save_column_str(stmt, idx++, &info->component);
622 _save_column_str(stmt, idx++, &info->exec);
623 _save_column_str(stmt, idx++, &info->nodisplay);
624 _save_column_str(stmt, idx++, &info->type);
625 _save_column_str(stmt, idx++, &info->onboot);
626 _save_column_str(stmt, idx++, &info->multiple);
627 _save_column_str(stmt, idx++, &info->autorestart);
628 _save_column_str(stmt, idx++, &info->taskmanage);
629 _save_column_str(stmt, idx++, &info->enabled);
630 _save_column_str(stmt, idx++, &info->hwacceleration);
631 _save_column_str(stmt, idx++, &info->screenreader);
632 _save_column_str(stmt, idx++, &info->mainapp);
633 _save_column_str(stmt, idx++, &info->recentimage);
634 _save_column_str(stmt, idx++, &info->launchcondition);
635 _save_column_str(stmt, idx++, &info->indicatordisplay);
636 _save_column_str(stmt, idx++, &info->portraitimg);
637 _save_column_str(stmt, idx++, &info->landscapeimg);
638 _save_column_str(stmt, idx++, &info->guestmode_visibility);
639 _save_column_str(stmt, idx++, &info->permission_type);
640 _save_column_str(stmt, idx++, &info->preload);
641 _save_column_str(stmt, idx++, &info->submode);
642 _save_column_str(stmt, idx++, &info->submode_mainid);
643 _save_column_str(stmt, idx++, &info->launch_mode);
644 _save_column_str(stmt, idx++, &info->ui_gadget);
645 _save_column_str(stmt, idx++, &info->support_disable);
646 _save_column_str(stmt, idx++, &info->process_pool);
647 _save_column_str(stmt, idx++, &info->installed_storage);
648 _save_column_str(stmt, idx++, &bg_category_str);
649 _save_column_str(stmt, idx++, &info->package_type);
650 _save_column_str(stmt, idx++, &info->root_path);
651 _save_column_str(stmt, idx++, &info->api_version);
652 _save_column_str(stmt, idx++, &info->effective_appid);
653 _save_column_str(stmt, idx++, &info->is_disabled);
654 _save_column_str(stmt, idx++, &info->splash_screen_display);
655 _save_column_str(stmt, idx++, &info->zip_mount_file);
656 _save_column_str(stmt, idx++, &info->component_type);
657 _save_column_str(stmt, idx++, &info->package);
658 info->for_all_users =
659 strdup((uid != GLOBAL_USER) ? "false" : "true");
661 if (db_uid == GLOBAL_USER)
662 __get_splash_screen_display(db, info->appid, db_uid,
663 &info->splash_screen_display);
665 info->background_category = __get_background_category(
667 free(bg_category_str);
669 if (flag & PMINFO_APPINFO_GET_LABEL) {
670 if (_appinfo_get_label(db, info->appid, locale,
672 ret = PMINFO_R_ERROR;
677 if (flag & PMINFO_APPINFO_GET_ICON) {
678 if (_appinfo_get_icon(db, info->appid, locale,
680 ret = PMINFO_R_ERROR;
685 if (flag & PMINFO_APPINFO_GET_CATEGORY) {
686 if (_appinfo_get_category(db, info->appid,
688 ret = PMINFO_R_ERROR;
693 if (flag & PMINFO_APPINFO_GET_APP_CONTROL) {
694 if (_appinfo_get_app_control(db, info->appid,
695 &info->appcontrol)) {
696 ret = PMINFO_R_ERROR;
701 if (flag & PMINFO_APPINFO_GET_DATA_CONTROL) {
702 if (_appinfo_get_data_control(db, info->appid,
703 &info->datacontrol)) {
704 ret = PMINFO_R_ERROR;
709 if (flag & PMINFO_APPINFO_GET_METADATA) {
710 if (_appinfo_get_metadata(db, info->appid,
712 ret = PMINFO_R_ERROR;
717 if (flag & PMINFO_APPINFO_GET_SPLASH_SCREEN) {
718 if (_appinfo_get_splashscreens(db, info->appid,
719 &info->splashscreens)) {
720 ret = PMINFO_R_ERROR;
725 g_hash_table_insert(applications, (gpointer)info->appid,
735 if (ret != PMINFO_R_OK && info != NULL)
736 pkgmgrinfo_basic_free_application(info);
738 g_list_free_full(bind_params, free);
739 sqlite3_close_v2(db);
740 sqlite3_finalize(stmt);
745 API int pkgmgrinfo_appinfo_get_usr_disabled_appinfo(const char *appid, uid_t uid,
746 pkgmgrinfo_appinfo_h *handle)
751 pkgmgrinfo_appinfo_filter_h filter;
752 pkgmgr_appinfo_x *info;
754 if (appid == NULL || handle == NULL) {
755 LOGE("invalid parameter");
756 return PMINFO_R_EINVAL;
759 locale = _get_system_locale();
761 return PMINFO_R_ERROR;
763 ret = pkgmgrinfo_appinfo_filter_create(&filter);
764 if (ret != PMINFO_R_OK) {
769 ret = pkgmgrinfo_appinfo_filter_add_string(filter,
770 PMINFO_APPINFO_PROP_APP_ID, appid);
771 if (ret != PMINFO_R_OK) {
772 pkgmgrinfo_appinfo_filter_destroy(filter);
774 return PMINFO_R_ERROR;
777 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
778 PMINFO_APPINFO_PROP_APP_DISABLE, true);
779 if (ret != PMINFO_R_OK) {
780 pkgmgrinfo_appinfo_filter_destroy(filter);
782 return PMINFO_R_ERROR;
785 list = g_hash_table_new(g_str_hash, g_str_equal);
787 pkgmgrinfo_appinfo_filter_destroy(filter);
789 return PMINFO_R_ERROR;
792 ret = _appinfo_get_applications(uid, uid, locale, filter,
793 PMINFO_APPINFO_GET_ALL, list);
794 if (!g_hash_table_size(list) && uid != GLOBAL_USER)
795 ret = _appinfo_get_applications(GLOBAL_USER, uid, locale,
796 filter, PMINFO_APPINFO_GET_ALL, list);
798 pkgmgrinfo_appinfo_filter_destroy(filter);
799 if (ret != PMINFO_R_OK) {
800 g_hash_table_destroy(list);
805 if (!g_hash_table_size(list)) {
806 _LOGI("Appinfo for [%s] is not existed for user [%d]",
808 g_hash_table_destroy(list);
810 return PMINFO_R_ENOENT;
813 info = calloc(1, sizeof(pkgmgr_appinfo_x));
815 _LOGE("out of memory");
817 return PMINFO_R_ERROR;
820 info->app_info = (application_x *)g_hash_table_lookup(list, appid);
821 info->locale = locale;
822 info->package = strdup(info->app_info->package);
824 /* just free list only */
825 g_hash_table_destroy(list);
832 API int pkgmgrinfo_appinfo_get_disabled_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
834 return pkgmgrinfo_appinfo_get_usr_disabled_appinfo(appid, _getuid(), handle);
837 API int pkgmgrinfo_appinfo_get_usr_appinfo(const char *appid, uid_t uid,
838 pkgmgrinfo_appinfo_h *handle)
843 pkgmgrinfo_appinfo_filter_h filter;
844 pkgmgr_appinfo_x *info;
846 if (appid == NULL || handle == NULL) {
847 LOGE("invalid parameter");
848 return PMINFO_R_EINVAL;
851 locale = _get_system_locale();
853 return PMINFO_R_ERROR;
855 ret = pkgmgrinfo_appinfo_filter_create(&filter);
856 if (ret != PMINFO_R_OK) {
861 ret = pkgmgrinfo_appinfo_filter_add_string(filter,
862 PMINFO_APPINFO_PROP_APP_ID, appid);
863 if (ret != PMINFO_R_OK) {
864 pkgmgrinfo_appinfo_filter_destroy(filter);
866 return PMINFO_R_ERROR;
869 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
870 PMINFO_APPINFO_PROP_APP_DISABLE, false);
871 if (ret != PMINFO_R_OK) {
872 pkgmgrinfo_appinfo_filter_destroy(filter);
874 return PMINFO_R_ERROR;
877 list = g_hash_table_new(g_str_hash, g_str_equal);
879 pkgmgrinfo_appinfo_filter_destroy(filter);
881 return PMINFO_R_ERROR;
884 ret = _appinfo_get_applications(uid, uid, locale, filter,
885 PMINFO_APPINFO_GET_ALL, list);
886 if (!g_hash_table_size(list) && uid != GLOBAL_USER)
887 ret = _appinfo_get_applications(GLOBAL_USER, uid, locale,
888 filter, PMINFO_APPINFO_GET_ALL, list);
890 pkgmgrinfo_appinfo_filter_destroy(filter);
891 if (ret != PMINFO_R_OK) {
892 g_hash_table_destroy(list);
897 if (!g_hash_table_size(list)) {
898 _LOGI("Appinfo for [%s] is not existed for user [%d]", appid, uid);
899 g_hash_table_destroy(list);
901 return PMINFO_R_ENOENT;
904 info = calloc(1, sizeof(pkgmgr_appinfo_x));
906 _LOGE("out of memory");
908 return PMINFO_R_ERROR;
911 info->app_info = (application_x *)g_hash_table_lookup(list, appid);
912 info->locale = locale;
913 info->package = strdup(info->app_info->package);
915 /* just free list only */
916 g_hash_table_destroy(list);
923 API int pkgmgrinfo_appinfo_get_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
925 return pkgmgrinfo_appinfo_get_usr_appinfo(appid, _getuid(), handle);
928 static gpointer __copy_str(gconstpointer src, gpointer data)
930 const char *tmp = (const char *)src;
933 buffer = strdup(tmp);
934 if (buffer == NULL) {
935 LOGE("memory alloc failed");
943 static gpointer __copy_label(gconstpointer src, gpointer data)
945 label_x *tmp = (label_x *)src;
948 label = calloc(1, sizeof(label_x));
950 LOGE("memory alloc failed");
956 label->name = strdup(tmp->name);
958 label->text = strdup(tmp->text);
960 label->lang = strdup(tmp->lang);
965 static gpointer __copy_icon(gconstpointer src, gpointer data)
967 icon_x *tmp = (icon_x *)src;
970 icon = calloc(1, sizeof(icon_x));
972 LOGE("memory alloc failed");
978 icon->text = strdup(tmp->text);
980 icon->lang = strdup(tmp->lang);
982 icon->section = strdup(tmp->section);
984 icon->size = strdup(tmp->size);
986 icon->resolution = strdup(tmp->resolution);
991 static gpointer __copy_metadata(gconstpointer src, gpointer data)
993 metadata_x *tmp = (metadata_x *)src;
994 metadata_x *metadata;
996 metadata = calloc(1, sizeof(metadata_x));
997 if (metadata == NULL) {
998 LOGE("memory alloc failed");
1004 metadata->key = strdup(tmp->key);
1006 metadata->value = strdup(tmp->value);
1011 static gpointer __copy_datacontrol(gconstpointer src, gpointer data)
1013 datacontrol_x *tmp = (datacontrol_x *)src;
1014 datacontrol_x *datacontrol;
1016 datacontrol = calloc(1, sizeof(datacontrol_x));
1017 if (datacontrol == NULL) {
1018 LOGE("memory alloc failed");
1023 if (tmp->providerid)
1024 datacontrol->providerid = strdup(tmp->providerid);
1026 datacontrol->access = strdup(tmp->access);
1028 datacontrol->type = strdup(tmp->type);
1033 static gpointer __copy_appcontrol(gconstpointer src, gpointer data)
1035 appcontrol_x *tmp = (appcontrol_x *)src;
1036 appcontrol_x *appcontrol;
1038 appcontrol = calloc(1, sizeof(appcontrol_x));
1039 if (appcontrol ==NULL) {
1040 LOGE("memory alloc failed");
1046 appcontrol->operation = strdup(tmp->operation);
1048 appcontrol->uri = strdup(tmp->uri);
1050 appcontrol->mime = strdup(tmp->mime);
1055 static gpointer __copy_splashscreens(gconstpointer src, gpointer data)
1057 splashscreen_x *tmp = (splashscreen_x *)src;
1058 splashscreen_x *splashscreen;
1060 splashscreen = (splashscreen_x *)calloc(1, sizeof(splashscreen_x));
1061 if (splashscreen == NULL) {
1062 LOGE("memory alloc failed");
1068 splashscreen->src = strdup(tmp->src);
1070 splashscreen->type = strdup(tmp->type);
1071 if (tmp->orientation)
1072 splashscreen->orientation = strdup(tmp->orientation);
1073 if (tmp->indicatordisplay)
1074 splashscreen->indicatordisplay = strdup(tmp->indicatordisplay);
1076 splashscreen->operation = strdup(tmp->operation);
1077 if (tmp->color_depth)
1078 splashscreen->color_depth = strdup(tmp->color_depth);
1080 return splashscreen;
1083 static int _appinfo_copy_appinfo(application_x **application, application_x *data)
1085 application_x *app_info;
1088 app_info = calloc(1, sizeof(application_x));
1089 if (app_info == NULL) {
1090 LOGE("memory alloc failed");
1091 return PMINFO_R_ERROR;
1094 if (data->appid != NULL)
1095 app_info->appid = strdup(data->appid);
1096 if (data->exec != NULL)
1097 app_info->exec = strdup(data->exec);
1098 if (data->nodisplay != NULL)
1099 app_info->nodisplay = strdup(data->nodisplay);
1100 if (data->multiple != NULL)
1101 app_info->multiple = strdup(data->multiple);
1102 if (data->taskmanage != NULL)
1103 app_info->taskmanage = strdup(data->taskmanage);
1104 if (data->enabled != NULL)
1105 app_info->enabled = strdup(data->enabled);
1106 if (data->type != NULL)
1107 app_info->type = strdup(data->type);
1108 if (data->categories != NULL)
1109 app_info->categories = strdup(data->categories);
1110 if (data->hwacceleration != NULL)
1111 app_info->hwacceleration = strdup(data->hwacceleration);
1112 if (data->screenreader != NULL)
1113 app_info->screenreader = strdup(data->screenreader);
1114 if (data->mainapp != NULL)
1115 app_info->mainapp = strdup(data->mainapp);
1116 if (data->package != NULL)
1117 app_info->package = strdup(data->package);
1118 if (data->recentimage != NULL)
1119 app_info->recentimage = strdup(data->recentimage);
1120 if (data->launchcondition != NULL)
1121 app_info->launchcondition = strdup(data->launchcondition);
1122 if (data->indicatordisplay != NULL)
1123 app_info->indicatordisplay = strdup(data->indicatordisplay);
1124 if (data->portraitimg != NULL)
1125 app_info->portraitimg = strdup(data->portraitimg);
1126 if (data->landscapeimg != NULL)
1127 app_info->landscapeimg = strdup(data->landscapeimg);
1128 if (data->guestmode_visibility != NULL)
1129 app_info->guestmode_visibility = strdup(data->guestmode_visibility);
1130 if (data->component != NULL)
1131 app_info->component = strdup(data->component);
1132 if (data->permission_type != NULL)
1133 app_info->permission_type = strdup(data->permission_type);
1134 if (data->component_type != NULL)
1135 app_info->component_type = strdup(data->component_type);
1136 if (data->preload != NULL)
1137 app_info->preload = strdup(data->preload);
1138 if (data->submode != NULL)
1139 app_info->submode = strdup(data->submode);
1140 if (data->submode_mainid != NULL)
1141 app_info->submode_mainid = strdup(data->submode_mainid);
1142 if (data->process_pool != NULL)
1143 app_info->process_pool = strdup(data->process_pool);
1144 if (data->installed_storage != NULL)
1145 app_info->installed_storage = strdup(data->installed_storage);
1146 if (data->autorestart != NULL)
1147 app_info->autorestart = strdup(data->autorestart);
1148 if (data->onboot != NULL)
1149 app_info->onboot = strdup(data->onboot);
1150 if (data->support_disable != NULL)
1151 app_info->support_disable = strdup(data->support_disable);
1152 if (data->ui_gadget != NULL)
1153 app_info->ui_gadget = strdup(data->ui_gadget);
1154 if (data->launch_mode != NULL)
1155 app_info->launch_mode = strdup(data->launch_mode);
1156 if (data->package_type != NULL)
1157 app_info->package_type = strdup(data->package_type);
1158 if (data->effective_appid != NULL)
1159 app_info->effective_appid = strdup(data->effective_appid);
1160 if (data->splash_screen_display != NULL)
1161 app_info->splash_screen_display = strdup(data->splash_screen_display);
1165 app_info->label = g_list_copy_deep(data->label, __copy_label, &ret);
1167 LOGE("memory alloc failed");
1168 pkgmgrinfo_basic_free_application(app_info);
1169 return PMINFO_R_ERROR;
1173 app_info->icon = g_list_copy_deep(data->icon, __copy_icon, &ret);
1175 LOGE("memory alloc failed");
1176 pkgmgrinfo_basic_free_application(app_info);
1177 return PMINFO_R_ERROR;
1181 app_info->category = g_list_copy_deep(data->category, __copy_str, &ret);
1183 LOGE("memory alloc failed");
1184 pkgmgrinfo_basic_free_application(app_info);
1185 return PMINFO_R_ERROR;
1189 app_info->metadata = g_list_copy_deep(data->metadata, __copy_metadata, &ret);
1191 LOGE("memory alloc failed");
1192 pkgmgrinfo_basic_free_application(app_info);
1193 return PMINFO_R_ERROR;
1197 app_info->datacontrol = g_list_copy_deep(data->datacontrol, __copy_datacontrol, &ret);
1199 LOGE("memory alloc failed");
1200 pkgmgrinfo_basic_free_application(app_info);
1201 return PMINFO_R_ERROR;
1205 app_info->appcontrol = g_list_copy_deep(data->appcontrol, __copy_appcontrol, &ret);
1207 LOGE("memory alloc failed");
1208 pkgmgrinfo_basic_free_application(app_info);
1209 return PMINFO_R_ERROR;
1213 app_info->background_category = g_list_copy_deep(data->background_category, __copy_str, &ret);
1215 LOGE("memory alloc failed");
1216 pkgmgrinfo_basic_free_application(app_info);
1217 return PMINFO_R_ERROR;
1221 app_info->splashscreens = g_list_copy_deep(data->splashscreens, __copy_splashscreens, &ret);
1223 LOGE("memory alloc failed");
1224 pkgmgrinfo_basic_free_application(app_info);
1225 return PMINFO_R_ERROR;
1228 *application = app_info;
1233 API int pkgmgrinfo_appinfo_clone_appinfo(pkgmgrinfo_appinfo_h handle,
1234 pkgmgrinfo_appinfo_h *clone)
1236 pkgmgr_appinfo_x *info;
1237 pkgmgr_appinfo_x *temp = (pkgmgr_appinfo_x *)handle;
1240 return PMINFO_R_EINVAL;
1242 info = calloc(1, sizeof(pkgmgr_appinfo_x));
1244 LOGE("memory alloc failed");
1245 return PMINFO_R_ERROR;
1248 if (temp->package != NULL)
1249 info->package = strdup(temp->package);
1250 if (temp->locale != NULL)
1251 info->locale = strdup(temp->locale);
1253 info->app_component = temp->app_component;
1255 if (_appinfo_copy_appinfo(&info->app_info, temp->app_info) < 0) {
1256 LOGE("appinfo copy failed");
1258 free((void *)info->package);
1262 return PMINFO_R_ERROR;
1270 static int _appinfo_get_filtered_foreach_appinfo(uid_t uid,
1271 pkgmgrinfo_filter_x *filter, int flag, pkgmgrinfo_app_list_cb app_list_cb,
1277 pkgmgr_appinfo_x info;
1279 GHashTableIter iter;
1282 locale = _get_system_locale();
1284 return PMINFO_R_ERROR;
1286 list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
1287 __free_applications);
1290 return PMINFO_R_ERROR;
1293 ret = _appinfo_get_applications(uid, uid, locale, filter, flag, list);
1294 if (ret == PMINFO_R_OK && uid != GLOBAL_USER)
1295 ret = _appinfo_get_applications(GLOBAL_USER, uid, locale,
1296 filter, flag, list);
1298 if (ret != PMINFO_R_OK) {
1299 g_hash_table_destroy(list);
1304 g_hash_table_iter_init(&iter, list);
1305 while (g_hash_table_iter_next(&iter, NULL, &value)) {
1306 app = (application_x *)value;
1307 info.app_info = app;
1308 info.locale = locale;
1309 info.package = app->package;
1310 if (app_list_cb(&info, user_data) < 0)
1313 g_hash_table_destroy(list);
1319 static const char *__appcomponent_str(pkgmgrinfo_app_component comp);
1321 API int pkgmgrinfo_appinfo_get_usr_list(pkgmgrinfo_pkginfo_h handle,
1322 pkgmgrinfo_app_component component,
1323 pkgmgrinfo_app_list_cb app_func, void *user_data, uid_t uid)
1326 pkgmgrinfo_appinfo_filter_h filter;
1328 const char *comp_str = NULL;
1330 if (handle == NULL || app_func == NULL) {
1331 LOGE("invalid parameter");
1332 return PMINFO_R_EINVAL;
1335 if (pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid)) {
1336 LOGE("invalid parameter");
1337 return PMINFO_R_EINVAL;
1340 if (pkgmgrinfo_appinfo_filter_create(&filter))
1341 return PMINFO_R_ERROR;
1343 if (pkgmgrinfo_appinfo_filter_add_string(filter,
1344 PMINFO_APPINFO_PROP_APP_PACKAGE, pkgid)) {
1345 pkgmgrinfo_appinfo_filter_destroy(filter);
1346 return PMINFO_R_ERROR;
1349 if (uid == GLOBAL_USER) {
1350 if (pkgmgrinfo_appinfo_filter_add_int(filter,
1351 PMINFO_APPINFO_PROP_APP_DISABLE_FOR_USER,
1353 pkgmgrinfo_appinfo_filter_destroy(filter);
1354 return PMINFO_R_ERROR;
1358 comp_str = __appcomponent_str(component);
1361 if (pkgmgrinfo_appinfo_filter_add_string(filter,
1362 PMINFO_APPINFO_PROP_APP_COMPONENT,
1364 pkgmgrinfo_appinfo_filter_destroy(filter);
1365 return PMINFO_R_ERROR;
1369 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter,
1370 PMINFO_APPINFO_GET_ALL, app_func, user_data);
1372 pkgmgrinfo_appinfo_filter_destroy(filter);
1377 API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle,
1378 pkgmgrinfo_app_component component,
1379 pkgmgrinfo_app_list_cb app_func, void *user_data)
1381 return pkgmgrinfo_appinfo_get_usr_list(handle, component, app_func, user_data, _getuid());
1384 API int pkgmgrinfo_appinfo_get_usr_installed_list_full(
1385 pkgmgrinfo_app_list_cb app_func, uid_t uid, int flag,
1389 pkgmgrinfo_appinfo_filter_h filter;
1391 if (app_func == NULL) {
1392 LOGE("invalid parameter");
1393 return PMINFO_R_EINVAL;
1396 if (pkgmgrinfo_appinfo_filter_create(&filter)) {
1397 return PMINFO_R_ERROR;
1400 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
1401 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
1402 pkgmgrinfo_appinfo_filter_destroy(filter);
1403 return PMINFO_R_ERROR;
1406 if (uid == GLOBAL_USER) {
1407 if (pkgmgrinfo_appinfo_filter_add_int(filter,
1408 PMINFO_APPINFO_PROP_APP_DISABLE_FOR_USER,
1410 pkgmgrinfo_appinfo_filter_destroy(filter);
1411 return PMINFO_R_ERROR;
1415 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter, flag, app_func,
1418 pkgmgrinfo_appinfo_filter_destroy(filter);
1423 API int pkgmgrinfo_appinfo_get_installed_list_full(
1424 pkgmgrinfo_app_list_cb app_func, int flag, void *user_data)
1426 return pkgmgrinfo_appinfo_get_usr_installed_list_full(app_func,
1427 _getuid(), flag, user_data);
1430 API int pkgmgrinfo_appinfo_get_usr_install_list(pkgmgrinfo_app_list_cb app_func,
1431 uid_t uid, void *user_data)
1433 return pkgmgrinfo_appinfo_get_usr_installed_list_full(app_func,
1434 uid, PMINFO_APPINFO_GET_ALL, user_data);
1437 API int pkgmgrinfo_appinfo_get_install_list(pkgmgrinfo_app_list_cb app_func,
1440 return pkgmgrinfo_appinfo_get_usr_installed_list_full(app_func,
1441 _getuid(), PMINFO_APPINFO_GET_ALL, user_data);
1444 API int pkgmgrinfo_appinfo_get_usr_installed_list(
1445 pkgmgrinfo_app_list_cb app_func, uid_t uid, void *user_data)
1447 if (app_func == NULL) {
1448 LOGE("invalid parameter");
1449 return PMINFO_R_EINVAL;
1452 return _appinfo_get_filtered_foreach_appinfo(uid, NULL,
1453 PMINFO_APPINFO_GET_ALL, app_func, user_data);
1456 API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func,
1459 return pkgmgrinfo_appinfo_get_usr_installed_list(app_func, _getuid(),
1463 API int pkgmgrinfo_appinfo_get_appid(pkgmgrinfo_appinfo_h handle, char **appid)
1465 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1467 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1468 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1470 if (info->app_info == NULL || info->app_info->appid == NULL)
1471 return PMINFO_R_ERROR;
1472 *appid = (char *)info->app_info->appid;
1477 API int pkgmgrinfo_appinfo_get_pkgname(pkgmgrinfo_appinfo_h handle, char **pkg_name)
1479 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1481 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1482 retvm_if(pkg_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1484 if (info->package == NULL)
1485 return PMINFO_R_ERROR;
1487 *pkg_name = (char *)info->package;
1492 API int pkgmgrinfo_appinfo_get_pkgid(pkgmgrinfo_appinfo_h handle, char **pkgid)
1494 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1496 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1497 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1499 if (info->package == NULL)
1500 return PMINFO_R_ERROR;
1502 *pkgid = (char *)info->package;
1507 API int pkgmgrinfo_appinfo_get_pkgtype(pkgmgrinfo_appinfo_h handle, char **pkgtype)
1509 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1510 retvm_if(pkgtype == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1511 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1513 *pkgtype = (char *)info->app_info->package_type;
1518 API int pkgmgrinfo_appinfo_get_exec(pkgmgrinfo_appinfo_h handle, char **exec)
1520 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1522 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1523 retvm_if(exec == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1525 if (info->app_info == NULL || info->app_info->exec == NULL)
1526 return PMINFO_R_ERROR;
1527 *exec = (char *)info->app_info->exec;
1533 API int pkgmgrinfo_appinfo_get_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1538 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1540 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1541 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1543 locale = info->locale;
1544 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
1546 if (info->app_info == NULL)
1547 return PMINFO_R_ERROR;
1549 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1550 ptr = (icon_x *)tmp->data;
1551 if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL ||
1552 !strcasecmp(ptr->text, "") ||
1553 strcmp(ptr->lang, locale))
1555 *icon = (char *)ptr->text;
1559 locale = DEFAULT_LOCALE;
1560 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1561 ptr = (icon_x *)tmp->data;
1562 if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL ||
1563 strcmp(ptr->lang, locale))
1565 *icon = (char *)ptr->text;
1569 return PMINFO_R_ERROR;
1573 API int pkgmgrinfo_appinfo_get_label(pkgmgrinfo_appinfo_h handle, char **label)
1578 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1580 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1581 retvm_if(label == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1583 locale = info->locale;
1584 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
1586 if (info->app_info == NULL)
1587 return PMINFO_R_ERROR;
1589 for (tmp = info->app_info->label; tmp; tmp = tmp->next) {
1590 ptr = (label_x *)tmp->data;
1591 if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL ||
1592 strcmp(ptr->lang, locale))
1594 *label = (char *)ptr->text;
1598 locale = DEFAULT_LOCALE;
1599 for (tmp = info->app_info->label; tmp; tmp = tmp->next) {
1600 ptr = (label_x *)tmp->data;
1601 if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL ||
1602 strcmp(ptr->lang, locale))
1604 *label = (char *)ptr->text;
1608 return PMINFO_R_ERROR;
1611 static char *_get_localed_label(const char *appid, const char *locale, uid_t uid)
1613 char *result = NULL;
1615 sqlite3_stmt *stmt = NULL;
1618 const char *manifest_db;
1620 manifest_db = getUserPkgParserDBPathUID(uid);
1621 if (manifest_db == NULL) {
1622 _LOGE("Failed to get manifest db path");
1626 if (sqlite3_open_v2(manifest_db, &db, SQLITE_OPEN_READONLY, NULL) != SQLITE_OK) {
1627 _LOGE("DB open fail\n");
1631 query = sqlite3_mprintf("select app_label from package_app_localized_info where app_id=%Q and app_locale=%Q", appid, locale);
1632 if (query == NULL) {
1633 _LOGE("Out of memory");
1637 if (sqlite3_prepare_v2(db, query, -1, &stmt, NULL) != SQLITE_OK) {
1638 _LOGE("prepare_v2 fail\n");
1642 if (sqlite3_step(stmt) == SQLITE_ROW) {
1643 val = (char *)sqlite3_column_text(stmt, 0);
1645 result = strdup(val);
1649 sqlite3_finalize(stmt);
1650 sqlite3_free(query);
1656 API int pkgmgrinfo_appinfo_usr_get_localed_label(const char *appid, const char *locale, uid_t uid, char **label)
1660 retvm_if(appid == NULL || locale == NULL || label == NULL, PMINFO_R_EINVAL, "Argument is NULL");
1662 val = _get_localed_label(appid, locale, uid);
1664 val = _get_localed_label(appid, DEFAULT_LOCALE, uid);
1667 return PMINFO_R_ERROR;
1674 API int pkgmgrinfo_appinfo_get_localed_label(const char *appid, const char *locale, char **label)
1676 return pkgmgrinfo_appinfo_usr_get_localed_label(appid, locale, _getuid(), label);
1679 API int pkgmgrinfo_appinfo_get_metadata_value(pkgmgrinfo_appinfo_h handle, const char *metadata_key, char **metadata_value)
1681 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1682 retvm_if(metadata_key == NULL, PMINFO_R_EINVAL, "metadata_key is NULL");
1683 retvm_if(metadata_value == NULL, PMINFO_R_EINVAL, "metadata_value is NULL");
1685 GList *list_md = NULL;
1686 metadata_x *metadata = NULL;
1687 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1689 list_md = info->app_info->metadata;
1691 for (; list_md; list_md = list_md->next) {
1692 metadata = (metadata_x *)list_md->data;
1693 if (metadata && metadata->key) {
1694 if (strcasecmp(metadata->key, metadata_key) == 0) {
1695 *metadata_value = (char*)metadata->value;
1701 return PMINFO_R_EINVAL;
1704 static pkgmgrinfo_app_component __appcomponent_convert(const char *comp)
1706 if (strcasecmp(comp, "uiapp") == 0)
1707 return PMINFO_UI_APP;
1708 else if (strcasecmp(comp, "svcapp") == 0)
1709 return PMINFO_SVC_APP;
1710 else if (strcasecmp(comp, "widgetapp") == 0)
1711 return PMINFO_WIDGET_APP;
1712 else if (strcasecmp(comp, "watchapp") == 0)
1713 return PMINFO_WATCH_APP;
1718 static const char *__appcomponent_str(pkgmgrinfo_app_component comp)
1723 case PMINFO_SVC_APP:
1725 case PMINFO_WIDGET_APP:
1727 case PMINFO_WATCH_APP:
1734 API int pkgmgrinfo_appinfo_get_component(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_component *component)
1736 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1739 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1740 retvm_if(component == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1742 if (info->app_info == NULL)
1743 return PMINFO_R_ERROR;
1745 comp = __appcomponent_convert(info->app_info->component);
1747 return PMINFO_R_ERROR;
1754 API int pkgmgrinfo_appinfo_get_apptype(pkgmgrinfo_appinfo_h handle, char **app_type)
1756 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1758 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1759 retvm_if(app_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1761 if (info->app_info == NULL || info->app_info->type == NULL)
1762 return PMINFO_R_ERROR;
1763 *app_type = (char *)info->app_info->type;
1768 API int pkgmgrinfo_appinfo_get_operation(pkgmgrinfo_appcontrol_h handle,
1769 int *operation_count, char ***operation)
1771 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1772 retvm_if(operation == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1773 retvm_if(operation_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1774 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1775 *operation_count = data->operation_count;
1776 *operation = data->operation;
1780 API int pkgmgrinfo_appinfo_get_uri(pkgmgrinfo_appcontrol_h handle,
1781 int *uri_count, char ***uri)
1783 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1784 retvm_if(uri == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1785 retvm_if(uri_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1786 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1787 *uri_count = data->uri_count;
1792 API int pkgmgrinfo_appinfo_get_mime(pkgmgrinfo_appcontrol_h handle,
1793 int *mime_count, char ***mime)
1795 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1796 retvm_if(mime == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1797 retvm_if(mime_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1798 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1799 *mime_count = data->mime_count;
1804 API int pkgmgrinfo_appinfo_get_subapp(pkgmgrinfo_appcontrol_h handle,
1805 int *subapp_count, char ***subapp)
1807 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1808 retvm_if(subapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1809 retvm_if(subapp_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1810 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1811 *subapp_count = data->subapp_count;
1812 *subapp = data->subapp;
1816 API int pkgmgrinfo_appinfo_get_setting_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1821 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1823 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1824 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1826 if (info->app_info == NULL)
1827 return PMINFO_R_ERROR;
1829 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1830 ptr = (icon_x *)tmp->data;
1831 if (ptr == NULL || ptr->section == NULL)
1834 val = (char *)ptr->section;
1835 if (val && strcmp(val, "setting") == 0) {
1836 *icon = (char *)ptr->text;
1841 return PMINFO_R_ERROR;
1845 API int pkgmgrinfo_appinfo_get_notification_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1850 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1852 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1853 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1855 if (info->app_info == NULL)
1856 return PMINFO_R_ERROR;
1858 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1859 ptr = (icon_x *)tmp->data;
1860 if (ptr == NULL || ptr->section == NULL)
1863 val = (char *)ptr->section;
1864 if (val && strcmp(val, "notification") == 0){
1865 *icon = (char *)ptr->text;
1870 return PMINFO_R_ERROR;
1873 API int pkgmgrinfo_appinfo_get_recent_image_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_recentimage *type)
1876 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1878 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1879 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1881 if (info->app_info == NULL || info->app_info->recentimage == NULL)
1882 return PMINFO_R_ERROR;
1884 val = (char *)info->app_info->recentimage;
1885 if (strcasecmp(val, "capture") == 0)
1886 *type = PMINFO_RECENTIMAGE_USE_CAPTURE;
1887 else if (strcasecmp(val, "icon") == 0)
1888 *type = PMINFO_RECENTIMAGE_USE_ICON;
1890 *type = PMINFO_RECENTIMAGE_USE_NOTHING;
1895 API int pkgmgrinfo_appinfo_get_preview_image(pkgmgrinfo_appinfo_h handle, char **preview_img)
1900 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1902 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1903 retvm_if(preview_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1905 if (info->app_info == NULL)
1906 return PMINFO_R_ERROR;
1908 for (tmp = info->app_info->image; tmp; tmp = tmp->next) {
1909 ptr = (image_x *)tmp->data;
1910 if (ptr == NULL || ptr->section == NULL)
1913 val = (char *)ptr->section;
1914 if (val && strcmp(val, "preview") == 0) {
1915 *preview_img = (char *)ptr->text;
1920 return PMINFO_R_ERROR;
1923 API int pkgmgrinfo_appinfo_get_permission_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_permission_type *permission)
1926 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1928 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1929 retvm_if(permission == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1931 val = info->app_info->permission_type;
1933 return PMINFO_R_ERROR;
1935 if (strcmp(val, "signature") == 0)
1936 *permission = PMINFO_PERMISSION_SIGNATURE;
1937 else if (strcmp(val, "privilege") == 0)
1938 *permission = PMINFO_PERMISSION_PRIVILEGE;
1940 *permission = PMINFO_PERMISSION_NORMAL;
1945 API int pkgmgrinfo_appinfo_get_component_type(pkgmgrinfo_appinfo_h handle, char **component_type)
1947 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1949 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1950 retvm_if(component_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1952 if (info->app_info == NULL || info->app_info->component_type == NULL)
1953 return PMINFO_R_ERROR;
1955 *component_type = (char *)info->app_info->component_type;
1960 API int pkgmgrinfo_appinfo_get_hwacceleration(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_hwacceleration *hwacceleration)
1963 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1965 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1966 retvm_if(hwacceleration == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1968 if (info->app_info == NULL || info->app_info->hwacceleration == NULL)
1969 return PMINFO_R_ERROR;
1971 val = (char *)info->app_info->hwacceleration;
1972 if (strcasecmp(val, "off") == 0)
1973 *hwacceleration = PMINFO_HWACCELERATION_OFF;
1974 else if (strcasecmp(val, "on") == 0)
1975 *hwacceleration = PMINFO_HWACCELERATION_ON;
1977 *hwacceleration = PMINFO_HWACCELERATION_DEFAULT;
1982 API int pkgmgrinfo_appinfo_get_screenreader(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_screenreader *screenreader)
1985 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1987 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1988 retvm_if(screenreader == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1990 if (info->app_info == NULL || info->app_info->screenreader == NULL)
1991 return PMINFO_R_ERROR;
1993 val = (char *)info->app_info->screenreader;
1994 if (strcasecmp(val, "screenreader-off") == 0)
1995 *screenreader = PMINFO_SCREENREADER_OFF;
1996 else if (strcasecmp(val, "screenreader-on") == 0)
1997 *screenreader = PMINFO_SCREENREADER_ON;
1999 *screenreader = PMINFO_SCREENREADER_USE_SYSTEM_SETTING;
2004 API int pkgmgrinfo_appinfo_get_effectimage(pkgmgrinfo_appinfo_h handle, char **portrait_img, char **landscape_img)
2006 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2008 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2009 retvm_if(portrait_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2010 retvm_if(landscape_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2012 if (info->app_info == NULL || (info->app_info->portraitimg == NULL
2013 && info->app_info->landscapeimg == NULL))
2014 return PMINFO_R_ERROR;
2016 *portrait_img = (char *)info->app_info->portraitimg;
2017 *landscape_img = (char *)info->app_info->landscapeimg;
2022 API int pkgmgrinfo_appinfo_get_effectimage_type(pkgmgrinfo_appinfo_h handle, char **effectimage_type)
2024 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2026 if (handle == NULL || effectimage_type == NULL) {
2027 LOGE("invalid parameter");
2028 return PMINFO_R_EINVAL;
2031 if (info->app_info == NULL || info->app_info->effectimage_type == NULL)
2032 return PMINFO_R_ERROR;
2034 *effectimage_type = (char *)info->app_info->effectimage_type;
2039 API int pkgmgrinfo_appinfo_get_submode_mainid(pkgmgrinfo_appinfo_h handle, char **submode_mainid)
2041 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2043 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2044 retvm_if(submode_mainid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2046 if (info->app_info == NULL || info->app_info->submode_mainid == NULL)
2047 return PMINFO_R_ERROR;
2049 *submode_mainid = (char *)info->app_info->submode_mainid;
2054 API int pkgmgrinfo_appinfo_get_installed_storage_location(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_installed_storage *storage)
2056 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2057 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2059 if (info->app_info && info->app_info->installed_storage){
2060 if (strcmp(info->app_info->installed_storage,"installed_internal") == 0)
2061 *storage = PMINFO_INTERNAL_STORAGE;
2062 else if (strcmp(info->app_info->installed_storage,"installed_external") == 0)
2063 *storage = PMINFO_EXTERNAL_STORAGE;
2065 return PMINFO_R_ERROR;
2067 return PMINFO_R_ERROR;
2072 API int pkgmgrinfo_appinfo_get_launch_mode(pkgmgrinfo_appinfo_h handle, char **mode)
2074 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2076 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2077 retvm_if(mode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2079 if (info->app_info->launch_mode == NULL)
2080 return PMINFO_R_ERROR;
2082 *mode = (char *)(info->app_info->launch_mode);
2087 API int pkgmgrinfo_appinfo_get_alias_appid(pkgmgrinfo_appinfo_h handle, char **alias_appid)
2089 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2091 if (handle == NULL || alias_appid == NULL) {
2092 LOGE("invalid parameter");
2093 return PMINFO_R_EINVAL;
2096 if (info->app_info == NULL || info->app_info->alias_appid == NULL)
2097 return PMINFO_R_ERROR;
2099 *alias_appid = (char *)info->app_info->alias_appid;
2104 API int pkgmgrinfo_appinfo_get_effective_appid(pkgmgrinfo_appinfo_h handle, char **effective_appid)
2106 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2108 if (handle == NULL || effective_appid == NULL) {
2109 LOGE("invalid parameter");
2110 return PMINFO_R_EINVAL;
2113 if (info->app_info == NULL || info->app_info->effective_appid == NULL)
2114 return PMINFO_R_ERROR;
2116 *effective_appid = (char *)info->app_info->effective_appid;
2121 API int pkgmgrinfo_appinfo_get_tep_name(pkgmgrinfo_appinfo_h handle, char **tep_name)
2123 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2125 if (handle == NULL || tep_name == NULL) {
2126 LOGE("invalid parameter");
2127 return PMINFO_R_EINVAL;
2130 if (info->app_info == NULL || info->app_info->tep_name == NULL)
2131 return PMINFO_R_ERROR;
2133 *tep_name = (char *)info->app_info->tep_name;
2138 API int pkgmgrinfo_appinfo_get_zip_mount_file(pkgmgrinfo_appinfo_h handle, char **zip_mount_file)
2140 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2142 if (handle == NULL || zip_mount_file == NULL) {
2143 LOGE("invalid parameter");
2144 return PMINFO_R_EINVAL;
2147 *zip_mount_file = (char *)info->app_info->zip_mount_file;
2152 API int pkgmgrinfo_appinfo_get_root_path(pkgmgrinfo_appinfo_h handle, char **root_path)
2154 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2156 if (handle == NULL || root_path == NULL) {
2157 LOGE("invalid parameter");
2158 return PMINFO_R_EINVAL;
2161 if (info->app_info == NULL || info->app_info->root_path == NULL)
2162 return PMINFO_R_ERROR;
2164 *root_path = (char *)info->app_info->root_path;
2169 API int pkgmgrinfo_appinfo_get_api_version(pkgmgrinfo_appinfo_h handle, char **api_version)
2171 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2173 if (handle == NULL || api_version == NULL) {
2174 LOGE("invalid parameter");
2175 return PMINFO_R_EINVAL;
2178 if (info->app_info == NULL || info->app_info->api_version == NULL)
2179 return PMINFO_R_ERROR;
2181 *api_version = (char *)info->app_info->api_version;
2186 API int pkgmgrinfo_appinfo_usr_get_datacontrol_info(const char *providerid, const char *type, uid_t uid, char **appid, char **access)
2188 retvm_if(providerid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
2189 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
2190 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2191 retvm_if(access == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2193 int ret = PMINFO_R_OK;
2195 sqlite3_stmt *stmt = NULL;
2198 ret = __open_manifest_db(uid, true);
2199 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
2201 /*Start constructing query*/
2202 query = sqlite3_mprintf("select * from package_app_data_control where providerid=%Q and type=%Q", providerid, type);
2205 ret = sqlite3_prepare_v2(GET_DB(manifest_db), query, strlen(query), &stmt, NULL);
2206 tryvm_if(ret != PMINFO_R_OK, ret = PMINFO_R_ERROR, "sqlite3_prepare_v2 failed[%s]\n", query);
2209 ret = sqlite3_step(stmt);
2210 tryvm_if((ret != SQLITE_ROW) || (ret == SQLITE_DONE), ret = PMINFO_R_ERROR, "No records found");
2212 *appid = strdup((char *)sqlite3_column_text(stmt, 0));
2213 *access = strdup((char *)sqlite3_column_text(stmt, 2));
2218 sqlite3_free(query);
2219 sqlite3_finalize(stmt);
2220 __close_manifest_db();
2224 API int pkgmgrinfo_appinfo_get_datacontrol_info(const char *providerid, const char *type, char **appid, char **access)
2226 return pkgmgrinfo_appinfo_usr_get_datacontrol_info(providerid, type, _getuid(), appid, access);
2229 API int pkgmgrinfo_appinfo_usr_get_datacontrol_appid(const char *providerid, uid_t uid, char **appid)
2231 retvm_if(providerid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
2232 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2234 int ret = PMINFO_R_OK;
2236 sqlite3_stmt *stmt = NULL;
2239 ret = __open_manifest_db(uid, true);
2240 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
2242 /*Start constructing query*/
2243 query = sqlite3_mprintf("select * from package_app_data_control where providerid=%Q", providerid);
2246 ret = sqlite3_prepare_v2(GET_DB(manifest_db), query, strlen(query), &stmt, NULL);
2247 tryvm_if(ret != PMINFO_R_OK, ret = PMINFO_R_ERROR, "sqlite3_prepare_v2 failed[%s]\n", query);
2250 ret = sqlite3_step(stmt);
2251 tryvm_if((ret != SQLITE_ROW) || (ret == SQLITE_DONE), ret = PMINFO_R_ERROR, "No records found");
2253 *appid = strdup((char *)sqlite3_column_text(stmt, 0));
2258 sqlite3_free(query);
2259 sqlite3_finalize(stmt);
2260 __close_manifest_db();
2264 API int pkgmgrinfo_appinfo_get_datacontrol_appid(const char *providerid, char **appid)
2266 return pkgmgrinfo_appinfo_usr_get_datacontrol_appid(providerid, _getuid(), appid);
2269 API int pkgmgrinfo_appinfo_foreach_permission(pkgmgrinfo_appinfo_h handle,
2270 pkgmgrinfo_app_permission_list_cb permission_func, void *user_data)
2272 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2273 retvm_if(permission_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2277 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2279 if (info->app_info == NULL)
2280 return PMINFO_R_ERROR;
2282 for (tmp = info->app_info->permission; tmp; tmp = tmp->next) {
2283 ptr = (permission_x *)tmp->data;
2287 ret = permission_func(ptr->value, user_data);
2295 API int pkgmgrinfo_appinfo_foreach_category(pkgmgrinfo_appinfo_h handle,
2296 pkgmgrinfo_app_category_list_cb category_func, void *user_data)
2298 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2299 retvm_if(category_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2301 const char *category;
2303 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2305 if (info->app_info == NULL)
2306 return PMINFO_R_ERROR;
2308 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
2309 category = (const char *)tmp->data;
2311 ret = category_func(category, user_data);
2319 API int pkgmgrinfo_appinfo_foreach_metadata(pkgmgrinfo_appinfo_h handle,
2320 pkgmgrinfo_app_metadata_list_cb metadata_func, void *user_data)
2322 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2323 retvm_if(metadata_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2327 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2329 if (info->app_info == NULL)
2330 return PMINFO_R_ERROR;
2332 for (tmp = info->app_info->metadata; tmp; tmp = tmp->next) {
2333 ptr = (metadata_x *)tmp->data;
2337 ret = metadata_func(ptr->key, ptr->value, user_data);
2345 API int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
2346 pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
2348 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2349 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2351 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2352 appcontrol_x *appcontrol;
2355 if (info->app_info == NULL)
2356 return PMINFO_R_ERROR;
2358 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
2359 appcontrol = (appcontrol_x *)tmp->data;
2360 if (appcontrol == NULL)
2362 ret = appcontrol_func(appcontrol->operation, appcontrol->uri, appcontrol->mime, user_data);
2370 API int pkgmgrinfo_appinfo_foreach_background_category(
2371 pkgmgrinfo_appinfo_h handle,
2372 pkgmgrinfo_app_background_category_list_cb category_func,
2375 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2379 if (handle == NULL || category_func == NULL || info->app_info == NULL) {
2380 LOGE("invalid parameter");
2381 return PMINFO_R_EINVAL;
2384 for (tmp = info->app_info->background_category; tmp; tmp = tmp->next) {
2385 category = (char *)tmp->data;
2386 if (category == NULL)
2389 if (category_func(category, user_data) < 0)
2396 API int pkgmgrinfo_appinfo_foreach_splash_screen(pkgmgrinfo_appinfo_h handle,
2397 pkgmgrinfo_app_splash_screen_list_cb splash_screen_func,
2400 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2401 splashscreen_x *splashscreen;
2405 if (info == NULL || info->app_info == NULL
2406 || splash_screen_func == NULL) {
2407 LOGE("invalid parameter");
2408 return PMINFO_R_EINVAL;
2411 for (tmp = info->app_info->splashscreens; tmp; tmp = tmp->next) {
2412 splashscreen = (splashscreen_x *)tmp->data;
2413 if (splashscreen == NULL)
2415 ret = splash_screen_func(splashscreen->src,
2417 splashscreen->orientation,
2418 splashscreen->indicatordisplay,
2419 splashscreen->operation,
2420 splashscreen->color_depth,
2429 API int pkgmgrinfo_appinfo_is_nodisplay(pkgmgrinfo_appinfo_h handle, bool *nodisplay)
2431 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2432 retvm_if(nodisplay == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2433 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2435 if (info->app_info == NULL || info->app_info->nodisplay == NULL)
2436 return PMINFO_R_ERROR;
2438 *nodisplay = _get_bool_value(info->app_info->nodisplay);
2443 API int pkgmgrinfo_appinfo_is_multiple(pkgmgrinfo_appinfo_h handle, bool *multiple)
2445 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2446 retvm_if(multiple == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2447 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2449 if (info->app_info == NULL || info->app_info->multiple == NULL)
2450 return PMINFO_R_ERROR;
2452 *multiple = _get_bool_value(info->app_info->multiple);
2457 API int pkgmgrinfo_appinfo_is_indicator_display_allowed(pkgmgrinfo_appinfo_h handle, bool *indicator_disp)
2459 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2460 retvm_if(indicator_disp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2461 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2463 if (info->app_info == NULL || info->app_info->indicatordisplay == NULL)
2464 return PMINFO_R_ERROR;
2466 *indicator_disp = _get_bool_value(info->app_info->indicatordisplay);
2471 API int pkgmgrinfo_appinfo_is_taskmanage(pkgmgrinfo_appinfo_h handle, bool *taskmanage)
2473 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2474 retvm_if(taskmanage == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2475 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2477 if (info->app_info == NULL || info->app_info->taskmanage == NULL)
2478 return PMINFO_R_ERROR;
2480 *taskmanage = _get_bool_value(info->app_info->taskmanage);
2485 API int pkgmgrinfo_appinfo_is_enabled(pkgmgrinfo_appinfo_h handle, bool *enabled)
2487 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2488 retvm_if(enabled == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2489 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2491 if (info->app_info == NULL || info->app_info->enabled == NULL)
2492 return PMINFO_R_ERROR;
2494 *enabled = _get_bool_value(info->app_info->enabled);
2499 API int pkgmgrinfo_appinfo_is_onboot(pkgmgrinfo_appinfo_h handle, bool *onboot)
2501 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2502 retvm_if(onboot == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2503 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2505 if (info->app_info == NULL || info->app_info->onboot == NULL)
2506 return PMINFO_R_ERROR;
2508 *onboot = _get_bool_value(info->app_info->onboot);
2513 API int pkgmgrinfo_appinfo_is_autorestart(pkgmgrinfo_appinfo_h handle, bool *autorestart)
2515 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2516 retvm_if(autorestart == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2517 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2519 if (info->app_info == NULL || info->app_info->autorestart == NULL)
2520 return PMINFO_R_ERROR;
2522 *autorestart = _get_bool_value(info->app_info->autorestart);
2527 API int pkgmgrinfo_appinfo_is_mainapp(pkgmgrinfo_appinfo_h handle, bool *mainapp)
2529 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2530 retvm_if(mainapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2531 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2533 if (info->app_info == NULL || info->app_info->mainapp == NULL)
2534 return PMINFO_R_ERROR;
2536 *mainapp = _get_bool_value(info->app_info->mainapp);
2541 API int pkgmgrinfo_appinfo_is_preload(pkgmgrinfo_appinfo_h handle, bool *preload)
2543 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2544 retvm_if(preload == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2545 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2547 if (info->app_info == NULL || info->app_info->preload == NULL)
2548 return PMINFO_R_ERROR;
2550 *preload = _get_bool_value(info->app_info->preload);
2555 API int pkgmgrinfo_appinfo_is_submode(pkgmgrinfo_appinfo_h handle, bool *submode)
2557 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2558 retvm_if(submode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2559 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2561 if (info->app_info == NULL || info->app_info->submode == NULL)
2562 return PMINFO_R_ERROR;
2564 *submode = _get_bool_value(info->app_info->submode);
2569 API int pkgmgrinfo_appinfo_is_process_pool(pkgmgrinfo_appinfo_h handle, bool *process_pool)
2571 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2573 if (handle == NULL || process_pool == NULL) {
2574 LOGE("invalid parameter");
2575 return PMINFO_R_EINVAL;
2578 if (info->app_info == NULL)
2579 return PMINFO_R_ERROR;
2581 *process_pool = _get_bool_value(info->app_info->process_pool);
2586 API int pkgmgrinfo_appinfo_is_category_exist(pkgmgrinfo_appinfo_h handle, const char *category, bool *exist)
2588 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2589 retvm_if(category == NULL, PMINFO_R_EINVAL, "category is NULL");
2590 retvm_if(exist == NULL, PMINFO_R_EINVAL, "exist is NULL");
2594 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2596 if (info->app_info == NULL)
2597 return PMINFO_R_ERROR;
2600 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
2601 val = (const char *)tmp->data;
2604 if (strcasecmp(val, category) == 0) {
2613 API int pkgmgrinfo_appinfo_is_ui_gadget(pkgmgrinfo_appinfo_h handle,
2616 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2618 if (info == NULL || info->app_info == NULL || ui_gadget == NULL) {
2619 _LOGE("invalid parameter");
2620 return PMINFO_R_EINVAL;
2623 *ui_gadget = _get_bool_value(info->app_info->ui_gadget);
2628 API int pkgmgrinfo_appinfo_is_support_disable(pkgmgrinfo_appinfo_h handle,
2629 bool *support_disable)
2631 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2633 if (info == NULL || info->app_info == NULL || support_disable == NULL) {
2634 _LOGE("invalid parameter");
2635 return PMINFO_R_EINVAL;
2638 *support_disable = _get_bool_value(info->app_info->support_disable);
2643 API int pkgmgrinfo_appinfo_is_disabled(pkgmgrinfo_appinfo_h handle, bool *disabled)
2645 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2646 retvm_if(disabled == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2647 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2649 if (info->app_info == NULL || info->app_info->is_disabled == NULL)
2650 return PMINFO_R_ERROR;
2652 *disabled = _get_bool_value(info->app_info->is_disabled);
2657 API int pkgmgrinfo_appinfo_is_global(pkgmgrinfo_appinfo_h handle, bool *global)
2659 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2661 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2662 retvm_if(global == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2664 if (info->app_info == NULL || info->app_info->for_all_users == NULL)
2665 return PMINFO_R_ERROR;
2667 *global = _get_bool_value(info->app_info->for_all_users);
2672 API int pkgmgrinfo_appinfo_get_splash_screen_display(pkgmgrinfo_appinfo_h handle, bool *splash_screen_display)
2674 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2676 if (info == NULL || splash_screen_display == NULL) {
2677 _LOGE("Invalid parameter");
2678 return PMINFO_R_EINVAL;
2681 if (info->app_info == NULL || info->app_info->splash_screen_display == NULL)
2682 return PMINFO_R_ERROR;
2684 *splash_screen_display = _get_bool_value(info->app_info->splash_screen_display);
2689 API int pkgmgrinfo_appinfo_destroy_appinfo(pkgmgrinfo_appinfo_h handle)
2691 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2692 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2693 __cleanup_appinfo(info);
2697 API int pkgmgrinfo_appinfo_filter_create(pkgmgrinfo_appinfo_filter_h *handle)
2699 return (pkgmgrinfo_pkginfo_filter_create(handle));
2702 API int pkgmgrinfo_appinfo_filter_destroy(pkgmgrinfo_appinfo_filter_h handle)
2704 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
2707 static gint __compare_func(gconstpointer data1, gconstpointer data2)
2709 pkgmgrinfo_node_x *node1 = (pkgmgrinfo_node_x*)data1;
2710 pkgmgrinfo_node_x *node2 = (pkgmgrinfo_node_x*)data2;
2711 if (node1->prop == node2->prop)
2713 else if (node1->prop > node2->prop)
2719 API int pkgmgrinfo_appinfo_filter_add_int(pkgmgrinfo_appinfo_filter_h handle,
2720 const char *property, const int value)
2722 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2723 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2724 char buf[PKG_VALUE_STRING_LEN_MAX] = {'\0'};
2726 GSList *link = NULL;
2728 prop = _pminfo_appinfo_convert_to_prop_int(property);
2729 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_INT ||
2730 prop > E_PMINFO_APPINFO_PROP_APP_MAX_INT) {
2731 _LOGE("Invalid Integer Property\n");
2732 return PMINFO_R_EINVAL;
2734 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
2735 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
2737 _LOGE("Out of Memory!!!\n");
2738 return PMINFO_R_ERROR;
2740 snprintf(buf, PKG_VALUE_STRING_LEN_MAX - 1, "%d", value);
2741 val = strndup(buf, PKG_VALUE_STRING_LEN_MAX - 1);
2743 _LOGE("Out of Memory\n");
2746 return PMINFO_R_ERROR;
2750 /*If API is called multiple times for same property, we should override the previous values.
2751 Last value set will be used for filtering.*/
2752 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2754 filter->list = g_slist_delete_link(filter->list, link);
2755 filter->list = g_slist_append(filter->list, (gpointer)node);
2760 API int pkgmgrinfo_appinfo_filter_add_bool(pkgmgrinfo_appinfo_filter_h handle,
2761 const char *property, const bool value)
2763 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2764 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2766 GSList *link = NULL;
2768 prop = _pminfo_appinfo_convert_to_prop_bool(property);
2769 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_BOOL ||
2770 prop > E_PMINFO_APPINFO_PROP_APP_MAX_BOOL) {
2771 _LOGE("Invalid Boolean Property\n");
2772 return PMINFO_R_EINVAL;
2774 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
2775 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
2777 _LOGE("Out of Memory!!!\n");
2778 return PMINFO_R_ERROR;
2781 val = strndup("true", 4);
2783 val = strndup("false", 5);
2785 _LOGE("Out of Memory\n");
2788 return PMINFO_R_ERROR;
2792 /*If API is called multiple times for same property, we should override the previous values.
2793 Last value set will be used for filtering.*/
2794 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2796 filter->list = g_slist_delete_link(filter->list, link);
2797 filter->list = g_slist_append(filter->list, (gpointer)node);
2802 API int pkgmgrinfo_appinfo_filter_add_string(pkgmgrinfo_appinfo_filter_h handle,
2803 const char *property, const char *value)
2805 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2806 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2807 retvm_if(value == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2809 pkgmgrinfo_node_x *ptr = NULL;
2810 char prev[PKG_STRING_LEN_MAX] = {'\0'};
2811 char temp[PKG_STRING_LEN_MAX] = {'\0'};
2812 GSList *link = NULL;
2814 prop = _pminfo_appinfo_convert_to_prop_str(property);
2815 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_STR ||
2816 prop > E_PMINFO_APPINFO_PROP_APP_MAX_STR) {
2817 _LOGE("Invalid String Property\n");
2818 return PMINFO_R_EINVAL;
2820 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
2821 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
2823 _LOGE("Out of Memory!!!\n");
2824 return PMINFO_R_ERROR;
2828 case E_PMINFO_APPINFO_PROP_APP_COMPONENT:
2829 node->value = strdup(value);
2830 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2832 filter->list = g_slist_delete_link(filter->list, link);
2833 filter->list = g_slist_append(filter->list, (gpointer)node);
2835 case E_PMINFO_APPINFO_PROP_APP_CATEGORY:
2836 val = (char *)calloc(1, PKG_STRING_LEN_MAX);
2838 _LOGE("Out of Memory\n");
2841 return PMINFO_R_ERROR;
2843 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2845 ptr = (pkgmgrinfo_node_x *)link->data;
2846 strncpy(prev, ptr->value, PKG_STRING_LEN_MAX - 1);
2847 _LOGI("Previous value is %s\n", prev);
2848 filter->list = g_slist_delete_link(filter->list, link);
2849 snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s,%s", prev, value);
2850 strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
2851 _LOGI("New value is %s\n", val);
2853 filter->list = g_slist_append(filter->list, (gpointer)node);
2854 memset(temp, '\0', PKG_STRING_LEN_MAX);
2856 snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s", value);
2857 strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
2858 _LOGI("First value is %s\n", val);
2860 filter->list = g_slist_append(filter->list, (gpointer)node);
2861 memset(temp, '\0', PKG_STRING_LEN_MAX);
2865 node->value = strndup(value, PKG_STRING_LEN_MAX - 1);
2866 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2868 filter->list = g_slist_delete_link(filter->list, link);
2869 filter->list = g_slist_append(filter->list, (gpointer)node);
2875 API int pkgmgrinfo_appinfo_usr_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count, uid_t uid)
2881 if (handle == NULL || count == NULL) {
2882 _LOGE("invalid parameter");
2883 return PMINFO_R_EINVAL;
2886 locale = _get_system_locale();
2888 return PMINFO_R_ERROR;
2890 list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
2891 __free_applications);
2894 return PMINFO_R_ERROR;
2897 ret = _appinfo_get_applications(uid, uid, locale, handle, 0, list);
2898 if (ret == PMINFO_R_OK && uid != GLOBAL_USER)
2899 ret = _appinfo_get_applications(GLOBAL_USER, uid, locale,
2902 if (ret != PMINFO_R_OK) {
2903 g_hash_table_destroy(list);
2905 return PMINFO_R_ERROR;
2908 *count = g_hash_table_size(list);
2909 g_hash_table_destroy(list);
2915 API int pkgmgrinfo_appinfo_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count)
2917 return pkgmgrinfo_appinfo_usr_filter_count(handle, count, _getuid());
2920 API int pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(
2921 pkgmgrinfo_appinfo_filter_h handle,
2922 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
2924 if (handle == NULL || app_cb == NULL) {
2925 LOGE("invalid parameter");
2926 return PMINFO_R_EINVAL;
2929 return _appinfo_get_filtered_foreach_appinfo(uid, handle, PMINFO_APPINFO_GET_ALL, app_cb,
2933 API int pkgmgrinfo_appinfo_filter_foreach_appinfo(pkgmgrinfo_appinfo_filter_h handle,
2934 pkgmgrinfo_app_list_cb app_cb, void * user_data)
2936 return pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(handle, app_cb, user_data, _getuid());
2939 API int pkgmgrinfo_appinfo_metadata_filter_create(pkgmgrinfo_appinfo_metadata_filter_h *handle)
2941 return (pkgmgrinfo_pkginfo_filter_create(handle));
2944 API int pkgmgrinfo_appinfo_metadata_filter_destroy(pkgmgrinfo_appinfo_metadata_filter_h handle)
2946 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
2949 API int pkgmgrinfo_appinfo_metadata_filter_add(
2950 pkgmgrinfo_appinfo_metadata_filter_h handle,
2951 const char *key, const char *value)
2955 ret = pkgmgrinfo_appinfo_filter_add_string(handle,
2956 PMINFO_APPINFO_PROP_APP_METADATA_KEY, key);
2957 if (ret != PMINFO_R_OK)
2960 /* value can be NULL.
2961 * In that case all apps with specified key should be displayed
2964 ret = pkgmgrinfo_appinfo_filter_add_string(handle,
2965 PMINFO_APPINFO_PROP_APP_METADATA_VALUE, value);
2966 if (ret != PMINFO_R_OK)
2973 API int pkgmgrinfo_appinfo_usr_metadata_filter_foreach(
2974 pkgmgrinfo_appinfo_metadata_filter_h handle,
2975 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
2977 if (handle == NULL || app_cb == NULL) {
2978 LOGE("invalid parameter");
2979 return PMINFO_R_EINVAL;
2982 return _appinfo_get_filtered_foreach_appinfo(uid, handle, PMINFO_APPINFO_GET_ALL, app_cb,
2986 API int pkgmgrinfo_appinfo_metadata_filter_foreach(
2987 pkgmgrinfo_appinfo_metadata_filter_h handle,
2988 pkgmgrinfo_app_list_cb app_cb, void *user_data)
2990 return pkgmgrinfo_appinfo_usr_metadata_filter_foreach(handle, app_cb,
2991 user_data, _getuid());
2994 API int pkgmgrinfo_appinfo_is_guestmode_visibility(pkgmgrinfo_appinfo_h handle, bool *status)
2997 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2999 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
3000 retvm_if(status == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3002 val = info->app_info->guestmode_visibility;
3003 *status = _get_bool_value(val);