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 ";
55 static const char join_privilege[] =
56 " LEFT OUTER JOIN package_privilege_info"
57 " ON ai.package=package_privilege_info.package ";
59 static int _get_filtered_query(pkgmgrinfo_filter_x *filter,
60 const char *locale, uid_t uid, char **query, GList **bind_params)
63 char *condition = NULL;
64 char buf[MAX_QUERY_LEN] = { '\0' };
65 char tmp_query[MAX_QUERY_LEN] = { '\0' };
70 strncat(buf, " WHERE 1=1", sizeof(buf) - strlen(buf) - 1);
72 for (list = filter->list; list; list = list->next) {
73 joined |= __get_filter_condition(list->data, uid, &condition, bind_params);
74 if (condition == NULL)
77 strncat(buf, " AND ", sizeof(buf) - strlen(buf) - 1);
79 strncat(buf, condition, sizeof(buf) - strlen(buf) - 1);
84 if (filter->list_metadata)
85 strncat(buf, " AND (", sizeof(buf) - strlen(buf) - 1);
86 for (list = filter->list_metadata; list; list = list->next) {
87 joined |= __get_metadata_filter_condition(list->data,
88 &condition, bind_params);
89 if (condition == NULL)
91 strncat(buf, condition, sizeof(buf) - strlen(buf) - 1);
95 strncat(buf, " OR ", sizeof(buf) - strlen(buf) - 1);
97 if (filter->list_metadata)
98 strncat(buf, "1=0)", sizeof(buf) - strlen(buf) - 1);
100 if (joined & E_PMINFO_APPINFO_JOIN_LOCALIZED_INFO) {
101 strncat(tmp_query, join_localized_info, sizeof(tmp_query) - strlen(tmp_query) - 1);
102 *bind_params = g_list_append(*bind_params, strdup(locale));
104 if (joined & E_PMINFO_APPINFO_JOIN_CATEGORY)
105 strncat(tmp_query, join_category, sizeof(tmp_query) - strlen(tmp_query) - 1);
106 if (joined & E_PMINFO_APPINFO_JOIN_APP_CONTROL)
107 strncat(tmp_query, join_app_control, sizeof(tmp_query) - strlen(tmp_query) - 1);
108 if (joined & E_PMINFO_APPINFO_JOIN_METADATA)
109 strncat(tmp_query, join_metadata, sizeof(tmp_query) - strlen(tmp_query) - 1);
110 if (joined & E_PMINFO_APPINFO_JOIN_PRIVILEGE)
111 strncat(tmp_query, join_privilege, sizeof(tmp_query) - strlen(tmp_query) - 1);
113 strncat(tmp_query, buf, sizeof(tmp_query) - strlen(tmp_query) - 1);
115 *query = strdup(tmp_query);
117 return PMINFO_R_ERROR;
122 static int _appinfo_get_category(sqlite3 *db, const char *appid,
125 static const char query_raw[] =
126 "SELECT category FROM package_app_app_category WHERE app_id=%Q";
132 query = sqlite3_mprintf(query_raw, appid);
134 LOGE("out of memory");
135 return PMINFO_R_ERROR;
138 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
140 if (ret != SQLITE_OK) {
141 LOGE("prepare failed: %s", sqlite3_errmsg(db));
142 return PMINFO_R_ERROR;
145 while (sqlite3_step(stmt) == SQLITE_ROW) {
147 _save_column_str(stmt, 0, &val);
149 *category = g_list_append(*category, (gpointer)val);
152 sqlite3_finalize(stmt);
157 static void __parse_appcontrol(GList **appcontrol, char *appcontrol_str,
165 if (appcontrol_str == NULL)
168 dup = strdup(appcontrol_str);
170 _LOGE("out of memory");
175 ac = calloc(1, sizeof(appcontrol_x));
177 _LOGE("out of memory");
180 token = strtok_r(dup, "|", &ptr);
181 if (token && strcmp(token, "NULL"))
182 ac->operation = strdup(token);
183 token = strtok_r(NULL, "|", &ptr);
184 if (token && strcmp(token, "NULL"))
185 ac->uri = strdup(token);
186 token = strtok_r(NULL, "|", &ptr);
187 if (token && strcmp(token, "NULL"))
188 ac->mime = strdup(token);
189 ac->visibility = strdup(visibility);
190 *appcontrol = g_list_append(*appcontrol, ac);
191 } while ((token = strtok_r(NULL, ";", &ptr)));
196 static int _appinfo_get_app_control(sqlite3 *db, const char *appid,
199 static const char query_raw[] =
200 "SELECT app_control, visibility FROM package_app_app_control "
208 query = sqlite3_mprintf(query_raw, appid);
210 LOGE("out of memory");
211 return PMINFO_R_ERROR;
214 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
216 if (ret != SQLITE_OK) {
217 LOGE("prepare failed: %s", sqlite3_errmsg(db));
218 return PMINFO_R_ERROR;
221 while (sqlite3_step(stmt) == SQLITE_ROW) {
224 _save_column_str(stmt, 0, &str);
225 _save_column_str(stmt, 0, &visibility);
227 __parse_appcontrol(appcontrol, str, visibility);
232 sqlite3_finalize(stmt);
237 static int _appinfo_get_metadata(sqlite3 *db, const char *appid,
240 static const char query_raw[] =
241 "SELECT md_key, md_value "
242 "FROM package_app_app_metadata WHERE app_id=%Q";
249 query = sqlite3_mprintf(query_raw, appid);
251 LOGE("out of memory");
252 return PMINFO_R_ERROR;
255 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
257 if (ret != SQLITE_OK) {
258 LOGE("prepare failed: %s", sqlite3_errmsg(db));
259 return PMINFO_R_ERROR;
262 while (sqlite3_step(stmt) == SQLITE_ROW) {
263 info = calloc(1, sizeof(metadata_x));
265 LOGE("out of memory");
266 sqlite3_finalize(stmt);
267 return PMINFO_R_ERROR;
270 _save_column_str(stmt, idx++, &info->key);
271 _save_column_str(stmt, idx++, &info->value);
272 *metadata = g_list_append(*metadata, info);
275 sqlite3_finalize(stmt);
281 static int _appinfo_get_splashscreens(sqlite3 *db, const char *appid,
282 GList **splashscreens)
284 static const char query_raw[] =
285 "SELECT src, type, orientation, indicatordisplay, operation, color_depth "
286 "FROM package_app_splash_screen WHERE app_id=%Q";
291 splashscreen_x *info;
293 query = sqlite3_mprintf(query_raw, appid);
295 LOGE("out of memory");
296 return PMINFO_R_ERROR;
299 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
301 if (ret != SQLITE_OK) {
302 LOGE("prepare failed: %s", sqlite3_errmsg(db));
303 return PMINFO_R_ERROR;
306 while (sqlite3_step(stmt) == SQLITE_ROW) {
307 info = calloc(1, sizeof(splashscreen_x));
309 LOGE("out of memory");
310 sqlite3_finalize(stmt);
311 return PMINFO_R_ERROR;
314 _save_column_str(stmt, idx++, &info->src);
315 _save_column_str(stmt, idx++, &info->type);
316 _save_column_str(stmt, idx++, &info->orientation);
317 _save_column_str(stmt, idx++, &info->indicatordisplay);
318 _save_column_str(stmt, idx++, &info->operation);
319 _save_column_str(stmt, idx++, &info->color_depth);
320 *splashscreens = g_list_append(*splashscreens, info);
323 sqlite3_finalize(stmt);
328 static GList *__get_background_category(const char *value)
330 GList *category_list = NULL;
331 int convert_value = 0;
332 if (!value || strlen(value) == 0)
335 convert_value = atoi(value);
336 if (convert_value < 0)
339 if (convert_value & APP_BG_CATEGORY_USER_DISABLE_TRUE_VAL)
340 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_USER_DISABLE_TRUE_STR));
342 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_USER_DISABLE_FALSE_STR));
344 if (convert_value & APP_BG_CATEGORY_MEDIA_VAL)
345 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_MEDIA_STR));
347 if (convert_value & APP_BG_CATEGORY_DOWNLOAD_VAL)
348 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_DOWNLOAD_STR));
350 if (convert_value & APP_BG_CATEGORY_BGNETWORK_VAL)
351 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_BGNETWORK_STR));
353 if (convert_value & APP_BG_CATEGORY_LOCATION_VAL)
354 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_LOCATION_STR));
356 if (convert_value & APP_BG_CATEGORY_SENSOR_VAL)
357 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_SENSOR_STR));
359 if (convert_value & APP_BG_CATEGORY_IOTCOMM_VAL)
360 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_IOTCOMM_STR));
362 if (convert_value & APP_BG_CATEGORY_SYSTEM_VAL)
363 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_SYSTEM));
365 return category_list;
369 static void __free_applications(gpointer data)
371 pkgmgrinfo_basic_free_application((application_x *)data);
374 static gint __disable_chk_func(gconstpointer data1, gconstpointer data2)
376 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)data1;
377 pkgmgrinfo_appinfo_disable_type value = GPOINTER_TO_INT(data2);
379 if (value == E_APPINFO_DISABLE_TYPE_PKG)
380 return (node->prop == E_PMINFO_APPINFO_PROP_PKG_DISABLE)
383 return (node->prop == E_PMINFO_APPINFO_PROP_APP_DISABLE)
387 static bool __check_disable_filter_exist(pkgmgrinfo_filter_x *filter,
388 pkgmgrinfo_appinfo_disable_type type)
395 link = g_slist_find_custom(filter->list, GINT_TO_POINTER(type), __disable_chk_func);
402 static int __bind_params(sqlite3_stmt *stmt, GList *params)
404 GList *tmp_list = NULL;
408 if (stmt == NULL || params == NULL)
409 return PMINFO_R_EINVAL;
413 ret = sqlite3_bind_text(stmt, ++idx, (char *)tmp_list->data, -1, SQLITE_STATIC);
414 if (ret != SQLITE_OK)
415 return PMINFO_R_ERROR;
416 tmp_list = tmp_list->next;
422 static bool __check_app_storage_status(pkgmgrinfo_filter_x *tmp_filter)
424 GSList *tmp_list = NULL;
425 pkgmgrinfo_node_x *tmp_node = NULL;
428 if (tmp_filter == NULL)
431 property = _pminfo_appinfo_convert_to_prop_bool(PMINFO_APPINFO_PROP_APP_CHECK_STORAGE);
432 for (tmp_list = tmp_filter->list; tmp_list != NULL;
433 tmp_list = g_slist_next(tmp_list)) {
434 tmp_node = (pkgmgrinfo_node_x *)tmp_list->data;
435 if (property == tmp_node->prop) {
436 if (strcmp(tmp_node->value, "true") == 0)
446 static int _appinfo_get_applications(uid_t db_uid, uid_t uid,
447 const char *locale, pkgmgrinfo_filter_x *filter, int flag,
448 GHashTable *applications)
450 static const char query_raw[] =
451 "SELECT DISTINCT ai.app_id, ai.app_installed_storage, "
452 "ai.app_external_path";
453 static const char query_basic[] =
454 ", ai.app_component, ai.app_exec, "
455 "ai.app_nodisplay, ai.app_type, ai.app_onboot, "
456 "ai.app_multiple, ai.app_autorestart, ai.app_taskmanage, "
457 "ai.app_hwacceleration, ai.app_screenreader, "
458 "ai.app_mainapp, ai.app_recentimage, ai.app_launchcondition, "
459 "ai.app_indicatordisplay, ai.app_portraitimg, "
460 "ai.app_landscapeimg, ai.app_guestmodevisibility, "
461 "ai.app_permissiontype, ai.app_preload, ai.app_submode, "
462 "ai.app_submode_mainid, ai.app_launch_mode, ai.app_ui_gadget, "
463 "ai.app_support_disable, ai.app_process_pool, "
464 "ai.app_background_category, ai.app_package_type, "
465 "ai.app_root_path, ai.app_api_version, ai.app_effective_appid, "
466 "ai.app_disable, ai.app_splash_screen_display, ai.app_tep_name, "
467 "ai.app_zip_mount_file, ai.component_type, ai.package, "
468 "ai.app_package_system, ai.app_removable, "
469 "ai.app_package_installed_time, ai.app_support_mode, "
470 "ai.app_support_ambient, ai.app_setup_appid";
471 static const char query_uid_info[] =
472 ", ui.is_disabled, ui.is_splash_screen_enabled";
473 static const char query_label[] =
475 "(SELECT app_label FROM package_app_localized_info WHERE ai.app_id=app_id AND app_locale=?), "
476 "(SELECT app_label FROM package_app_localized_info WHERE ai.app_id=app_id AND app_locale='No Locale'))";
477 static const char query_icon[] =
479 "(SELECT app_icon FROM package_app_localized_info WHERE ai.app_id=app_id AND app_locale=?), "
480 "(SELECT app_icon FROM package_app_localized_info WHERE ai.app_id=app_id AND app_locale='No Locale'))";
481 static const char query_from_clause[] = " FROM package_app_info as ai";
482 static const char query_uid_info_clause[] =
483 " LEFT OUTER JOIN package_app_info_for_uid AS ui "
484 "ON (ai.app_id=ui.app_id AND ui.uid=?)";
485 int ret = PMINFO_R_ERROR;
488 char *bg_category_str = NULL;
489 char *constraint = NULL;
490 char *tmp_record = NULL;
491 char query[MAX_QUERY_LEN] = { '\0' };
492 char buf[BUFSIZE] = { '\0' };
493 application_x *info = NULL;
494 GList *bind_params = NULL;
496 sqlite3_stmt *stmt = NULL;
497 bool is_check_storage = true;
498 const uid_t global_user_uid = GLOBAL_USER;
500 dbpath = getUserPkgParserDBPathUID(db_uid);
502 return PMINFO_R_ERROR;
504 ret = __open_db(dbpath, &db, SQLITE_OPEN_READONLY);
505 if (ret != SQLITE_OK) {
506 _LOGE("failed to open db(%s): %d", dbpath, ret);
508 return PMINFO_R_ERROR;
512 snprintf(query, MAX_QUERY_LEN - 1, "%s", query_raw);
514 if (flag & PMINFO_APPINFO_GET_BASICINFO) {
515 strncat(query, query_basic, sizeof(query) - strlen(query) - 1);
516 strncat(query, query_uid_info, sizeof(query) - strlen(query) - 1);
518 if (flag & PMINFO_APPINFO_GET_LABEL) {
519 strncat(query, query_label, sizeof(query) - strlen(query) - 1);
520 bind_params = g_list_append(bind_params, strdup(locale));
522 if (flag & PMINFO_APPINFO_GET_ICON) {
523 strncat(query, query_icon, sizeof(query) - strlen(query) - 1);
524 bind_params = g_list_append(bind_params, strdup(locale));
527 snprintf(buf, MAX_QUERY_LEN - 1, "%d", uid);
528 bind_params = g_list_append(bind_params, strdup(buf));
530 is_check_storage = __check_app_storage_status(filter);
532 ret = _get_filtered_query(filter, locale, uid, &constraint, &bind_params);
533 if (ret != PMINFO_R_OK) {
534 LOGE("Failed to get WHERE clause");
537 strncat(query, query_from_clause, sizeof(query) - strlen(query) - 1);
539 strncat(query, query_uid_info_clause, sizeof(query) - strlen(query) - 1);
542 strncat(query, constraint, sizeof(query) - strlen(query) - 1);
544 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
545 if (ret != SQLITE_OK) {
546 LOGE("prepare failed: %s", sqlite3_errmsg(db));
547 ret = PMINFO_R_ERROR;
551 if (g_list_length(bind_params) != 0) {
552 ret = __bind_params(stmt, bind_params);
553 if (ret != SQLITE_OK) {
554 LOGE("Failed to bind parameters");
559 while (sqlite3_step(stmt) == SQLITE_ROW) {
560 info = calloc(1, sizeof(application_x));
562 LOGE("out of memory");
563 ret = PMINFO_R_ERROR;
567 _save_column_str(stmt, idx++, &info->appid);
568 _save_column_str(stmt, idx++, &info->installed_storage);
569 _save_column_str(stmt, idx++ , &info->external_path);
571 if (flag & PMINFO_APPINFO_GET_BASICINFO) {
572 _save_column_str(stmt, idx++, &info->component);
573 _save_column_str(stmt, idx++, &info->exec);
574 _save_column_str(stmt, idx++, &info->nodisplay);
575 _save_column_str(stmt, idx++, &info->type);
576 _save_column_str(stmt, idx++, &info->onboot);
577 _save_column_str(stmt, idx++, &info->multiple);
578 _save_column_str(stmt, idx++, &info->autorestart);
579 _save_column_str(stmt, idx++, &info->taskmanage);
580 _save_column_str(stmt, idx++, &info->hwacceleration);
581 _save_column_str(stmt, idx++, &info->screenreader);
582 _save_column_str(stmt, idx++, &info->mainapp);
583 _save_column_str(stmt, idx++, &info->recentimage);
584 _save_column_str(stmt, idx++, &info->launchcondition);
585 _save_column_str(stmt, idx++, &info->indicatordisplay);
586 _save_column_str(stmt, idx++, &info->portraitimg);
587 _save_column_str(stmt, idx++, &info->landscapeimg);
588 _save_column_str(stmt, idx++, &info->guestmode_visibility);
589 _save_column_str(stmt, idx++, &info->permission_type);
590 _save_column_str(stmt, idx++, &info->preload);
591 _save_column_str(stmt, idx++, &info->submode);
592 _save_column_str(stmt, idx++, &info->submode_mainid);
593 _save_column_str(stmt, idx++, &info->launch_mode);
594 _save_column_str(stmt, idx++, &info->ui_gadget);
595 _save_column_str(stmt, idx++, &info->support_disable);
596 _save_column_str(stmt, idx++, &info->process_pool);
597 _save_column_str(stmt, idx++, &bg_category_str);
598 _save_column_str(stmt, idx++, &info->package_type);
599 _save_column_str(stmt, idx++, &info->root_path);
600 _save_column_str(stmt, idx++, &info->api_version);
601 _save_column_str(stmt, idx++, &info->effective_appid);
602 _save_column_str(stmt, idx++, &info->is_disabled);
603 _save_column_str(stmt, idx++, &info->splash_screen_display);
604 _save_column_str(stmt, idx++, &info->tep_name);
605 _save_column_str(stmt, idx++, &info->zip_mount_file);
606 _save_column_str(stmt, idx++, &info->component_type);
607 _save_column_str(stmt, idx++, &info->package);
608 _save_column_str(stmt, idx++, &info->package_system);
609 _save_column_str(stmt, idx++, &info->removable);
610 _save_column_str(stmt, idx++, &info->package_installed_time);
611 _save_column_str(stmt, idx++, &info->support_mode);
612 _save_column_str(stmt, idx++, &info->support_ambient);
613 _save_column_str(stmt, idx++, &info->setup_appid);
614 info->background_category = __get_background_category(
616 free(bg_category_str);
619 info->for_all_users =
620 strdup((db_uid != global_user_uid) ? "false" : "true");
622 if (db_uid != global_user_uid) {
626 _save_column_str(stmt, idx++, &tmp_record);
627 if (tmp_record != NULL) {
628 if (strcasecmp(info->is_disabled, "false") == 0 &&
629 strcasecmp(tmp_record, "false") == 0) {
630 free(info->is_disabled);
631 info->is_disabled = tmp_record;
637 _save_column_str(stmt, idx++, &tmp_record);
638 if (tmp_record != NULL) {
639 if (strcasecmp(info->splash_screen_display, "false") == 0 &&
640 strcasecmp(tmp_record, "false") == 0) {
641 free(info->splash_screen_display);
642 info->splash_screen_display = tmp_record;
649 if (flag & PMINFO_APPINFO_GET_LABEL) {
651 _save_column_str(stmt, idx++, &tmp_record);
652 if (_add_label_info_into_list(locale, tmp_record, &info->label)) {
653 ret = PMINFO_R_ERROR;
658 if (flag & PMINFO_APPINFO_GET_ICON) {
660 _save_column_str(stmt, idx++, &tmp_record);
661 if (_add_icon_info_into_list(locale, tmp_record, &info->icon)) {
662 ret = PMINFO_R_ERROR;
667 if (flag & PMINFO_APPINFO_GET_CATEGORY) {
668 if (_appinfo_get_category(db, info->appid,
670 ret = PMINFO_R_ERROR;
675 if (flag & PMINFO_APPINFO_GET_APP_CONTROL) {
676 if (_appinfo_get_app_control(db, info->appid,
677 &info->appcontrol)) {
678 ret = PMINFO_R_ERROR;
683 if (flag & PMINFO_APPINFO_GET_METADATA) {
684 if (_appinfo_get_metadata(db, info->appid,
686 ret = PMINFO_R_ERROR;
691 if (flag & PMINFO_APPINFO_GET_SPLASH_SCREEN) {
692 if (_appinfo_get_splashscreens(db, info->appid,
693 &info->splashscreens)) {
694 ret = PMINFO_R_ERROR;
699 if (is_check_storage &&
700 __appinfo_check_installed_storage(info) != PMINFO_R_OK) {
701 ret = PMINFO_R_ERROR;
702 pkgmgrinfo_basic_free_application(info);
707 g_hash_table_insert(applications, (gpointer)info->appid,
714 sqlite3_finalize(stmt);
715 sqlite3_close_v2(db);
720 if (ret != PMINFO_R_OK && info != NULL)
721 pkgmgrinfo_basic_free_application(info);
723 g_list_free_full(bind_params, free);
728 static int _pkgmgrinfo_get_appinfo(const char *appid, uid_t uid,
729 pkgmgrinfo_appinfo_filter_h filter, pkgmgrinfo_appinfo_h *handle)
734 pkgmgr_appinfo_x *info;
736 if (appid == NULL || filter == NULL || handle == NULL) {
737 LOGE("invalid parameter");
738 return PMINFO_R_EINVAL;
741 locale = _get_system_locale();
743 return PMINFO_R_ERROR;
745 list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
746 __free_applications);
749 return PMINFO_R_ERROR;
752 ret = _appinfo_get_applications(uid, uid, locale, filter,
753 PMINFO_APPINFO_GET_ALL, list);
754 if (!g_hash_table_size(list) && uid != GLOBAL_USER)
755 ret = _appinfo_get_applications(GLOBAL_USER, uid, locale, filter,
756 PMINFO_APPINFO_GET_ALL, list);
758 if (ret != PMINFO_R_OK) {
759 g_hash_table_destroy(list);
764 if (!g_hash_table_size(list)) {
765 _LOGD("appinfo for [%s] is not existed for user [%d]",
767 g_hash_table_destroy(list);
769 return PMINFO_R_ENOENT;
772 info = calloc(1, sizeof(pkgmgr_appinfo_x));
774 _LOGE("out of memory");
775 g_hash_table_destroy(list);
777 return PMINFO_R_ERROR;
780 info->app_info = (application_x *)g_hash_table_lookup(list, appid);
781 info->locale = locale;
782 info->package = strdup(info->app_info->package);
784 /* just free list only */
785 g_hash_table_steal(list, (gconstpointer)appid);
786 g_hash_table_destroy(list);
793 API int pkgmgrinfo_appinfo_get_usr_disabled_appinfo(const char *appid, uid_t uid,
794 pkgmgrinfo_appinfo_h *handle)
797 pkgmgrinfo_appinfo_filter_h filter;
799 if (appid == NULL || handle == NULL) {
800 LOGE("invalid parameter");
801 return PMINFO_R_EINVAL;
804 ret = pkgmgrinfo_appinfo_filter_create(&filter);
805 if (ret != PMINFO_R_OK)
808 ret = pkgmgrinfo_appinfo_filter_add_string(filter,
809 PMINFO_APPINFO_PROP_APP_ID, appid);
810 if (ret != PMINFO_R_OK) {
811 pkgmgrinfo_appinfo_filter_destroy(filter);
812 return PMINFO_R_ERROR;
815 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
816 PMINFO_APPINFO_PROP_APP_DISABLE, true);
817 if (ret != PMINFO_R_OK) {
818 pkgmgrinfo_appinfo_filter_destroy(filter);
819 return PMINFO_R_ERROR;
822 ret = _pkgmgrinfo_get_appinfo(appid, uid, filter, handle);
823 pkgmgrinfo_appinfo_filter_destroy(filter);
828 API int pkgmgrinfo_appinfo_get_disabled_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
830 return pkgmgrinfo_appinfo_get_usr_disabled_appinfo(appid, _getuid(), handle);
833 API int pkgmgrinfo_appinfo_get_usr_appinfo(const char *appid, uid_t uid,
834 pkgmgrinfo_appinfo_h *handle)
837 pkgmgrinfo_appinfo_filter_h filter;
839 if (appid == NULL || handle == NULL) {
840 LOGE("invalid parameter");
841 return PMINFO_R_EINVAL;
844 ret = pkgmgrinfo_appinfo_filter_create(&filter);
845 if (ret != PMINFO_R_OK)
848 ret = pkgmgrinfo_appinfo_filter_add_string(filter,
849 PMINFO_APPINFO_PROP_APP_ID, appid);
850 if (ret != PMINFO_R_OK) {
851 pkgmgrinfo_appinfo_filter_destroy(filter);
852 return PMINFO_R_ERROR;
855 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
856 PMINFO_APPINFO_PROP_APP_DISABLE, false);
857 if (ret != PMINFO_R_OK) {
858 pkgmgrinfo_appinfo_filter_destroy(filter);
859 return PMINFO_R_ERROR;
862 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
863 PMINFO_APPINFO_PROP_PKG_DISABLE, false);
864 if (ret != PMINFO_R_OK) {
865 pkgmgrinfo_appinfo_filter_destroy(filter);
866 return PMINFO_R_ERROR;
869 ret = _pkgmgrinfo_get_appinfo(appid, uid, filter, handle);
870 pkgmgrinfo_appinfo_filter_destroy(filter);
874 API int pkgmgrinfo_appinfo_get_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
876 return pkgmgrinfo_appinfo_get_usr_appinfo(appid, _getuid(), handle);
879 API int pkgmgrinfo_appinfo_get_usr_all_appinfo(const char *appid, uid_t uid,
880 pkgmgrinfo_appinfo_h *handle)
883 pkgmgrinfo_appinfo_filter_h filter;
885 if (appid == NULL || handle == NULL) {
886 LOGE("invalid parameter");
887 return PMINFO_R_EINVAL;
890 ret = pkgmgrinfo_appinfo_filter_create(&filter);
891 if (ret != PMINFO_R_OK)
894 ret = pkgmgrinfo_appinfo_filter_add_string(filter,
895 PMINFO_APPINFO_PROP_APP_ID, appid);
896 if (ret != PMINFO_R_OK) {
897 pkgmgrinfo_appinfo_filter_destroy(filter);
898 return PMINFO_R_ERROR;
901 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
902 PMINFO_APPINFO_PROP_APP_CHECK_STORAGE, false);
903 if (ret != PMINFO_R_OK) {
904 pkgmgrinfo_appinfo_filter_destroy(filter);
905 return PMINFO_R_ERROR;
908 ret = _pkgmgrinfo_get_appinfo(appid, uid, filter, handle);
909 pkgmgrinfo_appinfo_filter_destroy(filter);
914 API int pkgmgrinfo_appinfo_get_all_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
916 return pkgmgrinfo_appinfo_get_usr_all_appinfo(appid, _getuid(), handle);
919 static gpointer __copy_str(gconstpointer src, gpointer data)
921 const char *tmp = (const char *)src;
924 buffer = strdup(tmp);
925 if (buffer == NULL) {
926 LOGE("memory alloc failed");
934 static gpointer __copy_label(gconstpointer src, gpointer data)
936 label_x *tmp = (label_x *)src;
939 label = calloc(1, sizeof(label_x));
941 LOGE("memory alloc failed");
947 label->name = strdup(tmp->name);
949 label->text = strdup(tmp->text);
951 label->lang = strdup(tmp->lang);
956 static gpointer __copy_icon(gconstpointer src, gpointer data)
958 icon_x *tmp = (icon_x *)src;
961 icon = calloc(1, sizeof(icon_x));
963 LOGE("memory alloc failed");
969 icon->text = strdup(tmp->text);
971 icon->lang = strdup(tmp->lang);
973 icon->section = strdup(tmp->section);
975 icon->size = strdup(tmp->size);
977 icon->resolution = strdup(tmp->resolution);
982 static gpointer __copy_metadata(gconstpointer src, gpointer data)
984 metadata_x *tmp = (metadata_x *)src;
985 metadata_x *metadata;
987 metadata = calloc(1, sizeof(metadata_x));
988 if (metadata == NULL) {
989 LOGE("memory alloc failed");
995 metadata->key = strdup(tmp->key);
997 metadata->value = strdup(tmp->value);
1002 static gpointer __copy_datacontrol(gconstpointer src, gpointer data)
1004 datacontrol_x *tmp = (datacontrol_x *)src;
1005 datacontrol_x *datacontrol;
1007 datacontrol = calloc(1, sizeof(datacontrol_x));
1008 if (datacontrol == NULL) {
1009 LOGE("memory alloc failed");
1014 if (tmp->providerid)
1015 datacontrol->providerid = strdup(tmp->providerid);
1017 datacontrol->access = strdup(tmp->access);
1019 datacontrol->type = strdup(tmp->type);
1021 datacontrol->trusted = strdup(tmp->trusted);
1026 static gpointer __copy_appcontrol(gconstpointer src, gpointer data)
1028 appcontrol_x *tmp = (appcontrol_x *)src;
1029 appcontrol_x *appcontrol;
1031 appcontrol = calloc(1, sizeof(appcontrol_x));
1032 if (appcontrol == NULL) {
1033 LOGE("memory alloc failed");
1039 appcontrol->operation = strdup(tmp->operation);
1041 appcontrol->uri = strdup(tmp->uri);
1043 appcontrol->mime = strdup(tmp->mime);
1048 static gpointer __copy_splashscreens(gconstpointer src, gpointer data)
1050 splashscreen_x *tmp = (splashscreen_x *)src;
1051 splashscreen_x *splashscreen;
1053 splashscreen = (splashscreen_x *)calloc(1, sizeof(splashscreen_x));
1054 if (splashscreen == NULL) {
1055 LOGE("memory alloc failed");
1061 splashscreen->src = strdup(tmp->src);
1063 splashscreen->type = strdup(tmp->type);
1064 if (tmp->orientation)
1065 splashscreen->orientation = strdup(tmp->orientation);
1066 if (tmp->indicatordisplay)
1067 splashscreen->indicatordisplay = strdup(tmp->indicatordisplay);
1069 splashscreen->operation = strdup(tmp->operation);
1070 if (tmp->color_depth)
1071 splashscreen->color_depth = strdup(tmp->color_depth);
1073 return splashscreen;
1076 static int _appinfo_copy_appinfo(application_x **application, application_x *data)
1078 application_x *app_info;
1081 app_info = calloc(1, sizeof(application_x));
1082 if (app_info == NULL) {
1083 LOGE("memory alloc failed");
1084 return PMINFO_R_ERROR;
1087 if (data->appid != NULL)
1088 app_info->appid = strdup(data->appid);
1089 if (data->exec != NULL)
1090 app_info->exec = strdup(data->exec);
1091 if (data->nodisplay != NULL)
1092 app_info->nodisplay = strdup(data->nodisplay);
1093 if (data->multiple != NULL)
1094 app_info->multiple = strdup(data->multiple);
1095 if (data->taskmanage != NULL)
1096 app_info->taskmanage = strdup(data->taskmanage);
1097 if (data->type != NULL)
1098 app_info->type = strdup(data->type);
1099 if (data->categories != NULL)
1100 app_info->categories = strdup(data->categories);
1101 if (data->hwacceleration != NULL)
1102 app_info->hwacceleration = strdup(data->hwacceleration);
1103 if (data->screenreader != NULL)
1104 app_info->screenreader = strdup(data->screenreader);
1105 if (data->mainapp != NULL)
1106 app_info->mainapp = strdup(data->mainapp);
1107 if (data->package != NULL)
1108 app_info->package = strdup(data->package);
1109 if (data->recentimage != NULL)
1110 app_info->recentimage = strdup(data->recentimage);
1111 if (data->launchcondition != NULL)
1112 app_info->launchcondition = strdup(data->launchcondition);
1113 if (data->indicatordisplay != NULL)
1114 app_info->indicatordisplay = strdup(data->indicatordisplay);
1115 if (data->portraitimg != NULL)
1116 app_info->portraitimg = strdup(data->portraitimg);
1117 if (data->landscapeimg != NULL)
1118 app_info->landscapeimg = strdup(data->landscapeimg);
1119 if (data->guestmode_visibility != NULL)
1120 app_info->guestmode_visibility = strdup(data->guestmode_visibility);
1121 if (data->component != NULL)
1122 app_info->component = strdup(data->component);
1123 if (data->permission_type != NULL)
1124 app_info->permission_type = strdup(data->permission_type);
1125 if (data->component_type != NULL)
1126 app_info->component_type = strdup(data->component_type);
1127 if (data->preload != NULL)
1128 app_info->preload = strdup(data->preload);
1129 if (data->submode != NULL)
1130 app_info->submode = strdup(data->submode);
1131 if (data->submode_mainid != NULL)
1132 app_info->submode_mainid = strdup(data->submode_mainid);
1133 if (data->process_pool != NULL)
1134 app_info->process_pool = strdup(data->process_pool);
1135 if (data->installed_storage != NULL)
1136 app_info->installed_storage = strdup(data->installed_storage);
1137 if (data->autorestart != NULL)
1138 app_info->autorestart = strdup(data->autorestart);
1139 if (data->onboot != NULL)
1140 app_info->onboot = strdup(data->onboot);
1141 if (data->support_disable != NULL)
1142 app_info->support_disable = strdup(data->support_disable);
1143 if (data->ui_gadget != NULL)
1144 app_info->ui_gadget = strdup(data->ui_gadget);
1145 if (data->launch_mode != NULL)
1146 app_info->launch_mode = strdup(data->launch_mode);
1147 if (data->package_type != NULL)
1148 app_info->package_type = strdup(data->package_type);
1149 if (data->effective_appid != NULL)
1150 app_info->effective_appid = strdup(data->effective_appid);
1151 if (data->splash_screen_display != NULL)
1152 app_info->splash_screen_display = strdup(data->splash_screen_display);
1156 app_info->label = g_list_copy_deep(data->label, __copy_label, &ret);
1158 LOGE("memory alloc failed");
1159 pkgmgrinfo_basic_free_application(app_info);
1160 return PMINFO_R_ERROR;
1164 app_info->icon = g_list_copy_deep(data->icon, __copy_icon, &ret);
1166 LOGE("memory alloc failed");
1167 pkgmgrinfo_basic_free_application(app_info);
1168 return PMINFO_R_ERROR;
1172 app_info->category = g_list_copy_deep(data->category, __copy_str, &ret);
1174 LOGE("memory alloc failed");
1175 pkgmgrinfo_basic_free_application(app_info);
1176 return PMINFO_R_ERROR;
1180 app_info->metadata = g_list_copy_deep(data->metadata, __copy_metadata, &ret);
1182 LOGE("memory alloc failed");
1183 pkgmgrinfo_basic_free_application(app_info);
1184 return PMINFO_R_ERROR;
1188 app_info->datacontrol = g_list_copy_deep(data->datacontrol, __copy_datacontrol, &ret);
1190 LOGE("memory alloc failed");
1191 pkgmgrinfo_basic_free_application(app_info);
1192 return PMINFO_R_ERROR;
1196 app_info->appcontrol = g_list_copy_deep(data->appcontrol, __copy_appcontrol, &ret);
1198 LOGE("memory alloc failed");
1199 pkgmgrinfo_basic_free_application(app_info);
1200 return PMINFO_R_ERROR;
1204 app_info->background_category = g_list_copy_deep(data->background_category, __copy_str, &ret);
1206 LOGE("memory alloc failed");
1207 pkgmgrinfo_basic_free_application(app_info);
1208 return PMINFO_R_ERROR;
1212 app_info->splashscreens = g_list_copy_deep(data->splashscreens, __copy_splashscreens, &ret);
1214 LOGE("memory alloc failed");
1215 pkgmgrinfo_basic_free_application(app_info);
1216 return PMINFO_R_ERROR;
1219 *application = app_info;
1224 API int pkgmgrinfo_appinfo_clone_appinfo(pkgmgrinfo_appinfo_h handle,
1225 pkgmgrinfo_appinfo_h *clone)
1227 pkgmgr_appinfo_x *info;
1228 pkgmgr_appinfo_x *temp = (pkgmgr_appinfo_x *)handle;
1231 return PMINFO_R_EINVAL;
1233 info = calloc(1, sizeof(pkgmgr_appinfo_x));
1235 LOGE("memory alloc failed");
1236 return PMINFO_R_ERROR;
1239 if (temp->package != NULL)
1240 info->package = strdup(temp->package);
1241 if (temp->locale != NULL)
1242 info->locale = strdup(temp->locale);
1244 info->app_component = temp->app_component;
1246 if (_appinfo_copy_appinfo(&info->app_info, temp->app_info) < 0) {
1247 LOGE("appinfo copy failed");
1249 free((void *)info->package);
1253 return PMINFO_R_ERROR;
1261 static int _appinfo_get_filtered_foreach_appinfo(uid_t uid,
1262 pkgmgrinfo_filter_x *filter, int flag, pkgmgrinfo_app_list_cb app_list_cb,
1268 pkgmgr_appinfo_x info;
1270 GHashTableIter iter;
1273 locale = _get_system_locale();
1275 return PMINFO_R_ERROR;
1277 list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
1278 __free_applications);
1281 return PMINFO_R_ERROR;
1284 ret = _appinfo_get_applications(uid, uid, locale, filter,
1285 flag | PMINFO_APPINFO_GET_BASICINFO, list);
1286 if (ret == PMINFO_R_OK && uid != GLOBAL_USER)
1287 ret = _appinfo_get_applications(GLOBAL_USER, uid, locale,
1288 filter, flag | PMINFO_APPINFO_GET_BASICINFO, list);
1290 if (ret != PMINFO_R_OK) {
1291 g_hash_table_destroy(list);
1296 g_hash_table_iter_init(&iter, list);
1297 while (g_hash_table_iter_next(&iter, NULL, &value)) {
1298 app = (application_x *)value;
1299 info.app_info = app;
1300 info.locale = locale;
1301 info.package = app->package;
1302 if (app_list_cb(&info, user_data) < 0)
1305 g_hash_table_destroy(list);
1311 static const char *__appcomponent_str(pkgmgrinfo_app_component comp);
1313 API int pkgmgrinfo_appinfo_get_usr_list(pkgmgrinfo_pkginfo_h handle,
1314 pkgmgrinfo_app_component component,
1315 pkgmgrinfo_app_list_cb app_func, void *user_data, uid_t uid)
1318 pkgmgrinfo_appinfo_filter_h filter;
1320 const char *comp_str = NULL;
1322 if (handle == NULL || app_func == NULL) {
1323 LOGE("invalid parameter");
1324 return PMINFO_R_EINVAL;
1327 if (pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid)) {
1328 LOGE("invalid parameter");
1329 return PMINFO_R_EINVAL;
1332 if (pkgmgrinfo_appinfo_filter_create(&filter))
1333 return PMINFO_R_ERROR;
1335 if (pkgmgrinfo_appinfo_filter_add_string(filter,
1336 PMINFO_APPINFO_PROP_APP_PACKAGE, pkgid)) {
1337 pkgmgrinfo_appinfo_filter_destroy(filter);
1338 return PMINFO_R_ERROR;
1341 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
1342 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
1343 pkgmgrinfo_appinfo_filter_destroy(filter);
1344 return PMINFO_R_ERROR;
1347 comp_str = __appcomponent_str(component);
1350 if (pkgmgrinfo_appinfo_filter_add_string(filter,
1351 PMINFO_APPINFO_PROP_APP_COMPONENT,
1353 pkgmgrinfo_appinfo_filter_destroy(filter);
1354 return PMINFO_R_ERROR;
1358 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter,
1359 PMINFO_APPINFO_GET_ALL, app_func, user_data);
1361 pkgmgrinfo_appinfo_filter_destroy(filter);
1366 API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle,
1367 pkgmgrinfo_app_component component,
1368 pkgmgrinfo_app_list_cb app_func, void *user_data)
1370 return pkgmgrinfo_appinfo_get_usr_list(handle, component, app_func, user_data, _getuid());
1373 API int pkgmgrinfo_appinfo_get_usr_installed_list_full(
1374 pkgmgrinfo_app_list_cb app_func, uid_t uid, int flag,
1378 pkgmgrinfo_appinfo_filter_h filter;
1380 if (app_func == NULL) {
1381 LOGE("invalid parameter");
1382 return PMINFO_R_EINVAL;
1385 if (pkgmgrinfo_appinfo_filter_create(&filter))
1386 return PMINFO_R_ERROR;
1388 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
1389 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
1390 pkgmgrinfo_appinfo_filter_destroy(filter);
1391 return PMINFO_R_ERROR;
1394 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
1395 PMINFO_APPINFO_PROP_PKG_DISABLE, false)) {
1396 pkgmgrinfo_appinfo_filter_destroy(filter);
1397 return PMINFO_R_ERROR;
1400 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
1401 PMINFO_APPINFO_PROP_APP_CHECK_STORAGE, false)) {
1402 pkgmgrinfo_appinfo_filter_destroy(filter);
1403 return PMINFO_R_ERROR;
1406 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter, flag, app_func,
1409 pkgmgrinfo_appinfo_filter_destroy(filter);
1414 API int pkgmgrinfo_appinfo_get_installed_list_full(
1415 pkgmgrinfo_app_list_cb app_func, int flag, void *user_data)
1417 return pkgmgrinfo_appinfo_get_usr_installed_list_full(app_func,
1418 _getuid(), flag, user_data);
1421 API int pkgmgrinfo_appinfo_get_usr_installed_list(
1422 pkgmgrinfo_app_list_cb app_func, uid_t uid, void *user_data)
1425 pkgmgrinfo_appinfo_filter_h filter;
1427 if (app_func == NULL) {
1428 LOGE("invalid parameter");
1429 return PMINFO_R_EINVAL;
1432 /* create an empty filter */
1433 ret = pkgmgrinfo_appinfo_filter_create(&filter);
1434 if (ret != PMINFO_R_OK)
1437 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
1438 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
1439 pkgmgrinfo_appinfo_filter_destroy(filter);
1440 return PMINFO_R_ERROR;
1443 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
1444 PMINFO_APPINFO_PROP_PKG_DISABLE, false)) {
1445 pkgmgrinfo_appinfo_filter_destroy(filter);
1446 return PMINFO_R_ERROR;
1449 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter,
1450 PMINFO_APPINFO_GET_ALL, app_func, user_data);
1452 pkgmgrinfo_appinfo_filter_destroy(filter);
1457 API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func,
1460 return pkgmgrinfo_appinfo_get_usr_installed_list(app_func, _getuid(),
1464 API int pkgmgrinfo_appinfo_get_appid(pkgmgrinfo_appinfo_h handle, char **appid)
1466 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1468 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1469 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1471 if (info->app_info == NULL || info->app_info->appid == NULL)
1472 return PMINFO_R_ERROR;
1473 *appid = (char *)info->app_info->appid;
1478 API int pkgmgrinfo_appinfo_get_pkgname(pkgmgrinfo_appinfo_h handle, char **pkg_name)
1480 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1482 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1483 retvm_if(pkg_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1485 if (info->package == NULL)
1486 return PMINFO_R_ERROR;
1488 *pkg_name = (char *)info->package;
1493 API int pkgmgrinfo_appinfo_get_pkgid(pkgmgrinfo_appinfo_h handle, char **pkgid)
1495 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1497 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1498 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1500 if (info->package == NULL)
1501 return PMINFO_R_ERROR;
1503 *pkgid = (char *)info->package;
1508 API int pkgmgrinfo_appinfo_get_pkgtype(pkgmgrinfo_appinfo_h handle, char **pkgtype)
1510 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1511 retvm_if(pkgtype == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1512 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1514 *pkgtype = (char *)info->app_info->package_type;
1519 API int pkgmgrinfo_appinfo_get_exec(pkgmgrinfo_appinfo_h handle, char **exec)
1521 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1523 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1524 retvm_if(exec == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1526 if (info->app_info == NULL || info->app_info->exec == NULL)
1527 return PMINFO_R_ERROR;
1528 *exec = (char *)info->app_info->exec;
1534 API int pkgmgrinfo_appinfo_get_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1537 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1539 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1540 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1542 if (info->app_info == NULL)
1543 return PMINFO_R_ERROR;
1545 if (info->app_info->icon == NULL) {
1550 ptr = (icon_x *)info->app_info->icon->data;
1552 return PMINFO_R_ERROR;
1554 if (ptr->text == NULL)
1555 return PMINFO_R_ERROR;
1563 API int pkgmgrinfo_appinfo_get_label(pkgmgrinfo_appinfo_h handle, char **label)
1566 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1571 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1572 retvm_if(label == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1574 if (info->app_info == NULL)
1575 return PMINFO_R_ERROR;
1577 locale = info->locale;
1579 locale = DEFAULT_LOCALE;
1581 for (tmp = info->app_info->label; tmp; tmp = tmp->next) {
1582 ptr = (label_x *)tmp->data;
1583 if (ptr == NULL || strcmp(locale, ptr->lang) != 0)
1594 for (tmp = info->app_info->label; tmp; tmp = tmp->next) {
1595 ptr = (label_x *)tmp->data;
1596 if (ptr == NULL || strcmp(DEFAULT_LOCALE, ptr->lang) != 0)
1602 *label = lbl ? lbl : "";
1607 static char *_get_localed_label(const char *appid, const char *locale, uid_t uid)
1609 char *result = NULL;
1611 sqlite3_stmt *stmt = NULL;
1616 parser_db = getUserPkgParserDBPathUID(uid);
1617 if (parser_db == NULL) {
1618 _LOGE("Failed to get parser db path");
1622 if (__open_db(parser_db, &db, SQLITE_OPEN_READONLY) != SQLITE_OK) {
1623 _LOGE("DB open fail\n");
1629 query = sqlite3_mprintf("select app_label from package_app_localized_info where app_id=%Q and app_locale=%Q", appid, locale);
1630 if (query == NULL) {
1631 _LOGE("Out of memory");
1635 if (sqlite3_prepare_v2(db, query, -1, &stmt, NULL) != SQLITE_OK) {
1636 _LOGE("prepare_v2 fail\n");
1640 if (sqlite3_step(stmt) == SQLITE_ROW) {
1641 val = (char *)sqlite3_column_text(stmt, 0);
1643 result = strdup(val);
1647 sqlite3_finalize(stmt);
1648 sqlite3_free(query);
1654 API int pkgmgrinfo_appinfo_usr_get_localed_label(const char *appid, const char *locale, uid_t uid, char **label)
1658 retvm_if(appid == NULL || locale == NULL || label == NULL, PMINFO_R_EINVAL, "Argument is NULL");
1660 val = _get_localed_label(appid, locale, uid);
1662 val = _get_localed_label(appid, DEFAULT_LOCALE, uid);
1665 val = _get_localed_label(appid, locale, GLOBAL_USER);
1667 val = _get_localed_label(appid, DEFAULT_LOCALE, GLOBAL_USER);
1671 return PMINFO_R_ERROR;
1678 API int pkgmgrinfo_appinfo_get_localed_label(const char *appid, const char *locale, char **label)
1680 return pkgmgrinfo_appinfo_usr_get_localed_label(appid, locale, _getuid(), label);
1683 API int pkgmgrinfo_appinfo_get_metadata_value(pkgmgrinfo_appinfo_h handle, const char *metadata_key, char **metadata_value)
1685 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1686 retvm_if(metadata_key == NULL, PMINFO_R_EINVAL, "metadata_key is NULL");
1687 retvm_if(metadata_value == NULL, PMINFO_R_EINVAL, "metadata_value is NULL");
1689 GList *list_md = NULL;
1690 metadata_x *metadata = NULL;
1691 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1693 list_md = info->app_info->metadata;
1695 for (; list_md; list_md = list_md->next) {
1696 metadata = (metadata_x *)list_md->data;
1697 if (metadata && metadata->key) {
1698 if (strcasecmp(metadata->key, metadata_key) == 0) {
1699 if (metadata->value == NULL)
1700 *metadata_value = "";
1702 *metadata_value = (char *)metadata->value;
1708 return PMINFO_R_EINVAL;
1711 static pkgmgrinfo_app_component __appcomponent_convert(const char *comp)
1713 if (strcasecmp(comp, "uiapp") == 0)
1714 return PMINFO_UI_APP;
1715 else if (strcasecmp(comp, "svcapp") == 0)
1716 return PMINFO_SVC_APP;
1717 else if (strcasecmp(comp, "widgetapp") == 0)
1718 return PMINFO_WIDGET_APP;
1719 else if (strcasecmp(comp, "watchapp") == 0)
1720 return PMINFO_WATCH_APP;
1725 static const char *__appcomponent_str(pkgmgrinfo_app_component comp)
1730 case PMINFO_SVC_APP:
1732 case PMINFO_WIDGET_APP:
1734 case PMINFO_WATCH_APP:
1741 API int pkgmgrinfo_appinfo_get_component(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_component *component)
1743 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1746 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1747 retvm_if(component == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1749 if (info->app_info == NULL)
1750 return PMINFO_R_ERROR;
1752 comp = __appcomponent_convert(info->app_info->component);
1754 return PMINFO_R_ERROR;
1761 API int pkgmgrinfo_appinfo_get_apptype(pkgmgrinfo_appinfo_h handle, char **app_type)
1763 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1765 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1766 retvm_if(app_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1768 if (info->app_info == NULL || info->app_info->type == NULL)
1769 return PMINFO_R_ERROR;
1770 *app_type = (char *)info->app_info->type;
1775 API int pkgmgrinfo_appinfo_get_operation(pkgmgrinfo_appcontrol_h handle,
1776 int *operation_count, char ***operation)
1778 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1779 retvm_if(operation == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1780 retvm_if(operation_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1781 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1782 *operation_count = data->operation_count;
1783 *operation = data->operation;
1787 API int pkgmgrinfo_appinfo_get_uri(pkgmgrinfo_appcontrol_h handle,
1788 int *uri_count, char ***uri)
1790 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1791 retvm_if(uri == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1792 retvm_if(uri_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1793 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1794 *uri_count = data->uri_count;
1799 API int pkgmgrinfo_appinfo_get_mime(pkgmgrinfo_appcontrol_h handle,
1800 int *mime_count, char ***mime)
1802 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1803 retvm_if(mime == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1804 retvm_if(mime_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1805 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1806 *mime_count = data->mime_count;
1811 API int pkgmgrinfo_appinfo_get_subapp(pkgmgrinfo_appcontrol_h handle,
1812 int *subapp_count, char ***subapp)
1814 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1815 retvm_if(subapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1816 retvm_if(subapp_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1817 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1818 *subapp_count = data->subapp_count;
1819 *subapp = data->subapp;
1823 API int pkgmgrinfo_appinfo_get_notification_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1828 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1830 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1831 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1833 if (info->app_info == NULL)
1834 return PMINFO_R_ERROR;
1836 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1837 ptr = (icon_x *)tmp->data;
1838 if (ptr == NULL || ptr->section == NULL)
1841 val = (char *)ptr->section;
1842 if (val && strcmp(val, "notification") == 0) {
1843 *icon = (char *)ptr->text;
1848 return PMINFO_R_ERROR;
1851 API int pkgmgrinfo_appinfo_get_recent_image_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_recentimage *type)
1854 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1856 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1857 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1859 if (info->app_info == NULL || info->app_info->recentimage == NULL)
1860 return PMINFO_R_ERROR;
1862 val = (char *)info->app_info->recentimage;
1863 if (strcasecmp(val, "capture") == 0)
1864 *type = PMINFO_RECENTIMAGE_USE_CAPTURE;
1865 else if (strcasecmp(val, "icon") == 0)
1866 *type = PMINFO_RECENTIMAGE_USE_ICON;
1868 *type = PMINFO_RECENTIMAGE_USE_NOTHING;
1873 API int pkgmgrinfo_appinfo_get_preview_image(pkgmgrinfo_appinfo_h handle, char **preview_img)
1878 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1880 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1881 retvm_if(preview_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1883 if (info->app_info == NULL)
1884 return PMINFO_R_ERROR;
1886 for (tmp = info->app_info->image; tmp; tmp = tmp->next) {
1887 ptr = (image_x *)tmp->data;
1888 if (ptr == NULL || ptr->section == NULL)
1891 val = (char *)ptr->section;
1892 if (val && strcmp(val, "preview") == 0) {
1893 *preview_img = (char *)ptr->text;
1898 return PMINFO_R_ERROR;
1901 API int pkgmgrinfo_appinfo_get_permission_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_permission_type *permission)
1904 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1906 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1907 retvm_if(permission == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1909 val = info->app_info->permission_type;
1911 return PMINFO_R_ERROR;
1913 if (strcmp(val, "signature") == 0)
1914 *permission = PMINFO_PERMISSION_SIGNATURE;
1915 else if (strcmp(val, "privilege") == 0)
1916 *permission = PMINFO_PERMISSION_PRIVILEGE;
1918 *permission = PMINFO_PERMISSION_NORMAL;
1923 API int pkgmgrinfo_appinfo_get_component_type(pkgmgrinfo_appinfo_h handle, char **component_type)
1925 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1927 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1928 retvm_if(component_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1930 if (info->app_info == NULL || info->app_info->component_type == NULL)
1931 return PMINFO_R_ERROR;
1933 *component_type = (char *)info->app_info->component_type;
1938 API int pkgmgrinfo_appinfo_get_hwacceleration(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_hwacceleration *hwacceleration)
1941 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1943 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1944 retvm_if(hwacceleration == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1946 if (info->app_info == NULL || info->app_info->hwacceleration == NULL)
1947 return PMINFO_R_ERROR;
1949 val = (char *)info->app_info->hwacceleration;
1950 if (strcasecmp(val, "off") == 0)
1951 *hwacceleration = PMINFO_HWACCELERATION_OFF;
1952 else if (strcasecmp(val, "on") == 0)
1953 *hwacceleration = PMINFO_HWACCELERATION_ON;
1955 *hwacceleration = PMINFO_HWACCELERATION_DEFAULT;
1960 API int pkgmgrinfo_appinfo_get_screenreader(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_screenreader *screenreader)
1963 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1965 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1966 retvm_if(screenreader == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1968 if (info->app_info == NULL || info->app_info->screenreader == NULL)
1969 return PMINFO_R_ERROR;
1971 val = (char *)info->app_info->screenreader;
1972 if (strcasecmp(val, "screenreader-off") == 0)
1973 *screenreader = PMINFO_SCREENREADER_OFF;
1974 else if (strcasecmp(val, "screenreader-on") == 0)
1975 *screenreader = PMINFO_SCREENREADER_ON;
1977 *screenreader = PMINFO_SCREENREADER_USE_SYSTEM_SETTING;
1982 API int pkgmgrinfo_appinfo_get_effectimage(pkgmgrinfo_appinfo_h handle, char **portrait_img, char **landscape_img)
1984 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1986 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1987 retvm_if(portrait_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1988 retvm_if(landscape_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1990 if (info->app_info == NULL)
1991 return PMINFO_R_ERROR;
1993 if (info->app_info->portraitimg == NULL)
1996 *portrait_img = (char *)info->app_info->portraitimg;
1998 if (info->app_info->landscapeimg == NULL)
1999 *landscape_img = "";
2001 *landscape_img = (char *)info->app_info->landscapeimg;
2006 API int pkgmgrinfo_appinfo_get_effectimage_type(pkgmgrinfo_appinfo_h handle, char **effectimage_type)
2008 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2010 if (handle == NULL || effectimage_type == NULL) {
2011 LOGE("invalid parameter");
2012 return PMINFO_R_EINVAL;
2015 if (info->app_info == NULL || info->app_info->effectimage_type == NULL)
2016 return PMINFO_R_ERROR;
2018 *effectimage_type = (char *)info->app_info->effectimage_type;
2023 API int pkgmgrinfo_appinfo_get_submode_mainid(pkgmgrinfo_appinfo_h handle, char **submode_mainid)
2025 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2027 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2028 retvm_if(submode_mainid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2030 if (info->app_info == NULL)
2031 return PMINFO_R_ERROR;
2033 if (info->app_info->submode_mainid == NULL)
2034 *submode_mainid = "";
2036 *submode_mainid = (char *)info->app_info->submode_mainid;
2041 API int pkgmgrinfo_appinfo_get_installed_storage_location(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_installed_storage *storage)
2043 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2044 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2046 if (info->app_info && info->app_info->installed_storage) {
2047 if (strcmp(info->app_info->installed_storage, "installed_internal") == 0)
2048 *storage = PMINFO_INTERNAL_STORAGE;
2049 else if (strcmp(info->app_info->installed_storage, "installed_external") == 0)
2050 *storage = PMINFO_EXTERNAL_STORAGE;
2052 return PMINFO_R_ERROR;
2054 return PMINFO_R_ERROR;
2060 API int pkgmgrinfo_appinfo_get_launch_mode(pkgmgrinfo_appinfo_h handle, char **mode)
2062 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2064 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2065 retvm_if(mode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2067 if (info->app_info->launch_mode == NULL)
2068 return PMINFO_R_ERROR;
2070 *mode = (char *)(info->app_info->launch_mode);
2075 API int pkgmgrinfo_appinfo_get_alias_appid(pkgmgrinfo_appinfo_h handle, char **alias_appid)
2077 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2079 if (handle == NULL || alias_appid == NULL) {
2080 LOGE("invalid parameter");
2081 return PMINFO_R_EINVAL;
2084 if (info->app_info == NULL || info->app_info->alias_appid == NULL)
2085 return PMINFO_R_ERROR;
2087 *alias_appid = (char *)info->app_info->alias_appid;
2092 API int pkgmgrinfo_appinfo_get_effective_appid(pkgmgrinfo_appinfo_h handle, char **effective_appid)
2094 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2096 if (handle == NULL || effective_appid == NULL) {
2097 LOGE("invalid parameter");
2098 return PMINFO_R_EINVAL;
2101 if (info->app_info == NULL)
2102 return PMINFO_R_ERROR;
2104 if (info->app_info->effective_appid == NULL)
2105 *effective_appid = "";
2107 *effective_appid = (char *)info->app_info->effective_appid;
2112 API int pkgmgrinfo_appinfo_get_tep_name(pkgmgrinfo_appinfo_h handle, char **tep_name)
2114 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2116 if (handle == NULL || tep_name == NULL) {
2117 LOGE("invalid parameter");
2118 return PMINFO_R_EINVAL;
2121 if (info->app_info == NULL)
2122 return PMINFO_R_ERROR;
2124 if (info->app_info->tep_name == NULL)
2127 *tep_name = (char *)info->app_info->tep_name;
2132 API int pkgmgrinfo_appinfo_get_zip_mount_file(pkgmgrinfo_appinfo_h handle, char **zip_mount_file)
2134 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2136 if (handle == NULL || zip_mount_file == NULL) {
2137 LOGE("invalid parameter");
2138 return PMINFO_R_EINVAL;
2141 if (info->app_info == NULL)
2142 return PMINFO_R_ERROR;
2144 if (info->app_info->zip_mount_file == NULL)
2145 *zip_mount_file = "";
2147 *zip_mount_file = (char *)info->app_info->zip_mount_file;
2152 API int pkgmgrinfo_appinfo_get_root_path(pkgmgrinfo_appinfo_h handle, char **root_path)
2154 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2156 if (handle == NULL || root_path == NULL) {
2157 LOGE("invalid parameter");
2158 return PMINFO_R_EINVAL;
2161 if (info->app_info == NULL || info->app_info->root_path == NULL)
2162 return PMINFO_R_ERROR;
2164 *root_path = (char *)info->app_info->root_path;
2169 API int pkgmgrinfo_appinfo_get_api_version(pkgmgrinfo_appinfo_h handle, char **api_version)
2171 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2173 if (handle == NULL || api_version == NULL) {
2174 LOGE("invalid parameter");
2175 return PMINFO_R_EINVAL;
2178 if (info->app_info == NULL || info->app_info->api_version == NULL)
2179 return PMINFO_R_ERROR;
2181 *api_version = (char *)info->app_info->api_version;
2186 API int pkgmgrinfo_appinfo_get_installed_time(pkgmgrinfo_appinfo_h handle, int *installed_time)
2188 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2190 if (handle == NULL || installed_time == NULL) {
2191 LOGE("invalid parameter");
2192 return PMINFO_R_EINVAL;
2195 if (info->app_info == NULL || info->app_info->package_installed_time == NULL)
2196 return PMINFO_R_ERROR;
2198 *installed_time = atoi(info->app_info->package_installed_time);
2203 static int _appinfo_get_datacontrol_info(sqlite3 *db, const char *providerid,
2204 const char *type, char **appid, char **access)
2206 static const char query[] =
2207 "SELECT app_id, access FROM package_app_data_control "
2208 "WHERE providerid=? AND type=?";
2212 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
2213 if (ret != SQLITE_OK) {
2214 LOGE("prepare failed: %s", sqlite3_errmsg(db));
2215 return PMINFO_R_ERROR;
2218 ret = sqlite3_bind_text(stmt, 1, providerid, -1, SQLITE_STATIC);
2219 if (ret != SQLITE_OK) {
2220 LOGE("bind failed: %s", sqlite3_errmsg(db));
2221 sqlite3_finalize(stmt);
2222 return PMINFO_R_ERROR;
2225 ret = sqlite3_bind_text(stmt, 2, type, -1, SQLITE_STATIC);
2226 if (ret != SQLITE_OK) {
2227 LOGE("bind failed: %s", sqlite3_errmsg(db));
2228 sqlite3_finalize(stmt);
2229 return PMINFO_R_ERROR;
2232 ret = sqlite3_step(stmt);
2233 if (ret != SQLITE_ROW) {
2234 sqlite3_finalize(stmt);
2235 if (ret == SQLITE_DONE) {
2236 return PMINFO_R_ENOENT;
2238 LOGE("step error: %s", sqlite3_errmsg(db));
2239 return PMINFO_R_ERROR;
2243 *appid = strdup((char *)sqlite3_column_text(stmt, 0));
2244 if (*appid == NULL) {
2245 LOGE("out of memory");
2246 sqlite3_finalize(stmt);
2247 return PMINFO_R_ERROR;
2249 *access = strdup((char *)sqlite3_column_text(stmt, 1));
2250 if (*access == NULL) {
2251 LOGE("out of memory");
2253 sqlite3_finalize(stmt);
2254 return PMINFO_R_ERROR;
2257 sqlite3_finalize(stmt);
2262 static int _pkgmgrinfo_appinfo_get_datacontrol_info(uid_t uid,
2263 const char *providerid, const char *type,
2264 char **appid, char **access)
2270 dbpath = getUserPkgParserDBPathUID(GLOBAL_USER);
2272 return PMINFO_R_ERROR;
2274 ret = __open_db(dbpath, &db, SQLITE_OPEN_READONLY);
2276 if (ret != SQLITE_OK) {
2277 LOGE("open db failed: %s", sqlite3_errmsg(db));
2278 return PMINFO_R_ERROR;
2281 ret = _appinfo_get_datacontrol_info(db, providerid, type, appid,
2283 sqlite3_close_v2(db);
2288 API int pkgmgrinfo_appinfo_usr_get_datacontrol_info(const char *providerid,
2289 const char *type, uid_t uid, char **appid, char **access)
2293 if (providerid == NULL || type == NULL || appid == NULL ||
2295 LOGE("invalid parameter");
2296 return PMINFO_R_EINVAL;
2299 ret = _pkgmgrinfo_appinfo_get_datacontrol_info(GLOBAL_USER, providerid,
2300 type, appid, access);
2301 if (ret == PMINFO_R_ENOENT && uid != GLOBAL_USER)
2302 ret = _pkgmgrinfo_appinfo_get_datacontrol_info(uid, providerid,
2303 type, appid, access);
2305 /* FIXME: It should return PMINFO_R_ENOENT but to keep previous
2306 * implementation, return PMINFO_R_ERROR. This should be
2309 if (ret == PMINFO_R_ENOENT) {
2310 LOGE("no datacontrol info of %s", providerid);
2311 ret = PMINFO_R_ERROR;
2317 API int pkgmgrinfo_appinfo_get_datacontrol_info(const char *providerid,
2318 const char *type, char **appid, char **access)
2320 return pkgmgrinfo_appinfo_usr_get_datacontrol_info(providerid,
2321 type, _getuid(), appid, access);
2324 static int _appinfo_get_datacontrol_appid(sqlite3 *db, const char *providerid,
2327 static const char query[] =
2328 "SELECT app_id FROM package_app_data_control "
2329 "WHERE providerid=?";
2333 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
2334 if (ret != SQLITE_OK) {
2335 LOGE("prepare failed: %s", sqlite3_errmsg(db));
2336 return PMINFO_R_ERROR;
2339 ret = sqlite3_bind_text(stmt, 1, providerid, -1, SQLITE_STATIC);
2340 if (ret != SQLITE_OK) {
2341 LOGE("bind failed: %s", sqlite3_errmsg(db));
2342 sqlite3_finalize(stmt);
2343 return PMINFO_R_ERROR;
2346 ret = sqlite3_step(stmt);
2347 if (ret != SQLITE_ROW) {
2348 sqlite3_finalize(stmt);
2349 if (ret == SQLITE_DONE) {
2350 return PMINFO_R_ENOENT;
2352 LOGE("step error: %s", sqlite3_errmsg(db));
2353 return PMINFO_R_ERROR;
2357 *appid = strdup((char *)sqlite3_column_text(stmt, 0));
2359 sqlite3_finalize(stmt);
2361 if (*appid == NULL) {
2362 LOGE("out of memory");
2363 return PMINFO_R_ERROR;
2369 static int _pkgmgrinfo_appinfo_get_datacontrol_appid(uid_t uid,
2370 const char *providerid, char **appid)
2376 dbpath = getUserPkgParserDBPathUID(GLOBAL_USER);
2378 return PMINFO_R_ERROR;
2380 ret = __open_db(dbpath, &db, SQLITE_OPEN_READONLY);
2382 if (ret != SQLITE_OK) {
2383 LOGE("open db failed: %s", sqlite3_errmsg(db));
2384 return PMINFO_R_ERROR;
2387 ret = _appinfo_get_datacontrol_appid(db, providerid, appid);
2388 sqlite3_close_v2(db);
2393 API int pkgmgrinfo_appinfo_usr_get_datacontrol_appid(const char *providerid,
2394 uid_t uid, char **appid)
2398 if (providerid == NULL || appid == NULL) {
2399 LOGE("invalid parameter");
2400 return PMINFO_R_EINVAL;
2403 ret = _pkgmgrinfo_appinfo_get_datacontrol_appid(GLOBAL_USER, providerid,
2405 if (ret == PMINFO_R_ENOENT && uid != GLOBAL_USER)
2406 ret = _pkgmgrinfo_appinfo_get_datacontrol_appid(uid, providerid,
2409 /* FIXME: It should return PMINFO_R_ENOENT but to keep previous
2410 * implementation, return PMINFO_R_ERROR. This should be
2413 if (ret == PMINFO_R_ENOENT) {
2414 LOGE("no datacontrol appid of %s", providerid);
2415 ret = PMINFO_R_ERROR;
2421 API int pkgmgrinfo_appinfo_get_datacontrol_appid(const char *providerid, char **appid)
2423 return pkgmgrinfo_appinfo_usr_get_datacontrol_appid(providerid, _getuid(), appid);
2426 static int _appinfo_get_datacontrol_trusted_info(sqlite3 *db,
2427 const char *providerid, const char *type, char **appid,
2430 static const char query[] =
2431 "SELECT app_id, trusted FROM package_app_data_control "
2432 "WHERE providerid=? AND type=?";
2436 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
2437 if (ret != SQLITE_OK) {
2438 LOGE("prepare failed: %s", sqlite3_errmsg(db));
2439 return PMINFO_R_ERROR;
2442 ret = sqlite3_bind_text(stmt, 1, providerid, -1, SQLITE_STATIC);
2443 if (ret != SQLITE_OK) {
2444 LOGE("bind failed: %s", sqlite3_errmsg(db));
2445 sqlite3_finalize(stmt);
2446 return PMINFO_R_ERROR;
2449 ret = sqlite3_bind_text(stmt, 2, type, -1, SQLITE_STATIC);
2450 if (ret != SQLITE_OK) {
2451 LOGE("bind failed: %s", sqlite3_errmsg(db));
2452 sqlite3_finalize(stmt);
2453 return PMINFO_R_ERROR;
2456 ret = sqlite3_step(stmt);
2457 if (ret != SQLITE_ROW) {
2458 sqlite3_finalize(stmt);
2459 if (ret == SQLITE_DONE) {
2460 return PMINFO_R_ENOENT;
2462 LOGE("step error: %s", sqlite3_errmsg(db));
2463 return PMINFO_R_ERROR;
2467 *appid = strdup((char *)sqlite3_column_text(stmt, 0));
2468 *is_trusted = _get_bool_value((char *)sqlite3_column_text(stmt, 1));
2470 sqlite3_finalize(stmt);
2472 if (*appid == NULL) {
2473 LOGE("out of memory");
2474 return PMINFO_R_ERROR;
2480 static int _pkgmgrinfo_appinfo_get_datacontrol_trusted_info(uid_t uid,
2481 const char *providerid, const char *type, char **appid,
2488 dbpath = getUserPkgParserDBPathUID(GLOBAL_USER);
2490 return PMINFO_R_ERROR;
2492 ret = __open_db(dbpath, &db, SQLITE_OPEN_READONLY);
2494 if (ret != SQLITE_OK) {
2495 LOGE("open db failed: %s", sqlite3_errmsg(db));
2496 return PMINFO_R_ERROR;
2499 ret = _appinfo_get_datacontrol_trusted_info(db, providerid, type, appid,
2501 sqlite3_close_v2(db);
2506 API int pkgmgrinfo_appinfo_usr_get_datacontrol_trusted_info(
2507 const char *providerid, const char *type, uid_t uid,
2508 char **appid, bool *is_trusted)
2512 if (providerid == NULL || type == NULL || appid == NULL ||
2513 is_trusted == NULL) {
2514 LOGE("invalid parameter");
2515 return PMINFO_R_EINVAL;
2518 ret = _pkgmgrinfo_appinfo_get_datacontrol_trusted_info(GLOBAL_USER,
2519 providerid, type, appid, is_trusted);
2520 if (ret == PMINFO_R_ENOENT && uid != GLOBAL_USER)
2521 ret = _pkgmgrinfo_appinfo_get_datacontrol_trusted_info(uid,
2522 providerid, type, appid, is_trusted);
2524 /* FIXME: It should return PMINFO_R_ENOENT but to keep previous
2525 * implementation, return PMINFO_R_ERROR. This should be
2528 if (ret == PMINFO_R_ENOENT) {
2529 LOGE("no datacontrol trusted info of %s", providerid);
2530 ret = PMINFO_R_ERROR;
2536 API int pkgmgrinfo_appinfo_get_datacontrol_trsuted_info(const char *providerid,
2537 const char *type, char **appid, bool *is_trusted)
2539 return pkgmgrinfo_appinfo_usr_get_datacontrol_trusted_info(providerid,
2540 type, _getuid(), appid, is_trusted);
2543 static int _appinfo_foreach_datacontrol_privileges(sqlite3 *db,
2544 const char *providerid, const char *type,
2545 pkgmgrinfo_pkg_privilege_list_cb callback, void *user_data)
2547 static const char query[] =
2548 "SELECT privilege FROM package_app_data_control_privilege "
2549 "WHERE providerid=? AND type=?";
2554 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
2555 if (ret != SQLITE_OK) {
2556 LOGE("prepare failed: %s", sqlite3_errmsg(db));
2557 return PMINFO_R_ERROR;
2560 ret = sqlite3_bind_text(stmt, 1, providerid, -1, SQLITE_STATIC);
2561 if (ret != SQLITE_OK) {
2562 LOGE("bind failed: %s", sqlite3_errmsg(db));
2563 sqlite3_finalize(stmt);
2564 return PMINFO_R_ERROR;
2567 ret = sqlite3_bind_text(stmt, 2, type, -1, SQLITE_STATIC);
2568 if (ret != SQLITE_OK) {
2569 LOGE("bind failed: %s", sqlite3_errmsg(db));
2570 sqlite3_finalize(stmt);
2571 return PMINFO_R_ERROR;
2574 while (sqlite3_step(stmt) == SQLITE_ROW) {
2576 ret = callback((const char *)sqlite3_column_text(stmt, 0),
2582 sqlite3_finalize(stmt);
2584 return count ? PMINFO_R_OK : PMINFO_R_ENOENT;
2587 static int _pkgmgrinfo_appinfo_foreach_datacontrol_privileges(uid_t uid,
2588 const char *providerid, const char *type,
2589 pkgmgrinfo_pkg_privilege_list_cb callback, void *user_data)
2595 dbpath = getUserPkgParserDBPathUID(GLOBAL_USER);
2597 return PMINFO_R_ERROR;
2599 ret = __open_db(dbpath, &db, SQLITE_OPEN_READONLY);
2601 if (ret != SQLITE_OK) {
2602 LOGE("open db failed: %s", sqlite3_errmsg(db));
2603 return PMINFO_R_ERROR;
2606 ret = _appinfo_foreach_datacontrol_privileges(db, providerid, type,
2607 callback, user_data);
2608 sqlite3_close_v2(db);
2613 API int pkgmgrinfo_appinfo_usr_foreach_datacontrol_privileges(
2614 const char *providerid, const char *type,
2615 pkgmgrinfo_pkg_privilege_list_cb privilege_func,
2616 void *user_data, uid_t uid)
2620 if (providerid == NULL || type == NULL || privilege_func == NULL) {
2621 LOGE("invalid parameter");
2622 return PMINFO_R_EINVAL;
2625 ret = _pkgmgrinfo_appinfo_foreach_datacontrol_privileges(GLOBAL_USER,
2626 providerid, type, privilege_func, user_data);
2627 if (ret == PMINFO_R_ENOENT && uid != GLOBAL_USER)
2628 ret = _pkgmgrinfo_appinfo_foreach_datacontrol_privileges(uid,
2629 providerid, type, privilege_func, user_data);
2631 if (ret == PMINFO_R_ENOENT)
2637 API int pkgmgrinfo_appinfo_foreach_datacontrol_privileges(
2638 const char *providerid, const char *type,
2639 pkgmgrinfo_pkg_privilege_list_cb privilege_func,
2642 return pkgmgrinfo_appinfo_usr_foreach_datacontrol_privileges(
2643 providerid, type, privilege_func, user_data, _getuid());
2646 API int pkgmgrinfo_appinfo_get_support_mode(pkgmgrinfo_appinfo_h handle, int *support_mode)
2648 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2649 retvm_if(support_mode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2651 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2652 if (info->app_info->support_mode)
2653 *support_mode = atoi(info->app_info->support_mode);
2660 API int pkgmgrinfo_appinfo_foreach_category(pkgmgrinfo_appinfo_h handle,
2661 pkgmgrinfo_app_category_list_cb category_func, void *user_data)
2663 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2664 retvm_if(category_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2666 const char *category;
2668 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2670 if (info->app_info == NULL)
2671 return PMINFO_R_ERROR;
2673 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
2674 category = (const char *)tmp->data;
2676 ret = category_func(category, user_data);
2684 API int pkgmgrinfo_appinfo_foreach_metadata(pkgmgrinfo_appinfo_h handle,
2685 pkgmgrinfo_app_metadata_list_cb metadata_func, void *user_data)
2687 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2688 retvm_if(metadata_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2692 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2694 if (info->app_info == NULL)
2695 return PMINFO_R_ERROR;
2697 for (tmp = info->app_info->metadata; tmp; tmp = tmp->next) {
2698 ptr = (metadata_x *)tmp->data;
2702 ret = metadata_func(ptr->key, ptr->value ? ptr->value : "", user_data);
2710 static int _appinfo_foreach_appcontrol_privileges(sqlite3 *db,
2711 const char *appid, const char *operation,
2712 pkgmgrinfo_pkg_privilege_list_cb callback, void *user_data)
2714 static const char query[] =
2715 "SELECT app_control, privilege FROM package_app_app_control_privilege "
2719 const char *app_control;
2720 char *dup_app_control;
2722 char *saveptr = NULL;
2723 const char *privilege;
2726 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
2727 if (ret != SQLITE_OK) {
2728 LOGE("prepare failed: %s", sqlite3_errmsg(db));
2729 return PMINFO_R_ERROR;
2732 ret = sqlite3_bind_text(stmt, 1, appid, -1, SQLITE_STATIC);
2733 if (ret != SQLITE_OK) {
2734 LOGE("bind failed: %s", sqlite3_errmsg(db));
2735 sqlite3_finalize(stmt);
2736 return PMINFO_R_ERROR;
2739 while (sqlite3_step(stmt) == SQLITE_ROW) {
2740 app_control = (const char *)sqlite3_column_text(stmt, 0);
2744 dup_app_control = strdup(app_control);
2745 if (!dup_app_control)
2748 token = strtok_r(dup_app_control, "|", &saveptr);
2749 if (token && !strcmp(token, operation)) {
2751 privilege = (const char *)sqlite3_column_text(stmt, 1);
2752 ret = callback(privilege, user_data);
2754 free(dup_app_control);
2758 free(dup_app_control);
2761 sqlite3_finalize(stmt);
2763 return count ? PMINFO_R_OK : PMINFO_R_ENOENT;
2766 static int _pkgmgrinfo_appinfo_foreach_appcontrol_privileges(uid_t uid,
2767 const char *appid, const char *operation,
2768 pkgmgrinfo_pkg_privilege_list_cb callback, void *user_data)
2774 dbpath = getUserPkgParserDBPathUID(uid);
2776 return PMINFO_R_ERROR;
2778 ret = __open_db(dbpath, &db, SQLITE_OPEN_READONLY);
2780 if (ret != SQLITE_OK) {
2781 LOGE("open db failed: %s", sqlite3_errmsg(db));
2782 return PMINFO_R_ERROR;
2785 ret = _appinfo_foreach_appcontrol_privileges(db, appid, operation,
2786 callback, user_data);
2787 sqlite3_close_v2(db);
2792 API int pkgmgrinfo_appinfo_usr_foreach_appcontrol_privileges(const char *appid,
2793 const char *operation,
2794 pkgmgrinfo_pkg_privilege_list_cb privilege_func,
2795 void *user_data, uid_t uid)
2799 if (appid == NULL || operation == NULL || privilege_func == NULL) {
2800 LOGE("invalid parameter");
2801 return PMINFO_R_EINVAL;
2804 ret = _pkgmgrinfo_appinfo_foreach_appcontrol_privileges(GLOBAL_USER,
2805 appid, operation, privilege_func, user_data);
2806 if (ret == PMINFO_R_ENOENT && uid != GLOBAL_USER)
2807 ret = _pkgmgrinfo_appinfo_foreach_appcontrol_privileges(uid,
2808 appid, operation, privilege_func, user_data);
2810 if (ret == PMINFO_R_ENOENT)
2816 API int pkgmgrinfo_appinfo_foreach_appcontrol_privileges(const char *appid,
2817 const char *operation,
2818 pkgmgrinfo_pkg_privilege_list_cb privilege_func,
2821 return pkgmgrinfo_appinfo_usr_foreach_appcontrol_privileges(appid,
2822 operation, privilege_func, user_data, _getuid());
2825 API int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
2826 pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
2828 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2829 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2831 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2832 appcontrol_x *appcontrol;
2835 if (info->app_info == NULL)
2836 return PMINFO_R_ERROR;
2838 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
2839 appcontrol = (appcontrol_x *)tmp->data;
2840 if (appcontrol == NULL || !strcasecmp(appcontrol->visibility, "remote-only"))
2842 ret = appcontrol_func(appcontrol->operation, appcontrol->uri, appcontrol->mime, user_data);
2850 API int pkgmgrinfo_appinfo_foreach_remote_appcontrol(pkgmgrinfo_appinfo_h handle,
2851 pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
2853 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2854 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2856 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2857 appcontrol_x *appcontrol;
2860 if (info->app_info == NULL)
2861 return PMINFO_R_ERROR;
2863 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
2864 appcontrol = (appcontrol_x *)tmp->data;
2865 if (appcontrol == NULL || !strcasecmp(appcontrol->visibility, "local-only"))
2867 ret = appcontrol_func(appcontrol->operation, appcontrol->uri, appcontrol->mime, user_data);
2875 API int pkgmgrinfo_appinfo_foreach_background_category(
2876 pkgmgrinfo_appinfo_h handle,
2877 pkgmgrinfo_app_background_category_list_cb category_func,
2880 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2884 if (handle == NULL || category_func == NULL || info->app_info == NULL) {
2885 LOGE("invalid parameter");
2886 return PMINFO_R_EINVAL;
2889 for (tmp = info->app_info->background_category; tmp; tmp = tmp->next) {
2890 category = (char *)tmp->data;
2891 if (category == NULL)
2894 if (category_func(category, user_data) < 0)
2901 API int pkgmgrinfo_appinfo_foreach_splash_screen(pkgmgrinfo_appinfo_h handle,
2902 pkgmgrinfo_app_splash_screen_list_cb splash_screen_func,
2905 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2906 splashscreen_x *splashscreen;
2910 if (info == NULL || info->app_info == NULL
2911 || splash_screen_func == NULL) {
2912 LOGE("invalid parameter");
2913 return PMINFO_R_EINVAL;
2916 for (tmp = info->app_info->splashscreens; tmp; tmp = tmp->next) {
2917 splashscreen = (splashscreen_x *)tmp->data;
2918 if (splashscreen == NULL)
2920 ret = splash_screen_func(splashscreen->src,
2922 splashscreen->orientation,
2923 splashscreen->indicatordisplay,
2924 splashscreen->operation,
2925 splashscreen->color_depth,
2934 API int pkgmgrinfo_appinfo_is_nodisplay(pkgmgrinfo_appinfo_h handle, bool *nodisplay)
2936 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2937 retvm_if(nodisplay == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2938 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2940 if (info->app_info == NULL || info->app_info->nodisplay == NULL)
2941 return PMINFO_R_ERROR;
2943 *nodisplay = _get_bool_value(info->app_info->nodisplay);
2948 API int pkgmgrinfo_appinfo_is_multiple(pkgmgrinfo_appinfo_h handle, bool *multiple)
2950 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2951 retvm_if(multiple == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2952 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2954 if (info->app_info == NULL || info->app_info->multiple == NULL)
2955 return PMINFO_R_ERROR;
2957 *multiple = _get_bool_value(info->app_info->multiple);
2962 API int pkgmgrinfo_appinfo_is_indicator_display_allowed(pkgmgrinfo_appinfo_h handle, bool *indicator_disp)
2964 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2965 retvm_if(indicator_disp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2966 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2968 if (info->app_info == NULL || info->app_info->indicatordisplay == NULL)
2969 return PMINFO_R_ERROR;
2971 *indicator_disp = _get_bool_value(info->app_info->indicatordisplay);
2976 API int pkgmgrinfo_appinfo_is_taskmanage(pkgmgrinfo_appinfo_h handle, bool *taskmanage)
2978 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2979 retvm_if(taskmanage == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2980 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2982 if (info->app_info == NULL || info->app_info->taskmanage == NULL)
2983 return PMINFO_R_ERROR;
2985 *taskmanage = _get_bool_value(info->app_info->taskmanage);
2990 API int pkgmgrinfo_appinfo_is_enabled(pkgmgrinfo_appinfo_h handle, bool *enabled)
2992 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2993 retvm_if(enabled == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2994 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2996 if (info->app_info == NULL || info->app_info->is_disabled == NULL)
2997 return PMINFO_R_ERROR;
2999 *enabled = !_get_bool_value(info->app_info->is_disabled);
3004 API int pkgmgrinfo_appinfo_is_onboot(pkgmgrinfo_appinfo_h handle, bool *onboot)
3006 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
3007 retvm_if(onboot == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
3008 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3010 if (info->app_info == NULL || info->app_info->onboot == NULL)
3011 return PMINFO_R_ERROR;
3013 *onboot = _get_bool_value(info->app_info->onboot);
3018 API int pkgmgrinfo_appinfo_is_autorestart(pkgmgrinfo_appinfo_h handle, bool *autorestart)
3020 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
3021 retvm_if(autorestart == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
3022 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3024 if (info->app_info == NULL || info->app_info->autorestart == NULL)
3025 return PMINFO_R_ERROR;
3027 *autorestart = _get_bool_value(info->app_info->autorestart);
3032 API int pkgmgrinfo_appinfo_is_mainapp(pkgmgrinfo_appinfo_h handle, bool *mainapp)
3034 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
3035 retvm_if(mainapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
3036 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3038 if (info->app_info == NULL || info->app_info->mainapp == NULL)
3039 return PMINFO_R_ERROR;
3041 *mainapp = _get_bool_value(info->app_info->mainapp);
3046 API int pkgmgrinfo_appinfo_is_preload(pkgmgrinfo_appinfo_h handle, bool *preload)
3048 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
3049 retvm_if(preload == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3050 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3052 if (info->app_info == NULL || info->app_info->preload == NULL)
3053 return PMINFO_R_ERROR;
3055 *preload = _get_bool_value(info->app_info->preload);
3060 API int pkgmgrinfo_appinfo_is_submode(pkgmgrinfo_appinfo_h handle, bool *submode)
3062 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
3063 retvm_if(submode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3064 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3066 if (info->app_info == NULL || info->app_info->submode == NULL)
3067 return PMINFO_R_ERROR;
3069 *submode = _get_bool_value(info->app_info->submode);
3074 API int pkgmgrinfo_appinfo_is_process_pool(pkgmgrinfo_appinfo_h handle, bool *process_pool)
3076 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3078 if (handle == NULL || process_pool == NULL) {
3079 LOGE("invalid parameter");
3080 return PMINFO_R_EINVAL;
3083 if (info->app_info == NULL)
3084 return PMINFO_R_ERROR;
3086 *process_pool = _get_bool_value(info->app_info->process_pool);
3091 API int pkgmgrinfo_appinfo_is_category_exist(pkgmgrinfo_appinfo_h handle, const char *category, bool *exist)
3093 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
3094 retvm_if(category == NULL, PMINFO_R_EINVAL, "category is NULL");
3095 retvm_if(exist == NULL, PMINFO_R_EINVAL, "exist is NULL");
3099 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3101 if (info->app_info == NULL)
3102 return PMINFO_R_ERROR;
3105 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
3106 val = (const char *)tmp->data;
3109 if (strcasecmp(val, category) == 0) {
3118 API int pkgmgrinfo_appinfo_is_ui_gadget(pkgmgrinfo_appinfo_h handle,
3121 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3123 if (info == NULL || info->app_info == NULL || ui_gadget == NULL) {
3124 _LOGE("invalid parameter");
3125 return PMINFO_R_EINVAL;
3127 if (info->app_info->ui_gadget == NULL)
3128 info->app_info->ui_gadget = strdup("false");
3130 *ui_gadget = _get_bool_value(info->app_info->ui_gadget);
3135 API int pkgmgrinfo_appinfo_is_support_disable(pkgmgrinfo_appinfo_h handle,
3136 bool *support_disable)
3138 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3140 if (info == NULL || info->app_info == NULL || support_disable == NULL) {
3141 _LOGE("invalid parameter");
3142 return PMINFO_R_EINVAL;
3145 *support_disable = _get_bool_value(info->app_info->support_disable);
3150 API int pkgmgrinfo_appinfo_is_removable(pkgmgrinfo_appinfo_h handle,
3153 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3155 if (info == NULL || info->app_info == NULL || removable == NULL) {
3156 _LOGE("invalid parameter");
3157 return PMINFO_R_EINVAL;
3160 *removable = _get_bool_value(info->app_info->removable);
3165 API int pkgmgrinfo_appinfo_is_system(pkgmgrinfo_appinfo_h handle, bool *system)
3167 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3169 if (info == NULL || info->app_info == NULL || system == NULL) {
3170 _LOGE("invalid parameter");
3171 return PMINFO_R_EINVAL;
3174 *system = _get_bool_value(info->app_info->package_system);
3179 API int pkgmgrinfo_appinfo_is_disabled(pkgmgrinfo_appinfo_h handle, bool *disabled)
3181 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
3182 retvm_if(disabled == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
3183 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3185 if (info->app_info == NULL || info->app_info->is_disabled == NULL)
3186 return PMINFO_R_ERROR;
3188 *disabled = _get_bool_value(info->app_info->is_disabled);
3193 API int pkgmgrinfo_appinfo_is_global(pkgmgrinfo_appinfo_h handle, bool *global)
3195 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3197 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
3198 retvm_if(global == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3200 if (info->app_info == NULL || info->app_info->for_all_users == NULL)
3201 return PMINFO_R_ERROR;
3203 *global = _get_bool_value(info->app_info->for_all_users);
3208 API int pkgmgrinfo_appinfo_get_splash_screen_display(pkgmgrinfo_appinfo_h handle, bool *splash_screen_display)
3210 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3212 if (info == NULL || splash_screen_display == NULL) {
3213 _LOGE("Invalid parameter");
3214 return PMINFO_R_EINVAL;
3217 if (info->app_info == NULL || info->app_info->splash_screen_display == NULL)
3218 return PMINFO_R_ERROR;
3220 *splash_screen_display = _get_bool_value(info->app_info->splash_screen_display);
3225 API int pkgmgrinfo_appinfo_get_setup_appid(pkgmgrinfo_appinfo_h handle, char **setup_appid)
3227 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3229 if (info == NULL || setup_appid == NULL) {
3230 _LOGE("Invalid parameter");
3231 return PMINFO_R_EINVAL;
3234 if (info->app_info == NULL || info->app_info->setup_appid == NULL)
3235 return PMINFO_R_ERROR;
3237 *setup_appid = info->app_info->setup_appid;
3241 API int pkgmgrinfo_appinfo_is_support_ambient(pkgmgrinfo_appinfo_h handle,
3242 bool *support_ambient)
3244 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3246 if (info == NULL || support_ambient == NULL) {
3247 _LOGE("Invalid parameter");
3248 return PMINFO_R_EINVAL;
3251 if (info->app_info == NULL || info->app_info->support_ambient == NULL)
3252 return PMINFO_R_ERROR;
3254 *support_ambient = _get_bool_value(info->app_info->support_ambient);
3259 API int pkgmgrinfo_appinfo_destroy_appinfo(pkgmgrinfo_appinfo_h handle)
3261 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
3262 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3263 __cleanup_appinfo(info);
3267 API int pkgmgrinfo_appinfo_filter_create(pkgmgrinfo_appinfo_filter_h *handle)
3269 return (pkgmgrinfo_pkginfo_filter_create(handle));
3272 API int pkgmgrinfo_appinfo_filter_destroy(pkgmgrinfo_appinfo_filter_h handle)
3274 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
3277 static gint __compare_func(gconstpointer data1, gconstpointer data2)
3279 pkgmgrinfo_node_x *node1 = (pkgmgrinfo_node_x *)data1;
3280 pkgmgrinfo_node_x *node2 = (pkgmgrinfo_node_x *)data2;
3281 if (node1->prop == node2->prop)
3283 else if (node1->prop > node2->prop)
3289 API int pkgmgrinfo_appinfo_filter_add_int(pkgmgrinfo_appinfo_filter_h handle,
3290 const char *property, const int value)
3292 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3293 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3294 char buf[PKG_VALUE_STRING_LEN_MAX] = {'\0'};
3296 GSList *link = NULL;
3298 prop = _pminfo_appinfo_convert_to_prop_int(property);
3299 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_INT ||
3300 prop > E_PMINFO_APPINFO_PROP_APP_MAX_INT) {
3301 _LOGE("Invalid Integer Property\n");
3302 return PMINFO_R_EINVAL;
3304 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
3305 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1, sizeof(pkgmgrinfo_node_x));
3307 _LOGE("Out of Memory!!!\n");
3308 return PMINFO_R_ERROR;
3310 snprintf(buf, PKG_VALUE_STRING_LEN_MAX - 1, "%d", value);
3311 val = strndup(buf, PKG_VALUE_STRING_LEN_MAX - 1);
3313 _LOGE("Out of Memory\n");
3316 return PMINFO_R_ERROR;
3320 /*If API is called multiple times for same property, we should override the previous values.
3321 Last value set will be used for filtering.*/
3322 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
3324 filter->list = g_slist_delete_link(filter->list, link);
3325 filter->list = g_slist_append(filter->list, (gpointer)node);
3330 API int pkgmgrinfo_appinfo_filter_add_bool(pkgmgrinfo_appinfo_filter_h handle,
3331 const char *property, const bool value)
3333 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3334 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3336 GSList *link = NULL;
3338 prop = _pminfo_appinfo_convert_to_prop_bool(property);
3339 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_BOOL ||
3340 prop > E_PMINFO_APPINFO_PROP_APP_MAX_BOOL) {
3341 _LOGE("Invalid Boolean Property\n");
3342 return PMINFO_R_EINVAL;
3344 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
3345 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1, sizeof(pkgmgrinfo_node_x));
3347 _LOGE("Out of Memory!!!\n");
3348 return PMINFO_R_ERROR;
3351 val = strndup("true", 4);
3353 val = strndup("false", 5);
3355 _LOGE("Out of Memory\n");
3358 return PMINFO_R_ERROR;
3362 /*If API is called multiple times for same property, we should override the previous values.
3363 Last value set will be used for filtering.*/
3364 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
3366 filter->list = g_slist_delete_link(filter->list, link);
3367 filter->list = g_slist_append(filter->list, (gpointer)node);
3372 API int pkgmgrinfo_appinfo_filter_add_string(pkgmgrinfo_appinfo_filter_h handle,
3373 const char *property, const char *value)
3375 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3376 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3377 retvm_if(value == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3379 pkgmgrinfo_node_x *ptr = NULL;
3380 char prev[PKG_STRING_LEN_MAX] = {'\0'};
3381 char temp[PKG_STRING_LEN_MAX] = {'\0'};
3382 GSList *link = NULL;
3384 prop = _pminfo_appinfo_convert_to_prop_str(property);
3385 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_STR ||
3386 prop > E_PMINFO_APPINFO_PROP_APP_MAX_STR) {
3387 _LOGE("Invalid String Property\n");
3388 return PMINFO_R_EINVAL;
3390 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
3391 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1, sizeof(pkgmgrinfo_node_x));
3393 _LOGE("Out of Memory!!!\n");
3394 return PMINFO_R_ERROR;
3398 case E_PMINFO_APPINFO_PROP_APP_COMPONENT:
3399 node->value = strdup(value);
3400 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
3402 filter->list = g_slist_delete_link(filter->list, link);
3403 filter->list = g_slist_append(filter->list, (gpointer)node);
3405 case E_PMINFO_APPINFO_PROP_APP_CATEGORY:
3406 val = (char *)calloc(1, PKG_STRING_LEN_MAX);
3408 _LOGE("Out of Memory\n");
3411 return PMINFO_R_ERROR;
3413 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
3415 ptr = (pkgmgrinfo_node_x *)link->data;
3416 strncpy(prev, ptr->value, PKG_STRING_LEN_MAX - 1);
3417 _LOGI("Previous value is %s\n", prev);
3418 filter->list = g_slist_delete_link(filter->list, link);
3419 snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s,%s", prev, value);
3420 strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
3421 _LOGI("New value is %s\n", val);
3423 filter->list = g_slist_append(filter->list, (gpointer)node);
3424 memset(temp, '\0', PKG_STRING_LEN_MAX);
3426 snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s", value);
3427 strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
3428 _LOGI("First value is %s\n", val);
3430 filter->list = g_slist_append(filter->list, (gpointer)node);
3431 memset(temp, '\0', PKG_STRING_LEN_MAX);
3435 node->value = strndup(value, PKG_STRING_LEN_MAX - 1);
3436 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
3438 filter->list = g_slist_delete_link(filter->list, link);
3439 filter->list = g_slist_append(filter->list, (gpointer)node);
3445 API int pkgmgrinfo_appinfo_usr_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count, uid_t uid)
3451 if (handle == NULL || count == NULL) {
3452 _LOGE("invalid parameter");
3453 return PMINFO_R_EINVAL;
3456 locale = _get_system_locale();
3458 return PMINFO_R_ERROR;
3460 list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
3461 __free_applications);
3464 return PMINFO_R_ERROR;
3467 if (__check_disable_filter_exist(
3468 handle, E_APPINFO_DISABLE_TYPE_APP) == false) {
3469 if (pkgmgrinfo_appinfo_filter_add_bool(handle,
3470 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
3471 g_hash_table_destroy(list);
3473 return PMINFO_R_ERROR;
3477 if (__check_disable_filter_exist(
3478 handle, E_APPINFO_DISABLE_TYPE_PKG) == false) {
3479 if (pkgmgrinfo_appinfo_filter_add_bool(handle,
3480 PMINFO_APPINFO_PROP_PKG_DISABLE, false)) {
3481 g_hash_table_destroy(list);
3483 return PMINFO_R_ERROR;
3487 ret = _appinfo_get_applications(uid, uid, locale, handle, 0, list);
3488 if (ret == PMINFO_R_OK && uid != GLOBAL_USER)
3489 ret = _appinfo_get_applications(GLOBAL_USER, uid, locale,
3492 if (ret != PMINFO_R_OK) {
3493 g_hash_table_destroy(list);
3495 return PMINFO_R_ERROR;
3498 *count = g_hash_table_size(list);
3499 g_hash_table_destroy(list);
3505 API int pkgmgrinfo_appinfo_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count)
3507 return pkgmgrinfo_appinfo_usr_filter_count(handle, count, _getuid());
3510 API int pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(
3511 pkgmgrinfo_appinfo_filter_h handle,
3512 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
3514 if (handle == NULL || app_cb == NULL) {
3515 LOGE("invalid parameter");
3516 return PMINFO_R_EINVAL;
3519 if (__check_disable_filter_exist(
3520 handle, E_APPINFO_DISABLE_TYPE_APP) == false) {
3521 if (pkgmgrinfo_appinfo_filter_add_bool(handle,
3522 PMINFO_APPINFO_PROP_APP_DISABLE, false))
3523 return PMINFO_R_ERROR;
3526 if (__check_disable_filter_exist(
3527 handle, E_APPINFO_DISABLE_TYPE_PKG) == false) {
3528 if (pkgmgrinfo_appinfo_filter_add_bool(handle,
3529 PMINFO_APPINFO_PROP_PKG_DISABLE, false))
3530 return PMINFO_R_ERROR;
3533 return _appinfo_get_filtered_foreach_appinfo(uid, handle, PMINFO_APPINFO_GET_ALL, app_cb,
3537 API int pkgmgrinfo_appinfo_filter_foreach_appinfo(pkgmgrinfo_appinfo_filter_h handle,
3538 pkgmgrinfo_app_list_cb app_cb, void *user_data)
3540 return pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(handle, app_cb, user_data, _getuid());
3543 API int pkgmgrinfo_appinfo_metadata_filter_create(pkgmgrinfo_appinfo_metadata_filter_h *handle)
3545 return (pkgmgrinfo_pkginfo_filter_create(handle));
3548 API int pkgmgrinfo_appinfo_metadata_filter_destroy(pkgmgrinfo_appinfo_metadata_filter_h handle)
3550 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
3553 API int pkgmgrinfo_appinfo_metadata_filter_add(
3554 pkgmgrinfo_appinfo_metadata_filter_h handle,
3555 const char *key, const char *value)
3557 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
3558 pkgmgrinfo_metadata_node_x *node;
3560 /* value can be NULL.
3561 * In that case all apps with specified key should be displayed
3564 LOGE("invalid parameter");
3565 return PMINFO_R_EINVAL;
3568 node = calloc(1, sizeof(pkgmgrinfo_metadata_node_x));
3570 LOGE("out of memory");
3571 return PMINFO_R_ERROR;
3574 node->key = strdup(key);
3575 if (value && strlen(value))
3576 node->value = strdup(value);
3578 filter->list_metadata = g_slist_append(filter->list_metadata,
3584 API int pkgmgrinfo_appinfo_usr_metadata_filter_foreach(
3585 pkgmgrinfo_appinfo_metadata_filter_h handle,
3586 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
3588 if (handle == NULL || app_cb == NULL) {
3589 LOGE("invalid parameter");
3590 return PMINFO_R_EINVAL;
3593 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
3594 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
3595 PMINFO_APPINFO_PROP_APP_DISABLE, false))
3596 return PMINFO_R_ERROR;
3598 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
3599 PMINFO_APPINFO_PROP_PKG_DISABLE, false))
3600 return PMINFO_R_ERROR;
3602 return _appinfo_get_filtered_foreach_appinfo(uid, handle, PMINFO_APPINFO_GET_ALL, app_cb,
3606 API int pkgmgrinfo_appinfo_metadata_filter_foreach(
3607 pkgmgrinfo_appinfo_metadata_filter_h handle,
3608 pkgmgrinfo_app_list_cb app_cb, void *user_data)
3610 return pkgmgrinfo_appinfo_usr_metadata_filter_foreach(handle, app_cb,
3611 user_data, _getuid());
3614 API int pkgmgrinfo_appinfo_is_guestmode_visibility(pkgmgrinfo_appinfo_h handle, bool *status)
3617 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3619 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
3620 retvm_if(status == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3622 val = info->app_info->guestmode_visibility;
3623 *status = _get_bool_value(val);