13 #include "pkgmgr-info.h"
14 #include "pkgmgrinfo_debug.h"
15 #include "pkgmgrinfo_private.h"
16 #include "pkgmgr_parser.h"
18 static bool _get_bool_value(const char *str)
20 if (str && !strcmp(str, "true"))
26 static void __cleanup_appinfo(pkgmgr_appinfo_x *data)
28 pkgmgr_appinfo_x *info = data;
32 free((void *)info->package);
34 free((void *)info->locale);
36 pkgmgrinfo_basic_free_application(info->app_info);
42 static const char join_localized_info[] =
43 " LEFT OUTER JOIN package_app_localized_info"
44 " ON ai.app_id=package_app_localized_info.app_id"
45 " AND package_app_localized_info.app_locale=?";
46 static const char join_category[] =
47 " LEFT OUTER JOIN package_app_app_category"
48 " ON ai.app_id=package_app_app_category.app_id";
49 static const char join_app_control[] =
50 " LEFT OUTER JOIN package_app_app_control"
51 " ON ai.app_id=package_app_app_control.app_id";
52 static const char join_metadata[] =
53 " LEFT OUTER JOIN package_app_app_metadata"
54 " ON ai.app_id=package_app_app_metadata.app_id ";
56 static int _get_filtered_query(pkgmgrinfo_filter_x *filter,
57 const char *locale, uid_t uid, char **query, GList **bind_params)
61 char *condition = NULL;
62 char buf[MAX_QUERY_LEN] = { '\0' };
63 char tmp_query[MAX_QUERY_LEN] = { '\0' };
68 strncat(buf, " WHERE 1=1", MAX_QUERY_LEN - len - 1);
69 len += strlen(" WHERE 1=1");
71 for (list = filter->list; list; list = list->next) {
72 joined |= __get_filter_condition(list->data, uid, &condition, bind_params);
73 if (condition == NULL)
76 strncat(buf, " AND ", MAX_QUERY_LEN - len - 1);
77 len += strlen(" AND ");
79 strncat(buf, condition, sizeof(buf) - len - 1);
80 len += strlen(condition);
85 if (filter->list_metadata) {
86 strncat(buf, " AND (", MAX_QUERY_LEN - len - 1);
87 len += strlen(" AND (");
89 for (list = filter->list_metadata; list; list = list->next) {
90 joined |= __get_metadata_filter_condition(list->data,
91 &condition, bind_params);
92 if (condition == NULL)
94 strncat(buf, condition, sizeof(buf) - len - 1);
95 len += strlen(condition);
99 strncat(buf, " OR ", MAX_QUERY_LEN - len - 1);
100 len += strlen(" OR ");
102 if (filter->list_metadata) {
103 strncat(buf, "1=0)", MAX_QUERY_LEN - len - 1);
104 len += strlen("1=0)");
107 if (joined & E_PMINFO_APPINFO_JOIN_LOCALIZED_INFO) {
108 strncat(tmp_query, join_localized_info, MAX_QUERY_LEN - len - 1);
109 len += strlen(join_localized_info);
110 *bind_params = g_list_append(*bind_params, strdup(locale));
112 if (joined & E_PMINFO_APPINFO_JOIN_CATEGORY) {
113 strncat(tmp_query, join_category, MAX_QUERY_LEN - len - 1);
114 len += strlen(join_category);
116 if (joined & E_PMINFO_APPINFO_JOIN_APP_CONTROL) {
117 strncat(tmp_query, join_app_control, MAX_QUERY_LEN - len - 1);
118 len += strlen(join_app_control);
120 if (joined & E_PMINFO_APPINFO_JOIN_METADATA) {
121 strncat(tmp_query, join_metadata, MAX_QUERY_LEN - len - 1);
122 len += strlen(join_metadata);
125 strncat(tmp_query, buf, MAX_QUERY_LEN - len - 1);
128 *query = strdup(tmp_query);
130 return PMINFO_R_ERROR;
135 static int _appinfo_get_category(sqlite3 *db, const char *appid,
138 static const char query_raw[] =
139 "SELECT category FROM package_app_app_category WHERE app_id=%Q";
145 query = sqlite3_mprintf(query_raw, appid);
147 LOGE("out of memory");
148 return PMINFO_R_ERROR;
151 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
153 if (ret != SQLITE_OK) {
154 LOGE("prepare failed: %s", sqlite3_errmsg(db));
155 return PMINFO_R_ERROR;
158 while (sqlite3_step(stmt) == SQLITE_ROW) {
160 _save_column_str(stmt, 0, &val);
162 *category = g_list_append(*category, (gpointer)val);
165 sqlite3_finalize(stmt);
170 static void __parse_appcontrol(GList **appcontrol, char *appcontrol_str)
177 if (appcontrol_str == NULL)
180 dup = strdup(appcontrol_str);
182 ac = calloc(1, sizeof(appcontrol_x));
184 _LOGE("out of memory");
187 token = strtok_r(dup, "|", &ptr);
188 if (token && strcmp(token, "NULL"))
189 ac->operation = strdup(token);
190 token = strtok_r(NULL, "|", &ptr);
191 if (token && strcmp(token, "NULL"))
192 ac->uri = strdup(token);
193 token = strtok_r(NULL, "|", &ptr);
194 if (token && strcmp(token, "NULL"))
195 ac->mime = strdup(token);
196 *appcontrol = g_list_append(*appcontrol, ac);
197 } while ((token = strtok_r(NULL, ";", &ptr)));
202 static int _appinfo_get_app_control(sqlite3 *db, const char *appid,
205 static const char query_raw[] =
206 "SELECT app_control FROM package_app_app_control "
213 query = sqlite3_mprintf(query_raw, appid);
215 LOGE("out of memory");
216 return PMINFO_R_ERROR;
219 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
221 if (ret != SQLITE_OK) {
222 LOGE("prepare failed: %s", sqlite3_errmsg(db));
223 return PMINFO_R_ERROR;
226 while (sqlite3_step(stmt) == SQLITE_ROW) {
228 _save_column_str(stmt, 0, &str);
230 __parse_appcontrol(appcontrol, str);
234 sqlite3_finalize(stmt);
239 static int _appinfo_get_metadata(sqlite3 *db, const char *appid,
242 static const char query_raw[] =
243 "SELECT md_key, md_value "
244 "FROM package_app_app_metadata WHERE app_id=%Q";
251 query = sqlite3_mprintf(query_raw, appid);
253 LOGE("out of memory");
254 return PMINFO_R_ERROR;
257 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
259 if (ret != SQLITE_OK) {
260 LOGE("prepare failed: %s", sqlite3_errmsg(db));
261 return PMINFO_R_ERROR;
264 while (sqlite3_step(stmt) == SQLITE_ROW) {
265 info = calloc(1, sizeof(metadata_x));
267 LOGE("out of memory");
268 sqlite3_finalize(stmt);
269 return PMINFO_R_ERROR;
272 _save_column_str(stmt, idx++, &info->key);
273 _save_column_str(stmt, idx++, &info->value);
274 *metadata = g_list_append(*metadata, info);
277 sqlite3_finalize(stmt);
283 static int _appinfo_get_splashscreens(sqlite3 *db, const char *appid,
284 GList **splashscreens)
286 static const char query_raw[] =
287 "SELECT src, type, orientation, indicatordisplay, operation, color_depth "
288 "FROM package_app_splash_screen WHERE app_id=%Q";
293 splashscreen_x *info;
295 query = sqlite3_mprintf(query_raw, appid);
297 LOGE("out of memory");
298 return PMINFO_R_ERROR;
301 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
303 if (ret != SQLITE_OK) {
304 LOGE("prepare failed: %s", sqlite3_errmsg(db));
305 return PMINFO_R_ERROR;
308 while (sqlite3_step(stmt) == SQLITE_ROW) {
309 info = calloc(1, sizeof(splashscreen_x));
311 LOGE("out of memory");
312 sqlite3_finalize(stmt);
313 return PMINFO_R_ERROR;
316 _save_column_str(stmt, idx++, &info->src);
317 _save_column_str(stmt, idx++, &info->type);
318 _save_column_str(stmt, idx++, &info->orientation);
319 _save_column_str(stmt, idx++, &info->indicatordisplay);
320 _save_column_str(stmt, idx++, &info->operation);
321 _save_column_str(stmt, idx++, &info->color_depth);
322 *splashscreens = g_list_append(*splashscreens, info);
325 sqlite3_finalize(stmt);
330 static GList *__get_background_category(const char *value)
332 GList *category_list = NULL;
333 int convert_value = 0;
334 if (!value || strlen(value) == 0)
337 convert_value = atoi(value);
338 if (convert_value < 0)
341 if (convert_value & APP_BG_CATEGORY_USER_DISABLE_TRUE_VAL)
342 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_USER_DISABLE_TRUE_STR));
344 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_USER_DISABLE_FALSE_STR));
346 if (convert_value & APP_BG_CATEGORY_MEDIA_VAL)
347 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_MEDIA_STR));
349 if (convert_value & APP_BG_CATEGORY_DOWNLOAD_VAL)
350 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_DOWNLOAD_STR));
352 if (convert_value & APP_BG_CATEGORY_BGNETWORK_VAL)
353 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_BGNETWORK_STR));
355 if (convert_value & APP_BG_CATEGORY_LOCATION_VAL)
356 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_LOCATION_STR));
358 if (convert_value & APP_BG_CATEGORY_SENSOR_VAL)
359 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_SENSOR_STR));
361 if (convert_value & APP_BG_CATEGORY_IOTCOMM_VAL)
362 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_IOTCOMM_STR));
364 if (convert_value & APP_BG_CATEGORY_SYSTEM_VAL)
365 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_SYSTEM));
367 return category_list;
371 static void __free_applications(gpointer data)
373 pkgmgrinfo_basic_free_application((application_x *)data);
376 static gint __disable_chk_func(gconstpointer data1, gconstpointer data2)
378 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)data1;
379 pkgmgrinfo_appinfo_disable_type *value =
380 (pkgmgrinfo_appinfo_disable_type *)data2;
382 if (value == E_APPINFO_DISABLE_TYPE_PKG)
383 return (node->prop == E_PMINFO_APPINFO_PROP_PKG_DISABLE)
386 return (node->prop == E_PMINFO_APPINFO_PROP_APP_DISABLE)
390 static bool __check_disable_filter_exist(pkgmgrinfo_filter_x *filter,
391 pkgmgrinfo_appinfo_disable_type type)
398 link = g_slist_find_custom(filter->list, &type, __disable_chk_func);
405 static int __bind_params(sqlite3_stmt *stmt, GList *params)
407 GList *tmp_list = NULL;
411 if (stmt == NULL || params == NULL)
412 return PMINFO_R_EINVAL;
416 ret = sqlite3_bind_text(stmt, ++idx, (char *)tmp_list->data, -1, SQLITE_STATIC);
417 if (ret != SQLITE_OK)
418 return PMINFO_R_ERROR;
419 tmp_list = tmp_list->next;
425 static bool __check_app_storage_status(pkgmgrinfo_filter_x *tmp_filter)
427 GSList *tmp_list = NULL;
428 pkgmgrinfo_node_x *tmp_node = NULL;
431 if (tmp_filter == NULL)
434 property = _pminfo_appinfo_convert_to_prop_bool(PMINFO_APPINFO_PROP_APP_CHECK_STORAGE);
435 for (tmp_list = tmp_filter->list; tmp_list != NULL;
436 tmp_list = g_slist_next(tmp_list)) {
437 tmp_node = (pkgmgrinfo_node_x *)tmp_list->data;
438 if (property == tmp_node->prop) {
439 if (strcmp(tmp_node->value, "true") == 0)
449 static int _appinfo_get_applications(uid_t db_uid, uid_t uid,
450 const char *locale, pkgmgrinfo_filter_x *filter, int flag,
451 GHashTable *applications)
453 static const char query_raw[] =
454 "SELECT DISTINCT ai.app_id, ai.app_installed_storage, "
455 "ai.app_external_path";
456 static const char query_basic[] =
457 ", ai.app_component, ai.app_exec, "
458 "ai.app_nodisplay, ai.app_type, ai.app_onboot, "
459 "ai.app_multiple, ai.app_autorestart, ai.app_taskmanage, "
460 "ai.app_hwacceleration, ai.app_screenreader, "
461 "ai.app_mainapp, ai.app_recentimage, ai.app_launchcondition, "
462 "ai.app_indicatordisplay, ai.app_portraitimg, "
463 "ai.app_landscapeimg, ai.app_guestmodevisibility, "
464 "ai.app_permissiontype, ai.app_preload, ai.app_submode, "
465 "ai.app_submode_mainid, ai.app_launch_mode, ai.app_ui_gadget, "
466 "ai.app_support_disable, ai.app_process_pool, "
467 "ai.app_background_category, ai.app_package_type, "
468 "ai.app_root_path, ai.app_api_version, ai.app_effective_appid, "
469 "ai.app_disable, ai.app_splash_screen_display, ai.app_tep_name, "
470 "ai.app_zip_mount_file, ai.component_type, ai.package, "
471 "ai.app_package_system, ai.app_removable, "
472 "ai.app_package_installed_time, ai.app_support_mode, "
473 "ai.app_support_ambient, ai.app_setup_appid";
474 static const char query_uid_info[] =
475 ", ui.is_disabled, ui.is_splash_screen_enabled";
476 static const char query_label[] =
478 "(SELECT app_label FROM package_app_localized_info WHERE ai.app_id=app_id AND app_locale=?), "
479 "(SELECT app_label FROM package_app_localized_info WHERE ai.app_id=app_id AND app_locale='No Locale'))";
480 static const char query_icon[] =
482 "(SELECT app_icon FROM package_app_localized_info WHERE ai.app_id=app_id AND app_locale=?), "
483 "(SELECT app_icon FROM package_app_localized_info WHERE ai.app_id=app_id AND app_locale='No Locale'))";
484 static const char query_from_clause[] = " FROM package_app_info as ai";
485 static const char query_uid_info_clause[] =
486 " LEFT OUTER JOIN package_app_info_for_uid AS ui "
487 "ON (ai.app_id=ui.app_id AND ui.uid=?)";
488 int ret = PMINFO_R_ERROR;
492 char *bg_category_str = NULL;
493 char *constraint = NULL;
494 char *tmp_record = NULL;
495 char query[MAX_QUERY_LEN] = { '\0' };
496 char buf[BUFSIZE] = { '\0' };
497 application_x *info = NULL;
498 GList *bind_params = NULL;
500 sqlite3_stmt *stmt = NULL;
501 bool is_check_storage = true;
502 const uid_t global_user_uid = GLOBAL_USER;
504 dbpath = getUserPkgParserDBPathUID(db_uid);
506 return PMINFO_R_ERROR;
508 ret = __open_db(dbpath, &db, SQLITE_OPEN_READONLY);
509 if (ret != SQLITE_OK) {
510 _LOGE("failed to open db(%s): %d", dbpath, ret);
512 return PMINFO_R_ERROR;
516 len = strlen(query_raw);
517 snprintf(query, MAX_QUERY_LEN - 1, "%s", query_raw);
519 if (flag & PMINFO_APPINFO_GET_BASICINFO) {
520 strncat(query, query_basic, MAX_QUERY_LEN - len - 1);
521 len += strlen(query_basic);
522 strncat(query, query_uid_info, MAX_QUERY_LEN - len - 1);
523 len += strlen(query_uid_info);
525 if (flag & PMINFO_APPINFO_GET_LABEL) {
526 strncat(query, query_label, MAX_QUERY_LEN - len - 1);
527 len += strlen(query_label);
528 bind_params = g_list_append(bind_params, strdup(locale));
530 if (flag & PMINFO_APPINFO_GET_ICON) {
531 strncat(query, query_icon, MAX_QUERY_LEN - len - 1);
532 len += strlen(query_icon);
533 bind_params = g_list_append(bind_params, strdup(locale));
536 snprintf(buf, MAX_QUERY_LEN - 1, "%d", uid);
537 bind_params = g_list_append(bind_params, strdup(buf));
539 is_check_storage = __check_app_storage_status(filter);
541 ret = _get_filtered_query(filter, locale, uid, &constraint, &bind_params);
542 if (ret != PMINFO_R_OK) {
543 LOGE("Failed to get WHERE clause");
546 strncat(query, query_from_clause, MAX_QUERY_LEN - len - 1);
547 len += strlen(query_from_clause);
549 strncat(query, query_uid_info_clause, MAX_QUERY_LEN - len - 1);
550 len += strlen(query_uid_info_clause);
553 strncat(query, constraint, MAX_QUERY_LEN - len - 1);
555 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
556 if (ret != SQLITE_OK) {
557 LOGE("prepare failed: %s", sqlite3_errmsg(db));
558 ret = PMINFO_R_ERROR;
562 if (g_list_length(bind_params) != 0) {
563 ret = __bind_params(stmt, bind_params);
564 if (ret != SQLITE_OK) {
565 LOGE("Failed to bind parameters");
570 while (sqlite3_step(stmt) == SQLITE_ROW) {
571 info = calloc(1, sizeof(application_x));
573 LOGE("out of memory");
574 ret = PMINFO_R_ERROR;
578 _save_column_str(stmt, idx++, &info->appid);
579 _save_column_str(stmt, idx++, &info->installed_storage);
580 _save_column_str(stmt, idx++ , &info->external_path);
582 if (flag & PMINFO_APPINFO_GET_BASICINFO) {
583 _save_column_str(stmt, idx++, &info->component);
584 _save_column_str(stmt, idx++, &info->exec);
585 _save_column_str(stmt, idx++, &info->nodisplay);
586 _save_column_str(stmt, idx++, &info->type);
587 _save_column_str(stmt, idx++, &info->onboot);
588 _save_column_str(stmt, idx++, &info->multiple);
589 _save_column_str(stmt, idx++, &info->autorestart);
590 _save_column_str(stmt, idx++, &info->taskmanage);
591 _save_column_str(stmt, idx++, &info->hwacceleration);
592 _save_column_str(stmt, idx++, &info->screenreader);
593 _save_column_str(stmt, idx++, &info->mainapp);
594 _save_column_str(stmt, idx++, &info->recentimage);
595 _save_column_str(stmt, idx++, &info->launchcondition);
596 _save_column_str(stmt, idx++, &info->indicatordisplay);
597 _save_column_str(stmt, idx++, &info->portraitimg);
598 _save_column_str(stmt, idx++, &info->landscapeimg);
599 _save_column_str(stmt, idx++, &info->guestmode_visibility);
600 _save_column_str(stmt, idx++, &info->permission_type);
601 _save_column_str(stmt, idx++, &info->preload);
602 _save_column_str(stmt, idx++, &info->submode);
603 _save_column_str(stmt, idx++, &info->submode_mainid);
604 _save_column_str(stmt, idx++, &info->launch_mode);
605 _save_column_str(stmt, idx++, &info->ui_gadget);
606 _save_column_str(stmt, idx++, &info->support_disable);
607 _save_column_str(stmt, idx++, &info->process_pool);
608 _save_column_str(stmt, idx++, &bg_category_str);
609 _save_column_str(stmt, idx++, &info->package_type);
610 _save_column_str(stmt, idx++, &info->root_path);
611 _save_column_str(stmt, idx++, &info->api_version);
612 _save_column_str(stmt, idx++, &info->effective_appid);
613 _save_column_str(stmt, idx++, &info->is_disabled);
614 _save_column_str(stmt, idx++, &info->splash_screen_display);
615 _save_column_str(stmt, idx++, &info->tep_name);
616 _save_column_str(stmt, idx++, &info->zip_mount_file);
617 _save_column_str(stmt, idx++, &info->component_type);
618 _save_column_str(stmt, idx++, &info->package);
619 _save_column_str(stmt, idx++, &info->package_system);
620 _save_column_str(stmt, idx++, &info->removable);
621 _save_column_str(stmt, idx++, &info->package_installed_time);
622 _save_column_str(stmt, idx++, &info->support_mode);
623 _save_column_str(stmt, idx++, &info->support_ambient);
624 _save_column_str(stmt, idx++, &info->setup_appid);
625 info->background_category = __get_background_category(
627 free(bg_category_str);
630 info->for_all_users =
631 strdup((db_uid != global_user_uid) ? "false" : "true");
633 if (db_uid != global_user_uid) {
637 _save_column_str(stmt, idx++, &tmp_record);
638 if (tmp_record != NULL) {
639 if (strcasecmp(info->is_disabled, "false") == 0 &&
640 strcasecmp(tmp_record, "false") == 0) {
641 free(info->is_disabled);
642 info->is_disabled = tmp_record;
646 _save_column_str(stmt, idx++, &tmp_record);
647 if (tmp_record != NULL) {
648 if (strcasecmp(info->splash_screen_display, "false") == 0 &&
649 strcasecmp(tmp_record, "false") == 0) {
650 free(info->splash_screen_display);
651 info->splash_screen_display = tmp_record;
656 if (flag & PMINFO_APPINFO_GET_LABEL) {
658 _save_column_str(stmt, idx++, &tmp_record);
659 if (_add_label_info_into_list(locale, tmp_record, &info->label)) {
660 ret = PMINFO_R_ERROR;
665 if (flag & PMINFO_APPINFO_GET_ICON) {
667 _save_column_str(stmt, idx++, &tmp_record);
668 if (_add_icon_info_into_list(locale, tmp_record, &info->icon)) {
669 ret = PMINFO_R_ERROR;
674 if (flag & PMINFO_APPINFO_GET_CATEGORY) {
675 if (_appinfo_get_category(db, info->appid,
677 ret = PMINFO_R_ERROR;
682 if (flag & PMINFO_APPINFO_GET_APP_CONTROL) {
683 if (_appinfo_get_app_control(db, info->appid,
684 &info->appcontrol)) {
685 ret = PMINFO_R_ERROR;
690 if (flag & PMINFO_APPINFO_GET_METADATA) {
691 if (_appinfo_get_metadata(db, info->appid,
693 ret = PMINFO_R_ERROR;
698 if (flag & PMINFO_APPINFO_GET_SPLASH_SCREEN) {
699 if (_appinfo_get_splashscreens(db, info->appid,
700 &info->splashscreens)) {
701 ret = PMINFO_R_ERROR;
706 if (is_check_storage &&
707 __appinfo_check_installed_storage(info) != PMINFO_R_OK) {
708 ret = PMINFO_R_ERROR;
709 pkgmgrinfo_basic_free_application(info);
714 g_hash_table_insert(applications, (gpointer)info->appid,
724 if (ret != PMINFO_R_OK && info != NULL)
725 pkgmgrinfo_basic_free_application(info);
727 g_list_free_full(bind_params, free);
728 sqlite3_close_v2(db);
729 sqlite3_finalize(stmt);
734 static int _pkgmgrinfo_get_appinfo(const char *appid, uid_t uid,
735 pkgmgrinfo_appinfo_filter_h filter, pkgmgrinfo_appinfo_h *handle)
740 pkgmgr_appinfo_x *info;
742 if (appid == NULL || filter == NULL || handle == NULL) {
743 LOGE("invalid parameter");
744 return PMINFO_R_EINVAL;
747 locale = _get_system_locale();
749 return PMINFO_R_ERROR;
751 list = g_hash_table_new(g_str_hash, g_str_equal);
754 return PMINFO_R_ERROR;
757 ret = _appinfo_get_applications(uid, uid, locale, filter,
758 PMINFO_APPINFO_GET_ALL, list);
759 if (!g_hash_table_size(list) && uid != GLOBAL_USER)
760 ret = _appinfo_get_applications(GLOBAL_USER, uid, locale, filter,
761 PMINFO_APPINFO_GET_ALL, list);
763 if (!g_hash_table_size(list)) {
764 _LOGI("appinfo for [%s] is not existed for user [%d]",
766 g_hash_table_destroy(list);
768 return PMINFO_R_ENOENT;
771 info = calloc(1, sizeof(pkgmgr_appinfo_x));
773 _LOGE("out of memory");
774 g_hash_table_destroy(list);
776 return PMINFO_R_ERROR;
779 info->app_info = (application_x *)g_hash_table_lookup(list, appid);
780 info->locale = locale;
781 info->package = strdup(info->app_info->package);
783 /* just free list only */
784 g_hash_table_destroy(list);
791 API int pkgmgrinfo_appinfo_get_usr_disabled_appinfo(const char *appid, uid_t uid,
792 pkgmgrinfo_appinfo_h *handle)
795 pkgmgrinfo_appinfo_filter_h filter;
797 if (appid == NULL || handle == NULL) {
798 LOGE("invalid parameter");
799 return PMINFO_R_EINVAL;
802 ret = pkgmgrinfo_appinfo_filter_create(&filter);
803 if (ret != PMINFO_R_OK)
806 ret = pkgmgrinfo_appinfo_filter_add_string(filter,
807 PMINFO_APPINFO_PROP_APP_ID, appid);
808 if (ret != PMINFO_R_OK) {
809 pkgmgrinfo_appinfo_filter_destroy(filter);
810 return PMINFO_R_ERROR;
813 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
814 PMINFO_APPINFO_PROP_APP_DISABLE, true);
815 if (ret != PMINFO_R_OK) {
816 pkgmgrinfo_appinfo_filter_destroy(filter);
817 return PMINFO_R_ERROR;
820 ret = _pkgmgrinfo_get_appinfo(appid, uid, filter, handle);
821 pkgmgrinfo_appinfo_filter_destroy(filter);
826 API int pkgmgrinfo_appinfo_get_disabled_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
828 return pkgmgrinfo_appinfo_get_usr_disabled_appinfo(appid, _getuid(), handle);
831 API int pkgmgrinfo_appinfo_get_usr_appinfo(const char *appid, uid_t uid,
832 pkgmgrinfo_appinfo_h *handle)
835 pkgmgrinfo_appinfo_filter_h filter;
837 if (appid == NULL || handle == NULL) {
838 LOGE("invalid parameter");
839 return PMINFO_R_EINVAL;
842 ret = pkgmgrinfo_appinfo_filter_create(&filter);
843 if (ret != PMINFO_R_OK)
846 ret = pkgmgrinfo_appinfo_filter_add_string(filter,
847 PMINFO_APPINFO_PROP_APP_ID, appid);
848 if (ret != PMINFO_R_OK) {
849 pkgmgrinfo_appinfo_filter_destroy(filter);
850 return PMINFO_R_ERROR;
853 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
854 PMINFO_APPINFO_PROP_APP_DISABLE, false);
855 if (ret != PMINFO_R_OK) {
856 pkgmgrinfo_appinfo_filter_destroy(filter);
857 return PMINFO_R_ERROR;
860 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
861 PMINFO_APPINFO_PROP_PKG_DISABLE, false);
862 if (ret != PMINFO_R_OK) {
863 pkgmgrinfo_appinfo_filter_destroy(filter);
864 return PMINFO_R_ERROR;
867 ret = _pkgmgrinfo_get_appinfo(appid, uid, filter, handle);
868 pkgmgrinfo_appinfo_filter_destroy(filter);
872 API int pkgmgrinfo_appinfo_get_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
874 return pkgmgrinfo_appinfo_get_usr_appinfo(appid, _getuid(), handle);
877 API int pkgmgrinfo_appinfo_get_usr_all_appinfo(const char *appid, uid_t uid,
878 pkgmgrinfo_appinfo_h *handle)
881 pkgmgrinfo_appinfo_filter_h filter;
883 if (appid == NULL || handle == NULL) {
884 LOGE("invalid parameter");
885 return PMINFO_R_EINVAL;
888 ret = pkgmgrinfo_appinfo_filter_create(&filter);
889 if (ret != PMINFO_R_OK)
892 ret = pkgmgrinfo_appinfo_filter_add_string(filter,
893 PMINFO_APPINFO_PROP_APP_ID, appid);
894 if (ret != PMINFO_R_OK) {
895 pkgmgrinfo_appinfo_filter_destroy(filter);
896 return PMINFO_R_ERROR;
899 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
900 PMINFO_APPINFO_PROP_APP_CHECK_STORAGE, false);
901 if (ret != PMINFO_R_OK) {
902 pkgmgrinfo_appinfo_filter_destroy(filter);
903 return PMINFO_R_ERROR;
906 ret = _pkgmgrinfo_get_appinfo(appid, uid, filter, handle);
907 pkgmgrinfo_appinfo_filter_destroy(filter);
912 API int pkgmgrinfo_appinfo_get_all_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
914 return pkgmgrinfo_appinfo_get_usr_all_appinfo(appid, _getuid(), handle);
917 static gpointer __copy_str(gconstpointer src, gpointer data)
919 const char *tmp = (const char *)src;
922 buffer = strdup(tmp);
923 if (buffer == NULL) {
924 LOGE("memory alloc failed");
932 static gpointer __copy_label(gconstpointer src, gpointer data)
934 label_x *tmp = (label_x *)src;
937 label = calloc(1, sizeof(label_x));
939 LOGE("memory alloc failed");
945 label->name = strdup(tmp->name);
947 label->text = strdup(tmp->text);
949 label->lang = strdup(tmp->lang);
954 static gpointer __copy_icon(gconstpointer src, gpointer data)
956 icon_x *tmp = (icon_x *)src;
959 icon = calloc(1, sizeof(icon_x));
961 LOGE("memory alloc failed");
967 icon->text = strdup(tmp->text);
969 icon->lang = strdup(tmp->lang);
971 icon->section = strdup(tmp->section);
973 icon->size = strdup(tmp->size);
975 icon->resolution = strdup(tmp->resolution);
980 static gpointer __copy_metadata(gconstpointer src, gpointer data)
982 metadata_x *tmp = (metadata_x *)src;
983 metadata_x *metadata;
985 metadata = calloc(1, sizeof(metadata_x));
986 if (metadata == NULL) {
987 LOGE("memory alloc failed");
993 metadata->key = strdup(tmp->key);
995 metadata->value = strdup(tmp->value);
1000 static gpointer __copy_datacontrol(gconstpointer src, gpointer data)
1002 datacontrol_x *tmp = (datacontrol_x *)src;
1003 datacontrol_x *datacontrol;
1005 datacontrol = calloc(1, sizeof(datacontrol_x));
1006 if (datacontrol == NULL) {
1007 LOGE("memory alloc failed");
1012 if (tmp->providerid)
1013 datacontrol->providerid = strdup(tmp->providerid);
1015 datacontrol->access = strdup(tmp->access);
1017 datacontrol->type = strdup(tmp->type);
1019 datacontrol->trusted = strdup(tmp->trusted);
1024 static gpointer __copy_appcontrol(gconstpointer src, gpointer data)
1026 appcontrol_x *tmp = (appcontrol_x *)src;
1027 appcontrol_x *appcontrol;
1029 appcontrol = calloc(1, sizeof(appcontrol_x));
1030 if (appcontrol == NULL) {
1031 LOGE("memory alloc failed");
1037 appcontrol->operation = strdup(tmp->operation);
1039 appcontrol->uri = strdup(tmp->uri);
1041 appcontrol->mime = strdup(tmp->mime);
1046 static gpointer __copy_splashscreens(gconstpointer src, gpointer data)
1048 splashscreen_x *tmp = (splashscreen_x *)src;
1049 splashscreen_x *splashscreen;
1051 splashscreen = (splashscreen_x *)calloc(1, sizeof(splashscreen_x));
1052 if (splashscreen == NULL) {
1053 LOGE("memory alloc failed");
1059 splashscreen->src = strdup(tmp->src);
1061 splashscreen->type = strdup(tmp->type);
1062 if (tmp->orientation)
1063 splashscreen->orientation = strdup(tmp->orientation);
1064 if (tmp->indicatordisplay)
1065 splashscreen->indicatordisplay = strdup(tmp->indicatordisplay);
1067 splashscreen->operation = strdup(tmp->operation);
1068 if (tmp->color_depth)
1069 splashscreen->color_depth = strdup(tmp->color_depth);
1071 return splashscreen;
1074 static int _appinfo_copy_appinfo(application_x **application, application_x *data)
1076 application_x *app_info;
1079 app_info = calloc(1, sizeof(application_x));
1080 if (app_info == NULL) {
1081 LOGE("memory alloc failed");
1082 return PMINFO_R_ERROR;
1085 if (data->appid != NULL)
1086 app_info->appid = strdup(data->appid);
1087 if (data->exec != NULL)
1088 app_info->exec = strdup(data->exec);
1089 if (data->nodisplay != NULL)
1090 app_info->nodisplay = strdup(data->nodisplay);
1091 if (data->multiple != NULL)
1092 app_info->multiple = strdup(data->multiple);
1093 if (data->taskmanage != NULL)
1094 app_info->taskmanage = strdup(data->taskmanage);
1095 if (data->type != NULL)
1096 app_info->type = strdup(data->type);
1097 if (data->categories != NULL)
1098 app_info->categories = strdup(data->categories);
1099 if (data->hwacceleration != NULL)
1100 app_info->hwacceleration = strdup(data->hwacceleration);
1101 if (data->screenreader != NULL)
1102 app_info->screenreader = strdup(data->screenreader);
1103 if (data->mainapp != NULL)
1104 app_info->mainapp = strdup(data->mainapp);
1105 if (data->package != NULL)
1106 app_info->package = strdup(data->package);
1107 if (data->recentimage != NULL)
1108 app_info->recentimage = strdup(data->recentimage);
1109 if (data->launchcondition != NULL)
1110 app_info->launchcondition = strdup(data->launchcondition);
1111 if (data->indicatordisplay != NULL)
1112 app_info->indicatordisplay = strdup(data->indicatordisplay);
1113 if (data->portraitimg != NULL)
1114 app_info->portraitimg = strdup(data->portraitimg);
1115 if (data->landscapeimg != NULL)
1116 app_info->landscapeimg = strdup(data->landscapeimg);
1117 if (data->guestmode_visibility != NULL)
1118 app_info->guestmode_visibility = strdup(data->guestmode_visibility);
1119 if (data->component != NULL)
1120 app_info->component = strdup(data->component);
1121 if (data->permission_type != NULL)
1122 app_info->permission_type = strdup(data->permission_type);
1123 if (data->component_type != NULL)
1124 app_info->component_type = strdup(data->component_type);
1125 if (data->preload != NULL)
1126 app_info->preload = strdup(data->preload);
1127 if (data->submode != NULL)
1128 app_info->submode = strdup(data->submode);
1129 if (data->submode_mainid != NULL)
1130 app_info->submode_mainid = strdup(data->submode_mainid);
1131 if (data->process_pool != NULL)
1132 app_info->process_pool = strdup(data->process_pool);
1133 if (data->installed_storage != NULL)
1134 app_info->installed_storage = strdup(data->installed_storage);
1135 if (data->autorestart != NULL)
1136 app_info->autorestart = strdup(data->autorestart);
1137 if (data->onboot != NULL)
1138 app_info->onboot = strdup(data->onboot);
1139 if (data->support_disable != NULL)
1140 app_info->support_disable = strdup(data->support_disable);
1141 if (data->ui_gadget != NULL)
1142 app_info->ui_gadget = strdup(data->ui_gadget);
1143 if (data->launch_mode != NULL)
1144 app_info->launch_mode = strdup(data->launch_mode);
1145 if (data->package_type != NULL)
1146 app_info->package_type = strdup(data->package_type);
1147 if (data->effective_appid != NULL)
1148 app_info->effective_appid = strdup(data->effective_appid);
1149 if (data->splash_screen_display != NULL)
1150 app_info->splash_screen_display = strdup(data->splash_screen_display);
1154 app_info->label = g_list_copy_deep(data->label, __copy_label, &ret);
1156 LOGE("memory alloc failed");
1157 pkgmgrinfo_basic_free_application(app_info);
1158 return PMINFO_R_ERROR;
1162 app_info->icon = g_list_copy_deep(data->icon, __copy_icon, &ret);
1164 LOGE("memory alloc failed");
1165 pkgmgrinfo_basic_free_application(app_info);
1166 return PMINFO_R_ERROR;
1170 app_info->category = g_list_copy_deep(data->category, __copy_str, &ret);
1172 LOGE("memory alloc failed");
1173 pkgmgrinfo_basic_free_application(app_info);
1174 return PMINFO_R_ERROR;
1178 app_info->metadata = g_list_copy_deep(data->metadata, __copy_metadata, &ret);
1180 LOGE("memory alloc failed");
1181 pkgmgrinfo_basic_free_application(app_info);
1182 return PMINFO_R_ERROR;
1186 app_info->datacontrol = g_list_copy_deep(data->datacontrol, __copy_datacontrol, &ret);
1188 LOGE("memory alloc failed");
1189 pkgmgrinfo_basic_free_application(app_info);
1190 return PMINFO_R_ERROR;
1194 app_info->appcontrol = g_list_copy_deep(data->appcontrol, __copy_appcontrol, &ret);
1196 LOGE("memory alloc failed");
1197 pkgmgrinfo_basic_free_application(app_info);
1198 return PMINFO_R_ERROR;
1202 app_info->background_category = g_list_copy_deep(data->background_category, __copy_str, &ret);
1204 LOGE("memory alloc failed");
1205 pkgmgrinfo_basic_free_application(app_info);
1206 return PMINFO_R_ERROR;
1210 app_info->splashscreens = g_list_copy_deep(data->splashscreens, __copy_splashscreens, &ret);
1212 LOGE("memory alloc failed");
1213 pkgmgrinfo_basic_free_application(app_info);
1214 return PMINFO_R_ERROR;
1217 *application = app_info;
1222 API int pkgmgrinfo_appinfo_clone_appinfo(pkgmgrinfo_appinfo_h handle,
1223 pkgmgrinfo_appinfo_h *clone)
1225 pkgmgr_appinfo_x *info;
1226 pkgmgr_appinfo_x *temp = (pkgmgr_appinfo_x *)handle;
1229 return PMINFO_R_EINVAL;
1231 info = calloc(1, sizeof(pkgmgr_appinfo_x));
1233 LOGE("memory alloc failed");
1234 return PMINFO_R_ERROR;
1237 if (temp->package != NULL)
1238 info->package = strdup(temp->package);
1239 if (temp->locale != NULL)
1240 info->locale = strdup(temp->locale);
1242 info->app_component = temp->app_component;
1244 if (_appinfo_copy_appinfo(&info->app_info, temp->app_info) < 0) {
1245 LOGE("appinfo copy failed");
1247 free((void *)info->package);
1251 return PMINFO_R_ERROR;
1259 static int _appinfo_get_filtered_foreach_appinfo(uid_t uid,
1260 pkgmgrinfo_filter_x *filter, int flag, pkgmgrinfo_app_list_cb app_list_cb,
1266 pkgmgr_appinfo_x info;
1268 GHashTableIter iter;
1271 locale = _get_system_locale();
1273 return PMINFO_R_ERROR;
1275 list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
1276 __free_applications);
1279 return PMINFO_R_ERROR;
1282 ret = _appinfo_get_applications(uid, uid, locale, filter,
1283 flag | PMINFO_APPINFO_GET_BASICINFO, list);
1284 if (ret == PMINFO_R_OK && uid != GLOBAL_USER)
1285 ret = _appinfo_get_applications(GLOBAL_USER, uid, locale,
1286 filter, flag | PMINFO_APPINFO_GET_BASICINFO, list);
1288 if (ret != PMINFO_R_OK) {
1289 g_hash_table_destroy(list);
1294 g_hash_table_iter_init(&iter, list);
1295 while (g_hash_table_iter_next(&iter, NULL, &value)) {
1296 app = (application_x *)value;
1297 info.app_info = app;
1298 info.locale = locale;
1299 info.package = app->package;
1300 if (app_list_cb(&info, user_data) < 0)
1303 g_hash_table_destroy(list);
1309 static const char *__appcomponent_str(pkgmgrinfo_app_component comp);
1311 API int pkgmgrinfo_appinfo_get_usr_list(pkgmgrinfo_pkginfo_h handle,
1312 pkgmgrinfo_app_component component,
1313 pkgmgrinfo_app_list_cb app_func, void *user_data, uid_t uid)
1316 pkgmgrinfo_appinfo_filter_h filter;
1318 const char *comp_str = NULL;
1320 if (handle == NULL || app_func == NULL) {
1321 LOGE("invalid parameter");
1322 return PMINFO_R_EINVAL;
1325 if (pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid)) {
1326 LOGE("invalid parameter");
1327 return PMINFO_R_EINVAL;
1330 if (pkgmgrinfo_appinfo_filter_create(&filter))
1331 return PMINFO_R_ERROR;
1333 if (pkgmgrinfo_appinfo_filter_add_string(filter,
1334 PMINFO_APPINFO_PROP_APP_PACKAGE, pkgid)) {
1335 pkgmgrinfo_appinfo_filter_destroy(filter);
1336 return PMINFO_R_ERROR;
1339 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
1340 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
1341 pkgmgrinfo_appinfo_filter_destroy(filter);
1342 return PMINFO_R_ERROR;
1345 comp_str = __appcomponent_str(component);
1348 if (pkgmgrinfo_appinfo_filter_add_string(filter,
1349 PMINFO_APPINFO_PROP_APP_COMPONENT,
1351 pkgmgrinfo_appinfo_filter_destroy(filter);
1352 return PMINFO_R_ERROR;
1356 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter,
1357 PMINFO_APPINFO_GET_ALL, app_func, user_data);
1359 pkgmgrinfo_appinfo_filter_destroy(filter);
1364 API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle,
1365 pkgmgrinfo_app_component component,
1366 pkgmgrinfo_app_list_cb app_func, void *user_data)
1368 return pkgmgrinfo_appinfo_get_usr_list(handle, component, app_func, user_data, _getuid());
1371 API int pkgmgrinfo_appinfo_get_usr_installed_list_full(
1372 pkgmgrinfo_app_list_cb app_func, uid_t uid, int flag,
1376 pkgmgrinfo_appinfo_filter_h filter;
1378 if (app_func == NULL) {
1379 LOGE("invalid parameter");
1380 return PMINFO_R_EINVAL;
1383 if (pkgmgrinfo_appinfo_filter_create(&filter))
1384 return PMINFO_R_ERROR;
1386 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
1387 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
1388 pkgmgrinfo_appinfo_filter_destroy(filter);
1389 return PMINFO_R_ERROR;
1392 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
1393 PMINFO_APPINFO_PROP_PKG_DISABLE, false)) {
1394 pkgmgrinfo_appinfo_filter_destroy(filter);
1395 return PMINFO_R_ERROR;
1398 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
1399 PMINFO_APPINFO_PROP_APP_CHECK_STORAGE, false)) {
1400 pkgmgrinfo_appinfo_filter_destroy(filter);
1401 return PMINFO_R_ERROR;
1404 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter, flag, app_func,
1407 pkgmgrinfo_appinfo_filter_destroy(filter);
1412 API int pkgmgrinfo_appinfo_get_installed_list_full(
1413 pkgmgrinfo_app_list_cb app_func, int flag, void *user_data)
1415 return pkgmgrinfo_appinfo_get_usr_installed_list_full(app_func,
1416 _getuid(), flag, user_data);
1419 API int pkgmgrinfo_appinfo_get_usr_installed_list(
1420 pkgmgrinfo_app_list_cb app_func, uid_t uid, void *user_data)
1423 pkgmgrinfo_appinfo_filter_h filter;
1425 if (app_func == NULL) {
1426 LOGE("invalid parameter");
1427 return PMINFO_R_EINVAL;
1430 /* create an empty filter */
1431 ret = pkgmgrinfo_appinfo_filter_create(&filter);
1432 if (ret != PMINFO_R_OK)
1435 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
1436 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
1437 pkgmgrinfo_appinfo_filter_destroy(filter);
1438 return PMINFO_R_ERROR;
1441 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
1442 PMINFO_APPINFO_PROP_PKG_DISABLE, false)) {
1443 pkgmgrinfo_appinfo_filter_destroy(filter);
1444 return PMINFO_R_ERROR;
1447 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter,
1448 PMINFO_APPINFO_GET_ALL, app_func, user_data);
1450 pkgmgrinfo_appinfo_filter_destroy(filter);
1455 API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func,
1458 return pkgmgrinfo_appinfo_get_usr_installed_list(app_func, _getuid(),
1462 API int pkgmgrinfo_appinfo_get_appid(pkgmgrinfo_appinfo_h handle, char **appid)
1464 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1466 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1467 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1469 if (info->app_info == NULL || info->app_info->appid == NULL)
1470 return PMINFO_R_ERROR;
1471 *appid = (char *)info->app_info->appid;
1476 API int pkgmgrinfo_appinfo_get_pkgname(pkgmgrinfo_appinfo_h handle, char **pkg_name)
1478 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1480 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1481 retvm_if(pkg_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1483 if (info->package == NULL)
1484 return PMINFO_R_ERROR;
1486 *pkg_name = (char *)info->package;
1491 API int pkgmgrinfo_appinfo_get_pkgid(pkgmgrinfo_appinfo_h handle, char **pkgid)
1493 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1495 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1496 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1498 if (info->package == NULL)
1499 return PMINFO_R_ERROR;
1501 *pkgid = (char *)info->package;
1506 API int pkgmgrinfo_appinfo_get_pkgtype(pkgmgrinfo_appinfo_h handle, char **pkgtype)
1508 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1509 retvm_if(pkgtype == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1510 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1512 *pkgtype = (char *)info->app_info->package_type;
1517 API int pkgmgrinfo_appinfo_get_exec(pkgmgrinfo_appinfo_h handle, char **exec)
1519 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1521 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1522 retvm_if(exec == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1524 if (info->app_info == NULL || info->app_info->exec == NULL)
1525 return PMINFO_R_ERROR;
1526 *exec = (char *)info->app_info->exec;
1532 API int pkgmgrinfo_appinfo_get_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1535 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1537 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1538 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1540 if (info->app_info == NULL)
1541 return PMINFO_R_ERROR;
1543 if (info->app_info->icon == NULL) {
1548 ptr = (icon_x *)info->app_info->icon->data;
1550 return PMINFO_R_ERROR;
1552 if (ptr->text == NULL)
1553 return PMINFO_R_ERROR;
1561 API int pkgmgrinfo_appinfo_get_label(pkgmgrinfo_appinfo_h handle, char **label)
1564 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1569 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1570 retvm_if(label == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1572 if (info->app_info == NULL)
1573 return PMINFO_R_ERROR;
1575 locale = info->locale;
1577 locale = DEFAULT_LOCALE;
1579 for (tmp = info->app_info->label; tmp; tmp = tmp->next) {
1580 ptr = (label_x *)tmp->data;
1581 if (ptr == NULL || strcmp(locale, ptr->lang) != 0)
1592 for (tmp = info->app_info->label; tmp; tmp = tmp->next) {
1593 ptr = (label_x *)tmp->data;
1594 if (ptr == NULL || strcmp(DEFAULT_LOCALE, ptr->lang) != 0)
1600 *label = lbl ? lbl : "";
1605 static char *_get_localed_label(const char *appid, const char *locale, uid_t uid)
1607 char *result = NULL;
1609 sqlite3_stmt *stmt = NULL;
1614 parser_db = getUserPkgParserDBPathUID(uid);
1615 if (parser_db == NULL) {
1616 _LOGE("Failed to get parser db path");
1620 if (__open_db(parser_db, &db, SQLITE_OPEN_READONLY) != SQLITE_OK) {
1621 _LOGE("DB open fail\n");
1627 query = sqlite3_mprintf("select app_label from package_app_localized_info where app_id=%Q and app_locale=%Q", appid, locale);
1628 if (query == NULL) {
1629 _LOGE("Out of memory");
1633 if (sqlite3_prepare_v2(db, query, -1, &stmt, NULL) != SQLITE_OK) {
1634 _LOGE("prepare_v2 fail\n");
1638 if (sqlite3_step(stmt) == SQLITE_ROW) {
1639 val = (char *)sqlite3_column_text(stmt, 0);
1641 result = strdup(val);
1645 sqlite3_finalize(stmt);
1646 sqlite3_free(query);
1652 API int pkgmgrinfo_appinfo_usr_get_localed_label(const char *appid, const char *locale, uid_t uid, char **label)
1656 retvm_if(appid == NULL || locale == NULL || label == NULL, PMINFO_R_EINVAL, "Argument is NULL");
1658 val = _get_localed_label(appid, locale, uid);
1660 val = _get_localed_label(appid, DEFAULT_LOCALE, uid);
1663 val = _get_localed_label(appid, locale, GLOBAL_USER);
1665 val = _get_localed_label(appid, DEFAULT_LOCALE, GLOBAL_USER);
1669 return PMINFO_R_ERROR;
1676 API int pkgmgrinfo_appinfo_get_localed_label(const char *appid, const char *locale, char **label)
1678 return pkgmgrinfo_appinfo_usr_get_localed_label(appid, locale, _getuid(), label);
1681 API int pkgmgrinfo_appinfo_get_metadata_value(pkgmgrinfo_appinfo_h handle, const char *metadata_key, char **metadata_value)
1683 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1684 retvm_if(metadata_key == NULL, PMINFO_R_EINVAL, "metadata_key is NULL");
1685 retvm_if(metadata_value == NULL, PMINFO_R_EINVAL, "metadata_value is NULL");
1687 GList *list_md = NULL;
1688 metadata_x *metadata = NULL;
1689 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1691 list_md = info->app_info->metadata;
1693 for (; list_md; list_md = list_md->next) {
1694 metadata = (metadata_x *)list_md->data;
1695 if (metadata && metadata->key) {
1696 if (strcasecmp(metadata->key, metadata_key) == 0) {
1697 if (metadata->value == NULL)
1698 *metadata_value = "";
1700 *metadata_value = (char *)metadata->value;
1706 return PMINFO_R_EINVAL;
1709 static pkgmgrinfo_app_component __appcomponent_convert(const char *comp)
1711 if (strcasecmp(comp, "uiapp") == 0)
1712 return PMINFO_UI_APP;
1713 else if (strcasecmp(comp, "svcapp") == 0)
1714 return PMINFO_SVC_APP;
1715 else if (strcasecmp(comp, "widgetapp") == 0)
1716 return PMINFO_WIDGET_APP;
1717 else if (strcasecmp(comp, "watchapp") == 0)
1718 return PMINFO_WATCH_APP;
1723 static const char *__appcomponent_str(pkgmgrinfo_app_component comp)
1728 case PMINFO_SVC_APP:
1730 case PMINFO_WIDGET_APP:
1732 case PMINFO_WATCH_APP:
1739 API int pkgmgrinfo_appinfo_get_component(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_component *component)
1741 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1744 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1745 retvm_if(component == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1747 if (info->app_info == NULL)
1748 return PMINFO_R_ERROR;
1750 comp = __appcomponent_convert(info->app_info->component);
1752 return PMINFO_R_ERROR;
1759 API int pkgmgrinfo_appinfo_get_apptype(pkgmgrinfo_appinfo_h handle, char **app_type)
1761 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1763 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1764 retvm_if(app_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1766 if (info->app_info == NULL || info->app_info->type == NULL)
1767 return PMINFO_R_ERROR;
1768 *app_type = (char *)info->app_info->type;
1773 API int pkgmgrinfo_appinfo_get_operation(pkgmgrinfo_appcontrol_h handle,
1774 int *operation_count, char ***operation)
1776 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1777 retvm_if(operation == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1778 retvm_if(operation_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1779 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1780 *operation_count = data->operation_count;
1781 *operation = data->operation;
1785 API int pkgmgrinfo_appinfo_get_uri(pkgmgrinfo_appcontrol_h handle,
1786 int *uri_count, char ***uri)
1788 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1789 retvm_if(uri == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1790 retvm_if(uri_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1791 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1792 *uri_count = data->uri_count;
1797 API int pkgmgrinfo_appinfo_get_mime(pkgmgrinfo_appcontrol_h handle,
1798 int *mime_count, char ***mime)
1800 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1801 retvm_if(mime == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1802 retvm_if(mime_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1803 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1804 *mime_count = data->mime_count;
1809 API int pkgmgrinfo_appinfo_get_subapp(pkgmgrinfo_appcontrol_h handle,
1810 int *subapp_count, char ***subapp)
1812 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1813 retvm_if(subapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1814 retvm_if(subapp_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1815 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1816 *subapp_count = data->subapp_count;
1817 *subapp = data->subapp;
1821 API int pkgmgrinfo_appinfo_get_notification_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1826 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1828 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1829 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1831 if (info->app_info == NULL)
1832 return PMINFO_R_ERROR;
1834 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1835 ptr = (icon_x *)tmp->data;
1836 if (ptr == NULL || ptr->section == NULL)
1839 val = (char *)ptr->section;
1840 if (val && strcmp(val, "notification") == 0) {
1841 *icon = (char *)ptr->text;
1846 return PMINFO_R_ERROR;
1849 API int pkgmgrinfo_appinfo_get_recent_image_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_recentimage *type)
1852 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1854 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1855 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1857 if (info->app_info == NULL || info->app_info->recentimage == NULL)
1858 return PMINFO_R_ERROR;
1860 val = (char *)info->app_info->recentimage;
1861 if (strcasecmp(val, "capture") == 0)
1862 *type = PMINFO_RECENTIMAGE_USE_CAPTURE;
1863 else if (strcasecmp(val, "icon") == 0)
1864 *type = PMINFO_RECENTIMAGE_USE_ICON;
1866 *type = PMINFO_RECENTIMAGE_USE_NOTHING;
1871 API int pkgmgrinfo_appinfo_get_preview_image(pkgmgrinfo_appinfo_h handle, char **preview_img)
1876 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1878 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1879 retvm_if(preview_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1881 if (info->app_info == NULL)
1882 return PMINFO_R_ERROR;
1884 for (tmp = info->app_info->image; tmp; tmp = tmp->next) {
1885 ptr = (image_x *)tmp->data;
1886 if (ptr == NULL || ptr->section == NULL)
1889 val = (char *)ptr->section;
1890 if (val && strcmp(val, "preview") == 0) {
1891 *preview_img = (char *)ptr->text;
1896 return PMINFO_R_ERROR;
1899 API int pkgmgrinfo_appinfo_get_permission_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_permission_type *permission)
1902 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1904 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1905 retvm_if(permission == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1907 val = info->app_info->permission_type;
1909 return PMINFO_R_ERROR;
1911 if (strcmp(val, "signature") == 0)
1912 *permission = PMINFO_PERMISSION_SIGNATURE;
1913 else if (strcmp(val, "privilege") == 0)
1914 *permission = PMINFO_PERMISSION_PRIVILEGE;
1916 *permission = PMINFO_PERMISSION_NORMAL;
1921 API int pkgmgrinfo_appinfo_get_component_type(pkgmgrinfo_appinfo_h handle, char **component_type)
1923 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1925 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1926 retvm_if(component_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1928 if (info->app_info == NULL || info->app_info->component_type == NULL)
1929 return PMINFO_R_ERROR;
1931 *component_type = (char *)info->app_info->component_type;
1936 API int pkgmgrinfo_appinfo_get_hwacceleration(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_hwacceleration *hwacceleration)
1939 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1941 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1942 retvm_if(hwacceleration == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1944 if (info->app_info == NULL || info->app_info->hwacceleration == NULL)
1945 return PMINFO_R_ERROR;
1947 val = (char *)info->app_info->hwacceleration;
1948 if (strcasecmp(val, "off") == 0)
1949 *hwacceleration = PMINFO_HWACCELERATION_OFF;
1950 else if (strcasecmp(val, "on") == 0)
1951 *hwacceleration = PMINFO_HWACCELERATION_ON;
1953 *hwacceleration = PMINFO_HWACCELERATION_DEFAULT;
1958 API int pkgmgrinfo_appinfo_get_screenreader(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_screenreader *screenreader)
1961 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1963 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1964 retvm_if(screenreader == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1966 if (info->app_info == NULL || info->app_info->screenreader == NULL)
1967 return PMINFO_R_ERROR;
1969 val = (char *)info->app_info->screenreader;
1970 if (strcasecmp(val, "screenreader-off") == 0)
1971 *screenreader = PMINFO_SCREENREADER_OFF;
1972 else if (strcasecmp(val, "screenreader-on") == 0)
1973 *screenreader = PMINFO_SCREENREADER_ON;
1975 *screenreader = PMINFO_SCREENREADER_USE_SYSTEM_SETTING;
1980 API int pkgmgrinfo_appinfo_get_effectimage(pkgmgrinfo_appinfo_h handle, char **portrait_img, char **landscape_img)
1982 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1984 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1985 retvm_if(portrait_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1986 retvm_if(landscape_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1988 if (info->app_info == NULL)
1989 return PMINFO_R_ERROR;
1991 if (info->app_info->portraitimg == NULL)
1994 *portrait_img = (char *)info->app_info->portraitimg;
1996 if (info->app_info->landscapeimg == NULL)
1997 *landscape_img = "";
1999 *landscape_img = (char *)info->app_info->landscapeimg;
2004 API int pkgmgrinfo_appinfo_get_effectimage_type(pkgmgrinfo_appinfo_h handle, char **effectimage_type)
2006 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2008 if (handle == NULL || effectimage_type == NULL) {
2009 LOGE("invalid parameter");
2010 return PMINFO_R_EINVAL;
2013 if (info->app_info == NULL || info->app_info->effectimage_type == NULL)
2014 return PMINFO_R_ERROR;
2016 *effectimage_type = (char *)info->app_info->effectimage_type;
2021 API int pkgmgrinfo_appinfo_get_submode_mainid(pkgmgrinfo_appinfo_h handle, char **submode_mainid)
2023 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2025 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2026 retvm_if(submode_mainid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2028 if (info->app_info == NULL)
2029 return PMINFO_R_ERROR;
2031 if (info->app_info->submode_mainid == NULL)
2032 *submode_mainid = "";
2034 *submode_mainid = (char *)info->app_info->submode_mainid;
2039 API int pkgmgrinfo_appinfo_get_installed_storage_location(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_installed_storage *storage)
2041 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2042 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2044 if (info->app_info && info->app_info->installed_storage) {
2045 if (strcmp(info->app_info->installed_storage, "installed_internal") == 0)
2046 *storage = PMINFO_INTERNAL_STORAGE;
2047 else if (strcmp(info->app_info->installed_storage, "installed_external") == 0)
2048 *storage = PMINFO_EXTERNAL_STORAGE;
2050 return PMINFO_R_ERROR;
2052 return PMINFO_R_ERROR;
2058 API int pkgmgrinfo_appinfo_get_launch_mode(pkgmgrinfo_appinfo_h handle, char **mode)
2060 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2062 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2063 retvm_if(mode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2065 if (info->app_info->launch_mode == NULL)
2066 return PMINFO_R_ERROR;
2068 *mode = (char *)(info->app_info->launch_mode);
2073 API int pkgmgrinfo_appinfo_get_alias_appid(pkgmgrinfo_appinfo_h handle, char **alias_appid)
2075 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2077 if (handle == NULL || alias_appid == NULL) {
2078 LOGE("invalid parameter");
2079 return PMINFO_R_EINVAL;
2082 if (info->app_info == NULL || info->app_info->alias_appid == NULL)
2083 return PMINFO_R_ERROR;
2085 *alias_appid = (char *)info->app_info->alias_appid;
2090 API int pkgmgrinfo_appinfo_get_effective_appid(pkgmgrinfo_appinfo_h handle, char **effective_appid)
2092 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2094 if (handle == NULL || effective_appid == NULL) {
2095 LOGE("invalid parameter");
2096 return PMINFO_R_EINVAL;
2099 if (info->app_info == NULL)
2100 return PMINFO_R_ERROR;
2102 if (info->app_info->effective_appid == NULL)
2103 *effective_appid = "";
2105 *effective_appid = (char *)info->app_info->effective_appid;
2110 API int pkgmgrinfo_appinfo_get_tep_name(pkgmgrinfo_appinfo_h handle, char **tep_name)
2112 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2114 if (handle == NULL || tep_name == NULL) {
2115 LOGE("invalid parameter");
2116 return PMINFO_R_EINVAL;
2119 if (info->app_info == NULL)
2120 return PMINFO_R_ERROR;
2122 if (info->app_info->tep_name == NULL)
2125 *tep_name = (char *)info->app_info->tep_name;
2130 API int pkgmgrinfo_appinfo_get_zip_mount_file(pkgmgrinfo_appinfo_h handle, char **zip_mount_file)
2132 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2134 if (handle == NULL || zip_mount_file == NULL) {
2135 LOGE("invalid parameter");
2136 return PMINFO_R_EINVAL;
2139 if (info->app_info == NULL)
2140 return PMINFO_R_ERROR;
2142 if (info->app_info->zip_mount_file == NULL)
2143 *zip_mount_file = "";
2145 *zip_mount_file = (char *)info->app_info->zip_mount_file;
2150 API int pkgmgrinfo_appinfo_get_root_path(pkgmgrinfo_appinfo_h handle, char **root_path)
2152 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2154 if (handle == NULL || root_path == NULL) {
2155 LOGE("invalid parameter");
2156 return PMINFO_R_EINVAL;
2159 if (info->app_info == NULL || info->app_info->root_path == NULL)
2160 return PMINFO_R_ERROR;
2162 *root_path = (char *)info->app_info->root_path;
2167 API int pkgmgrinfo_appinfo_get_api_version(pkgmgrinfo_appinfo_h handle, char **api_version)
2169 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2171 if (handle == NULL || api_version == NULL) {
2172 LOGE("invalid parameter");
2173 return PMINFO_R_EINVAL;
2176 if (info->app_info == NULL || info->app_info->api_version == NULL)
2177 return PMINFO_R_ERROR;
2179 *api_version = (char *)info->app_info->api_version;
2184 API int pkgmgrinfo_appinfo_get_installed_time(pkgmgrinfo_appinfo_h handle, int *installed_time)
2186 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2188 if (handle == NULL || installed_time == NULL) {
2189 LOGE("invalid parameter");
2190 return PMINFO_R_EINVAL;
2193 if (info->app_info == NULL || info->app_info->package_installed_time == NULL)
2194 return PMINFO_R_ERROR;
2196 *installed_time = atoi(info->app_info->package_installed_time);
2201 API int pkgmgrinfo_appinfo_usr_get_datacontrol_info(const char *providerid,
2202 const char *type, uid_t uid, char **appid, char **access)
2204 retvm_if(providerid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
2205 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
2206 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2207 retvm_if(access == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2209 int ret = PMINFO_R_OK;
2211 sqlite3_stmt *stmt = NULL;
2214 ret = __open_manifest_db(uid, true);
2215 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
2217 /*Start constructing query*/
2218 query = sqlite3_mprintf("select * from package_app_data_control where providerid=%Q and type=%Q", providerid, type);
2219 tryvm_if(query == NULL, ret = PMINFO_R_ERROR, "Out of memory");
2222 ret = sqlite3_prepare_v2(GET_DB(manifest_db), query, strlen(query), &stmt, NULL);
2223 tryvm_if(ret != PMINFO_R_OK, ret = PMINFO_R_ERROR, "sqlite3_prepare_v2 failed[%s]\n", query);
2226 ret = sqlite3_step(stmt);
2227 tryvm_if((ret != SQLITE_ROW) || (ret == SQLITE_DONE), ret = PMINFO_R_ERROR, "No records found");
2229 *appid = strdup((char *)sqlite3_column_text(stmt, 0));
2230 *access = strdup((char *)sqlite3_column_text(stmt, 2));
2235 sqlite3_free(query);
2236 sqlite3_finalize(stmt);
2237 __close_manifest_db();
2241 API int pkgmgrinfo_appinfo_get_datacontrol_info(const char *providerid,
2242 const char *type, char **appid, char **access)
2244 return pkgmgrinfo_appinfo_usr_get_datacontrol_info(providerid,
2245 type, _getuid(), appid, access);
2248 API int pkgmgrinfo_appinfo_usr_get_datacontrol_appid(const char *providerid, uid_t uid, char **appid)
2250 retvm_if(providerid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
2251 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2253 int ret = PMINFO_R_OK;
2255 sqlite3_stmt *stmt = NULL;
2258 ret = __open_manifest_db(uid, true);
2259 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
2261 /*Start constructing query*/
2262 query = sqlite3_mprintf("select * from package_app_data_control where providerid=%Q", providerid);
2263 tryvm_if(query == NULL, ret = PMINFO_R_ERROR, "Out of memory");
2266 ret = sqlite3_prepare_v2(GET_DB(manifest_db), query, strlen(query), &stmt, NULL);
2267 tryvm_if(ret != PMINFO_R_OK, ret = PMINFO_R_ERROR, "sqlite3_prepare_v2 failed[%s]\n", query);
2270 ret = sqlite3_step(stmt);
2271 tryvm_if((ret != SQLITE_ROW) || (ret == SQLITE_DONE), ret = PMINFO_R_ERROR, "No records found");
2273 *appid = strdup((char *)sqlite3_column_text(stmt, 0));
2278 sqlite3_free(query);
2279 sqlite3_finalize(stmt);
2280 __close_manifest_db();
2284 API int pkgmgrinfo_appinfo_get_datacontrol_appid(const char *providerid, char **appid)
2286 return pkgmgrinfo_appinfo_usr_get_datacontrol_appid(providerid, _getuid(), appid);
2289 API int pkgmgrinfo_appinfo_usr_get_datacontrol_trusted_info(const char *providerid,
2290 const char *type, uid_t uid, char **appid, bool *is_trusted)
2292 retvm_if(providerid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
2293 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2295 int ret = PMINFO_R_OK;
2297 sqlite3_stmt *stmt = NULL;
2300 ret = __open_manifest_db(uid, true);
2301 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
2303 /*Start constructing query*/
2304 query = sqlite3_mprintf("SELECT app_id, trusted FROM package_app_data_control WHERE providerid=%Q AND type=%Q", providerid, type);
2305 tryvm_if(query == NULL, ret = PMINFO_R_ERROR, "Out of memory");
2308 ret = sqlite3_prepare_v2(GET_DB(manifest_db), query, strlen(query), &stmt, NULL);
2309 tryvm_if(ret != PMINFO_R_OK, ret = PMINFO_R_ERROR, "sqlite3_prepare_v2 failed[%s]\n", query);
2312 ret = sqlite3_step(stmt);
2313 tryvm_if((ret != SQLITE_ROW) || (ret == SQLITE_DONE), ret = PMINFO_R_ERROR, "No records found");
2315 _save_column_str(stmt, 0, appid);
2316 *is_trusted = _get_bool_value((char *)sqlite3_column_text(stmt, 1));
2321 sqlite3_free(query);
2322 sqlite3_finalize(stmt);
2323 __close_manifest_db();
2327 API int pkgmgrinfo_appinfo_get_datacontrol_trsuted_info(const char *providerid,
2328 const char *type, char **appid, bool *is_trusted)
2330 return pkgmgrinfo_appinfo_usr_get_datacontrol_trusted_info(providerid,
2331 type, _getuid(), appid, is_trusted);
2334 API int pkgmgrinfo_appinfo_usr_foreach_datacontrol_privileges(const char *providerid, const char *type,
2335 pkgmgrinfo_pkg_privilege_list_cb privilege_func, void *user_data, uid_t uid)
2337 retvm_if(providerid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
2338 retvm_if(privilege_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2340 int ret = PMINFO_R_OK;
2342 sqlite3_stmt *stmt = NULL;
2345 ret = __open_manifest_db(uid, true);
2346 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
2348 /*Start constructing query*/
2349 query = sqlite3_mprintf("SELECT privilege FROM package_app_data_control_privilege "
2350 "WHERE providerid=%Q AND type=%Q", providerid, type);
2351 tryvm_if(query == NULL, ret = PMINFO_R_ERROR, "Out of memory");
2354 ret = sqlite3_prepare_v2(GET_DB(manifest_db), query, strlen(query), &stmt, NULL);
2355 tryvm_if(ret != PMINFO_R_OK, ret = PMINFO_R_ERROR, "sqlite3_prepare_v2 failed[%s]\n", query);
2357 while (sqlite3_step(stmt) == SQLITE_ROW) {
2359 privilege = (char *)sqlite3_column_text(stmt, 0);
2360 ret = privilege_func(privilege, user_data);
2368 sqlite3_free(query);
2369 sqlite3_finalize(stmt);
2370 __close_manifest_db();
2374 API int pkgmgrinfo_appinfo_foreach_datacontrol_privileges(const char *providerid, const char *type,
2375 pkgmgrinfo_pkg_privilege_list_cb privilege_func, void *user_data)
2377 return pkgmgrinfo_appinfo_usr_foreach_datacontrol_privileges(providerid, type, privilege_func,
2378 user_data, _getuid());
2381 API int pkgmgrinfo_appinfo_get_support_mode(pkgmgrinfo_appinfo_h handle, int *support_mode)
2383 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2384 retvm_if(support_mode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2386 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2387 if (info->app_info->support_mode)
2388 *support_mode = atoi(info->app_info->support_mode);
2395 API int pkgmgrinfo_appinfo_foreach_category(pkgmgrinfo_appinfo_h handle,
2396 pkgmgrinfo_app_category_list_cb category_func, void *user_data)
2398 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2399 retvm_if(category_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2401 const char *category;
2403 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2405 if (info->app_info == NULL)
2406 return PMINFO_R_ERROR;
2408 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
2409 category = (const char *)tmp->data;
2411 ret = category_func(category, user_data);
2419 API int pkgmgrinfo_appinfo_foreach_metadata(pkgmgrinfo_appinfo_h handle,
2420 pkgmgrinfo_app_metadata_list_cb metadata_func, void *user_data)
2422 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2423 retvm_if(metadata_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2427 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2429 if (info->app_info == NULL)
2430 return PMINFO_R_ERROR;
2432 for (tmp = info->app_info->metadata; tmp; tmp = tmp->next) {
2433 ptr = (metadata_x *)tmp->data;
2437 ret = metadata_func(ptr->key, ptr->value ? ptr->value : "", user_data);
2445 API int pkgmgrinfo_appinfo_usr_foreach_appcontrol_privileges(const char *appid,
2446 const char *operation, const char *uri, const char *mime,
2447 pkgmgrinfo_pkg_privilege_list_cb privilege_func,
2448 void *user_data, uid_t uid)
2450 static const char query_raw[] =
2451 "SELECT privilege FROM package_app_app_control_privilege "
2452 "WHERE app_id=%Q AND app_control=%Q";
2457 char app_control[BUFSIZE];
2459 if (appid == NULL || operation == NULL || privilege_func == NULL) {
2460 LOGE("invalid parameter");
2461 return PMINFO_R_EINVAL;
2464 snprintf(app_control, sizeof(app_control), "%s|%s|%s", operation,
2465 uri ? uri : "NULL", mime ? mime : "NULL");
2467 ret = __open_manifest_db(uid, true);
2468 if (ret != SQLITE_OK) {
2469 LOGE("open db failed");
2470 return PMINFO_R_ERROR;
2473 query = sqlite3_mprintf(query_raw, appid, app_control);
2474 if (query == NULL) {
2475 LOGE("out of memory");
2476 __close_manifest_db();
2477 return PMINFO_R_ERROR;
2480 ret = sqlite3_prepare_v2(GET_DB(manifest_db), query, strlen(query),
2482 sqlite3_free(query);
2483 if (ret != PMINFO_R_OK) {
2484 LOGE("prepare failed: %s", sqlite3_errmsg(GET_DB(manifest_db)));
2485 __close_manifest_db();
2486 return PMINFO_R_ERROR;
2489 while (sqlite3_step(stmt) == SQLITE_ROW) {
2490 privilege = (char *)sqlite3_column_text(stmt, 0);
2491 ret = privilege_func(privilege, user_data);
2496 sqlite3_finalize(stmt);
2497 __close_manifest_db();
2502 API int pkgmgrinfo_appinfo_foreach_appcontrol_privileges(const char *appid,
2503 const char *operation, const char *uri, const char *mime,
2504 pkgmgrinfo_pkg_privilege_list_cb privilege_func,
2507 return pkgmgrinfo_appinfo_usr_foreach_appcontrol_privileges(appid,
2508 operation, uri, mime, privilege_func, user_data,
2512 API int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
2513 pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
2515 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2516 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2518 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2519 appcontrol_x *appcontrol;
2522 if (info->app_info == NULL)
2523 return PMINFO_R_ERROR;
2525 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
2526 appcontrol = (appcontrol_x *)tmp->data;
2527 if (appcontrol == NULL)
2529 ret = appcontrol_func(appcontrol->operation, appcontrol->uri, appcontrol->mime, user_data);
2537 API int pkgmgrinfo_appinfo_foreach_background_category(
2538 pkgmgrinfo_appinfo_h handle,
2539 pkgmgrinfo_app_background_category_list_cb category_func,
2542 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2546 if (handle == NULL || category_func == NULL || info->app_info == NULL) {
2547 LOGE("invalid parameter");
2548 return PMINFO_R_EINVAL;
2551 for (tmp = info->app_info->background_category; tmp; tmp = tmp->next) {
2552 category = (char *)tmp->data;
2553 if (category == NULL)
2556 if (category_func(category, user_data) < 0)
2563 API int pkgmgrinfo_appinfo_foreach_splash_screen(pkgmgrinfo_appinfo_h handle,
2564 pkgmgrinfo_app_splash_screen_list_cb splash_screen_func,
2567 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2568 splashscreen_x *splashscreen;
2572 if (info == NULL || info->app_info == NULL
2573 || splash_screen_func == NULL) {
2574 LOGE("invalid parameter");
2575 return PMINFO_R_EINVAL;
2578 for (tmp = info->app_info->splashscreens; tmp; tmp = tmp->next) {
2579 splashscreen = (splashscreen_x *)tmp->data;
2580 if (splashscreen == NULL)
2582 ret = splash_screen_func(splashscreen->src,
2584 splashscreen->orientation,
2585 splashscreen->indicatordisplay,
2586 splashscreen->operation,
2587 splashscreen->color_depth,
2596 API int pkgmgrinfo_appinfo_is_nodisplay(pkgmgrinfo_appinfo_h handle, bool *nodisplay)
2598 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2599 retvm_if(nodisplay == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2600 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2602 if (info->app_info == NULL || info->app_info->nodisplay == NULL)
2603 return PMINFO_R_ERROR;
2605 *nodisplay = _get_bool_value(info->app_info->nodisplay);
2610 API int pkgmgrinfo_appinfo_is_multiple(pkgmgrinfo_appinfo_h handle, bool *multiple)
2612 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2613 retvm_if(multiple == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2614 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2616 if (info->app_info == NULL || info->app_info->multiple == NULL)
2617 return PMINFO_R_ERROR;
2619 *multiple = _get_bool_value(info->app_info->multiple);
2624 API int pkgmgrinfo_appinfo_is_indicator_display_allowed(pkgmgrinfo_appinfo_h handle, bool *indicator_disp)
2626 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2627 retvm_if(indicator_disp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2628 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2630 if (info->app_info == NULL || info->app_info->indicatordisplay == NULL)
2631 return PMINFO_R_ERROR;
2633 *indicator_disp = _get_bool_value(info->app_info->indicatordisplay);
2638 API int pkgmgrinfo_appinfo_is_taskmanage(pkgmgrinfo_appinfo_h handle, bool *taskmanage)
2640 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2641 retvm_if(taskmanage == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2642 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2644 if (info->app_info == NULL || info->app_info->taskmanage == NULL)
2645 return PMINFO_R_ERROR;
2647 *taskmanage = _get_bool_value(info->app_info->taskmanage);
2652 API int pkgmgrinfo_appinfo_is_enabled(pkgmgrinfo_appinfo_h handle, bool *enabled)
2654 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2655 retvm_if(enabled == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2656 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2658 if (info->app_info == NULL || info->app_info->is_disabled == NULL)
2659 return PMINFO_R_ERROR;
2661 *enabled = !_get_bool_value(info->app_info->is_disabled);
2666 API int pkgmgrinfo_appinfo_is_onboot(pkgmgrinfo_appinfo_h handle, bool *onboot)
2668 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2669 retvm_if(onboot == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2670 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2672 if (info->app_info == NULL || info->app_info->onboot == NULL)
2673 return PMINFO_R_ERROR;
2675 *onboot = _get_bool_value(info->app_info->onboot);
2680 API int pkgmgrinfo_appinfo_is_autorestart(pkgmgrinfo_appinfo_h handle, bool *autorestart)
2682 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2683 retvm_if(autorestart == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2684 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2686 if (info->app_info == NULL || info->app_info->autorestart == NULL)
2687 return PMINFO_R_ERROR;
2689 *autorestart = _get_bool_value(info->app_info->autorestart);
2694 API int pkgmgrinfo_appinfo_is_mainapp(pkgmgrinfo_appinfo_h handle, bool *mainapp)
2696 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2697 retvm_if(mainapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2698 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2700 if (info->app_info == NULL || info->app_info->mainapp == NULL)
2701 return PMINFO_R_ERROR;
2703 *mainapp = _get_bool_value(info->app_info->mainapp);
2708 API int pkgmgrinfo_appinfo_is_preload(pkgmgrinfo_appinfo_h handle, bool *preload)
2710 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2711 retvm_if(preload == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2712 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2714 if (info->app_info == NULL || info->app_info->preload == NULL)
2715 return PMINFO_R_ERROR;
2717 *preload = _get_bool_value(info->app_info->preload);
2722 API int pkgmgrinfo_appinfo_is_submode(pkgmgrinfo_appinfo_h handle, bool *submode)
2724 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2725 retvm_if(submode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2726 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2728 if (info->app_info == NULL || info->app_info->submode == NULL)
2729 return PMINFO_R_ERROR;
2731 *submode = _get_bool_value(info->app_info->submode);
2736 API int pkgmgrinfo_appinfo_is_process_pool(pkgmgrinfo_appinfo_h handle, bool *process_pool)
2738 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2740 if (handle == NULL || process_pool == NULL) {
2741 LOGE("invalid parameter");
2742 return PMINFO_R_EINVAL;
2745 if (info->app_info == NULL)
2746 return PMINFO_R_ERROR;
2748 *process_pool = _get_bool_value(info->app_info->process_pool);
2753 API int pkgmgrinfo_appinfo_is_category_exist(pkgmgrinfo_appinfo_h handle, const char *category, bool *exist)
2755 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2756 retvm_if(category == NULL, PMINFO_R_EINVAL, "category is NULL");
2757 retvm_if(exist == NULL, PMINFO_R_EINVAL, "exist is NULL");
2761 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2763 if (info->app_info == NULL)
2764 return PMINFO_R_ERROR;
2767 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
2768 val = (const char *)tmp->data;
2771 if (strcasecmp(val, category) == 0) {
2780 API int pkgmgrinfo_appinfo_is_ui_gadget(pkgmgrinfo_appinfo_h handle,
2783 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2785 if (info == NULL || info->app_info == NULL || ui_gadget == NULL) {
2786 _LOGE("invalid parameter");
2787 return PMINFO_R_EINVAL;
2789 if (info->app_info->ui_gadget == NULL)
2790 info->app_info->ui_gadget = strdup("false");
2792 *ui_gadget = _get_bool_value(info->app_info->ui_gadget);
2797 API int pkgmgrinfo_appinfo_is_support_disable(pkgmgrinfo_appinfo_h handle,
2798 bool *support_disable)
2800 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2802 if (info == NULL || info->app_info == NULL || support_disable == NULL) {
2803 _LOGE("invalid parameter");
2804 return PMINFO_R_EINVAL;
2807 *support_disable = _get_bool_value(info->app_info->support_disable);
2812 API int pkgmgrinfo_appinfo_is_removable(pkgmgrinfo_appinfo_h handle,
2815 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2817 if (info == NULL || info->app_info == NULL || removable == NULL) {
2818 _LOGE("invalid parameter");
2819 return PMINFO_R_EINVAL;
2822 *removable = _get_bool_value(info->app_info->removable);
2827 API int pkgmgrinfo_appinfo_is_system(pkgmgrinfo_appinfo_h handle, bool *system)
2829 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2831 if (info == NULL || info->app_info == NULL || system == NULL) {
2832 _LOGE("invalid parameter");
2833 return PMINFO_R_EINVAL;
2836 *system = _get_bool_value(info->app_info->package_system);
2841 API int pkgmgrinfo_appinfo_is_disabled(pkgmgrinfo_appinfo_h handle, bool *disabled)
2843 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2844 retvm_if(disabled == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2845 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2847 if (info->app_info == NULL || info->app_info->is_disabled == NULL)
2848 return PMINFO_R_ERROR;
2850 *disabled = _get_bool_value(info->app_info->is_disabled);
2855 API int pkgmgrinfo_appinfo_is_global(pkgmgrinfo_appinfo_h handle, bool *global)
2857 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2859 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2860 retvm_if(global == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2862 if (info->app_info == NULL || info->app_info->for_all_users == NULL)
2863 return PMINFO_R_ERROR;
2865 *global = _get_bool_value(info->app_info->for_all_users);
2870 API int pkgmgrinfo_appinfo_get_splash_screen_display(pkgmgrinfo_appinfo_h handle, bool *splash_screen_display)
2872 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2874 if (info == NULL || splash_screen_display == NULL) {
2875 _LOGE("Invalid parameter");
2876 return PMINFO_R_EINVAL;
2879 if (info->app_info == NULL || info->app_info->splash_screen_display == NULL)
2880 return PMINFO_R_ERROR;
2882 *splash_screen_display = _get_bool_value(info->app_info->splash_screen_display);
2887 API int pkgmgrinfo_appinfo_get_setup_appid(pkgmgrinfo_appinfo_h handle, char **setup_appid)
2889 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2891 if (info == NULL || setup_appid == NULL) {
2892 _LOGE("Invalid parameter");
2893 return PMINFO_R_EINVAL;
2896 if (info->app_info == NULL || info->app_info->setup_appid == NULL)
2897 return PMINFO_R_ERROR;
2899 *setup_appid = info->app_info->setup_appid;
2903 API int pkgmgrinfo_appinfo_is_support_ambient(pkgmgrinfo_appinfo_h handle,
2904 bool *support_ambient)
2906 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2908 if (info == NULL || support_ambient == NULL) {
2909 _LOGE("Invalid parameter");
2910 return PMINFO_R_EINVAL;
2913 if (info->app_info == NULL || info->app_info->support_ambient == NULL)
2914 return PMINFO_R_ERROR;
2916 *support_ambient = _get_bool_value(info->app_info->support_ambient);
2921 API int pkgmgrinfo_appinfo_destroy_appinfo(pkgmgrinfo_appinfo_h handle)
2923 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2924 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2925 __cleanup_appinfo(info);
2929 API int pkgmgrinfo_appinfo_filter_create(pkgmgrinfo_appinfo_filter_h *handle)
2931 return (pkgmgrinfo_pkginfo_filter_create(handle));
2934 API int pkgmgrinfo_appinfo_filter_destroy(pkgmgrinfo_appinfo_filter_h handle)
2936 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
2939 static gint __compare_func(gconstpointer data1, gconstpointer data2)
2941 pkgmgrinfo_node_x *node1 = (pkgmgrinfo_node_x *)data1;
2942 pkgmgrinfo_node_x *node2 = (pkgmgrinfo_node_x *)data2;
2943 if (node1->prop == node2->prop)
2945 else if (node1->prop > node2->prop)
2951 API int pkgmgrinfo_appinfo_filter_add_int(pkgmgrinfo_appinfo_filter_h handle,
2952 const char *property, const int value)
2954 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2955 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2956 char buf[PKG_VALUE_STRING_LEN_MAX] = {'\0'};
2958 GSList *link = NULL;
2960 prop = _pminfo_appinfo_convert_to_prop_int(property);
2961 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_INT ||
2962 prop > E_PMINFO_APPINFO_PROP_APP_MAX_INT) {
2963 _LOGE("Invalid Integer Property\n");
2964 return PMINFO_R_EINVAL;
2966 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2967 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1, sizeof(pkgmgrinfo_node_x));
2969 _LOGE("Out of Memory!!!\n");
2970 return PMINFO_R_ERROR;
2972 snprintf(buf, PKG_VALUE_STRING_LEN_MAX - 1, "%d", value);
2973 val = strndup(buf, PKG_VALUE_STRING_LEN_MAX - 1);
2975 _LOGE("Out of Memory\n");
2978 return PMINFO_R_ERROR;
2982 /*If API is called multiple times for same property, we should override the previous values.
2983 Last value set will be used for filtering.*/
2984 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2986 filter->list = g_slist_delete_link(filter->list, link);
2987 filter->list = g_slist_append(filter->list, (gpointer)node);
2992 API int pkgmgrinfo_appinfo_filter_add_bool(pkgmgrinfo_appinfo_filter_h handle,
2993 const char *property, const bool value)
2995 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2996 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2998 GSList *link = NULL;
3000 prop = _pminfo_appinfo_convert_to_prop_bool(property);
3001 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_BOOL ||
3002 prop > E_PMINFO_APPINFO_PROP_APP_MAX_BOOL) {
3003 _LOGE("Invalid Boolean Property\n");
3004 return PMINFO_R_EINVAL;
3006 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
3007 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1, sizeof(pkgmgrinfo_node_x));
3009 _LOGE("Out of Memory!!!\n");
3010 return PMINFO_R_ERROR;
3013 val = strndup("true", 4);
3015 val = strndup("false", 5);
3017 _LOGE("Out of Memory\n");
3020 return PMINFO_R_ERROR;
3024 /*If API is called multiple times for same property, we should override the previous values.
3025 Last value set will be used for filtering.*/
3026 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
3028 filter->list = g_slist_delete_link(filter->list, link);
3029 filter->list = g_slist_append(filter->list, (gpointer)node);
3034 API int pkgmgrinfo_appinfo_filter_add_string(pkgmgrinfo_appinfo_filter_h handle,
3035 const char *property, const char *value)
3037 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3038 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3039 retvm_if(value == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3041 pkgmgrinfo_node_x *ptr = NULL;
3042 char prev[PKG_STRING_LEN_MAX] = {'\0'};
3043 char temp[PKG_STRING_LEN_MAX] = {'\0'};
3044 GSList *link = NULL;
3046 prop = _pminfo_appinfo_convert_to_prop_str(property);
3047 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_STR ||
3048 prop > E_PMINFO_APPINFO_PROP_APP_MAX_STR) {
3049 _LOGE("Invalid String Property\n");
3050 return PMINFO_R_EINVAL;
3052 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
3053 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1, sizeof(pkgmgrinfo_node_x));
3055 _LOGE("Out of Memory!!!\n");
3056 return PMINFO_R_ERROR;
3060 case E_PMINFO_APPINFO_PROP_APP_COMPONENT:
3061 node->value = strdup(value);
3062 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
3064 filter->list = g_slist_delete_link(filter->list, link);
3065 filter->list = g_slist_append(filter->list, (gpointer)node);
3067 case E_PMINFO_APPINFO_PROP_APP_CATEGORY:
3068 val = (char *)calloc(1, PKG_STRING_LEN_MAX);
3070 _LOGE("Out of Memory\n");
3073 return PMINFO_R_ERROR;
3075 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
3077 ptr = (pkgmgrinfo_node_x *)link->data;
3078 strncpy(prev, ptr->value, PKG_STRING_LEN_MAX - 1);
3079 _LOGI("Previous value is %s\n", prev);
3080 filter->list = g_slist_delete_link(filter->list, link);
3081 snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s,%s", prev, value);
3082 strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
3083 _LOGI("New value is %s\n", val);
3085 filter->list = g_slist_append(filter->list, (gpointer)node);
3086 memset(temp, '\0', PKG_STRING_LEN_MAX);
3088 snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s", value);
3089 strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
3090 _LOGI("First value is %s\n", val);
3092 filter->list = g_slist_append(filter->list, (gpointer)node);
3093 memset(temp, '\0', PKG_STRING_LEN_MAX);
3097 node->value = strndup(value, PKG_STRING_LEN_MAX - 1);
3098 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
3100 filter->list = g_slist_delete_link(filter->list, link);
3101 filter->list = g_slist_append(filter->list, (gpointer)node);
3107 API int pkgmgrinfo_appinfo_usr_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count, uid_t uid)
3113 if (handle == NULL || count == NULL) {
3114 _LOGE("invalid parameter");
3115 return PMINFO_R_EINVAL;
3118 locale = _get_system_locale();
3120 return PMINFO_R_ERROR;
3122 list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
3123 __free_applications);
3126 return PMINFO_R_ERROR;
3129 if (__check_disable_filter_exist(
3130 handle, E_APPINFO_DISABLE_TYPE_APP) == false) {
3131 if (pkgmgrinfo_appinfo_filter_add_bool(handle,
3132 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
3133 g_hash_table_destroy(list);
3135 return PMINFO_R_ERROR;
3139 if (__check_disable_filter_exist(
3140 handle, E_APPINFO_DISABLE_TYPE_PKG) == false) {
3141 if (pkgmgrinfo_appinfo_filter_add_bool(handle,
3142 PMINFO_APPINFO_PROP_PKG_DISABLE, false)) {
3143 g_hash_table_destroy(list);
3145 return PMINFO_R_ERROR;
3149 ret = _appinfo_get_applications(uid, uid, locale, handle, 0, list);
3150 if (ret == PMINFO_R_OK && uid != GLOBAL_USER)
3151 ret = _appinfo_get_applications(GLOBAL_USER, uid, locale,
3154 if (ret != PMINFO_R_OK) {
3155 g_hash_table_destroy(list);
3157 return PMINFO_R_ERROR;
3160 *count = g_hash_table_size(list);
3161 g_hash_table_destroy(list);
3167 API int pkgmgrinfo_appinfo_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count)
3169 return pkgmgrinfo_appinfo_usr_filter_count(handle, count, _getuid());
3172 API int pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(
3173 pkgmgrinfo_appinfo_filter_h handle,
3174 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
3176 if (handle == NULL || app_cb == NULL) {
3177 LOGE("invalid parameter");
3178 return PMINFO_R_EINVAL;
3181 if (__check_disable_filter_exist(
3182 handle, E_APPINFO_DISABLE_TYPE_APP) == false) {
3183 if (pkgmgrinfo_appinfo_filter_add_bool(handle,
3184 PMINFO_APPINFO_PROP_APP_DISABLE, false))
3185 return PMINFO_R_ERROR;
3188 if (__check_disable_filter_exist(
3189 handle, E_APPINFO_DISABLE_TYPE_PKG) == false) {
3190 if (pkgmgrinfo_appinfo_filter_add_bool(handle,
3191 PMINFO_APPINFO_PROP_PKG_DISABLE, false))
3192 return PMINFO_R_ERROR;
3195 return _appinfo_get_filtered_foreach_appinfo(uid, handle, PMINFO_APPINFO_GET_ALL, app_cb,
3199 API int pkgmgrinfo_appinfo_filter_foreach_appinfo(pkgmgrinfo_appinfo_filter_h handle,
3200 pkgmgrinfo_app_list_cb app_cb, void *user_data)
3202 return pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(handle, app_cb, user_data, _getuid());
3205 API int pkgmgrinfo_appinfo_metadata_filter_create(pkgmgrinfo_appinfo_metadata_filter_h *handle)
3207 return (pkgmgrinfo_pkginfo_filter_create(handle));
3210 API int pkgmgrinfo_appinfo_metadata_filter_destroy(pkgmgrinfo_appinfo_metadata_filter_h handle)
3212 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
3215 API int pkgmgrinfo_appinfo_metadata_filter_add(
3216 pkgmgrinfo_appinfo_metadata_filter_h handle,
3217 const char *key, const char *value)
3219 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
3220 pkgmgrinfo_metadata_node_x *node;
3222 /* value can be NULL.
3223 * In that case all apps with specified key should be displayed
3226 LOGE("invalid parameter");
3227 return PMINFO_R_EINVAL;
3230 node = calloc(1, sizeof(pkgmgrinfo_metadata_node_x));
3232 LOGE("out of memory");
3233 return PMINFO_R_ERROR;
3236 node->key = strdup(key);
3237 if (value && strlen(value))
3238 node->value = strdup(value);
3240 filter->list_metadata = g_slist_append(filter->list_metadata,
3246 API int pkgmgrinfo_appinfo_usr_metadata_filter_foreach(
3247 pkgmgrinfo_appinfo_metadata_filter_h handle,
3248 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
3250 if (handle == NULL || app_cb == NULL) {
3251 LOGE("invalid parameter");
3252 return PMINFO_R_EINVAL;
3255 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
3256 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
3257 PMINFO_APPINFO_PROP_APP_DISABLE, false))
3258 return PMINFO_R_ERROR;
3260 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
3261 PMINFO_APPINFO_PROP_PKG_DISABLE, false))
3262 return PMINFO_R_ERROR;
3264 return _appinfo_get_filtered_foreach_appinfo(uid, handle, PMINFO_APPINFO_GET_ALL, app_cb,
3268 API int pkgmgrinfo_appinfo_metadata_filter_foreach(
3269 pkgmgrinfo_appinfo_metadata_filter_h handle,
3270 pkgmgrinfo_app_list_cb app_cb, void *user_data)
3272 return pkgmgrinfo_appinfo_usr_metadata_filter_foreach(handle, app_cb,
3273 user_data, _getuid());
3276 API int pkgmgrinfo_appinfo_is_guestmode_visibility(pkgmgrinfo_appinfo_h handle, bool *status)
3279 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3281 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
3282 retvm_if(status == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3284 val = info->app_info->guestmode_visibility;
3285 *status = _get_bool_value(val);