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)
20 if (str && !strcmp(str, "true"))
26 static void __cleanup_appinfo(pkgmgr_appinfo_x *data)
28 pkgmgr_appinfo_x *info = data;
32 free((void *)info->package);
34 free((void *)info->locale);
36 pkgmgrinfo_basic_free_application(info->app_info);
42 static const char join_localized_info[] =
43 " LEFT OUTER JOIN package_app_localized_info"
44 " ON ai.app_id=package_app_localized_info.app_id"
45 " AND package_app_localized_info.app_locale=?";
46 static const char join_category[] =
47 " LEFT OUTER JOIN package_app_app_category"
48 " ON ai.app_id=package_app_app_category.app_id";
49 static const char join_app_control[] =
50 " LEFT OUTER JOIN package_app_app_control"
51 " ON ai.app_id=package_app_app_control.app_id";
52 static const char join_metadata[] =
53 " LEFT OUTER JOIN package_app_app_metadata"
54 " ON ai.app_id=package_app_app_metadata.app_id ";
56 static int _get_filtered_query(pkgmgrinfo_filter_x *filter,
57 const char *locale, char **query, GList **bind_params)
61 char *condition = NULL;
62 char buf[MAX_QUERY_LEN] = { '\0' };
63 char tmp_query[MAX_QUERY_LEN] = { '\0' };
69 len += strlen(" WHERE 1=1");
70 strncat(buf, " WHERE 1=1", MAX_QUERY_LEN - len - 1);
71 for (list = filter->list; list; list = list->next) {
72 joined |= __get_filter_condition(list->data, &condition, bind_params);
73 if (condition == NULL)
76 len += strlen(" AND ");
77 strncat(buf, " AND ", MAX_QUERY_LEN - len - 1);
79 len += strlen(condition);
80 strncat(buf, condition, sizeof(buf) - len - 1);
85 if (joined & E_PMINFO_APPINFO_JOIN_LOCALIZED_INFO) {
86 strncat(tmp_query, join_localized_info, MAX_QUERY_LEN - len - 1);
87 len += strlen(join_localized_info);
88 *bind_params = g_list_append(*bind_params, strdup(locale));
90 if (joined & E_PMINFO_APPINFO_JOIN_CATEGORY) {
91 strncat(tmp_query, join_category, MAX_QUERY_LEN - len - 1);
92 len += strlen(join_category);
94 if (joined & E_PMINFO_APPINFO_JOIN_APP_CONTROL) {
95 strncat(tmp_query, join_app_control, MAX_QUERY_LEN - len - 1);
96 len += strlen(join_app_control);
98 if (joined & E_PMINFO_APPINFO_JOIN_METADATA) {
99 strncat(tmp_query, join_metadata, MAX_QUERY_LEN - len - 1);
100 len += strlen(join_metadata);
102 strncat(tmp_query, buf, MAX_QUERY_LEN - len - 1);
104 *query = strdup(tmp_query);
106 return PMINFO_R_ERROR;
111 static int _appinfo_get_label(sqlite3 *db, const char *appid,
112 const char *locale, GList **label)
114 static const char query_raw[] =
115 "SELECT app_label, app_locale "
116 "FROM package_app_localized_info "
117 "WHERE app_id=%Q AND app_locale IN (%Q, %Q)";
124 query = sqlite3_mprintf(query_raw, appid, locale, DEFAULT_LOCALE);
126 LOGE("out of memory");
127 return PMINFO_R_ERROR;
130 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
132 if (ret != SQLITE_OK) {
133 LOGE("prepare failed: %s", sqlite3_errmsg(db));
134 return PMINFO_R_ERROR;
137 while (sqlite3_step(stmt) == SQLITE_ROW) {
138 info = calloc(1, sizeof(label_x));
140 LOGE("out of memory");
141 sqlite3_finalize(stmt);
142 return PMINFO_R_ERROR;
145 _save_column_str(stmt, idx++, &info->text);
146 _save_column_str(stmt, idx++, &info->lang);
147 *label = g_list_append(*label, info);
150 sqlite3_finalize(stmt);
155 static int _appinfo_get_icon(sqlite3 *db, const char *appid, const char *locale,
158 static const char query_raw[] =
159 "SELECT app_icon, app_locale "
160 "FROM package_app_localized_info "
161 "WHERE app_id=%Q AND app_locale IN (%Q, %Q)";
168 query = sqlite3_mprintf(query_raw, appid, locale, DEFAULT_LOCALE);
170 LOGE("out of memory");
171 return PMINFO_R_ERROR;
174 ret = sqlite3_prepare_v2(db, query, strlen(query),
177 if (ret != SQLITE_OK) {
178 LOGE("prepare failed: %s", sqlite3_errmsg(db));
179 return PMINFO_R_ERROR;
182 while (sqlite3_step(stmt) == SQLITE_ROW) {
183 info = calloc(1, sizeof(icon_x));
185 LOGE("out of memory");
186 sqlite3_finalize(stmt);
187 return PMINFO_R_ERROR;
190 _save_column_str(stmt, idx++, &info->text);
191 _save_column_str(stmt, idx++, &info->lang);
192 *icon = g_list_append(*icon, info);
195 sqlite3_finalize(stmt);
200 static int _appinfo_get_category(sqlite3 *db, const char *appid,
203 static const char query_raw[] =
204 "SELECT category FROM package_app_app_category WHERE app_id=%Q";
210 query = sqlite3_mprintf(query_raw, appid);
212 LOGE("out of memory");
213 return PMINFO_R_ERROR;
216 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
218 if (ret != SQLITE_OK) {
219 LOGE("prepare failed: %s", sqlite3_errmsg(db));
220 return PMINFO_R_ERROR;
223 while (sqlite3_step(stmt) == SQLITE_ROW) {
225 _save_column_str(stmt, 0, &val);
227 *category = g_list_append(*category, (gpointer)val);
230 sqlite3_finalize(stmt);
235 static void __parse_appcontrol(GList **appcontrol, char *appcontrol_str)
242 if (appcontrol_str == NULL)
245 dup = strdup(appcontrol_str);
247 ac = calloc(1, sizeof(appcontrol_x));
249 _LOGE("out of memory");
252 token = strtok_r(dup, "|", &ptr);
253 if (token && strcmp(token, "NULL"))
254 ac->operation = strdup(token);
255 token = strtok_r(NULL, "|", &ptr);
256 if (token && strcmp(token, "NULL"))
257 ac->uri = strdup(token);
258 token = strtok_r(NULL, "|", &ptr);
259 if (token && strcmp(token, "NULL"))
260 ac->mime = strdup(token);
261 *appcontrol = g_list_append(*appcontrol, ac);
262 } while ((token = strtok_r(NULL, ";", &ptr)));
267 static int _appinfo_get_app_control(sqlite3 *db, const char *appid,
270 static const char query_raw[] =
271 "SELECT app_control FROM package_app_app_control "
278 query = sqlite3_mprintf(query_raw, appid);
280 LOGE("out of memory");
281 return PMINFO_R_ERROR;
284 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
286 if (ret != SQLITE_OK) {
287 LOGE("prepare failed: %s", sqlite3_errmsg(db));
288 return PMINFO_R_ERROR;
291 while (sqlite3_step(stmt) == SQLITE_ROW) {
293 _save_column_str(stmt, 0, &str);
295 __parse_appcontrol(appcontrol, str);
299 sqlite3_finalize(stmt);
304 static int _appinfo_get_data_control(sqlite3 *db, const char *appid,
307 static const char query_raw[] =
308 "SELECT providerid, access, type "
309 "FROM package_app_data_control WHERE app_id=%Q";
316 query = sqlite3_mprintf(query_raw, appid);
318 LOGE("out of memory");
319 return PMINFO_R_ERROR;
322 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
324 if (ret != SQLITE_OK) {
325 LOGE("prepare failed: %s", sqlite3_errmsg(db));
326 return PMINFO_R_ERROR;
329 while (sqlite3_step(stmt) == SQLITE_ROW) {
330 info = calloc(1, sizeof(datacontrol_x));
332 LOGE("out of memory");
333 sqlite3_finalize(stmt);
334 return PMINFO_R_ERROR;
337 _save_column_str(stmt, idx++, &info->providerid);
338 _save_column_str(stmt, idx++, &info->access);
339 _save_column_str(stmt, idx++, &info->type);
340 *datacontrol = g_list_append(*datacontrol, info);
343 sqlite3_finalize(stmt);
348 static int _appinfo_get_metadata(sqlite3 *db, const char *appid,
351 static const char query_raw[] =
352 "SELECT md_key, md_value "
353 "FROM package_app_app_metadata WHERE app_id=%Q";
360 query = sqlite3_mprintf(query_raw, appid);
362 LOGE("out of memory");
363 return PMINFO_R_ERROR;
366 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
368 if (ret != SQLITE_OK) {
369 LOGE("prepare failed: %s", sqlite3_errmsg(db));
370 return PMINFO_R_ERROR;
373 while (sqlite3_step(stmt) == SQLITE_ROW) {
374 info = calloc(1, sizeof(metadata_x));
376 LOGE("out of memory");
377 sqlite3_finalize(stmt);
378 return PMINFO_R_ERROR;
381 _save_column_str(stmt, idx++, &info->key);
382 _save_column_str(stmt, idx++, &info->value);
383 *metadata = g_list_append(*metadata, info);
386 sqlite3_finalize(stmt);
392 static int _appinfo_get_splashscreens(sqlite3 *db, const char *appid,
393 GList **splashscreens)
395 static const char query_raw[] =
396 "SELECT src, type, orientation, indicatordisplay, operation, color_depth "
397 "FROM package_app_splash_screen WHERE app_id=%Q";
402 splashscreen_x *info;
404 query = sqlite3_mprintf(query_raw, appid);
406 LOGE("out of memory");
407 return PMINFO_R_ERROR;
410 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
412 if (ret != SQLITE_OK) {
413 LOGE("prepare failed: %s", sqlite3_errmsg(db));
414 return PMINFO_R_ERROR;
417 while (sqlite3_step(stmt) == SQLITE_ROW) {
418 info = calloc(1, sizeof(splashscreen_x));
420 LOGE("out of memory");
421 sqlite3_finalize(stmt);
422 return PMINFO_R_ERROR;
425 _save_column_str(stmt, idx++, &info->src);
426 _save_column_str(stmt, idx++, &info->type);
427 _save_column_str(stmt, idx++, &info->orientation);
428 _save_column_str(stmt, idx++, &info->indicatordisplay);
429 _save_column_str(stmt, idx++, &info->operation);
430 _save_column_str(stmt, idx++, &info->color_depth);
431 *splashscreens = g_list_append(*splashscreens, info);
434 sqlite3_finalize(stmt);
439 static GList *__get_background_category(const char *value)
441 GList *category_list = NULL;
442 int convert_value = 0;
443 if (!value || strlen(value) == 0)
446 convert_value = atoi(value);
447 if (convert_value < 0)
450 if (convert_value & APP_BG_CATEGORY_USER_DISABLE_TRUE_VAL)
451 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_USER_DISABLE_TRUE_STR));
453 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_USER_DISABLE_FALSE_STR));
455 if (convert_value & APP_BG_CATEGORY_MEDIA_VAL)
456 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_MEDIA_STR));
458 if (convert_value & APP_BG_CATEGORY_DOWNLOAD_VAL)
459 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_DOWNLOAD_STR));
461 if (convert_value & APP_BG_CATEGORY_BGNETWORK_VAL)
462 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_BGNETWORK_STR));
464 if (convert_value & APP_BG_CATEGORY_LOCATION_VAL)
465 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_LOCATION_STR));
467 if (convert_value & APP_BG_CATEGORY_SENSOR_VAL)
468 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_SENSOR_STR));
470 if (convert_value & APP_BG_CATEGORY_IOTCOMM_VAL)
471 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_IOTCOMM_STR));
473 if (convert_value & APP_BG_CATEGORY_SYSTEM_VAL)
474 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_SYSTEM));
476 return category_list;
480 static void __get_splash_screen_display(sqlite3 *db, const char *appid, uid_t uid, char **value)
482 static const char query_raw[] =
483 "SELECT is_splash_screen_enabled FROM package_app_info_for_uid "
484 "WHERE app_id='%s' AND uid='%d'";
489 query = sqlite3_mprintf(query_raw, appid, uid);
491 LOGE("out of memory");
495 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
497 if (ret != SQLITE_OK) {
498 LOGE("sqlite3_prepare_v2() failed: %s", sqlite3_errmsg(db));
502 while (sqlite3_step(stmt) == SQLITE_ROW) {
505 _save_column_str(stmt, 0, value);
508 sqlite3_finalize(stmt);
511 static void __free_applications(gpointer data)
513 pkgmgrinfo_basic_free_application((application_x *)data);
516 static int __bind_params(sqlite3_stmt *stmt, GList *params)
518 GList *tmp_list = NULL;
522 if (stmt == NULL || params == NULL)
523 return PMINFO_R_EINVAL;
527 ret = sqlite3_bind_text(stmt, ++idx, (char *)tmp_list->data, -1, SQLITE_STATIC);
528 if (ret != SQLITE_OK)
529 return PMINFO_R_ERROR;
530 tmp_list = tmp_list->next;
536 static int _appinfo_get_applications(uid_t db_uid, uid_t uid,
537 const char *locale, pkgmgrinfo_filter_x *filter, int flag,
538 GHashTable *applications)
540 static const char query_raw[] =
541 "SELECT DISTINCT ai.app_id, ai.app_component, ai.app_exec, "
542 "ai.app_nodisplay, ai.app_type, ai.app_onboot, "
543 "ai.app_multiple, ai.app_autorestart, ai.app_taskmanage, "
544 "ai.app_enabled, ai.app_hwacceleration, ai.app_screenreader, "
545 "ai.app_mainapp, ai.app_recentimage, ai.app_launchcondition, "
546 "ai.app_indicatordisplay, ai.app_portraitimg, "
547 "ai.app_landscapeimg, ai.app_guestmodevisibility, "
548 "ai.app_permissiontype, ai.app_preload, ai.app_submode, "
549 "ai.app_submode_mainid, ai.app_launch_mode, ai.app_ui_gadget, "
550 "ai.app_support_disable, ai.app_process_pool, "
551 "ai.app_installed_storage, ai.app_background_category, "
552 "ai.app_package_type, ai.app_root_path, ai.app_api_version, "
553 "ai.app_effective_appid, ai.app_disable, "
554 "ai.app_splash_screen_display, ai.app_tep_name, "
555 "ai.app_zip_mount_file, ai.component_type, ai.package "
556 "FROM package_app_info as ai";
557 int ret = PMINFO_R_ERROR;
560 char *bg_category_str = NULL;
561 char *constraint = NULL;
562 char query[MAX_QUERY_LEN] = { '\0' };
563 application_x *info = NULL;
564 GList *bind_params = NULL;
566 sqlite3_stmt *stmt = NULL;
568 dbpath = getUserPkgParserDBPathUID(db_uid);
570 return PMINFO_R_ERROR;
572 ret = sqlite3_open_v2(dbpath, &db, SQLITE_OPEN_READONLY, NULL);
573 if (ret != SQLITE_OK) {
574 _LOGE("failed to open db: %d", ret);
575 return PMINFO_R_ERROR;
578 ret = _get_filtered_query(filter, locale, &constraint, &bind_params);
579 if (ret != PMINFO_R_OK) {
580 LOGE("Failed to get WHERE clause");
585 snprintf(query, MAX_QUERY_LEN - 1, "%s%s", query_raw, constraint);
587 snprintf(query, MAX_QUERY_LEN - 1, "%s", query_raw);
589 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
590 if (ret != SQLITE_OK) {
591 LOGE("prepare failed: %s", sqlite3_errmsg(db));
592 ret = PMINFO_R_ERROR;
596 if (g_list_length(bind_params) != 0) {
597 ret = __bind_params(stmt, bind_params);
598 if (ret != SQLITE_OK) {
599 LOGE("Failed to bind parameters");
604 while (sqlite3_step(stmt) == SQLITE_ROW) {
605 info = calloc(1, sizeof(application_x));
607 LOGE("out of memory");
608 ret = PMINFO_R_ERROR;
612 _save_column_str(stmt, idx++, &info->appid);
613 if (g_hash_table_contains(applications,
614 (gconstpointer)info->appid)) {
619 _save_column_str(stmt, idx++, &info->component);
620 _save_column_str(stmt, idx++, &info->exec);
621 _save_column_str(stmt, idx++, &info->nodisplay);
622 _save_column_str(stmt, idx++, &info->type);
623 _save_column_str(stmt, idx++, &info->onboot);
624 _save_column_str(stmt, idx++, &info->multiple);
625 _save_column_str(stmt, idx++, &info->autorestart);
626 _save_column_str(stmt, idx++, &info->taskmanage);
627 _save_column_str(stmt, idx++, &info->enabled);
628 _save_column_str(stmt, idx++, &info->hwacceleration);
629 _save_column_str(stmt, idx++, &info->screenreader);
630 _save_column_str(stmt, idx++, &info->mainapp);
631 _save_column_str(stmt, idx++, &info->recentimage);
632 _save_column_str(stmt, idx++, &info->launchcondition);
633 _save_column_str(stmt, idx++, &info->indicatordisplay);
634 _save_column_str(stmt, idx++, &info->portraitimg);
635 _save_column_str(stmt, idx++, &info->landscapeimg);
636 _save_column_str(stmt, idx++, &info->guestmode_visibility);
637 _save_column_str(stmt, idx++, &info->permission_type);
638 _save_column_str(stmt, idx++, &info->preload);
639 _save_column_str(stmt, idx++, &info->submode);
640 _save_column_str(stmt, idx++, &info->submode_mainid);
641 _save_column_str(stmt, idx++, &info->launch_mode);
642 _save_column_str(stmt, idx++, &info->ui_gadget);
643 _save_column_str(stmt, idx++, &info->support_disable);
644 _save_column_str(stmt, idx++, &info->process_pool);
645 _save_column_str(stmt, idx++, &info->installed_storage);
646 _save_column_str(stmt, idx++, &bg_category_str);
647 _save_column_str(stmt, idx++, &info->package_type);
648 _save_column_str(stmt, idx++, &info->root_path);
649 _save_column_str(stmt, idx++, &info->api_version);
650 _save_column_str(stmt, idx++, &info->effective_appid);
651 _save_column_str(stmt, idx++, &info->is_disabled);
652 _save_column_str(stmt, idx++, &info->splash_screen_display);
653 _save_column_str(stmt, idx++, &info->tep_name);
654 _save_column_str(stmt, idx++, &info->zip_mount_file);
655 _save_column_str(stmt, idx++, &info->component_type);
656 _save_column_str(stmt, idx++, &info->package);
657 info->for_all_users =
658 strdup((uid != GLOBAL_USER) ? "false" : "true");
660 if (db_uid == GLOBAL_USER)
661 __get_splash_screen_display(db, info->appid, db_uid,
662 &info->splash_screen_display);
664 info->background_category = __get_background_category(
666 free(bg_category_str);
668 if (flag & PMINFO_APPINFO_GET_LABEL) {
669 if (_appinfo_get_label(db, info->appid, locale,
671 ret = PMINFO_R_ERROR;
676 if (flag & PMINFO_APPINFO_GET_ICON) {
677 if (_appinfo_get_icon(db, info->appid, locale,
679 ret = PMINFO_R_ERROR;
684 if (flag & PMINFO_APPINFO_GET_CATEGORY) {
685 if (_appinfo_get_category(db, info->appid,
687 ret = PMINFO_R_ERROR;
692 if (flag & PMINFO_APPINFO_GET_APP_CONTROL) {
693 if (_appinfo_get_app_control(db, info->appid,
694 &info->appcontrol)) {
695 ret = PMINFO_R_ERROR;
700 if (flag & PMINFO_APPINFO_GET_DATA_CONTROL) {
701 if (_appinfo_get_data_control(db, info->appid,
702 &info->datacontrol)) {
703 ret = PMINFO_R_ERROR;
708 if (flag & PMINFO_APPINFO_GET_METADATA) {
709 if (_appinfo_get_metadata(db, info->appid,
711 ret = PMINFO_R_ERROR;
716 if (flag & PMINFO_APPINFO_GET_SPLASH_SCREEN) {
717 if (_appinfo_get_splashscreens(db, info->appid,
718 &info->splashscreens)) {
719 ret = PMINFO_R_ERROR;
724 g_hash_table_insert(applications, (gpointer)info->appid,
734 if (ret != PMINFO_R_OK && info != NULL)
735 pkgmgrinfo_basic_free_application(info);
737 g_list_free_full(bind_params, free);
738 sqlite3_close_v2(db);
739 sqlite3_finalize(stmt);
744 API int pkgmgrinfo_appinfo_get_usr_disabled_appinfo(const char *appid, uid_t uid,
745 pkgmgrinfo_appinfo_h *handle)
750 pkgmgrinfo_appinfo_filter_h filter;
751 pkgmgr_appinfo_x *info;
753 if (appid == NULL || handle == NULL) {
754 LOGE("invalid parameter");
755 return PMINFO_R_EINVAL;
758 locale = _get_system_locale();
760 return PMINFO_R_ERROR;
762 ret = pkgmgrinfo_appinfo_filter_create(&filter);
763 if (ret != PMINFO_R_OK) {
768 ret = pkgmgrinfo_appinfo_filter_add_string(filter,
769 PMINFO_APPINFO_PROP_APP_ID, appid);
770 if (ret != PMINFO_R_OK) {
771 pkgmgrinfo_appinfo_filter_destroy(filter);
773 return PMINFO_R_ERROR;
776 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
777 PMINFO_APPINFO_PROP_APP_DISABLE, true);
778 if (ret != PMINFO_R_OK) {
779 pkgmgrinfo_appinfo_filter_destroy(filter);
781 return PMINFO_R_ERROR;
784 list = g_hash_table_new(g_str_hash, g_str_equal);
786 pkgmgrinfo_appinfo_filter_destroy(filter);
788 return PMINFO_R_ERROR;
791 ret = _appinfo_get_applications(uid, uid, locale, filter,
792 PMINFO_APPINFO_GET_ALL, list);
793 if (!g_hash_table_size(list) && uid != GLOBAL_USER)
794 ret = _appinfo_get_applications(GLOBAL_USER, uid, locale,
795 filter, PMINFO_APPINFO_GET_ALL, list);
797 pkgmgrinfo_appinfo_filter_destroy(filter);
798 if (ret != PMINFO_R_OK) {
799 g_hash_table_destroy(list);
804 if (!g_hash_table_size(list)) {
805 _LOGI("Appinfo for [%s] is not existed for user [%d]",
807 g_hash_table_destroy(list);
809 return PMINFO_R_ENOENT;
812 info = calloc(1, sizeof(pkgmgr_appinfo_x));
814 _LOGE("out of memory");
816 return PMINFO_R_ERROR;
819 info->app_info = (application_x *)g_hash_table_lookup(list, appid);
820 info->locale = locale;
821 info->package = strdup(info->app_info->package);
823 /* just free list only */
824 g_hash_table_destroy(list);
831 API int pkgmgrinfo_appinfo_get_disabled_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
833 return pkgmgrinfo_appinfo_get_usr_disabled_appinfo(appid, _getuid(), handle);
836 API int pkgmgrinfo_appinfo_get_usr_appinfo(const char *appid, uid_t uid,
837 pkgmgrinfo_appinfo_h *handle)
842 pkgmgrinfo_appinfo_filter_h filter;
843 pkgmgr_appinfo_x *info;
845 if (appid == NULL || handle == NULL) {
846 LOGE("invalid parameter");
847 return PMINFO_R_EINVAL;
850 locale = _get_system_locale();
852 return PMINFO_R_ERROR;
854 ret = pkgmgrinfo_appinfo_filter_create(&filter);
855 if (ret != PMINFO_R_OK) {
860 ret = pkgmgrinfo_appinfo_filter_add_string(filter,
861 PMINFO_APPINFO_PROP_APP_ID, appid);
862 if (ret != PMINFO_R_OK) {
863 pkgmgrinfo_appinfo_filter_destroy(filter);
865 return PMINFO_R_ERROR;
868 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
869 PMINFO_APPINFO_PROP_APP_DISABLE, false);
870 if (ret != PMINFO_R_OK) {
871 pkgmgrinfo_appinfo_filter_destroy(filter);
873 return PMINFO_R_ERROR;
876 list = g_hash_table_new(g_str_hash, g_str_equal);
878 pkgmgrinfo_appinfo_filter_destroy(filter);
880 return PMINFO_R_ERROR;
883 ret = _appinfo_get_applications(uid, uid, locale, filter,
884 PMINFO_APPINFO_GET_ALL, list);
885 if (!g_hash_table_size(list) && uid != GLOBAL_USER)
886 ret = _appinfo_get_applications(GLOBAL_USER, uid, locale,
887 filter, PMINFO_APPINFO_GET_ALL, list);
889 pkgmgrinfo_appinfo_filter_destroy(filter);
890 if (ret != PMINFO_R_OK) {
891 g_hash_table_destroy(list);
896 if (!g_hash_table_size(list)) {
897 _LOGI("Appinfo for [%s] is not existed for user [%d]", appid, uid);
898 g_hash_table_destroy(list);
900 return PMINFO_R_ENOENT;
903 info = calloc(1, sizeof(pkgmgr_appinfo_x));
905 _LOGE("out of memory");
907 return PMINFO_R_ERROR;
910 info->app_info = (application_x *)g_hash_table_lookup(list, appid);
911 info->locale = locale;
912 info->package = strdup(info->app_info->package);
914 /* just free list only */
915 g_hash_table_destroy(list);
922 API int pkgmgrinfo_appinfo_get_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
924 return pkgmgrinfo_appinfo_get_usr_appinfo(appid, _getuid(), handle);
927 static gpointer __copy_str(gconstpointer src, gpointer data)
929 const char *tmp = (const char *)src;
932 buffer = strdup(tmp);
933 if (buffer == NULL) {
934 LOGE("memory alloc failed");
942 static gpointer __copy_label(gconstpointer src, gpointer data)
944 label_x *tmp = (label_x *)src;
947 label = calloc(1, sizeof(label_x));
949 LOGE("memory alloc failed");
955 label->name = strdup(tmp->name);
957 label->text = strdup(tmp->text);
959 label->lang = strdup(tmp->lang);
964 static gpointer __copy_icon(gconstpointer src, gpointer data)
966 icon_x *tmp = (icon_x *)src;
969 icon = calloc(1, sizeof(icon_x));
971 LOGE("memory alloc failed");
977 icon->text = strdup(tmp->text);
979 icon->lang = strdup(tmp->lang);
981 icon->section = strdup(tmp->section);
983 icon->size = strdup(tmp->size);
985 icon->resolution = strdup(tmp->resolution);
990 static gpointer __copy_metadata(gconstpointer src, gpointer data)
992 metadata_x *tmp = (metadata_x *)src;
993 metadata_x *metadata;
995 metadata = calloc(1, sizeof(metadata_x));
996 if (metadata == NULL) {
997 LOGE("memory alloc failed");
1003 metadata->key = strdup(tmp->key);
1005 metadata->value = strdup(tmp->value);
1010 static gpointer __copy_datacontrol(gconstpointer src, gpointer data)
1012 datacontrol_x *tmp = (datacontrol_x *)src;
1013 datacontrol_x *datacontrol;
1015 datacontrol = calloc(1, sizeof(datacontrol_x));
1016 if (datacontrol == NULL) {
1017 LOGE("memory alloc failed");
1022 if (tmp->providerid)
1023 datacontrol->providerid = strdup(tmp->providerid);
1025 datacontrol->access = strdup(tmp->access);
1027 datacontrol->type = strdup(tmp->type);
1032 static gpointer __copy_appcontrol(gconstpointer src, gpointer data)
1034 appcontrol_x *tmp = (appcontrol_x *)src;
1035 appcontrol_x *appcontrol;
1037 appcontrol = calloc(1, sizeof(appcontrol_x));
1038 if (appcontrol == NULL) {
1039 LOGE("memory alloc failed");
1045 appcontrol->operation = strdup(tmp->operation);
1047 appcontrol->uri = strdup(tmp->uri);
1049 appcontrol->mime = strdup(tmp->mime);
1054 static gpointer __copy_splashscreens(gconstpointer src, gpointer data)
1056 splashscreen_x *tmp = (splashscreen_x *)src;
1057 splashscreen_x *splashscreen;
1059 splashscreen = (splashscreen_x *)calloc(1, sizeof(splashscreen_x));
1060 if (splashscreen == NULL) {
1061 LOGE("memory alloc failed");
1067 splashscreen->src = strdup(tmp->src);
1069 splashscreen->type = strdup(tmp->type);
1070 if (tmp->orientation)
1071 splashscreen->orientation = strdup(tmp->orientation);
1072 if (tmp->indicatordisplay)
1073 splashscreen->indicatordisplay = strdup(tmp->indicatordisplay);
1075 splashscreen->operation = strdup(tmp->operation);
1076 if (tmp->color_depth)
1077 splashscreen->color_depth = strdup(tmp->color_depth);
1079 return splashscreen;
1082 static int _appinfo_copy_appinfo(application_x **application, application_x *data)
1084 application_x *app_info;
1087 app_info = calloc(1, sizeof(application_x));
1088 if (app_info == NULL) {
1089 LOGE("memory alloc failed");
1090 return PMINFO_R_ERROR;
1093 if (data->appid != NULL)
1094 app_info->appid = strdup(data->appid);
1095 if (data->exec != NULL)
1096 app_info->exec = strdup(data->exec);
1097 if (data->nodisplay != NULL)
1098 app_info->nodisplay = strdup(data->nodisplay);
1099 if (data->multiple != NULL)
1100 app_info->multiple = strdup(data->multiple);
1101 if (data->taskmanage != NULL)
1102 app_info->taskmanage = strdup(data->taskmanage);
1103 if (data->enabled != NULL)
1104 app_info->enabled = strdup(data->enabled);
1105 if (data->type != NULL)
1106 app_info->type = strdup(data->type);
1107 if (data->categories != NULL)
1108 app_info->categories = strdup(data->categories);
1109 if (data->hwacceleration != NULL)
1110 app_info->hwacceleration = strdup(data->hwacceleration);
1111 if (data->screenreader != NULL)
1112 app_info->screenreader = strdup(data->screenreader);
1113 if (data->mainapp != NULL)
1114 app_info->mainapp = strdup(data->mainapp);
1115 if (data->package != NULL)
1116 app_info->package = strdup(data->package);
1117 if (data->recentimage != NULL)
1118 app_info->recentimage = strdup(data->recentimage);
1119 if (data->launchcondition != NULL)
1120 app_info->launchcondition = strdup(data->launchcondition);
1121 if (data->indicatordisplay != NULL)
1122 app_info->indicatordisplay = strdup(data->indicatordisplay);
1123 if (data->portraitimg != NULL)
1124 app_info->portraitimg = strdup(data->portraitimg);
1125 if (data->landscapeimg != NULL)
1126 app_info->landscapeimg = strdup(data->landscapeimg);
1127 if (data->guestmode_visibility != NULL)
1128 app_info->guestmode_visibility = strdup(data->guestmode_visibility);
1129 if (data->component != NULL)
1130 app_info->component = strdup(data->component);
1131 if (data->permission_type != NULL)
1132 app_info->permission_type = strdup(data->permission_type);
1133 if (data->component_type != NULL)
1134 app_info->component_type = strdup(data->component_type);
1135 if (data->preload != NULL)
1136 app_info->preload = strdup(data->preload);
1137 if (data->submode != NULL)
1138 app_info->submode = strdup(data->submode);
1139 if (data->submode_mainid != NULL)
1140 app_info->submode_mainid = strdup(data->submode_mainid);
1141 if (data->process_pool != NULL)
1142 app_info->process_pool = strdup(data->process_pool);
1143 if (data->installed_storage != NULL)
1144 app_info->installed_storage = strdup(data->installed_storage);
1145 if (data->autorestart != NULL)
1146 app_info->autorestart = strdup(data->autorestart);
1147 if (data->onboot != NULL)
1148 app_info->onboot = strdup(data->onboot);
1149 if (data->support_disable != NULL)
1150 app_info->support_disable = strdup(data->support_disable);
1151 if (data->ui_gadget != NULL)
1152 app_info->ui_gadget = strdup(data->ui_gadget);
1153 if (data->launch_mode != NULL)
1154 app_info->launch_mode = strdup(data->launch_mode);
1155 if (data->package_type != NULL)
1156 app_info->package_type = strdup(data->package_type);
1157 if (data->effective_appid != NULL)
1158 app_info->effective_appid = strdup(data->effective_appid);
1159 if (data->splash_screen_display != NULL)
1160 app_info->splash_screen_display = strdup(data->splash_screen_display);
1164 app_info->label = g_list_copy_deep(data->label, __copy_label, &ret);
1166 LOGE("memory alloc failed");
1167 pkgmgrinfo_basic_free_application(app_info);
1168 return PMINFO_R_ERROR;
1172 app_info->icon = g_list_copy_deep(data->icon, __copy_icon, &ret);
1174 LOGE("memory alloc failed");
1175 pkgmgrinfo_basic_free_application(app_info);
1176 return PMINFO_R_ERROR;
1180 app_info->category = g_list_copy_deep(data->category, __copy_str, &ret);
1182 LOGE("memory alloc failed");
1183 pkgmgrinfo_basic_free_application(app_info);
1184 return PMINFO_R_ERROR;
1188 app_info->metadata = g_list_copy_deep(data->metadata, __copy_metadata, &ret);
1190 LOGE("memory alloc failed");
1191 pkgmgrinfo_basic_free_application(app_info);
1192 return PMINFO_R_ERROR;
1196 app_info->datacontrol = g_list_copy_deep(data->datacontrol, __copy_datacontrol, &ret);
1198 LOGE("memory alloc failed");
1199 pkgmgrinfo_basic_free_application(app_info);
1200 return PMINFO_R_ERROR;
1204 app_info->appcontrol = g_list_copy_deep(data->appcontrol, __copy_appcontrol, &ret);
1206 LOGE("memory alloc failed");
1207 pkgmgrinfo_basic_free_application(app_info);
1208 return PMINFO_R_ERROR;
1212 app_info->background_category = g_list_copy_deep(data->background_category, __copy_str, &ret);
1214 LOGE("memory alloc failed");
1215 pkgmgrinfo_basic_free_application(app_info);
1216 return PMINFO_R_ERROR;
1220 app_info->splashscreens = g_list_copy_deep(data->splashscreens, __copy_splashscreens, &ret);
1222 LOGE("memory alloc failed");
1223 pkgmgrinfo_basic_free_application(app_info);
1224 return PMINFO_R_ERROR;
1227 *application = app_info;
1232 API int pkgmgrinfo_appinfo_clone_appinfo(pkgmgrinfo_appinfo_h handle,
1233 pkgmgrinfo_appinfo_h *clone)
1235 pkgmgr_appinfo_x *info;
1236 pkgmgr_appinfo_x *temp = (pkgmgr_appinfo_x *)handle;
1239 return PMINFO_R_EINVAL;
1241 info = calloc(1, sizeof(pkgmgr_appinfo_x));
1243 LOGE("memory alloc failed");
1244 return PMINFO_R_ERROR;
1247 if (temp->package != NULL)
1248 info->package = strdup(temp->package);
1249 if (temp->locale != NULL)
1250 info->locale = strdup(temp->locale);
1252 info->app_component = temp->app_component;
1254 if (_appinfo_copy_appinfo(&info->app_info, temp->app_info) < 0) {
1255 LOGE("appinfo copy failed");
1257 free((void *)info->package);
1261 return PMINFO_R_ERROR;
1269 static int _appinfo_get_filtered_foreach_appinfo(uid_t uid,
1270 pkgmgrinfo_filter_x *filter, int flag, pkgmgrinfo_app_list_cb app_list_cb,
1276 pkgmgr_appinfo_x info;
1278 GHashTableIter iter;
1281 locale = _get_system_locale();
1283 return PMINFO_R_ERROR;
1285 list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
1286 __free_applications);
1289 return PMINFO_R_ERROR;
1292 ret = _appinfo_get_applications(uid, uid, locale, filter, flag, list);
1293 if (ret == PMINFO_R_OK && uid != GLOBAL_USER)
1294 ret = _appinfo_get_applications(GLOBAL_USER, uid, locale,
1295 filter, flag, list);
1297 if (ret != PMINFO_R_OK) {
1298 g_hash_table_destroy(list);
1303 g_hash_table_iter_init(&iter, list);
1304 while (g_hash_table_iter_next(&iter, NULL, &value)) {
1305 app = (application_x *)value;
1306 info.app_info = app;
1307 info.locale = locale;
1308 info.package = app->package;
1309 if (app_list_cb(&info, user_data) < 0)
1312 g_hash_table_destroy(list);
1318 static const char *__appcomponent_str(pkgmgrinfo_app_component comp);
1320 API int pkgmgrinfo_appinfo_get_usr_list(pkgmgrinfo_pkginfo_h handle,
1321 pkgmgrinfo_app_component component,
1322 pkgmgrinfo_app_list_cb app_func, void *user_data, uid_t uid)
1325 pkgmgrinfo_appinfo_filter_h filter;
1327 const char *comp_str = NULL;
1329 if (handle == NULL || app_func == NULL) {
1330 LOGE("invalid parameter");
1331 return PMINFO_R_EINVAL;
1334 if (pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid)) {
1335 LOGE("invalid parameter");
1336 return PMINFO_R_EINVAL;
1339 if (pkgmgrinfo_appinfo_filter_create(&filter))
1340 return PMINFO_R_ERROR;
1342 if (pkgmgrinfo_appinfo_filter_add_string(filter,
1343 PMINFO_APPINFO_PROP_APP_PACKAGE, pkgid)) {
1344 pkgmgrinfo_appinfo_filter_destroy(filter);
1345 return PMINFO_R_ERROR;
1348 if (uid == GLOBAL_USER) {
1349 if (pkgmgrinfo_appinfo_filter_add_int(filter,
1350 PMINFO_APPINFO_PROP_APP_DISABLE_FOR_USER,
1352 pkgmgrinfo_appinfo_filter_destroy(filter);
1353 return PMINFO_R_ERROR;
1357 comp_str = __appcomponent_str(component);
1360 if (pkgmgrinfo_appinfo_filter_add_string(filter,
1361 PMINFO_APPINFO_PROP_APP_COMPONENT,
1363 pkgmgrinfo_appinfo_filter_destroy(filter);
1364 return PMINFO_R_ERROR;
1368 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter,
1369 PMINFO_APPINFO_GET_ALL, app_func, user_data);
1371 pkgmgrinfo_appinfo_filter_destroy(filter);
1376 API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle,
1377 pkgmgrinfo_app_component component,
1378 pkgmgrinfo_app_list_cb app_func, void *user_data)
1380 return pkgmgrinfo_appinfo_get_usr_list(handle, component, app_func, user_data, _getuid());
1383 API int pkgmgrinfo_appinfo_get_usr_installed_list_full(
1384 pkgmgrinfo_app_list_cb app_func, uid_t uid, int flag,
1388 pkgmgrinfo_appinfo_filter_h filter;
1390 if (app_func == NULL) {
1391 LOGE("invalid parameter");
1392 return PMINFO_R_EINVAL;
1395 if (pkgmgrinfo_appinfo_filter_create(&filter))
1396 return PMINFO_R_ERROR;
1398 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
1399 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
1400 pkgmgrinfo_appinfo_filter_destroy(filter);
1401 return PMINFO_R_ERROR;
1404 if (uid == GLOBAL_USER) {
1405 if (pkgmgrinfo_appinfo_filter_add_int(filter,
1406 PMINFO_APPINFO_PROP_APP_DISABLE_FOR_USER,
1408 pkgmgrinfo_appinfo_filter_destroy(filter);
1409 return PMINFO_R_ERROR;
1413 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter, flag, app_func,
1416 pkgmgrinfo_appinfo_filter_destroy(filter);
1421 API int pkgmgrinfo_appinfo_get_installed_list_full(
1422 pkgmgrinfo_app_list_cb app_func, int flag, void *user_data)
1424 return pkgmgrinfo_appinfo_get_usr_installed_list_full(app_func,
1425 _getuid(), flag, user_data);
1428 API int pkgmgrinfo_appinfo_get_usr_install_list(pkgmgrinfo_app_list_cb app_func,
1429 uid_t uid, void *user_data)
1431 return pkgmgrinfo_appinfo_get_usr_installed_list_full(app_func,
1432 uid, PMINFO_APPINFO_GET_ALL, user_data);
1435 API int pkgmgrinfo_appinfo_get_install_list(pkgmgrinfo_app_list_cb app_func,
1438 return pkgmgrinfo_appinfo_get_usr_installed_list_full(app_func,
1439 _getuid(), PMINFO_APPINFO_GET_ALL, user_data);
1442 API int pkgmgrinfo_appinfo_get_usr_installed_list(
1443 pkgmgrinfo_app_list_cb app_func, uid_t uid, void *user_data)
1445 if (app_func == NULL) {
1446 LOGE("invalid parameter");
1447 return PMINFO_R_EINVAL;
1450 return _appinfo_get_filtered_foreach_appinfo(uid, NULL,
1451 PMINFO_APPINFO_GET_ALL, app_func, user_data);
1454 API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func,
1457 return pkgmgrinfo_appinfo_get_usr_installed_list(app_func, _getuid(),
1461 API int pkgmgrinfo_appinfo_get_appid(pkgmgrinfo_appinfo_h handle, char **appid)
1463 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1465 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1466 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1468 if (info->app_info == NULL || info->app_info->appid == NULL)
1469 return PMINFO_R_ERROR;
1470 *appid = (char *)info->app_info->appid;
1475 API int pkgmgrinfo_appinfo_get_pkgname(pkgmgrinfo_appinfo_h handle, char **pkg_name)
1477 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1479 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1480 retvm_if(pkg_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1482 if (info->package == NULL)
1483 return PMINFO_R_ERROR;
1485 *pkg_name = (char *)info->package;
1490 API int pkgmgrinfo_appinfo_get_pkgid(pkgmgrinfo_appinfo_h handle, char **pkgid)
1492 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1494 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1495 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1497 if (info->package == NULL)
1498 return PMINFO_R_ERROR;
1500 *pkgid = (char *)info->package;
1505 API int pkgmgrinfo_appinfo_get_pkgtype(pkgmgrinfo_appinfo_h handle, char **pkgtype)
1507 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1508 retvm_if(pkgtype == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1509 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1511 *pkgtype = (char *)info->app_info->package_type;
1516 API int pkgmgrinfo_appinfo_get_exec(pkgmgrinfo_appinfo_h handle, char **exec)
1518 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1520 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1521 retvm_if(exec == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1523 if (info->app_info == NULL || info->app_info->exec == NULL)
1524 return PMINFO_R_ERROR;
1525 *exec = (char *)info->app_info->exec;
1531 API int pkgmgrinfo_appinfo_get_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1536 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1538 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1539 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1541 locale = info->locale;
1542 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
1544 if (info->app_info == NULL)
1545 return PMINFO_R_ERROR;
1547 if (info->app_info->icon == NULL) {
1552 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1553 ptr = (icon_x *)tmp->data;
1554 if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL ||
1555 !strcasecmp(ptr->text, "") ||
1556 strcmp(ptr->lang, locale))
1558 *icon = (char *)ptr->text;
1562 locale = DEFAULT_LOCALE;
1563 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1564 ptr = (icon_x *)tmp->data;
1565 if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL ||
1566 strcmp(ptr->lang, locale))
1568 *icon = (char *)ptr->text;
1572 return PMINFO_R_ERROR;
1576 API int pkgmgrinfo_appinfo_get_label(pkgmgrinfo_appinfo_h handle, char **label)
1581 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1583 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1584 retvm_if(label == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1586 locale = info->locale;
1587 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
1589 if (info->app_info == NULL)
1590 return PMINFO_R_ERROR;
1592 for (tmp = info->app_info->label; tmp; tmp = tmp->next) {
1593 ptr = (label_x *)tmp->data;
1594 if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL ||
1595 strcmp(ptr->lang, locale))
1597 *label = (char *)ptr->text;
1601 locale = DEFAULT_LOCALE;
1602 for (tmp = info->app_info->label; tmp; tmp = tmp->next) {
1603 ptr = (label_x *)tmp->data;
1604 if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL ||
1605 strcmp(ptr->lang, locale))
1607 *label = (char *)ptr->text;
1611 return PMINFO_R_ERROR;
1614 static char *_get_localed_label(const char *appid, const char *locale, uid_t uid)
1616 char *result = NULL;
1618 sqlite3_stmt *stmt = NULL;
1621 const char *manifest_db;
1623 manifest_db = getUserPkgParserDBPathUID(uid);
1624 if (manifest_db == NULL) {
1625 _LOGE("Failed to get manifest db path");
1629 if (sqlite3_open_v2(manifest_db, &db, SQLITE_OPEN_READONLY, NULL) != SQLITE_OK) {
1630 _LOGE("DB open fail\n");
1634 query = sqlite3_mprintf("select app_label from package_app_localized_info where app_id=%Q and app_locale=%Q", appid, locale);
1635 if (query == NULL) {
1636 _LOGE("Out of memory");
1640 if (sqlite3_prepare_v2(db, query, -1, &stmt, NULL) != SQLITE_OK) {
1641 _LOGE("prepare_v2 fail\n");
1645 if (sqlite3_step(stmt) == SQLITE_ROW) {
1646 val = (char *)sqlite3_column_text(stmt, 0);
1648 result = strdup(val);
1652 sqlite3_finalize(stmt);
1653 sqlite3_free(query);
1659 API int pkgmgrinfo_appinfo_usr_get_localed_label(const char *appid, const char *locale, uid_t uid, char **label)
1663 retvm_if(appid == NULL || locale == NULL || label == NULL, PMINFO_R_EINVAL, "Argument is NULL");
1665 val = _get_localed_label(appid, locale, uid);
1667 val = _get_localed_label(appid, DEFAULT_LOCALE, uid);
1670 return PMINFO_R_ERROR;
1677 API int pkgmgrinfo_appinfo_get_localed_label(const char *appid, const char *locale, char **label)
1679 return pkgmgrinfo_appinfo_usr_get_localed_label(appid, locale, _getuid(), label);
1682 API int pkgmgrinfo_appinfo_get_metadata_value(pkgmgrinfo_appinfo_h handle, const char *metadata_key, char **metadata_value)
1684 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1685 retvm_if(metadata_key == NULL, PMINFO_R_EINVAL, "metadata_key is NULL");
1686 retvm_if(metadata_value == NULL, PMINFO_R_EINVAL, "metadata_value is NULL");
1688 GList *list_md = NULL;
1689 metadata_x *metadata = NULL;
1690 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1692 list_md = info->app_info->metadata;
1694 for (; list_md; list_md = list_md->next) {
1695 metadata = (metadata_x *)list_md->data;
1696 if (metadata && metadata->key) {
1697 if (strcasecmp(metadata->key, metadata_key) == 0) {
1698 if (metadata->value == NULL)
1699 metadata->value = strdup("");
1700 *metadata_value = (char*)metadata->value;
1706 return PMINFO_R_EINVAL;
1709 static pkgmgrinfo_app_component __appcomponent_convert(const char *comp)
1711 if (strcasecmp(comp, "uiapp") == 0)
1712 return PMINFO_UI_APP;
1713 else if (strcasecmp(comp, "svcapp") == 0)
1714 return PMINFO_SVC_APP;
1715 else if (strcasecmp(comp, "widgetapp") == 0)
1716 return PMINFO_WIDGET_APP;
1717 else if (strcasecmp(comp, "watchapp") == 0)
1718 return PMINFO_WATCH_APP;
1723 static const char *__appcomponent_str(pkgmgrinfo_app_component comp)
1728 case PMINFO_SVC_APP:
1730 case PMINFO_WIDGET_APP:
1732 case PMINFO_WATCH_APP:
1739 API int pkgmgrinfo_appinfo_get_component(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_component *component)
1741 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1744 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1745 retvm_if(component == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1747 if (info->app_info == NULL)
1748 return PMINFO_R_ERROR;
1750 comp = __appcomponent_convert(info->app_info->component);
1752 return PMINFO_R_ERROR;
1759 API int pkgmgrinfo_appinfo_get_apptype(pkgmgrinfo_appinfo_h handle, char **app_type)
1761 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1763 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1764 retvm_if(app_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1766 if (info->app_info == NULL || info->app_info->type == NULL)
1767 return PMINFO_R_ERROR;
1768 *app_type = (char *)info->app_info->type;
1773 API int pkgmgrinfo_appinfo_get_operation(pkgmgrinfo_appcontrol_h handle,
1774 int *operation_count, char ***operation)
1776 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1777 retvm_if(operation == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1778 retvm_if(operation_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1779 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1780 *operation_count = data->operation_count;
1781 *operation = data->operation;
1785 API int pkgmgrinfo_appinfo_get_uri(pkgmgrinfo_appcontrol_h handle,
1786 int *uri_count, char ***uri)
1788 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1789 retvm_if(uri == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1790 retvm_if(uri_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1791 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1792 *uri_count = data->uri_count;
1797 API int pkgmgrinfo_appinfo_get_mime(pkgmgrinfo_appcontrol_h handle,
1798 int *mime_count, char ***mime)
1800 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1801 retvm_if(mime == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1802 retvm_if(mime_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1803 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1804 *mime_count = data->mime_count;
1809 API int pkgmgrinfo_appinfo_get_subapp(pkgmgrinfo_appcontrol_h handle,
1810 int *subapp_count, char ***subapp)
1812 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1813 retvm_if(subapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1814 retvm_if(subapp_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1815 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1816 *subapp_count = data->subapp_count;
1817 *subapp = data->subapp;
1821 API int pkgmgrinfo_appinfo_get_setting_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1826 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1828 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1829 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1831 if (info->app_info == NULL)
1832 return PMINFO_R_ERROR;
1834 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1835 ptr = (icon_x *)tmp->data;
1836 if (ptr == NULL || ptr->section == NULL)
1839 val = (char *)ptr->section;
1840 if (val && strcmp(val, "setting") == 0) {
1841 *icon = (char *)ptr->text;
1846 return PMINFO_R_ERROR;
1850 API int pkgmgrinfo_appinfo_get_notification_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1855 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1857 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1858 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1860 if (info->app_info == NULL)
1861 return PMINFO_R_ERROR;
1863 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1864 ptr = (icon_x *)tmp->data;
1865 if (ptr == NULL || ptr->section == NULL)
1868 val = (char *)ptr->section;
1869 if (val && strcmp(val, "notification") == 0) {
1870 *icon = (char *)ptr->text;
1875 return PMINFO_R_ERROR;
1878 API int pkgmgrinfo_appinfo_get_recent_image_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_recentimage *type)
1881 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1883 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1884 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1886 if (info->app_info == NULL || info->app_info->recentimage == NULL)
1887 return PMINFO_R_ERROR;
1889 val = (char *)info->app_info->recentimage;
1890 if (strcasecmp(val, "capture") == 0)
1891 *type = PMINFO_RECENTIMAGE_USE_CAPTURE;
1892 else if (strcasecmp(val, "icon") == 0)
1893 *type = PMINFO_RECENTIMAGE_USE_ICON;
1895 *type = PMINFO_RECENTIMAGE_USE_NOTHING;
1900 API int pkgmgrinfo_appinfo_get_preview_image(pkgmgrinfo_appinfo_h handle, char **preview_img)
1905 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1907 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1908 retvm_if(preview_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1910 if (info->app_info == NULL)
1911 return PMINFO_R_ERROR;
1913 for (tmp = info->app_info->image; tmp; tmp = tmp->next) {
1914 ptr = (image_x *)tmp->data;
1915 if (ptr == NULL || ptr->section == NULL)
1918 val = (char *)ptr->section;
1919 if (val && strcmp(val, "preview") == 0) {
1920 *preview_img = (char *)ptr->text;
1925 return PMINFO_R_ERROR;
1928 API int pkgmgrinfo_appinfo_get_permission_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_permission_type *permission)
1931 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1933 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1934 retvm_if(permission == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1936 val = info->app_info->permission_type;
1938 return PMINFO_R_ERROR;
1940 if (strcmp(val, "signature") == 0)
1941 *permission = PMINFO_PERMISSION_SIGNATURE;
1942 else if (strcmp(val, "privilege") == 0)
1943 *permission = PMINFO_PERMISSION_PRIVILEGE;
1945 *permission = PMINFO_PERMISSION_NORMAL;
1950 API int pkgmgrinfo_appinfo_get_component_type(pkgmgrinfo_appinfo_h handle, char **component_type)
1952 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1954 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1955 retvm_if(component_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1957 if (info->app_info == NULL || info->app_info->component_type == NULL)
1958 return PMINFO_R_ERROR;
1960 *component_type = (char *)info->app_info->component_type;
1965 API int pkgmgrinfo_appinfo_get_hwacceleration(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_hwacceleration *hwacceleration)
1968 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1970 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1971 retvm_if(hwacceleration == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1973 if (info->app_info == NULL || info->app_info->hwacceleration == NULL)
1974 return PMINFO_R_ERROR;
1976 val = (char *)info->app_info->hwacceleration;
1977 if (strcasecmp(val, "off") == 0)
1978 *hwacceleration = PMINFO_HWACCELERATION_OFF;
1979 else if (strcasecmp(val, "on") == 0)
1980 *hwacceleration = PMINFO_HWACCELERATION_ON;
1982 *hwacceleration = PMINFO_HWACCELERATION_DEFAULT;
1987 API int pkgmgrinfo_appinfo_get_screenreader(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_screenreader *screenreader)
1990 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1992 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1993 retvm_if(screenreader == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1995 if (info->app_info == NULL || info->app_info->screenreader == NULL)
1996 return PMINFO_R_ERROR;
1998 val = (char *)info->app_info->screenreader;
1999 if (strcasecmp(val, "screenreader-off") == 0)
2000 *screenreader = PMINFO_SCREENREADER_OFF;
2001 else if (strcasecmp(val, "screenreader-on") == 0)
2002 *screenreader = PMINFO_SCREENREADER_ON;
2004 *screenreader = PMINFO_SCREENREADER_USE_SYSTEM_SETTING;
2009 API int pkgmgrinfo_appinfo_get_effectimage(pkgmgrinfo_appinfo_h handle, char **portrait_img, char **landscape_img)
2011 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2013 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2014 retvm_if(portrait_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2015 retvm_if(landscape_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2017 if (info->app_info == NULL)
2018 return PMINFO_R_ERROR;
2019 if (info->app_info->portraitimg == NULL)
2020 info->app_info->portraitimg = strdup("");
2021 if (info->app_info->landscapeimg == NULL)
2022 info->app_info->landscapeimg = strdup("");
2024 *portrait_img = (char *)info->app_info->portraitimg;
2025 *landscape_img = (char *)info->app_info->landscapeimg;
2030 API int pkgmgrinfo_appinfo_get_effectimage_type(pkgmgrinfo_appinfo_h handle, char **effectimage_type)
2032 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2034 if (handle == NULL || effectimage_type == NULL) {
2035 LOGE("invalid parameter");
2036 return PMINFO_R_EINVAL;
2039 if (info->app_info == NULL || info->app_info->effectimage_type == NULL)
2040 return PMINFO_R_ERROR;
2042 *effectimage_type = (char *)info->app_info->effectimage_type;
2047 API int pkgmgrinfo_appinfo_get_submode_mainid(pkgmgrinfo_appinfo_h handle, char **submode_mainid)
2049 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2051 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2052 retvm_if(submode_mainid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2054 if (info->app_info == NULL)
2055 return PMINFO_R_ERROR;
2056 if (info->app_info->submode_mainid == NULL)
2057 info->app_info->submode_mainid = strdup("");
2059 *submode_mainid = (char *)info->app_info->submode_mainid;
2064 API int pkgmgrinfo_appinfo_get_installed_storage_location(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_installed_storage *storage)
2066 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2067 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2069 if (info->app_info && info->app_info->installed_storage) {
2070 if (strcmp(info->app_info->installed_storage, "installed_internal") == 0)
2071 *storage = PMINFO_INTERNAL_STORAGE;
2072 else if (strcmp(info->app_info->installed_storage, "installed_external") == 0)
2073 *storage = PMINFO_EXTERNAL_STORAGE;
2075 return PMINFO_R_ERROR;
2077 return PMINFO_R_ERROR;
2083 API int pkgmgrinfo_appinfo_get_launch_mode(pkgmgrinfo_appinfo_h handle, char **mode)
2085 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2087 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2088 retvm_if(mode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2090 if (info->app_info->launch_mode == NULL)
2091 return PMINFO_R_ERROR;
2093 *mode = (char *)(info->app_info->launch_mode);
2098 API int pkgmgrinfo_appinfo_get_alias_appid(pkgmgrinfo_appinfo_h handle, char **alias_appid)
2100 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2102 if (handle == NULL || alias_appid == NULL) {
2103 LOGE("invalid parameter");
2104 return PMINFO_R_EINVAL;
2107 if (info->app_info == NULL || info->app_info->alias_appid == NULL)
2108 return PMINFO_R_ERROR;
2110 *alias_appid = (char *)info->app_info->alias_appid;
2115 API int pkgmgrinfo_appinfo_get_effective_appid(pkgmgrinfo_appinfo_h handle, char **effective_appid)
2117 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2119 if (handle == NULL || effective_appid == NULL) {
2120 LOGE("invalid parameter");
2121 return PMINFO_R_EINVAL;
2124 if (info->app_info == NULL)
2125 return PMINFO_R_ERROR;
2126 if (info->app_info->effective_appid == NULL)
2127 info->app_info->effective_appid = strdup("");
2129 *effective_appid = (char *)info->app_info->effective_appid;
2134 API int pkgmgrinfo_appinfo_get_tep_name(pkgmgrinfo_appinfo_h handle, char **tep_name)
2136 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2138 if (handle == NULL || tep_name == NULL) {
2139 LOGE("invalid parameter");
2140 return PMINFO_R_EINVAL;
2143 if (info->app_info == NULL)
2144 return PMINFO_R_ERROR;
2145 if (info->app_info->tep_name == NULL)
2146 info->app_info->tep_name = strdup("");
2148 *tep_name = (char *)info->app_info->tep_name;
2153 API int pkgmgrinfo_appinfo_get_zip_mount_file(pkgmgrinfo_appinfo_h handle, char **zip_mount_file)
2155 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2157 if (handle == NULL || zip_mount_file == NULL) {
2158 LOGE("invalid parameter");
2159 return PMINFO_R_EINVAL;
2162 if (info->app_info == NULL)
2163 return PMINFO_R_ERROR;
2164 if (info->app_info->zip_mount_file == NULL)
2165 info->app_info->zip_mount_file = strdup("");
2167 *zip_mount_file = (char *)info->app_info->zip_mount_file;
2172 API int pkgmgrinfo_appinfo_get_root_path(pkgmgrinfo_appinfo_h handle, char **root_path)
2174 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2176 if (handle == NULL || root_path == NULL) {
2177 LOGE("invalid parameter");
2178 return PMINFO_R_EINVAL;
2181 if (info->app_info == NULL || info->app_info->root_path == NULL)
2182 return PMINFO_R_ERROR;
2184 *root_path = (char *)info->app_info->root_path;
2189 API int pkgmgrinfo_appinfo_get_api_version(pkgmgrinfo_appinfo_h handle, char **api_version)
2191 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2193 if (handle == NULL || api_version == NULL) {
2194 LOGE("invalid parameter");
2195 return PMINFO_R_EINVAL;
2198 if (info->app_info == NULL || info->app_info->api_version == NULL)
2199 return PMINFO_R_ERROR;
2201 *api_version = (char *)info->app_info->api_version;
2206 API int pkgmgrinfo_appinfo_usr_get_datacontrol_info(const char *providerid, const char *type, uid_t uid, char **appid, char **access)
2208 retvm_if(providerid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
2209 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
2210 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2211 retvm_if(access == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2213 int ret = PMINFO_R_OK;
2215 sqlite3_stmt *stmt = NULL;
2218 ret = __open_manifest_db(uid, true);
2219 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
2221 /*Start constructing query*/
2222 query = sqlite3_mprintf("select * from package_app_data_control where providerid=%Q and type=%Q", providerid, type);
2223 tryvm_if(query == NULL, ret = PMINFO_R_ERROR, "Out of memory");
2226 ret = sqlite3_prepare_v2(GET_DB(manifest_db), query, strlen(query), &stmt, NULL);
2227 tryvm_if(ret != PMINFO_R_OK, ret = PMINFO_R_ERROR, "sqlite3_prepare_v2 failed[%s]\n", query);
2230 ret = sqlite3_step(stmt);
2231 tryvm_if((ret != SQLITE_ROW) || (ret == SQLITE_DONE), ret = PMINFO_R_ERROR, "No records found");
2233 *appid = strdup((char *)sqlite3_column_text(stmt, 0));
2234 *access = strdup((char *)sqlite3_column_text(stmt, 2));
2239 sqlite3_free(query);
2240 sqlite3_finalize(stmt);
2241 __close_manifest_db();
2245 API int pkgmgrinfo_appinfo_get_datacontrol_info(const char *providerid, const char *type, char **appid, char **access)
2247 return pkgmgrinfo_appinfo_usr_get_datacontrol_info(providerid, type, _getuid(), appid, access);
2250 API int pkgmgrinfo_appinfo_usr_get_datacontrol_appid(const char *providerid, uid_t uid, char **appid)
2252 retvm_if(providerid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
2253 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2255 int ret = PMINFO_R_OK;
2257 sqlite3_stmt *stmt = NULL;
2260 ret = __open_manifest_db(uid, true);
2261 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
2263 /*Start constructing query*/
2264 query = sqlite3_mprintf("select * from package_app_data_control where providerid=%Q", providerid);
2265 tryvm_if(query == NULL, ret = PMINFO_R_ERROR, "Out of memory");
2268 ret = sqlite3_prepare_v2(GET_DB(manifest_db), query, strlen(query), &stmt, NULL);
2269 tryvm_if(ret != PMINFO_R_OK, ret = PMINFO_R_ERROR, "sqlite3_prepare_v2 failed[%s]\n", query);
2272 ret = sqlite3_step(stmt);
2273 tryvm_if((ret != SQLITE_ROW) || (ret == SQLITE_DONE), ret = PMINFO_R_ERROR, "No records found");
2275 *appid = strdup((char *)sqlite3_column_text(stmt, 0));
2280 sqlite3_free(query);
2281 sqlite3_finalize(stmt);
2282 __close_manifest_db();
2286 API int pkgmgrinfo_appinfo_get_datacontrol_appid(const char *providerid, char **appid)
2288 return pkgmgrinfo_appinfo_usr_get_datacontrol_appid(providerid, _getuid(), appid);
2291 API int pkgmgrinfo_appinfo_foreach_permission(pkgmgrinfo_appinfo_h handle,
2292 pkgmgrinfo_app_permission_list_cb permission_func, void *user_data)
2294 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2295 retvm_if(permission_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2299 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2301 if (info->app_info == NULL)
2302 return PMINFO_R_ERROR;
2304 for (tmp = info->app_info->permission; tmp; tmp = tmp->next) {
2305 ptr = (permission_x *)tmp->data;
2309 ret = permission_func(ptr->value, user_data);
2317 API int pkgmgrinfo_appinfo_foreach_category(pkgmgrinfo_appinfo_h handle,
2318 pkgmgrinfo_app_category_list_cb category_func, void *user_data)
2320 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2321 retvm_if(category_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2323 const char *category;
2325 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2327 if (info->app_info == NULL)
2328 return PMINFO_R_ERROR;
2330 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
2331 category = (const char *)tmp->data;
2333 ret = category_func(category, user_data);
2341 API int pkgmgrinfo_appinfo_foreach_metadata(pkgmgrinfo_appinfo_h handle,
2342 pkgmgrinfo_app_metadata_list_cb metadata_func, void *user_data)
2344 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2345 retvm_if(metadata_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2349 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2351 if (info->app_info == NULL)
2352 return PMINFO_R_ERROR;
2354 for (tmp = info->app_info->metadata; tmp; tmp = tmp->next) {
2355 ptr = (metadata_x *)tmp->data;
2359 if (ptr->value == NULL)
2360 ptr->value = strdup("");
2361 ret = metadata_func(ptr->key, ptr->value, user_data);
2369 API int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
2370 pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
2372 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2373 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2375 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2376 appcontrol_x *appcontrol;
2379 if (info->app_info == NULL)
2380 return PMINFO_R_ERROR;
2382 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
2383 appcontrol = (appcontrol_x *)tmp->data;
2384 if (appcontrol == NULL)
2386 ret = appcontrol_func(appcontrol->operation, appcontrol->uri, appcontrol->mime, user_data);
2394 API int pkgmgrinfo_appinfo_foreach_background_category(
2395 pkgmgrinfo_appinfo_h handle,
2396 pkgmgrinfo_app_background_category_list_cb category_func,
2399 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2403 if (handle == NULL || category_func == NULL || info->app_info == NULL) {
2404 LOGE("invalid parameter");
2405 return PMINFO_R_EINVAL;
2408 for (tmp = info->app_info->background_category; tmp; tmp = tmp->next) {
2409 category = (char *)tmp->data;
2410 if (category == NULL)
2413 if (category_func(category, user_data) < 0)
2420 API int pkgmgrinfo_appinfo_foreach_splash_screen(pkgmgrinfo_appinfo_h handle,
2421 pkgmgrinfo_app_splash_screen_list_cb splash_screen_func,
2424 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2425 splashscreen_x *splashscreen;
2429 if (info == NULL || info->app_info == NULL
2430 || splash_screen_func == NULL) {
2431 LOGE("invalid parameter");
2432 return PMINFO_R_EINVAL;
2435 for (tmp = info->app_info->splashscreens; tmp; tmp = tmp->next) {
2436 splashscreen = (splashscreen_x *)tmp->data;
2437 if (splashscreen == NULL)
2439 ret = splash_screen_func(splashscreen->src,
2441 splashscreen->orientation,
2442 splashscreen->indicatordisplay,
2443 splashscreen->operation,
2444 splashscreen->color_depth,
2453 API int pkgmgrinfo_appinfo_is_nodisplay(pkgmgrinfo_appinfo_h handle, bool *nodisplay)
2455 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2456 retvm_if(nodisplay == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2457 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2459 if (info->app_info == NULL || info->app_info->nodisplay == NULL)
2460 return PMINFO_R_ERROR;
2462 *nodisplay = _get_bool_value(info->app_info->nodisplay);
2467 API int pkgmgrinfo_appinfo_is_multiple(pkgmgrinfo_appinfo_h handle, bool *multiple)
2469 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2470 retvm_if(multiple == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2471 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2473 if (info->app_info == NULL || info->app_info->multiple == NULL)
2474 return PMINFO_R_ERROR;
2476 *multiple = _get_bool_value(info->app_info->multiple);
2481 API int pkgmgrinfo_appinfo_is_indicator_display_allowed(pkgmgrinfo_appinfo_h handle, bool *indicator_disp)
2483 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2484 retvm_if(indicator_disp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2485 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2487 if (info->app_info == NULL || info->app_info->indicatordisplay == NULL)
2488 return PMINFO_R_ERROR;
2490 *indicator_disp = _get_bool_value(info->app_info->indicatordisplay);
2495 API int pkgmgrinfo_appinfo_is_taskmanage(pkgmgrinfo_appinfo_h handle, bool *taskmanage)
2497 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2498 retvm_if(taskmanage == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2499 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2501 if (info->app_info == NULL || info->app_info->taskmanage == NULL)
2502 return PMINFO_R_ERROR;
2504 *taskmanage = _get_bool_value(info->app_info->taskmanage);
2509 API int pkgmgrinfo_appinfo_is_enabled(pkgmgrinfo_appinfo_h handle, bool *enabled)
2511 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2512 retvm_if(enabled == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2513 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2515 if (info->app_info == NULL || info->app_info->enabled == NULL)
2516 return PMINFO_R_ERROR;
2518 *enabled = _get_bool_value(info->app_info->enabled);
2523 API int pkgmgrinfo_appinfo_is_onboot(pkgmgrinfo_appinfo_h handle, bool *onboot)
2525 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2526 retvm_if(onboot == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2527 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2529 if (info->app_info == NULL || info->app_info->onboot == NULL)
2530 return PMINFO_R_ERROR;
2532 *onboot = _get_bool_value(info->app_info->onboot);
2537 API int pkgmgrinfo_appinfo_is_autorestart(pkgmgrinfo_appinfo_h handle, bool *autorestart)
2539 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2540 retvm_if(autorestart == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2541 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2543 if (info->app_info == NULL || info->app_info->autorestart == NULL)
2544 return PMINFO_R_ERROR;
2546 *autorestart = _get_bool_value(info->app_info->autorestart);
2551 API int pkgmgrinfo_appinfo_is_mainapp(pkgmgrinfo_appinfo_h handle, bool *mainapp)
2553 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2554 retvm_if(mainapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2555 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2557 if (info->app_info == NULL || info->app_info->mainapp == NULL)
2558 return PMINFO_R_ERROR;
2560 *mainapp = _get_bool_value(info->app_info->mainapp);
2565 API int pkgmgrinfo_appinfo_is_preload(pkgmgrinfo_appinfo_h handle, bool *preload)
2567 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2568 retvm_if(preload == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2569 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2571 if (info->app_info == NULL || info->app_info->preload == NULL)
2572 return PMINFO_R_ERROR;
2574 *preload = _get_bool_value(info->app_info->preload);
2579 API int pkgmgrinfo_appinfo_is_submode(pkgmgrinfo_appinfo_h handle, bool *submode)
2581 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2582 retvm_if(submode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2583 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2585 if (info->app_info == NULL || info->app_info->submode == NULL)
2586 return PMINFO_R_ERROR;
2588 *submode = _get_bool_value(info->app_info->submode);
2593 API int pkgmgrinfo_appinfo_is_process_pool(pkgmgrinfo_appinfo_h handle, bool *process_pool)
2595 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2597 if (handle == NULL || process_pool == NULL) {
2598 LOGE("invalid parameter");
2599 return PMINFO_R_EINVAL;
2602 if (info->app_info == NULL)
2603 return PMINFO_R_ERROR;
2605 *process_pool = _get_bool_value(info->app_info->process_pool);
2610 API int pkgmgrinfo_appinfo_is_category_exist(pkgmgrinfo_appinfo_h handle, const char *category, bool *exist)
2612 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2613 retvm_if(category == NULL, PMINFO_R_EINVAL, "category is NULL");
2614 retvm_if(exist == NULL, PMINFO_R_EINVAL, "exist is NULL");
2618 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2620 if (info->app_info == NULL)
2621 return PMINFO_R_ERROR;
2624 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
2625 val = (const char *)tmp->data;
2628 if (strcasecmp(val, category) == 0) {
2637 API int pkgmgrinfo_appinfo_is_ui_gadget(pkgmgrinfo_appinfo_h handle,
2640 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2642 if (info == NULL || info->app_info == NULL || ui_gadget == NULL) {
2643 _LOGE("invalid parameter");
2644 return PMINFO_R_EINVAL;
2646 if (info->app_info->ui_gadget == NULL)
2647 info->app_info->ui_gadget = strdup("false");
2649 *ui_gadget = _get_bool_value(info->app_info->ui_gadget);
2654 API int pkgmgrinfo_appinfo_is_support_disable(pkgmgrinfo_appinfo_h handle,
2655 bool *support_disable)
2657 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2659 if (info == NULL || info->app_info == NULL || support_disable == NULL) {
2660 _LOGE("invalid parameter");
2661 return PMINFO_R_EINVAL;
2664 *support_disable = _get_bool_value(info->app_info->support_disable);
2669 API int pkgmgrinfo_appinfo_is_disabled(pkgmgrinfo_appinfo_h handle, bool *disabled)
2671 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2672 retvm_if(disabled == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2673 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2675 if (info->app_info == NULL || info->app_info->is_disabled == NULL)
2676 return PMINFO_R_ERROR;
2678 *disabled = _get_bool_value(info->app_info->is_disabled);
2683 API int pkgmgrinfo_appinfo_is_global(pkgmgrinfo_appinfo_h handle, bool *global)
2685 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2687 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2688 retvm_if(global == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2690 if (info->app_info == NULL || info->app_info->for_all_users == NULL)
2691 return PMINFO_R_ERROR;
2693 *global = _get_bool_value(info->app_info->for_all_users);
2698 API int pkgmgrinfo_appinfo_get_splash_screen_display(pkgmgrinfo_appinfo_h handle, bool *splash_screen_display)
2700 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2702 if (info == NULL || splash_screen_display == NULL) {
2703 _LOGE("Invalid parameter");
2704 return PMINFO_R_EINVAL;
2707 if (info->app_info == NULL || info->app_info->splash_screen_display == NULL)
2708 return PMINFO_R_ERROR;
2710 *splash_screen_display = _get_bool_value(info->app_info->splash_screen_display);
2715 API int pkgmgrinfo_appinfo_destroy_appinfo(pkgmgrinfo_appinfo_h handle)
2717 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2718 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2719 __cleanup_appinfo(info);
2723 API int pkgmgrinfo_appinfo_filter_create(pkgmgrinfo_appinfo_filter_h *handle)
2725 return (pkgmgrinfo_pkginfo_filter_create(handle));
2728 API int pkgmgrinfo_appinfo_filter_destroy(pkgmgrinfo_appinfo_filter_h handle)
2730 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
2733 static gint __compare_func(gconstpointer data1, gconstpointer data2)
2735 pkgmgrinfo_node_x *node1 = (pkgmgrinfo_node_x*)data1;
2736 pkgmgrinfo_node_x *node2 = (pkgmgrinfo_node_x*)data2;
2737 if (node1->prop == node2->prop)
2739 else if (node1->prop > node2->prop)
2745 API int pkgmgrinfo_appinfo_filter_add_int(pkgmgrinfo_appinfo_filter_h handle,
2746 const char *property, const int value)
2748 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2749 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2750 char buf[PKG_VALUE_STRING_LEN_MAX] = {'\0'};
2752 GSList *link = NULL;
2754 prop = _pminfo_appinfo_convert_to_prop_int(property);
2755 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_INT ||
2756 prop > E_PMINFO_APPINFO_PROP_APP_MAX_INT) {
2757 _LOGE("Invalid Integer Property\n");
2758 return PMINFO_R_EINVAL;
2760 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
2761 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
2763 _LOGE("Out of Memory!!!\n");
2764 return PMINFO_R_ERROR;
2766 snprintf(buf, PKG_VALUE_STRING_LEN_MAX - 1, "%d", value);
2767 val = strndup(buf, PKG_VALUE_STRING_LEN_MAX - 1);
2769 _LOGE("Out of Memory\n");
2772 return PMINFO_R_ERROR;
2776 /*If API is called multiple times for same property, we should override the previous values.
2777 Last value set will be used for filtering.*/
2778 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2780 filter->list = g_slist_delete_link(filter->list, link);
2781 filter->list = g_slist_append(filter->list, (gpointer)node);
2786 API int pkgmgrinfo_appinfo_filter_add_bool(pkgmgrinfo_appinfo_filter_h handle,
2787 const char *property, const bool value)
2789 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2790 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2792 GSList *link = NULL;
2794 prop = _pminfo_appinfo_convert_to_prop_bool(property);
2795 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_BOOL ||
2796 prop > E_PMINFO_APPINFO_PROP_APP_MAX_BOOL) {
2797 _LOGE("Invalid Boolean Property\n");
2798 return PMINFO_R_EINVAL;
2800 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
2801 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
2803 _LOGE("Out of Memory!!!\n");
2804 return PMINFO_R_ERROR;
2807 val = strndup("true", 4);
2809 val = strndup("false", 5);
2811 _LOGE("Out of Memory\n");
2814 return PMINFO_R_ERROR;
2818 /*If API is called multiple times for same property, we should override the previous values.
2819 Last value set will be used for filtering.*/
2820 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2822 filter->list = g_slist_delete_link(filter->list, link);
2823 filter->list = g_slist_append(filter->list, (gpointer)node);
2828 API int pkgmgrinfo_appinfo_filter_add_string(pkgmgrinfo_appinfo_filter_h handle,
2829 const char *property, const char *value)
2831 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2832 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2833 retvm_if(value == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2835 pkgmgrinfo_node_x *ptr = NULL;
2836 char prev[PKG_STRING_LEN_MAX] = {'\0'};
2837 char temp[PKG_STRING_LEN_MAX] = {'\0'};
2838 GSList *link = NULL;
2840 prop = _pminfo_appinfo_convert_to_prop_str(property);
2841 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_STR ||
2842 prop > E_PMINFO_APPINFO_PROP_APP_MAX_STR) {
2843 _LOGE("Invalid String Property\n");
2844 return PMINFO_R_EINVAL;
2846 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
2847 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
2849 _LOGE("Out of Memory!!!\n");
2850 return PMINFO_R_ERROR;
2854 case E_PMINFO_APPINFO_PROP_APP_COMPONENT:
2855 node->value = strdup(value);
2856 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2858 filter->list = g_slist_delete_link(filter->list, link);
2859 filter->list = g_slist_append(filter->list, (gpointer)node);
2861 case E_PMINFO_APPINFO_PROP_APP_CATEGORY:
2862 val = (char *)calloc(1, PKG_STRING_LEN_MAX);
2864 _LOGE("Out of Memory\n");
2867 return PMINFO_R_ERROR;
2869 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2871 ptr = (pkgmgrinfo_node_x *)link->data;
2872 strncpy(prev, ptr->value, PKG_STRING_LEN_MAX - 1);
2873 _LOGI("Previous value is %s\n", prev);
2874 filter->list = g_slist_delete_link(filter->list, link);
2875 snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s,%s", prev, value);
2876 strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
2877 _LOGI("New value is %s\n", val);
2879 filter->list = g_slist_append(filter->list, (gpointer)node);
2880 memset(temp, '\0', PKG_STRING_LEN_MAX);
2882 snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s", value);
2883 strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
2884 _LOGI("First value is %s\n", val);
2886 filter->list = g_slist_append(filter->list, (gpointer)node);
2887 memset(temp, '\0', PKG_STRING_LEN_MAX);
2891 node->value = strndup(value, PKG_STRING_LEN_MAX - 1);
2892 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2894 filter->list = g_slist_delete_link(filter->list, link);
2895 filter->list = g_slist_append(filter->list, (gpointer)node);
2901 API int pkgmgrinfo_appinfo_usr_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count, uid_t uid)
2907 if (handle == NULL || count == NULL) {
2908 _LOGE("invalid parameter");
2909 return PMINFO_R_EINVAL;
2912 locale = _get_system_locale();
2914 return PMINFO_R_ERROR;
2916 list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
2917 __free_applications);
2920 return PMINFO_R_ERROR;
2923 ret = _appinfo_get_applications(uid, uid, locale, handle, 0, list);
2924 if (ret == PMINFO_R_OK && uid != GLOBAL_USER)
2925 ret = _appinfo_get_applications(GLOBAL_USER, uid, locale,
2928 if (ret != PMINFO_R_OK) {
2929 g_hash_table_destroy(list);
2931 return PMINFO_R_ERROR;
2934 *count = g_hash_table_size(list);
2935 g_hash_table_destroy(list);
2941 API int pkgmgrinfo_appinfo_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count)
2943 return pkgmgrinfo_appinfo_usr_filter_count(handle, count, _getuid());
2946 API int pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(
2947 pkgmgrinfo_appinfo_filter_h handle,
2948 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
2950 if (handle == NULL || app_cb == NULL) {
2951 LOGE("invalid parameter");
2952 return PMINFO_R_EINVAL;
2955 return _appinfo_get_filtered_foreach_appinfo(uid, handle, PMINFO_APPINFO_GET_ALL, app_cb,
2959 API int pkgmgrinfo_appinfo_filter_foreach_appinfo(pkgmgrinfo_appinfo_filter_h handle,
2960 pkgmgrinfo_app_list_cb app_cb, void * user_data)
2962 return pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(handle, app_cb, user_data, _getuid());
2965 API int pkgmgrinfo_appinfo_metadata_filter_create(pkgmgrinfo_appinfo_metadata_filter_h *handle)
2967 return (pkgmgrinfo_pkginfo_filter_create(handle));
2970 API int pkgmgrinfo_appinfo_metadata_filter_destroy(pkgmgrinfo_appinfo_metadata_filter_h handle)
2972 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
2975 API int pkgmgrinfo_appinfo_metadata_filter_add(
2976 pkgmgrinfo_appinfo_metadata_filter_h handle,
2977 const char *key, const char *value)
2981 ret = pkgmgrinfo_appinfo_filter_add_string(handle,
2982 PMINFO_APPINFO_PROP_APP_METADATA_KEY, key);
2983 if (ret != PMINFO_R_OK)
2986 /* value can be NULL.
2987 * In that case all apps with specified key should be displayed
2990 ret = pkgmgrinfo_appinfo_filter_add_string(handle,
2991 PMINFO_APPINFO_PROP_APP_METADATA_VALUE, value);
2992 if (ret != PMINFO_R_OK)
2999 API int pkgmgrinfo_appinfo_usr_metadata_filter_foreach(
3000 pkgmgrinfo_appinfo_metadata_filter_h handle,
3001 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
3003 if (handle == NULL || app_cb == NULL) {
3004 LOGE("invalid parameter");
3005 return PMINFO_R_EINVAL;
3008 return _appinfo_get_filtered_foreach_appinfo(uid, handle, PMINFO_APPINFO_GET_ALL, app_cb,
3012 API int pkgmgrinfo_appinfo_metadata_filter_foreach(
3013 pkgmgrinfo_appinfo_metadata_filter_h handle,
3014 pkgmgrinfo_app_list_cb app_cb, void *user_data)
3016 return pkgmgrinfo_appinfo_usr_metadata_filter_foreach(handle, app_cb,
3017 user_data, _getuid());
3020 API int pkgmgrinfo_appinfo_is_guestmode_visibility(pkgmgrinfo_appinfo_h handle, bool *status)
3023 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3025 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
3026 retvm_if(status == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3028 val = info->app_info->guestmode_visibility;
3029 *status = _get_bool_value(val);