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 void _appinfo_modify_icon(const char *appid, const char **icon)
255 char buf[PKG_VALUE_STRING_LEN_MAX];
258 if (*icon == NULL || (*icon)[0] == '/' || !strcasecmp(*icon, ""))
262 snprintf(buf, sizeof(buf), "%s%s.png", getIconPath(getuid()), appid);
267 static int _appinfo_get_icon(sqlite3 *db, const char *appid, const char *locale,
270 static const char query_raw[] =
271 "SELECT app_icon, app_locale "
272 "FROM package_app_localized_info "
273 "WHERE app_id=%Q AND app_locale IN (%Q, %Q)";
280 query = sqlite3_mprintf(query_raw, appid, locale, DEFAULT_LOCALE);
282 LOGE("out of memory");
283 return PMINFO_R_ERROR;
286 ret = sqlite3_prepare_v2(db, query, strlen(query),
289 if (ret != SQLITE_OK) {
290 LOGE("prepare failed: %s", sqlite3_errmsg(db));
291 return PMINFO_R_ERROR;
294 while (sqlite3_step(stmt) == SQLITE_ROW) {
295 info = calloc(1, sizeof(icon_x));
297 LOGE("out of memory");
298 sqlite3_finalize(stmt);
299 return PMINFO_R_ERROR;
302 _save_column_str(stmt, idx++, &info->text);
303 /* FIXME: this is a workaround. this must be removed later */
304 _appinfo_modify_icon(appid, &info->text);
305 _save_column_str(stmt, idx++, &info->lang);
306 *icon = g_list_append(*icon, info);
309 sqlite3_finalize(stmt);
314 static int _appinfo_get_category(sqlite3 *db, const char *appid,
317 static const char query_raw[] =
318 "SELECT category FROM package_app_app_category WHERE app_id=%Q";
324 query = sqlite3_mprintf(query_raw, appid);
326 LOGE("out of memory");
327 return PMINFO_R_ERROR;
330 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
332 if (ret != SQLITE_OK) {
333 LOGE("prepare failed: %s", sqlite3_errmsg(db));
334 return PMINFO_R_ERROR;
337 while (sqlite3_step(stmt) == SQLITE_ROW) {
339 _save_column_str(stmt, 0, &val);
341 *category = g_list_append(*category, (gpointer)val);
344 sqlite3_finalize(stmt);
349 static void __parse_appcontrol(GList **appcontrol, char *appcontrol_str)
356 if (appcontrol_str == NULL)
359 dup = strdup(appcontrol_str);
361 ac = calloc(1, sizeof(appcontrol_x));
363 _LOGE("out of memory");
366 token = strtok_r(dup, "|", &ptr);
367 if (token && strcmp(token, "NULL"))
368 ac->operation = strdup(token);
369 token = strtok_r(NULL, "|", &ptr);
370 if (token && strcmp(token, "NULL"))
371 ac->uri = strdup(token);
372 token = strtok_r(NULL, "|", &ptr);
373 if (token && strcmp(token, "NULL"))
374 ac->mime = strdup(token);
375 *appcontrol = g_list_append(*appcontrol, ac);
376 } while ((token = strtok_r(NULL, ";", &ptr)));
381 static int _appinfo_get_app_control(sqlite3 *db, const char *appid,
384 static const char query_raw[] =
385 "SELECT app_control FROM package_app_app_control "
392 query = sqlite3_mprintf(query_raw, appid);
394 LOGE("out of memory");
395 return PMINFO_R_ERROR;
398 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
400 if (ret != SQLITE_OK) {
401 LOGE("prepare failed: %s", sqlite3_errmsg(db));
402 return PMINFO_R_ERROR;
405 while (sqlite3_step(stmt) == SQLITE_ROW) {
407 _save_column_str(stmt, 0, (const char **)&str);
409 __parse_appcontrol(appcontrol, str);
413 sqlite3_finalize(stmt);
418 static int _appinfo_get_data_control(sqlite3 *db, const char *appid,
421 static const char query_raw[] =
422 "SELECT providerid, access, type "
423 "FROM package_app_data_control WHERE app_id=%Q";
430 query = sqlite3_mprintf(query_raw, appid);
432 LOGE("out of memory");
433 return PMINFO_R_ERROR;
436 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
438 if (ret != SQLITE_OK) {
439 LOGE("prepare failed: %s", sqlite3_errmsg(db));
440 return PMINFO_R_ERROR;
443 while (sqlite3_step(stmt) == SQLITE_ROW) {
444 info = calloc(1, sizeof(datacontrol_x));
446 LOGE("out of memory");
447 sqlite3_finalize(stmt);
448 return PMINFO_R_ERROR;
451 _save_column_str(stmt, idx++, &info->providerid);
452 _save_column_str(stmt, idx++, &info->access);
453 _save_column_str(stmt, idx++, &info->type);
454 *datacontrol = g_list_append(*datacontrol, info);
457 sqlite3_finalize(stmt);
462 static int _appinfo_get_metadata(sqlite3 *db, const char *appid,
465 static const char query_raw[] =
466 "SELECT md_key, md_value "
467 "FROM package_app_app_metadata WHERE app_id=%Q";
474 query = sqlite3_mprintf(query_raw, appid);
476 LOGE("out of memory");
477 return PMINFO_R_ERROR;
480 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
482 if (ret != SQLITE_OK) {
483 LOGE("prepare failed: %s", sqlite3_errmsg(db));
484 return PMINFO_R_ERROR;
487 while (sqlite3_step(stmt) == SQLITE_ROW) {
488 info = calloc(1, sizeof(metadata_x));
490 LOGE("out of memory");
491 sqlite3_finalize(stmt);
492 return PMINFO_R_ERROR;
495 _save_column_str(stmt, idx++, &info->key);
496 _save_column_str(stmt, idx++, &info->value);
497 *metadata = g_list_append(*metadata, info);
500 sqlite3_finalize(stmt);
506 static int _appinfo_get_splashscreens(sqlite3 *db, const char *appid,
507 GList **splashscreens)
509 static const char query_raw[] =
510 "SELECT src, type, orientation, indicatordisplay "
511 "FROM package_app_splash_screen WHERE app_id=%Q";
516 splashscreen_x *info;
518 query = sqlite3_mprintf(query_raw, appid);
520 LOGE("out of memory");
521 return PMINFO_R_ERROR;
524 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
526 if (ret != SQLITE_OK) {
527 LOGE("prepare failed: %s", sqlite3_errmsg(db));
528 return PMINFO_R_ERROR;
531 while (sqlite3_step(stmt) == SQLITE_ROW) {
532 info = calloc(1, sizeof(splashscreen_x));
534 LOGE("out of memory");
535 sqlite3_finalize(stmt);
536 return PMINFO_R_ERROR;
539 _save_column_str(stmt, idx++, &info->src);
540 _save_column_str(stmt, idx++, &info->type);
541 _save_column_str(stmt, idx++, &info->orientation);
542 _save_column_str(stmt, idx++, &info->indicatordisplay);
543 *splashscreens = g_list_append(*splashscreens, info);
546 sqlite3_finalize(stmt);
551 static GList *__get_background_category(char *value)
553 GList *category_list = NULL;
554 int convert_value = 0;
555 if (!value || strlen(value) == 0)
558 convert_value = atoi(value);
559 if (convert_value < 0)
562 if (convert_value & APP_BG_CATEGORY_USER_DISABLE_TRUE_VAL)
563 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_USER_DISABLE_TRUE_STR));
565 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_USER_DISABLE_FALSE_STR));
567 if (convert_value & APP_BG_CATEGORY_MEDIA_VAL)
568 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_MEDIA_STR));
570 if (convert_value & APP_BG_CATEGORY_DOWNLOAD_VAL)
571 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_DOWNLOAD_STR));
573 if (convert_value & APP_BG_CATEGORY_BGNETWORK_VAL)
574 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_BGNETWORK_STR));
576 if (convert_value & APP_BG_CATEGORY_LOCATION_VAL)
577 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_LOCATION_STR));
579 if (convert_value & APP_BG_CATEGORY_SENSOR_VAL)
580 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_SENSOR_STR));
582 if (convert_value & APP_BG_CATEGORY_IOTCOMM_VAL)
583 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_IOTCOMM_STR));
585 if (convert_value & APP_BG_CATEGORY_SYSTEM_VAL)
586 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_SYSTEM));
588 return category_list;
592 static int _appinfo_get_application(sqlite3 *db, const char *appid,
593 const char *locale, application_x **application)
595 static const char query_raw[] =
596 "SELECT app_id, app_component, app_exec, app_nodisplay, "
597 "app_type, app_onboot, app_multiple, app_autorestart, "
598 "app_taskmanage, app_enabled, app_hwacceleration, "
599 "app_screenreader, app_mainapp, app_recentimage, "
600 "app_launchcondition, app_indicatordisplay, app_portraitimg, "
601 "app_landscapeimg, app_guestmodevisibility, "
602 "app_permissiontype, app_preload, app_submode, "
603 "app_submode_mainid, app_launch_mode, app_ui_gadget, "
604 "app_support_disable, "
605 "component_type, package, app_process_pool, app_installed_storage, "
606 "app_background_category, app_package_type "
607 "FROM package_app_info WHERE app_id='%s' "
609 "(SELECT app_id from package_app_disable_for_user WHERE uid='%d')";
611 char query[MAX_QUERY_LEN] = { '\0' };
615 char *bg_category_str = NULL;
616 snprintf(query, MAX_QUERY_LEN - 1, query_raw, appid, (int)getuid());
617 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
618 if (ret != SQLITE_OK) {
619 LOGE("prepare failed: %s", sqlite3_errmsg(db));
620 return PMINFO_R_ERROR;
623 ret = sqlite3_step(stmt);
624 if (ret == SQLITE_DONE) {
625 sqlite3_finalize(stmt);
626 return PMINFO_R_ENOENT;
627 } else if (ret != SQLITE_ROW) {
628 LOGE("step failed: %s", sqlite3_errmsg(db));
629 sqlite3_finalize(stmt);
630 return PMINFO_R_ERROR;
633 info = calloc(1, sizeof(application_x));
635 LOGE("out of memory");
636 sqlite3_finalize(stmt);
637 return PMINFO_R_ERROR;
640 _save_column_str(stmt, idx++, &info->appid);
641 _save_column_str(stmt, idx++, &info->component);
642 _save_column_str(stmt, idx++, &info->exec);
643 _save_column_str(stmt, idx++, &info->nodisplay);
644 _save_column_str(stmt, idx++, &info->type);
645 _save_column_str(stmt, idx++, &info->onboot);
646 _save_column_str(stmt, idx++, &info->multiple);
647 _save_column_str(stmt, idx++, &info->autorestart);
648 _save_column_str(stmt, idx++, &info->taskmanage);
649 _save_column_str(stmt, idx++, &info->enabled);
650 _save_column_str(stmt, idx++, &info->hwacceleration);
651 _save_column_str(stmt, idx++, &info->screenreader);
652 _save_column_str(stmt, idx++, &info->mainapp);
653 _save_column_str(stmt, idx++, &info->recentimage);
654 _save_column_str(stmt, idx++, &info->launchcondition);
655 _save_column_str(stmt, idx++, &info->indicatordisplay);
656 _save_column_str(stmt, idx++, &info->portraitimg);
657 _save_column_str(stmt, idx++, &info->landscapeimg);
658 _save_column_str(stmt, idx++, &info->guestmode_visibility);
659 _save_column_str(stmt, idx++, &info->permission_type);
660 _save_column_str(stmt, idx++, &info->preload);
661 _save_column_str(stmt, idx++, &info->submode);
662 _save_column_str(stmt, idx++, &info->submode_mainid);
663 _save_column_str(stmt, idx++, &info->launch_mode);
664 _save_column_str(stmt, idx++, &info->ui_gadget);
665 _save_column_str(stmt, idx++, &info->support_disable);
666 _save_column_str(stmt, idx++, &info->component_type);
667 _save_column_str(stmt, idx++, &info->package);
668 _save_column_str(stmt, idx++, &info->process_pool);
669 _save_column_str(stmt, idx++, &info->installed_storage);
670 _save_column_str(stmt, idx++, &bg_category_str);
671 _save_column_str(stmt, idx++, &info->package_type);
673 info->background_category = __get_background_category(bg_category_str);
675 if (_appinfo_get_label(db, info->appid, locale, &info->label)) {
676 pkgmgrinfo_basic_free_application(info);
677 sqlite3_finalize(stmt);
678 return PMINFO_R_ERROR;
681 if (_appinfo_get_icon(db, info->appid, locale, &info->icon)) {
682 pkgmgrinfo_basic_free_application(info);
683 sqlite3_finalize(stmt);
684 return PMINFO_R_ERROR;
687 if (_appinfo_get_category(db, info->appid, &info->category)) {
688 pkgmgrinfo_basic_free_application(info);
689 sqlite3_finalize(stmt);
690 return PMINFO_R_ERROR;
693 if (_appinfo_get_app_control(db, info->appid, &info->appcontrol)) {
694 pkgmgrinfo_basic_free_application(info);
695 sqlite3_finalize(stmt);
696 return PMINFO_R_ERROR;
699 if (_appinfo_get_data_control(db, info->appid, &info->datacontrol)) {
700 pkgmgrinfo_basic_free_application(info);
701 sqlite3_finalize(stmt);
702 return PMINFO_R_ERROR;
705 if (_appinfo_get_metadata(db, info->appid, &info->metadata)) {
706 pkgmgrinfo_basic_free_application(info);
707 sqlite3_finalize(stmt);
708 return PMINFO_R_ERROR;
711 if (_appinfo_get_splashscreens(db, info->appid, &info->splashscreens)) {
712 pkgmgrinfo_basic_free_application(info);
713 sqlite3_finalize(stmt);
714 return PMINFO_R_ERROR;
719 sqlite3_finalize(stmt);
724 static int _appinfo_get_appinfo(const char *appid, uid_t uid,
725 pkgmgr_appinfo_x **appinfo)
731 pkgmgr_appinfo_x *info;
733 dbpath = getUserPkgParserDBPathUID(uid);
735 return PMINFO_R_ERROR;
737 locale = _get_system_locale();
739 return PMINFO_R_ERROR;
741 ret = sqlite3_open_v2(dbpath, &db, SQLITE_OPEN_READONLY, NULL);
742 if (ret != SQLITE_OK) {
743 _LOGE("failed to open db: %d", ret);
745 return PMINFO_R_ERROR;
748 info = calloc(1, sizeof(pkgmgr_appinfo_x));
750 _LOGE("out of memory");
752 sqlite3_close_v2(db);
753 return PMINFO_R_ERROR;
756 ret = _appinfo_get_application(db, appid, locale, &info->app_info);
757 if (ret != PMINFO_R_OK) {
760 sqlite3_close_v2(db);
764 info->locale = locale;
765 info->package = strdup(info->app_info->package);
769 sqlite3_close_v2(db);
774 API int pkgmgrinfo_appinfo_get_usr_appinfo(const char *appid, uid_t uid,
775 pkgmgrinfo_appinfo_h *handle)
779 if (appid == NULL || handle == NULL) {
780 LOGE("invalid parameter");
781 return PMINFO_R_EINVAL;
784 ret = _appinfo_get_appinfo(appid, uid, (pkgmgr_appinfo_x **)handle);
785 if (ret == PMINFO_R_ENOENT && uid != GLOBAL_USER)
786 ret = _appinfo_get_appinfo(appid, GLOBAL_USER,
787 (pkgmgr_appinfo_x **)handle);
789 if (ret != PMINFO_R_OK)
790 _LOGE("failed to get appinfo of %s for user %d", appid, uid);
795 API int pkgmgrinfo_appinfo_get_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
797 return pkgmgrinfo_appinfo_get_usr_appinfo(appid, GLOBAL_USER, handle);
800 static gpointer __copy_str(gconstpointer src, gpointer data)
802 const char *tmp = (const char *)src;
805 buffer = strdup(tmp);
806 if (buffer == NULL) {
807 LOGE("memory alloc failed");
815 static gpointer __copy_label(gconstpointer src, gpointer data)
817 label_x *tmp = (label_x *)src;
820 label = calloc(1, sizeof(label_x));
822 LOGE("memory alloc failed");
828 label->name = strdup(tmp->name);
830 label->text = strdup(tmp->text);
832 label->lang = strdup(tmp->lang);
837 static gpointer __copy_icon(gconstpointer src, gpointer data)
839 icon_x *tmp = (icon_x *)src;
842 icon = calloc(1, sizeof(icon_x));
844 LOGE("memory alloc failed");
850 icon->text = strdup(tmp->text);
852 icon->lang = strdup(tmp->lang);
854 icon->section = strdup(tmp->section);
856 icon->size = strdup(tmp->size);
858 icon->resolution = strdup(tmp->resolution);
863 static gpointer __copy_metadata(gconstpointer src, gpointer data)
865 metadata_x *tmp = (metadata_x *)src;
866 metadata_x *metadata;
868 metadata = calloc(1, sizeof(metadata_x));
869 if (metadata == NULL) {
870 LOGE("memory alloc failed");
876 metadata->key = strdup(tmp->key);
878 metadata->value = strdup(tmp->value);
883 static gpointer __copy_datacontrol(gconstpointer src, gpointer data)
885 datacontrol_x *tmp = (datacontrol_x *)src;
886 datacontrol_x *datacontrol;
888 datacontrol = calloc(1, sizeof(datacontrol_x));
889 if (datacontrol == NULL) {
890 LOGE("memory alloc failed");
896 datacontrol->providerid = strdup(tmp->providerid);
898 datacontrol->access = strdup(tmp->access);
900 datacontrol->type = strdup(tmp->type);
905 static gpointer __copy_appcontrol(gconstpointer src, gpointer data)
907 appcontrol_x *tmp = (appcontrol_x *)src;
908 appcontrol_x *appcontrol;
910 appcontrol = calloc(1, sizeof(appcontrol_x));
911 if (appcontrol ==NULL) {
912 LOGE("memory alloc failed");
918 appcontrol->operation = strdup(tmp->operation);
920 appcontrol->uri = strdup(tmp->uri);
922 appcontrol->mime = strdup(tmp->mime);
927 static gpointer __copy_splashscreens(gconstpointer src, gpointer data)
929 splashscreen_x *tmp = (splashscreen_x *)src;
930 splashscreen_x *splashscreen;
932 splashscreen = (splashscreen_x *)calloc(1, sizeof(splashscreen_x));
933 if (splashscreen == NULL) {
934 LOGE("memory alloc failed");
940 splashscreen->src = strdup(tmp->src);
942 splashscreen->type = strdup(tmp->type);
943 if (tmp->orientation)
944 splashscreen->orientation = strdup(tmp->orientation);
945 if (tmp->indicatordisplay)
946 splashscreen->indicatordisplay = strdup(tmp->indicatordisplay);
951 static int _appinfo_copy_appinfo(application_x **application, application_x *data)
953 application_x *app_info;
956 app_info = calloc(1, sizeof(application_x));
957 if (app_info == NULL) {
958 LOGE("memory alloc failed");
959 return PMINFO_R_ERROR;
962 if (data->appid != NULL)
963 app_info->appid = strdup(data->appid);
964 if (data->exec != NULL)
965 app_info->exec = strdup(data->exec);
966 if (data->nodisplay != NULL)
967 app_info->nodisplay = strdup(data->nodisplay);
968 if (data->multiple != NULL)
969 app_info->multiple = strdup(data->multiple);
970 if (data->taskmanage != NULL)
971 app_info->taskmanage = strdup(data->taskmanage);
972 if (data->enabled != NULL)
973 app_info->enabled = strdup(data->enabled);
974 if (data->type != NULL)
975 app_info->type = strdup(data->type);
976 if (data->categories != NULL)
977 app_info->categories = strdup(data->categories);
978 if (data->hwacceleration != NULL)
979 app_info->hwacceleration = strdup(data->hwacceleration);
980 if (data->screenreader != NULL)
981 app_info->screenreader = strdup(data->screenreader);
982 if (data->mainapp != NULL)
983 app_info->mainapp = strdup(data->mainapp);
984 if (data->package != NULL)
985 app_info->package = strdup(data->package);
986 if (data->recentimage != NULL)
987 app_info->recentimage = strdup(data->recentimage);
988 if (data->launchcondition != NULL)
989 app_info->launchcondition = strdup(data->launchcondition);
990 if (data->indicatordisplay != NULL)
991 app_info->indicatordisplay = strdup(data->indicatordisplay);
992 if (data->portraitimg != NULL)
993 app_info->portraitimg = strdup(data->portraitimg);
994 if (data->landscapeimg != NULL)
995 app_info->landscapeimg = strdup(data->landscapeimg);
996 if (data->guestmode_visibility != NULL)
997 app_info->guestmode_visibility = strdup(data->guestmode_visibility);
998 if (data->component != NULL)
999 app_info->component = strdup(data->component);
1000 if (data->permission_type != NULL)
1001 app_info->permission_type = strdup(data->permission_type);
1002 if (data->component_type != NULL)
1003 app_info->component_type = strdup(data->component_type);
1004 if (data->preload != NULL)
1005 app_info->preload = strdup(data->preload);
1006 if (data->submode != NULL)
1007 app_info->submode = strdup(data->submode);
1008 if (data->submode_mainid != NULL)
1009 app_info->submode_mainid = strdup(data->submode_mainid);
1010 if (data->process_pool != NULL)
1011 app_info->process_pool = strdup(data->process_pool);
1012 if (data->installed_storage != NULL)
1013 app_info->installed_storage = strdup(data->installed_storage);
1014 if (data->autorestart != NULL)
1015 app_info->autorestart = strdup(data->autorestart);
1016 if (data->onboot != NULL)
1017 app_info->onboot = strdup(data->onboot);
1018 if (data->support_disable != NULL)
1019 app_info->support_disable = strdup(data->support_disable);
1020 if (data->ui_gadget != NULL)
1021 app_info->ui_gadget = strdup(data->ui_gadget);
1022 if (data->launch_mode != NULL)
1023 app_info->launch_mode = strdup(data->launch_mode);
1024 if (data->package_type != NULL)
1025 app_info->package_type = strdup(data->package_type);
1029 app_info->label = g_list_copy_deep(data->label, __copy_label, &ret);
1031 LOGE("memory alloc failed");
1032 pkgmgrinfo_basic_free_application(app_info);
1033 return PMINFO_R_ERROR;
1037 app_info->icon = g_list_copy_deep(data->icon, __copy_icon, &ret);
1039 LOGE("memory alloc failed");
1040 pkgmgrinfo_basic_free_application(app_info);
1041 return PMINFO_R_ERROR;
1045 app_info->category = g_list_copy_deep(data->category, __copy_str, &ret);
1047 LOGE("memory alloc failed");
1048 pkgmgrinfo_basic_free_application(app_info);
1049 return PMINFO_R_ERROR;
1053 app_info->metadata = g_list_copy_deep(data->metadata, __copy_metadata, &ret);
1055 LOGE("memory alloc failed");
1056 pkgmgrinfo_basic_free_application(app_info);
1057 return PMINFO_R_ERROR;
1061 app_info->datacontrol = g_list_copy_deep(data->datacontrol, __copy_datacontrol, &ret);
1063 LOGE("memory alloc failed");
1064 pkgmgrinfo_basic_free_application(app_info);
1065 return PMINFO_R_ERROR;
1069 app_info->appcontrol = g_list_copy_deep(data->appcontrol, __copy_appcontrol, &ret);
1071 LOGE("memory alloc failed");
1072 pkgmgrinfo_basic_free_application(app_info);
1073 return PMINFO_R_ERROR;
1077 app_info->background_category = g_list_copy_deep(data->background_category, __copy_str, &ret);
1079 LOGE("memory alloc failed");
1080 pkgmgrinfo_basic_free_application(app_info);
1081 return PMINFO_R_ERROR;
1085 app_info->splashscreens = g_list_copy_deep(data->splashscreens, __copy_splashscreens, &ret);
1087 LOGE("memory alloc failed");
1088 pkgmgrinfo_basic_free_application(app_info);
1089 return PMINFO_R_ERROR;
1092 *application = app_info;
1097 API int pkgmgrinfo_appinfo_clone_appinfo(pkgmgrinfo_appinfo_h handle,
1098 pkgmgrinfo_appinfo_h *clone)
1100 pkgmgr_appinfo_x *info;
1101 pkgmgr_appinfo_x *temp = (pkgmgr_appinfo_x *)handle;
1104 return PMINFO_R_EINVAL;
1106 info = calloc(1, sizeof(pkgmgr_appinfo_x));
1108 LOGE("memory alloc failed");
1109 return PMINFO_R_ERROR;
1112 if (temp->package != NULL)
1113 info->package = strdup(temp->package);
1114 if (temp->locale != NULL)
1115 info->locale = strdup(temp->locale);
1117 info->app_component = temp->app_component;
1119 if (_appinfo_copy_appinfo(&info->app_info, temp->app_info) < 0) {
1120 LOGE("appinfo copy failed");
1122 free((void *)info->package);
1126 return PMINFO_R_ERROR;
1134 static int _appinfo_get_filtered_foreach_appinfo(uid_t uid,
1135 pkgmgrinfo_filter_x *filter, pkgmgrinfo_app_list_cb app_list_cb,
1139 pkgmgr_appinfo_x *info;
1145 ret = _appinfo_get_filtered_list(filter, uid, &list);
1146 if (ret != PMINFO_R_OK)
1147 return PMINFO_R_ERROR;
1149 for (tmp = list; tmp; tmp = tmp->next) {
1150 appid = (char *)tmp->data;
1152 ret = _appinfo_get_appinfo(appid, uid, &info);
1153 if (ret == PMINFO_R_ENOENT && uid != GLOBAL_USER)
1154 ret = _appinfo_get_appinfo(appid, GLOBAL_USER,
1156 if (ret != PMINFO_R_OK) {
1160 if (app_list_cb(info, user_data) < 0)
1162 pkgmgrinfo_appinfo_destroy_appinfo(info);
1172 API int pkgmgrinfo_appinfo_get_usr_list(pkgmgrinfo_pkginfo_h handle,
1173 pkgmgrinfo_app_component component,
1174 pkgmgrinfo_app_list_cb app_func, void *user_data, uid_t uid)
1177 pkgmgrinfo_appinfo_filter_h filter;
1179 const char *comp_str = NULL;
1181 if (handle == NULL || app_func == NULL) {
1182 LOGE("invalid parameter");
1183 return PMINFO_R_EINVAL;
1186 if (pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid)) {
1187 LOGE("invalid parameter");
1188 return PMINFO_R_EINVAL;
1191 if (pkgmgrinfo_appinfo_filter_create(&filter))
1192 return PMINFO_R_ERROR;
1194 if (pkgmgrinfo_appinfo_filter_add_string(filter,
1195 PMINFO_APPINFO_PROP_APP_PACKAGE, pkgid)) {
1196 pkgmgrinfo_appinfo_filter_destroy(filter);
1197 return PMINFO_R_ERROR;
1200 if (uid == GLOBAL_USER) {
1201 if (pkgmgrinfo_appinfo_filter_add_int(filter,
1202 PMINFO_APPINFO_PROP_APP_DISABLE_FOR_USER, (int)getuid())) {
1203 pkgmgrinfo_appinfo_filter_destroy(filter);
1204 return PMINFO_R_ERROR;
1208 switch (component) {
1210 comp_str = PMINFO_APPINFO_UI_APP;
1212 case PMINFO_SVC_APP:
1213 comp_str = PMINFO_APPINFO_SVC_APP;
1220 if (pkgmgrinfo_appinfo_filter_add_string(filter,
1221 PMINFO_APPINFO_PROP_APP_COMPONENT,
1223 pkgmgrinfo_appinfo_filter_destroy(filter);
1224 return PMINFO_R_ERROR;
1228 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter, app_func,
1231 pkgmgrinfo_appinfo_filter_destroy(filter);
1236 API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_component component,
1237 pkgmgrinfo_app_list_cb app_func, void *user_data)
1239 return pkgmgrinfo_appinfo_get_usr_list(handle, component, app_func, user_data, GLOBAL_USER);
1242 API int pkgmgrinfo_appinfo_get_usr_install_list(pkgmgrinfo_app_list_cb app_func, uid_t uid, void *user_data)
1244 if (app_func == NULL) {
1245 LOGE("invalid parameter");
1246 return PMINFO_R_EINVAL;
1249 return _appinfo_get_filtered_foreach_appinfo(uid, NULL, app_func,
1253 API int pkgmgrinfo_appinfo_get_install_list(pkgmgrinfo_app_list_cb app_func, void *user_data)
1255 return pkgmgrinfo_appinfo_get_usr_install_list(app_func, GLOBAL_USER, user_data);
1258 API int pkgmgrinfo_appinfo_get_usr_installed_list(pkgmgrinfo_app_list_cb app_func, uid_t uid, void *user_data)
1260 if (app_func == NULL) {
1261 LOGE("invalid parameter");
1262 return PMINFO_R_EINVAL;
1265 return _appinfo_get_filtered_foreach_appinfo(uid, NULL, app_func,
1269 API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func, void *user_data)
1271 return pkgmgrinfo_appinfo_get_usr_installed_list(app_func, GLOBAL_USER, user_data);
1274 API int pkgmgrinfo_appinfo_get_appid(pkgmgrinfo_appinfo_h handle, char **appid)
1276 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1278 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1279 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1281 if (info->app_info == NULL || info->app_info->appid == NULL)
1282 return PMINFO_R_ERROR;
1283 *appid = (char *)info->app_info->appid;
1288 API int pkgmgrinfo_appinfo_get_pkgname(pkgmgrinfo_appinfo_h handle, char **pkg_name)
1290 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1292 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1293 retvm_if(pkg_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1295 if (info->package == NULL)
1296 return PMINFO_R_ERROR;
1298 *pkg_name = (char *)info->package;
1303 API int pkgmgrinfo_appinfo_get_pkgid(pkgmgrinfo_appinfo_h handle, char **pkgid)
1305 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1307 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1308 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1310 if (info->package == NULL)
1311 return PMINFO_R_ERROR;
1313 *pkgid = (char *)info->package;
1318 API int pkgmgrinfo_appinfo_get_pkgtype(pkgmgrinfo_appinfo_h handle, char **pkgtype)
1320 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1321 retvm_if(pkgtype == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1322 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1324 *pkgtype = (char *)info->app_info->package_type;
1329 API int pkgmgrinfo_appinfo_get_exec(pkgmgrinfo_appinfo_h handle, char **exec)
1331 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1333 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1334 retvm_if(exec == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1336 if (info->app_info == NULL || info->app_info->exec == NULL)
1337 return PMINFO_R_ERROR;
1338 *exec = (char *)info->app_info->exec;
1344 API int pkgmgrinfo_appinfo_get_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1349 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1351 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1352 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1354 locale = info->locale;
1355 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
1357 if (info->app_info == NULL)
1358 return PMINFO_R_ERROR;
1360 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1361 ptr = (icon_x *)tmp->data;
1362 if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL ||
1363 !strcasecmp(ptr->text, "") ||
1364 strcmp(ptr->lang, locale))
1366 *icon = (char *)ptr->text;
1370 locale = DEFAULT_LOCALE;
1371 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1372 ptr = (icon_x *)tmp->data;
1373 if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL ||
1374 strcmp(ptr->lang, locale))
1376 *icon = (char *)ptr->text;
1380 return PMINFO_R_ERROR;
1384 API int pkgmgrinfo_appinfo_get_label(pkgmgrinfo_appinfo_h handle, char **label)
1389 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1391 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1392 retvm_if(label == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1394 locale = info->locale;
1395 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
1397 if (info->app_info == NULL)
1398 return PMINFO_R_ERROR;
1400 for (tmp = info->app_info->label; tmp; tmp = tmp->next) {
1401 ptr = (label_x *)tmp->data;
1402 if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL ||
1403 strcmp(ptr->lang, locale))
1405 *label = (char *)ptr->text;
1409 locale = DEFAULT_LOCALE;
1410 for (tmp = info->app_info->label; tmp; tmp = tmp->next) {
1411 ptr = (label_x *)tmp->data;
1412 if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL ||
1413 strcmp(ptr->lang, locale))
1415 *label = (char *)ptr->text;
1419 return PMINFO_R_ERROR;
1422 static char *_get_localed_label(const char *appid, const char *locale, uid_t uid)
1424 char *result = NULL;
1426 sqlite3_stmt *stmt = NULL;
1429 const char *manifest_db;
1431 manifest_db = getUserPkgParserDBPathUID(uid);
1432 if (manifest_db == NULL) {
1433 _LOGE("Failed to get manifest db path");
1437 if (sqlite3_open_v2(manifest_db, &db, SQLITE_OPEN_READONLY, NULL) != SQLITE_OK) {
1438 _LOGE("DB open fail\n");
1442 query = sqlite3_mprintf("select app_label from package_app_localized_info where app_id=%Q and app_locale=%Q", appid, locale);
1443 if (query == NULL) {
1444 _LOGE("Out of memory");
1448 if (sqlite3_prepare_v2(db, query, -1, &stmt, NULL) != SQLITE_OK) {
1449 _LOGE("prepare_v2 fail\n");
1453 if (sqlite3_step(stmt) == SQLITE_ROW) {
1454 val = (char *)sqlite3_column_text(stmt, 0);
1456 result = strdup(val);
1460 sqlite3_finalize(stmt);
1461 sqlite3_free(query);
1467 API int pkgmgrinfo_appinfo_usr_get_localed_label(const char *appid, const char *locale, uid_t uid, char **label)
1471 retvm_if(appid == NULL || locale == NULL || label == NULL, PMINFO_R_EINVAL, "Argument is NULL");
1473 val = _get_localed_label(appid, locale, uid);
1475 val = _get_localed_label(appid, DEFAULT_LOCALE, uid);
1478 return PMINFO_R_ERROR;
1485 API int pkgmgrinfo_appinfo_get_localed_label(const char *appid, const char *locale, char **label)
1487 return pkgmgrinfo_appinfo_usr_get_localed_label(appid, locale, GLOBAL_USER, label);
1490 static pkgmgrinfo_app_component __appcomponent_convert(const char *comp)
1492 if ( strcasecmp(comp, "uiapp") == 0)
1493 return PMINFO_UI_APP;
1494 else if ( strcasecmp(comp, "svcapp") == 0)
1495 return PMINFO_SVC_APP;
1500 API int pkgmgrinfo_appinfo_get_component(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_component *component)
1502 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1505 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1506 retvm_if(component == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1508 if (info->app_info == NULL)
1509 return PMINFO_R_ERROR;
1511 comp = __appcomponent_convert(info->app_info->component);
1513 return PMINFO_R_ERROR;
1520 API int pkgmgrinfo_appinfo_get_apptype(pkgmgrinfo_appinfo_h handle, char **app_type)
1522 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1524 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1525 retvm_if(app_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1527 if (info->app_info == NULL || info->app_info->type == NULL)
1528 return PMINFO_R_ERROR;
1529 *app_type = (char *)info->app_info->type;
1534 API int pkgmgrinfo_appinfo_get_operation(pkgmgrinfo_appcontrol_h handle,
1535 int *operation_count, char ***operation)
1537 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1538 retvm_if(operation == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1539 retvm_if(operation_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1540 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1541 *operation_count = data->operation_count;
1542 *operation = data->operation;
1546 API int pkgmgrinfo_appinfo_get_uri(pkgmgrinfo_appcontrol_h handle,
1547 int *uri_count, char ***uri)
1549 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1550 retvm_if(uri == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1551 retvm_if(uri_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1552 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1553 *uri_count = data->uri_count;
1558 API int pkgmgrinfo_appinfo_get_mime(pkgmgrinfo_appcontrol_h handle,
1559 int *mime_count, char ***mime)
1561 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1562 retvm_if(mime == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1563 retvm_if(mime_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1564 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1565 *mime_count = data->mime_count;
1570 API int pkgmgrinfo_appinfo_get_subapp(pkgmgrinfo_appcontrol_h handle,
1571 int *subapp_count, char ***subapp)
1573 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1574 retvm_if(subapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1575 retvm_if(subapp_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1576 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1577 *subapp_count = data->subapp_count;
1578 *subapp = data->subapp;
1582 API int pkgmgrinfo_appinfo_get_setting_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1587 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1589 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1590 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1592 if (info->app_info == NULL)
1593 return PMINFO_R_ERROR;
1595 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1596 ptr = (icon_x *)tmp->data;
1597 if (ptr == NULL || ptr->section == NULL)
1600 val = (char *)ptr->section;
1601 if (val && strcmp(val, "setting") == 0) {
1602 *icon = (char *)ptr->text;
1607 return PMINFO_R_ERROR;
1611 API int pkgmgrinfo_appinfo_get_notification_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1616 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1618 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1619 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1621 if (info->app_info == NULL)
1622 return PMINFO_R_ERROR;
1624 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1625 ptr = (icon_x *)tmp->data;
1626 if (ptr == NULL || ptr->section == NULL)
1629 val = (char *)ptr->section;
1630 if (val && strcmp(val, "notification") == 0){
1631 *icon = (char *)ptr->text;
1636 return PMINFO_R_ERROR;
1639 API int pkgmgrinfo_appinfo_get_recent_image_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_recentimage *type)
1642 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1644 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1645 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1647 if (info->app_info == NULL || info->app_info->recentimage == NULL)
1648 return PMINFO_R_ERROR;
1650 val = (char *)info->app_info->recentimage;
1651 if (strcasecmp(val, "capture") == 0)
1652 *type = PMINFO_RECENTIMAGE_USE_CAPTURE;
1653 else if (strcasecmp(val, "icon") == 0)
1654 *type = PMINFO_RECENTIMAGE_USE_ICON;
1656 *type = PMINFO_RECENTIMAGE_USE_NOTHING;
1661 API int pkgmgrinfo_appinfo_get_preview_image(pkgmgrinfo_appinfo_h handle, char **preview_img)
1666 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1668 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1669 retvm_if(preview_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1671 if (info->app_info == NULL)
1672 return PMINFO_R_ERROR;
1674 for (tmp = info->app_info->image; tmp; tmp = tmp->next) {
1675 ptr = (image_x *)tmp->data;
1676 if (ptr == NULL || ptr->section == NULL)
1679 val = (char *)ptr->section;
1680 if (val && strcmp(val, "preview") == 0) {
1681 *preview_img = (char *)ptr->text;
1686 return PMINFO_R_ERROR;
1689 API int pkgmgrinfo_appinfo_get_permission_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_permission_type *permission)
1692 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1694 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1695 retvm_if(permission == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1697 val = info->app_info->permission_type;
1699 return PMINFO_R_ERROR;
1701 if (strcmp(val, "signature") == 0)
1702 *permission = PMINFO_PERMISSION_SIGNATURE;
1703 else if (strcmp(val, "privilege") == 0)
1704 *permission = PMINFO_PERMISSION_PRIVILEGE;
1706 *permission = PMINFO_PERMISSION_NORMAL;
1711 API int pkgmgrinfo_appinfo_get_component_type(pkgmgrinfo_appinfo_h handle, char **component_type)
1713 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1715 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1716 retvm_if(component_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1718 if (info->app_info == NULL || info->app_info->component_type == NULL)
1719 return PMINFO_R_ERROR;
1721 *component_type = (char *)info->app_info->component_type;
1726 API int pkgmgrinfo_appinfo_get_hwacceleration(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_hwacceleration *hwacceleration)
1729 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1731 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1732 retvm_if(hwacceleration == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1734 if (info->app_info == NULL || info->app_info->hwacceleration == NULL)
1735 return PMINFO_R_ERROR;
1737 val = (char *)info->app_info->hwacceleration;
1738 if (strcasecmp(val, "not-use-GL") == 0)
1739 *hwacceleration = PMINFO_HWACCELERATION_NOT_USE_GL;
1740 else if (strcasecmp(val, "use-GL") == 0)
1741 *hwacceleration = PMINFO_HWACCELERATION_USE_GL;
1743 *hwacceleration = PMINFO_HWACCELERATION_USE_SYSTEM_SETTING;
1748 API int pkgmgrinfo_appinfo_get_screenreader(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_screenreader *screenreader)
1751 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1753 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1754 retvm_if(screenreader == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1756 if (info->app_info == NULL || info->app_info->screenreader == NULL)
1757 return PMINFO_R_ERROR;
1759 val = (char *)info->app_info->screenreader;
1760 if (strcasecmp(val, "screenreader-off") == 0)
1761 *screenreader = PMINFO_SCREENREADER_OFF;
1762 else if (strcasecmp(val, "screenreader-on") == 0)
1763 *screenreader = PMINFO_SCREENREADER_ON;
1765 *screenreader = PMINFO_SCREENREADER_USE_SYSTEM_SETTING;
1770 API int pkgmgrinfo_appinfo_get_effectimage(pkgmgrinfo_appinfo_h handle, char **portrait_img, char **landscape_img)
1772 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1774 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1775 retvm_if(portrait_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1776 retvm_if(landscape_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1778 if (info->app_info == NULL || (info->app_info->portraitimg == NULL
1779 && info->app_info->landscapeimg == NULL))
1780 return PMINFO_R_ERROR;
1782 *portrait_img = (char *)info->app_info->portraitimg;
1783 *landscape_img = (char *)info->app_info->landscapeimg;
1788 API int pkgmgrinfo_appinfo_get_effectimage_type(pkgmgrinfo_appinfo_h handle, char **effectimage_type)
1790 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1792 if (handle == NULL || effectimage_type == NULL) {
1793 LOGE("invalid parameter");
1794 return PMINFO_R_EINVAL;
1797 if (info->app_info == NULL || info->app_info->effectimage_type == NULL)
1798 return PMINFO_R_ERROR;
1800 *effectimage_type = (char *)info->app_info->effectimage_type;
1805 API int pkgmgrinfo_appinfo_get_submode_mainid(pkgmgrinfo_appinfo_h handle, char **submode_mainid)
1807 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1809 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1810 retvm_if(submode_mainid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1812 if (info->app_info == NULL || info->app_info->submode_mainid == NULL)
1813 return PMINFO_R_ERROR;
1815 *submode_mainid = (char *)info->app_info->submode_mainid;
1820 API int pkgmgrinfo_appinfo_get_installed_storage_location(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_installed_storage *storage)
1822 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1823 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1825 if (info->app_info && info->app_info->installed_storage){
1826 if (strcmp(info->app_info->installed_storage,"installed_internal") == 0)
1827 *storage = PMINFO_INTERNAL_STORAGE;
1828 else if (strcmp(info->app_info->installed_storage,"installed_external") == 0)
1829 *storage = PMINFO_EXTERNAL_STORAGE;
1831 return PMINFO_R_ERROR;
1833 return PMINFO_R_ERROR;
1838 API int pkgmgrinfo_appinfo_get_launch_mode(pkgmgrinfo_appinfo_h handle, char **mode)
1840 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1842 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1843 retvm_if(mode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1845 if (info->app_info->launch_mode == NULL)
1846 return PMINFO_R_ERROR;
1848 *mode = (char *)(info->app_info->launch_mode);
1853 API int pkgmgrinfo_appinfo_get_alias_appid(pkgmgrinfo_appinfo_h handle, char **alias_appid)
1855 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1857 if (handle == NULL || alias_appid == NULL) {
1858 LOGE("invalid parameter");
1859 return PMINFO_R_EINVAL;
1862 if (info->app_info == NULL || info->app_info->alias_appid == NULL)
1863 return PMINFO_R_ERROR;
1865 *alias_appid = (char *)info->app_info->alias_appid;
1870 API int pkgmgrinfo_appinfo_get_effective_appid(pkgmgrinfo_appinfo_h handle, char **effective_appid)
1872 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1874 if (handle == NULL || effective_appid == NULL) {
1875 LOGE("invalid parameter");
1876 return PMINFO_R_EINVAL;
1879 if (info->app_info == NULL || info->app_info->effective_appid == NULL)
1880 return PMINFO_R_ERROR;
1882 *effective_appid = (char *)info->app_info->effective_appid;
1887 API int pkgmgrinfo_appinfo_usr_get_datacontrol_info(const char *providerid, const char *type, uid_t uid, char **appid, char **access)
1889 retvm_if(providerid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
1890 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
1891 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1892 retvm_if(access == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1894 int ret = PMINFO_R_OK;
1896 sqlite3_stmt *stmt = NULL;
1899 ret = __open_manifest_db(uid, true);
1900 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
1902 /*Start constructing query*/
1903 query = sqlite3_mprintf("select * from package_app_data_control where providerid=%Q and type=%Q", providerid, type);
1906 ret = sqlite3_prepare_v2(GET_DB(manifest_db), query, strlen(query), &stmt, NULL);
1907 tryvm_if(ret != PMINFO_R_OK, ret = PMINFO_R_ERROR, "sqlite3_prepare_v2 failed[%s]\n", query);
1910 ret = sqlite3_step(stmt);
1911 tryvm_if((ret != SQLITE_ROW) || (ret == SQLITE_DONE), ret = PMINFO_R_ERROR, "No records found");
1913 *appid = strdup((char *)sqlite3_column_text(stmt, 0));
1914 *access = strdup((char *)sqlite3_column_text(stmt, 2));
1919 sqlite3_free(query);
1920 sqlite3_finalize(stmt);
1921 __close_manifest_db();
1925 API int pkgmgrinfo_appinfo_get_datacontrol_info(const char *providerid, const char *type, char **appid, char **access)
1927 return pkgmgrinfo_appinfo_usr_get_datacontrol_info(providerid, type, GLOBAL_USER, appid, access);
1930 API int pkgmgrinfo_appinfo_usr_get_datacontrol_appid(const char *providerid, uid_t uid, char **appid)
1932 retvm_if(providerid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
1933 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1935 int ret = PMINFO_R_OK;
1937 sqlite3_stmt *stmt = NULL;
1940 ret = __open_manifest_db(uid, true);
1941 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
1943 /*Start constructing query*/
1944 query = sqlite3_mprintf("select * from package_app_data_control where providerid=%Q", providerid);
1947 ret = sqlite3_prepare_v2(GET_DB(manifest_db), query, strlen(query), &stmt, NULL);
1948 tryvm_if(ret != PMINFO_R_OK, ret = PMINFO_R_ERROR, "sqlite3_prepare_v2 failed[%s]\n", query);
1951 ret = sqlite3_step(stmt);
1952 tryvm_if((ret != SQLITE_ROW) || (ret == SQLITE_DONE), ret = PMINFO_R_ERROR, "No records found");
1954 *appid = strdup((char *)sqlite3_column_text(stmt, 0));
1959 sqlite3_free(query);
1960 sqlite3_finalize(stmt);
1961 __close_manifest_db();
1965 API int pkgmgrinfo_appinfo_get_datacontrol_appid(const char *providerid, char **appid)
1967 return pkgmgrinfo_appinfo_usr_get_datacontrol_appid(providerid, GLOBAL_USER, appid);
1970 API int pkgmgrinfo_appinfo_foreach_permission(pkgmgrinfo_appinfo_h handle,
1971 pkgmgrinfo_app_permission_list_cb permission_func, void *user_data)
1973 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1974 retvm_if(permission_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
1978 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1980 if (info->app_info == NULL)
1981 return PMINFO_R_ERROR;
1983 for (tmp = info->app_info->permission; tmp; tmp = tmp->next) {
1984 ptr = (permission_x *)tmp->data;
1988 ret = permission_func(ptr->value, user_data);
1996 API int pkgmgrinfo_appinfo_foreach_category(pkgmgrinfo_appinfo_h handle,
1997 pkgmgrinfo_app_category_list_cb category_func, void *user_data)
1999 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2000 retvm_if(category_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2002 const char *category;
2004 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2006 if (info->app_info == NULL)
2007 return PMINFO_R_ERROR;
2009 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
2010 category = (const char *)tmp->data;
2012 ret = category_func(category, user_data);
2020 API int pkgmgrinfo_appinfo_foreach_metadata(pkgmgrinfo_appinfo_h handle,
2021 pkgmgrinfo_app_metadata_list_cb metadata_func, void *user_data)
2023 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2024 retvm_if(metadata_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2028 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2030 if (info->app_info == NULL)
2031 return PMINFO_R_ERROR;
2033 for (tmp = info->app_info->metadata; tmp; tmp = tmp->next) {
2034 ptr = (metadata_x *)tmp->data;
2038 ret = metadata_func(ptr->key, ptr->value, user_data);
2046 API int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
2047 pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
2049 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2050 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2052 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2053 appcontrol_x *appcontrol;
2056 if (info->app_info == NULL)
2057 return PMINFO_R_ERROR;
2059 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
2060 appcontrol = (appcontrol_x *)tmp->data;
2061 if (appcontrol == NULL)
2063 ret = appcontrol_func(appcontrol->operation, appcontrol->uri, appcontrol->mime, user_data);
2071 API int pkgmgrinfo_appinfo_foreach_background_category(
2072 pkgmgrinfo_appinfo_h handle,
2073 pkgmgrinfo_app_background_category_list_cb category_func,
2076 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2080 if (handle == NULL || category_func == NULL || info->app_info == NULL) {
2081 LOGE("invalid parameter");
2082 return PMINFO_R_EINVAL;
2085 for (tmp = info->app_info->background_category; tmp; tmp = tmp->next) {
2086 category = (char *)tmp->data;
2087 if (category == NULL)
2090 if (category_func(category, user_data) < 0)
2097 API int pkgmgrinfo_appinfo_foreach_splash_screen(pkgmgrinfo_appinfo_h handle,
2098 pkgmgrinfo_app_splash_screen_list_cb splash_screen_func,
2101 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2102 splashscreen_x *splashscreen;
2106 if (info == NULL || info->app_info == NULL
2107 || splash_screen_func == NULL) {
2108 LOGE("invalid parameter");
2109 return PMINFO_R_EINVAL;
2112 for (tmp = info->app_info->splashscreens; tmp; tmp = tmp->next) {
2113 splashscreen = (splashscreen_x *)tmp->data;
2114 if (splashscreen == NULL)
2116 ret = splash_screen_func(splashscreen->src,
2118 splashscreen->orientation,
2119 splashscreen->indicatordisplay,
2128 API int pkgmgrinfo_appinfo_is_nodisplay(pkgmgrinfo_appinfo_h handle, bool *nodisplay)
2130 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2131 retvm_if(nodisplay == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2132 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2134 if (info->app_info == NULL || info->app_info->nodisplay == NULL)
2135 return PMINFO_R_ERROR;
2137 *nodisplay = _get_bool_value(info->app_info->nodisplay);
2142 API int pkgmgrinfo_appinfo_is_multiple(pkgmgrinfo_appinfo_h handle, bool *multiple)
2144 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2145 retvm_if(multiple == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2146 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2148 if (info->app_info == NULL || info->app_info->multiple == NULL)
2149 return PMINFO_R_ERROR;
2151 *multiple = _get_bool_value(info->app_info->multiple);
2156 API int pkgmgrinfo_appinfo_is_indicator_display_allowed(pkgmgrinfo_appinfo_h handle, bool *indicator_disp)
2158 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2159 retvm_if(indicator_disp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2160 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2162 if (info->app_info == NULL || info->app_info->indicatordisplay == NULL)
2163 return PMINFO_R_ERROR;
2165 *indicator_disp = _get_bool_value(info->app_info->indicatordisplay);
2170 API int pkgmgrinfo_appinfo_is_taskmanage(pkgmgrinfo_appinfo_h handle, bool *taskmanage)
2172 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2173 retvm_if(taskmanage == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2174 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2176 if (info->app_info == NULL || info->app_info->taskmanage == NULL)
2177 return PMINFO_R_ERROR;
2179 *taskmanage = _get_bool_value(info->app_info->taskmanage);
2184 API int pkgmgrinfo_appinfo_is_enabled(pkgmgrinfo_appinfo_h handle, bool *enabled)
2186 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2187 retvm_if(enabled == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2188 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2190 if (info->app_info == NULL || info->app_info->enabled == NULL)
2191 return PMINFO_R_ERROR;
2193 *enabled = _get_bool_value(info->app_info->enabled);
2198 API int pkgmgrinfo_appinfo_is_onboot(pkgmgrinfo_appinfo_h handle, bool *onboot)
2200 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2201 retvm_if(onboot == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2202 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2204 if (info->app_info == NULL || info->app_info->onboot == NULL)
2205 return PMINFO_R_ERROR;
2207 *onboot = _get_bool_value(info->app_info->onboot);
2212 API int pkgmgrinfo_appinfo_is_autorestart(pkgmgrinfo_appinfo_h handle, bool *autorestart)
2214 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2215 retvm_if(autorestart == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2216 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2218 if (info->app_info == NULL || info->app_info->autorestart == NULL)
2219 return PMINFO_R_ERROR;
2221 *autorestart = _get_bool_value(info->app_info->autorestart);
2226 API int pkgmgrinfo_appinfo_is_mainapp(pkgmgrinfo_appinfo_h handle, bool *mainapp)
2228 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2229 retvm_if(mainapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2230 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2232 if (info->app_info == NULL || info->app_info->mainapp == NULL)
2233 return PMINFO_R_ERROR;
2235 *mainapp = _get_bool_value(info->app_info->mainapp);
2240 API int pkgmgrinfo_appinfo_is_preload(pkgmgrinfo_appinfo_h handle, bool *preload)
2242 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2243 retvm_if(preload == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2244 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2246 if (info->app_info == NULL || info->app_info->preload == NULL)
2247 return PMINFO_R_ERROR;
2249 *preload = _get_bool_value(info->app_info->preload);
2254 API int pkgmgrinfo_appinfo_is_submode(pkgmgrinfo_appinfo_h handle, bool *submode)
2256 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2257 retvm_if(submode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2258 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2260 if (info->app_info == NULL || info->app_info->submode == NULL)
2261 return PMINFO_R_ERROR;
2263 *submode = _get_bool_value(info->app_info->submode);
2268 API int pkgmgrinfo_appinfo_is_process_pool(pkgmgrinfo_appinfo_h handle, bool *process_pool)
2270 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2272 if (handle == NULL || process_pool == NULL) {
2273 LOGE("invalid parameter");
2274 return PMINFO_R_EINVAL;
2277 if (info->app_info == NULL)
2278 return PMINFO_R_ERROR;
2280 *process_pool = _get_bool_value(info->app_info->process_pool);
2285 API int pkgmgrinfo_appinfo_is_category_exist(pkgmgrinfo_appinfo_h handle, const char *category, bool *exist)
2287 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2288 retvm_if(category == NULL, PMINFO_R_EINVAL, "category is NULL");
2289 retvm_if(exist == NULL, PMINFO_R_EINVAL, "exist is NULL");
2293 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2295 if (info->app_info == NULL)
2296 return PMINFO_R_ERROR;
2299 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
2300 val = (const char *)tmp->data;
2303 if (strcasecmp(val, category) == 0) {
2312 API int pkgmgrinfo_appinfo_is_ui_gadget(pkgmgrinfo_appinfo_h handle,
2315 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2317 if (info == NULL || info->app_info == NULL || ui_gadget == NULL) {
2318 _LOGE("invalid parameter");
2319 return PMINFO_R_EINVAL;
2322 *ui_gadget = _get_bool_value(info->app_info->ui_gadget);
2327 API int pkgmgrinfo_appinfo_is_support_disable(pkgmgrinfo_appinfo_h handle,
2328 bool *support_disable)
2330 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2332 if (info == NULL || info->app_info == NULL || support_disable == NULL) {
2333 _LOGE("invalid parameter");
2334 return PMINFO_R_EINVAL;
2337 *support_disable = _get_bool_value(info->app_info->support_disable);
2342 API int pkgmgrinfo_appinfo_destroy_appinfo(pkgmgrinfo_appinfo_h handle)
2344 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2345 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2346 __cleanup_appinfo(info);
2350 API int pkgmgrinfo_appinfo_filter_create(pkgmgrinfo_appinfo_filter_h *handle)
2352 return (pkgmgrinfo_pkginfo_filter_create(handle));
2355 API int pkgmgrinfo_appinfo_filter_destroy(pkgmgrinfo_appinfo_filter_h handle)
2357 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
2360 static gint __compare_func(gconstpointer data1, gconstpointer data2)
2362 pkgmgrinfo_node_x *node1 = (pkgmgrinfo_node_x*)data1;
2363 pkgmgrinfo_node_x *node2 = (pkgmgrinfo_node_x*)data2;
2364 if (node1->prop == node2->prop)
2366 else if (node1->prop > node2->prop)
2372 API int pkgmgrinfo_appinfo_filter_add_int(pkgmgrinfo_appinfo_filter_h handle,
2373 const char *property, const int value)
2375 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2376 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2377 char buf[PKG_VALUE_STRING_LEN_MAX] = {'\0'};
2379 GSList *link = NULL;
2381 prop = _pminfo_appinfo_convert_to_prop_int(property);
2382 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_INT ||
2383 prop > E_PMINFO_APPINFO_PROP_APP_MAX_INT) {
2384 _LOGE("Invalid Integer Property\n");
2385 return PMINFO_R_EINVAL;
2387 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
2388 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
2390 _LOGE("Out of Memory!!!\n");
2391 return PMINFO_R_ERROR;
2393 snprintf(buf, PKG_VALUE_STRING_LEN_MAX - 1, "%d", value);
2394 val = strndup(buf, PKG_VALUE_STRING_LEN_MAX - 1);
2396 _LOGE("Out of Memory\n");
2399 return PMINFO_R_ERROR;
2403 /*If API is called multiple times for same property, we should override the previous values.
2404 Last value set will be used for filtering.*/
2405 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2407 filter->list = g_slist_delete_link(filter->list, link);
2408 filter->list = g_slist_append(filter->list, (gpointer)node);
2413 API int pkgmgrinfo_appinfo_filter_add_bool(pkgmgrinfo_appinfo_filter_h handle,
2414 const char *property, const bool value)
2416 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2417 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2419 GSList *link = NULL;
2421 prop = _pminfo_appinfo_convert_to_prop_bool(property);
2422 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_BOOL ||
2423 prop > E_PMINFO_APPINFO_PROP_APP_MAX_BOOL) {
2424 _LOGE("Invalid Boolean Property\n");
2425 return PMINFO_R_EINVAL;
2427 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
2428 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
2430 _LOGE("Out of Memory!!!\n");
2431 return PMINFO_R_ERROR;
2434 val = strndup("('true','True')", 15);
2436 val = strndup("('false','False')", 17);
2438 _LOGE("Out of Memory\n");
2441 return PMINFO_R_ERROR;
2445 /*If API is called multiple times for same property, we should override the previous values.
2446 Last value set will be used for filtering.*/
2447 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2449 filter->list = g_slist_delete_link(filter->list, link);
2450 filter->list = g_slist_append(filter->list, (gpointer)node);
2455 API int pkgmgrinfo_appinfo_filter_add_string(pkgmgrinfo_appinfo_filter_h handle,
2456 const char *property, const char *value)
2458 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2459 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2460 retvm_if(value == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2462 pkgmgrinfo_node_x *ptr = NULL;
2463 char prev[PKG_STRING_LEN_MAX] = {'\0'};
2464 char temp[PKG_STRING_LEN_MAX] = {'\0'};
2465 GSList *link = NULL;
2467 prop = _pminfo_appinfo_convert_to_prop_str(property);
2468 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_STR ||
2469 prop > E_PMINFO_APPINFO_PROP_APP_MAX_STR) {
2470 _LOGE("Invalid String Property\n");
2471 return PMINFO_R_EINVAL;
2473 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
2474 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
2476 _LOGE("Out of Memory!!!\n");
2477 return PMINFO_R_ERROR;
2481 case E_PMINFO_APPINFO_PROP_APP_COMPONENT:
2482 if (strcmp(value, PMINFO_APPINFO_UI_APP) == 0)
2483 val = strndup("uiapp", PKG_STRING_LEN_MAX - 1);
2485 val = strndup("svcapp", PKG_STRING_LEN_MAX - 1);
2487 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2489 filter->list = g_slist_delete_link(filter->list, link);
2490 filter->list = g_slist_append(filter->list, (gpointer)node);
2492 case E_PMINFO_APPINFO_PROP_APP_CATEGORY:
2493 case E_PMINFO_APPINFO_PROP_APP_OPERATION:
2494 case E_PMINFO_APPINFO_PROP_APP_URI:
2495 case E_PMINFO_APPINFO_PROP_APP_MIME:
2496 val = (char *)calloc(1, PKG_STRING_LEN_MAX);
2498 _LOGE("Out of Memory\n");
2501 return PMINFO_R_ERROR;
2503 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2505 ptr = (pkgmgrinfo_node_x *)link->data;
2506 strncpy(prev, ptr->value, PKG_STRING_LEN_MAX - 1);
2507 _LOGE("Previous value is %s\n", prev);
2508 filter->list = g_slist_delete_link(filter->list, link);
2509 snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s , '%s'", prev, value);
2510 strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
2511 _LOGE("New value is %s\n", val);
2513 filter->list = g_slist_append(filter->list, (gpointer)node);
2514 memset(temp, '\0', PKG_STRING_LEN_MAX);
2516 snprintf(temp, PKG_STRING_LEN_MAX - 1, "'%s'", value);
2517 strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
2518 _LOGE("First value is %s\n", val);
2520 filter->list = g_slist_append(filter->list, (gpointer)node);
2521 memset(temp, '\0', PKG_STRING_LEN_MAX);
2525 node->value = strndup(value, PKG_STRING_LEN_MAX - 1);
2526 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2528 filter->list = g_slist_delete_link(filter->list, link);
2529 filter->list = g_slist_append(filter->list, (gpointer)node);
2535 API int pkgmgrinfo_appinfo_usr_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count, uid_t uid)
2540 if (handle == NULL || count == NULL) {
2541 _LOGE("invalid parameter");
2542 return PMINFO_R_EINVAL;
2545 ret = _appinfo_get_filtered_list(handle, uid, &list);
2546 if (ret != PMINFO_R_OK)
2547 return PMINFO_R_ERROR;
2549 *count = g_list_length(list);
2551 g_list_free_full(list, free);
2556 API int pkgmgrinfo_appinfo_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count)
2558 return pkgmgrinfo_appinfo_usr_filter_count(handle, count, GLOBAL_USER);
2561 API int pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(
2562 pkgmgrinfo_appinfo_filter_h handle,
2563 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
2565 if (handle == NULL || app_cb == NULL) {
2566 LOGE("invalid parameter");
2567 return PMINFO_R_EINVAL;
2570 return _appinfo_get_filtered_foreach_appinfo(uid, handle, app_cb,
2574 API int pkgmgrinfo_appinfo_filter_foreach_appinfo(pkgmgrinfo_appinfo_filter_h handle,
2575 pkgmgrinfo_app_list_cb app_cb, void * user_data)
2577 return pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(handle, app_cb, user_data, GLOBAL_USER);
2580 API int pkgmgrinfo_appinfo_metadata_filter_create(pkgmgrinfo_appinfo_metadata_filter_h *handle)
2582 return (pkgmgrinfo_pkginfo_filter_create(handle));
2585 API int pkgmgrinfo_appinfo_metadata_filter_destroy(pkgmgrinfo_appinfo_metadata_filter_h handle)
2587 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
2590 API int pkgmgrinfo_appinfo_metadata_filter_add(
2591 pkgmgrinfo_appinfo_metadata_filter_h handle,
2592 const char *key, const char *value)
2596 ret = pkgmgrinfo_appinfo_filter_add_string(handle,
2597 PMINFO_APPINFO_PROP_APP_METADATA_KEY, key);
2598 if (ret != PMINFO_R_OK)
2601 /* value can be NULL.
2602 * In that case all apps with specified key should be displayed
2605 ret = pkgmgrinfo_appinfo_filter_add_string(handle,
2606 PMINFO_APPINFO_PROP_APP_METADATA_VALUE, value);
2607 if (ret != PMINFO_R_OK)
2614 API int pkgmgrinfo_appinfo_usr_metadata_filter_foreach(
2615 pkgmgrinfo_appinfo_metadata_filter_h handle,
2616 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
2618 if (handle == NULL || app_cb == NULL) {
2619 LOGE("invalid parameter");
2620 return PMINFO_R_EINVAL;
2623 return _appinfo_get_filtered_foreach_appinfo(uid, handle, app_cb,
2627 API int pkgmgrinfo_appinfo_metadata_filter_foreach(
2628 pkgmgrinfo_appinfo_metadata_filter_h handle,
2629 pkgmgrinfo_app_list_cb app_cb, void *user_data)
2631 return pkgmgrinfo_appinfo_usr_metadata_filter_foreach(handle, app_cb,
2632 user_data, GLOBAL_USER);
2635 API int pkgmgrinfo_appinfo_is_guestmode_visibility(pkgmgrinfo_appinfo_h handle, bool *status)
2638 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2640 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2641 retvm_if(status == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2643 val = info->app_info->guestmode_visibility;
2644 *status = _get_bool_value(val);