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)
22 else if (!strcasecmp(str, "true"))
28 static void __cleanup_appinfo(pkgmgr_appinfo_x *data)
30 pkgmgr_appinfo_x *info = data;
34 free((void *)info->package);
36 free((void *)info->locale);
38 pkgmgrinfo_basic_free_application(info->app_info);
44 static void __free_appinfo_list(gpointer data)
46 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)data;
47 __cleanup_appinfo(info);
50 static char *_get_filtered_query(const char *query_raw,
51 pkgmgrinfo_filter_x *filter)
53 char buf[MAX_QUERY_LEN] = { 0, };
62 strncat(buf, query_raw, MAX_QUERY_LEN - 1);
64 for (list = head; list; list = list->next) {
65 /* TODO: revise condition getter function */
66 __get_filter_condition(list->data, &condition);
67 if (condition == NULL)
69 if (buf[strlen(query_raw)] == '\0') {
70 len += strlen(" WHERE ");
71 strncat(buf, " WHERE ", MAX_QUERY_LEN - len - 1);
73 len += strlen(" AND ");
74 strncat(buf, " AND ", MAX_QUERY_LEN -len - 1);
76 len += strlen(condition);
77 strncat(buf, condition, sizeof(buf) - len - 1);
85 static gint __list_strcmp(gconstpointer a, gconstpointer b)
87 return strcmp((char *)a, (char *)b);
90 static gint _appinfo_get_list(sqlite3 *db, const char *locale,
91 pkgmgrinfo_filter_x *filter, GList **list)
93 static const char query_raw[] =
94 "SELECT DISTINCT package_app_info.app_id FROM package_app_info"
95 " LEFT OUTER JOIN package_app_localized_info"
96 " ON package_app_info.app_id=package_app_localized_info.app_id"
97 " AND package_app_localized_info.app_locale=%Q"
98 " LEFT OUTER JOIN package_app_app_category"
99 " ON package_app_info.app_id=package_app_app_category.app_id"
100 " LEFT OUTER JOIN package_app_app_control"
101 " ON package_app_info.app_id=package_app_app_control.app_id"
102 " LEFT OUTER JOIN package_app_app_metadata"
103 " ON package_app_info.app_id=package_app_app_metadata.app_id ";
106 char *query_localized;
110 query = _get_filtered_query(query_raw, filter);
112 return PMINFO_R_ERROR;
113 query_localized = sqlite3_mprintf(query, locale);
115 if (query_localized == NULL)
116 return PMINFO_R_ERROR;
118 ret = sqlite3_prepare_v2(db, query_localized,
119 strlen(query_localized), &stmt, NULL);
120 sqlite3_free(query_localized);
121 if (ret != SQLITE_OK) {
122 LOGE("prepare failed: %s", sqlite3_errmsg(db));
123 return PMINFO_R_ERROR;
126 while (sqlite3_step(stmt) == SQLITE_ROW) {
127 _save_column_str(stmt, 0, &appid);
129 *list = g_list_insert_sorted(*list, appid,
133 sqlite3_finalize(stmt);
138 static int _appinfo_get_filtered_list(pkgmgrinfo_filter_x *filter, uid_t uid,
148 locale = _get_system_locale();
150 return PMINFO_R_ERROR;
152 dbpath = getUserPkgParserDBPathUID(uid);
153 if (dbpath == NULL) {
155 return PMINFO_R_ERROR;
158 ret = sqlite3_open_v2(dbpath, &db, SQLITE_OPEN_READONLY, NULL);
159 if (ret != SQLITE_OK) {
160 _LOGE("failed to open db: %d", ret);
162 return PMINFO_R_ERROR;
165 if (_appinfo_get_list(db, locale, filter, list)) {
167 sqlite3_close_v2(db);
168 return PMINFO_R_ERROR;
170 sqlite3_close_v2(db);
172 if (uid == GLOBAL_USER) {
177 /* search again from global */
178 dbpath = getUserPkgParserDBPathUID(GLOBAL_USER);
179 if (dbpath == NULL) {
181 return PMINFO_R_ERROR;
184 ret = sqlite3_open_v2(dbpath, &db, SQLITE_OPEN_READONLY, NULL);
185 if (ret != SQLITE_OK) {
186 _LOGE("failed to open db: %d", ret);
188 return PMINFO_R_ERROR;
191 if (_appinfo_get_list(db, locale, filter, list)) {
193 sqlite3_close_v2(db);
194 return PMINFO_R_ERROR;
196 sqlite3_close_v2(db);
198 /* remove duplicate element:
199 * since the list is sorted, we can remove duplicates in linear time
201 for (tmp = *list, tmp2 = g_list_next(tmp); tmp;
202 tmp = tmp2, tmp2 = g_list_next(tmp)) {
203 if (tmp->prev == NULL || tmp->data == NULL)
205 if (strcmp((const char *)tmp->prev->data,
206 (const char *)tmp->data) == 0)
207 *list = g_list_delete_link(*list, tmp);
215 static int _appinfo_get_label(sqlite3 *db, const char *appid,
216 const char *locale, GList **label)
218 static const char query_raw[] =
219 "SELECT app_label, app_locale "
220 "FROM package_app_localized_info "
221 "WHERE app_id=%Q AND app_locale IN (%Q, %Q)";
228 query = sqlite3_mprintf(query_raw, appid, locale, DEFAULT_LOCALE);
230 LOGE("out of memory");
231 return PMINFO_R_ERROR;
234 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
236 if (ret != SQLITE_OK) {
237 LOGE("prepare failed: %s", sqlite3_errmsg(db));
238 return PMINFO_R_ERROR;
241 while (sqlite3_step(stmt) == SQLITE_ROW) {
242 info = calloc(1, sizeof(label_x));
244 LOGE("out of memory");
245 sqlite3_finalize(stmt);
246 return PMINFO_R_ERROR;
249 _save_column_str(stmt, idx++, &info->text);
250 _save_column_str(stmt, idx++, &info->lang);
251 *label = g_list_append(*label, info);
254 sqlite3_finalize(stmt);
259 static int _appinfo_get_icon(sqlite3 *db, const char *appid, const char *locale,
262 static const char query_raw[] =
263 "SELECT app_icon, app_locale "
264 "FROM package_app_localized_info "
265 "WHERE app_id=%Q AND app_locale IN (%Q, %Q)";
272 query = sqlite3_mprintf(query_raw, appid, locale, DEFAULT_LOCALE);
274 LOGE("out of memory");
275 return PMINFO_R_ERROR;
278 ret = sqlite3_prepare_v2(db, query, strlen(query),
281 if (ret != SQLITE_OK) {
282 LOGE("prepare failed: %s", sqlite3_errmsg(db));
283 return PMINFO_R_ERROR;
286 while (sqlite3_step(stmt) == SQLITE_ROW) {
287 info = calloc(1, sizeof(icon_x));
289 LOGE("out of memory");
290 sqlite3_finalize(stmt);
291 return PMINFO_R_ERROR;
294 _save_column_str(stmt, idx++, &info->text);
295 _save_column_str(stmt, idx++, &info->lang);
296 *icon = g_list_append(*icon, info);
299 sqlite3_finalize(stmt);
304 static int _appinfo_get_category(sqlite3 *db, const char *appid,
307 static const char query_raw[] =
308 "SELECT category FROM package_app_app_category WHERE app_id=%Q";
314 query = sqlite3_mprintf(query_raw, appid);
316 LOGE("out of memory");
317 return PMINFO_R_ERROR;
320 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
322 if (ret != SQLITE_OK) {
323 LOGE("prepare failed: %s", sqlite3_errmsg(db));
324 return PMINFO_R_ERROR;
327 while (sqlite3_step(stmt) == SQLITE_ROW) {
329 _save_column_str(stmt, 0, &val);
331 *category = g_list_append(*category, (gpointer)val);
334 sqlite3_finalize(stmt);
339 static void __parse_appcontrol(GList **appcontrol, char *appcontrol_str)
346 if (appcontrol_str == NULL)
349 dup = strdup(appcontrol_str);
351 ac = calloc(1, sizeof(appcontrol_x));
353 _LOGE("out of memory");
356 token = strtok_r(dup, "|", &ptr);
357 if (token && strcmp(token, "NULL"))
358 ac->operation = strdup(token);
359 token = strtok_r(NULL, "|", &ptr);
360 if (token && strcmp(token, "NULL"))
361 ac->uri = strdup(token);
362 token = strtok_r(NULL, "|", &ptr);
363 if (token && strcmp(token, "NULL"))
364 ac->mime = strdup(token);
365 *appcontrol = g_list_append(*appcontrol, ac);
366 } while ((token = strtok_r(NULL, ";", &ptr)));
371 static int _appinfo_get_app_control(sqlite3 *db, const char *appid,
374 static const char query_raw[] =
375 "SELECT app_control FROM package_app_app_control "
382 query = sqlite3_mprintf(query_raw, appid);
384 LOGE("out of memory");
385 return PMINFO_R_ERROR;
388 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
390 if (ret != SQLITE_OK) {
391 LOGE("prepare failed: %s", sqlite3_errmsg(db));
392 return PMINFO_R_ERROR;
395 while (sqlite3_step(stmt) == SQLITE_ROW) {
397 _save_column_str(stmt, 0, &str);
399 __parse_appcontrol(appcontrol, str);
403 sqlite3_finalize(stmt);
408 static int _appinfo_get_data_control(sqlite3 *db, const char *appid,
411 static const char query_raw[] =
412 "SELECT providerid, access, type "
413 "FROM package_app_data_control WHERE app_id=%Q";
420 query = sqlite3_mprintf(query_raw, appid);
422 LOGE("out of memory");
423 return PMINFO_R_ERROR;
426 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
428 if (ret != SQLITE_OK) {
429 LOGE("prepare failed: %s", sqlite3_errmsg(db));
430 return PMINFO_R_ERROR;
433 while (sqlite3_step(stmt) == SQLITE_ROW) {
434 info = calloc(1, sizeof(datacontrol_x));
436 LOGE("out of memory");
437 sqlite3_finalize(stmt);
438 return PMINFO_R_ERROR;
441 _save_column_str(stmt, idx++, &info->providerid);
442 _save_column_str(stmt, idx++, &info->access);
443 _save_column_str(stmt, idx++, &info->type);
444 *datacontrol = g_list_append(*datacontrol, info);
447 sqlite3_finalize(stmt);
452 static int _appinfo_get_metadata(sqlite3 *db, const char *appid,
455 static const char query_raw[] =
456 "SELECT md_key, md_value "
457 "FROM package_app_app_metadata WHERE app_id=%Q";
464 query = sqlite3_mprintf(query_raw, appid);
466 LOGE("out of memory");
467 return PMINFO_R_ERROR;
470 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
472 if (ret != SQLITE_OK) {
473 LOGE("prepare failed: %s", sqlite3_errmsg(db));
474 return PMINFO_R_ERROR;
477 while (sqlite3_step(stmt) == SQLITE_ROW) {
478 info = calloc(1, sizeof(metadata_x));
480 LOGE("out of memory");
481 sqlite3_finalize(stmt);
482 return PMINFO_R_ERROR;
485 _save_column_str(stmt, idx++, &info->key);
486 _save_column_str(stmt, idx++, &info->value);
487 *metadata = g_list_append(*metadata, info);
490 sqlite3_finalize(stmt);
496 static int _appinfo_get_splashscreens(sqlite3 *db, const char *appid,
497 GList **splashscreens)
499 static const char query_raw[] =
500 "SELECT src, type, orientation, indicatordisplay, operation "
501 "FROM package_app_splash_screen WHERE app_id=%Q";
506 splashscreen_x *info;
508 query = sqlite3_mprintf(query_raw, appid);
510 LOGE("out of memory");
511 return PMINFO_R_ERROR;
514 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
516 if (ret != SQLITE_OK) {
517 LOGE("prepare failed: %s", sqlite3_errmsg(db));
518 return PMINFO_R_ERROR;
521 while (sqlite3_step(stmt) == SQLITE_ROW) {
522 info = calloc(1, sizeof(splashscreen_x));
524 LOGE("out of memory");
525 sqlite3_finalize(stmt);
526 return PMINFO_R_ERROR;
529 _save_column_str(stmt, idx++, &info->src);
530 _save_column_str(stmt, idx++, &info->type);
531 _save_column_str(stmt, idx++, &info->orientation);
532 _save_column_str(stmt, idx++, &info->indicatordisplay);
533 _save_column_str(stmt, idx++, &info->operation);
534 *splashscreens = g_list_append(*splashscreens, info);
537 sqlite3_finalize(stmt);
542 static GList *__get_background_category(const char *value)
544 GList *category_list = NULL;
545 int convert_value = 0;
546 if (!value || strlen(value) == 0)
549 convert_value = atoi(value);
550 if (convert_value < 0)
553 if (convert_value & APP_BG_CATEGORY_USER_DISABLE_TRUE_VAL)
554 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_USER_DISABLE_TRUE_STR));
556 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_USER_DISABLE_FALSE_STR));
558 if (convert_value & APP_BG_CATEGORY_MEDIA_VAL)
559 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_MEDIA_STR));
561 if (convert_value & APP_BG_CATEGORY_DOWNLOAD_VAL)
562 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_DOWNLOAD_STR));
564 if (convert_value & APP_BG_CATEGORY_BGNETWORK_VAL)
565 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_BGNETWORK_STR));
567 if (convert_value & APP_BG_CATEGORY_LOCATION_VAL)
568 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_LOCATION_STR));
570 if (convert_value & APP_BG_CATEGORY_SENSOR_VAL)
571 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_SENSOR_STR));
573 if (convert_value & APP_BG_CATEGORY_IOTCOMM_VAL)
574 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_IOTCOMM_STR));
576 if (convert_value & APP_BG_CATEGORY_SYSTEM_VAL)
577 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_SYSTEM));
579 return category_list;
583 static void __get_splash_screen_display(sqlite3 *db, const char *appid, uid_t uid, char **value)
585 static const char query_raw[] =
586 "SELECT is_splash_screen_enabled FROM package_app_info_for_uid "
587 "WHERE app_id='%s' AND uid='%d'";
592 query = sqlite3_mprintf(query_raw, appid, uid);
594 LOGE("out of memory");
598 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
600 if (ret != SQLITE_OK) {
601 LOGE("sqlite3_prepare_v2() failed: %s", sqlite3_errmsg(db));
605 while (sqlite3_step(stmt) == SQLITE_ROW) {
608 _save_column_str(stmt, 0, value);
611 sqlite3_finalize(stmt);
614 static int _appinfo_get_application(sqlite3 *db, const char *appid,
615 const char *locale, application_x **application, bool is_disabled, uid_t db_uid, uid_t target_uid)
617 static const char query_raw[] =
618 "SELECT app_id, app_component, app_exec, app_nodisplay, "
619 "app_type, app_onboot, app_multiple, app_autorestart, "
620 "app_taskmanage, app_enabled, app_hwacceleration, "
621 "app_screenreader, app_mainapp, app_recentimage, "
622 "app_launchcondition, app_indicatordisplay, app_portraitimg, "
623 "app_landscapeimg, app_guestmodevisibility, "
624 "app_permissiontype, app_preload, app_submode, "
625 "app_submode_mainid, app_launch_mode, app_ui_gadget, "
626 "app_support_disable, "
627 "component_type, package, app_tep_name, app_process_pool, "
628 "app_installed_storage, app_background_category, "
629 "app_package_type, app_root_path, app_api_version, "
630 "app_effective_appid, app_disable, app_splash_screen_display "
631 "FROM package_app_info WHERE app_id='%s' "
632 "AND (app_disable='%s' "
634 "(SELECT app_id from package_app_info_for_uid WHERE uid='%d' AND is_disabled='true'))";
636 char query[MAX_QUERY_LEN] = { '\0' };
640 char *bg_category_str = NULL;
641 snprintf(query, MAX_QUERY_LEN - 1, query_raw,
643 is_disabled ? "true" : "false",
644 is_disabled ? "OR" : "AND",
645 is_disabled ? "" : "NOT",
648 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
649 if (ret != SQLITE_OK) {
650 LOGE("prepare failed: %s", sqlite3_errmsg(db));
651 return PMINFO_R_ERROR;
654 ret = sqlite3_step(stmt);
655 if (ret == SQLITE_DONE) {
656 sqlite3_finalize(stmt);
657 return PMINFO_R_ENOENT;
658 } else if (ret != SQLITE_ROW) {
659 LOGE("step failed: %s", sqlite3_errmsg(db));
660 sqlite3_finalize(stmt);
661 return PMINFO_R_ERROR;
664 info = calloc(1, sizeof(application_x));
666 LOGE("out of memory");
667 sqlite3_finalize(stmt);
668 return PMINFO_R_ERROR;
671 _save_column_str(stmt, idx++, &info->appid);
672 _save_column_str(stmt, idx++, &info->component);
673 _save_column_str(stmt, idx++, &info->exec);
674 _save_column_str(stmt, idx++, &info->nodisplay);
675 _save_column_str(stmt, idx++, &info->type);
676 _save_column_str(stmt, idx++, &info->onboot);
677 _save_column_str(stmt, idx++, &info->multiple);
678 _save_column_str(stmt, idx++, &info->autorestart);
679 _save_column_str(stmt, idx++, &info->taskmanage);
680 _save_column_str(stmt, idx++, &info->enabled);
681 _save_column_str(stmt, idx++, &info->hwacceleration);
682 _save_column_str(stmt, idx++, &info->screenreader);
683 _save_column_str(stmt, idx++, &info->mainapp);
684 _save_column_str(stmt, idx++, &info->recentimage);
685 _save_column_str(stmt, idx++, &info->launchcondition);
686 _save_column_str(stmt, idx++, &info->indicatordisplay);
687 _save_column_str(stmt, idx++, &info->portraitimg);
688 _save_column_str(stmt, idx++, &info->landscapeimg);
689 _save_column_str(stmt, idx++, &info->guestmode_visibility);
690 _save_column_str(stmt, idx++, &info->permission_type);
691 _save_column_str(stmt, idx++, &info->preload);
692 _save_column_str(stmt, idx++, &info->submode);
693 _save_column_str(stmt, idx++, &info->submode_mainid);
694 _save_column_str(stmt, idx++, &info->launch_mode);
695 _save_column_str(stmt, idx++, &info->ui_gadget);
696 _save_column_str(stmt, idx++, &info->support_disable);
697 _save_column_str(stmt, idx++, &info->component_type);
698 _save_column_str(stmt, idx++, &info->package);
699 _save_column_str(stmt, idx++, &info->tep_name);
700 _save_column_str(stmt, idx++, &info->process_pool);
701 _save_column_str(stmt, idx++, &info->installed_storage);
702 _save_column_str(stmt, idx++, &bg_category_str);
703 _save_column_str(stmt, idx++, &info->package_type);
704 _save_column_str(stmt, idx++, &info->root_path);
705 _save_column_str(stmt, idx++, &info->api_version);
706 _save_column_str(stmt, idx++, &info->effective_appid);
707 _save_column_str(stmt, idx++, &info->is_disabled);
708 _save_column_str(stmt, idx++, &info->splash_screen_display);
710 if (db_uid == GLOBAL_USER)
711 __get_splash_screen_display(db, info->appid, db_uid,
712 &info->splash_screen_display);
714 info->background_category = __get_background_category(bg_category_str);
715 free(bg_category_str);
717 if (_appinfo_get_label(db, info->appid, locale, &info->label)) {
718 pkgmgrinfo_basic_free_application(info);
719 sqlite3_finalize(stmt);
720 return PMINFO_R_ERROR;
723 if (_appinfo_get_icon(db, info->appid, locale, &info->icon)) {
724 pkgmgrinfo_basic_free_application(info);
725 sqlite3_finalize(stmt);
726 return PMINFO_R_ERROR;
729 if (_appinfo_get_category(db, info->appid, &info->category)) {
730 pkgmgrinfo_basic_free_application(info);
731 sqlite3_finalize(stmt);
732 return PMINFO_R_ERROR;
735 if (_appinfo_get_app_control(db, info->appid, &info->appcontrol)) {
736 pkgmgrinfo_basic_free_application(info);
737 sqlite3_finalize(stmt);
738 return PMINFO_R_ERROR;
741 if (_appinfo_get_data_control(db, info->appid, &info->datacontrol)) {
742 pkgmgrinfo_basic_free_application(info);
743 sqlite3_finalize(stmt);
744 return PMINFO_R_ERROR;
747 if (_appinfo_get_metadata(db, info->appid, &info->metadata)) {
748 pkgmgrinfo_basic_free_application(info);
749 sqlite3_finalize(stmt);
750 return PMINFO_R_ERROR;
753 if (_appinfo_get_splashscreens(db, info->appid, &info->splashscreens)) {
754 pkgmgrinfo_basic_free_application(info);
755 sqlite3_finalize(stmt);
756 return PMINFO_R_ERROR;
759 info->for_all_users = strdup((db_uid != GLOBAL_USER) ? "false" : "true");
763 sqlite3_finalize(stmt);
768 static int _appinfo_get_appinfo(const char *appid, uid_t db_uid,
769 uid_t target_uid, bool is_disabled, pkgmgr_appinfo_x **appinfo)
775 pkgmgr_appinfo_x *info;
777 dbpath = getUserPkgParserDBPathUID(db_uid);
779 return PMINFO_R_ERROR;
781 locale = _get_system_locale();
783 return PMINFO_R_ERROR;
785 ret = sqlite3_open_v2(dbpath, &db, SQLITE_OPEN_READONLY, NULL);
786 if (ret != SQLITE_OK) {
787 _LOGE("failed to open db: %d", ret);
789 return PMINFO_R_ERROR;
792 info = calloc(1, sizeof(pkgmgr_appinfo_x));
794 _LOGE("out of memory");
796 sqlite3_close_v2(db);
797 return PMINFO_R_ERROR;
800 ret = _appinfo_get_application(db, appid, locale, &info->app_info, is_disabled, db_uid, target_uid);
801 if (ret != PMINFO_R_OK) {
804 sqlite3_close_v2(db);
808 info->locale = locale;
809 info->package = strdup(info->app_info->package);
813 sqlite3_close_v2(db);
818 int _appinfo_get_applist(uid_t uid, const char *locale, GHashTable **appinfo_table)
820 int ret = PMINFO_R_ERROR;
824 char *bg_category_str = NULL;
827 sqlite3_stmt *stmt = NULL;
828 pkgmgr_appinfo_x *info = NULL;
829 application_x *appinfo = NULL;
831 dbpath = getUserPkgParserDBPathUID(uid);
833 return PMINFO_R_ERROR;
835 ret = sqlite3_open_v2(dbpath, &db, SQLITE_OPEN_READONLY, NULL);
836 if (ret != SQLITE_OK) {
837 _LOGE("failed to open db: %d", ret);
838 ret = PMINFO_R_ERROR;
842 query = sqlite3_mprintf("SELECT app_id, app_exec, app_type, "
843 "app_onboot, app_multiple, app_autorestart, app_taskmanage, "
844 "app_hwacceleration, app_permissiontype, app_preload, "
845 "app_installed_storage, app_process_pool, app_launch_mode, "
846 "app_package_type, component_type, package, app_tep_name, "
847 "app_background_category, app_root_path, app_api_version, "
848 "app_effective_appid, app_disable, app_splash_screen_display, "
849 "(CASE WHEN A.app_disable='true' THEN 'true' "
850 "ELSE (CASE WHEN (SELECT app_id FROM package_app_info_for_uid "
851 "WHERE app_id=A.app_id AND uid='%d' AND is_disabled='true') IS NULL "
852 "THEN 'false' ELSE 'true' END) END) AS app_disable "
853 "FROM package_app_info A", (int)getuid());
856 _LOGE("Out of memory");
860 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
861 if (ret != SQLITE_OK) {
862 LOGE("prepare failed: %s", sqlite3_errmsg(db));
863 ret = PMINFO_R_ERROR;
867 while (sqlite3_step(stmt) == SQLITE_ROW) {
868 info = calloc(1, sizeof(pkgmgr_appinfo_x));
869 appinfo = calloc(1, sizeof(application_x));
870 if (info == NULL || appinfo == NULL) {
871 LOGE("calloc failed");
872 ret = PMINFO_R_ERROR;
877 _save_column_str(stmt, idx++, &appinfo->appid);
878 _save_column_str(stmt, idx++, &appinfo->exec);
879 _save_column_str(stmt, idx++, &appinfo->type);
881 _save_column_str(stmt, idx++, &appinfo->onboot);
882 _save_column_str(stmt, idx++, &appinfo->multiple);
883 _save_column_str(stmt, idx++, &appinfo->autorestart);
884 _save_column_str(stmt, idx++, &appinfo->taskmanage);
886 _save_column_str(stmt, idx++, &appinfo->hwacceleration);
887 _save_column_str(stmt, idx++, &appinfo->permission_type);
888 _save_column_str(stmt, idx++, &appinfo->preload);
890 _save_column_str(stmt, idx++, &appinfo->installed_storage);
891 _save_column_str(stmt, idx++, &appinfo->process_pool);
892 _save_column_str(stmt, idx++, &appinfo->launch_mode);
894 _save_column_str(stmt, idx++, &appinfo->package_type);
895 _save_column_str(stmt, idx++, &appinfo->component_type);
896 _save_column_str(stmt, idx++, &appinfo->package);
897 _save_column_str(stmt, idx++, &appinfo->tep_name);
899 _save_column_str(stmt, idx++, &bg_category_str);
900 _save_column_str(stmt, idx++, &appinfo->root_path);
901 _save_column_str(stmt, idx++, &appinfo->api_version);
903 _save_column_str(stmt, idx++, &appinfo->effective_appid);
904 _save_column_str(stmt, idx++, &appinfo->is_disabled);
905 _save_column_str(stmt, idx++, &appinfo->splash_screen_display);
907 if (uid == GLOBAL_USER)
908 __get_splash_screen_display(db, appinfo->appid, uid,
909 &appinfo->splash_screen_display);
911 appinfo->background_category = __get_background_category(bg_category_str);
912 free(bg_category_str);
914 if (_appinfo_get_splashscreens(db, appinfo->appid, &appinfo->splashscreens)) {
915 pkgmgrinfo_basic_free_application(appinfo);
916 ret = PMINFO_R_ERROR;
920 info->locale = strdup(locale);
921 info->package = strdup(appinfo->package);
922 appinfo->for_all_users = strdup((uid != GLOBAL_USER) ? "false" : "true");
923 info->app_info = appinfo;
924 key = strdup(info->app_info->appid);
926 if (!g_hash_table_contains(*appinfo_table, (gconstpointer)key))
927 g_hash_table_insert(*appinfo_table, (gpointer)key, (gpointer)info);
929 __cleanup_appinfo(info);
936 sqlite3_finalize(stmt);
943 API int pkgmgrinfo_appinfo_get_usr_disabled_appinfo(const char *appid, uid_t uid,
944 pkgmgrinfo_appinfo_h *handle)
948 if (appid == NULL || handle == NULL) {
949 LOGE("invalid parameter");
950 return PMINFO_R_EINVAL;
953 ret = _appinfo_get_appinfo(appid, uid, uid, true, (pkgmgr_appinfo_x **)handle);
954 if (ret == PMINFO_R_ENOENT && uid != GLOBAL_USER)
955 ret = _appinfo_get_appinfo(appid, GLOBAL_USER, uid, true,
956 (pkgmgr_appinfo_x **)handle);
958 if (ret != PMINFO_R_OK)
959 _LOGI("Appinfo for [%s] is not existed for user [%d]", appid, uid);
964 API int pkgmgrinfo_appinfo_get_disabled_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
966 return pkgmgrinfo_appinfo_get_usr_disabled_appinfo(appid, _getuid(), handle);
969 API int pkgmgrinfo_appinfo_get_usr_appinfo(const char *appid, uid_t uid,
970 pkgmgrinfo_appinfo_h *handle)
974 if (appid == NULL || handle == NULL) {
975 LOGE("invalid parameter");
976 return PMINFO_R_EINVAL;
979 ret = _appinfo_get_appinfo(appid, uid, uid, false, (pkgmgr_appinfo_x **)handle);
980 if (ret == PMINFO_R_ENOENT && uid != GLOBAL_USER)
981 ret = _appinfo_get_appinfo(appid, GLOBAL_USER, uid, false,
982 (pkgmgr_appinfo_x **)handle);
983 if (ret != PMINFO_R_OK)
984 _LOGI("Appinfo for [%s] is not existed for user [%d]", appid, uid);
989 API int pkgmgrinfo_appinfo_get_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
991 return pkgmgrinfo_appinfo_get_usr_appinfo(appid, _getuid(), handle);
994 static gpointer __copy_str(gconstpointer src, gpointer data)
996 const char *tmp = (const char *)src;
999 buffer = strdup(tmp);
1000 if (buffer == NULL) {
1001 LOGE("memory alloc failed");
1009 static gpointer __copy_label(gconstpointer src, gpointer data)
1011 label_x *tmp = (label_x *)src;
1014 label = calloc(1, sizeof(label_x));
1015 if (label == NULL) {
1016 LOGE("memory alloc failed");
1022 label->name = strdup(tmp->name);
1024 label->text = strdup(tmp->text);
1026 label->lang = strdup(tmp->lang);
1031 static gpointer __copy_icon(gconstpointer src, gpointer data)
1033 icon_x *tmp = (icon_x *)src;
1036 icon = calloc(1, sizeof(icon_x));
1038 LOGE("memory alloc failed");
1044 icon->text = strdup(tmp->text);
1046 icon->lang = strdup(tmp->lang);
1048 icon->section = strdup(tmp->section);
1050 icon->size = strdup(tmp->size);
1051 if (tmp->resolution)
1052 icon->resolution = strdup(tmp->resolution);
1057 static gpointer __copy_metadata(gconstpointer src, gpointer data)
1059 metadata_x *tmp = (metadata_x *)src;
1060 metadata_x *metadata;
1062 metadata = calloc(1, sizeof(metadata_x));
1063 if (metadata == NULL) {
1064 LOGE("memory alloc failed");
1070 metadata->key = strdup(tmp->key);
1072 metadata->value = strdup(tmp->value);
1077 static gpointer __copy_datacontrol(gconstpointer src, gpointer data)
1079 datacontrol_x *tmp = (datacontrol_x *)src;
1080 datacontrol_x *datacontrol;
1082 datacontrol = calloc(1, sizeof(datacontrol_x));
1083 if (datacontrol == NULL) {
1084 LOGE("memory alloc failed");
1089 if (tmp->providerid)
1090 datacontrol->providerid = strdup(tmp->providerid);
1092 datacontrol->access = strdup(tmp->access);
1094 datacontrol->type = strdup(tmp->type);
1099 static gpointer __copy_appcontrol(gconstpointer src, gpointer data)
1101 appcontrol_x *tmp = (appcontrol_x *)src;
1102 appcontrol_x *appcontrol;
1104 appcontrol = calloc(1, sizeof(appcontrol_x));
1105 if (appcontrol ==NULL) {
1106 LOGE("memory alloc failed");
1112 appcontrol->operation = strdup(tmp->operation);
1114 appcontrol->uri = strdup(tmp->uri);
1116 appcontrol->mime = strdup(tmp->mime);
1121 static gpointer __copy_splashscreens(gconstpointer src, gpointer data)
1123 splashscreen_x *tmp = (splashscreen_x *)src;
1124 splashscreen_x *splashscreen;
1126 splashscreen = (splashscreen_x *)calloc(1, sizeof(splashscreen_x));
1127 if (splashscreen == NULL) {
1128 LOGE("memory alloc failed");
1134 splashscreen->src = strdup(tmp->src);
1136 splashscreen->type = strdup(tmp->type);
1137 if (tmp->orientation)
1138 splashscreen->orientation = strdup(tmp->orientation);
1139 if (tmp->indicatordisplay)
1140 splashscreen->indicatordisplay = strdup(tmp->indicatordisplay);
1142 splashscreen->operation = strdup(tmp->operation);
1144 return splashscreen;
1147 static int _appinfo_copy_appinfo(application_x **application, application_x *data)
1149 application_x *app_info;
1152 app_info = calloc(1, sizeof(application_x));
1153 if (app_info == NULL) {
1154 LOGE("memory alloc failed");
1155 return PMINFO_R_ERROR;
1158 if (data->appid != NULL)
1159 app_info->appid = strdup(data->appid);
1160 if (data->exec != NULL)
1161 app_info->exec = strdup(data->exec);
1162 if (data->nodisplay != NULL)
1163 app_info->nodisplay = strdup(data->nodisplay);
1164 if (data->multiple != NULL)
1165 app_info->multiple = strdup(data->multiple);
1166 if (data->taskmanage != NULL)
1167 app_info->taskmanage = strdup(data->taskmanage);
1168 if (data->enabled != NULL)
1169 app_info->enabled = strdup(data->enabled);
1170 if (data->type != NULL)
1171 app_info->type = strdup(data->type);
1172 if (data->categories != NULL)
1173 app_info->categories = strdup(data->categories);
1174 if (data->hwacceleration != NULL)
1175 app_info->hwacceleration = strdup(data->hwacceleration);
1176 if (data->screenreader != NULL)
1177 app_info->screenreader = strdup(data->screenreader);
1178 if (data->mainapp != NULL)
1179 app_info->mainapp = strdup(data->mainapp);
1180 if (data->package != NULL)
1181 app_info->package = strdup(data->package);
1182 if (data->recentimage != NULL)
1183 app_info->recentimage = strdup(data->recentimage);
1184 if (data->launchcondition != NULL)
1185 app_info->launchcondition = strdup(data->launchcondition);
1186 if (data->indicatordisplay != NULL)
1187 app_info->indicatordisplay = strdup(data->indicatordisplay);
1188 if (data->portraitimg != NULL)
1189 app_info->portraitimg = strdup(data->portraitimg);
1190 if (data->landscapeimg != NULL)
1191 app_info->landscapeimg = strdup(data->landscapeimg);
1192 if (data->guestmode_visibility != NULL)
1193 app_info->guestmode_visibility = strdup(data->guestmode_visibility);
1194 if (data->component != NULL)
1195 app_info->component = strdup(data->component);
1196 if (data->permission_type != NULL)
1197 app_info->permission_type = strdup(data->permission_type);
1198 if (data->component_type != NULL)
1199 app_info->component_type = strdup(data->component_type);
1200 if (data->preload != NULL)
1201 app_info->preload = strdup(data->preload);
1202 if (data->submode != NULL)
1203 app_info->submode = strdup(data->submode);
1204 if (data->submode_mainid != NULL)
1205 app_info->submode_mainid = strdup(data->submode_mainid);
1206 if (data->process_pool != NULL)
1207 app_info->process_pool = strdup(data->process_pool);
1208 if (data->installed_storage != NULL)
1209 app_info->installed_storage = strdup(data->installed_storage);
1210 if (data->autorestart != NULL)
1211 app_info->autorestart = strdup(data->autorestart);
1212 if (data->onboot != NULL)
1213 app_info->onboot = strdup(data->onboot);
1214 if (data->support_disable != NULL)
1215 app_info->support_disable = strdup(data->support_disable);
1216 if (data->ui_gadget != NULL)
1217 app_info->ui_gadget = strdup(data->ui_gadget);
1218 if (data->launch_mode != NULL)
1219 app_info->launch_mode = strdup(data->launch_mode);
1220 if (data->package_type != NULL)
1221 app_info->package_type = strdup(data->package_type);
1222 if (data->effective_appid != NULL)
1223 app_info->effective_appid = strdup(data->effective_appid);
1224 if (data->splash_screen_display != NULL)
1225 app_info->splash_screen_display = strdup(data->splash_screen_display);
1229 app_info->label = g_list_copy_deep(data->label, __copy_label, &ret);
1231 LOGE("memory alloc failed");
1232 pkgmgrinfo_basic_free_application(app_info);
1233 return PMINFO_R_ERROR;
1237 app_info->icon = g_list_copy_deep(data->icon, __copy_icon, &ret);
1239 LOGE("memory alloc failed");
1240 pkgmgrinfo_basic_free_application(app_info);
1241 return PMINFO_R_ERROR;
1245 app_info->category = g_list_copy_deep(data->category, __copy_str, &ret);
1247 LOGE("memory alloc failed");
1248 pkgmgrinfo_basic_free_application(app_info);
1249 return PMINFO_R_ERROR;
1253 app_info->metadata = g_list_copy_deep(data->metadata, __copy_metadata, &ret);
1255 LOGE("memory alloc failed");
1256 pkgmgrinfo_basic_free_application(app_info);
1257 return PMINFO_R_ERROR;
1261 app_info->datacontrol = g_list_copy_deep(data->datacontrol, __copy_datacontrol, &ret);
1263 LOGE("memory alloc failed");
1264 pkgmgrinfo_basic_free_application(app_info);
1265 return PMINFO_R_ERROR;
1269 app_info->appcontrol = g_list_copy_deep(data->appcontrol, __copy_appcontrol, &ret);
1271 LOGE("memory alloc failed");
1272 pkgmgrinfo_basic_free_application(app_info);
1273 return PMINFO_R_ERROR;
1277 app_info->background_category = g_list_copy_deep(data->background_category, __copy_str, &ret);
1279 LOGE("memory alloc failed");
1280 pkgmgrinfo_basic_free_application(app_info);
1281 return PMINFO_R_ERROR;
1285 app_info->splashscreens = g_list_copy_deep(data->splashscreens, __copy_splashscreens, &ret);
1287 LOGE("memory alloc failed");
1288 pkgmgrinfo_basic_free_application(app_info);
1289 return PMINFO_R_ERROR;
1292 *application = app_info;
1297 API int pkgmgrinfo_appinfo_clone_appinfo(pkgmgrinfo_appinfo_h handle,
1298 pkgmgrinfo_appinfo_h *clone)
1300 pkgmgr_appinfo_x *info;
1301 pkgmgr_appinfo_x *temp = (pkgmgr_appinfo_x *)handle;
1304 return PMINFO_R_EINVAL;
1306 info = calloc(1, sizeof(pkgmgr_appinfo_x));
1308 LOGE("memory alloc failed");
1309 return PMINFO_R_ERROR;
1312 if (temp->package != NULL)
1313 info->package = strdup(temp->package);
1314 if (temp->locale != NULL)
1315 info->locale = strdup(temp->locale);
1317 info->app_component = temp->app_component;
1319 if (_appinfo_copy_appinfo(&info->app_info, temp->app_info) < 0) {
1320 LOGE("appinfo copy failed");
1322 free((void *)info->package);
1326 return PMINFO_R_ERROR;
1334 static int _appinfo_get_filtered_foreach_appinfo(uid_t uid,
1335 pkgmgrinfo_filter_x *filter, pkgmgrinfo_app_list_cb app_list_cb,
1339 pkgmgr_appinfo_x *info;
1345 ret = _appinfo_get_filtered_list(filter, uid, &list);
1346 if (ret != PMINFO_R_OK)
1347 return PMINFO_R_ERROR;
1349 for (tmp = list; tmp; tmp = tmp->next) {
1350 appid = (char *)tmp->data;
1352 ret = _appinfo_get_appinfo(appid, uid, uid, false, &info);
1353 if (ret == PMINFO_R_ENOENT && uid != GLOBAL_USER)
1354 ret = _appinfo_get_appinfo(appid, GLOBAL_USER, uid, false,
1356 if (ret != PMINFO_R_OK) {
1360 if (app_list_cb(info, user_data) < 0)
1362 pkgmgrinfo_appinfo_destroy_appinfo(info);
1372 API int pkgmgrinfo_appinfo_get_usr_list(pkgmgrinfo_pkginfo_h handle,
1373 pkgmgrinfo_app_component component,
1374 pkgmgrinfo_app_list_cb app_func, void *user_data, uid_t uid)
1377 pkgmgrinfo_appinfo_filter_h filter;
1379 const char *comp_str = NULL;
1381 if (handle == NULL || app_func == NULL) {
1382 LOGE("invalid parameter");
1383 return PMINFO_R_EINVAL;
1386 if (pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid)) {
1387 LOGE("invalid parameter");
1388 return PMINFO_R_EINVAL;
1391 if (pkgmgrinfo_appinfo_filter_create(&filter))
1392 return PMINFO_R_ERROR;
1394 if (pkgmgrinfo_appinfo_filter_add_string(filter,
1395 PMINFO_APPINFO_PROP_APP_PACKAGE, pkgid)) {
1396 pkgmgrinfo_appinfo_filter_destroy(filter);
1397 return PMINFO_R_ERROR;
1400 if (uid == GLOBAL_USER) {
1401 if (pkgmgrinfo_appinfo_filter_add_int(filter,
1402 PMINFO_APPINFO_PROP_APP_DISABLE_FOR_USER, (int)getuid())) {
1403 pkgmgrinfo_appinfo_filter_destroy(filter);
1404 return PMINFO_R_ERROR;
1408 switch (component) {
1410 comp_str = PMINFO_APPINFO_UI_APP;
1412 case PMINFO_SVC_APP:
1413 comp_str = PMINFO_APPINFO_SVC_APP;
1420 if (pkgmgrinfo_appinfo_filter_add_string(filter,
1421 PMINFO_APPINFO_PROP_APP_COMPONENT,
1423 pkgmgrinfo_appinfo_filter_destroy(filter);
1424 return PMINFO_R_ERROR;
1428 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter, app_func,
1431 pkgmgrinfo_appinfo_filter_destroy(filter);
1436 API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_component component,
1437 pkgmgrinfo_app_list_cb app_func, void *user_data)
1439 return pkgmgrinfo_appinfo_get_usr_list(handle, component, app_func, user_data, _getuid());
1442 API int pkgmgrinfo_appinfo_get_usr_applist_for_amd(pkgmgrinfo_app_list_cb app_func, uid_t uid, void *user_data)
1444 int ret = PMINFO_R_ERROR;
1445 char *locale = NULL;
1446 GHashTable *appinfo_table;
1447 GHashTableIter iter;
1449 pkgmgr_appinfo_x *val;
1451 locale = _get_system_locale();
1453 return PMINFO_R_ERROR;
1455 appinfo_table = g_hash_table_new_full(g_str_hash, g_str_equal,
1456 free, __free_appinfo_list);
1457 if (appinfo_table == NULL) {
1462 ret = _appinfo_get_applist(uid, locale, &appinfo_table);
1463 if (ret != PMINFO_R_OK) {
1464 LOGE("failed get applist[%d]", (int)uid);
1468 if (uid != GLOBAL_USER) {
1469 ret = _appinfo_get_applist(GLOBAL_USER, locale, &appinfo_table);
1470 if (ret != PMINFO_R_OK) {
1471 LOGE("failed get applist[%d]", GLOBAL_USER);
1476 g_hash_table_iter_init(&iter, appinfo_table);
1477 while (g_hash_table_iter_next(&iter, (gpointer)&key, (gpointer)&val)) {
1478 ret = app_func((void *)val, user_data);
1479 if (ret != PMINFO_R_OK) {
1480 LOGE("callback is stopped");
1490 g_hash_table_destroy(appinfo_table);
1495 API int pkgmgrinfo_appinfo_get_applist_for_amd(pkgmgrinfo_app_list_cb app_func, void *user_data)
1497 return pkgmgrinfo_appinfo_get_usr_applist_for_amd(app_func, _getuid(), user_data);
1500 API int pkgmgrinfo_appinfo_get_usr_installed_list(pkgmgrinfo_app_list_cb app_func, uid_t uid, void *user_data)
1502 if (app_func == NULL) {
1503 LOGE("invalid parameter");
1504 return PMINFO_R_EINVAL;
1507 return _appinfo_get_filtered_foreach_appinfo(uid, NULL, app_func,
1511 API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func, void *user_data)
1513 return pkgmgrinfo_appinfo_get_usr_installed_list(app_func, _getuid(), user_data);
1516 API int pkgmgrinfo_appinfo_get_appid(pkgmgrinfo_appinfo_h handle, char **appid)
1518 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1520 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1521 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1523 if (info->app_info == NULL || info->app_info->appid == NULL)
1524 return PMINFO_R_ERROR;
1525 *appid = (char *)info->app_info->appid;
1530 API int pkgmgrinfo_appinfo_get_pkgname(pkgmgrinfo_appinfo_h handle, char **pkg_name)
1532 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1534 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1535 retvm_if(pkg_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1537 if (info->package == NULL)
1538 return PMINFO_R_ERROR;
1540 *pkg_name = (char *)info->package;
1545 API int pkgmgrinfo_appinfo_get_pkgid(pkgmgrinfo_appinfo_h handle, char **pkgid)
1547 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1549 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1550 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1552 if (info->package == NULL)
1553 return PMINFO_R_ERROR;
1555 *pkgid = (char *)info->package;
1560 API int pkgmgrinfo_appinfo_get_pkgtype(pkgmgrinfo_appinfo_h handle, char **pkgtype)
1562 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1563 retvm_if(pkgtype == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1564 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1566 *pkgtype = (char *)info->app_info->package_type;
1571 API int pkgmgrinfo_appinfo_get_exec(pkgmgrinfo_appinfo_h handle, char **exec)
1573 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1575 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1576 retvm_if(exec == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1578 if (info->app_info == NULL || info->app_info->exec == NULL)
1579 return PMINFO_R_ERROR;
1580 *exec = (char *)info->app_info->exec;
1586 API int pkgmgrinfo_appinfo_get_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1591 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1593 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1594 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1596 locale = info->locale;
1597 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
1599 if (info->app_info == NULL)
1600 return PMINFO_R_ERROR;
1602 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1603 ptr = (icon_x *)tmp->data;
1604 if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL ||
1605 !strcasecmp(ptr->text, "") ||
1606 strcmp(ptr->lang, locale))
1608 *icon = (char *)ptr->text;
1612 locale = DEFAULT_LOCALE;
1613 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1614 ptr = (icon_x *)tmp->data;
1615 if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL ||
1616 strcmp(ptr->lang, locale))
1618 *icon = (char *)ptr->text;
1622 return PMINFO_R_ERROR;
1626 API int pkgmgrinfo_appinfo_get_label(pkgmgrinfo_appinfo_h handle, char **label)
1631 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1633 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1634 retvm_if(label == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1636 locale = info->locale;
1637 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
1639 if (info->app_info == NULL)
1640 return PMINFO_R_ERROR;
1642 for (tmp = info->app_info->label; tmp; tmp = tmp->next) {
1643 ptr = (label_x *)tmp->data;
1644 if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL ||
1645 strcmp(ptr->lang, locale))
1647 *label = (char *)ptr->text;
1651 locale = DEFAULT_LOCALE;
1652 for (tmp = info->app_info->label; tmp; tmp = tmp->next) {
1653 ptr = (label_x *)tmp->data;
1654 if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL ||
1655 strcmp(ptr->lang, locale))
1657 *label = (char *)ptr->text;
1661 return PMINFO_R_ERROR;
1664 static char *_get_localed_label(const char *appid, const char *locale, uid_t uid)
1666 char *result = NULL;
1668 sqlite3_stmt *stmt = NULL;
1671 const char *manifest_db;
1673 manifest_db = getUserPkgParserDBPathUID(uid);
1674 if (manifest_db == NULL) {
1675 _LOGE("Failed to get manifest db path");
1679 if (sqlite3_open_v2(manifest_db, &db, SQLITE_OPEN_READONLY, NULL) != SQLITE_OK) {
1680 _LOGE("DB open fail\n");
1684 query = sqlite3_mprintf("select app_label from package_app_localized_info where app_id=%Q and app_locale=%Q", appid, locale);
1685 if (query == NULL) {
1686 _LOGE("Out of memory");
1690 if (sqlite3_prepare_v2(db, query, -1, &stmt, NULL) != SQLITE_OK) {
1691 _LOGE("prepare_v2 fail\n");
1695 if (sqlite3_step(stmt) == SQLITE_ROW) {
1696 val = (char *)sqlite3_column_text(stmt, 0);
1698 result = strdup(val);
1702 sqlite3_finalize(stmt);
1703 sqlite3_free(query);
1709 API int pkgmgrinfo_appinfo_usr_get_localed_label(const char *appid, const char *locale, uid_t uid, char **label)
1713 retvm_if(appid == NULL || locale == NULL || label == NULL, PMINFO_R_EINVAL, "Argument is NULL");
1715 val = _get_localed_label(appid, locale, uid);
1717 val = _get_localed_label(appid, DEFAULT_LOCALE, uid);
1720 return PMINFO_R_ERROR;
1727 API int pkgmgrinfo_appinfo_get_localed_label(const char *appid, const char *locale, char **label)
1729 return pkgmgrinfo_appinfo_usr_get_localed_label(appid, locale, _getuid(), label);
1732 API int pkgmgrinfo_appinfo_get_metadata_value(pkgmgrinfo_appinfo_h handle, const char *metadata_key, char **metadata_value)
1734 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1735 retvm_if(metadata_key == NULL, PMINFO_R_EINVAL, "metadata_key is NULL");
1736 retvm_if(metadata_value == NULL, PMINFO_R_EINVAL, "metadata_value is NULL");
1738 GList *list_md = NULL;
1739 metadata_x *metadata = NULL;
1740 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1742 list_md = info->app_info->metadata;
1744 for (; list_md; list_md = list_md->next) {
1745 metadata = (metadata_x *)list_md->data;
1746 if (metadata && metadata->key) {
1747 if (strcasecmp(metadata->key, metadata_key) == 0) {
1748 *metadata_value = (char*)metadata->value;
1754 return PMINFO_R_EINVAL;
1757 static pkgmgrinfo_app_component __appcomponent_convert(const char *comp)
1759 if (strcasecmp(comp, "uiapp") == 0)
1760 return PMINFO_UI_APP;
1761 else if (strcasecmp(comp, "svcapp") == 0)
1762 return PMINFO_SVC_APP;
1763 else if (strcasecmp(comp, "widgetapp") == 0)
1764 return PMINFO_WIDGET_APP;
1765 else if (strcasecmp(comp, "watchapp") == 0)
1766 return PMINFO_WATCH_APP;
1771 API int pkgmgrinfo_appinfo_get_component(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_component *component)
1773 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1776 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1777 retvm_if(component == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1779 if (info->app_info == NULL)
1780 return PMINFO_R_ERROR;
1782 comp = __appcomponent_convert(info->app_info->component);
1784 return PMINFO_R_ERROR;
1791 API int pkgmgrinfo_appinfo_get_apptype(pkgmgrinfo_appinfo_h handle, char **app_type)
1793 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1795 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1796 retvm_if(app_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1798 if (info->app_info == NULL || info->app_info->type == NULL)
1799 return PMINFO_R_ERROR;
1800 *app_type = (char *)info->app_info->type;
1805 API int pkgmgrinfo_appinfo_get_operation(pkgmgrinfo_appcontrol_h handle,
1806 int *operation_count, char ***operation)
1808 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1809 retvm_if(operation == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1810 retvm_if(operation_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1811 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1812 *operation_count = data->operation_count;
1813 *operation = data->operation;
1817 API int pkgmgrinfo_appinfo_get_uri(pkgmgrinfo_appcontrol_h handle,
1818 int *uri_count, char ***uri)
1820 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1821 retvm_if(uri == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1822 retvm_if(uri_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1823 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1824 *uri_count = data->uri_count;
1829 API int pkgmgrinfo_appinfo_get_mime(pkgmgrinfo_appcontrol_h handle,
1830 int *mime_count, char ***mime)
1832 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1833 retvm_if(mime == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1834 retvm_if(mime_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1835 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1836 *mime_count = data->mime_count;
1841 API int pkgmgrinfo_appinfo_get_subapp(pkgmgrinfo_appcontrol_h handle,
1842 int *subapp_count, char ***subapp)
1844 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1845 retvm_if(subapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1846 retvm_if(subapp_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1847 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1848 *subapp_count = data->subapp_count;
1849 *subapp = data->subapp;
1853 API int pkgmgrinfo_appinfo_get_setting_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1858 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1860 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1861 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1863 if (info->app_info == NULL)
1864 return PMINFO_R_ERROR;
1866 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1867 ptr = (icon_x *)tmp->data;
1868 if (ptr == NULL || ptr->section == NULL)
1871 val = (char *)ptr->section;
1872 if (val && strcmp(val, "setting") == 0) {
1873 *icon = (char *)ptr->text;
1878 return PMINFO_R_ERROR;
1882 API int pkgmgrinfo_appinfo_get_notification_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1887 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1889 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1890 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1892 if (info->app_info == NULL)
1893 return PMINFO_R_ERROR;
1895 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1896 ptr = (icon_x *)tmp->data;
1897 if (ptr == NULL || ptr->section == NULL)
1900 val = (char *)ptr->section;
1901 if (val && strcmp(val, "notification") == 0){
1902 *icon = (char *)ptr->text;
1907 return PMINFO_R_ERROR;
1910 API int pkgmgrinfo_appinfo_get_recent_image_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_recentimage *type)
1913 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1915 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1916 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1918 if (info->app_info == NULL || info->app_info->recentimage == NULL)
1919 return PMINFO_R_ERROR;
1921 val = (char *)info->app_info->recentimage;
1922 if (strcasecmp(val, "capture") == 0)
1923 *type = PMINFO_RECENTIMAGE_USE_CAPTURE;
1924 else if (strcasecmp(val, "icon") == 0)
1925 *type = PMINFO_RECENTIMAGE_USE_ICON;
1927 *type = PMINFO_RECENTIMAGE_USE_NOTHING;
1932 API int pkgmgrinfo_appinfo_get_preview_image(pkgmgrinfo_appinfo_h handle, char **preview_img)
1937 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1939 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1940 retvm_if(preview_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1942 if (info->app_info == NULL)
1943 return PMINFO_R_ERROR;
1945 for (tmp = info->app_info->image; tmp; tmp = tmp->next) {
1946 ptr = (image_x *)tmp->data;
1947 if (ptr == NULL || ptr->section == NULL)
1950 val = (char *)ptr->section;
1951 if (val && strcmp(val, "preview") == 0) {
1952 *preview_img = (char *)ptr->text;
1957 return PMINFO_R_ERROR;
1960 API int pkgmgrinfo_appinfo_get_permission_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_permission_type *permission)
1963 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1965 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1966 retvm_if(permission == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1968 val = info->app_info->permission_type;
1970 return PMINFO_R_ERROR;
1972 if (strcmp(val, "signature") == 0)
1973 *permission = PMINFO_PERMISSION_SIGNATURE;
1974 else if (strcmp(val, "privilege") == 0)
1975 *permission = PMINFO_PERMISSION_PRIVILEGE;
1977 *permission = PMINFO_PERMISSION_NORMAL;
1982 API int pkgmgrinfo_appinfo_get_component_type(pkgmgrinfo_appinfo_h handle, char **component_type)
1984 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1986 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1987 retvm_if(component_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1989 if (info->app_info == NULL || info->app_info->component_type == NULL)
1990 return PMINFO_R_ERROR;
1992 *component_type = (char *)info->app_info->component_type;
1997 API int pkgmgrinfo_appinfo_get_hwacceleration(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_hwacceleration *hwacceleration)
2000 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2002 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2003 retvm_if(hwacceleration == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2005 if (info->app_info == NULL || info->app_info->hwacceleration == NULL)
2006 return PMINFO_R_ERROR;
2008 val = (char *)info->app_info->hwacceleration;
2009 if (strcasecmp(val, "not-use-GL") == 0)
2010 *hwacceleration = PMINFO_HWACCELERATION_NOT_USE_GL;
2011 else if (strcasecmp(val, "use-GL") == 0)
2012 *hwacceleration = PMINFO_HWACCELERATION_USE_GL;
2014 *hwacceleration = PMINFO_HWACCELERATION_USE_SYSTEM_SETTING;
2019 API int pkgmgrinfo_appinfo_get_screenreader(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_screenreader *screenreader)
2022 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2024 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2025 retvm_if(screenreader == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2027 if (info->app_info == NULL || info->app_info->screenreader == NULL)
2028 return PMINFO_R_ERROR;
2030 val = (char *)info->app_info->screenreader;
2031 if (strcasecmp(val, "screenreader-off") == 0)
2032 *screenreader = PMINFO_SCREENREADER_OFF;
2033 else if (strcasecmp(val, "screenreader-on") == 0)
2034 *screenreader = PMINFO_SCREENREADER_ON;
2036 *screenreader = PMINFO_SCREENREADER_USE_SYSTEM_SETTING;
2041 API int pkgmgrinfo_appinfo_get_effectimage(pkgmgrinfo_appinfo_h handle, char **portrait_img, char **landscape_img)
2043 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2045 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2046 retvm_if(portrait_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2047 retvm_if(landscape_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2049 if (info->app_info == NULL || (info->app_info->portraitimg == NULL
2050 && info->app_info->landscapeimg == NULL))
2051 return PMINFO_R_ERROR;
2053 *portrait_img = (char *)info->app_info->portraitimg;
2054 *landscape_img = (char *)info->app_info->landscapeimg;
2059 API int pkgmgrinfo_appinfo_get_effectimage_type(pkgmgrinfo_appinfo_h handle, char **effectimage_type)
2061 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2063 if (handle == NULL || effectimage_type == NULL) {
2064 LOGE("invalid parameter");
2065 return PMINFO_R_EINVAL;
2068 if (info->app_info == NULL || info->app_info->effectimage_type == NULL)
2069 return PMINFO_R_ERROR;
2071 *effectimage_type = (char *)info->app_info->effectimage_type;
2076 API int pkgmgrinfo_appinfo_get_submode_mainid(pkgmgrinfo_appinfo_h handle, char **submode_mainid)
2078 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2080 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2081 retvm_if(submode_mainid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2083 if (info->app_info == NULL || info->app_info->submode_mainid == NULL)
2084 return PMINFO_R_ERROR;
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;
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 || info->app_info->effective_appid == NULL)
2151 return PMINFO_R_ERROR;
2153 *effective_appid = (char *)info->app_info->effective_appid;
2158 API int pkgmgrinfo_appinfo_get_tep_name(pkgmgrinfo_appinfo_h handle, char **tep_name)
2160 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2162 if (handle == NULL || tep_name == NULL) {
2163 LOGE("invalid parameter");
2164 return PMINFO_R_EINVAL;
2167 if (info->app_info == NULL || info->app_info->tep_name == NULL)
2168 return PMINFO_R_ERROR;
2170 *tep_name = (char *)info->app_info->tep_name;
2175 API int pkgmgrinfo_appinfo_get_root_path(pkgmgrinfo_appinfo_h handle, char **root_path)
2177 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2179 if (handle == NULL || root_path == NULL) {
2180 LOGE("invalid parameter");
2181 return PMINFO_R_EINVAL;
2184 if (info->app_info == NULL || info->app_info->root_path == NULL)
2185 return PMINFO_R_ERROR;
2187 *root_path = (char *)info->app_info->root_path;
2192 API int pkgmgrinfo_appinfo_get_api_version(pkgmgrinfo_appinfo_h handle, char **api_version)
2194 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2196 if (handle == NULL || api_version == NULL) {
2197 LOGE("invalid parameter");
2198 return PMINFO_R_EINVAL;
2201 if (info->app_info == NULL || info->app_info->api_version == NULL)
2202 return PMINFO_R_ERROR;
2204 *api_version = (char *)info->app_info->api_version;
2209 API int pkgmgrinfo_appinfo_usr_get_datacontrol_info(const char *providerid, const char *type, uid_t uid, char **appid, char **access)
2211 retvm_if(providerid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
2212 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
2213 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2214 retvm_if(access == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2216 int ret = PMINFO_R_OK;
2218 sqlite3_stmt *stmt = NULL;
2221 ret = __open_manifest_db(uid, true);
2222 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
2224 /*Start constructing query*/
2225 query = sqlite3_mprintf("select * from package_app_data_control where providerid=%Q and type=%Q", providerid, type);
2228 ret = sqlite3_prepare_v2(GET_DB(manifest_db), query, strlen(query), &stmt, NULL);
2229 tryvm_if(ret != PMINFO_R_OK, ret = PMINFO_R_ERROR, "sqlite3_prepare_v2 failed[%s]\n", query);
2232 ret = sqlite3_step(stmt);
2233 tryvm_if((ret != SQLITE_ROW) || (ret == SQLITE_DONE), ret = PMINFO_R_ERROR, "No records found");
2235 *appid = strdup((char *)sqlite3_column_text(stmt, 0));
2236 *access = strdup((char *)sqlite3_column_text(stmt, 2));
2241 sqlite3_free(query);
2242 sqlite3_finalize(stmt);
2243 __close_manifest_db();
2247 API int pkgmgrinfo_appinfo_get_datacontrol_info(const char *providerid, const char *type, char **appid, char **access)
2249 return pkgmgrinfo_appinfo_usr_get_datacontrol_info(providerid, type, _getuid(), appid, access);
2252 API int pkgmgrinfo_appinfo_usr_get_datacontrol_appid(const char *providerid, uid_t uid, char **appid)
2254 retvm_if(providerid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
2255 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2257 int ret = PMINFO_R_OK;
2259 sqlite3_stmt *stmt = NULL;
2262 ret = __open_manifest_db(uid, true);
2263 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
2265 /*Start constructing query*/
2266 query = sqlite3_mprintf("select * from package_app_data_control where providerid=%Q", providerid);
2269 ret = sqlite3_prepare_v2(GET_DB(manifest_db), query, strlen(query), &stmt, NULL);
2270 tryvm_if(ret != PMINFO_R_OK, ret = PMINFO_R_ERROR, "sqlite3_prepare_v2 failed[%s]\n", query);
2273 ret = sqlite3_step(stmt);
2274 tryvm_if((ret != SQLITE_ROW) || (ret == SQLITE_DONE), ret = PMINFO_R_ERROR, "No records found");
2276 *appid = strdup((char *)sqlite3_column_text(stmt, 0));
2281 sqlite3_free(query);
2282 sqlite3_finalize(stmt);
2283 __close_manifest_db();
2287 API int pkgmgrinfo_appinfo_get_datacontrol_appid(const char *providerid, char **appid)
2289 return pkgmgrinfo_appinfo_usr_get_datacontrol_appid(providerid, _getuid(), appid);
2292 API int pkgmgrinfo_appinfo_foreach_permission(pkgmgrinfo_appinfo_h handle,
2293 pkgmgrinfo_app_permission_list_cb permission_func, void *user_data)
2295 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2296 retvm_if(permission_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2300 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2302 if (info->app_info == NULL)
2303 return PMINFO_R_ERROR;
2305 for (tmp = info->app_info->permission; tmp; tmp = tmp->next) {
2306 ptr = (permission_x *)tmp->data;
2310 ret = permission_func(ptr->value, user_data);
2318 API int pkgmgrinfo_appinfo_foreach_category(pkgmgrinfo_appinfo_h handle,
2319 pkgmgrinfo_app_category_list_cb category_func, void *user_data)
2321 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2322 retvm_if(category_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2324 const char *category;
2326 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2328 if (info->app_info == NULL)
2329 return PMINFO_R_ERROR;
2331 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
2332 category = (const char *)tmp->data;
2334 ret = category_func(category, user_data);
2342 API int pkgmgrinfo_appinfo_foreach_metadata(pkgmgrinfo_appinfo_h handle,
2343 pkgmgrinfo_app_metadata_list_cb metadata_func, void *user_data)
2345 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2346 retvm_if(metadata_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2350 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2352 if (info->app_info == NULL)
2353 return PMINFO_R_ERROR;
2355 for (tmp = info->app_info->metadata; tmp; tmp = tmp->next) {
2356 ptr = (metadata_x *)tmp->data;
2360 ret = metadata_func(ptr->key, ptr->value, user_data);
2368 API int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
2369 pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
2371 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2372 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2374 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2375 appcontrol_x *appcontrol;
2378 if (info->app_info == NULL)
2379 return PMINFO_R_ERROR;
2381 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
2382 appcontrol = (appcontrol_x *)tmp->data;
2383 if (appcontrol == NULL)
2385 ret = appcontrol_func(appcontrol->operation, appcontrol->uri, appcontrol->mime, user_data);
2393 API int pkgmgrinfo_appinfo_foreach_background_category(
2394 pkgmgrinfo_appinfo_h handle,
2395 pkgmgrinfo_app_background_category_list_cb category_func,
2398 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2402 if (handle == NULL || category_func == NULL || info->app_info == NULL) {
2403 LOGE("invalid parameter");
2404 return PMINFO_R_EINVAL;
2407 for (tmp = info->app_info->background_category; tmp; tmp = tmp->next) {
2408 category = (char *)tmp->data;
2409 if (category == NULL)
2412 if (category_func(category, user_data) < 0)
2419 API int pkgmgrinfo_appinfo_foreach_splash_screen(pkgmgrinfo_appinfo_h handle,
2420 pkgmgrinfo_app_splash_screen_list_cb splash_screen_func,
2423 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2424 splashscreen_x *splashscreen;
2428 if (info == NULL || info->app_info == NULL
2429 || splash_screen_func == NULL) {
2430 LOGE("invalid parameter");
2431 return PMINFO_R_EINVAL;
2434 for (tmp = info->app_info->splashscreens; tmp; tmp = tmp->next) {
2435 splashscreen = (splashscreen_x *)tmp->data;
2436 if (splashscreen == NULL)
2438 ret = splash_screen_func(splashscreen->src,
2440 splashscreen->orientation,
2441 splashscreen->indicatordisplay,
2442 splashscreen->operation,
2451 API int pkgmgrinfo_appinfo_is_nodisplay(pkgmgrinfo_appinfo_h handle, bool *nodisplay)
2453 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2454 retvm_if(nodisplay == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2455 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2457 if (info->app_info == NULL || info->app_info->nodisplay == NULL)
2458 return PMINFO_R_ERROR;
2460 *nodisplay = _get_bool_value(info->app_info->nodisplay);
2465 API int pkgmgrinfo_appinfo_is_multiple(pkgmgrinfo_appinfo_h handle, bool *multiple)
2467 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2468 retvm_if(multiple == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2469 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2471 if (info->app_info == NULL || info->app_info->multiple == NULL)
2472 return PMINFO_R_ERROR;
2474 *multiple = _get_bool_value(info->app_info->multiple);
2479 API int pkgmgrinfo_appinfo_is_indicator_display_allowed(pkgmgrinfo_appinfo_h handle, bool *indicator_disp)
2481 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2482 retvm_if(indicator_disp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2483 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2485 if (info->app_info == NULL || info->app_info->indicatordisplay == NULL)
2486 return PMINFO_R_ERROR;
2488 *indicator_disp = _get_bool_value(info->app_info->indicatordisplay);
2493 API int pkgmgrinfo_appinfo_is_taskmanage(pkgmgrinfo_appinfo_h handle, bool *taskmanage)
2495 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2496 retvm_if(taskmanage == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2497 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2499 if (info->app_info == NULL || info->app_info->taskmanage == NULL)
2500 return PMINFO_R_ERROR;
2502 *taskmanage = _get_bool_value(info->app_info->taskmanage);
2507 API int pkgmgrinfo_appinfo_is_enabled(pkgmgrinfo_appinfo_h handle, bool *enabled)
2509 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2510 retvm_if(enabled == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2511 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2513 if (info->app_info == NULL || info->app_info->enabled == NULL)
2514 return PMINFO_R_ERROR;
2516 *enabled = _get_bool_value(info->app_info->enabled);
2521 API int pkgmgrinfo_appinfo_is_onboot(pkgmgrinfo_appinfo_h handle, bool *onboot)
2523 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2524 retvm_if(onboot == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2525 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2527 if (info->app_info == NULL || info->app_info->onboot == NULL)
2528 return PMINFO_R_ERROR;
2530 *onboot = _get_bool_value(info->app_info->onboot);
2535 API int pkgmgrinfo_appinfo_is_autorestart(pkgmgrinfo_appinfo_h handle, bool *autorestart)
2537 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2538 retvm_if(autorestart == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2539 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2541 if (info->app_info == NULL || info->app_info->autorestart == NULL)
2542 return PMINFO_R_ERROR;
2544 *autorestart = _get_bool_value(info->app_info->autorestart);
2549 API int pkgmgrinfo_appinfo_is_mainapp(pkgmgrinfo_appinfo_h handle, bool *mainapp)
2551 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2552 retvm_if(mainapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2553 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2555 if (info->app_info == NULL || info->app_info->mainapp == NULL)
2556 return PMINFO_R_ERROR;
2558 *mainapp = _get_bool_value(info->app_info->mainapp);
2563 API int pkgmgrinfo_appinfo_is_preload(pkgmgrinfo_appinfo_h handle, bool *preload)
2565 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2566 retvm_if(preload == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2567 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2569 if (info->app_info == NULL || info->app_info->preload == NULL)
2570 return PMINFO_R_ERROR;
2572 *preload = _get_bool_value(info->app_info->preload);
2577 API int pkgmgrinfo_appinfo_is_submode(pkgmgrinfo_appinfo_h handle, bool *submode)
2579 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2580 retvm_if(submode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2581 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2583 if (info->app_info == NULL || info->app_info->submode == NULL)
2584 return PMINFO_R_ERROR;
2586 *submode = _get_bool_value(info->app_info->submode);
2591 API int pkgmgrinfo_appinfo_is_process_pool(pkgmgrinfo_appinfo_h handle, bool *process_pool)
2593 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2595 if (handle == NULL || process_pool == NULL) {
2596 LOGE("invalid parameter");
2597 return PMINFO_R_EINVAL;
2600 if (info->app_info == NULL)
2601 return PMINFO_R_ERROR;
2603 *process_pool = _get_bool_value(info->app_info->process_pool);
2608 API int pkgmgrinfo_appinfo_is_category_exist(pkgmgrinfo_appinfo_h handle, const char *category, bool *exist)
2610 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2611 retvm_if(category == NULL, PMINFO_R_EINVAL, "category is NULL");
2612 retvm_if(exist == NULL, PMINFO_R_EINVAL, "exist is NULL");
2616 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2618 if (info->app_info == NULL)
2619 return PMINFO_R_ERROR;
2622 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
2623 val = (const char *)tmp->data;
2626 if (strcasecmp(val, category) == 0) {
2635 API int pkgmgrinfo_appinfo_is_ui_gadget(pkgmgrinfo_appinfo_h handle,
2638 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2640 if (info == NULL || info->app_info == NULL || ui_gadget == NULL) {
2641 _LOGE("invalid parameter");
2642 return PMINFO_R_EINVAL;
2645 *ui_gadget = _get_bool_value(info->app_info->ui_gadget);
2650 API int pkgmgrinfo_appinfo_is_support_disable(pkgmgrinfo_appinfo_h handle,
2651 bool *support_disable)
2653 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2655 if (info == NULL || info->app_info == NULL || support_disable == NULL) {
2656 _LOGE("invalid parameter");
2657 return PMINFO_R_EINVAL;
2660 *support_disable = _get_bool_value(info->app_info->support_disable);
2665 API int pkgmgrinfo_appinfo_is_disabled(pkgmgrinfo_appinfo_h handle, bool *disabled)
2667 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2668 retvm_if(disabled == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2669 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2671 if (info->app_info == NULL || info->app_info->is_disabled == NULL)
2672 return PMINFO_R_ERROR;
2674 *disabled = _get_bool_value(info->app_info->is_disabled);
2679 API int pkgmgrinfo_appinfo_is_global(pkgmgrinfo_appinfo_h handle, bool *global)
2681 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2683 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2684 retvm_if(global == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2686 if (info->app_info == NULL || info->app_info->for_all_users == NULL)
2687 return PMINFO_R_ERROR;
2689 *global = _get_bool_value(info->app_info->for_all_users);
2694 API int pkgmgrinfo_appinfo_get_splash_screen_display(pkgmgrinfo_appinfo_h handle, bool *splash_screen_display)
2696 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2698 if (info == NULL || splash_screen_display == NULL) {
2699 _LOGE("Invalid parameter");
2700 return PMINFO_R_EINVAL;
2703 if (info->app_info == NULL || info->app_info->splash_screen_display == NULL)
2704 return PMINFO_R_ERROR;
2706 *splash_screen_display = _get_bool_value(info->app_info->splash_screen_display);
2711 API int pkgmgrinfo_appinfo_destroy_appinfo(pkgmgrinfo_appinfo_h handle)
2713 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2714 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2715 __cleanup_appinfo(info);
2719 API int pkgmgrinfo_appinfo_filter_create(pkgmgrinfo_appinfo_filter_h *handle)
2721 return (pkgmgrinfo_pkginfo_filter_create(handle));
2724 API int pkgmgrinfo_appinfo_filter_destroy(pkgmgrinfo_appinfo_filter_h handle)
2726 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
2729 static gint __compare_func(gconstpointer data1, gconstpointer data2)
2731 pkgmgrinfo_node_x *node1 = (pkgmgrinfo_node_x*)data1;
2732 pkgmgrinfo_node_x *node2 = (pkgmgrinfo_node_x*)data2;
2733 if (node1->prop == node2->prop)
2735 else if (node1->prop > node2->prop)
2741 API int pkgmgrinfo_appinfo_filter_add_int(pkgmgrinfo_appinfo_filter_h handle,
2742 const char *property, const int value)
2744 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2745 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2746 char buf[PKG_VALUE_STRING_LEN_MAX] = {'\0'};
2748 GSList *link = NULL;
2750 prop = _pminfo_appinfo_convert_to_prop_int(property);
2751 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_INT ||
2752 prop > E_PMINFO_APPINFO_PROP_APP_MAX_INT) {
2753 _LOGE("Invalid Integer Property\n");
2754 return PMINFO_R_EINVAL;
2756 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
2757 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
2759 _LOGE("Out of Memory!!!\n");
2760 return PMINFO_R_ERROR;
2762 snprintf(buf, PKG_VALUE_STRING_LEN_MAX - 1, "%d", value);
2763 val = strndup(buf, PKG_VALUE_STRING_LEN_MAX - 1);
2765 _LOGE("Out of Memory\n");
2768 return PMINFO_R_ERROR;
2772 /*If API is called multiple times for same property, we should override the previous values.
2773 Last value set will be used for filtering.*/
2774 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2776 filter->list = g_slist_delete_link(filter->list, link);
2777 filter->list = g_slist_append(filter->list, (gpointer)node);
2782 API int pkgmgrinfo_appinfo_filter_add_bool(pkgmgrinfo_appinfo_filter_h handle,
2783 const char *property, const bool value)
2785 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2786 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2788 GSList *link = NULL;
2790 prop = _pminfo_appinfo_convert_to_prop_bool(property);
2791 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_BOOL ||
2792 prop > E_PMINFO_APPINFO_PROP_APP_MAX_BOOL) {
2793 _LOGE("Invalid Boolean Property\n");
2794 return PMINFO_R_EINVAL;
2796 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
2797 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
2799 _LOGE("Out of Memory!!!\n");
2800 return PMINFO_R_ERROR;
2803 val = strndup("('true','True')", 15);
2805 val = strndup("('false','False')", 17);
2807 _LOGE("Out of Memory\n");
2810 return PMINFO_R_ERROR;
2814 /*If API is called multiple times for same property, we should override the previous values.
2815 Last value set will be used for filtering.*/
2816 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2818 filter->list = g_slist_delete_link(filter->list, link);
2819 filter->list = g_slist_append(filter->list, (gpointer)node);
2824 API int pkgmgrinfo_appinfo_filter_add_string(pkgmgrinfo_appinfo_filter_h handle,
2825 const char *property, const char *value)
2827 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2828 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2829 retvm_if(value == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2831 pkgmgrinfo_node_x *ptr = NULL;
2832 char prev[PKG_STRING_LEN_MAX] = {'\0'};
2833 char temp[PKG_STRING_LEN_MAX] = {'\0'};
2834 GSList *link = NULL;
2836 prop = _pminfo_appinfo_convert_to_prop_str(property);
2837 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_STR ||
2838 prop > E_PMINFO_APPINFO_PROP_APP_MAX_STR) {
2839 _LOGE("Invalid String Property\n");
2840 return PMINFO_R_EINVAL;
2842 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
2843 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
2845 _LOGE("Out of Memory!!!\n");
2846 return PMINFO_R_ERROR;
2850 case E_PMINFO_APPINFO_PROP_APP_COMPONENT:
2851 if (strcmp(value, PMINFO_APPINFO_UI_APP) == 0)
2852 val = strndup("uiapp", PKG_STRING_LEN_MAX - 1);
2854 val = strndup("svcapp", PKG_STRING_LEN_MAX - 1);
2856 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2858 filter->list = g_slist_delete_link(filter->list, link);
2859 filter->list = g_slist_append(filter->list, (gpointer)node);
2861 case E_PMINFO_APPINFO_PROP_APP_CATEGORY:
2862 val = (char *)calloc(1, PKG_STRING_LEN_MAX);
2864 _LOGE("Out of Memory\n");
2867 return PMINFO_R_ERROR;
2869 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2871 ptr = (pkgmgrinfo_node_x *)link->data;
2872 strncpy(prev, ptr->value, PKG_STRING_LEN_MAX - 1);
2873 _LOGI("Previous value is %s\n", prev);
2874 filter->list = g_slist_delete_link(filter->list, link);
2875 snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s , '%s'", prev, value);
2876 strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
2877 _LOGI("New value is %s\n", val);
2879 filter->list = g_slist_append(filter->list, (gpointer)node);
2880 memset(temp, '\0', PKG_STRING_LEN_MAX);
2882 snprintf(temp, PKG_STRING_LEN_MAX - 1, "'%s'", value);
2883 strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
2884 _LOGI("First value is %s\n", val);
2886 filter->list = g_slist_append(filter->list, (gpointer)node);
2887 memset(temp, '\0', PKG_STRING_LEN_MAX);
2891 node->value = strndup(value, PKG_STRING_LEN_MAX - 1);
2892 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2894 filter->list = g_slist_delete_link(filter->list, link);
2895 filter->list = g_slist_append(filter->list, (gpointer)node);
2901 API int pkgmgrinfo_appinfo_usr_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count, uid_t uid)
2906 if (handle == NULL || count == NULL) {
2907 _LOGE("invalid parameter");
2908 return PMINFO_R_EINVAL;
2911 ret = _appinfo_get_filtered_list(handle, uid, &list);
2912 if (ret != PMINFO_R_OK)
2913 return PMINFO_R_ERROR;
2915 *count = g_list_length(list);
2917 g_list_free_full(list, free);
2922 API int pkgmgrinfo_appinfo_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count)
2924 return pkgmgrinfo_appinfo_usr_filter_count(handle, count, _getuid());
2927 API int pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(
2928 pkgmgrinfo_appinfo_filter_h handle,
2929 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
2931 if (handle == NULL || app_cb == NULL) {
2932 LOGE("invalid parameter");
2933 return PMINFO_R_EINVAL;
2936 return _appinfo_get_filtered_foreach_appinfo(uid, handle, app_cb,
2940 API int pkgmgrinfo_appinfo_filter_foreach_appinfo(pkgmgrinfo_appinfo_filter_h handle,
2941 pkgmgrinfo_app_list_cb app_cb, void * user_data)
2943 return pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(handle, app_cb, user_data, _getuid());
2946 API int pkgmgrinfo_appinfo_metadata_filter_create(pkgmgrinfo_appinfo_metadata_filter_h *handle)
2948 return (pkgmgrinfo_pkginfo_filter_create(handle));
2951 API int pkgmgrinfo_appinfo_metadata_filter_destroy(pkgmgrinfo_appinfo_metadata_filter_h handle)
2953 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
2956 API int pkgmgrinfo_appinfo_metadata_filter_add(
2957 pkgmgrinfo_appinfo_metadata_filter_h handle,
2958 const char *key, const char *value)
2962 ret = pkgmgrinfo_appinfo_filter_add_string(handle,
2963 PMINFO_APPINFO_PROP_APP_METADATA_KEY, key);
2964 if (ret != PMINFO_R_OK)
2967 /* value can be NULL.
2968 * In that case all apps with specified key should be displayed
2971 ret = pkgmgrinfo_appinfo_filter_add_string(handle,
2972 PMINFO_APPINFO_PROP_APP_METADATA_VALUE, value);
2973 if (ret != PMINFO_R_OK)
2980 API int pkgmgrinfo_appinfo_usr_metadata_filter_foreach(
2981 pkgmgrinfo_appinfo_metadata_filter_h handle,
2982 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
2984 if (handle == NULL || app_cb == NULL) {
2985 LOGE("invalid parameter");
2986 return PMINFO_R_EINVAL;
2989 return _appinfo_get_filtered_foreach_appinfo(uid, handle, app_cb,
2993 API int pkgmgrinfo_appinfo_metadata_filter_foreach(
2994 pkgmgrinfo_appinfo_metadata_filter_h handle,
2995 pkgmgrinfo_app_list_cb app_cb, void *user_data)
2997 return pkgmgrinfo_appinfo_usr_metadata_filter_foreach(handle, app_cb,
2998 user_data, _getuid());
3001 API int pkgmgrinfo_appinfo_is_guestmode_visibility(pkgmgrinfo_appinfo_h handle, bool *status)
3004 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3006 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
3007 retvm_if(status == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3009 val = info->app_info->guestmode_visibility;
3010 *status = _get_bool_value(val);