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_tep_name, "
557 "ai.app_zip_mount_file, 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->tep_name);
656 _save_column_str(stmt, idx++, &info->zip_mount_file);
657 _save_column_str(stmt, idx++, &info->component_type);
658 _save_column_str(stmt, idx++, &info->package);
659 info->for_all_users =
660 strdup((uid != GLOBAL_USER) ? "false" : "true");
662 if (db_uid == GLOBAL_USER)
663 __get_splash_screen_display(db, info->appid, db_uid,
664 &info->splash_screen_display);
666 info->background_category = __get_background_category(
668 free(bg_category_str);
670 if (flag & PMINFO_APPINFO_GET_LABEL) {
671 if (_appinfo_get_label(db, info->appid, locale,
673 ret = PMINFO_R_ERROR;
678 if (flag & PMINFO_APPINFO_GET_ICON) {
679 if (_appinfo_get_icon(db, info->appid, locale,
681 ret = PMINFO_R_ERROR;
686 if (flag & PMINFO_APPINFO_GET_CATEGORY) {
687 if (_appinfo_get_category(db, info->appid,
689 ret = PMINFO_R_ERROR;
694 if (flag & PMINFO_APPINFO_GET_APP_CONTROL) {
695 if (_appinfo_get_app_control(db, info->appid,
696 &info->appcontrol)) {
697 ret = PMINFO_R_ERROR;
702 if (flag & PMINFO_APPINFO_GET_DATA_CONTROL) {
703 if (_appinfo_get_data_control(db, info->appid,
704 &info->datacontrol)) {
705 ret = PMINFO_R_ERROR;
710 if (flag & PMINFO_APPINFO_GET_METADATA) {
711 if (_appinfo_get_metadata(db, info->appid,
713 ret = PMINFO_R_ERROR;
718 if (flag & PMINFO_APPINFO_GET_SPLASH_SCREEN) {
719 if (_appinfo_get_splashscreens(db, info->appid,
720 &info->splashscreens)) {
721 ret = PMINFO_R_ERROR;
726 g_hash_table_insert(applications, (gpointer)info->appid,
736 if (ret != PMINFO_R_OK && info != NULL)
737 pkgmgrinfo_basic_free_application(info);
739 g_list_free_full(bind_params, free);
740 sqlite3_close_v2(db);
741 sqlite3_finalize(stmt);
746 API int pkgmgrinfo_appinfo_get_usr_disabled_appinfo(const char *appid, uid_t uid,
747 pkgmgrinfo_appinfo_h *handle)
752 pkgmgrinfo_appinfo_filter_h filter;
753 pkgmgr_appinfo_x *info;
755 if (appid == NULL || handle == NULL) {
756 LOGE("invalid parameter");
757 return PMINFO_R_EINVAL;
760 locale = _get_system_locale();
762 return PMINFO_R_ERROR;
764 ret = pkgmgrinfo_appinfo_filter_create(&filter);
765 if (ret != PMINFO_R_OK) {
770 ret = pkgmgrinfo_appinfo_filter_add_string(filter,
771 PMINFO_APPINFO_PROP_APP_ID, appid);
772 if (ret != PMINFO_R_OK) {
773 pkgmgrinfo_appinfo_filter_destroy(filter);
775 return PMINFO_R_ERROR;
778 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
779 PMINFO_APPINFO_PROP_APP_DISABLE, true);
780 if (ret != PMINFO_R_OK) {
781 pkgmgrinfo_appinfo_filter_destroy(filter);
783 return PMINFO_R_ERROR;
786 list = g_hash_table_new(g_str_hash, g_str_equal);
788 pkgmgrinfo_appinfo_filter_destroy(filter);
790 return PMINFO_R_ERROR;
793 ret = _appinfo_get_applications(uid, uid, locale, filter,
794 PMINFO_APPINFO_GET_ALL, list);
795 if (!g_hash_table_size(list) && uid != GLOBAL_USER)
796 ret = _appinfo_get_applications(GLOBAL_USER, uid, locale,
797 filter, PMINFO_APPINFO_GET_ALL, list);
799 pkgmgrinfo_appinfo_filter_destroy(filter);
800 if (ret != PMINFO_R_OK) {
801 g_hash_table_destroy(list);
806 if (!g_hash_table_size(list)) {
807 _LOGI("Appinfo for [%s] is not existed for user [%d]",
809 g_hash_table_destroy(list);
811 return PMINFO_R_ENOENT;
814 info = calloc(1, sizeof(pkgmgr_appinfo_x));
816 _LOGE("out of memory");
818 return PMINFO_R_ERROR;
821 info->app_info = (application_x *)g_hash_table_lookup(list, appid);
822 info->locale = locale;
823 info->package = strdup(info->app_info->package);
825 /* just free list only */
826 g_hash_table_destroy(list);
833 API int pkgmgrinfo_appinfo_get_disabled_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
835 return pkgmgrinfo_appinfo_get_usr_disabled_appinfo(appid, _getuid(), handle);
838 API int pkgmgrinfo_appinfo_get_usr_appinfo(const char *appid, uid_t uid,
839 pkgmgrinfo_appinfo_h *handle)
844 pkgmgrinfo_appinfo_filter_h filter;
845 pkgmgr_appinfo_x *info;
847 if (appid == NULL || handle == NULL) {
848 LOGE("invalid parameter");
849 return PMINFO_R_EINVAL;
852 locale = _get_system_locale();
854 return PMINFO_R_ERROR;
856 ret = pkgmgrinfo_appinfo_filter_create(&filter);
857 if (ret != PMINFO_R_OK) {
862 ret = pkgmgrinfo_appinfo_filter_add_string(filter,
863 PMINFO_APPINFO_PROP_APP_ID, appid);
864 if (ret != PMINFO_R_OK) {
865 pkgmgrinfo_appinfo_filter_destroy(filter);
867 return PMINFO_R_ERROR;
870 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
871 PMINFO_APPINFO_PROP_APP_DISABLE, false);
872 if (ret != PMINFO_R_OK) {
873 pkgmgrinfo_appinfo_filter_destroy(filter);
875 return PMINFO_R_ERROR;
878 list = g_hash_table_new(g_str_hash, g_str_equal);
880 pkgmgrinfo_appinfo_filter_destroy(filter);
882 return PMINFO_R_ERROR;
885 ret = _appinfo_get_applications(uid, uid, locale, filter,
886 PMINFO_APPINFO_GET_ALL, list);
887 if (!g_hash_table_size(list) && uid != GLOBAL_USER)
888 ret = _appinfo_get_applications(GLOBAL_USER, uid, locale,
889 filter, PMINFO_APPINFO_GET_ALL, list);
891 pkgmgrinfo_appinfo_filter_destroy(filter);
892 if (ret != PMINFO_R_OK) {
893 g_hash_table_destroy(list);
898 if (!g_hash_table_size(list)) {
899 _LOGI("Appinfo for [%s] is not existed for user [%d]", appid, uid);
900 g_hash_table_destroy(list);
902 return PMINFO_R_ENOENT;
905 info = calloc(1, sizeof(pkgmgr_appinfo_x));
907 _LOGE("out of memory");
909 return PMINFO_R_ERROR;
912 info->app_info = (application_x *)g_hash_table_lookup(list, appid);
913 info->locale = locale;
914 info->package = strdup(info->app_info->package);
916 /* just free list only */
917 g_hash_table_destroy(list);
924 API int pkgmgrinfo_appinfo_get_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
926 return pkgmgrinfo_appinfo_get_usr_appinfo(appid, _getuid(), handle);
929 static gpointer __copy_str(gconstpointer src, gpointer data)
931 const char *tmp = (const char *)src;
934 buffer = strdup(tmp);
935 if (buffer == NULL) {
936 LOGE("memory alloc failed");
944 static gpointer __copy_label(gconstpointer src, gpointer data)
946 label_x *tmp = (label_x *)src;
949 label = calloc(1, sizeof(label_x));
951 LOGE("memory alloc failed");
957 label->name = strdup(tmp->name);
959 label->text = strdup(tmp->text);
961 label->lang = strdup(tmp->lang);
966 static gpointer __copy_icon(gconstpointer src, gpointer data)
968 icon_x *tmp = (icon_x *)src;
971 icon = calloc(1, sizeof(icon_x));
973 LOGE("memory alloc failed");
979 icon->text = strdup(tmp->text);
981 icon->lang = strdup(tmp->lang);
983 icon->section = strdup(tmp->section);
985 icon->size = strdup(tmp->size);
987 icon->resolution = strdup(tmp->resolution);
992 static gpointer __copy_metadata(gconstpointer src, gpointer data)
994 metadata_x *tmp = (metadata_x *)src;
995 metadata_x *metadata;
997 metadata = calloc(1, sizeof(metadata_x));
998 if (metadata == NULL) {
999 LOGE("memory alloc failed");
1005 metadata->key = strdup(tmp->key);
1007 metadata->value = strdup(tmp->value);
1012 static gpointer __copy_datacontrol(gconstpointer src, gpointer data)
1014 datacontrol_x *tmp = (datacontrol_x *)src;
1015 datacontrol_x *datacontrol;
1017 datacontrol = calloc(1, sizeof(datacontrol_x));
1018 if (datacontrol == NULL) {
1019 LOGE("memory alloc failed");
1024 if (tmp->providerid)
1025 datacontrol->providerid = strdup(tmp->providerid);
1027 datacontrol->access = strdup(tmp->access);
1029 datacontrol->type = strdup(tmp->type);
1034 static gpointer __copy_appcontrol(gconstpointer src, gpointer data)
1036 appcontrol_x *tmp = (appcontrol_x *)src;
1037 appcontrol_x *appcontrol;
1039 appcontrol = calloc(1, sizeof(appcontrol_x));
1040 if (appcontrol ==NULL) {
1041 LOGE("memory alloc failed");
1047 appcontrol->operation = strdup(tmp->operation);
1049 appcontrol->uri = strdup(tmp->uri);
1051 appcontrol->mime = strdup(tmp->mime);
1056 static gpointer __copy_splashscreens(gconstpointer src, gpointer data)
1058 splashscreen_x *tmp = (splashscreen_x *)src;
1059 splashscreen_x *splashscreen;
1061 splashscreen = (splashscreen_x *)calloc(1, sizeof(splashscreen_x));
1062 if (splashscreen == NULL) {
1063 LOGE("memory alloc failed");
1069 splashscreen->src = strdup(tmp->src);
1071 splashscreen->type = strdup(tmp->type);
1072 if (tmp->orientation)
1073 splashscreen->orientation = strdup(tmp->orientation);
1074 if (tmp->indicatordisplay)
1075 splashscreen->indicatordisplay = strdup(tmp->indicatordisplay);
1077 splashscreen->operation = strdup(tmp->operation);
1078 if (tmp->color_depth)
1079 splashscreen->color_depth = strdup(tmp->color_depth);
1081 return splashscreen;
1084 static int _appinfo_copy_appinfo(application_x **application, application_x *data)
1086 application_x *app_info;
1089 app_info = calloc(1, sizeof(application_x));
1090 if (app_info == NULL) {
1091 LOGE("memory alloc failed");
1092 return PMINFO_R_ERROR;
1095 if (data->appid != NULL)
1096 app_info->appid = strdup(data->appid);
1097 if (data->exec != NULL)
1098 app_info->exec = strdup(data->exec);
1099 if (data->nodisplay != NULL)
1100 app_info->nodisplay = strdup(data->nodisplay);
1101 if (data->multiple != NULL)
1102 app_info->multiple = strdup(data->multiple);
1103 if (data->taskmanage != NULL)
1104 app_info->taskmanage = strdup(data->taskmanage);
1105 if (data->enabled != NULL)
1106 app_info->enabled = strdup(data->enabled);
1107 if (data->type != NULL)
1108 app_info->type = strdup(data->type);
1109 if (data->categories != NULL)
1110 app_info->categories = strdup(data->categories);
1111 if (data->hwacceleration != NULL)
1112 app_info->hwacceleration = strdup(data->hwacceleration);
1113 if (data->screenreader != NULL)
1114 app_info->screenreader = strdup(data->screenreader);
1115 if (data->mainapp != NULL)
1116 app_info->mainapp = strdup(data->mainapp);
1117 if (data->package != NULL)
1118 app_info->package = strdup(data->package);
1119 if (data->recentimage != NULL)
1120 app_info->recentimage = strdup(data->recentimage);
1121 if (data->launchcondition != NULL)
1122 app_info->launchcondition = strdup(data->launchcondition);
1123 if (data->indicatordisplay != NULL)
1124 app_info->indicatordisplay = strdup(data->indicatordisplay);
1125 if (data->portraitimg != NULL)
1126 app_info->portraitimg = strdup(data->portraitimg);
1127 if (data->landscapeimg != NULL)
1128 app_info->landscapeimg = strdup(data->landscapeimg);
1129 if (data->guestmode_visibility != NULL)
1130 app_info->guestmode_visibility = strdup(data->guestmode_visibility);
1131 if (data->component != NULL)
1132 app_info->component = strdup(data->component);
1133 if (data->permission_type != NULL)
1134 app_info->permission_type = strdup(data->permission_type);
1135 if (data->component_type != NULL)
1136 app_info->component_type = strdup(data->component_type);
1137 if (data->preload != NULL)
1138 app_info->preload = strdup(data->preload);
1139 if (data->submode != NULL)
1140 app_info->submode = strdup(data->submode);
1141 if (data->submode_mainid != NULL)
1142 app_info->submode_mainid = strdup(data->submode_mainid);
1143 if (data->process_pool != NULL)
1144 app_info->process_pool = strdup(data->process_pool);
1145 if (data->installed_storage != NULL)
1146 app_info->installed_storage = strdup(data->installed_storage);
1147 if (data->autorestart != NULL)
1148 app_info->autorestart = strdup(data->autorestart);
1149 if (data->onboot != NULL)
1150 app_info->onboot = strdup(data->onboot);
1151 if (data->support_disable != NULL)
1152 app_info->support_disable = strdup(data->support_disable);
1153 if (data->ui_gadget != NULL)
1154 app_info->ui_gadget = strdup(data->ui_gadget);
1155 if (data->launch_mode != NULL)
1156 app_info->launch_mode = strdup(data->launch_mode);
1157 if (data->package_type != NULL)
1158 app_info->package_type = strdup(data->package_type);
1159 if (data->effective_appid != NULL)
1160 app_info->effective_appid = strdup(data->effective_appid);
1161 if (data->splash_screen_display != NULL)
1162 app_info->splash_screen_display = strdup(data->splash_screen_display);
1166 app_info->label = g_list_copy_deep(data->label, __copy_label, &ret);
1168 LOGE("memory alloc failed");
1169 pkgmgrinfo_basic_free_application(app_info);
1170 return PMINFO_R_ERROR;
1174 app_info->icon = g_list_copy_deep(data->icon, __copy_icon, &ret);
1176 LOGE("memory alloc failed");
1177 pkgmgrinfo_basic_free_application(app_info);
1178 return PMINFO_R_ERROR;
1182 app_info->category = g_list_copy_deep(data->category, __copy_str, &ret);
1184 LOGE("memory alloc failed");
1185 pkgmgrinfo_basic_free_application(app_info);
1186 return PMINFO_R_ERROR;
1190 app_info->metadata = g_list_copy_deep(data->metadata, __copy_metadata, &ret);
1192 LOGE("memory alloc failed");
1193 pkgmgrinfo_basic_free_application(app_info);
1194 return PMINFO_R_ERROR;
1198 app_info->datacontrol = g_list_copy_deep(data->datacontrol, __copy_datacontrol, &ret);
1200 LOGE("memory alloc failed");
1201 pkgmgrinfo_basic_free_application(app_info);
1202 return PMINFO_R_ERROR;
1206 app_info->appcontrol = g_list_copy_deep(data->appcontrol, __copy_appcontrol, &ret);
1208 LOGE("memory alloc failed");
1209 pkgmgrinfo_basic_free_application(app_info);
1210 return PMINFO_R_ERROR;
1214 app_info->background_category = g_list_copy_deep(data->background_category, __copy_str, &ret);
1216 LOGE("memory alloc failed");
1217 pkgmgrinfo_basic_free_application(app_info);
1218 return PMINFO_R_ERROR;
1222 app_info->splashscreens = g_list_copy_deep(data->splashscreens, __copy_splashscreens, &ret);
1224 LOGE("memory alloc failed");
1225 pkgmgrinfo_basic_free_application(app_info);
1226 return PMINFO_R_ERROR;
1229 *application = app_info;
1234 API int pkgmgrinfo_appinfo_clone_appinfo(pkgmgrinfo_appinfo_h handle,
1235 pkgmgrinfo_appinfo_h *clone)
1237 pkgmgr_appinfo_x *info;
1238 pkgmgr_appinfo_x *temp = (pkgmgr_appinfo_x *)handle;
1241 return PMINFO_R_EINVAL;
1243 info = calloc(1, sizeof(pkgmgr_appinfo_x));
1245 LOGE("memory alloc failed");
1246 return PMINFO_R_ERROR;
1249 if (temp->package != NULL)
1250 info->package = strdup(temp->package);
1251 if (temp->locale != NULL)
1252 info->locale = strdup(temp->locale);
1254 info->app_component = temp->app_component;
1256 if (_appinfo_copy_appinfo(&info->app_info, temp->app_info) < 0) {
1257 LOGE("appinfo copy failed");
1259 free((void *)info->package);
1263 return PMINFO_R_ERROR;
1271 static int _appinfo_get_filtered_foreach_appinfo(uid_t uid,
1272 pkgmgrinfo_filter_x *filter, int flag, pkgmgrinfo_app_list_cb app_list_cb,
1278 pkgmgr_appinfo_x info;
1280 GHashTableIter iter;
1283 locale = _get_system_locale();
1285 return PMINFO_R_ERROR;
1287 list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
1288 __free_applications);
1291 return PMINFO_R_ERROR;
1294 ret = _appinfo_get_applications(uid, uid, locale, filter, flag, list);
1295 if (ret == PMINFO_R_OK && uid != GLOBAL_USER)
1296 ret = _appinfo_get_applications(GLOBAL_USER, uid, locale,
1297 filter, flag, list);
1299 if (ret != PMINFO_R_OK) {
1300 g_hash_table_destroy(list);
1305 g_hash_table_iter_init(&iter, list);
1306 while (g_hash_table_iter_next(&iter, NULL, &value)) {
1307 app = (application_x *)value;
1308 info.app_info = app;
1309 info.locale = locale;
1310 info.package = app->package;
1311 if (app_list_cb(&info, user_data) < 0)
1314 g_hash_table_destroy(list);
1320 static const char *__appcomponent_str(pkgmgrinfo_app_component comp);
1322 API int pkgmgrinfo_appinfo_get_usr_list(pkgmgrinfo_pkginfo_h handle,
1323 pkgmgrinfo_app_component component,
1324 pkgmgrinfo_app_list_cb app_func, void *user_data, uid_t uid)
1327 pkgmgrinfo_appinfo_filter_h filter;
1329 const char *comp_str = NULL;
1331 if (handle == NULL || app_func == NULL) {
1332 LOGE("invalid parameter");
1333 return PMINFO_R_EINVAL;
1336 if (pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid)) {
1337 LOGE("invalid parameter");
1338 return PMINFO_R_EINVAL;
1341 if (pkgmgrinfo_appinfo_filter_create(&filter))
1342 return PMINFO_R_ERROR;
1344 if (pkgmgrinfo_appinfo_filter_add_string(filter,
1345 PMINFO_APPINFO_PROP_APP_PACKAGE, pkgid)) {
1346 pkgmgrinfo_appinfo_filter_destroy(filter);
1347 return PMINFO_R_ERROR;
1350 if (uid == GLOBAL_USER) {
1351 if (pkgmgrinfo_appinfo_filter_add_int(filter,
1352 PMINFO_APPINFO_PROP_APP_DISABLE_FOR_USER,
1354 pkgmgrinfo_appinfo_filter_destroy(filter);
1355 return PMINFO_R_ERROR;
1359 comp_str = __appcomponent_str(component);
1362 if (pkgmgrinfo_appinfo_filter_add_string(filter,
1363 PMINFO_APPINFO_PROP_APP_COMPONENT,
1365 pkgmgrinfo_appinfo_filter_destroy(filter);
1366 return PMINFO_R_ERROR;
1370 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter,
1371 PMINFO_APPINFO_GET_ALL, app_func, user_data);
1373 pkgmgrinfo_appinfo_filter_destroy(filter);
1378 API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle,
1379 pkgmgrinfo_app_component component,
1380 pkgmgrinfo_app_list_cb app_func, void *user_data)
1382 return pkgmgrinfo_appinfo_get_usr_list(handle, component, app_func, user_data, _getuid());
1385 API int pkgmgrinfo_appinfo_get_usr_installed_list_full(
1386 pkgmgrinfo_app_list_cb app_func, uid_t uid, int flag,
1390 pkgmgrinfo_appinfo_filter_h filter;
1392 if (app_func == NULL) {
1393 LOGE("invalid parameter");
1394 return PMINFO_R_EINVAL;
1397 if (pkgmgrinfo_appinfo_filter_create(&filter)) {
1398 return PMINFO_R_ERROR;
1401 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
1402 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
1403 pkgmgrinfo_appinfo_filter_destroy(filter);
1404 return PMINFO_R_ERROR;
1407 if (uid == GLOBAL_USER) {
1408 if (pkgmgrinfo_appinfo_filter_add_int(filter,
1409 PMINFO_APPINFO_PROP_APP_DISABLE_FOR_USER,
1411 pkgmgrinfo_appinfo_filter_destroy(filter);
1412 return PMINFO_R_ERROR;
1416 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter, flag, app_func,
1419 pkgmgrinfo_appinfo_filter_destroy(filter);
1424 API int pkgmgrinfo_appinfo_get_installed_list_full(
1425 pkgmgrinfo_app_list_cb app_func, int flag, void *user_data)
1427 return pkgmgrinfo_appinfo_get_usr_installed_list_full(app_func,
1428 _getuid(), flag, user_data);
1431 API int pkgmgrinfo_appinfo_get_usr_install_list(pkgmgrinfo_app_list_cb app_func,
1432 uid_t uid, void *user_data)
1434 return pkgmgrinfo_appinfo_get_usr_installed_list_full(app_func,
1435 uid, PMINFO_APPINFO_GET_ALL, user_data);
1438 API int pkgmgrinfo_appinfo_get_install_list(pkgmgrinfo_app_list_cb app_func,
1441 return pkgmgrinfo_appinfo_get_usr_installed_list_full(app_func,
1442 _getuid(), PMINFO_APPINFO_GET_ALL, user_data);
1445 API int pkgmgrinfo_appinfo_get_usr_installed_list(
1446 pkgmgrinfo_app_list_cb app_func, uid_t uid, void *user_data)
1448 if (app_func == NULL) {
1449 LOGE("invalid parameter");
1450 return PMINFO_R_EINVAL;
1453 return _appinfo_get_filtered_foreach_appinfo(uid, NULL,
1454 PMINFO_APPINFO_GET_ALL, app_func, user_data);
1457 API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func,
1460 return pkgmgrinfo_appinfo_get_usr_installed_list(app_func, _getuid(),
1464 API int pkgmgrinfo_appinfo_get_appid(pkgmgrinfo_appinfo_h handle, char **appid)
1466 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1468 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1469 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1471 if (info->app_info == NULL || info->app_info->appid == NULL)
1472 return PMINFO_R_ERROR;
1473 *appid = (char *)info->app_info->appid;
1478 API int pkgmgrinfo_appinfo_get_pkgname(pkgmgrinfo_appinfo_h handle, char **pkg_name)
1480 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1482 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1483 retvm_if(pkg_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1485 if (info->package == NULL)
1486 return PMINFO_R_ERROR;
1488 *pkg_name = (char *)info->package;
1493 API int pkgmgrinfo_appinfo_get_pkgid(pkgmgrinfo_appinfo_h handle, char **pkgid)
1495 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1497 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1498 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1500 if (info->package == NULL)
1501 return PMINFO_R_ERROR;
1503 *pkgid = (char *)info->package;
1508 API int pkgmgrinfo_appinfo_get_pkgtype(pkgmgrinfo_appinfo_h handle, char **pkgtype)
1510 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1511 retvm_if(pkgtype == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1512 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1514 *pkgtype = (char *)info->app_info->package_type;
1519 API int pkgmgrinfo_appinfo_get_exec(pkgmgrinfo_appinfo_h handle, char **exec)
1521 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1523 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1524 retvm_if(exec == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1526 if (info->app_info == NULL || info->app_info->exec == NULL)
1527 return PMINFO_R_ERROR;
1528 *exec = (char *)info->app_info->exec;
1534 API int pkgmgrinfo_appinfo_get_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1539 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1541 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1542 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1544 locale = info->locale;
1545 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
1547 if (info->app_info == NULL)
1548 return PMINFO_R_ERROR;
1550 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1551 ptr = (icon_x *)tmp->data;
1552 if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL ||
1553 !strcasecmp(ptr->text, "") ||
1554 strcmp(ptr->lang, locale))
1556 *icon = (char *)ptr->text;
1560 locale = DEFAULT_LOCALE;
1561 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1562 ptr = (icon_x *)tmp->data;
1563 if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL ||
1564 strcmp(ptr->lang, locale))
1566 *icon = (char *)ptr->text;
1570 return PMINFO_R_ERROR;
1574 API int pkgmgrinfo_appinfo_get_label(pkgmgrinfo_appinfo_h handle, char **label)
1579 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1581 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1582 retvm_if(label == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1584 locale = info->locale;
1585 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
1587 if (info->app_info == NULL)
1588 return PMINFO_R_ERROR;
1590 for (tmp = info->app_info->label; tmp; tmp = tmp->next) {
1591 ptr = (label_x *)tmp->data;
1592 if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL ||
1593 strcmp(ptr->lang, locale))
1595 *label = (char *)ptr->text;
1599 locale = DEFAULT_LOCALE;
1600 for (tmp = info->app_info->label; tmp; tmp = tmp->next) {
1601 ptr = (label_x *)tmp->data;
1602 if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL ||
1603 strcmp(ptr->lang, locale))
1605 *label = (char *)ptr->text;
1609 return PMINFO_R_ERROR;
1612 static char *_get_localed_label(const char *appid, const char *locale, uid_t uid)
1614 char *result = NULL;
1616 sqlite3_stmt *stmt = NULL;
1619 const char *manifest_db;
1621 manifest_db = getUserPkgParserDBPathUID(uid);
1622 if (manifest_db == NULL) {
1623 _LOGE("Failed to get manifest db path");
1627 if (sqlite3_open_v2(manifest_db, &db, SQLITE_OPEN_READONLY, NULL) != SQLITE_OK) {
1628 _LOGE("DB open fail\n");
1632 query = sqlite3_mprintf("select app_label from package_app_localized_info where app_id=%Q and app_locale=%Q", appid, locale);
1633 if (query == NULL) {
1634 _LOGE("Out of memory");
1638 if (sqlite3_prepare_v2(db, query, -1, &stmt, NULL) != SQLITE_OK) {
1639 _LOGE("prepare_v2 fail\n");
1643 if (sqlite3_step(stmt) == SQLITE_ROW) {
1644 val = (char *)sqlite3_column_text(stmt, 0);
1646 result = strdup(val);
1650 sqlite3_finalize(stmt);
1651 sqlite3_free(query);
1657 API int pkgmgrinfo_appinfo_usr_get_localed_label(const char *appid, const char *locale, uid_t uid, char **label)
1661 retvm_if(appid == NULL || locale == NULL || label == NULL, PMINFO_R_EINVAL, "Argument is NULL");
1663 val = _get_localed_label(appid, locale, uid);
1665 val = _get_localed_label(appid, DEFAULT_LOCALE, uid);
1668 return PMINFO_R_ERROR;
1675 API int pkgmgrinfo_appinfo_get_localed_label(const char *appid, const char *locale, char **label)
1677 return pkgmgrinfo_appinfo_usr_get_localed_label(appid, locale, _getuid(), label);
1680 API int pkgmgrinfo_appinfo_get_metadata_value(pkgmgrinfo_appinfo_h handle, const char *metadata_key, char **metadata_value)
1682 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1683 retvm_if(metadata_key == NULL, PMINFO_R_EINVAL, "metadata_key is NULL");
1684 retvm_if(metadata_value == NULL, PMINFO_R_EINVAL, "metadata_value is NULL");
1686 GList *list_md = NULL;
1687 metadata_x *metadata = NULL;
1688 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1690 list_md = info->app_info->metadata;
1692 for (; list_md; list_md = list_md->next) {
1693 metadata = (metadata_x *)list_md->data;
1694 if (metadata && metadata->key) {
1695 if (strcasecmp(metadata->key, metadata_key) == 0) {
1696 *metadata_value = (char*)metadata->value;
1702 return PMINFO_R_EINVAL;
1705 static pkgmgrinfo_app_component __appcomponent_convert(const char *comp)
1707 if (strcasecmp(comp, "uiapp") == 0)
1708 return PMINFO_UI_APP;
1709 else if (strcasecmp(comp, "svcapp") == 0)
1710 return PMINFO_SVC_APP;
1711 else if (strcasecmp(comp, "widgetapp") == 0)
1712 return PMINFO_WIDGET_APP;
1713 else if (strcasecmp(comp, "watchapp") == 0)
1714 return PMINFO_WATCH_APP;
1719 static const char *__appcomponent_str(pkgmgrinfo_app_component comp)
1724 case PMINFO_SVC_APP:
1726 case PMINFO_WIDGET_APP:
1728 case PMINFO_WATCH_APP:
1735 API int pkgmgrinfo_appinfo_get_component(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_component *component)
1737 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1740 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1741 retvm_if(component == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1743 if (info->app_info == NULL)
1744 return PMINFO_R_ERROR;
1746 comp = __appcomponent_convert(info->app_info->component);
1748 return PMINFO_R_ERROR;
1755 API int pkgmgrinfo_appinfo_get_apptype(pkgmgrinfo_appinfo_h handle, char **app_type)
1757 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1759 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1760 retvm_if(app_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1762 if (info->app_info == NULL || info->app_info->type == NULL)
1763 return PMINFO_R_ERROR;
1764 *app_type = (char *)info->app_info->type;
1769 API int pkgmgrinfo_appinfo_get_operation(pkgmgrinfo_appcontrol_h handle,
1770 int *operation_count, char ***operation)
1772 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1773 retvm_if(operation == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1774 retvm_if(operation_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1775 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1776 *operation_count = data->operation_count;
1777 *operation = data->operation;
1781 API int pkgmgrinfo_appinfo_get_uri(pkgmgrinfo_appcontrol_h handle,
1782 int *uri_count, char ***uri)
1784 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1785 retvm_if(uri == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1786 retvm_if(uri_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1787 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1788 *uri_count = data->uri_count;
1793 API int pkgmgrinfo_appinfo_get_mime(pkgmgrinfo_appcontrol_h handle,
1794 int *mime_count, char ***mime)
1796 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1797 retvm_if(mime == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1798 retvm_if(mime_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1799 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1800 *mime_count = data->mime_count;
1805 API int pkgmgrinfo_appinfo_get_subapp(pkgmgrinfo_appcontrol_h handle,
1806 int *subapp_count, char ***subapp)
1808 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1809 retvm_if(subapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1810 retvm_if(subapp_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1811 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1812 *subapp_count = data->subapp_count;
1813 *subapp = data->subapp;
1817 API int pkgmgrinfo_appinfo_get_setting_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1822 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1824 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1825 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1827 if (info->app_info == NULL)
1828 return PMINFO_R_ERROR;
1830 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1831 ptr = (icon_x *)tmp->data;
1832 if (ptr == NULL || ptr->section == NULL)
1835 val = (char *)ptr->section;
1836 if (val && strcmp(val, "setting") == 0) {
1837 *icon = (char *)ptr->text;
1842 return PMINFO_R_ERROR;
1846 API int pkgmgrinfo_appinfo_get_notification_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1851 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1853 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1854 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1856 if (info->app_info == NULL)
1857 return PMINFO_R_ERROR;
1859 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1860 ptr = (icon_x *)tmp->data;
1861 if (ptr == NULL || ptr->section == NULL)
1864 val = (char *)ptr->section;
1865 if (val && strcmp(val, "notification") == 0){
1866 *icon = (char *)ptr->text;
1871 return PMINFO_R_ERROR;
1874 API int pkgmgrinfo_appinfo_get_recent_image_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_recentimage *type)
1877 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1879 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1880 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1882 if (info->app_info == NULL || info->app_info->recentimage == NULL)
1883 return PMINFO_R_ERROR;
1885 val = (char *)info->app_info->recentimage;
1886 if (strcasecmp(val, "capture") == 0)
1887 *type = PMINFO_RECENTIMAGE_USE_CAPTURE;
1888 else if (strcasecmp(val, "icon") == 0)
1889 *type = PMINFO_RECENTIMAGE_USE_ICON;
1891 *type = PMINFO_RECENTIMAGE_USE_NOTHING;
1896 API int pkgmgrinfo_appinfo_get_preview_image(pkgmgrinfo_appinfo_h handle, char **preview_img)
1901 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1903 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1904 retvm_if(preview_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1906 if (info->app_info == NULL)
1907 return PMINFO_R_ERROR;
1909 for (tmp = info->app_info->image; tmp; tmp = tmp->next) {
1910 ptr = (image_x *)tmp->data;
1911 if (ptr == NULL || ptr->section == NULL)
1914 val = (char *)ptr->section;
1915 if (val && strcmp(val, "preview") == 0) {
1916 *preview_img = (char *)ptr->text;
1921 return PMINFO_R_ERROR;
1924 API int pkgmgrinfo_appinfo_get_permission_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_permission_type *permission)
1927 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1929 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1930 retvm_if(permission == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1932 val = info->app_info->permission_type;
1934 return PMINFO_R_ERROR;
1936 if (strcmp(val, "signature") == 0)
1937 *permission = PMINFO_PERMISSION_SIGNATURE;
1938 else if (strcmp(val, "privilege") == 0)
1939 *permission = PMINFO_PERMISSION_PRIVILEGE;
1941 *permission = PMINFO_PERMISSION_NORMAL;
1946 API int pkgmgrinfo_appinfo_get_component_type(pkgmgrinfo_appinfo_h handle, char **component_type)
1948 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1950 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1951 retvm_if(component_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1953 if (info->app_info == NULL || info->app_info->component_type == NULL)
1954 return PMINFO_R_ERROR;
1956 *component_type = (char *)info->app_info->component_type;
1961 API int pkgmgrinfo_appinfo_get_hwacceleration(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_hwacceleration *hwacceleration)
1964 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1966 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1967 retvm_if(hwacceleration == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1969 if (info->app_info == NULL || info->app_info->hwacceleration == NULL)
1970 return PMINFO_R_ERROR;
1972 val = (char *)info->app_info->hwacceleration;
1973 if (strcasecmp(val, "off") == 0)
1974 *hwacceleration = PMINFO_HWACCELERATION_OFF;
1975 else if (strcasecmp(val, "on") == 0)
1976 *hwacceleration = PMINFO_HWACCELERATION_ON;
1978 *hwacceleration = PMINFO_HWACCELERATION_DEFAULT;
1983 API int pkgmgrinfo_appinfo_get_screenreader(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_screenreader *screenreader)
1986 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1988 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1989 retvm_if(screenreader == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1991 if (info->app_info == NULL || info->app_info->screenreader == NULL)
1992 return PMINFO_R_ERROR;
1994 val = (char *)info->app_info->screenreader;
1995 if (strcasecmp(val, "screenreader-off") == 0)
1996 *screenreader = PMINFO_SCREENREADER_OFF;
1997 else if (strcasecmp(val, "screenreader-on") == 0)
1998 *screenreader = PMINFO_SCREENREADER_ON;
2000 *screenreader = PMINFO_SCREENREADER_USE_SYSTEM_SETTING;
2005 API int pkgmgrinfo_appinfo_get_effectimage(pkgmgrinfo_appinfo_h handle, char **portrait_img, char **landscape_img)
2007 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2009 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2010 retvm_if(portrait_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2011 retvm_if(landscape_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2013 if (info->app_info == NULL || (info->app_info->portraitimg == NULL
2014 && info->app_info->landscapeimg == NULL))
2015 return PMINFO_R_ERROR;
2017 *portrait_img = (char *)info->app_info->portraitimg;
2018 *landscape_img = (char *)info->app_info->landscapeimg;
2023 API int pkgmgrinfo_appinfo_get_effectimage_type(pkgmgrinfo_appinfo_h handle, char **effectimage_type)
2025 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2027 if (handle == NULL || effectimage_type == NULL) {
2028 LOGE("invalid parameter");
2029 return PMINFO_R_EINVAL;
2032 if (info->app_info == NULL || info->app_info->effectimage_type == NULL)
2033 return PMINFO_R_ERROR;
2035 *effectimage_type = (char *)info->app_info->effectimage_type;
2040 API int pkgmgrinfo_appinfo_get_submode_mainid(pkgmgrinfo_appinfo_h handle, char **submode_mainid)
2042 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2044 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2045 retvm_if(submode_mainid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2047 if (info->app_info == NULL || info->app_info->submode_mainid == NULL)
2048 return PMINFO_R_ERROR;
2050 *submode_mainid = (char *)info->app_info->submode_mainid;
2055 API int pkgmgrinfo_appinfo_get_installed_storage_location(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_installed_storage *storage)
2057 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2058 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2060 if (info->app_info && info->app_info->installed_storage){
2061 if (strcmp(info->app_info->installed_storage,"installed_internal") == 0)
2062 *storage = PMINFO_INTERNAL_STORAGE;
2063 else if (strcmp(info->app_info->installed_storage,"installed_external") == 0)
2064 *storage = PMINFO_EXTERNAL_STORAGE;
2066 return PMINFO_R_ERROR;
2068 return PMINFO_R_ERROR;
2073 API int pkgmgrinfo_appinfo_get_launch_mode(pkgmgrinfo_appinfo_h handle, char **mode)
2075 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2077 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2078 retvm_if(mode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2080 if (info->app_info->launch_mode == NULL)
2081 return PMINFO_R_ERROR;
2083 *mode = (char *)(info->app_info->launch_mode);
2088 API int pkgmgrinfo_appinfo_get_alias_appid(pkgmgrinfo_appinfo_h handle, char **alias_appid)
2090 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2092 if (handle == NULL || alias_appid == NULL) {
2093 LOGE("invalid parameter");
2094 return PMINFO_R_EINVAL;
2097 if (info->app_info == NULL || info->app_info->alias_appid == NULL)
2098 return PMINFO_R_ERROR;
2100 *alias_appid = (char *)info->app_info->alias_appid;
2105 API int pkgmgrinfo_appinfo_get_effective_appid(pkgmgrinfo_appinfo_h handle, char **effective_appid)
2107 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2109 if (handle == NULL || effective_appid == NULL) {
2110 LOGE("invalid parameter");
2111 return PMINFO_R_EINVAL;
2114 if (info->app_info == NULL || info->app_info->effective_appid == NULL)
2115 return PMINFO_R_ERROR;
2117 *effective_appid = (char *)info->app_info->effective_appid;
2122 API int pkgmgrinfo_appinfo_get_tep_name(pkgmgrinfo_appinfo_h handle, char **tep_name)
2124 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2126 if (handle == NULL || tep_name == NULL) {
2127 LOGE("invalid parameter");
2128 return PMINFO_R_EINVAL;
2131 if (info->app_info == NULL || info->app_info->tep_name == NULL)
2132 return PMINFO_R_ERROR;
2134 *tep_name = (char *)info->app_info->tep_name;
2139 API int pkgmgrinfo_appinfo_get_zip_mount_file(pkgmgrinfo_appinfo_h handle, char **zip_mount_file)
2141 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2143 if (handle == NULL || zip_mount_file == NULL) {
2144 LOGE("invalid parameter");
2145 return PMINFO_R_EINVAL;
2148 *zip_mount_file = (char *)info->app_info->zip_mount_file;
2153 API int pkgmgrinfo_appinfo_get_root_path(pkgmgrinfo_appinfo_h handle, char **root_path)
2155 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2157 if (handle == NULL || root_path == NULL) {
2158 LOGE("invalid parameter");
2159 return PMINFO_R_EINVAL;
2162 if (info->app_info == NULL || info->app_info->root_path == NULL)
2163 return PMINFO_R_ERROR;
2165 *root_path = (char *)info->app_info->root_path;
2170 API int pkgmgrinfo_appinfo_get_api_version(pkgmgrinfo_appinfo_h handle, char **api_version)
2172 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2174 if (handle == NULL || api_version == NULL) {
2175 LOGE("invalid parameter");
2176 return PMINFO_R_EINVAL;
2179 if (info->app_info == NULL || info->app_info->api_version == NULL)
2180 return PMINFO_R_ERROR;
2182 *api_version = (char *)info->app_info->api_version;
2187 API int pkgmgrinfo_appinfo_usr_get_datacontrol_info(const char *providerid, const char *type, uid_t uid, char **appid, char **access)
2189 retvm_if(providerid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
2190 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
2191 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2192 retvm_if(access == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2194 int ret = PMINFO_R_OK;
2196 sqlite3_stmt *stmt = NULL;
2199 ret = __open_manifest_db(uid, true);
2200 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
2202 /*Start constructing query*/
2203 query = sqlite3_mprintf("select * from package_app_data_control where providerid=%Q and type=%Q", providerid, type);
2204 tryvm_if(query == NULL, ret = PMINFO_R_ERROR, "Out of memory");
2207 ret = sqlite3_prepare_v2(GET_DB(manifest_db), query, strlen(query), &stmt, NULL);
2208 tryvm_if(ret != PMINFO_R_OK, ret = PMINFO_R_ERROR, "sqlite3_prepare_v2 failed[%s]\n", query);
2211 ret = sqlite3_step(stmt);
2212 tryvm_if((ret != SQLITE_ROW) || (ret == SQLITE_DONE), ret = PMINFO_R_ERROR, "No records found");
2214 *appid = strdup((char *)sqlite3_column_text(stmt, 0));
2215 *access = strdup((char *)sqlite3_column_text(stmt, 2));
2220 sqlite3_free(query);
2221 sqlite3_finalize(stmt);
2222 __close_manifest_db();
2226 API int pkgmgrinfo_appinfo_get_datacontrol_info(const char *providerid, const char *type, char **appid, char **access)
2228 return pkgmgrinfo_appinfo_usr_get_datacontrol_info(providerid, type, _getuid(), appid, access);
2231 API int pkgmgrinfo_appinfo_usr_get_datacontrol_appid(const char *providerid, uid_t uid, char **appid)
2233 retvm_if(providerid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
2234 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2236 int ret = PMINFO_R_OK;
2238 sqlite3_stmt *stmt = NULL;
2241 ret = __open_manifest_db(uid, true);
2242 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
2244 /*Start constructing query*/
2245 query = sqlite3_mprintf("select * from package_app_data_control where providerid=%Q", providerid);
2246 tryvm_if(query == NULL, ret = PMINFO_R_ERROR, "Out of memory");
2249 ret = sqlite3_prepare_v2(GET_DB(manifest_db), query, strlen(query), &stmt, NULL);
2250 tryvm_if(ret != PMINFO_R_OK, ret = PMINFO_R_ERROR, "sqlite3_prepare_v2 failed[%s]\n", query);
2253 ret = sqlite3_step(stmt);
2254 tryvm_if((ret != SQLITE_ROW) || (ret == SQLITE_DONE), ret = PMINFO_R_ERROR, "No records found");
2256 *appid = strdup((char *)sqlite3_column_text(stmt, 0));
2261 sqlite3_free(query);
2262 sqlite3_finalize(stmt);
2263 __close_manifest_db();
2267 API int pkgmgrinfo_appinfo_get_datacontrol_appid(const char *providerid, char **appid)
2269 return pkgmgrinfo_appinfo_usr_get_datacontrol_appid(providerid, _getuid(), appid);
2272 API int pkgmgrinfo_appinfo_foreach_permission(pkgmgrinfo_appinfo_h handle,
2273 pkgmgrinfo_app_permission_list_cb permission_func, void *user_data)
2275 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2276 retvm_if(permission_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2280 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2282 if (info->app_info == NULL)
2283 return PMINFO_R_ERROR;
2285 for (tmp = info->app_info->permission; tmp; tmp = tmp->next) {
2286 ptr = (permission_x *)tmp->data;
2290 ret = permission_func(ptr->value, user_data);
2298 API int pkgmgrinfo_appinfo_foreach_category(pkgmgrinfo_appinfo_h handle,
2299 pkgmgrinfo_app_category_list_cb category_func, void *user_data)
2301 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2302 retvm_if(category_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2304 const char *category;
2306 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2308 if (info->app_info == NULL)
2309 return PMINFO_R_ERROR;
2311 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
2312 category = (const char *)tmp->data;
2314 ret = category_func(category, user_data);
2322 API int pkgmgrinfo_appinfo_foreach_metadata(pkgmgrinfo_appinfo_h handle,
2323 pkgmgrinfo_app_metadata_list_cb metadata_func, void *user_data)
2325 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2326 retvm_if(metadata_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2330 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2332 if (info->app_info == NULL)
2333 return PMINFO_R_ERROR;
2335 for (tmp = info->app_info->metadata; tmp; tmp = tmp->next) {
2336 ptr = (metadata_x *)tmp->data;
2340 ret = metadata_func(ptr->key, ptr->value, user_data);
2348 API int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
2349 pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
2351 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2352 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2354 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2355 appcontrol_x *appcontrol;
2358 if (info->app_info == NULL)
2359 return PMINFO_R_ERROR;
2361 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
2362 appcontrol = (appcontrol_x *)tmp->data;
2363 if (appcontrol == NULL)
2365 ret = appcontrol_func(appcontrol->operation, appcontrol->uri, appcontrol->mime, user_data);
2373 API int pkgmgrinfo_appinfo_foreach_background_category(
2374 pkgmgrinfo_appinfo_h handle,
2375 pkgmgrinfo_app_background_category_list_cb category_func,
2378 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2382 if (handle == NULL || category_func == NULL || info->app_info == NULL) {
2383 LOGE("invalid parameter");
2384 return PMINFO_R_EINVAL;
2387 for (tmp = info->app_info->background_category; tmp; tmp = tmp->next) {
2388 category = (char *)tmp->data;
2389 if (category == NULL)
2392 if (category_func(category, user_data) < 0)
2399 API int pkgmgrinfo_appinfo_foreach_splash_screen(pkgmgrinfo_appinfo_h handle,
2400 pkgmgrinfo_app_splash_screen_list_cb splash_screen_func,
2403 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2404 splashscreen_x *splashscreen;
2408 if (info == NULL || info->app_info == NULL
2409 || splash_screen_func == NULL) {
2410 LOGE("invalid parameter");
2411 return PMINFO_R_EINVAL;
2414 for (tmp = info->app_info->splashscreens; tmp; tmp = tmp->next) {
2415 splashscreen = (splashscreen_x *)tmp->data;
2416 if (splashscreen == NULL)
2418 ret = splash_screen_func(splashscreen->src,
2420 splashscreen->orientation,
2421 splashscreen->indicatordisplay,
2422 splashscreen->operation,
2423 splashscreen->color_depth,
2432 API int pkgmgrinfo_appinfo_is_nodisplay(pkgmgrinfo_appinfo_h handle, bool *nodisplay)
2434 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2435 retvm_if(nodisplay == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2436 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2438 if (info->app_info == NULL || info->app_info->nodisplay == NULL)
2439 return PMINFO_R_ERROR;
2441 *nodisplay = _get_bool_value(info->app_info->nodisplay);
2446 API int pkgmgrinfo_appinfo_is_multiple(pkgmgrinfo_appinfo_h handle, bool *multiple)
2448 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2449 retvm_if(multiple == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2450 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2452 if (info->app_info == NULL || info->app_info->multiple == NULL)
2453 return PMINFO_R_ERROR;
2455 *multiple = _get_bool_value(info->app_info->multiple);
2460 API int pkgmgrinfo_appinfo_is_indicator_display_allowed(pkgmgrinfo_appinfo_h handle, bool *indicator_disp)
2462 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2463 retvm_if(indicator_disp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2464 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2466 if (info->app_info == NULL || info->app_info->indicatordisplay == NULL)
2467 return PMINFO_R_ERROR;
2469 *indicator_disp = _get_bool_value(info->app_info->indicatordisplay);
2474 API int pkgmgrinfo_appinfo_is_taskmanage(pkgmgrinfo_appinfo_h handle, bool *taskmanage)
2476 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2477 retvm_if(taskmanage == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2478 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2480 if (info->app_info == NULL || info->app_info->taskmanage == NULL)
2481 return PMINFO_R_ERROR;
2483 *taskmanage = _get_bool_value(info->app_info->taskmanage);
2488 API int pkgmgrinfo_appinfo_is_enabled(pkgmgrinfo_appinfo_h handle, bool *enabled)
2490 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2491 retvm_if(enabled == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2492 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2494 if (info->app_info == NULL || info->app_info->enabled == NULL)
2495 return PMINFO_R_ERROR;
2497 *enabled = _get_bool_value(info->app_info->enabled);
2502 API int pkgmgrinfo_appinfo_is_onboot(pkgmgrinfo_appinfo_h handle, bool *onboot)
2504 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2505 retvm_if(onboot == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2506 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2508 if (info->app_info == NULL || info->app_info->onboot == NULL)
2509 return PMINFO_R_ERROR;
2511 *onboot = _get_bool_value(info->app_info->onboot);
2516 API int pkgmgrinfo_appinfo_is_autorestart(pkgmgrinfo_appinfo_h handle, bool *autorestart)
2518 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2519 retvm_if(autorestart == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2520 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2522 if (info->app_info == NULL || info->app_info->autorestart == NULL)
2523 return PMINFO_R_ERROR;
2525 *autorestart = _get_bool_value(info->app_info->autorestart);
2530 API int pkgmgrinfo_appinfo_is_mainapp(pkgmgrinfo_appinfo_h handle, bool *mainapp)
2532 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2533 retvm_if(mainapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2534 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2536 if (info->app_info == NULL || info->app_info->mainapp == NULL)
2537 return PMINFO_R_ERROR;
2539 *mainapp = _get_bool_value(info->app_info->mainapp);
2544 API int pkgmgrinfo_appinfo_is_preload(pkgmgrinfo_appinfo_h handle, bool *preload)
2546 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2547 retvm_if(preload == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2548 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2550 if (info->app_info == NULL || info->app_info->preload == NULL)
2551 return PMINFO_R_ERROR;
2553 *preload = _get_bool_value(info->app_info->preload);
2558 API int pkgmgrinfo_appinfo_is_submode(pkgmgrinfo_appinfo_h handle, bool *submode)
2560 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2561 retvm_if(submode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2562 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2564 if (info->app_info == NULL || info->app_info->submode == NULL)
2565 return PMINFO_R_ERROR;
2567 *submode = _get_bool_value(info->app_info->submode);
2572 API int pkgmgrinfo_appinfo_is_process_pool(pkgmgrinfo_appinfo_h handle, bool *process_pool)
2574 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2576 if (handle == NULL || process_pool == NULL) {
2577 LOGE("invalid parameter");
2578 return PMINFO_R_EINVAL;
2581 if (info->app_info == NULL)
2582 return PMINFO_R_ERROR;
2584 *process_pool = _get_bool_value(info->app_info->process_pool);
2589 API int pkgmgrinfo_appinfo_is_category_exist(pkgmgrinfo_appinfo_h handle, const char *category, bool *exist)
2591 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2592 retvm_if(category == NULL, PMINFO_R_EINVAL, "category is NULL");
2593 retvm_if(exist == NULL, PMINFO_R_EINVAL, "exist is NULL");
2597 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2599 if (info->app_info == NULL)
2600 return PMINFO_R_ERROR;
2603 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
2604 val = (const char *)tmp->data;
2607 if (strcasecmp(val, category) == 0) {
2616 API int pkgmgrinfo_appinfo_is_ui_gadget(pkgmgrinfo_appinfo_h handle,
2619 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2621 if (info == NULL || info->app_info == NULL || ui_gadget == NULL) {
2622 _LOGE("invalid parameter");
2623 return PMINFO_R_EINVAL;
2626 *ui_gadget = _get_bool_value(info->app_info->ui_gadget);
2631 API int pkgmgrinfo_appinfo_is_support_disable(pkgmgrinfo_appinfo_h handle,
2632 bool *support_disable)
2634 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2636 if (info == NULL || info->app_info == NULL || support_disable == NULL) {
2637 _LOGE("invalid parameter");
2638 return PMINFO_R_EINVAL;
2641 *support_disable = _get_bool_value(info->app_info->support_disable);
2646 API int pkgmgrinfo_appinfo_is_disabled(pkgmgrinfo_appinfo_h handle, bool *disabled)
2648 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2649 retvm_if(disabled == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2650 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2652 if (info->app_info == NULL || info->app_info->is_disabled == NULL)
2653 return PMINFO_R_ERROR;
2655 *disabled = _get_bool_value(info->app_info->is_disabled);
2660 API int pkgmgrinfo_appinfo_is_global(pkgmgrinfo_appinfo_h handle, bool *global)
2662 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2664 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2665 retvm_if(global == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2667 if (info->app_info == NULL || info->app_info->for_all_users == NULL)
2668 return PMINFO_R_ERROR;
2670 *global = _get_bool_value(info->app_info->for_all_users);
2675 API int pkgmgrinfo_appinfo_get_splash_screen_display(pkgmgrinfo_appinfo_h handle, bool *splash_screen_display)
2677 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2679 if (info == NULL || splash_screen_display == NULL) {
2680 _LOGE("Invalid parameter");
2681 return PMINFO_R_EINVAL;
2684 if (info->app_info == NULL || info->app_info->splash_screen_display == NULL)
2685 return PMINFO_R_ERROR;
2687 *splash_screen_display = _get_bool_value(info->app_info->splash_screen_display);
2692 API int pkgmgrinfo_appinfo_destroy_appinfo(pkgmgrinfo_appinfo_h handle)
2694 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2695 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2696 __cleanup_appinfo(info);
2700 API int pkgmgrinfo_appinfo_filter_create(pkgmgrinfo_appinfo_filter_h *handle)
2702 return (pkgmgrinfo_pkginfo_filter_create(handle));
2705 API int pkgmgrinfo_appinfo_filter_destroy(pkgmgrinfo_appinfo_filter_h handle)
2707 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
2710 static gint __compare_func(gconstpointer data1, gconstpointer data2)
2712 pkgmgrinfo_node_x *node1 = (pkgmgrinfo_node_x*)data1;
2713 pkgmgrinfo_node_x *node2 = (pkgmgrinfo_node_x*)data2;
2714 if (node1->prop == node2->prop)
2716 else if (node1->prop > node2->prop)
2722 API int pkgmgrinfo_appinfo_filter_add_int(pkgmgrinfo_appinfo_filter_h handle,
2723 const char *property, const int value)
2725 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2726 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2727 char buf[PKG_VALUE_STRING_LEN_MAX] = {'\0'};
2729 GSList *link = NULL;
2731 prop = _pminfo_appinfo_convert_to_prop_int(property);
2732 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_INT ||
2733 prop > E_PMINFO_APPINFO_PROP_APP_MAX_INT) {
2734 _LOGE("Invalid Integer Property\n");
2735 return PMINFO_R_EINVAL;
2737 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
2738 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
2740 _LOGE("Out of Memory!!!\n");
2741 return PMINFO_R_ERROR;
2743 snprintf(buf, PKG_VALUE_STRING_LEN_MAX - 1, "%d", value);
2744 val = strndup(buf, PKG_VALUE_STRING_LEN_MAX - 1);
2746 _LOGE("Out of Memory\n");
2749 return PMINFO_R_ERROR;
2753 /*If API is called multiple times for same property, we should override the previous values.
2754 Last value set will be used for filtering.*/
2755 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2757 filter->list = g_slist_delete_link(filter->list, link);
2758 filter->list = g_slist_append(filter->list, (gpointer)node);
2763 API int pkgmgrinfo_appinfo_filter_add_bool(pkgmgrinfo_appinfo_filter_h handle,
2764 const char *property, const bool value)
2766 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2767 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2769 GSList *link = NULL;
2771 prop = _pminfo_appinfo_convert_to_prop_bool(property);
2772 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_BOOL ||
2773 prop > E_PMINFO_APPINFO_PROP_APP_MAX_BOOL) {
2774 _LOGE("Invalid Boolean Property\n");
2775 return PMINFO_R_EINVAL;
2777 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
2778 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
2780 _LOGE("Out of Memory!!!\n");
2781 return PMINFO_R_ERROR;
2784 val = strndup("true", 4);
2786 val = strndup("false", 5);
2788 _LOGE("Out of Memory\n");
2791 return PMINFO_R_ERROR;
2795 /*If API is called multiple times for same property, we should override the previous values.
2796 Last value set will be used for filtering.*/
2797 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2799 filter->list = g_slist_delete_link(filter->list, link);
2800 filter->list = g_slist_append(filter->list, (gpointer)node);
2805 API int pkgmgrinfo_appinfo_filter_add_string(pkgmgrinfo_appinfo_filter_h handle,
2806 const char *property, const char *value)
2808 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2809 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2810 retvm_if(value == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2812 pkgmgrinfo_node_x *ptr = NULL;
2813 char prev[PKG_STRING_LEN_MAX] = {'\0'};
2814 char temp[PKG_STRING_LEN_MAX] = {'\0'};
2815 GSList *link = NULL;
2817 prop = _pminfo_appinfo_convert_to_prop_str(property);
2818 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_STR ||
2819 prop > E_PMINFO_APPINFO_PROP_APP_MAX_STR) {
2820 _LOGE("Invalid String Property\n");
2821 return PMINFO_R_EINVAL;
2823 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
2824 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
2826 _LOGE("Out of Memory!!!\n");
2827 return PMINFO_R_ERROR;
2831 case E_PMINFO_APPINFO_PROP_APP_COMPONENT:
2832 node->value = strdup(value);
2833 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2835 filter->list = g_slist_delete_link(filter->list, link);
2836 filter->list = g_slist_append(filter->list, (gpointer)node);
2838 case E_PMINFO_APPINFO_PROP_APP_CATEGORY:
2839 val = (char *)calloc(1, PKG_STRING_LEN_MAX);
2841 _LOGE("Out of Memory\n");
2844 return PMINFO_R_ERROR;
2846 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2848 ptr = (pkgmgrinfo_node_x *)link->data;
2849 strncpy(prev, ptr->value, PKG_STRING_LEN_MAX - 1);
2850 _LOGI("Previous value is %s\n", prev);
2851 filter->list = g_slist_delete_link(filter->list, link);
2852 snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s,%s", prev, value);
2853 strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
2854 _LOGI("New value is %s\n", val);
2856 filter->list = g_slist_append(filter->list, (gpointer)node);
2857 memset(temp, '\0', PKG_STRING_LEN_MAX);
2859 snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s", value);
2860 strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
2861 _LOGI("First value is %s\n", val);
2863 filter->list = g_slist_append(filter->list, (gpointer)node);
2864 memset(temp, '\0', PKG_STRING_LEN_MAX);
2868 node->value = strndup(value, PKG_STRING_LEN_MAX - 1);
2869 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2871 filter->list = g_slist_delete_link(filter->list, link);
2872 filter->list = g_slist_append(filter->list, (gpointer)node);
2878 API int pkgmgrinfo_appinfo_usr_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count, uid_t uid)
2884 if (handle == NULL || count == NULL) {
2885 _LOGE("invalid parameter");
2886 return PMINFO_R_EINVAL;
2889 locale = _get_system_locale();
2891 return PMINFO_R_ERROR;
2893 list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
2894 __free_applications);
2897 return PMINFO_R_ERROR;
2900 ret = _appinfo_get_applications(uid, uid, locale, handle, 0, list);
2901 if (ret == PMINFO_R_OK && uid != GLOBAL_USER)
2902 ret = _appinfo_get_applications(GLOBAL_USER, uid, locale,
2905 if (ret != PMINFO_R_OK) {
2906 g_hash_table_destroy(list);
2908 return PMINFO_R_ERROR;
2911 *count = g_hash_table_size(list);
2912 g_hash_table_destroy(list);
2918 API int pkgmgrinfo_appinfo_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count)
2920 return pkgmgrinfo_appinfo_usr_filter_count(handle, count, _getuid());
2923 API int pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(
2924 pkgmgrinfo_appinfo_filter_h handle,
2925 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
2927 if (handle == NULL || app_cb == NULL) {
2928 LOGE("invalid parameter");
2929 return PMINFO_R_EINVAL;
2932 return _appinfo_get_filtered_foreach_appinfo(uid, handle, PMINFO_APPINFO_GET_ALL, app_cb,
2936 API int pkgmgrinfo_appinfo_filter_foreach_appinfo(pkgmgrinfo_appinfo_filter_h handle,
2937 pkgmgrinfo_app_list_cb app_cb, void * user_data)
2939 return pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(handle, app_cb, user_data, _getuid());
2942 API int pkgmgrinfo_appinfo_metadata_filter_create(pkgmgrinfo_appinfo_metadata_filter_h *handle)
2944 return (pkgmgrinfo_pkginfo_filter_create(handle));
2947 API int pkgmgrinfo_appinfo_metadata_filter_destroy(pkgmgrinfo_appinfo_metadata_filter_h handle)
2949 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
2952 API int pkgmgrinfo_appinfo_metadata_filter_add(
2953 pkgmgrinfo_appinfo_metadata_filter_h handle,
2954 const char *key, const char *value)
2958 ret = pkgmgrinfo_appinfo_filter_add_string(handle,
2959 PMINFO_APPINFO_PROP_APP_METADATA_KEY, key);
2960 if (ret != PMINFO_R_OK)
2963 /* value can be NULL.
2964 * In that case all apps with specified key should be displayed
2967 ret = pkgmgrinfo_appinfo_filter_add_string(handle,
2968 PMINFO_APPINFO_PROP_APP_METADATA_VALUE, value);
2969 if (ret != PMINFO_R_OK)
2976 API int pkgmgrinfo_appinfo_usr_metadata_filter_foreach(
2977 pkgmgrinfo_appinfo_metadata_filter_h handle,
2978 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
2980 if (handle == NULL || app_cb == NULL) {
2981 LOGE("invalid parameter");
2982 return PMINFO_R_EINVAL;
2985 return _appinfo_get_filtered_foreach_appinfo(uid, handle, PMINFO_APPINFO_GET_ALL, app_cb,
2989 API int pkgmgrinfo_appinfo_metadata_filter_foreach(
2990 pkgmgrinfo_appinfo_metadata_filter_h handle,
2991 pkgmgrinfo_app_list_cb app_cb, void *user_data)
2993 return pkgmgrinfo_appinfo_usr_metadata_filter_foreach(handle, app_cb,
2994 user_data, _getuid());
2997 API int pkgmgrinfo_appinfo_is_guestmode_visibility(pkgmgrinfo_appinfo_h handle, bool *status)
3000 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3002 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
3003 retvm_if(status == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3005 val = info->app_info->guestmode_visibility;
3006 *status = _get_bool_value(val);