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, color_depth "
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 _save_column_str(stmt, idx++, &info->color_depth);
535 *splashscreens = g_list_append(*splashscreens, info);
538 sqlite3_finalize(stmt);
543 static GList *__get_background_category(const char *value)
545 GList *category_list = NULL;
546 int convert_value = 0;
547 if (!value || strlen(value) == 0)
550 convert_value = atoi(value);
551 if (convert_value < 0)
554 if (convert_value & APP_BG_CATEGORY_USER_DISABLE_TRUE_VAL)
555 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_USER_DISABLE_TRUE_STR));
557 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_USER_DISABLE_FALSE_STR));
559 if (convert_value & APP_BG_CATEGORY_MEDIA_VAL)
560 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_MEDIA_STR));
562 if (convert_value & APP_BG_CATEGORY_DOWNLOAD_VAL)
563 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_DOWNLOAD_STR));
565 if (convert_value & APP_BG_CATEGORY_BGNETWORK_VAL)
566 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_BGNETWORK_STR));
568 if (convert_value & APP_BG_CATEGORY_LOCATION_VAL)
569 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_LOCATION_STR));
571 if (convert_value & APP_BG_CATEGORY_SENSOR_VAL)
572 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_SENSOR_STR));
574 if (convert_value & APP_BG_CATEGORY_IOTCOMM_VAL)
575 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_IOTCOMM_STR));
577 if (convert_value & APP_BG_CATEGORY_SYSTEM_VAL)
578 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_SYSTEM));
580 return category_list;
584 static void __get_splash_screen_display(sqlite3 *db, const char *appid, uid_t uid, char **value)
586 static const char query_raw[] =
587 "SELECT is_splash_screen_enabled FROM package_app_info_for_uid "
588 "WHERE app_id='%s' AND uid='%d'";
593 query = sqlite3_mprintf(query_raw, appid, uid);
595 LOGE("out of memory");
599 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
601 if (ret != SQLITE_OK) {
602 LOGE("sqlite3_prepare_v2() failed: %s", sqlite3_errmsg(db));
606 while (sqlite3_step(stmt) == SQLITE_ROW) {
609 _save_column_str(stmt, 0, value);
612 sqlite3_finalize(stmt);
615 static int _appinfo_get_application(sqlite3 *db, const char *appid,
616 const char *locale, application_x **application, bool is_disabled, uid_t db_uid, uid_t target_uid)
618 static const char query_raw[] =
619 "SELECT app_id, app_component, app_exec, app_nodisplay, "
620 "app_type, app_onboot, app_multiple, app_autorestart, "
621 "app_taskmanage, app_enabled, app_hwacceleration, "
622 "app_screenreader, app_mainapp, app_recentimage, "
623 "app_launchcondition, app_indicatordisplay, app_portraitimg, "
624 "app_landscapeimg, app_guestmodevisibility, "
625 "app_permissiontype, app_preload, app_submode, "
626 "app_submode_mainid, app_launch_mode, app_ui_gadget, "
627 "app_support_disable, "
628 "component_type, package, app_tep_name, app_zip_mount_file, app_process_pool, "
629 "app_installed_storage, app_background_category, "
630 "app_package_type, app_root_path, app_api_version, "
631 "app_effective_appid, app_disable, app_splash_screen_display "
632 "FROM package_app_info WHERE app_id='%s' "
633 "AND (app_disable='%s' "
635 "(SELECT app_id from package_app_info_for_uid WHERE uid='%d' AND is_disabled='true'))";
637 char query[MAX_QUERY_LEN] = { '\0' };
641 char *bg_category_str = NULL;
642 snprintf(query, MAX_QUERY_LEN - 1, query_raw,
644 is_disabled ? "true" : "false",
645 is_disabled ? "OR" : "AND",
646 is_disabled ? "" : "NOT",
649 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
650 if (ret != SQLITE_OK) {
651 LOGE("prepare failed: %s", sqlite3_errmsg(db));
652 return PMINFO_R_ERROR;
655 ret = sqlite3_step(stmt);
656 if (ret == SQLITE_DONE) {
657 sqlite3_finalize(stmt);
658 return PMINFO_R_ENOENT;
659 } else if (ret != SQLITE_ROW) {
660 LOGE("step failed: %s", sqlite3_errmsg(db));
661 sqlite3_finalize(stmt);
662 return PMINFO_R_ERROR;
665 info = calloc(1, sizeof(application_x));
667 LOGE("out of memory");
668 sqlite3_finalize(stmt);
669 return PMINFO_R_ERROR;
672 _save_column_str(stmt, idx++, &info->appid);
673 _save_column_str(stmt, idx++, &info->component);
674 _save_column_str(stmt, idx++, &info->exec);
675 _save_column_str(stmt, idx++, &info->nodisplay);
676 _save_column_str(stmt, idx++, &info->type);
677 _save_column_str(stmt, idx++, &info->onboot);
678 _save_column_str(stmt, idx++, &info->multiple);
679 _save_column_str(stmt, idx++, &info->autorestart);
680 _save_column_str(stmt, idx++, &info->taskmanage);
681 _save_column_str(stmt, idx++, &info->enabled);
682 _save_column_str(stmt, idx++, &info->hwacceleration);
683 _save_column_str(stmt, idx++, &info->screenreader);
684 _save_column_str(stmt, idx++, &info->mainapp);
685 _save_column_str(stmt, idx++, &info->recentimage);
686 _save_column_str(stmt, idx++, &info->launchcondition);
687 _save_column_str(stmt, idx++, &info->indicatordisplay);
688 _save_column_str(stmt, idx++, &info->portraitimg);
689 _save_column_str(stmt, idx++, &info->landscapeimg);
690 _save_column_str(stmt, idx++, &info->guestmode_visibility);
691 _save_column_str(stmt, idx++, &info->permission_type);
692 _save_column_str(stmt, idx++, &info->preload);
693 _save_column_str(stmt, idx++, &info->submode);
694 _save_column_str(stmt, idx++, &info->submode_mainid);
695 _save_column_str(stmt, idx++, &info->launch_mode);
696 _save_column_str(stmt, idx++, &info->ui_gadget);
697 _save_column_str(stmt, idx++, &info->support_disable);
698 _save_column_str(stmt, idx++, &info->component_type);
699 _save_column_str(stmt, idx++, &info->package);
700 _save_column_str(stmt, idx++, &info->tep_name);
701 _save_column_str(stmt, idx++, &info->zip_mount_file);
702 _save_column_str(stmt, idx++, &info->process_pool);
703 _save_column_str(stmt, idx++, &info->installed_storage);
704 _save_column_str(stmt, idx++, &bg_category_str);
705 _save_column_str(stmt, idx++, &info->package_type);
706 _save_column_str(stmt, idx++, &info->root_path);
707 _save_column_str(stmt, idx++, &info->api_version);
708 _save_column_str(stmt, idx++, &info->effective_appid);
709 _save_column_str(stmt, idx++, &info->is_disabled);
710 _save_column_str(stmt, idx++, &info->splash_screen_display);
712 if (db_uid == GLOBAL_USER)
713 __get_splash_screen_display(db, info->appid, db_uid,
714 &info->splash_screen_display);
716 info->background_category = __get_background_category(bg_category_str);
717 free(bg_category_str);
719 if (_appinfo_get_label(db, info->appid, locale, &info->label)) {
720 pkgmgrinfo_basic_free_application(info);
721 sqlite3_finalize(stmt);
722 return PMINFO_R_ERROR;
725 if (_appinfo_get_icon(db, info->appid, locale, &info->icon)) {
726 pkgmgrinfo_basic_free_application(info);
727 sqlite3_finalize(stmt);
728 return PMINFO_R_ERROR;
731 if (_appinfo_get_category(db, info->appid, &info->category)) {
732 pkgmgrinfo_basic_free_application(info);
733 sqlite3_finalize(stmt);
734 return PMINFO_R_ERROR;
737 if (_appinfo_get_app_control(db, info->appid, &info->appcontrol)) {
738 pkgmgrinfo_basic_free_application(info);
739 sqlite3_finalize(stmt);
740 return PMINFO_R_ERROR;
743 if (_appinfo_get_data_control(db, info->appid, &info->datacontrol)) {
744 pkgmgrinfo_basic_free_application(info);
745 sqlite3_finalize(stmt);
746 return PMINFO_R_ERROR;
749 if (_appinfo_get_metadata(db, info->appid, &info->metadata)) {
750 pkgmgrinfo_basic_free_application(info);
751 sqlite3_finalize(stmt);
752 return PMINFO_R_ERROR;
755 if (_appinfo_get_splashscreens(db, info->appid, &info->splashscreens)) {
756 pkgmgrinfo_basic_free_application(info);
757 sqlite3_finalize(stmt);
758 return PMINFO_R_ERROR;
761 info->for_all_users = strdup((db_uid != GLOBAL_USER) ? "false" : "true");
765 sqlite3_finalize(stmt);
770 static int _appinfo_get_appinfo(const char *appid, uid_t db_uid,
771 uid_t target_uid, bool is_disabled, pkgmgr_appinfo_x **appinfo)
777 pkgmgr_appinfo_x *info;
779 dbpath = getUserPkgParserDBPathUID(db_uid);
781 return PMINFO_R_ERROR;
783 locale = _get_system_locale();
785 return PMINFO_R_ERROR;
787 ret = sqlite3_open_v2(dbpath, &db, SQLITE_OPEN_READONLY, NULL);
788 if (ret != SQLITE_OK) {
789 _LOGE("failed to open db: %d", ret);
791 return PMINFO_R_ERROR;
794 info = calloc(1, sizeof(pkgmgr_appinfo_x));
796 _LOGE("out of memory");
798 sqlite3_close_v2(db);
799 return PMINFO_R_ERROR;
802 ret = _appinfo_get_application(db, appid, locale, &info->app_info, is_disabled, db_uid, target_uid);
803 if (ret != PMINFO_R_OK) {
806 sqlite3_close_v2(db);
810 info->locale = locale;
811 info->package = strdup(info->app_info->package);
815 sqlite3_close_v2(db);
820 int _appinfo_get_applist(uid_t uid, const char *locale, GHashTable **appinfo_table)
822 int ret = PMINFO_R_ERROR;
826 char *bg_category_str = NULL;
829 sqlite3_stmt *stmt = NULL;
830 pkgmgr_appinfo_x *info = NULL;
831 application_x *appinfo = NULL;
833 dbpath = getUserPkgParserDBPathUID(uid);
835 return PMINFO_R_ERROR;
837 ret = sqlite3_open_v2(dbpath, &db, SQLITE_OPEN_READONLY, NULL);
838 if (ret != SQLITE_OK) {
839 _LOGE("failed to open db: %d", ret);
840 ret = PMINFO_R_ERROR;
844 query = sqlite3_mprintf("SELECT app_id, app_exec, app_type, "
845 "app_onboot, app_multiple, app_autorestart, app_taskmanage, "
846 "app_hwacceleration, app_permissiontype, app_preload, "
847 "app_installed_storage, app_process_pool, app_launch_mode, "
848 "app_package_type, component_type, package, app_tep_name, app_zip_mount_file, "
849 "app_background_category, app_root_path, app_api_version, "
850 "app_effective_appid, app_disable, app_splash_screen_display, "
851 "(CASE WHEN A.app_disable='true' THEN 'true' "
852 "ELSE (CASE WHEN (SELECT app_id FROM package_app_info_for_uid "
853 "WHERE app_id=A.app_id AND uid='%d' AND is_disabled='true') IS NULL "
854 "THEN 'false' ELSE 'true' END) END) AS app_disable "
855 "FROM package_app_info A", (int)getuid());
858 _LOGE("Out of memory");
862 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
863 if (ret != SQLITE_OK) {
864 LOGE("prepare failed: %s", sqlite3_errmsg(db));
865 ret = PMINFO_R_ERROR;
869 while (sqlite3_step(stmt) == SQLITE_ROW) {
870 info = calloc(1, sizeof(pkgmgr_appinfo_x));
871 appinfo = calloc(1, sizeof(application_x));
872 if (info == NULL || appinfo == NULL) {
873 LOGE("calloc failed");
874 ret = PMINFO_R_ERROR;
879 _save_column_str(stmt, idx++, &appinfo->appid);
880 _save_column_str(stmt, idx++, &appinfo->exec);
881 _save_column_str(stmt, idx++, &appinfo->type);
883 _save_column_str(stmt, idx++, &appinfo->onboot);
884 _save_column_str(stmt, idx++, &appinfo->multiple);
885 _save_column_str(stmt, idx++, &appinfo->autorestart);
886 _save_column_str(stmt, idx++, &appinfo->taskmanage);
888 _save_column_str(stmt, idx++, &appinfo->hwacceleration);
889 _save_column_str(stmt, idx++, &appinfo->permission_type);
890 _save_column_str(stmt, idx++, &appinfo->preload);
892 _save_column_str(stmt, idx++, &appinfo->installed_storage);
893 _save_column_str(stmt, idx++, &appinfo->process_pool);
894 _save_column_str(stmt, idx++, &appinfo->launch_mode);
896 _save_column_str(stmt, idx++, &appinfo->package_type);
897 _save_column_str(stmt, idx++, &appinfo->component_type);
898 _save_column_str(stmt, idx++, &appinfo->package);
899 _save_column_str(stmt, idx++, &appinfo->tep_name);
900 _save_column_str(stmt, idx++, &appinfo->zip_mount_file);
902 _save_column_str(stmt, idx++, &bg_category_str);
903 _save_column_str(stmt, idx++, &appinfo->root_path);
904 _save_column_str(stmt, idx++, &appinfo->api_version);
906 _save_column_str(stmt, idx++, &appinfo->effective_appid);
907 _save_column_str(stmt, idx++, &appinfo->is_disabled);
908 _save_column_str(stmt, idx++, &appinfo->splash_screen_display);
910 if (uid == GLOBAL_USER)
911 __get_splash_screen_display(db, appinfo->appid, uid,
912 &appinfo->splash_screen_display);
914 appinfo->background_category = __get_background_category(bg_category_str);
915 free(bg_category_str);
917 if (_appinfo_get_splashscreens(db, appinfo->appid, &appinfo->splashscreens)) {
918 pkgmgrinfo_basic_free_application(appinfo);
919 ret = PMINFO_R_ERROR;
923 info->locale = strdup(locale);
924 info->package = strdup(appinfo->package);
925 appinfo->for_all_users = strdup((uid != GLOBAL_USER) ? "false" : "true");
926 info->app_info = appinfo;
927 key = strdup(info->app_info->appid);
929 if (!g_hash_table_contains(*appinfo_table, (gconstpointer)key))
930 g_hash_table_insert(*appinfo_table, (gpointer)key, (gpointer)info);
932 __cleanup_appinfo(info);
939 sqlite3_finalize(stmt);
946 API int pkgmgrinfo_appinfo_get_usr_disabled_appinfo(const char *appid, uid_t uid,
947 pkgmgrinfo_appinfo_h *handle)
951 if (appid == NULL || handle == NULL) {
952 LOGE("invalid parameter");
953 return PMINFO_R_EINVAL;
956 ret = _appinfo_get_appinfo(appid, uid, uid, true, (pkgmgr_appinfo_x **)handle);
957 if (ret == PMINFO_R_ENOENT && uid != GLOBAL_USER)
958 ret = _appinfo_get_appinfo(appid, GLOBAL_USER, uid, true,
959 (pkgmgr_appinfo_x **)handle);
961 if (ret != PMINFO_R_OK)
962 _LOGI("Appinfo for [%s] is not existed for user [%d]", appid, uid);
967 API int pkgmgrinfo_appinfo_get_disabled_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
969 return pkgmgrinfo_appinfo_get_usr_disabled_appinfo(appid, _getuid(), handle);
972 API int pkgmgrinfo_appinfo_get_usr_appinfo(const char *appid, uid_t uid,
973 pkgmgrinfo_appinfo_h *handle)
977 if (appid == NULL || handle == NULL) {
978 LOGE("invalid parameter");
979 return PMINFO_R_EINVAL;
982 ret = _appinfo_get_appinfo(appid, uid, uid, false, (pkgmgr_appinfo_x **)handle);
983 if (ret == PMINFO_R_ENOENT && uid != GLOBAL_USER)
984 ret = _appinfo_get_appinfo(appid, GLOBAL_USER, uid, false,
985 (pkgmgr_appinfo_x **)handle);
986 if (ret != PMINFO_R_OK)
987 _LOGI("Appinfo for [%s] is not existed for user [%d]", appid, uid);
992 API int pkgmgrinfo_appinfo_get_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
994 return pkgmgrinfo_appinfo_get_usr_appinfo(appid, _getuid(), handle);
997 static gpointer __copy_str(gconstpointer src, gpointer data)
999 const char *tmp = (const char *)src;
1002 buffer = strdup(tmp);
1003 if (buffer == NULL) {
1004 LOGE("memory alloc failed");
1012 static gpointer __copy_label(gconstpointer src, gpointer data)
1014 label_x *tmp = (label_x *)src;
1017 label = calloc(1, sizeof(label_x));
1018 if (label == NULL) {
1019 LOGE("memory alloc failed");
1025 label->name = strdup(tmp->name);
1027 label->text = strdup(tmp->text);
1029 label->lang = strdup(tmp->lang);
1034 static gpointer __copy_icon(gconstpointer src, gpointer data)
1036 icon_x *tmp = (icon_x *)src;
1039 icon = calloc(1, sizeof(icon_x));
1041 LOGE("memory alloc failed");
1047 icon->text = strdup(tmp->text);
1049 icon->lang = strdup(tmp->lang);
1051 icon->section = strdup(tmp->section);
1053 icon->size = strdup(tmp->size);
1054 if (tmp->resolution)
1055 icon->resolution = strdup(tmp->resolution);
1060 static gpointer __copy_metadata(gconstpointer src, gpointer data)
1062 metadata_x *tmp = (metadata_x *)src;
1063 metadata_x *metadata;
1065 metadata = calloc(1, sizeof(metadata_x));
1066 if (metadata == NULL) {
1067 LOGE("memory alloc failed");
1073 metadata->key = strdup(tmp->key);
1075 metadata->value = strdup(tmp->value);
1080 static gpointer __copy_datacontrol(gconstpointer src, gpointer data)
1082 datacontrol_x *tmp = (datacontrol_x *)src;
1083 datacontrol_x *datacontrol;
1085 datacontrol = calloc(1, sizeof(datacontrol_x));
1086 if (datacontrol == NULL) {
1087 LOGE("memory alloc failed");
1092 if (tmp->providerid)
1093 datacontrol->providerid = strdup(tmp->providerid);
1095 datacontrol->access = strdup(tmp->access);
1097 datacontrol->type = strdup(tmp->type);
1102 static gpointer __copy_appcontrol(gconstpointer src, gpointer data)
1104 appcontrol_x *tmp = (appcontrol_x *)src;
1105 appcontrol_x *appcontrol;
1107 appcontrol = calloc(1, sizeof(appcontrol_x));
1108 if (appcontrol ==NULL) {
1109 LOGE("memory alloc failed");
1115 appcontrol->operation = strdup(tmp->operation);
1117 appcontrol->uri = strdup(tmp->uri);
1119 appcontrol->mime = strdup(tmp->mime);
1124 static gpointer __copy_splashscreens(gconstpointer src, gpointer data)
1126 splashscreen_x *tmp = (splashscreen_x *)src;
1127 splashscreen_x *splashscreen;
1129 splashscreen = (splashscreen_x *)calloc(1, sizeof(splashscreen_x));
1130 if (splashscreen == NULL) {
1131 LOGE("memory alloc failed");
1137 splashscreen->src = strdup(tmp->src);
1139 splashscreen->type = strdup(tmp->type);
1140 if (tmp->orientation)
1141 splashscreen->orientation = strdup(tmp->orientation);
1142 if (tmp->indicatordisplay)
1143 splashscreen->indicatordisplay = strdup(tmp->indicatordisplay);
1145 splashscreen->operation = strdup(tmp->operation);
1146 if (tmp->color_depth)
1147 splashscreen->color_depth = strdup(tmp->color_depth);
1149 return splashscreen;
1152 static int _appinfo_copy_appinfo(application_x **application, application_x *data)
1154 application_x *app_info;
1157 app_info = calloc(1, sizeof(application_x));
1158 if (app_info == NULL) {
1159 LOGE("memory alloc failed");
1160 return PMINFO_R_ERROR;
1163 if (data->appid != NULL)
1164 app_info->appid = strdup(data->appid);
1165 if (data->exec != NULL)
1166 app_info->exec = strdup(data->exec);
1167 if (data->nodisplay != NULL)
1168 app_info->nodisplay = strdup(data->nodisplay);
1169 if (data->multiple != NULL)
1170 app_info->multiple = strdup(data->multiple);
1171 if (data->taskmanage != NULL)
1172 app_info->taskmanage = strdup(data->taskmanage);
1173 if (data->enabled != NULL)
1174 app_info->enabled = strdup(data->enabled);
1175 if (data->type != NULL)
1176 app_info->type = strdup(data->type);
1177 if (data->categories != NULL)
1178 app_info->categories = strdup(data->categories);
1179 if (data->hwacceleration != NULL)
1180 app_info->hwacceleration = strdup(data->hwacceleration);
1181 if (data->screenreader != NULL)
1182 app_info->screenreader = strdup(data->screenreader);
1183 if (data->mainapp != NULL)
1184 app_info->mainapp = strdup(data->mainapp);
1185 if (data->package != NULL)
1186 app_info->package = strdup(data->package);
1187 if (data->recentimage != NULL)
1188 app_info->recentimage = strdup(data->recentimage);
1189 if (data->launchcondition != NULL)
1190 app_info->launchcondition = strdup(data->launchcondition);
1191 if (data->indicatordisplay != NULL)
1192 app_info->indicatordisplay = strdup(data->indicatordisplay);
1193 if (data->portraitimg != NULL)
1194 app_info->portraitimg = strdup(data->portraitimg);
1195 if (data->landscapeimg != NULL)
1196 app_info->landscapeimg = strdup(data->landscapeimg);
1197 if (data->guestmode_visibility != NULL)
1198 app_info->guestmode_visibility = strdup(data->guestmode_visibility);
1199 if (data->component != NULL)
1200 app_info->component = strdup(data->component);
1201 if (data->permission_type != NULL)
1202 app_info->permission_type = strdup(data->permission_type);
1203 if (data->component_type != NULL)
1204 app_info->component_type = strdup(data->component_type);
1205 if (data->preload != NULL)
1206 app_info->preload = strdup(data->preload);
1207 if (data->submode != NULL)
1208 app_info->submode = strdup(data->submode);
1209 if (data->submode_mainid != NULL)
1210 app_info->submode_mainid = strdup(data->submode_mainid);
1211 if (data->process_pool != NULL)
1212 app_info->process_pool = strdup(data->process_pool);
1213 if (data->installed_storage != NULL)
1214 app_info->installed_storage = strdup(data->installed_storage);
1215 if (data->autorestart != NULL)
1216 app_info->autorestart = strdup(data->autorestart);
1217 if (data->onboot != NULL)
1218 app_info->onboot = strdup(data->onboot);
1219 if (data->support_disable != NULL)
1220 app_info->support_disable = strdup(data->support_disable);
1221 if (data->ui_gadget != NULL)
1222 app_info->ui_gadget = strdup(data->ui_gadget);
1223 if (data->launch_mode != NULL)
1224 app_info->launch_mode = strdup(data->launch_mode);
1225 if (data->package_type != NULL)
1226 app_info->package_type = strdup(data->package_type);
1227 if (data->effective_appid != NULL)
1228 app_info->effective_appid = strdup(data->effective_appid);
1229 if (data->splash_screen_display != NULL)
1230 app_info->splash_screen_display = strdup(data->splash_screen_display);
1234 app_info->label = g_list_copy_deep(data->label, __copy_label, &ret);
1236 LOGE("memory alloc failed");
1237 pkgmgrinfo_basic_free_application(app_info);
1238 return PMINFO_R_ERROR;
1242 app_info->icon = g_list_copy_deep(data->icon, __copy_icon, &ret);
1244 LOGE("memory alloc failed");
1245 pkgmgrinfo_basic_free_application(app_info);
1246 return PMINFO_R_ERROR;
1250 app_info->category = g_list_copy_deep(data->category, __copy_str, &ret);
1252 LOGE("memory alloc failed");
1253 pkgmgrinfo_basic_free_application(app_info);
1254 return PMINFO_R_ERROR;
1258 app_info->metadata = g_list_copy_deep(data->metadata, __copy_metadata, &ret);
1260 LOGE("memory alloc failed");
1261 pkgmgrinfo_basic_free_application(app_info);
1262 return PMINFO_R_ERROR;
1266 app_info->datacontrol = g_list_copy_deep(data->datacontrol, __copy_datacontrol, &ret);
1268 LOGE("memory alloc failed");
1269 pkgmgrinfo_basic_free_application(app_info);
1270 return PMINFO_R_ERROR;
1274 app_info->appcontrol = g_list_copy_deep(data->appcontrol, __copy_appcontrol, &ret);
1276 LOGE("memory alloc failed");
1277 pkgmgrinfo_basic_free_application(app_info);
1278 return PMINFO_R_ERROR;
1282 app_info->background_category = g_list_copy_deep(data->background_category, __copy_str, &ret);
1284 LOGE("memory alloc failed");
1285 pkgmgrinfo_basic_free_application(app_info);
1286 return PMINFO_R_ERROR;
1290 app_info->splashscreens = g_list_copy_deep(data->splashscreens, __copy_splashscreens, &ret);
1292 LOGE("memory alloc failed");
1293 pkgmgrinfo_basic_free_application(app_info);
1294 return PMINFO_R_ERROR;
1297 *application = app_info;
1302 API int pkgmgrinfo_appinfo_clone_appinfo(pkgmgrinfo_appinfo_h handle,
1303 pkgmgrinfo_appinfo_h *clone)
1305 pkgmgr_appinfo_x *info;
1306 pkgmgr_appinfo_x *temp = (pkgmgr_appinfo_x *)handle;
1309 return PMINFO_R_EINVAL;
1311 info = calloc(1, sizeof(pkgmgr_appinfo_x));
1313 LOGE("memory alloc failed");
1314 return PMINFO_R_ERROR;
1317 if (temp->package != NULL)
1318 info->package = strdup(temp->package);
1319 if (temp->locale != NULL)
1320 info->locale = strdup(temp->locale);
1322 info->app_component = temp->app_component;
1324 if (_appinfo_copy_appinfo(&info->app_info, temp->app_info) < 0) {
1325 LOGE("appinfo copy failed");
1327 free((void *)info->package);
1331 return PMINFO_R_ERROR;
1339 static int _appinfo_get_filtered_foreach_appinfo(uid_t uid,
1340 pkgmgrinfo_filter_x *filter, pkgmgrinfo_app_list_cb app_list_cb,
1344 pkgmgr_appinfo_x *info;
1350 ret = _appinfo_get_filtered_list(filter, uid, &list);
1351 if (ret != PMINFO_R_OK)
1352 return PMINFO_R_ERROR;
1354 for (tmp = list; tmp; tmp = tmp->next) {
1355 appid = (char *)tmp->data;
1357 ret = _appinfo_get_appinfo(appid, uid, uid, false, &info);
1358 if (ret == PMINFO_R_ENOENT && uid != GLOBAL_USER)
1359 ret = _appinfo_get_appinfo(appid, GLOBAL_USER, uid, false,
1361 if (ret != PMINFO_R_OK) {
1365 if (app_list_cb(info, user_data) < 0)
1367 pkgmgrinfo_appinfo_destroy_appinfo(info);
1377 static const char *__appcomponent_str(pkgmgrinfo_app_component comp);
1379 API int pkgmgrinfo_appinfo_get_usr_list(pkgmgrinfo_pkginfo_h handle,
1380 pkgmgrinfo_app_component component,
1381 pkgmgrinfo_app_list_cb app_func, void *user_data, uid_t uid)
1384 pkgmgrinfo_appinfo_filter_h filter;
1386 const char *comp_str = NULL;
1388 if (handle == NULL || app_func == NULL) {
1389 LOGE("invalid parameter");
1390 return PMINFO_R_EINVAL;
1393 if (pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid)) {
1394 LOGE("invalid parameter");
1395 return PMINFO_R_EINVAL;
1398 if (pkgmgrinfo_appinfo_filter_create(&filter))
1399 return PMINFO_R_ERROR;
1401 if (pkgmgrinfo_appinfo_filter_add_string(filter,
1402 PMINFO_APPINFO_PROP_APP_PACKAGE, pkgid)) {
1403 pkgmgrinfo_appinfo_filter_destroy(filter);
1404 return PMINFO_R_ERROR;
1407 if (uid == GLOBAL_USER) {
1408 if (pkgmgrinfo_appinfo_filter_add_int(filter,
1409 PMINFO_APPINFO_PROP_APP_DISABLE_FOR_USER, (int)getuid())) {
1410 pkgmgrinfo_appinfo_filter_destroy(filter);
1411 return PMINFO_R_ERROR;
1415 comp_str = __appcomponent_str(component);
1418 if (pkgmgrinfo_appinfo_filter_add_string(filter,
1419 PMINFO_APPINFO_PROP_APP_COMPONENT,
1421 pkgmgrinfo_appinfo_filter_destroy(filter);
1422 return PMINFO_R_ERROR;
1426 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter, app_func,
1429 pkgmgrinfo_appinfo_filter_destroy(filter);
1434 API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_component component,
1435 pkgmgrinfo_app_list_cb app_func, void *user_data)
1437 return pkgmgrinfo_appinfo_get_usr_list(handle, component, app_func, user_data, _getuid());
1440 API int pkgmgrinfo_appinfo_get_usr_applist_for_amd(pkgmgrinfo_app_list_cb app_func, uid_t uid, void *user_data)
1442 int ret = PMINFO_R_ERROR;
1443 char *locale = NULL;
1444 GHashTable *appinfo_table;
1445 GHashTableIter iter;
1447 pkgmgr_appinfo_x *val;
1449 locale = _get_system_locale();
1451 return PMINFO_R_ERROR;
1453 appinfo_table = g_hash_table_new_full(g_str_hash, g_str_equal,
1454 free, __free_appinfo_list);
1455 if (appinfo_table == NULL) {
1460 ret = _appinfo_get_applist(uid, locale, &appinfo_table);
1461 if (ret != PMINFO_R_OK) {
1462 LOGE("failed get applist[%d]", (int)uid);
1466 if (uid != GLOBAL_USER) {
1467 ret = _appinfo_get_applist(GLOBAL_USER, locale, &appinfo_table);
1468 if (ret != PMINFO_R_OK) {
1469 LOGE("failed get applist[%d]", GLOBAL_USER);
1474 g_hash_table_iter_init(&iter, appinfo_table);
1475 while (g_hash_table_iter_next(&iter, (gpointer)&key, (gpointer)&val)) {
1476 ret = app_func((void *)val, user_data);
1477 if (ret != PMINFO_R_OK) {
1478 LOGE("callback is stopped");
1488 g_hash_table_destroy(appinfo_table);
1493 API int pkgmgrinfo_appinfo_get_applist_for_amd(pkgmgrinfo_app_list_cb app_func, void *user_data)
1495 return pkgmgrinfo_appinfo_get_usr_applist_for_amd(app_func, _getuid(), user_data);
1498 API int pkgmgrinfo_appinfo_get_usr_installed_list(pkgmgrinfo_app_list_cb app_func, uid_t uid, void *user_data)
1500 if (app_func == NULL) {
1501 LOGE("invalid parameter");
1502 return PMINFO_R_EINVAL;
1505 return _appinfo_get_filtered_foreach_appinfo(uid, NULL, app_func,
1509 API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func, void *user_data)
1511 return pkgmgrinfo_appinfo_get_usr_installed_list(app_func, _getuid(), user_data);
1514 API int pkgmgrinfo_appinfo_get_appid(pkgmgrinfo_appinfo_h handle, char **appid)
1516 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1518 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1519 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1521 if (info->app_info == NULL || info->app_info->appid == NULL)
1522 return PMINFO_R_ERROR;
1523 *appid = (char *)info->app_info->appid;
1528 API int pkgmgrinfo_appinfo_get_pkgname(pkgmgrinfo_appinfo_h handle, char **pkg_name)
1530 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1532 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1533 retvm_if(pkg_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1535 if (info->package == NULL)
1536 return PMINFO_R_ERROR;
1538 *pkg_name = (char *)info->package;
1543 API int pkgmgrinfo_appinfo_get_pkgid(pkgmgrinfo_appinfo_h handle, char **pkgid)
1545 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1547 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1548 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1550 if (info->package == NULL)
1551 return PMINFO_R_ERROR;
1553 *pkgid = (char *)info->package;
1558 API int pkgmgrinfo_appinfo_get_pkgtype(pkgmgrinfo_appinfo_h handle, char **pkgtype)
1560 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1561 retvm_if(pkgtype == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1562 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1564 *pkgtype = (char *)info->app_info->package_type;
1569 API int pkgmgrinfo_appinfo_get_exec(pkgmgrinfo_appinfo_h handle, char **exec)
1571 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1573 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1574 retvm_if(exec == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1576 if (info->app_info == NULL || info->app_info->exec == NULL)
1577 return PMINFO_R_ERROR;
1578 *exec = (char *)info->app_info->exec;
1584 API int pkgmgrinfo_appinfo_get_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1589 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1591 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1592 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1594 locale = info->locale;
1595 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
1597 if (info->app_info == NULL)
1598 return PMINFO_R_ERROR;
1600 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1601 ptr = (icon_x *)tmp->data;
1602 if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL ||
1603 !strcasecmp(ptr->text, "") ||
1604 strcmp(ptr->lang, locale))
1606 *icon = (char *)ptr->text;
1610 locale = DEFAULT_LOCALE;
1611 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1612 ptr = (icon_x *)tmp->data;
1613 if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL ||
1614 strcmp(ptr->lang, locale))
1616 *icon = (char *)ptr->text;
1620 return PMINFO_R_ERROR;
1624 API int pkgmgrinfo_appinfo_get_label(pkgmgrinfo_appinfo_h handle, char **label)
1629 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1631 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1632 retvm_if(label == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1634 locale = info->locale;
1635 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
1637 if (info->app_info == NULL)
1638 return PMINFO_R_ERROR;
1640 for (tmp = info->app_info->label; tmp; tmp = tmp->next) {
1641 ptr = (label_x *)tmp->data;
1642 if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL ||
1643 strcmp(ptr->lang, locale))
1645 *label = (char *)ptr->text;
1649 locale = DEFAULT_LOCALE;
1650 for (tmp = info->app_info->label; tmp; tmp = tmp->next) {
1651 ptr = (label_x *)tmp->data;
1652 if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL ||
1653 strcmp(ptr->lang, locale))
1655 *label = (char *)ptr->text;
1659 return PMINFO_R_ERROR;
1662 static char *_get_localed_label(const char *appid, const char *locale, uid_t uid)
1664 char *result = NULL;
1666 sqlite3_stmt *stmt = NULL;
1669 const char *manifest_db;
1671 manifest_db = getUserPkgParserDBPathUID(uid);
1672 if (manifest_db == NULL) {
1673 _LOGE("Failed to get manifest db path");
1677 if (sqlite3_open_v2(manifest_db, &db, SQLITE_OPEN_READONLY, NULL) != SQLITE_OK) {
1678 _LOGE("DB open fail\n");
1682 query = sqlite3_mprintf("select app_label from package_app_localized_info where app_id=%Q and app_locale=%Q", appid, locale);
1683 if (query == NULL) {
1684 _LOGE("Out of memory");
1688 if (sqlite3_prepare_v2(db, query, -1, &stmt, NULL) != SQLITE_OK) {
1689 _LOGE("prepare_v2 fail\n");
1693 if (sqlite3_step(stmt) == SQLITE_ROW) {
1694 val = (char *)sqlite3_column_text(stmt, 0);
1696 result = strdup(val);
1700 sqlite3_finalize(stmt);
1701 sqlite3_free(query);
1707 API int pkgmgrinfo_appinfo_usr_get_localed_label(const char *appid, const char *locale, uid_t uid, char **label)
1711 retvm_if(appid == NULL || locale == NULL || label == NULL, PMINFO_R_EINVAL, "Argument is NULL");
1713 val = _get_localed_label(appid, locale, uid);
1715 val = _get_localed_label(appid, DEFAULT_LOCALE, uid);
1718 return PMINFO_R_ERROR;
1725 API int pkgmgrinfo_appinfo_get_localed_label(const char *appid, const char *locale, char **label)
1727 return pkgmgrinfo_appinfo_usr_get_localed_label(appid, locale, _getuid(), label);
1730 API int pkgmgrinfo_appinfo_get_metadata_value(pkgmgrinfo_appinfo_h handle, const char *metadata_key, char **metadata_value)
1732 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1733 retvm_if(metadata_key == NULL, PMINFO_R_EINVAL, "metadata_key is NULL");
1734 retvm_if(metadata_value == NULL, PMINFO_R_EINVAL, "metadata_value is NULL");
1736 GList *list_md = NULL;
1737 metadata_x *metadata = NULL;
1738 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1740 list_md = info->app_info->metadata;
1742 for (; list_md; list_md = list_md->next) {
1743 metadata = (metadata_x *)list_md->data;
1744 if (metadata && metadata->key) {
1745 if (strcasecmp(metadata->key, metadata_key) == 0) {
1746 *metadata_value = (char*)metadata->value;
1752 return PMINFO_R_EINVAL;
1755 static pkgmgrinfo_app_component __appcomponent_convert(const char *comp)
1757 if (strcasecmp(comp, "uiapp") == 0)
1758 return PMINFO_UI_APP;
1759 else if (strcasecmp(comp, "svcapp") == 0)
1760 return PMINFO_SVC_APP;
1761 else if (strcasecmp(comp, "widgetapp") == 0)
1762 return PMINFO_WIDGET_APP;
1763 else if (strcasecmp(comp, "watchapp") == 0)
1764 return PMINFO_WATCH_APP;
1769 static const char *__appcomponent_str(pkgmgrinfo_app_component comp)
1774 case PMINFO_SVC_APP:
1776 case PMINFO_WIDGET_APP:
1778 case PMINFO_WATCH_APP:
1785 API int pkgmgrinfo_appinfo_get_component(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_component *component)
1787 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1790 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1791 retvm_if(component == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1793 if (info->app_info == NULL)
1794 return PMINFO_R_ERROR;
1796 comp = __appcomponent_convert(info->app_info->component);
1798 return PMINFO_R_ERROR;
1805 API int pkgmgrinfo_appinfo_get_apptype(pkgmgrinfo_appinfo_h handle, char **app_type)
1807 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1809 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1810 retvm_if(app_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1812 if (info->app_info == NULL || info->app_info->type == NULL)
1813 return PMINFO_R_ERROR;
1814 *app_type = (char *)info->app_info->type;
1819 API int pkgmgrinfo_appinfo_get_operation(pkgmgrinfo_appcontrol_h handle,
1820 int *operation_count, char ***operation)
1822 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1823 retvm_if(operation == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1824 retvm_if(operation_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1825 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1826 *operation_count = data->operation_count;
1827 *operation = data->operation;
1831 API int pkgmgrinfo_appinfo_get_uri(pkgmgrinfo_appcontrol_h handle,
1832 int *uri_count, char ***uri)
1834 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1835 retvm_if(uri == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1836 retvm_if(uri_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1837 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1838 *uri_count = data->uri_count;
1843 API int pkgmgrinfo_appinfo_get_mime(pkgmgrinfo_appcontrol_h handle,
1844 int *mime_count, char ***mime)
1846 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1847 retvm_if(mime == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1848 retvm_if(mime_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1849 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1850 *mime_count = data->mime_count;
1855 API int pkgmgrinfo_appinfo_get_subapp(pkgmgrinfo_appcontrol_h handle,
1856 int *subapp_count, char ***subapp)
1858 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1859 retvm_if(subapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1860 retvm_if(subapp_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1861 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1862 *subapp_count = data->subapp_count;
1863 *subapp = data->subapp;
1867 API int pkgmgrinfo_appinfo_get_setting_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1872 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1874 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1875 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1877 if (info->app_info == NULL)
1878 return PMINFO_R_ERROR;
1880 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1881 ptr = (icon_x *)tmp->data;
1882 if (ptr == NULL || ptr->section == NULL)
1885 val = (char *)ptr->section;
1886 if (val && strcmp(val, "setting") == 0) {
1887 *icon = (char *)ptr->text;
1892 return PMINFO_R_ERROR;
1896 API int pkgmgrinfo_appinfo_get_notification_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1901 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1903 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1904 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1906 if (info->app_info == NULL)
1907 return PMINFO_R_ERROR;
1909 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1910 ptr = (icon_x *)tmp->data;
1911 if (ptr == NULL || ptr->section == NULL)
1914 val = (char *)ptr->section;
1915 if (val && strcmp(val, "notification") == 0){
1916 *icon = (char *)ptr->text;
1921 return PMINFO_R_ERROR;
1924 API int pkgmgrinfo_appinfo_get_recent_image_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_recentimage *type)
1927 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1929 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1930 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1932 if (info->app_info == NULL || info->app_info->recentimage == NULL)
1933 return PMINFO_R_ERROR;
1935 val = (char *)info->app_info->recentimage;
1936 if (strcasecmp(val, "capture") == 0)
1937 *type = PMINFO_RECENTIMAGE_USE_CAPTURE;
1938 else if (strcasecmp(val, "icon") == 0)
1939 *type = PMINFO_RECENTIMAGE_USE_ICON;
1941 *type = PMINFO_RECENTIMAGE_USE_NOTHING;
1946 API int pkgmgrinfo_appinfo_get_preview_image(pkgmgrinfo_appinfo_h handle, char **preview_img)
1951 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1953 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1954 retvm_if(preview_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1956 if (info->app_info == NULL)
1957 return PMINFO_R_ERROR;
1959 for (tmp = info->app_info->image; tmp; tmp = tmp->next) {
1960 ptr = (image_x *)tmp->data;
1961 if (ptr == NULL || ptr->section == NULL)
1964 val = (char *)ptr->section;
1965 if (val && strcmp(val, "preview") == 0) {
1966 *preview_img = (char *)ptr->text;
1971 return PMINFO_R_ERROR;
1974 API int pkgmgrinfo_appinfo_get_permission_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_permission_type *permission)
1977 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1979 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1980 retvm_if(permission == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1982 val = info->app_info->permission_type;
1984 return PMINFO_R_ERROR;
1986 if (strcmp(val, "signature") == 0)
1987 *permission = PMINFO_PERMISSION_SIGNATURE;
1988 else if (strcmp(val, "privilege") == 0)
1989 *permission = PMINFO_PERMISSION_PRIVILEGE;
1991 *permission = PMINFO_PERMISSION_NORMAL;
1996 API int pkgmgrinfo_appinfo_get_component_type(pkgmgrinfo_appinfo_h handle, char **component_type)
1998 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2000 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2001 retvm_if(component_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2003 if (info->app_info == NULL || info->app_info->component_type == NULL)
2004 return PMINFO_R_ERROR;
2006 *component_type = (char *)info->app_info->component_type;
2011 API int pkgmgrinfo_appinfo_get_hwacceleration(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_hwacceleration *hwacceleration)
2014 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2016 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2017 retvm_if(hwacceleration == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2019 if (info->app_info == NULL || info->app_info->hwacceleration == NULL)
2020 return PMINFO_R_ERROR;
2022 val = (char *)info->app_info->hwacceleration;
2023 if (strcasecmp(val, "off") == 0)
2024 *hwacceleration = PMINFO_HWACCELERATION_OFF;
2025 else if (strcasecmp(val, "on") == 0)
2026 *hwacceleration = PMINFO_HWACCELERATION_ON;
2028 *hwacceleration = PMINFO_HWACCELERATION_DEFAULT;
2033 API int pkgmgrinfo_appinfo_get_screenreader(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_screenreader *screenreader)
2036 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2038 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2039 retvm_if(screenreader == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2041 if (info->app_info == NULL || info->app_info->screenreader == NULL)
2042 return PMINFO_R_ERROR;
2044 val = (char *)info->app_info->screenreader;
2045 if (strcasecmp(val, "screenreader-off") == 0)
2046 *screenreader = PMINFO_SCREENREADER_OFF;
2047 else if (strcasecmp(val, "screenreader-on") == 0)
2048 *screenreader = PMINFO_SCREENREADER_ON;
2050 *screenreader = PMINFO_SCREENREADER_USE_SYSTEM_SETTING;
2055 API int pkgmgrinfo_appinfo_get_effectimage(pkgmgrinfo_appinfo_h handle, char **portrait_img, char **landscape_img)
2057 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2059 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2060 retvm_if(portrait_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2061 retvm_if(landscape_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2063 if (info->app_info == NULL || (info->app_info->portraitimg == NULL
2064 && info->app_info->landscapeimg == NULL))
2065 return PMINFO_R_ERROR;
2067 *portrait_img = (char *)info->app_info->portraitimg;
2068 *landscape_img = (char *)info->app_info->landscapeimg;
2073 API int pkgmgrinfo_appinfo_get_effectimage_type(pkgmgrinfo_appinfo_h handle, char **effectimage_type)
2075 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2077 if (handle == NULL || effectimage_type == NULL) {
2078 LOGE("invalid parameter");
2079 return PMINFO_R_EINVAL;
2082 if (info->app_info == NULL || info->app_info->effectimage_type == NULL)
2083 return PMINFO_R_ERROR;
2085 *effectimage_type = (char *)info->app_info->effectimage_type;
2090 API int pkgmgrinfo_appinfo_get_submode_mainid(pkgmgrinfo_appinfo_h handle, char **submode_mainid)
2092 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2094 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2095 retvm_if(submode_mainid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2097 if (info->app_info == NULL || info->app_info->submode_mainid == NULL)
2098 return PMINFO_R_ERROR;
2100 *submode_mainid = (char *)info->app_info->submode_mainid;
2105 API int pkgmgrinfo_appinfo_get_installed_storage_location(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_installed_storage *storage)
2107 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2108 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2110 if (info->app_info && info->app_info->installed_storage){
2111 if (strcmp(info->app_info->installed_storage,"installed_internal") == 0)
2112 *storage = PMINFO_INTERNAL_STORAGE;
2113 else if (strcmp(info->app_info->installed_storage,"installed_external") == 0)
2114 *storage = PMINFO_EXTERNAL_STORAGE;
2116 return PMINFO_R_ERROR;
2118 return PMINFO_R_ERROR;
2123 API int pkgmgrinfo_appinfo_get_launch_mode(pkgmgrinfo_appinfo_h handle, char **mode)
2125 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2127 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2128 retvm_if(mode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2130 if (info->app_info->launch_mode == NULL)
2131 return PMINFO_R_ERROR;
2133 *mode = (char *)(info->app_info->launch_mode);
2138 API int pkgmgrinfo_appinfo_get_alias_appid(pkgmgrinfo_appinfo_h handle, char **alias_appid)
2140 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2142 if (handle == NULL || alias_appid == NULL) {
2143 LOGE("invalid parameter");
2144 return PMINFO_R_EINVAL;
2147 if (info->app_info == NULL || info->app_info->alias_appid == NULL)
2148 return PMINFO_R_ERROR;
2150 *alias_appid = (char *)info->app_info->alias_appid;
2155 API int pkgmgrinfo_appinfo_get_effective_appid(pkgmgrinfo_appinfo_h handle, char **effective_appid)
2157 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2159 if (handle == NULL || effective_appid == NULL) {
2160 LOGE("invalid parameter");
2161 return PMINFO_R_EINVAL;
2164 if (info->app_info == NULL || info->app_info->effective_appid == NULL)
2165 return PMINFO_R_ERROR;
2167 *effective_appid = (char *)info->app_info->effective_appid;
2172 API int pkgmgrinfo_appinfo_get_tep_name(pkgmgrinfo_appinfo_h handle, char **tep_name)
2174 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2176 if (handle == NULL || tep_name == NULL) {
2177 LOGE("invalid parameter");
2178 return PMINFO_R_EINVAL;
2181 if (info->app_info == NULL || info->app_info->tep_name == NULL)
2182 return PMINFO_R_ERROR;
2184 *tep_name = (char *)info->app_info->tep_name;
2189 API int pkgmgrinfo_appinfo_get_zip_mount_file(pkgmgrinfo_appinfo_h handle, char **zip_mount_file)
2191 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2193 if (handle == NULL || zip_mount_file == NULL) {
2194 LOGE("invalid parameter");
2195 return PMINFO_R_EINVAL;
2198 *zip_mount_file = (char *)info->app_info->zip_mount_file;
2203 API int pkgmgrinfo_appinfo_get_root_path(pkgmgrinfo_appinfo_h handle, char **root_path)
2205 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2207 if (handle == NULL || root_path == NULL) {
2208 LOGE("invalid parameter");
2209 return PMINFO_R_EINVAL;
2212 if (info->app_info == NULL || info->app_info->root_path == NULL)
2213 return PMINFO_R_ERROR;
2215 *root_path = (char *)info->app_info->root_path;
2220 API int pkgmgrinfo_appinfo_get_api_version(pkgmgrinfo_appinfo_h handle, char **api_version)
2222 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2224 if (handle == NULL || api_version == NULL) {
2225 LOGE("invalid parameter");
2226 return PMINFO_R_EINVAL;
2229 if (info->app_info == NULL || info->app_info->api_version == NULL)
2230 return PMINFO_R_ERROR;
2232 *api_version = (char *)info->app_info->api_version;
2237 API int pkgmgrinfo_appinfo_usr_get_datacontrol_info(const char *providerid, const char *type, uid_t uid, char **appid, char **access)
2239 retvm_if(providerid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
2240 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
2241 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2242 retvm_if(access == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2244 int ret = PMINFO_R_OK;
2246 sqlite3_stmt *stmt = NULL;
2249 ret = __open_manifest_db(uid, true);
2250 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
2252 /*Start constructing query*/
2253 query = sqlite3_mprintf("select * from package_app_data_control where providerid=%Q and type=%Q", providerid, type);
2256 ret = sqlite3_prepare_v2(GET_DB(manifest_db), query, strlen(query), &stmt, NULL);
2257 tryvm_if(ret != PMINFO_R_OK, ret = PMINFO_R_ERROR, "sqlite3_prepare_v2 failed[%s]\n", query);
2260 ret = sqlite3_step(stmt);
2261 tryvm_if((ret != SQLITE_ROW) || (ret == SQLITE_DONE), ret = PMINFO_R_ERROR, "No records found");
2263 *appid = strdup((char *)sqlite3_column_text(stmt, 0));
2264 *access = strdup((char *)sqlite3_column_text(stmt, 2));
2269 sqlite3_free(query);
2270 sqlite3_finalize(stmt);
2271 __close_manifest_db();
2275 API int pkgmgrinfo_appinfo_get_datacontrol_info(const char *providerid, const char *type, char **appid, char **access)
2277 return pkgmgrinfo_appinfo_usr_get_datacontrol_info(providerid, type, _getuid(), appid, access);
2280 API int pkgmgrinfo_appinfo_usr_get_datacontrol_appid(const char *providerid, uid_t uid, char **appid)
2282 retvm_if(providerid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
2283 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2285 int ret = PMINFO_R_OK;
2287 sqlite3_stmt *stmt = NULL;
2290 ret = __open_manifest_db(uid, true);
2291 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
2293 /*Start constructing query*/
2294 query = sqlite3_mprintf("select * from package_app_data_control where providerid=%Q", providerid);
2297 ret = sqlite3_prepare_v2(GET_DB(manifest_db), query, strlen(query), &stmt, NULL);
2298 tryvm_if(ret != PMINFO_R_OK, ret = PMINFO_R_ERROR, "sqlite3_prepare_v2 failed[%s]\n", query);
2301 ret = sqlite3_step(stmt);
2302 tryvm_if((ret != SQLITE_ROW) || (ret == SQLITE_DONE), ret = PMINFO_R_ERROR, "No records found");
2304 *appid = strdup((char *)sqlite3_column_text(stmt, 0));
2309 sqlite3_free(query);
2310 sqlite3_finalize(stmt);
2311 __close_manifest_db();
2315 API int pkgmgrinfo_appinfo_get_datacontrol_appid(const char *providerid, char **appid)
2317 return pkgmgrinfo_appinfo_usr_get_datacontrol_appid(providerid, _getuid(), appid);
2320 API int pkgmgrinfo_appinfo_foreach_permission(pkgmgrinfo_appinfo_h handle,
2321 pkgmgrinfo_app_permission_list_cb permission_func, void *user_data)
2323 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2324 retvm_if(permission_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2328 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2330 if (info->app_info == NULL)
2331 return PMINFO_R_ERROR;
2333 for (tmp = info->app_info->permission; tmp; tmp = tmp->next) {
2334 ptr = (permission_x *)tmp->data;
2338 ret = permission_func(ptr->value, user_data);
2346 API int pkgmgrinfo_appinfo_foreach_category(pkgmgrinfo_appinfo_h handle,
2347 pkgmgrinfo_app_category_list_cb category_func, void *user_data)
2349 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2350 retvm_if(category_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2352 const char *category;
2354 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2356 if (info->app_info == NULL)
2357 return PMINFO_R_ERROR;
2359 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
2360 category = (const char *)tmp->data;
2362 ret = category_func(category, user_data);
2370 API int pkgmgrinfo_appinfo_foreach_metadata(pkgmgrinfo_appinfo_h handle,
2371 pkgmgrinfo_app_metadata_list_cb metadata_func, void *user_data)
2373 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2374 retvm_if(metadata_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2378 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2380 if (info->app_info == NULL)
2381 return PMINFO_R_ERROR;
2383 for (tmp = info->app_info->metadata; tmp; tmp = tmp->next) {
2384 ptr = (metadata_x *)tmp->data;
2388 ret = metadata_func(ptr->key, ptr->value, user_data);
2396 API int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
2397 pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
2399 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2400 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2402 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2403 appcontrol_x *appcontrol;
2406 if (info->app_info == NULL)
2407 return PMINFO_R_ERROR;
2409 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
2410 appcontrol = (appcontrol_x *)tmp->data;
2411 if (appcontrol == NULL)
2413 ret = appcontrol_func(appcontrol->operation, appcontrol->uri, appcontrol->mime, user_data);
2421 API int pkgmgrinfo_appinfo_foreach_background_category(
2422 pkgmgrinfo_appinfo_h handle,
2423 pkgmgrinfo_app_background_category_list_cb category_func,
2426 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2430 if (handle == NULL || category_func == NULL || info->app_info == NULL) {
2431 LOGE("invalid parameter");
2432 return PMINFO_R_EINVAL;
2435 for (tmp = info->app_info->background_category; tmp; tmp = tmp->next) {
2436 category = (char *)tmp->data;
2437 if (category == NULL)
2440 if (category_func(category, user_data) < 0)
2447 API int pkgmgrinfo_appinfo_foreach_splash_screen(pkgmgrinfo_appinfo_h handle,
2448 pkgmgrinfo_app_splash_screen_list_cb splash_screen_func,
2451 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2452 splashscreen_x *splashscreen;
2456 if (info == NULL || info->app_info == NULL
2457 || splash_screen_func == NULL) {
2458 LOGE("invalid parameter");
2459 return PMINFO_R_EINVAL;
2462 for (tmp = info->app_info->splashscreens; tmp; tmp = tmp->next) {
2463 splashscreen = (splashscreen_x *)tmp->data;
2464 if (splashscreen == NULL)
2466 ret = splash_screen_func(splashscreen->src,
2468 splashscreen->orientation,
2469 splashscreen->indicatordisplay,
2470 splashscreen->operation,
2471 splashscreen->color_depth,
2480 API int pkgmgrinfo_appinfo_is_nodisplay(pkgmgrinfo_appinfo_h handle, bool *nodisplay)
2482 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2483 retvm_if(nodisplay == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2484 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2486 if (info->app_info == NULL || info->app_info->nodisplay == NULL)
2487 return PMINFO_R_ERROR;
2489 *nodisplay = _get_bool_value(info->app_info->nodisplay);
2494 API int pkgmgrinfo_appinfo_is_multiple(pkgmgrinfo_appinfo_h handle, bool *multiple)
2496 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2497 retvm_if(multiple == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2498 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2500 if (info->app_info == NULL || info->app_info->multiple == NULL)
2501 return PMINFO_R_ERROR;
2503 *multiple = _get_bool_value(info->app_info->multiple);
2508 API int pkgmgrinfo_appinfo_is_indicator_display_allowed(pkgmgrinfo_appinfo_h handle, bool *indicator_disp)
2510 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2511 retvm_if(indicator_disp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2512 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2514 if (info->app_info == NULL || info->app_info->indicatordisplay == NULL)
2515 return PMINFO_R_ERROR;
2517 *indicator_disp = _get_bool_value(info->app_info->indicatordisplay);
2522 API int pkgmgrinfo_appinfo_is_taskmanage(pkgmgrinfo_appinfo_h handle, bool *taskmanage)
2524 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2525 retvm_if(taskmanage == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2526 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2528 if (info->app_info == NULL || info->app_info->taskmanage == NULL)
2529 return PMINFO_R_ERROR;
2531 *taskmanage = _get_bool_value(info->app_info->taskmanage);
2536 API int pkgmgrinfo_appinfo_is_enabled(pkgmgrinfo_appinfo_h handle, bool *enabled)
2538 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2539 retvm_if(enabled == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2540 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2542 if (info->app_info == NULL || info->app_info->enabled == NULL)
2543 return PMINFO_R_ERROR;
2545 *enabled = _get_bool_value(info->app_info->enabled);
2550 API int pkgmgrinfo_appinfo_is_onboot(pkgmgrinfo_appinfo_h handle, bool *onboot)
2552 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2553 retvm_if(onboot == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2554 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2556 if (info->app_info == NULL || info->app_info->onboot == NULL)
2557 return PMINFO_R_ERROR;
2559 *onboot = _get_bool_value(info->app_info->onboot);
2564 API int pkgmgrinfo_appinfo_is_autorestart(pkgmgrinfo_appinfo_h handle, bool *autorestart)
2566 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2567 retvm_if(autorestart == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2568 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2570 if (info->app_info == NULL || info->app_info->autorestart == NULL)
2571 return PMINFO_R_ERROR;
2573 *autorestart = _get_bool_value(info->app_info->autorestart);
2578 API int pkgmgrinfo_appinfo_is_mainapp(pkgmgrinfo_appinfo_h handle, bool *mainapp)
2580 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2581 retvm_if(mainapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2582 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2584 if (info->app_info == NULL || info->app_info->mainapp == NULL)
2585 return PMINFO_R_ERROR;
2587 *mainapp = _get_bool_value(info->app_info->mainapp);
2592 API int pkgmgrinfo_appinfo_is_preload(pkgmgrinfo_appinfo_h handle, bool *preload)
2594 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2595 retvm_if(preload == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2596 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2598 if (info->app_info == NULL || info->app_info->preload == NULL)
2599 return PMINFO_R_ERROR;
2601 *preload = _get_bool_value(info->app_info->preload);
2606 API int pkgmgrinfo_appinfo_is_submode(pkgmgrinfo_appinfo_h handle, bool *submode)
2608 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2609 retvm_if(submode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2610 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2612 if (info->app_info == NULL || info->app_info->submode == NULL)
2613 return PMINFO_R_ERROR;
2615 *submode = _get_bool_value(info->app_info->submode);
2620 API int pkgmgrinfo_appinfo_is_process_pool(pkgmgrinfo_appinfo_h handle, bool *process_pool)
2622 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2624 if (handle == NULL || process_pool == NULL) {
2625 LOGE("invalid parameter");
2626 return PMINFO_R_EINVAL;
2629 if (info->app_info == NULL)
2630 return PMINFO_R_ERROR;
2632 *process_pool = _get_bool_value(info->app_info->process_pool);
2637 API int pkgmgrinfo_appinfo_is_category_exist(pkgmgrinfo_appinfo_h handle, const char *category, bool *exist)
2639 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2640 retvm_if(category == NULL, PMINFO_R_EINVAL, "category is NULL");
2641 retvm_if(exist == NULL, PMINFO_R_EINVAL, "exist is NULL");
2645 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2647 if (info->app_info == NULL)
2648 return PMINFO_R_ERROR;
2651 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
2652 val = (const char *)tmp->data;
2655 if (strcasecmp(val, category) == 0) {
2664 API int pkgmgrinfo_appinfo_is_ui_gadget(pkgmgrinfo_appinfo_h handle,
2667 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2669 if (info == NULL || info->app_info == NULL || ui_gadget == NULL) {
2670 _LOGE("invalid parameter");
2671 return PMINFO_R_EINVAL;
2674 *ui_gadget = _get_bool_value(info->app_info->ui_gadget);
2679 API int pkgmgrinfo_appinfo_is_support_disable(pkgmgrinfo_appinfo_h handle,
2680 bool *support_disable)
2682 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2684 if (info == NULL || info->app_info == NULL || support_disable == NULL) {
2685 _LOGE("invalid parameter");
2686 return PMINFO_R_EINVAL;
2689 *support_disable = _get_bool_value(info->app_info->support_disable);
2694 API int pkgmgrinfo_appinfo_is_disabled(pkgmgrinfo_appinfo_h handle, bool *disabled)
2696 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2697 retvm_if(disabled == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2698 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2700 if (info->app_info == NULL || info->app_info->is_disabled == NULL)
2701 return PMINFO_R_ERROR;
2703 *disabled = _get_bool_value(info->app_info->is_disabled);
2708 API int pkgmgrinfo_appinfo_is_global(pkgmgrinfo_appinfo_h handle, bool *global)
2710 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2712 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2713 retvm_if(global == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2715 if (info->app_info == NULL || info->app_info->for_all_users == NULL)
2716 return PMINFO_R_ERROR;
2718 *global = _get_bool_value(info->app_info->for_all_users);
2723 API int pkgmgrinfo_appinfo_get_splash_screen_display(pkgmgrinfo_appinfo_h handle, bool *splash_screen_display)
2725 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2727 if (info == NULL || splash_screen_display == NULL) {
2728 _LOGE("Invalid parameter");
2729 return PMINFO_R_EINVAL;
2732 if (info->app_info == NULL || info->app_info->splash_screen_display == NULL)
2733 return PMINFO_R_ERROR;
2735 *splash_screen_display = _get_bool_value(info->app_info->splash_screen_display);
2740 API int pkgmgrinfo_appinfo_destroy_appinfo(pkgmgrinfo_appinfo_h handle)
2742 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2743 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2744 __cleanup_appinfo(info);
2748 API int pkgmgrinfo_appinfo_filter_create(pkgmgrinfo_appinfo_filter_h *handle)
2750 return (pkgmgrinfo_pkginfo_filter_create(handle));
2753 API int pkgmgrinfo_appinfo_filter_destroy(pkgmgrinfo_appinfo_filter_h handle)
2755 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
2758 static gint __compare_func(gconstpointer data1, gconstpointer data2)
2760 pkgmgrinfo_node_x *node1 = (pkgmgrinfo_node_x*)data1;
2761 pkgmgrinfo_node_x *node2 = (pkgmgrinfo_node_x*)data2;
2762 if (node1->prop == node2->prop)
2764 else if (node1->prop > node2->prop)
2770 API int pkgmgrinfo_appinfo_filter_add_int(pkgmgrinfo_appinfo_filter_h handle,
2771 const char *property, const int value)
2773 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2774 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2775 char buf[PKG_VALUE_STRING_LEN_MAX] = {'\0'};
2777 GSList *link = NULL;
2779 prop = _pminfo_appinfo_convert_to_prop_int(property);
2780 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_INT ||
2781 prop > E_PMINFO_APPINFO_PROP_APP_MAX_INT) {
2782 _LOGE("Invalid Integer Property\n");
2783 return PMINFO_R_EINVAL;
2785 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
2786 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
2788 _LOGE("Out of Memory!!!\n");
2789 return PMINFO_R_ERROR;
2791 snprintf(buf, PKG_VALUE_STRING_LEN_MAX - 1, "%d", value);
2792 val = strndup(buf, PKG_VALUE_STRING_LEN_MAX - 1);
2794 _LOGE("Out of Memory\n");
2797 return PMINFO_R_ERROR;
2801 /*If API is called multiple times for same property, we should override the previous values.
2802 Last value set will be used for filtering.*/
2803 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2805 filter->list = g_slist_delete_link(filter->list, link);
2806 filter->list = g_slist_append(filter->list, (gpointer)node);
2811 API int pkgmgrinfo_appinfo_filter_add_bool(pkgmgrinfo_appinfo_filter_h handle,
2812 const char *property, const bool value)
2814 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2815 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2817 GSList *link = NULL;
2819 prop = _pminfo_appinfo_convert_to_prop_bool(property);
2820 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_BOOL ||
2821 prop > E_PMINFO_APPINFO_PROP_APP_MAX_BOOL) {
2822 _LOGE("Invalid Boolean Property\n");
2823 return PMINFO_R_EINVAL;
2825 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
2826 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
2828 _LOGE("Out of Memory!!!\n");
2829 return PMINFO_R_ERROR;
2832 val = strndup("('true','True')", 15);
2834 val = strndup("('false','False')", 17);
2836 _LOGE("Out of Memory\n");
2839 return PMINFO_R_ERROR;
2843 /*If API is called multiple times for same property, we should override the previous values.
2844 Last value set will be used for filtering.*/
2845 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2847 filter->list = g_slist_delete_link(filter->list, link);
2848 filter->list = g_slist_append(filter->list, (gpointer)node);
2853 API int pkgmgrinfo_appinfo_filter_add_string(pkgmgrinfo_appinfo_filter_h handle,
2854 const char *property, const char *value)
2856 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2857 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2858 retvm_if(value == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2860 pkgmgrinfo_node_x *ptr = NULL;
2861 char prev[PKG_STRING_LEN_MAX] = {'\0'};
2862 char temp[PKG_STRING_LEN_MAX] = {'\0'};
2863 GSList *link = NULL;
2865 prop = _pminfo_appinfo_convert_to_prop_str(property);
2866 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_STR ||
2867 prop > E_PMINFO_APPINFO_PROP_APP_MAX_STR) {
2868 _LOGE("Invalid String Property\n");
2869 return PMINFO_R_EINVAL;
2871 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
2872 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
2874 _LOGE("Out of Memory!!!\n");
2875 return PMINFO_R_ERROR;
2879 case E_PMINFO_APPINFO_PROP_APP_COMPONENT:
2880 node->value = strdup(value);
2881 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2883 filter->list = g_slist_delete_link(filter->list, link);
2884 filter->list = g_slist_append(filter->list, (gpointer)node);
2886 case E_PMINFO_APPINFO_PROP_APP_CATEGORY:
2887 val = (char *)calloc(1, PKG_STRING_LEN_MAX);
2889 _LOGE("Out of Memory\n");
2892 return PMINFO_R_ERROR;
2894 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2896 ptr = (pkgmgrinfo_node_x *)link->data;
2897 strncpy(prev, ptr->value, PKG_STRING_LEN_MAX - 1);
2898 _LOGI("Previous value is %s\n", prev);
2899 filter->list = g_slist_delete_link(filter->list, link);
2900 snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s , '%s'", prev, value);
2901 strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
2902 _LOGI("New value is %s\n", val);
2904 filter->list = g_slist_append(filter->list, (gpointer)node);
2905 memset(temp, '\0', PKG_STRING_LEN_MAX);
2907 snprintf(temp, PKG_STRING_LEN_MAX - 1, "'%s'", value);
2908 strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
2909 _LOGI("First value is %s\n", val);
2911 filter->list = g_slist_append(filter->list, (gpointer)node);
2912 memset(temp, '\0', PKG_STRING_LEN_MAX);
2916 node->value = strndup(value, PKG_STRING_LEN_MAX - 1);
2917 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2919 filter->list = g_slist_delete_link(filter->list, link);
2920 filter->list = g_slist_append(filter->list, (gpointer)node);
2926 API int pkgmgrinfo_appinfo_usr_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count, uid_t uid)
2931 if (handle == NULL || count == NULL) {
2932 _LOGE("invalid parameter");
2933 return PMINFO_R_EINVAL;
2936 ret = _appinfo_get_filtered_list(handle, uid, &list);
2937 if (ret != PMINFO_R_OK)
2938 return PMINFO_R_ERROR;
2940 *count = g_list_length(list);
2942 g_list_free_full(list, free);
2947 API int pkgmgrinfo_appinfo_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count)
2949 return pkgmgrinfo_appinfo_usr_filter_count(handle, count, _getuid());
2952 API int pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(
2953 pkgmgrinfo_appinfo_filter_h handle,
2954 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
2956 if (handle == NULL || app_cb == NULL) {
2957 LOGE("invalid parameter");
2958 return PMINFO_R_EINVAL;
2961 return _appinfo_get_filtered_foreach_appinfo(uid, handle, app_cb,
2965 API int pkgmgrinfo_appinfo_filter_foreach_appinfo(pkgmgrinfo_appinfo_filter_h handle,
2966 pkgmgrinfo_app_list_cb app_cb, void * user_data)
2968 return pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(handle, app_cb, user_data, _getuid());
2971 API int pkgmgrinfo_appinfo_metadata_filter_create(pkgmgrinfo_appinfo_metadata_filter_h *handle)
2973 return (pkgmgrinfo_pkginfo_filter_create(handle));
2976 API int pkgmgrinfo_appinfo_metadata_filter_destroy(pkgmgrinfo_appinfo_metadata_filter_h handle)
2978 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
2981 API int pkgmgrinfo_appinfo_metadata_filter_add(
2982 pkgmgrinfo_appinfo_metadata_filter_h handle,
2983 const char *key, const char *value)
2987 ret = pkgmgrinfo_appinfo_filter_add_string(handle,
2988 PMINFO_APPINFO_PROP_APP_METADATA_KEY, key);
2989 if (ret != PMINFO_R_OK)
2992 /* value can be NULL.
2993 * In that case all apps with specified key should be displayed
2996 ret = pkgmgrinfo_appinfo_filter_add_string(handle,
2997 PMINFO_APPINFO_PROP_APP_METADATA_VALUE, value);
2998 if (ret != PMINFO_R_OK)
3005 API int pkgmgrinfo_appinfo_usr_metadata_filter_foreach(
3006 pkgmgrinfo_appinfo_metadata_filter_h handle,
3007 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
3009 if (handle == NULL || app_cb == NULL) {
3010 LOGE("invalid parameter");
3011 return PMINFO_R_EINVAL;
3014 return _appinfo_get_filtered_foreach_appinfo(uid, handle, app_cb,
3018 API int pkgmgrinfo_appinfo_metadata_filter_foreach(
3019 pkgmgrinfo_appinfo_metadata_filter_h handle,
3020 pkgmgrinfo_app_list_cb app_cb, void *user_data)
3022 return pkgmgrinfo_appinfo_usr_metadata_filter_foreach(handle, app_cb,
3023 user_data, _getuid());
3026 API int pkgmgrinfo_appinfo_is_guestmode_visibility(pkgmgrinfo_appinfo_h handle, bool *status)
3029 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3031 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
3032 retvm_if(status == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3034 val = info->app_info->guestmode_visibility;
3035 *status = _get_bool_value(val);