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,
158 char *visibility, char *id)
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);
191 *appcontrol = g_list_append(*appcontrol, ac);
192 } while ((token = strtok_r(NULL, ";", &ptr)));
197 static int _appinfo_get_app_control(sqlite3 *db, const char *appid,
200 static const char query_raw[] =
201 "SELECT app_control, visibility, app_control_id "
202 "FROM package_app_app_control WHERE app_id=%Q";
211 query = sqlite3_mprintf(query_raw, appid);
213 LOGE("out of memory");
214 return PMINFO_R_ERROR;
217 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
219 if (ret != SQLITE_OK) {
220 LOGE("prepare failed: %s", sqlite3_errmsg(db));
221 return PMINFO_R_ERROR;
224 while (sqlite3_step(stmt) == SQLITE_ROW) {
229 _save_column_str(stmt, idx++, &str);
230 _save_column_str(stmt, idx++, &visibility);
231 _save_column_str(stmt, idx++, &id);
233 __parse_appcontrol(appcontrol, str, visibility, id);
239 sqlite3_finalize(stmt);
244 static int _appinfo_get_metadata(sqlite3 *db, const char *appid,
247 static const char query_raw[] =
248 "SELECT md_key, md_value "
249 "FROM package_app_app_metadata WHERE app_id=%Q";
256 query = sqlite3_mprintf(query_raw, appid);
258 LOGE("out of memory");
259 return PMINFO_R_ERROR;
262 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
264 if (ret != SQLITE_OK) {
265 LOGE("prepare failed: %s", sqlite3_errmsg(db));
266 return PMINFO_R_ERROR;
269 while (sqlite3_step(stmt) == SQLITE_ROW) {
270 info = calloc(1, sizeof(metadata_x));
272 LOGE("out of memory");
273 sqlite3_finalize(stmt);
274 return PMINFO_R_ERROR;
277 _save_column_str(stmt, idx++, &info->key);
278 _save_column_str(stmt, idx++, &info->value);
279 *metadata = g_list_append(*metadata, info);
282 sqlite3_finalize(stmt);
288 static int _appinfo_get_splashscreens(sqlite3 *db, const char *appid,
289 GList **splashscreens)
291 static const char query_raw[] =
292 "SELECT src, type, orientation, indicatordisplay, operation, color_depth "
293 "FROM package_app_splash_screen WHERE app_id=%Q";
298 splashscreen_x *info;
300 query = sqlite3_mprintf(query_raw, appid);
302 LOGE("out of memory");
303 return PMINFO_R_ERROR;
306 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
308 if (ret != SQLITE_OK) {
309 LOGE("prepare failed: %s", sqlite3_errmsg(db));
310 return PMINFO_R_ERROR;
313 while (sqlite3_step(stmt) == SQLITE_ROW) {
314 info = calloc(1, sizeof(splashscreen_x));
316 LOGE("out of memory");
317 sqlite3_finalize(stmt);
318 return PMINFO_R_ERROR;
321 _save_column_str(stmt, idx++, &info->src);
322 _save_column_str(stmt, idx++, &info->type);
323 _save_column_str(stmt, idx++, &info->orientation);
324 _save_column_str(stmt, idx++, &info->indicatordisplay);
325 _save_column_str(stmt, idx++, &info->operation);
326 _save_column_str(stmt, idx++, &info->color_depth);
327 *splashscreens = g_list_append(*splashscreens, info);
330 sqlite3_finalize(stmt);
335 static GList *__get_background_category(const char *value)
337 GList *category_list = NULL;
338 int convert_value = 0;
339 if (!value || strlen(value) == 0)
342 convert_value = atoi(value);
343 if (convert_value < 0)
346 if (convert_value & APP_BG_CATEGORY_USER_DISABLE_TRUE_VAL)
347 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_USER_DISABLE_TRUE_STR));
349 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_USER_DISABLE_FALSE_STR));
351 if (convert_value & APP_BG_CATEGORY_MEDIA_VAL)
352 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_MEDIA_STR));
354 if (convert_value & APP_BG_CATEGORY_DOWNLOAD_VAL)
355 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_DOWNLOAD_STR));
357 if (convert_value & APP_BG_CATEGORY_BGNETWORK_VAL)
358 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_BGNETWORK_STR));
360 if (convert_value & APP_BG_CATEGORY_LOCATION_VAL)
361 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_LOCATION_STR));
363 if (convert_value & APP_BG_CATEGORY_SENSOR_VAL)
364 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_SENSOR_STR));
366 if (convert_value & APP_BG_CATEGORY_IOTCOMM_VAL)
367 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_IOTCOMM_STR));
369 if (convert_value & APP_BG_CATEGORY_SYSTEM_VAL)
370 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_SYSTEM));
372 return category_list;
376 static void __free_applications(gpointer data)
378 pkgmgrinfo_basic_free_application((application_x *)data);
381 static gint __disable_chk_func(gconstpointer data1, gconstpointer data2)
383 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)data1;
384 pkgmgrinfo_appinfo_disable_type value = GPOINTER_TO_INT(data2);
386 if (value == E_APPINFO_DISABLE_TYPE_PKG)
387 return (node->prop == E_PMINFO_APPINFO_PROP_PKG_DISABLE)
390 return (node->prop == E_PMINFO_APPINFO_PROP_APP_DISABLE)
394 static bool __check_disable_filter_exist(pkgmgrinfo_filter_x *filter,
395 pkgmgrinfo_appinfo_disable_type type)
402 link = g_slist_find_custom(filter->list, GINT_TO_POINTER(type), __disable_chk_func);
409 static int __bind_params(sqlite3_stmt *stmt, GList *params)
411 GList *tmp_list = NULL;
415 if (stmt == NULL || params == NULL)
416 return PMINFO_R_EINVAL;
420 ret = sqlite3_bind_text(stmt, ++idx, (char *)tmp_list->data, -1, SQLITE_STATIC);
421 if (ret != SQLITE_OK)
422 return PMINFO_R_ERROR;
423 tmp_list = tmp_list->next;
429 static bool __check_app_storage_status(pkgmgrinfo_filter_x *tmp_filter)
431 GSList *tmp_list = NULL;
432 pkgmgrinfo_node_x *tmp_node = NULL;
435 if (tmp_filter == NULL)
438 property = _pminfo_appinfo_convert_to_prop_bool(PMINFO_APPINFO_PROP_APP_CHECK_STORAGE);
439 for (tmp_list = tmp_filter->list; tmp_list != NULL;
440 tmp_list = g_slist_next(tmp_list)) {
441 tmp_node = (pkgmgrinfo_node_x *)tmp_list->data;
442 if (property == tmp_node->prop) {
443 if (strcmp(tmp_node->value, "true") == 0)
453 static int _appinfo_get_applications(uid_t db_uid, uid_t uid,
454 const char *locale, pkgmgrinfo_filter_x *filter, int flag,
455 GHashTable *applications)
457 static const char query_raw[] =
458 "SELECT DISTINCT ai.app_id, ai.app_installed_storage, "
459 "ai.app_external_path";
460 static const char query_basic[] =
461 ", ai.app_component, ai.app_exec, "
462 "ai.app_nodisplay, ai.app_type, ai.app_onboot, "
463 "ai.app_multiple, ai.app_autorestart, ai.app_taskmanage, "
464 "ai.app_hwacceleration, ai.app_screenreader, "
465 "ai.app_mainapp, ai.app_recentimage, ai.app_launchcondition, "
466 "ai.app_indicatordisplay, ai.app_portraitimg, "
467 "ai.app_landscapeimg, ai.app_guestmodevisibility, "
468 "ai.app_permissiontype, ai.app_preload, ai.app_submode, "
469 "ai.app_submode_mainid, ai.app_launch_mode, ai.app_ui_gadget, "
470 "ai.app_support_disable, ai.app_process_pool, "
471 "ai.app_background_category, ai.app_package_type, "
472 "ai.app_root_path, ai.app_api_version, ai.app_effective_appid, "
473 "ai.app_disable, ai.app_splash_screen_display, ai.app_tep_name, "
474 "ai.app_zip_mount_file, ai.component_type, ai.package, "
475 "ai.app_package_system, ai.app_removable, "
476 "ai.app_package_installed_time, ai.app_support_mode, "
477 "ai.app_support_ambient, ai.app_setup_appid";
478 static const char query_uid_info[] =
479 ", ui.is_disabled, ui.is_splash_screen_enabled";
480 static const char query_label[] =
482 "(SELECT app_label FROM package_app_localized_info WHERE ai.app_id=app_id AND app_locale=?), "
483 "(SELECT app_label FROM package_app_localized_info WHERE ai.app_id=app_id AND app_locale='No Locale'))";
484 static const char query_icon[] =
486 "(SELECT app_icon FROM package_app_localized_info WHERE ai.app_id=app_id AND app_locale=?), "
487 "(SELECT app_icon FROM package_app_localized_info WHERE ai.app_id=app_id AND app_locale='No Locale'))";
488 static const char query_from_clause[] = " FROM package_app_info as ai";
489 static const char query_uid_info_clause[] =
490 " LEFT OUTER JOIN package_app_info_for_uid AS ui "
491 "ON (ai.app_id=ui.app_id AND ui.uid=?)";
492 int ret = PMINFO_R_ERROR;
495 char *bg_category_str = NULL;
496 char *constraint = NULL;
497 char *tmp_record = NULL;
498 char query[MAX_QUERY_LEN] = { '\0' };
499 char buf[BUFSIZE] = { '\0' };
500 application_x *info = NULL;
501 GList *bind_params = NULL;
503 sqlite3_stmt *stmt = NULL;
504 bool is_check_storage = true;
505 const uid_t global_user_uid = GLOBAL_USER;
507 dbpath = getUserPkgParserDBPathUID(db_uid);
509 return PMINFO_R_ERROR;
511 ret = __open_db(dbpath, &db, SQLITE_OPEN_READONLY);
512 if (ret != SQLITE_OK) {
513 _LOGE("failed to open db(%s): %d", dbpath, ret);
515 return PMINFO_R_ERROR;
519 snprintf(query, MAX_QUERY_LEN - 1, "%s", query_raw);
521 if (flag & PMINFO_APPINFO_GET_BASICINFO) {
522 strncat(query, query_basic, sizeof(query) - strlen(query) - 1);
523 strncat(query, query_uid_info, sizeof(query) - strlen(query) - 1);
525 if (flag & PMINFO_APPINFO_GET_LABEL) {
526 strncat(query, query_label, sizeof(query) - strlen(query) - 1);
527 bind_params = g_list_append(bind_params, strdup(locale));
529 if (flag & PMINFO_APPINFO_GET_ICON) {
530 strncat(query, query_icon, sizeof(query) - strlen(query) - 1);
531 bind_params = g_list_append(bind_params, strdup(locale));
534 snprintf(buf, MAX_QUERY_LEN - 1, "%d", uid);
535 bind_params = g_list_append(bind_params, strdup(buf));
537 is_check_storage = __check_app_storage_status(filter);
539 ret = _get_filtered_query(filter, locale, uid, &constraint, &bind_params);
540 if (ret != PMINFO_R_OK) {
541 LOGE("Failed to get WHERE clause");
544 strncat(query, query_from_clause, sizeof(query) - strlen(query) - 1);
546 strncat(query, query_uid_info_clause, sizeof(query) - strlen(query) - 1);
549 strncat(query, constraint, sizeof(query) - strlen(query) - 1);
551 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
552 if (ret != SQLITE_OK) {
553 LOGE("prepare failed: %s", sqlite3_errmsg(db));
554 ret = PMINFO_R_ERROR;
558 if (g_list_length(bind_params) != 0) {
559 ret = __bind_params(stmt, bind_params);
560 if (ret != SQLITE_OK) {
561 LOGE("Failed to bind parameters");
566 while (sqlite3_step(stmt) == SQLITE_ROW) {
567 info = calloc(1, sizeof(application_x));
569 LOGE("out of memory");
570 ret = PMINFO_R_ERROR;
574 _save_column_str(stmt, idx++, &info->appid);
575 _save_column_str(stmt, idx++, &info->installed_storage);
576 _save_column_str(stmt, idx++ , &info->external_path);
578 if (flag & PMINFO_APPINFO_GET_BASICINFO) {
579 _save_column_str(stmt, idx++, &info->component);
580 _save_column_str(stmt, idx++, &info->exec);
581 _save_column_str(stmt, idx++, &info->nodisplay);
582 _save_column_str(stmt, idx++, &info->type);
583 _save_column_str(stmt, idx++, &info->onboot);
584 _save_column_str(stmt, idx++, &info->multiple);
585 _save_column_str(stmt, idx++, &info->autorestart);
586 _save_column_str(stmt, idx++, &info->taskmanage);
587 _save_column_str(stmt, idx++, &info->hwacceleration);
588 _save_column_str(stmt, idx++, &info->screenreader);
589 _save_column_str(stmt, idx++, &info->mainapp);
590 _save_column_str(stmt, idx++, &info->recentimage);
591 _save_column_str(stmt, idx++, &info->launchcondition);
592 _save_column_str(stmt, idx++, &info->indicatordisplay);
593 _save_column_str(stmt, idx++, &info->portraitimg);
594 _save_column_str(stmt, idx++, &info->landscapeimg);
595 _save_column_str(stmt, idx++, &info->guestmode_visibility);
596 _save_column_str(stmt, idx++, &info->permission_type);
597 _save_column_str(stmt, idx++, &info->preload);
598 _save_column_str(stmt, idx++, &info->submode);
599 _save_column_str(stmt, idx++, &info->submode_mainid);
600 _save_column_str(stmt, idx++, &info->launch_mode);
601 _save_column_str(stmt, idx++, &info->ui_gadget);
602 _save_column_str(stmt, idx++, &info->support_disable);
603 _save_column_str(stmt, idx++, &info->process_pool);
604 _save_column_str(stmt, idx++, &bg_category_str);
605 _save_column_str(stmt, idx++, &info->package_type);
606 _save_column_str(stmt, idx++, &info->root_path);
607 _save_column_str(stmt, idx++, &info->api_version);
608 _save_column_str(stmt, idx++, &info->effective_appid);
609 _save_column_str(stmt, idx++, &info->is_disabled);
610 _save_column_str(stmt, idx++, &info->splash_screen_display);
611 _save_column_str(stmt, idx++, &info->tep_name);
612 _save_column_str(stmt, idx++, &info->zip_mount_file);
613 _save_column_str(stmt, idx++, &info->component_type);
614 _save_column_str(stmt, idx++, &info->package);
615 _save_column_str(stmt, idx++, &info->package_system);
616 _save_column_str(stmt, idx++, &info->removable);
617 _save_column_str(stmt, idx++, &info->package_installed_time);
618 _save_column_str(stmt, idx++, &info->support_mode);
619 _save_column_str(stmt, idx++, &info->support_ambient);
620 _save_column_str(stmt, idx++, &info->setup_appid);
621 info->background_category = __get_background_category(
623 free(bg_category_str);
626 info->for_all_users =
627 strdup((db_uid != global_user_uid) ? "false" : "true");
629 if (db_uid != global_user_uid) {
633 _save_column_str(stmt, idx++, &tmp_record);
634 if (tmp_record != NULL) {
635 if (strcasecmp(info->is_disabled, "false") == 0 &&
636 strcasecmp(tmp_record, "false") == 0) {
637 free(info->is_disabled);
638 info->is_disabled = tmp_record;
644 _save_column_str(stmt, idx++, &tmp_record);
645 if (tmp_record != NULL) {
646 if (strcasecmp(info->splash_screen_display, "false") == 0 &&
647 strcasecmp(tmp_record, "false") == 0) {
648 free(info->splash_screen_display);
649 info->splash_screen_display = tmp_record;
656 if (flag & PMINFO_APPINFO_GET_LABEL) {
658 _save_column_str(stmt, idx++, &tmp_record);
659 if (_add_label_info_into_list(locale, tmp_record, &info->label)) {
660 ret = PMINFO_R_ERROR;
665 if (flag & PMINFO_APPINFO_GET_ICON) {
667 _save_column_str(stmt, idx++, &tmp_record);
668 if (_add_icon_info_into_list(locale, tmp_record, &info->icon)) {
669 ret = PMINFO_R_ERROR;
674 if (flag & PMINFO_APPINFO_GET_CATEGORY) {
675 if (_appinfo_get_category(db, info->appid,
677 ret = PMINFO_R_ERROR;
682 if (flag & PMINFO_APPINFO_GET_APP_CONTROL) {
683 if (_appinfo_get_app_control(db, info->appid,
684 &info->appcontrol)) {
685 ret = PMINFO_R_ERROR;
690 if (flag & PMINFO_APPINFO_GET_METADATA) {
691 if (_appinfo_get_metadata(db, info->appid,
693 ret = PMINFO_R_ERROR;
698 if (flag & PMINFO_APPINFO_GET_SPLASH_SCREEN) {
699 if (_appinfo_get_splashscreens(db, info->appid,
700 &info->splashscreens)) {
701 ret = PMINFO_R_ERROR;
706 if (is_check_storage &&
707 __appinfo_check_installed_storage(info) != PMINFO_R_OK) {
708 ret = PMINFO_R_ERROR;
709 pkgmgrinfo_basic_free_application(info);
714 g_hash_table_insert(applications, (gpointer)info->appid,
721 sqlite3_finalize(stmt);
722 sqlite3_close_v2(db);
727 if (ret != PMINFO_R_OK && info != NULL)
728 pkgmgrinfo_basic_free_application(info);
730 g_list_free_full(bind_params, free);
735 static int _pkgmgrinfo_get_appinfo(const char *appid, uid_t uid,
736 pkgmgrinfo_appinfo_filter_h filter, pkgmgrinfo_appinfo_h *handle)
741 pkgmgr_appinfo_x *info;
743 if (appid == NULL || filter == NULL || handle == NULL) {
744 LOGE("invalid parameter");
745 return PMINFO_R_EINVAL;
748 locale = _get_system_locale();
750 return PMINFO_R_ERROR;
752 list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
753 __free_applications);
756 return PMINFO_R_ERROR;
759 ret = _appinfo_get_applications(uid, uid, locale, filter,
760 PMINFO_APPINFO_GET_ALL, list);
761 if (!g_hash_table_size(list) && uid != GLOBAL_USER)
762 ret = _appinfo_get_applications(GLOBAL_USER, uid, locale, filter,
763 PMINFO_APPINFO_GET_ALL, list);
765 if (ret != PMINFO_R_OK) {
766 g_hash_table_destroy(list);
771 if (!g_hash_table_size(list)) {
772 _LOGD("appinfo for [%s] is not existed for user [%d]",
774 g_hash_table_destroy(list);
776 return PMINFO_R_ENOENT;
779 info = calloc(1, sizeof(pkgmgr_appinfo_x));
781 _LOGE("out of memory");
782 g_hash_table_destroy(list);
784 return PMINFO_R_ERROR;
787 info->app_info = (application_x *)g_hash_table_lookup(list, appid);
788 info->locale = locale;
789 info->package = strdup(info->app_info->package);
791 /* just free list only */
792 g_hash_table_steal(list, (gconstpointer)appid);
793 g_hash_table_destroy(list);
800 API int pkgmgrinfo_appinfo_get_usr_disabled_appinfo(const char *appid, uid_t uid,
801 pkgmgrinfo_appinfo_h *handle)
804 pkgmgrinfo_appinfo_filter_h filter;
806 if (appid == NULL || handle == NULL) {
807 LOGE("invalid parameter");
808 return PMINFO_R_EINVAL;
811 ret = pkgmgrinfo_appinfo_filter_create(&filter);
812 if (ret != PMINFO_R_OK)
815 ret = pkgmgrinfo_appinfo_filter_add_string(filter,
816 PMINFO_APPINFO_PROP_APP_ID, appid);
817 if (ret != PMINFO_R_OK) {
818 pkgmgrinfo_appinfo_filter_destroy(filter);
819 return PMINFO_R_ERROR;
822 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
823 PMINFO_APPINFO_PROP_APP_DISABLE, true);
824 if (ret != PMINFO_R_OK) {
825 pkgmgrinfo_appinfo_filter_destroy(filter);
826 return PMINFO_R_ERROR;
829 ret = _pkgmgrinfo_get_appinfo(appid, uid, filter, handle);
830 pkgmgrinfo_appinfo_filter_destroy(filter);
835 API int pkgmgrinfo_appinfo_get_disabled_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
837 return pkgmgrinfo_appinfo_get_usr_disabled_appinfo(appid, _getuid(), handle);
840 API int pkgmgrinfo_appinfo_get_usr_appinfo(const char *appid, uid_t uid,
841 pkgmgrinfo_appinfo_h *handle)
844 pkgmgrinfo_appinfo_filter_h filter;
846 if (appid == NULL || handle == NULL) {
847 LOGE("invalid parameter");
848 return PMINFO_R_EINVAL;
851 ret = pkgmgrinfo_appinfo_filter_create(&filter);
852 if (ret != PMINFO_R_OK)
855 ret = pkgmgrinfo_appinfo_filter_add_string(filter,
856 PMINFO_APPINFO_PROP_APP_ID, appid);
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_APP_DISABLE, false);
864 if (ret != PMINFO_R_OK) {
865 pkgmgrinfo_appinfo_filter_destroy(filter);
866 return PMINFO_R_ERROR;
869 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
870 PMINFO_APPINFO_PROP_PKG_DISABLE, false);
871 if (ret != PMINFO_R_OK) {
872 pkgmgrinfo_appinfo_filter_destroy(filter);
873 return PMINFO_R_ERROR;
876 ret = _pkgmgrinfo_get_appinfo(appid, uid, filter, handle);
877 pkgmgrinfo_appinfo_filter_destroy(filter);
881 API int pkgmgrinfo_appinfo_get_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
883 return pkgmgrinfo_appinfo_get_usr_appinfo(appid, _getuid(), handle);
886 API int pkgmgrinfo_appinfo_get_usr_all_appinfo(const char *appid, uid_t uid,
887 pkgmgrinfo_appinfo_h *handle)
890 pkgmgrinfo_appinfo_filter_h filter;
892 if (appid == NULL || handle == NULL) {
893 LOGE("invalid parameter");
894 return PMINFO_R_EINVAL;
897 ret = pkgmgrinfo_appinfo_filter_create(&filter);
898 if (ret != PMINFO_R_OK)
901 ret = pkgmgrinfo_appinfo_filter_add_string(filter,
902 PMINFO_APPINFO_PROP_APP_ID, appid);
903 if (ret != PMINFO_R_OK) {
904 pkgmgrinfo_appinfo_filter_destroy(filter);
905 return PMINFO_R_ERROR;
908 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
909 PMINFO_APPINFO_PROP_APP_CHECK_STORAGE, false);
910 if (ret != PMINFO_R_OK) {
911 pkgmgrinfo_appinfo_filter_destroy(filter);
912 return PMINFO_R_ERROR;
915 ret = _pkgmgrinfo_get_appinfo(appid, uid, filter, handle);
916 pkgmgrinfo_appinfo_filter_destroy(filter);
921 API int pkgmgrinfo_appinfo_get_all_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
923 return pkgmgrinfo_appinfo_get_usr_all_appinfo(appid, _getuid(), handle);
926 static gpointer __copy_str(gconstpointer src, gpointer data)
928 const char *tmp = (const char *)src;
931 buffer = strdup(tmp);
932 if (buffer == NULL) {
933 LOGE("memory alloc failed");
941 static gpointer __copy_label(gconstpointer src, gpointer data)
943 label_x *tmp = (label_x *)src;
946 label = calloc(1, sizeof(label_x));
948 LOGE("memory alloc failed");
954 label->name = strdup(tmp->name);
956 label->text = strdup(tmp->text);
958 label->lang = strdup(tmp->lang);
963 static gpointer __copy_icon(gconstpointer src, gpointer data)
965 icon_x *tmp = (icon_x *)src;
968 icon = calloc(1, sizeof(icon_x));
970 LOGE("memory alloc failed");
976 icon->text = strdup(tmp->text);
978 icon->lang = strdup(tmp->lang);
980 icon->section = strdup(tmp->section);
982 icon->size = strdup(tmp->size);
984 icon->resolution = strdup(tmp->resolution);
989 static gpointer __copy_metadata(gconstpointer src, gpointer data)
991 metadata_x *tmp = (metadata_x *)src;
992 metadata_x *metadata;
994 metadata = calloc(1, sizeof(metadata_x));
995 if (metadata == NULL) {
996 LOGE("memory alloc failed");
1002 metadata->key = strdup(tmp->key);
1004 metadata->value = strdup(tmp->value);
1009 static gpointer __copy_datacontrol(gconstpointer src, gpointer data)
1011 datacontrol_x *tmp = (datacontrol_x *)src;
1012 datacontrol_x *datacontrol;
1014 datacontrol = calloc(1, sizeof(datacontrol_x));
1015 if (datacontrol == NULL) {
1016 LOGE("memory alloc failed");
1021 if (tmp->providerid)
1022 datacontrol->providerid = strdup(tmp->providerid);
1024 datacontrol->access = strdup(tmp->access);
1026 datacontrol->type = strdup(tmp->type);
1028 datacontrol->trusted = strdup(tmp->trusted);
1033 static gpointer __copy_appcontrol(gconstpointer src, gpointer data)
1035 appcontrol_x *tmp = (appcontrol_x *)src;
1036 appcontrol_x *appcontrol;
1038 appcontrol = calloc(1, sizeof(appcontrol_x));
1039 if (appcontrol == NULL) {
1040 LOGE("memory alloc failed");
1046 appcontrol->operation = strdup(tmp->operation);
1048 appcontrol->uri = strdup(tmp->uri);
1050 appcontrol->mime = strdup(tmp->mime);
1055 static gpointer __copy_splashscreens(gconstpointer src, gpointer data)
1057 splashscreen_x *tmp = (splashscreen_x *)src;
1058 splashscreen_x *splashscreen;
1060 splashscreen = (splashscreen_x *)calloc(1, sizeof(splashscreen_x));
1061 if (splashscreen == NULL) {
1062 LOGE("memory alloc failed");
1068 splashscreen->src = strdup(tmp->src);
1070 splashscreen->type = strdup(tmp->type);
1071 if (tmp->orientation)
1072 splashscreen->orientation = strdup(tmp->orientation);
1073 if (tmp->indicatordisplay)
1074 splashscreen->indicatordisplay = strdup(tmp->indicatordisplay);
1076 splashscreen->operation = strdup(tmp->operation);
1077 if (tmp->color_depth)
1078 splashscreen->color_depth = strdup(tmp->color_depth);
1080 return splashscreen;
1083 static int _appinfo_copy_appinfo(application_x **application, application_x *data)
1085 application_x *app_info;
1088 app_info = calloc(1, sizeof(application_x));
1089 if (app_info == NULL) {
1090 LOGE("memory alloc failed");
1091 return PMINFO_R_ERROR;
1094 if (data->appid != NULL)
1095 app_info->appid = strdup(data->appid);
1096 if (data->exec != NULL)
1097 app_info->exec = strdup(data->exec);
1098 if (data->nodisplay != NULL)
1099 app_info->nodisplay = strdup(data->nodisplay);
1100 if (data->multiple != NULL)
1101 app_info->multiple = strdup(data->multiple);
1102 if (data->taskmanage != NULL)
1103 app_info->taskmanage = strdup(data->taskmanage);
1104 if (data->type != NULL)
1105 app_info->type = strdup(data->type);
1106 if (data->categories != NULL)
1107 app_info->categories = strdup(data->categories);
1108 if (data->hwacceleration != NULL)
1109 app_info->hwacceleration = strdup(data->hwacceleration);
1110 if (data->screenreader != NULL)
1111 app_info->screenreader = strdup(data->screenreader);
1112 if (data->mainapp != NULL)
1113 app_info->mainapp = strdup(data->mainapp);
1114 if (data->package != NULL)
1115 app_info->package = strdup(data->package);
1116 if (data->recentimage != NULL)
1117 app_info->recentimage = strdup(data->recentimage);
1118 if (data->launchcondition != NULL)
1119 app_info->launchcondition = strdup(data->launchcondition);
1120 if (data->indicatordisplay != NULL)
1121 app_info->indicatordisplay = strdup(data->indicatordisplay);
1122 if (data->portraitimg != NULL)
1123 app_info->portraitimg = strdup(data->portraitimg);
1124 if (data->landscapeimg != NULL)
1125 app_info->landscapeimg = strdup(data->landscapeimg);
1126 if (data->guestmode_visibility != NULL)
1127 app_info->guestmode_visibility = strdup(data->guestmode_visibility);
1128 if (data->component != NULL)
1129 app_info->component = strdup(data->component);
1130 if (data->permission_type != NULL)
1131 app_info->permission_type = strdup(data->permission_type);
1132 if (data->component_type != NULL)
1133 app_info->component_type = strdup(data->component_type);
1134 if (data->preload != NULL)
1135 app_info->preload = strdup(data->preload);
1136 if (data->submode != NULL)
1137 app_info->submode = strdup(data->submode);
1138 if (data->submode_mainid != NULL)
1139 app_info->submode_mainid = strdup(data->submode_mainid);
1140 if (data->process_pool != NULL)
1141 app_info->process_pool = strdup(data->process_pool);
1142 if (data->installed_storage != NULL)
1143 app_info->installed_storage = strdup(data->installed_storage);
1144 if (data->autorestart != NULL)
1145 app_info->autorestart = strdup(data->autorestart);
1146 if (data->onboot != NULL)
1147 app_info->onboot = strdup(data->onboot);
1148 if (data->support_disable != NULL)
1149 app_info->support_disable = strdup(data->support_disable);
1150 if (data->ui_gadget != NULL)
1151 app_info->ui_gadget = strdup(data->ui_gadget);
1152 if (data->launch_mode != NULL)
1153 app_info->launch_mode = strdup(data->launch_mode);
1154 if (data->package_type != NULL)
1155 app_info->package_type = strdup(data->package_type);
1156 if (data->effective_appid != NULL)
1157 app_info->effective_appid = strdup(data->effective_appid);
1158 if (data->splash_screen_display != NULL)
1159 app_info->splash_screen_display = strdup(data->splash_screen_display);
1163 app_info->label = g_list_copy_deep(data->label, __copy_label, &ret);
1165 LOGE("memory alloc failed");
1166 pkgmgrinfo_basic_free_application(app_info);
1167 return PMINFO_R_ERROR;
1171 app_info->icon = g_list_copy_deep(data->icon, __copy_icon, &ret);
1173 LOGE("memory alloc failed");
1174 pkgmgrinfo_basic_free_application(app_info);
1175 return PMINFO_R_ERROR;
1179 app_info->category = g_list_copy_deep(data->category, __copy_str, &ret);
1181 LOGE("memory alloc failed");
1182 pkgmgrinfo_basic_free_application(app_info);
1183 return PMINFO_R_ERROR;
1187 app_info->metadata = g_list_copy_deep(data->metadata, __copy_metadata, &ret);
1189 LOGE("memory alloc failed");
1190 pkgmgrinfo_basic_free_application(app_info);
1191 return PMINFO_R_ERROR;
1195 app_info->datacontrol = g_list_copy_deep(data->datacontrol, __copy_datacontrol, &ret);
1197 LOGE("memory alloc failed");
1198 pkgmgrinfo_basic_free_application(app_info);
1199 return PMINFO_R_ERROR;
1203 app_info->appcontrol = g_list_copy_deep(data->appcontrol, __copy_appcontrol, &ret);
1205 LOGE("memory alloc failed");
1206 pkgmgrinfo_basic_free_application(app_info);
1207 return PMINFO_R_ERROR;
1211 app_info->background_category = g_list_copy_deep(data->background_category, __copy_str, &ret);
1213 LOGE("memory alloc failed");
1214 pkgmgrinfo_basic_free_application(app_info);
1215 return PMINFO_R_ERROR;
1219 app_info->splashscreens = g_list_copy_deep(data->splashscreens, __copy_splashscreens, &ret);
1221 LOGE("memory alloc failed");
1222 pkgmgrinfo_basic_free_application(app_info);
1223 return PMINFO_R_ERROR;
1226 *application = app_info;
1231 API int pkgmgrinfo_appinfo_clone_appinfo(pkgmgrinfo_appinfo_h handle,
1232 pkgmgrinfo_appinfo_h *clone)
1234 pkgmgr_appinfo_x *info;
1235 pkgmgr_appinfo_x *temp = (pkgmgr_appinfo_x *)handle;
1238 return PMINFO_R_EINVAL;
1240 info = calloc(1, sizeof(pkgmgr_appinfo_x));
1242 LOGE("memory alloc failed");
1243 return PMINFO_R_ERROR;
1246 if (temp->package != NULL)
1247 info->package = strdup(temp->package);
1248 if (temp->locale != NULL)
1249 info->locale = strdup(temp->locale);
1251 info->app_component = temp->app_component;
1253 if (_appinfo_copy_appinfo(&info->app_info, temp->app_info) < 0) {
1254 LOGE("appinfo copy failed");
1256 free((void *)info->package);
1260 return PMINFO_R_ERROR;
1268 static int _appinfo_get_filtered_foreach_appinfo(uid_t uid,
1269 pkgmgrinfo_filter_x *filter, int flag, pkgmgrinfo_app_list_cb app_list_cb,
1275 pkgmgr_appinfo_x info;
1277 GHashTableIter iter;
1280 locale = _get_system_locale();
1282 return PMINFO_R_ERROR;
1284 list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
1285 __free_applications);
1288 return PMINFO_R_ERROR;
1291 ret = _appinfo_get_applications(uid, uid, locale, filter,
1292 flag | PMINFO_APPINFO_GET_BASICINFO, list);
1293 if (ret == PMINFO_R_OK && uid != GLOBAL_USER)
1294 ret = _appinfo_get_applications(GLOBAL_USER, uid, locale,
1295 filter, flag | PMINFO_APPINFO_GET_BASICINFO, list);
1297 if (ret != PMINFO_R_OK) {
1298 g_hash_table_destroy(list);
1303 g_hash_table_iter_init(&iter, list);
1304 while (g_hash_table_iter_next(&iter, NULL, &value)) {
1305 app = (application_x *)value;
1306 info.app_info = app;
1307 info.locale = locale;
1308 info.package = app->package;
1309 if (app_list_cb(&info, user_data) < 0)
1312 g_hash_table_destroy(list);
1318 static const char *__appcomponent_str(pkgmgrinfo_app_component comp);
1320 API int pkgmgrinfo_appinfo_get_usr_list(pkgmgrinfo_pkginfo_h handle,
1321 pkgmgrinfo_app_component component,
1322 pkgmgrinfo_app_list_cb app_func, void *user_data, uid_t uid)
1325 pkgmgrinfo_appinfo_filter_h filter;
1327 const char *comp_str = NULL;
1329 if (handle == NULL || app_func == NULL) {
1330 LOGE("invalid parameter");
1331 return PMINFO_R_EINVAL;
1334 if (pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid)) {
1335 LOGE("invalid parameter");
1336 return PMINFO_R_EINVAL;
1339 if (pkgmgrinfo_appinfo_filter_create(&filter))
1340 return PMINFO_R_ERROR;
1342 if (pkgmgrinfo_appinfo_filter_add_string(filter,
1343 PMINFO_APPINFO_PROP_APP_PACKAGE, pkgid)) {
1344 pkgmgrinfo_appinfo_filter_destroy(filter);
1345 return PMINFO_R_ERROR;
1348 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
1349 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
1350 pkgmgrinfo_appinfo_filter_destroy(filter);
1351 return PMINFO_R_ERROR;
1354 comp_str = __appcomponent_str(component);
1357 if (pkgmgrinfo_appinfo_filter_add_string(filter,
1358 PMINFO_APPINFO_PROP_APP_COMPONENT,
1360 pkgmgrinfo_appinfo_filter_destroy(filter);
1361 return PMINFO_R_ERROR;
1365 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter,
1366 PMINFO_APPINFO_GET_ALL, app_func, user_data);
1368 pkgmgrinfo_appinfo_filter_destroy(filter);
1373 API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle,
1374 pkgmgrinfo_app_component component,
1375 pkgmgrinfo_app_list_cb app_func, void *user_data)
1377 return pkgmgrinfo_appinfo_get_usr_list(handle, component, app_func, user_data, _getuid());
1380 API int pkgmgrinfo_appinfo_get_usr_installed_list_full(
1381 pkgmgrinfo_app_list_cb app_func, uid_t uid, int flag,
1385 pkgmgrinfo_appinfo_filter_h filter;
1387 if (app_func == NULL) {
1388 LOGE("invalid parameter");
1389 return PMINFO_R_EINVAL;
1392 if (pkgmgrinfo_appinfo_filter_create(&filter))
1393 return PMINFO_R_ERROR;
1395 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
1396 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
1397 pkgmgrinfo_appinfo_filter_destroy(filter);
1398 return PMINFO_R_ERROR;
1401 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
1402 PMINFO_APPINFO_PROP_PKG_DISABLE, false)) {
1403 pkgmgrinfo_appinfo_filter_destroy(filter);
1404 return PMINFO_R_ERROR;
1407 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
1408 PMINFO_APPINFO_PROP_APP_CHECK_STORAGE, false)) {
1409 pkgmgrinfo_appinfo_filter_destroy(filter);
1410 return PMINFO_R_ERROR;
1413 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter, flag, app_func,
1416 pkgmgrinfo_appinfo_filter_destroy(filter);
1421 API int pkgmgrinfo_appinfo_get_installed_list_full(
1422 pkgmgrinfo_app_list_cb app_func, int flag, void *user_data)
1424 return pkgmgrinfo_appinfo_get_usr_installed_list_full(app_func,
1425 _getuid(), flag, user_data);
1428 API int pkgmgrinfo_appinfo_get_usr_installed_list(
1429 pkgmgrinfo_app_list_cb app_func, uid_t uid, void *user_data)
1432 pkgmgrinfo_appinfo_filter_h filter;
1434 if (app_func == NULL) {
1435 LOGE("invalid parameter");
1436 return PMINFO_R_EINVAL;
1439 /* create an empty filter */
1440 ret = pkgmgrinfo_appinfo_filter_create(&filter);
1441 if (ret != PMINFO_R_OK)
1444 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
1445 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
1446 pkgmgrinfo_appinfo_filter_destroy(filter);
1447 return PMINFO_R_ERROR;
1450 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
1451 PMINFO_APPINFO_PROP_PKG_DISABLE, false)) {
1452 pkgmgrinfo_appinfo_filter_destroy(filter);
1453 return PMINFO_R_ERROR;
1456 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter,
1457 PMINFO_APPINFO_GET_ALL, app_func, user_data);
1459 pkgmgrinfo_appinfo_filter_destroy(filter);
1464 API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func,
1467 return pkgmgrinfo_appinfo_get_usr_installed_list(app_func, _getuid(),
1471 API int pkgmgrinfo_appinfo_get_appid(pkgmgrinfo_appinfo_h handle, char **appid)
1473 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1475 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1476 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1478 if (info->app_info == NULL || info->app_info->appid == NULL)
1479 return PMINFO_R_ERROR;
1480 *appid = (char *)info->app_info->appid;
1485 API int pkgmgrinfo_appinfo_get_pkgname(pkgmgrinfo_appinfo_h handle, char **pkg_name)
1487 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1489 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1490 retvm_if(pkg_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1492 if (info->package == NULL)
1493 return PMINFO_R_ERROR;
1495 *pkg_name = (char *)info->package;
1500 API int pkgmgrinfo_appinfo_get_pkgid(pkgmgrinfo_appinfo_h handle, char **pkgid)
1502 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1504 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1505 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1507 if (info->package == NULL)
1508 return PMINFO_R_ERROR;
1510 *pkgid = (char *)info->package;
1515 API int pkgmgrinfo_appinfo_get_pkgtype(pkgmgrinfo_appinfo_h handle, char **pkgtype)
1517 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1518 retvm_if(pkgtype == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1519 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1521 *pkgtype = (char *)info->app_info->package_type;
1526 API int pkgmgrinfo_appinfo_get_exec(pkgmgrinfo_appinfo_h handle, char **exec)
1528 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1530 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1531 retvm_if(exec == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1533 if (info->app_info == NULL || info->app_info->exec == NULL)
1534 return PMINFO_R_ERROR;
1535 *exec = (char *)info->app_info->exec;
1541 API int pkgmgrinfo_appinfo_get_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1544 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1546 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1547 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1549 if (info->app_info == NULL)
1550 return PMINFO_R_ERROR;
1552 if (info->app_info->icon == NULL) {
1557 ptr = (icon_x *)info->app_info->icon->data;
1559 return PMINFO_R_ERROR;
1561 if (ptr->text == NULL)
1562 return PMINFO_R_ERROR;
1570 API int pkgmgrinfo_appinfo_get_label(pkgmgrinfo_appinfo_h handle, char **label)
1573 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1578 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1579 retvm_if(label == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1581 if (info->app_info == NULL)
1582 return PMINFO_R_ERROR;
1584 locale = info->locale;
1586 locale = DEFAULT_LOCALE;
1588 for (tmp = info->app_info->label; tmp; tmp = tmp->next) {
1589 ptr = (label_x *)tmp->data;
1590 if (ptr == NULL || strcmp(locale, ptr->lang) != 0)
1601 for (tmp = info->app_info->label; tmp; tmp = tmp->next) {
1602 ptr = (label_x *)tmp->data;
1603 if (ptr == NULL || strcmp(DEFAULT_LOCALE, ptr->lang) != 0)
1609 *label = lbl ? lbl : "";
1614 static char *_get_localed_label(const char *appid, const char *locale, uid_t uid)
1616 char *result = NULL;
1618 sqlite3_stmt *stmt = NULL;
1623 parser_db = getUserPkgParserDBPathUID(uid);
1624 if (parser_db == NULL) {
1625 _LOGE("Failed to get parser db path");
1629 if (__open_db(parser_db, &db, SQLITE_OPEN_READONLY) != SQLITE_OK) {
1630 _LOGE("DB open fail\n");
1636 query = sqlite3_mprintf("select app_label from package_app_localized_info where app_id=%Q and app_locale=%Q", appid, locale);
1637 if (query == NULL) {
1638 _LOGE("Out of memory");
1642 if (sqlite3_prepare_v2(db, query, -1, &stmt, NULL) != SQLITE_OK) {
1643 _LOGE("prepare_v2 fail\n");
1647 if (sqlite3_step(stmt) == SQLITE_ROW) {
1648 val = (char *)sqlite3_column_text(stmt, 0);
1650 result = strdup(val);
1654 sqlite3_finalize(stmt);
1655 sqlite3_free(query);
1661 API int pkgmgrinfo_appinfo_usr_get_localed_label(const char *appid, const char *locale, uid_t uid, char **label)
1665 retvm_if(appid == NULL || locale == NULL || label == NULL, PMINFO_R_EINVAL, "Argument is NULL");
1667 val = _get_localed_label(appid, locale, uid);
1669 val = _get_localed_label(appid, DEFAULT_LOCALE, uid);
1672 val = _get_localed_label(appid, locale, GLOBAL_USER);
1674 val = _get_localed_label(appid, DEFAULT_LOCALE, GLOBAL_USER);
1678 return PMINFO_R_ERROR;
1685 API int pkgmgrinfo_appinfo_get_localed_label(const char *appid, const char *locale, char **label)
1687 return pkgmgrinfo_appinfo_usr_get_localed_label(appid, locale, _getuid(), label);
1690 API int pkgmgrinfo_appinfo_get_metadata_value(pkgmgrinfo_appinfo_h handle, const char *metadata_key, char **metadata_value)
1692 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1693 retvm_if(metadata_key == NULL, PMINFO_R_EINVAL, "metadata_key is NULL");
1694 retvm_if(metadata_value == NULL, PMINFO_R_EINVAL, "metadata_value is NULL");
1696 GList *list_md = NULL;
1697 metadata_x *metadata = NULL;
1698 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1700 list_md = info->app_info->metadata;
1702 for (; list_md; list_md = list_md->next) {
1703 metadata = (metadata_x *)list_md->data;
1704 if (metadata && metadata->key) {
1705 if (strcasecmp(metadata->key, metadata_key) == 0) {
1706 if (metadata->value == NULL)
1707 *metadata_value = "";
1709 *metadata_value = (char *)metadata->value;
1715 return PMINFO_R_EINVAL;
1718 static pkgmgrinfo_app_component __appcomponent_convert(const char *comp)
1720 if (strcasecmp(comp, "uiapp") == 0)
1721 return PMINFO_UI_APP;
1722 else if (strcasecmp(comp, "svcapp") == 0)
1723 return PMINFO_SVC_APP;
1724 else if (strcasecmp(comp, "widgetapp") == 0)
1725 return PMINFO_WIDGET_APP;
1726 else if (strcasecmp(comp, "watchapp") == 0)
1727 return PMINFO_WATCH_APP;
1732 static const char *__appcomponent_str(pkgmgrinfo_app_component comp)
1737 case PMINFO_SVC_APP:
1739 case PMINFO_WIDGET_APP:
1741 case PMINFO_WATCH_APP:
1748 API int pkgmgrinfo_appinfo_get_component(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_component *component)
1750 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1753 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1754 retvm_if(component == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1756 if (info->app_info == NULL)
1757 return PMINFO_R_ERROR;
1759 comp = __appcomponent_convert(info->app_info->component);
1761 return PMINFO_R_ERROR;
1768 API int pkgmgrinfo_appinfo_get_apptype(pkgmgrinfo_appinfo_h handle, char **app_type)
1770 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1772 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1773 retvm_if(app_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1775 if (info->app_info == NULL || info->app_info->type == NULL)
1776 return PMINFO_R_ERROR;
1777 *app_type = (char *)info->app_info->type;
1782 API int pkgmgrinfo_appinfo_get_operation(pkgmgrinfo_appcontrol_h handle,
1783 int *operation_count, char ***operation)
1785 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1786 retvm_if(operation == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1787 retvm_if(operation_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1788 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1789 *operation_count = data->operation_count;
1790 *operation = data->operation;
1794 API int pkgmgrinfo_appinfo_get_uri(pkgmgrinfo_appcontrol_h handle,
1795 int *uri_count, char ***uri)
1797 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1798 retvm_if(uri == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1799 retvm_if(uri_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1800 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1801 *uri_count = data->uri_count;
1806 API int pkgmgrinfo_appinfo_get_mime(pkgmgrinfo_appcontrol_h handle,
1807 int *mime_count, char ***mime)
1809 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1810 retvm_if(mime == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1811 retvm_if(mime_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1812 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1813 *mime_count = data->mime_count;
1818 API int pkgmgrinfo_appinfo_get_subapp(pkgmgrinfo_appcontrol_h handle,
1819 int *subapp_count, char ***subapp)
1821 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1822 retvm_if(subapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1823 retvm_if(subapp_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1824 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1825 *subapp_count = data->subapp_count;
1826 *subapp = data->subapp;
1830 API int pkgmgrinfo_appinfo_get_notification_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1835 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1837 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1838 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1840 if (info->app_info == NULL)
1841 return PMINFO_R_ERROR;
1843 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1844 ptr = (icon_x *)tmp->data;
1845 if (ptr == NULL || ptr->section == NULL)
1848 val = (char *)ptr->section;
1849 if (val && strcmp(val, "notification") == 0) {
1850 *icon = (char *)ptr->text;
1855 return PMINFO_R_ERROR;
1858 API int pkgmgrinfo_appinfo_get_recent_image_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_recentimage *type)
1861 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1863 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1864 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1866 if (info->app_info == NULL || info->app_info->recentimage == NULL)
1867 return PMINFO_R_ERROR;
1869 val = (char *)info->app_info->recentimage;
1870 if (strcasecmp(val, "capture") == 0)
1871 *type = PMINFO_RECENTIMAGE_USE_CAPTURE;
1872 else if (strcasecmp(val, "icon") == 0)
1873 *type = PMINFO_RECENTIMAGE_USE_ICON;
1875 *type = PMINFO_RECENTIMAGE_USE_NOTHING;
1880 API int pkgmgrinfo_appinfo_get_preview_image(pkgmgrinfo_appinfo_h handle, char **preview_img)
1885 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1887 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1888 retvm_if(preview_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1890 if (info->app_info == NULL)
1891 return PMINFO_R_ERROR;
1893 for (tmp = info->app_info->image; tmp; tmp = tmp->next) {
1894 ptr = (image_x *)tmp->data;
1895 if (ptr == NULL || ptr->section == NULL)
1898 val = (char *)ptr->section;
1899 if (val && strcmp(val, "preview") == 0) {
1900 *preview_img = (char *)ptr->text;
1905 return PMINFO_R_ERROR;
1908 API int pkgmgrinfo_appinfo_get_permission_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_permission_type *permission)
1911 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1913 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1914 retvm_if(permission == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1916 val = info->app_info->permission_type;
1918 return PMINFO_R_ERROR;
1920 if (strcmp(val, "signature") == 0)
1921 *permission = PMINFO_PERMISSION_SIGNATURE;
1922 else if (strcmp(val, "privilege") == 0)
1923 *permission = PMINFO_PERMISSION_PRIVILEGE;
1925 *permission = PMINFO_PERMISSION_NORMAL;
1930 API int pkgmgrinfo_appinfo_get_component_type(pkgmgrinfo_appinfo_h handle, char **component_type)
1932 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1934 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1935 retvm_if(component_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1937 if (info->app_info == NULL || info->app_info->component_type == NULL)
1938 return PMINFO_R_ERROR;
1940 *component_type = (char *)info->app_info->component_type;
1945 API int pkgmgrinfo_appinfo_get_hwacceleration(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_hwacceleration *hwacceleration)
1948 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1950 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1951 retvm_if(hwacceleration == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1953 if (info->app_info == NULL || info->app_info->hwacceleration == NULL)
1954 return PMINFO_R_ERROR;
1956 val = (char *)info->app_info->hwacceleration;
1957 if (strcasecmp(val, "off") == 0)
1958 *hwacceleration = PMINFO_HWACCELERATION_OFF;
1959 else if (strcasecmp(val, "on") == 0)
1960 *hwacceleration = PMINFO_HWACCELERATION_ON;
1962 *hwacceleration = PMINFO_HWACCELERATION_DEFAULT;
1967 API int pkgmgrinfo_appinfo_get_screenreader(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_screenreader *screenreader)
1970 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1972 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1973 retvm_if(screenreader == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1975 if (info->app_info == NULL || info->app_info->screenreader == NULL)
1976 return PMINFO_R_ERROR;
1978 val = (char *)info->app_info->screenreader;
1979 if (strcasecmp(val, "screenreader-off") == 0)
1980 *screenreader = PMINFO_SCREENREADER_OFF;
1981 else if (strcasecmp(val, "screenreader-on") == 0)
1982 *screenreader = PMINFO_SCREENREADER_ON;
1984 *screenreader = PMINFO_SCREENREADER_USE_SYSTEM_SETTING;
1989 API int pkgmgrinfo_appinfo_get_effectimage(pkgmgrinfo_appinfo_h handle, char **portrait_img, char **landscape_img)
1991 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1993 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1994 retvm_if(portrait_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1995 retvm_if(landscape_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1997 if (info->app_info == NULL)
1998 return PMINFO_R_ERROR;
2000 if (info->app_info->portraitimg == NULL)
2003 *portrait_img = (char *)info->app_info->portraitimg;
2005 if (info->app_info->landscapeimg == NULL)
2006 *landscape_img = "";
2008 *landscape_img = (char *)info->app_info->landscapeimg;
2013 API int pkgmgrinfo_appinfo_get_effectimage_type(pkgmgrinfo_appinfo_h handle, char **effectimage_type)
2015 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2017 if (handle == NULL || effectimage_type == NULL) {
2018 LOGE("invalid parameter");
2019 return PMINFO_R_EINVAL;
2022 if (info->app_info == NULL || info->app_info->effectimage_type == NULL)
2023 return PMINFO_R_ERROR;
2025 *effectimage_type = (char *)info->app_info->effectimage_type;
2030 API int pkgmgrinfo_appinfo_get_submode_mainid(pkgmgrinfo_appinfo_h handle, char **submode_mainid)
2032 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2034 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2035 retvm_if(submode_mainid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2037 if (info->app_info == NULL)
2038 return PMINFO_R_ERROR;
2040 if (info->app_info->submode_mainid == NULL)
2041 *submode_mainid = "";
2043 *submode_mainid = (char *)info->app_info->submode_mainid;
2048 API int pkgmgrinfo_appinfo_get_installed_storage_location(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_installed_storage *storage)
2050 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2051 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2053 if (info->app_info && info->app_info->installed_storage) {
2054 if (strcmp(info->app_info->installed_storage, "installed_internal") == 0)
2055 *storage = PMINFO_INTERNAL_STORAGE;
2056 else if (strcmp(info->app_info->installed_storage, "installed_external") == 0)
2057 *storage = PMINFO_EXTERNAL_STORAGE;
2059 return PMINFO_R_ERROR;
2061 return PMINFO_R_ERROR;
2067 API int pkgmgrinfo_appinfo_get_launch_mode(pkgmgrinfo_appinfo_h handle, char **mode)
2069 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2071 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2072 retvm_if(mode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2074 if (info->app_info->launch_mode == NULL)
2075 return PMINFO_R_ERROR;
2077 *mode = (char *)(info->app_info->launch_mode);
2082 API int pkgmgrinfo_appinfo_get_alias_appid(pkgmgrinfo_appinfo_h handle, char **alias_appid)
2084 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2086 if (handle == NULL || alias_appid == NULL) {
2087 LOGE("invalid parameter");
2088 return PMINFO_R_EINVAL;
2091 if (info->app_info == NULL || info->app_info->alias_appid == NULL)
2092 return PMINFO_R_ERROR;
2094 *alias_appid = (char *)info->app_info->alias_appid;
2099 API int pkgmgrinfo_appinfo_get_effective_appid(pkgmgrinfo_appinfo_h handle, char **effective_appid)
2101 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2103 if (handle == NULL || effective_appid == NULL) {
2104 LOGE("invalid parameter");
2105 return PMINFO_R_EINVAL;
2108 if (info->app_info == NULL)
2109 return PMINFO_R_ERROR;
2111 if (info->app_info->effective_appid == NULL)
2112 *effective_appid = "";
2114 *effective_appid = (char *)info->app_info->effective_appid;
2119 API int pkgmgrinfo_appinfo_get_tep_name(pkgmgrinfo_appinfo_h handle, char **tep_name)
2121 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2123 if (handle == NULL || tep_name == NULL) {
2124 LOGE("invalid parameter");
2125 return PMINFO_R_EINVAL;
2128 if (info->app_info == NULL)
2129 return PMINFO_R_ERROR;
2131 if (info->app_info->tep_name == NULL)
2134 *tep_name = (char *)info->app_info->tep_name;
2139 API int pkgmgrinfo_appinfo_get_zip_mount_file(pkgmgrinfo_appinfo_h handle, char **zip_mount_file)
2141 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2143 if (handle == NULL || zip_mount_file == NULL) {
2144 LOGE("invalid parameter");
2145 return PMINFO_R_EINVAL;
2148 if (info->app_info == NULL)
2149 return PMINFO_R_ERROR;
2151 if (info->app_info->zip_mount_file == NULL)
2152 *zip_mount_file = "";
2154 *zip_mount_file = (char *)info->app_info->zip_mount_file;
2159 API int pkgmgrinfo_appinfo_get_root_path(pkgmgrinfo_appinfo_h handle, char **root_path)
2161 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2163 if (handle == NULL || root_path == NULL) {
2164 LOGE("invalid parameter");
2165 return PMINFO_R_EINVAL;
2168 if (info->app_info == NULL || info->app_info->root_path == NULL)
2169 return PMINFO_R_ERROR;
2171 *root_path = (char *)info->app_info->root_path;
2176 API int pkgmgrinfo_appinfo_get_api_version(pkgmgrinfo_appinfo_h handle, char **api_version)
2178 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2180 if (handle == NULL || api_version == NULL) {
2181 LOGE("invalid parameter");
2182 return PMINFO_R_EINVAL;
2185 if (info->app_info == NULL || info->app_info->api_version == NULL)
2186 return PMINFO_R_ERROR;
2188 *api_version = (char *)info->app_info->api_version;
2193 API int pkgmgrinfo_appinfo_get_installed_time(pkgmgrinfo_appinfo_h handle, int *installed_time)
2195 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2197 if (handle == NULL || installed_time == NULL) {
2198 LOGE("invalid parameter");
2199 return PMINFO_R_EINVAL;
2202 if (info->app_info == NULL || info->app_info->package_installed_time == NULL)
2203 return PMINFO_R_ERROR;
2205 *installed_time = atoi(info->app_info->package_installed_time);
2210 static int _appinfo_get_datacontrol_info(sqlite3 *db, const char *providerid,
2211 const char *type, char **appid, char **access)
2213 static const char query[] =
2214 "SELECT app_id, access FROM package_app_data_control "
2215 "WHERE providerid=? AND type=?";
2219 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
2220 if (ret != SQLITE_OK) {
2221 LOGE("prepare failed: %s", sqlite3_errmsg(db));
2222 return PMINFO_R_ERROR;
2225 ret = sqlite3_bind_text(stmt, 1, providerid, -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_bind_text(stmt, 2, type, -1, SQLITE_STATIC);
2233 if (ret != SQLITE_OK) {
2234 LOGE("bind failed: %s", sqlite3_errmsg(db));
2235 sqlite3_finalize(stmt);
2236 return PMINFO_R_ERROR;
2239 ret = sqlite3_step(stmt);
2240 if (ret != SQLITE_ROW) {
2241 sqlite3_finalize(stmt);
2242 if (ret == SQLITE_DONE) {
2243 return PMINFO_R_ENOENT;
2245 LOGE("step error: %s", sqlite3_errmsg(db));
2246 return PMINFO_R_ERROR;
2250 *appid = strdup((char *)sqlite3_column_text(stmt, 0));
2251 if (*appid == NULL) {
2252 LOGE("out of memory");
2253 sqlite3_finalize(stmt);
2254 return PMINFO_R_ERROR;
2256 *access = strdup((char *)sqlite3_column_text(stmt, 1));
2257 if (*access == NULL) {
2258 LOGE("out of memory");
2260 sqlite3_finalize(stmt);
2261 return PMINFO_R_ERROR;
2264 sqlite3_finalize(stmt);
2269 static int _pkgmgrinfo_appinfo_get_datacontrol_info(uid_t uid,
2270 const char *providerid, const char *type,
2271 char **appid, char **access)
2277 dbpath = getUserPkgParserDBPathUID(GLOBAL_USER);
2279 return PMINFO_R_ERROR;
2281 ret = __open_db(dbpath, &db, SQLITE_OPEN_READONLY);
2283 if (ret != SQLITE_OK) {
2284 LOGE("open db failed: %s", sqlite3_errmsg(db));
2285 return PMINFO_R_ERROR;
2288 ret = _appinfo_get_datacontrol_info(db, providerid, type, appid,
2290 sqlite3_close_v2(db);
2295 API int pkgmgrinfo_appinfo_usr_get_datacontrol_info(const char *providerid,
2296 const char *type, uid_t uid, char **appid, char **access)
2300 if (providerid == NULL || type == NULL || appid == NULL ||
2302 LOGE("invalid parameter");
2303 return PMINFO_R_EINVAL;
2306 ret = _pkgmgrinfo_appinfo_get_datacontrol_info(GLOBAL_USER, providerid,
2307 type, appid, access);
2308 if (ret == PMINFO_R_ENOENT && uid != GLOBAL_USER)
2309 ret = _pkgmgrinfo_appinfo_get_datacontrol_info(uid, providerid,
2310 type, appid, access);
2312 /* FIXME: It should return PMINFO_R_ENOENT but to keep previous
2313 * implementation, return PMINFO_R_ERROR. This should be
2316 if (ret == PMINFO_R_ENOENT) {
2317 LOGE("no datacontrol info of %s", providerid);
2318 ret = PMINFO_R_ERROR;
2324 API int pkgmgrinfo_appinfo_get_datacontrol_info(const char *providerid,
2325 const char *type, char **appid, char **access)
2327 return pkgmgrinfo_appinfo_usr_get_datacontrol_info(providerid,
2328 type, _getuid(), appid, access);
2331 static int _appinfo_get_datacontrol_appid(sqlite3 *db, const char *providerid,
2334 static const char query[] =
2335 "SELECT app_id FROM package_app_data_control "
2336 "WHERE providerid=?";
2340 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
2341 if (ret != SQLITE_OK) {
2342 LOGE("prepare failed: %s", sqlite3_errmsg(db));
2343 return PMINFO_R_ERROR;
2346 ret = sqlite3_bind_text(stmt, 1, providerid, -1, SQLITE_STATIC);
2347 if (ret != SQLITE_OK) {
2348 LOGE("bind failed: %s", sqlite3_errmsg(db));
2349 sqlite3_finalize(stmt);
2350 return PMINFO_R_ERROR;
2353 ret = sqlite3_step(stmt);
2354 if (ret != SQLITE_ROW) {
2355 sqlite3_finalize(stmt);
2356 if (ret == SQLITE_DONE) {
2357 return PMINFO_R_ENOENT;
2359 LOGE("step error: %s", sqlite3_errmsg(db));
2360 return PMINFO_R_ERROR;
2364 *appid = strdup((char *)sqlite3_column_text(stmt, 0));
2366 sqlite3_finalize(stmt);
2368 if (*appid == NULL) {
2369 LOGE("out of memory");
2370 return PMINFO_R_ERROR;
2376 static int _pkgmgrinfo_appinfo_get_datacontrol_appid(uid_t uid,
2377 const char *providerid, char **appid)
2383 dbpath = getUserPkgParserDBPathUID(GLOBAL_USER);
2385 return PMINFO_R_ERROR;
2387 ret = __open_db(dbpath, &db, SQLITE_OPEN_READONLY);
2389 if (ret != SQLITE_OK) {
2390 LOGE("open db failed: %s", sqlite3_errmsg(db));
2391 return PMINFO_R_ERROR;
2394 ret = _appinfo_get_datacontrol_appid(db, providerid, appid);
2395 sqlite3_close_v2(db);
2400 API int pkgmgrinfo_appinfo_usr_get_datacontrol_appid(const char *providerid,
2401 uid_t uid, char **appid)
2405 if (providerid == NULL || appid == NULL) {
2406 LOGE("invalid parameter");
2407 return PMINFO_R_EINVAL;
2410 ret = _pkgmgrinfo_appinfo_get_datacontrol_appid(GLOBAL_USER, providerid,
2412 if (ret == PMINFO_R_ENOENT && uid != GLOBAL_USER)
2413 ret = _pkgmgrinfo_appinfo_get_datacontrol_appid(uid, providerid,
2416 /* FIXME: It should return PMINFO_R_ENOENT but to keep previous
2417 * implementation, return PMINFO_R_ERROR. This should be
2420 if (ret == PMINFO_R_ENOENT) {
2421 LOGE("no datacontrol appid of %s", providerid);
2422 ret = PMINFO_R_ERROR;
2428 API int pkgmgrinfo_appinfo_get_datacontrol_appid(const char *providerid, char **appid)
2430 return pkgmgrinfo_appinfo_usr_get_datacontrol_appid(providerid, _getuid(), appid);
2433 static int _appinfo_get_datacontrol_trusted_info(sqlite3 *db,
2434 const char *providerid, const char *type, char **appid,
2437 static const char query[] =
2438 "SELECT app_id, trusted FROM package_app_data_control "
2439 "WHERE providerid=? AND type=?";
2443 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
2444 if (ret != SQLITE_OK) {
2445 LOGE("prepare failed: %s", sqlite3_errmsg(db));
2446 return PMINFO_R_ERROR;
2449 ret = sqlite3_bind_text(stmt, 1, providerid, -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_bind_text(stmt, 2, type, -1, SQLITE_STATIC);
2457 if (ret != SQLITE_OK) {
2458 LOGE("bind failed: %s", sqlite3_errmsg(db));
2459 sqlite3_finalize(stmt);
2460 return PMINFO_R_ERROR;
2463 ret = sqlite3_step(stmt);
2464 if (ret != SQLITE_ROW) {
2465 sqlite3_finalize(stmt);
2466 if (ret == SQLITE_DONE) {
2467 return PMINFO_R_ENOENT;
2469 LOGE("step error: %s", sqlite3_errmsg(db));
2470 return PMINFO_R_ERROR;
2474 *appid = strdup((char *)sqlite3_column_text(stmt, 0));
2475 *is_trusted = _get_bool_value((char *)sqlite3_column_text(stmt, 1));
2477 sqlite3_finalize(stmt);
2479 if (*appid == NULL) {
2480 LOGE("out of memory");
2481 return PMINFO_R_ERROR;
2487 static int _pkgmgrinfo_appinfo_get_datacontrol_trusted_info(uid_t uid,
2488 const char *providerid, const char *type, char **appid,
2495 dbpath = getUserPkgParserDBPathUID(GLOBAL_USER);
2497 return PMINFO_R_ERROR;
2499 ret = __open_db(dbpath, &db, SQLITE_OPEN_READONLY);
2501 if (ret != SQLITE_OK) {
2502 LOGE("open db failed: %s", sqlite3_errmsg(db));
2503 return PMINFO_R_ERROR;
2506 ret = _appinfo_get_datacontrol_trusted_info(db, providerid, type, appid,
2508 sqlite3_close_v2(db);
2513 API int pkgmgrinfo_appinfo_usr_get_datacontrol_trusted_info(
2514 const char *providerid, const char *type, uid_t uid,
2515 char **appid, bool *is_trusted)
2519 if (providerid == NULL || type == NULL || appid == NULL ||
2520 is_trusted == NULL) {
2521 LOGE("invalid parameter");
2522 return PMINFO_R_EINVAL;
2525 ret = _pkgmgrinfo_appinfo_get_datacontrol_trusted_info(GLOBAL_USER,
2526 providerid, type, appid, is_trusted);
2527 if (ret == PMINFO_R_ENOENT && uid != GLOBAL_USER)
2528 ret = _pkgmgrinfo_appinfo_get_datacontrol_trusted_info(uid,
2529 providerid, type, appid, is_trusted);
2531 /* FIXME: It should return PMINFO_R_ENOENT but to keep previous
2532 * implementation, return PMINFO_R_ERROR. This should be
2535 if (ret == PMINFO_R_ENOENT) {
2536 LOGE("no datacontrol trusted info of %s", providerid);
2537 ret = PMINFO_R_ERROR;
2543 API int pkgmgrinfo_appinfo_get_datacontrol_trsuted_info(const char *providerid,
2544 const char *type, char **appid, bool *is_trusted)
2546 return pkgmgrinfo_appinfo_usr_get_datacontrol_trusted_info(providerid,
2547 type, _getuid(), appid, is_trusted);
2550 static int _appinfo_foreach_datacontrol_privileges(sqlite3 *db,
2551 const char *providerid, const char *type,
2552 pkgmgrinfo_pkg_privilege_list_cb callback, void *user_data)
2554 static const char query[] =
2555 "SELECT privilege FROM package_app_data_control_privilege "
2556 "WHERE providerid=? AND type=?";
2561 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
2562 if (ret != SQLITE_OK) {
2563 LOGE("prepare failed: %s", sqlite3_errmsg(db));
2564 return PMINFO_R_ERROR;
2567 ret = sqlite3_bind_text(stmt, 1, providerid, -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 ret = sqlite3_bind_text(stmt, 2, type, -1, SQLITE_STATIC);
2575 if (ret != SQLITE_OK) {
2576 LOGE("bind failed: %s", sqlite3_errmsg(db));
2577 sqlite3_finalize(stmt);
2578 return PMINFO_R_ERROR;
2581 while (sqlite3_step(stmt) == SQLITE_ROW) {
2583 ret = callback((const char *)sqlite3_column_text(stmt, 0),
2589 sqlite3_finalize(stmt);
2591 return count ? PMINFO_R_OK : PMINFO_R_ENOENT;
2594 static int _pkgmgrinfo_appinfo_foreach_datacontrol_privileges(uid_t uid,
2595 const char *providerid, const char *type,
2596 pkgmgrinfo_pkg_privilege_list_cb callback, void *user_data)
2602 dbpath = getUserPkgParserDBPathUID(GLOBAL_USER);
2604 return PMINFO_R_ERROR;
2606 ret = __open_db(dbpath, &db, SQLITE_OPEN_READONLY);
2608 if (ret != SQLITE_OK) {
2609 LOGE("open db failed: %s", sqlite3_errmsg(db));
2610 return PMINFO_R_ERROR;
2613 ret = _appinfo_foreach_datacontrol_privileges(db, providerid, type,
2614 callback, user_data);
2615 sqlite3_close_v2(db);
2620 API int pkgmgrinfo_appinfo_usr_foreach_datacontrol_privileges(
2621 const char *providerid, const char *type,
2622 pkgmgrinfo_pkg_privilege_list_cb privilege_func,
2623 void *user_data, uid_t uid)
2627 if (providerid == NULL || type == NULL || privilege_func == NULL) {
2628 LOGE("invalid parameter");
2629 return PMINFO_R_EINVAL;
2632 ret = _pkgmgrinfo_appinfo_foreach_datacontrol_privileges(GLOBAL_USER,
2633 providerid, type, privilege_func, user_data);
2634 if (ret == PMINFO_R_ENOENT && uid != GLOBAL_USER)
2635 ret = _pkgmgrinfo_appinfo_foreach_datacontrol_privileges(uid,
2636 providerid, type, privilege_func, user_data);
2638 if (ret == PMINFO_R_ENOENT)
2644 API int pkgmgrinfo_appinfo_foreach_datacontrol_privileges(
2645 const char *providerid, const char *type,
2646 pkgmgrinfo_pkg_privilege_list_cb privilege_func,
2649 return pkgmgrinfo_appinfo_usr_foreach_datacontrol_privileges(
2650 providerid, type, privilege_func, user_data, _getuid());
2653 API int pkgmgrinfo_appinfo_get_support_mode(pkgmgrinfo_appinfo_h handle, int *support_mode)
2655 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2656 retvm_if(support_mode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2658 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2659 if (info->app_info->support_mode)
2660 *support_mode = atoi(info->app_info->support_mode);
2667 API int pkgmgrinfo_appinfo_foreach_category(pkgmgrinfo_appinfo_h handle,
2668 pkgmgrinfo_app_category_list_cb category_func, void *user_data)
2670 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2671 retvm_if(category_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2673 const char *category;
2675 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2677 if (info->app_info == NULL)
2678 return PMINFO_R_ERROR;
2680 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
2681 category = (const char *)tmp->data;
2683 ret = category_func(category, user_data);
2691 API int pkgmgrinfo_appinfo_foreach_metadata(pkgmgrinfo_appinfo_h handle,
2692 pkgmgrinfo_app_metadata_list_cb metadata_func, void *user_data)
2694 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2695 retvm_if(metadata_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2699 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2701 if (info->app_info == NULL)
2702 return PMINFO_R_ERROR;
2704 for (tmp = info->app_info->metadata; tmp; tmp = tmp->next) {
2705 ptr = (metadata_x *)tmp->data;
2709 ret = metadata_func(ptr->key, ptr->value ? ptr->value : "", user_data);
2717 static int _appinfo_foreach_appcontrol_privileges(sqlite3 *db,
2718 const char *appid, const char *operation,
2719 pkgmgrinfo_pkg_privilege_list_cb callback, void *user_data)
2721 static const char query[] =
2722 "SELECT app_control, privilege FROM package_app_app_control_privilege "
2726 const char *app_control;
2727 char *dup_app_control;
2729 char *saveptr = NULL;
2730 const char *privilege;
2733 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
2734 if (ret != SQLITE_OK) {
2735 LOGE("prepare failed: %s", sqlite3_errmsg(db));
2736 return PMINFO_R_ERROR;
2739 ret = sqlite3_bind_text(stmt, 1, appid, -1, SQLITE_STATIC);
2740 if (ret != SQLITE_OK) {
2741 LOGE("bind failed: %s", sqlite3_errmsg(db));
2742 sqlite3_finalize(stmt);
2743 return PMINFO_R_ERROR;
2746 while (sqlite3_step(stmt) == SQLITE_ROW) {
2747 app_control = (const char *)sqlite3_column_text(stmt, 0);
2751 dup_app_control = strdup(app_control);
2752 if (!dup_app_control)
2755 token = strtok_r(dup_app_control, "|", &saveptr);
2756 if (token && !strcmp(token, operation)) {
2758 privilege = (const char *)sqlite3_column_text(stmt, 1);
2759 ret = callback(privilege, user_data);
2761 free(dup_app_control);
2765 free(dup_app_control);
2768 sqlite3_finalize(stmt);
2770 return count ? PMINFO_R_OK : PMINFO_R_ENOENT;
2773 static int _pkgmgrinfo_appinfo_foreach_appcontrol_privileges(uid_t uid,
2774 const char *appid, const char *operation,
2775 pkgmgrinfo_pkg_privilege_list_cb callback, void *user_data)
2781 dbpath = getUserPkgParserDBPathUID(uid);
2783 return PMINFO_R_ERROR;
2785 ret = __open_db(dbpath, &db, SQLITE_OPEN_READONLY);
2787 if (ret != SQLITE_OK) {
2788 LOGE("open db failed: %s", sqlite3_errmsg(db));
2789 return PMINFO_R_ERROR;
2792 ret = _appinfo_foreach_appcontrol_privileges(db, appid, operation,
2793 callback, user_data);
2794 sqlite3_close_v2(db);
2799 API int pkgmgrinfo_appinfo_usr_foreach_appcontrol_privileges(const char *appid,
2800 const char *operation,
2801 pkgmgrinfo_pkg_privilege_list_cb privilege_func,
2802 void *user_data, uid_t uid)
2806 if (appid == NULL || operation == NULL || privilege_func == NULL) {
2807 LOGE("invalid parameter");
2808 return PMINFO_R_EINVAL;
2811 ret = _pkgmgrinfo_appinfo_foreach_appcontrol_privileges(GLOBAL_USER,
2812 appid, operation, privilege_func, user_data);
2813 if (ret == PMINFO_R_ENOENT && uid != GLOBAL_USER)
2814 ret = _pkgmgrinfo_appinfo_foreach_appcontrol_privileges(uid,
2815 appid, operation, privilege_func, user_data);
2817 if (ret == PMINFO_R_ENOENT)
2823 API int pkgmgrinfo_appinfo_foreach_appcontrol_privileges(const char *appid,
2824 const char *operation,
2825 pkgmgrinfo_pkg_privilege_list_cb privilege_func,
2828 return pkgmgrinfo_appinfo_usr_foreach_appcontrol_privileges(appid,
2829 operation, privilege_func, user_data, _getuid());
2832 API int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
2833 pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
2835 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2836 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2838 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2839 appcontrol_x *appcontrol;
2842 if (info->app_info == NULL)
2843 return PMINFO_R_ERROR;
2845 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
2846 appcontrol = (appcontrol_x *)tmp->data;
2847 if (appcontrol == NULL || !strcasecmp(appcontrol->visibility, "remote-only"))
2849 ret = appcontrol_func(appcontrol->operation, appcontrol->uri, appcontrol->mime, user_data);
2857 API int pkgmgrinfo_appinfo_foreach_remote_appcontrol(pkgmgrinfo_appinfo_h handle,
2858 pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
2860 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2861 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2863 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2864 appcontrol_x *appcontrol;
2867 if (info->app_info == NULL)
2868 return PMINFO_R_ERROR;
2870 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
2871 appcontrol = (appcontrol_x *)tmp->data;
2872 if (appcontrol == NULL || !strcasecmp(appcontrol->visibility, "local-only"))
2874 ret = appcontrol_func(appcontrol->operation, appcontrol->uri, appcontrol->mime, user_data);
2882 API int pkgmgrinfo_appinfo_foreach_background_category(
2883 pkgmgrinfo_appinfo_h handle,
2884 pkgmgrinfo_app_background_category_list_cb category_func,
2887 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2891 if (handle == NULL || category_func == NULL || info->app_info == NULL) {
2892 LOGE("invalid parameter");
2893 return PMINFO_R_EINVAL;
2896 for (tmp = info->app_info->background_category; tmp; tmp = tmp->next) {
2897 category = (char *)tmp->data;
2898 if (category == NULL)
2901 if (category_func(category, user_data) < 0)
2908 API int pkgmgrinfo_appinfo_foreach_splash_screen(pkgmgrinfo_appinfo_h handle,
2909 pkgmgrinfo_app_splash_screen_list_cb splash_screen_func,
2912 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2913 splashscreen_x *splashscreen;
2917 if (info == NULL || info->app_info == NULL
2918 || splash_screen_func == NULL) {
2919 LOGE("invalid parameter");
2920 return PMINFO_R_EINVAL;
2923 for (tmp = info->app_info->splashscreens; tmp; tmp = tmp->next) {
2924 splashscreen = (splashscreen_x *)tmp->data;
2925 if (splashscreen == NULL)
2927 ret = splash_screen_func(splashscreen->src,
2929 splashscreen->orientation,
2930 splashscreen->indicatordisplay,
2931 splashscreen->operation,
2932 splashscreen->color_depth,
2941 API int pkgmgrinfo_appinfo_is_nodisplay(pkgmgrinfo_appinfo_h handle, bool *nodisplay)
2943 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2944 retvm_if(nodisplay == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2945 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2947 if (info->app_info == NULL || info->app_info->nodisplay == NULL)
2948 return PMINFO_R_ERROR;
2950 *nodisplay = _get_bool_value(info->app_info->nodisplay);
2955 API int pkgmgrinfo_appinfo_is_multiple(pkgmgrinfo_appinfo_h handle, bool *multiple)
2957 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2958 retvm_if(multiple == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2959 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2961 if (info->app_info == NULL || info->app_info->multiple == NULL)
2962 return PMINFO_R_ERROR;
2964 *multiple = _get_bool_value(info->app_info->multiple);
2969 API int pkgmgrinfo_appinfo_is_indicator_display_allowed(pkgmgrinfo_appinfo_h handle, bool *indicator_disp)
2971 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2972 retvm_if(indicator_disp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2973 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2975 if (info->app_info == NULL || info->app_info->indicatordisplay == NULL)
2976 return PMINFO_R_ERROR;
2978 *indicator_disp = _get_bool_value(info->app_info->indicatordisplay);
2983 API int pkgmgrinfo_appinfo_is_taskmanage(pkgmgrinfo_appinfo_h handle, bool *taskmanage)
2985 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2986 retvm_if(taskmanage == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2987 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2989 if (info->app_info == NULL || info->app_info->taskmanage == NULL)
2990 return PMINFO_R_ERROR;
2992 *taskmanage = _get_bool_value(info->app_info->taskmanage);
2997 API int pkgmgrinfo_appinfo_is_enabled(pkgmgrinfo_appinfo_h handle, bool *enabled)
2999 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
3000 retvm_if(enabled == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
3001 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3003 if (info->app_info == NULL || info->app_info->is_disabled == NULL)
3004 return PMINFO_R_ERROR;
3006 *enabled = !_get_bool_value(info->app_info->is_disabled);
3011 API int pkgmgrinfo_appinfo_is_onboot(pkgmgrinfo_appinfo_h handle, bool *onboot)
3013 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
3014 retvm_if(onboot == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
3015 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3017 if (info->app_info == NULL || info->app_info->onboot == NULL)
3018 return PMINFO_R_ERROR;
3020 *onboot = _get_bool_value(info->app_info->onboot);
3025 API int pkgmgrinfo_appinfo_is_autorestart(pkgmgrinfo_appinfo_h handle, bool *autorestart)
3027 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
3028 retvm_if(autorestart == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
3029 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3031 if (info->app_info == NULL || info->app_info->autorestart == NULL)
3032 return PMINFO_R_ERROR;
3034 *autorestart = _get_bool_value(info->app_info->autorestart);
3039 API int pkgmgrinfo_appinfo_is_mainapp(pkgmgrinfo_appinfo_h handle, bool *mainapp)
3041 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
3042 retvm_if(mainapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
3043 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3045 if (info->app_info == NULL || info->app_info->mainapp == NULL)
3046 return PMINFO_R_ERROR;
3048 *mainapp = _get_bool_value(info->app_info->mainapp);
3053 API int pkgmgrinfo_appinfo_is_preload(pkgmgrinfo_appinfo_h handle, bool *preload)
3055 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
3056 retvm_if(preload == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3057 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3059 if (info->app_info == NULL || info->app_info->preload == NULL)
3060 return PMINFO_R_ERROR;
3062 *preload = _get_bool_value(info->app_info->preload);
3067 API int pkgmgrinfo_appinfo_is_submode(pkgmgrinfo_appinfo_h handle, bool *submode)
3069 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
3070 retvm_if(submode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3071 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3073 if (info->app_info == NULL || info->app_info->submode == NULL)
3074 return PMINFO_R_ERROR;
3076 *submode = _get_bool_value(info->app_info->submode);
3081 API int pkgmgrinfo_appinfo_is_process_pool(pkgmgrinfo_appinfo_h handle, bool *process_pool)
3083 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3085 if (handle == NULL || process_pool == NULL) {
3086 LOGE("invalid parameter");
3087 return PMINFO_R_EINVAL;
3090 if (info->app_info == NULL)
3091 return PMINFO_R_ERROR;
3093 *process_pool = _get_bool_value(info->app_info->process_pool);
3098 API int pkgmgrinfo_appinfo_is_category_exist(pkgmgrinfo_appinfo_h handle, const char *category, bool *exist)
3100 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
3101 retvm_if(category == NULL, PMINFO_R_EINVAL, "category is NULL");
3102 retvm_if(exist == NULL, PMINFO_R_EINVAL, "exist is NULL");
3106 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3108 if (info->app_info == NULL)
3109 return PMINFO_R_ERROR;
3112 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
3113 val = (const char *)tmp->data;
3116 if (strcasecmp(val, category) == 0) {
3125 API int pkgmgrinfo_appinfo_is_ui_gadget(pkgmgrinfo_appinfo_h handle,
3128 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3130 if (info == NULL || info->app_info == NULL || ui_gadget == NULL) {
3131 _LOGE("invalid parameter");
3132 return PMINFO_R_EINVAL;
3134 if (info->app_info->ui_gadget == NULL)
3135 info->app_info->ui_gadget = strdup("false");
3137 *ui_gadget = _get_bool_value(info->app_info->ui_gadget);
3142 API int pkgmgrinfo_appinfo_is_support_disable(pkgmgrinfo_appinfo_h handle,
3143 bool *support_disable)
3145 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3147 if (info == NULL || info->app_info == NULL || support_disable == NULL) {
3148 _LOGE("invalid parameter");
3149 return PMINFO_R_EINVAL;
3152 *support_disable = _get_bool_value(info->app_info->support_disable);
3157 API int pkgmgrinfo_appinfo_is_removable(pkgmgrinfo_appinfo_h handle,
3160 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3162 if (info == NULL || info->app_info == NULL || removable == NULL) {
3163 _LOGE("invalid parameter");
3164 return PMINFO_R_EINVAL;
3167 *removable = _get_bool_value(info->app_info->removable);
3172 API int pkgmgrinfo_appinfo_is_system(pkgmgrinfo_appinfo_h handle, bool *system)
3174 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3176 if (info == NULL || info->app_info == NULL || system == NULL) {
3177 _LOGE("invalid parameter");
3178 return PMINFO_R_EINVAL;
3181 *system = _get_bool_value(info->app_info->package_system);
3186 API int pkgmgrinfo_appinfo_is_disabled(pkgmgrinfo_appinfo_h handle, bool *disabled)
3188 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
3189 retvm_if(disabled == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
3190 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3192 if (info->app_info == NULL || info->app_info->is_disabled == NULL)
3193 return PMINFO_R_ERROR;
3195 *disabled = _get_bool_value(info->app_info->is_disabled);
3200 API int pkgmgrinfo_appinfo_is_global(pkgmgrinfo_appinfo_h handle, bool *global)
3202 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3204 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
3205 retvm_if(global == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3207 if (info->app_info == NULL || info->app_info->for_all_users == NULL)
3208 return PMINFO_R_ERROR;
3210 *global = _get_bool_value(info->app_info->for_all_users);
3215 API int pkgmgrinfo_appinfo_get_splash_screen_display(pkgmgrinfo_appinfo_h handle, bool *splash_screen_display)
3217 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3219 if (info == NULL || splash_screen_display == NULL) {
3220 _LOGE("Invalid parameter");
3221 return PMINFO_R_EINVAL;
3224 if (info->app_info == NULL || info->app_info->splash_screen_display == NULL)
3225 return PMINFO_R_ERROR;
3227 *splash_screen_display = _get_bool_value(info->app_info->splash_screen_display);
3232 API int pkgmgrinfo_appinfo_get_setup_appid(pkgmgrinfo_appinfo_h handle, char **setup_appid)
3234 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3236 if (info == NULL || setup_appid == NULL) {
3237 _LOGE("Invalid parameter");
3238 return PMINFO_R_EINVAL;
3241 if (info->app_info == NULL || info->app_info->setup_appid == NULL)
3242 return PMINFO_R_ERROR;
3244 *setup_appid = info->app_info->setup_appid;
3248 API int pkgmgrinfo_appinfo_is_support_ambient(pkgmgrinfo_appinfo_h handle,
3249 bool *support_ambient)
3251 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3253 if (info == NULL || support_ambient == NULL) {
3254 _LOGE("Invalid parameter");
3255 return PMINFO_R_EINVAL;
3258 if (info->app_info == NULL || info->app_info->support_ambient == NULL)
3259 return PMINFO_R_ERROR;
3261 *support_ambient = _get_bool_value(info->app_info->support_ambient);
3266 API int pkgmgrinfo_appinfo_destroy_appinfo(pkgmgrinfo_appinfo_h handle)
3268 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
3269 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3270 __cleanup_appinfo(info);
3274 API int pkgmgrinfo_appinfo_filter_create(pkgmgrinfo_appinfo_filter_h *handle)
3276 return (pkgmgrinfo_pkginfo_filter_create(handle));
3279 API int pkgmgrinfo_appinfo_filter_destroy(pkgmgrinfo_appinfo_filter_h handle)
3281 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
3284 static gint __compare_func(gconstpointer data1, gconstpointer data2)
3286 pkgmgrinfo_node_x *node1 = (pkgmgrinfo_node_x *)data1;
3287 pkgmgrinfo_node_x *node2 = (pkgmgrinfo_node_x *)data2;
3288 if (node1->prop == node2->prop)
3290 else if (node1->prop > node2->prop)
3296 API int pkgmgrinfo_appinfo_filter_add_int(pkgmgrinfo_appinfo_filter_h handle,
3297 const char *property, const int value)
3299 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3300 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3301 char buf[PKG_VALUE_STRING_LEN_MAX] = {'\0'};
3303 GSList *link = NULL;
3305 prop = _pminfo_appinfo_convert_to_prop_int(property);
3306 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_INT ||
3307 prop > E_PMINFO_APPINFO_PROP_APP_MAX_INT) {
3308 _LOGE("Invalid Integer Property\n");
3309 return PMINFO_R_EINVAL;
3311 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
3312 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1, sizeof(pkgmgrinfo_node_x));
3314 _LOGE("Out of Memory!!!\n");
3315 return PMINFO_R_ERROR;
3317 snprintf(buf, PKG_VALUE_STRING_LEN_MAX - 1, "%d", value);
3318 val = strndup(buf, PKG_VALUE_STRING_LEN_MAX - 1);
3320 _LOGE("Out of Memory\n");
3323 return PMINFO_R_ERROR;
3327 /*If API is called multiple times for same property, we should override the previous values.
3328 Last value set will be used for filtering.*/
3329 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
3331 filter->list = g_slist_delete_link(filter->list, link);
3332 filter->list = g_slist_append(filter->list, (gpointer)node);
3337 API int pkgmgrinfo_appinfo_filter_add_bool(pkgmgrinfo_appinfo_filter_h handle,
3338 const char *property, const bool value)
3340 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3341 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3343 GSList *link = NULL;
3345 prop = _pminfo_appinfo_convert_to_prop_bool(property);
3346 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_BOOL ||
3347 prop > E_PMINFO_APPINFO_PROP_APP_MAX_BOOL) {
3348 _LOGE("Invalid Boolean Property\n");
3349 return PMINFO_R_EINVAL;
3351 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
3352 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1, sizeof(pkgmgrinfo_node_x));
3354 _LOGE("Out of Memory!!!\n");
3355 return PMINFO_R_ERROR;
3358 val = strndup("true", 4);
3360 val = strndup("false", 5);
3362 _LOGE("Out of Memory\n");
3365 return PMINFO_R_ERROR;
3369 /*If API is called multiple times for same property, we should override the previous values.
3370 Last value set will be used for filtering.*/
3371 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
3373 filter->list = g_slist_delete_link(filter->list, link);
3374 filter->list = g_slist_append(filter->list, (gpointer)node);
3379 API int pkgmgrinfo_appinfo_filter_add_string(pkgmgrinfo_appinfo_filter_h handle,
3380 const char *property, const char *value)
3382 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3383 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3384 retvm_if(value == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3386 pkgmgrinfo_node_x *ptr = NULL;
3387 char prev[PKG_STRING_LEN_MAX] = {'\0'};
3388 char temp[PKG_STRING_LEN_MAX] = {'\0'};
3389 GSList *link = NULL;
3391 prop = _pminfo_appinfo_convert_to_prop_str(property);
3392 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_STR ||
3393 prop > E_PMINFO_APPINFO_PROP_APP_MAX_STR) {
3394 _LOGE("Invalid String Property\n");
3395 return PMINFO_R_EINVAL;
3397 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
3398 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1, sizeof(pkgmgrinfo_node_x));
3400 _LOGE("Out of Memory!!!\n");
3401 return PMINFO_R_ERROR;
3405 case E_PMINFO_APPINFO_PROP_APP_COMPONENT:
3406 node->value = strdup(value);
3407 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
3409 filter->list = g_slist_delete_link(filter->list, link);
3410 filter->list = g_slist_append(filter->list, (gpointer)node);
3412 case E_PMINFO_APPINFO_PROP_APP_CATEGORY:
3413 val = (char *)calloc(1, PKG_STRING_LEN_MAX);
3415 _LOGE("Out of Memory\n");
3418 return PMINFO_R_ERROR;
3420 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
3422 ptr = (pkgmgrinfo_node_x *)link->data;
3423 strncpy(prev, ptr->value, PKG_STRING_LEN_MAX - 1);
3424 _LOGI("Previous value is %s\n", prev);
3425 filter->list = g_slist_delete_link(filter->list, link);
3426 snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s,%s", prev, value);
3427 strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
3428 _LOGI("New value is %s\n", val);
3430 filter->list = g_slist_append(filter->list, (gpointer)node);
3431 memset(temp, '\0', PKG_STRING_LEN_MAX);
3433 snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s", value);
3434 strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
3435 _LOGI("First value is %s\n", val);
3437 filter->list = g_slist_append(filter->list, (gpointer)node);
3438 memset(temp, '\0', PKG_STRING_LEN_MAX);
3442 node->value = strndup(value, PKG_STRING_LEN_MAX - 1);
3443 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
3445 filter->list = g_slist_delete_link(filter->list, link);
3446 filter->list = g_slist_append(filter->list, (gpointer)node);
3452 API int pkgmgrinfo_appinfo_usr_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count, uid_t uid)
3458 if (handle == NULL || count == NULL) {
3459 _LOGE("invalid parameter");
3460 return PMINFO_R_EINVAL;
3463 locale = _get_system_locale();
3465 return PMINFO_R_ERROR;
3467 list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
3468 __free_applications);
3471 return PMINFO_R_ERROR;
3474 if (__check_disable_filter_exist(
3475 handle, E_APPINFO_DISABLE_TYPE_APP) == false) {
3476 if (pkgmgrinfo_appinfo_filter_add_bool(handle,
3477 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
3478 g_hash_table_destroy(list);
3480 return PMINFO_R_ERROR;
3484 if (__check_disable_filter_exist(
3485 handle, E_APPINFO_DISABLE_TYPE_PKG) == false) {
3486 if (pkgmgrinfo_appinfo_filter_add_bool(handle,
3487 PMINFO_APPINFO_PROP_PKG_DISABLE, false)) {
3488 g_hash_table_destroy(list);
3490 return PMINFO_R_ERROR;
3494 ret = _appinfo_get_applications(uid, uid, locale, handle, 0, list);
3495 if (ret == PMINFO_R_OK && uid != GLOBAL_USER)
3496 ret = _appinfo_get_applications(GLOBAL_USER, uid, locale,
3499 if (ret != PMINFO_R_OK) {
3500 g_hash_table_destroy(list);
3502 return PMINFO_R_ERROR;
3505 *count = g_hash_table_size(list);
3506 g_hash_table_destroy(list);
3512 API int pkgmgrinfo_appinfo_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count)
3514 return pkgmgrinfo_appinfo_usr_filter_count(handle, count, _getuid());
3517 API int pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(
3518 pkgmgrinfo_appinfo_filter_h handle,
3519 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
3521 if (handle == NULL || app_cb == NULL) {
3522 LOGE("invalid parameter");
3523 return PMINFO_R_EINVAL;
3526 if (__check_disable_filter_exist(
3527 handle, E_APPINFO_DISABLE_TYPE_APP) == false) {
3528 if (pkgmgrinfo_appinfo_filter_add_bool(handle,
3529 PMINFO_APPINFO_PROP_APP_DISABLE, false))
3530 return PMINFO_R_ERROR;
3533 if (__check_disable_filter_exist(
3534 handle, E_APPINFO_DISABLE_TYPE_PKG) == false) {
3535 if (pkgmgrinfo_appinfo_filter_add_bool(handle,
3536 PMINFO_APPINFO_PROP_PKG_DISABLE, false))
3537 return PMINFO_R_ERROR;
3540 return _appinfo_get_filtered_foreach_appinfo(uid, handle, PMINFO_APPINFO_GET_ALL, app_cb,
3544 API int pkgmgrinfo_appinfo_filter_foreach_appinfo(pkgmgrinfo_appinfo_filter_h handle,
3545 pkgmgrinfo_app_list_cb app_cb, void *user_data)
3547 return pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(handle, app_cb, user_data, _getuid());
3550 API int pkgmgrinfo_appinfo_metadata_filter_create(pkgmgrinfo_appinfo_metadata_filter_h *handle)
3552 return (pkgmgrinfo_pkginfo_filter_create(handle));
3555 API int pkgmgrinfo_appinfo_metadata_filter_destroy(pkgmgrinfo_appinfo_metadata_filter_h handle)
3557 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
3560 API int pkgmgrinfo_appinfo_metadata_filter_add(
3561 pkgmgrinfo_appinfo_metadata_filter_h handle,
3562 const char *key, const char *value)
3564 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
3565 pkgmgrinfo_metadata_node_x *node;
3567 /* value can be NULL.
3568 * In that case all apps with specified key should be displayed
3571 LOGE("invalid parameter");
3572 return PMINFO_R_EINVAL;
3575 node = calloc(1, sizeof(pkgmgrinfo_metadata_node_x));
3577 LOGE("out of memory");
3578 return PMINFO_R_ERROR;
3581 node->key = strdup(key);
3582 if (value && strlen(value))
3583 node->value = strdup(value);
3585 filter->list_metadata = g_slist_append(filter->list_metadata,
3591 API int pkgmgrinfo_appinfo_usr_metadata_filter_foreach(
3592 pkgmgrinfo_appinfo_metadata_filter_h handle,
3593 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
3595 if (handle == NULL || app_cb == NULL) {
3596 LOGE("invalid parameter");
3597 return PMINFO_R_EINVAL;
3600 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
3601 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
3602 PMINFO_APPINFO_PROP_APP_DISABLE, false))
3603 return PMINFO_R_ERROR;
3605 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
3606 PMINFO_APPINFO_PROP_PKG_DISABLE, false))
3607 return PMINFO_R_ERROR;
3609 return _appinfo_get_filtered_foreach_appinfo(uid, handle, PMINFO_APPINFO_GET_ALL, app_cb,
3613 API int pkgmgrinfo_appinfo_metadata_filter_foreach(
3614 pkgmgrinfo_appinfo_metadata_filter_h handle,
3615 pkgmgrinfo_app_list_cb app_cb, void *user_data)
3617 return pkgmgrinfo_appinfo_usr_metadata_filter_foreach(handle, app_cb,
3618 user_data, _getuid());
3621 API int pkgmgrinfo_appinfo_is_guestmode_visibility(pkgmgrinfo_appinfo_h handle, bool *status)
3624 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3626 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
3627 retvm_if(status == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3629 val = info->app_info->guestmode_visibility;
3630 *status = _get_bool_value(val);
3634 API int pkgmgrinfo_appinfo_foreach_appcontrol_v2(pkgmgrinfo_appinfo_h handle,
3635 pkgmgrinfo_app_control_list_cb_v2 appcontrol_func,
3638 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
3639 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
3641 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3642 appcontrol_x *appcontrol;
3645 if (info->app_info == NULL)
3646 return PMINFO_R_ERROR;
3648 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
3649 appcontrol = (appcontrol_x *)tmp->data;
3650 if (appcontrol == NULL ||
3651 !strcasecmp(appcontrol->visibility, "remote-only"))
3653 ret = appcontrol_func(appcontrol->operation, appcontrol->uri,
3654 appcontrol->mime, appcontrol->id, user_data);
3662 API int pkgmgrinfo_appinfo_foreach_remote_appcontrol_v2(
3663 pkgmgrinfo_appinfo_h handle,
3664 pkgmgrinfo_app_control_list_cb_v2 appcontrol_func,
3667 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
3668 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
3670 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3671 appcontrol_x *appcontrol;
3674 if (info->app_info == NULL)
3675 return PMINFO_R_ERROR;
3677 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
3678 appcontrol = (appcontrol_x *)tmp->data;
3679 if (appcontrol == NULL ||
3680 !strcasecmp(appcontrol->visibility, "local-only"))
3682 ret = appcontrol_func(appcontrol->operation, appcontrol->uri,
3683 appcontrol->mime, appcontrol->id, user_data);