13 #include "pkgmgr-info.h"
14 #include "pkgmgrinfo_debug.h"
15 #include "pkgmgrinfo_private.h"
16 #include "pkgmgr_parser.h"
18 static bool _get_bool_value(const char *str)
20 if (str && !strcmp(str, "true"))
26 static void __cleanup_appinfo(pkgmgr_appinfo_x *data)
28 pkgmgr_appinfo_x *info = data;
32 free((void *)info->package);
34 free((void *)info->locale);
36 pkgmgrinfo_basic_free_application(info->app_info);
42 static const char join_localized_info[] =
43 " LEFT OUTER JOIN package_app_localized_info"
44 " ON ai.app_id=package_app_localized_info.app_id"
45 " AND package_app_localized_info.app_locale=?";
46 static const char join_category[] =
47 " LEFT OUTER JOIN package_app_app_category"
48 " ON ai.app_id=package_app_app_category.app_id";
49 static const char join_app_control[] =
50 " LEFT OUTER JOIN package_app_app_control"
51 " ON ai.app_id=package_app_app_control.app_id";
52 static const char join_metadata[] =
53 " LEFT OUTER JOIN package_app_app_metadata"
54 " ON ai.app_id=package_app_app_metadata.app_id ";
55 static const char join_appinfo_for_uid[] =
56 " LEFT OUTER JOIN package_app_info_for_uid"
57 " ON ai.app_id=package_app_info_for_uid.app_id ";
59 static int _get_filtered_query(pkgmgrinfo_filter_x *filter,
60 const char *locale, uid_t uid, char **query, GList **bind_params)
64 char *condition = NULL;
65 char buf[MAX_QUERY_LEN] = { '\0' };
66 char tmp_query[MAX_QUERY_LEN] = { '\0' };
67 static const char query_pkg_disable[] = " AND ai.package IN "
68 "(SELECT package FROM package_info WHERE package_disable='false')";
71 strncat(buf, " WHERE 1=1", MAX_QUERY_LEN - len - 1);
72 len += strlen(" WHERE 1=1");
75 strncat(buf, query_pkg_disable, MAX_QUERY_LEN - len - 1);
80 for (list = filter->list; list; list = list->next) {
81 joined |= __get_filter_condition(list->data, uid, &condition, bind_params);
82 if (condition == NULL)
85 strncat(buf, " AND ", MAX_QUERY_LEN - len - 1);
86 len += strlen(" AND ");
88 strncat(buf, condition, sizeof(buf) - len - 1);
89 len += strlen(condition);
94 if (filter->list_metadata) {
95 strncat(buf, " AND (", MAX_QUERY_LEN - len - 1);
96 len += strlen(" AND (");
98 for (list = filter->list_metadata; list; list = list->next) {
99 joined |= __get_metadata_filter_condition(list->data,
100 &condition, bind_params);
101 if (condition == NULL)
103 strncat(buf, condition, sizeof(buf) - len - 1);
104 len += strlen(condition);
108 strncat(buf, " OR ", MAX_QUERY_LEN - len - 1);
109 len += strlen(" OR ");
111 if (filter->list_metadata) {
112 strncat(buf, "1=0)", MAX_QUERY_LEN - len - 1);
113 len += strlen("1=0)");
116 if (joined & E_PMINFO_APPINFO_JOIN_LOCALIZED_INFO) {
117 strncat(tmp_query, join_localized_info, MAX_QUERY_LEN - len - 1);
118 len += strlen(join_localized_info);
119 *bind_params = g_list_append(*bind_params, strdup(locale));
121 if (joined & E_PMINFO_APPINFO_JOIN_CATEGORY) {
122 strncat(tmp_query, join_category, MAX_QUERY_LEN - len - 1);
123 len += strlen(join_category);
125 if (joined & E_PMINFO_APPINFO_JOIN_APP_CONTROL) {
126 strncat(tmp_query, join_app_control, MAX_QUERY_LEN - len - 1);
127 len += strlen(join_app_control);
129 if (joined & E_PMINFO_APPINFO_JOIN_METADATA) {
130 strncat(tmp_query, join_metadata, MAX_QUERY_LEN - len - 1);
131 len += strlen(join_metadata);
133 if (joined & E_PMINFO_APPINFO_JOIN_APPINFO_FOR_UID) {
134 strncat(tmp_query, join_appinfo_for_uid, MAX_QUERY_LEN - len - 1);
135 len += strlen(join_appinfo_for_uid);
137 strncat(tmp_query, buf, MAX_QUERY_LEN - len - 1);
140 strncat(tmp_query, query_pkg_disable, MAX_QUERY_LEN - len - 1);
142 *query = strdup(tmp_query);
144 return PMINFO_R_ERROR;
149 static int _appinfo_get_category(sqlite3 *db, const char *appid,
152 static const char query_raw[] =
153 "SELECT category FROM package_app_app_category WHERE app_id=%Q";
159 query = sqlite3_mprintf(query_raw, appid);
161 LOGE("out of memory");
162 return PMINFO_R_ERROR;
165 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
167 if (ret != SQLITE_OK) {
168 LOGE("prepare failed: %s", sqlite3_errmsg(db));
169 return PMINFO_R_ERROR;
172 while (sqlite3_step(stmt) == SQLITE_ROW) {
174 _save_column_str(stmt, 0, &val);
176 *category = g_list_append(*category, (gpointer)val);
179 sqlite3_finalize(stmt);
184 static void __parse_appcontrol(GList **appcontrol, char *appcontrol_str)
191 if (appcontrol_str == NULL)
194 dup = strdup(appcontrol_str);
196 ac = calloc(1, sizeof(appcontrol_x));
198 _LOGE("out of memory");
201 token = strtok_r(dup, "|", &ptr);
202 if (token && strcmp(token, "NULL"))
203 ac->operation = strdup(token);
204 token = strtok_r(NULL, "|", &ptr);
205 if (token && strcmp(token, "NULL"))
206 ac->uri = strdup(token);
207 token = strtok_r(NULL, "|", &ptr);
208 if (token && strcmp(token, "NULL"))
209 ac->mime = strdup(token);
210 *appcontrol = g_list_append(*appcontrol, ac);
211 } while ((token = strtok_r(NULL, ";", &ptr)));
216 static int _appinfo_get_app_control(sqlite3 *db, const char *appid,
219 static const char query_raw[] =
220 "SELECT app_control FROM package_app_app_control "
227 query = sqlite3_mprintf(query_raw, appid);
229 LOGE("out of memory");
230 return PMINFO_R_ERROR;
233 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
235 if (ret != SQLITE_OK) {
236 LOGE("prepare failed: %s", sqlite3_errmsg(db));
237 return PMINFO_R_ERROR;
240 while (sqlite3_step(stmt) == SQLITE_ROW) {
242 _save_column_str(stmt, 0, &str);
244 __parse_appcontrol(appcontrol, str);
248 sqlite3_finalize(stmt);
253 static int _appinfo_get_data_control(sqlite3 *db, const char *appid,
256 static const char query_raw[] =
257 "SELECT providerid, access, type "
258 "FROM package_app_data_control WHERE app_id=%Q";
265 query = sqlite3_mprintf(query_raw, appid);
267 LOGE("out of memory");
268 return PMINFO_R_ERROR;
271 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
273 if (ret != SQLITE_OK) {
274 LOGE("prepare failed: %s", sqlite3_errmsg(db));
275 return PMINFO_R_ERROR;
278 while (sqlite3_step(stmt) == SQLITE_ROW) {
279 info = calloc(1, sizeof(datacontrol_x));
281 LOGE("out of memory");
282 sqlite3_finalize(stmt);
283 return PMINFO_R_ERROR;
286 _save_column_str(stmt, idx++, &info->providerid);
287 _save_column_str(stmt, idx++, &info->access);
288 _save_column_str(stmt, idx++, &info->type);
289 *datacontrol = g_list_append(*datacontrol, info);
292 sqlite3_finalize(stmt);
297 static int _appinfo_get_metadata(sqlite3 *db, const char *appid,
300 static const char query_raw[] =
301 "SELECT md_key, md_value "
302 "FROM package_app_app_metadata WHERE app_id=%Q";
309 query = sqlite3_mprintf(query_raw, appid);
311 LOGE("out of memory");
312 return PMINFO_R_ERROR;
315 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
317 if (ret != SQLITE_OK) {
318 LOGE("prepare failed: %s", sqlite3_errmsg(db));
319 return PMINFO_R_ERROR;
322 while (sqlite3_step(stmt) == SQLITE_ROW) {
323 info = calloc(1, sizeof(metadata_x));
325 LOGE("out of memory");
326 sqlite3_finalize(stmt);
327 return PMINFO_R_ERROR;
330 _save_column_str(stmt, idx++, &info->key);
331 _save_column_str(stmt, idx++, &info->value);
332 *metadata = g_list_append(*metadata, info);
335 sqlite3_finalize(stmt);
341 static int _appinfo_get_splashscreens(sqlite3 *db, const char *appid,
342 GList **splashscreens)
344 static const char query_raw[] =
345 "SELECT src, type, orientation, indicatordisplay, operation, color_depth "
346 "FROM package_app_splash_screen WHERE app_id=%Q";
351 splashscreen_x *info;
353 query = sqlite3_mprintf(query_raw, appid);
355 LOGE("out of memory");
356 return PMINFO_R_ERROR;
359 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
361 if (ret != SQLITE_OK) {
362 LOGE("prepare failed: %s", sqlite3_errmsg(db));
363 return PMINFO_R_ERROR;
366 while (sqlite3_step(stmt) == SQLITE_ROW) {
367 info = calloc(1, sizeof(splashscreen_x));
369 LOGE("out of memory");
370 sqlite3_finalize(stmt);
371 return PMINFO_R_ERROR;
374 _save_column_str(stmt, idx++, &info->src);
375 _save_column_str(stmt, idx++, &info->type);
376 _save_column_str(stmt, idx++, &info->orientation);
377 _save_column_str(stmt, idx++, &info->indicatordisplay);
378 _save_column_str(stmt, idx++, &info->operation);
379 _save_column_str(stmt, idx++, &info->color_depth);
380 *splashscreens = g_list_append(*splashscreens, info);
383 sqlite3_finalize(stmt);
388 static GList *__get_background_category(const char *value)
390 GList *category_list = NULL;
391 int convert_value = 0;
392 if (!value || strlen(value) == 0)
395 convert_value = atoi(value);
396 if (convert_value < 0)
399 if (convert_value & APP_BG_CATEGORY_USER_DISABLE_TRUE_VAL)
400 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_USER_DISABLE_TRUE_STR));
402 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_USER_DISABLE_FALSE_STR));
404 if (convert_value & APP_BG_CATEGORY_MEDIA_VAL)
405 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_MEDIA_STR));
407 if (convert_value & APP_BG_CATEGORY_DOWNLOAD_VAL)
408 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_DOWNLOAD_STR));
410 if (convert_value & APP_BG_CATEGORY_BGNETWORK_VAL)
411 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_BGNETWORK_STR));
413 if (convert_value & APP_BG_CATEGORY_LOCATION_VAL)
414 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_LOCATION_STR));
416 if (convert_value & APP_BG_CATEGORY_SENSOR_VAL)
417 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_SENSOR_STR));
419 if (convert_value & APP_BG_CATEGORY_IOTCOMM_VAL)
420 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_IOTCOMM_STR));
422 if (convert_value & APP_BG_CATEGORY_SYSTEM_VAL)
423 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_SYSTEM));
425 return category_list;
429 static int __get_appinfo_for_uid(sqlite3 *db, application_x *info, uid_t uid)
431 static const char query_raw[] =
432 "SELECT is_splash_screen_enabled, is_disabled "
433 "FROM package_app_info_for_uid WHERE app_id='%s' AND uid='%d'";
436 char *is_disabled = NULL;
439 query = sqlite3_mprintf(query_raw, info->appid, uid);
441 LOGE("out of memory");
442 return PMINFO_R_ERROR;
445 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
447 if (ret != SQLITE_OK) {
448 LOGE("sqlite3_prepare_v2() failed: %s", sqlite3_errmsg(db));
449 return PMINFO_R_ERROR;
452 while (sqlite3_step(stmt) == SQLITE_ROW) {
453 if (info->splash_screen_display)
454 free(info->splash_screen_display);
455 _save_column_str(stmt, 0, &info->splash_screen_display);
456 if (strcasecmp(info->is_disabled, "false") == 0) {
457 _save_column_str(stmt, 1, &is_disabled);
458 if (strcasecmp(is_disabled, "true") == 0) {
459 free(info->is_disabled);
460 info->is_disabled = is_disabled;
467 sqlite3_finalize(stmt);
471 static void __free_applications(gpointer data)
473 pkgmgrinfo_basic_free_application((application_x *)data);
476 static gint __app_disable_chk_func(gconstpointer data1, gconstpointer data2)
478 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)data1;
480 if (node->prop == E_PMINFO_APPINFO_PROP_APP_DISABLE)
486 static bool __check_disable_filter_exist(pkgmgrinfo_filter_x *filter)
493 link = g_slist_find_custom(filter->list, NULL, __app_disable_chk_func);
500 static int __bind_params(sqlite3_stmt *stmt, GList *params)
502 GList *tmp_list = NULL;
506 if (stmt == NULL || params == NULL)
507 return PMINFO_R_EINVAL;
511 ret = sqlite3_bind_text(stmt, ++idx, (char *)tmp_list->data, -1, SQLITE_STATIC);
512 if (ret != SQLITE_OK)
513 return PMINFO_R_ERROR;
514 tmp_list = tmp_list->next;
520 static bool __check_app_storage_status(pkgmgrinfo_filter_x *tmp_filter)
522 GSList *tmp_list = NULL;
523 pkgmgrinfo_node_x *tmp_node = NULL;
526 if (tmp_filter == NULL)
529 property = _pminfo_appinfo_convert_to_prop_bool(PMINFO_APPINFO_PROP_APP_CHECK_STORAGE);
530 for (tmp_list = tmp_filter->list; tmp_list != NULL;
531 tmp_list = g_slist_next(tmp_list)) {
532 tmp_node = (pkgmgrinfo_node_x *)tmp_list->data;
533 if (property == tmp_node->prop) {
534 if (strcmp(tmp_node->value, "true") == 0)
544 static int _appinfo_get_applications(uid_t db_uid, uid_t uid,
545 const char *locale, pkgmgrinfo_filter_x *filter, int flag,
546 GHashTable *applications)
548 static const char query_raw[] =
549 "SELECT DISTINCT ai.app_id, ai.app_component, ai.app_exec, "
550 "ai.app_nodisplay, ai.app_type, ai.app_onboot, "
551 "ai.app_multiple, ai.app_autorestart, ai.app_taskmanage, "
552 "ai.app_hwacceleration, ai.app_screenreader, "
553 "ai.app_mainapp, ai.app_recentimage, ai.app_launchcondition, "
554 "ai.app_indicatordisplay, ai.app_portraitimg, "
555 "ai.app_landscapeimg, ai.app_guestmodevisibility, "
556 "ai.app_permissiontype, ai.app_preload, ai.app_submode, "
557 "ai.app_submode_mainid, ai.app_launch_mode, ai.app_ui_gadget, "
558 "ai.app_support_disable, ai.app_process_pool, "
559 "ai.app_installed_storage, ai.app_background_category, "
560 "ai.app_package_type, ai.app_root_path, ai.app_api_version, "
561 "ai.app_effective_appid, ai.app_disable, "
562 "ai.app_splash_screen_display, ai.app_tep_name, "
563 "ai.app_zip_mount_file, ai.component_type, ai.package, "
564 "ai.app_external_path, ai.app_package_system, ai.app_removable, "
565 "ai.app_package_installed_time, ai.app_support_mode, "
566 "ai.app_support_ambient, ai.app_setup_appid";
567 static const char query_label[] =
569 "(SELECT app_label FROM package_app_localized_info WHERE ai.app_id=app_id AND app_locale=?), "
570 "(SELECT app_label FROM package_app_localized_info WHERE ai.app_id=app_id AND app_locale='No Locale'))";
571 static const char query_icon[] =
573 "(SELECT app_icon FROM package_app_localized_info WHERE ai.app_id=app_id AND app_locale=?), "
574 "(SELECT app_icon FROM package_app_localized_info WHERE ai.app_id=app_id AND app_locale='No Locale'))";
575 static const char query_from_clause[] = " FROM package_app_info as ai";
576 int ret = PMINFO_R_ERROR;
580 char *bg_category_str = NULL;
581 char *constraint = NULL;
582 char *tmp_record = NULL;
583 char query[MAX_QUERY_LEN] = { '\0' };
584 application_x *info = NULL;
585 GList *bind_params = NULL;
587 sqlite3_stmt *stmt = NULL;
588 bool is_check_storage = true;
590 dbpath = getUserPkgParserDBPathUID(db_uid);
592 return PMINFO_R_ERROR;
594 ret = __open_db(dbpath, &db, SQLITE_OPEN_READONLY);
595 if (ret != SQLITE_OK) {
596 _LOGE("failed to open db: %d", ret);
598 return PMINFO_R_ERROR;
602 len = strlen(query_raw);
603 snprintf(query, MAX_QUERY_LEN - 1, "%s", query_raw);
604 if (flag & PMINFO_APPINFO_GET_LABEL) {
605 strncat(query, query_label, MAX_QUERY_LEN - len - 1);
606 len += strlen(query_label);
607 bind_params = g_list_append(bind_params, strdup(locale));
609 if (flag & PMINFO_APPINFO_GET_ICON) {
610 strncat(query, query_icon, MAX_QUERY_LEN - len - 1);
611 len += strlen(query_icon);
612 bind_params = g_list_append(bind_params, strdup(locale));
615 is_check_storage = __check_app_storage_status(filter);
617 ret = _get_filtered_query(filter, locale, uid, &constraint, &bind_params);
618 if (ret != PMINFO_R_OK) {
619 LOGE("Failed to get WHERE clause");
622 strncat(query, query_from_clause, MAX_QUERY_LEN - len - 1);
623 len += strlen(query_from_clause);
626 strncat(query, constraint, MAX_QUERY_LEN - len - 1);
628 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
629 if (ret != SQLITE_OK) {
630 LOGE("prepare failed: %s", sqlite3_errmsg(db));
631 ret = PMINFO_R_ERROR;
635 if (g_list_length(bind_params) != 0) {
636 ret = __bind_params(stmt, bind_params);
637 if (ret != SQLITE_OK) {
638 LOGE("Failed to bind parameters");
643 while (sqlite3_step(stmt) == SQLITE_ROW) {
644 info = calloc(1, sizeof(application_x));
646 LOGE("out of memory");
647 ret = PMINFO_R_ERROR;
651 _save_column_str(stmt, idx++, &info->appid);
652 if (g_hash_table_contains(applications,
653 (gconstpointer)info->appid)) {
659 _save_column_str(stmt, idx++, &info->component);
660 _save_column_str(stmt, idx++, &info->exec);
661 _save_column_str(stmt, idx++, &info->nodisplay);
662 _save_column_str(stmt, idx++, &info->type);
663 _save_column_str(stmt, idx++, &info->onboot);
664 _save_column_str(stmt, idx++, &info->multiple);
665 _save_column_str(stmt, idx++, &info->autorestart);
666 _save_column_str(stmt, idx++, &info->taskmanage);
667 _save_column_str(stmt, idx++, &info->hwacceleration);
668 _save_column_str(stmt, idx++, &info->screenreader);
669 _save_column_str(stmt, idx++, &info->mainapp);
670 _save_column_str(stmt, idx++, &info->recentimage);
671 _save_column_str(stmt, idx++, &info->launchcondition);
672 _save_column_str(stmt, idx++, &info->indicatordisplay);
673 _save_column_str(stmt, idx++, &info->portraitimg);
674 _save_column_str(stmt, idx++, &info->landscapeimg);
675 _save_column_str(stmt, idx++, &info->guestmode_visibility);
676 _save_column_str(stmt, idx++, &info->permission_type);
677 _save_column_str(stmt, idx++, &info->preload);
678 _save_column_str(stmt, idx++, &info->submode);
679 _save_column_str(stmt, idx++, &info->submode_mainid);
680 _save_column_str(stmt, idx++, &info->launch_mode);
681 _save_column_str(stmt, idx++, &info->ui_gadget);
682 _save_column_str(stmt, idx++, &info->support_disable);
683 _save_column_str(stmt, idx++, &info->process_pool);
684 _save_column_str(stmt, idx++, &info->installed_storage);
685 _save_column_str(stmt, idx++, &bg_category_str);
686 _save_column_str(stmt, idx++, &info->package_type);
687 _save_column_str(stmt, idx++, &info->root_path);
688 _save_column_str(stmt, idx++, &info->api_version);
689 _save_column_str(stmt, idx++, &info->effective_appid);
690 _save_column_str(stmt, idx++, &info->is_disabled);
691 _save_column_str(stmt, idx++, &info->splash_screen_display);
692 _save_column_str(stmt, idx++, &info->tep_name);
693 _save_column_str(stmt, idx++, &info->zip_mount_file);
694 _save_column_str(stmt, idx++, &info->component_type);
695 _save_column_str(stmt, idx++, &info->package);
696 _save_column_str(stmt, idx++, &info->external_path);
697 _save_column_str(stmt, idx++, &info->package_system);
698 _save_column_str(stmt, idx++, &info->removable);
699 _save_column_str(stmt, idx++, &info->package_installed_time);
700 _save_column_str(stmt, idx++, &info->support_mode);
701 _save_column_str(stmt, idx++, &info->support_ambient);
702 _save_column_str(stmt, idx++, &info->setup_appid);
704 info->for_all_users =
705 strdup((db_uid != GLOBAL_USER) ? "false" : "true");
707 if (db_uid == GLOBAL_USER) {
708 ret = __get_appinfo_for_uid(db, info, uid);
709 if (ret != PMINFO_R_OK) {
710 LOGI("Failed to get appinfo for given uid[%d]", (int)uid);
711 pkgmgrinfo_basic_free_application(info);
717 info->background_category = __get_background_category(
719 free(bg_category_str);
721 if (flag & PMINFO_APPINFO_GET_LABEL) {
723 _save_column_str(stmt, idx++, &tmp_record);
724 if (_add_label_info_into_list(locale, tmp_record, &info->label)) {
725 ret = PMINFO_R_ERROR;
730 if (flag & PMINFO_APPINFO_GET_ICON) {
732 _save_column_str(stmt, idx++, &tmp_record);
733 if (_add_icon_info_into_list(locale, tmp_record, &info->icon)) {
734 ret = PMINFO_R_ERROR;
739 if (flag & PMINFO_APPINFO_GET_CATEGORY) {
740 if (_appinfo_get_category(db, info->appid,
742 ret = PMINFO_R_ERROR;
747 if (flag & PMINFO_APPINFO_GET_APP_CONTROL) {
748 if (_appinfo_get_app_control(db, info->appid,
749 &info->appcontrol)) {
750 ret = PMINFO_R_ERROR;
755 if (flag & PMINFO_APPINFO_GET_DATA_CONTROL) {
756 if (_appinfo_get_data_control(db, info->appid,
757 &info->datacontrol)) {
758 ret = PMINFO_R_ERROR;
763 if (flag & PMINFO_APPINFO_GET_METADATA) {
764 if (_appinfo_get_metadata(db, info->appid,
766 ret = PMINFO_R_ERROR;
771 if (flag & PMINFO_APPINFO_GET_SPLASH_SCREEN) {
772 if (_appinfo_get_splashscreens(db, info->appid,
773 &info->splashscreens)) {
774 ret = PMINFO_R_ERROR;
779 if (is_check_storage &&
780 __appinfo_check_installed_storage(info) != PMINFO_R_OK) {
781 ret = PMINFO_R_ERROR;
782 pkgmgrinfo_basic_free_application(info);
787 g_hash_table_insert(applications, (gpointer)info->appid,
797 if (ret != PMINFO_R_OK && info != NULL)
798 pkgmgrinfo_basic_free_application(info);
800 g_list_free_full(bind_params, free);
801 sqlite3_close_v2(db);
802 sqlite3_finalize(stmt);
807 static int _pkgmgrinfo_get_appinfo(const char *appid, uid_t uid,
808 pkgmgrinfo_appinfo_filter_h filter, pkgmgrinfo_appinfo_h *handle)
813 pkgmgr_appinfo_x *info;
815 if (appid == NULL || filter == NULL || handle == NULL) {
816 LOGE("invalid parameter");
817 return PMINFO_R_EINVAL;
820 locale = _get_system_locale();
822 return PMINFO_R_ERROR;
824 list = g_hash_table_new(g_str_hash, g_str_equal);
827 return PMINFO_R_ERROR;
830 ret = _appinfo_get_applications(uid, uid, locale, filter,
831 PMINFO_APPINFO_GET_ALL, list);
832 if (!g_hash_table_size(list) && uid != GLOBAL_USER)
833 ret = _appinfo_get_applications(GLOBAL_USER, uid, locale, filter,
834 PMINFO_APPINFO_GET_ALL, list);
836 if (!g_hash_table_size(list)) {
837 _LOGI("appinfo for [%s] is not existed for user [%d]",
839 g_hash_table_destroy(list);
841 return PMINFO_R_ENOENT;
844 info = calloc(1, sizeof(pkgmgr_appinfo_x));
846 _LOGE("out of memory");
847 g_hash_table_destroy(list);
849 return PMINFO_R_ERROR;
852 info->app_info = (application_x *)g_hash_table_lookup(list, appid);
853 info->locale = locale;
854 info->package = strdup(info->app_info->package);
856 /* just free list only */
857 g_hash_table_destroy(list);
864 API int pkgmgrinfo_appinfo_get_usr_disabled_appinfo(const char *appid, uid_t uid,
865 pkgmgrinfo_appinfo_h *handle)
868 pkgmgrinfo_appinfo_filter_h filter;
870 if (appid == NULL || handle == NULL) {
871 LOGE("invalid parameter");
872 return PMINFO_R_EINVAL;
875 ret = pkgmgrinfo_appinfo_filter_create(&filter);
876 if (ret != PMINFO_R_OK)
879 ret = pkgmgrinfo_appinfo_filter_add_string(filter,
880 PMINFO_APPINFO_PROP_APP_ID, appid);
881 if (ret != PMINFO_R_OK) {
882 pkgmgrinfo_appinfo_filter_destroy(filter);
883 return PMINFO_R_ERROR;
886 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
887 PMINFO_APPINFO_PROP_APP_DISABLE, true);
888 if (ret != PMINFO_R_OK) {
889 pkgmgrinfo_appinfo_filter_destroy(filter);
890 return PMINFO_R_ERROR;
893 ret = _pkgmgrinfo_get_appinfo(appid, uid, filter, handle);
894 pkgmgrinfo_appinfo_filter_destroy(filter);
899 API int pkgmgrinfo_appinfo_get_disabled_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
901 return pkgmgrinfo_appinfo_get_usr_disabled_appinfo(appid, _getuid(), handle);
904 API int pkgmgrinfo_appinfo_get_usr_appinfo(const char *appid, uid_t uid,
905 pkgmgrinfo_appinfo_h *handle)
908 pkgmgrinfo_appinfo_filter_h filter;
910 if (appid == NULL || handle == NULL) {
911 LOGE("invalid parameter");
912 return PMINFO_R_EINVAL;
915 ret = pkgmgrinfo_appinfo_filter_create(&filter);
916 if (ret != PMINFO_R_OK)
919 ret = pkgmgrinfo_appinfo_filter_add_string(filter,
920 PMINFO_APPINFO_PROP_APP_ID, appid);
921 if (ret != PMINFO_R_OK) {
922 pkgmgrinfo_appinfo_filter_destroy(filter);
923 return PMINFO_R_ERROR;
926 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
927 PMINFO_APPINFO_PROP_APP_DISABLE, false);
928 if (ret != PMINFO_R_OK) {
929 pkgmgrinfo_appinfo_filter_destroy(filter);
930 return PMINFO_R_ERROR;
933 ret = _pkgmgrinfo_get_appinfo(appid, uid, filter, handle);
934 pkgmgrinfo_appinfo_filter_destroy(filter);
938 API int pkgmgrinfo_appinfo_get_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
940 return pkgmgrinfo_appinfo_get_usr_appinfo(appid, _getuid(), handle);
943 API int pkgmgrinfo_appinfo_get_usr_all_appinfo(const char *appid, uid_t uid,
944 pkgmgrinfo_appinfo_h *handle)
947 pkgmgrinfo_appinfo_filter_h filter;
949 if (appid == NULL || handle == NULL) {
950 LOGE("invalid parameter");
951 return PMINFO_R_EINVAL;
954 ret = pkgmgrinfo_appinfo_filter_create(&filter);
955 if (ret != PMINFO_R_OK)
958 ret = pkgmgrinfo_appinfo_filter_add_string(filter,
959 PMINFO_APPINFO_PROP_APP_ID, appid);
960 if (ret != PMINFO_R_OK) {
961 pkgmgrinfo_appinfo_filter_destroy(filter);
962 return PMINFO_R_ERROR;
965 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
966 PMINFO_APPINFO_PROP_APP_CHECK_STORAGE, false);
967 if (ret != PMINFO_R_OK) {
968 pkgmgrinfo_appinfo_filter_destroy(filter);
969 return PMINFO_R_ERROR;
972 ret = _pkgmgrinfo_get_appinfo(appid, uid, filter, handle);
973 pkgmgrinfo_appinfo_filter_destroy(filter);
978 API int pkgmgrinfo_appinfo_get_all_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
980 return pkgmgrinfo_appinfo_get_usr_all_appinfo(appid, _getuid(), handle);
983 static gpointer __copy_str(gconstpointer src, gpointer data)
985 const char *tmp = (const char *)src;
988 buffer = strdup(tmp);
989 if (buffer == NULL) {
990 LOGE("memory alloc failed");
998 static gpointer __copy_label(gconstpointer src, gpointer data)
1000 label_x *tmp = (label_x *)src;
1003 label = calloc(1, sizeof(label_x));
1004 if (label == NULL) {
1005 LOGE("memory alloc failed");
1011 label->name = strdup(tmp->name);
1013 label->text = strdup(tmp->text);
1015 label->lang = strdup(tmp->lang);
1020 static gpointer __copy_icon(gconstpointer src, gpointer data)
1022 icon_x *tmp = (icon_x *)src;
1025 icon = calloc(1, sizeof(icon_x));
1027 LOGE("memory alloc failed");
1033 icon->text = strdup(tmp->text);
1035 icon->lang = strdup(tmp->lang);
1037 icon->section = strdup(tmp->section);
1039 icon->size = strdup(tmp->size);
1040 if (tmp->resolution)
1041 icon->resolution = strdup(tmp->resolution);
1046 static gpointer __copy_metadata(gconstpointer src, gpointer data)
1048 metadata_x *tmp = (metadata_x *)src;
1049 metadata_x *metadata;
1051 metadata = calloc(1, sizeof(metadata_x));
1052 if (metadata == NULL) {
1053 LOGE("memory alloc failed");
1059 metadata->key = strdup(tmp->key);
1061 metadata->value = strdup(tmp->value);
1066 static gpointer __copy_datacontrol(gconstpointer src, gpointer data)
1068 datacontrol_x *tmp = (datacontrol_x *)src;
1069 datacontrol_x *datacontrol;
1071 datacontrol = calloc(1, sizeof(datacontrol_x));
1072 if (datacontrol == NULL) {
1073 LOGE("memory alloc failed");
1078 if (tmp->providerid)
1079 datacontrol->providerid = strdup(tmp->providerid);
1081 datacontrol->access = strdup(tmp->access);
1083 datacontrol->type = strdup(tmp->type);
1088 static gpointer __copy_appcontrol(gconstpointer src, gpointer data)
1090 appcontrol_x *tmp = (appcontrol_x *)src;
1091 appcontrol_x *appcontrol;
1093 appcontrol = calloc(1, sizeof(appcontrol_x));
1094 if (appcontrol == NULL) {
1095 LOGE("memory alloc failed");
1101 appcontrol->operation = strdup(tmp->operation);
1103 appcontrol->uri = strdup(tmp->uri);
1105 appcontrol->mime = strdup(tmp->mime);
1110 static gpointer __copy_splashscreens(gconstpointer src, gpointer data)
1112 splashscreen_x *tmp = (splashscreen_x *)src;
1113 splashscreen_x *splashscreen;
1115 splashscreen = (splashscreen_x *)calloc(1, sizeof(splashscreen_x));
1116 if (splashscreen == NULL) {
1117 LOGE("memory alloc failed");
1123 splashscreen->src = strdup(tmp->src);
1125 splashscreen->type = strdup(tmp->type);
1126 if (tmp->orientation)
1127 splashscreen->orientation = strdup(tmp->orientation);
1128 if (tmp->indicatordisplay)
1129 splashscreen->indicatordisplay = strdup(tmp->indicatordisplay);
1131 splashscreen->operation = strdup(tmp->operation);
1132 if (tmp->color_depth)
1133 splashscreen->color_depth = strdup(tmp->color_depth);
1135 return splashscreen;
1138 static int _appinfo_copy_appinfo(application_x **application, application_x *data)
1140 application_x *app_info;
1143 app_info = calloc(1, sizeof(application_x));
1144 if (app_info == NULL) {
1145 LOGE("memory alloc failed");
1146 return PMINFO_R_ERROR;
1149 if (data->appid != NULL)
1150 app_info->appid = strdup(data->appid);
1151 if (data->exec != NULL)
1152 app_info->exec = strdup(data->exec);
1153 if (data->nodisplay != NULL)
1154 app_info->nodisplay = strdup(data->nodisplay);
1155 if (data->multiple != NULL)
1156 app_info->multiple = strdup(data->multiple);
1157 if (data->taskmanage != NULL)
1158 app_info->taskmanage = strdup(data->taskmanage);
1159 if (data->type != NULL)
1160 app_info->type = strdup(data->type);
1161 if (data->categories != NULL)
1162 app_info->categories = strdup(data->categories);
1163 if (data->hwacceleration != NULL)
1164 app_info->hwacceleration = strdup(data->hwacceleration);
1165 if (data->screenreader != NULL)
1166 app_info->screenreader = strdup(data->screenreader);
1167 if (data->mainapp != NULL)
1168 app_info->mainapp = strdup(data->mainapp);
1169 if (data->package != NULL)
1170 app_info->package = strdup(data->package);
1171 if (data->recentimage != NULL)
1172 app_info->recentimage = strdup(data->recentimage);
1173 if (data->launchcondition != NULL)
1174 app_info->launchcondition = strdup(data->launchcondition);
1175 if (data->indicatordisplay != NULL)
1176 app_info->indicatordisplay = strdup(data->indicatordisplay);
1177 if (data->portraitimg != NULL)
1178 app_info->portraitimg = strdup(data->portraitimg);
1179 if (data->landscapeimg != NULL)
1180 app_info->landscapeimg = strdup(data->landscapeimg);
1181 if (data->guestmode_visibility != NULL)
1182 app_info->guestmode_visibility = strdup(data->guestmode_visibility);
1183 if (data->component != NULL)
1184 app_info->component = strdup(data->component);
1185 if (data->permission_type != NULL)
1186 app_info->permission_type = strdup(data->permission_type);
1187 if (data->component_type != NULL)
1188 app_info->component_type = strdup(data->component_type);
1189 if (data->preload != NULL)
1190 app_info->preload = strdup(data->preload);
1191 if (data->submode != NULL)
1192 app_info->submode = strdup(data->submode);
1193 if (data->submode_mainid != NULL)
1194 app_info->submode_mainid = strdup(data->submode_mainid);
1195 if (data->process_pool != NULL)
1196 app_info->process_pool = strdup(data->process_pool);
1197 if (data->installed_storage != NULL)
1198 app_info->installed_storage = strdup(data->installed_storage);
1199 if (data->autorestart != NULL)
1200 app_info->autorestart = strdup(data->autorestart);
1201 if (data->onboot != NULL)
1202 app_info->onboot = strdup(data->onboot);
1203 if (data->support_disable != NULL)
1204 app_info->support_disable = strdup(data->support_disable);
1205 if (data->ui_gadget != NULL)
1206 app_info->ui_gadget = strdup(data->ui_gadget);
1207 if (data->launch_mode != NULL)
1208 app_info->launch_mode = strdup(data->launch_mode);
1209 if (data->package_type != NULL)
1210 app_info->package_type = strdup(data->package_type);
1211 if (data->effective_appid != NULL)
1212 app_info->effective_appid = strdup(data->effective_appid);
1213 if (data->splash_screen_display != NULL)
1214 app_info->splash_screen_display = strdup(data->splash_screen_display);
1218 app_info->label = g_list_copy_deep(data->label, __copy_label, &ret);
1220 LOGE("memory alloc failed");
1221 pkgmgrinfo_basic_free_application(app_info);
1222 return PMINFO_R_ERROR;
1226 app_info->icon = g_list_copy_deep(data->icon, __copy_icon, &ret);
1228 LOGE("memory alloc failed");
1229 pkgmgrinfo_basic_free_application(app_info);
1230 return PMINFO_R_ERROR;
1234 app_info->category = g_list_copy_deep(data->category, __copy_str, &ret);
1236 LOGE("memory alloc failed");
1237 pkgmgrinfo_basic_free_application(app_info);
1238 return PMINFO_R_ERROR;
1242 app_info->metadata = g_list_copy_deep(data->metadata, __copy_metadata, &ret);
1244 LOGE("memory alloc failed");
1245 pkgmgrinfo_basic_free_application(app_info);
1246 return PMINFO_R_ERROR;
1250 app_info->datacontrol = g_list_copy_deep(data->datacontrol, __copy_datacontrol, &ret);
1252 LOGE("memory alloc failed");
1253 pkgmgrinfo_basic_free_application(app_info);
1254 return PMINFO_R_ERROR;
1258 app_info->appcontrol = g_list_copy_deep(data->appcontrol, __copy_appcontrol, &ret);
1260 LOGE("memory alloc failed");
1261 pkgmgrinfo_basic_free_application(app_info);
1262 return PMINFO_R_ERROR;
1266 app_info->background_category = g_list_copy_deep(data->background_category, __copy_str, &ret);
1268 LOGE("memory alloc failed");
1269 pkgmgrinfo_basic_free_application(app_info);
1270 return PMINFO_R_ERROR;
1274 app_info->splashscreens = g_list_copy_deep(data->splashscreens, __copy_splashscreens, &ret);
1276 LOGE("memory alloc failed");
1277 pkgmgrinfo_basic_free_application(app_info);
1278 return PMINFO_R_ERROR;
1281 *application = app_info;
1286 API int pkgmgrinfo_appinfo_clone_appinfo(pkgmgrinfo_appinfo_h handle,
1287 pkgmgrinfo_appinfo_h *clone)
1289 pkgmgr_appinfo_x *info;
1290 pkgmgr_appinfo_x *temp = (pkgmgr_appinfo_x *)handle;
1293 return PMINFO_R_EINVAL;
1295 info = calloc(1, sizeof(pkgmgr_appinfo_x));
1297 LOGE("memory alloc failed");
1298 return PMINFO_R_ERROR;
1301 if (temp->package != NULL)
1302 info->package = strdup(temp->package);
1303 if (temp->locale != NULL)
1304 info->locale = strdup(temp->locale);
1306 info->app_component = temp->app_component;
1308 if (_appinfo_copy_appinfo(&info->app_info, temp->app_info) < 0) {
1309 LOGE("appinfo copy failed");
1311 free((void *)info->package);
1315 return PMINFO_R_ERROR;
1323 static int _appinfo_get_filtered_foreach_appinfo(uid_t uid,
1324 pkgmgrinfo_filter_x *filter, int flag, pkgmgrinfo_app_list_cb app_list_cb,
1330 pkgmgr_appinfo_x info;
1332 GHashTableIter iter;
1335 locale = _get_system_locale();
1337 return PMINFO_R_ERROR;
1339 list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
1340 __free_applications);
1343 return PMINFO_R_ERROR;
1346 if (__check_disable_filter_exist(filter) == false) {
1347 pkgmgrinfo_appinfo_filter_add_bool(filter,
1348 PMINFO_APPINFO_PROP_APP_DISABLE, false);
1351 ret = _appinfo_get_applications(uid, uid, locale, filter, flag, list);
1352 if (ret == PMINFO_R_OK && uid != GLOBAL_USER)
1353 ret = _appinfo_get_applications(GLOBAL_USER, uid, locale,
1354 filter, flag, list);
1356 if (ret != PMINFO_R_OK) {
1357 g_hash_table_destroy(list);
1362 g_hash_table_iter_init(&iter, list);
1363 while (g_hash_table_iter_next(&iter, NULL, &value)) {
1364 app = (application_x *)value;
1365 info.app_info = app;
1366 info.locale = locale;
1367 info.package = app->package;
1368 if (app_list_cb(&info, user_data) < 0)
1371 g_hash_table_destroy(list);
1377 static const char *__appcomponent_str(pkgmgrinfo_app_component comp);
1379 API int pkgmgrinfo_appinfo_get_usr_list(pkgmgrinfo_pkginfo_h handle,
1380 pkgmgrinfo_app_component component,
1381 pkgmgrinfo_app_list_cb app_func, void *user_data, uid_t uid)
1384 pkgmgrinfo_appinfo_filter_h filter;
1386 const char *comp_str = NULL;
1388 if (handle == NULL || app_func == NULL) {
1389 LOGE("invalid parameter");
1390 return PMINFO_R_EINVAL;
1393 if (pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid)) {
1394 LOGE("invalid parameter");
1395 return PMINFO_R_EINVAL;
1398 if (pkgmgrinfo_appinfo_filter_create(&filter))
1399 return PMINFO_R_ERROR;
1401 if (pkgmgrinfo_appinfo_filter_add_string(filter,
1402 PMINFO_APPINFO_PROP_APP_PACKAGE, pkgid)) {
1403 pkgmgrinfo_appinfo_filter_destroy(filter);
1404 return PMINFO_R_ERROR;
1407 comp_str = __appcomponent_str(component);
1410 if (pkgmgrinfo_appinfo_filter_add_string(filter,
1411 PMINFO_APPINFO_PROP_APP_COMPONENT,
1413 pkgmgrinfo_appinfo_filter_destroy(filter);
1414 return PMINFO_R_ERROR;
1418 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter,
1419 PMINFO_APPINFO_GET_ALL, app_func, user_data);
1421 pkgmgrinfo_appinfo_filter_destroy(filter);
1426 API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle,
1427 pkgmgrinfo_app_component component,
1428 pkgmgrinfo_app_list_cb app_func, void *user_data)
1430 return pkgmgrinfo_appinfo_get_usr_list(handle, component, app_func, user_data, _getuid());
1433 API int pkgmgrinfo_appinfo_get_usr_installed_list_full(
1434 pkgmgrinfo_app_list_cb app_func, uid_t uid, int flag,
1438 pkgmgrinfo_appinfo_filter_h filter;
1440 if (app_func == NULL) {
1441 LOGE("invalid parameter");
1442 return PMINFO_R_EINVAL;
1445 if (pkgmgrinfo_appinfo_filter_create(&filter))
1446 return PMINFO_R_ERROR;
1448 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
1449 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
1450 pkgmgrinfo_appinfo_filter_destroy(filter);
1451 return PMINFO_R_ERROR;
1454 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
1455 PMINFO_APPINFO_PROP_APP_CHECK_STORAGE, false)) {
1456 pkgmgrinfo_appinfo_filter_destroy(filter);
1457 return PMINFO_R_ERROR;
1460 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter, flag, app_func,
1463 pkgmgrinfo_appinfo_filter_destroy(filter);
1468 API int pkgmgrinfo_appinfo_get_installed_list_full(
1469 pkgmgrinfo_app_list_cb app_func, int flag, void *user_data)
1471 return pkgmgrinfo_appinfo_get_usr_installed_list_full(app_func,
1472 _getuid(), flag, user_data);
1475 API int pkgmgrinfo_appinfo_get_usr_installed_list(
1476 pkgmgrinfo_app_list_cb app_func, uid_t uid, void *user_data)
1479 pkgmgrinfo_appinfo_filter_h filter;
1481 if (app_func == NULL) {
1482 LOGE("invalid parameter");
1483 return PMINFO_R_EINVAL;
1486 /* create an empty filter */
1487 ret = pkgmgrinfo_appinfo_filter_create(&filter);
1488 if (ret != PMINFO_R_OK)
1491 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter,
1492 PMINFO_APPINFO_GET_ALL, app_func, user_data);
1494 pkgmgrinfo_appinfo_filter_destroy(filter);
1499 API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func,
1502 return pkgmgrinfo_appinfo_get_usr_installed_list(app_func, _getuid(),
1506 API int pkgmgrinfo_appinfo_get_appid(pkgmgrinfo_appinfo_h handle, char **appid)
1508 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1510 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1511 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1513 if (info->app_info == NULL || info->app_info->appid == NULL)
1514 return PMINFO_R_ERROR;
1515 *appid = (char *)info->app_info->appid;
1520 API int pkgmgrinfo_appinfo_get_pkgname(pkgmgrinfo_appinfo_h handle, char **pkg_name)
1522 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1524 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1525 retvm_if(pkg_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1527 if (info->package == NULL)
1528 return PMINFO_R_ERROR;
1530 *pkg_name = (char *)info->package;
1535 API int pkgmgrinfo_appinfo_get_pkgid(pkgmgrinfo_appinfo_h handle, char **pkgid)
1537 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1539 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1540 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1542 if (info->package == NULL)
1543 return PMINFO_R_ERROR;
1545 *pkgid = (char *)info->package;
1550 API int pkgmgrinfo_appinfo_get_pkgtype(pkgmgrinfo_appinfo_h handle, char **pkgtype)
1552 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1553 retvm_if(pkgtype == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1554 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1556 *pkgtype = (char *)info->app_info->package_type;
1561 API int pkgmgrinfo_appinfo_get_exec(pkgmgrinfo_appinfo_h handle, char **exec)
1563 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1565 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1566 retvm_if(exec == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1568 if (info->app_info == NULL || info->app_info->exec == NULL)
1569 return PMINFO_R_ERROR;
1570 *exec = (char *)info->app_info->exec;
1576 API int pkgmgrinfo_appinfo_get_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1579 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1581 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1582 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1584 if (info->app_info == NULL)
1585 return PMINFO_R_ERROR;
1587 if (info->app_info->icon == NULL) {
1592 ptr = (icon_x *)info->app_info->icon->data;
1594 return PMINFO_R_ERROR;
1596 if (ptr->text == NULL)
1597 return PMINFO_R_ERROR;
1605 API int pkgmgrinfo_appinfo_get_label(pkgmgrinfo_appinfo_h handle, char **label)
1608 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1610 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1611 retvm_if(label == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1613 if (info->app_info == NULL || info->app_info->label == NULL)
1614 return PMINFO_R_ERROR;
1616 ptr = (label_x *)info->app_info->label->data;
1618 return PMINFO_R_ERROR;
1620 if (ptr->text == NULL)
1621 return PMINFO_R_ERROR;
1628 static char *_get_localed_label(const char *appid, const char *locale, uid_t uid)
1630 char *result = NULL;
1632 sqlite3_stmt *stmt = NULL;
1637 parser_db = getUserPkgParserDBPathUID(uid);
1638 if (parser_db == NULL) {
1639 _LOGE("Failed to get parser db path");
1643 if (__open_db(parser_db, &db, SQLITE_OPEN_READONLY) != SQLITE_OK) {
1644 _LOGE("DB open fail\n");
1650 query = sqlite3_mprintf("select app_label from package_app_localized_info where app_id=%Q and app_locale=%Q", appid, locale);
1651 if (query == NULL) {
1652 _LOGE("Out of memory");
1656 if (sqlite3_prepare_v2(db, query, -1, &stmt, NULL) != SQLITE_OK) {
1657 _LOGE("prepare_v2 fail\n");
1661 if (sqlite3_step(stmt) == SQLITE_ROW) {
1662 val = (char *)sqlite3_column_text(stmt, 0);
1664 result = strdup(val);
1668 sqlite3_finalize(stmt);
1669 sqlite3_free(query);
1675 API int pkgmgrinfo_appinfo_usr_get_localed_label(const char *appid, const char *locale, uid_t uid, char **label)
1679 retvm_if(appid == NULL || locale == NULL || label == NULL, PMINFO_R_EINVAL, "Argument is NULL");
1681 val = _get_localed_label(appid, locale, uid);
1683 val = _get_localed_label(appid, DEFAULT_LOCALE, uid);
1686 val = _get_localed_label(appid, locale, GLOBAL_USER);
1688 val = _get_localed_label(appid, DEFAULT_LOCALE, GLOBAL_USER);
1692 return PMINFO_R_ERROR;
1699 API int pkgmgrinfo_appinfo_get_localed_label(const char *appid, const char *locale, char **label)
1701 return pkgmgrinfo_appinfo_usr_get_localed_label(appid, locale, _getuid(), label);
1704 API int pkgmgrinfo_appinfo_get_metadata_value(pkgmgrinfo_appinfo_h handle, const char *metadata_key, char **metadata_value)
1706 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1707 retvm_if(metadata_key == NULL, PMINFO_R_EINVAL, "metadata_key is NULL");
1708 retvm_if(metadata_value == NULL, PMINFO_R_EINVAL, "metadata_value is NULL");
1710 GList *list_md = NULL;
1711 metadata_x *metadata = NULL;
1712 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1714 list_md = info->app_info->metadata;
1716 for (; list_md; list_md = list_md->next) {
1717 metadata = (metadata_x *)list_md->data;
1718 if (metadata && metadata->key) {
1719 if (strcasecmp(metadata->key, metadata_key) == 0) {
1720 if (metadata->value == NULL)
1721 *metadata_value = "";
1723 *metadata_value = (char *)metadata->value;
1729 return PMINFO_R_EINVAL;
1732 static pkgmgrinfo_app_component __appcomponent_convert(const char *comp)
1734 if (strcasecmp(comp, "uiapp") == 0)
1735 return PMINFO_UI_APP;
1736 else if (strcasecmp(comp, "svcapp") == 0)
1737 return PMINFO_SVC_APP;
1738 else if (strcasecmp(comp, "widgetapp") == 0)
1739 return PMINFO_WIDGET_APP;
1740 else if (strcasecmp(comp, "watchapp") == 0)
1741 return PMINFO_WATCH_APP;
1746 static const char *__appcomponent_str(pkgmgrinfo_app_component comp)
1751 case PMINFO_SVC_APP:
1753 case PMINFO_WIDGET_APP:
1755 case PMINFO_WATCH_APP:
1762 API int pkgmgrinfo_appinfo_get_component(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_component *component)
1764 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1767 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1768 retvm_if(component == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1770 if (info->app_info == NULL)
1771 return PMINFO_R_ERROR;
1773 comp = __appcomponent_convert(info->app_info->component);
1775 return PMINFO_R_ERROR;
1782 API int pkgmgrinfo_appinfo_get_apptype(pkgmgrinfo_appinfo_h handle, char **app_type)
1784 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1786 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1787 retvm_if(app_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1789 if (info->app_info == NULL || info->app_info->type == NULL)
1790 return PMINFO_R_ERROR;
1791 *app_type = (char *)info->app_info->type;
1796 API int pkgmgrinfo_appinfo_get_operation(pkgmgrinfo_appcontrol_h handle,
1797 int *operation_count, char ***operation)
1799 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1800 retvm_if(operation == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1801 retvm_if(operation_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1802 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1803 *operation_count = data->operation_count;
1804 *operation = data->operation;
1808 API int pkgmgrinfo_appinfo_get_uri(pkgmgrinfo_appcontrol_h handle,
1809 int *uri_count, char ***uri)
1811 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1812 retvm_if(uri == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1813 retvm_if(uri_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1814 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1815 *uri_count = data->uri_count;
1820 API int pkgmgrinfo_appinfo_get_mime(pkgmgrinfo_appcontrol_h handle,
1821 int *mime_count, char ***mime)
1823 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1824 retvm_if(mime == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1825 retvm_if(mime_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1826 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1827 *mime_count = data->mime_count;
1832 API int pkgmgrinfo_appinfo_get_subapp(pkgmgrinfo_appcontrol_h handle,
1833 int *subapp_count, char ***subapp)
1835 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1836 retvm_if(subapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1837 retvm_if(subapp_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1838 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1839 *subapp_count = data->subapp_count;
1840 *subapp = data->subapp;
1844 API int pkgmgrinfo_appinfo_get_setting_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1849 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1851 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1852 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1854 if (info->app_info == NULL)
1855 return PMINFO_R_ERROR;
1857 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1858 ptr = (icon_x *)tmp->data;
1859 if (ptr == NULL || ptr->section == NULL)
1862 val = (char *)ptr->section;
1863 if (val && strcmp(val, "setting") == 0) {
1864 *icon = (char *)ptr->text;
1869 return PMINFO_R_ERROR;
1873 API int pkgmgrinfo_appinfo_get_notification_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1878 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1880 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1881 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1883 if (info->app_info == NULL)
1884 return PMINFO_R_ERROR;
1886 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1887 ptr = (icon_x *)tmp->data;
1888 if (ptr == NULL || ptr->section == NULL)
1891 val = (char *)ptr->section;
1892 if (val && strcmp(val, "notification") == 0) {
1893 *icon = (char *)ptr->text;
1898 return PMINFO_R_ERROR;
1901 API int pkgmgrinfo_appinfo_get_recent_image_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_recentimage *type)
1904 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1906 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1907 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1909 if (info->app_info == NULL || info->app_info->recentimage == NULL)
1910 return PMINFO_R_ERROR;
1912 val = (char *)info->app_info->recentimage;
1913 if (strcasecmp(val, "capture") == 0)
1914 *type = PMINFO_RECENTIMAGE_USE_CAPTURE;
1915 else if (strcasecmp(val, "icon") == 0)
1916 *type = PMINFO_RECENTIMAGE_USE_ICON;
1918 *type = PMINFO_RECENTIMAGE_USE_NOTHING;
1923 API int pkgmgrinfo_appinfo_get_preview_image(pkgmgrinfo_appinfo_h handle, char **preview_img)
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(preview_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1933 if (info->app_info == NULL)
1934 return PMINFO_R_ERROR;
1936 for (tmp = info->app_info->image; tmp; tmp = tmp->next) {
1937 ptr = (image_x *)tmp->data;
1938 if (ptr == NULL || ptr->section == NULL)
1941 val = (char *)ptr->section;
1942 if (val && strcmp(val, "preview") == 0) {
1943 *preview_img = (char *)ptr->text;
1948 return PMINFO_R_ERROR;
1951 API int pkgmgrinfo_appinfo_get_permission_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_permission_type *permission)
1954 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1956 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1957 retvm_if(permission == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1959 val = info->app_info->permission_type;
1961 return PMINFO_R_ERROR;
1963 if (strcmp(val, "signature") == 0)
1964 *permission = PMINFO_PERMISSION_SIGNATURE;
1965 else if (strcmp(val, "privilege") == 0)
1966 *permission = PMINFO_PERMISSION_PRIVILEGE;
1968 *permission = PMINFO_PERMISSION_NORMAL;
1973 API int pkgmgrinfo_appinfo_get_component_type(pkgmgrinfo_appinfo_h handle, char **component_type)
1975 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1977 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1978 retvm_if(component_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1980 if (info->app_info == NULL || info->app_info->component_type == NULL)
1981 return PMINFO_R_ERROR;
1983 *component_type = (char *)info->app_info->component_type;
1988 API int pkgmgrinfo_appinfo_get_hwacceleration(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_hwacceleration *hwacceleration)
1991 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1993 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1994 retvm_if(hwacceleration == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1996 if (info->app_info == NULL || info->app_info->hwacceleration == NULL)
1997 return PMINFO_R_ERROR;
1999 val = (char *)info->app_info->hwacceleration;
2000 if (strcasecmp(val, "off") == 0)
2001 *hwacceleration = PMINFO_HWACCELERATION_OFF;
2002 else if (strcasecmp(val, "on") == 0)
2003 *hwacceleration = PMINFO_HWACCELERATION_ON;
2005 *hwacceleration = PMINFO_HWACCELERATION_DEFAULT;
2010 API int pkgmgrinfo_appinfo_get_screenreader(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_screenreader *screenreader)
2013 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2015 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2016 retvm_if(screenreader == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2018 if (info->app_info == NULL || info->app_info->screenreader == NULL)
2019 return PMINFO_R_ERROR;
2021 val = (char *)info->app_info->screenreader;
2022 if (strcasecmp(val, "screenreader-off") == 0)
2023 *screenreader = PMINFO_SCREENREADER_OFF;
2024 else if (strcasecmp(val, "screenreader-on") == 0)
2025 *screenreader = PMINFO_SCREENREADER_ON;
2027 *screenreader = PMINFO_SCREENREADER_USE_SYSTEM_SETTING;
2032 API int pkgmgrinfo_appinfo_get_effectimage(pkgmgrinfo_appinfo_h handle, char **portrait_img, char **landscape_img)
2034 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2036 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2037 retvm_if(portrait_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2038 retvm_if(landscape_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2040 if (info->app_info == NULL)
2041 return PMINFO_R_ERROR;
2043 if (info->app_info->portraitimg == NULL)
2046 *portrait_img = (char *)info->app_info->portraitimg;
2048 if (info->app_info->landscapeimg == NULL)
2049 *landscape_img = "";
2051 *landscape_img = (char *)info->app_info->landscapeimg;
2056 API int pkgmgrinfo_appinfo_get_effectimage_type(pkgmgrinfo_appinfo_h handle, char **effectimage_type)
2058 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2060 if (handle == NULL || effectimage_type == NULL) {
2061 LOGE("invalid parameter");
2062 return PMINFO_R_EINVAL;
2065 if (info->app_info == NULL || info->app_info->effectimage_type == NULL)
2066 return PMINFO_R_ERROR;
2068 *effectimage_type = (char *)info->app_info->effectimage_type;
2073 API int pkgmgrinfo_appinfo_get_submode_mainid(pkgmgrinfo_appinfo_h handle, char **submode_mainid)
2075 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2077 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2078 retvm_if(submode_mainid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2080 if (info->app_info == NULL)
2081 return PMINFO_R_ERROR;
2083 if (info->app_info->submode_mainid == NULL)
2084 *submode_mainid = "";
2086 *submode_mainid = (char *)info->app_info->submode_mainid;
2091 API int pkgmgrinfo_appinfo_get_installed_storage_location(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_installed_storage *storage)
2093 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2094 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2096 if (info->app_info && info->app_info->installed_storage) {
2097 if (strcmp(info->app_info->installed_storage, "installed_internal") == 0)
2098 *storage = PMINFO_INTERNAL_STORAGE;
2099 else if (strcmp(info->app_info->installed_storage, "installed_external") == 0)
2100 *storage = PMINFO_EXTERNAL_STORAGE;
2102 return PMINFO_R_ERROR;
2104 return PMINFO_R_ERROR;
2110 API int pkgmgrinfo_appinfo_get_launch_mode(pkgmgrinfo_appinfo_h handle, char **mode)
2112 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2114 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2115 retvm_if(mode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2117 if (info->app_info->launch_mode == NULL)
2118 return PMINFO_R_ERROR;
2120 *mode = (char *)(info->app_info->launch_mode);
2125 API int pkgmgrinfo_appinfo_get_alias_appid(pkgmgrinfo_appinfo_h handle, char **alias_appid)
2127 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2129 if (handle == NULL || alias_appid == NULL) {
2130 LOGE("invalid parameter");
2131 return PMINFO_R_EINVAL;
2134 if (info->app_info == NULL || info->app_info->alias_appid == NULL)
2135 return PMINFO_R_ERROR;
2137 *alias_appid = (char *)info->app_info->alias_appid;
2142 API int pkgmgrinfo_appinfo_get_effective_appid(pkgmgrinfo_appinfo_h handle, char **effective_appid)
2144 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2146 if (handle == NULL || effective_appid == NULL) {
2147 LOGE("invalid parameter");
2148 return PMINFO_R_EINVAL;
2151 if (info->app_info == NULL)
2152 return PMINFO_R_ERROR;
2154 if (info->app_info->effective_appid == NULL)
2155 *effective_appid = "";
2157 *effective_appid = (char *)info->app_info->effective_appid;
2162 API int pkgmgrinfo_appinfo_get_tep_name(pkgmgrinfo_appinfo_h handle, char **tep_name)
2164 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2166 if (handle == NULL || tep_name == NULL) {
2167 LOGE("invalid parameter");
2168 return PMINFO_R_EINVAL;
2171 if (info->app_info == NULL)
2172 return PMINFO_R_ERROR;
2174 if (info->app_info->tep_name == NULL)
2177 *tep_name = (char *)info->app_info->tep_name;
2182 API int pkgmgrinfo_appinfo_get_zip_mount_file(pkgmgrinfo_appinfo_h handle, char **zip_mount_file)
2184 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2186 if (handle == NULL || zip_mount_file == NULL) {
2187 LOGE("invalid parameter");
2188 return PMINFO_R_EINVAL;
2191 if (info->app_info == NULL)
2192 return PMINFO_R_ERROR;
2194 if (info->app_info->zip_mount_file == NULL)
2195 *zip_mount_file = "";
2197 *zip_mount_file = (char *)info->app_info->zip_mount_file;
2202 API int pkgmgrinfo_appinfo_get_root_path(pkgmgrinfo_appinfo_h handle, char **root_path)
2204 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2206 if (handle == NULL || root_path == NULL) {
2207 LOGE("invalid parameter");
2208 return PMINFO_R_EINVAL;
2211 if (info->app_info == NULL || info->app_info->root_path == NULL)
2212 return PMINFO_R_ERROR;
2214 *root_path = (char *)info->app_info->root_path;
2219 API int pkgmgrinfo_appinfo_get_api_version(pkgmgrinfo_appinfo_h handle, char **api_version)
2221 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2223 if (handle == NULL || api_version == NULL) {
2224 LOGE("invalid parameter");
2225 return PMINFO_R_EINVAL;
2228 if (info->app_info == NULL || info->app_info->api_version == NULL)
2229 return PMINFO_R_ERROR;
2231 *api_version = (char *)info->app_info->api_version;
2236 API int pkgmgrinfo_appinfo_get_installed_time(pkgmgrinfo_appinfo_h handle, int *installed_time)
2238 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2240 if (handle == NULL || installed_time == NULL) {
2241 LOGE("invalid parameter");
2242 return PMINFO_R_EINVAL;
2245 if (info->app_info == NULL || info->app_info->package_installed_time == NULL)
2246 return PMINFO_R_ERROR;
2248 *installed_time = atoi(info->app_info->package_installed_time);
2253 API int pkgmgrinfo_appinfo_usr_get_datacontrol_info(const char *providerid, const char *type, uid_t uid, char **appid, char **access)
2255 retvm_if(providerid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
2256 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
2257 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2258 retvm_if(access == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2260 int ret = PMINFO_R_OK;
2262 sqlite3_stmt *stmt = NULL;
2265 ret = __open_manifest_db(uid, true);
2266 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
2268 /*Start constructing query*/
2269 query = sqlite3_mprintf("select * from package_app_data_control where providerid=%Q and type=%Q", providerid, type);
2270 tryvm_if(query == NULL, ret = PMINFO_R_ERROR, "Out of memory");
2273 ret = sqlite3_prepare_v2(GET_DB(manifest_db), query, strlen(query), &stmt, NULL);
2274 tryvm_if(ret != PMINFO_R_OK, ret = PMINFO_R_ERROR, "sqlite3_prepare_v2 failed[%s]\n", query);
2277 ret = sqlite3_step(stmt);
2278 tryvm_if((ret != SQLITE_ROW) || (ret == SQLITE_DONE), ret = PMINFO_R_ERROR, "No records found");
2280 *appid = strdup((char *)sqlite3_column_text(stmt, 0));
2281 *access = strdup((char *)sqlite3_column_text(stmt, 2));
2286 sqlite3_free(query);
2287 sqlite3_finalize(stmt);
2288 __close_manifest_db();
2292 API int pkgmgrinfo_appinfo_get_datacontrol_info(const char *providerid, const char *type, char **appid, char **access)
2294 return pkgmgrinfo_appinfo_usr_get_datacontrol_info(providerid, type, _getuid(), appid, access);
2297 API int pkgmgrinfo_appinfo_usr_get_datacontrol_appid(const char *providerid, uid_t uid, char **appid)
2299 retvm_if(providerid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
2300 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2302 int ret = PMINFO_R_OK;
2304 sqlite3_stmt *stmt = NULL;
2307 ret = __open_manifest_db(uid, true);
2308 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
2310 /*Start constructing query*/
2311 query = sqlite3_mprintf("select * from package_app_data_control where providerid=%Q", providerid);
2312 tryvm_if(query == NULL, ret = PMINFO_R_ERROR, "Out of memory");
2315 ret = sqlite3_prepare_v2(GET_DB(manifest_db), query, strlen(query), &stmt, NULL);
2316 tryvm_if(ret != PMINFO_R_OK, ret = PMINFO_R_ERROR, "sqlite3_prepare_v2 failed[%s]\n", query);
2319 ret = sqlite3_step(stmt);
2320 tryvm_if((ret != SQLITE_ROW) || (ret == SQLITE_DONE), ret = PMINFO_R_ERROR, "No records found");
2322 *appid = strdup((char *)sqlite3_column_text(stmt, 0));
2327 sqlite3_free(query);
2328 sqlite3_finalize(stmt);
2329 __close_manifest_db();
2333 API int pkgmgrinfo_appinfo_get_datacontrol_appid(const char *providerid, char **appid)
2335 return pkgmgrinfo_appinfo_usr_get_datacontrol_appid(providerid, _getuid(), appid);
2338 API int pkgmgrinfo_appinfo_get_support_mode(pkgmgrinfo_appinfo_h handle, int *support_mode)
2340 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2341 retvm_if(support_mode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2343 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2344 if (info->app_info->support_mode)
2345 *support_mode = atoi(info->app_info->support_mode);
2352 API int pkgmgrinfo_appinfo_foreach_permission(pkgmgrinfo_appinfo_h handle,
2353 pkgmgrinfo_app_permission_list_cb permission_func, void *user_data)
2355 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2356 retvm_if(permission_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
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->permission; tmp; tmp = tmp->next) {
2366 ptr = (permission_x *)tmp->data;
2370 ret = permission_func(ptr->value, user_data);
2378 API int pkgmgrinfo_appinfo_foreach_category(pkgmgrinfo_appinfo_h handle,
2379 pkgmgrinfo_app_category_list_cb category_func, void *user_data)
2381 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2382 retvm_if(category_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2384 const char *category;
2386 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2388 if (info->app_info == NULL)
2389 return PMINFO_R_ERROR;
2391 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
2392 category = (const char *)tmp->data;
2394 ret = category_func(category, user_data);
2402 API int pkgmgrinfo_appinfo_foreach_metadata(pkgmgrinfo_appinfo_h handle,
2403 pkgmgrinfo_app_metadata_list_cb metadata_func, void *user_data)
2405 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2406 retvm_if(metadata_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2410 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2412 if (info->app_info == NULL)
2413 return PMINFO_R_ERROR;
2415 for (tmp = info->app_info->metadata; tmp; tmp = tmp->next) {
2416 ptr = (metadata_x *)tmp->data;
2420 ret = metadata_func(ptr->key, ptr->value ? ptr->value : "", user_data);
2428 API int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
2429 pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
2431 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2432 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2434 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2435 appcontrol_x *appcontrol;
2438 if (info->app_info == NULL)
2439 return PMINFO_R_ERROR;
2441 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
2442 appcontrol = (appcontrol_x *)tmp->data;
2443 if (appcontrol == NULL)
2445 ret = appcontrol_func(appcontrol->operation, appcontrol->uri, appcontrol->mime, user_data);
2453 API int pkgmgrinfo_appinfo_foreach_background_category(
2454 pkgmgrinfo_appinfo_h handle,
2455 pkgmgrinfo_app_background_category_list_cb category_func,
2458 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2462 if (handle == NULL || category_func == NULL || info->app_info == NULL) {
2463 LOGE("invalid parameter");
2464 return PMINFO_R_EINVAL;
2467 for (tmp = info->app_info->background_category; tmp; tmp = tmp->next) {
2468 category = (char *)tmp->data;
2469 if (category == NULL)
2472 if (category_func(category, user_data) < 0)
2479 API int pkgmgrinfo_appinfo_foreach_splash_screen(pkgmgrinfo_appinfo_h handle,
2480 pkgmgrinfo_app_splash_screen_list_cb splash_screen_func,
2483 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2484 splashscreen_x *splashscreen;
2488 if (info == NULL || info->app_info == NULL
2489 || splash_screen_func == NULL) {
2490 LOGE("invalid parameter");
2491 return PMINFO_R_EINVAL;
2494 for (tmp = info->app_info->splashscreens; tmp; tmp = tmp->next) {
2495 splashscreen = (splashscreen_x *)tmp->data;
2496 if (splashscreen == NULL)
2498 ret = splash_screen_func(splashscreen->src,
2500 splashscreen->orientation,
2501 splashscreen->indicatordisplay,
2502 splashscreen->operation,
2503 splashscreen->color_depth,
2512 API int pkgmgrinfo_appinfo_is_nodisplay(pkgmgrinfo_appinfo_h handle, bool *nodisplay)
2514 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2515 retvm_if(nodisplay == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2516 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2518 if (info->app_info == NULL || info->app_info->nodisplay == NULL)
2519 return PMINFO_R_ERROR;
2521 *nodisplay = _get_bool_value(info->app_info->nodisplay);
2526 API int pkgmgrinfo_appinfo_is_multiple(pkgmgrinfo_appinfo_h handle, bool *multiple)
2528 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2529 retvm_if(multiple == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2530 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2532 if (info->app_info == NULL || info->app_info->multiple == NULL)
2533 return PMINFO_R_ERROR;
2535 *multiple = _get_bool_value(info->app_info->multiple);
2540 API int pkgmgrinfo_appinfo_is_indicator_display_allowed(pkgmgrinfo_appinfo_h handle, bool *indicator_disp)
2542 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2543 retvm_if(indicator_disp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2544 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2546 if (info->app_info == NULL || info->app_info->indicatordisplay == NULL)
2547 return PMINFO_R_ERROR;
2549 *indicator_disp = _get_bool_value(info->app_info->indicatordisplay);
2554 API int pkgmgrinfo_appinfo_is_taskmanage(pkgmgrinfo_appinfo_h handle, bool *taskmanage)
2556 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2557 retvm_if(taskmanage == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2558 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2560 if (info->app_info == NULL || info->app_info->taskmanage == NULL)
2561 return PMINFO_R_ERROR;
2563 *taskmanage = _get_bool_value(info->app_info->taskmanage);
2568 API int pkgmgrinfo_appinfo_is_enabled(pkgmgrinfo_appinfo_h handle, bool *enabled)
2570 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2571 retvm_if(enabled == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2572 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2574 if (info->app_info == NULL || info->app_info->is_disabled == NULL)
2575 return PMINFO_R_ERROR;
2577 *enabled = !_get_bool_value(info->app_info->is_disabled);
2582 API int pkgmgrinfo_appinfo_is_onboot(pkgmgrinfo_appinfo_h handle, bool *onboot)
2584 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2585 retvm_if(onboot == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2586 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2588 if (info->app_info == NULL || info->app_info->onboot == NULL)
2589 return PMINFO_R_ERROR;
2591 *onboot = _get_bool_value(info->app_info->onboot);
2596 API int pkgmgrinfo_appinfo_is_autorestart(pkgmgrinfo_appinfo_h handle, bool *autorestart)
2598 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2599 retvm_if(autorestart == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2600 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2602 if (info->app_info == NULL || info->app_info->autorestart == NULL)
2603 return PMINFO_R_ERROR;
2605 *autorestart = _get_bool_value(info->app_info->autorestart);
2610 API int pkgmgrinfo_appinfo_is_mainapp(pkgmgrinfo_appinfo_h handle, bool *mainapp)
2612 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2613 retvm_if(mainapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2614 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2616 if (info->app_info == NULL || info->app_info->mainapp == NULL)
2617 return PMINFO_R_ERROR;
2619 *mainapp = _get_bool_value(info->app_info->mainapp);
2624 API int pkgmgrinfo_appinfo_is_preload(pkgmgrinfo_appinfo_h handle, bool *preload)
2626 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2627 retvm_if(preload == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2628 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2630 if (info->app_info == NULL || info->app_info->preload == NULL)
2631 return PMINFO_R_ERROR;
2633 *preload = _get_bool_value(info->app_info->preload);
2638 API int pkgmgrinfo_appinfo_is_submode(pkgmgrinfo_appinfo_h handle, bool *submode)
2640 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2641 retvm_if(submode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2642 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2644 if (info->app_info == NULL || info->app_info->submode == NULL)
2645 return PMINFO_R_ERROR;
2647 *submode = _get_bool_value(info->app_info->submode);
2652 API int pkgmgrinfo_appinfo_is_process_pool(pkgmgrinfo_appinfo_h handle, bool *process_pool)
2654 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2656 if (handle == NULL || process_pool == NULL) {
2657 LOGE("invalid parameter");
2658 return PMINFO_R_EINVAL;
2661 if (info->app_info == NULL)
2662 return PMINFO_R_ERROR;
2664 *process_pool = _get_bool_value(info->app_info->process_pool);
2669 API int pkgmgrinfo_appinfo_is_category_exist(pkgmgrinfo_appinfo_h handle, const char *category, bool *exist)
2671 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2672 retvm_if(category == NULL, PMINFO_R_EINVAL, "category is NULL");
2673 retvm_if(exist == NULL, PMINFO_R_EINVAL, "exist is NULL");
2677 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2679 if (info->app_info == NULL)
2680 return PMINFO_R_ERROR;
2683 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
2684 val = (const char *)tmp->data;
2687 if (strcasecmp(val, category) == 0) {
2696 API int pkgmgrinfo_appinfo_is_ui_gadget(pkgmgrinfo_appinfo_h handle,
2699 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2701 if (info == NULL || info->app_info == NULL || ui_gadget == NULL) {
2702 _LOGE("invalid parameter");
2703 return PMINFO_R_EINVAL;
2705 if (info->app_info->ui_gadget == NULL)
2706 info->app_info->ui_gadget = strdup("false");
2708 *ui_gadget = _get_bool_value(info->app_info->ui_gadget);
2713 API int pkgmgrinfo_appinfo_is_support_disable(pkgmgrinfo_appinfo_h handle,
2714 bool *support_disable)
2716 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2718 if (info == NULL || info->app_info == NULL || support_disable == NULL) {
2719 _LOGE("invalid parameter");
2720 return PMINFO_R_EINVAL;
2723 *support_disable = _get_bool_value(info->app_info->support_disable);
2728 API int pkgmgrinfo_appinfo_is_removable(pkgmgrinfo_appinfo_h handle,
2731 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2733 if (info == NULL || info->app_info == NULL || removable == NULL) {
2734 _LOGE("invalid parameter");
2735 return PMINFO_R_EINVAL;
2738 *removable = _get_bool_value(info->app_info->removable);
2743 API int pkgmgrinfo_appinfo_is_system(pkgmgrinfo_appinfo_h handle, bool *system)
2745 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2747 if (info == NULL || info->app_info == NULL || system == NULL) {
2748 _LOGE("invalid parameter");
2749 return PMINFO_R_EINVAL;
2752 *system = _get_bool_value(info->app_info->package_system);
2757 API int pkgmgrinfo_appinfo_is_disabled(pkgmgrinfo_appinfo_h handle, bool *disabled)
2759 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2760 retvm_if(disabled == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2761 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2763 if (info->app_info == NULL || info->app_info->is_disabled == NULL)
2764 return PMINFO_R_ERROR;
2766 *disabled = _get_bool_value(info->app_info->is_disabled);
2771 API int pkgmgrinfo_appinfo_is_global(pkgmgrinfo_appinfo_h handle, bool *global)
2773 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2775 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2776 retvm_if(global == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2778 if (info->app_info == NULL || info->app_info->for_all_users == NULL)
2779 return PMINFO_R_ERROR;
2781 *global = _get_bool_value(info->app_info->for_all_users);
2786 API int pkgmgrinfo_appinfo_get_splash_screen_display(pkgmgrinfo_appinfo_h handle, bool *splash_screen_display)
2788 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2790 if (info == NULL || splash_screen_display == NULL) {
2791 _LOGE("Invalid parameter");
2792 return PMINFO_R_EINVAL;
2795 if (info->app_info == NULL || info->app_info->splash_screen_display == NULL)
2796 return PMINFO_R_ERROR;
2798 *splash_screen_display = _get_bool_value(info->app_info->splash_screen_display);
2803 API int pkgmgrinfo_appinfo_get_setup_appid(pkgmgrinfo_appinfo_h handle, char **setup_appid)
2805 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2807 if (info == NULL || setup_appid == NULL) {
2808 _LOGE("Invalid parameter");
2809 return PMINFO_R_EINVAL;
2812 if (info->app_info == NULL || info->app_info->setup_appid == NULL)
2813 return PMINFO_R_ERROR;
2815 *setup_appid = info->app_info->setup_appid;
2819 API int pkgmgrinfo_appinfo_is_support_ambient(pkgmgrinfo_appinfo_h handle,
2820 bool *support_ambient)
2822 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2824 if (info == NULL || support_ambient == NULL) {
2825 _LOGE("Invalid parameter");
2826 return PMINFO_R_EINVAL;
2829 if (info->app_info == NULL || info->app_info->support_ambient == NULL)
2830 return PMINFO_R_ERROR;
2832 *support_ambient = _get_bool_value(info->app_info->support_ambient);
2837 API int pkgmgrinfo_appinfo_destroy_appinfo(pkgmgrinfo_appinfo_h handle)
2839 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2840 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2841 __cleanup_appinfo(info);
2845 API int pkgmgrinfo_appinfo_filter_create(pkgmgrinfo_appinfo_filter_h *handle)
2847 return (pkgmgrinfo_pkginfo_filter_create(handle));
2850 API int pkgmgrinfo_appinfo_filter_destroy(pkgmgrinfo_appinfo_filter_h handle)
2852 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
2855 static gint __compare_func(gconstpointer data1, gconstpointer data2)
2857 pkgmgrinfo_node_x *node1 = (pkgmgrinfo_node_x *)data1;
2858 pkgmgrinfo_node_x *node2 = (pkgmgrinfo_node_x *)data2;
2859 if (node1->prop == node2->prop)
2861 else if (node1->prop > node2->prop)
2867 API int pkgmgrinfo_appinfo_filter_add_int(pkgmgrinfo_appinfo_filter_h handle,
2868 const char *property, const int value)
2870 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2871 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2872 char buf[PKG_VALUE_STRING_LEN_MAX] = {'\0'};
2874 GSList *link = NULL;
2876 prop = _pminfo_appinfo_convert_to_prop_int(property);
2877 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_INT ||
2878 prop > E_PMINFO_APPINFO_PROP_APP_MAX_INT) {
2879 _LOGE("Invalid Integer Property\n");
2880 return PMINFO_R_EINVAL;
2882 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2883 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1, sizeof(pkgmgrinfo_node_x));
2885 _LOGE("Out of Memory!!!\n");
2886 return PMINFO_R_ERROR;
2888 snprintf(buf, PKG_VALUE_STRING_LEN_MAX - 1, "%d", value);
2889 val = strndup(buf, PKG_VALUE_STRING_LEN_MAX - 1);
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_bool(pkgmgrinfo_appinfo_filter_h handle,
2909 const char *property, const bool 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");
2914 GSList *link = NULL;
2916 prop = _pminfo_appinfo_convert_to_prop_bool(property);
2917 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_BOOL ||
2918 prop > E_PMINFO_APPINFO_PROP_APP_MAX_BOOL) {
2919 _LOGE("Invalid Boolean Property\n");
2920 return PMINFO_R_EINVAL;
2922 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2923 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1, sizeof(pkgmgrinfo_node_x));
2925 _LOGE("Out of Memory!!!\n");
2926 return PMINFO_R_ERROR;
2929 val = strndup("true", 4);
2931 val = strndup("false", 5);
2933 _LOGE("Out of Memory\n");
2936 return PMINFO_R_ERROR;
2940 /*If API is called multiple times for same property, we should override the previous values.
2941 Last value set will be used for filtering.*/
2942 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2944 filter->list = g_slist_delete_link(filter->list, link);
2945 filter->list = g_slist_append(filter->list, (gpointer)node);
2950 API int pkgmgrinfo_appinfo_filter_add_string(pkgmgrinfo_appinfo_filter_h handle,
2951 const char *property, const char *value)
2953 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2954 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2955 retvm_if(value == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2957 pkgmgrinfo_node_x *ptr = NULL;
2958 char prev[PKG_STRING_LEN_MAX] = {'\0'};
2959 char temp[PKG_STRING_LEN_MAX] = {'\0'};
2960 GSList *link = NULL;
2962 prop = _pminfo_appinfo_convert_to_prop_str(property);
2963 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_STR ||
2964 prop > E_PMINFO_APPINFO_PROP_APP_MAX_STR) {
2965 _LOGE("Invalid String Property\n");
2966 return PMINFO_R_EINVAL;
2968 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2969 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1, sizeof(pkgmgrinfo_node_x));
2971 _LOGE("Out of Memory!!!\n");
2972 return PMINFO_R_ERROR;
2976 case E_PMINFO_APPINFO_PROP_APP_COMPONENT:
2977 node->value = strdup(value);
2978 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2980 filter->list = g_slist_delete_link(filter->list, link);
2981 filter->list = g_slist_append(filter->list, (gpointer)node);
2983 case E_PMINFO_APPINFO_PROP_APP_CATEGORY:
2984 val = (char *)calloc(1, PKG_STRING_LEN_MAX);
2986 _LOGE("Out of Memory\n");
2989 return PMINFO_R_ERROR;
2991 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2993 ptr = (pkgmgrinfo_node_x *)link->data;
2994 strncpy(prev, ptr->value, PKG_STRING_LEN_MAX - 1);
2995 _LOGI("Previous value is %s\n", prev);
2996 filter->list = g_slist_delete_link(filter->list, link);
2997 snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s,%s", prev, value);
2998 strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
2999 _LOGI("New value is %s\n", val);
3001 filter->list = g_slist_append(filter->list, (gpointer)node);
3002 memset(temp, '\0', PKG_STRING_LEN_MAX);
3004 snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s", value);
3005 strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
3006 _LOGI("First value is %s\n", val);
3008 filter->list = g_slist_append(filter->list, (gpointer)node);
3009 memset(temp, '\0', PKG_STRING_LEN_MAX);
3013 node->value = strndup(value, PKG_STRING_LEN_MAX - 1);
3014 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
3016 filter->list = g_slist_delete_link(filter->list, link);
3017 filter->list = g_slist_append(filter->list, (gpointer)node);
3023 API int pkgmgrinfo_appinfo_usr_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count, uid_t uid)
3029 if (handle == NULL || count == NULL) {
3030 _LOGE("invalid parameter");
3031 return PMINFO_R_EINVAL;
3034 locale = _get_system_locale();
3036 return PMINFO_R_ERROR;
3038 list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
3039 __free_applications);
3042 return PMINFO_R_ERROR;
3045 ret = _appinfo_get_applications(uid, uid, locale, handle, 0, list);
3046 if (ret == PMINFO_R_OK && uid != GLOBAL_USER)
3047 ret = _appinfo_get_applications(GLOBAL_USER, uid, locale,
3050 if (ret != PMINFO_R_OK) {
3051 g_hash_table_destroy(list);
3053 return PMINFO_R_ERROR;
3056 *count = g_hash_table_size(list);
3057 g_hash_table_destroy(list);
3063 API int pkgmgrinfo_appinfo_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count)
3065 return pkgmgrinfo_appinfo_usr_filter_count(handle, count, _getuid());
3068 API int pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(
3069 pkgmgrinfo_appinfo_filter_h handle,
3070 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
3072 if (handle == NULL || app_cb == NULL) {
3073 LOGE("invalid parameter");
3074 return PMINFO_R_EINVAL;
3077 return _appinfo_get_filtered_foreach_appinfo(uid, handle, PMINFO_APPINFO_GET_ALL, app_cb,
3081 API int pkgmgrinfo_appinfo_filter_foreach_appinfo(pkgmgrinfo_appinfo_filter_h handle,
3082 pkgmgrinfo_app_list_cb app_cb, void *user_data)
3084 return pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(handle, app_cb, user_data, _getuid());
3087 API int pkgmgrinfo_appinfo_metadata_filter_create(pkgmgrinfo_appinfo_metadata_filter_h *handle)
3089 return (pkgmgrinfo_pkginfo_filter_create(handle));
3092 API int pkgmgrinfo_appinfo_metadata_filter_destroy(pkgmgrinfo_appinfo_metadata_filter_h handle)
3094 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
3097 API int pkgmgrinfo_appinfo_metadata_filter_add(
3098 pkgmgrinfo_appinfo_metadata_filter_h handle,
3099 const char *key, const char *value)
3101 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
3102 pkgmgrinfo_metadata_node_x *node;
3104 /* value can be NULL.
3105 * In that case all apps with specified key should be displayed
3108 LOGE("invalid parameter");
3109 return PMINFO_R_EINVAL;
3112 node = calloc(1, sizeof(pkgmgrinfo_metadata_node_x));
3114 LOGE("out of memory");
3115 return PMINFO_R_ERROR;
3118 node->key = strdup(key);
3119 if (value && strlen(value))
3120 node->value = strdup(value);
3122 filter->list_metadata = g_slist_append(filter->list_metadata,
3128 API int pkgmgrinfo_appinfo_usr_metadata_filter_foreach(
3129 pkgmgrinfo_appinfo_metadata_filter_h handle,
3130 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
3132 if (handle == NULL || app_cb == NULL) {
3133 LOGE("invalid parameter");
3134 return PMINFO_R_EINVAL;
3137 return _appinfo_get_filtered_foreach_appinfo(uid, handle, PMINFO_APPINFO_GET_ALL, app_cb,
3141 API int pkgmgrinfo_appinfo_metadata_filter_foreach(
3142 pkgmgrinfo_appinfo_metadata_filter_h handle,
3143 pkgmgrinfo_app_list_cb app_cb, void *user_data)
3145 return pkgmgrinfo_appinfo_usr_metadata_filter_foreach(handle, app_cb,
3146 user_data, _getuid());
3149 API int pkgmgrinfo_appinfo_is_guestmode_visibility(pkgmgrinfo_appinfo_h handle, bool *status)
3152 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3154 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
3155 retvm_if(status == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3157 val = info->app_info->guestmode_visibility;
3158 *status = _get_bool_value(val);