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, char **query, GList **bind_params)
61 char *condition = NULL;
62 char buf[MAX_QUERY_LEN] = { '\0' };
63 char tmp_query[MAX_QUERY_LEN] = { '\0' };
64 static const char query_pkg_disable[] = " AND ai.package IN "
65 "(SELECT package FROM package_info WHERE package_disable='false')";
68 len += strlen(" WHERE 1=1");
69 strncat(buf, " WHERE 1=1", MAX_QUERY_LEN - len - 1);
72 strncat(buf, query_pkg_disable, MAX_QUERY_LEN - len - 1);
77 for (list = filter->list; list; list = list->next) {
78 joined |= __get_filter_condition(list->data, &condition, bind_params);
79 if (condition == NULL)
82 len += strlen(" AND ");
83 strncat(buf, " AND ", MAX_QUERY_LEN - len - 1);
85 len += strlen(condition);
86 strncat(buf, condition, sizeof(buf) - len - 1);
91 if (joined & E_PMINFO_APPINFO_JOIN_LOCALIZED_INFO) {
92 strncat(tmp_query, join_localized_info, MAX_QUERY_LEN - len - 1);
93 len += strlen(join_localized_info);
94 *bind_params = g_list_append(*bind_params, strdup(locale));
96 if (joined & E_PMINFO_APPINFO_JOIN_CATEGORY) {
97 strncat(tmp_query, join_category, MAX_QUERY_LEN - len - 1);
98 len += strlen(join_category);
100 if (joined & E_PMINFO_APPINFO_JOIN_APP_CONTROL) {
101 strncat(tmp_query, join_app_control, MAX_QUERY_LEN - len - 1);
102 len += strlen(join_app_control);
104 if (joined & E_PMINFO_APPINFO_JOIN_METADATA) {
105 strncat(tmp_query, join_metadata, MAX_QUERY_LEN - len - 1);
106 len += strlen(join_metadata);
108 strncat(tmp_query, buf, MAX_QUERY_LEN - len - 1);
111 strncat(tmp_query, query_pkg_disable, MAX_QUERY_LEN - len - 1);
113 *query = strdup(tmp_query);
115 return PMINFO_R_ERROR;
120 static int _appinfo_get_category(sqlite3 *db, const char *appid,
123 static const char query_raw[] =
124 "SELECT category FROM package_app_app_category WHERE app_id=%Q";
130 query = sqlite3_mprintf(query_raw, appid);
132 LOGE("out of memory");
133 return PMINFO_R_ERROR;
136 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
138 if (ret != SQLITE_OK) {
139 LOGE("prepare failed: %s", sqlite3_errmsg(db));
140 return PMINFO_R_ERROR;
143 while (sqlite3_step(stmt) == SQLITE_ROW) {
145 _save_column_str(stmt, 0, &val);
147 *category = g_list_append(*category, (gpointer)val);
150 sqlite3_finalize(stmt);
155 static void __parse_appcontrol(GList **appcontrol, char *appcontrol_str)
162 if (appcontrol_str == NULL)
165 dup = strdup(appcontrol_str);
167 ac = calloc(1, sizeof(appcontrol_x));
169 _LOGE("out of memory");
172 token = strtok_r(dup, "|", &ptr);
173 if (token && strcmp(token, "NULL"))
174 ac->operation = strdup(token);
175 token = strtok_r(NULL, "|", &ptr);
176 if (token && strcmp(token, "NULL"))
177 ac->uri = strdup(token);
178 token = strtok_r(NULL, "|", &ptr);
179 if (token && strcmp(token, "NULL"))
180 ac->mime = strdup(token);
181 *appcontrol = g_list_append(*appcontrol, ac);
182 } while ((token = strtok_r(NULL, ";", &ptr)));
187 static int _appinfo_get_app_control(sqlite3 *db, const char *appid,
190 static const char query_raw[] =
191 "SELECT app_control FROM package_app_app_control "
198 query = sqlite3_mprintf(query_raw, appid);
200 LOGE("out of memory");
201 return PMINFO_R_ERROR;
204 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
206 if (ret != SQLITE_OK) {
207 LOGE("prepare failed: %s", sqlite3_errmsg(db));
208 return PMINFO_R_ERROR;
211 while (sqlite3_step(stmt) == SQLITE_ROW) {
213 _save_column_str(stmt, 0, &str);
215 __parse_appcontrol(appcontrol, str);
219 sqlite3_finalize(stmt);
224 static int _appinfo_get_data_control(sqlite3 *db, const char *appid,
227 static const char query_raw[] =
228 "SELECT providerid, access, type "
229 "FROM package_app_data_control WHERE app_id=%Q";
236 query = sqlite3_mprintf(query_raw, appid);
238 LOGE("out of memory");
239 return PMINFO_R_ERROR;
242 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
244 if (ret != SQLITE_OK) {
245 LOGE("prepare failed: %s", sqlite3_errmsg(db));
246 return PMINFO_R_ERROR;
249 while (sqlite3_step(stmt) == SQLITE_ROW) {
250 info = calloc(1, sizeof(datacontrol_x));
252 LOGE("out of memory");
253 sqlite3_finalize(stmt);
254 return PMINFO_R_ERROR;
257 _save_column_str(stmt, idx++, &info->providerid);
258 _save_column_str(stmt, idx++, &info->access);
259 _save_column_str(stmt, idx++, &info->type);
260 *datacontrol = g_list_append(*datacontrol, info);
263 sqlite3_finalize(stmt);
268 static int _appinfo_get_metadata(sqlite3 *db, const char *appid,
271 static const char query_raw[] =
272 "SELECT md_key, md_value "
273 "FROM package_app_app_metadata WHERE app_id=%Q";
280 query = sqlite3_mprintf(query_raw, appid);
282 LOGE("out of memory");
283 return PMINFO_R_ERROR;
286 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
288 if (ret != SQLITE_OK) {
289 LOGE("prepare failed: %s", sqlite3_errmsg(db));
290 return PMINFO_R_ERROR;
293 while (sqlite3_step(stmt) == SQLITE_ROW) {
294 info = calloc(1, sizeof(metadata_x));
296 LOGE("out of memory");
297 sqlite3_finalize(stmt);
298 return PMINFO_R_ERROR;
301 _save_column_str(stmt, idx++, &info->key);
302 _save_column_str(stmt, idx++, &info->value);
303 *metadata = g_list_append(*metadata, info);
306 sqlite3_finalize(stmt);
312 static int _appinfo_get_splashscreens(sqlite3 *db, const char *appid,
313 GList **splashscreens)
315 static const char query_raw[] =
316 "SELECT src, type, orientation, indicatordisplay, operation, color_depth "
317 "FROM package_app_splash_screen WHERE app_id=%Q";
322 splashscreen_x *info;
324 query = sqlite3_mprintf(query_raw, appid);
326 LOGE("out of memory");
327 return PMINFO_R_ERROR;
330 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
332 if (ret != SQLITE_OK) {
333 LOGE("prepare failed: %s", sqlite3_errmsg(db));
334 return PMINFO_R_ERROR;
337 while (sqlite3_step(stmt) == SQLITE_ROW) {
338 info = calloc(1, sizeof(splashscreen_x));
340 LOGE("out of memory");
341 sqlite3_finalize(stmt);
342 return PMINFO_R_ERROR;
345 _save_column_str(stmt, idx++, &info->src);
346 _save_column_str(stmt, idx++, &info->type);
347 _save_column_str(stmt, idx++, &info->orientation);
348 _save_column_str(stmt, idx++, &info->indicatordisplay);
349 _save_column_str(stmt, idx++, &info->operation);
350 _save_column_str(stmt, idx++, &info->color_depth);
351 *splashscreens = g_list_append(*splashscreens, info);
354 sqlite3_finalize(stmt);
359 static GList *__get_background_category(const char *value)
361 GList *category_list = NULL;
362 int convert_value = 0;
363 if (!value || strlen(value) == 0)
366 convert_value = atoi(value);
367 if (convert_value < 0)
370 if (convert_value & APP_BG_CATEGORY_USER_DISABLE_TRUE_VAL)
371 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_USER_DISABLE_TRUE_STR));
373 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_USER_DISABLE_FALSE_STR));
375 if (convert_value & APP_BG_CATEGORY_MEDIA_VAL)
376 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_MEDIA_STR));
378 if (convert_value & APP_BG_CATEGORY_DOWNLOAD_VAL)
379 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_DOWNLOAD_STR));
381 if (convert_value & APP_BG_CATEGORY_BGNETWORK_VAL)
382 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_BGNETWORK_STR));
384 if (convert_value & APP_BG_CATEGORY_LOCATION_VAL)
385 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_LOCATION_STR));
387 if (convert_value & APP_BG_CATEGORY_SENSOR_VAL)
388 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_SENSOR_STR));
390 if (convert_value & APP_BG_CATEGORY_IOTCOMM_VAL)
391 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_IOTCOMM_STR));
393 if (convert_value & APP_BG_CATEGORY_SYSTEM_VAL)
394 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_SYSTEM));
396 return category_list;
400 static int __get_appinfo_for_uid(sqlite3 *db, application_x *info, uid_t uid)
402 static const char query_raw[] =
403 "SELECT is_splash_screen_enabled, is_disabled "
404 "FROM package_app_info_for_uid WHERE app_id='%s' AND uid='%d'";
407 char *is_disabled = NULL;
410 query = sqlite3_mprintf(query_raw, info->appid, uid);
412 LOGE("out of memory");
413 return PMINFO_R_ERROR;
416 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
418 if (ret != SQLITE_OK) {
419 LOGE("sqlite3_prepare_v2() failed: %s", sqlite3_errmsg(db));
420 return PMINFO_R_ERROR;
423 while (sqlite3_step(stmt) == SQLITE_ROW) {
424 if (info->splash_screen_display)
425 free(info->splash_screen_display);
426 _save_column_str(stmt, 0, &info->splash_screen_display);
427 if (strcasecmp(info->is_disabled, "false") == 0) {
428 _save_column_str(stmt, 1, &is_disabled);
429 if (strcasecmp(is_disabled, "true") == 0)
430 ret = PMINFO_R_ERROR;
435 sqlite3_finalize(stmt);
439 static void __free_applications(gpointer data)
441 pkgmgrinfo_basic_free_application((application_x *)data);
444 static gint __app_disable_chk_func(gconstpointer data1, gconstpointer data2)
446 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)data1;
448 if (node->prop == E_PMINFO_APPINFO_PROP_APP_DISABLE)
454 static bool __check_disable_filter_exist(pkgmgrinfo_filter_x *filter)
461 link = g_slist_find_custom(filter->list, NULL, __app_disable_chk_func);
468 static int __bind_params(sqlite3_stmt *stmt, GList *params)
470 GList *tmp_list = NULL;
474 if (stmt == NULL || params == NULL)
475 return PMINFO_R_EINVAL;
479 ret = sqlite3_bind_text(stmt, ++idx, (char *)tmp_list->data, -1, SQLITE_STATIC);
480 if (ret != SQLITE_OK)
481 return PMINFO_R_ERROR;
482 tmp_list = tmp_list->next;
488 static bool __check_app_storage_status(pkgmgrinfo_filter_x *tmp_filter)
490 GSList *tmp_list = NULL;
491 pkgmgrinfo_node_x *tmp_node = NULL;
494 if (tmp_filter == NULL)
497 property = _pminfo_appinfo_convert_to_prop_bool(PMINFO_APPINFO_PROP_APP_CHECK_STORAGE);
498 for (tmp_list = tmp_filter->list; tmp_list != NULL;
499 tmp_list = g_slist_next(tmp_list)) {
500 tmp_node = (pkgmgrinfo_node_x *)tmp_list->data;
501 if (property == tmp_node->prop) {
502 if (strcmp(tmp_node->value, "true") == 0)
512 static int _appinfo_get_applications(uid_t db_uid, uid_t uid,
513 const char *locale, pkgmgrinfo_filter_x *filter, int flag,
514 GHashTable *applications)
516 static const char query_raw[] =
517 "SELECT DISTINCT ai.app_id, ai.app_component, ai.app_exec, "
518 "ai.app_nodisplay, ai.app_type, ai.app_onboot, "
519 "ai.app_multiple, ai.app_autorestart, ai.app_taskmanage, "
520 "ai.app_hwacceleration, ai.app_screenreader, "
521 "ai.app_mainapp, ai.app_recentimage, ai.app_launchcondition, "
522 "ai.app_indicatordisplay, ai.app_portraitimg, "
523 "ai.app_landscapeimg, ai.app_guestmodevisibility, "
524 "ai.app_permissiontype, ai.app_preload, ai.app_submode, "
525 "ai.app_submode_mainid, ai.app_launch_mode, ai.app_ui_gadget, "
526 "ai.app_support_disable, ai.app_process_pool, "
527 "ai.app_installed_storage, ai.app_background_category, "
528 "ai.app_package_type, ai.app_root_path, ai.app_api_version, "
529 "ai.app_effective_appid, ai.app_disable, "
530 "ai.app_splash_screen_display, ai.app_tep_name, "
531 "ai.app_zip_mount_file, ai.component_type, ai.package, "
532 "ai.app_external_path, ai.app_package_system, ai.app_removable, "
533 "ai.app_package_installed_time, ai.app_support_mode, "
534 "ai.app_support_ambient";
535 static const char query_label[] =
537 "(SELECT app_label FROM package_app_localized_info WHERE ai.app_id=app_id AND app_locale=?), "
538 "(SELECT app_label FROM package_app_localized_info WHERE ai.app_id=app_id AND app_locale='No Locale'))";
539 static const char query_icon[] =
541 "(SELECT app_icon FROM package_app_localized_info WHERE ai.app_id=app_id AND app_locale=?), "
542 "(SELECT app_icon FROM package_app_localized_info WHERE ai.app_id=app_id AND app_locale='No Locale'))";
543 static const char query_from_clause[] = " FROM package_app_info as ai";
544 int ret = PMINFO_R_ERROR;
548 char *bg_category_str = NULL;
549 char *constraint = NULL;
550 char *tmp_record = NULL;
551 char query[MAX_QUERY_LEN] = { '\0' };
552 application_x *info = NULL;
553 GList *bind_params = NULL;
555 sqlite3_stmt *stmt = NULL;
556 bool is_check_storage = true;
558 dbpath = getUserPkgParserDBPathUID(db_uid);
560 return PMINFO_R_ERROR;
562 ret = sqlite3_open_v2(dbpath, &db, SQLITE_OPEN_READONLY, NULL);
563 if (ret != SQLITE_OK) {
564 _LOGE("failed to open db: %d", ret);
566 return PMINFO_R_ERROR;
570 len = strlen(query_raw);
571 snprintf(query, MAX_QUERY_LEN - 1, "%s", query_raw);
572 if (flag & PMINFO_APPINFO_GET_LABEL) {
573 strncat(query, query_label, MAX_QUERY_LEN - len - 1);
574 len += strlen(query_label);
575 bind_params = g_list_append(bind_params, strdup(locale));
577 if (flag & PMINFO_APPINFO_GET_ICON) {
578 strncat(query, query_icon, MAX_QUERY_LEN - len - 1);
579 len += strlen(query_icon);
580 bind_params = g_list_append(bind_params, strdup(locale));
583 is_check_storage = __check_app_storage_status(filter);
585 ret = _get_filtered_query(filter, locale, &constraint, &bind_params);
586 if (ret != PMINFO_R_OK) {
587 LOGE("Failed to get WHERE clause");
590 strncat(query, query_from_clause, MAX_QUERY_LEN - len - 1);
591 len += strlen(query_from_clause);
594 strncat(query, constraint, MAX_QUERY_LEN - len - 1);
596 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
597 if (ret != SQLITE_OK) {
598 LOGE("prepare failed: %s", sqlite3_errmsg(db));
599 ret = PMINFO_R_ERROR;
603 if (g_list_length(bind_params) != 0) {
604 ret = __bind_params(stmt, bind_params);
605 if (ret != SQLITE_OK) {
606 LOGE("Failed to bind parameters");
611 while (sqlite3_step(stmt) == SQLITE_ROW) {
612 info = calloc(1, sizeof(application_x));
614 LOGE("out of memory");
615 ret = PMINFO_R_ERROR;
619 _save_column_str(stmt, idx++, &info->appid);
620 if (g_hash_table_contains(applications,
621 (gconstpointer)info->appid)) {
627 _save_column_str(stmt, idx++, &info->component);
628 _save_column_str(stmt, idx++, &info->exec);
629 _save_column_str(stmt, idx++, &info->nodisplay);
630 _save_column_str(stmt, idx++, &info->type);
631 _save_column_str(stmt, idx++, &info->onboot);
632 _save_column_str(stmt, idx++, &info->multiple);
633 _save_column_str(stmt, idx++, &info->autorestart);
634 _save_column_str(stmt, idx++, &info->taskmanage);
635 _save_column_str(stmt, idx++, &info->hwacceleration);
636 _save_column_str(stmt, idx++, &info->screenreader);
637 _save_column_str(stmt, idx++, &info->mainapp);
638 _save_column_str(stmt, idx++, &info->recentimage);
639 _save_column_str(stmt, idx++, &info->launchcondition);
640 _save_column_str(stmt, idx++, &info->indicatordisplay);
641 _save_column_str(stmt, idx++, &info->portraitimg);
642 _save_column_str(stmt, idx++, &info->landscapeimg);
643 _save_column_str(stmt, idx++, &info->guestmode_visibility);
644 _save_column_str(stmt, idx++, &info->permission_type);
645 _save_column_str(stmt, idx++, &info->preload);
646 _save_column_str(stmt, idx++, &info->submode);
647 _save_column_str(stmt, idx++, &info->submode_mainid);
648 _save_column_str(stmt, idx++, &info->launch_mode);
649 _save_column_str(stmt, idx++, &info->ui_gadget);
650 _save_column_str(stmt, idx++, &info->support_disable);
651 _save_column_str(stmt, idx++, &info->process_pool);
652 _save_column_str(stmt, idx++, &info->installed_storage);
653 _save_column_str(stmt, idx++, &bg_category_str);
654 _save_column_str(stmt, idx++, &info->package_type);
655 _save_column_str(stmt, idx++, &info->root_path);
656 _save_column_str(stmt, idx++, &info->api_version);
657 _save_column_str(stmt, idx++, &info->effective_appid);
658 _save_column_str(stmt, idx++, &info->is_disabled);
659 _save_column_str(stmt, idx++, &info->splash_screen_display);
660 _save_column_str(stmt, idx++, &info->tep_name);
661 _save_column_str(stmt, idx++, &info->zip_mount_file);
662 _save_column_str(stmt, idx++, &info->component_type);
663 _save_column_str(stmt, idx++, &info->package);
664 _save_column_str(stmt, idx++, &info->external_path);
665 _save_column_str(stmt, idx++, &info->package_system);
666 _save_column_str(stmt, idx++, &info->removable);
667 _save_column_str(stmt, idx++, &info->package_installed_time);
668 _save_column_str(stmt, idx++, &info->support_mode);
669 _save_column_str(stmt, idx++, &info->support_ambient);
671 info->for_all_users =
672 strdup((db_uid != GLOBAL_USER) ? "false" : "true");
674 if (db_uid == GLOBAL_USER) {
675 ret = __get_appinfo_for_uid(db, info, uid);
676 if (ret != PMINFO_R_OK) {
677 pkgmgrinfo_basic_free_application(info);
683 info->background_category = __get_background_category(
685 free(bg_category_str);
687 if (flag & PMINFO_APPINFO_GET_LABEL) {
689 _save_column_str(stmt, idx++, &tmp_record);
690 if (_add_label_info_into_list(locale, tmp_record, &info->label)) {
691 ret = PMINFO_R_ERROR;
696 if (flag & PMINFO_APPINFO_GET_ICON) {
698 _save_column_str(stmt, idx++, &tmp_record);
699 if (_add_icon_info_into_list(locale, tmp_record, &info->icon)) {
700 ret = PMINFO_R_ERROR;
705 if (flag & PMINFO_APPINFO_GET_CATEGORY) {
706 if (_appinfo_get_category(db, info->appid,
708 ret = PMINFO_R_ERROR;
713 if (flag & PMINFO_APPINFO_GET_APP_CONTROL) {
714 if (_appinfo_get_app_control(db, info->appid,
715 &info->appcontrol)) {
716 ret = PMINFO_R_ERROR;
721 if (flag & PMINFO_APPINFO_GET_DATA_CONTROL) {
722 if (_appinfo_get_data_control(db, info->appid,
723 &info->datacontrol)) {
724 ret = PMINFO_R_ERROR;
729 if (flag & PMINFO_APPINFO_GET_METADATA) {
730 if (_appinfo_get_metadata(db, info->appid,
732 ret = PMINFO_R_ERROR;
737 if (flag & PMINFO_APPINFO_GET_SPLASH_SCREEN) {
738 if (_appinfo_get_splashscreens(db, info->appid,
739 &info->splashscreens)) {
740 ret = PMINFO_R_ERROR;
745 if (is_check_storage &&
746 __appinfo_check_installed_storage(info) != PMINFO_R_OK) {
747 ret = PMINFO_R_ERROR;
748 pkgmgrinfo_basic_free_application(info);
753 g_hash_table_insert(applications, (gpointer)info->appid,
763 if (ret != PMINFO_R_OK && info != NULL)
764 pkgmgrinfo_basic_free_application(info);
766 g_list_free_full(bind_params, free);
767 sqlite3_close_v2(db);
768 sqlite3_finalize(stmt);
773 static int _pkgmgrinfo_get_appinfo(const char *appid, uid_t uid,
774 pkgmgrinfo_appinfo_filter_h filter, pkgmgrinfo_appinfo_h *handle)
779 pkgmgr_appinfo_x *info;
781 if (appid == NULL || filter == NULL || handle == NULL) {
782 LOGE("invalid parameter");
783 return PMINFO_R_EINVAL;
786 locale = _get_system_locale();
788 return PMINFO_R_ERROR;
790 list = g_hash_table_new(g_str_hash, g_str_equal);
793 return PMINFO_R_ERROR;
796 ret = _appinfo_get_applications(uid, uid, locale, filter,
797 PMINFO_APPINFO_GET_ALL, list);
798 if (!g_hash_table_size(list) && uid != GLOBAL_USER)
799 ret = _appinfo_get_applications(GLOBAL_USER, GLOBAL_USER, locale, filter,
800 PMINFO_APPINFO_GET_ALL, list);
802 if (!g_hash_table_size(list)) {
803 _LOGI("appinfo for [%s] is not existed for user [%d]",
805 g_hash_table_destroy(list);
807 return PMINFO_R_ENOENT;
810 info = calloc(1, sizeof(pkgmgr_appinfo_x));
812 _LOGE("out of memory");
813 g_hash_table_destroy(list);
815 return PMINFO_R_ERROR;
818 info->app_info = (application_x *)g_hash_table_lookup(list, appid);
819 info->locale = locale;
820 info->package = strdup(info->app_info->package);
822 /* just free list only */
823 g_hash_table_destroy(list);
830 API int pkgmgrinfo_appinfo_get_usr_disabled_appinfo(const char *appid, uid_t uid,
831 pkgmgrinfo_appinfo_h *handle)
834 pkgmgrinfo_appinfo_filter_h filter;
836 if (appid == NULL || handle == NULL) {
837 LOGE("invalid parameter");
838 return PMINFO_R_EINVAL;
841 ret = pkgmgrinfo_appinfo_filter_create(&filter);
842 if (ret != PMINFO_R_OK)
845 ret = pkgmgrinfo_appinfo_filter_add_string(filter,
846 PMINFO_APPINFO_PROP_APP_ID, appid);
847 if (ret != PMINFO_R_OK) {
848 pkgmgrinfo_appinfo_filter_destroy(filter);
849 return PMINFO_R_ERROR;
852 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
853 PMINFO_APPINFO_PROP_APP_DISABLE, true);
854 if (ret != PMINFO_R_OK) {
855 pkgmgrinfo_appinfo_filter_destroy(filter);
856 return PMINFO_R_ERROR;
859 ret = _pkgmgrinfo_get_appinfo(appid, uid, filter, handle);
860 pkgmgrinfo_appinfo_filter_destroy(filter);
865 API int pkgmgrinfo_appinfo_get_disabled_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
867 return pkgmgrinfo_appinfo_get_usr_disabled_appinfo(appid, _getuid(), handle);
870 API int pkgmgrinfo_appinfo_get_usr_appinfo(const char *appid, uid_t uid,
871 pkgmgrinfo_appinfo_h *handle)
874 pkgmgrinfo_appinfo_filter_h filter;
876 if (appid == NULL || handle == NULL) {
877 LOGE("invalid parameter");
878 return PMINFO_R_EINVAL;
881 ret = pkgmgrinfo_appinfo_filter_create(&filter);
882 if (ret != PMINFO_R_OK)
885 ret = pkgmgrinfo_appinfo_filter_add_string(filter,
886 PMINFO_APPINFO_PROP_APP_ID, appid);
887 if (ret != PMINFO_R_OK) {
888 pkgmgrinfo_appinfo_filter_destroy(filter);
889 return PMINFO_R_ERROR;
892 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
893 PMINFO_APPINFO_PROP_APP_DISABLE, false);
894 if (ret != PMINFO_R_OK) {
895 pkgmgrinfo_appinfo_filter_destroy(filter);
896 return PMINFO_R_ERROR;
899 ret = _pkgmgrinfo_get_appinfo(appid, uid, filter, handle);
900 pkgmgrinfo_appinfo_filter_destroy(filter);
904 API int pkgmgrinfo_appinfo_get_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
906 return pkgmgrinfo_appinfo_get_usr_appinfo(appid, _getuid(), handle);
909 API int pkgmgrinfo_appinfo_get_usr_all_appinfo(const char *appid, uid_t uid,
910 pkgmgrinfo_appinfo_h *handle)
913 pkgmgrinfo_appinfo_filter_h filter;
915 if (appid == NULL || handle == NULL) {
916 LOGE("invalid parameter");
917 return PMINFO_R_EINVAL;
920 ret = pkgmgrinfo_appinfo_filter_create(&filter);
921 if (ret != PMINFO_R_OK)
924 ret = pkgmgrinfo_appinfo_filter_add_string(filter,
925 PMINFO_APPINFO_PROP_APP_ID, appid);
926 if (ret != PMINFO_R_OK) {
927 pkgmgrinfo_appinfo_filter_destroy(filter);
928 return PMINFO_R_ERROR;
931 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
932 PMINFO_APPINFO_PROP_APP_CHECK_STORAGE, false);
933 if (ret != PMINFO_R_OK) {
934 pkgmgrinfo_appinfo_filter_destroy(filter);
935 return PMINFO_R_ERROR;
938 ret = _pkgmgrinfo_get_appinfo(appid, uid, filter, handle);
939 pkgmgrinfo_appinfo_filter_destroy(filter);
944 API int pkgmgrinfo_appinfo_get_all_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
946 return pkgmgrinfo_appinfo_get_usr_all_appinfo(appid, _getuid(), handle);
949 static gpointer __copy_str(gconstpointer src, gpointer data)
951 const char *tmp = (const char *)src;
954 buffer = strdup(tmp);
955 if (buffer == NULL) {
956 LOGE("memory alloc failed");
964 static gpointer __copy_label(gconstpointer src, gpointer data)
966 label_x *tmp = (label_x *)src;
969 label = calloc(1, sizeof(label_x));
971 LOGE("memory alloc failed");
977 label->name = strdup(tmp->name);
979 label->text = strdup(tmp->text);
981 label->lang = strdup(tmp->lang);
986 static gpointer __copy_icon(gconstpointer src, gpointer data)
988 icon_x *tmp = (icon_x *)src;
991 icon = calloc(1, sizeof(icon_x));
993 LOGE("memory alloc failed");
999 icon->text = strdup(tmp->text);
1001 icon->lang = strdup(tmp->lang);
1003 icon->section = strdup(tmp->section);
1005 icon->size = strdup(tmp->size);
1006 if (tmp->resolution)
1007 icon->resolution = strdup(tmp->resolution);
1012 static gpointer __copy_metadata(gconstpointer src, gpointer data)
1014 metadata_x *tmp = (metadata_x *)src;
1015 metadata_x *metadata;
1017 metadata = calloc(1, sizeof(metadata_x));
1018 if (metadata == NULL) {
1019 LOGE("memory alloc failed");
1025 metadata->key = strdup(tmp->key);
1027 metadata->value = strdup(tmp->value);
1032 static gpointer __copy_datacontrol(gconstpointer src, gpointer data)
1034 datacontrol_x *tmp = (datacontrol_x *)src;
1035 datacontrol_x *datacontrol;
1037 datacontrol = calloc(1, sizeof(datacontrol_x));
1038 if (datacontrol == NULL) {
1039 LOGE("memory alloc failed");
1044 if (tmp->providerid)
1045 datacontrol->providerid = strdup(tmp->providerid);
1047 datacontrol->access = strdup(tmp->access);
1049 datacontrol->type = strdup(tmp->type);
1054 static gpointer __copy_appcontrol(gconstpointer src, gpointer data)
1056 appcontrol_x *tmp = (appcontrol_x *)src;
1057 appcontrol_x *appcontrol;
1059 appcontrol = calloc(1, sizeof(appcontrol_x));
1060 if (appcontrol == NULL) {
1061 LOGE("memory alloc failed");
1067 appcontrol->operation = strdup(tmp->operation);
1069 appcontrol->uri = strdup(tmp->uri);
1071 appcontrol->mime = strdup(tmp->mime);
1076 static gpointer __copy_splashscreens(gconstpointer src, gpointer data)
1078 splashscreen_x *tmp = (splashscreen_x *)src;
1079 splashscreen_x *splashscreen;
1081 splashscreen = (splashscreen_x *)calloc(1, sizeof(splashscreen_x));
1082 if (splashscreen == NULL) {
1083 LOGE("memory alloc failed");
1089 splashscreen->src = strdup(tmp->src);
1091 splashscreen->type = strdup(tmp->type);
1092 if (tmp->orientation)
1093 splashscreen->orientation = strdup(tmp->orientation);
1094 if (tmp->indicatordisplay)
1095 splashscreen->indicatordisplay = strdup(tmp->indicatordisplay);
1097 splashscreen->operation = strdup(tmp->operation);
1098 if (tmp->color_depth)
1099 splashscreen->color_depth = strdup(tmp->color_depth);
1101 return splashscreen;
1104 static int _appinfo_copy_appinfo(application_x **application, application_x *data)
1106 application_x *app_info;
1109 app_info = calloc(1, sizeof(application_x));
1110 if (app_info == NULL) {
1111 LOGE("memory alloc failed");
1112 return PMINFO_R_ERROR;
1115 if (data->appid != NULL)
1116 app_info->appid = strdup(data->appid);
1117 if (data->exec != NULL)
1118 app_info->exec = strdup(data->exec);
1119 if (data->nodisplay != NULL)
1120 app_info->nodisplay = strdup(data->nodisplay);
1121 if (data->multiple != NULL)
1122 app_info->multiple = strdup(data->multiple);
1123 if (data->taskmanage != NULL)
1124 app_info->taskmanage = strdup(data->taskmanage);
1125 if (data->type != NULL)
1126 app_info->type = strdup(data->type);
1127 if (data->categories != NULL)
1128 app_info->categories = strdup(data->categories);
1129 if (data->hwacceleration != NULL)
1130 app_info->hwacceleration = strdup(data->hwacceleration);
1131 if (data->screenreader != NULL)
1132 app_info->screenreader = strdup(data->screenreader);
1133 if (data->mainapp != NULL)
1134 app_info->mainapp = strdup(data->mainapp);
1135 if (data->package != NULL)
1136 app_info->package = strdup(data->package);
1137 if (data->recentimage != NULL)
1138 app_info->recentimage = strdup(data->recentimage);
1139 if (data->launchcondition != NULL)
1140 app_info->launchcondition = strdup(data->launchcondition);
1141 if (data->indicatordisplay != NULL)
1142 app_info->indicatordisplay = strdup(data->indicatordisplay);
1143 if (data->portraitimg != NULL)
1144 app_info->portraitimg = strdup(data->portraitimg);
1145 if (data->landscapeimg != NULL)
1146 app_info->landscapeimg = strdup(data->landscapeimg);
1147 if (data->guestmode_visibility != NULL)
1148 app_info->guestmode_visibility = strdup(data->guestmode_visibility);
1149 if (data->component != NULL)
1150 app_info->component = strdup(data->component);
1151 if (data->permission_type != NULL)
1152 app_info->permission_type = strdup(data->permission_type);
1153 if (data->component_type != NULL)
1154 app_info->component_type = strdup(data->component_type);
1155 if (data->preload != NULL)
1156 app_info->preload = strdup(data->preload);
1157 if (data->submode != NULL)
1158 app_info->submode = strdup(data->submode);
1159 if (data->submode_mainid != NULL)
1160 app_info->submode_mainid = strdup(data->submode_mainid);
1161 if (data->process_pool != NULL)
1162 app_info->process_pool = strdup(data->process_pool);
1163 if (data->installed_storage != NULL)
1164 app_info->installed_storage = strdup(data->installed_storage);
1165 if (data->autorestart != NULL)
1166 app_info->autorestart = strdup(data->autorestart);
1167 if (data->onboot != NULL)
1168 app_info->onboot = strdup(data->onboot);
1169 if (data->support_disable != NULL)
1170 app_info->support_disable = strdup(data->support_disable);
1171 if (data->ui_gadget != NULL)
1172 app_info->ui_gadget = strdup(data->ui_gadget);
1173 if (data->launch_mode != NULL)
1174 app_info->launch_mode = strdup(data->launch_mode);
1175 if (data->package_type != NULL)
1176 app_info->package_type = strdup(data->package_type);
1177 if (data->effective_appid != NULL)
1178 app_info->effective_appid = strdup(data->effective_appid);
1179 if (data->splash_screen_display != NULL)
1180 app_info->splash_screen_display = strdup(data->splash_screen_display);
1184 app_info->label = g_list_copy_deep(data->label, __copy_label, &ret);
1186 LOGE("memory alloc failed");
1187 pkgmgrinfo_basic_free_application(app_info);
1188 return PMINFO_R_ERROR;
1192 app_info->icon = g_list_copy_deep(data->icon, __copy_icon, &ret);
1194 LOGE("memory alloc failed");
1195 pkgmgrinfo_basic_free_application(app_info);
1196 return PMINFO_R_ERROR;
1200 app_info->category = g_list_copy_deep(data->category, __copy_str, &ret);
1202 LOGE("memory alloc failed");
1203 pkgmgrinfo_basic_free_application(app_info);
1204 return PMINFO_R_ERROR;
1208 app_info->metadata = g_list_copy_deep(data->metadata, __copy_metadata, &ret);
1210 LOGE("memory alloc failed");
1211 pkgmgrinfo_basic_free_application(app_info);
1212 return PMINFO_R_ERROR;
1216 app_info->datacontrol = g_list_copy_deep(data->datacontrol, __copy_datacontrol, &ret);
1218 LOGE("memory alloc failed");
1219 pkgmgrinfo_basic_free_application(app_info);
1220 return PMINFO_R_ERROR;
1224 app_info->appcontrol = g_list_copy_deep(data->appcontrol, __copy_appcontrol, &ret);
1226 LOGE("memory alloc failed");
1227 pkgmgrinfo_basic_free_application(app_info);
1228 return PMINFO_R_ERROR;
1232 app_info->background_category = g_list_copy_deep(data->background_category, __copy_str, &ret);
1234 LOGE("memory alloc failed");
1235 pkgmgrinfo_basic_free_application(app_info);
1236 return PMINFO_R_ERROR;
1240 app_info->splashscreens = g_list_copy_deep(data->splashscreens, __copy_splashscreens, &ret);
1242 LOGE("memory alloc failed");
1243 pkgmgrinfo_basic_free_application(app_info);
1244 return PMINFO_R_ERROR;
1247 *application = app_info;
1252 API int pkgmgrinfo_appinfo_clone_appinfo(pkgmgrinfo_appinfo_h handle,
1253 pkgmgrinfo_appinfo_h *clone)
1255 pkgmgr_appinfo_x *info;
1256 pkgmgr_appinfo_x *temp = (pkgmgr_appinfo_x *)handle;
1259 return PMINFO_R_EINVAL;
1261 info = calloc(1, sizeof(pkgmgr_appinfo_x));
1263 LOGE("memory alloc failed");
1264 return PMINFO_R_ERROR;
1267 if (temp->package != NULL)
1268 info->package = strdup(temp->package);
1269 if (temp->locale != NULL)
1270 info->locale = strdup(temp->locale);
1272 info->app_component = temp->app_component;
1274 if (_appinfo_copy_appinfo(&info->app_info, temp->app_info) < 0) {
1275 LOGE("appinfo copy failed");
1277 free((void *)info->package);
1281 return PMINFO_R_ERROR;
1289 static int _appinfo_get_filtered_foreach_appinfo(uid_t uid,
1290 pkgmgrinfo_filter_x *filter, int flag, pkgmgrinfo_app_list_cb app_list_cb,
1296 pkgmgr_appinfo_x info;
1298 GHashTableIter iter;
1301 locale = _get_system_locale();
1303 return PMINFO_R_ERROR;
1305 list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
1306 __free_applications);
1309 return PMINFO_R_ERROR;
1312 if (__check_disable_filter_exist(filter) == false) {
1313 pkgmgrinfo_appinfo_filter_add_bool(filter,
1314 PMINFO_APPINFO_PROP_APP_DISABLE, false);
1317 ret = _appinfo_get_applications(uid, uid, locale, filter, flag, list);
1318 if (ret == PMINFO_R_OK && uid != GLOBAL_USER)
1319 ret = _appinfo_get_applications(GLOBAL_USER, uid, locale,
1320 filter, flag, list);
1322 if (ret != PMINFO_R_OK) {
1323 g_hash_table_destroy(list);
1328 g_hash_table_iter_init(&iter, list);
1329 while (g_hash_table_iter_next(&iter, NULL, &value)) {
1330 app = (application_x *)value;
1331 info.app_info = app;
1332 info.locale = locale;
1333 info.package = app->package;
1334 if (app_list_cb(&info, user_data) < 0)
1337 g_hash_table_destroy(list);
1343 static const char *__appcomponent_str(pkgmgrinfo_app_component comp);
1345 API int pkgmgrinfo_appinfo_get_usr_list(pkgmgrinfo_pkginfo_h handle,
1346 pkgmgrinfo_app_component component,
1347 pkgmgrinfo_app_list_cb app_func, void *user_data, uid_t uid)
1350 pkgmgrinfo_appinfo_filter_h filter;
1352 const char *comp_str = NULL;
1354 if (handle == NULL || app_func == NULL) {
1355 LOGE("invalid parameter");
1356 return PMINFO_R_EINVAL;
1359 if (pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid)) {
1360 LOGE("invalid parameter");
1361 return PMINFO_R_EINVAL;
1364 if (pkgmgrinfo_appinfo_filter_create(&filter))
1365 return PMINFO_R_ERROR;
1367 if (pkgmgrinfo_appinfo_filter_add_string(filter,
1368 PMINFO_APPINFO_PROP_APP_PACKAGE, pkgid)) {
1369 pkgmgrinfo_appinfo_filter_destroy(filter);
1370 return PMINFO_R_ERROR;
1373 comp_str = __appcomponent_str(component);
1376 if (pkgmgrinfo_appinfo_filter_add_string(filter,
1377 PMINFO_APPINFO_PROP_APP_COMPONENT,
1379 pkgmgrinfo_appinfo_filter_destroy(filter);
1380 return PMINFO_R_ERROR;
1384 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter,
1385 PMINFO_APPINFO_GET_ALL, app_func, user_data);
1387 pkgmgrinfo_appinfo_filter_destroy(filter);
1392 API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle,
1393 pkgmgrinfo_app_component component,
1394 pkgmgrinfo_app_list_cb app_func, void *user_data)
1396 return pkgmgrinfo_appinfo_get_usr_list(handle, component, app_func, user_data, _getuid());
1399 API int pkgmgrinfo_appinfo_get_usr_installed_list_full(
1400 pkgmgrinfo_app_list_cb app_func, uid_t uid, int flag,
1404 pkgmgrinfo_appinfo_filter_h filter;
1406 if (app_func == NULL) {
1407 LOGE("invalid parameter");
1408 return PMINFO_R_EINVAL;
1411 if (pkgmgrinfo_appinfo_filter_create(&filter))
1412 return PMINFO_R_ERROR;
1414 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
1415 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
1416 pkgmgrinfo_appinfo_filter_destroy(filter);
1417 return PMINFO_R_ERROR;
1420 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter, flag, app_func,
1423 pkgmgrinfo_appinfo_filter_destroy(filter);
1428 API int pkgmgrinfo_appinfo_get_installed_list_full(
1429 pkgmgrinfo_app_list_cb app_func, int flag, void *user_data)
1431 return pkgmgrinfo_appinfo_get_usr_installed_list_full(app_func,
1432 _getuid(), flag, user_data);
1435 API int pkgmgrinfo_appinfo_get_usr_install_list(pkgmgrinfo_app_list_cb app_func,
1436 uid_t uid, void *user_data)
1438 return pkgmgrinfo_appinfo_get_usr_installed_list_full(app_func,
1439 uid, PMINFO_APPINFO_GET_ALL, user_data);
1442 API int pkgmgrinfo_appinfo_get_install_list(pkgmgrinfo_app_list_cb app_func,
1445 return pkgmgrinfo_appinfo_get_usr_installed_list_full(app_func,
1446 _getuid(), PMINFO_APPINFO_GET_ALL, user_data);
1449 API int pkgmgrinfo_appinfo_get_usr_installed_list(
1450 pkgmgrinfo_app_list_cb app_func, uid_t uid, void *user_data)
1453 pkgmgrinfo_appinfo_filter_h filter;
1455 if (app_func == NULL) {
1456 LOGE("invalid parameter");
1457 return PMINFO_R_EINVAL;
1460 /* create an empty filter */
1461 ret = pkgmgrinfo_appinfo_filter_create(&filter);
1462 if (ret != PMINFO_R_OK)
1465 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter,
1466 PMINFO_APPINFO_GET_ALL, app_func, user_data);
1468 pkgmgrinfo_appinfo_filter_destroy(filter);
1473 API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func,
1476 return pkgmgrinfo_appinfo_get_usr_installed_list(app_func, _getuid(),
1480 API int pkgmgrinfo_appinfo_get_appid(pkgmgrinfo_appinfo_h handle, char **appid)
1482 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1484 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1485 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1487 if (info->app_info == NULL || info->app_info->appid == NULL)
1488 return PMINFO_R_ERROR;
1489 *appid = (char *)info->app_info->appid;
1494 API int pkgmgrinfo_appinfo_get_pkgname(pkgmgrinfo_appinfo_h handle, char **pkg_name)
1496 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1498 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1499 retvm_if(pkg_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1501 if (info->package == NULL)
1502 return PMINFO_R_ERROR;
1504 *pkg_name = (char *)info->package;
1509 API int pkgmgrinfo_appinfo_get_pkgid(pkgmgrinfo_appinfo_h handle, char **pkgid)
1511 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1513 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1514 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1516 if (info->package == NULL)
1517 return PMINFO_R_ERROR;
1519 *pkgid = (char *)info->package;
1524 API int pkgmgrinfo_appinfo_get_pkgtype(pkgmgrinfo_appinfo_h handle, char **pkgtype)
1526 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1527 retvm_if(pkgtype == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1528 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1530 *pkgtype = (char *)info->app_info->package_type;
1535 API int pkgmgrinfo_appinfo_get_exec(pkgmgrinfo_appinfo_h handle, char **exec)
1537 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1539 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1540 retvm_if(exec == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1542 if (info->app_info == NULL || info->app_info->exec == NULL)
1543 return PMINFO_R_ERROR;
1544 *exec = (char *)info->app_info->exec;
1550 API int pkgmgrinfo_appinfo_get_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1553 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1555 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1556 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1558 if (info->app_info == NULL)
1559 return PMINFO_R_ERROR;
1561 if (info->app_info->icon == NULL) {
1566 ptr = (icon_x *)info->app_info->icon->data;
1568 return PMINFO_R_ERROR;
1570 if (ptr->text == NULL)
1571 return PMINFO_R_ERROR;
1579 API int pkgmgrinfo_appinfo_get_label(pkgmgrinfo_appinfo_h handle, char **label)
1582 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1584 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1585 retvm_if(label == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1587 if (info->app_info == NULL || info->app_info->label == NULL)
1588 return PMINFO_R_ERROR;
1590 ptr = (label_x *)info->app_info->label->data;
1592 return PMINFO_R_ERROR;
1594 if (ptr->text == NULL)
1595 return PMINFO_R_ERROR;
1602 static char *_get_localed_label(const char *appid, const char *locale, uid_t uid)
1604 char *result = NULL;
1606 sqlite3_stmt *stmt = NULL;
1611 parser_db = getUserPkgParserDBPathUID(uid);
1612 if (parser_db == NULL) {
1613 _LOGE("Failed to get parser db path");
1617 if (sqlite3_open_v2(parser_db, &db, SQLITE_OPEN_READONLY, NULL) != SQLITE_OK) {
1618 _LOGE("DB open fail\n");
1624 query = sqlite3_mprintf("select app_label from package_app_localized_info where app_id=%Q and app_locale=%Q", appid, locale);
1625 if (query == NULL) {
1626 _LOGE("Out of memory");
1630 if (sqlite3_prepare_v2(db, query, -1, &stmt, NULL) != SQLITE_OK) {
1631 _LOGE("prepare_v2 fail\n");
1635 if (sqlite3_step(stmt) == SQLITE_ROW) {
1636 val = (char *)sqlite3_column_text(stmt, 0);
1638 result = strdup(val);
1642 sqlite3_finalize(stmt);
1643 sqlite3_free(query);
1649 API int pkgmgrinfo_appinfo_usr_get_localed_label(const char *appid, const char *locale, uid_t uid, char **label)
1653 retvm_if(appid == NULL || locale == NULL || label == NULL, PMINFO_R_EINVAL, "Argument is NULL");
1655 val = _get_localed_label(appid, locale, uid);
1657 val = _get_localed_label(appid, DEFAULT_LOCALE, uid);
1660 val = _get_localed_label(appid, locale, GLOBAL_USER);
1662 val = _get_localed_label(appid, DEFAULT_LOCALE, GLOBAL_USER);
1666 return PMINFO_R_ERROR;
1673 API int pkgmgrinfo_appinfo_get_localed_label(const char *appid, const char *locale, char **label)
1675 return pkgmgrinfo_appinfo_usr_get_localed_label(appid, locale, _getuid(), label);
1678 API int pkgmgrinfo_appinfo_get_metadata_value(pkgmgrinfo_appinfo_h handle, const char *metadata_key, char **metadata_value)
1680 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1681 retvm_if(metadata_key == NULL, PMINFO_R_EINVAL, "metadata_key is NULL");
1682 retvm_if(metadata_value == NULL, PMINFO_R_EINVAL, "metadata_value is NULL");
1684 GList *list_md = NULL;
1685 metadata_x *metadata = NULL;
1686 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1688 list_md = info->app_info->metadata;
1690 for (; list_md; list_md = list_md->next) {
1691 metadata = (metadata_x *)list_md->data;
1692 if (metadata && metadata->key) {
1693 if (strcasecmp(metadata->key, metadata_key) == 0) {
1694 if (metadata->value == NULL)
1695 *metadata_value = "";
1697 *metadata_value = (char *)metadata->value;
1703 return PMINFO_R_EINVAL;
1706 static pkgmgrinfo_app_component __appcomponent_convert(const char *comp)
1708 if (strcasecmp(comp, "uiapp") == 0)
1709 return PMINFO_UI_APP;
1710 else if (strcasecmp(comp, "svcapp") == 0)
1711 return PMINFO_SVC_APP;
1712 else if (strcasecmp(comp, "widgetapp") == 0)
1713 return PMINFO_WIDGET_APP;
1714 else if (strcasecmp(comp, "watchapp") == 0)
1715 return PMINFO_WATCH_APP;
1720 static const char *__appcomponent_str(pkgmgrinfo_app_component comp)
1725 case PMINFO_SVC_APP:
1727 case PMINFO_WIDGET_APP:
1729 case PMINFO_WATCH_APP:
1736 API int pkgmgrinfo_appinfo_get_component(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_component *component)
1738 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1741 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1742 retvm_if(component == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1744 if (info->app_info == NULL)
1745 return PMINFO_R_ERROR;
1747 comp = __appcomponent_convert(info->app_info->component);
1749 return PMINFO_R_ERROR;
1756 API int pkgmgrinfo_appinfo_get_apptype(pkgmgrinfo_appinfo_h handle, char **app_type)
1758 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1760 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1761 retvm_if(app_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1763 if (info->app_info == NULL || info->app_info->type == NULL)
1764 return PMINFO_R_ERROR;
1765 *app_type = (char *)info->app_info->type;
1770 API int pkgmgrinfo_appinfo_get_operation(pkgmgrinfo_appcontrol_h handle,
1771 int *operation_count, char ***operation)
1773 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1774 retvm_if(operation == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1775 retvm_if(operation_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1776 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1777 *operation_count = data->operation_count;
1778 *operation = data->operation;
1782 API int pkgmgrinfo_appinfo_get_uri(pkgmgrinfo_appcontrol_h handle,
1783 int *uri_count, char ***uri)
1785 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1786 retvm_if(uri == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1787 retvm_if(uri_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1788 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1789 *uri_count = data->uri_count;
1794 API int pkgmgrinfo_appinfo_get_mime(pkgmgrinfo_appcontrol_h handle,
1795 int *mime_count, char ***mime)
1797 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1798 retvm_if(mime == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1799 retvm_if(mime_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1800 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1801 *mime_count = data->mime_count;
1806 API int pkgmgrinfo_appinfo_get_subapp(pkgmgrinfo_appcontrol_h handle,
1807 int *subapp_count, char ***subapp)
1809 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1810 retvm_if(subapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1811 retvm_if(subapp_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1812 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1813 *subapp_count = data->subapp_count;
1814 *subapp = data->subapp;
1818 API int pkgmgrinfo_appinfo_get_setting_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1823 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1825 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1826 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1828 if (info->app_info == NULL)
1829 return PMINFO_R_ERROR;
1831 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1832 ptr = (icon_x *)tmp->data;
1833 if (ptr == NULL || ptr->section == NULL)
1836 val = (char *)ptr->section;
1837 if (val && strcmp(val, "setting") == 0) {
1838 *icon = (char *)ptr->text;
1843 return PMINFO_R_ERROR;
1847 API int pkgmgrinfo_appinfo_get_notification_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, "notification") == 0) {
1867 *icon = (char *)ptr->text;
1872 return PMINFO_R_ERROR;
1875 API int pkgmgrinfo_appinfo_get_recent_image_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_recentimage *type)
1878 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1880 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1881 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1883 if (info->app_info == NULL || info->app_info->recentimage == NULL)
1884 return PMINFO_R_ERROR;
1886 val = (char *)info->app_info->recentimage;
1887 if (strcasecmp(val, "capture") == 0)
1888 *type = PMINFO_RECENTIMAGE_USE_CAPTURE;
1889 else if (strcasecmp(val, "icon") == 0)
1890 *type = PMINFO_RECENTIMAGE_USE_ICON;
1892 *type = PMINFO_RECENTIMAGE_USE_NOTHING;
1897 API int pkgmgrinfo_appinfo_get_preview_image(pkgmgrinfo_appinfo_h handle, char **preview_img)
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(preview_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1907 if (info->app_info == NULL)
1908 return PMINFO_R_ERROR;
1910 for (tmp = info->app_info->image; tmp; tmp = tmp->next) {
1911 ptr = (image_x *)tmp->data;
1912 if (ptr == NULL || ptr->section == NULL)
1915 val = (char *)ptr->section;
1916 if (val && strcmp(val, "preview") == 0) {
1917 *preview_img = (char *)ptr->text;
1922 return PMINFO_R_ERROR;
1925 API int pkgmgrinfo_appinfo_get_permission_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_permission_type *permission)
1928 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1930 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1931 retvm_if(permission == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1933 val = info->app_info->permission_type;
1935 return PMINFO_R_ERROR;
1937 if (strcmp(val, "signature") == 0)
1938 *permission = PMINFO_PERMISSION_SIGNATURE;
1939 else if (strcmp(val, "privilege") == 0)
1940 *permission = PMINFO_PERMISSION_PRIVILEGE;
1942 *permission = PMINFO_PERMISSION_NORMAL;
1947 API int pkgmgrinfo_appinfo_get_component_type(pkgmgrinfo_appinfo_h handle, char **component_type)
1949 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1951 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1952 retvm_if(component_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1954 if (info->app_info == NULL || info->app_info->component_type == NULL)
1955 return PMINFO_R_ERROR;
1957 *component_type = (char *)info->app_info->component_type;
1962 API int pkgmgrinfo_appinfo_get_hwacceleration(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_hwacceleration *hwacceleration)
1965 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1967 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1968 retvm_if(hwacceleration == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1970 if (info->app_info == NULL || info->app_info->hwacceleration == NULL)
1971 return PMINFO_R_ERROR;
1973 val = (char *)info->app_info->hwacceleration;
1974 if (strcasecmp(val, "off") == 0)
1975 *hwacceleration = PMINFO_HWACCELERATION_OFF;
1976 else if (strcasecmp(val, "on") == 0)
1977 *hwacceleration = PMINFO_HWACCELERATION_ON;
1979 *hwacceleration = PMINFO_HWACCELERATION_DEFAULT;
1984 API int pkgmgrinfo_appinfo_get_screenreader(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_screenreader *screenreader)
1987 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1989 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1990 retvm_if(screenreader == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1992 if (info->app_info == NULL || info->app_info->screenreader == NULL)
1993 return PMINFO_R_ERROR;
1995 val = (char *)info->app_info->screenreader;
1996 if (strcasecmp(val, "screenreader-off") == 0)
1997 *screenreader = PMINFO_SCREENREADER_OFF;
1998 else if (strcasecmp(val, "screenreader-on") == 0)
1999 *screenreader = PMINFO_SCREENREADER_ON;
2001 *screenreader = PMINFO_SCREENREADER_USE_SYSTEM_SETTING;
2006 API int pkgmgrinfo_appinfo_get_effectimage(pkgmgrinfo_appinfo_h handle, char **portrait_img, char **landscape_img)
2008 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2010 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2011 retvm_if(portrait_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2012 retvm_if(landscape_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2014 if (info->app_info == NULL)
2015 return PMINFO_R_ERROR;
2017 if (info->app_info->portraitimg == NULL)
2020 *portrait_img = (char *)info->app_info->portraitimg;
2022 if (info->app_info->landscapeimg == NULL)
2023 *landscape_img = "";
2025 *landscape_img = (char *)info->app_info->landscapeimg;
2030 API int pkgmgrinfo_appinfo_get_effectimage_type(pkgmgrinfo_appinfo_h handle, char **effectimage_type)
2032 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2034 if (handle == NULL || effectimage_type == NULL) {
2035 LOGE("invalid parameter");
2036 return PMINFO_R_EINVAL;
2039 if (info->app_info == NULL || info->app_info->effectimage_type == NULL)
2040 return PMINFO_R_ERROR;
2042 *effectimage_type = (char *)info->app_info->effectimage_type;
2047 API int pkgmgrinfo_appinfo_get_submode_mainid(pkgmgrinfo_appinfo_h handle, char **submode_mainid)
2049 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2051 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2052 retvm_if(submode_mainid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2054 if (info->app_info == NULL)
2055 return PMINFO_R_ERROR;
2057 if (info->app_info->submode_mainid == NULL)
2058 *submode_mainid = "";
2060 *submode_mainid = (char *)info->app_info->submode_mainid;
2065 API int pkgmgrinfo_appinfo_get_installed_storage_location(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_installed_storage *storage)
2067 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2068 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2070 if (info->app_info && info->app_info->installed_storage) {
2071 if (strcmp(info->app_info->installed_storage, "installed_internal") == 0)
2072 *storage = PMINFO_INTERNAL_STORAGE;
2073 else if (strcmp(info->app_info->installed_storage, "installed_external") == 0)
2074 *storage = PMINFO_EXTERNAL_STORAGE;
2076 return PMINFO_R_ERROR;
2078 return PMINFO_R_ERROR;
2084 API int pkgmgrinfo_appinfo_get_launch_mode(pkgmgrinfo_appinfo_h handle, char **mode)
2086 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2088 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2089 retvm_if(mode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2091 if (info->app_info->launch_mode == NULL)
2092 return PMINFO_R_ERROR;
2094 *mode = (char *)(info->app_info->launch_mode);
2099 API int pkgmgrinfo_appinfo_get_alias_appid(pkgmgrinfo_appinfo_h handle, char **alias_appid)
2101 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2103 if (handle == NULL || alias_appid == NULL) {
2104 LOGE("invalid parameter");
2105 return PMINFO_R_EINVAL;
2108 if (info->app_info == NULL || info->app_info->alias_appid == NULL)
2109 return PMINFO_R_ERROR;
2111 *alias_appid = (char *)info->app_info->alias_appid;
2116 API int pkgmgrinfo_appinfo_get_effective_appid(pkgmgrinfo_appinfo_h handle, char **effective_appid)
2118 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2120 if (handle == NULL || effective_appid == NULL) {
2121 LOGE("invalid parameter");
2122 return PMINFO_R_EINVAL;
2125 if (info->app_info == NULL)
2126 return PMINFO_R_ERROR;
2128 if (info->app_info->effective_appid == NULL)
2129 *effective_appid = "";
2131 *effective_appid = (char *)info->app_info->effective_appid;
2136 API int pkgmgrinfo_appinfo_get_tep_name(pkgmgrinfo_appinfo_h handle, char **tep_name)
2138 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2140 if (handle == NULL || tep_name == NULL) {
2141 LOGE("invalid parameter");
2142 return PMINFO_R_EINVAL;
2145 if (info->app_info == NULL)
2146 return PMINFO_R_ERROR;
2148 if (info->app_info->tep_name == NULL)
2151 *tep_name = (char *)info->app_info->tep_name;
2156 API int pkgmgrinfo_appinfo_get_zip_mount_file(pkgmgrinfo_appinfo_h handle, char **zip_mount_file)
2158 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2160 if (handle == NULL || zip_mount_file == NULL) {
2161 LOGE("invalid parameter");
2162 return PMINFO_R_EINVAL;
2165 if (info->app_info == NULL)
2166 return PMINFO_R_ERROR;
2168 if (info->app_info->zip_mount_file == NULL)
2169 *zip_mount_file = "";
2171 *zip_mount_file = (char *)info->app_info->zip_mount_file;
2176 API int pkgmgrinfo_appinfo_get_root_path(pkgmgrinfo_appinfo_h handle, char **root_path)
2178 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2180 if (handle == NULL || root_path == NULL) {
2181 LOGE("invalid parameter");
2182 return PMINFO_R_EINVAL;
2185 if (info->app_info == NULL || info->app_info->root_path == NULL)
2186 return PMINFO_R_ERROR;
2188 *root_path = (char *)info->app_info->root_path;
2193 API int pkgmgrinfo_appinfo_get_api_version(pkgmgrinfo_appinfo_h handle, char **api_version)
2195 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2197 if (handle == NULL || api_version == NULL) {
2198 LOGE("invalid parameter");
2199 return PMINFO_R_EINVAL;
2202 if (info->app_info == NULL || info->app_info->api_version == NULL)
2203 return PMINFO_R_ERROR;
2205 *api_version = (char *)info->app_info->api_version;
2210 API int pkgmgrinfo_appinfo_get_installed_time(pkgmgrinfo_appinfo_h handle, int *installed_time)
2212 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2214 if (handle == NULL || installed_time == NULL) {
2215 LOGE("invalid parameter");
2216 return PMINFO_R_EINVAL;
2219 if (info->app_info == NULL || info->app_info->package_installed_time == NULL)
2220 return PMINFO_R_ERROR;
2222 *installed_time = atoi(info->app_info->package_installed_time);
2227 API int pkgmgrinfo_appinfo_usr_get_datacontrol_info(const char *providerid, const char *type, uid_t uid, char **appid, char **access)
2229 retvm_if(providerid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
2230 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
2231 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2232 retvm_if(access == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2234 int ret = PMINFO_R_OK;
2236 sqlite3_stmt *stmt = NULL;
2239 ret = __open_manifest_db(uid, true);
2240 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
2242 /*Start constructing query*/
2243 query = sqlite3_mprintf("select * from package_app_data_control where providerid=%Q and type=%Q", providerid, type);
2244 tryvm_if(query == NULL, ret = PMINFO_R_ERROR, "Out of memory");
2247 ret = sqlite3_prepare_v2(GET_DB(manifest_db), query, strlen(query), &stmt, NULL);
2248 tryvm_if(ret != PMINFO_R_OK, ret = PMINFO_R_ERROR, "sqlite3_prepare_v2 failed[%s]\n", query);
2251 ret = sqlite3_step(stmt);
2252 tryvm_if((ret != SQLITE_ROW) || (ret == SQLITE_DONE), ret = PMINFO_R_ERROR, "No records found");
2254 *appid = strdup((char *)sqlite3_column_text(stmt, 0));
2255 *access = strdup((char *)sqlite3_column_text(stmt, 2));
2260 sqlite3_free(query);
2261 sqlite3_finalize(stmt);
2262 __close_manifest_db();
2266 API int pkgmgrinfo_appinfo_get_datacontrol_info(const char *providerid, const char *type, char **appid, char **access)
2268 return pkgmgrinfo_appinfo_usr_get_datacontrol_info(providerid, type, _getuid(), appid, access);
2271 API int pkgmgrinfo_appinfo_usr_get_datacontrol_appid(const char *providerid, uid_t uid, char **appid)
2273 retvm_if(providerid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
2274 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2276 int ret = PMINFO_R_OK;
2278 sqlite3_stmt *stmt = NULL;
2281 ret = __open_manifest_db(uid, true);
2282 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
2284 /*Start constructing query*/
2285 query = sqlite3_mprintf("select * from package_app_data_control where providerid=%Q", providerid);
2286 tryvm_if(query == NULL, ret = PMINFO_R_ERROR, "Out of memory");
2289 ret = sqlite3_prepare_v2(GET_DB(manifest_db), query, strlen(query), &stmt, NULL);
2290 tryvm_if(ret != PMINFO_R_OK, ret = PMINFO_R_ERROR, "sqlite3_prepare_v2 failed[%s]\n", query);
2293 ret = sqlite3_step(stmt);
2294 tryvm_if((ret != SQLITE_ROW) || (ret == SQLITE_DONE), ret = PMINFO_R_ERROR, "No records found");
2296 *appid = strdup((char *)sqlite3_column_text(stmt, 0));
2301 sqlite3_free(query);
2302 sqlite3_finalize(stmt);
2303 __close_manifest_db();
2307 API int pkgmgrinfo_appinfo_get_datacontrol_appid(const char *providerid, char **appid)
2309 return pkgmgrinfo_appinfo_usr_get_datacontrol_appid(providerid, _getuid(), appid);
2312 API int pkgmgrinfo_appinfo_get_support_mode(pkgmgrinfo_appinfo_h handle, int *support_mode)
2314 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2315 retvm_if(support_mode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2317 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2318 if (info->app_info->support_mode)
2319 *support_mode = atoi(info->app_info->support_mode);
2326 API int pkgmgrinfo_appinfo_foreach_permission(pkgmgrinfo_appinfo_h handle,
2327 pkgmgrinfo_app_permission_list_cb permission_func, void *user_data)
2329 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2330 retvm_if(permission_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2334 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2336 if (info->app_info == NULL)
2337 return PMINFO_R_ERROR;
2339 for (tmp = info->app_info->permission; tmp; tmp = tmp->next) {
2340 ptr = (permission_x *)tmp->data;
2344 ret = permission_func(ptr->value, user_data);
2352 API int pkgmgrinfo_appinfo_foreach_category(pkgmgrinfo_appinfo_h handle,
2353 pkgmgrinfo_app_category_list_cb category_func, void *user_data)
2355 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2356 retvm_if(category_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2358 const char *category;
2360 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2362 if (info->app_info == NULL)
2363 return PMINFO_R_ERROR;
2365 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
2366 category = (const char *)tmp->data;
2368 ret = category_func(category, user_data);
2376 API int pkgmgrinfo_appinfo_foreach_metadata(pkgmgrinfo_appinfo_h handle,
2377 pkgmgrinfo_app_metadata_list_cb metadata_func, void *user_data)
2379 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2380 retvm_if(metadata_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2384 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2386 if (info->app_info == NULL)
2387 return PMINFO_R_ERROR;
2389 for (tmp = info->app_info->metadata; tmp; tmp = tmp->next) {
2390 ptr = (metadata_x *)tmp->data;
2394 ret = metadata_func(ptr->key, ptr->value ? ptr->value : "", user_data);
2402 API int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
2403 pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
2405 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2406 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2408 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2409 appcontrol_x *appcontrol;
2412 if (info->app_info == NULL)
2413 return PMINFO_R_ERROR;
2415 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
2416 appcontrol = (appcontrol_x *)tmp->data;
2417 if (appcontrol == NULL)
2419 ret = appcontrol_func(appcontrol->operation, appcontrol->uri, appcontrol->mime, user_data);
2427 API int pkgmgrinfo_appinfo_foreach_background_category(
2428 pkgmgrinfo_appinfo_h handle,
2429 pkgmgrinfo_app_background_category_list_cb category_func,
2432 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2436 if (handle == NULL || category_func == NULL || info->app_info == NULL) {
2437 LOGE("invalid parameter");
2438 return PMINFO_R_EINVAL;
2441 for (tmp = info->app_info->background_category; tmp; tmp = tmp->next) {
2442 category = (char *)tmp->data;
2443 if (category == NULL)
2446 if (category_func(category, user_data) < 0)
2453 API int pkgmgrinfo_appinfo_foreach_splash_screen(pkgmgrinfo_appinfo_h handle,
2454 pkgmgrinfo_app_splash_screen_list_cb splash_screen_func,
2457 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2458 splashscreen_x *splashscreen;
2462 if (info == NULL || info->app_info == NULL
2463 || splash_screen_func == NULL) {
2464 LOGE("invalid parameter");
2465 return PMINFO_R_EINVAL;
2468 for (tmp = info->app_info->splashscreens; tmp; tmp = tmp->next) {
2469 splashscreen = (splashscreen_x *)tmp->data;
2470 if (splashscreen == NULL)
2472 ret = splash_screen_func(splashscreen->src,
2474 splashscreen->orientation,
2475 splashscreen->indicatordisplay,
2476 splashscreen->operation,
2477 splashscreen->color_depth,
2486 API int pkgmgrinfo_appinfo_is_nodisplay(pkgmgrinfo_appinfo_h handle, bool *nodisplay)
2488 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2489 retvm_if(nodisplay == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2490 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2492 if (info->app_info == NULL || info->app_info->nodisplay == NULL)
2493 return PMINFO_R_ERROR;
2495 *nodisplay = _get_bool_value(info->app_info->nodisplay);
2500 API int pkgmgrinfo_appinfo_is_multiple(pkgmgrinfo_appinfo_h handle, bool *multiple)
2502 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2503 retvm_if(multiple == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2504 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2506 if (info->app_info == NULL || info->app_info->multiple == NULL)
2507 return PMINFO_R_ERROR;
2509 *multiple = _get_bool_value(info->app_info->multiple);
2514 API int pkgmgrinfo_appinfo_is_indicator_display_allowed(pkgmgrinfo_appinfo_h handle, bool *indicator_disp)
2516 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2517 retvm_if(indicator_disp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2518 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2520 if (info->app_info == NULL || info->app_info->indicatordisplay == NULL)
2521 return PMINFO_R_ERROR;
2523 *indicator_disp = _get_bool_value(info->app_info->indicatordisplay);
2528 API int pkgmgrinfo_appinfo_is_taskmanage(pkgmgrinfo_appinfo_h handle, bool *taskmanage)
2530 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2531 retvm_if(taskmanage == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2532 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2534 if (info->app_info == NULL || info->app_info->taskmanage == NULL)
2535 return PMINFO_R_ERROR;
2537 *taskmanage = _get_bool_value(info->app_info->taskmanage);
2542 API int pkgmgrinfo_appinfo_is_enabled(pkgmgrinfo_appinfo_h handle, bool *enabled)
2544 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2545 retvm_if(enabled == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2546 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2548 if (info->app_info == NULL || info->app_info->is_disabled == NULL)
2549 return PMINFO_R_ERROR;
2551 *enabled = !_get_bool_value(info->app_info->is_disabled);
2556 API int pkgmgrinfo_appinfo_is_onboot(pkgmgrinfo_appinfo_h handle, bool *onboot)
2558 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2559 retvm_if(onboot == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2560 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2562 if (info->app_info == NULL || info->app_info->onboot == NULL)
2563 return PMINFO_R_ERROR;
2565 *onboot = _get_bool_value(info->app_info->onboot);
2570 API int pkgmgrinfo_appinfo_is_autorestart(pkgmgrinfo_appinfo_h handle, bool *autorestart)
2572 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2573 retvm_if(autorestart == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2574 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2576 if (info->app_info == NULL || info->app_info->autorestart == NULL)
2577 return PMINFO_R_ERROR;
2579 *autorestart = _get_bool_value(info->app_info->autorestart);
2584 API int pkgmgrinfo_appinfo_is_mainapp(pkgmgrinfo_appinfo_h handle, bool *mainapp)
2586 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2587 retvm_if(mainapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2588 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2590 if (info->app_info == NULL || info->app_info->mainapp == NULL)
2591 return PMINFO_R_ERROR;
2593 *mainapp = _get_bool_value(info->app_info->mainapp);
2598 API int pkgmgrinfo_appinfo_is_preload(pkgmgrinfo_appinfo_h handle, bool *preload)
2600 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2601 retvm_if(preload == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2602 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2604 if (info->app_info == NULL || info->app_info->preload == NULL)
2605 return PMINFO_R_ERROR;
2607 *preload = _get_bool_value(info->app_info->preload);
2612 API int pkgmgrinfo_appinfo_is_submode(pkgmgrinfo_appinfo_h handle, bool *submode)
2614 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2615 retvm_if(submode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2616 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2618 if (info->app_info == NULL || info->app_info->submode == NULL)
2619 return PMINFO_R_ERROR;
2621 *submode = _get_bool_value(info->app_info->submode);
2626 API int pkgmgrinfo_appinfo_is_process_pool(pkgmgrinfo_appinfo_h handle, bool *process_pool)
2628 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2630 if (handle == NULL || process_pool == NULL) {
2631 LOGE("invalid parameter");
2632 return PMINFO_R_EINVAL;
2635 if (info->app_info == NULL)
2636 return PMINFO_R_ERROR;
2638 *process_pool = _get_bool_value(info->app_info->process_pool);
2643 API int pkgmgrinfo_appinfo_is_category_exist(pkgmgrinfo_appinfo_h handle, const char *category, bool *exist)
2645 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2646 retvm_if(category == NULL, PMINFO_R_EINVAL, "category is NULL");
2647 retvm_if(exist == NULL, PMINFO_R_EINVAL, "exist is NULL");
2651 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2653 if (info->app_info == NULL)
2654 return PMINFO_R_ERROR;
2657 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
2658 val = (const char *)tmp->data;
2661 if (strcasecmp(val, category) == 0) {
2670 API int pkgmgrinfo_appinfo_is_ui_gadget(pkgmgrinfo_appinfo_h handle,
2673 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2675 if (info == NULL || info->app_info == NULL || ui_gadget == NULL) {
2676 _LOGE("invalid parameter");
2677 return PMINFO_R_EINVAL;
2679 if (info->app_info->ui_gadget == NULL)
2680 info->app_info->ui_gadget = strdup("false");
2682 *ui_gadget = _get_bool_value(info->app_info->ui_gadget);
2687 API int pkgmgrinfo_appinfo_is_support_disable(pkgmgrinfo_appinfo_h handle,
2688 bool *support_disable)
2690 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2692 if (info == NULL || info->app_info == NULL || support_disable == NULL) {
2693 _LOGE("invalid parameter");
2694 return PMINFO_R_EINVAL;
2697 *support_disable = _get_bool_value(info->app_info->support_disable);
2702 API int pkgmgrinfo_appinfo_is_removable(pkgmgrinfo_appinfo_h handle,
2705 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2707 if (info == NULL || info->app_info == NULL || removable == NULL) {
2708 _LOGE("invalid parameter");
2709 return PMINFO_R_EINVAL;
2712 *removable = _get_bool_value(info->app_info->removable);
2717 API int pkgmgrinfo_appinfo_is_system(pkgmgrinfo_appinfo_h handle, bool *system)
2719 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2721 if (info == NULL || info->app_info == NULL || system == NULL) {
2722 _LOGE("invalid parameter");
2723 return PMINFO_R_EINVAL;
2726 *system = _get_bool_value(info->app_info->package_system);
2731 API int pkgmgrinfo_appinfo_is_disabled(pkgmgrinfo_appinfo_h handle, bool *disabled)
2733 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2734 retvm_if(disabled == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2735 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2737 if (info->app_info == NULL || info->app_info->is_disabled == NULL)
2738 return PMINFO_R_ERROR;
2740 *disabled = _get_bool_value(info->app_info->is_disabled);
2745 API int pkgmgrinfo_appinfo_is_global(pkgmgrinfo_appinfo_h handle, bool *global)
2747 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2749 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2750 retvm_if(global == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2752 if (info->app_info == NULL || info->app_info->for_all_users == NULL)
2753 return PMINFO_R_ERROR;
2755 *global = _get_bool_value(info->app_info->for_all_users);
2760 API int pkgmgrinfo_appinfo_get_splash_screen_display(pkgmgrinfo_appinfo_h handle, bool *splash_screen_display)
2762 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2764 if (info == NULL || splash_screen_display == NULL) {
2765 _LOGE("Invalid parameter");
2766 return PMINFO_R_EINVAL;
2769 if (info->app_info == NULL || info->app_info->splash_screen_display == NULL)
2770 return PMINFO_R_ERROR;
2772 *splash_screen_display = _get_bool_value(info->app_info->splash_screen_display);
2777 API int pkgmgrinfo_appinfo_is_support_ambient(pkgmgrinfo_appinfo_h handle,
2778 bool *support_ambient)
2780 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2782 if (info == NULL || support_ambient == NULL) {
2783 _LOGE("Invalid parameter");
2784 return PMINFO_R_EINVAL;
2787 if (info->app_info == NULL || info->app_info->support_ambient == NULL)
2788 return PMINFO_R_ERROR;
2790 *support_ambient = _get_bool_value(info->app_info->support_ambient);
2795 API int pkgmgrinfo_appinfo_destroy_appinfo(pkgmgrinfo_appinfo_h handle)
2797 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2798 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2799 __cleanup_appinfo(info);
2803 API int pkgmgrinfo_appinfo_filter_create(pkgmgrinfo_appinfo_filter_h *handle)
2805 return (pkgmgrinfo_pkginfo_filter_create(handle));
2808 API int pkgmgrinfo_appinfo_filter_destroy(pkgmgrinfo_appinfo_filter_h handle)
2810 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
2813 static gint __compare_func(gconstpointer data1, gconstpointer data2)
2815 pkgmgrinfo_node_x *node1 = (pkgmgrinfo_node_x *)data1;
2816 pkgmgrinfo_node_x *node2 = (pkgmgrinfo_node_x *)data2;
2817 if (node1->prop == node2->prop)
2819 else if (node1->prop > node2->prop)
2825 API int pkgmgrinfo_appinfo_filter_add_int(pkgmgrinfo_appinfo_filter_h handle,
2826 const char *property, const int value)
2828 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2829 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2830 char buf[PKG_VALUE_STRING_LEN_MAX] = {'\0'};
2832 GSList *link = NULL;
2834 prop = _pminfo_appinfo_convert_to_prop_int(property);
2835 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_INT ||
2836 prop > E_PMINFO_APPINFO_PROP_APP_MAX_INT) {
2837 _LOGE("Invalid Integer Property\n");
2838 return PMINFO_R_EINVAL;
2840 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2841 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1, sizeof(pkgmgrinfo_node_x));
2843 _LOGE("Out of Memory!!!\n");
2844 return PMINFO_R_ERROR;
2846 snprintf(buf, PKG_VALUE_STRING_LEN_MAX - 1, "%d", value);
2847 val = strndup(buf, PKG_VALUE_STRING_LEN_MAX - 1);
2849 _LOGE("Out of Memory\n");
2852 return PMINFO_R_ERROR;
2856 /*If API is called multiple times for same property, we should override the previous values.
2857 Last value set will be used for filtering.*/
2858 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2860 filter->list = g_slist_delete_link(filter->list, link);
2861 filter->list = g_slist_append(filter->list, (gpointer)node);
2866 API int pkgmgrinfo_appinfo_filter_add_bool(pkgmgrinfo_appinfo_filter_h handle,
2867 const char *property, const bool value)
2869 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2870 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2872 GSList *link = NULL;
2874 prop = _pminfo_appinfo_convert_to_prop_bool(property);
2875 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_BOOL ||
2876 prop > E_PMINFO_APPINFO_PROP_APP_MAX_BOOL) {
2877 _LOGE("Invalid Boolean Property\n");
2878 return PMINFO_R_EINVAL;
2880 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2881 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1, sizeof(pkgmgrinfo_node_x));
2883 _LOGE("Out of Memory!!!\n");
2884 return PMINFO_R_ERROR;
2887 val = strndup("true", 4);
2889 val = strndup("false", 5);
2891 _LOGE("Out of Memory\n");
2894 return PMINFO_R_ERROR;
2898 /*If API is called multiple times for same property, we should override the previous values.
2899 Last value set will be used for filtering.*/
2900 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2902 filter->list = g_slist_delete_link(filter->list, link);
2903 filter->list = g_slist_append(filter->list, (gpointer)node);
2908 API int pkgmgrinfo_appinfo_filter_add_string(pkgmgrinfo_appinfo_filter_h handle,
2909 const char *property, const char *value)
2911 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2912 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2913 retvm_if(value == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2915 pkgmgrinfo_node_x *ptr = NULL;
2916 char prev[PKG_STRING_LEN_MAX] = {'\0'};
2917 char temp[PKG_STRING_LEN_MAX] = {'\0'};
2918 GSList *link = NULL;
2920 prop = _pminfo_appinfo_convert_to_prop_str(property);
2921 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_STR ||
2922 prop > E_PMINFO_APPINFO_PROP_APP_MAX_STR) {
2923 _LOGE("Invalid String Property\n");
2924 return PMINFO_R_EINVAL;
2926 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2927 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1, sizeof(pkgmgrinfo_node_x));
2929 _LOGE("Out of Memory!!!\n");
2930 return PMINFO_R_ERROR;
2934 case E_PMINFO_APPINFO_PROP_APP_COMPONENT:
2935 node->value = strdup(value);
2936 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2938 filter->list = g_slist_delete_link(filter->list, link);
2939 filter->list = g_slist_append(filter->list, (gpointer)node);
2941 case E_PMINFO_APPINFO_PROP_APP_CATEGORY:
2942 val = (char *)calloc(1, PKG_STRING_LEN_MAX);
2944 _LOGE("Out of Memory\n");
2947 return PMINFO_R_ERROR;
2949 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2951 ptr = (pkgmgrinfo_node_x *)link->data;
2952 strncpy(prev, ptr->value, PKG_STRING_LEN_MAX - 1);
2953 _LOGI("Previous value is %s\n", prev);
2954 filter->list = g_slist_delete_link(filter->list, link);
2955 snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s,%s", prev, value);
2956 strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
2957 _LOGI("New value is %s\n", val);
2959 filter->list = g_slist_append(filter->list, (gpointer)node);
2960 memset(temp, '\0', PKG_STRING_LEN_MAX);
2962 snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s", value);
2963 strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
2964 _LOGI("First value is %s\n", val);
2966 filter->list = g_slist_append(filter->list, (gpointer)node);
2967 memset(temp, '\0', PKG_STRING_LEN_MAX);
2971 node->value = strndup(value, PKG_STRING_LEN_MAX - 1);
2972 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2974 filter->list = g_slist_delete_link(filter->list, link);
2975 filter->list = g_slist_append(filter->list, (gpointer)node);
2981 API int pkgmgrinfo_appinfo_usr_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count, uid_t uid)
2987 if (handle == NULL || count == NULL) {
2988 _LOGE("invalid parameter");
2989 return PMINFO_R_EINVAL;
2992 locale = _get_system_locale();
2994 return PMINFO_R_ERROR;
2996 list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
2997 __free_applications);
3000 return PMINFO_R_ERROR;
3003 ret = _appinfo_get_applications(uid, uid, locale, handle, 0, list);
3004 if (ret == PMINFO_R_OK && uid != GLOBAL_USER)
3005 ret = _appinfo_get_applications(GLOBAL_USER, uid, locale,
3008 if (ret != PMINFO_R_OK) {
3009 g_hash_table_destroy(list);
3011 return PMINFO_R_ERROR;
3014 *count = g_hash_table_size(list);
3015 g_hash_table_destroy(list);
3021 API int pkgmgrinfo_appinfo_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count)
3023 return pkgmgrinfo_appinfo_usr_filter_count(handle, count, _getuid());
3026 API int pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(
3027 pkgmgrinfo_appinfo_filter_h handle,
3028 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
3030 if (handle == NULL || app_cb == NULL) {
3031 LOGE("invalid parameter");
3032 return PMINFO_R_EINVAL;
3035 return _appinfo_get_filtered_foreach_appinfo(uid, handle, PMINFO_APPINFO_GET_ALL, app_cb,
3039 API int pkgmgrinfo_appinfo_filter_foreach_appinfo(pkgmgrinfo_appinfo_filter_h handle,
3040 pkgmgrinfo_app_list_cb app_cb, void *user_data)
3042 return pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(handle, app_cb, user_data, _getuid());
3045 API int pkgmgrinfo_appinfo_metadata_filter_create(pkgmgrinfo_appinfo_metadata_filter_h *handle)
3047 return (pkgmgrinfo_pkginfo_filter_create(handle));
3050 API int pkgmgrinfo_appinfo_metadata_filter_destroy(pkgmgrinfo_appinfo_metadata_filter_h handle)
3052 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
3055 API int pkgmgrinfo_appinfo_metadata_filter_add(
3056 pkgmgrinfo_appinfo_metadata_filter_h handle,
3057 const char *key, const char *value)
3061 ret = pkgmgrinfo_appinfo_filter_add_string(handle,
3062 PMINFO_APPINFO_PROP_APP_METADATA_KEY, key);
3063 if (ret != PMINFO_R_OK)
3066 /* value can be NULL.
3067 * In that case all apps with specified key should be displayed
3069 if (value && strlen(value)) {
3070 ret = pkgmgrinfo_appinfo_filter_add_string(handle,
3071 PMINFO_APPINFO_PROP_APP_METADATA_VALUE, value);
3072 if (ret != PMINFO_R_OK)
3079 API int pkgmgrinfo_appinfo_usr_metadata_filter_foreach(
3080 pkgmgrinfo_appinfo_metadata_filter_h handle,
3081 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
3083 if (handle == NULL || app_cb == NULL) {
3084 LOGE("invalid parameter");
3085 return PMINFO_R_EINVAL;
3088 return _appinfo_get_filtered_foreach_appinfo(uid, handle, PMINFO_APPINFO_GET_ALL, app_cb,
3092 API int pkgmgrinfo_appinfo_metadata_filter_foreach(
3093 pkgmgrinfo_appinfo_metadata_filter_h handle,
3094 pkgmgrinfo_app_list_cb app_cb, void *user_data)
3096 return pkgmgrinfo_appinfo_usr_metadata_filter_foreach(handle, app_cb,
3097 user_data, _getuid());
3100 API int pkgmgrinfo_appinfo_is_guestmode_visibility(pkgmgrinfo_appinfo_h handle, bool *status)
3103 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3105 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
3106 retvm_if(status == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3108 val = info->app_info->guestmode_visibility;
3109 *status = _get_bool_value(val);