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_category(sqlite3 *db, const char *appid,
114 static const char query_raw[] =
115 "SELECT category FROM package_app_app_category WHERE app_id=%Q";
121 query = sqlite3_mprintf(query_raw, appid);
123 LOGE("out of memory");
124 return PMINFO_R_ERROR;
127 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
129 if (ret != SQLITE_OK) {
130 LOGE("prepare failed: %s", sqlite3_errmsg(db));
131 return PMINFO_R_ERROR;
134 while (sqlite3_step(stmt) == SQLITE_ROW) {
136 _save_column_str(stmt, 0, &val);
138 *category = g_list_append(*category, (gpointer)val);
141 sqlite3_finalize(stmt);
146 static void __parse_appcontrol(GList **appcontrol, char *appcontrol_str)
153 if (appcontrol_str == NULL)
156 dup = strdup(appcontrol_str);
158 ac = calloc(1, sizeof(appcontrol_x));
160 _LOGE("out of memory");
163 token = strtok_r(dup, "|", &ptr);
164 if (token && strcmp(token, "NULL"))
165 ac->operation = strdup(token);
166 token = strtok_r(NULL, "|", &ptr);
167 if (token && strcmp(token, "NULL"))
168 ac->uri = strdup(token);
169 token = strtok_r(NULL, "|", &ptr);
170 if (token && strcmp(token, "NULL"))
171 ac->mime = strdup(token);
172 *appcontrol = g_list_append(*appcontrol, ac);
173 } while ((token = strtok_r(NULL, ";", &ptr)));
178 static int _appinfo_get_app_control(sqlite3 *db, const char *appid,
181 static const char query_raw[] =
182 "SELECT app_control FROM package_app_app_control "
189 query = sqlite3_mprintf(query_raw, appid);
191 LOGE("out of memory");
192 return PMINFO_R_ERROR;
195 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
197 if (ret != SQLITE_OK) {
198 LOGE("prepare failed: %s", sqlite3_errmsg(db));
199 return PMINFO_R_ERROR;
202 while (sqlite3_step(stmt) == SQLITE_ROW) {
204 _save_column_str(stmt, 0, &str);
206 __parse_appcontrol(appcontrol, str);
210 sqlite3_finalize(stmt);
215 static int _appinfo_get_data_control(sqlite3 *db, const char *appid,
218 static const char query_raw[] =
219 "SELECT providerid, access, type "
220 "FROM package_app_data_control WHERE app_id=%Q";
227 query = sqlite3_mprintf(query_raw, appid);
229 LOGE("out of memory");
230 return PMINFO_R_ERROR;
233 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
235 if (ret != SQLITE_OK) {
236 LOGE("prepare failed: %s", sqlite3_errmsg(db));
237 return PMINFO_R_ERROR;
240 while (sqlite3_step(stmt) == SQLITE_ROW) {
241 info = calloc(1, sizeof(datacontrol_x));
243 LOGE("out of memory");
244 sqlite3_finalize(stmt);
245 return PMINFO_R_ERROR;
248 _save_column_str(stmt, idx++, &info->providerid);
249 _save_column_str(stmt, idx++, &info->access);
250 _save_column_str(stmt, idx++, &info->type);
251 *datacontrol = g_list_append(*datacontrol, info);
254 sqlite3_finalize(stmt);
259 static int _appinfo_get_metadata(sqlite3 *db, const char *appid,
262 static const char query_raw[] =
263 "SELECT md_key, md_value "
264 "FROM package_app_app_metadata WHERE app_id=%Q";
271 query = sqlite3_mprintf(query_raw, appid);
273 LOGE("out of memory");
274 return PMINFO_R_ERROR;
277 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
279 if (ret != SQLITE_OK) {
280 LOGE("prepare failed: %s", sqlite3_errmsg(db));
281 return PMINFO_R_ERROR;
284 while (sqlite3_step(stmt) == SQLITE_ROW) {
285 info = calloc(1, sizeof(metadata_x));
287 LOGE("out of memory");
288 sqlite3_finalize(stmt);
289 return PMINFO_R_ERROR;
292 _save_column_str(stmt, idx++, &info->key);
293 _save_column_str(stmt, idx++, &info->value);
294 *metadata = g_list_append(*metadata, info);
297 sqlite3_finalize(stmt);
303 static int _appinfo_get_splashscreens(sqlite3 *db, const char *appid,
304 GList **splashscreens)
306 static const char query_raw[] =
307 "SELECT src, type, orientation, indicatordisplay, operation, color_depth "
308 "FROM package_app_splash_screen WHERE app_id=%Q";
313 splashscreen_x *info;
315 query = sqlite3_mprintf(query_raw, appid);
317 LOGE("out of memory");
318 return PMINFO_R_ERROR;
321 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
323 if (ret != SQLITE_OK) {
324 LOGE("prepare failed: %s", sqlite3_errmsg(db));
325 return PMINFO_R_ERROR;
328 while (sqlite3_step(stmt) == SQLITE_ROW) {
329 info = calloc(1, sizeof(splashscreen_x));
331 LOGE("out of memory");
332 sqlite3_finalize(stmt);
333 return PMINFO_R_ERROR;
336 _save_column_str(stmt, idx++, &info->src);
337 _save_column_str(stmt, idx++, &info->type);
338 _save_column_str(stmt, idx++, &info->orientation);
339 _save_column_str(stmt, idx++, &info->indicatordisplay);
340 _save_column_str(stmt, idx++, &info->operation);
341 _save_column_str(stmt, idx++, &info->color_depth);
342 *splashscreens = g_list_append(*splashscreens, info);
345 sqlite3_finalize(stmt);
350 static GList *__get_background_category(const char *value)
352 GList *category_list = NULL;
353 int convert_value = 0;
354 if (!value || strlen(value) == 0)
357 convert_value = atoi(value);
358 if (convert_value < 0)
361 if (convert_value & APP_BG_CATEGORY_USER_DISABLE_TRUE_VAL)
362 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_USER_DISABLE_TRUE_STR));
364 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_USER_DISABLE_FALSE_STR));
366 if (convert_value & APP_BG_CATEGORY_MEDIA_VAL)
367 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_MEDIA_STR));
369 if (convert_value & APP_BG_CATEGORY_DOWNLOAD_VAL)
370 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_DOWNLOAD_STR));
372 if (convert_value & APP_BG_CATEGORY_BGNETWORK_VAL)
373 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_BGNETWORK_STR));
375 if (convert_value & APP_BG_CATEGORY_LOCATION_VAL)
376 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_LOCATION_STR));
378 if (convert_value & APP_BG_CATEGORY_SENSOR_VAL)
379 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_SENSOR_STR));
381 if (convert_value & APP_BG_CATEGORY_IOTCOMM_VAL)
382 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_IOTCOMM_STR));
384 if (convert_value & APP_BG_CATEGORY_SYSTEM_VAL)
385 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_SYSTEM));
387 return category_list;
391 static void __get_splash_screen_display(sqlite3 *db, const char *appid, uid_t uid, char **value)
393 static const char query_raw[] =
394 "SELECT is_splash_screen_enabled FROM package_app_info_for_uid "
395 "WHERE app_id='%s' AND uid='%d'";
400 query = sqlite3_mprintf(query_raw, appid, uid);
402 LOGE("out of memory");
406 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
408 if (ret != SQLITE_OK) {
409 LOGE("sqlite3_prepare_v2() failed: %s", sqlite3_errmsg(db));
413 while (sqlite3_step(stmt) == SQLITE_ROW) {
416 _save_column_str(stmt, 0, value);
419 sqlite3_finalize(stmt);
422 static void __free_applications(gpointer data)
424 pkgmgrinfo_basic_free_application((application_x *)data);
427 static int __bind_params(sqlite3_stmt *stmt, GList *params)
429 GList *tmp_list = NULL;
433 if (stmt == NULL || params == NULL)
434 return PMINFO_R_EINVAL;
438 ret = sqlite3_bind_text(stmt, ++idx, (char *)tmp_list->data, -1, SQLITE_STATIC);
439 if (ret != SQLITE_OK)
440 return PMINFO_R_ERROR;
441 tmp_list = tmp_list->next;
447 static int _appinfo_get_applications(uid_t db_uid, uid_t uid,
448 const char *locale, pkgmgrinfo_filter_x *filter, int flag,
449 GHashTable *applications)
451 static const char query_raw[] =
452 "SELECT DISTINCT ai.app_id, ai.app_component, ai.app_exec, "
453 "ai.app_nodisplay, ai.app_type, ai.app_onboot, "
454 "ai.app_multiple, ai.app_autorestart, ai.app_taskmanage, "
455 "ai.app_enabled, ai.app_hwacceleration, ai.app_screenreader, "
456 "ai.app_mainapp, ai.app_recentimage, ai.app_launchcondition, "
457 "ai.app_indicatordisplay, ai.app_portraitimg, "
458 "ai.app_landscapeimg, ai.app_guestmodevisibility, "
459 "ai.app_permissiontype, ai.app_preload, ai.app_submode, "
460 "ai.app_submode_mainid, ai.app_launch_mode, ai.app_ui_gadget, "
461 "ai.app_support_disable, ai.app_process_pool, "
462 "ai.app_installed_storage, ai.app_background_category, "
463 "ai.app_package_type, ai.app_root_path, ai.app_api_version, "
464 "ai.app_effective_appid, ai.app_disable, "
465 "ai.app_splash_screen_display, ai.app_tep_name, "
466 "ai.app_zip_mount_file, ai.component_type, ai.package, "
467 "ai.app_external_path";
468 static const char query_label[] =
470 "(SELECT app_label FROM package_app_localized_info WHERE ai.app_id=app_id AND app_locale=?), "
471 "(SELECT app_label FROM package_app_localized_info WHERE ai.app_id=app_id AND app_locale='No Locale'))";
472 static const char query_icon[] =
474 "(SELECT app_icon FROM package_app_localized_info WHERE ai.app_id=app_id AND app_locale=?), "
475 "(SELECT app_icon FROM package_app_localized_info WHERE ai.app_id=app_id AND app_locale='No Locale'))";
476 static const char query_from_clause[] = " FROM package_app_info as ai";
477 int ret = PMINFO_R_ERROR;
481 char *bg_category_str = NULL;
482 char *constraint = NULL;
483 char *tmp_record = NULL;
484 char query[MAX_QUERY_LEN] = { '\0' };
485 application_x *info = NULL;
486 GList *bind_params = NULL;
488 sqlite3_stmt *stmt = NULL;
490 dbpath = getUserPkgParserDBPathUID(db_uid);
492 return PMINFO_R_ERROR;
494 ret = sqlite3_open_v2(dbpath, &db, SQLITE_OPEN_READONLY, NULL);
495 if (ret != SQLITE_OK) {
496 _LOGE("failed to open db: %d", ret);
498 return PMINFO_R_ERROR;
502 len = strlen(query_raw);
503 snprintf(query, MAX_QUERY_LEN - 1, "%s", query_raw);
504 if (flag & PMINFO_APPINFO_GET_LABEL) {
505 strncat(query, query_label, MAX_QUERY_LEN - len - 1);
506 len += strlen(query_label);
507 bind_params = g_list_append(bind_params, strdup(locale));
509 if (flag & PMINFO_APPINFO_GET_ICON) {
510 strncat(query, query_icon, MAX_QUERY_LEN - len - 1);
511 len += strlen(query_icon);
512 bind_params = g_list_append(bind_params, strdup(locale));
515 ret = _get_filtered_query(filter, locale, &constraint, &bind_params);
516 if (ret != PMINFO_R_OK) {
517 LOGE("Failed to get WHERE clause");
520 strncat(query, query_from_clause, MAX_QUERY_LEN - len - 1);
521 len += strlen(query_from_clause);
524 strncat(query, constraint, MAX_QUERY_LEN - len - 1);
526 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
527 if (ret != SQLITE_OK) {
528 LOGE("prepare failed: %s", sqlite3_errmsg(db));
529 ret = PMINFO_R_ERROR;
533 if (g_list_length(bind_params) != 0) {
534 ret = __bind_params(stmt, bind_params);
535 if (ret != SQLITE_OK) {
536 LOGE("Failed to bind parameters");
541 while (sqlite3_step(stmt) == SQLITE_ROW) {
542 info = calloc(1, sizeof(application_x));
544 LOGE("out of memory");
545 ret = PMINFO_R_ERROR;
549 _save_column_str(stmt, idx++, &info->appid);
550 if (g_hash_table_contains(applications,
551 (gconstpointer)info->appid)) {
556 _save_column_str(stmt, idx++, &info->component);
557 _save_column_str(stmt, idx++, &info->exec);
558 _save_column_str(stmt, idx++, &info->nodisplay);
559 _save_column_str(stmt, idx++, &info->type);
560 _save_column_str(stmt, idx++, &info->onboot);
561 _save_column_str(stmt, idx++, &info->multiple);
562 _save_column_str(stmt, idx++, &info->autorestart);
563 _save_column_str(stmt, idx++, &info->taskmanage);
564 _save_column_str(stmt, idx++, &info->enabled);
565 _save_column_str(stmt, idx++, &info->hwacceleration);
566 _save_column_str(stmt, idx++, &info->screenreader);
567 _save_column_str(stmt, idx++, &info->mainapp);
568 _save_column_str(stmt, idx++, &info->recentimage);
569 _save_column_str(stmt, idx++, &info->launchcondition);
570 _save_column_str(stmt, idx++, &info->indicatordisplay);
571 _save_column_str(stmt, idx++, &info->portraitimg);
572 _save_column_str(stmt, idx++, &info->landscapeimg);
573 _save_column_str(stmt, idx++, &info->guestmode_visibility);
574 _save_column_str(stmt, idx++, &info->permission_type);
575 _save_column_str(stmt, idx++, &info->preload);
576 _save_column_str(stmt, idx++, &info->submode);
577 _save_column_str(stmt, idx++, &info->submode_mainid);
578 _save_column_str(stmt, idx++, &info->launch_mode);
579 _save_column_str(stmt, idx++, &info->ui_gadget);
580 _save_column_str(stmt, idx++, &info->support_disable);
581 _save_column_str(stmt, idx++, &info->process_pool);
582 _save_column_str(stmt, idx++, &info->installed_storage);
583 _save_column_str(stmt, idx++, &bg_category_str);
584 _save_column_str(stmt, idx++, &info->package_type);
585 _save_column_str(stmt, idx++, &info->root_path);
586 _save_column_str(stmt, idx++, &info->api_version);
587 _save_column_str(stmt, idx++, &info->effective_appid);
588 _save_column_str(stmt, idx++, &info->is_disabled);
589 _save_column_str(stmt, idx++, &info->splash_screen_display);
590 _save_column_str(stmt, idx++, &info->tep_name);
591 _save_column_str(stmt, idx++, &info->zip_mount_file);
592 _save_column_str(stmt, idx++, &info->component_type);
593 _save_column_str(stmt, idx++, &info->package);
594 _save_column_str(stmt, idx++, &info->external_path);
595 info->for_all_users =
596 strdup((uid != GLOBAL_USER) ? "false" : "true");
598 if (db_uid == GLOBAL_USER)
599 __get_splash_screen_display(db, info->appid, db_uid,
600 &info->splash_screen_display);
602 info->background_category = __get_background_category(
604 free(bg_category_str);
606 if (flag & PMINFO_APPINFO_GET_LABEL) {
608 _save_column_str(stmt, idx++, &tmp_record);
609 if (_add_label_info_into_list(locale, tmp_record, &info->label)) {
610 ret = PMINFO_R_ERROR;
615 if (flag & PMINFO_APPINFO_GET_ICON) {
617 _save_column_str(stmt, idx++, &tmp_record);
618 if (_add_icon_info_into_list(locale, tmp_record, &info->icon)) {
619 ret = PMINFO_R_ERROR;
624 if (flag & PMINFO_APPINFO_GET_CATEGORY) {
625 if (_appinfo_get_category(db, info->appid,
627 ret = PMINFO_R_ERROR;
632 if (flag & PMINFO_APPINFO_GET_APP_CONTROL) {
633 if (_appinfo_get_app_control(db, info->appid,
634 &info->appcontrol)) {
635 ret = PMINFO_R_ERROR;
640 if (flag & PMINFO_APPINFO_GET_DATA_CONTROL) {
641 if (_appinfo_get_data_control(db, info->appid,
642 &info->datacontrol)) {
643 ret = PMINFO_R_ERROR;
648 if (flag & PMINFO_APPINFO_GET_METADATA) {
649 if (_appinfo_get_metadata(db, info->appid,
651 ret = PMINFO_R_ERROR;
656 if (flag & PMINFO_APPINFO_GET_SPLASH_SCREEN) {
657 if (_appinfo_get_splashscreens(db, info->appid,
658 &info->splashscreens)) {
659 ret = PMINFO_R_ERROR;
664 if (__appinfo_check_installed_storage(info) != PMINFO_R_OK) {
665 ret = PMINFO_R_ERROR;
666 pkgmgrinfo_basic_free_application(info);
671 g_hash_table_insert(applications, (gpointer)info->appid,
681 if (ret != PMINFO_R_OK && info != NULL)
682 pkgmgrinfo_basic_free_application(info);
684 g_list_free_full(bind_params, free);
685 sqlite3_close_v2(db);
686 sqlite3_finalize(stmt);
691 API int pkgmgrinfo_appinfo_get_usr_disabled_appinfo(const char *appid, uid_t uid,
692 pkgmgrinfo_appinfo_h *handle)
697 pkgmgrinfo_appinfo_filter_h filter;
698 pkgmgr_appinfo_x *info;
700 if (appid == NULL || handle == NULL) {
701 LOGE("invalid parameter");
702 return PMINFO_R_EINVAL;
705 locale = _get_system_locale();
707 return PMINFO_R_ERROR;
709 ret = pkgmgrinfo_appinfo_filter_create(&filter);
710 if (ret != PMINFO_R_OK) {
715 ret = pkgmgrinfo_appinfo_filter_add_string(filter,
716 PMINFO_APPINFO_PROP_APP_ID, appid);
717 if (ret != PMINFO_R_OK) {
718 pkgmgrinfo_appinfo_filter_destroy(filter);
720 return PMINFO_R_ERROR;
723 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
724 PMINFO_APPINFO_PROP_APP_DISABLE, true);
725 if (ret != PMINFO_R_OK) {
726 pkgmgrinfo_appinfo_filter_destroy(filter);
728 return PMINFO_R_ERROR;
731 list = g_hash_table_new(g_str_hash, g_str_equal);
733 pkgmgrinfo_appinfo_filter_destroy(filter);
735 return PMINFO_R_ERROR;
738 ret = _appinfo_get_applications(uid, uid, locale, filter,
739 PMINFO_APPINFO_GET_ALL, list);
740 if (!g_hash_table_size(list) && uid != GLOBAL_USER)
741 ret = _appinfo_get_applications(GLOBAL_USER, uid, locale,
742 filter, PMINFO_APPINFO_GET_ALL, list);
744 pkgmgrinfo_appinfo_filter_destroy(filter);
745 if (ret != PMINFO_R_OK) {
746 g_hash_table_destroy(list);
751 if (!g_hash_table_size(list)) {
752 _LOGI("Appinfo for [%s] is not existed for user [%d]",
754 g_hash_table_destroy(list);
756 return PMINFO_R_ENOENT;
759 info = calloc(1, sizeof(pkgmgr_appinfo_x));
761 _LOGE("out of memory");
763 return PMINFO_R_ERROR;
766 info->app_info = (application_x *)g_hash_table_lookup(list, appid);
767 info->locale = locale;
768 info->package = strdup(info->app_info->package);
770 /* just free list only */
771 g_hash_table_destroy(list);
778 API int pkgmgrinfo_appinfo_get_disabled_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
780 return pkgmgrinfo_appinfo_get_usr_disabled_appinfo(appid, _getuid(), handle);
783 API int pkgmgrinfo_appinfo_get_usr_appinfo(const char *appid, uid_t uid,
784 pkgmgrinfo_appinfo_h *handle)
789 pkgmgrinfo_appinfo_filter_h filter;
790 pkgmgr_appinfo_x *info;
792 if (appid == NULL || handle == NULL) {
793 LOGE("invalid parameter");
794 return PMINFO_R_EINVAL;
797 locale = _get_system_locale();
799 return PMINFO_R_ERROR;
801 ret = pkgmgrinfo_appinfo_filter_create(&filter);
802 if (ret != PMINFO_R_OK) {
807 ret = pkgmgrinfo_appinfo_filter_add_string(filter,
808 PMINFO_APPINFO_PROP_APP_ID, appid);
809 if (ret != PMINFO_R_OK) {
810 pkgmgrinfo_appinfo_filter_destroy(filter);
812 return PMINFO_R_ERROR;
815 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
816 PMINFO_APPINFO_PROP_APP_DISABLE, false);
817 if (ret != PMINFO_R_OK) {
818 pkgmgrinfo_appinfo_filter_destroy(filter);
820 return PMINFO_R_ERROR;
823 list = g_hash_table_new(g_str_hash, g_str_equal);
825 pkgmgrinfo_appinfo_filter_destroy(filter);
827 return PMINFO_R_ERROR;
830 ret = _appinfo_get_applications(uid, uid, locale, filter,
831 PMINFO_APPINFO_GET_ALL, list);
832 if (!g_hash_table_size(list) && uid != GLOBAL_USER)
833 ret = _appinfo_get_applications(GLOBAL_USER, uid, locale,
834 filter, PMINFO_APPINFO_GET_ALL, list);
836 pkgmgrinfo_appinfo_filter_destroy(filter);
837 if (ret != PMINFO_R_OK) {
838 g_hash_table_destroy(list);
843 if (!g_hash_table_size(list)) {
844 _LOGI("Appinfo for [%s] is not existed for user [%d]", appid, uid);
845 g_hash_table_destroy(list);
847 return PMINFO_R_ENOENT;
850 info = calloc(1, sizeof(pkgmgr_appinfo_x));
852 _LOGE("out of memory");
854 return PMINFO_R_ERROR;
857 info->app_info = (application_x *)g_hash_table_lookup(list, appid);
858 info->locale = locale;
859 info->package = strdup(info->app_info->package);
861 /* just free list only */
862 g_hash_table_destroy(list);
869 API int pkgmgrinfo_appinfo_get_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
871 return pkgmgrinfo_appinfo_get_usr_appinfo(appid, _getuid(), handle);
874 static gpointer __copy_str(gconstpointer src, gpointer data)
876 const char *tmp = (const char *)src;
879 buffer = strdup(tmp);
880 if (buffer == NULL) {
881 LOGE("memory alloc failed");
889 static gpointer __copy_label(gconstpointer src, gpointer data)
891 label_x *tmp = (label_x *)src;
894 label = calloc(1, sizeof(label_x));
896 LOGE("memory alloc failed");
902 label->name = strdup(tmp->name);
904 label->text = strdup(tmp->text);
906 label->lang = strdup(tmp->lang);
911 static gpointer __copy_icon(gconstpointer src, gpointer data)
913 icon_x *tmp = (icon_x *)src;
916 icon = calloc(1, sizeof(icon_x));
918 LOGE("memory alloc failed");
924 icon->text = strdup(tmp->text);
926 icon->lang = strdup(tmp->lang);
928 icon->section = strdup(tmp->section);
930 icon->size = strdup(tmp->size);
932 icon->resolution = strdup(tmp->resolution);
937 static gpointer __copy_metadata(gconstpointer src, gpointer data)
939 metadata_x *tmp = (metadata_x *)src;
940 metadata_x *metadata;
942 metadata = calloc(1, sizeof(metadata_x));
943 if (metadata == NULL) {
944 LOGE("memory alloc failed");
950 metadata->key = strdup(tmp->key);
952 metadata->value = strdup(tmp->value);
957 static gpointer __copy_datacontrol(gconstpointer src, gpointer data)
959 datacontrol_x *tmp = (datacontrol_x *)src;
960 datacontrol_x *datacontrol;
962 datacontrol = calloc(1, sizeof(datacontrol_x));
963 if (datacontrol == NULL) {
964 LOGE("memory alloc failed");
970 datacontrol->providerid = strdup(tmp->providerid);
972 datacontrol->access = strdup(tmp->access);
974 datacontrol->type = strdup(tmp->type);
979 static gpointer __copy_appcontrol(gconstpointer src, gpointer data)
981 appcontrol_x *tmp = (appcontrol_x *)src;
982 appcontrol_x *appcontrol;
984 appcontrol = calloc(1, sizeof(appcontrol_x));
985 if (appcontrol == NULL) {
986 LOGE("memory alloc failed");
992 appcontrol->operation = strdup(tmp->operation);
994 appcontrol->uri = strdup(tmp->uri);
996 appcontrol->mime = strdup(tmp->mime);
1001 static gpointer __copy_splashscreens(gconstpointer src, gpointer data)
1003 splashscreen_x *tmp = (splashscreen_x *)src;
1004 splashscreen_x *splashscreen;
1006 splashscreen = (splashscreen_x *)calloc(1, sizeof(splashscreen_x));
1007 if (splashscreen == NULL) {
1008 LOGE("memory alloc failed");
1014 splashscreen->src = strdup(tmp->src);
1016 splashscreen->type = strdup(tmp->type);
1017 if (tmp->orientation)
1018 splashscreen->orientation = strdup(tmp->orientation);
1019 if (tmp->indicatordisplay)
1020 splashscreen->indicatordisplay = strdup(tmp->indicatordisplay);
1022 splashscreen->operation = strdup(tmp->operation);
1023 if (tmp->color_depth)
1024 splashscreen->color_depth = strdup(tmp->color_depth);
1026 return splashscreen;
1029 static int _appinfo_copy_appinfo(application_x **application, application_x *data)
1031 application_x *app_info;
1034 app_info = calloc(1, sizeof(application_x));
1035 if (app_info == NULL) {
1036 LOGE("memory alloc failed");
1037 return PMINFO_R_ERROR;
1040 if (data->appid != NULL)
1041 app_info->appid = strdup(data->appid);
1042 if (data->exec != NULL)
1043 app_info->exec = strdup(data->exec);
1044 if (data->nodisplay != NULL)
1045 app_info->nodisplay = strdup(data->nodisplay);
1046 if (data->multiple != NULL)
1047 app_info->multiple = strdup(data->multiple);
1048 if (data->taskmanage != NULL)
1049 app_info->taskmanage = strdup(data->taskmanage);
1050 if (data->enabled != NULL)
1051 app_info->enabled = strdup(data->enabled);
1052 if (data->type != NULL)
1053 app_info->type = strdup(data->type);
1054 if (data->categories != NULL)
1055 app_info->categories = strdup(data->categories);
1056 if (data->hwacceleration != NULL)
1057 app_info->hwacceleration = strdup(data->hwacceleration);
1058 if (data->screenreader != NULL)
1059 app_info->screenreader = strdup(data->screenreader);
1060 if (data->mainapp != NULL)
1061 app_info->mainapp = strdup(data->mainapp);
1062 if (data->package != NULL)
1063 app_info->package = strdup(data->package);
1064 if (data->recentimage != NULL)
1065 app_info->recentimage = strdup(data->recentimage);
1066 if (data->launchcondition != NULL)
1067 app_info->launchcondition = strdup(data->launchcondition);
1068 if (data->indicatordisplay != NULL)
1069 app_info->indicatordisplay = strdup(data->indicatordisplay);
1070 if (data->portraitimg != NULL)
1071 app_info->portraitimg = strdup(data->portraitimg);
1072 if (data->landscapeimg != NULL)
1073 app_info->landscapeimg = strdup(data->landscapeimg);
1074 if (data->guestmode_visibility != NULL)
1075 app_info->guestmode_visibility = strdup(data->guestmode_visibility);
1076 if (data->component != NULL)
1077 app_info->component = strdup(data->component);
1078 if (data->permission_type != NULL)
1079 app_info->permission_type = strdup(data->permission_type);
1080 if (data->component_type != NULL)
1081 app_info->component_type = strdup(data->component_type);
1082 if (data->preload != NULL)
1083 app_info->preload = strdup(data->preload);
1084 if (data->submode != NULL)
1085 app_info->submode = strdup(data->submode);
1086 if (data->submode_mainid != NULL)
1087 app_info->submode_mainid = strdup(data->submode_mainid);
1088 if (data->process_pool != NULL)
1089 app_info->process_pool = strdup(data->process_pool);
1090 if (data->installed_storage != NULL)
1091 app_info->installed_storage = strdup(data->installed_storage);
1092 if (data->autorestart != NULL)
1093 app_info->autorestart = strdup(data->autorestart);
1094 if (data->onboot != NULL)
1095 app_info->onboot = strdup(data->onboot);
1096 if (data->support_disable != NULL)
1097 app_info->support_disable = strdup(data->support_disable);
1098 if (data->ui_gadget != NULL)
1099 app_info->ui_gadget = strdup(data->ui_gadget);
1100 if (data->launch_mode != NULL)
1101 app_info->launch_mode = strdup(data->launch_mode);
1102 if (data->package_type != NULL)
1103 app_info->package_type = strdup(data->package_type);
1104 if (data->effective_appid != NULL)
1105 app_info->effective_appid = strdup(data->effective_appid);
1106 if (data->splash_screen_display != NULL)
1107 app_info->splash_screen_display = strdup(data->splash_screen_display);
1111 app_info->label = g_list_copy_deep(data->label, __copy_label, &ret);
1113 LOGE("memory alloc failed");
1114 pkgmgrinfo_basic_free_application(app_info);
1115 return PMINFO_R_ERROR;
1119 app_info->icon = g_list_copy_deep(data->icon, __copy_icon, &ret);
1121 LOGE("memory alloc failed");
1122 pkgmgrinfo_basic_free_application(app_info);
1123 return PMINFO_R_ERROR;
1127 app_info->category = g_list_copy_deep(data->category, __copy_str, &ret);
1129 LOGE("memory alloc failed");
1130 pkgmgrinfo_basic_free_application(app_info);
1131 return PMINFO_R_ERROR;
1135 app_info->metadata = g_list_copy_deep(data->metadata, __copy_metadata, &ret);
1137 LOGE("memory alloc failed");
1138 pkgmgrinfo_basic_free_application(app_info);
1139 return PMINFO_R_ERROR;
1143 app_info->datacontrol = g_list_copy_deep(data->datacontrol, __copy_datacontrol, &ret);
1145 LOGE("memory alloc failed");
1146 pkgmgrinfo_basic_free_application(app_info);
1147 return PMINFO_R_ERROR;
1151 app_info->appcontrol = g_list_copy_deep(data->appcontrol, __copy_appcontrol, &ret);
1153 LOGE("memory alloc failed");
1154 pkgmgrinfo_basic_free_application(app_info);
1155 return PMINFO_R_ERROR;
1159 app_info->background_category = g_list_copy_deep(data->background_category, __copy_str, &ret);
1161 LOGE("memory alloc failed");
1162 pkgmgrinfo_basic_free_application(app_info);
1163 return PMINFO_R_ERROR;
1167 app_info->splashscreens = g_list_copy_deep(data->splashscreens, __copy_splashscreens, &ret);
1169 LOGE("memory alloc failed");
1170 pkgmgrinfo_basic_free_application(app_info);
1171 return PMINFO_R_ERROR;
1174 *application = app_info;
1179 API int pkgmgrinfo_appinfo_clone_appinfo(pkgmgrinfo_appinfo_h handle,
1180 pkgmgrinfo_appinfo_h *clone)
1182 pkgmgr_appinfo_x *info;
1183 pkgmgr_appinfo_x *temp = (pkgmgr_appinfo_x *)handle;
1186 return PMINFO_R_EINVAL;
1188 info = calloc(1, sizeof(pkgmgr_appinfo_x));
1190 LOGE("memory alloc failed");
1191 return PMINFO_R_ERROR;
1194 if (temp->package != NULL)
1195 info->package = strdup(temp->package);
1196 if (temp->locale != NULL)
1197 info->locale = strdup(temp->locale);
1199 info->app_component = temp->app_component;
1201 if (_appinfo_copy_appinfo(&info->app_info, temp->app_info) < 0) {
1202 LOGE("appinfo copy failed");
1204 free((void *)info->package);
1208 return PMINFO_R_ERROR;
1216 static int _appinfo_get_filtered_foreach_appinfo(uid_t uid,
1217 pkgmgrinfo_filter_x *filter, int flag, pkgmgrinfo_app_list_cb app_list_cb,
1223 pkgmgr_appinfo_x info;
1225 GHashTableIter iter;
1228 locale = _get_system_locale();
1230 return PMINFO_R_ERROR;
1232 list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
1233 __free_applications);
1236 return PMINFO_R_ERROR;
1239 ret = _appinfo_get_applications(uid, uid, locale, filter, flag, list);
1240 if (ret == PMINFO_R_OK && uid != GLOBAL_USER)
1241 ret = _appinfo_get_applications(GLOBAL_USER, uid, locale,
1242 filter, flag, list);
1244 if (ret != PMINFO_R_OK) {
1245 g_hash_table_destroy(list);
1250 g_hash_table_iter_init(&iter, list);
1251 while (g_hash_table_iter_next(&iter, NULL, &value)) {
1252 app = (application_x *)value;
1253 info.app_info = app;
1254 info.locale = locale;
1255 info.package = app->package;
1256 if (app_list_cb(&info, user_data) < 0)
1259 g_hash_table_destroy(list);
1265 static const char *__appcomponent_str(pkgmgrinfo_app_component comp);
1267 API int pkgmgrinfo_appinfo_get_usr_list(pkgmgrinfo_pkginfo_h handle,
1268 pkgmgrinfo_app_component component,
1269 pkgmgrinfo_app_list_cb app_func, void *user_data, uid_t uid)
1272 pkgmgrinfo_appinfo_filter_h filter;
1274 const char *comp_str = NULL;
1276 if (handle == NULL || app_func == NULL) {
1277 LOGE("invalid parameter");
1278 return PMINFO_R_EINVAL;
1281 if (pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid)) {
1282 LOGE("invalid parameter");
1283 return PMINFO_R_EINVAL;
1286 if (pkgmgrinfo_appinfo_filter_create(&filter))
1287 return PMINFO_R_ERROR;
1289 if (pkgmgrinfo_appinfo_filter_add_string(filter,
1290 PMINFO_APPINFO_PROP_APP_PACKAGE, pkgid)) {
1291 pkgmgrinfo_appinfo_filter_destroy(filter);
1292 return PMINFO_R_ERROR;
1295 if (uid == GLOBAL_USER) {
1296 if (pkgmgrinfo_appinfo_filter_add_int(filter,
1297 PMINFO_APPINFO_PROP_APP_DISABLE_FOR_USER,
1299 pkgmgrinfo_appinfo_filter_destroy(filter);
1300 return PMINFO_R_ERROR;
1304 comp_str = __appcomponent_str(component);
1307 if (pkgmgrinfo_appinfo_filter_add_string(filter,
1308 PMINFO_APPINFO_PROP_APP_COMPONENT,
1310 pkgmgrinfo_appinfo_filter_destroy(filter);
1311 return PMINFO_R_ERROR;
1315 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter,
1316 PMINFO_APPINFO_GET_ALL, app_func, user_data);
1318 pkgmgrinfo_appinfo_filter_destroy(filter);
1323 API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle,
1324 pkgmgrinfo_app_component component,
1325 pkgmgrinfo_app_list_cb app_func, void *user_data)
1327 return pkgmgrinfo_appinfo_get_usr_list(handle, component, app_func, user_data, _getuid());
1330 API int pkgmgrinfo_appinfo_get_usr_installed_list_full(
1331 pkgmgrinfo_app_list_cb app_func, uid_t uid, int flag,
1335 pkgmgrinfo_appinfo_filter_h filter;
1337 if (app_func == NULL) {
1338 LOGE("invalid parameter");
1339 return PMINFO_R_EINVAL;
1342 if (pkgmgrinfo_appinfo_filter_create(&filter))
1343 return PMINFO_R_ERROR;
1345 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
1346 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
1347 pkgmgrinfo_appinfo_filter_destroy(filter);
1348 return PMINFO_R_ERROR;
1351 if (uid == GLOBAL_USER) {
1352 if (pkgmgrinfo_appinfo_filter_add_int(filter,
1353 PMINFO_APPINFO_PROP_APP_DISABLE_FOR_USER,
1355 pkgmgrinfo_appinfo_filter_destroy(filter);
1356 return PMINFO_R_ERROR;
1360 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter, flag, app_func,
1363 pkgmgrinfo_appinfo_filter_destroy(filter);
1368 API int pkgmgrinfo_appinfo_get_installed_list_full(
1369 pkgmgrinfo_app_list_cb app_func, int flag, void *user_data)
1371 return pkgmgrinfo_appinfo_get_usr_installed_list_full(app_func,
1372 _getuid(), flag, user_data);
1375 API int pkgmgrinfo_appinfo_get_usr_install_list(pkgmgrinfo_app_list_cb app_func,
1376 uid_t uid, void *user_data)
1378 return pkgmgrinfo_appinfo_get_usr_installed_list_full(app_func,
1379 uid, PMINFO_APPINFO_GET_ALL, user_data);
1382 API int pkgmgrinfo_appinfo_get_install_list(pkgmgrinfo_app_list_cb app_func,
1385 return pkgmgrinfo_appinfo_get_usr_installed_list_full(app_func,
1386 _getuid(), PMINFO_APPINFO_GET_ALL, user_data);
1389 API int pkgmgrinfo_appinfo_get_usr_installed_list(
1390 pkgmgrinfo_app_list_cb app_func, uid_t uid, void *user_data)
1392 if (app_func == NULL) {
1393 LOGE("invalid parameter");
1394 return PMINFO_R_EINVAL;
1397 return _appinfo_get_filtered_foreach_appinfo(uid, NULL,
1398 PMINFO_APPINFO_GET_ALL, app_func, user_data);
1401 API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func,
1404 return pkgmgrinfo_appinfo_get_usr_installed_list(app_func, _getuid(),
1408 API int pkgmgrinfo_appinfo_get_appid(pkgmgrinfo_appinfo_h handle, char **appid)
1410 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1412 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1413 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1415 if (info->app_info == NULL || info->app_info->appid == NULL)
1416 return PMINFO_R_ERROR;
1417 *appid = (char *)info->app_info->appid;
1422 API int pkgmgrinfo_appinfo_get_pkgname(pkgmgrinfo_appinfo_h handle, char **pkg_name)
1424 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1426 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1427 retvm_if(pkg_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1429 if (info->package == NULL)
1430 return PMINFO_R_ERROR;
1432 *pkg_name = (char *)info->package;
1437 API int pkgmgrinfo_appinfo_get_pkgid(pkgmgrinfo_appinfo_h handle, char **pkgid)
1439 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1441 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1442 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1444 if (info->package == NULL)
1445 return PMINFO_R_ERROR;
1447 *pkgid = (char *)info->package;
1452 API int pkgmgrinfo_appinfo_get_pkgtype(pkgmgrinfo_appinfo_h handle, char **pkgtype)
1454 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1455 retvm_if(pkgtype == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1456 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1458 *pkgtype = (char *)info->app_info->package_type;
1463 API int pkgmgrinfo_appinfo_get_exec(pkgmgrinfo_appinfo_h handle, char **exec)
1465 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1467 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1468 retvm_if(exec == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1470 if (info->app_info == NULL || info->app_info->exec == NULL)
1471 return PMINFO_R_ERROR;
1472 *exec = (char *)info->app_info->exec;
1478 API int pkgmgrinfo_appinfo_get_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1481 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1483 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1484 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1486 if (info->app_info == NULL)
1487 return PMINFO_R_ERROR;
1489 if (info->app_info->icon == NULL) {
1494 ptr = (icon_x *)info->app_info->icon->data;
1496 return PMINFO_R_ERROR;
1498 if (ptr->text == NULL)
1499 return PMINFO_R_ERROR;
1507 API int pkgmgrinfo_appinfo_get_label(pkgmgrinfo_appinfo_h handle, char **label)
1510 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1512 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1513 retvm_if(label == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1515 if (info->app_info == NULL || info->app_info->label == NULL)
1516 return PMINFO_R_ERROR;
1518 ptr = (label_x *)info->app_info->label->data;
1520 return PMINFO_R_ERROR;
1522 if (ptr->text == NULL)
1523 return PMINFO_R_ERROR;
1530 static char *_get_localed_label(const char *appid, const char *locale, uid_t uid)
1532 char *result = NULL;
1534 sqlite3_stmt *stmt = NULL;
1539 parser_db = getUserPkgParserDBPathUID(uid);
1540 if (parser_db == NULL) {
1541 _LOGE("Failed to get parser db path");
1545 if (sqlite3_open_v2(parser_db, &db, SQLITE_OPEN_READONLY, NULL) != SQLITE_OK) {
1546 _LOGE("DB open fail\n");
1552 query = sqlite3_mprintf("select app_label from package_app_localized_info where app_id=%Q and app_locale=%Q", appid, locale);
1553 if (query == NULL) {
1554 _LOGE("Out of memory");
1558 if (sqlite3_prepare_v2(db, query, -1, &stmt, NULL) != SQLITE_OK) {
1559 _LOGE("prepare_v2 fail\n");
1563 if (sqlite3_step(stmt) == SQLITE_ROW) {
1564 val = (char *)sqlite3_column_text(stmt, 0);
1566 result = strdup(val);
1570 sqlite3_finalize(stmt);
1571 sqlite3_free(query);
1577 API int pkgmgrinfo_appinfo_usr_get_localed_label(const char *appid, const char *locale, uid_t uid, char **label)
1581 retvm_if(appid == NULL || locale == NULL || label == NULL, PMINFO_R_EINVAL, "Argument is NULL");
1583 val = _get_localed_label(appid, locale, uid);
1585 val = _get_localed_label(appid, DEFAULT_LOCALE, uid);
1588 return PMINFO_R_ERROR;
1595 API int pkgmgrinfo_appinfo_get_localed_label(const char *appid, const char *locale, char **label)
1597 return pkgmgrinfo_appinfo_usr_get_localed_label(appid, locale, _getuid(), label);
1600 API int pkgmgrinfo_appinfo_get_metadata_value(pkgmgrinfo_appinfo_h handle, const char *metadata_key, char **metadata_value)
1602 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1603 retvm_if(metadata_key == NULL, PMINFO_R_EINVAL, "metadata_key is NULL");
1604 retvm_if(metadata_value == NULL, PMINFO_R_EINVAL, "metadata_value is NULL");
1606 GList *list_md = NULL;
1607 metadata_x *metadata = NULL;
1608 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1610 list_md = info->app_info->metadata;
1612 for (; list_md; list_md = list_md->next) {
1613 metadata = (metadata_x *)list_md->data;
1614 if (metadata && metadata->key) {
1615 if (strcasecmp(metadata->key, metadata_key) == 0) {
1616 if (metadata->value == NULL)
1617 *metadata_value = "";
1619 *metadata_value = (char*)metadata->value;
1625 return PMINFO_R_EINVAL;
1628 static pkgmgrinfo_app_component __appcomponent_convert(const char *comp)
1630 if (strcasecmp(comp, "uiapp") == 0)
1631 return PMINFO_UI_APP;
1632 else if (strcasecmp(comp, "svcapp") == 0)
1633 return PMINFO_SVC_APP;
1634 else if (strcasecmp(comp, "widgetapp") == 0)
1635 return PMINFO_WIDGET_APP;
1636 else if (strcasecmp(comp, "watchapp") == 0)
1637 return PMINFO_WATCH_APP;
1642 static const char *__appcomponent_str(pkgmgrinfo_app_component comp)
1647 case PMINFO_SVC_APP:
1649 case PMINFO_WIDGET_APP:
1651 case PMINFO_WATCH_APP:
1658 API int pkgmgrinfo_appinfo_get_component(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_component *component)
1660 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1663 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1664 retvm_if(component == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1666 if (info->app_info == NULL)
1667 return PMINFO_R_ERROR;
1669 comp = __appcomponent_convert(info->app_info->component);
1671 return PMINFO_R_ERROR;
1678 API int pkgmgrinfo_appinfo_get_apptype(pkgmgrinfo_appinfo_h handle, char **app_type)
1680 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1682 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1683 retvm_if(app_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1685 if (info->app_info == NULL || info->app_info->type == NULL)
1686 return PMINFO_R_ERROR;
1687 *app_type = (char *)info->app_info->type;
1692 API int pkgmgrinfo_appinfo_get_operation(pkgmgrinfo_appcontrol_h handle,
1693 int *operation_count, char ***operation)
1695 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1696 retvm_if(operation == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1697 retvm_if(operation_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1698 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1699 *operation_count = data->operation_count;
1700 *operation = data->operation;
1704 API int pkgmgrinfo_appinfo_get_uri(pkgmgrinfo_appcontrol_h handle,
1705 int *uri_count, char ***uri)
1707 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1708 retvm_if(uri == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1709 retvm_if(uri_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1710 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1711 *uri_count = data->uri_count;
1716 API int pkgmgrinfo_appinfo_get_mime(pkgmgrinfo_appcontrol_h handle,
1717 int *mime_count, char ***mime)
1719 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1720 retvm_if(mime == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1721 retvm_if(mime_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1722 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1723 *mime_count = data->mime_count;
1728 API int pkgmgrinfo_appinfo_get_subapp(pkgmgrinfo_appcontrol_h handle,
1729 int *subapp_count, char ***subapp)
1731 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1732 retvm_if(subapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1733 retvm_if(subapp_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1734 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1735 *subapp_count = data->subapp_count;
1736 *subapp = data->subapp;
1740 API int pkgmgrinfo_appinfo_get_setting_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1745 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1747 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1748 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1750 if (info->app_info == NULL)
1751 return PMINFO_R_ERROR;
1753 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1754 ptr = (icon_x *)tmp->data;
1755 if (ptr == NULL || ptr->section == NULL)
1758 val = (char *)ptr->section;
1759 if (val && strcmp(val, "setting") == 0) {
1760 *icon = (char *)ptr->text;
1765 return PMINFO_R_ERROR;
1769 API int pkgmgrinfo_appinfo_get_notification_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1774 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1776 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1777 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1779 if (info->app_info == NULL)
1780 return PMINFO_R_ERROR;
1782 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1783 ptr = (icon_x *)tmp->data;
1784 if (ptr == NULL || ptr->section == NULL)
1787 val = (char *)ptr->section;
1788 if (val && strcmp(val, "notification") == 0) {
1789 *icon = (char *)ptr->text;
1794 return PMINFO_R_ERROR;
1797 API int pkgmgrinfo_appinfo_get_recent_image_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_recentimage *type)
1800 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1802 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1803 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1805 if (info->app_info == NULL || info->app_info->recentimage == NULL)
1806 return PMINFO_R_ERROR;
1808 val = (char *)info->app_info->recentimage;
1809 if (strcasecmp(val, "capture") == 0)
1810 *type = PMINFO_RECENTIMAGE_USE_CAPTURE;
1811 else if (strcasecmp(val, "icon") == 0)
1812 *type = PMINFO_RECENTIMAGE_USE_ICON;
1814 *type = PMINFO_RECENTIMAGE_USE_NOTHING;
1819 API int pkgmgrinfo_appinfo_get_preview_image(pkgmgrinfo_appinfo_h handle, char **preview_img)
1824 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1826 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1827 retvm_if(preview_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1829 if (info->app_info == NULL)
1830 return PMINFO_R_ERROR;
1832 for (tmp = info->app_info->image; tmp; tmp = tmp->next) {
1833 ptr = (image_x *)tmp->data;
1834 if (ptr == NULL || ptr->section == NULL)
1837 val = (char *)ptr->section;
1838 if (val && strcmp(val, "preview") == 0) {
1839 *preview_img = (char *)ptr->text;
1844 return PMINFO_R_ERROR;
1847 API int pkgmgrinfo_appinfo_get_permission_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_permission_type *permission)
1850 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1852 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1853 retvm_if(permission == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1855 val = info->app_info->permission_type;
1857 return PMINFO_R_ERROR;
1859 if (strcmp(val, "signature") == 0)
1860 *permission = PMINFO_PERMISSION_SIGNATURE;
1861 else if (strcmp(val, "privilege") == 0)
1862 *permission = PMINFO_PERMISSION_PRIVILEGE;
1864 *permission = PMINFO_PERMISSION_NORMAL;
1869 API int pkgmgrinfo_appinfo_get_component_type(pkgmgrinfo_appinfo_h handle, char **component_type)
1871 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1873 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1874 retvm_if(component_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1876 if (info->app_info == NULL || info->app_info->component_type == NULL)
1877 return PMINFO_R_ERROR;
1879 *component_type = (char *)info->app_info->component_type;
1884 API int pkgmgrinfo_appinfo_get_hwacceleration(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_hwacceleration *hwacceleration)
1887 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1889 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1890 retvm_if(hwacceleration == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1892 if (info->app_info == NULL || info->app_info->hwacceleration == NULL)
1893 return PMINFO_R_ERROR;
1895 val = (char *)info->app_info->hwacceleration;
1896 if (strcasecmp(val, "off") == 0)
1897 *hwacceleration = PMINFO_HWACCELERATION_OFF;
1898 else if (strcasecmp(val, "on") == 0)
1899 *hwacceleration = PMINFO_HWACCELERATION_ON;
1901 *hwacceleration = PMINFO_HWACCELERATION_DEFAULT;
1906 API int pkgmgrinfo_appinfo_get_screenreader(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_screenreader *screenreader)
1909 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1911 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1912 retvm_if(screenreader == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1914 if (info->app_info == NULL || info->app_info->screenreader == NULL)
1915 return PMINFO_R_ERROR;
1917 val = (char *)info->app_info->screenreader;
1918 if (strcasecmp(val, "screenreader-off") == 0)
1919 *screenreader = PMINFO_SCREENREADER_OFF;
1920 else if (strcasecmp(val, "screenreader-on") == 0)
1921 *screenreader = PMINFO_SCREENREADER_ON;
1923 *screenreader = PMINFO_SCREENREADER_USE_SYSTEM_SETTING;
1928 API int pkgmgrinfo_appinfo_get_effectimage(pkgmgrinfo_appinfo_h handle, char **portrait_img, char **landscape_img)
1930 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1932 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1933 retvm_if(portrait_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1934 retvm_if(landscape_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1936 if (info->app_info == NULL)
1937 return PMINFO_R_ERROR;
1939 if (info->app_info->portraitimg == NULL)
1942 *portrait_img = (char *)info->app_info->portraitimg;
1944 if (info->app_info->landscapeimg == NULL)
1945 *landscape_img = "";
1947 *landscape_img = (char *)info->app_info->landscapeimg;
1952 API int pkgmgrinfo_appinfo_get_effectimage_type(pkgmgrinfo_appinfo_h handle, char **effectimage_type)
1954 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1956 if (handle == NULL || effectimage_type == NULL) {
1957 LOGE("invalid parameter");
1958 return PMINFO_R_EINVAL;
1961 if (info->app_info == NULL || info->app_info->effectimage_type == NULL)
1962 return PMINFO_R_ERROR;
1964 *effectimage_type = (char *)info->app_info->effectimage_type;
1969 API int pkgmgrinfo_appinfo_get_submode_mainid(pkgmgrinfo_appinfo_h handle, char **submode_mainid)
1971 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1973 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1974 retvm_if(submode_mainid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1976 if (info->app_info == NULL)
1977 return PMINFO_R_ERROR;
1979 if (info->app_info->submode_mainid == NULL)
1980 *submode_mainid = "";
1982 *submode_mainid = (char *)info->app_info->submode_mainid;
1987 API int pkgmgrinfo_appinfo_get_installed_storage_location(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_installed_storage *storage)
1989 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1990 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1992 if (info->app_info && info->app_info->installed_storage) {
1993 if (strcmp(info->app_info->installed_storage, "installed_internal") == 0)
1994 *storage = PMINFO_INTERNAL_STORAGE;
1995 else if (strcmp(info->app_info->installed_storage, "installed_external") == 0)
1996 *storage = PMINFO_EXTERNAL_STORAGE;
1998 return PMINFO_R_ERROR;
2000 return PMINFO_R_ERROR;
2006 API int pkgmgrinfo_appinfo_get_launch_mode(pkgmgrinfo_appinfo_h handle, char **mode)
2008 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2010 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2011 retvm_if(mode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2013 if (info->app_info->launch_mode == NULL)
2014 return PMINFO_R_ERROR;
2016 *mode = (char *)(info->app_info->launch_mode);
2021 API int pkgmgrinfo_appinfo_get_alias_appid(pkgmgrinfo_appinfo_h handle, char **alias_appid)
2023 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2025 if (handle == NULL || alias_appid == NULL) {
2026 LOGE("invalid parameter");
2027 return PMINFO_R_EINVAL;
2030 if (info->app_info == NULL || info->app_info->alias_appid == NULL)
2031 return PMINFO_R_ERROR;
2033 *alias_appid = (char *)info->app_info->alias_appid;
2038 API int pkgmgrinfo_appinfo_get_effective_appid(pkgmgrinfo_appinfo_h handle, char **effective_appid)
2040 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2042 if (handle == NULL || effective_appid == NULL) {
2043 LOGE("invalid parameter");
2044 return PMINFO_R_EINVAL;
2047 if (info->app_info == NULL)
2048 return PMINFO_R_ERROR;
2050 if (info->app_info->effective_appid == NULL)
2051 *effective_appid = "";
2053 *effective_appid = (char *)info->app_info->effective_appid;
2058 API int pkgmgrinfo_appinfo_get_tep_name(pkgmgrinfo_appinfo_h handle, char **tep_name)
2060 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2062 if (handle == NULL || tep_name == NULL) {
2063 LOGE("invalid parameter");
2064 return PMINFO_R_EINVAL;
2067 if (info->app_info == NULL)
2068 return PMINFO_R_ERROR;
2070 if (info->app_info->tep_name == NULL)
2073 *tep_name = (char *)info->app_info->tep_name;
2078 API int pkgmgrinfo_appinfo_get_zip_mount_file(pkgmgrinfo_appinfo_h handle, char **zip_mount_file)
2080 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2082 if (handle == NULL || zip_mount_file == NULL) {
2083 LOGE("invalid parameter");
2084 return PMINFO_R_EINVAL;
2087 if (info->app_info == NULL)
2088 return PMINFO_R_ERROR;
2090 if (info->app_info->zip_mount_file == NULL)
2091 *zip_mount_file = "";
2093 *zip_mount_file = (char *)info->app_info->zip_mount_file;
2098 API int pkgmgrinfo_appinfo_get_root_path(pkgmgrinfo_appinfo_h handle, char **root_path)
2100 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2102 if (handle == NULL || root_path == NULL) {
2103 LOGE("invalid parameter");
2104 return PMINFO_R_EINVAL;
2107 if (info->app_info == NULL || info->app_info->root_path == NULL)
2108 return PMINFO_R_ERROR;
2110 *root_path = (char *)info->app_info->root_path;
2115 API int pkgmgrinfo_appinfo_get_api_version(pkgmgrinfo_appinfo_h handle, char **api_version)
2117 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2119 if (handle == NULL || api_version == NULL) {
2120 LOGE("invalid parameter");
2121 return PMINFO_R_EINVAL;
2124 if (info->app_info == NULL || info->app_info->api_version == NULL)
2125 return PMINFO_R_ERROR;
2127 *api_version = (char *)info->app_info->api_version;
2132 API int pkgmgrinfo_appinfo_usr_get_datacontrol_info(const char *providerid, const char *type, uid_t uid, char **appid, char **access)
2134 retvm_if(providerid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
2135 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
2136 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2137 retvm_if(access == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2139 int ret = PMINFO_R_OK;
2141 sqlite3_stmt *stmt = NULL;
2144 ret = __open_manifest_db(uid, true);
2145 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
2147 /*Start constructing query*/
2148 query = sqlite3_mprintf("select * from package_app_data_control where providerid=%Q and type=%Q", providerid, type);
2149 tryvm_if(query == NULL, ret = PMINFO_R_ERROR, "Out of memory");
2152 ret = sqlite3_prepare_v2(GET_DB(manifest_db), query, strlen(query), &stmt, NULL);
2153 tryvm_if(ret != PMINFO_R_OK, ret = PMINFO_R_ERROR, "sqlite3_prepare_v2 failed[%s]\n", query);
2156 ret = sqlite3_step(stmt);
2157 tryvm_if((ret != SQLITE_ROW) || (ret == SQLITE_DONE), ret = PMINFO_R_ERROR, "No records found");
2159 *appid = strdup((char *)sqlite3_column_text(stmt, 0));
2160 *access = strdup((char *)sqlite3_column_text(stmt, 2));
2165 sqlite3_free(query);
2166 sqlite3_finalize(stmt);
2167 __close_manifest_db();
2171 API int pkgmgrinfo_appinfo_get_datacontrol_info(const char *providerid, const char *type, char **appid, char **access)
2173 return pkgmgrinfo_appinfo_usr_get_datacontrol_info(providerid, type, _getuid(), appid, access);
2176 API int pkgmgrinfo_appinfo_usr_get_datacontrol_appid(const char *providerid, uid_t uid, char **appid)
2178 retvm_if(providerid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
2179 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2181 int ret = PMINFO_R_OK;
2183 sqlite3_stmt *stmt = NULL;
2186 ret = __open_manifest_db(uid, true);
2187 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
2189 /*Start constructing query*/
2190 query = sqlite3_mprintf("select * from package_app_data_control where providerid=%Q", providerid);
2191 tryvm_if(query == NULL, ret = PMINFO_R_ERROR, "Out of memory");
2194 ret = sqlite3_prepare_v2(GET_DB(manifest_db), query, strlen(query), &stmt, NULL);
2195 tryvm_if(ret != PMINFO_R_OK, ret = PMINFO_R_ERROR, "sqlite3_prepare_v2 failed[%s]\n", query);
2198 ret = sqlite3_step(stmt);
2199 tryvm_if((ret != SQLITE_ROW) || (ret == SQLITE_DONE), ret = PMINFO_R_ERROR, "No records found");
2201 *appid = strdup((char *)sqlite3_column_text(stmt, 0));
2206 sqlite3_free(query);
2207 sqlite3_finalize(stmt);
2208 __close_manifest_db();
2212 API int pkgmgrinfo_appinfo_get_datacontrol_appid(const char *providerid, char **appid)
2214 return pkgmgrinfo_appinfo_usr_get_datacontrol_appid(providerid, _getuid(), appid);
2217 API int pkgmgrinfo_appinfo_foreach_permission(pkgmgrinfo_appinfo_h handle,
2218 pkgmgrinfo_app_permission_list_cb permission_func, void *user_data)
2220 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2221 retvm_if(permission_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2225 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2227 if (info->app_info == NULL)
2228 return PMINFO_R_ERROR;
2230 for (tmp = info->app_info->permission; tmp; tmp = tmp->next) {
2231 ptr = (permission_x *)tmp->data;
2235 ret = permission_func(ptr->value, user_data);
2243 API int pkgmgrinfo_appinfo_foreach_category(pkgmgrinfo_appinfo_h handle,
2244 pkgmgrinfo_app_category_list_cb category_func, void *user_data)
2246 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2247 retvm_if(category_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2249 const char *category;
2251 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2253 if (info->app_info == NULL)
2254 return PMINFO_R_ERROR;
2256 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
2257 category = (const char *)tmp->data;
2259 ret = category_func(category, user_data);
2267 API int pkgmgrinfo_appinfo_foreach_metadata(pkgmgrinfo_appinfo_h handle,
2268 pkgmgrinfo_app_metadata_list_cb metadata_func, void *user_data)
2270 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2271 retvm_if(metadata_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2275 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2277 if (info->app_info == NULL)
2278 return PMINFO_R_ERROR;
2280 for (tmp = info->app_info->metadata; tmp; tmp = tmp->next) {
2281 ptr = (metadata_x *)tmp->data;
2285 ret = metadata_func(ptr->key, ptr->value ? ptr->value : "", user_data);
2293 API int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
2294 pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
2296 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2297 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2299 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2300 appcontrol_x *appcontrol;
2303 if (info->app_info == NULL)
2304 return PMINFO_R_ERROR;
2306 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
2307 appcontrol = (appcontrol_x *)tmp->data;
2308 if (appcontrol == NULL)
2310 ret = appcontrol_func(appcontrol->operation, appcontrol->uri, appcontrol->mime, user_data);
2318 API int pkgmgrinfo_appinfo_foreach_background_category(
2319 pkgmgrinfo_appinfo_h handle,
2320 pkgmgrinfo_app_background_category_list_cb category_func,
2323 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2327 if (handle == NULL || category_func == NULL || info->app_info == NULL) {
2328 LOGE("invalid parameter");
2329 return PMINFO_R_EINVAL;
2332 for (tmp = info->app_info->background_category; tmp; tmp = tmp->next) {
2333 category = (char *)tmp->data;
2334 if (category == NULL)
2337 if (category_func(category, user_data) < 0)
2344 API int pkgmgrinfo_appinfo_foreach_splash_screen(pkgmgrinfo_appinfo_h handle,
2345 pkgmgrinfo_app_splash_screen_list_cb splash_screen_func,
2348 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2349 splashscreen_x *splashscreen;
2353 if (info == NULL || info->app_info == NULL
2354 || splash_screen_func == NULL) {
2355 LOGE("invalid parameter");
2356 return PMINFO_R_EINVAL;
2359 for (tmp = info->app_info->splashscreens; tmp; tmp = tmp->next) {
2360 splashscreen = (splashscreen_x *)tmp->data;
2361 if (splashscreen == NULL)
2363 ret = splash_screen_func(splashscreen->src,
2365 splashscreen->orientation,
2366 splashscreen->indicatordisplay,
2367 splashscreen->operation,
2368 splashscreen->color_depth,
2377 API int pkgmgrinfo_appinfo_is_nodisplay(pkgmgrinfo_appinfo_h handle, bool *nodisplay)
2379 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2380 retvm_if(nodisplay == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2381 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2383 if (info->app_info == NULL || info->app_info->nodisplay == NULL)
2384 return PMINFO_R_ERROR;
2386 *nodisplay = _get_bool_value(info->app_info->nodisplay);
2391 API int pkgmgrinfo_appinfo_is_multiple(pkgmgrinfo_appinfo_h handle, bool *multiple)
2393 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2394 retvm_if(multiple == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2395 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2397 if (info->app_info == NULL || info->app_info->multiple == NULL)
2398 return PMINFO_R_ERROR;
2400 *multiple = _get_bool_value(info->app_info->multiple);
2405 API int pkgmgrinfo_appinfo_is_indicator_display_allowed(pkgmgrinfo_appinfo_h handle, bool *indicator_disp)
2407 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2408 retvm_if(indicator_disp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2409 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2411 if (info->app_info == NULL || info->app_info->indicatordisplay == NULL)
2412 return PMINFO_R_ERROR;
2414 *indicator_disp = _get_bool_value(info->app_info->indicatordisplay);
2419 API int pkgmgrinfo_appinfo_is_taskmanage(pkgmgrinfo_appinfo_h handle, bool *taskmanage)
2421 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2422 retvm_if(taskmanage == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2423 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2425 if (info->app_info == NULL || info->app_info->taskmanage == NULL)
2426 return PMINFO_R_ERROR;
2428 *taskmanage = _get_bool_value(info->app_info->taskmanage);
2433 API int pkgmgrinfo_appinfo_is_enabled(pkgmgrinfo_appinfo_h handle, bool *enabled)
2435 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2436 retvm_if(enabled == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2437 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2439 if (info->app_info == NULL || info->app_info->enabled == NULL)
2440 return PMINFO_R_ERROR;
2442 *enabled = _get_bool_value(info->app_info->enabled);
2447 API int pkgmgrinfo_appinfo_is_onboot(pkgmgrinfo_appinfo_h handle, bool *onboot)
2449 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2450 retvm_if(onboot == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2451 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2453 if (info->app_info == NULL || info->app_info->onboot == NULL)
2454 return PMINFO_R_ERROR;
2456 *onboot = _get_bool_value(info->app_info->onboot);
2461 API int pkgmgrinfo_appinfo_is_autorestart(pkgmgrinfo_appinfo_h handle, bool *autorestart)
2463 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2464 retvm_if(autorestart == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2465 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2467 if (info->app_info == NULL || info->app_info->autorestart == NULL)
2468 return PMINFO_R_ERROR;
2470 *autorestart = _get_bool_value(info->app_info->autorestart);
2475 API int pkgmgrinfo_appinfo_is_mainapp(pkgmgrinfo_appinfo_h handle, bool *mainapp)
2477 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2478 retvm_if(mainapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2479 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2481 if (info->app_info == NULL || info->app_info->mainapp == NULL)
2482 return PMINFO_R_ERROR;
2484 *mainapp = _get_bool_value(info->app_info->mainapp);
2489 API int pkgmgrinfo_appinfo_is_preload(pkgmgrinfo_appinfo_h handle, bool *preload)
2491 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2492 retvm_if(preload == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2493 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2495 if (info->app_info == NULL || info->app_info->preload == NULL)
2496 return PMINFO_R_ERROR;
2498 *preload = _get_bool_value(info->app_info->preload);
2503 API int pkgmgrinfo_appinfo_is_submode(pkgmgrinfo_appinfo_h handle, bool *submode)
2505 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2506 retvm_if(submode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2507 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2509 if (info->app_info == NULL || info->app_info->submode == NULL)
2510 return PMINFO_R_ERROR;
2512 *submode = _get_bool_value(info->app_info->submode);
2517 API int pkgmgrinfo_appinfo_is_process_pool(pkgmgrinfo_appinfo_h handle, bool *process_pool)
2519 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2521 if (handle == NULL || process_pool == NULL) {
2522 LOGE("invalid parameter");
2523 return PMINFO_R_EINVAL;
2526 if (info->app_info == NULL)
2527 return PMINFO_R_ERROR;
2529 *process_pool = _get_bool_value(info->app_info->process_pool);
2534 API int pkgmgrinfo_appinfo_is_category_exist(pkgmgrinfo_appinfo_h handle, const char *category, bool *exist)
2536 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2537 retvm_if(category == NULL, PMINFO_R_EINVAL, "category is NULL");
2538 retvm_if(exist == NULL, PMINFO_R_EINVAL, "exist is NULL");
2542 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2544 if (info->app_info == NULL)
2545 return PMINFO_R_ERROR;
2548 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
2549 val = (const char *)tmp->data;
2552 if (strcasecmp(val, category) == 0) {
2561 API int pkgmgrinfo_appinfo_is_ui_gadget(pkgmgrinfo_appinfo_h handle,
2564 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2566 if (info == NULL || info->app_info == NULL || ui_gadget == NULL) {
2567 _LOGE("invalid parameter");
2568 return PMINFO_R_EINVAL;
2570 if (info->app_info->ui_gadget == NULL)
2571 info->app_info->ui_gadget = strdup("false");
2573 *ui_gadget = _get_bool_value(info->app_info->ui_gadget);
2578 API int pkgmgrinfo_appinfo_is_support_disable(pkgmgrinfo_appinfo_h handle,
2579 bool *support_disable)
2581 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2583 if (info == NULL || info->app_info == NULL || support_disable == NULL) {
2584 _LOGE("invalid parameter");
2585 return PMINFO_R_EINVAL;
2588 *support_disable = _get_bool_value(info->app_info->support_disable);
2593 API int pkgmgrinfo_appinfo_is_disabled(pkgmgrinfo_appinfo_h handle, bool *disabled)
2595 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2596 retvm_if(disabled == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2597 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2599 if (info->app_info == NULL || info->app_info->is_disabled == NULL)
2600 return PMINFO_R_ERROR;
2602 *disabled = _get_bool_value(info->app_info->is_disabled);
2607 API int pkgmgrinfo_appinfo_is_global(pkgmgrinfo_appinfo_h handle, bool *global)
2609 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2611 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2612 retvm_if(global == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2614 if (info->app_info == NULL || info->app_info->for_all_users == NULL)
2615 return PMINFO_R_ERROR;
2617 *global = _get_bool_value(info->app_info->for_all_users);
2622 API int pkgmgrinfo_appinfo_get_splash_screen_display(pkgmgrinfo_appinfo_h handle, bool *splash_screen_display)
2624 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2626 if (info == NULL || splash_screen_display == NULL) {
2627 _LOGE("Invalid parameter");
2628 return PMINFO_R_EINVAL;
2631 if (info->app_info == NULL || info->app_info->splash_screen_display == NULL)
2632 return PMINFO_R_ERROR;
2634 *splash_screen_display = _get_bool_value(info->app_info->splash_screen_display);
2639 API int pkgmgrinfo_appinfo_destroy_appinfo(pkgmgrinfo_appinfo_h handle)
2641 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2642 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2643 __cleanup_appinfo(info);
2647 API int pkgmgrinfo_appinfo_filter_create(pkgmgrinfo_appinfo_filter_h *handle)
2649 return (pkgmgrinfo_pkginfo_filter_create(handle));
2652 API int pkgmgrinfo_appinfo_filter_destroy(pkgmgrinfo_appinfo_filter_h handle)
2654 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
2657 static gint __compare_func(gconstpointer data1, gconstpointer data2)
2659 pkgmgrinfo_node_x *node1 = (pkgmgrinfo_node_x*)data1;
2660 pkgmgrinfo_node_x *node2 = (pkgmgrinfo_node_x*)data2;
2661 if (node1->prop == node2->prop)
2663 else if (node1->prop > node2->prop)
2669 API int pkgmgrinfo_appinfo_filter_add_int(pkgmgrinfo_appinfo_filter_h handle,
2670 const char *property, const int value)
2672 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2673 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2674 char buf[PKG_VALUE_STRING_LEN_MAX] = {'\0'};
2676 GSList *link = NULL;
2678 prop = _pminfo_appinfo_convert_to_prop_int(property);
2679 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_INT ||
2680 prop > E_PMINFO_APPINFO_PROP_APP_MAX_INT) {
2681 _LOGE("Invalid Integer Property\n");
2682 return PMINFO_R_EINVAL;
2684 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
2685 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
2687 _LOGE("Out of Memory!!!\n");
2688 return PMINFO_R_ERROR;
2690 snprintf(buf, PKG_VALUE_STRING_LEN_MAX - 1, "%d", value);
2691 val = strndup(buf, PKG_VALUE_STRING_LEN_MAX - 1);
2693 _LOGE("Out of Memory\n");
2696 return PMINFO_R_ERROR;
2700 /*If API is called multiple times for same property, we should override the previous values.
2701 Last value set will be used for filtering.*/
2702 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2704 filter->list = g_slist_delete_link(filter->list, link);
2705 filter->list = g_slist_append(filter->list, (gpointer)node);
2710 API int pkgmgrinfo_appinfo_filter_add_bool(pkgmgrinfo_appinfo_filter_h handle,
2711 const char *property, const bool value)
2713 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2714 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2716 GSList *link = NULL;
2718 prop = _pminfo_appinfo_convert_to_prop_bool(property);
2719 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_BOOL ||
2720 prop > E_PMINFO_APPINFO_PROP_APP_MAX_BOOL) {
2721 _LOGE("Invalid Boolean Property\n");
2722 return PMINFO_R_EINVAL;
2724 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
2725 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
2727 _LOGE("Out of Memory!!!\n");
2728 return PMINFO_R_ERROR;
2731 val = strndup("true", 4);
2733 val = strndup("false", 5);
2735 _LOGE("Out of Memory\n");
2738 return PMINFO_R_ERROR;
2742 /*If API is called multiple times for same property, we should override the previous values.
2743 Last value set will be used for filtering.*/
2744 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2746 filter->list = g_slist_delete_link(filter->list, link);
2747 filter->list = g_slist_append(filter->list, (gpointer)node);
2752 API int pkgmgrinfo_appinfo_filter_add_string(pkgmgrinfo_appinfo_filter_h handle,
2753 const char *property, const char *value)
2755 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2756 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2757 retvm_if(value == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2759 pkgmgrinfo_node_x *ptr = NULL;
2760 char prev[PKG_STRING_LEN_MAX] = {'\0'};
2761 char temp[PKG_STRING_LEN_MAX] = {'\0'};
2762 GSList *link = NULL;
2764 prop = _pminfo_appinfo_convert_to_prop_str(property);
2765 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_STR ||
2766 prop > E_PMINFO_APPINFO_PROP_APP_MAX_STR) {
2767 _LOGE("Invalid String Property\n");
2768 return PMINFO_R_EINVAL;
2770 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
2771 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
2773 _LOGE("Out of Memory!!!\n");
2774 return PMINFO_R_ERROR;
2778 case E_PMINFO_APPINFO_PROP_APP_COMPONENT:
2779 node->value = strdup(value);
2780 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2782 filter->list = g_slist_delete_link(filter->list, link);
2783 filter->list = g_slist_append(filter->list, (gpointer)node);
2785 case E_PMINFO_APPINFO_PROP_APP_CATEGORY:
2786 val = (char *)calloc(1, PKG_STRING_LEN_MAX);
2788 _LOGE("Out of Memory\n");
2791 return PMINFO_R_ERROR;
2793 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2795 ptr = (pkgmgrinfo_node_x *)link->data;
2796 strncpy(prev, ptr->value, PKG_STRING_LEN_MAX - 1);
2797 _LOGI("Previous value is %s\n", prev);
2798 filter->list = g_slist_delete_link(filter->list, link);
2799 snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s,%s", prev, value);
2800 strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
2801 _LOGI("New value is %s\n", val);
2803 filter->list = g_slist_append(filter->list, (gpointer)node);
2804 memset(temp, '\0', PKG_STRING_LEN_MAX);
2806 snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s", value);
2807 strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
2808 _LOGI("First value is %s\n", val);
2810 filter->list = g_slist_append(filter->list, (gpointer)node);
2811 memset(temp, '\0', PKG_STRING_LEN_MAX);
2815 node->value = strndup(value, PKG_STRING_LEN_MAX - 1);
2816 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2818 filter->list = g_slist_delete_link(filter->list, link);
2819 filter->list = g_slist_append(filter->list, (gpointer)node);
2825 API int pkgmgrinfo_appinfo_usr_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count, uid_t uid)
2831 if (handle == NULL || count == NULL) {
2832 _LOGE("invalid parameter");
2833 return PMINFO_R_EINVAL;
2836 locale = _get_system_locale();
2838 return PMINFO_R_ERROR;
2840 list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
2841 __free_applications);
2844 return PMINFO_R_ERROR;
2847 ret = _appinfo_get_applications(uid, uid, locale, handle, 0, list);
2848 if (ret == PMINFO_R_OK && uid != GLOBAL_USER)
2849 ret = _appinfo_get_applications(GLOBAL_USER, uid, locale,
2852 if (ret != PMINFO_R_OK) {
2853 g_hash_table_destroy(list);
2855 return PMINFO_R_ERROR;
2858 *count = g_hash_table_size(list);
2859 g_hash_table_destroy(list);
2865 API int pkgmgrinfo_appinfo_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count)
2867 return pkgmgrinfo_appinfo_usr_filter_count(handle, count, _getuid());
2870 API int pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(
2871 pkgmgrinfo_appinfo_filter_h handle,
2872 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
2874 if (handle == NULL || app_cb == NULL) {
2875 LOGE("invalid parameter");
2876 return PMINFO_R_EINVAL;
2879 return _appinfo_get_filtered_foreach_appinfo(uid, handle, PMINFO_APPINFO_GET_ALL, app_cb,
2883 API int pkgmgrinfo_appinfo_filter_foreach_appinfo(pkgmgrinfo_appinfo_filter_h handle,
2884 pkgmgrinfo_app_list_cb app_cb, void * user_data)
2886 return pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(handle, app_cb, user_data, _getuid());
2889 API int pkgmgrinfo_appinfo_metadata_filter_create(pkgmgrinfo_appinfo_metadata_filter_h *handle)
2891 return (pkgmgrinfo_pkginfo_filter_create(handle));
2894 API int pkgmgrinfo_appinfo_metadata_filter_destroy(pkgmgrinfo_appinfo_metadata_filter_h handle)
2896 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
2899 API int pkgmgrinfo_appinfo_metadata_filter_add(
2900 pkgmgrinfo_appinfo_metadata_filter_h handle,
2901 const char *key, const char *value)
2905 ret = pkgmgrinfo_appinfo_filter_add_string(handle,
2906 PMINFO_APPINFO_PROP_APP_METADATA_KEY, key);
2907 if (ret != PMINFO_R_OK)
2910 /* value can be NULL.
2911 * In that case all apps with specified key should be displayed
2914 ret = pkgmgrinfo_appinfo_filter_add_string(handle,
2915 PMINFO_APPINFO_PROP_APP_METADATA_VALUE, value);
2916 if (ret != PMINFO_R_OK)
2923 API int pkgmgrinfo_appinfo_usr_metadata_filter_foreach(
2924 pkgmgrinfo_appinfo_metadata_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_metadata_filter_foreach(
2937 pkgmgrinfo_appinfo_metadata_filter_h handle,
2938 pkgmgrinfo_app_list_cb app_cb, void *user_data)
2940 return pkgmgrinfo_appinfo_usr_metadata_filter_foreach(handle, app_cb,
2941 user_data, _getuid());
2944 API int pkgmgrinfo_appinfo_is_guestmode_visibility(pkgmgrinfo_appinfo_h handle, bool *status)
2947 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2949 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2950 retvm_if(status == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2952 val = info->app_info->guestmode_visibility;
2953 *status = _get_bool_value(val);