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 char *_get_filtered_query(const char *query_raw,
45 pkgmgrinfo_filter_x *filter)
47 char buf[MAX_QUERY_LEN] = { 0, };
56 strncat(buf, query_raw, MAX_QUERY_LEN - 1);
58 for (list = head; list; list = list->next) {
59 /* TODO: revise condition getter function */
60 __get_filter_condition(list->data, &condition);
61 if (condition == NULL)
63 if (buf[strlen(query_raw)] == '\0') {
64 len += strlen(" WHERE ");
65 strncat(buf, " WHERE ", MAX_QUERY_LEN - len - 1);
67 len += strlen(" AND ");
68 strncat(buf, " AND ", MAX_QUERY_LEN -len - 1);
70 len += strlen(condition);
71 strncat(buf, condition, sizeof(buf) - len - 1);
79 static gint __list_strcmp(gconstpointer a, gconstpointer b)
81 return strcmp((char *)a, (char *)b);
84 static gint _appinfo_get_list(sqlite3 *db, const char *locale,
85 pkgmgrinfo_filter_x *filter, GList **list)
87 static const char query_raw[] =
88 "SELECT DISTINCT package_app_info.app_id FROM package_app_info"
89 " LEFT OUTER JOIN package_app_localized_info"
90 " ON package_app_info.app_id=package_app_localized_info.app_id"
91 " AND package_app_localized_info.app_locale=%Q"
92 " LEFT OUTER JOIN package_app_app_category"
93 " ON package_app_info.app_id=package_app_app_category.app_id"
94 " LEFT OUTER JOIN package_app_app_control"
95 " ON package_app_info.app_id=package_app_app_control.app_id"
96 " LEFT OUTER JOIN package_app_app_metadata"
97 " ON package_app_info.app_id=package_app_app_metadata.app_id ";
100 char *query_localized;
104 query = _get_filtered_query(query_raw, filter);
106 return PMINFO_R_ERROR;
107 query_localized = sqlite3_mprintf(query, locale);
109 if (query_localized == NULL)
110 return PMINFO_R_ERROR;
112 ret = sqlite3_prepare_v2(db, query_localized,
113 strlen(query_localized), &stmt, NULL);
114 sqlite3_free(query_localized);
115 if (ret != SQLITE_OK) {
116 LOGE("prepare failed: %s", sqlite3_errmsg(db));
117 return PMINFO_R_ERROR;
120 while (sqlite3_step(stmt) == SQLITE_ROW) {
121 _save_column_str(stmt, 0, (const char **)&appid);
123 *list = g_list_insert_sorted(*list, appid,
127 sqlite3_finalize(stmt);
132 static int _appinfo_get_filtered_list(pkgmgrinfo_filter_x *filter, uid_t uid,
142 locale = _get_system_locale();
144 return PMINFO_R_ERROR;
146 dbpath = getUserPkgParserDBPathUID(uid);
147 if (dbpath == NULL) {
149 return PMINFO_R_ERROR;
152 ret = sqlite3_open_v2(dbpath, &db, SQLITE_OPEN_READONLY, NULL);
153 if (ret != SQLITE_OK) {
154 _LOGE("failed to open db: %d", ret);
156 return PMINFO_R_ERROR;
159 if (_appinfo_get_list(db, locale, filter, list)) {
161 sqlite3_close_v2(db);
162 return PMINFO_R_ERROR;
164 sqlite3_close_v2(db);
166 if (uid == GLOBAL_USER) {
171 /* search again from global */
172 dbpath = getUserPkgParserDBPathUID(GLOBAL_USER);
173 if (dbpath == NULL) {
175 return PMINFO_R_ERROR;
178 ret = sqlite3_open_v2(dbpath, &db, SQLITE_OPEN_READONLY, NULL);
179 if (ret != SQLITE_OK) {
180 _LOGE("failed to open db: %d", ret);
182 return PMINFO_R_ERROR;
185 if (_appinfo_get_list(db, locale, filter, list)) {
187 sqlite3_close_v2(db);
188 return PMINFO_R_ERROR;
190 sqlite3_close_v2(db);
192 /* remove duplicate element:
193 * since the list is sorted, we can remove duplicates in linear time
195 for (tmp = *list, tmp2 = g_list_next(tmp); tmp;
196 tmp = tmp2, tmp2 = g_list_next(tmp)) {
197 if (tmp->prev == NULL || tmp->data == NULL)
199 if (strcmp((const char *)tmp->prev->data,
200 (const char *)tmp->data) == 0)
201 *list = g_list_delete_link(*list, tmp);
209 static int _appinfo_get_label(sqlite3 *db, const char *appid,
210 const char *locale, GList **label)
212 static const char query_raw[] =
213 "SELECT app_label, app_locale "
214 "FROM package_app_localized_info "
215 "WHERE app_id=%Q AND app_locale IN (%Q, %Q)";
222 query = sqlite3_mprintf(query_raw, appid, locale, DEFAULT_LOCALE);
224 LOGE("out of memory");
225 return PMINFO_R_ERROR;
228 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
230 if (ret != SQLITE_OK) {
231 LOGE("prepare failed: %s", sqlite3_errmsg(db));
232 return PMINFO_R_ERROR;
235 while (sqlite3_step(stmt) == SQLITE_ROW) {
236 info = calloc(1, sizeof(label_x));
238 LOGE("out of memory");
239 sqlite3_finalize(stmt);
240 return PMINFO_R_ERROR;
243 _save_column_str(stmt, idx++, &info->text);
244 _save_column_str(stmt, idx++, &info->lang);
245 *label = g_list_append(*label, info);
248 sqlite3_finalize(stmt);
253 static int _appinfo_get_icon(sqlite3 *db, const char *appid, const char *locale,
256 static const char query_raw[] =
257 "SELECT app_icon, app_locale "
258 "FROM package_app_localized_info "
259 "WHERE app_id=%Q AND app_locale IN (%Q, %Q)";
266 query = sqlite3_mprintf(query_raw, appid, locale, DEFAULT_LOCALE);
268 LOGE("out of memory");
269 return PMINFO_R_ERROR;
272 ret = sqlite3_prepare_v2(db, query, strlen(query),
275 if (ret != SQLITE_OK) {
276 LOGE("prepare failed: %s", sqlite3_errmsg(db));
277 return PMINFO_R_ERROR;
280 while (sqlite3_step(stmt) == SQLITE_ROW) {
281 info = calloc(1, sizeof(icon_x));
283 LOGE("out of memory");
284 sqlite3_finalize(stmt);
285 return PMINFO_R_ERROR;
288 _save_column_str(stmt, idx++, &info->text);
289 _save_column_str(stmt, idx++, &info->lang);
290 *icon = g_list_append(*icon, info);
293 sqlite3_finalize(stmt);
298 static int _appinfo_get_category(sqlite3 *db, const char *appid,
301 static const char query_raw[] =
302 "SELECT category FROM package_app_app_category WHERE app_id=%Q";
308 query = sqlite3_mprintf(query_raw, appid);
310 LOGE("out of memory");
311 return PMINFO_R_ERROR;
314 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
316 if (ret != SQLITE_OK) {
317 LOGE("prepare failed: %s", sqlite3_errmsg(db));
318 return PMINFO_R_ERROR;
321 while (sqlite3_step(stmt) == SQLITE_ROW) {
323 _save_column_str(stmt, 0, &val);
325 *category = g_list_append(*category, (gpointer)val);
328 sqlite3_finalize(stmt);
333 static void __parse_appcontrol(GList **appcontrol, char *appcontrol_str)
340 if (appcontrol_str == NULL)
343 dup = strdup(appcontrol_str);
345 ac = calloc(1, sizeof(appcontrol_x));
347 _LOGE("out of memory");
350 token = strtok_r(dup, "|", &ptr);
351 if (token && strcmp(token, "NULL"))
352 ac->operation = strdup(token);
353 token = strtok_r(NULL, "|", &ptr);
354 if (token && strcmp(token, "NULL"))
355 ac->uri = strdup(token);
356 token = strtok_r(NULL, "|", &ptr);
357 if (token && strcmp(token, "NULL"))
358 ac->mime = strdup(token);
359 *appcontrol = g_list_append(*appcontrol, ac);
360 } while ((token = strtok_r(NULL, ";", &ptr)));
365 static int _appinfo_get_app_control(sqlite3 *db, const char *appid,
368 static const char query_raw[] =
369 "SELECT app_control FROM package_app_app_control "
376 query = sqlite3_mprintf(query_raw, appid);
378 LOGE("out of memory");
379 return PMINFO_R_ERROR;
382 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
384 if (ret != SQLITE_OK) {
385 LOGE("prepare failed: %s", sqlite3_errmsg(db));
386 return PMINFO_R_ERROR;
389 while (sqlite3_step(stmt) == SQLITE_ROW) {
391 _save_column_str(stmt, 0, (const char **)&str);
393 __parse_appcontrol(appcontrol, str);
397 sqlite3_finalize(stmt);
402 static int _appinfo_get_data_control(sqlite3 *db, const char *appid,
405 static const char query_raw[] =
406 "SELECT providerid, access, type "
407 "FROM package_app_data_control WHERE app_id=%Q";
414 query = sqlite3_mprintf(query_raw, appid);
416 LOGE("out of memory");
417 return PMINFO_R_ERROR;
420 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
422 if (ret != SQLITE_OK) {
423 LOGE("prepare failed: %s", sqlite3_errmsg(db));
424 return PMINFO_R_ERROR;
427 while (sqlite3_step(stmt) == SQLITE_ROW) {
428 info = calloc(1, sizeof(datacontrol_x));
430 LOGE("out of memory");
431 sqlite3_finalize(stmt);
432 return PMINFO_R_ERROR;
435 _save_column_str(stmt, idx++, &info->providerid);
436 _save_column_str(stmt, idx++, &info->access);
437 _save_column_str(stmt, idx++, &info->type);
438 *datacontrol = g_list_append(*datacontrol, info);
441 sqlite3_finalize(stmt);
446 static int _appinfo_get_metadata(sqlite3 *db, const char *appid,
449 static const char query_raw[] =
450 "SELECT md_key, md_value "
451 "FROM package_app_app_metadata WHERE app_id=%Q";
458 query = sqlite3_mprintf(query_raw, appid);
460 LOGE("out of memory");
461 return PMINFO_R_ERROR;
464 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
466 if (ret != SQLITE_OK) {
467 LOGE("prepare failed: %s", sqlite3_errmsg(db));
468 return PMINFO_R_ERROR;
471 while (sqlite3_step(stmt) == SQLITE_ROW) {
472 info = calloc(1, sizeof(metadata_x));
474 LOGE("out of memory");
475 sqlite3_finalize(stmt);
476 return PMINFO_R_ERROR;
479 _save_column_str(stmt, idx++, &info->key);
480 _save_column_str(stmt, idx++, &info->value);
481 *metadata = g_list_append(*metadata, info);
484 sqlite3_finalize(stmt);
490 static int _appinfo_get_splashscreens(sqlite3 *db, const char *appid,
491 GList **splashscreens)
493 static const char query_raw[] =
494 "SELECT src, type, orientation, indicatordisplay, operation "
495 "FROM package_app_splash_screen WHERE app_id=%Q";
500 splashscreen_x *info;
502 query = sqlite3_mprintf(query_raw, appid);
504 LOGE("out of memory");
505 return PMINFO_R_ERROR;
508 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
510 if (ret != SQLITE_OK) {
511 LOGE("prepare failed: %s", sqlite3_errmsg(db));
512 return PMINFO_R_ERROR;
515 while (sqlite3_step(stmt) == SQLITE_ROW) {
516 info = calloc(1, sizeof(splashscreen_x));
518 LOGE("out of memory");
519 sqlite3_finalize(stmt);
520 return PMINFO_R_ERROR;
523 _save_column_str(stmt, idx++, &info->src);
524 _save_column_str(stmt, idx++, &info->type);
525 _save_column_str(stmt, idx++, &info->orientation);
526 _save_column_str(stmt, idx++, &info->indicatordisplay);
527 _save_column_str(stmt, idx++, &info->operation);
528 *splashscreens = g_list_append(*splashscreens, info);
531 sqlite3_finalize(stmt);
536 static GList *__get_background_category(char *value)
538 GList *category_list = NULL;
539 int convert_value = 0;
540 if (!value || strlen(value) == 0)
543 convert_value = atoi(value);
544 if (convert_value < 0)
547 if (convert_value & APP_BG_CATEGORY_USER_DISABLE_TRUE_VAL)
548 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_USER_DISABLE_TRUE_STR));
550 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_USER_DISABLE_FALSE_STR));
552 if (convert_value & APP_BG_CATEGORY_MEDIA_VAL)
553 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_MEDIA_STR));
555 if (convert_value & APP_BG_CATEGORY_DOWNLOAD_VAL)
556 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_DOWNLOAD_STR));
558 if (convert_value & APP_BG_CATEGORY_BGNETWORK_VAL)
559 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_BGNETWORK_STR));
561 if (convert_value & APP_BG_CATEGORY_LOCATION_VAL)
562 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_LOCATION_STR));
564 if (convert_value & APP_BG_CATEGORY_SENSOR_VAL)
565 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_SENSOR_STR));
567 if (convert_value & APP_BG_CATEGORY_IOTCOMM_VAL)
568 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_IOTCOMM_STR));
570 if (convert_value & APP_BG_CATEGORY_SYSTEM_VAL)
571 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_SYSTEM));
573 return category_list;
577 static int _appinfo_get_application(sqlite3 *db, const char *appid,
578 const char *locale, application_x **application, bool is_disabled)
580 static const char query_raw[] =
581 "SELECT app_id, app_component, app_exec, app_nodisplay, "
582 "app_type, app_onboot, app_multiple, app_autorestart, "
583 "app_taskmanage, app_enabled, app_hwacceleration, "
584 "app_screenreader, app_mainapp, app_recentimage, "
585 "app_launchcondition, app_indicatordisplay, app_portraitimg, "
586 "app_landscapeimg, app_guestmodevisibility, "
587 "app_permissiontype, app_preload, app_submode, "
588 "app_submode_mainid, app_launch_mode, app_ui_gadget, "
589 "app_support_disable, "
590 "component_type, package, app_process_pool, app_installed_storage, "
591 "app_background_category, app_package_type "
592 "FROM package_app_info WHERE app_id='%s' "
593 "AND (app_disable='%s' "
595 "(SELECT app_id from package_app_disable_for_user WHERE uid='%d'))";
597 char query[MAX_QUERY_LEN] = { '\0' };
601 char *bg_category_str = NULL;
602 snprintf(query, MAX_QUERY_LEN - 1, query_raw,
604 is_disabled ? "true" : "false",
605 is_disabled ? "OR" : "AND",
606 is_disabled ? "" : "NOT",
609 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
610 if (ret != SQLITE_OK) {
611 LOGE("prepare failed: %s", sqlite3_errmsg(db));
612 return PMINFO_R_ERROR;
615 ret = sqlite3_step(stmt);
616 if (ret == SQLITE_DONE) {
617 sqlite3_finalize(stmt);
618 return PMINFO_R_ENOENT;
619 } else if (ret != SQLITE_ROW) {
620 LOGE("step failed: %s", sqlite3_errmsg(db));
621 sqlite3_finalize(stmt);
622 return PMINFO_R_ERROR;
625 info = calloc(1, sizeof(application_x));
627 LOGE("out of memory");
628 sqlite3_finalize(stmt);
629 return PMINFO_R_ERROR;
632 _save_column_str(stmt, idx++, &info->appid);
633 _save_column_str(stmt, idx++, &info->component);
634 _save_column_str(stmt, idx++, &info->exec);
635 _save_column_str(stmt, idx++, &info->nodisplay);
636 _save_column_str(stmt, idx++, &info->type);
637 _save_column_str(stmt, idx++, &info->onboot);
638 _save_column_str(stmt, idx++, &info->multiple);
639 _save_column_str(stmt, idx++, &info->autorestart);
640 _save_column_str(stmt, idx++, &info->taskmanage);
641 _save_column_str(stmt, idx++, &info->enabled);
642 _save_column_str(stmt, idx++, &info->hwacceleration);
643 _save_column_str(stmt, idx++, &info->screenreader);
644 _save_column_str(stmt, idx++, &info->mainapp);
645 _save_column_str(stmt, idx++, &info->recentimage);
646 _save_column_str(stmt, idx++, &info->launchcondition);
647 _save_column_str(stmt, idx++, &info->indicatordisplay);
648 _save_column_str(stmt, idx++, &info->portraitimg);
649 _save_column_str(stmt, idx++, &info->landscapeimg);
650 _save_column_str(stmt, idx++, &info->guestmode_visibility);
651 _save_column_str(stmt, idx++, &info->permission_type);
652 _save_column_str(stmt, idx++, &info->preload);
653 _save_column_str(stmt, idx++, &info->submode);
654 _save_column_str(stmt, idx++, &info->submode_mainid);
655 _save_column_str(stmt, idx++, &info->launch_mode);
656 _save_column_str(stmt, idx++, &info->ui_gadget);
657 _save_column_str(stmt, idx++, &info->support_disable);
658 _save_column_str(stmt, idx++, &info->component_type);
659 _save_column_str(stmt, idx++, &info->package);
660 _save_column_str(stmt, idx++, &info->process_pool);
661 _save_column_str(stmt, idx++, &info->installed_storage);
662 _save_column_str(stmt, idx++, &bg_category_str);
663 _save_column_str(stmt, idx++, &info->package_type);
665 info->background_category = __get_background_category(bg_category_str);
667 if (_appinfo_get_label(db, info->appid, locale, &info->label)) {
668 pkgmgrinfo_basic_free_application(info);
669 sqlite3_finalize(stmt);
670 return PMINFO_R_ERROR;
673 if (_appinfo_get_icon(db, info->appid, locale, &info->icon)) {
674 pkgmgrinfo_basic_free_application(info);
675 sqlite3_finalize(stmt);
676 return PMINFO_R_ERROR;
679 if (_appinfo_get_category(db, info->appid, &info->category)) {
680 pkgmgrinfo_basic_free_application(info);
681 sqlite3_finalize(stmt);
682 return PMINFO_R_ERROR;
685 if (_appinfo_get_app_control(db, info->appid, &info->appcontrol)) {
686 pkgmgrinfo_basic_free_application(info);
687 sqlite3_finalize(stmt);
688 return PMINFO_R_ERROR;
691 if (_appinfo_get_data_control(db, info->appid, &info->datacontrol)) {
692 pkgmgrinfo_basic_free_application(info);
693 sqlite3_finalize(stmt);
694 return PMINFO_R_ERROR;
697 if (_appinfo_get_metadata(db, info->appid, &info->metadata)) {
698 pkgmgrinfo_basic_free_application(info);
699 sqlite3_finalize(stmt);
700 return PMINFO_R_ERROR;
703 if (_appinfo_get_splashscreens(db, info->appid, &info->splashscreens)) {
704 pkgmgrinfo_basic_free_application(info);
705 sqlite3_finalize(stmt);
706 return PMINFO_R_ERROR;
711 sqlite3_finalize(stmt);
716 static int _appinfo_get_appinfo(const char *appid, uid_t uid,
717 pkgmgr_appinfo_x **appinfo, bool is_disabled)
723 pkgmgr_appinfo_x *info;
725 dbpath = getUserPkgParserDBPathUID(uid);
727 return PMINFO_R_ERROR;
729 locale = _get_system_locale();
731 return PMINFO_R_ERROR;
733 ret = sqlite3_open_v2(dbpath, &db, SQLITE_OPEN_READONLY, NULL);
734 if (ret != SQLITE_OK) {
735 _LOGE("failed to open db: %d", ret);
737 return PMINFO_R_ERROR;
740 info = calloc(1, sizeof(pkgmgr_appinfo_x));
742 _LOGE("out of memory");
744 sqlite3_close_v2(db);
745 return PMINFO_R_ERROR;
748 ret = _appinfo_get_application(db, appid, locale, &info->app_info, is_disabled);
749 if (ret != PMINFO_R_OK) {
752 sqlite3_close_v2(db);
756 info->locale = locale;
757 info->package = strdup(info->app_info->package);
761 sqlite3_close_v2(db);
766 API int pkgmgrinfo_appinfo_get_usr_disabled_appinfo(const char *appid, uid_t uid,
767 pkgmgrinfo_appinfo_h *handle)
771 if (appid == NULL || handle == NULL) {
772 LOGE("invalid parameter");
773 return PMINFO_R_EINVAL;
776 ret = _appinfo_get_appinfo(appid, uid, (pkgmgr_appinfo_x **)handle, true);
777 if (ret == PMINFO_R_ENOENT && uid != GLOBAL_USER)
778 ret = _appinfo_get_appinfo(appid, GLOBAL_USER,
779 (pkgmgr_appinfo_x **)handle, true);
781 if (ret != PMINFO_R_OK)
782 _LOGE("failed to get appinfo of %s for user %d", appid, uid);
787 API int pkgmgrinfo_appinfo_get_disabled_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
789 return pkgmgrinfo_appinfo_get_usr_disabled_appinfo(appid, GLOBAL_USER, handle);
792 API int pkgmgrinfo_appinfo_get_usr_appinfo(const char *appid, uid_t uid,
793 pkgmgrinfo_appinfo_h *handle)
797 if (appid == NULL || handle == NULL) {
798 LOGE("invalid parameter");
799 return PMINFO_R_EINVAL;
802 ret = _appinfo_get_appinfo(appid, uid, (pkgmgr_appinfo_x **)handle, false);
803 if (ret == PMINFO_R_ENOENT && uid != GLOBAL_USER)
804 ret = _appinfo_get_appinfo(appid, GLOBAL_USER,
805 (pkgmgr_appinfo_x **)handle, false);
807 if (ret != PMINFO_R_OK)
808 _LOGE("failed to get appinfo of %s for user %d", appid, uid);
813 API int pkgmgrinfo_appinfo_get_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
815 return pkgmgrinfo_appinfo_get_usr_appinfo(appid, GLOBAL_USER, handle);
818 static gpointer __copy_str(gconstpointer src, gpointer data)
820 const char *tmp = (const char *)src;
823 buffer = strdup(tmp);
824 if (buffer == NULL) {
825 LOGE("memory alloc failed");
833 static gpointer __copy_label(gconstpointer src, gpointer data)
835 label_x *tmp = (label_x *)src;
838 label = calloc(1, sizeof(label_x));
840 LOGE("memory alloc failed");
846 label->name = strdup(tmp->name);
848 label->text = strdup(tmp->text);
850 label->lang = strdup(tmp->lang);
855 static gpointer __copy_icon(gconstpointer src, gpointer data)
857 icon_x *tmp = (icon_x *)src;
860 icon = calloc(1, sizeof(icon_x));
862 LOGE("memory alloc failed");
868 icon->text = strdup(tmp->text);
870 icon->lang = strdup(tmp->lang);
872 icon->section = strdup(tmp->section);
874 icon->size = strdup(tmp->size);
876 icon->resolution = strdup(tmp->resolution);
881 static gpointer __copy_metadata(gconstpointer src, gpointer data)
883 metadata_x *tmp = (metadata_x *)src;
884 metadata_x *metadata;
886 metadata = calloc(1, sizeof(metadata_x));
887 if (metadata == NULL) {
888 LOGE("memory alloc failed");
894 metadata->key = strdup(tmp->key);
896 metadata->value = strdup(tmp->value);
901 static gpointer __copy_datacontrol(gconstpointer src, gpointer data)
903 datacontrol_x *tmp = (datacontrol_x *)src;
904 datacontrol_x *datacontrol;
906 datacontrol = calloc(1, sizeof(datacontrol_x));
907 if (datacontrol == NULL) {
908 LOGE("memory alloc failed");
914 datacontrol->providerid = strdup(tmp->providerid);
916 datacontrol->access = strdup(tmp->access);
918 datacontrol->type = strdup(tmp->type);
923 static gpointer __copy_appcontrol(gconstpointer src, gpointer data)
925 appcontrol_x *tmp = (appcontrol_x *)src;
926 appcontrol_x *appcontrol;
928 appcontrol = calloc(1, sizeof(appcontrol_x));
929 if (appcontrol ==NULL) {
930 LOGE("memory alloc failed");
936 appcontrol->operation = strdup(tmp->operation);
938 appcontrol->uri = strdup(tmp->uri);
940 appcontrol->mime = strdup(tmp->mime);
945 static gpointer __copy_splashscreens(gconstpointer src, gpointer data)
947 splashscreen_x *tmp = (splashscreen_x *)src;
948 splashscreen_x *splashscreen;
950 splashscreen = (splashscreen_x *)calloc(1, sizeof(splashscreen_x));
951 if (splashscreen == NULL) {
952 LOGE("memory alloc failed");
958 splashscreen->src = strdup(tmp->src);
960 splashscreen->type = strdup(tmp->type);
961 if (tmp->orientation)
962 splashscreen->orientation = strdup(tmp->orientation);
963 if (tmp->indicatordisplay)
964 splashscreen->indicatordisplay = strdup(tmp->indicatordisplay);
966 splashscreen->operation = strdup(tmp->operation);
971 static int _appinfo_copy_appinfo(application_x **application, application_x *data)
973 application_x *app_info;
976 app_info = calloc(1, sizeof(application_x));
977 if (app_info == NULL) {
978 LOGE("memory alloc failed");
979 return PMINFO_R_ERROR;
982 if (data->appid != NULL)
983 app_info->appid = strdup(data->appid);
984 if (data->exec != NULL)
985 app_info->exec = strdup(data->exec);
986 if (data->nodisplay != NULL)
987 app_info->nodisplay = strdup(data->nodisplay);
988 if (data->multiple != NULL)
989 app_info->multiple = strdup(data->multiple);
990 if (data->taskmanage != NULL)
991 app_info->taskmanage = strdup(data->taskmanage);
992 if (data->enabled != NULL)
993 app_info->enabled = strdup(data->enabled);
994 if (data->type != NULL)
995 app_info->type = strdup(data->type);
996 if (data->categories != NULL)
997 app_info->categories = strdup(data->categories);
998 if (data->hwacceleration != NULL)
999 app_info->hwacceleration = strdup(data->hwacceleration);
1000 if (data->screenreader != NULL)
1001 app_info->screenreader = strdup(data->screenreader);
1002 if (data->mainapp != NULL)
1003 app_info->mainapp = strdup(data->mainapp);
1004 if (data->package != NULL)
1005 app_info->package = strdup(data->package);
1006 if (data->recentimage != NULL)
1007 app_info->recentimage = strdup(data->recentimage);
1008 if (data->launchcondition != NULL)
1009 app_info->launchcondition = strdup(data->launchcondition);
1010 if (data->indicatordisplay != NULL)
1011 app_info->indicatordisplay = strdup(data->indicatordisplay);
1012 if (data->portraitimg != NULL)
1013 app_info->portraitimg = strdup(data->portraitimg);
1014 if (data->landscapeimg != NULL)
1015 app_info->landscapeimg = strdup(data->landscapeimg);
1016 if (data->guestmode_visibility != NULL)
1017 app_info->guestmode_visibility = strdup(data->guestmode_visibility);
1018 if (data->component != NULL)
1019 app_info->component = strdup(data->component);
1020 if (data->permission_type != NULL)
1021 app_info->permission_type = strdup(data->permission_type);
1022 if (data->component_type != NULL)
1023 app_info->component_type = strdup(data->component_type);
1024 if (data->preload != NULL)
1025 app_info->preload = strdup(data->preload);
1026 if (data->submode != NULL)
1027 app_info->submode = strdup(data->submode);
1028 if (data->submode_mainid != NULL)
1029 app_info->submode_mainid = strdup(data->submode_mainid);
1030 if (data->process_pool != NULL)
1031 app_info->process_pool = strdup(data->process_pool);
1032 if (data->installed_storage != NULL)
1033 app_info->installed_storage = strdup(data->installed_storage);
1034 if (data->autorestart != NULL)
1035 app_info->autorestart = strdup(data->autorestart);
1036 if (data->onboot != NULL)
1037 app_info->onboot = strdup(data->onboot);
1038 if (data->support_disable != NULL)
1039 app_info->support_disable = strdup(data->support_disable);
1040 if (data->ui_gadget != NULL)
1041 app_info->ui_gadget = strdup(data->ui_gadget);
1042 if (data->launch_mode != NULL)
1043 app_info->launch_mode = strdup(data->launch_mode);
1044 if (data->package_type != NULL)
1045 app_info->package_type = strdup(data->package_type);
1049 app_info->label = g_list_copy_deep(data->label, __copy_label, &ret);
1051 LOGE("memory alloc failed");
1052 pkgmgrinfo_basic_free_application(app_info);
1053 return PMINFO_R_ERROR;
1057 app_info->icon = g_list_copy_deep(data->icon, __copy_icon, &ret);
1059 LOGE("memory alloc failed");
1060 pkgmgrinfo_basic_free_application(app_info);
1061 return PMINFO_R_ERROR;
1065 app_info->category = g_list_copy_deep(data->category, __copy_str, &ret);
1067 LOGE("memory alloc failed");
1068 pkgmgrinfo_basic_free_application(app_info);
1069 return PMINFO_R_ERROR;
1073 app_info->metadata = g_list_copy_deep(data->metadata, __copy_metadata, &ret);
1075 LOGE("memory alloc failed");
1076 pkgmgrinfo_basic_free_application(app_info);
1077 return PMINFO_R_ERROR;
1081 app_info->datacontrol = g_list_copy_deep(data->datacontrol, __copy_datacontrol, &ret);
1083 LOGE("memory alloc failed");
1084 pkgmgrinfo_basic_free_application(app_info);
1085 return PMINFO_R_ERROR;
1089 app_info->appcontrol = g_list_copy_deep(data->appcontrol, __copy_appcontrol, &ret);
1091 LOGE("memory alloc failed");
1092 pkgmgrinfo_basic_free_application(app_info);
1093 return PMINFO_R_ERROR;
1097 app_info->background_category = g_list_copy_deep(data->background_category, __copy_str, &ret);
1099 LOGE("memory alloc failed");
1100 pkgmgrinfo_basic_free_application(app_info);
1101 return PMINFO_R_ERROR;
1105 app_info->splashscreens = g_list_copy_deep(data->splashscreens, __copy_splashscreens, &ret);
1107 LOGE("memory alloc failed");
1108 pkgmgrinfo_basic_free_application(app_info);
1109 return PMINFO_R_ERROR;
1112 *application = app_info;
1117 API int pkgmgrinfo_appinfo_clone_appinfo(pkgmgrinfo_appinfo_h handle,
1118 pkgmgrinfo_appinfo_h *clone)
1120 pkgmgr_appinfo_x *info;
1121 pkgmgr_appinfo_x *temp = (pkgmgr_appinfo_x *)handle;
1124 return PMINFO_R_EINVAL;
1126 info = calloc(1, sizeof(pkgmgr_appinfo_x));
1128 LOGE("memory alloc failed");
1129 return PMINFO_R_ERROR;
1132 if (temp->package != NULL)
1133 info->package = strdup(temp->package);
1134 if (temp->locale != NULL)
1135 info->locale = strdup(temp->locale);
1137 info->app_component = temp->app_component;
1139 if (_appinfo_copy_appinfo(&info->app_info, temp->app_info) < 0) {
1140 LOGE("appinfo copy failed");
1142 free((void *)info->package);
1146 return PMINFO_R_ERROR;
1154 static int _appinfo_get_filtered_foreach_appinfo(uid_t uid,
1155 pkgmgrinfo_filter_x *filter, pkgmgrinfo_app_list_cb app_list_cb,
1159 pkgmgr_appinfo_x *info;
1165 ret = _appinfo_get_filtered_list(filter, uid, &list);
1166 if (ret != PMINFO_R_OK)
1167 return PMINFO_R_ERROR;
1169 for (tmp = list; tmp; tmp = tmp->next) {
1170 appid = (char *)tmp->data;
1172 ret = _appinfo_get_appinfo(appid, uid, &info, false);
1173 if (ret == PMINFO_R_ENOENT && uid != GLOBAL_USER)
1174 ret = _appinfo_get_appinfo(appid, GLOBAL_USER,
1176 if (ret != PMINFO_R_OK) {
1180 if (app_list_cb(info, user_data) < 0)
1182 pkgmgrinfo_appinfo_destroy_appinfo(info);
1192 API int pkgmgrinfo_appinfo_get_usr_list(pkgmgrinfo_pkginfo_h handle,
1193 pkgmgrinfo_app_component component,
1194 pkgmgrinfo_app_list_cb app_func, void *user_data, uid_t uid)
1197 pkgmgrinfo_appinfo_filter_h filter;
1199 const char *comp_str = NULL;
1201 if (handle == NULL || app_func == NULL) {
1202 LOGE("invalid parameter");
1203 return PMINFO_R_EINVAL;
1206 if (pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid)) {
1207 LOGE("invalid parameter");
1208 return PMINFO_R_EINVAL;
1211 if (pkgmgrinfo_appinfo_filter_create(&filter))
1212 return PMINFO_R_ERROR;
1214 if (pkgmgrinfo_appinfo_filter_add_string(filter,
1215 PMINFO_APPINFO_PROP_APP_PACKAGE, pkgid)) {
1216 pkgmgrinfo_appinfo_filter_destroy(filter);
1217 return PMINFO_R_ERROR;
1220 if (uid == GLOBAL_USER) {
1221 if (pkgmgrinfo_appinfo_filter_add_int(filter,
1222 PMINFO_APPINFO_PROP_APP_DISABLE_FOR_USER, (int)getuid())) {
1223 pkgmgrinfo_appinfo_filter_destroy(filter);
1224 return PMINFO_R_ERROR;
1228 switch (component) {
1230 comp_str = PMINFO_APPINFO_UI_APP;
1232 case PMINFO_SVC_APP:
1233 comp_str = PMINFO_APPINFO_SVC_APP;
1240 if (pkgmgrinfo_appinfo_filter_add_string(filter,
1241 PMINFO_APPINFO_PROP_APP_COMPONENT,
1243 pkgmgrinfo_appinfo_filter_destroy(filter);
1244 return PMINFO_R_ERROR;
1248 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter, app_func,
1251 pkgmgrinfo_appinfo_filter_destroy(filter);
1256 API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_component component,
1257 pkgmgrinfo_app_list_cb app_func, void *user_data)
1259 return pkgmgrinfo_appinfo_get_usr_list(handle, component, app_func, user_data, GLOBAL_USER);
1262 API int pkgmgrinfo_appinfo_get_usr_install_list(pkgmgrinfo_app_list_cb app_func, uid_t uid, void *user_data)
1264 if (app_func == NULL) {
1265 LOGE("invalid parameter");
1266 return PMINFO_R_EINVAL;
1269 return _appinfo_get_filtered_foreach_appinfo(uid, NULL, app_func,
1273 API int pkgmgrinfo_appinfo_get_install_list(pkgmgrinfo_app_list_cb app_func, void *user_data)
1275 return pkgmgrinfo_appinfo_get_usr_install_list(app_func, GLOBAL_USER, user_data);
1278 API int pkgmgrinfo_appinfo_get_usr_installed_list(pkgmgrinfo_app_list_cb app_func, uid_t uid, void *user_data)
1280 if (app_func == NULL) {
1281 LOGE("invalid parameter");
1282 return PMINFO_R_EINVAL;
1285 return _appinfo_get_filtered_foreach_appinfo(uid, NULL, app_func,
1289 API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func, void *user_data)
1291 return pkgmgrinfo_appinfo_get_usr_installed_list(app_func, GLOBAL_USER, user_data);
1294 API int pkgmgrinfo_appinfo_get_appid(pkgmgrinfo_appinfo_h handle, char **appid)
1296 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1298 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1299 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1301 if (info->app_info == NULL || info->app_info->appid == NULL)
1302 return PMINFO_R_ERROR;
1303 *appid = (char *)info->app_info->appid;
1308 API int pkgmgrinfo_appinfo_get_pkgname(pkgmgrinfo_appinfo_h handle, char **pkg_name)
1310 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1312 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1313 retvm_if(pkg_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1315 if (info->package == NULL)
1316 return PMINFO_R_ERROR;
1318 *pkg_name = (char *)info->package;
1323 API int pkgmgrinfo_appinfo_get_pkgid(pkgmgrinfo_appinfo_h handle, char **pkgid)
1325 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1327 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1328 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1330 if (info->package == NULL)
1331 return PMINFO_R_ERROR;
1333 *pkgid = (char *)info->package;
1338 API int pkgmgrinfo_appinfo_get_pkgtype(pkgmgrinfo_appinfo_h handle, char **pkgtype)
1340 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1341 retvm_if(pkgtype == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1342 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1344 *pkgtype = (char *)info->app_info->package_type;
1349 API int pkgmgrinfo_appinfo_get_exec(pkgmgrinfo_appinfo_h handle, char **exec)
1351 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1353 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1354 retvm_if(exec == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1356 if (info->app_info == NULL || info->app_info->exec == NULL)
1357 return PMINFO_R_ERROR;
1358 *exec = (char *)info->app_info->exec;
1364 API int pkgmgrinfo_appinfo_get_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1369 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1371 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1372 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1374 locale = info->locale;
1375 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
1377 if (info->app_info == NULL)
1378 return PMINFO_R_ERROR;
1380 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1381 ptr = (icon_x *)tmp->data;
1382 if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL ||
1383 !strcasecmp(ptr->text, "") ||
1384 strcmp(ptr->lang, locale))
1386 *icon = (char *)ptr->text;
1390 locale = DEFAULT_LOCALE;
1391 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1392 ptr = (icon_x *)tmp->data;
1393 if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL ||
1394 strcmp(ptr->lang, locale))
1396 *icon = (char *)ptr->text;
1400 return PMINFO_R_ERROR;
1404 API int pkgmgrinfo_appinfo_get_label(pkgmgrinfo_appinfo_h handle, char **label)
1409 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1411 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1412 retvm_if(label == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1414 locale = info->locale;
1415 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
1417 if (info->app_info == NULL)
1418 return PMINFO_R_ERROR;
1420 for (tmp = info->app_info->label; tmp; tmp = tmp->next) {
1421 ptr = (label_x *)tmp->data;
1422 if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL ||
1423 strcmp(ptr->lang, locale))
1425 *label = (char *)ptr->text;
1429 locale = DEFAULT_LOCALE;
1430 for (tmp = info->app_info->label; tmp; tmp = tmp->next) {
1431 ptr = (label_x *)tmp->data;
1432 if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL ||
1433 strcmp(ptr->lang, locale))
1435 *label = (char *)ptr->text;
1439 return PMINFO_R_ERROR;
1442 static char *_get_localed_label(const char *appid, const char *locale, uid_t uid)
1444 char *result = NULL;
1446 sqlite3_stmt *stmt = NULL;
1449 const char *manifest_db;
1451 manifest_db = getUserPkgParserDBPathUID(uid);
1452 if (manifest_db == NULL) {
1453 _LOGE("Failed to get manifest db path");
1457 if (sqlite3_open_v2(manifest_db, &db, SQLITE_OPEN_READONLY, NULL) != SQLITE_OK) {
1458 _LOGE("DB open fail\n");
1462 query = sqlite3_mprintf("select app_label from package_app_localized_info where app_id=%Q and app_locale=%Q", appid, locale);
1463 if (query == NULL) {
1464 _LOGE("Out of memory");
1468 if (sqlite3_prepare_v2(db, query, -1, &stmt, NULL) != SQLITE_OK) {
1469 _LOGE("prepare_v2 fail\n");
1473 if (sqlite3_step(stmt) == SQLITE_ROW) {
1474 val = (char *)sqlite3_column_text(stmt, 0);
1476 result = strdup(val);
1480 sqlite3_finalize(stmt);
1481 sqlite3_free(query);
1487 API int pkgmgrinfo_appinfo_usr_get_localed_label(const char *appid, const char *locale, uid_t uid, char **label)
1491 retvm_if(appid == NULL || locale == NULL || label == NULL, PMINFO_R_EINVAL, "Argument is NULL");
1493 val = _get_localed_label(appid, locale, uid);
1495 val = _get_localed_label(appid, DEFAULT_LOCALE, uid);
1498 return PMINFO_R_ERROR;
1505 API int pkgmgrinfo_appinfo_get_localed_label(const char *appid, const char *locale, char **label)
1507 return pkgmgrinfo_appinfo_usr_get_localed_label(appid, locale, GLOBAL_USER, label);
1510 static pkgmgrinfo_app_component __appcomponent_convert(const char *comp)
1512 if (strcasecmp(comp, "uiapp") == 0)
1513 return PMINFO_UI_APP;
1514 else if (strcasecmp(comp, "svcapp") == 0)
1515 return PMINFO_SVC_APP;
1516 else if (strcasecmp(comp, "widgetapp") == 0)
1517 return PMINFO_WIDGET_APP;
1522 API int pkgmgrinfo_appinfo_get_component(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_component *component)
1524 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1527 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1528 retvm_if(component == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1530 if (info->app_info == NULL)
1531 return PMINFO_R_ERROR;
1533 comp = __appcomponent_convert(info->app_info->component);
1535 return PMINFO_R_ERROR;
1542 API int pkgmgrinfo_appinfo_get_apptype(pkgmgrinfo_appinfo_h handle, char **app_type)
1544 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1546 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1547 retvm_if(app_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1549 if (info->app_info == NULL || info->app_info->type == NULL)
1550 return PMINFO_R_ERROR;
1551 *app_type = (char *)info->app_info->type;
1556 API int pkgmgrinfo_appinfo_get_operation(pkgmgrinfo_appcontrol_h handle,
1557 int *operation_count, char ***operation)
1559 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1560 retvm_if(operation == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1561 retvm_if(operation_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1562 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1563 *operation_count = data->operation_count;
1564 *operation = data->operation;
1568 API int pkgmgrinfo_appinfo_get_uri(pkgmgrinfo_appcontrol_h handle,
1569 int *uri_count, char ***uri)
1571 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1572 retvm_if(uri == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1573 retvm_if(uri_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1574 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1575 *uri_count = data->uri_count;
1580 API int pkgmgrinfo_appinfo_get_mime(pkgmgrinfo_appcontrol_h handle,
1581 int *mime_count, char ***mime)
1583 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1584 retvm_if(mime == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1585 retvm_if(mime_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1586 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1587 *mime_count = data->mime_count;
1592 API int pkgmgrinfo_appinfo_get_subapp(pkgmgrinfo_appcontrol_h handle,
1593 int *subapp_count, char ***subapp)
1595 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1596 retvm_if(subapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1597 retvm_if(subapp_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1598 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1599 *subapp_count = data->subapp_count;
1600 *subapp = data->subapp;
1604 API int pkgmgrinfo_appinfo_get_setting_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1609 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1611 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1612 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1614 if (info->app_info == NULL)
1615 return PMINFO_R_ERROR;
1617 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1618 ptr = (icon_x *)tmp->data;
1619 if (ptr == NULL || ptr->section == NULL)
1622 val = (char *)ptr->section;
1623 if (val && strcmp(val, "setting") == 0) {
1624 *icon = (char *)ptr->text;
1629 return PMINFO_R_ERROR;
1633 API int pkgmgrinfo_appinfo_get_notification_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1638 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1640 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1641 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1643 if (info->app_info == NULL)
1644 return PMINFO_R_ERROR;
1646 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1647 ptr = (icon_x *)tmp->data;
1648 if (ptr == NULL || ptr->section == NULL)
1651 val = (char *)ptr->section;
1652 if (val && strcmp(val, "notification") == 0){
1653 *icon = (char *)ptr->text;
1658 return PMINFO_R_ERROR;
1661 API int pkgmgrinfo_appinfo_get_recent_image_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_recentimage *type)
1664 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1666 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1667 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1669 if (info->app_info == NULL || info->app_info->recentimage == NULL)
1670 return PMINFO_R_ERROR;
1672 val = (char *)info->app_info->recentimage;
1673 if (strcasecmp(val, "capture") == 0)
1674 *type = PMINFO_RECENTIMAGE_USE_CAPTURE;
1675 else if (strcasecmp(val, "icon") == 0)
1676 *type = PMINFO_RECENTIMAGE_USE_ICON;
1678 *type = PMINFO_RECENTIMAGE_USE_NOTHING;
1683 API int pkgmgrinfo_appinfo_get_preview_image(pkgmgrinfo_appinfo_h handle, char **preview_img)
1688 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1690 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1691 retvm_if(preview_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1693 if (info->app_info == NULL)
1694 return PMINFO_R_ERROR;
1696 for (tmp = info->app_info->image; tmp; tmp = tmp->next) {
1697 ptr = (image_x *)tmp->data;
1698 if (ptr == NULL || ptr->section == NULL)
1701 val = (char *)ptr->section;
1702 if (val && strcmp(val, "preview") == 0) {
1703 *preview_img = (char *)ptr->text;
1708 return PMINFO_R_ERROR;
1711 API int pkgmgrinfo_appinfo_get_permission_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_permission_type *permission)
1714 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1716 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1717 retvm_if(permission == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1719 val = info->app_info->permission_type;
1721 return PMINFO_R_ERROR;
1723 if (strcmp(val, "signature") == 0)
1724 *permission = PMINFO_PERMISSION_SIGNATURE;
1725 else if (strcmp(val, "privilege") == 0)
1726 *permission = PMINFO_PERMISSION_PRIVILEGE;
1728 *permission = PMINFO_PERMISSION_NORMAL;
1733 API int pkgmgrinfo_appinfo_get_component_type(pkgmgrinfo_appinfo_h handle, char **component_type)
1735 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1737 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1738 retvm_if(component_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1740 if (info->app_info == NULL || info->app_info->component_type == NULL)
1741 return PMINFO_R_ERROR;
1743 *component_type = (char *)info->app_info->component_type;
1748 API int pkgmgrinfo_appinfo_get_hwacceleration(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_hwacceleration *hwacceleration)
1751 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1753 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1754 retvm_if(hwacceleration == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1756 if (info->app_info == NULL || info->app_info->hwacceleration == NULL)
1757 return PMINFO_R_ERROR;
1759 val = (char *)info->app_info->hwacceleration;
1760 if (strcasecmp(val, "not-use-GL") == 0)
1761 *hwacceleration = PMINFO_HWACCELERATION_NOT_USE_GL;
1762 else if (strcasecmp(val, "use-GL") == 0)
1763 *hwacceleration = PMINFO_HWACCELERATION_USE_GL;
1765 *hwacceleration = PMINFO_HWACCELERATION_USE_SYSTEM_SETTING;
1770 API int pkgmgrinfo_appinfo_get_screenreader(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_screenreader *screenreader)
1773 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1775 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1776 retvm_if(screenreader == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1778 if (info->app_info == NULL || info->app_info->screenreader == NULL)
1779 return PMINFO_R_ERROR;
1781 val = (char *)info->app_info->screenreader;
1782 if (strcasecmp(val, "screenreader-off") == 0)
1783 *screenreader = PMINFO_SCREENREADER_OFF;
1784 else if (strcasecmp(val, "screenreader-on") == 0)
1785 *screenreader = PMINFO_SCREENREADER_ON;
1787 *screenreader = PMINFO_SCREENREADER_USE_SYSTEM_SETTING;
1792 API int pkgmgrinfo_appinfo_get_effectimage(pkgmgrinfo_appinfo_h handle, char **portrait_img, char **landscape_img)
1794 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1796 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1797 retvm_if(portrait_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1798 retvm_if(landscape_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1800 if (info->app_info == NULL || (info->app_info->portraitimg == NULL
1801 && info->app_info->landscapeimg == NULL))
1802 return PMINFO_R_ERROR;
1804 *portrait_img = (char *)info->app_info->portraitimg;
1805 *landscape_img = (char *)info->app_info->landscapeimg;
1810 API int pkgmgrinfo_appinfo_get_effectimage_type(pkgmgrinfo_appinfo_h handle, char **effectimage_type)
1812 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1814 if (handle == NULL || effectimage_type == NULL) {
1815 LOGE("invalid parameter");
1816 return PMINFO_R_EINVAL;
1819 if (info->app_info == NULL || info->app_info->effectimage_type == NULL)
1820 return PMINFO_R_ERROR;
1822 *effectimage_type = (char *)info->app_info->effectimage_type;
1827 API int pkgmgrinfo_appinfo_get_submode_mainid(pkgmgrinfo_appinfo_h handle, char **submode_mainid)
1829 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1831 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1832 retvm_if(submode_mainid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1834 if (info->app_info == NULL || info->app_info->submode_mainid == NULL)
1835 return PMINFO_R_ERROR;
1837 *submode_mainid = (char *)info->app_info->submode_mainid;
1842 API int pkgmgrinfo_appinfo_get_installed_storage_location(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_installed_storage *storage)
1844 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1845 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1847 if (info->app_info && info->app_info->installed_storage){
1848 if (strcmp(info->app_info->installed_storage,"installed_internal") == 0)
1849 *storage = PMINFO_INTERNAL_STORAGE;
1850 else if (strcmp(info->app_info->installed_storage,"installed_external") == 0)
1851 *storage = PMINFO_EXTERNAL_STORAGE;
1853 return PMINFO_R_ERROR;
1855 return PMINFO_R_ERROR;
1860 API int pkgmgrinfo_appinfo_get_launch_mode(pkgmgrinfo_appinfo_h handle, char **mode)
1862 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1864 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1865 retvm_if(mode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1867 if (info->app_info->launch_mode == NULL)
1868 return PMINFO_R_ERROR;
1870 *mode = (char *)(info->app_info->launch_mode);
1875 API int pkgmgrinfo_appinfo_get_alias_appid(pkgmgrinfo_appinfo_h handle, char **alias_appid)
1877 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1879 if (handle == NULL || alias_appid == NULL) {
1880 LOGE("invalid parameter");
1881 return PMINFO_R_EINVAL;
1884 if (info->app_info == NULL || info->app_info->alias_appid == NULL)
1885 return PMINFO_R_ERROR;
1887 *alias_appid = (char *)info->app_info->alias_appid;
1892 API int pkgmgrinfo_appinfo_get_effective_appid(pkgmgrinfo_appinfo_h handle, char **effective_appid)
1894 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1896 if (handle == NULL || effective_appid == NULL) {
1897 LOGE("invalid parameter");
1898 return PMINFO_R_EINVAL;
1901 if (info->app_info == NULL || info->app_info->effective_appid == NULL)
1902 return PMINFO_R_ERROR;
1904 *effective_appid = (char *)info->app_info->effective_appid;
1909 API int pkgmgrinfo_appinfo_usr_get_datacontrol_info(const char *providerid, const char *type, uid_t uid, char **appid, char **access)
1911 retvm_if(providerid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
1912 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
1913 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1914 retvm_if(access == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1916 int ret = PMINFO_R_OK;
1918 sqlite3_stmt *stmt = NULL;
1921 ret = __open_manifest_db(uid, true);
1922 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
1924 /*Start constructing query*/
1925 query = sqlite3_mprintf("select * from package_app_data_control where providerid=%Q and type=%Q", providerid, type);
1928 ret = sqlite3_prepare_v2(GET_DB(manifest_db), query, strlen(query), &stmt, NULL);
1929 tryvm_if(ret != PMINFO_R_OK, ret = PMINFO_R_ERROR, "sqlite3_prepare_v2 failed[%s]\n", query);
1932 ret = sqlite3_step(stmt);
1933 tryvm_if((ret != SQLITE_ROW) || (ret == SQLITE_DONE), ret = PMINFO_R_ERROR, "No records found");
1935 *appid = strdup((char *)sqlite3_column_text(stmt, 0));
1936 *access = strdup((char *)sqlite3_column_text(stmt, 2));
1941 sqlite3_free(query);
1942 sqlite3_finalize(stmt);
1943 __close_manifest_db();
1947 API int pkgmgrinfo_appinfo_get_datacontrol_info(const char *providerid, const char *type, char **appid, char **access)
1949 return pkgmgrinfo_appinfo_usr_get_datacontrol_info(providerid, type, GLOBAL_USER, appid, access);
1952 API int pkgmgrinfo_appinfo_usr_get_datacontrol_appid(const char *providerid, uid_t uid, char **appid)
1954 retvm_if(providerid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
1955 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1957 int ret = PMINFO_R_OK;
1959 sqlite3_stmt *stmt = NULL;
1962 ret = __open_manifest_db(uid, true);
1963 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
1965 /*Start constructing query*/
1966 query = sqlite3_mprintf("select * from package_app_data_control where providerid=%Q", providerid);
1969 ret = sqlite3_prepare_v2(GET_DB(manifest_db), query, strlen(query), &stmt, NULL);
1970 tryvm_if(ret != PMINFO_R_OK, ret = PMINFO_R_ERROR, "sqlite3_prepare_v2 failed[%s]\n", query);
1973 ret = sqlite3_step(stmt);
1974 tryvm_if((ret != SQLITE_ROW) || (ret == SQLITE_DONE), ret = PMINFO_R_ERROR, "No records found");
1976 *appid = strdup((char *)sqlite3_column_text(stmt, 0));
1981 sqlite3_free(query);
1982 sqlite3_finalize(stmt);
1983 __close_manifest_db();
1987 API int pkgmgrinfo_appinfo_get_datacontrol_appid(const char *providerid, char **appid)
1989 return pkgmgrinfo_appinfo_usr_get_datacontrol_appid(providerid, GLOBAL_USER, appid);
1992 API int pkgmgrinfo_appinfo_foreach_permission(pkgmgrinfo_appinfo_h handle,
1993 pkgmgrinfo_app_permission_list_cb permission_func, void *user_data)
1995 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1996 retvm_if(permission_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2000 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2002 if (info->app_info == NULL)
2003 return PMINFO_R_ERROR;
2005 for (tmp = info->app_info->permission; tmp; tmp = tmp->next) {
2006 ptr = (permission_x *)tmp->data;
2010 ret = permission_func(ptr->value, user_data);
2018 API int pkgmgrinfo_appinfo_foreach_category(pkgmgrinfo_appinfo_h handle,
2019 pkgmgrinfo_app_category_list_cb category_func, void *user_data)
2021 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2022 retvm_if(category_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2024 const char *category;
2026 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2028 if (info->app_info == NULL)
2029 return PMINFO_R_ERROR;
2031 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
2032 category = (const char *)tmp->data;
2034 ret = category_func(category, user_data);
2042 API int pkgmgrinfo_appinfo_foreach_metadata(pkgmgrinfo_appinfo_h handle,
2043 pkgmgrinfo_app_metadata_list_cb metadata_func, void *user_data)
2045 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2046 retvm_if(metadata_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2050 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2052 if (info->app_info == NULL)
2053 return PMINFO_R_ERROR;
2055 for (tmp = info->app_info->metadata; tmp; tmp = tmp->next) {
2056 ptr = (metadata_x *)tmp->data;
2060 ret = metadata_func(ptr->key, ptr->value, user_data);
2068 API int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
2069 pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
2071 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2072 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2074 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2075 appcontrol_x *appcontrol;
2078 if (info->app_info == NULL)
2079 return PMINFO_R_ERROR;
2081 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
2082 appcontrol = (appcontrol_x *)tmp->data;
2083 if (appcontrol == NULL)
2085 ret = appcontrol_func(appcontrol->operation, appcontrol->uri, appcontrol->mime, user_data);
2093 API int pkgmgrinfo_appinfo_foreach_background_category(
2094 pkgmgrinfo_appinfo_h handle,
2095 pkgmgrinfo_app_background_category_list_cb category_func,
2098 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2102 if (handle == NULL || category_func == NULL || info->app_info == NULL) {
2103 LOGE("invalid parameter");
2104 return PMINFO_R_EINVAL;
2107 for (tmp = info->app_info->background_category; tmp; tmp = tmp->next) {
2108 category = (char *)tmp->data;
2109 if (category == NULL)
2112 if (category_func(category, user_data) < 0)
2119 API int pkgmgrinfo_appinfo_foreach_splash_screen(pkgmgrinfo_appinfo_h handle,
2120 pkgmgrinfo_app_splash_screen_list_cb splash_screen_func,
2123 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2124 splashscreen_x *splashscreen;
2128 if (info == NULL || info->app_info == NULL
2129 || splash_screen_func == NULL) {
2130 LOGE("invalid parameter");
2131 return PMINFO_R_EINVAL;
2134 for (tmp = info->app_info->splashscreens; tmp; tmp = tmp->next) {
2135 splashscreen = (splashscreen_x *)tmp->data;
2136 if (splashscreen == NULL)
2138 ret = splash_screen_func(splashscreen->src,
2140 splashscreen->orientation,
2141 splashscreen->indicatordisplay,
2142 splashscreen->operation,
2151 API int pkgmgrinfo_appinfo_is_nodisplay(pkgmgrinfo_appinfo_h handle, bool *nodisplay)
2153 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2154 retvm_if(nodisplay == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2155 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2157 if (info->app_info == NULL || info->app_info->nodisplay == NULL)
2158 return PMINFO_R_ERROR;
2160 *nodisplay = _get_bool_value(info->app_info->nodisplay);
2165 API int pkgmgrinfo_appinfo_is_multiple(pkgmgrinfo_appinfo_h handle, bool *multiple)
2167 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2168 retvm_if(multiple == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2169 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2171 if (info->app_info == NULL || info->app_info->multiple == NULL)
2172 return PMINFO_R_ERROR;
2174 *multiple = _get_bool_value(info->app_info->multiple);
2179 API int pkgmgrinfo_appinfo_is_indicator_display_allowed(pkgmgrinfo_appinfo_h handle, bool *indicator_disp)
2181 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2182 retvm_if(indicator_disp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2183 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2185 if (info->app_info == NULL || info->app_info->indicatordisplay == NULL)
2186 return PMINFO_R_ERROR;
2188 *indicator_disp = _get_bool_value(info->app_info->indicatordisplay);
2193 API int pkgmgrinfo_appinfo_is_taskmanage(pkgmgrinfo_appinfo_h handle, bool *taskmanage)
2195 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2196 retvm_if(taskmanage == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2197 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2199 if (info->app_info == NULL || info->app_info->taskmanage == NULL)
2200 return PMINFO_R_ERROR;
2202 *taskmanage = _get_bool_value(info->app_info->taskmanage);
2207 API int pkgmgrinfo_appinfo_is_enabled(pkgmgrinfo_appinfo_h handle, bool *enabled)
2209 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2210 retvm_if(enabled == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2211 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2213 if (info->app_info == NULL || info->app_info->enabled == NULL)
2214 return PMINFO_R_ERROR;
2216 *enabled = _get_bool_value(info->app_info->enabled);
2221 API int pkgmgrinfo_appinfo_is_onboot(pkgmgrinfo_appinfo_h handle, bool *onboot)
2223 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2224 retvm_if(onboot == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2225 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2227 if (info->app_info == NULL || info->app_info->onboot == NULL)
2228 return PMINFO_R_ERROR;
2230 *onboot = _get_bool_value(info->app_info->onboot);
2235 API int pkgmgrinfo_appinfo_is_autorestart(pkgmgrinfo_appinfo_h handle, bool *autorestart)
2237 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2238 retvm_if(autorestart == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2239 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2241 if (info->app_info == NULL || info->app_info->autorestart == NULL)
2242 return PMINFO_R_ERROR;
2244 *autorestart = _get_bool_value(info->app_info->autorestart);
2249 API int pkgmgrinfo_appinfo_is_mainapp(pkgmgrinfo_appinfo_h handle, bool *mainapp)
2251 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2252 retvm_if(mainapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2253 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2255 if (info->app_info == NULL || info->app_info->mainapp == NULL)
2256 return PMINFO_R_ERROR;
2258 *mainapp = _get_bool_value(info->app_info->mainapp);
2263 API int pkgmgrinfo_appinfo_is_preload(pkgmgrinfo_appinfo_h handle, bool *preload)
2265 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2266 retvm_if(preload == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2267 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2269 if (info->app_info == NULL || info->app_info->preload == NULL)
2270 return PMINFO_R_ERROR;
2272 *preload = _get_bool_value(info->app_info->preload);
2277 API int pkgmgrinfo_appinfo_is_submode(pkgmgrinfo_appinfo_h handle, bool *submode)
2279 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2280 retvm_if(submode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2281 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2283 if (info->app_info == NULL || info->app_info->submode == NULL)
2284 return PMINFO_R_ERROR;
2286 *submode = _get_bool_value(info->app_info->submode);
2291 API int pkgmgrinfo_appinfo_is_process_pool(pkgmgrinfo_appinfo_h handle, bool *process_pool)
2293 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2295 if (handle == NULL || process_pool == NULL) {
2296 LOGE("invalid parameter");
2297 return PMINFO_R_EINVAL;
2300 if (info->app_info == NULL)
2301 return PMINFO_R_ERROR;
2303 *process_pool = _get_bool_value(info->app_info->process_pool);
2308 API int pkgmgrinfo_appinfo_is_category_exist(pkgmgrinfo_appinfo_h handle, const char *category, bool *exist)
2310 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2311 retvm_if(category == NULL, PMINFO_R_EINVAL, "category is NULL");
2312 retvm_if(exist == NULL, PMINFO_R_EINVAL, "exist is NULL");
2316 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2318 if (info->app_info == NULL)
2319 return PMINFO_R_ERROR;
2322 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
2323 val = (const char *)tmp->data;
2326 if (strcasecmp(val, category) == 0) {
2335 API int pkgmgrinfo_appinfo_is_ui_gadget(pkgmgrinfo_appinfo_h handle,
2338 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2340 if (info == NULL || info->app_info == NULL || ui_gadget == NULL) {
2341 _LOGE("invalid parameter");
2342 return PMINFO_R_EINVAL;
2345 *ui_gadget = _get_bool_value(info->app_info->ui_gadget);
2350 API int pkgmgrinfo_appinfo_is_support_disable(pkgmgrinfo_appinfo_h handle,
2351 bool *support_disable)
2353 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2355 if (info == NULL || info->app_info == NULL || support_disable == NULL) {
2356 _LOGE("invalid parameter");
2357 return PMINFO_R_EINVAL;
2360 *support_disable = _get_bool_value(info->app_info->support_disable);
2365 API int pkgmgrinfo_appinfo_destroy_appinfo(pkgmgrinfo_appinfo_h handle)
2367 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2368 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2369 __cleanup_appinfo(info);
2373 API int pkgmgrinfo_appinfo_filter_create(pkgmgrinfo_appinfo_filter_h *handle)
2375 return (pkgmgrinfo_pkginfo_filter_create(handle));
2378 API int pkgmgrinfo_appinfo_filter_destroy(pkgmgrinfo_appinfo_filter_h handle)
2380 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
2383 static gint __compare_func(gconstpointer data1, gconstpointer data2)
2385 pkgmgrinfo_node_x *node1 = (pkgmgrinfo_node_x*)data1;
2386 pkgmgrinfo_node_x *node2 = (pkgmgrinfo_node_x*)data2;
2387 if (node1->prop == node2->prop)
2389 else if (node1->prop > node2->prop)
2395 API int pkgmgrinfo_appinfo_filter_add_int(pkgmgrinfo_appinfo_filter_h handle,
2396 const char *property, const int value)
2398 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2399 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2400 char buf[PKG_VALUE_STRING_LEN_MAX] = {'\0'};
2402 GSList *link = NULL;
2404 prop = _pminfo_appinfo_convert_to_prop_int(property);
2405 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_INT ||
2406 prop > E_PMINFO_APPINFO_PROP_APP_MAX_INT) {
2407 _LOGE("Invalid Integer Property\n");
2408 return PMINFO_R_EINVAL;
2410 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
2411 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
2413 _LOGE("Out of Memory!!!\n");
2414 return PMINFO_R_ERROR;
2416 snprintf(buf, PKG_VALUE_STRING_LEN_MAX - 1, "%d", value);
2417 val = strndup(buf, PKG_VALUE_STRING_LEN_MAX - 1);
2419 _LOGE("Out of Memory\n");
2422 return PMINFO_R_ERROR;
2426 /*If API is called multiple times for same property, we should override the previous values.
2427 Last value set will be used for filtering.*/
2428 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2430 filter->list = g_slist_delete_link(filter->list, link);
2431 filter->list = g_slist_append(filter->list, (gpointer)node);
2436 API int pkgmgrinfo_appinfo_filter_add_bool(pkgmgrinfo_appinfo_filter_h handle,
2437 const char *property, const bool value)
2439 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2440 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2442 GSList *link = NULL;
2444 prop = _pminfo_appinfo_convert_to_prop_bool(property);
2445 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_BOOL ||
2446 prop > E_PMINFO_APPINFO_PROP_APP_MAX_BOOL) {
2447 _LOGE("Invalid Boolean Property\n");
2448 return PMINFO_R_EINVAL;
2450 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
2451 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
2453 _LOGE("Out of Memory!!!\n");
2454 return PMINFO_R_ERROR;
2457 val = strndup("('true','True')", 15);
2459 val = strndup("('false','False')", 17);
2461 _LOGE("Out of Memory\n");
2464 return PMINFO_R_ERROR;
2468 /*If API is called multiple times for same property, we should override the previous values.
2469 Last value set will be used for filtering.*/
2470 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2472 filter->list = g_slist_delete_link(filter->list, link);
2473 filter->list = g_slist_append(filter->list, (gpointer)node);
2478 API int pkgmgrinfo_appinfo_filter_add_string(pkgmgrinfo_appinfo_filter_h handle,
2479 const char *property, const char *value)
2481 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2482 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2483 retvm_if(value == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2485 pkgmgrinfo_node_x *ptr = NULL;
2486 char prev[PKG_STRING_LEN_MAX] = {'\0'};
2487 char temp[PKG_STRING_LEN_MAX] = {'\0'};
2488 GSList *link = NULL;
2490 prop = _pminfo_appinfo_convert_to_prop_str(property);
2491 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_STR ||
2492 prop > E_PMINFO_APPINFO_PROP_APP_MAX_STR) {
2493 _LOGE("Invalid String Property\n");
2494 return PMINFO_R_EINVAL;
2496 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
2497 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
2499 _LOGE("Out of Memory!!!\n");
2500 return PMINFO_R_ERROR;
2504 case E_PMINFO_APPINFO_PROP_APP_COMPONENT:
2505 if (strcmp(value, PMINFO_APPINFO_UI_APP) == 0)
2506 val = strndup("uiapp", PKG_STRING_LEN_MAX - 1);
2508 val = strndup("svcapp", PKG_STRING_LEN_MAX - 1);
2510 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2512 filter->list = g_slist_delete_link(filter->list, link);
2513 filter->list = g_slist_append(filter->list, (gpointer)node);
2515 case E_PMINFO_APPINFO_PROP_APP_CATEGORY:
2516 case E_PMINFO_APPINFO_PROP_APP_OPERATION:
2517 case E_PMINFO_APPINFO_PROP_APP_URI:
2518 case E_PMINFO_APPINFO_PROP_APP_MIME:
2519 val = (char *)calloc(1, PKG_STRING_LEN_MAX);
2521 _LOGE("Out of Memory\n");
2524 return PMINFO_R_ERROR;
2526 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2528 ptr = (pkgmgrinfo_node_x *)link->data;
2529 strncpy(prev, ptr->value, PKG_STRING_LEN_MAX - 1);
2530 _LOGE("Previous value is %s\n", prev);
2531 filter->list = g_slist_delete_link(filter->list, link);
2532 snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s , '%s'", prev, value);
2533 strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
2534 _LOGE("New value is %s\n", val);
2536 filter->list = g_slist_append(filter->list, (gpointer)node);
2537 memset(temp, '\0', PKG_STRING_LEN_MAX);
2539 snprintf(temp, PKG_STRING_LEN_MAX - 1, "'%s'", value);
2540 strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
2541 _LOGE("First value is %s\n", val);
2543 filter->list = g_slist_append(filter->list, (gpointer)node);
2544 memset(temp, '\0', PKG_STRING_LEN_MAX);
2548 node->value = strndup(value, PKG_STRING_LEN_MAX - 1);
2549 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2551 filter->list = g_slist_delete_link(filter->list, link);
2552 filter->list = g_slist_append(filter->list, (gpointer)node);
2558 API int pkgmgrinfo_appinfo_usr_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count, uid_t uid)
2563 if (handle == NULL || count == NULL) {
2564 _LOGE("invalid parameter");
2565 return PMINFO_R_EINVAL;
2568 ret = _appinfo_get_filtered_list(handle, uid, &list);
2569 if (ret != PMINFO_R_OK)
2570 return PMINFO_R_ERROR;
2572 *count = g_list_length(list);
2574 g_list_free_full(list, free);
2579 API int pkgmgrinfo_appinfo_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count)
2581 return pkgmgrinfo_appinfo_usr_filter_count(handle, count, GLOBAL_USER);
2584 API int pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(
2585 pkgmgrinfo_appinfo_filter_h handle,
2586 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
2588 if (handle == NULL || app_cb == NULL) {
2589 LOGE("invalid parameter");
2590 return PMINFO_R_EINVAL;
2593 return _appinfo_get_filtered_foreach_appinfo(uid, handle, app_cb,
2597 API int pkgmgrinfo_appinfo_filter_foreach_appinfo(pkgmgrinfo_appinfo_filter_h handle,
2598 pkgmgrinfo_app_list_cb app_cb, void * user_data)
2600 return pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(handle, app_cb, user_data, GLOBAL_USER);
2603 API int pkgmgrinfo_appinfo_metadata_filter_create(pkgmgrinfo_appinfo_metadata_filter_h *handle)
2605 return (pkgmgrinfo_pkginfo_filter_create(handle));
2608 API int pkgmgrinfo_appinfo_metadata_filter_destroy(pkgmgrinfo_appinfo_metadata_filter_h handle)
2610 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
2613 API int pkgmgrinfo_appinfo_metadata_filter_add(
2614 pkgmgrinfo_appinfo_metadata_filter_h handle,
2615 const char *key, const char *value)
2619 ret = pkgmgrinfo_appinfo_filter_add_string(handle,
2620 PMINFO_APPINFO_PROP_APP_METADATA_KEY, key);
2621 if (ret != PMINFO_R_OK)
2624 /* value can be NULL.
2625 * In that case all apps with specified key should be displayed
2628 ret = pkgmgrinfo_appinfo_filter_add_string(handle,
2629 PMINFO_APPINFO_PROP_APP_METADATA_VALUE, value);
2630 if (ret != PMINFO_R_OK)
2637 API int pkgmgrinfo_appinfo_usr_metadata_filter_foreach(
2638 pkgmgrinfo_appinfo_metadata_filter_h handle,
2639 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
2641 if (handle == NULL || app_cb == NULL) {
2642 LOGE("invalid parameter");
2643 return PMINFO_R_EINVAL;
2646 return _appinfo_get_filtered_foreach_appinfo(uid, handle, app_cb,
2650 API int pkgmgrinfo_appinfo_metadata_filter_foreach(
2651 pkgmgrinfo_appinfo_metadata_filter_h handle,
2652 pkgmgrinfo_app_list_cb app_cb, void *user_data)
2654 return pkgmgrinfo_appinfo_usr_metadata_filter_foreach(handle, app_cb,
2655 user_data, GLOBAL_USER);
2658 API int pkgmgrinfo_appinfo_is_guestmode_visibility(pkgmgrinfo_appinfo_h handle, bool *status)
2661 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2663 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2664 retvm_if(status == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2666 val = info->app_info->guestmode_visibility;
2667 *status = _get_bool_value(val);