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 len += strlen(" WHERE 1=1");
72 strncat(buf, " WHERE 1=1", MAX_QUERY_LEN - len - 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 len += strlen(" AND ");
86 strncat(buf, " AND ", MAX_QUERY_LEN - len - 1);
88 len += strlen(condition);
89 strncat(buf, condition, sizeof(buf) - len - 1);
94 if (filter->list_metadata) {
95 len += strlen(" AND (");
96 strncat(buf, " AND (", MAX_QUERY_LEN - len - 1);
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 len += strlen(condition);
104 strncat(buf, condition, sizeof(buf) - len - 1);
108 len += strlen(" OR ");
109 strncat(buf, " OR ", MAX_QUERY_LEN - len - 1);
111 if (filter->list_metadata) {
112 len += strlen("1=0)");
113 strncat(buf, "1=0)", MAX_QUERY_LEN - len - 1);
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";
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);
703 info->for_all_users =
704 strdup((db_uid != GLOBAL_USER) ? "false" : "true");
706 if (db_uid == GLOBAL_USER) {
707 ret = __get_appinfo_for_uid(db, info, uid);
708 if (ret != PMINFO_R_OK) {
709 LOGI("Failed to get appinfo for given uid[%d]", (int)uid);
710 pkgmgrinfo_basic_free_application(info);
716 info->background_category = __get_background_category(
718 free(bg_category_str);
720 if (flag & PMINFO_APPINFO_GET_LABEL) {
722 _save_column_str(stmt, idx++, &tmp_record);
723 if (_add_label_info_into_list(locale, tmp_record, &info->label)) {
724 ret = PMINFO_R_ERROR;
729 if (flag & PMINFO_APPINFO_GET_ICON) {
731 _save_column_str(stmt, idx++, &tmp_record);
732 if (_add_icon_info_into_list(locale, tmp_record, &info->icon)) {
733 ret = PMINFO_R_ERROR;
738 if (flag & PMINFO_APPINFO_GET_CATEGORY) {
739 if (_appinfo_get_category(db, info->appid,
741 ret = PMINFO_R_ERROR;
746 if (flag & PMINFO_APPINFO_GET_APP_CONTROL) {
747 if (_appinfo_get_app_control(db, info->appid,
748 &info->appcontrol)) {
749 ret = PMINFO_R_ERROR;
754 if (flag & PMINFO_APPINFO_GET_DATA_CONTROL) {
755 if (_appinfo_get_data_control(db, info->appid,
756 &info->datacontrol)) {
757 ret = PMINFO_R_ERROR;
762 if (flag & PMINFO_APPINFO_GET_METADATA) {
763 if (_appinfo_get_metadata(db, info->appid,
765 ret = PMINFO_R_ERROR;
770 if (flag & PMINFO_APPINFO_GET_SPLASH_SCREEN) {
771 if (_appinfo_get_splashscreens(db, info->appid,
772 &info->splashscreens)) {
773 ret = PMINFO_R_ERROR;
778 if (is_check_storage &&
779 __appinfo_check_installed_storage(info) != PMINFO_R_OK) {
780 ret = PMINFO_R_ERROR;
781 pkgmgrinfo_basic_free_application(info);
786 g_hash_table_insert(applications, (gpointer)info->appid,
796 if (ret != PMINFO_R_OK && info != NULL)
797 pkgmgrinfo_basic_free_application(info);
799 g_list_free_full(bind_params, free);
800 sqlite3_close_v2(db);
801 sqlite3_finalize(stmt);
806 static int _pkgmgrinfo_get_appinfo(const char *appid, uid_t uid,
807 pkgmgrinfo_appinfo_filter_h filter, pkgmgrinfo_appinfo_h *handle)
812 pkgmgr_appinfo_x *info;
814 if (appid == NULL || filter == NULL || handle == NULL) {
815 LOGE("invalid parameter");
816 return PMINFO_R_EINVAL;
819 locale = _get_system_locale();
821 return PMINFO_R_ERROR;
823 list = g_hash_table_new(g_str_hash, g_str_equal);
826 return PMINFO_R_ERROR;
829 ret = _appinfo_get_applications(uid, uid, locale, filter,
830 PMINFO_APPINFO_GET_ALL, list);
831 if (!g_hash_table_size(list) && uid != GLOBAL_USER)
832 ret = _appinfo_get_applications(GLOBAL_USER, uid, locale, filter,
833 PMINFO_APPINFO_GET_ALL, list);
835 if (!g_hash_table_size(list)) {
836 _LOGI("appinfo for [%s] is not existed for user [%d]",
838 g_hash_table_destroy(list);
840 return PMINFO_R_ENOENT;
843 info = calloc(1, sizeof(pkgmgr_appinfo_x));
845 _LOGE("out of memory");
846 g_hash_table_destroy(list);
848 return PMINFO_R_ERROR;
851 info->app_info = (application_x *)g_hash_table_lookup(list, appid);
852 info->locale = locale;
853 info->package = strdup(info->app_info->package);
855 /* just free list only */
856 g_hash_table_destroy(list);
863 API int pkgmgrinfo_appinfo_get_usr_disabled_appinfo(const char *appid, uid_t uid,
864 pkgmgrinfo_appinfo_h *handle)
867 pkgmgrinfo_appinfo_filter_h filter;
869 if (appid == NULL || handle == NULL) {
870 LOGE("invalid parameter");
871 return PMINFO_R_EINVAL;
874 ret = pkgmgrinfo_appinfo_filter_create(&filter);
875 if (ret != PMINFO_R_OK)
878 ret = pkgmgrinfo_appinfo_filter_add_string(filter,
879 PMINFO_APPINFO_PROP_APP_ID, appid);
880 if (ret != PMINFO_R_OK) {
881 pkgmgrinfo_appinfo_filter_destroy(filter);
882 return PMINFO_R_ERROR;
885 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
886 PMINFO_APPINFO_PROP_APP_DISABLE, true);
887 if (ret != PMINFO_R_OK) {
888 pkgmgrinfo_appinfo_filter_destroy(filter);
889 return PMINFO_R_ERROR;
892 ret = _pkgmgrinfo_get_appinfo(appid, uid, filter, handle);
893 pkgmgrinfo_appinfo_filter_destroy(filter);
898 API int pkgmgrinfo_appinfo_get_disabled_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
900 return pkgmgrinfo_appinfo_get_usr_disabled_appinfo(appid, _getuid(), handle);
903 API int pkgmgrinfo_appinfo_get_usr_appinfo(const char *appid, uid_t uid,
904 pkgmgrinfo_appinfo_h *handle)
907 pkgmgrinfo_appinfo_filter_h filter;
909 if (appid == NULL || handle == NULL) {
910 LOGE("invalid parameter");
911 return PMINFO_R_EINVAL;
914 ret = pkgmgrinfo_appinfo_filter_create(&filter);
915 if (ret != PMINFO_R_OK)
918 ret = pkgmgrinfo_appinfo_filter_add_string(filter,
919 PMINFO_APPINFO_PROP_APP_ID, appid);
920 if (ret != PMINFO_R_OK) {
921 pkgmgrinfo_appinfo_filter_destroy(filter);
922 return PMINFO_R_ERROR;
925 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
926 PMINFO_APPINFO_PROP_APP_DISABLE, false);
927 if (ret != PMINFO_R_OK) {
928 pkgmgrinfo_appinfo_filter_destroy(filter);
929 return PMINFO_R_ERROR;
932 ret = _pkgmgrinfo_get_appinfo(appid, uid, filter, handle);
933 pkgmgrinfo_appinfo_filter_destroy(filter);
937 API int pkgmgrinfo_appinfo_get_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
939 return pkgmgrinfo_appinfo_get_usr_appinfo(appid, _getuid(), handle);
942 API int pkgmgrinfo_appinfo_get_usr_all_appinfo(const char *appid, uid_t uid,
943 pkgmgrinfo_appinfo_h *handle)
946 pkgmgrinfo_appinfo_filter_h filter;
948 if (appid == NULL || handle == NULL) {
949 LOGE("invalid parameter");
950 return PMINFO_R_EINVAL;
953 ret = pkgmgrinfo_appinfo_filter_create(&filter);
954 if (ret != PMINFO_R_OK)
957 ret = pkgmgrinfo_appinfo_filter_add_string(filter,
958 PMINFO_APPINFO_PROP_APP_ID, appid);
959 if (ret != PMINFO_R_OK) {
960 pkgmgrinfo_appinfo_filter_destroy(filter);
961 return PMINFO_R_ERROR;
964 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
965 PMINFO_APPINFO_PROP_APP_CHECK_STORAGE, false);
966 if (ret != PMINFO_R_OK) {
967 pkgmgrinfo_appinfo_filter_destroy(filter);
968 return PMINFO_R_ERROR;
971 ret = _pkgmgrinfo_get_appinfo(appid, uid, filter, handle);
972 pkgmgrinfo_appinfo_filter_destroy(filter);
977 API int pkgmgrinfo_appinfo_get_all_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
979 return pkgmgrinfo_appinfo_get_usr_all_appinfo(appid, _getuid(), handle);
982 static gpointer __copy_str(gconstpointer src, gpointer data)
984 const char *tmp = (const char *)src;
987 buffer = strdup(tmp);
988 if (buffer == NULL) {
989 LOGE("memory alloc failed");
997 static gpointer __copy_label(gconstpointer src, gpointer data)
999 label_x *tmp = (label_x *)src;
1002 label = calloc(1, sizeof(label_x));
1003 if (label == NULL) {
1004 LOGE("memory alloc failed");
1010 label->name = strdup(tmp->name);
1012 label->text = strdup(tmp->text);
1014 label->lang = strdup(tmp->lang);
1019 static gpointer __copy_icon(gconstpointer src, gpointer data)
1021 icon_x *tmp = (icon_x *)src;
1024 icon = calloc(1, sizeof(icon_x));
1026 LOGE("memory alloc failed");
1032 icon->text = strdup(tmp->text);
1034 icon->lang = strdup(tmp->lang);
1036 icon->section = strdup(tmp->section);
1038 icon->size = strdup(tmp->size);
1039 if (tmp->resolution)
1040 icon->resolution = strdup(tmp->resolution);
1045 static gpointer __copy_metadata(gconstpointer src, gpointer data)
1047 metadata_x *tmp = (metadata_x *)src;
1048 metadata_x *metadata;
1050 metadata = calloc(1, sizeof(metadata_x));
1051 if (metadata == NULL) {
1052 LOGE("memory alloc failed");
1058 metadata->key = strdup(tmp->key);
1060 metadata->value = strdup(tmp->value);
1065 static gpointer __copy_datacontrol(gconstpointer src, gpointer data)
1067 datacontrol_x *tmp = (datacontrol_x *)src;
1068 datacontrol_x *datacontrol;
1070 datacontrol = calloc(1, sizeof(datacontrol_x));
1071 if (datacontrol == NULL) {
1072 LOGE("memory alloc failed");
1077 if (tmp->providerid)
1078 datacontrol->providerid = strdup(tmp->providerid);
1080 datacontrol->access = strdup(tmp->access);
1082 datacontrol->type = strdup(tmp->type);
1087 static gpointer __copy_appcontrol(gconstpointer src, gpointer data)
1089 appcontrol_x *tmp = (appcontrol_x *)src;
1090 appcontrol_x *appcontrol;
1092 appcontrol = calloc(1, sizeof(appcontrol_x));
1093 if (appcontrol == NULL) {
1094 LOGE("memory alloc failed");
1100 appcontrol->operation = strdup(tmp->operation);
1102 appcontrol->uri = strdup(tmp->uri);
1104 appcontrol->mime = strdup(tmp->mime);
1109 static gpointer __copy_splashscreens(gconstpointer src, gpointer data)
1111 splashscreen_x *tmp = (splashscreen_x *)src;
1112 splashscreen_x *splashscreen;
1114 splashscreen = (splashscreen_x *)calloc(1, sizeof(splashscreen_x));
1115 if (splashscreen == NULL) {
1116 LOGE("memory alloc failed");
1122 splashscreen->src = strdup(tmp->src);
1124 splashscreen->type = strdup(tmp->type);
1125 if (tmp->orientation)
1126 splashscreen->orientation = strdup(tmp->orientation);
1127 if (tmp->indicatordisplay)
1128 splashscreen->indicatordisplay = strdup(tmp->indicatordisplay);
1130 splashscreen->operation = strdup(tmp->operation);
1131 if (tmp->color_depth)
1132 splashscreen->color_depth = strdup(tmp->color_depth);
1134 return splashscreen;
1137 static int _appinfo_copy_appinfo(application_x **application, application_x *data)
1139 application_x *app_info;
1142 app_info = calloc(1, sizeof(application_x));
1143 if (app_info == NULL) {
1144 LOGE("memory alloc failed");
1145 return PMINFO_R_ERROR;
1148 if (data->appid != NULL)
1149 app_info->appid = strdup(data->appid);
1150 if (data->exec != NULL)
1151 app_info->exec = strdup(data->exec);
1152 if (data->nodisplay != NULL)
1153 app_info->nodisplay = strdup(data->nodisplay);
1154 if (data->multiple != NULL)
1155 app_info->multiple = strdup(data->multiple);
1156 if (data->taskmanage != NULL)
1157 app_info->taskmanage = strdup(data->taskmanage);
1158 if (data->type != NULL)
1159 app_info->type = strdup(data->type);
1160 if (data->categories != NULL)
1161 app_info->categories = strdup(data->categories);
1162 if (data->hwacceleration != NULL)
1163 app_info->hwacceleration = strdup(data->hwacceleration);
1164 if (data->screenreader != NULL)
1165 app_info->screenreader = strdup(data->screenreader);
1166 if (data->mainapp != NULL)
1167 app_info->mainapp = strdup(data->mainapp);
1168 if (data->package != NULL)
1169 app_info->package = strdup(data->package);
1170 if (data->recentimage != NULL)
1171 app_info->recentimage = strdup(data->recentimage);
1172 if (data->launchcondition != NULL)
1173 app_info->launchcondition = strdup(data->launchcondition);
1174 if (data->indicatordisplay != NULL)
1175 app_info->indicatordisplay = strdup(data->indicatordisplay);
1176 if (data->portraitimg != NULL)
1177 app_info->portraitimg = strdup(data->portraitimg);
1178 if (data->landscapeimg != NULL)
1179 app_info->landscapeimg = strdup(data->landscapeimg);
1180 if (data->guestmode_visibility != NULL)
1181 app_info->guestmode_visibility = strdup(data->guestmode_visibility);
1182 if (data->component != NULL)
1183 app_info->component = strdup(data->component);
1184 if (data->permission_type != NULL)
1185 app_info->permission_type = strdup(data->permission_type);
1186 if (data->component_type != NULL)
1187 app_info->component_type = strdup(data->component_type);
1188 if (data->preload != NULL)
1189 app_info->preload = strdup(data->preload);
1190 if (data->submode != NULL)
1191 app_info->submode = strdup(data->submode);
1192 if (data->submode_mainid != NULL)
1193 app_info->submode_mainid = strdup(data->submode_mainid);
1194 if (data->process_pool != NULL)
1195 app_info->process_pool = strdup(data->process_pool);
1196 if (data->installed_storage != NULL)
1197 app_info->installed_storage = strdup(data->installed_storage);
1198 if (data->autorestart != NULL)
1199 app_info->autorestart = strdup(data->autorestart);
1200 if (data->onboot != NULL)
1201 app_info->onboot = strdup(data->onboot);
1202 if (data->support_disable != NULL)
1203 app_info->support_disable = strdup(data->support_disable);
1204 if (data->ui_gadget != NULL)
1205 app_info->ui_gadget = strdup(data->ui_gadget);
1206 if (data->launch_mode != NULL)
1207 app_info->launch_mode = strdup(data->launch_mode);
1208 if (data->package_type != NULL)
1209 app_info->package_type = strdup(data->package_type);
1210 if (data->effective_appid != NULL)
1211 app_info->effective_appid = strdup(data->effective_appid);
1212 if (data->splash_screen_display != NULL)
1213 app_info->splash_screen_display = strdup(data->splash_screen_display);
1217 app_info->label = g_list_copy_deep(data->label, __copy_label, &ret);
1219 LOGE("memory alloc failed");
1220 pkgmgrinfo_basic_free_application(app_info);
1221 return PMINFO_R_ERROR;
1225 app_info->icon = g_list_copy_deep(data->icon, __copy_icon, &ret);
1227 LOGE("memory alloc failed");
1228 pkgmgrinfo_basic_free_application(app_info);
1229 return PMINFO_R_ERROR;
1233 app_info->category = g_list_copy_deep(data->category, __copy_str, &ret);
1235 LOGE("memory alloc failed");
1236 pkgmgrinfo_basic_free_application(app_info);
1237 return PMINFO_R_ERROR;
1241 app_info->metadata = g_list_copy_deep(data->metadata, __copy_metadata, &ret);
1243 LOGE("memory alloc failed");
1244 pkgmgrinfo_basic_free_application(app_info);
1245 return PMINFO_R_ERROR;
1249 app_info->datacontrol = g_list_copy_deep(data->datacontrol, __copy_datacontrol, &ret);
1251 LOGE("memory alloc failed");
1252 pkgmgrinfo_basic_free_application(app_info);
1253 return PMINFO_R_ERROR;
1257 app_info->appcontrol = g_list_copy_deep(data->appcontrol, __copy_appcontrol, &ret);
1259 LOGE("memory alloc failed");
1260 pkgmgrinfo_basic_free_application(app_info);
1261 return PMINFO_R_ERROR;
1265 app_info->background_category = g_list_copy_deep(data->background_category, __copy_str, &ret);
1267 LOGE("memory alloc failed");
1268 pkgmgrinfo_basic_free_application(app_info);
1269 return PMINFO_R_ERROR;
1273 app_info->splashscreens = g_list_copy_deep(data->splashscreens, __copy_splashscreens, &ret);
1275 LOGE("memory alloc failed");
1276 pkgmgrinfo_basic_free_application(app_info);
1277 return PMINFO_R_ERROR;
1280 *application = app_info;
1285 API int pkgmgrinfo_appinfo_clone_appinfo(pkgmgrinfo_appinfo_h handle,
1286 pkgmgrinfo_appinfo_h *clone)
1288 pkgmgr_appinfo_x *info;
1289 pkgmgr_appinfo_x *temp = (pkgmgr_appinfo_x *)handle;
1292 return PMINFO_R_EINVAL;
1294 info = calloc(1, sizeof(pkgmgr_appinfo_x));
1296 LOGE("memory alloc failed");
1297 return PMINFO_R_ERROR;
1300 if (temp->package != NULL)
1301 info->package = strdup(temp->package);
1302 if (temp->locale != NULL)
1303 info->locale = strdup(temp->locale);
1305 info->app_component = temp->app_component;
1307 if (_appinfo_copy_appinfo(&info->app_info, temp->app_info) < 0) {
1308 LOGE("appinfo copy failed");
1310 free((void *)info->package);
1314 return PMINFO_R_ERROR;
1322 static int _appinfo_get_filtered_foreach_appinfo(uid_t uid,
1323 pkgmgrinfo_filter_x *filter, int flag, pkgmgrinfo_app_list_cb app_list_cb,
1329 pkgmgr_appinfo_x info;
1331 GHashTableIter iter;
1334 locale = _get_system_locale();
1336 return PMINFO_R_ERROR;
1338 list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
1339 __free_applications);
1342 return PMINFO_R_ERROR;
1345 if (__check_disable_filter_exist(filter) == false) {
1346 pkgmgrinfo_appinfo_filter_add_bool(filter,
1347 PMINFO_APPINFO_PROP_APP_DISABLE, false);
1350 ret = _appinfo_get_applications(uid, uid, locale, filter, flag, list);
1351 if (ret == PMINFO_R_OK && uid != GLOBAL_USER)
1352 ret = _appinfo_get_applications(GLOBAL_USER, uid, locale,
1353 filter, flag, list);
1355 if (ret != PMINFO_R_OK) {
1356 g_hash_table_destroy(list);
1361 g_hash_table_iter_init(&iter, list);
1362 while (g_hash_table_iter_next(&iter, NULL, &value)) {
1363 app = (application_x *)value;
1364 info.app_info = app;
1365 info.locale = locale;
1366 info.package = app->package;
1367 if (app_list_cb(&info, user_data) < 0)
1370 g_hash_table_destroy(list);
1376 static const char *__appcomponent_str(pkgmgrinfo_app_component comp);
1378 API int pkgmgrinfo_appinfo_get_usr_list(pkgmgrinfo_pkginfo_h handle,
1379 pkgmgrinfo_app_component component,
1380 pkgmgrinfo_app_list_cb app_func, void *user_data, uid_t uid)
1383 pkgmgrinfo_appinfo_filter_h filter;
1385 const char *comp_str = NULL;
1387 if (handle == NULL || app_func == NULL) {
1388 LOGE("invalid parameter");
1389 return PMINFO_R_EINVAL;
1392 if (pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid)) {
1393 LOGE("invalid parameter");
1394 return PMINFO_R_EINVAL;
1397 if (pkgmgrinfo_appinfo_filter_create(&filter))
1398 return PMINFO_R_ERROR;
1400 if (pkgmgrinfo_appinfo_filter_add_string(filter,
1401 PMINFO_APPINFO_PROP_APP_PACKAGE, pkgid)) {
1402 pkgmgrinfo_appinfo_filter_destroy(filter);
1403 return PMINFO_R_ERROR;
1406 comp_str = __appcomponent_str(component);
1409 if (pkgmgrinfo_appinfo_filter_add_string(filter,
1410 PMINFO_APPINFO_PROP_APP_COMPONENT,
1412 pkgmgrinfo_appinfo_filter_destroy(filter);
1413 return PMINFO_R_ERROR;
1417 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter,
1418 PMINFO_APPINFO_GET_ALL, app_func, user_data);
1420 pkgmgrinfo_appinfo_filter_destroy(filter);
1425 API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle,
1426 pkgmgrinfo_app_component component,
1427 pkgmgrinfo_app_list_cb app_func, void *user_data)
1429 return pkgmgrinfo_appinfo_get_usr_list(handle, component, app_func, user_data, _getuid());
1432 API int pkgmgrinfo_appinfo_get_usr_installed_list_full(
1433 pkgmgrinfo_app_list_cb app_func, uid_t uid, int flag,
1437 pkgmgrinfo_appinfo_filter_h filter;
1439 if (app_func == NULL) {
1440 LOGE("invalid parameter");
1441 return PMINFO_R_EINVAL;
1444 if (pkgmgrinfo_appinfo_filter_create(&filter))
1445 return PMINFO_R_ERROR;
1447 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
1448 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
1449 pkgmgrinfo_appinfo_filter_destroy(filter);
1450 return PMINFO_R_ERROR;
1453 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
1454 PMINFO_APPINFO_PROP_APP_CHECK_STORAGE, false)) {
1455 pkgmgrinfo_appinfo_filter_destroy(filter);
1456 return PMINFO_R_ERROR;
1459 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter, flag, app_func,
1462 pkgmgrinfo_appinfo_filter_destroy(filter);
1467 API int pkgmgrinfo_appinfo_get_installed_list_full(
1468 pkgmgrinfo_app_list_cb app_func, int flag, void *user_data)
1470 return pkgmgrinfo_appinfo_get_usr_installed_list_full(app_func,
1471 _getuid(), flag, user_data);
1474 API int pkgmgrinfo_appinfo_get_usr_installed_list(
1475 pkgmgrinfo_app_list_cb app_func, uid_t uid, void *user_data)
1478 pkgmgrinfo_appinfo_filter_h filter;
1480 if (app_func == NULL) {
1481 LOGE("invalid parameter");
1482 return PMINFO_R_EINVAL;
1485 /* create an empty filter */
1486 ret = pkgmgrinfo_appinfo_filter_create(&filter);
1487 if (ret != PMINFO_R_OK)
1490 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter,
1491 PMINFO_APPINFO_GET_ALL, app_func, user_data);
1493 pkgmgrinfo_appinfo_filter_destroy(filter);
1498 API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func,
1501 return pkgmgrinfo_appinfo_get_usr_installed_list(app_func, _getuid(),
1505 API int pkgmgrinfo_appinfo_get_appid(pkgmgrinfo_appinfo_h handle, char **appid)
1507 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1509 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1510 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1512 if (info->app_info == NULL || info->app_info->appid == NULL)
1513 return PMINFO_R_ERROR;
1514 *appid = (char *)info->app_info->appid;
1519 API int pkgmgrinfo_appinfo_get_pkgname(pkgmgrinfo_appinfo_h handle, char **pkg_name)
1521 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1523 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1524 retvm_if(pkg_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1526 if (info->package == NULL)
1527 return PMINFO_R_ERROR;
1529 *pkg_name = (char *)info->package;
1534 API int pkgmgrinfo_appinfo_get_pkgid(pkgmgrinfo_appinfo_h handle, char **pkgid)
1536 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1538 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1539 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1541 if (info->package == NULL)
1542 return PMINFO_R_ERROR;
1544 *pkgid = (char *)info->package;
1549 API int pkgmgrinfo_appinfo_get_pkgtype(pkgmgrinfo_appinfo_h handle, char **pkgtype)
1551 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1552 retvm_if(pkgtype == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1553 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1555 *pkgtype = (char *)info->app_info->package_type;
1560 API int pkgmgrinfo_appinfo_get_exec(pkgmgrinfo_appinfo_h handle, char **exec)
1562 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1564 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1565 retvm_if(exec == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1567 if (info->app_info == NULL || info->app_info->exec == NULL)
1568 return PMINFO_R_ERROR;
1569 *exec = (char *)info->app_info->exec;
1575 API int pkgmgrinfo_appinfo_get_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1578 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1580 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1581 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1583 if (info->app_info == NULL)
1584 return PMINFO_R_ERROR;
1586 if (info->app_info->icon == NULL) {
1591 ptr = (icon_x *)info->app_info->icon->data;
1593 return PMINFO_R_ERROR;
1595 if (ptr->text == NULL)
1596 return PMINFO_R_ERROR;
1604 API int pkgmgrinfo_appinfo_get_label(pkgmgrinfo_appinfo_h handle, char **label)
1607 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1609 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1610 retvm_if(label == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1612 if (info->app_info == NULL || info->app_info->label == NULL)
1613 return PMINFO_R_ERROR;
1615 ptr = (label_x *)info->app_info->label->data;
1617 return PMINFO_R_ERROR;
1619 if (ptr->text == NULL)
1620 return PMINFO_R_ERROR;
1627 static char *_get_localed_label(const char *appid, const char *locale, uid_t uid)
1629 char *result = NULL;
1631 sqlite3_stmt *stmt = NULL;
1636 parser_db = getUserPkgParserDBPathUID(uid);
1637 if (parser_db == NULL) {
1638 _LOGE("Failed to get parser db path");
1642 if (__open_db(parser_db, &db, SQLITE_OPEN_READONLY) != SQLITE_OK) {
1643 _LOGE("DB open fail\n");
1649 query = sqlite3_mprintf("select app_label from package_app_localized_info where app_id=%Q and app_locale=%Q", appid, locale);
1650 if (query == NULL) {
1651 _LOGE("Out of memory");
1655 if (sqlite3_prepare_v2(db, query, -1, &stmt, NULL) != SQLITE_OK) {
1656 _LOGE("prepare_v2 fail\n");
1660 if (sqlite3_step(stmt) == SQLITE_ROW) {
1661 val = (char *)sqlite3_column_text(stmt, 0);
1663 result = strdup(val);
1667 sqlite3_finalize(stmt);
1668 sqlite3_free(query);
1674 API int pkgmgrinfo_appinfo_usr_get_localed_label(const char *appid, const char *locale, uid_t uid, char **label)
1678 retvm_if(appid == NULL || locale == NULL || label == NULL, PMINFO_R_EINVAL, "Argument is NULL");
1680 val = _get_localed_label(appid, locale, uid);
1682 val = _get_localed_label(appid, DEFAULT_LOCALE, uid);
1685 val = _get_localed_label(appid, locale, GLOBAL_USER);
1687 val = _get_localed_label(appid, DEFAULT_LOCALE, GLOBAL_USER);
1691 return PMINFO_R_ERROR;
1698 API int pkgmgrinfo_appinfo_get_localed_label(const char *appid, const char *locale, char **label)
1700 return pkgmgrinfo_appinfo_usr_get_localed_label(appid, locale, _getuid(), label);
1703 API int pkgmgrinfo_appinfo_get_metadata_value(pkgmgrinfo_appinfo_h handle, const char *metadata_key, char **metadata_value)
1705 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1706 retvm_if(metadata_key == NULL, PMINFO_R_EINVAL, "metadata_key is NULL");
1707 retvm_if(metadata_value == NULL, PMINFO_R_EINVAL, "metadata_value is NULL");
1709 GList *list_md = NULL;
1710 metadata_x *metadata = NULL;
1711 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1713 list_md = info->app_info->metadata;
1715 for (; list_md; list_md = list_md->next) {
1716 metadata = (metadata_x *)list_md->data;
1717 if (metadata && metadata->key) {
1718 if (strcasecmp(metadata->key, metadata_key) == 0) {
1719 if (metadata->value == NULL)
1720 *metadata_value = "";
1722 *metadata_value = (char *)metadata->value;
1728 return PMINFO_R_EINVAL;
1731 static pkgmgrinfo_app_component __appcomponent_convert(const char *comp)
1733 if (strcasecmp(comp, "uiapp") == 0)
1734 return PMINFO_UI_APP;
1735 else if (strcasecmp(comp, "svcapp") == 0)
1736 return PMINFO_SVC_APP;
1737 else if (strcasecmp(comp, "widgetapp") == 0)
1738 return PMINFO_WIDGET_APP;
1739 else if (strcasecmp(comp, "watchapp") == 0)
1740 return PMINFO_WATCH_APP;
1745 static const char *__appcomponent_str(pkgmgrinfo_app_component comp)
1750 case PMINFO_SVC_APP:
1752 case PMINFO_WIDGET_APP:
1754 case PMINFO_WATCH_APP:
1761 API int pkgmgrinfo_appinfo_get_component(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_component *component)
1763 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1766 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1767 retvm_if(component == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1769 if (info->app_info == NULL)
1770 return PMINFO_R_ERROR;
1772 comp = __appcomponent_convert(info->app_info->component);
1774 return PMINFO_R_ERROR;
1781 API int pkgmgrinfo_appinfo_get_apptype(pkgmgrinfo_appinfo_h handle, char **app_type)
1783 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1785 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1786 retvm_if(app_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1788 if (info->app_info == NULL || info->app_info->type == NULL)
1789 return PMINFO_R_ERROR;
1790 *app_type = (char *)info->app_info->type;
1795 API int pkgmgrinfo_appinfo_get_operation(pkgmgrinfo_appcontrol_h handle,
1796 int *operation_count, char ***operation)
1798 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1799 retvm_if(operation == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1800 retvm_if(operation_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1801 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1802 *operation_count = data->operation_count;
1803 *operation = data->operation;
1807 API int pkgmgrinfo_appinfo_get_uri(pkgmgrinfo_appcontrol_h handle,
1808 int *uri_count, char ***uri)
1810 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1811 retvm_if(uri == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1812 retvm_if(uri_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1813 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1814 *uri_count = data->uri_count;
1819 API int pkgmgrinfo_appinfo_get_mime(pkgmgrinfo_appcontrol_h handle,
1820 int *mime_count, char ***mime)
1822 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1823 retvm_if(mime == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1824 retvm_if(mime_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1825 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1826 *mime_count = data->mime_count;
1831 API int pkgmgrinfo_appinfo_get_subapp(pkgmgrinfo_appcontrol_h handle,
1832 int *subapp_count, char ***subapp)
1834 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1835 retvm_if(subapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1836 retvm_if(subapp_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1837 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1838 *subapp_count = data->subapp_count;
1839 *subapp = data->subapp;
1843 API int pkgmgrinfo_appinfo_get_setting_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1848 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1850 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1851 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1853 if (info->app_info == NULL)
1854 return PMINFO_R_ERROR;
1856 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1857 ptr = (icon_x *)tmp->data;
1858 if (ptr == NULL || ptr->section == NULL)
1861 val = (char *)ptr->section;
1862 if (val && strcmp(val, "setting") == 0) {
1863 *icon = (char *)ptr->text;
1868 return PMINFO_R_ERROR;
1872 API int pkgmgrinfo_appinfo_get_notification_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1877 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1879 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1880 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1882 if (info->app_info == NULL)
1883 return PMINFO_R_ERROR;
1885 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1886 ptr = (icon_x *)tmp->data;
1887 if (ptr == NULL || ptr->section == NULL)
1890 val = (char *)ptr->section;
1891 if (val && strcmp(val, "notification") == 0) {
1892 *icon = (char *)ptr->text;
1897 return PMINFO_R_ERROR;
1900 API int pkgmgrinfo_appinfo_get_recent_image_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_recentimage *type)
1903 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1905 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1906 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1908 if (info->app_info == NULL || info->app_info->recentimage == NULL)
1909 return PMINFO_R_ERROR;
1911 val = (char *)info->app_info->recentimage;
1912 if (strcasecmp(val, "capture") == 0)
1913 *type = PMINFO_RECENTIMAGE_USE_CAPTURE;
1914 else if (strcasecmp(val, "icon") == 0)
1915 *type = PMINFO_RECENTIMAGE_USE_ICON;
1917 *type = PMINFO_RECENTIMAGE_USE_NOTHING;
1922 API int pkgmgrinfo_appinfo_get_preview_image(pkgmgrinfo_appinfo_h handle, char **preview_img)
1927 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1929 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1930 retvm_if(preview_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1932 if (info->app_info == NULL)
1933 return PMINFO_R_ERROR;
1935 for (tmp = info->app_info->image; tmp; tmp = tmp->next) {
1936 ptr = (image_x *)tmp->data;
1937 if (ptr == NULL || ptr->section == NULL)
1940 val = (char *)ptr->section;
1941 if (val && strcmp(val, "preview") == 0) {
1942 *preview_img = (char *)ptr->text;
1947 return PMINFO_R_ERROR;
1950 API int pkgmgrinfo_appinfo_get_permission_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_permission_type *permission)
1953 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1955 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1956 retvm_if(permission == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1958 val = info->app_info->permission_type;
1960 return PMINFO_R_ERROR;
1962 if (strcmp(val, "signature") == 0)
1963 *permission = PMINFO_PERMISSION_SIGNATURE;
1964 else if (strcmp(val, "privilege") == 0)
1965 *permission = PMINFO_PERMISSION_PRIVILEGE;
1967 *permission = PMINFO_PERMISSION_NORMAL;
1972 API int pkgmgrinfo_appinfo_get_component_type(pkgmgrinfo_appinfo_h handle, char **component_type)
1974 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1976 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1977 retvm_if(component_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1979 if (info->app_info == NULL || info->app_info->component_type == NULL)
1980 return PMINFO_R_ERROR;
1982 *component_type = (char *)info->app_info->component_type;
1987 API int pkgmgrinfo_appinfo_get_hwacceleration(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_hwacceleration *hwacceleration)
1990 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1992 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1993 retvm_if(hwacceleration == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1995 if (info->app_info == NULL || info->app_info->hwacceleration == NULL)
1996 return PMINFO_R_ERROR;
1998 val = (char *)info->app_info->hwacceleration;
1999 if (strcasecmp(val, "off") == 0)
2000 *hwacceleration = PMINFO_HWACCELERATION_OFF;
2001 else if (strcasecmp(val, "on") == 0)
2002 *hwacceleration = PMINFO_HWACCELERATION_ON;
2004 *hwacceleration = PMINFO_HWACCELERATION_DEFAULT;
2009 API int pkgmgrinfo_appinfo_get_screenreader(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_screenreader *screenreader)
2012 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2014 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2015 retvm_if(screenreader == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2017 if (info->app_info == NULL || info->app_info->screenreader == NULL)
2018 return PMINFO_R_ERROR;
2020 val = (char *)info->app_info->screenreader;
2021 if (strcasecmp(val, "screenreader-off") == 0)
2022 *screenreader = PMINFO_SCREENREADER_OFF;
2023 else if (strcasecmp(val, "screenreader-on") == 0)
2024 *screenreader = PMINFO_SCREENREADER_ON;
2026 *screenreader = PMINFO_SCREENREADER_USE_SYSTEM_SETTING;
2031 API int pkgmgrinfo_appinfo_get_effectimage(pkgmgrinfo_appinfo_h handle, char **portrait_img, char **landscape_img)
2033 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2035 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2036 retvm_if(portrait_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2037 retvm_if(landscape_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2039 if (info->app_info == NULL)
2040 return PMINFO_R_ERROR;
2042 if (info->app_info->portraitimg == NULL)
2045 *portrait_img = (char *)info->app_info->portraitimg;
2047 if (info->app_info->landscapeimg == NULL)
2048 *landscape_img = "";
2050 *landscape_img = (char *)info->app_info->landscapeimg;
2055 API int pkgmgrinfo_appinfo_get_effectimage_type(pkgmgrinfo_appinfo_h handle, char **effectimage_type)
2057 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2059 if (handle == NULL || effectimage_type == NULL) {
2060 LOGE("invalid parameter");
2061 return PMINFO_R_EINVAL;
2064 if (info->app_info == NULL || info->app_info->effectimage_type == NULL)
2065 return PMINFO_R_ERROR;
2067 *effectimage_type = (char *)info->app_info->effectimage_type;
2072 API int pkgmgrinfo_appinfo_get_submode_mainid(pkgmgrinfo_appinfo_h handle, char **submode_mainid)
2074 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2076 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2077 retvm_if(submode_mainid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2079 if (info->app_info == NULL)
2080 return PMINFO_R_ERROR;
2082 if (info->app_info->submode_mainid == NULL)
2083 *submode_mainid = "";
2085 *submode_mainid = (char *)info->app_info->submode_mainid;
2090 API int pkgmgrinfo_appinfo_get_installed_storage_location(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_installed_storage *storage)
2092 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2093 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2095 if (info->app_info && info->app_info->installed_storage) {
2096 if (strcmp(info->app_info->installed_storage, "installed_internal") == 0)
2097 *storage = PMINFO_INTERNAL_STORAGE;
2098 else if (strcmp(info->app_info->installed_storage, "installed_external") == 0)
2099 *storage = PMINFO_EXTERNAL_STORAGE;
2101 return PMINFO_R_ERROR;
2103 return PMINFO_R_ERROR;
2109 API int pkgmgrinfo_appinfo_get_launch_mode(pkgmgrinfo_appinfo_h handle, char **mode)
2111 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2113 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2114 retvm_if(mode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2116 if (info->app_info->launch_mode == NULL)
2117 return PMINFO_R_ERROR;
2119 *mode = (char *)(info->app_info->launch_mode);
2124 API int pkgmgrinfo_appinfo_get_alias_appid(pkgmgrinfo_appinfo_h handle, char **alias_appid)
2126 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2128 if (handle == NULL || alias_appid == NULL) {
2129 LOGE("invalid parameter");
2130 return PMINFO_R_EINVAL;
2133 if (info->app_info == NULL || info->app_info->alias_appid == NULL)
2134 return PMINFO_R_ERROR;
2136 *alias_appid = (char *)info->app_info->alias_appid;
2141 API int pkgmgrinfo_appinfo_get_effective_appid(pkgmgrinfo_appinfo_h handle, char **effective_appid)
2143 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2145 if (handle == NULL || effective_appid == NULL) {
2146 LOGE("invalid parameter");
2147 return PMINFO_R_EINVAL;
2150 if (info->app_info == NULL)
2151 return PMINFO_R_ERROR;
2153 if (info->app_info->effective_appid == NULL)
2154 *effective_appid = "";
2156 *effective_appid = (char *)info->app_info->effective_appid;
2161 API int pkgmgrinfo_appinfo_get_tep_name(pkgmgrinfo_appinfo_h handle, char **tep_name)
2163 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2165 if (handle == NULL || tep_name == NULL) {
2166 LOGE("invalid parameter");
2167 return PMINFO_R_EINVAL;
2170 if (info->app_info == NULL)
2171 return PMINFO_R_ERROR;
2173 if (info->app_info->tep_name == NULL)
2176 *tep_name = (char *)info->app_info->tep_name;
2181 API int pkgmgrinfo_appinfo_get_zip_mount_file(pkgmgrinfo_appinfo_h handle, char **zip_mount_file)
2183 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2185 if (handle == NULL || zip_mount_file == NULL) {
2186 LOGE("invalid parameter");
2187 return PMINFO_R_EINVAL;
2190 if (info->app_info == NULL)
2191 return PMINFO_R_ERROR;
2193 if (info->app_info->zip_mount_file == NULL)
2194 *zip_mount_file = "";
2196 *zip_mount_file = (char *)info->app_info->zip_mount_file;
2201 API int pkgmgrinfo_appinfo_get_root_path(pkgmgrinfo_appinfo_h handle, char **root_path)
2203 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2205 if (handle == NULL || root_path == NULL) {
2206 LOGE("invalid parameter");
2207 return PMINFO_R_EINVAL;
2210 if (info->app_info == NULL || info->app_info->root_path == NULL)
2211 return PMINFO_R_ERROR;
2213 *root_path = (char *)info->app_info->root_path;
2218 API int pkgmgrinfo_appinfo_get_api_version(pkgmgrinfo_appinfo_h handle, char **api_version)
2220 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2222 if (handle == NULL || api_version == NULL) {
2223 LOGE("invalid parameter");
2224 return PMINFO_R_EINVAL;
2227 if (info->app_info == NULL || info->app_info->api_version == NULL)
2228 return PMINFO_R_ERROR;
2230 *api_version = (char *)info->app_info->api_version;
2235 API int pkgmgrinfo_appinfo_get_installed_time(pkgmgrinfo_appinfo_h handle, int *installed_time)
2237 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2239 if (handle == NULL || installed_time == NULL) {
2240 LOGE("invalid parameter");
2241 return PMINFO_R_EINVAL;
2244 if (info->app_info == NULL || info->app_info->package_installed_time == NULL)
2245 return PMINFO_R_ERROR;
2247 *installed_time = atoi(info->app_info->package_installed_time);
2252 API int pkgmgrinfo_appinfo_usr_get_datacontrol_info(const char *providerid, const char *type, uid_t uid, char **appid, char **access)
2254 retvm_if(providerid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
2255 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
2256 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2257 retvm_if(access == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2259 int ret = PMINFO_R_OK;
2261 sqlite3_stmt *stmt = NULL;
2264 ret = __open_manifest_db(uid, true);
2265 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
2267 /*Start constructing query*/
2268 query = sqlite3_mprintf("select * from package_app_data_control where providerid=%Q and type=%Q", providerid, type);
2269 tryvm_if(query == NULL, ret = PMINFO_R_ERROR, "Out of memory");
2272 ret = sqlite3_prepare_v2(GET_DB(manifest_db), query, strlen(query), &stmt, NULL);
2273 tryvm_if(ret != PMINFO_R_OK, ret = PMINFO_R_ERROR, "sqlite3_prepare_v2 failed[%s]\n", query);
2276 ret = sqlite3_step(stmt);
2277 tryvm_if((ret != SQLITE_ROW) || (ret == SQLITE_DONE), ret = PMINFO_R_ERROR, "No records found");
2279 *appid = strdup((char *)sqlite3_column_text(stmt, 0));
2280 *access = strdup((char *)sqlite3_column_text(stmt, 2));
2285 sqlite3_free(query);
2286 sqlite3_finalize(stmt);
2287 __close_manifest_db();
2291 API int pkgmgrinfo_appinfo_get_datacontrol_info(const char *providerid, const char *type, char **appid, char **access)
2293 return pkgmgrinfo_appinfo_usr_get_datacontrol_info(providerid, type, _getuid(), appid, access);
2296 API int pkgmgrinfo_appinfo_usr_get_datacontrol_appid(const char *providerid, uid_t uid, char **appid)
2298 retvm_if(providerid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
2299 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2301 int ret = PMINFO_R_OK;
2303 sqlite3_stmt *stmt = NULL;
2306 ret = __open_manifest_db(uid, true);
2307 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
2309 /*Start constructing query*/
2310 query = sqlite3_mprintf("select * from package_app_data_control where providerid=%Q", providerid);
2311 tryvm_if(query == NULL, ret = PMINFO_R_ERROR, "Out of memory");
2314 ret = sqlite3_prepare_v2(GET_DB(manifest_db), query, strlen(query), &stmt, NULL);
2315 tryvm_if(ret != PMINFO_R_OK, ret = PMINFO_R_ERROR, "sqlite3_prepare_v2 failed[%s]\n", query);
2318 ret = sqlite3_step(stmt);
2319 tryvm_if((ret != SQLITE_ROW) || (ret == SQLITE_DONE), ret = PMINFO_R_ERROR, "No records found");
2321 *appid = strdup((char *)sqlite3_column_text(stmt, 0));
2326 sqlite3_free(query);
2327 sqlite3_finalize(stmt);
2328 __close_manifest_db();
2332 API int pkgmgrinfo_appinfo_get_datacontrol_appid(const char *providerid, char **appid)
2334 return pkgmgrinfo_appinfo_usr_get_datacontrol_appid(providerid, _getuid(), appid);
2337 API int pkgmgrinfo_appinfo_get_support_mode(pkgmgrinfo_appinfo_h handle, int *support_mode)
2339 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2340 retvm_if(support_mode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2342 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2343 if (info->app_info->support_mode)
2344 *support_mode = atoi(info->app_info->support_mode);
2351 API int pkgmgrinfo_appinfo_foreach_permission(pkgmgrinfo_appinfo_h handle,
2352 pkgmgrinfo_app_permission_list_cb permission_func, void *user_data)
2354 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2355 retvm_if(permission_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2359 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2361 if (info->app_info == NULL)
2362 return PMINFO_R_ERROR;
2364 for (tmp = info->app_info->permission; tmp; tmp = tmp->next) {
2365 ptr = (permission_x *)tmp->data;
2369 ret = permission_func(ptr->value, user_data);
2377 API int pkgmgrinfo_appinfo_foreach_category(pkgmgrinfo_appinfo_h handle,
2378 pkgmgrinfo_app_category_list_cb category_func, void *user_data)
2380 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2381 retvm_if(category_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2383 const char *category;
2385 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2387 if (info->app_info == NULL)
2388 return PMINFO_R_ERROR;
2390 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
2391 category = (const char *)tmp->data;
2393 ret = category_func(category, user_data);
2401 API int pkgmgrinfo_appinfo_foreach_metadata(pkgmgrinfo_appinfo_h handle,
2402 pkgmgrinfo_app_metadata_list_cb metadata_func, void *user_data)
2404 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2405 retvm_if(metadata_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2409 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2411 if (info->app_info == NULL)
2412 return PMINFO_R_ERROR;
2414 for (tmp = info->app_info->metadata; tmp; tmp = tmp->next) {
2415 ptr = (metadata_x *)tmp->data;
2419 ret = metadata_func(ptr->key, ptr->value ? ptr->value : "", user_data);
2427 API int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
2428 pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
2430 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2431 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2433 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2434 appcontrol_x *appcontrol;
2437 if (info->app_info == NULL)
2438 return PMINFO_R_ERROR;
2440 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
2441 appcontrol = (appcontrol_x *)tmp->data;
2442 if (appcontrol == NULL)
2444 ret = appcontrol_func(appcontrol->operation, appcontrol->uri, appcontrol->mime, user_data);
2452 API int pkgmgrinfo_appinfo_foreach_background_category(
2453 pkgmgrinfo_appinfo_h handle,
2454 pkgmgrinfo_app_background_category_list_cb category_func,
2457 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2461 if (handle == NULL || category_func == NULL || info->app_info == NULL) {
2462 LOGE("invalid parameter");
2463 return PMINFO_R_EINVAL;
2466 for (tmp = info->app_info->background_category; tmp; tmp = tmp->next) {
2467 category = (char *)tmp->data;
2468 if (category == NULL)
2471 if (category_func(category, user_data) < 0)
2478 API int pkgmgrinfo_appinfo_foreach_splash_screen(pkgmgrinfo_appinfo_h handle,
2479 pkgmgrinfo_app_splash_screen_list_cb splash_screen_func,
2482 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2483 splashscreen_x *splashscreen;
2487 if (info == NULL || info->app_info == NULL
2488 || splash_screen_func == NULL) {
2489 LOGE("invalid parameter");
2490 return PMINFO_R_EINVAL;
2493 for (tmp = info->app_info->splashscreens; tmp; tmp = tmp->next) {
2494 splashscreen = (splashscreen_x *)tmp->data;
2495 if (splashscreen == NULL)
2497 ret = splash_screen_func(splashscreen->src,
2499 splashscreen->orientation,
2500 splashscreen->indicatordisplay,
2501 splashscreen->operation,
2502 splashscreen->color_depth,
2511 API int pkgmgrinfo_appinfo_is_nodisplay(pkgmgrinfo_appinfo_h handle, bool *nodisplay)
2513 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2514 retvm_if(nodisplay == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2515 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2517 if (info->app_info == NULL || info->app_info->nodisplay == NULL)
2518 return PMINFO_R_ERROR;
2520 *nodisplay = _get_bool_value(info->app_info->nodisplay);
2525 API int pkgmgrinfo_appinfo_is_multiple(pkgmgrinfo_appinfo_h handle, bool *multiple)
2527 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2528 retvm_if(multiple == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2529 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2531 if (info->app_info == NULL || info->app_info->multiple == NULL)
2532 return PMINFO_R_ERROR;
2534 *multiple = _get_bool_value(info->app_info->multiple);
2539 API int pkgmgrinfo_appinfo_is_indicator_display_allowed(pkgmgrinfo_appinfo_h handle, bool *indicator_disp)
2541 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2542 retvm_if(indicator_disp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2543 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2545 if (info->app_info == NULL || info->app_info->indicatordisplay == NULL)
2546 return PMINFO_R_ERROR;
2548 *indicator_disp = _get_bool_value(info->app_info->indicatordisplay);
2553 API int pkgmgrinfo_appinfo_is_taskmanage(pkgmgrinfo_appinfo_h handle, bool *taskmanage)
2555 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2556 retvm_if(taskmanage == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2557 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2559 if (info->app_info == NULL || info->app_info->taskmanage == NULL)
2560 return PMINFO_R_ERROR;
2562 *taskmanage = _get_bool_value(info->app_info->taskmanage);
2567 API int pkgmgrinfo_appinfo_is_enabled(pkgmgrinfo_appinfo_h handle, bool *enabled)
2569 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2570 retvm_if(enabled == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2571 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2573 if (info->app_info == NULL || info->app_info->is_disabled == NULL)
2574 return PMINFO_R_ERROR;
2576 *enabled = !_get_bool_value(info->app_info->is_disabled);
2581 API int pkgmgrinfo_appinfo_is_onboot(pkgmgrinfo_appinfo_h handle, bool *onboot)
2583 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2584 retvm_if(onboot == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2585 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2587 if (info->app_info == NULL || info->app_info->onboot == NULL)
2588 return PMINFO_R_ERROR;
2590 *onboot = _get_bool_value(info->app_info->onboot);
2595 API int pkgmgrinfo_appinfo_is_autorestart(pkgmgrinfo_appinfo_h handle, bool *autorestart)
2597 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2598 retvm_if(autorestart == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2599 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2601 if (info->app_info == NULL || info->app_info->autorestart == NULL)
2602 return PMINFO_R_ERROR;
2604 *autorestart = _get_bool_value(info->app_info->autorestart);
2609 API int pkgmgrinfo_appinfo_is_mainapp(pkgmgrinfo_appinfo_h handle, bool *mainapp)
2611 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2612 retvm_if(mainapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2613 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2615 if (info->app_info == NULL || info->app_info->mainapp == NULL)
2616 return PMINFO_R_ERROR;
2618 *mainapp = _get_bool_value(info->app_info->mainapp);
2623 API int pkgmgrinfo_appinfo_is_preload(pkgmgrinfo_appinfo_h handle, bool *preload)
2625 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2626 retvm_if(preload == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2627 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2629 if (info->app_info == NULL || info->app_info->preload == NULL)
2630 return PMINFO_R_ERROR;
2632 *preload = _get_bool_value(info->app_info->preload);
2637 API int pkgmgrinfo_appinfo_is_submode(pkgmgrinfo_appinfo_h handle, bool *submode)
2639 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2640 retvm_if(submode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2641 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2643 if (info->app_info == NULL || info->app_info->submode == NULL)
2644 return PMINFO_R_ERROR;
2646 *submode = _get_bool_value(info->app_info->submode);
2651 API int pkgmgrinfo_appinfo_is_process_pool(pkgmgrinfo_appinfo_h handle, bool *process_pool)
2653 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2655 if (handle == NULL || process_pool == NULL) {
2656 LOGE("invalid parameter");
2657 return PMINFO_R_EINVAL;
2660 if (info->app_info == NULL)
2661 return PMINFO_R_ERROR;
2663 *process_pool = _get_bool_value(info->app_info->process_pool);
2668 API int pkgmgrinfo_appinfo_is_category_exist(pkgmgrinfo_appinfo_h handle, const char *category, bool *exist)
2670 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2671 retvm_if(category == NULL, PMINFO_R_EINVAL, "category is NULL");
2672 retvm_if(exist == NULL, PMINFO_R_EINVAL, "exist is NULL");
2676 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2678 if (info->app_info == NULL)
2679 return PMINFO_R_ERROR;
2682 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
2683 val = (const char *)tmp->data;
2686 if (strcasecmp(val, category) == 0) {
2695 API int pkgmgrinfo_appinfo_is_ui_gadget(pkgmgrinfo_appinfo_h handle,
2698 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2700 if (info == NULL || info->app_info == NULL || ui_gadget == NULL) {
2701 _LOGE("invalid parameter");
2702 return PMINFO_R_EINVAL;
2704 if (info->app_info->ui_gadget == NULL)
2705 info->app_info->ui_gadget = strdup("false");
2707 *ui_gadget = _get_bool_value(info->app_info->ui_gadget);
2712 API int pkgmgrinfo_appinfo_is_support_disable(pkgmgrinfo_appinfo_h handle,
2713 bool *support_disable)
2715 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2717 if (info == NULL || info->app_info == NULL || support_disable == NULL) {
2718 _LOGE("invalid parameter");
2719 return PMINFO_R_EINVAL;
2722 *support_disable = _get_bool_value(info->app_info->support_disable);
2727 API int pkgmgrinfo_appinfo_is_removable(pkgmgrinfo_appinfo_h handle,
2730 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2732 if (info == NULL || info->app_info == NULL || removable == NULL) {
2733 _LOGE("invalid parameter");
2734 return PMINFO_R_EINVAL;
2737 *removable = _get_bool_value(info->app_info->removable);
2742 API int pkgmgrinfo_appinfo_is_system(pkgmgrinfo_appinfo_h handle, bool *system)
2744 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2746 if (info == NULL || info->app_info == NULL || system == NULL) {
2747 _LOGE("invalid parameter");
2748 return PMINFO_R_EINVAL;
2751 *system = _get_bool_value(info->app_info->package_system);
2756 API int pkgmgrinfo_appinfo_is_disabled(pkgmgrinfo_appinfo_h handle, bool *disabled)
2758 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2759 retvm_if(disabled == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2760 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2762 if (info->app_info == NULL || info->app_info->is_disabled == NULL)
2763 return PMINFO_R_ERROR;
2765 *disabled = _get_bool_value(info->app_info->is_disabled);
2770 API int pkgmgrinfo_appinfo_is_global(pkgmgrinfo_appinfo_h handle, bool *global)
2772 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2774 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2775 retvm_if(global == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2777 if (info->app_info == NULL || info->app_info->for_all_users == NULL)
2778 return PMINFO_R_ERROR;
2780 *global = _get_bool_value(info->app_info->for_all_users);
2785 API int pkgmgrinfo_appinfo_get_splash_screen_display(pkgmgrinfo_appinfo_h handle, bool *splash_screen_display)
2787 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2789 if (info == NULL || splash_screen_display == NULL) {
2790 _LOGE("Invalid parameter");
2791 return PMINFO_R_EINVAL;
2794 if (info->app_info == NULL || info->app_info->splash_screen_display == NULL)
2795 return PMINFO_R_ERROR;
2797 *splash_screen_display = _get_bool_value(info->app_info->splash_screen_display);
2802 API int pkgmgrinfo_appinfo_is_support_ambient(pkgmgrinfo_appinfo_h handle,
2803 bool *support_ambient)
2805 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2807 if (info == NULL || support_ambient == NULL) {
2808 _LOGE("Invalid parameter");
2809 return PMINFO_R_EINVAL;
2812 if (info->app_info == NULL || info->app_info->support_ambient == NULL)
2813 return PMINFO_R_ERROR;
2815 *support_ambient = _get_bool_value(info->app_info->support_ambient);
2820 API int pkgmgrinfo_appinfo_destroy_appinfo(pkgmgrinfo_appinfo_h handle)
2822 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2823 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2824 __cleanup_appinfo(info);
2828 API int pkgmgrinfo_appinfo_filter_create(pkgmgrinfo_appinfo_filter_h *handle)
2830 return (pkgmgrinfo_pkginfo_filter_create(handle));
2833 API int pkgmgrinfo_appinfo_filter_destroy(pkgmgrinfo_appinfo_filter_h handle)
2835 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
2838 static gint __compare_func(gconstpointer data1, gconstpointer data2)
2840 pkgmgrinfo_node_x *node1 = (pkgmgrinfo_node_x *)data1;
2841 pkgmgrinfo_node_x *node2 = (pkgmgrinfo_node_x *)data2;
2842 if (node1->prop == node2->prop)
2844 else if (node1->prop > node2->prop)
2850 API int pkgmgrinfo_appinfo_filter_add_int(pkgmgrinfo_appinfo_filter_h handle,
2851 const char *property, const int value)
2853 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2854 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2855 char buf[PKG_VALUE_STRING_LEN_MAX] = {'\0'};
2857 GSList *link = NULL;
2859 prop = _pminfo_appinfo_convert_to_prop_int(property);
2860 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_INT ||
2861 prop > E_PMINFO_APPINFO_PROP_APP_MAX_INT) {
2862 _LOGE("Invalid Integer Property\n");
2863 return PMINFO_R_EINVAL;
2865 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2866 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1, sizeof(pkgmgrinfo_node_x));
2868 _LOGE("Out of Memory!!!\n");
2869 return PMINFO_R_ERROR;
2871 snprintf(buf, PKG_VALUE_STRING_LEN_MAX - 1, "%d", value);
2872 val = strndup(buf, PKG_VALUE_STRING_LEN_MAX - 1);
2874 _LOGE("Out of Memory\n");
2877 return PMINFO_R_ERROR;
2881 /*If API is called multiple times for same property, we should override the previous values.
2882 Last value set will be used for filtering.*/
2883 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2885 filter->list = g_slist_delete_link(filter->list, link);
2886 filter->list = g_slist_append(filter->list, (gpointer)node);
2891 API int pkgmgrinfo_appinfo_filter_add_bool(pkgmgrinfo_appinfo_filter_h handle,
2892 const char *property, const bool value)
2894 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2895 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2897 GSList *link = NULL;
2899 prop = _pminfo_appinfo_convert_to_prop_bool(property);
2900 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_BOOL ||
2901 prop > E_PMINFO_APPINFO_PROP_APP_MAX_BOOL) {
2902 _LOGE("Invalid Boolean Property\n");
2903 return PMINFO_R_EINVAL;
2905 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2906 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1, sizeof(pkgmgrinfo_node_x));
2908 _LOGE("Out of Memory!!!\n");
2909 return PMINFO_R_ERROR;
2912 val = strndup("true", 4);
2914 val = strndup("false", 5);
2916 _LOGE("Out of Memory\n");
2919 return PMINFO_R_ERROR;
2923 /*If API is called multiple times for same property, we should override the previous values.
2924 Last value set will be used for filtering.*/
2925 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2927 filter->list = g_slist_delete_link(filter->list, link);
2928 filter->list = g_slist_append(filter->list, (gpointer)node);
2933 API int pkgmgrinfo_appinfo_filter_add_string(pkgmgrinfo_appinfo_filter_h handle,
2934 const char *property, const char *value)
2936 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2937 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2938 retvm_if(value == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2940 pkgmgrinfo_node_x *ptr = NULL;
2941 char prev[PKG_STRING_LEN_MAX] = {'\0'};
2942 char temp[PKG_STRING_LEN_MAX] = {'\0'};
2943 GSList *link = NULL;
2945 prop = _pminfo_appinfo_convert_to_prop_str(property);
2946 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_STR ||
2947 prop > E_PMINFO_APPINFO_PROP_APP_MAX_STR) {
2948 _LOGE("Invalid String Property\n");
2949 return PMINFO_R_EINVAL;
2951 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2952 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1, sizeof(pkgmgrinfo_node_x));
2954 _LOGE("Out of Memory!!!\n");
2955 return PMINFO_R_ERROR;
2959 case E_PMINFO_APPINFO_PROP_APP_COMPONENT:
2960 node->value = strdup(value);
2961 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2963 filter->list = g_slist_delete_link(filter->list, link);
2964 filter->list = g_slist_append(filter->list, (gpointer)node);
2966 case E_PMINFO_APPINFO_PROP_APP_CATEGORY:
2967 val = (char *)calloc(1, PKG_STRING_LEN_MAX);
2969 _LOGE("Out of Memory\n");
2972 return PMINFO_R_ERROR;
2974 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2976 ptr = (pkgmgrinfo_node_x *)link->data;
2977 strncpy(prev, ptr->value, PKG_STRING_LEN_MAX - 1);
2978 _LOGI("Previous value is %s\n", prev);
2979 filter->list = g_slist_delete_link(filter->list, link);
2980 snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s,%s", prev, value);
2981 strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
2982 _LOGI("New value is %s\n", val);
2984 filter->list = g_slist_append(filter->list, (gpointer)node);
2985 memset(temp, '\0', PKG_STRING_LEN_MAX);
2987 snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s", value);
2988 strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
2989 _LOGI("First value is %s\n", val);
2991 filter->list = g_slist_append(filter->list, (gpointer)node);
2992 memset(temp, '\0', PKG_STRING_LEN_MAX);
2996 node->value = strndup(value, PKG_STRING_LEN_MAX - 1);
2997 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2999 filter->list = g_slist_delete_link(filter->list, link);
3000 filter->list = g_slist_append(filter->list, (gpointer)node);
3006 API int pkgmgrinfo_appinfo_usr_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count, uid_t uid)
3012 if (handle == NULL || count == NULL) {
3013 _LOGE("invalid parameter");
3014 return PMINFO_R_EINVAL;
3017 locale = _get_system_locale();
3019 return PMINFO_R_ERROR;
3021 list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
3022 __free_applications);
3025 return PMINFO_R_ERROR;
3028 ret = _appinfo_get_applications(uid, uid, locale, handle, 0, list);
3029 if (ret == PMINFO_R_OK && uid != GLOBAL_USER)
3030 ret = _appinfo_get_applications(GLOBAL_USER, uid, locale,
3033 if (ret != PMINFO_R_OK) {
3034 g_hash_table_destroy(list);
3036 return PMINFO_R_ERROR;
3039 *count = g_hash_table_size(list);
3040 g_hash_table_destroy(list);
3046 API int pkgmgrinfo_appinfo_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count)
3048 return pkgmgrinfo_appinfo_usr_filter_count(handle, count, _getuid());
3051 API int pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(
3052 pkgmgrinfo_appinfo_filter_h handle,
3053 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
3055 if (handle == NULL || app_cb == NULL) {
3056 LOGE("invalid parameter");
3057 return PMINFO_R_EINVAL;
3060 return _appinfo_get_filtered_foreach_appinfo(uid, handle, PMINFO_APPINFO_GET_ALL, app_cb,
3064 API int pkgmgrinfo_appinfo_filter_foreach_appinfo(pkgmgrinfo_appinfo_filter_h handle,
3065 pkgmgrinfo_app_list_cb app_cb, void *user_data)
3067 return pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(handle, app_cb, user_data, _getuid());
3070 API int pkgmgrinfo_appinfo_metadata_filter_create(pkgmgrinfo_appinfo_metadata_filter_h *handle)
3072 return (pkgmgrinfo_pkginfo_filter_create(handle));
3075 API int pkgmgrinfo_appinfo_metadata_filter_destroy(pkgmgrinfo_appinfo_metadata_filter_h handle)
3077 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
3080 API int pkgmgrinfo_appinfo_metadata_filter_add(
3081 pkgmgrinfo_appinfo_metadata_filter_h handle,
3082 const char *key, const char *value)
3084 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
3085 pkgmgrinfo_metadata_node_x *node;
3087 /* value can be NULL.
3088 * In that case all apps with specified key should be displayed
3091 LOGE("invalid parameter");
3092 return PMINFO_R_EINVAL;
3095 node = calloc(1, sizeof(pkgmgrinfo_metadata_node_x));
3097 LOGE("out of memory");
3098 return PMINFO_R_ERROR;
3101 node->key = strdup(key);
3102 if (value && strlen(value))
3103 node->value = strdup(value);
3105 filter->list_metadata = g_slist_append(filter->list_metadata,
3111 API int pkgmgrinfo_appinfo_usr_metadata_filter_foreach(
3112 pkgmgrinfo_appinfo_metadata_filter_h handle,
3113 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
3115 if (handle == NULL || app_cb == NULL) {
3116 LOGE("invalid parameter");
3117 return PMINFO_R_EINVAL;
3120 return _appinfo_get_filtered_foreach_appinfo(uid, handle, PMINFO_APPINFO_GET_ALL, app_cb,
3124 API int pkgmgrinfo_appinfo_metadata_filter_foreach(
3125 pkgmgrinfo_appinfo_metadata_filter_h handle,
3126 pkgmgrinfo_app_list_cb app_cb, void *user_data)
3128 return pkgmgrinfo_appinfo_usr_metadata_filter_foreach(handle, app_cb,
3129 user_data, _getuid());
3132 API int pkgmgrinfo_appinfo_is_guestmode_visibility(pkgmgrinfo_appinfo_h handle, bool *status)
3135 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3137 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
3138 retvm_if(status == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3140 val = info->app_info->guestmode_visibility;
3141 *status = _get_bool_value(val);