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_appinfo_for_uid[] =
56 " LEFT OUTER JOIN package_app_info_for_uid"
57 " ON ai.app_id=package_app_info_for_uid.app_id ";
59 static int _get_filtered_query(pkgmgrinfo_filter_x *filter,
60 const char *locale, uid_t uid, char **query, GList **bind_params)
64 char *condition = NULL;
65 char buf[MAX_QUERY_LEN] = { '\0' };
66 char tmp_query[MAX_QUERY_LEN] = { '\0' };
67 static const char query_pkg_disable[] = " AND ai.package IN "
68 "(SELECT package FROM package_info WHERE package_disable='false')";
71 strncat(buf, " WHERE 1=1", MAX_QUERY_LEN - len - 1);
72 len += strlen(" WHERE 1=1");
75 strncat(buf, query_pkg_disable, MAX_QUERY_LEN - len - 1);
80 for (list = filter->list; list; list = list->next) {
81 joined |= __get_filter_condition(list->data, uid, &condition, bind_params);
82 if (condition == NULL)
85 strncat(buf, " AND ", MAX_QUERY_LEN - len - 1);
86 len += strlen(" AND ");
88 strncat(buf, condition, sizeof(buf) - len - 1);
89 len += strlen(condition);
94 if (filter->list_metadata) {
95 strncat(buf, " AND (", MAX_QUERY_LEN - len - 1);
96 len += strlen(" AND (");
98 for (list = filter->list_metadata; list; list = list->next) {
99 joined |= __get_metadata_filter_condition(list->data,
100 &condition, bind_params);
101 if (condition == NULL)
103 strncat(buf, condition, sizeof(buf) - len - 1);
104 len += strlen(condition);
108 strncat(buf, " OR ", MAX_QUERY_LEN - len - 1);
109 len += strlen(" OR ");
111 if (filter->list_metadata) {
112 strncat(buf, "1=0)", MAX_QUERY_LEN - len - 1);
113 len += strlen("1=0)");
116 if (joined & E_PMINFO_APPINFO_JOIN_LOCALIZED_INFO) {
117 strncat(tmp_query, join_localized_info, MAX_QUERY_LEN - len - 1);
118 len += strlen(join_localized_info);
119 *bind_params = g_list_append(*bind_params, strdup(locale));
121 if (joined & E_PMINFO_APPINFO_JOIN_CATEGORY) {
122 strncat(tmp_query, join_category, MAX_QUERY_LEN - len - 1);
123 len += strlen(join_category);
125 if (joined & E_PMINFO_APPINFO_JOIN_APP_CONTROL) {
126 strncat(tmp_query, join_app_control, MAX_QUERY_LEN - len - 1);
127 len += strlen(join_app_control);
129 if (joined & E_PMINFO_APPINFO_JOIN_METADATA) {
130 strncat(tmp_query, join_metadata, MAX_QUERY_LEN - len - 1);
131 len += strlen(join_metadata);
133 if (joined & E_PMINFO_APPINFO_JOIN_APPINFO_FOR_UID) {
134 strncat(tmp_query, join_appinfo_for_uid, MAX_QUERY_LEN - len - 1);
135 len += strlen(join_appinfo_for_uid);
137 strncat(tmp_query, buf, MAX_QUERY_LEN - len - 1);
140 strncat(tmp_query, query_pkg_disable, MAX_QUERY_LEN - len - 1);
142 *query = strdup(tmp_query);
144 return PMINFO_R_ERROR;
149 static int _appinfo_get_category(sqlite3 *db, const char *appid,
152 static const char query_raw[] =
153 "SELECT category FROM package_app_app_category WHERE app_id=%Q";
159 query = sqlite3_mprintf(query_raw, appid);
161 LOGE("out of memory");
162 return PMINFO_R_ERROR;
165 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
167 if (ret != SQLITE_OK) {
168 LOGE("prepare failed: %s", sqlite3_errmsg(db));
169 return PMINFO_R_ERROR;
172 while (sqlite3_step(stmt) == SQLITE_ROW) {
174 _save_column_str(stmt, 0, &val);
176 *category = g_list_append(*category, (gpointer)val);
179 sqlite3_finalize(stmt);
184 static void __parse_appcontrol(GList **appcontrol, char *appcontrol_str)
191 if (appcontrol_str == NULL)
194 dup = strdup(appcontrol_str);
196 ac = calloc(1, sizeof(appcontrol_x));
198 _LOGE("out of memory");
201 token = strtok_r(dup, "|", &ptr);
202 if (token && strcmp(token, "NULL"))
203 ac->operation = strdup(token);
204 token = strtok_r(NULL, "|", &ptr);
205 if (token && strcmp(token, "NULL"))
206 ac->uri = strdup(token);
207 token = strtok_r(NULL, "|", &ptr);
208 if (token && strcmp(token, "NULL"))
209 ac->mime = strdup(token);
210 *appcontrol = g_list_append(*appcontrol, ac);
211 } while ((token = strtok_r(NULL, ";", &ptr)));
216 static int _appinfo_get_app_control(sqlite3 *db, const char *appid,
219 static const char query_raw[] =
220 "SELECT app_control FROM package_app_app_control "
227 query = sqlite3_mprintf(query_raw, appid);
229 LOGE("out of memory");
230 return PMINFO_R_ERROR;
233 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
235 if (ret != SQLITE_OK) {
236 LOGE("prepare failed: %s", sqlite3_errmsg(db));
237 return PMINFO_R_ERROR;
240 while (sqlite3_step(stmt) == SQLITE_ROW) {
242 _save_column_str(stmt, 0, &str);
244 __parse_appcontrol(appcontrol, str);
248 sqlite3_finalize(stmt);
253 static int _appinfo_get_data_control(sqlite3 *db, const char *appid,
256 static const char query_raw[] =
257 "SELECT providerid, access, type, trusted "
258 "FROM package_app_data_control WHERE app_id=%Q";
265 query = sqlite3_mprintf(query_raw, appid);
267 LOGE("out of memory");
268 return PMINFO_R_ERROR;
271 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
273 if (ret != SQLITE_OK) {
274 LOGE("prepare failed: %s", sqlite3_errmsg(db));
275 return PMINFO_R_ERROR;
278 while (sqlite3_step(stmt) == SQLITE_ROW) {
279 info = calloc(1, sizeof(datacontrol_x));
281 LOGE("out of memory");
282 sqlite3_finalize(stmt);
283 return PMINFO_R_ERROR;
286 _save_column_str(stmt, idx++, &info->providerid);
287 _save_column_str(stmt, idx++, &info->access);
288 _save_column_str(stmt, idx++, &info->type);
289 _save_column_str(stmt, idx++, &info->trusted);
290 *datacontrol = g_list_append(*datacontrol, info);
293 sqlite3_finalize(stmt);
298 static int _appinfo_get_metadata(sqlite3 *db, const char *appid,
301 static const char query_raw[] =
302 "SELECT md_key, md_value "
303 "FROM package_app_app_metadata WHERE app_id=%Q";
310 query = sqlite3_mprintf(query_raw, appid);
312 LOGE("out of memory");
313 return PMINFO_R_ERROR;
316 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
318 if (ret != SQLITE_OK) {
319 LOGE("prepare failed: %s", sqlite3_errmsg(db));
320 return PMINFO_R_ERROR;
323 while (sqlite3_step(stmt) == SQLITE_ROW) {
324 info = calloc(1, sizeof(metadata_x));
326 LOGE("out of memory");
327 sqlite3_finalize(stmt);
328 return PMINFO_R_ERROR;
331 _save_column_str(stmt, idx++, &info->key);
332 _save_column_str(stmt, idx++, &info->value);
333 *metadata = g_list_append(*metadata, info);
336 sqlite3_finalize(stmt);
342 static int _appinfo_get_splashscreens(sqlite3 *db, const char *appid,
343 GList **splashscreens)
345 static const char query_raw[] =
346 "SELECT src, type, orientation, indicatordisplay, operation, color_depth "
347 "FROM package_app_splash_screen WHERE app_id=%Q";
352 splashscreen_x *info;
354 query = sqlite3_mprintf(query_raw, appid);
356 LOGE("out of memory");
357 return PMINFO_R_ERROR;
360 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
362 if (ret != SQLITE_OK) {
363 LOGE("prepare failed: %s", sqlite3_errmsg(db));
364 return PMINFO_R_ERROR;
367 while (sqlite3_step(stmt) == SQLITE_ROW) {
368 info = calloc(1, sizeof(splashscreen_x));
370 LOGE("out of memory");
371 sqlite3_finalize(stmt);
372 return PMINFO_R_ERROR;
375 _save_column_str(stmt, idx++, &info->src);
376 _save_column_str(stmt, idx++, &info->type);
377 _save_column_str(stmt, idx++, &info->orientation);
378 _save_column_str(stmt, idx++, &info->indicatordisplay);
379 _save_column_str(stmt, idx++, &info->operation);
380 _save_column_str(stmt, idx++, &info->color_depth);
381 *splashscreens = g_list_append(*splashscreens, info);
384 sqlite3_finalize(stmt);
389 static GList *__get_background_category(const char *value)
391 GList *category_list = NULL;
392 int convert_value = 0;
393 if (!value || strlen(value) == 0)
396 convert_value = atoi(value);
397 if (convert_value < 0)
400 if (convert_value & APP_BG_CATEGORY_USER_DISABLE_TRUE_VAL)
401 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_USER_DISABLE_TRUE_STR));
403 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_USER_DISABLE_FALSE_STR));
405 if (convert_value & APP_BG_CATEGORY_MEDIA_VAL)
406 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_MEDIA_STR));
408 if (convert_value & APP_BG_CATEGORY_DOWNLOAD_VAL)
409 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_DOWNLOAD_STR));
411 if (convert_value & APP_BG_CATEGORY_BGNETWORK_VAL)
412 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_BGNETWORK_STR));
414 if (convert_value & APP_BG_CATEGORY_LOCATION_VAL)
415 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_LOCATION_STR));
417 if (convert_value & APP_BG_CATEGORY_SENSOR_VAL)
418 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_SENSOR_STR));
420 if (convert_value & APP_BG_CATEGORY_IOTCOMM_VAL)
421 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_IOTCOMM_STR));
423 if (convert_value & APP_BG_CATEGORY_SYSTEM_VAL)
424 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_SYSTEM));
426 return category_list;
430 static int __get_appinfo_for_uid(sqlite3 *db, application_x *info, uid_t uid)
432 static const char query_raw[] =
433 "SELECT is_splash_screen_enabled, is_disabled "
434 "FROM package_app_info_for_uid WHERE app_id=%Q AND uid=%d";
437 char *is_disabled = NULL;
440 query = sqlite3_mprintf(query_raw, info->appid, uid);
442 LOGE("out of memory");
443 return PMINFO_R_ERROR;
446 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
448 if (ret != SQLITE_OK) {
449 LOGE("sqlite3_prepare_v2() failed: %s", sqlite3_errmsg(db));
450 return PMINFO_R_ERROR;
453 while (sqlite3_step(stmt) == SQLITE_ROW) {
454 if (info->splash_screen_display)
455 free(info->splash_screen_display);
456 _save_column_str(stmt, 0, &info->splash_screen_display);
457 if (strcasecmp(info->is_disabled, "false") == 0) {
458 _save_column_str(stmt, 1, &is_disabled);
459 if (strcasecmp(is_disabled, "true") == 0) {
460 free(info->is_disabled);
461 info->is_disabled = is_disabled;
468 sqlite3_finalize(stmt);
472 static void __free_applications(gpointer data)
474 pkgmgrinfo_basic_free_application((application_x *)data);
477 static gint __app_disable_chk_func(gconstpointer data1, gconstpointer data2)
479 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)data1;
481 if (node->prop == E_PMINFO_APPINFO_PROP_APP_DISABLE)
487 static bool __check_disable_filter_exist(pkgmgrinfo_filter_x *filter)
494 link = g_slist_find_custom(filter->list, NULL, __app_disable_chk_func);
501 static int __bind_params(sqlite3_stmt *stmt, GList *params)
503 GList *tmp_list = NULL;
507 if (stmt == NULL || params == NULL)
508 return PMINFO_R_EINVAL;
512 ret = sqlite3_bind_text(stmt, ++idx, (char *)tmp_list->data, -1, SQLITE_STATIC);
513 if (ret != SQLITE_OK)
514 return PMINFO_R_ERROR;
515 tmp_list = tmp_list->next;
521 static bool __check_app_storage_status(pkgmgrinfo_filter_x *tmp_filter)
523 GSList *tmp_list = NULL;
524 pkgmgrinfo_node_x *tmp_node = NULL;
527 if (tmp_filter == NULL)
530 property = _pminfo_appinfo_convert_to_prop_bool(PMINFO_APPINFO_PROP_APP_CHECK_STORAGE);
531 for (tmp_list = tmp_filter->list; tmp_list != NULL;
532 tmp_list = g_slist_next(tmp_list)) {
533 tmp_node = (pkgmgrinfo_node_x *)tmp_list->data;
534 if (property == tmp_node->prop) {
535 if (strcmp(tmp_node->value, "true") == 0)
545 static int _appinfo_get_applications(uid_t db_uid, uid_t uid,
546 const char *locale, pkgmgrinfo_filter_x *filter, int flag,
547 GHashTable *applications)
549 static const char query_raw[] =
550 "SELECT DISTINCT ai.app_id, ai.app_component, ai.app_exec, "
551 "ai.app_nodisplay, ai.app_type, ai.app_onboot, "
552 "ai.app_multiple, ai.app_autorestart, ai.app_taskmanage, "
553 "ai.app_hwacceleration, ai.app_screenreader, "
554 "ai.app_mainapp, ai.app_recentimage, ai.app_launchcondition, "
555 "ai.app_indicatordisplay, ai.app_portraitimg, "
556 "ai.app_landscapeimg, ai.app_guestmodevisibility, "
557 "ai.app_permissiontype, ai.app_preload, ai.app_submode, "
558 "ai.app_submode_mainid, ai.app_launch_mode, ai.app_ui_gadget, "
559 "ai.app_support_disable, ai.app_process_pool, "
560 "ai.app_installed_storage, ai.app_background_category, "
561 "ai.app_package_type, ai.app_root_path, ai.app_api_version, "
562 "ai.app_effective_appid, ai.app_disable, "
563 "ai.app_splash_screen_display, ai.app_tep_name, "
564 "ai.app_zip_mount_file, ai.component_type, ai.package, "
565 "ai.app_external_path, ai.app_package_system, ai.app_removable, "
566 "ai.app_package_installed_time, ai.app_support_mode, "
567 "ai.app_support_ambient, ai.app_setup_appid";
568 static const char query_label[] =
570 "(SELECT app_label FROM package_app_localized_info WHERE ai.app_id=app_id AND app_locale=?), "
571 "(SELECT app_label FROM package_app_localized_info WHERE ai.app_id=app_id AND app_locale='No Locale'))";
572 static const char query_icon[] =
574 "(SELECT app_icon FROM package_app_localized_info WHERE ai.app_id=app_id AND app_locale=?), "
575 "(SELECT app_icon FROM package_app_localized_info WHERE ai.app_id=app_id AND app_locale='No Locale'))";
576 static const char query_from_clause[] = " FROM package_app_info as ai";
577 int ret = PMINFO_R_ERROR;
581 char *bg_category_str = NULL;
582 char *constraint = NULL;
583 char *tmp_record = NULL;
584 char query[MAX_QUERY_LEN] = { '\0' };
585 application_x *info = NULL;
586 GList *bind_params = NULL;
588 sqlite3_stmt *stmt = NULL;
589 bool is_check_storage = true;
591 dbpath = getUserPkgParserDBPathUID(db_uid);
593 return PMINFO_R_ERROR;
595 ret = __open_db(dbpath, &db, SQLITE_OPEN_READONLY);
596 if (ret != SQLITE_OK) {
597 _LOGE("failed to open db: %d", ret);
599 return PMINFO_R_ERROR;
603 len = strlen(query_raw);
604 snprintf(query, MAX_QUERY_LEN - 1, "%s", query_raw);
605 if (flag & PMINFO_APPINFO_GET_LABEL) {
606 strncat(query, query_label, MAX_QUERY_LEN - len - 1);
607 len += strlen(query_label);
608 bind_params = g_list_append(bind_params, strdup(locale));
610 if (flag & PMINFO_APPINFO_GET_ICON) {
611 strncat(query, query_icon, MAX_QUERY_LEN - len - 1);
612 len += strlen(query_icon);
613 bind_params = g_list_append(bind_params, strdup(locale));
616 is_check_storage = __check_app_storage_status(filter);
618 ret = _get_filtered_query(filter, locale, uid, &constraint, &bind_params);
619 if (ret != PMINFO_R_OK) {
620 LOGE("Failed to get WHERE clause");
623 strncat(query, query_from_clause, MAX_QUERY_LEN - len - 1);
624 len += strlen(query_from_clause);
627 strncat(query, constraint, MAX_QUERY_LEN - len - 1);
629 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
630 if (ret != SQLITE_OK) {
631 LOGE("prepare failed: %s", sqlite3_errmsg(db));
632 ret = PMINFO_R_ERROR;
636 if (g_list_length(bind_params) != 0) {
637 ret = __bind_params(stmt, bind_params);
638 if (ret != SQLITE_OK) {
639 LOGE("Failed to bind parameters");
644 while (sqlite3_step(stmt) == SQLITE_ROW) {
645 info = calloc(1, sizeof(application_x));
647 LOGE("out of memory");
648 ret = PMINFO_R_ERROR;
652 _save_column_str(stmt, idx++, &info->appid);
653 if (g_hash_table_contains(applications,
654 (gconstpointer)info->appid)) {
660 _save_column_str(stmt, idx++, &info->component);
661 _save_column_str(stmt, idx++, &info->exec);
662 _save_column_str(stmt, idx++, &info->nodisplay);
663 _save_column_str(stmt, idx++, &info->type);
664 _save_column_str(stmt, idx++, &info->onboot);
665 _save_column_str(stmt, idx++, &info->multiple);
666 _save_column_str(stmt, idx++, &info->autorestart);
667 _save_column_str(stmt, idx++, &info->taskmanage);
668 _save_column_str(stmt, idx++, &info->hwacceleration);
669 _save_column_str(stmt, idx++, &info->screenreader);
670 _save_column_str(stmt, idx++, &info->mainapp);
671 _save_column_str(stmt, idx++, &info->recentimage);
672 _save_column_str(stmt, idx++, &info->launchcondition);
673 _save_column_str(stmt, idx++, &info->indicatordisplay);
674 _save_column_str(stmt, idx++, &info->portraitimg);
675 _save_column_str(stmt, idx++, &info->landscapeimg);
676 _save_column_str(stmt, idx++, &info->guestmode_visibility);
677 _save_column_str(stmt, idx++, &info->permission_type);
678 _save_column_str(stmt, idx++, &info->preload);
679 _save_column_str(stmt, idx++, &info->submode);
680 _save_column_str(stmt, idx++, &info->submode_mainid);
681 _save_column_str(stmt, idx++, &info->launch_mode);
682 _save_column_str(stmt, idx++, &info->ui_gadget);
683 _save_column_str(stmt, idx++, &info->support_disable);
684 _save_column_str(stmt, idx++, &info->process_pool);
685 _save_column_str(stmt, idx++, &info->installed_storage);
686 _save_column_str(stmt, idx++, &bg_category_str);
687 _save_column_str(stmt, idx++, &info->package_type);
688 _save_column_str(stmt, idx++, &info->root_path);
689 _save_column_str(stmt, idx++, &info->api_version);
690 _save_column_str(stmt, idx++, &info->effective_appid);
691 _save_column_str(stmt, idx++, &info->is_disabled);
692 _save_column_str(stmt, idx++, &info->splash_screen_display);
693 _save_column_str(stmt, idx++, &info->tep_name);
694 _save_column_str(stmt, idx++, &info->zip_mount_file);
695 _save_column_str(stmt, idx++, &info->component_type);
696 _save_column_str(stmt, idx++, &info->package);
697 _save_column_str(stmt, idx++, &info->external_path);
698 _save_column_str(stmt, idx++, &info->package_system);
699 _save_column_str(stmt, idx++, &info->removable);
700 _save_column_str(stmt, idx++, &info->package_installed_time);
701 _save_column_str(stmt, idx++, &info->support_mode);
702 _save_column_str(stmt, idx++, &info->support_ambient);
703 _save_column_str(stmt, idx++, &info->setup_appid);
705 info->for_all_users =
706 strdup((db_uid != GLOBAL_USER) ? "false" : "true");
708 if (db_uid == GLOBAL_USER) {
709 ret = __get_appinfo_for_uid(db, info, uid);
710 if (ret != PMINFO_R_OK) {
711 LOGI("Failed to get appinfo for given uid[%d]", (int)uid);
712 pkgmgrinfo_basic_free_application(info);
718 info->background_category = __get_background_category(
720 free(bg_category_str);
722 if (flag & PMINFO_APPINFO_GET_LABEL) {
724 _save_column_str(stmt, idx++, &tmp_record);
725 if (_add_label_info_into_list(locale, tmp_record, &info->label)) {
726 ret = PMINFO_R_ERROR;
731 if (flag & PMINFO_APPINFO_GET_ICON) {
733 _save_column_str(stmt, idx++, &tmp_record);
734 if (_add_icon_info_into_list(locale, tmp_record, &info->icon)) {
735 ret = PMINFO_R_ERROR;
740 if (flag & PMINFO_APPINFO_GET_CATEGORY) {
741 if (_appinfo_get_category(db, info->appid,
743 ret = PMINFO_R_ERROR;
748 if (flag & PMINFO_APPINFO_GET_APP_CONTROL) {
749 if (_appinfo_get_app_control(db, info->appid,
750 &info->appcontrol)) {
751 ret = PMINFO_R_ERROR;
756 if (flag & PMINFO_APPINFO_GET_DATA_CONTROL) {
757 if (_appinfo_get_data_control(db, info->appid,
758 &info->datacontrol)) {
759 ret = PMINFO_R_ERROR;
764 if (flag & PMINFO_APPINFO_GET_METADATA) {
765 if (_appinfo_get_metadata(db, info->appid,
767 ret = PMINFO_R_ERROR;
772 if (flag & PMINFO_APPINFO_GET_SPLASH_SCREEN) {
773 if (_appinfo_get_splashscreens(db, info->appid,
774 &info->splashscreens)) {
775 ret = PMINFO_R_ERROR;
780 if (is_check_storage &&
781 __appinfo_check_installed_storage(info) != PMINFO_R_OK) {
782 ret = PMINFO_R_ERROR;
783 pkgmgrinfo_basic_free_application(info);
788 g_hash_table_insert(applications, (gpointer)info->appid,
798 if (ret != PMINFO_R_OK && info != NULL)
799 pkgmgrinfo_basic_free_application(info);
801 g_list_free_full(bind_params, free);
802 sqlite3_close_v2(db);
803 sqlite3_finalize(stmt);
808 static int _pkgmgrinfo_get_appinfo(const char *appid, uid_t uid,
809 pkgmgrinfo_appinfo_filter_h filter, pkgmgrinfo_appinfo_h *handle)
814 pkgmgr_appinfo_x *info;
816 if (appid == NULL || filter == NULL || handle == NULL) {
817 LOGE("invalid parameter");
818 return PMINFO_R_EINVAL;
821 locale = _get_system_locale();
823 return PMINFO_R_ERROR;
825 list = g_hash_table_new(g_str_hash, g_str_equal);
828 return PMINFO_R_ERROR;
831 ret = _appinfo_get_applications(uid, uid, locale, filter,
832 PMINFO_APPINFO_GET_ALL, list);
833 if (!g_hash_table_size(list) && uid != GLOBAL_USER)
834 ret = _appinfo_get_applications(GLOBAL_USER, uid, locale, filter,
835 PMINFO_APPINFO_GET_ALL, list);
837 if (!g_hash_table_size(list)) {
838 _LOGI("appinfo for [%s] is not existed for user [%d]",
840 g_hash_table_destroy(list);
842 return PMINFO_R_ENOENT;
845 info = calloc(1, sizeof(pkgmgr_appinfo_x));
847 _LOGE("out of memory");
848 g_hash_table_destroy(list);
850 return PMINFO_R_ERROR;
853 info->app_info = (application_x *)g_hash_table_lookup(list, appid);
854 info->locale = locale;
855 info->package = strdup(info->app_info->package);
857 /* just free list only */
858 g_hash_table_destroy(list);
865 API int pkgmgrinfo_appinfo_get_usr_disabled_appinfo(const char *appid, uid_t uid,
866 pkgmgrinfo_appinfo_h *handle)
869 pkgmgrinfo_appinfo_filter_h filter;
871 if (appid == NULL || handle == NULL) {
872 LOGE("invalid parameter");
873 return PMINFO_R_EINVAL;
876 ret = pkgmgrinfo_appinfo_filter_create(&filter);
877 if (ret != PMINFO_R_OK)
880 ret = pkgmgrinfo_appinfo_filter_add_string(filter,
881 PMINFO_APPINFO_PROP_APP_ID, appid);
882 if (ret != PMINFO_R_OK) {
883 pkgmgrinfo_appinfo_filter_destroy(filter);
884 return PMINFO_R_ERROR;
887 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
888 PMINFO_APPINFO_PROP_APP_DISABLE, true);
889 if (ret != PMINFO_R_OK) {
890 pkgmgrinfo_appinfo_filter_destroy(filter);
891 return PMINFO_R_ERROR;
894 ret = _pkgmgrinfo_get_appinfo(appid, uid, filter, handle);
895 pkgmgrinfo_appinfo_filter_destroy(filter);
900 API int pkgmgrinfo_appinfo_get_disabled_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
902 return pkgmgrinfo_appinfo_get_usr_disabled_appinfo(appid, _getuid(), handle);
905 API int pkgmgrinfo_appinfo_get_usr_appinfo(const char *appid, uid_t uid,
906 pkgmgrinfo_appinfo_h *handle)
909 pkgmgrinfo_appinfo_filter_h filter;
911 if (appid == NULL || handle == NULL) {
912 LOGE("invalid parameter");
913 return PMINFO_R_EINVAL;
916 ret = pkgmgrinfo_appinfo_filter_create(&filter);
917 if (ret != PMINFO_R_OK)
920 ret = pkgmgrinfo_appinfo_filter_add_string(filter,
921 PMINFO_APPINFO_PROP_APP_ID, appid);
922 if (ret != PMINFO_R_OK) {
923 pkgmgrinfo_appinfo_filter_destroy(filter);
924 return PMINFO_R_ERROR;
927 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
928 PMINFO_APPINFO_PROP_APP_DISABLE, false);
929 if (ret != PMINFO_R_OK) {
930 pkgmgrinfo_appinfo_filter_destroy(filter);
931 return PMINFO_R_ERROR;
934 ret = _pkgmgrinfo_get_appinfo(appid, uid, filter, handle);
935 pkgmgrinfo_appinfo_filter_destroy(filter);
939 API int pkgmgrinfo_appinfo_get_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
941 return pkgmgrinfo_appinfo_get_usr_appinfo(appid, _getuid(), handle);
944 API int pkgmgrinfo_appinfo_get_usr_all_appinfo(const char *appid, uid_t uid,
945 pkgmgrinfo_appinfo_h *handle)
948 pkgmgrinfo_appinfo_filter_h filter;
950 if (appid == NULL || handle == NULL) {
951 LOGE("invalid parameter");
952 return PMINFO_R_EINVAL;
955 ret = pkgmgrinfo_appinfo_filter_create(&filter);
956 if (ret != PMINFO_R_OK)
959 ret = pkgmgrinfo_appinfo_filter_add_string(filter,
960 PMINFO_APPINFO_PROP_APP_ID, appid);
961 if (ret != PMINFO_R_OK) {
962 pkgmgrinfo_appinfo_filter_destroy(filter);
963 return PMINFO_R_ERROR;
966 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
967 PMINFO_APPINFO_PROP_APP_CHECK_STORAGE, false);
968 if (ret != PMINFO_R_OK) {
969 pkgmgrinfo_appinfo_filter_destroy(filter);
970 return PMINFO_R_ERROR;
973 ret = _pkgmgrinfo_get_appinfo(appid, uid, filter, handle);
974 pkgmgrinfo_appinfo_filter_destroy(filter);
979 API int pkgmgrinfo_appinfo_get_all_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
981 return pkgmgrinfo_appinfo_get_usr_all_appinfo(appid, _getuid(), handle);
984 static gpointer __copy_str(gconstpointer src, gpointer data)
986 const char *tmp = (const char *)src;
989 buffer = strdup(tmp);
990 if (buffer == NULL) {
991 LOGE("memory alloc failed");
999 static gpointer __copy_label(gconstpointer src, gpointer data)
1001 label_x *tmp = (label_x *)src;
1004 label = calloc(1, sizeof(label_x));
1005 if (label == NULL) {
1006 LOGE("memory alloc failed");
1012 label->name = strdup(tmp->name);
1014 label->text = strdup(tmp->text);
1016 label->lang = strdup(tmp->lang);
1021 static gpointer __copy_icon(gconstpointer src, gpointer data)
1023 icon_x *tmp = (icon_x *)src;
1026 icon = calloc(1, sizeof(icon_x));
1028 LOGE("memory alloc failed");
1034 icon->text = strdup(tmp->text);
1036 icon->lang = strdup(tmp->lang);
1038 icon->section = strdup(tmp->section);
1040 icon->size = strdup(tmp->size);
1041 if (tmp->resolution)
1042 icon->resolution = strdup(tmp->resolution);
1047 static gpointer __copy_metadata(gconstpointer src, gpointer data)
1049 metadata_x *tmp = (metadata_x *)src;
1050 metadata_x *metadata;
1052 metadata = calloc(1, sizeof(metadata_x));
1053 if (metadata == NULL) {
1054 LOGE("memory alloc failed");
1060 metadata->key = strdup(tmp->key);
1062 metadata->value = strdup(tmp->value);
1067 static gpointer __copy_datacontrol(gconstpointer src, gpointer data)
1069 datacontrol_x *tmp = (datacontrol_x *)src;
1070 datacontrol_x *datacontrol;
1072 datacontrol = calloc(1, sizeof(datacontrol_x));
1073 if (datacontrol == NULL) {
1074 LOGE("memory alloc failed");
1079 if (tmp->providerid)
1080 datacontrol->providerid = strdup(tmp->providerid);
1082 datacontrol->access = strdup(tmp->access);
1084 datacontrol->type = strdup(tmp->type);
1086 datacontrol->trusted = strdup(tmp->trusted);
1091 static gpointer __copy_appcontrol(gconstpointer src, gpointer data)
1093 appcontrol_x *tmp = (appcontrol_x *)src;
1094 appcontrol_x *appcontrol;
1096 appcontrol = calloc(1, sizeof(appcontrol_x));
1097 if (appcontrol == NULL) {
1098 LOGE("memory alloc failed");
1104 appcontrol->operation = strdup(tmp->operation);
1106 appcontrol->uri = strdup(tmp->uri);
1108 appcontrol->mime = strdup(tmp->mime);
1113 static gpointer __copy_splashscreens(gconstpointer src, gpointer data)
1115 splashscreen_x *tmp = (splashscreen_x *)src;
1116 splashscreen_x *splashscreen;
1118 splashscreen = (splashscreen_x *)calloc(1, sizeof(splashscreen_x));
1119 if (splashscreen == NULL) {
1120 LOGE("memory alloc failed");
1126 splashscreen->src = strdup(tmp->src);
1128 splashscreen->type = strdup(tmp->type);
1129 if (tmp->orientation)
1130 splashscreen->orientation = strdup(tmp->orientation);
1131 if (tmp->indicatordisplay)
1132 splashscreen->indicatordisplay = strdup(tmp->indicatordisplay);
1134 splashscreen->operation = strdup(tmp->operation);
1135 if (tmp->color_depth)
1136 splashscreen->color_depth = strdup(tmp->color_depth);
1138 return splashscreen;
1141 static int _appinfo_copy_appinfo(application_x **application, application_x *data)
1143 application_x *app_info;
1146 app_info = calloc(1, sizeof(application_x));
1147 if (app_info == NULL) {
1148 LOGE("memory alloc failed");
1149 return PMINFO_R_ERROR;
1152 if (data->appid != NULL)
1153 app_info->appid = strdup(data->appid);
1154 if (data->exec != NULL)
1155 app_info->exec = strdup(data->exec);
1156 if (data->nodisplay != NULL)
1157 app_info->nodisplay = strdup(data->nodisplay);
1158 if (data->multiple != NULL)
1159 app_info->multiple = strdup(data->multiple);
1160 if (data->taskmanage != NULL)
1161 app_info->taskmanage = strdup(data->taskmanage);
1162 if (data->type != NULL)
1163 app_info->type = strdup(data->type);
1164 if (data->categories != NULL)
1165 app_info->categories = strdup(data->categories);
1166 if (data->hwacceleration != NULL)
1167 app_info->hwacceleration = strdup(data->hwacceleration);
1168 if (data->screenreader != NULL)
1169 app_info->screenreader = strdup(data->screenreader);
1170 if (data->mainapp != NULL)
1171 app_info->mainapp = strdup(data->mainapp);
1172 if (data->package != NULL)
1173 app_info->package = strdup(data->package);
1174 if (data->recentimage != NULL)
1175 app_info->recentimage = strdup(data->recentimage);
1176 if (data->launchcondition != NULL)
1177 app_info->launchcondition = strdup(data->launchcondition);
1178 if (data->indicatordisplay != NULL)
1179 app_info->indicatordisplay = strdup(data->indicatordisplay);
1180 if (data->portraitimg != NULL)
1181 app_info->portraitimg = strdup(data->portraitimg);
1182 if (data->landscapeimg != NULL)
1183 app_info->landscapeimg = strdup(data->landscapeimg);
1184 if (data->guestmode_visibility != NULL)
1185 app_info->guestmode_visibility = strdup(data->guestmode_visibility);
1186 if (data->component != NULL)
1187 app_info->component = strdup(data->component);
1188 if (data->permission_type != NULL)
1189 app_info->permission_type = strdup(data->permission_type);
1190 if (data->component_type != NULL)
1191 app_info->component_type = strdup(data->component_type);
1192 if (data->preload != NULL)
1193 app_info->preload = strdup(data->preload);
1194 if (data->submode != NULL)
1195 app_info->submode = strdup(data->submode);
1196 if (data->submode_mainid != NULL)
1197 app_info->submode_mainid = strdup(data->submode_mainid);
1198 if (data->process_pool != NULL)
1199 app_info->process_pool = strdup(data->process_pool);
1200 if (data->installed_storage != NULL)
1201 app_info->installed_storage = strdup(data->installed_storage);
1202 if (data->autorestart != NULL)
1203 app_info->autorestart = strdup(data->autorestart);
1204 if (data->onboot != NULL)
1205 app_info->onboot = strdup(data->onboot);
1206 if (data->support_disable != NULL)
1207 app_info->support_disable = strdup(data->support_disable);
1208 if (data->ui_gadget != NULL)
1209 app_info->ui_gadget = strdup(data->ui_gadget);
1210 if (data->launch_mode != NULL)
1211 app_info->launch_mode = strdup(data->launch_mode);
1212 if (data->package_type != NULL)
1213 app_info->package_type = strdup(data->package_type);
1214 if (data->effective_appid != NULL)
1215 app_info->effective_appid = strdup(data->effective_appid);
1216 if (data->splash_screen_display != NULL)
1217 app_info->splash_screen_display = strdup(data->splash_screen_display);
1221 app_info->label = g_list_copy_deep(data->label, __copy_label, &ret);
1223 LOGE("memory alloc failed");
1224 pkgmgrinfo_basic_free_application(app_info);
1225 return PMINFO_R_ERROR;
1229 app_info->icon = g_list_copy_deep(data->icon, __copy_icon, &ret);
1231 LOGE("memory alloc failed");
1232 pkgmgrinfo_basic_free_application(app_info);
1233 return PMINFO_R_ERROR;
1237 app_info->category = g_list_copy_deep(data->category, __copy_str, &ret);
1239 LOGE("memory alloc failed");
1240 pkgmgrinfo_basic_free_application(app_info);
1241 return PMINFO_R_ERROR;
1245 app_info->metadata = g_list_copy_deep(data->metadata, __copy_metadata, &ret);
1247 LOGE("memory alloc failed");
1248 pkgmgrinfo_basic_free_application(app_info);
1249 return PMINFO_R_ERROR;
1253 app_info->datacontrol = g_list_copy_deep(data->datacontrol, __copy_datacontrol, &ret);
1255 LOGE("memory alloc failed");
1256 pkgmgrinfo_basic_free_application(app_info);
1257 return PMINFO_R_ERROR;
1261 app_info->appcontrol = g_list_copy_deep(data->appcontrol, __copy_appcontrol, &ret);
1263 LOGE("memory alloc failed");
1264 pkgmgrinfo_basic_free_application(app_info);
1265 return PMINFO_R_ERROR;
1269 app_info->background_category = g_list_copy_deep(data->background_category, __copy_str, &ret);
1271 LOGE("memory alloc failed");
1272 pkgmgrinfo_basic_free_application(app_info);
1273 return PMINFO_R_ERROR;
1277 app_info->splashscreens = g_list_copy_deep(data->splashscreens, __copy_splashscreens, &ret);
1279 LOGE("memory alloc failed");
1280 pkgmgrinfo_basic_free_application(app_info);
1281 return PMINFO_R_ERROR;
1284 *application = app_info;
1289 API int pkgmgrinfo_appinfo_clone_appinfo(pkgmgrinfo_appinfo_h handle,
1290 pkgmgrinfo_appinfo_h *clone)
1292 pkgmgr_appinfo_x *info;
1293 pkgmgr_appinfo_x *temp = (pkgmgr_appinfo_x *)handle;
1296 return PMINFO_R_EINVAL;
1298 info = calloc(1, sizeof(pkgmgr_appinfo_x));
1300 LOGE("memory alloc failed");
1301 return PMINFO_R_ERROR;
1304 if (temp->package != NULL)
1305 info->package = strdup(temp->package);
1306 if (temp->locale != NULL)
1307 info->locale = strdup(temp->locale);
1309 info->app_component = temp->app_component;
1311 if (_appinfo_copy_appinfo(&info->app_info, temp->app_info) < 0) {
1312 LOGE("appinfo copy failed");
1314 free((void *)info->package);
1318 return PMINFO_R_ERROR;
1326 static int _appinfo_get_filtered_foreach_appinfo(uid_t uid,
1327 pkgmgrinfo_filter_x *filter, int flag, pkgmgrinfo_app_list_cb app_list_cb,
1333 pkgmgr_appinfo_x info;
1335 GHashTableIter iter;
1338 locale = _get_system_locale();
1340 return PMINFO_R_ERROR;
1342 list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
1343 __free_applications);
1346 return PMINFO_R_ERROR;
1349 if (__check_disable_filter_exist(filter) == false) {
1350 pkgmgrinfo_appinfo_filter_add_bool(filter,
1351 PMINFO_APPINFO_PROP_APP_DISABLE, false);
1354 ret = _appinfo_get_applications(uid, uid, locale, filter, flag, list);
1355 if (ret == PMINFO_R_OK && uid != GLOBAL_USER)
1356 ret = _appinfo_get_applications(GLOBAL_USER, uid, locale,
1357 filter, flag, list);
1359 if (ret != PMINFO_R_OK) {
1360 g_hash_table_destroy(list);
1365 g_hash_table_iter_init(&iter, list);
1366 while (g_hash_table_iter_next(&iter, NULL, &value)) {
1367 app = (application_x *)value;
1368 info.app_info = app;
1369 info.locale = locale;
1370 info.package = app->package;
1371 if (app_list_cb(&info, user_data) < 0)
1374 g_hash_table_destroy(list);
1380 static const char *__appcomponent_str(pkgmgrinfo_app_component comp);
1382 API int pkgmgrinfo_appinfo_get_usr_list(pkgmgrinfo_pkginfo_h handle,
1383 pkgmgrinfo_app_component component,
1384 pkgmgrinfo_app_list_cb app_func, void *user_data, uid_t uid)
1387 pkgmgrinfo_appinfo_filter_h filter;
1389 const char *comp_str = NULL;
1391 if (handle == NULL || app_func == NULL) {
1392 LOGE("invalid parameter");
1393 return PMINFO_R_EINVAL;
1396 if (pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid)) {
1397 LOGE("invalid parameter");
1398 return PMINFO_R_EINVAL;
1401 if (pkgmgrinfo_appinfo_filter_create(&filter))
1402 return PMINFO_R_ERROR;
1404 if (pkgmgrinfo_appinfo_filter_add_string(filter,
1405 PMINFO_APPINFO_PROP_APP_PACKAGE, pkgid)) {
1406 pkgmgrinfo_appinfo_filter_destroy(filter);
1407 return PMINFO_R_ERROR;
1410 comp_str = __appcomponent_str(component);
1413 if (pkgmgrinfo_appinfo_filter_add_string(filter,
1414 PMINFO_APPINFO_PROP_APP_COMPONENT,
1416 pkgmgrinfo_appinfo_filter_destroy(filter);
1417 return PMINFO_R_ERROR;
1421 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter,
1422 PMINFO_APPINFO_GET_ALL, app_func, user_data);
1424 pkgmgrinfo_appinfo_filter_destroy(filter);
1429 API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle,
1430 pkgmgrinfo_app_component component,
1431 pkgmgrinfo_app_list_cb app_func, void *user_data)
1433 return pkgmgrinfo_appinfo_get_usr_list(handle, component, app_func, user_data, _getuid());
1436 API int pkgmgrinfo_appinfo_get_usr_installed_list_full(
1437 pkgmgrinfo_app_list_cb app_func, uid_t uid, int flag,
1441 pkgmgrinfo_appinfo_filter_h filter;
1443 if (app_func == NULL) {
1444 LOGE("invalid parameter");
1445 return PMINFO_R_EINVAL;
1448 if (pkgmgrinfo_appinfo_filter_create(&filter))
1449 return PMINFO_R_ERROR;
1451 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
1452 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
1453 pkgmgrinfo_appinfo_filter_destroy(filter);
1454 return PMINFO_R_ERROR;
1457 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
1458 PMINFO_APPINFO_PROP_APP_CHECK_STORAGE, false)) {
1459 pkgmgrinfo_appinfo_filter_destroy(filter);
1460 return PMINFO_R_ERROR;
1463 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter, flag, app_func,
1466 pkgmgrinfo_appinfo_filter_destroy(filter);
1471 API int pkgmgrinfo_appinfo_get_installed_list_full(
1472 pkgmgrinfo_app_list_cb app_func, int flag, void *user_data)
1474 return pkgmgrinfo_appinfo_get_usr_installed_list_full(app_func,
1475 _getuid(), flag, user_data);
1478 API int pkgmgrinfo_appinfo_get_usr_installed_list(
1479 pkgmgrinfo_app_list_cb app_func, uid_t uid, void *user_data)
1482 pkgmgrinfo_appinfo_filter_h filter;
1484 if (app_func == NULL) {
1485 LOGE("invalid parameter");
1486 return PMINFO_R_EINVAL;
1489 /* create an empty filter */
1490 ret = pkgmgrinfo_appinfo_filter_create(&filter);
1491 if (ret != PMINFO_R_OK)
1494 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter,
1495 PMINFO_APPINFO_GET_ALL, app_func, user_data);
1497 pkgmgrinfo_appinfo_filter_destroy(filter);
1502 API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func,
1505 return pkgmgrinfo_appinfo_get_usr_installed_list(app_func, _getuid(),
1509 API int pkgmgrinfo_appinfo_get_appid(pkgmgrinfo_appinfo_h handle, char **appid)
1511 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1513 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1514 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1516 if (info->app_info == NULL || info->app_info->appid == NULL)
1517 return PMINFO_R_ERROR;
1518 *appid = (char *)info->app_info->appid;
1523 API int pkgmgrinfo_appinfo_get_pkgname(pkgmgrinfo_appinfo_h handle, char **pkg_name)
1525 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1527 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1528 retvm_if(pkg_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1530 if (info->package == NULL)
1531 return PMINFO_R_ERROR;
1533 *pkg_name = (char *)info->package;
1538 API int pkgmgrinfo_appinfo_get_pkgid(pkgmgrinfo_appinfo_h handle, char **pkgid)
1540 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1542 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1543 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1545 if (info->package == NULL)
1546 return PMINFO_R_ERROR;
1548 *pkgid = (char *)info->package;
1553 API int pkgmgrinfo_appinfo_get_pkgtype(pkgmgrinfo_appinfo_h handle, char **pkgtype)
1555 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1556 retvm_if(pkgtype == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1557 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1559 *pkgtype = (char *)info->app_info->package_type;
1564 API int pkgmgrinfo_appinfo_get_exec(pkgmgrinfo_appinfo_h handle, char **exec)
1566 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1568 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1569 retvm_if(exec == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1571 if (info->app_info == NULL || info->app_info->exec == NULL)
1572 return PMINFO_R_ERROR;
1573 *exec = (char *)info->app_info->exec;
1579 API int pkgmgrinfo_appinfo_get_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1582 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1584 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1585 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1587 if (info->app_info == NULL)
1588 return PMINFO_R_ERROR;
1590 if (info->app_info->icon == NULL) {
1595 ptr = (icon_x *)info->app_info->icon->data;
1597 return PMINFO_R_ERROR;
1599 if (ptr->text == NULL)
1600 return PMINFO_R_ERROR;
1608 API int pkgmgrinfo_appinfo_get_label(pkgmgrinfo_appinfo_h handle, char **label)
1611 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1613 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1614 retvm_if(label == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1616 if (info->app_info == NULL || info->app_info->label == NULL)
1617 return PMINFO_R_ERROR;
1619 ptr = (label_x *)info->app_info->label->data;
1621 return PMINFO_R_ERROR;
1623 if (ptr->text == NULL)
1624 return PMINFO_R_ERROR;
1631 static char *_get_localed_label(const char *appid, const char *locale, uid_t uid)
1633 char *result = NULL;
1635 sqlite3_stmt *stmt = NULL;
1640 parser_db = getUserPkgParserDBPathUID(uid);
1641 if (parser_db == NULL) {
1642 _LOGE("Failed to get parser db path");
1646 if (__open_db(parser_db, &db, SQLITE_OPEN_READONLY) != SQLITE_OK) {
1647 _LOGE("DB open fail\n");
1653 query = sqlite3_mprintf("select app_label from package_app_localized_info where app_id=%Q and app_locale=%Q", appid, locale);
1654 if (query == NULL) {
1655 _LOGE("Out of memory");
1659 if (sqlite3_prepare_v2(db, query, -1, &stmt, NULL) != SQLITE_OK) {
1660 _LOGE("prepare_v2 fail\n");
1664 if (sqlite3_step(stmt) == SQLITE_ROW) {
1665 val = (char *)sqlite3_column_text(stmt, 0);
1667 result = strdup(val);
1671 sqlite3_finalize(stmt);
1672 sqlite3_free(query);
1678 API int pkgmgrinfo_appinfo_usr_get_localed_label(const char *appid, const char *locale, uid_t uid, char **label)
1682 retvm_if(appid == NULL || locale == NULL || label == NULL, PMINFO_R_EINVAL, "Argument is NULL");
1684 val = _get_localed_label(appid, locale, uid);
1686 val = _get_localed_label(appid, DEFAULT_LOCALE, uid);
1689 val = _get_localed_label(appid, locale, GLOBAL_USER);
1691 val = _get_localed_label(appid, DEFAULT_LOCALE, GLOBAL_USER);
1695 return PMINFO_R_ERROR;
1702 API int pkgmgrinfo_appinfo_get_localed_label(const char *appid, const char *locale, char **label)
1704 return pkgmgrinfo_appinfo_usr_get_localed_label(appid, locale, _getuid(), label);
1707 API int pkgmgrinfo_appinfo_get_metadata_value(pkgmgrinfo_appinfo_h handle, const char *metadata_key, char **metadata_value)
1709 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1710 retvm_if(metadata_key == NULL, PMINFO_R_EINVAL, "metadata_key is NULL");
1711 retvm_if(metadata_value == NULL, PMINFO_R_EINVAL, "metadata_value is NULL");
1713 GList *list_md = NULL;
1714 metadata_x *metadata = NULL;
1715 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1717 list_md = info->app_info->metadata;
1719 for (; list_md; list_md = list_md->next) {
1720 metadata = (metadata_x *)list_md->data;
1721 if (metadata && metadata->key) {
1722 if (strcasecmp(metadata->key, metadata_key) == 0) {
1723 if (metadata->value == NULL)
1724 *metadata_value = "";
1726 *metadata_value = (char *)metadata->value;
1732 return PMINFO_R_EINVAL;
1735 static pkgmgrinfo_app_component __appcomponent_convert(const char *comp)
1737 if (strcasecmp(comp, "uiapp") == 0)
1738 return PMINFO_UI_APP;
1739 else if (strcasecmp(comp, "svcapp") == 0)
1740 return PMINFO_SVC_APP;
1741 else if (strcasecmp(comp, "widgetapp") == 0)
1742 return PMINFO_WIDGET_APP;
1743 else if (strcasecmp(comp, "watchapp") == 0)
1744 return PMINFO_WATCH_APP;
1749 static const char *__appcomponent_str(pkgmgrinfo_app_component comp)
1754 case PMINFO_SVC_APP:
1756 case PMINFO_WIDGET_APP:
1758 case PMINFO_WATCH_APP:
1765 API int pkgmgrinfo_appinfo_get_component(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_component *component)
1767 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1770 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1771 retvm_if(component == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1773 if (info->app_info == NULL)
1774 return PMINFO_R_ERROR;
1776 comp = __appcomponent_convert(info->app_info->component);
1778 return PMINFO_R_ERROR;
1785 API int pkgmgrinfo_appinfo_get_apptype(pkgmgrinfo_appinfo_h handle, char **app_type)
1787 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1789 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1790 retvm_if(app_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1792 if (info->app_info == NULL || info->app_info->type == NULL)
1793 return PMINFO_R_ERROR;
1794 *app_type = (char *)info->app_info->type;
1799 API int pkgmgrinfo_appinfo_get_operation(pkgmgrinfo_appcontrol_h handle,
1800 int *operation_count, char ***operation)
1802 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1803 retvm_if(operation == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1804 retvm_if(operation_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1805 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1806 *operation_count = data->operation_count;
1807 *operation = data->operation;
1811 API int pkgmgrinfo_appinfo_get_uri(pkgmgrinfo_appcontrol_h handle,
1812 int *uri_count, char ***uri)
1814 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1815 retvm_if(uri == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1816 retvm_if(uri_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1817 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1818 *uri_count = data->uri_count;
1823 API int pkgmgrinfo_appinfo_get_mime(pkgmgrinfo_appcontrol_h handle,
1824 int *mime_count, char ***mime)
1826 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1827 retvm_if(mime == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1828 retvm_if(mime_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1829 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1830 *mime_count = data->mime_count;
1835 API int pkgmgrinfo_appinfo_get_subapp(pkgmgrinfo_appcontrol_h handle,
1836 int *subapp_count, char ***subapp)
1838 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1839 retvm_if(subapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1840 retvm_if(subapp_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1841 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1842 *subapp_count = data->subapp_count;
1843 *subapp = data->subapp;
1847 API int pkgmgrinfo_appinfo_get_setting_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1852 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1854 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1855 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1857 if (info->app_info == NULL)
1858 return PMINFO_R_ERROR;
1860 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1861 ptr = (icon_x *)tmp->data;
1862 if (ptr == NULL || ptr->section == NULL)
1865 val = (char *)ptr->section;
1866 if (val && strcmp(val, "setting") == 0) {
1867 *icon = (char *)ptr->text;
1872 return PMINFO_R_ERROR;
1876 API int pkgmgrinfo_appinfo_get_notification_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1881 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1883 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1884 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1886 if (info->app_info == NULL)
1887 return PMINFO_R_ERROR;
1889 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1890 ptr = (icon_x *)tmp->data;
1891 if (ptr == NULL || ptr->section == NULL)
1894 val = (char *)ptr->section;
1895 if (val && strcmp(val, "notification") == 0) {
1896 *icon = (char *)ptr->text;
1901 return PMINFO_R_ERROR;
1904 API int pkgmgrinfo_appinfo_get_recent_image_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_recentimage *type)
1907 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1909 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1910 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1912 if (info->app_info == NULL || info->app_info->recentimage == NULL)
1913 return PMINFO_R_ERROR;
1915 val = (char *)info->app_info->recentimage;
1916 if (strcasecmp(val, "capture") == 0)
1917 *type = PMINFO_RECENTIMAGE_USE_CAPTURE;
1918 else if (strcasecmp(val, "icon") == 0)
1919 *type = PMINFO_RECENTIMAGE_USE_ICON;
1921 *type = PMINFO_RECENTIMAGE_USE_NOTHING;
1926 API int pkgmgrinfo_appinfo_get_preview_image(pkgmgrinfo_appinfo_h handle, char **preview_img)
1931 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1933 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1934 retvm_if(preview_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1936 if (info->app_info == NULL)
1937 return PMINFO_R_ERROR;
1939 for (tmp = info->app_info->image; tmp; tmp = tmp->next) {
1940 ptr = (image_x *)tmp->data;
1941 if (ptr == NULL || ptr->section == NULL)
1944 val = (char *)ptr->section;
1945 if (val && strcmp(val, "preview") == 0) {
1946 *preview_img = (char *)ptr->text;
1951 return PMINFO_R_ERROR;
1954 API int pkgmgrinfo_appinfo_get_permission_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_permission_type *permission)
1957 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1959 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1960 retvm_if(permission == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1962 val = info->app_info->permission_type;
1964 return PMINFO_R_ERROR;
1966 if (strcmp(val, "signature") == 0)
1967 *permission = PMINFO_PERMISSION_SIGNATURE;
1968 else if (strcmp(val, "privilege") == 0)
1969 *permission = PMINFO_PERMISSION_PRIVILEGE;
1971 *permission = PMINFO_PERMISSION_NORMAL;
1976 API int pkgmgrinfo_appinfo_get_component_type(pkgmgrinfo_appinfo_h handle, char **component_type)
1978 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1980 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1981 retvm_if(component_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1983 if (info->app_info == NULL || info->app_info->component_type == NULL)
1984 return PMINFO_R_ERROR;
1986 *component_type = (char *)info->app_info->component_type;
1991 API int pkgmgrinfo_appinfo_get_hwacceleration(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_hwacceleration *hwacceleration)
1994 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1996 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1997 retvm_if(hwacceleration == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1999 if (info->app_info == NULL || info->app_info->hwacceleration == NULL)
2000 return PMINFO_R_ERROR;
2002 val = (char *)info->app_info->hwacceleration;
2003 if (strcasecmp(val, "off") == 0)
2004 *hwacceleration = PMINFO_HWACCELERATION_OFF;
2005 else if (strcasecmp(val, "on") == 0)
2006 *hwacceleration = PMINFO_HWACCELERATION_ON;
2008 *hwacceleration = PMINFO_HWACCELERATION_DEFAULT;
2013 API int pkgmgrinfo_appinfo_get_screenreader(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_screenreader *screenreader)
2016 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2018 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2019 retvm_if(screenreader == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2021 if (info->app_info == NULL || info->app_info->screenreader == NULL)
2022 return PMINFO_R_ERROR;
2024 val = (char *)info->app_info->screenreader;
2025 if (strcasecmp(val, "screenreader-off") == 0)
2026 *screenreader = PMINFO_SCREENREADER_OFF;
2027 else if (strcasecmp(val, "screenreader-on") == 0)
2028 *screenreader = PMINFO_SCREENREADER_ON;
2030 *screenreader = PMINFO_SCREENREADER_USE_SYSTEM_SETTING;
2035 API int pkgmgrinfo_appinfo_get_effectimage(pkgmgrinfo_appinfo_h handle, char **portrait_img, char **landscape_img)
2037 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2039 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2040 retvm_if(portrait_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2041 retvm_if(landscape_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2043 if (info->app_info == NULL)
2044 return PMINFO_R_ERROR;
2046 if (info->app_info->portraitimg == NULL)
2049 *portrait_img = (char *)info->app_info->portraitimg;
2051 if (info->app_info->landscapeimg == NULL)
2052 *landscape_img = "";
2054 *landscape_img = (char *)info->app_info->landscapeimg;
2059 API int pkgmgrinfo_appinfo_get_effectimage_type(pkgmgrinfo_appinfo_h handle, char **effectimage_type)
2061 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2063 if (handle == NULL || effectimage_type == NULL) {
2064 LOGE("invalid parameter");
2065 return PMINFO_R_EINVAL;
2068 if (info->app_info == NULL || info->app_info->effectimage_type == NULL)
2069 return PMINFO_R_ERROR;
2071 *effectimage_type = (char *)info->app_info->effectimage_type;
2076 API int pkgmgrinfo_appinfo_get_submode_mainid(pkgmgrinfo_appinfo_h handle, char **submode_mainid)
2078 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2080 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2081 retvm_if(submode_mainid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2083 if (info->app_info == NULL)
2084 return PMINFO_R_ERROR;
2086 if (info->app_info->submode_mainid == NULL)
2087 *submode_mainid = "";
2089 *submode_mainid = (char *)info->app_info->submode_mainid;
2094 API int pkgmgrinfo_appinfo_get_installed_storage_location(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_installed_storage *storage)
2096 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2097 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2099 if (info->app_info && info->app_info->installed_storage) {
2100 if (strcmp(info->app_info->installed_storage, "installed_internal") == 0)
2101 *storage = PMINFO_INTERNAL_STORAGE;
2102 else if (strcmp(info->app_info->installed_storage, "installed_external") == 0)
2103 *storage = PMINFO_EXTERNAL_STORAGE;
2105 return PMINFO_R_ERROR;
2107 return PMINFO_R_ERROR;
2113 API int pkgmgrinfo_appinfo_get_launch_mode(pkgmgrinfo_appinfo_h handle, char **mode)
2115 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2117 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2118 retvm_if(mode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2120 if (info->app_info->launch_mode == NULL)
2121 return PMINFO_R_ERROR;
2123 *mode = (char *)(info->app_info->launch_mode);
2128 API int pkgmgrinfo_appinfo_get_alias_appid(pkgmgrinfo_appinfo_h handle, char **alias_appid)
2130 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2132 if (handle == NULL || alias_appid == NULL) {
2133 LOGE("invalid parameter");
2134 return PMINFO_R_EINVAL;
2137 if (info->app_info == NULL || info->app_info->alias_appid == NULL)
2138 return PMINFO_R_ERROR;
2140 *alias_appid = (char *)info->app_info->alias_appid;
2145 API int pkgmgrinfo_appinfo_get_effective_appid(pkgmgrinfo_appinfo_h handle, char **effective_appid)
2147 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2149 if (handle == NULL || effective_appid == NULL) {
2150 LOGE("invalid parameter");
2151 return PMINFO_R_EINVAL;
2154 if (info->app_info == NULL)
2155 return PMINFO_R_ERROR;
2157 if (info->app_info->effective_appid == NULL)
2158 *effective_appid = "";
2160 *effective_appid = (char *)info->app_info->effective_appid;
2165 API int pkgmgrinfo_appinfo_get_tep_name(pkgmgrinfo_appinfo_h handle, char **tep_name)
2167 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2169 if (handle == NULL || tep_name == NULL) {
2170 LOGE("invalid parameter");
2171 return PMINFO_R_EINVAL;
2174 if (info->app_info == NULL)
2175 return PMINFO_R_ERROR;
2177 if (info->app_info->tep_name == NULL)
2180 *tep_name = (char *)info->app_info->tep_name;
2185 API int pkgmgrinfo_appinfo_get_zip_mount_file(pkgmgrinfo_appinfo_h handle, char **zip_mount_file)
2187 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2189 if (handle == NULL || zip_mount_file == NULL) {
2190 LOGE("invalid parameter");
2191 return PMINFO_R_EINVAL;
2194 if (info->app_info == NULL)
2195 return PMINFO_R_ERROR;
2197 if (info->app_info->zip_mount_file == NULL)
2198 *zip_mount_file = "";
2200 *zip_mount_file = (char *)info->app_info->zip_mount_file;
2205 API int pkgmgrinfo_appinfo_get_root_path(pkgmgrinfo_appinfo_h handle, char **root_path)
2207 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2209 if (handle == NULL || root_path == NULL) {
2210 LOGE("invalid parameter");
2211 return PMINFO_R_EINVAL;
2214 if (info->app_info == NULL || info->app_info->root_path == NULL)
2215 return PMINFO_R_ERROR;
2217 *root_path = (char *)info->app_info->root_path;
2222 API int pkgmgrinfo_appinfo_get_api_version(pkgmgrinfo_appinfo_h handle, char **api_version)
2224 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2226 if (handle == NULL || api_version == NULL) {
2227 LOGE("invalid parameter");
2228 return PMINFO_R_EINVAL;
2231 if (info->app_info == NULL || info->app_info->api_version == NULL)
2232 return PMINFO_R_ERROR;
2234 *api_version = (char *)info->app_info->api_version;
2239 API int pkgmgrinfo_appinfo_get_installed_time(pkgmgrinfo_appinfo_h handle, int *installed_time)
2241 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2243 if (handle == NULL || installed_time == NULL) {
2244 LOGE("invalid parameter");
2245 return PMINFO_R_EINVAL;
2248 if (info->app_info == NULL || info->app_info->package_installed_time == NULL)
2249 return PMINFO_R_ERROR;
2251 *installed_time = atoi(info->app_info->package_installed_time);
2256 API int pkgmgrinfo_appinfo_usr_get_datacontrol_info(const char *providerid,
2257 const char *type, uid_t uid, char **appid, char **access)
2259 retvm_if(providerid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
2260 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
2261 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2262 retvm_if(access == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2264 int ret = PMINFO_R_OK;
2266 sqlite3_stmt *stmt = NULL;
2269 ret = __open_manifest_db(uid, true);
2270 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
2272 /*Start constructing query*/
2273 query = sqlite3_mprintf("select * from package_app_data_control where providerid=%Q and type=%Q", providerid, type);
2274 tryvm_if(query == NULL, ret = PMINFO_R_ERROR, "Out of memory");
2277 ret = sqlite3_prepare_v2(GET_DB(manifest_db), query, strlen(query), &stmt, NULL);
2278 tryvm_if(ret != PMINFO_R_OK, ret = PMINFO_R_ERROR, "sqlite3_prepare_v2 failed[%s]\n", query);
2281 ret = sqlite3_step(stmt);
2282 tryvm_if((ret != SQLITE_ROW) || (ret == SQLITE_DONE), ret = PMINFO_R_ERROR, "No records found");
2284 *appid = strdup((char *)sqlite3_column_text(stmt, 0));
2285 *access = strdup((char *)sqlite3_column_text(stmt, 2));
2290 sqlite3_free(query);
2291 sqlite3_finalize(stmt);
2292 __close_manifest_db();
2296 API int pkgmgrinfo_appinfo_get_datacontrol_info(const char *providerid,
2297 const char *type, char **appid, char **access)
2299 return pkgmgrinfo_appinfo_usr_get_datacontrol_info(providerid,
2300 type, _getuid(), appid, access);
2303 API int pkgmgrinfo_appinfo_usr_get_datacontrol_appid(const char *providerid, uid_t uid, char **appid)
2305 retvm_if(providerid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
2306 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2308 int ret = PMINFO_R_OK;
2310 sqlite3_stmt *stmt = NULL;
2313 ret = __open_manifest_db(uid, true);
2314 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
2316 /*Start constructing query*/
2317 query = sqlite3_mprintf("select * from package_app_data_control where providerid=%Q", providerid);
2318 tryvm_if(query == NULL, ret = PMINFO_R_ERROR, "Out of memory");
2321 ret = sqlite3_prepare_v2(GET_DB(manifest_db), query, strlen(query), &stmt, NULL);
2322 tryvm_if(ret != PMINFO_R_OK, ret = PMINFO_R_ERROR, "sqlite3_prepare_v2 failed[%s]\n", query);
2325 ret = sqlite3_step(stmt);
2326 tryvm_if((ret != SQLITE_ROW) || (ret == SQLITE_DONE), ret = PMINFO_R_ERROR, "No records found");
2328 *appid = strdup((char *)sqlite3_column_text(stmt, 0));
2333 sqlite3_free(query);
2334 sqlite3_finalize(stmt);
2335 __close_manifest_db();
2339 API int pkgmgrinfo_appinfo_get_datacontrol_appid(const char *providerid, char **appid)
2341 return pkgmgrinfo_appinfo_usr_get_datacontrol_appid(providerid, _getuid(), appid);
2344 API int pkgmgrinfo_appinfo_usr_get_datacontrol_trusted_info(const char *providerid,
2345 const char *type, uid_t uid, char **appid, bool *is_trusted)
2347 retvm_if(providerid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
2348 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2350 int ret = PMINFO_R_OK;
2352 sqlite3_stmt *stmt = NULL;
2355 ret = __open_manifest_db(uid, true);
2356 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
2358 /*Start constructing query*/
2359 query = sqlite3_mprintf("SELECT app_id, trusted FROM package_app_data_control WHERE providerid=%Q AND type=%Q", providerid, type);
2360 tryvm_if(query == NULL, ret = PMINFO_R_ERROR, "Out of memory");
2363 ret = sqlite3_prepare_v2(GET_DB(manifest_db), query, strlen(query), &stmt, NULL);
2364 tryvm_if(ret != PMINFO_R_OK, ret = PMINFO_R_ERROR, "sqlite3_prepare_v2 failed[%s]\n", query);
2367 ret = sqlite3_step(stmt);
2368 tryvm_if((ret != SQLITE_ROW) || (ret == SQLITE_DONE), ret = PMINFO_R_ERROR, "No records found");
2370 _save_column_str(stmt, 0, appid);
2371 *is_trusted = _get_bool_value((char *)sqlite3_column_text(stmt, 1));
2376 sqlite3_free(query);
2377 sqlite3_finalize(stmt);
2378 __close_manifest_db();
2382 API int pkgmgrinfo_appinfo_get_datacontrol_trsuted_info(const char *providerid,
2383 const char *type, char **appid, bool *is_trusted)
2385 return pkgmgrinfo_appinfo_usr_get_datacontrol_trusted_info(providerid,
2386 type, _getuid(), appid, is_trusted);
2390 API int pkgmgrinfo_appinfo_get_support_mode(pkgmgrinfo_appinfo_h handle, int *support_mode)
2392 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2393 retvm_if(support_mode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2395 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2396 if (info->app_info->support_mode)
2397 *support_mode = atoi(info->app_info->support_mode);
2404 API int pkgmgrinfo_appinfo_foreach_permission(pkgmgrinfo_appinfo_h handle,
2405 pkgmgrinfo_app_permission_list_cb permission_func, void *user_data)
2407 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2408 retvm_if(permission_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2412 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2414 if (info->app_info == NULL)
2415 return PMINFO_R_ERROR;
2417 for (tmp = info->app_info->permission; tmp; tmp = tmp->next) {
2418 ptr = (permission_x *)tmp->data;
2422 ret = permission_func(ptr->value, user_data);
2430 API int pkgmgrinfo_appinfo_foreach_category(pkgmgrinfo_appinfo_h handle,
2431 pkgmgrinfo_app_category_list_cb category_func, void *user_data)
2433 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2434 retvm_if(category_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2436 const char *category;
2438 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2440 if (info->app_info == NULL)
2441 return PMINFO_R_ERROR;
2443 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
2444 category = (const char *)tmp->data;
2446 ret = category_func(category, user_data);
2454 API int pkgmgrinfo_appinfo_foreach_metadata(pkgmgrinfo_appinfo_h handle,
2455 pkgmgrinfo_app_metadata_list_cb metadata_func, void *user_data)
2457 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2458 retvm_if(metadata_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2462 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2464 if (info->app_info == NULL)
2465 return PMINFO_R_ERROR;
2467 for (tmp = info->app_info->metadata; tmp; tmp = tmp->next) {
2468 ptr = (metadata_x *)tmp->data;
2472 ret = metadata_func(ptr->key, ptr->value ? ptr->value : "", user_data);
2480 API int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
2481 pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
2483 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2484 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2486 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2487 appcontrol_x *appcontrol;
2490 if (info->app_info == NULL)
2491 return PMINFO_R_ERROR;
2493 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
2494 appcontrol = (appcontrol_x *)tmp->data;
2495 if (appcontrol == NULL)
2497 ret = appcontrol_func(appcontrol->operation, appcontrol->uri, appcontrol->mime, user_data);
2505 API int pkgmgrinfo_appinfo_foreach_background_category(
2506 pkgmgrinfo_appinfo_h handle,
2507 pkgmgrinfo_app_background_category_list_cb category_func,
2510 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2514 if (handle == NULL || category_func == NULL || info->app_info == NULL) {
2515 LOGE("invalid parameter");
2516 return PMINFO_R_EINVAL;
2519 for (tmp = info->app_info->background_category; tmp; tmp = tmp->next) {
2520 category = (char *)tmp->data;
2521 if (category == NULL)
2524 if (category_func(category, user_data) < 0)
2531 API int pkgmgrinfo_appinfo_foreach_splash_screen(pkgmgrinfo_appinfo_h handle,
2532 pkgmgrinfo_app_splash_screen_list_cb splash_screen_func,
2535 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2536 splashscreen_x *splashscreen;
2540 if (info == NULL || info->app_info == NULL
2541 || splash_screen_func == NULL) {
2542 LOGE("invalid parameter");
2543 return PMINFO_R_EINVAL;
2546 for (tmp = info->app_info->splashscreens; tmp; tmp = tmp->next) {
2547 splashscreen = (splashscreen_x *)tmp->data;
2548 if (splashscreen == NULL)
2550 ret = splash_screen_func(splashscreen->src,
2552 splashscreen->orientation,
2553 splashscreen->indicatordisplay,
2554 splashscreen->operation,
2555 splashscreen->color_depth,
2564 API int pkgmgrinfo_appinfo_is_nodisplay(pkgmgrinfo_appinfo_h handle, bool *nodisplay)
2566 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2567 retvm_if(nodisplay == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2568 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2570 if (info->app_info == NULL || info->app_info->nodisplay == NULL)
2571 return PMINFO_R_ERROR;
2573 *nodisplay = _get_bool_value(info->app_info->nodisplay);
2578 API int pkgmgrinfo_appinfo_is_multiple(pkgmgrinfo_appinfo_h handle, bool *multiple)
2580 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2581 retvm_if(multiple == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2582 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2584 if (info->app_info == NULL || info->app_info->multiple == NULL)
2585 return PMINFO_R_ERROR;
2587 *multiple = _get_bool_value(info->app_info->multiple);
2592 API int pkgmgrinfo_appinfo_is_indicator_display_allowed(pkgmgrinfo_appinfo_h handle, bool *indicator_disp)
2594 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2595 retvm_if(indicator_disp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2596 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2598 if (info->app_info == NULL || info->app_info->indicatordisplay == NULL)
2599 return PMINFO_R_ERROR;
2601 *indicator_disp = _get_bool_value(info->app_info->indicatordisplay);
2606 API int pkgmgrinfo_appinfo_is_taskmanage(pkgmgrinfo_appinfo_h handle, bool *taskmanage)
2608 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2609 retvm_if(taskmanage == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2610 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2612 if (info->app_info == NULL || info->app_info->taskmanage == NULL)
2613 return PMINFO_R_ERROR;
2615 *taskmanage = _get_bool_value(info->app_info->taskmanage);
2620 API int pkgmgrinfo_appinfo_is_enabled(pkgmgrinfo_appinfo_h handle, bool *enabled)
2622 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2623 retvm_if(enabled == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2624 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2626 if (info->app_info == NULL || info->app_info->is_disabled == NULL)
2627 return PMINFO_R_ERROR;
2629 *enabled = !_get_bool_value(info->app_info->is_disabled);
2634 API int pkgmgrinfo_appinfo_is_onboot(pkgmgrinfo_appinfo_h handle, bool *onboot)
2636 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2637 retvm_if(onboot == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2638 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2640 if (info->app_info == NULL || info->app_info->onboot == NULL)
2641 return PMINFO_R_ERROR;
2643 *onboot = _get_bool_value(info->app_info->onboot);
2648 API int pkgmgrinfo_appinfo_is_autorestart(pkgmgrinfo_appinfo_h handle, bool *autorestart)
2650 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2651 retvm_if(autorestart == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2652 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2654 if (info->app_info == NULL || info->app_info->autorestart == NULL)
2655 return PMINFO_R_ERROR;
2657 *autorestart = _get_bool_value(info->app_info->autorestart);
2662 API int pkgmgrinfo_appinfo_is_mainapp(pkgmgrinfo_appinfo_h handle, bool *mainapp)
2664 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2665 retvm_if(mainapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2666 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2668 if (info->app_info == NULL || info->app_info->mainapp == NULL)
2669 return PMINFO_R_ERROR;
2671 *mainapp = _get_bool_value(info->app_info->mainapp);
2676 API int pkgmgrinfo_appinfo_is_preload(pkgmgrinfo_appinfo_h handle, bool *preload)
2678 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2679 retvm_if(preload == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2680 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2682 if (info->app_info == NULL || info->app_info->preload == NULL)
2683 return PMINFO_R_ERROR;
2685 *preload = _get_bool_value(info->app_info->preload);
2690 API int pkgmgrinfo_appinfo_is_submode(pkgmgrinfo_appinfo_h handle, bool *submode)
2692 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2693 retvm_if(submode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2694 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2696 if (info->app_info == NULL || info->app_info->submode == NULL)
2697 return PMINFO_R_ERROR;
2699 *submode = _get_bool_value(info->app_info->submode);
2704 API int pkgmgrinfo_appinfo_is_process_pool(pkgmgrinfo_appinfo_h handle, bool *process_pool)
2706 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2708 if (handle == NULL || process_pool == NULL) {
2709 LOGE("invalid parameter");
2710 return PMINFO_R_EINVAL;
2713 if (info->app_info == NULL)
2714 return PMINFO_R_ERROR;
2716 *process_pool = _get_bool_value(info->app_info->process_pool);
2721 API int pkgmgrinfo_appinfo_is_category_exist(pkgmgrinfo_appinfo_h handle, const char *category, bool *exist)
2723 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2724 retvm_if(category == NULL, PMINFO_R_EINVAL, "category is NULL");
2725 retvm_if(exist == NULL, PMINFO_R_EINVAL, "exist is NULL");
2729 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2731 if (info->app_info == NULL)
2732 return PMINFO_R_ERROR;
2735 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
2736 val = (const char *)tmp->data;
2739 if (strcasecmp(val, category) == 0) {
2748 API int pkgmgrinfo_appinfo_is_ui_gadget(pkgmgrinfo_appinfo_h handle,
2751 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2753 if (info == NULL || info->app_info == NULL || ui_gadget == NULL) {
2754 _LOGE("invalid parameter");
2755 return PMINFO_R_EINVAL;
2757 if (info->app_info->ui_gadget == NULL)
2758 info->app_info->ui_gadget = strdup("false");
2760 *ui_gadget = _get_bool_value(info->app_info->ui_gadget);
2765 API int pkgmgrinfo_appinfo_is_support_disable(pkgmgrinfo_appinfo_h handle,
2766 bool *support_disable)
2768 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2770 if (info == NULL || info->app_info == NULL || support_disable == NULL) {
2771 _LOGE("invalid parameter");
2772 return PMINFO_R_EINVAL;
2775 *support_disable = _get_bool_value(info->app_info->support_disable);
2780 API int pkgmgrinfo_appinfo_is_removable(pkgmgrinfo_appinfo_h handle,
2783 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2785 if (info == NULL || info->app_info == NULL || removable == NULL) {
2786 _LOGE("invalid parameter");
2787 return PMINFO_R_EINVAL;
2790 *removable = _get_bool_value(info->app_info->removable);
2795 API int pkgmgrinfo_appinfo_is_system(pkgmgrinfo_appinfo_h handle, bool *system)
2797 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2799 if (info == NULL || info->app_info == NULL || system == NULL) {
2800 _LOGE("invalid parameter");
2801 return PMINFO_R_EINVAL;
2804 *system = _get_bool_value(info->app_info->package_system);
2809 API int pkgmgrinfo_appinfo_is_disabled(pkgmgrinfo_appinfo_h handle, bool *disabled)
2811 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2812 retvm_if(disabled == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2813 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2815 if (info->app_info == NULL || info->app_info->is_disabled == NULL)
2816 return PMINFO_R_ERROR;
2818 *disabled = _get_bool_value(info->app_info->is_disabled);
2823 API int pkgmgrinfo_appinfo_is_global(pkgmgrinfo_appinfo_h handle, bool *global)
2825 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2827 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2828 retvm_if(global == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2830 if (info->app_info == NULL || info->app_info->for_all_users == NULL)
2831 return PMINFO_R_ERROR;
2833 *global = _get_bool_value(info->app_info->for_all_users);
2838 API int pkgmgrinfo_appinfo_get_splash_screen_display(pkgmgrinfo_appinfo_h handle, bool *splash_screen_display)
2840 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2842 if (info == NULL || splash_screen_display == NULL) {
2843 _LOGE("Invalid parameter");
2844 return PMINFO_R_EINVAL;
2847 if (info->app_info == NULL || info->app_info->splash_screen_display == NULL)
2848 return PMINFO_R_ERROR;
2850 *splash_screen_display = _get_bool_value(info->app_info->splash_screen_display);
2855 API int pkgmgrinfo_appinfo_get_setup_appid(pkgmgrinfo_appinfo_h handle, char **setup_appid)
2857 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2859 if (info == NULL || setup_appid == NULL) {
2860 _LOGE("Invalid parameter");
2861 return PMINFO_R_EINVAL;
2864 if (info->app_info == NULL || info->app_info->setup_appid == NULL)
2865 return PMINFO_R_ERROR;
2867 *setup_appid = info->app_info->setup_appid;
2871 API int pkgmgrinfo_appinfo_is_support_ambient(pkgmgrinfo_appinfo_h handle,
2872 bool *support_ambient)
2874 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2876 if (info == NULL || support_ambient == NULL) {
2877 _LOGE("Invalid parameter");
2878 return PMINFO_R_EINVAL;
2881 if (info->app_info == NULL || info->app_info->support_ambient == NULL)
2882 return PMINFO_R_ERROR;
2884 *support_ambient = _get_bool_value(info->app_info->support_ambient);
2889 API int pkgmgrinfo_appinfo_destroy_appinfo(pkgmgrinfo_appinfo_h handle)
2891 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2892 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2893 __cleanup_appinfo(info);
2897 API int pkgmgrinfo_appinfo_filter_create(pkgmgrinfo_appinfo_filter_h *handle)
2899 return (pkgmgrinfo_pkginfo_filter_create(handle));
2902 API int pkgmgrinfo_appinfo_filter_destroy(pkgmgrinfo_appinfo_filter_h handle)
2904 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
2907 static gint __compare_func(gconstpointer data1, gconstpointer data2)
2909 pkgmgrinfo_node_x *node1 = (pkgmgrinfo_node_x *)data1;
2910 pkgmgrinfo_node_x *node2 = (pkgmgrinfo_node_x *)data2;
2911 if (node1->prop == node2->prop)
2913 else if (node1->prop > node2->prop)
2919 API int pkgmgrinfo_appinfo_filter_add_int(pkgmgrinfo_appinfo_filter_h handle,
2920 const char *property, const int value)
2922 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2923 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2924 char buf[PKG_VALUE_STRING_LEN_MAX] = {'\0'};
2926 GSList *link = NULL;
2928 prop = _pminfo_appinfo_convert_to_prop_int(property);
2929 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_INT ||
2930 prop > E_PMINFO_APPINFO_PROP_APP_MAX_INT) {
2931 _LOGE("Invalid Integer Property\n");
2932 return PMINFO_R_EINVAL;
2934 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2935 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1, sizeof(pkgmgrinfo_node_x));
2937 _LOGE("Out of Memory!!!\n");
2938 return PMINFO_R_ERROR;
2940 snprintf(buf, PKG_VALUE_STRING_LEN_MAX - 1, "%d", value);
2941 val = strndup(buf, PKG_VALUE_STRING_LEN_MAX - 1);
2943 _LOGE("Out of Memory\n");
2946 return PMINFO_R_ERROR;
2950 /*If API is called multiple times for same property, we should override the previous values.
2951 Last value set will be used for filtering.*/
2952 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2954 filter->list = g_slist_delete_link(filter->list, link);
2955 filter->list = g_slist_append(filter->list, (gpointer)node);
2960 API int pkgmgrinfo_appinfo_filter_add_bool(pkgmgrinfo_appinfo_filter_h handle,
2961 const char *property, const bool value)
2963 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2964 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2966 GSList *link = NULL;
2968 prop = _pminfo_appinfo_convert_to_prop_bool(property);
2969 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_BOOL ||
2970 prop > E_PMINFO_APPINFO_PROP_APP_MAX_BOOL) {
2971 _LOGE("Invalid Boolean Property\n");
2972 return PMINFO_R_EINVAL;
2974 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2975 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1, sizeof(pkgmgrinfo_node_x));
2977 _LOGE("Out of Memory!!!\n");
2978 return PMINFO_R_ERROR;
2981 val = strndup("true", 4);
2983 val = strndup("false", 5);
2985 _LOGE("Out of Memory\n");
2988 return PMINFO_R_ERROR;
2992 /*If API is called multiple times for same property, we should override the previous values.
2993 Last value set will be used for filtering.*/
2994 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2996 filter->list = g_slist_delete_link(filter->list, link);
2997 filter->list = g_slist_append(filter->list, (gpointer)node);
3002 API int pkgmgrinfo_appinfo_filter_add_string(pkgmgrinfo_appinfo_filter_h handle,
3003 const char *property, const char *value)
3005 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3006 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3007 retvm_if(value == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3009 pkgmgrinfo_node_x *ptr = NULL;
3010 char prev[PKG_STRING_LEN_MAX] = {'\0'};
3011 char temp[PKG_STRING_LEN_MAX] = {'\0'};
3012 GSList *link = NULL;
3014 prop = _pminfo_appinfo_convert_to_prop_str(property);
3015 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_STR ||
3016 prop > E_PMINFO_APPINFO_PROP_APP_MAX_STR) {
3017 _LOGE("Invalid String Property\n");
3018 return PMINFO_R_EINVAL;
3020 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
3021 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1, sizeof(pkgmgrinfo_node_x));
3023 _LOGE("Out of Memory!!!\n");
3024 return PMINFO_R_ERROR;
3028 case E_PMINFO_APPINFO_PROP_APP_COMPONENT:
3029 node->value = strdup(value);
3030 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
3032 filter->list = g_slist_delete_link(filter->list, link);
3033 filter->list = g_slist_append(filter->list, (gpointer)node);
3035 case E_PMINFO_APPINFO_PROP_APP_CATEGORY:
3036 val = (char *)calloc(1, PKG_STRING_LEN_MAX);
3038 _LOGE("Out of Memory\n");
3041 return PMINFO_R_ERROR;
3043 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
3045 ptr = (pkgmgrinfo_node_x *)link->data;
3046 strncpy(prev, ptr->value, PKG_STRING_LEN_MAX - 1);
3047 _LOGI("Previous value is %s\n", prev);
3048 filter->list = g_slist_delete_link(filter->list, link);
3049 snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s,%s", prev, value);
3050 strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
3051 _LOGI("New value is %s\n", val);
3053 filter->list = g_slist_append(filter->list, (gpointer)node);
3054 memset(temp, '\0', PKG_STRING_LEN_MAX);
3056 snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s", value);
3057 strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
3058 _LOGI("First value is %s\n", val);
3060 filter->list = g_slist_append(filter->list, (gpointer)node);
3061 memset(temp, '\0', PKG_STRING_LEN_MAX);
3065 node->value = strndup(value, PKG_STRING_LEN_MAX - 1);
3066 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
3068 filter->list = g_slist_delete_link(filter->list, link);
3069 filter->list = g_slist_append(filter->list, (gpointer)node);
3075 API int pkgmgrinfo_appinfo_usr_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count, uid_t uid)
3081 if (handle == NULL || count == NULL) {
3082 _LOGE("invalid parameter");
3083 return PMINFO_R_EINVAL;
3086 locale = _get_system_locale();
3088 return PMINFO_R_ERROR;
3090 list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
3091 __free_applications);
3094 return PMINFO_R_ERROR;
3097 ret = _appinfo_get_applications(uid, uid, locale, handle, 0, list);
3098 if (ret == PMINFO_R_OK && uid != GLOBAL_USER)
3099 ret = _appinfo_get_applications(GLOBAL_USER, uid, locale,
3102 if (ret != PMINFO_R_OK) {
3103 g_hash_table_destroy(list);
3105 return PMINFO_R_ERROR;
3108 *count = g_hash_table_size(list);
3109 g_hash_table_destroy(list);
3115 API int pkgmgrinfo_appinfo_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count)
3117 return pkgmgrinfo_appinfo_usr_filter_count(handle, count, _getuid());
3120 API int pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(
3121 pkgmgrinfo_appinfo_filter_h handle,
3122 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
3124 if (handle == NULL || app_cb == NULL) {
3125 LOGE("invalid parameter");
3126 return PMINFO_R_EINVAL;
3129 return _appinfo_get_filtered_foreach_appinfo(uid, handle, PMINFO_APPINFO_GET_ALL, app_cb,
3133 API int pkgmgrinfo_appinfo_filter_foreach_appinfo(pkgmgrinfo_appinfo_filter_h handle,
3134 pkgmgrinfo_app_list_cb app_cb, void *user_data)
3136 return pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(handle, app_cb, user_data, _getuid());
3139 API int pkgmgrinfo_appinfo_metadata_filter_create(pkgmgrinfo_appinfo_metadata_filter_h *handle)
3141 return (pkgmgrinfo_pkginfo_filter_create(handle));
3144 API int pkgmgrinfo_appinfo_metadata_filter_destroy(pkgmgrinfo_appinfo_metadata_filter_h handle)
3146 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
3149 API int pkgmgrinfo_appinfo_metadata_filter_add(
3150 pkgmgrinfo_appinfo_metadata_filter_h handle,
3151 const char *key, const char *value)
3153 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
3154 pkgmgrinfo_metadata_node_x *node;
3156 /* value can be NULL.
3157 * In that case all apps with specified key should be displayed
3160 LOGE("invalid parameter");
3161 return PMINFO_R_EINVAL;
3164 node = calloc(1, sizeof(pkgmgrinfo_metadata_node_x));
3166 LOGE("out of memory");
3167 return PMINFO_R_ERROR;
3170 node->key = strdup(key);
3171 if (value && strlen(value))
3172 node->value = strdup(value);
3174 filter->list_metadata = g_slist_append(filter->list_metadata,
3180 API int pkgmgrinfo_appinfo_usr_metadata_filter_foreach(
3181 pkgmgrinfo_appinfo_metadata_filter_h handle,
3182 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
3184 if (handle == NULL || app_cb == NULL) {
3185 LOGE("invalid parameter");
3186 return PMINFO_R_EINVAL;
3189 return _appinfo_get_filtered_foreach_appinfo(uid, handle, PMINFO_APPINFO_GET_ALL, app_cb,
3193 API int pkgmgrinfo_appinfo_metadata_filter_foreach(
3194 pkgmgrinfo_appinfo_metadata_filter_h handle,
3195 pkgmgrinfo_app_list_cb app_cb, void *user_data)
3197 return pkgmgrinfo_appinfo_usr_metadata_filter_foreach(handle, app_cb,
3198 user_data, _getuid());
3201 API int pkgmgrinfo_appinfo_is_guestmode_visibility(pkgmgrinfo_appinfo_h handle, bool *status)
3204 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3206 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
3207 retvm_if(status == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3209 val = info->app_info->guestmode_visibility;
3210 *status = _get_bool_value(val);