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 int _appinfo_get_component_info(sqlite3 *db, const char *appid,
338 static const char query_raw[] =
339 "SELECT component_id, type, launch_mode "
340 "FROM package_app_component_info "
348 query = sqlite3_mprintf(query_raw, appid);
350 LOGE("out of memory");
351 return PMINFO_R_ERROR;
354 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
356 if (ret != SQLITE_OK) {
357 LOGE("prepare failed: %s", sqlite3_errmsg(db));
358 return PMINFO_R_ERROR;
361 while (sqlite3_step(stmt) == SQLITE_ROW) {
362 info = calloc(1, sizeof(component_x));
364 LOGE("out of memory");
365 sqlite3_finalize(stmt);
366 return PMINFO_R_ERROR;
370 _save_column_str(stmt, idx++, &info->id);
371 _save_column_str(stmt, idx++, &info->type);
372 _save_column_str(stmt, idx++, &info->launch_mode);
373 *components = g_list_append(*components, info);
376 sqlite3_finalize(stmt);
381 static GList *__get_background_category(const char *value)
383 GList *category_list = NULL;
384 int convert_value = 0;
385 if (!value || strlen(value) == 0)
388 convert_value = atoi(value);
389 if (convert_value < 0)
392 if (convert_value & APP_BG_CATEGORY_USER_DISABLE_TRUE_VAL)
393 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_USER_DISABLE_TRUE_STR));
395 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_USER_DISABLE_FALSE_STR));
397 if (convert_value & APP_BG_CATEGORY_MEDIA_VAL)
398 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_MEDIA_STR));
400 if (convert_value & APP_BG_CATEGORY_DOWNLOAD_VAL)
401 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_DOWNLOAD_STR));
403 if (convert_value & APP_BG_CATEGORY_BGNETWORK_VAL)
404 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_BGNETWORK_STR));
406 if (convert_value & APP_BG_CATEGORY_LOCATION_VAL)
407 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_LOCATION_STR));
409 if (convert_value & APP_BG_CATEGORY_SENSOR_VAL)
410 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_SENSOR_STR));
412 if (convert_value & APP_BG_CATEGORY_IOTCOMM_VAL)
413 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_IOTCOMM_STR));
415 if (convert_value & APP_BG_CATEGORY_SYSTEM_VAL)
416 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_SYSTEM));
418 return category_list;
422 static void __free_applications(gpointer data)
424 pkgmgrinfo_basic_free_application((application_x *)data);
427 static gint __disable_chk_func(gconstpointer data1, gconstpointer data2)
429 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)data1;
430 pkgmgrinfo_appinfo_disable_type value = GPOINTER_TO_INT(data2);
432 if (value == E_APPINFO_DISABLE_TYPE_PKG)
433 return (node->prop == E_PMINFO_APPINFO_PROP_PKG_DISABLE)
436 return (node->prop == E_PMINFO_APPINFO_PROP_APP_DISABLE)
440 static bool __check_disable_filter_exist(pkgmgrinfo_filter_x *filter,
441 pkgmgrinfo_appinfo_disable_type type)
448 link = g_slist_find_custom(filter->list, GINT_TO_POINTER(type), __disable_chk_func);
455 static int __bind_params(sqlite3_stmt *stmt, GList *params)
457 GList *tmp_list = NULL;
461 if (stmt == NULL || params == NULL)
462 return PMINFO_R_EINVAL;
466 ret = sqlite3_bind_text(stmt, ++idx, (char *)tmp_list->data, -1, SQLITE_STATIC);
467 if (ret != SQLITE_OK)
468 return PMINFO_R_ERROR;
469 tmp_list = tmp_list->next;
475 static bool __check_app_storage_status(pkgmgrinfo_filter_x *tmp_filter)
477 GSList *tmp_list = NULL;
478 pkgmgrinfo_node_x *tmp_node = NULL;
481 if (tmp_filter == NULL)
484 property = _pminfo_appinfo_convert_to_prop_bool(PMINFO_APPINFO_PROP_APP_CHECK_STORAGE);
485 for (tmp_list = tmp_filter->list; tmp_list != NULL;
486 tmp_list = g_slist_next(tmp_list)) {
487 tmp_node = (pkgmgrinfo_node_x *)tmp_list->data;
488 if (property == tmp_node->prop) {
489 if (strcmp(tmp_node->value, "true") == 0)
499 static int _appinfo_get_applications(uid_t db_uid, uid_t uid,
500 const char *locale, pkgmgrinfo_filter_x *filter, int flag,
501 GHashTable *applications)
503 static const char query_raw[] =
504 "SELECT DISTINCT ai.app_id, ai.app_installed_storage, "
505 "ai.app_external_path";
506 static const char query_basic[] =
507 ", ai.app_component, ai.app_exec, "
508 "ai.app_nodisplay, ai.app_type, ai.app_onboot, "
509 "ai.app_multiple, ai.app_autorestart, ai.app_taskmanage, "
510 "ai.app_hwacceleration, ai.app_screenreader, "
511 "ai.app_mainapp, ai.app_recentimage, ai.app_launchcondition, "
512 "ai.app_indicatordisplay, ai.app_portraitimg, "
513 "ai.app_landscapeimg, ai.app_guestmodevisibility, "
514 "ai.app_permissiontype, ai.app_preload, ai.app_submode, "
515 "ai.app_submode_mainid, ai.app_launch_mode, ai.app_ui_gadget, "
516 "ai.app_support_disable, ai.app_process_pool, "
517 "ai.app_background_category, ai.app_package_type, "
518 "ai.app_root_path, ai.app_api_version, ai.app_effective_appid, "
519 "ai.app_disable, ai.app_splash_screen_display, ai.app_tep_name, "
520 "ai.app_zip_mount_file, ai.component_type, ai.package, "
521 "ai.app_package_system, ai.app_removable, "
522 "ai.app_package_installed_time, ai.app_support_mode, "
523 "ai.app_support_ambient, ai.app_setup_appid";
524 static const char query_uid_info[] =
525 ", ui.is_disabled, ui.is_splash_screen_enabled";
526 static const char query_label[] =
528 "(SELECT app_label FROM package_app_localized_info WHERE ai.app_id=app_id AND app_locale=?), "
529 "(SELECT app_label FROM package_app_localized_info WHERE ai.app_id=app_id AND app_locale='No Locale'))";
530 static const char query_icon[] =
532 "(SELECT app_icon FROM package_app_localized_info WHERE ai.app_id=app_id AND app_locale=?), "
533 "(SELECT app_icon FROM package_app_localized_info WHERE ai.app_id=app_id AND app_locale='No Locale'))";
534 static const char query_from_clause[] = " FROM package_app_info as ai";
535 static const char query_uid_info_clause[] =
536 " LEFT OUTER JOIN package_app_info_for_uid AS ui "
537 "ON (ai.app_id=ui.app_id AND ui.uid=?)";
538 int ret = PMINFO_R_ERROR;
541 char *bg_category_str = NULL;
542 char *constraint = NULL;
543 char *tmp_record = NULL;
544 char query[MAX_QUERY_LEN] = { '\0' };
545 char buf[BUFSIZE] = { '\0' };
546 application_x *info = NULL;
547 GList *bind_params = NULL;
549 sqlite3_stmt *stmt = NULL;
550 bool is_check_storage = true;
551 const uid_t global_user_uid = GLOBAL_USER;
553 dbpath = getUserPkgParserDBPathUID(db_uid);
555 return PMINFO_R_ERROR;
557 ret = __open_db(dbpath, &db, SQLITE_OPEN_READONLY);
558 if (ret != SQLITE_OK) {
559 _LOGE("failed to open db(%s): %d", dbpath, ret);
561 return PMINFO_R_ERROR;
565 snprintf(query, MAX_QUERY_LEN - 1, "%s", query_raw);
567 if (flag & PMINFO_APPINFO_GET_BASICINFO) {
568 strncat(query, query_basic, sizeof(query) - strlen(query) - 1);
569 strncat(query, query_uid_info, sizeof(query) - strlen(query) - 1);
571 if (flag & PMINFO_APPINFO_GET_LABEL) {
572 strncat(query, query_label, sizeof(query) - strlen(query) - 1);
573 bind_params = g_list_append(bind_params, strdup(locale));
575 if (flag & PMINFO_APPINFO_GET_ICON) {
576 strncat(query, query_icon, sizeof(query) - strlen(query) - 1);
577 bind_params = g_list_append(bind_params, strdup(locale));
580 snprintf(buf, MAX_QUERY_LEN - 1, "%d", uid);
581 bind_params = g_list_append(bind_params, strdup(buf));
583 is_check_storage = __check_app_storage_status(filter);
585 ret = _get_filtered_query(filter, locale, uid, &constraint, &bind_params);
586 if (ret != PMINFO_R_OK) {
587 LOGE("Failed to get WHERE clause");
590 strncat(query, query_from_clause, sizeof(query) - strlen(query) - 1);
592 strncat(query, query_uid_info_clause, sizeof(query) - strlen(query) - 1);
595 strncat(query, constraint, sizeof(query) - strlen(query) - 1);
597 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
598 if (ret != SQLITE_OK) {
599 LOGE("prepare failed: %s", sqlite3_errmsg(db));
600 ret = PMINFO_R_ERROR;
604 if (g_list_length(bind_params) != 0) {
605 ret = __bind_params(stmt, bind_params);
606 if (ret != SQLITE_OK) {
607 LOGE("Failed to bind parameters");
612 while (sqlite3_step(stmt) == SQLITE_ROW) {
613 info = calloc(1, sizeof(application_x));
615 LOGE("out of memory");
616 ret = PMINFO_R_ERROR;
620 _save_column_str(stmt, idx++, &info->appid);
621 _save_column_str(stmt, idx++, &info->installed_storage);
622 _save_column_str(stmt, idx++ , &info->external_path);
624 if (flag & PMINFO_APPINFO_GET_BASICINFO) {
625 _save_column_str(stmt, idx++, &info->component);
626 _save_column_str(stmt, idx++, &info->exec);
627 _save_column_str(stmt, idx++, &info->nodisplay);
628 _save_column_str(stmt, idx++, &info->type);
629 _save_column_str(stmt, idx++, &info->onboot);
630 _save_column_str(stmt, idx++, &info->multiple);
631 _save_column_str(stmt, idx++, &info->autorestart);
632 _save_column_str(stmt, idx++, &info->taskmanage);
633 _save_column_str(stmt, idx++, &info->hwacceleration);
634 _save_column_str(stmt, idx++, &info->screenreader);
635 _save_column_str(stmt, idx++, &info->mainapp);
636 _save_column_str(stmt, idx++, &info->recentimage);
637 _save_column_str(stmt, idx++, &info->launchcondition);
638 _save_column_str(stmt, idx++, &info->indicatordisplay);
639 _save_column_str(stmt, idx++, &info->portraitimg);
640 _save_column_str(stmt, idx++, &info->landscapeimg);
641 _save_column_str(stmt, idx++, &info->guestmode_visibility);
642 _save_column_str(stmt, idx++, &info->permission_type);
643 _save_column_str(stmt, idx++, &info->preload);
644 _save_column_str(stmt, idx++, &info->submode);
645 _save_column_str(stmt, idx++, &info->submode_mainid);
646 _save_column_str(stmt, idx++, &info->launch_mode);
647 _save_column_str(stmt, idx++, &info->ui_gadget);
648 _save_column_str(stmt, idx++, &info->support_disable);
649 _save_column_str(stmt, idx++, &info->process_pool);
650 _save_column_str(stmt, idx++, &bg_category_str);
651 _save_column_str(stmt, idx++, &info->package_type);
652 _save_column_str(stmt, idx++, &info->root_path);
653 _save_column_str(stmt, idx++, &info->api_version);
654 _save_column_str(stmt, idx++, &info->effective_appid);
655 _save_column_str(stmt, idx++, &info->is_disabled);
656 _save_column_str(stmt, idx++, &info->splash_screen_display);
657 _save_column_str(stmt, idx++, &info->tep_name);
658 _save_column_str(stmt, idx++, &info->zip_mount_file);
659 _save_column_str(stmt, idx++, &info->component_type);
660 _save_column_str(stmt, idx++, &info->package);
661 _save_column_str(stmt, idx++, &info->package_system);
662 _save_column_str(stmt, idx++, &info->removable);
663 _save_column_str(stmt, idx++, &info->package_installed_time);
664 _save_column_str(stmt, idx++, &info->support_mode);
665 _save_column_str(stmt, idx++, &info->support_ambient);
666 _save_column_str(stmt, idx++, &info->setup_appid);
667 info->background_category = __get_background_category(
669 free(bg_category_str);
672 info->for_all_users =
673 strdup((db_uid != global_user_uid) ? "false" : "true");
675 if (db_uid != global_user_uid) {
679 _save_column_str(stmt, idx++, &tmp_record);
680 if (tmp_record != NULL) {
681 if (strcasecmp(info->is_disabled, "false") == 0 &&
682 strcasecmp(tmp_record, "false") == 0) {
683 free(info->is_disabled);
684 info->is_disabled = tmp_record;
690 _save_column_str(stmt, idx++, &tmp_record);
691 if (tmp_record != NULL) {
692 if (strcasecmp(info->splash_screen_display, "false") == 0 &&
693 strcasecmp(tmp_record, "false") == 0) {
694 free(info->splash_screen_display);
695 info->splash_screen_display = tmp_record;
702 if (flag & PMINFO_APPINFO_GET_LABEL) {
704 _save_column_str(stmt, idx++, &tmp_record);
705 if (_add_label_info_into_list(locale, tmp_record, &info->label)) {
706 ret = PMINFO_R_ERROR;
711 if (flag & PMINFO_APPINFO_GET_ICON) {
713 _save_column_str(stmt, idx++, &tmp_record);
714 if (_add_icon_info_into_list(locale, tmp_record, &info->icon)) {
715 ret = PMINFO_R_ERROR;
720 if (flag & PMINFO_APPINFO_GET_CATEGORY) {
721 if (_appinfo_get_category(db, info->appid,
723 ret = PMINFO_R_ERROR;
728 if (flag & PMINFO_APPINFO_GET_APP_CONTROL) {
729 if (_appinfo_get_app_control(db, info->appid,
730 &info->appcontrol)) {
731 ret = PMINFO_R_ERROR;
736 if (flag & PMINFO_APPINFO_GET_METADATA) {
737 if (_appinfo_get_metadata(db, info->appid,
739 ret = PMINFO_R_ERROR;
744 if (flag & PMINFO_APPINFO_GET_SPLASH_SCREEN) {
745 if (_appinfo_get_splashscreens(db, info->appid,
746 &info->splashscreens)) {
747 ret = PMINFO_R_ERROR;
752 if (info->component &&
753 !strcmp(info->component, "componentbasedapp")) {
754 if (_appinfo_get_component_info(db, info->appid,
755 &info->components)) {
756 ret = PMINFO_R_ERROR;
761 if (is_check_storage &&
762 __appinfo_check_installed_storage(info) != PMINFO_R_OK) {
763 ret = PMINFO_R_ERROR;
764 pkgmgrinfo_basic_free_application(info);
769 g_hash_table_insert(applications, (gpointer)info->appid,
776 sqlite3_finalize(stmt);
777 sqlite3_close_v2(db);
782 if (ret != PMINFO_R_OK && info != NULL)
783 pkgmgrinfo_basic_free_application(info);
785 g_list_free_full(bind_params, free);
790 static int _pkgmgrinfo_get_appinfo(const char *appid, uid_t uid,
791 pkgmgrinfo_appinfo_filter_h filter, pkgmgrinfo_appinfo_h *handle)
796 pkgmgr_appinfo_x *info;
798 if (appid == NULL || filter == NULL || handle == NULL) {
799 LOGE("invalid parameter");
800 return PMINFO_R_EINVAL;
803 locale = _get_system_locale();
805 return PMINFO_R_ERROR;
807 list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
808 __free_applications);
811 return PMINFO_R_ERROR;
814 ret = _appinfo_get_applications(uid, uid, locale, filter,
815 PMINFO_APPINFO_GET_ALL, list);
816 if (!g_hash_table_size(list) && uid != GLOBAL_USER)
817 ret = _appinfo_get_applications(GLOBAL_USER, uid, locale, filter,
818 PMINFO_APPINFO_GET_ALL, list);
820 if (ret != PMINFO_R_OK) {
821 g_hash_table_destroy(list);
826 if (!g_hash_table_size(list)) {
827 _LOGD("appinfo for [%s] is not existed for user [%d]",
829 g_hash_table_destroy(list);
831 return PMINFO_R_ENOENT;
834 info = calloc(1, sizeof(pkgmgr_appinfo_x));
836 _LOGE("out of memory");
837 g_hash_table_destroy(list);
839 return PMINFO_R_ERROR;
842 info->app_info = (application_x *)g_hash_table_lookup(list, appid);
843 info->locale = locale;
844 info->package = strdup(info->app_info->package);
846 /* just free list only */
847 g_hash_table_steal(list, (gconstpointer)appid);
848 g_hash_table_destroy(list);
855 API int pkgmgrinfo_appinfo_get_usr_disabled_appinfo(const char *appid, uid_t uid,
856 pkgmgrinfo_appinfo_h *handle)
859 pkgmgrinfo_appinfo_filter_h filter;
861 if (appid == NULL || handle == NULL) {
862 LOGE("invalid parameter");
863 return PMINFO_R_EINVAL;
866 ret = pkgmgrinfo_appinfo_filter_create(&filter);
867 if (ret != PMINFO_R_OK)
870 ret = pkgmgrinfo_appinfo_filter_add_string(filter,
871 PMINFO_APPINFO_PROP_APP_ID, appid);
872 if (ret != PMINFO_R_OK) {
873 pkgmgrinfo_appinfo_filter_destroy(filter);
874 return PMINFO_R_ERROR;
877 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
878 PMINFO_APPINFO_PROP_APP_DISABLE, true);
879 if (ret != PMINFO_R_OK) {
880 pkgmgrinfo_appinfo_filter_destroy(filter);
881 return PMINFO_R_ERROR;
884 ret = _pkgmgrinfo_get_appinfo(appid, uid, filter, handle);
885 pkgmgrinfo_appinfo_filter_destroy(filter);
890 API int pkgmgrinfo_appinfo_get_disabled_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
892 return pkgmgrinfo_appinfo_get_usr_disabled_appinfo(appid, _getuid(), handle);
895 API int pkgmgrinfo_appinfo_get_usr_appinfo(const char *appid, uid_t uid,
896 pkgmgrinfo_appinfo_h *handle)
899 pkgmgrinfo_appinfo_filter_h filter;
901 if (appid == NULL || handle == NULL) {
902 LOGE("invalid parameter");
903 return PMINFO_R_EINVAL;
906 ret = pkgmgrinfo_appinfo_filter_create(&filter);
907 if (ret != PMINFO_R_OK)
910 ret = pkgmgrinfo_appinfo_filter_add_string(filter,
911 PMINFO_APPINFO_PROP_APP_ID, appid);
912 if (ret != PMINFO_R_OK) {
913 pkgmgrinfo_appinfo_filter_destroy(filter);
914 return PMINFO_R_ERROR;
917 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
918 PMINFO_APPINFO_PROP_APP_DISABLE, false);
919 if (ret != PMINFO_R_OK) {
920 pkgmgrinfo_appinfo_filter_destroy(filter);
921 return PMINFO_R_ERROR;
924 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
925 PMINFO_APPINFO_PROP_PKG_DISABLE, false);
926 if (ret != PMINFO_R_OK) {
927 pkgmgrinfo_appinfo_filter_destroy(filter);
928 return PMINFO_R_ERROR;
931 ret = _pkgmgrinfo_get_appinfo(appid, uid, filter, handle);
932 pkgmgrinfo_appinfo_filter_destroy(filter);
936 API int pkgmgrinfo_appinfo_get_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
938 return pkgmgrinfo_appinfo_get_usr_appinfo(appid, _getuid(), handle);
941 API int pkgmgrinfo_appinfo_get_usr_all_appinfo(const char *appid, uid_t uid,
942 pkgmgrinfo_appinfo_h *handle)
945 pkgmgrinfo_appinfo_filter_h filter;
947 if (appid == NULL || handle == NULL) {
948 LOGE("invalid parameter");
949 return PMINFO_R_EINVAL;
952 ret = pkgmgrinfo_appinfo_filter_create(&filter);
953 if (ret != PMINFO_R_OK)
956 ret = pkgmgrinfo_appinfo_filter_add_string(filter,
957 PMINFO_APPINFO_PROP_APP_ID, appid);
958 if (ret != PMINFO_R_OK) {
959 pkgmgrinfo_appinfo_filter_destroy(filter);
960 return PMINFO_R_ERROR;
963 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
964 PMINFO_APPINFO_PROP_APP_CHECK_STORAGE, false);
965 if (ret != PMINFO_R_OK) {
966 pkgmgrinfo_appinfo_filter_destroy(filter);
967 return PMINFO_R_ERROR;
970 ret = _pkgmgrinfo_get_appinfo(appid, uid, filter, handle);
971 pkgmgrinfo_appinfo_filter_destroy(filter);
976 API int pkgmgrinfo_appinfo_get_all_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
978 return pkgmgrinfo_appinfo_get_usr_all_appinfo(appid, _getuid(), handle);
981 static gpointer __copy_str(gconstpointer src, gpointer data)
983 const char *tmp = (const char *)src;
986 buffer = strdup(tmp);
987 if (buffer == NULL) {
988 LOGE("memory alloc failed");
996 static gpointer __copy_label(gconstpointer src, gpointer data)
998 label_x *tmp = (label_x *)src;
1001 label = calloc(1, sizeof(label_x));
1002 if (label == NULL) {
1003 LOGE("memory alloc failed");
1009 label->name = strdup(tmp->name);
1011 label->text = strdup(tmp->text);
1013 label->lang = strdup(tmp->lang);
1018 static gpointer __copy_icon(gconstpointer src, gpointer data)
1020 icon_x *tmp = (icon_x *)src;
1023 icon = calloc(1, sizeof(icon_x));
1025 LOGE("memory alloc failed");
1031 icon->text = strdup(tmp->text);
1033 icon->lang = strdup(tmp->lang);
1035 icon->section = strdup(tmp->section);
1037 icon->size = strdup(tmp->size);
1038 if (tmp->resolution)
1039 icon->resolution = strdup(tmp->resolution);
1044 static gpointer __copy_metadata(gconstpointer src, gpointer data)
1046 metadata_x *tmp = (metadata_x *)src;
1047 metadata_x *metadata;
1049 metadata = calloc(1, sizeof(metadata_x));
1050 if (metadata == NULL) {
1051 LOGE("memory alloc failed");
1057 metadata->key = strdup(tmp->key);
1059 metadata->value = strdup(tmp->value);
1064 static gpointer __copy_datacontrol(gconstpointer src, gpointer data)
1066 datacontrol_x *tmp = (datacontrol_x *)src;
1067 datacontrol_x *datacontrol;
1069 datacontrol = calloc(1, sizeof(datacontrol_x));
1070 if (datacontrol == NULL) {
1071 LOGE("memory alloc failed");
1076 if (tmp->providerid)
1077 datacontrol->providerid = strdup(tmp->providerid);
1079 datacontrol->access = strdup(tmp->access);
1081 datacontrol->type = strdup(tmp->type);
1083 datacontrol->trusted = strdup(tmp->trusted);
1088 static gpointer __copy_appcontrol(gconstpointer src, gpointer data)
1090 appcontrol_x *tmp = (appcontrol_x *)src;
1091 appcontrol_x *appcontrol;
1093 appcontrol = calloc(1, sizeof(appcontrol_x));
1094 if (appcontrol == NULL) {
1095 LOGE("memory alloc failed");
1101 appcontrol->operation = strdup(tmp->operation);
1103 appcontrol->uri = strdup(tmp->uri);
1105 appcontrol->mime = strdup(tmp->mime);
1110 static gpointer __copy_splashscreens(gconstpointer src, gpointer data)
1112 splashscreen_x *tmp = (splashscreen_x *)src;
1113 splashscreen_x *splashscreen;
1115 splashscreen = (splashscreen_x *)calloc(1, sizeof(splashscreen_x));
1116 if (splashscreen == NULL) {
1117 LOGE("memory alloc failed");
1123 splashscreen->src = strdup(tmp->src);
1125 splashscreen->type = strdup(tmp->type);
1126 if (tmp->orientation)
1127 splashscreen->orientation = strdup(tmp->orientation);
1128 if (tmp->indicatordisplay)
1129 splashscreen->indicatordisplay = strdup(tmp->indicatordisplay);
1131 splashscreen->operation = strdup(tmp->operation);
1132 if (tmp->color_depth)
1133 splashscreen->color_depth = strdup(tmp->color_depth);
1135 return splashscreen;
1138 static gpointer __copy_components(gconstpointer src, gpointer data)
1140 component_x *tmp = (component_x *)src;
1141 component_x *component;
1143 component = (component_x *)calloc(1, sizeof(component_x));
1144 if (component == NULL) {
1145 LOGE("memory alloc failed");
1151 component->id = strdup(tmp->id);
1153 component->type = strdup(tmp->type);
1154 if (tmp->launch_mode)
1155 component->launch_mode = strdup(tmp->launch_mode);
1160 static int _appinfo_copy_appinfo(application_x **application, application_x *data)
1162 application_x *app_info;
1165 app_info = calloc(1, sizeof(application_x));
1166 if (app_info == NULL) {
1167 LOGE("memory alloc failed");
1168 return PMINFO_R_ERROR;
1171 if (data->appid != NULL)
1172 app_info->appid = strdup(data->appid);
1173 if (data->exec != NULL)
1174 app_info->exec = strdup(data->exec);
1175 if (data->nodisplay != NULL)
1176 app_info->nodisplay = strdup(data->nodisplay);
1177 if (data->multiple != NULL)
1178 app_info->multiple = strdup(data->multiple);
1179 if (data->taskmanage != NULL)
1180 app_info->taskmanage = strdup(data->taskmanage);
1181 if (data->type != NULL)
1182 app_info->type = strdup(data->type);
1183 if (data->categories != NULL)
1184 app_info->categories = strdup(data->categories);
1185 if (data->hwacceleration != NULL)
1186 app_info->hwacceleration = strdup(data->hwacceleration);
1187 if (data->screenreader != NULL)
1188 app_info->screenreader = strdup(data->screenreader);
1189 if (data->mainapp != NULL)
1190 app_info->mainapp = strdup(data->mainapp);
1191 if (data->package != NULL)
1192 app_info->package = strdup(data->package);
1193 if (data->recentimage != NULL)
1194 app_info->recentimage = strdup(data->recentimage);
1195 if (data->launchcondition != NULL)
1196 app_info->launchcondition = strdup(data->launchcondition);
1197 if (data->indicatordisplay != NULL)
1198 app_info->indicatordisplay = strdup(data->indicatordisplay);
1199 if (data->portraitimg != NULL)
1200 app_info->portraitimg = strdup(data->portraitimg);
1201 if (data->landscapeimg != NULL)
1202 app_info->landscapeimg = strdup(data->landscapeimg);
1203 if (data->guestmode_visibility != NULL)
1204 app_info->guestmode_visibility = strdup(data->guestmode_visibility);
1205 if (data->component != NULL)
1206 app_info->component = strdup(data->component);
1207 if (data->permission_type != NULL)
1208 app_info->permission_type = strdup(data->permission_type);
1209 if (data->component_type != NULL)
1210 app_info->component_type = strdup(data->component_type);
1211 if (data->preload != NULL)
1212 app_info->preload = strdup(data->preload);
1213 if (data->submode != NULL)
1214 app_info->submode = strdup(data->submode);
1215 if (data->submode_mainid != NULL)
1216 app_info->submode_mainid = strdup(data->submode_mainid);
1217 if (data->process_pool != NULL)
1218 app_info->process_pool = strdup(data->process_pool);
1219 if (data->installed_storage != NULL)
1220 app_info->installed_storage = strdup(data->installed_storage);
1221 if (data->autorestart != NULL)
1222 app_info->autorestart = strdup(data->autorestart);
1223 if (data->onboot != NULL)
1224 app_info->onboot = strdup(data->onboot);
1225 if (data->support_disable != NULL)
1226 app_info->support_disable = strdup(data->support_disable);
1227 if (data->ui_gadget != NULL)
1228 app_info->ui_gadget = strdup(data->ui_gadget);
1229 if (data->launch_mode != NULL)
1230 app_info->launch_mode = strdup(data->launch_mode);
1231 if (data->package_type != NULL)
1232 app_info->package_type = strdup(data->package_type);
1233 if (data->effective_appid != NULL)
1234 app_info->effective_appid = strdup(data->effective_appid);
1235 if (data->splash_screen_display != NULL)
1236 app_info->splash_screen_display = strdup(data->splash_screen_display);
1240 app_info->label = g_list_copy_deep(data->label, __copy_label, &ret);
1242 LOGE("memory alloc failed");
1243 pkgmgrinfo_basic_free_application(app_info);
1244 return PMINFO_R_ERROR;
1248 app_info->icon = g_list_copy_deep(data->icon, __copy_icon, &ret);
1250 LOGE("memory alloc failed");
1251 pkgmgrinfo_basic_free_application(app_info);
1252 return PMINFO_R_ERROR;
1256 app_info->category = g_list_copy_deep(data->category, __copy_str, &ret);
1258 LOGE("memory alloc failed");
1259 pkgmgrinfo_basic_free_application(app_info);
1260 return PMINFO_R_ERROR;
1264 app_info->metadata = g_list_copy_deep(data->metadata, __copy_metadata, &ret);
1266 LOGE("memory alloc failed");
1267 pkgmgrinfo_basic_free_application(app_info);
1268 return PMINFO_R_ERROR;
1272 app_info->datacontrol = g_list_copy_deep(data->datacontrol, __copy_datacontrol, &ret);
1274 LOGE("memory alloc failed");
1275 pkgmgrinfo_basic_free_application(app_info);
1276 return PMINFO_R_ERROR;
1280 app_info->appcontrol = g_list_copy_deep(data->appcontrol, __copy_appcontrol, &ret);
1282 LOGE("memory alloc failed");
1283 pkgmgrinfo_basic_free_application(app_info);
1284 return PMINFO_R_ERROR;
1288 app_info->background_category = g_list_copy_deep(data->background_category, __copy_str, &ret);
1290 LOGE("memory alloc failed");
1291 pkgmgrinfo_basic_free_application(app_info);
1292 return PMINFO_R_ERROR;
1296 app_info->splashscreens = g_list_copy_deep(data->splashscreens, __copy_splashscreens, &ret);
1298 LOGE("memory alloc failed");
1299 pkgmgrinfo_basic_free_application(app_info);
1300 return PMINFO_R_ERROR;
1304 app_info->components = g_list_copy_deep(data->components,
1305 __copy_components, &ret);
1307 LOGE("memory alloc failed");
1308 pkgmgrinfo_basic_free_application(app_info);
1309 return PMINFO_R_ERROR;
1312 *application = app_info;
1317 API int pkgmgrinfo_appinfo_clone_appinfo(pkgmgrinfo_appinfo_h handle,
1318 pkgmgrinfo_appinfo_h *clone)
1320 pkgmgr_appinfo_x *info;
1321 pkgmgr_appinfo_x *temp = (pkgmgr_appinfo_x *)handle;
1324 return PMINFO_R_EINVAL;
1326 info = calloc(1, sizeof(pkgmgr_appinfo_x));
1328 LOGE("memory alloc failed");
1329 return PMINFO_R_ERROR;
1332 if (temp->package != NULL)
1333 info->package = strdup(temp->package);
1334 if (temp->locale != NULL)
1335 info->locale = strdup(temp->locale);
1337 info->app_component = temp->app_component;
1339 if (_appinfo_copy_appinfo(&info->app_info, temp->app_info) < 0) {
1340 LOGE("appinfo copy failed");
1342 free((void *)info->package);
1346 return PMINFO_R_ERROR;
1354 static int _appinfo_get_filtered_foreach_appinfo(uid_t uid,
1355 pkgmgrinfo_filter_x *filter, int flag, pkgmgrinfo_app_list_cb app_list_cb,
1361 pkgmgr_appinfo_x info;
1363 GHashTableIter iter;
1366 locale = _get_system_locale();
1368 return PMINFO_R_ERROR;
1370 list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
1371 __free_applications);
1374 return PMINFO_R_ERROR;
1377 ret = _appinfo_get_applications(uid, uid, locale, filter,
1378 flag | PMINFO_APPINFO_GET_BASICINFO, list);
1379 if (ret == PMINFO_R_OK && uid != GLOBAL_USER)
1380 ret = _appinfo_get_applications(GLOBAL_USER, uid, locale,
1381 filter, flag | PMINFO_APPINFO_GET_BASICINFO, list);
1383 if (ret != PMINFO_R_OK) {
1384 g_hash_table_destroy(list);
1389 g_hash_table_iter_init(&iter, list);
1390 while (g_hash_table_iter_next(&iter, NULL, &value)) {
1391 app = (application_x *)value;
1392 info.app_info = app;
1393 info.locale = locale;
1394 info.package = app->package;
1395 if (app_list_cb(&info, user_data) < 0)
1398 g_hash_table_destroy(list);
1404 static const char *__appcomponent_str(pkgmgrinfo_app_component comp);
1406 API int pkgmgrinfo_appinfo_get_usr_list(pkgmgrinfo_pkginfo_h handle,
1407 pkgmgrinfo_app_component component,
1408 pkgmgrinfo_app_list_cb app_func, void *user_data, uid_t uid)
1411 pkgmgrinfo_appinfo_filter_h filter;
1413 const char *comp_str = NULL;
1415 if (handle == NULL || app_func == NULL) {
1416 LOGE("invalid parameter");
1417 return PMINFO_R_EINVAL;
1420 if (pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid)) {
1421 LOGE("invalid parameter");
1422 return PMINFO_R_EINVAL;
1425 if (pkgmgrinfo_appinfo_filter_create(&filter))
1426 return PMINFO_R_ERROR;
1428 if (pkgmgrinfo_appinfo_filter_add_string(filter,
1429 PMINFO_APPINFO_PROP_APP_PACKAGE, pkgid)) {
1430 pkgmgrinfo_appinfo_filter_destroy(filter);
1431 return PMINFO_R_ERROR;
1434 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
1435 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
1436 pkgmgrinfo_appinfo_filter_destroy(filter);
1437 return PMINFO_R_ERROR;
1440 comp_str = __appcomponent_str(component);
1443 if (pkgmgrinfo_appinfo_filter_add_string(filter,
1444 PMINFO_APPINFO_PROP_APP_COMPONENT,
1446 pkgmgrinfo_appinfo_filter_destroy(filter);
1447 return PMINFO_R_ERROR;
1451 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter,
1452 PMINFO_APPINFO_GET_ALL, app_func, user_data);
1454 pkgmgrinfo_appinfo_filter_destroy(filter);
1459 API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle,
1460 pkgmgrinfo_app_component component,
1461 pkgmgrinfo_app_list_cb app_func, void *user_data)
1463 return pkgmgrinfo_appinfo_get_usr_list(handle, component, app_func, user_data, _getuid());
1466 API int pkgmgrinfo_appinfo_get_usr_installed_list_full(
1467 pkgmgrinfo_app_list_cb app_func, uid_t uid, int flag,
1471 pkgmgrinfo_appinfo_filter_h filter;
1473 if (app_func == NULL) {
1474 LOGE("invalid parameter");
1475 return PMINFO_R_EINVAL;
1478 if (pkgmgrinfo_appinfo_filter_create(&filter))
1479 return PMINFO_R_ERROR;
1481 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
1482 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
1483 pkgmgrinfo_appinfo_filter_destroy(filter);
1484 return PMINFO_R_ERROR;
1487 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
1488 PMINFO_APPINFO_PROP_PKG_DISABLE, false)) {
1489 pkgmgrinfo_appinfo_filter_destroy(filter);
1490 return PMINFO_R_ERROR;
1493 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
1494 PMINFO_APPINFO_PROP_APP_CHECK_STORAGE, false)) {
1495 pkgmgrinfo_appinfo_filter_destroy(filter);
1496 return PMINFO_R_ERROR;
1499 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter, flag, app_func,
1502 pkgmgrinfo_appinfo_filter_destroy(filter);
1507 API int pkgmgrinfo_appinfo_get_installed_list_full(
1508 pkgmgrinfo_app_list_cb app_func, int flag, void *user_data)
1510 return pkgmgrinfo_appinfo_get_usr_installed_list_full(app_func,
1511 _getuid(), flag, user_data);
1514 API int pkgmgrinfo_appinfo_get_usr_installed_list(
1515 pkgmgrinfo_app_list_cb app_func, uid_t uid, void *user_data)
1518 pkgmgrinfo_appinfo_filter_h filter;
1520 if (app_func == NULL) {
1521 LOGE("invalid parameter");
1522 return PMINFO_R_EINVAL;
1525 /* create an empty filter */
1526 ret = pkgmgrinfo_appinfo_filter_create(&filter);
1527 if (ret != PMINFO_R_OK)
1530 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
1531 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
1532 pkgmgrinfo_appinfo_filter_destroy(filter);
1533 return PMINFO_R_ERROR;
1536 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
1537 PMINFO_APPINFO_PROP_PKG_DISABLE, false)) {
1538 pkgmgrinfo_appinfo_filter_destroy(filter);
1539 return PMINFO_R_ERROR;
1542 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter,
1543 PMINFO_APPINFO_GET_ALL, app_func, user_data);
1545 pkgmgrinfo_appinfo_filter_destroy(filter);
1550 API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func,
1553 return pkgmgrinfo_appinfo_get_usr_installed_list(app_func, _getuid(),
1557 API int pkgmgrinfo_appinfo_get_appid(pkgmgrinfo_appinfo_h handle, char **appid)
1559 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1561 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1562 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1564 if (info->app_info == NULL || info->app_info->appid == NULL)
1565 return PMINFO_R_ERROR;
1566 *appid = (char *)info->app_info->appid;
1571 API int pkgmgrinfo_appinfo_get_pkgname(pkgmgrinfo_appinfo_h handle, char **pkg_name)
1573 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1575 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1576 retvm_if(pkg_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1578 if (info->package == NULL)
1579 return PMINFO_R_ERROR;
1581 *pkg_name = (char *)info->package;
1586 API int pkgmgrinfo_appinfo_get_pkgid(pkgmgrinfo_appinfo_h handle, char **pkgid)
1588 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1590 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1591 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1593 if (info->package == NULL)
1594 return PMINFO_R_ERROR;
1596 *pkgid = (char *)info->package;
1601 API int pkgmgrinfo_appinfo_get_pkgtype(pkgmgrinfo_appinfo_h handle, char **pkgtype)
1603 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1604 retvm_if(pkgtype == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1605 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1607 *pkgtype = (char *)info->app_info->package_type;
1612 API int pkgmgrinfo_appinfo_get_exec(pkgmgrinfo_appinfo_h handle, char **exec)
1614 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1616 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1617 retvm_if(exec == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1619 if (info->app_info == NULL || info->app_info->exec == NULL)
1620 return PMINFO_R_ERROR;
1621 *exec = (char *)info->app_info->exec;
1627 API int pkgmgrinfo_appinfo_get_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1630 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1632 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1633 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1635 if (info->app_info == NULL)
1636 return PMINFO_R_ERROR;
1638 if (info->app_info->icon == NULL) {
1643 ptr = (icon_x *)info->app_info->icon->data;
1645 return PMINFO_R_ERROR;
1647 if (ptr->text == NULL)
1648 return PMINFO_R_ERROR;
1656 API int pkgmgrinfo_appinfo_get_label(pkgmgrinfo_appinfo_h handle, char **label)
1659 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1664 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1665 retvm_if(label == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1667 if (info->app_info == NULL)
1668 return PMINFO_R_ERROR;
1670 locale = info->locale;
1672 locale = DEFAULT_LOCALE;
1674 for (tmp = info->app_info->label; tmp; tmp = tmp->next) {
1675 ptr = (label_x *)tmp->data;
1676 if (ptr == NULL || strcmp(locale, ptr->lang) != 0)
1687 for (tmp = info->app_info->label; tmp; tmp = tmp->next) {
1688 ptr = (label_x *)tmp->data;
1689 if (ptr == NULL || strcmp(DEFAULT_LOCALE, ptr->lang) != 0)
1695 *label = lbl ? lbl : "";
1700 static char *_get_localed_label(const char *appid, const char *locale, uid_t uid)
1702 char *result = NULL;
1704 sqlite3_stmt *stmt = NULL;
1709 parser_db = getUserPkgParserDBPathUID(uid);
1710 if (parser_db == NULL) {
1711 _LOGE("Failed to get parser db path");
1715 if (__open_db(parser_db, &db, SQLITE_OPEN_READONLY) != SQLITE_OK) {
1716 _LOGE("DB open fail\n");
1722 query = sqlite3_mprintf("select app_label from package_app_localized_info where app_id=%Q and app_locale=%Q", appid, locale);
1723 if (query == NULL) {
1724 _LOGE("Out of memory");
1728 if (sqlite3_prepare_v2(db, query, -1, &stmt, NULL) != SQLITE_OK) {
1729 _LOGE("prepare_v2 fail\n");
1733 if (sqlite3_step(stmt) == SQLITE_ROW) {
1734 val = (char *)sqlite3_column_text(stmt, 0);
1736 result = strdup(val);
1740 sqlite3_finalize(stmt);
1741 sqlite3_free(query);
1747 API int pkgmgrinfo_appinfo_usr_get_localed_label(const char *appid, const char *locale, uid_t uid, char **label)
1751 retvm_if(appid == NULL || locale == NULL || label == NULL, PMINFO_R_EINVAL, "Argument is NULL");
1753 val = _get_localed_label(appid, locale, uid);
1755 val = _get_localed_label(appid, DEFAULT_LOCALE, uid);
1758 val = _get_localed_label(appid, locale, GLOBAL_USER);
1760 val = _get_localed_label(appid, DEFAULT_LOCALE, GLOBAL_USER);
1764 return PMINFO_R_ERROR;
1771 API int pkgmgrinfo_appinfo_get_localed_label(const char *appid, const char *locale, char **label)
1773 return pkgmgrinfo_appinfo_usr_get_localed_label(appid, locale, _getuid(), label);
1776 API int pkgmgrinfo_appinfo_get_metadata_value(pkgmgrinfo_appinfo_h handle, const char *metadata_key, char **metadata_value)
1778 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1779 retvm_if(metadata_key == NULL, PMINFO_R_EINVAL, "metadata_key is NULL");
1780 retvm_if(metadata_value == NULL, PMINFO_R_EINVAL, "metadata_value is NULL");
1782 GList *list_md = NULL;
1783 metadata_x *metadata = NULL;
1784 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1786 list_md = info->app_info->metadata;
1788 for (; list_md; list_md = list_md->next) {
1789 metadata = (metadata_x *)list_md->data;
1790 if (metadata && metadata->key) {
1791 if (strcasecmp(metadata->key, metadata_key) == 0) {
1792 if (metadata->value == NULL)
1793 *metadata_value = "";
1795 *metadata_value = (char *)metadata->value;
1801 return PMINFO_R_EINVAL;
1804 static pkgmgrinfo_app_component __appcomponent_convert(const char *comp)
1806 if (strcasecmp(comp, "uiapp") == 0)
1807 return PMINFO_UI_APP;
1808 else if (strcasecmp(comp, "svcapp") == 0)
1809 return PMINFO_SVC_APP;
1810 else if (strcasecmp(comp, "widgetapp") == 0)
1811 return PMINFO_WIDGET_APP;
1812 else if (strcasecmp(comp, "watchapp") == 0)
1813 return PMINFO_WATCH_APP;
1814 else if (strcasecmp(comp, "componentbasedapp") == 0)
1815 return PMINFO_COMPONENT_BASED_APP;
1820 static const char *__appcomponent_str(pkgmgrinfo_app_component comp)
1825 case PMINFO_SVC_APP:
1827 case PMINFO_WIDGET_APP:
1829 case PMINFO_WATCH_APP:
1831 case PMINFO_COMPONENT_BASED_APP:
1832 return "componentbasedapp";
1838 API int pkgmgrinfo_appinfo_get_component(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_component *component)
1840 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1843 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1844 retvm_if(component == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1846 if (info->app_info == NULL)
1847 return PMINFO_R_ERROR;
1849 comp = __appcomponent_convert(info->app_info->component);
1851 return PMINFO_R_ERROR;
1858 API int pkgmgrinfo_appinfo_get_apptype(pkgmgrinfo_appinfo_h handle, char **app_type)
1860 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1862 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1863 retvm_if(app_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1865 if (info->app_info == NULL || info->app_info->type == NULL)
1866 return PMINFO_R_ERROR;
1867 *app_type = (char *)info->app_info->type;
1872 API int pkgmgrinfo_appinfo_get_operation(pkgmgrinfo_appcontrol_h handle,
1873 int *operation_count, char ***operation)
1875 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1876 retvm_if(operation == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1877 retvm_if(operation_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1878 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1879 *operation_count = data->operation_count;
1880 *operation = data->operation;
1884 API int pkgmgrinfo_appinfo_get_uri(pkgmgrinfo_appcontrol_h handle,
1885 int *uri_count, char ***uri)
1887 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1888 retvm_if(uri == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1889 retvm_if(uri_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1890 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1891 *uri_count = data->uri_count;
1896 API int pkgmgrinfo_appinfo_get_mime(pkgmgrinfo_appcontrol_h handle,
1897 int *mime_count, char ***mime)
1899 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1900 retvm_if(mime == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1901 retvm_if(mime_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1902 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1903 *mime_count = data->mime_count;
1908 API int pkgmgrinfo_appinfo_get_subapp(pkgmgrinfo_appcontrol_h handle,
1909 int *subapp_count, char ***subapp)
1911 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1912 retvm_if(subapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1913 retvm_if(subapp_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1914 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1915 *subapp_count = data->subapp_count;
1916 *subapp = data->subapp;
1920 API int pkgmgrinfo_appinfo_get_notification_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1925 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1927 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1928 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1930 if (info->app_info == NULL)
1931 return PMINFO_R_ERROR;
1933 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1934 ptr = (icon_x *)tmp->data;
1935 if (ptr == NULL || ptr->section == NULL)
1938 val = (char *)ptr->section;
1939 if (val && strcmp(val, "notification") == 0) {
1940 *icon = (char *)ptr->text;
1945 return PMINFO_R_ERROR;
1948 API int pkgmgrinfo_appinfo_get_recent_image_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_recentimage *type)
1951 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1953 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1954 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1956 if (info->app_info == NULL || info->app_info->recentimage == NULL)
1957 return PMINFO_R_ERROR;
1959 val = (char *)info->app_info->recentimage;
1960 if (strcasecmp(val, "capture") == 0)
1961 *type = PMINFO_RECENTIMAGE_USE_CAPTURE;
1962 else if (strcasecmp(val, "icon") == 0)
1963 *type = PMINFO_RECENTIMAGE_USE_ICON;
1965 *type = PMINFO_RECENTIMAGE_USE_NOTHING;
1970 API int pkgmgrinfo_appinfo_get_preview_image(pkgmgrinfo_appinfo_h handle, char **preview_img)
1975 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1977 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1978 retvm_if(preview_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1980 if (info->app_info == NULL)
1981 return PMINFO_R_ERROR;
1983 for (tmp = info->app_info->image; tmp; tmp = tmp->next) {
1984 ptr = (image_x *)tmp->data;
1985 if (ptr == NULL || ptr->section == NULL)
1988 val = (char *)ptr->section;
1989 if (val && strcmp(val, "preview") == 0) {
1990 *preview_img = (char *)ptr->text;
1995 return PMINFO_R_ERROR;
1998 API int pkgmgrinfo_appinfo_get_permission_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_permission_type *permission)
2001 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2003 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2004 retvm_if(permission == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2006 val = info->app_info->permission_type;
2008 return PMINFO_R_ERROR;
2010 if (strcmp(val, "signature") == 0)
2011 *permission = PMINFO_PERMISSION_SIGNATURE;
2012 else if (strcmp(val, "privilege") == 0)
2013 *permission = PMINFO_PERMISSION_PRIVILEGE;
2015 *permission = PMINFO_PERMISSION_NORMAL;
2020 API int pkgmgrinfo_appinfo_get_component_type(pkgmgrinfo_appinfo_h handle, char **component_type)
2022 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2024 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2025 retvm_if(component_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2027 if (info->app_info == NULL || info->app_info->component_type == NULL)
2028 return PMINFO_R_ERROR;
2030 *component_type = (char *)info->app_info->component_type;
2035 API int pkgmgrinfo_appinfo_get_hwacceleration(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_hwacceleration *hwacceleration)
2038 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2040 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2041 retvm_if(hwacceleration == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2043 if (info->app_info == NULL || info->app_info->hwacceleration == NULL)
2044 return PMINFO_R_ERROR;
2046 val = (char *)info->app_info->hwacceleration;
2047 if (strcasecmp(val, "off") == 0)
2048 *hwacceleration = PMINFO_HWACCELERATION_OFF;
2049 else if (strcasecmp(val, "on") == 0)
2050 *hwacceleration = PMINFO_HWACCELERATION_ON;
2052 *hwacceleration = PMINFO_HWACCELERATION_DEFAULT;
2057 API int pkgmgrinfo_appinfo_get_screenreader(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_screenreader *screenreader)
2060 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2062 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2063 retvm_if(screenreader == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2065 if (info->app_info == NULL || info->app_info->screenreader == NULL)
2066 return PMINFO_R_ERROR;
2068 val = (char *)info->app_info->screenreader;
2069 if (strcasecmp(val, "screenreader-off") == 0)
2070 *screenreader = PMINFO_SCREENREADER_OFF;
2071 else if (strcasecmp(val, "screenreader-on") == 0)
2072 *screenreader = PMINFO_SCREENREADER_ON;
2074 *screenreader = PMINFO_SCREENREADER_USE_SYSTEM_SETTING;
2079 API int pkgmgrinfo_appinfo_get_effectimage(pkgmgrinfo_appinfo_h handle, char **portrait_img, char **landscape_img)
2081 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2083 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2084 retvm_if(portrait_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2085 retvm_if(landscape_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2087 if (info->app_info == NULL)
2088 return PMINFO_R_ERROR;
2090 if (info->app_info->portraitimg == NULL)
2093 *portrait_img = (char *)info->app_info->portraitimg;
2095 if (info->app_info->landscapeimg == NULL)
2096 *landscape_img = "";
2098 *landscape_img = (char *)info->app_info->landscapeimg;
2103 API int pkgmgrinfo_appinfo_get_effectimage_type(pkgmgrinfo_appinfo_h handle, char **effectimage_type)
2105 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2107 if (handle == NULL || effectimage_type == NULL) {
2108 LOGE("invalid parameter");
2109 return PMINFO_R_EINVAL;
2112 if (info->app_info == NULL || info->app_info->effectimage_type == NULL)
2113 return PMINFO_R_ERROR;
2115 *effectimage_type = (char *)info->app_info->effectimage_type;
2120 API int pkgmgrinfo_appinfo_get_submode_mainid(pkgmgrinfo_appinfo_h handle, char **submode_mainid)
2122 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2124 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2125 retvm_if(submode_mainid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2127 if (info->app_info == NULL)
2128 return PMINFO_R_ERROR;
2130 if (info->app_info->submode_mainid == NULL)
2131 *submode_mainid = "";
2133 *submode_mainid = (char *)info->app_info->submode_mainid;
2138 API int pkgmgrinfo_appinfo_get_installed_storage_location(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_installed_storage *storage)
2140 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2141 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2143 if (info->app_info && info->app_info->installed_storage) {
2144 if (strcmp(info->app_info->installed_storage, "installed_internal") == 0)
2145 *storage = PMINFO_INTERNAL_STORAGE;
2146 else if (strcmp(info->app_info->installed_storage, "installed_external") == 0)
2147 *storage = PMINFO_EXTERNAL_STORAGE;
2149 return PMINFO_R_ERROR;
2151 return PMINFO_R_ERROR;
2157 API int pkgmgrinfo_appinfo_get_launch_mode(pkgmgrinfo_appinfo_h handle, char **mode)
2159 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2161 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2162 retvm_if(mode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2164 if (info->app_info->launch_mode == NULL)
2165 return PMINFO_R_ERROR;
2167 *mode = (char *)(info->app_info->launch_mode);
2172 API int pkgmgrinfo_appinfo_get_alias_appid(pkgmgrinfo_appinfo_h handle, char **alias_appid)
2174 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2176 if (handle == NULL || alias_appid == NULL) {
2177 LOGE("invalid parameter");
2178 return PMINFO_R_EINVAL;
2181 if (info->app_info == NULL || info->app_info->alias_appid == NULL)
2182 return PMINFO_R_ERROR;
2184 *alias_appid = (char *)info->app_info->alias_appid;
2189 API int pkgmgrinfo_appinfo_get_effective_appid(pkgmgrinfo_appinfo_h handle, char **effective_appid)
2191 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2193 if (handle == NULL || effective_appid == NULL) {
2194 LOGE("invalid parameter");
2195 return PMINFO_R_EINVAL;
2198 if (info->app_info == NULL)
2199 return PMINFO_R_ERROR;
2201 if (info->app_info->effective_appid == NULL)
2202 *effective_appid = "";
2204 *effective_appid = (char *)info->app_info->effective_appid;
2209 API int pkgmgrinfo_appinfo_get_tep_name(pkgmgrinfo_appinfo_h handle, char **tep_name)
2211 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2213 if (handle == NULL || tep_name == NULL) {
2214 LOGE("invalid parameter");
2215 return PMINFO_R_EINVAL;
2218 if (info->app_info == NULL)
2219 return PMINFO_R_ERROR;
2221 if (info->app_info->tep_name == NULL)
2224 *tep_name = (char *)info->app_info->tep_name;
2229 API int pkgmgrinfo_appinfo_get_zip_mount_file(pkgmgrinfo_appinfo_h handle, char **zip_mount_file)
2231 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2233 if (handle == NULL || zip_mount_file == NULL) {
2234 LOGE("invalid parameter");
2235 return PMINFO_R_EINVAL;
2238 if (info->app_info == NULL)
2239 return PMINFO_R_ERROR;
2241 if (info->app_info->zip_mount_file == NULL)
2242 *zip_mount_file = "";
2244 *zip_mount_file = (char *)info->app_info->zip_mount_file;
2249 API int pkgmgrinfo_appinfo_get_root_path(pkgmgrinfo_appinfo_h handle, char **root_path)
2251 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2253 if (handle == NULL || root_path == NULL) {
2254 LOGE("invalid parameter");
2255 return PMINFO_R_EINVAL;
2258 if (info->app_info == NULL || info->app_info->root_path == NULL)
2259 return PMINFO_R_ERROR;
2261 *root_path = (char *)info->app_info->root_path;
2266 API int pkgmgrinfo_appinfo_get_api_version(pkgmgrinfo_appinfo_h handle, char **api_version)
2268 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2270 if (handle == NULL || api_version == NULL) {
2271 LOGE("invalid parameter");
2272 return PMINFO_R_EINVAL;
2275 if (info->app_info == NULL || info->app_info->api_version == NULL)
2276 return PMINFO_R_ERROR;
2278 *api_version = (char *)info->app_info->api_version;
2283 API int pkgmgrinfo_appinfo_get_installed_time(pkgmgrinfo_appinfo_h handle, int *installed_time)
2285 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2287 if (handle == NULL || installed_time == NULL) {
2288 LOGE("invalid parameter");
2289 return PMINFO_R_EINVAL;
2292 if (info->app_info == NULL || info->app_info->package_installed_time == NULL)
2293 return PMINFO_R_ERROR;
2295 *installed_time = atoi(info->app_info->package_installed_time);
2300 static int _appinfo_get_datacontrol_info(sqlite3 *db, const char *providerid,
2301 const char *type, char **appid, char **access)
2303 static const char query[] =
2304 "SELECT app_id, access FROM package_app_data_control "
2305 "WHERE providerid=? AND type=?";
2309 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
2310 if (ret != SQLITE_OK) {
2311 LOGE("prepare failed: %s", sqlite3_errmsg(db));
2312 return PMINFO_R_ERROR;
2315 ret = sqlite3_bind_text(stmt, 1, providerid, -1, SQLITE_STATIC);
2316 if (ret != SQLITE_OK) {
2317 LOGE("bind failed: %s", sqlite3_errmsg(db));
2318 sqlite3_finalize(stmt);
2319 return PMINFO_R_ERROR;
2322 ret = sqlite3_bind_text(stmt, 2, type, -1, SQLITE_STATIC);
2323 if (ret != SQLITE_OK) {
2324 LOGE("bind failed: %s", sqlite3_errmsg(db));
2325 sqlite3_finalize(stmt);
2326 return PMINFO_R_ERROR;
2329 ret = sqlite3_step(stmt);
2330 if (ret != SQLITE_ROW) {
2331 sqlite3_finalize(stmt);
2332 if (ret == SQLITE_DONE) {
2333 return PMINFO_R_ENOENT;
2335 LOGE("step error: %s", sqlite3_errmsg(db));
2336 return PMINFO_R_ERROR;
2340 *appid = strdup((char *)sqlite3_column_text(stmt, 0));
2341 if (*appid == NULL) {
2342 LOGE("out of memory");
2343 sqlite3_finalize(stmt);
2344 return PMINFO_R_ERROR;
2346 *access = strdup((char *)sqlite3_column_text(stmt, 1));
2347 if (*access == NULL) {
2348 LOGE("out of memory");
2350 sqlite3_finalize(stmt);
2351 return PMINFO_R_ERROR;
2354 sqlite3_finalize(stmt);
2359 static int _pkgmgrinfo_appinfo_get_datacontrol_info(uid_t uid,
2360 const char *providerid, const char *type,
2361 char **appid, char **access)
2367 dbpath = getUserPkgParserDBPathUID(GLOBAL_USER);
2369 return PMINFO_R_ERROR;
2371 ret = __open_db(dbpath, &db, SQLITE_OPEN_READONLY);
2373 if (ret != SQLITE_OK) {
2374 LOGE("open db failed: %s", sqlite3_errmsg(db));
2375 return PMINFO_R_ERROR;
2378 ret = _appinfo_get_datacontrol_info(db, providerid, type, appid,
2380 sqlite3_close_v2(db);
2385 API int pkgmgrinfo_appinfo_usr_get_datacontrol_info(const char *providerid,
2386 const char *type, uid_t uid, char **appid, char **access)
2390 if (providerid == NULL || type == NULL || appid == NULL ||
2392 LOGE("invalid parameter");
2393 return PMINFO_R_EINVAL;
2396 ret = _pkgmgrinfo_appinfo_get_datacontrol_info(GLOBAL_USER, providerid,
2397 type, appid, access);
2398 if (ret == PMINFO_R_ENOENT && uid != GLOBAL_USER)
2399 ret = _pkgmgrinfo_appinfo_get_datacontrol_info(uid, providerid,
2400 type, appid, access);
2402 /* FIXME: It should return PMINFO_R_ENOENT but to keep previous
2403 * implementation, return PMINFO_R_ERROR. This should be
2406 if (ret == PMINFO_R_ENOENT) {
2407 LOGE("no datacontrol info of %s", providerid);
2408 ret = PMINFO_R_ERROR;
2414 API int pkgmgrinfo_appinfo_get_datacontrol_info(const char *providerid,
2415 const char *type, char **appid, char **access)
2417 return pkgmgrinfo_appinfo_usr_get_datacontrol_info(providerid,
2418 type, _getuid(), appid, access);
2421 static int _appinfo_get_datacontrol_appid(sqlite3 *db, const char *providerid,
2424 static const char query[] =
2425 "SELECT app_id FROM package_app_data_control "
2426 "WHERE providerid=?";
2430 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
2431 if (ret != SQLITE_OK) {
2432 LOGE("prepare failed: %s", sqlite3_errmsg(db));
2433 return PMINFO_R_ERROR;
2436 ret = sqlite3_bind_text(stmt, 1, providerid, -1, SQLITE_STATIC);
2437 if (ret != SQLITE_OK) {
2438 LOGE("bind failed: %s", sqlite3_errmsg(db));
2439 sqlite3_finalize(stmt);
2440 return PMINFO_R_ERROR;
2443 ret = sqlite3_step(stmt);
2444 if (ret != SQLITE_ROW) {
2445 sqlite3_finalize(stmt);
2446 if (ret == SQLITE_DONE) {
2447 return PMINFO_R_ENOENT;
2449 LOGE("step error: %s", sqlite3_errmsg(db));
2450 return PMINFO_R_ERROR;
2454 *appid = strdup((char *)sqlite3_column_text(stmt, 0));
2456 sqlite3_finalize(stmt);
2458 if (*appid == NULL) {
2459 LOGE("out of memory");
2460 return PMINFO_R_ERROR;
2466 static int _pkgmgrinfo_appinfo_get_datacontrol_appid(uid_t uid,
2467 const char *providerid, char **appid)
2473 dbpath = getUserPkgParserDBPathUID(GLOBAL_USER);
2475 return PMINFO_R_ERROR;
2477 ret = __open_db(dbpath, &db, SQLITE_OPEN_READONLY);
2479 if (ret != SQLITE_OK) {
2480 LOGE("open db failed: %s", sqlite3_errmsg(db));
2481 return PMINFO_R_ERROR;
2484 ret = _appinfo_get_datacontrol_appid(db, providerid, appid);
2485 sqlite3_close_v2(db);
2490 API int pkgmgrinfo_appinfo_usr_get_datacontrol_appid(const char *providerid,
2491 uid_t uid, char **appid)
2495 if (providerid == NULL || appid == NULL) {
2496 LOGE("invalid parameter");
2497 return PMINFO_R_EINVAL;
2500 ret = _pkgmgrinfo_appinfo_get_datacontrol_appid(GLOBAL_USER, providerid,
2502 if (ret == PMINFO_R_ENOENT && uid != GLOBAL_USER)
2503 ret = _pkgmgrinfo_appinfo_get_datacontrol_appid(uid, providerid,
2506 /* FIXME: It should return PMINFO_R_ENOENT but to keep previous
2507 * implementation, return PMINFO_R_ERROR. This should be
2510 if (ret == PMINFO_R_ENOENT) {
2511 LOGE("no datacontrol appid of %s", providerid);
2512 ret = PMINFO_R_ERROR;
2518 API int pkgmgrinfo_appinfo_get_datacontrol_appid(const char *providerid, char **appid)
2520 return pkgmgrinfo_appinfo_usr_get_datacontrol_appid(providerid, _getuid(), appid);
2523 static int _appinfo_get_datacontrol_trusted_info(sqlite3 *db,
2524 const char *providerid, const char *type, char **appid,
2527 static const char query[] =
2528 "SELECT app_id, trusted FROM package_app_data_control "
2529 "WHERE providerid=? AND type=?";
2533 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
2534 if (ret != SQLITE_OK) {
2535 LOGE("prepare failed: %s", sqlite3_errmsg(db));
2536 return PMINFO_R_ERROR;
2539 ret = sqlite3_bind_text(stmt, 1, providerid, -1, SQLITE_STATIC);
2540 if (ret != SQLITE_OK) {
2541 LOGE("bind failed: %s", sqlite3_errmsg(db));
2542 sqlite3_finalize(stmt);
2543 return PMINFO_R_ERROR;
2546 ret = sqlite3_bind_text(stmt, 2, type, -1, SQLITE_STATIC);
2547 if (ret != SQLITE_OK) {
2548 LOGE("bind failed: %s", sqlite3_errmsg(db));
2549 sqlite3_finalize(stmt);
2550 return PMINFO_R_ERROR;
2553 ret = sqlite3_step(stmt);
2554 if (ret != SQLITE_ROW) {
2555 sqlite3_finalize(stmt);
2556 if (ret == SQLITE_DONE) {
2557 return PMINFO_R_ENOENT;
2559 LOGE("step error: %s", sqlite3_errmsg(db));
2560 return PMINFO_R_ERROR;
2564 *appid = strdup((char *)sqlite3_column_text(stmt, 0));
2565 *is_trusted = _get_bool_value((char *)sqlite3_column_text(stmt, 1));
2567 sqlite3_finalize(stmt);
2569 if (*appid == NULL) {
2570 LOGE("out of memory");
2571 return PMINFO_R_ERROR;
2577 static int _pkgmgrinfo_appinfo_get_datacontrol_trusted_info(uid_t uid,
2578 const char *providerid, const char *type, char **appid,
2585 dbpath = getUserPkgParserDBPathUID(GLOBAL_USER);
2587 return PMINFO_R_ERROR;
2589 ret = __open_db(dbpath, &db, SQLITE_OPEN_READONLY);
2591 if (ret != SQLITE_OK) {
2592 LOGE("open db failed: %s", sqlite3_errmsg(db));
2593 return PMINFO_R_ERROR;
2596 ret = _appinfo_get_datacontrol_trusted_info(db, providerid, type, appid,
2598 sqlite3_close_v2(db);
2603 API int pkgmgrinfo_appinfo_usr_get_datacontrol_trusted_info(
2604 const char *providerid, const char *type, uid_t uid,
2605 char **appid, bool *is_trusted)
2609 if (providerid == NULL || type == NULL || appid == NULL ||
2610 is_trusted == NULL) {
2611 LOGE("invalid parameter");
2612 return PMINFO_R_EINVAL;
2615 ret = _pkgmgrinfo_appinfo_get_datacontrol_trusted_info(GLOBAL_USER,
2616 providerid, type, appid, is_trusted);
2617 if (ret == PMINFO_R_ENOENT && uid != GLOBAL_USER)
2618 ret = _pkgmgrinfo_appinfo_get_datacontrol_trusted_info(uid,
2619 providerid, type, appid, is_trusted);
2621 /* FIXME: It should return PMINFO_R_ENOENT but to keep previous
2622 * implementation, return PMINFO_R_ERROR. This should be
2625 if (ret == PMINFO_R_ENOENT) {
2626 LOGE("no datacontrol trusted info of %s", providerid);
2627 ret = PMINFO_R_ERROR;
2633 API int pkgmgrinfo_appinfo_get_datacontrol_trsuted_info(const char *providerid,
2634 const char *type, char **appid, bool *is_trusted)
2636 return pkgmgrinfo_appinfo_usr_get_datacontrol_trusted_info(providerid,
2637 type, _getuid(), appid, is_trusted);
2640 static int _appinfo_foreach_datacontrol_privileges(sqlite3 *db,
2641 const char *providerid, const char *type,
2642 pkgmgrinfo_pkg_privilege_list_cb callback, void *user_data)
2644 static const char query[] =
2645 "SELECT privilege FROM package_app_data_control_privilege "
2646 "WHERE providerid=? AND type=?";
2651 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
2652 if (ret != SQLITE_OK) {
2653 LOGE("prepare failed: %s", sqlite3_errmsg(db));
2654 return PMINFO_R_ERROR;
2657 ret = sqlite3_bind_text(stmt, 1, providerid, -1, SQLITE_STATIC);
2658 if (ret != SQLITE_OK) {
2659 LOGE("bind failed: %s", sqlite3_errmsg(db));
2660 sqlite3_finalize(stmt);
2661 return PMINFO_R_ERROR;
2664 ret = sqlite3_bind_text(stmt, 2, type, -1, SQLITE_STATIC);
2665 if (ret != SQLITE_OK) {
2666 LOGE("bind failed: %s", sqlite3_errmsg(db));
2667 sqlite3_finalize(stmt);
2668 return PMINFO_R_ERROR;
2671 while (sqlite3_step(stmt) == SQLITE_ROW) {
2673 ret = callback((const char *)sqlite3_column_text(stmt, 0),
2679 sqlite3_finalize(stmt);
2681 return count ? PMINFO_R_OK : PMINFO_R_ENOENT;
2684 static int _pkgmgrinfo_appinfo_foreach_datacontrol_privileges(uid_t uid,
2685 const char *providerid, const char *type,
2686 pkgmgrinfo_pkg_privilege_list_cb callback, void *user_data)
2692 dbpath = getUserPkgParserDBPathUID(GLOBAL_USER);
2694 return PMINFO_R_ERROR;
2696 ret = __open_db(dbpath, &db, SQLITE_OPEN_READONLY);
2698 if (ret != SQLITE_OK) {
2699 LOGE("open db failed: %s", sqlite3_errmsg(db));
2700 return PMINFO_R_ERROR;
2703 ret = _appinfo_foreach_datacontrol_privileges(db, providerid, type,
2704 callback, user_data);
2705 sqlite3_close_v2(db);
2710 API int pkgmgrinfo_appinfo_usr_foreach_datacontrol_privileges(
2711 const char *providerid, const char *type,
2712 pkgmgrinfo_pkg_privilege_list_cb privilege_func,
2713 void *user_data, uid_t uid)
2717 if (providerid == NULL || type == NULL || privilege_func == NULL) {
2718 LOGE("invalid parameter");
2719 return PMINFO_R_EINVAL;
2722 ret = _pkgmgrinfo_appinfo_foreach_datacontrol_privileges(GLOBAL_USER,
2723 providerid, type, privilege_func, user_data);
2724 if (ret == PMINFO_R_ENOENT && uid != GLOBAL_USER)
2725 ret = _pkgmgrinfo_appinfo_foreach_datacontrol_privileges(uid,
2726 providerid, type, privilege_func, user_data);
2728 if (ret == PMINFO_R_ENOENT)
2734 API int pkgmgrinfo_appinfo_foreach_datacontrol_privileges(
2735 const char *providerid, const char *type,
2736 pkgmgrinfo_pkg_privilege_list_cb privilege_func,
2739 return pkgmgrinfo_appinfo_usr_foreach_datacontrol_privileges(
2740 providerid, type, privilege_func, user_data, _getuid());
2743 API int pkgmgrinfo_appinfo_get_support_mode(pkgmgrinfo_appinfo_h handle, int *support_mode)
2745 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2746 retvm_if(support_mode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2748 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2749 if (info->app_info->support_mode)
2750 *support_mode = atoi(info->app_info->support_mode);
2757 API int pkgmgrinfo_appinfo_foreach_category(pkgmgrinfo_appinfo_h handle,
2758 pkgmgrinfo_app_category_list_cb category_func, void *user_data)
2760 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2761 retvm_if(category_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2763 const char *category;
2765 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2767 if (info->app_info == NULL)
2768 return PMINFO_R_ERROR;
2770 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
2771 category = (const char *)tmp->data;
2773 ret = category_func(category, user_data);
2781 API int pkgmgrinfo_appinfo_foreach_metadata(pkgmgrinfo_appinfo_h handle,
2782 pkgmgrinfo_app_metadata_list_cb metadata_func, void *user_data)
2784 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2785 retvm_if(metadata_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2789 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2791 if (info->app_info == NULL)
2792 return PMINFO_R_ERROR;
2794 for (tmp = info->app_info->metadata; tmp; tmp = tmp->next) {
2795 ptr = (metadata_x *)tmp->data;
2799 ret = metadata_func(ptr->key, ptr->value ? ptr->value : "", user_data);
2807 static int _appinfo_foreach_appcontrol_privileges(sqlite3 *db,
2808 const char *appid, const char *operation,
2809 pkgmgrinfo_pkg_privilege_list_cb callback, void *user_data)
2811 static const char query[] =
2812 "SELECT app_control, privilege FROM package_app_app_control_privilege "
2816 const char *app_control;
2817 char *dup_app_control;
2819 char *saveptr = NULL;
2820 const char *privilege;
2823 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
2824 if (ret != SQLITE_OK) {
2825 LOGE("prepare failed: %s", sqlite3_errmsg(db));
2826 return PMINFO_R_ERROR;
2829 ret = sqlite3_bind_text(stmt, 1, appid, -1, SQLITE_STATIC);
2830 if (ret != SQLITE_OK) {
2831 LOGE("bind failed: %s", sqlite3_errmsg(db));
2832 sqlite3_finalize(stmt);
2833 return PMINFO_R_ERROR;
2836 while (sqlite3_step(stmt) == SQLITE_ROW) {
2837 app_control = (const char *)sqlite3_column_text(stmt, 0);
2841 dup_app_control = strdup(app_control);
2842 if (!dup_app_control)
2845 token = strtok_r(dup_app_control, "|", &saveptr);
2846 if (token && !strcmp(token, operation)) {
2848 privilege = (const char *)sqlite3_column_text(stmt, 1);
2849 ret = callback(privilege, user_data);
2851 free(dup_app_control);
2855 free(dup_app_control);
2858 sqlite3_finalize(stmt);
2860 return count ? PMINFO_R_OK : PMINFO_R_ENOENT;
2863 static int _pkgmgrinfo_appinfo_foreach_appcontrol_privileges(uid_t uid,
2864 const char *appid, const char *operation,
2865 pkgmgrinfo_pkg_privilege_list_cb callback, void *user_data)
2871 dbpath = getUserPkgParserDBPathUID(uid);
2873 return PMINFO_R_ERROR;
2875 ret = __open_db(dbpath, &db, SQLITE_OPEN_READONLY);
2877 if (ret != SQLITE_OK) {
2878 LOGE("open db failed: %s", sqlite3_errmsg(db));
2879 return PMINFO_R_ERROR;
2882 ret = _appinfo_foreach_appcontrol_privileges(db, appid, operation,
2883 callback, user_data);
2884 sqlite3_close_v2(db);
2889 API int pkgmgrinfo_appinfo_usr_foreach_appcontrol_privileges(const char *appid,
2890 const char *operation,
2891 pkgmgrinfo_pkg_privilege_list_cb privilege_func,
2892 void *user_data, uid_t uid)
2896 if (appid == NULL || operation == NULL || privilege_func == NULL) {
2897 LOGE("invalid parameter");
2898 return PMINFO_R_EINVAL;
2901 ret = _pkgmgrinfo_appinfo_foreach_appcontrol_privileges(GLOBAL_USER,
2902 appid, operation, privilege_func, user_data);
2903 if (ret == PMINFO_R_ENOENT && uid != GLOBAL_USER)
2904 ret = _pkgmgrinfo_appinfo_foreach_appcontrol_privileges(uid,
2905 appid, operation, privilege_func, user_data);
2907 if (ret == PMINFO_R_ENOENT)
2913 API int pkgmgrinfo_appinfo_foreach_appcontrol_privileges(const char *appid,
2914 const char *operation,
2915 pkgmgrinfo_pkg_privilege_list_cb privilege_func,
2918 return pkgmgrinfo_appinfo_usr_foreach_appcontrol_privileges(appid,
2919 operation, privilege_func, user_data, _getuid());
2922 API int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
2923 pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
2925 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2926 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2928 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2929 appcontrol_x *appcontrol;
2932 if (info->app_info == NULL)
2933 return PMINFO_R_ERROR;
2935 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
2936 appcontrol = (appcontrol_x *)tmp->data;
2937 if (appcontrol == NULL || !strcasecmp(appcontrol->visibility, "remote-only"))
2939 ret = appcontrol_func(appcontrol->operation, appcontrol->uri, appcontrol->mime, user_data);
2947 API int pkgmgrinfo_appinfo_foreach_remote_appcontrol(pkgmgrinfo_appinfo_h handle,
2948 pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
2950 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2951 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2953 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2954 appcontrol_x *appcontrol;
2957 if (info->app_info == NULL)
2958 return PMINFO_R_ERROR;
2960 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
2961 appcontrol = (appcontrol_x *)tmp->data;
2962 if (appcontrol == NULL || !strcasecmp(appcontrol->visibility, "local-only"))
2964 ret = appcontrol_func(appcontrol->operation, appcontrol->uri, appcontrol->mime, user_data);
2972 API int pkgmgrinfo_appinfo_foreach_background_category(
2973 pkgmgrinfo_appinfo_h handle,
2974 pkgmgrinfo_app_background_category_list_cb category_func,
2977 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2981 if (handle == NULL || category_func == NULL || info->app_info == NULL) {
2982 LOGE("invalid parameter");
2983 return PMINFO_R_EINVAL;
2986 for (tmp = info->app_info->background_category; tmp; tmp = tmp->next) {
2987 category = (char *)tmp->data;
2988 if (category == NULL)
2991 if (category_func(category, user_data) < 0)
2998 API int pkgmgrinfo_appinfo_foreach_splash_screen(pkgmgrinfo_appinfo_h handle,
2999 pkgmgrinfo_app_splash_screen_list_cb splash_screen_func,
3002 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3003 splashscreen_x *splashscreen;
3007 if (info == NULL || info->app_info == NULL
3008 || splash_screen_func == NULL) {
3009 LOGE("invalid parameter");
3010 return PMINFO_R_EINVAL;
3013 for (tmp = info->app_info->splashscreens; tmp; tmp = tmp->next) {
3014 splashscreen = (splashscreen_x *)tmp->data;
3015 if (splashscreen == NULL)
3017 ret = splash_screen_func(splashscreen->src,
3019 splashscreen->orientation,
3020 splashscreen->indicatordisplay,
3021 splashscreen->operation,
3022 splashscreen->color_depth,
3031 API int pkgmgrinfo_appinfo_is_nodisplay(pkgmgrinfo_appinfo_h handle, bool *nodisplay)
3033 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
3034 retvm_if(nodisplay == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
3035 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3037 if (info->app_info == NULL || info->app_info->nodisplay == NULL)
3038 return PMINFO_R_ERROR;
3040 *nodisplay = _get_bool_value(info->app_info->nodisplay);
3045 API int pkgmgrinfo_appinfo_is_multiple(pkgmgrinfo_appinfo_h handle, bool *multiple)
3047 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
3048 retvm_if(multiple == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
3049 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3051 if (info->app_info == NULL || info->app_info->multiple == NULL)
3052 return PMINFO_R_ERROR;
3054 *multiple = _get_bool_value(info->app_info->multiple);
3059 API int pkgmgrinfo_appinfo_is_indicator_display_allowed(pkgmgrinfo_appinfo_h handle, bool *indicator_disp)
3061 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
3062 retvm_if(indicator_disp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
3063 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3065 if (info->app_info == NULL || info->app_info->indicatordisplay == NULL)
3066 return PMINFO_R_ERROR;
3068 *indicator_disp = _get_bool_value(info->app_info->indicatordisplay);
3073 API int pkgmgrinfo_appinfo_is_taskmanage(pkgmgrinfo_appinfo_h handle, bool *taskmanage)
3075 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
3076 retvm_if(taskmanage == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
3077 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3079 if (info->app_info == NULL || info->app_info->taskmanage == NULL)
3080 return PMINFO_R_ERROR;
3082 *taskmanage = _get_bool_value(info->app_info->taskmanage);
3087 API int pkgmgrinfo_appinfo_is_enabled(pkgmgrinfo_appinfo_h handle, bool *enabled)
3089 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
3090 retvm_if(enabled == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
3091 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3093 if (info->app_info == NULL || info->app_info->is_disabled == NULL)
3094 return PMINFO_R_ERROR;
3096 *enabled = !_get_bool_value(info->app_info->is_disabled);
3101 API int pkgmgrinfo_appinfo_is_onboot(pkgmgrinfo_appinfo_h handle, bool *onboot)
3103 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
3104 retvm_if(onboot == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
3105 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3107 if (info->app_info == NULL || info->app_info->onboot == NULL)
3108 return PMINFO_R_ERROR;
3110 *onboot = _get_bool_value(info->app_info->onboot);
3115 API int pkgmgrinfo_appinfo_is_autorestart(pkgmgrinfo_appinfo_h handle, bool *autorestart)
3117 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
3118 retvm_if(autorestart == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
3119 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3121 if (info->app_info == NULL || info->app_info->autorestart == NULL)
3122 return PMINFO_R_ERROR;
3124 *autorestart = _get_bool_value(info->app_info->autorestart);
3129 API int pkgmgrinfo_appinfo_is_mainapp(pkgmgrinfo_appinfo_h handle, bool *mainapp)
3131 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
3132 retvm_if(mainapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
3133 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3135 if (info->app_info == NULL || info->app_info->mainapp == NULL)
3136 return PMINFO_R_ERROR;
3138 *mainapp = _get_bool_value(info->app_info->mainapp);
3143 API int pkgmgrinfo_appinfo_is_preload(pkgmgrinfo_appinfo_h handle, bool *preload)
3145 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
3146 retvm_if(preload == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3147 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3149 if (info->app_info == NULL || info->app_info->preload == NULL)
3150 return PMINFO_R_ERROR;
3152 *preload = _get_bool_value(info->app_info->preload);
3157 API int pkgmgrinfo_appinfo_is_submode(pkgmgrinfo_appinfo_h handle, bool *submode)
3159 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
3160 retvm_if(submode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3161 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3163 if (info->app_info == NULL || info->app_info->submode == NULL)
3164 return PMINFO_R_ERROR;
3166 *submode = _get_bool_value(info->app_info->submode);
3171 API int pkgmgrinfo_appinfo_is_process_pool(pkgmgrinfo_appinfo_h handle, bool *process_pool)
3173 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3175 if (handle == NULL || process_pool == NULL) {
3176 LOGE("invalid parameter");
3177 return PMINFO_R_EINVAL;
3180 if (info->app_info == NULL)
3181 return PMINFO_R_ERROR;
3183 *process_pool = _get_bool_value(info->app_info->process_pool);
3188 API int pkgmgrinfo_appinfo_is_category_exist(pkgmgrinfo_appinfo_h handle, const char *category, bool *exist)
3190 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
3191 retvm_if(category == NULL, PMINFO_R_EINVAL, "category is NULL");
3192 retvm_if(exist == NULL, PMINFO_R_EINVAL, "exist is NULL");
3196 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3198 if (info->app_info == NULL)
3199 return PMINFO_R_ERROR;
3202 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
3203 val = (const char *)tmp->data;
3206 if (strcasecmp(val, category) == 0) {
3215 API int pkgmgrinfo_appinfo_is_ui_gadget(pkgmgrinfo_appinfo_h handle,
3218 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3220 if (info == NULL || info->app_info == NULL || ui_gadget == NULL) {
3221 _LOGE("invalid parameter");
3222 return PMINFO_R_EINVAL;
3224 if (info->app_info->ui_gadget == NULL)
3225 info->app_info->ui_gadget = strdup("false");
3227 *ui_gadget = _get_bool_value(info->app_info->ui_gadget);
3232 API int pkgmgrinfo_appinfo_is_support_disable(pkgmgrinfo_appinfo_h handle,
3233 bool *support_disable)
3235 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3237 if (info == NULL || info->app_info == NULL || support_disable == NULL) {
3238 _LOGE("invalid parameter");
3239 return PMINFO_R_EINVAL;
3242 *support_disable = _get_bool_value(info->app_info->support_disable);
3247 API int pkgmgrinfo_appinfo_is_removable(pkgmgrinfo_appinfo_h handle,
3250 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3252 if (info == NULL || info->app_info == NULL || removable == NULL) {
3253 _LOGE("invalid parameter");
3254 return PMINFO_R_EINVAL;
3257 *removable = _get_bool_value(info->app_info->removable);
3262 API int pkgmgrinfo_appinfo_is_system(pkgmgrinfo_appinfo_h handle, bool *system)
3264 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3266 if (info == NULL || info->app_info == NULL || system == NULL) {
3267 _LOGE("invalid parameter");
3268 return PMINFO_R_EINVAL;
3271 *system = _get_bool_value(info->app_info->package_system);
3276 API int pkgmgrinfo_appinfo_is_disabled(pkgmgrinfo_appinfo_h handle, bool *disabled)
3278 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
3279 retvm_if(disabled == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
3280 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3282 if (info->app_info == NULL || info->app_info->is_disabled == NULL)
3283 return PMINFO_R_ERROR;
3285 *disabled = _get_bool_value(info->app_info->is_disabled);
3290 API int pkgmgrinfo_appinfo_is_global(pkgmgrinfo_appinfo_h handle, bool *global)
3292 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3294 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
3295 retvm_if(global == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3297 if (info->app_info == NULL || info->app_info->for_all_users == NULL)
3298 return PMINFO_R_ERROR;
3300 *global = _get_bool_value(info->app_info->for_all_users);
3305 API int pkgmgrinfo_appinfo_get_splash_screen_display(pkgmgrinfo_appinfo_h handle, bool *splash_screen_display)
3307 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3309 if (info == NULL || splash_screen_display == NULL) {
3310 _LOGE("Invalid parameter");
3311 return PMINFO_R_EINVAL;
3314 if (info->app_info == NULL || info->app_info->splash_screen_display == NULL)
3315 return PMINFO_R_ERROR;
3317 *splash_screen_display = _get_bool_value(info->app_info->splash_screen_display);
3322 API int pkgmgrinfo_appinfo_get_setup_appid(pkgmgrinfo_appinfo_h handle, char **setup_appid)
3324 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3326 if (info == NULL || setup_appid == NULL) {
3327 _LOGE("Invalid parameter");
3328 return PMINFO_R_EINVAL;
3331 if (info->app_info == NULL || info->app_info->setup_appid == NULL)
3332 return PMINFO_R_ERROR;
3334 *setup_appid = info->app_info->setup_appid;
3338 API int pkgmgrinfo_appinfo_is_support_ambient(pkgmgrinfo_appinfo_h handle,
3339 bool *support_ambient)
3341 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3343 if (info == NULL || support_ambient == NULL) {
3344 _LOGE("Invalid parameter");
3345 return PMINFO_R_EINVAL;
3348 if (info->app_info == NULL || info->app_info->support_ambient == NULL)
3349 return PMINFO_R_ERROR;
3351 *support_ambient = _get_bool_value(info->app_info->support_ambient);
3356 API int pkgmgrinfo_appinfo_destroy_appinfo(pkgmgrinfo_appinfo_h handle)
3358 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
3359 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3360 __cleanup_appinfo(info);
3364 API int pkgmgrinfo_appinfo_filter_create(pkgmgrinfo_appinfo_filter_h *handle)
3366 return (pkgmgrinfo_pkginfo_filter_create(handle));
3369 API int pkgmgrinfo_appinfo_filter_destroy(pkgmgrinfo_appinfo_filter_h handle)
3371 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
3374 static gint __compare_func(gconstpointer data1, gconstpointer data2)
3376 pkgmgrinfo_node_x *node1 = (pkgmgrinfo_node_x *)data1;
3377 pkgmgrinfo_node_x *node2 = (pkgmgrinfo_node_x *)data2;
3378 if (node1->prop == node2->prop)
3380 else if (node1->prop > node2->prop)
3386 API int pkgmgrinfo_appinfo_filter_add_int(pkgmgrinfo_appinfo_filter_h handle,
3387 const char *property, const int value)
3389 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3390 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3391 char buf[PKG_VALUE_STRING_LEN_MAX] = {'\0'};
3393 GSList *link = NULL;
3395 prop = _pminfo_appinfo_convert_to_prop_int(property);
3396 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_INT ||
3397 prop > E_PMINFO_APPINFO_PROP_APP_MAX_INT) {
3398 _LOGE("Invalid Integer Property\n");
3399 return PMINFO_R_EINVAL;
3401 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
3402 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1, sizeof(pkgmgrinfo_node_x));
3404 _LOGE("Out of Memory!!!\n");
3405 return PMINFO_R_ERROR;
3407 snprintf(buf, PKG_VALUE_STRING_LEN_MAX - 1, "%d", value);
3408 val = strndup(buf, PKG_VALUE_STRING_LEN_MAX - 1);
3410 _LOGE("Out of Memory\n");
3413 return PMINFO_R_ERROR;
3417 /*If API is called multiple times for same property, we should override the previous values.
3418 Last value set will be used for filtering.*/
3419 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
3421 filter->list = g_slist_delete_link(filter->list, link);
3422 filter->list = g_slist_append(filter->list, (gpointer)node);
3427 API int pkgmgrinfo_appinfo_filter_add_bool(pkgmgrinfo_appinfo_filter_h handle,
3428 const char *property, const bool value)
3430 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3431 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3433 GSList *link = NULL;
3435 prop = _pminfo_appinfo_convert_to_prop_bool(property);
3436 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_BOOL ||
3437 prop > E_PMINFO_APPINFO_PROP_APP_MAX_BOOL) {
3438 _LOGE("Invalid Boolean Property\n");
3439 return PMINFO_R_EINVAL;
3441 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
3442 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1, sizeof(pkgmgrinfo_node_x));
3444 _LOGE("Out of Memory!!!\n");
3445 return PMINFO_R_ERROR;
3448 val = strndup("true", 4);
3450 val = strndup("false", 5);
3452 _LOGE("Out of Memory\n");
3455 return PMINFO_R_ERROR;
3459 /*If API is called multiple times for same property, we should override the previous values.
3460 Last value set will be used for filtering.*/
3461 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
3463 filter->list = g_slist_delete_link(filter->list, link);
3464 filter->list = g_slist_append(filter->list, (gpointer)node);
3469 API int pkgmgrinfo_appinfo_filter_add_string(pkgmgrinfo_appinfo_filter_h handle,
3470 const char *property, const char *value)
3472 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3473 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3474 retvm_if(value == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3476 pkgmgrinfo_node_x *ptr = NULL;
3477 char prev[PKG_STRING_LEN_MAX] = {'\0'};
3478 char temp[PKG_STRING_LEN_MAX] = {'\0'};
3479 GSList *link = NULL;
3481 prop = _pminfo_appinfo_convert_to_prop_str(property);
3482 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_STR ||
3483 prop > E_PMINFO_APPINFO_PROP_APP_MAX_STR) {
3484 _LOGE("Invalid String Property\n");
3485 return PMINFO_R_EINVAL;
3487 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
3488 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1, sizeof(pkgmgrinfo_node_x));
3490 _LOGE("Out of Memory!!!\n");
3491 return PMINFO_R_ERROR;
3495 case E_PMINFO_APPINFO_PROP_APP_COMPONENT:
3496 node->value = strdup(value);
3497 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
3499 filter->list = g_slist_delete_link(filter->list, link);
3500 filter->list = g_slist_append(filter->list, (gpointer)node);
3502 case E_PMINFO_APPINFO_PROP_APP_CATEGORY:
3503 val = (char *)calloc(1, PKG_STRING_LEN_MAX);
3505 _LOGE("Out of Memory\n");
3508 return PMINFO_R_ERROR;
3510 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
3512 ptr = (pkgmgrinfo_node_x *)link->data;
3513 strncpy(prev, ptr->value, PKG_STRING_LEN_MAX - 1);
3514 _LOGI("Previous value is %s\n", prev);
3515 filter->list = g_slist_delete_link(filter->list, link);
3516 snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s,%s", prev, value);
3517 strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
3518 _LOGI("New value is %s\n", val);
3520 filter->list = g_slist_append(filter->list, (gpointer)node);
3521 memset(temp, '\0', PKG_STRING_LEN_MAX);
3523 snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s", value);
3524 strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
3525 _LOGI("First value is %s\n", val);
3527 filter->list = g_slist_append(filter->list, (gpointer)node);
3528 memset(temp, '\0', PKG_STRING_LEN_MAX);
3532 node->value = strndup(value, PKG_STRING_LEN_MAX - 1);
3533 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
3535 filter->list = g_slist_delete_link(filter->list, link);
3536 filter->list = g_slist_append(filter->list, (gpointer)node);
3542 API int pkgmgrinfo_appinfo_usr_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count, uid_t uid)
3548 if (handle == NULL || count == NULL) {
3549 _LOGE("invalid parameter");
3550 return PMINFO_R_EINVAL;
3553 locale = _get_system_locale();
3555 return PMINFO_R_ERROR;
3557 list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
3558 __free_applications);
3561 return PMINFO_R_ERROR;
3564 if (__check_disable_filter_exist(
3565 handle, E_APPINFO_DISABLE_TYPE_APP) == false) {
3566 if (pkgmgrinfo_appinfo_filter_add_bool(handle,
3567 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
3568 g_hash_table_destroy(list);
3570 return PMINFO_R_ERROR;
3574 if (__check_disable_filter_exist(
3575 handle, E_APPINFO_DISABLE_TYPE_PKG) == false) {
3576 if (pkgmgrinfo_appinfo_filter_add_bool(handle,
3577 PMINFO_APPINFO_PROP_PKG_DISABLE, false)) {
3578 g_hash_table_destroy(list);
3580 return PMINFO_R_ERROR;
3584 ret = _appinfo_get_applications(uid, uid, locale, handle, 0, list);
3585 if (ret == PMINFO_R_OK && uid != GLOBAL_USER)
3586 ret = _appinfo_get_applications(GLOBAL_USER, uid, locale,
3589 if (ret != PMINFO_R_OK) {
3590 g_hash_table_destroy(list);
3592 return PMINFO_R_ERROR;
3595 *count = g_hash_table_size(list);
3596 g_hash_table_destroy(list);
3602 API int pkgmgrinfo_appinfo_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count)
3604 return pkgmgrinfo_appinfo_usr_filter_count(handle, count, _getuid());
3607 API int pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(
3608 pkgmgrinfo_appinfo_filter_h handle,
3609 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
3611 if (handle == NULL || app_cb == NULL) {
3612 LOGE("invalid parameter");
3613 return PMINFO_R_EINVAL;
3616 if (__check_disable_filter_exist(
3617 handle, E_APPINFO_DISABLE_TYPE_APP) == false) {
3618 if (pkgmgrinfo_appinfo_filter_add_bool(handle,
3619 PMINFO_APPINFO_PROP_APP_DISABLE, false))
3620 return PMINFO_R_ERROR;
3623 if (__check_disable_filter_exist(
3624 handle, E_APPINFO_DISABLE_TYPE_PKG) == false) {
3625 if (pkgmgrinfo_appinfo_filter_add_bool(handle,
3626 PMINFO_APPINFO_PROP_PKG_DISABLE, false))
3627 return PMINFO_R_ERROR;
3630 return _appinfo_get_filtered_foreach_appinfo(uid, handle, PMINFO_APPINFO_GET_ALL, app_cb,
3634 API int pkgmgrinfo_appinfo_filter_foreach_appinfo(pkgmgrinfo_appinfo_filter_h handle,
3635 pkgmgrinfo_app_list_cb app_cb, void *user_data)
3637 return pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(handle, app_cb, user_data, _getuid());
3640 API int pkgmgrinfo_appinfo_metadata_filter_create(pkgmgrinfo_appinfo_metadata_filter_h *handle)
3642 return (pkgmgrinfo_pkginfo_filter_create(handle));
3645 API int pkgmgrinfo_appinfo_metadata_filter_destroy(pkgmgrinfo_appinfo_metadata_filter_h handle)
3647 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
3650 API int pkgmgrinfo_appinfo_metadata_filter_add(
3651 pkgmgrinfo_appinfo_metadata_filter_h handle,
3652 const char *key, const char *value)
3654 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
3655 pkgmgrinfo_metadata_node_x *node;
3657 /* value can be NULL.
3658 * In that case all apps with specified key should be displayed
3661 LOGE("invalid parameter");
3662 return PMINFO_R_EINVAL;
3665 node = calloc(1, sizeof(pkgmgrinfo_metadata_node_x));
3667 LOGE("out of memory");
3668 return PMINFO_R_ERROR;
3671 node->key = strdup(key);
3672 if (value && strlen(value))
3673 node->value = strdup(value);
3675 filter->list_metadata = g_slist_append(filter->list_metadata,
3681 API int pkgmgrinfo_appinfo_usr_metadata_filter_foreach(
3682 pkgmgrinfo_appinfo_metadata_filter_h handle,
3683 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
3685 if (handle == NULL || app_cb == NULL) {
3686 LOGE("invalid parameter");
3687 return PMINFO_R_EINVAL;
3690 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
3691 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
3692 PMINFO_APPINFO_PROP_APP_DISABLE, false))
3693 return PMINFO_R_ERROR;
3695 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
3696 PMINFO_APPINFO_PROP_PKG_DISABLE, false))
3697 return PMINFO_R_ERROR;
3699 return _appinfo_get_filtered_foreach_appinfo(uid, handle, PMINFO_APPINFO_GET_ALL, app_cb,
3703 API int pkgmgrinfo_appinfo_metadata_filter_foreach(
3704 pkgmgrinfo_appinfo_metadata_filter_h handle,
3705 pkgmgrinfo_app_list_cb app_cb, void *user_data)
3707 return pkgmgrinfo_appinfo_usr_metadata_filter_foreach(handle, app_cb,
3708 user_data, _getuid());
3711 API int pkgmgrinfo_appinfo_is_guestmode_visibility(pkgmgrinfo_appinfo_h handle, bool *status)
3714 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3716 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
3717 retvm_if(status == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3719 val = info->app_info->guestmode_visibility;
3720 *status = _get_bool_value(val);
3724 API int pkgmgrinfo_appinfo_foreach_appcontrol_v2(pkgmgrinfo_appinfo_h handle,
3725 pkgmgrinfo_app_control_list_cb_v2 appcontrol_func,
3728 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
3729 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
3731 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3732 appcontrol_x *appcontrol;
3735 if (info->app_info == NULL)
3736 return PMINFO_R_ERROR;
3738 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
3739 appcontrol = (appcontrol_x *)tmp->data;
3740 if (appcontrol == NULL ||
3741 !strcasecmp(appcontrol->visibility, "remote-only"))
3743 ret = appcontrol_func(appcontrol->operation, appcontrol->uri,
3744 appcontrol->mime, appcontrol->id, user_data);
3752 API int pkgmgrinfo_appinfo_foreach_remote_appcontrol_v2(
3753 pkgmgrinfo_appinfo_h handle,
3754 pkgmgrinfo_app_control_list_cb_v2 appcontrol_func,
3757 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
3758 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
3760 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3761 appcontrol_x *appcontrol;
3764 if (info->app_info == NULL)
3765 return PMINFO_R_ERROR;
3767 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
3768 appcontrol = (appcontrol_x *)tmp->data;
3769 if (appcontrol == NULL ||
3770 !strcasecmp(appcontrol->visibility, "local-only"))
3772 ret = appcontrol_func(appcontrol->operation, appcontrol->uri,
3773 appcontrol->mime, appcontrol->id, user_data);
3781 API int pkgmgrinfo_appinfo_foreach_component_info(pkgmgrinfo_appinfo_h handle,
3782 pkgmgrinfo_component_info_list_cb callback, void *user_data)
3784 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
3785 retvm_if(callback == NULL, PMINFO_R_EINVAL, "callback is NULL");
3786 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3787 pkgmgr_compinfo_x compinfo;
3790 if (info->app_info == NULL)
3791 return PMINFO_R_ERROR;
3793 compinfo.appid = info->app_info->appid;
3794 for (tmp = info->app_info->components; tmp; tmp = tmp->next) {
3795 compinfo.comp_info = (component_x *)tmp->data;
3796 if (callback(&compinfo, user_data) < 0)