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 void __get_splash_screen_display(sqlite3 *db, const char *appid, uid_t uid, char **value)
402 static const char query_raw[] =
403 "SELECT is_splash_screen_enabled FROM package_app_info_for_uid "
404 "WHERE app_id='%s' AND uid='%d'";
409 query = sqlite3_mprintf(query_raw, appid, uid);
411 LOGE("out of memory");
415 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
417 if (ret != SQLITE_OK) {
418 LOGE("sqlite3_prepare_v2() failed: %s", sqlite3_errmsg(db));
422 while (sqlite3_step(stmt) == SQLITE_ROW) {
425 _save_column_str(stmt, 0, value);
428 sqlite3_finalize(stmt);
431 static void __free_applications(gpointer data)
433 pkgmgrinfo_basic_free_application((application_x *)data);
436 static int __bind_params(sqlite3_stmt *stmt, GList *params)
438 GList *tmp_list = NULL;
442 if (stmt == NULL || params == NULL)
443 return PMINFO_R_EINVAL;
447 ret = sqlite3_bind_text(stmt, ++idx, (char *)tmp_list->data, -1, SQLITE_STATIC);
448 if (ret != SQLITE_OK)
449 return PMINFO_R_ERROR;
450 tmp_list = tmp_list->next;
456 static bool __check_app_storage_status(pkgmgrinfo_filter_x *tmp_filter)
458 GSList *tmp_list = NULL;
459 pkgmgrinfo_node_x *tmp_node = NULL;
462 if (tmp_filter == NULL)
465 property = _pminfo_appinfo_convert_to_prop_bool(PMINFO_APPINFO_PROP_APP_CHECK_STORAGE);
466 for (tmp_list = tmp_filter->list; tmp_list != NULL;
467 tmp_list = g_slist_next(tmp_list)) {
468 tmp_node = (pkgmgrinfo_node_x *)tmp_list->data;
469 if (property == tmp_node->prop) {
470 if (strcmp(tmp_node->value, "true") == 0)
480 static int _appinfo_get_applications(uid_t db_uid, uid_t uid,
481 const char *locale, pkgmgrinfo_filter_x *filter, int flag,
482 GHashTable *applications)
484 static const char query_raw[] =
485 "SELECT DISTINCT ai.app_id, ai.app_component, ai.app_exec, "
486 "ai.app_nodisplay, ai.app_type, ai.app_onboot, "
487 "ai.app_multiple, ai.app_autorestart, ai.app_taskmanage, "
488 "ai.app_enabled, ai.app_hwacceleration, ai.app_screenreader, "
489 "ai.app_mainapp, ai.app_recentimage, ai.app_launchcondition, "
490 "ai.app_indicatordisplay, ai.app_portraitimg, "
491 "ai.app_landscapeimg, ai.app_guestmodevisibility, "
492 "ai.app_permissiontype, ai.app_preload, ai.app_submode, "
493 "ai.app_submode_mainid, ai.app_launch_mode, ai.app_ui_gadget, "
494 "ai.app_support_disable, ai.app_process_pool, "
495 "ai.app_installed_storage, ai.app_background_category, "
496 "ai.app_package_type, ai.app_root_path, ai.app_api_version, "
497 "ai.app_effective_appid, ai.app_disable, "
498 "ai.app_splash_screen_display, ai.app_tep_name, "
499 "ai.app_zip_mount_file, ai.component_type, ai.package, "
500 "ai.app_external_path, ai.app_package_system, ai.app_removable, "
501 "ai.app_package_installed_time, ai.app_support_mode";
502 static const char query_label[] =
504 "(SELECT app_label FROM package_app_localized_info WHERE ai.app_id=app_id AND app_locale=?), "
505 "(SELECT app_label FROM package_app_localized_info WHERE ai.app_id=app_id AND app_locale='No Locale'))";
506 static const char query_icon[] =
508 "(SELECT app_icon FROM package_app_localized_info WHERE ai.app_id=app_id AND app_locale=?), "
509 "(SELECT app_icon FROM package_app_localized_info WHERE ai.app_id=app_id AND app_locale='No Locale'))";
510 static const char query_from_clause[] = " FROM package_app_info as ai";
511 int ret = PMINFO_R_ERROR;
515 char *bg_category_str = NULL;
516 char *constraint = NULL;
517 char *tmp_record = NULL;
518 char query[MAX_QUERY_LEN] = { '\0' };
519 application_x *info = NULL;
520 GList *bind_params = NULL;
522 sqlite3_stmt *stmt = NULL;
523 bool is_check_storage = true;
525 dbpath = getUserPkgParserDBPathUID(db_uid);
527 return PMINFO_R_ERROR;
529 ret = sqlite3_open_v2(dbpath, &db, SQLITE_OPEN_READONLY, NULL);
530 if (ret != SQLITE_OK) {
531 _LOGE("failed to open db: %d", ret);
533 return PMINFO_R_ERROR;
537 len = strlen(query_raw);
538 snprintf(query, MAX_QUERY_LEN - 1, "%s", query_raw);
539 if (flag & PMINFO_APPINFO_GET_LABEL) {
540 strncat(query, query_label, MAX_QUERY_LEN - len - 1);
541 len += strlen(query_label);
542 bind_params = g_list_append(bind_params, strdup(locale));
544 if (flag & PMINFO_APPINFO_GET_ICON) {
545 strncat(query, query_icon, MAX_QUERY_LEN - len - 1);
546 len += strlen(query_icon);
547 bind_params = g_list_append(bind_params, strdup(locale));
550 is_check_storage = __check_app_storage_status(filter);
552 ret = _get_filtered_query(filter, locale, &constraint, &bind_params);
553 if (ret != PMINFO_R_OK) {
554 LOGE("Failed to get WHERE clause");
557 strncat(query, query_from_clause, MAX_QUERY_LEN - len - 1);
558 len += strlen(query_from_clause);
561 strncat(query, constraint, MAX_QUERY_LEN - len - 1);
563 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
564 if (ret != SQLITE_OK) {
565 LOGE("prepare failed: %s", sqlite3_errmsg(db));
566 ret = PMINFO_R_ERROR;
570 if (g_list_length(bind_params) != 0) {
571 ret = __bind_params(stmt, bind_params);
572 if (ret != SQLITE_OK) {
573 LOGE("Failed to bind parameters");
578 while (sqlite3_step(stmt) == SQLITE_ROW) {
579 info = calloc(1, sizeof(application_x));
581 LOGE("out of memory");
582 ret = PMINFO_R_ERROR;
586 _save_column_str(stmt, idx++, &info->appid);
587 if (g_hash_table_contains(applications,
588 (gconstpointer)info->appid)) {
593 _save_column_str(stmt, idx++, &info->component);
594 _save_column_str(stmt, idx++, &info->exec);
595 _save_column_str(stmt, idx++, &info->nodisplay);
596 _save_column_str(stmt, idx++, &info->type);
597 _save_column_str(stmt, idx++, &info->onboot);
598 _save_column_str(stmt, idx++, &info->multiple);
599 _save_column_str(stmt, idx++, &info->autorestart);
600 _save_column_str(stmt, idx++, &info->taskmanage);
601 _save_column_str(stmt, idx++, &info->enabled);
602 _save_column_str(stmt, idx++, &info->hwacceleration);
603 _save_column_str(stmt, idx++, &info->screenreader);
604 _save_column_str(stmt, idx++, &info->mainapp);
605 _save_column_str(stmt, idx++, &info->recentimage);
606 _save_column_str(stmt, idx++, &info->launchcondition);
607 _save_column_str(stmt, idx++, &info->indicatordisplay);
608 _save_column_str(stmt, idx++, &info->portraitimg);
609 _save_column_str(stmt, idx++, &info->landscapeimg);
610 _save_column_str(stmt, idx++, &info->guestmode_visibility);
611 _save_column_str(stmt, idx++, &info->permission_type);
612 _save_column_str(stmt, idx++, &info->preload);
613 _save_column_str(stmt, idx++, &info->submode);
614 _save_column_str(stmt, idx++, &info->submode_mainid);
615 _save_column_str(stmt, idx++, &info->launch_mode);
616 _save_column_str(stmt, idx++, &info->ui_gadget);
617 _save_column_str(stmt, idx++, &info->support_disable);
618 _save_column_str(stmt, idx++, &info->process_pool);
619 _save_column_str(stmt, idx++, &info->installed_storage);
620 _save_column_str(stmt, idx++, &bg_category_str);
621 _save_column_str(stmt, idx++, &info->package_type);
622 _save_column_str(stmt, idx++, &info->root_path);
623 _save_column_str(stmt, idx++, &info->api_version);
624 _save_column_str(stmt, idx++, &info->effective_appid);
625 _save_column_str(stmt, idx++, &info->is_disabled);
626 _save_column_str(stmt, idx++, &info->splash_screen_display);
627 _save_column_str(stmt, idx++, &info->tep_name);
628 _save_column_str(stmt, idx++, &info->zip_mount_file);
629 _save_column_str(stmt, idx++, &info->component_type);
630 _save_column_str(stmt, idx++, &info->package);
631 _save_column_str(stmt, idx++, &info->external_path);
632 _save_column_str(stmt, idx++, &info->package_system);
633 _save_column_str(stmt, idx++, &info->removable);
634 _save_column_str(stmt, idx++, &info->package_installed_time);
635 _save_column_str(stmt, idx++, &info->support_mode);
637 info->for_all_users =
638 strdup((uid != GLOBAL_USER) ? "false" : "true");
640 if (db_uid == GLOBAL_USER)
641 __get_splash_screen_display(db, info->appid, db_uid,
642 &info->splash_screen_display);
644 info->background_category = __get_background_category(
646 free(bg_category_str);
648 if (flag & PMINFO_APPINFO_GET_LABEL) {
650 _save_column_str(stmt, idx++, &tmp_record);
651 if (_add_label_info_into_list(locale, tmp_record, &info->label)) {
652 ret = PMINFO_R_ERROR;
657 if (flag & PMINFO_APPINFO_GET_ICON) {
659 _save_column_str(stmt, idx++, &tmp_record);
660 if (_add_icon_info_into_list(locale, tmp_record, &info->icon)) {
661 ret = PMINFO_R_ERROR;
666 if (flag & PMINFO_APPINFO_GET_CATEGORY) {
667 if (_appinfo_get_category(db, info->appid,
669 ret = PMINFO_R_ERROR;
674 if (flag & PMINFO_APPINFO_GET_APP_CONTROL) {
675 if (_appinfo_get_app_control(db, info->appid,
676 &info->appcontrol)) {
677 ret = PMINFO_R_ERROR;
682 if (flag & PMINFO_APPINFO_GET_DATA_CONTROL) {
683 if (_appinfo_get_data_control(db, info->appid,
684 &info->datacontrol)) {
685 ret = PMINFO_R_ERROR;
690 if (flag & PMINFO_APPINFO_GET_METADATA) {
691 if (_appinfo_get_metadata(db, info->appid,
693 ret = PMINFO_R_ERROR;
698 if (flag & PMINFO_APPINFO_GET_SPLASH_SCREEN) {
699 if (_appinfo_get_splashscreens(db, info->appid,
700 &info->splashscreens)) {
701 ret = PMINFO_R_ERROR;
706 if (is_check_storage &&
707 __appinfo_check_installed_storage(info) != PMINFO_R_OK) {
708 ret = PMINFO_R_ERROR;
709 pkgmgrinfo_basic_free_application(info);
714 g_hash_table_insert(applications, (gpointer)info->appid,
724 if (ret != PMINFO_R_OK && info != NULL)
725 pkgmgrinfo_basic_free_application(info);
727 g_list_free_full(bind_params, free);
728 sqlite3_close_v2(db);
729 sqlite3_finalize(stmt);
734 static int _pkgmgrinfo_get_appinfo(const char *appid, uid_t uid,
735 pkgmgrinfo_appinfo_filter_h filter, pkgmgrinfo_appinfo_h *handle)
740 pkgmgr_appinfo_x *info;
742 if (appid == NULL || filter == NULL || handle == NULL) {
743 LOGE("invalid parameter");
744 return PMINFO_R_EINVAL;
747 locale = _get_system_locale();
749 return PMINFO_R_ERROR;
751 list = g_hash_table_new(g_str_hash, g_str_equal);
754 return PMINFO_R_ERROR;
757 ret = _appinfo_get_applications(uid, uid, locale, filter,
758 PMINFO_APPINFO_GET_ALL, list);
759 if (!g_hash_table_size(list) && uid != GLOBAL_USER)
760 ret = _appinfo_get_applications(GLOBAL_USER, GLOBAL_USER, locale, filter,
761 PMINFO_APPINFO_GET_ALL, list);
763 if (!g_hash_table_size(list)) {
764 _LOGI("appinfo for [%s] is not existed for user [%d]",
766 g_hash_table_destroy(list);
768 return PMINFO_R_ENOENT;
771 info = calloc(1, sizeof(pkgmgr_appinfo_x));
773 _LOGE("out of memory");
774 g_hash_table_destroy(list);
776 return PMINFO_R_ERROR;
779 info->app_info = (application_x *)g_hash_table_lookup(list, appid);
780 info->locale = locale;
781 info->package = strdup(info->app_info->package);
783 /* just free list only */
784 g_hash_table_destroy(list);
791 API int pkgmgrinfo_appinfo_get_usr_disabled_appinfo(const char *appid, uid_t uid,
792 pkgmgrinfo_appinfo_h *handle)
795 pkgmgrinfo_appinfo_filter_h filter;
797 if (appid == NULL || handle == NULL) {
798 LOGE("invalid parameter");
799 return PMINFO_R_EINVAL;
802 ret = pkgmgrinfo_appinfo_filter_create(&filter);
803 if (ret != PMINFO_R_OK)
806 ret = pkgmgrinfo_appinfo_filter_add_string(filter,
807 PMINFO_APPINFO_PROP_APP_ID, appid);
808 if (ret != PMINFO_R_OK) {
809 pkgmgrinfo_appinfo_filter_destroy(filter);
810 return PMINFO_R_ERROR;
813 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
814 PMINFO_APPINFO_PROP_APP_DISABLE, true);
815 if (ret != PMINFO_R_OK) {
816 pkgmgrinfo_appinfo_filter_destroy(filter);
817 return PMINFO_R_ERROR;
820 ret = _pkgmgrinfo_get_appinfo(appid, uid, filter, handle);
821 pkgmgrinfo_appinfo_filter_destroy(filter);
826 API int pkgmgrinfo_appinfo_get_disabled_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
828 return pkgmgrinfo_appinfo_get_usr_disabled_appinfo(appid, _getuid(), handle);
831 API int pkgmgrinfo_appinfo_get_usr_appinfo(const char *appid, uid_t uid,
832 pkgmgrinfo_appinfo_h *handle)
835 pkgmgrinfo_appinfo_filter_h filter;
837 if (appid == NULL || handle == NULL) {
838 LOGE("invalid parameter");
839 return PMINFO_R_EINVAL;
842 ret = pkgmgrinfo_appinfo_filter_create(&filter);
843 if (ret != PMINFO_R_OK)
846 ret = pkgmgrinfo_appinfo_filter_add_string(filter,
847 PMINFO_APPINFO_PROP_APP_ID, appid);
848 if (ret != PMINFO_R_OK) {
849 pkgmgrinfo_appinfo_filter_destroy(filter);
850 return PMINFO_R_ERROR;
853 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
854 PMINFO_APPINFO_PROP_APP_DISABLE, false);
855 if (ret != PMINFO_R_OK) {
856 pkgmgrinfo_appinfo_filter_destroy(filter);
857 return PMINFO_R_ERROR;
860 ret = _pkgmgrinfo_get_appinfo(appid, uid, filter, handle);
861 pkgmgrinfo_appinfo_filter_destroy(filter);
865 API int pkgmgrinfo_appinfo_get_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
867 return pkgmgrinfo_appinfo_get_usr_appinfo(appid, _getuid(), handle);
870 API int pkgmgrinfo_appinfo_get_usr_all_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_CHECK_STORAGE, 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);
905 API int pkgmgrinfo_appinfo_get_all_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
907 return pkgmgrinfo_appinfo_get_usr_all_appinfo(appid, _getuid(), handle);
910 static gpointer __copy_str(gconstpointer src, gpointer data)
912 const char *tmp = (const char *)src;
915 buffer = strdup(tmp);
916 if (buffer == NULL) {
917 LOGE("memory alloc failed");
925 static gpointer __copy_label(gconstpointer src, gpointer data)
927 label_x *tmp = (label_x *)src;
930 label = calloc(1, sizeof(label_x));
932 LOGE("memory alloc failed");
938 label->name = strdup(tmp->name);
940 label->text = strdup(tmp->text);
942 label->lang = strdup(tmp->lang);
947 static gpointer __copy_icon(gconstpointer src, gpointer data)
949 icon_x *tmp = (icon_x *)src;
952 icon = calloc(1, sizeof(icon_x));
954 LOGE("memory alloc failed");
960 icon->text = strdup(tmp->text);
962 icon->lang = strdup(tmp->lang);
964 icon->section = strdup(tmp->section);
966 icon->size = strdup(tmp->size);
968 icon->resolution = strdup(tmp->resolution);
973 static gpointer __copy_metadata(gconstpointer src, gpointer data)
975 metadata_x *tmp = (metadata_x *)src;
976 metadata_x *metadata;
978 metadata = calloc(1, sizeof(metadata_x));
979 if (metadata == NULL) {
980 LOGE("memory alloc failed");
986 metadata->key = strdup(tmp->key);
988 metadata->value = strdup(tmp->value);
993 static gpointer __copy_datacontrol(gconstpointer src, gpointer data)
995 datacontrol_x *tmp = (datacontrol_x *)src;
996 datacontrol_x *datacontrol;
998 datacontrol = calloc(1, sizeof(datacontrol_x));
999 if (datacontrol == NULL) {
1000 LOGE("memory alloc failed");
1005 if (tmp->providerid)
1006 datacontrol->providerid = strdup(tmp->providerid);
1008 datacontrol->access = strdup(tmp->access);
1010 datacontrol->type = strdup(tmp->type);
1015 static gpointer __copy_appcontrol(gconstpointer src, gpointer data)
1017 appcontrol_x *tmp = (appcontrol_x *)src;
1018 appcontrol_x *appcontrol;
1020 appcontrol = calloc(1, sizeof(appcontrol_x));
1021 if (appcontrol == NULL) {
1022 LOGE("memory alloc failed");
1028 appcontrol->operation = strdup(tmp->operation);
1030 appcontrol->uri = strdup(tmp->uri);
1032 appcontrol->mime = strdup(tmp->mime);
1037 static gpointer __copy_splashscreens(gconstpointer src, gpointer data)
1039 splashscreen_x *tmp = (splashscreen_x *)src;
1040 splashscreen_x *splashscreen;
1042 splashscreen = (splashscreen_x *)calloc(1, sizeof(splashscreen_x));
1043 if (splashscreen == NULL) {
1044 LOGE("memory alloc failed");
1050 splashscreen->src = strdup(tmp->src);
1052 splashscreen->type = strdup(tmp->type);
1053 if (tmp->orientation)
1054 splashscreen->orientation = strdup(tmp->orientation);
1055 if (tmp->indicatordisplay)
1056 splashscreen->indicatordisplay = strdup(tmp->indicatordisplay);
1058 splashscreen->operation = strdup(tmp->operation);
1059 if (tmp->color_depth)
1060 splashscreen->color_depth = strdup(tmp->color_depth);
1062 return splashscreen;
1065 static int _appinfo_copy_appinfo(application_x **application, application_x *data)
1067 application_x *app_info;
1070 app_info = calloc(1, sizeof(application_x));
1071 if (app_info == NULL) {
1072 LOGE("memory alloc failed");
1073 return PMINFO_R_ERROR;
1076 if (data->appid != NULL)
1077 app_info->appid = strdup(data->appid);
1078 if (data->exec != NULL)
1079 app_info->exec = strdup(data->exec);
1080 if (data->nodisplay != NULL)
1081 app_info->nodisplay = strdup(data->nodisplay);
1082 if (data->multiple != NULL)
1083 app_info->multiple = strdup(data->multiple);
1084 if (data->taskmanage != NULL)
1085 app_info->taskmanage = strdup(data->taskmanage);
1086 if (data->enabled != NULL)
1087 app_info->enabled = strdup(data->enabled);
1088 if (data->type != NULL)
1089 app_info->type = strdup(data->type);
1090 if (data->categories != NULL)
1091 app_info->categories = strdup(data->categories);
1092 if (data->hwacceleration != NULL)
1093 app_info->hwacceleration = strdup(data->hwacceleration);
1094 if (data->screenreader != NULL)
1095 app_info->screenreader = strdup(data->screenreader);
1096 if (data->mainapp != NULL)
1097 app_info->mainapp = strdup(data->mainapp);
1098 if (data->package != NULL)
1099 app_info->package = strdup(data->package);
1100 if (data->recentimage != NULL)
1101 app_info->recentimage = strdup(data->recentimage);
1102 if (data->launchcondition != NULL)
1103 app_info->launchcondition = strdup(data->launchcondition);
1104 if (data->indicatordisplay != NULL)
1105 app_info->indicatordisplay = strdup(data->indicatordisplay);
1106 if (data->portraitimg != NULL)
1107 app_info->portraitimg = strdup(data->portraitimg);
1108 if (data->landscapeimg != NULL)
1109 app_info->landscapeimg = strdup(data->landscapeimg);
1110 if (data->guestmode_visibility != NULL)
1111 app_info->guestmode_visibility = strdup(data->guestmode_visibility);
1112 if (data->component != NULL)
1113 app_info->component = strdup(data->component);
1114 if (data->permission_type != NULL)
1115 app_info->permission_type = strdup(data->permission_type);
1116 if (data->component_type != NULL)
1117 app_info->component_type = strdup(data->component_type);
1118 if (data->preload != NULL)
1119 app_info->preload = strdup(data->preload);
1120 if (data->submode != NULL)
1121 app_info->submode = strdup(data->submode);
1122 if (data->submode_mainid != NULL)
1123 app_info->submode_mainid = strdup(data->submode_mainid);
1124 if (data->process_pool != NULL)
1125 app_info->process_pool = strdup(data->process_pool);
1126 if (data->installed_storage != NULL)
1127 app_info->installed_storage = strdup(data->installed_storage);
1128 if (data->autorestart != NULL)
1129 app_info->autorestart = strdup(data->autorestart);
1130 if (data->onboot != NULL)
1131 app_info->onboot = strdup(data->onboot);
1132 if (data->support_disable != NULL)
1133 app_info->support_disable = strdup(data->support_disable);
1134 if (data->ui_gadget != NULL)
1135 app_info->ui_gadget = strdup(data->ui_gadget);
1136 if (data->launch_mode != NULL)
1137 app_info->launch_mode = strdup(data->launch_mode);
1138 if (data->package_type != NULL)
1139 app_info->package_type = strdup(data->package_type);
1140 if (data->effective_appid != NULL)
1141 app_info->effective_appid = strdup(data->effective_appid);
1142 if (data->splash_screen_display != NULL)
1143 app_info->splash_screen_display = strdup(data->splash_screen_display);
1147 app_info->label = g_list_copy_deep(data->label, __copy_label, &ret);
1149 LOGE("memory alloc failed");
1150 pkgmgrinfo_basic_free_application(app_info);
1151 return PMINFO_R_ERROR;
1155 app_info->icon = g_list_copy_deep(data->icon, __copy_icon, &ret);
1157 LOGE("memory alloc failed");
1158 pkgmgrinfo_basic_free_application(app_info);
1159 return PMINFO_R_ERROR;
1163 app_info->category = g_list_copy_deep(data->category, __copy_str, &ret);
1165 LOGE("memory alloc failed");
1166 pkgmgrinfo_basic_free_application(app_info);
1167 return PMINFO_R_ERROR;
1171 app_info->metadata = g_list_copy_deep(data->metadata, __copy_metadata, &ret);
1173 LOGE("memory alloc failed");
1174 pkgmgrinfo_basic_free_application(app_info);
1175 return PMINFO_R_ERROR;
1179 app_info->datacontrol = g_list_copy_deep(data->datacontrol, __copy_datacontrol, &ret);
1181 LOGE("memory alloc failed");
1182 pkgmgrinfo_basic_free_application(app_info);
1183 return PMINFO_R_ERROR;
1187 app_info->appcontrol = g_list_copy_deep(data->appcontrol, __copy_appcontrol, &ret);
1189 LOGE("memory alloc failed");
1190 pkgmgrinfo_basic_free_application(app_info);
1191 return PMINFO_R_ERROR;
1195 app_info->background_category = g_list_copy_deep(data->background_category, __copy_str, &ret);
1197 LOGE("memory alloc failed");
1198 pkgmgrinfo_basic_free_application(app_info);
1199 return PMINFO_R_ERROR;
1203 app_info->splashscreens = g_list_copy_deep(data->splashscreens, __copy_splashscreens, &ret);
1205 LOGE("memory alloc failed");
1206 pkgmgrinfo_basic_free_application(app_info);
1207 return PMINFO_R_ERROR;
1210 *application = app_info;
1215 API int pkgmgrinfo_appinfo_clone_appinfo(pkgmgrinfo_appinfo_h handle,
1216 pkgmgrinfo_appinfo_h *clone)
1218 pkgmgr_appinfo_x *info;
1219 pkgmgr_appinfo_x *temp = (pkgmgr_appinfo_x *)handle;
1222 return PMINFO_R_EINVAL;
1224 info = calloc(1, sizeof(pkgmgr_appinfo_x));
1226 LOGE("memory alloc failed");
1227 return PMINFO_R_ERROR;
1230 if (temp->package != NULL)
1231 info->package = strdup(temp->package);
1232 if (temp->locale != NULL)
1233 info->locale = strdup(temp->locale);
1235 info->app_component = temp->app_component;
1237 if (_appinfo_copy_appinfo(&info->app_info, temp->app_info) < 0) {
1238 LOGE("appinfo copy failed");
1240 free((void *)info->package);
1244 return PMINFO_R_ERROR;
1252 static int _appinfo_get_filtered_foreach_appinfo(uid_t uid,
1253 pkgmgrinfo_filter_x *filter, int flag, pkgmgrinfo_app_list_cb app_list_cb,
1259 pkgmgr_appinfo_x info;
1261 GHashTableIter iter;
1264 locale = _get_system_locale();
1266 return PMINFO_R_ERROR;
1268 list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
1269 __free_applications);
1272 return PMINFO_R_ERROR;
1275 ret = _appinfo_get_applications(uid, uid, locale, filter, flag, list);
1276 if (ret == PMINFO_R_OK && uid != GLOBAL_USER)
1277 ret = _appinfo_get_applications(GLOBAL_USER, uid, locale,
1278 filter, flag, list);
1280 if (ret != PMINFO_R_OK) {
1281 g_hash_table_destroy(list);
1286 g_hash_table_iter_init(&iter, list);
1287 while (g_hash_table_iter_next(&iter, NULL, &value)) {
1288 app = (application_x *)value;
1289 info.app_info = app;
1290 info.locale = locale;
1291 info.package = app->package;
1292 if (app_list_cb(&info, user_data) < 0)
1295 g_hash_table_destroy(list);
1301 static const char *__appcomponent_str(pkgmgrinfo_app_component comp);
1303 API int pkgmgrinfo_appinfo_get_usr_list(pkgmgrinfo_pkginfo_h handle,
1304 pkgmgrinfo_app_component component,
1305 pkgmgrinfo_app_list_cb app_func, void *user_data, uid_t uid)
1308 pkgmgrinfo_appinfo_filter_h filter;
1310 const char *comp_str = NULL;
1312 if (handle == NULL || app_func == NULL) {
1313 LOGE("invalid parameter");
1314 return PMINFO_R_EINVAL;
1317 if (pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid)) {
1318 LOGE("invalid parameter");
1319 return PMINFO_R_EINVAL;
1322 if (pkgmgrinfo_appinfo_filter_create(&filter))
1323 return PMINFO_R_ERROR;
1325 if (pkgmgrinfo_appinfo_filter_add_string(filter,
1326 PMINFO_APPINFO_PROP_APP_PACKAGE, pkgid)) {
1327 pkgmgrinfo_appinfo_filter_destroy(filter);
1328 return PMINFO_R_ERROR;
1331 if (uid == GLOBAL_USER) {
1332 if (pkgmgrinfo_appinfo_filter_add_int(filter,
1333 PMINFO_APPINFO_PROP_APP_DISABLE_FOR_USER,
1335 pkgmgrinfo_appinfo_filter_destroy(filter);
1336 return PMINFO_R_ERROR;
1340 comp_str = __appcomponent_str(component);
1343 if (pkgmgrinfo_appinfo_filter_add_string(filter,
1344 PMINFO_APPINFO_PROP_APP_COMPONENT,
1346 pkgmgrinfo_appinfo_filter_destroy(filter);
1347 return PMINFO_R_ERROR;
1351 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter,
1352 PMINFO_APPINFO_GET_ALL, app_func, user_data);
1354 pkgmgrinfo_appinfo_filter_destroy(filter);
1359 API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle,
1360 pkgmgrinfo_app_component component,
1361 pkgmgrinfo_app_list_cb app_func, void *user_data)
1363 return pkgmgrinfo_appinfo_get_usr_list(handle, component, app_func, user_data, _getuid());
1366 API int pkgmgrinfo_appinfo_get_usr_installed_list_full(
1367 pkgmgrinfo_app_list_cb app_func, uid_t uid, int flag,
1371 pkgmgrinfo_appinfo_filter_h filter;
1373 if (app_func == NULL) {
1374 LOGE("invalid parameter");
1375 return PMINFO_R_EINVAL;
1378 if (pkgmgrinfo_appinfo_filter_create(&filter))
1379 return PMINFO_R_ERROR;
1381 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
1382 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
1383 pkgmgrinfo_appinfo_filter_destroy(filter);
1384 return PMINFO_R_ERROR;
1387 if (uid == GLOBAL_USER) {
1388 if (pkgmgrinfo_appinfo_filter_add_int(filter,
1389 PMINFO_APPINFO_PROP_APP_DISABLE_FOR_USER,
1391 pkgmgrinfo_appinfo_filter_destroy(filter);
1392 return PMINFO_R_ERROR;
1396 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter, flag, app_func,
1399 pkgmgrinfo_appinfo_filter_destroy(filter);
1404 API int pkgmgrinfo_appinfo_get_installed_list_full(
1405 pkgmgrinfo_app_list_cb app_func, int flag, void *user_data)
1407 return pkgmgrinfo_appinfo_get_usr_installed_list_full(app_func,
1408 _getuid(), flag, user_data);
1411 API int pkgmgrinfo_appinfo_get_usr_install_list(pkgmgrinfo_app_list_cb app_func,
1412 uid_t uid, void *user_data)
1414 return pkgmgrinfo_appinfo_get_usr_installed_list_full(app_func,
1415 uid, PMINFO_APPINFO_GET_ALL, user_data);
1418 API int pkgmgrinfo_appinfo_get_install_list(pkgmgrinfo_app_list_cb app_func,
1421 return pkgmgrinfo_appinfo_get_usr_installed_list_full(app_func,
1422 _getuid(), PMINFO_APPINFO_GET_ALL, user_data);
1425 API int pkgmgrinfo_appinfo_get_usr_installed_list(
1426 pkgmgrinfo_app_list_cb app_func, uid_t uid, void *user_data)
1428 if (app_func == NULL) {
1429 LOGE("invalid parameter");
1430 return PMINFO_R_EINVAL;
1433 return _appinfo_get_filtered_foreach_appinfo(uid, NULL,
1434 PMINFO_APPINFO_GET_ALL, app_func, user_data);
1437 API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func,
1440 return pkgmgrinfo_appinfo_get_usr_installed_list(app_func, _getuid(),
1444 API int pkgmgrinfo_appinfo_get_appid(pkgmgrinfo_appinfo_h handle, char **appid)
1446 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1448 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1449 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1451 if (info->app_info == NULL || info->app_info->appid == NULL)
1452 return PMINFO_R_ERROR;
1453 *appid = (char *)info->app_info->appid;
1458 API int pkgmgrinfo_appinfo_get_pkgname(pkgmgrinfo_appinfo_h handle, char **pkg_name)
1460 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1462 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1463 retvm_if(pkg_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1465 if (info->package == NULL)
1466 return PMINFO_R_ERROR;
1468 *pkg_name = (char *)info->package;
1473 API int pkgmgrinfo_appinfo_get_pkgid(pkgmgrinfo_appinfo_h handle, char **pkgid)
1475 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1477 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1478 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1480 if (info->package == NULL)
1481 return PMINFO_R_ERROR;
1483 *pkgid = (char *)info->package;
1488 API int pkgmgrinfo_appinfo_get_pkgtype(pkgmgrinfo_appinfo_h handle, char **pkgtype)
1490 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1491 retvm_if(pkgtype == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1492 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1494 *pkgtype = (char *)info->app_info->package_type;
1499 API int pkgmgrinfo_appinfo_get_exec(pkgmgrinfo_appinfo_h handle, char **exec)
1501 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1503 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1504 retvm_if(exec == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1506 if (info->app_info == NULL || info->app_info->exec == NULL)
1507 return PMINFO_R_ERROR;
1508 *exec = (char *)info->app_info->exec;
1514 API int pkgmgrinfo_appinfo_get_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1517 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1519 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1520 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1522 if (info->app_info == NULL)
1523 return PMINFO_R_ERROR;
1525 if (info->app_info->icon == NULL) {
1530 ptr = (icon_x *)info->app_info->icon->data;
1532 return PMINFO_R_ERROR;
1534 if (ptr->text == NULL)
1535 return PMINFO_R_ERROR;
1543 API int pkgmgrinfo_appinfo_get_label(pkgmgrinfo_appinfo_h handle, char **label)
1546 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1548 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1549 retvm_if(label == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1551 if (info->app_info == NULL || info->app_info->label == NULL)
1552 return PMINFO_R_ERROR;
1554 ptr = (label_x *)info->app_info->label->data;
1556 return PMINFO_R_ERROR;
1558 if (ptr->text == NULL)
1559 return PMINFO_R_ERROR;
1566 static char *_get_localed_label(const char *appid, const char *locale, uid_t uid)
1568 char *result = NULL;
1570 sqlite3_stmt *stmt = NULL;
1575 parser_db = getUserPkgParserDBPathUID(uid);
1576 if (parser_db == NULL) {
1577 _LOGE("Failed to get parser db path");
1581 if (sqlite3_open_v2(parser_db, &db, SQLITE_OPEN_READONLY, NULL) != SQLITE_OK) {
1582 _LOGE("DB open fail\n");
1588 query = sqlite3_mprintf("select app_label from package_app_localized_info where app_id=%Q and app_locale=%Q", appid, locale);
1589 if (query == NULL) {
1590 _LOGE("Out of memory");
1594 if (sqlite3_prepare_v2(db, query, -1, &stmt, NULL) != SQLITE_OK) {
1595 _LOGE("prepare_v2 fail\n");
1599 if (sqlite3_step(stmt) == SQLITE_ROW) {
1600 val = (char *)sqlite3_column_text(stmt, 0);
1602 result = strdup(val);
1606 sqlite3_finalize(stmt);
1607 sqlite3_free(query);
1613 API int pkgmgrinfo_appinfo_usr_get_localed_label(const char *appid, const char *locale, uid_t uid, char **label)
1617 retvm_if(appid == NULL || locale == NULL || label == NULL, PMINFO_R_EINVAL, "Argument is NULL");
1619 val = _get_localed_label(appid, locale, uid);
1621 val = _get_localed_label(appid, DEFAULT_LOCALE, uid);
1624 val = _get_localed_label(appid, locale, GLOBAL_USER);
1626 val = _get_localed_label(appid, DEFAULT_LOCALE, GLOBAL_USER);
1630 return PMINFO_R_ERROR;
1637 API int pkgmgrinfo_appinfo_get_localed_label(const char *appid, const char *locale, char **label)
1639 return pkgmgrinfo_appinfo_usr_get_localed_label(appid, locale, _getuid(), label);
1642 API int pkgmgrinfo_appinfo_get_metadata_value(pkgmgrinfo_appinfo_h handle, const char *metadata_key, char **metadata_value)
1644 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1645 retvm_if(metadata_key == NULL, PMINFO_R_EINVAL, "metadata_key is NULL");
1646 retvm_if(metadata_value == NULL, PMINFO_R_EINVAL, "metadata_value is NULL");
1648 GList *list_md = NULL;
1649 metadata_x *metadata = NULL;
1650 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1652 list_md = info->app_info->metadata;
1654 for (; list_md; list_md = list_md->next) {
1655 metadata = (metadata_x *)list_md->data;
1656 if (metadata && metadata->key) {
1657 if (strcasecmp(metadata->key, metadata_key) == 0) {
1658 if (metadata->value == NULL)
1659 *metadata_value = "";
1661 *metadata_value = (char *)metadata->value;
1667 return PMINFO_R_EINVAL;
1670 static pkgmgrinfo_app_component __appcomponent_convert(const char *comp)
1672 if (strcasecmp(comp, "uiapp") == 0)
1673 return PMINFO_UI_APP;
1674 else if (strcasecmp(comp, "svcapp") == 0)
1675 return PMINFO_SVC_APP;
1676 else if (strcasecmp(comp, "widgetapp") == 0)
1677 return PMINFO_WIDGET_APP;
1678 else if (strcasecmp(comp, "watchapp") == 0)
1679 return PMINFO_WATCH_APP;
1684 static const char *__appcomponent_str(pkgmgrinfo_app_component comp)
1689 case PMINFO_SVC_APP:
1691 case PMINFO_WIDGET_APP:
1693 case PMINFO_WATCH_APP:
1700 API int pkgmgrinfo_appinfo_get_component(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_component *component)
1702 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1705 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1706 retvm_if(component == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1708 if (info->app_info == NULL)
1709 return PMINFO_R_ERROR;
1711 comp = __appcomponent_convert(info->app_info->component);
1713 return PMINFO_R_ERROR;
1720 API int pkgmgrinfo_appinfo_get_apptype(pkgmgrinfo_appinfo_h handle, char **app_type)
1722 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1724 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1725 retvm_if(app_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1727 if (info->app_info == NULL || info->app_info->type == NULL)
1728 return PMINFO_R_ERROR;
1729 *app_type = (char *)info->app_info->type;
1734 API int pkgmgrinfo_appinfo_get_operation(pkgmgrinfo_appcontrol_h handle,
1735 int *operation_count, char ***operation)
1737 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1738 retvm_if(operation == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1739 retvm_if(operation_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1740 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1741 *operation_count = data->operation_count;
1742 *operation = data->operation;
1746 API int pkgmgrinfo_appinfo_get_uri(pkgmgrinfo_appcontrol_h handle,
1747 int *uri_count, char ***uri)
1749 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1750 retvm_if(uri == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1751 retvm_if(uri_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1752 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1753 *uri_count = data->uri_count;
1758 API int pkgmgrinfo_appinfo_get_mime(pkgmgrinfo_appcontrol_h handle,
1759 int *mime_count, char ***mime)
1761 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1762 retvm_if(mime == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1763 retvm_if(mime_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1764 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1765 *mime_count = data->mime_count;
1770 API int pkgmgrinfo_appinfo_get_subapp(pkgmgrinfo_appcontrol_h handle,
1771 int *subapp_count, char ***subapp)
1773 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1774 retvm_if(subapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1775 retvm_if(subapp_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1776 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1777 *subapp_count = data->subapp_count;
1778 *subapp = data->subapp;
1782 API int pkgmgrinfo_appinfo_get_setting_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1787 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1789 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1790 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1792 if (info->app_info == NULL)
1793 return PMINFO_R_ERROR;
1795 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1796 ptr = (icon_x *)tmp->data;
1797 if (ptr == NULL || ptr->section == NULL)
1800 val = (char *)ptr->section;
1801 if (val && strcmp(val, "setting") == 0) {
1802 *icon = (char *)ptr->text;
1807 return PMINFO_R_ERROR;
1811 API int pkgmgrinfo_appinfo_get_notification_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1816 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1818 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1819 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1821 if (info->app_info == NULL)
1822 return PMINFO_R_ERROR;
1824 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1825 ptr = (icon_x *)tmp->data;
1826 if (ptr == NULL || ptr->section == NULL)
1829 val = (char *)ptr->section;
1830 if (val && strcmp(val, "notification") == 0) {
1831 *icon = (char *)ptr->text;
1836 return PMINFO_R_ERROR;
1839 API int pkgmgrinfo_appinfo_get_recent_image_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_recentimage *type)
1842 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1844 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1845 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1847 if (info->app_info == NULL || info->app_info->recentimage == NULL)
1848 return PMINFO_R_ERROR;
1850 val = (char *)info->app_info->recentimage;
1851 if (strcasecmp(val, "capture") == 0)
1852 *type = PMINFO_RECENTIMAGE_USE_CAPTURE;
1853 else if (strcasecmp(val, "icon") == 0)
1854 *type = PMINFO_RECENTIMAGE_USE_ICON;
1856 *type = PMINFO_RECENTIMAGE_USE_NOTHING;
1861 API int pkgmgrinfo_appinfo_get_preview_image(pkgmgrinfo_appinfo_h handle, char **preview_img)
1866 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1868 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1869 retvm_if(preview_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1871 if (info->app_info == NULL)
1872 return PMINFO_R_ERROR;
1874 for (tmp = info->app_info->image; tmp; tmp = tmp->next) {
1875 ptr = (image_x *)tmp->data;
1876 if (ptr == NULL || ptr->section == NULL)
1879 val = (char *)ptr->section;
1880 if (val && strcmp(val, "preview") == 0) {
1881 *preview_img = (char *)ptr->text;
1886 return PMINFO_R_ERROR;
1889 API int pkgmgrinfo_appinfo_get_permission_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_permission_type *permission)
1892 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1894 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1895 retvm_if(permission == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1897 val = info->app_info->permission_type;
1899 return PMINFO_R_ERROR;
1901 if (strcmp(val, "signature") == 0)
1902 *permission = PMINFO_PERMISSION_SIGNATURE;
1903 else if (strcmp(val, "privilege") == 0)
1904 *permission = PMINFO_PERMISSION_PRIVILEGE;
1906 *permission = PMINFO_PERMISSION_NORMAL;
1911 API int pkgmgrinfo_appinfo_get_component_type(pkgmgrinfo_appinfo_h handle, char **component_type)
1913 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1915 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1916 retvm_if(component_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1918 if (info->app_info == NULL || info->app_info->component_type == NULL)
1919 return PMINFO_R_ERROR;
1921 *component_type = (char *)info->app_info->component_type;
1926 API int pkgmgrinfo_appinfo_get_hwacceleration(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_hwacceleration *hwacceleration)
1929 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1931 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1932 retvm_if(hwacceleration == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1934 if (info->app_info == NULL || info->app_info->hwacceleration == NULL)
1935 return PMINFO_R_ERROR;
1937 val = (char *)info->app_info->hwacceleration;
1938 if (strcasecmp(val, "off") == 0)
1939 *hwacceleration = PMINFO_HWACCELERATION_OFF;
1940 else if (strcasecmp(val, "on") == 0)
1941 *hwacceleration = PMINFO_HWACCELERATION_ON;
1943 *hwacceleration = PMINFO_HWACCELERATION_DEFAULT;
1948 API int pkgmgrinfo_appinfo_get_screenreader(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_screenreader *screenreader)
1951 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1953 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1954 retvm_if(screenreader == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1956 if (info->app_info == NULL || info->app_info->screenreader == NULL)
1957 return PMINFO_R_ERROR;
1959 val = (char *)info->app_info->screenreader;
1960 if (strcasecmp(val, "screenreader-off") == 0)
1961 *screenreader = PMINFO_SCREENREADER_OFF;
1962 else if (strcasecmp(val, "screenreader-on") == 0)
1963 *screenreader = PMINFO_SCREENREADER_ON;
1965 *screenreader = PMINFO_SCREENREADER_USE_SYSTEM_SETTING;
1970 API int pkgmgrinfo_appinfo_get_effectimage(pkgmgrinfo_appinfo_h handle, char **portrait_img, char **landscape_img)
1972 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1974 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1975 retvm_if(portrait_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1976 retvm_if(landscape_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1978 if (info->app_info == NULL)
1979 return PMINFO_R_ERROR;
1981 if (info->app_info->portraitimg == NULL)
1984 *portrait_img = (char *)info->app_info->portraitimg;
1986 if (info->app_info->landscapeimg == NULL)
1987 *landscape_img = "";
1989 *landscape_img = (char *)info->app_info->landscapeimg;
1994 API int pkgmgrinfo_appinfo_get_effectimage_type(pkgmgrinfo_appinfo_h handle, char **effectimage_type)
1996 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1998 if (handle == NULL || effectimage_type == NULL) {
1999 LOGE("invalid parameter");
2000 return PMINFO_R_EINVAL;
2003 if (info->app_info == NULL || info->app_info->effectimage_type == NULL)
2004 return PMINFO_R_ERROR;
2006 *effectimage_type = (char *)info->app_info->effectimage_type;
2011 API int pkgmgrinfo_appinfo_get_submode_mainid(pkgmgrinfo_appinfo_h handle, char **submode_mainid)
2013 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2015 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2016 retvm_if(submode_mainid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2018 if (info->app_info == NULL)
2019 return PMINFO_R_ERROR;
2021 if (info->app_info->submode_mainid == NULL)
2022 *submode_mainid = "";
2024 *submode_mainid = (char *)info->app_info->submode_mainid;
2029 API int pkgmgrinfo_appinfo_get_installed_storage_location(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_installed_storage *storage)
2031 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2032 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2034 if (info->app_info && info->app_info->installed_storage) {
2035 if (strcmp(info->app_info->installed_storage, "installed_internal") == 0)
2036 *storage = PMINFO_INTERNAL_STORAGE;
2037 else if (strcmp(info->app_info->installed_storage, "installed_external") == 0)
2038 *storage = PMINFO_EXTERNAL_STORAGE;
2040 return PMINFO_R_ERROR;
2042 return PMINFO_R_ERROR;
2048 API int pkgmgrinfo_appinfo_get_launch_mode(pkgmgrinfo_appinfo_h handle, char **mode)
2050 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2052 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2053 retvm_if(mode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2055 if (info->app_info->launch_mode == NULL)
2056 return PMINFO_R_ERROR;
2058 *mode = (char *)(info->app_info->launch_mode);
2063 API int pkgmgrinfo_appinfo_get_alias_appid(pkgmgrinfo_appinfo_h handle, char **alias_appid)
2065 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2067 if (handle == NULL || alias_appid == NULL) {
2068 LOGE("invalid parameter");
2069 return PMINFO_R_EINVAL;
2072 if (info->app_info == NULL || info->app_info->alias_appid == NULL)
2073 return PMINFO_R_ERROR;
2075 *alias_appid = (char *)info->app_info->alias_appid;
2080 API int pkgmgrinfo_appinfo_get_effective_appid(pkgmgrinfo_appinfo_h handle, char **effective_appid)
2082 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2084 if (handle == NULL || effective_appid == NULL) {
2085 LOGE("invalid parameter");
2086 return PMINFO_R_EINVAL;
2089 if (info->app_info == NULL)
2090 return PMINFO_R_ERROR;
2092 if (info->app_info->effective_appid == NULL)
2093 *effective_appid = "";
2095 *effective_appid = (char *)info->app_info->effective_appid;
2100 API int pkgmgrinfo_appinfo_get_tep_name(pkgmgrinfo_appinfo_h handle, char **tep_name)
2102 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2104 if (handle == NULL || tep_name == NULL) {
2105 LOGE("invalid parameter");
2106 return PMINFO_R_EINVAL;
2109 if (info->app_info == NULL)
2110 return PMINFO_R_ERROR;
2112 if (info->app_info->tep_name == NULL)
2115 *tep_name = (char *)info->app_info->tep_name;
2120 API int pkgmgrinfo_appinfo_get_zip_mount_file(pkgmgrinfo_appinfo_h handle, char **zip_mount_file)
2122 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2124 if (handle == NULL || zip_mount_file == NULL) {
2125 LOGE("invalid parameter");
2126 return PMINFO_R_EINVAL;
2129 if (info->app_info == NULL)
2130 return PMINFO_R_ERROR;
2132 if (info->app_info->zip_mount_file == NULL)
2133 *zip_mount_file = "";
2135 *zip_mount_file = (char *)info->app_info->zip_mount_file;
2140 API int pkgmgrinfo_appinfo_get_root_path(pkgmgrinfo_appinfo_h handle, char **root_path)
2142 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2144 if (handle == NULL || root_path == NULL) {
2145 LOGE("invalid parameter");
2146 return PMINFO_R_EINVAL;
2149 if (info->app_info == NULL || info->app_info->root_path == NULL)
2150 return PMINFO_R_ERROR;
2152 *root_path = (char *)info->app_info->root_path;
2157 API int pkgmgrinfo_appinfo_get_api_version(pkgmgrinfo_appinfo_h handle, char **api_version)
2159 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2161 if (handle == NULL || api_version == NULL) {
2162 LOGE("invalid parameter");
2163 return PMINFO_R_EINVAL;
2166 if (info->app_info == NULL || info->app_info->api_version == NULL)
2167 return PMINFO_R_ERROR;
2169 *api_version = (char *)info->app_info->api_version;
2174 API int pkgmgrinfo_appinfo_get_installed_time(pkgmgrinfo_appinfo_h handle, int *installed_time)
2176 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2178 if (handle == NULL || installed_time == NULL) {
2179 LOGE("invalid parameter");
2180 return PMINFO_R_EINVAL;
2183 if (info->app_info == NULL || info->app_info->package_installed_time == NULL)
2184 return PMINFO_R_ERROR;
2186 *installed_time = atoi(info->app_info->package_installed_time);
2191 API int pkgmgrinfo_appinfo_usr_get_datacontrol_info(const char *providerid, const char *type, uid_t uid, char **appid, char **access)
2193 retvm_if(providerid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
2194 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
2195 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2196 retvm_if(access == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2198 int ret = PMINFO_R_OK;
2200 sqlite3_stmt *stmt = NULL;
2203 ret = __open_manifest_db(uid, true);
2204 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
2206 /*Start constructing query*/
2207 query = sqlite3_mprintf("select * from package_app_data_control where providerid=%Q and type=%Q", providerid, type);
2208 tryvm_if(query == NULL, ret = PMINFO_R_ERROR, "Out of memory");
2211 ret = sqlite3_prepare_v2(GET_DB(manifest_db), query, strlen(query), &stmt, NULL);
2212 tryvm_if(ret != PMINFO_R_OK, ret = PMINFO_R_ERROR, "sqlite3_prepare_v2 failed[%s]\n", query);
2215 ret = sqlite3_step(stmt);
2216 tryvm_if((ret != SQLITE_ROW) || (ret == SQLITE_DONE), ret = PMINFO_R_ERROR, "No records found");
2218 *appid = strdup((char *)sqlite3_column_text(stmt, 0));
2219 *access = strdup((char *)sqlite3_column_text(stmt, 2));
2224 sqlite3_free(query);
2225 sqlite3_finalize(stmt);
2226 __close_manifest_db();
2230 API int pkgmgrinfo_appinfo_get_datacontrol_info(const char *providerid, const char *type, char **appid, char **access)
2232 return pkgmgrinfo_appinfo_usr_get_datacontrol_info(providerid, type, _getuid(), appid, access);
2235 API int pkgmgrinfo_appinfo_usr_get_datacontrol_appid(const char *providerid, uid_t uid, char **appid)
2237 retvm_if(providerid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
2238 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2240 int ret = PMINFO_R_OK;
2242 sqlite3_stmt *stmt = NULL;
2245 ret = __open_manifest_db(uid, true);
2246 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
2248 /*Start constructing query*/
2249 query = sqlite3_mprintf("select * from package_app_data_control where providerid=%Q", providerid);
2250 tryvm_if(query == NULL, ret = PMINFO_R_ERROR, "Out of memory");
2253 ret = sqlite3_prepare_v2(GET_DB(manifest_db), query, strlen(query), &stmt, NULL);
2254 tryvm_if(ret != PMINFO_R_OK, ret = PMINFO_R_ERROR, "sqlite3_prepare_v2 failed[%s]\n", query);
2257 ret = sqlite3_step(stmt);
2258 tryvm_if((ret != SQLITE_ROW) || (ret == SQLITE_DONE), ret = PMINFO_R_ERROR, "No records found");
2260 *appid = strdup((char *)sqlite3_column_text(stmt, 0));
2265 sqlite3_free(query);
2266 sqlite3_finalize(stmt);
2267 __close_manifest_db();
2271 API int pkgmgrinfo_appinfo_get_datacontrol_appid(const char *providerid, char **appid)
2273 return pkgmgrinfo_appinfo_usr_get_datacontrol_appid(providerid, _getuid(), appid);
2276 API int pkgmgrinfo_appinfo_get_support_mode(pkgmgrinfo_appinfo_h handle, int *support_mode)
2278 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2279 retvm_if(support_mode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2281 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2282 if (info->app_info->support_mode)
2283 *support_mode = atoi(info->app_info->support_mode);
2290 API int pkgmgrinfo_appinfo_foreach_permission(pkgmgrinfo_appinfo_h handle,
2291 pkgmgrinfo_app_permission_list_cb permission_func, void *user_data)
2293 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2294 retvm_if(permission_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2298 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2300 if (info->app_info == NULL)
2301 return PMINFO_R_ERROR;
2303 for (tmp = info->app_info->permission; tmp; tmp = tmp->next) {
2304 ptr = (permission_x *)tmp->data;
2308 ret = permission_func(ptr->value, user_data);
2316 API int pkgmgrinfo_appinfo_foreach_category(pkgmgrinfo_appinfo_h handle,
2317 pkgmgrinfo_app_category_list_cb category_func, void *user_data)
2319 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2320 retvm_if(category_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2322 const char *category;
2324 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2326 if (info->app_info == NULL)
2327 return PMINFO_R_ERROR;
2329 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
2330 category = (const char *)tmp->data;
2332 ret = category_func(category, user_data);
2340 API int pkgmgrinfo_appinfo_foreach_metadata(pkgmgrinfo_appinfo_h handle,
2341 pkgmgrinfo_app_metadata_list_cb metadata_func, void *user_data)
2343 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2344 retvm_if(metadata_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2348 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2350 if (info->app_info == NULL)
2351 return PMINFO_R_ERROR;
2353 for (tmp = info->app_info->metadata; tmp; tmp = tmp->next) {
2354 ptr = (metadata_x *)tmp->data;
2358 ret = metadata_func(ptr->key, ptr->value ? ptr->value : "", user_data);
2366 API int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
2367 pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
2369 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2370 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2372 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2373 appcontrol_x *appcontrol;
2376 if (info->app_info == NULL)
2377 return PMINFO_R_ERROR;
2379 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
2380 appcontrol = (appcontrol_x *)tmp->data;
2381 if (appcontrol == NULL)
2383 ret = appcontrol_func(appcontrol->operation, appcontrol->uri, appcontrol->mime, user_data);
2391 API int pkgmgrinfo_appinfo_foreach_background_category(
2392 pkgmgrinfo_appinfo_h handle,
2393 pkgmgrinfo_app_background_category_list_cb category_func,
2396 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2400 if (handle == NULL || category_func == NULL || info->app_info == NULL) {
2401 LOGE("invalid parameter");
2402 return PMINFO_R_EINVAL;
2405 for (tmp = info->app_info->background_category; tmp; tmp = tmp->next) {
2406 category = (char *)tmp->data;
2407 if (category == NULL)
2410 if (category_func(category, user_data) < 0)
2417 API int pkgmgrinfo_appinfo_foreach_splash_screen(pkgmgrinfo_appinfo_h handle,
2418 pkgmgrinfo_app_splash_screen_list_cb splash_screen_func,
2421 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2422 splashscreen_x *splashscreen;
2426 if (info == NULL || info->app_info == NULL
2427 || splash_screen_func == NULL) {
2428 LOGE("invalid parameter");
2429 return PMINFO_R_EINVAL;
2432 for (tmp = info->app_info->splashscreens; tmp; tmp = tmp->next) {
2433 splashscreen = (splashscreen_x *)tmp->data;
2434 if (splashscreen == NULL)
2436 ret = splash_screen_func(splashscreen->src,
2438 splashscreen->orientation,
2439 splashscreen->indicatordisplay,
2440 splashscreen->operation,
2441 splashscreen->color_depth,
2450 API int pkgmgrinfo_appinfo_is_nodisplay(pkgmgrinfo_appinfo_h handle, bool *nodisplay)
2452 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2453 retvm_if(nodisplay == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2454 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2456 if (info->app_info == NULL || info->app_info->nodisplay == NULL)
2457 return PMINFO_R_ERROR;
2459 *nodisplay = _get_bool_value(info->app_info->nodisplay);
2464 API int pkgmgrinfo_appinfo_is_multiple(pkgmgrinfo_appinfo_h handle, bool *multiple)
2466 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2467 retvm_if(multiple == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2468 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2470 if (info->app_info == NULL || info->app_info->multiple == NULL)
2471 return PMINFO_R_ERROR;
2473 *multiple = _get_bool_value(info->app_info->multiple);
2478 API int pkgmgrinfo_appinfo_is_indicator_display_allowed(pkgmgrinfo_appinfo_h handle, bool *indicator_disp)
2480 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2481 retvm_if(indicator_disp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2482 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2484 if (info->app_info == NULL || info->app_info->indicatordisplay == NULL)
2485 return PMINFO_R_ERROR;
2487 *indicator_disp = _get_bool_value(info->app_info->indicatordisplay);
2492 API int pkgmgrinfo_appinfo_is_taskmanage(pkgmgrinfo_appinfo_h handle, bool *taskmanage)
2494 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2495 retvm_if(taskmanage == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2496 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2498 if (info->app_info == NULL || info->app_info->taskmanage == NULL)
2499 return PMINFO_R_ERROR;
2501 *taskmanage = _get_bool_value(info->app_info->taskmanage);
2506 API int pkgmgrinfo_appinfo_is_enabled(pkgmgrinfo_appinfo_h handle, bool *enabled)
2508 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2509 retvm_if(enabled == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2510 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2512 if (info->app_info == NULL || info->app_info->enabled == NULL)
2513 return PMINFO_R_ERROR;
2515 *enabled = _get_bool_value(info->app_info->enabled);
2520 API int pkgmgrinfo_appinfo_is_onboot(pkgmgrinfo_appinfo_h handle, bool *onboot)
2522 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2523 retvm_if(onboot == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2524 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2526 if (info->app_info == NULL || info->app_info->onboot == NULL)
2527 return PMINFO_R_ERROR;
2529 *onboot = _get_bool_value(info->app_info->onboot);
2534 API int pkgmgrinfo_appinfo_is_autorestart(pkgmgrinfo_appinfo_h handle, bool *autorestart)
2536 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2537 retvm_if(autorestart == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2538 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2540 if (info->app_info == NULL || info->app_info->autorestart == NULL)
2541 return PMINFO_R_ERROR;
2543 *autorestart = _get_bool_value(info->app_info->autorestart);
2548 API int pkgmgrinfo_appinfo_is_mainapp(pkgmgrinfo_appinfo_h handle, bool *mainapp)
2550 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2551 retvm_if(mainapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2552 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2554 if (info->app_info == NULL || info->app_info->mainapp == NULL)
2555 return PMINFO_R_ERROR;
2557 *mainapp = _get_bool_value(info->app_info->mainapp);
2562 API int pkgmgrinfo_appinfo_is_preload(pkgmgrinfo_appinfo_h handle, bool *preload)
2564 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2565 retvm_if(preload == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2566 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2568 if (info->app_info == NULL || info->app_info->preload == NULL)
2569 return PMINFO_R_ERROR;
2571 *preload = _get_bool_value(info->app_info->preload);
2576 API int pkgmgrinfo_appinfo_is_submode(pkgmgrinfo_appinfo_h handle, bool *submode)
2578 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2579 retvm_if(submode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2580 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2582 if (info->app_info == NULL || info->app_info->submode == NULL)
2583 return PMINFO_R_ERROR;
2585 *submode = _get_bool_value(info->app_info->submode);
2590 API int pkgmgrinfo_appinfo_is_process_pool(pkgmgrinfo_appinfo_h handle, bool *process_pool)
2592 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2594 if (handle == NULL || process_pool == NULL) {
2595 LOGE("invalid parameter");
2596 return PMINFO_R_EINVAL;
2599 if (info->app_info == NULL)
2600 return PMINFO_R_ERROR;
2602 *process_pool = _get_bool_value(info->app_info->process_pool);
2607 API int pkgmgrinfo_appinfo_is_category_exist(pkgmgrinfo_appinfo_h handle, const char *category, bool *exist)
2609 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2610 retvm_if(category == NULL, PMINFO_R_EINVAL, "category is NULL");
2611 retvm_if(exist == NULL, PMINFO_R_EINVAL, "exist is NULL");
2615 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2617 if (info->app_info == NULL)
2618 return PMINFO_R_ERROR;
2621 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
2622 val = (const char *)tmp->data;
2625 if (strcasecmp(val, category) == 0) {
2634 API int pkgmgrinfo_appinfo_is_ui_gadget(pkgmgrinfo_appinfo_h handle,
2637 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2639 if (info == NULL || info->app_info == NULL || ui_gadget == NULL) {
2640 _LOGE("invalid parameter");
2641 return PMINFO_R_EINVAL;
2643 if (info->app_info->ui_gadget == NULL)
2644 info->app_info->ui_gadget = strdup("false");
2646 *ui_gadget = _get_bool_value(info->app_info->ui_gadget);
2651 API int pkgmgrinfo_appinfo_is_support_disable(pkgmgrinfo_appinfo_h handle,
2652 bool *support_disable)
2654 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2656 if (info == NULL || info->app_info == NULL || support_disable == NULL) {
2657 _LOGE("invalid parameter");
2658 return PMINFO_R_EINVAL;
2661 *support_disable = _get_bool_value(info->app_info->support_disable);
2666 API int pkgmgrinfo_appinfo_is_removable(pkgmgrinfo_appinfo_h handle,
2669 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2671 if (info == NULL || info->app_info == NULL || removable == NULL) {
2672 _LOGE("invalid parameter");
2673 return PMINFO_R_EINVAL;
2676 *removable = _get_bool_value(info->app_info->removable);
2681 API int pkgmgrinfo_appinfo_is_system(pkgmgrinfo_appinfo_h handle, bool *system)
2683 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2685 if (info == NULL || info->app_info == NULL || system == NULL) {
2686 _LOGE("invalid parameter");
2687 return PMINFO_R_EINVAL;
2690 *system = _get_bool_value(info->app_info->package_system);
2695 API int pkgmgrinfo_appinfo_is_disabled(pkgmgrinfo_appinfo_h handle, bool *disabled)
2697 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2698 retvm_if(disabled == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2699 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2701 if (info->app_info == NULL || info->app_info->is_disabled == NULL)
2702 return PMINFO_R_ERROR;
2704 *disabled = _get_bool_value(info->app_info->is_disabled);
2709 API int pkgmgrinfo_appinfo_is_global(pkgmgrinfo_appinfo_h handle, bool *global)
2711 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2713 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2714 retvm_if(global == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2716 if (info->app_info == NULL || info->app_info->for_all_users == NULL)
2717 return PMINFO_R_ERROR;
2719 *global = _get_bool_value(info->app_info->for_all_users);
2724 API int pkgmgrinfo_appinfo_get_splash_screen_display(pkgmgrinfo_appinfo_h handle, bool *splash_screen_display)
2726 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2728 if (info == NULL || splash_screen_display == NULL) {
2729 _LOGE("Invalid parameter");
2730 return PMINFO_R_EINVAL;
2733 if (info->app_info == NULL || info->app_info->splash_screen_display == NULL)
2734 return PMINFO_R_ERROR;
2736 *splash_screen_display = _get_bool_value(info->app_info->splash_screen_display);
2741 API int pkgmgrinfo_appinfo_destroy_appinfo(pkgmgrinfo_appinfo_h handle)
2743 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2744 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2745 __cleanup_appinfo(info);
2749 API int pkgmgrinfo_appinfo_filter_create(pkgmgrinfo_appinfo_filter_h *handle)
2751 return (pkgmgrinfo_pkginfo_filter_create(handle));
2754 API int pkgmgrinfo_appinfo_filter_destroy(pkgmgrinfo_appinfo_filter_h handle)
2756 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
2759 static gint __compare_func(gconstpointer data1, gconstpointer data2)
2761 pkgmgrinfo_node_x *node1 = (pkgmgrinfo_node_x *)data1;
2762 pkgmgrinfo_node_x *node2 = (pkgmgrinfo_node_x *)data2;
2763 if (node1->prop == node2->prop)
2765 else if (node1->prop > node2->prop)
2771 API int pkgmgrinfo_appinfo_filter_add_int(pkgmgrinfo_appinfo_filter_h handle,
2772 const char *property, const int value)
2774 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2775 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2776 char buf[PKG_VALUE_STRING_LEN_MAX] = {'\0'};
2778 GSList *link = NULL;
2780 prop = _pminfo_appinfo_convert_to_prop_int(property);
2781 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_INT ||
2782 prop > E_PMINFO_APPINFO_PROP_APP_MAX_INT) {
2783 _LOGE("Invalid Integer Property\n");
2784 return PMINFO_R_EINVAL;
2786 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2787 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1, sizeof(pkgmgrinfo_node_x));
2789 _LOGE("Out of Memory!!!\n");
2790 return PMINFO_R_ERROR;
2792 snprintf(buf, PKG_VALUE_STRING_LEN_MAX - 1, "%d", value);
2793 val = strndup(buf, PKG_VALUE_STRING_LEN_MAX - 1);
2795 _LOGE("Out of Memory\n");
2798 return PMINFO_R_ERROR;
2802 /*If API is called multiple times for same property, we should override the previous values.
2803 Last value set will be used for filtering.*/
2804 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2806 filter->list = g_slist_delete_link(filter->list, link);
2807 filter->list = g_slist_append(filter->list, (gpointer)node);
2812 API int pkgmgrinfo_appinfo_filter_add_bool(pkgmgrinfo_appinfo_filter_h handle,
2813 const char *property, const bool value)
2815 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2816 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2818 GSList *link = NULL;
2820 prop = _pminfo_appinfo_convert_to_prop_bool(property);
2821 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_BOOL ||
2822 prop > E_PMINFO_APPINFO_PROP_APP_MAX_BOOL) {
2823 _LOGE("Invalid Boolean Property\n");
2824 return PMINFO_R_EINVAL;
2826 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2827 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1, sizeof(pkgmgrinfo_node_x));
2829 _LOGE("Out of Memory!!!\n");
2830 return PMINFO_R_ERROR;
2833 val = strndup("true", 4);
2835 val = strndup("false", 5);
2837 _LOGE("Out of Memory\n");
2840 return PMINFO_R_ERROR;
2844 /*If API is called multiple times for same property, we should override the previous values.
2845 Last value set will be used for filtering.*/
2846 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2848 filter->list = g_slist_delete_link(filter->list, link);
2849 filter->list = g_slist_append(filter->list, (gpointer)node);
2854 API int pkgmgrinfo_appinfo_filter_add_string(pkgmgrinfo_appinfo_filter_h handle,
2855 const char *property, const char *value)
2857 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2858 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2859 retvm_if(value == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2861 pkgmgrinfo_node_x *ptr = NULL;
2862 char prev[PKG_STRING_LEN_MAX] = {'\0'};
2863 char temp[PKG_STRING_LEN_MAX] = {'\0'};
2864 GSList *link = NULL;
2866 prop = _pminfo_appinfo_convert_to_prop_str(property);
2867 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_STR ||
2868 prop > E_PMINFO_APPINFO_PROP_APP_MAX_STR) {
2869 _LOGE("Invalid String Property\n");
2870 return PMINFO_R_EINVAL;
2872 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2873 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1, sizeof(pkgmgrinfo_node_x));
2875 _LOGE("Out of Memory!!!\n");
2876 return PMINFO_R_ERROR;
2880 case E_PMINFO_APPINFO_PROP_APP_COMPONENT:
2881 node->value = strdup(value);
2882 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2884 filter->list = g_slist_delete_link(filter->list, link);
2885 filter->list = g_slist_append(filter->list, (gpointer)node);
2887 case E_PMINFO_APPINFO_PROP_APP_CATEGORY:
2888 val = (char *)calloc(1, PKG_STRING_LEN_MAX);
2890 _LOGE("Out of Memory\n");
2893 return PMINFO_R_ERROR;
2895 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2897 ptr = (pkgmgrinfo_node_x *)link->data;
2898 strncpy(prev, ptr->value, PKG_STRING_LEN_MAX - 1);
2899 _LOGI("Previous value is %s\n", prev);
2900 filter->list = g_slist_delete_link(filter->list, link);
2901 snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s,%s", prev, value);
2902 strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
2903 _LOGI("New value is %s\n", val);
2905 filter->list = g_slist_append(filter->list, (gpointer)node);
2906 memset(temp, '\0', PKG_STRING_LEN_MAX);
2908 snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s", value);
2909 strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
2910 _LOGI("First value is %s\n", val);
2912 filter->list = g_slist_append(filter->list, (gpointer)node);
2913 memset(temp, '\0', PKG_STRING_LEN_MAX);
2917 node->value = strndup(value, PKG_STRING_LEN_MAX - 1);
2918 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2920 filter->list = g_slist_delete_link(filter->list, link);
2921 filter->list = g_slist_append(filter->list, (gpointer)node);
2927 API int pkgmgrinfo_appinfo_usr_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count, uid_t uid)
2933 if (handle == NULL || count == NULL) {
2934 _LOGE("invalid parameter");
2935 return PMINFO_R_EINVAL;
2938 locale = _get_system_locale();
2940 return PMINFO_R_ERROR;
2942 list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
2943 __free_applications);
2946 return PMINFO_R_ERROR;
2949 ret = _appinfo_get_applications(uid, uid, locale, handle, 0, list);
2950 if (ret == PMINFO_R_OK && uid != GLOBAL_USER)
2951 ret = _appinfo_get_applications(GLOBAL_USER, uid, locale,
2954 if (ret != PMINFO_R_OK) {
2955 g_hash_table_destroy(list);
2957 return PMINFO_R_ERROR;
2960 *count = g_hash_table_size(list);
2961 g_hash_table_destroy(list);
2967 API int pkgmgrinfo_appinfo_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count)
2969 return pkgmgrinfo_appinfo_usr_filter_count(handle, count, _getuid());
2972 API int pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(
2973 pkgmgrinfo_appinfo_filter_h handle,
2974 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
2976 if (handle == NULL || app_cb == NULL) {
2977 LOGE("invalid parameter");
2978 return PMINFO_R_EINVAL;
2981 return _appinfo_get_filtered_foreach_appinfo(uid, handle, PMINFO_APPINFO_GET_ALL, app_cb,
2985 API int pkgmgrinfo_appinfo_filter_foreach_appinfo(pkgmgrinfo_appinfo_filter_h handle,
2986 pkgmgrinfo_app_list_cb app_cb, void *user_data)
2988 return pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(handle, app_cb, user_data, _getuid());
2991 API int pkgmgrinfo_appinfo_metadata_filter_create(pkgmgrinfo_appinfo_metadata_filter_h *handle)
2993 return (pkgmgrinfo_pkginfo_filter_create(handle));
2996 API int pkgmgrinfo_appinfo_metadata_filter_destroy(pkgmgrinfo_appinfo_metadata_filter_h handle)
2998 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
3001 API int pkgmgrinfo_appinfo_metadata_filter_add(
3002 pkgmgrinfo_appinfo_metadata_filter_h handle,
3003 const char *key, const char *value)
3007 ret = pkgmgrinfo_appinfo_filter_add_string(handle,
3008 PMINFO_APPINFO_PROP_APP_METADATA_KEY, key);
3009 if (ret != PMINFO_R_OK)
3012 /* value can be NULL.
3013 * In that case all apps with specified key should be displayed
3015 if (value && strlen(value)) {
3016 ret = pkgmgrinfo_appinfo_filter_add_string(handle,
3017 PMINFO_APPINFO_PROP_APP_METADATA_VALUE, value);
3018 if (ret != PMINFO_R_OK)
3025 API int pkgmgrinfo_appinfo_usr_metadata_filter_foreach(
3026 pkgmgrinfo_appinfo_metadata_filter_h handle,
3027 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
3029 if (handle == NULL || app_cb == NULL) {
3030 LOGE("invalid parameter");
3031 return PMINFO_R_EINVAL;
3034 return _appinfo_get_filtered_foreach_appinfo(uid, handle, PMINFO_APPINFO_GET_ALL, app_cb,
3038 API int pkgmgrinfo_appinfo_metadata_filter_foreach(
3039 pkgmgrinfo_appinfo_metadata_filter_h handle,
3040 pkgmgrinfo_app_list_cb app_cb, void *user_data)
3042 return pkgmgrinfo_appinfo_usr_metadata_filter_foreach(handle, app_cb,
3043 user_data, _getuid());
3046 API int pkgmgrinfo_appinfo_is_guestmode_visibility(pkgmgrinfo_appinfo_h handle, bool *status)
3049 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3051 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
3052 retvm_if(status == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3054 val = info->app_info->guestmode_visibility;
3055 *status = _get_bool_value(val);