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 GList *__get_background_category(char *value)
508 GList *category_list = NULL;
509 int convert_value = 0;
510 if (!value || strlen(value) == 0)
513 convert_value = atoi(value);
514 if (convert_value < 0)
517 if (convert_value & APP_BG_CATEGORY_USER_DISABLE_TRUE_VAL)
518 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_USER_DISABLE_TRUE_STR));
520 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_USER_DISABLE_FALSE_STR));
522 if (convert_value & APP_BG_CATEGORY_MEDIA_VAL)
523 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_MEDIA_STR));
525 if (convert_value & APP_BG_CATEGORY_DOWNLOAD_VAL)
526 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_DOWNLOAD_STR));
528 if (convert_value & APP_BG_CATEGORY_BGNETWORK_VAL)
529 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_BGNETWORK_STR));
531 if (convert_value & APP_BG_CATEGORY_LOCATION_VAL)
532 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_LOCATION_STR));
534 if (convert_value & APP_BG_CATEGORY_SENSOR_VAL)
535 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_SENSOR_STR));
537 if (convert_value & APP_BG_CATEGORY_IOTCOMM_VAL)
538 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_IOTCOMM_STR));
540 if (convert_value & APP_BG_CATEGORY_SYSTEM_VAL)
541 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_SYSTEM));
543 return category_list;
547 static int _appinfo_get_application(sqlite3 *db, const char *appid,
548 const char *locale, application_x **application)
550 static const char query_raw[] =
551 "SELECT app_id, app_component, app_exec, app_nodisplay, "
552 "app_type, app_onboot, app_multiple, app_autorestart, "
553 "app_taskmanage, app_enabled, app_hwacceleration, "
554 "app_screenreader, app_mainapp, app_recentimage, "
555 "app_launchcondition, app_indicatordisplay, app_portraitimg, "
556 "app_landscapeimg, app_guestmodevisibility, "
557 "app_permissiontype, app_preload, app_submode, "
558 "app_submode_mainid, app_launch_mode, app_ui_gadget, "
559 "app_support_disable, "
560 "component_type, package, app_process_pool, app_installed_storage, "
561 "app_background_category, app_package_type "
562 "FROM package_app_info WHERE app_id='%s' AND app_disable='false' "
564 "(SELECT app_id from package_app_disable_for_user WHERE uid='%d')";
566 char query[MAX_QUERY_LEN] = { '\0' };
570 char *bg_category_str = NULL;
571 snprintf(query, MAX_QUERY_LEN - 1, query_raw, appid, (int)getuid());
572 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
573 if (ret != SQLITE_OK) {
574 LOGE("prepare failed: %s", sqlite3_errmsg(db));
575 return PMINFO_R_ERROR;
578 ret = sqlite3_step(stmt);
579 if (ret == SQLITE_DONE) {
580 sqlite3_finalize(stmt);
581 return PMINFO_R_ENOENT;
582 } else if (ret != SQLITE_ROW) {
583 LOGE("step failed: %s", sqlite3_errmsg(db));
584 sqlite3_finalize(stmt);
585 return PMINFO_R_ERROR;
588 info = calloc(1, sizeof(application_x));
590 LOGE("out of memory");
591 sqlite3_finalize(stmt);
592 return PMINFO_R_ERROR;
595 _save_column_str(stmt, idx++, &info->appid);
596 _save_column_str(stmt, idx++, &info->component);
597 _save_column_str(stmt, idx++, &info->exec);
598 _save_column_str(stmt, idx++, &info->nodisplay);
599 _save_column_str(stmt, idx++, &info->type);
600 _save_column_str(stmt, idx++, &info->onboot);
601 _save_column_str(stmt, idx++, &info->multiple);
602 _save_column_str(stmt, idx++, &info->autorestart);
603 _save_column_str(stmt, idx++, &info->taskmanage);
604 _save_column_str(stmt, idx++, &info->enabled);
605 _save_column_str(stmt, idx++, &info->hwacceleration);
606 _save_column_str(stmt, idx++, &info->screenreader);
607 _save_column_str(stmt, idx++, &info->mainapp);
608 _save_column_str(stmt, idx++, &info->recentimage);
609 _save_column_str(stmt, idx++, &info->launchcondition);
610 _save_column_str(stmt, idx++, &info->indicatordisplay);
611 _save_column_str(stmt, idx++, &info->portraitimg);
612 _save_column_str(stmt, idx++, &info->landscapeimg);
613 _save_column_str(stmt, idx++, &info->guestmode_visibility);
614 _save_column_str(stmt, idx++, &info->permission_type);
615 _save_column_str(stmt, idx++, &info->preload);
616 _save_column_str(stmt, idx++, &info->submode);
617 _save_column_str(stmt, idx++, &info->submode_mainid);
618 _save_column_str(stmt, idx++, &info->launch_mode);
619 _save_column_str(stmt, idx++, &info->ui_gadget);
620 _save_column_str(stmt, idx++, &info->support_disable);
621 _save_column_str(stmt, idx++, &info->component_type);
622 _save_column_str(stmt, idx++, &info->package);
623 _save_column_str(stmt, idx++, &info->process_pool);
624 _save_column_str(stmt, idx++, &info->installed_storage);
625 _save_column_str(stmt, idx++, &bg_category_str);
626 _save_column_str(stmt, idx++, &info->package_type);
628 info->background_category = __get_background_category(bg_category_str);
630 if (_appinfo_get_label(db, info->appid, locale, &info->label)) {
631 pkgmgrinfo_basic_free_application(info);
632 sqlite3_finalize(stmt);
633 return PMINFO_R_ERROR;
636 if (_appinfo_get_icon(db, info->appid, locale, &info->icon)) {
637 pkgmgrinfo_basic_free_application(info);
638 sqlite3_finalize(stmt);
639 return PMINFO_R_ERROR;
642 if (_appinfo_get_category(db, info->appid, &info->category)) {
643 pkgmgrinfo_basic_free_application(info);
644 sqlite3_finalize(stmt);
645 return PMINFO_R_ERROR;
648 if (_appinfo_get_app_control(db, info->appid, &info->appcontrol)) {
649 pkgmgrinfo_basic_free_application(info);
650 sqlite3_finalize(stmt);
651 return PMINFO_R_ERROR;
654 if (_appinfo_get_data_control(db, info->appid, &info->datacontrol)) {
655 pkgmgrinfo_basic_free_application(info);
656 sqlite3_finalize(stmt);
657 return PMINFO_R_ERROR;
660 if (_appinfo_get_metadata(db, info->appid, &info->metadata)) {
661 pkgmgrinfo_basic_free_application(info);
662 sqlite3_finalize(stmt);
663 return PMINFO_R_ERROR;
668 sqlite3_finalize(stmt);
673 static int _appinfo_get_appinfo(const char *appid, uid_t uid,
674 pkgmgr_appinfo_x **appinfo)
680 pkgmgr_appinfo_x *info;
682 dbpath = getUserPkgParserDBPathUID(uid);
684 return PMINFO_R_ERROR;
686 locale = _get_system_locale();
688 return PMINFO_R_ERROR;
690 ret = sqlite3_open_v2(dbpath, &db, SQLITE_OPEN_READONLY, NULL);
691 if (ret != SQLITE_OK) {
692 _LOGE("failed to open db: %d", ret);
694 return PMINFO_R_ERROR;
697 info = calloc(1, sizeof(pkgmgr_appinfo_x));
699 _LOGE("out of memory");
701 sqlite3_close_v2(db);
702 return PMINFO_R_ERROR;
705 ret = _appinfo_get_application(db, appid, locale, &info->app_info);
706 if (ret != PMINFO_R_OK) {
709 sqlite3_close_v2(db);
713 info->locale = locale;
714 info->package = strdup(info->app_info->package);
718 sqlite3_close_v2(db);
723 API int pkgmgrinfo_appinfo_get_usr_appinfo(const char *appid, uid_t uid,
724 pkgmgrinfo_appinfo_h *handle)
728 if (appid == NULL || handle == NULL) {
729 LOGE("invalid parameter");
730 return PMINFO_R_EINVAL;
733 ret = _appinfo_get_appinfo(appid, uid, (pkgmgr_appinfo_x **)handle);
734 if (ret == PMINFO_R_ENOENT && uid != GLOBAL_USER)
735 ret = _appinfo_get_appinfo(appid, GLOBAL_USER,
736 (pkgmgr_appinfo_x **)handle);
738 if (ret != PMINFO_R_OK)
739 _LOGE("failed to get appinfo of %s for user %d", appid, uid);
744 API int pkgmgrinfo_appinfo_get_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
746 return pkgmgrinfo_appinfo_get_usr_appinfo(appid, GLOBAL_USER, handle);
749 static gpointer __copy_str(gconstpointer src, gpointer data)
751 const char *tmp = (const char *)src;
754 buffer = strdup(tmp);
755 if (buffer == NULL) {
756 LOGE("memory alloc failed");
764 static gpointer __copy_label(gconstpointer src, gpointer data)
766 label_x *tmp = (label_x *)src;
769 label = calloc(1, sizeof(label_x));
771 LOGE("memory alloc failed");
777 label->name = strdup(tmp->name);
779 label->text = strdup(tmp->text);
781 label->lang = strdup(tmp->lang);
786 static gpointer __copy_icon(gconstpointer src, gpointer data)
788 icon_x *tmp = (icon_x *)src;
791 icon = calloc(1, sizeof(icon_x));
793 LOGE("memory alloc failed");
799 icon->text = strdup(tmp->text);
801 icon->lang = strdup(tmp->lang);
803 icon->name = strdup(tmp->name);
805 icon->section = strdup(tmp->section);
807 icon->size = strdup(tmp->size);
809 icon->resolution = strdup(tmp->resolution);
814 static gpointer __copy_metadata(gconstpointer src, gpointer data)
816 metadata_x *tmp = (metadata_x *)src;
817 metadata_x *metadata;
819 metadata = calloc(1, sizeof(metadata_x));
820 if (metadata == NULL) {
821 LOGE("memory alloc failed");
827 metadata->key = strdup(tmp->key);
829 metadata->value = strdup(tmp->value);
834 static gpointer __copy_datacontrol(gconstpointer src, gpointer data)
836 datacontrol_x *tmp = (datacontrol_x *)src;
837 datacontrol_x *datacontrol;
839 datacontrol = calloc(1, sizeof(datacontrol_x));
840 if (datacontrol == NULL) {
841 LOGE("memory alloc failed");
847 datacontrol->providerid = strdup(tmp->providerid);
849 datacontrol->access = strdup(tmp->access);
851 datacontrol->type = strdup(tmp->type);
856 static gpointer __copy_appcontrol(gconstpointer src, gpointer data)
858 appcontrol_x *tmp = (appcontrol_x *)src;
859 appcontrol_x *appcontrol;
861 appcontrol = calloc(1, sizeof(appcontrol_x));
862 if (appcontrol ==NULL) {
863 LOGE("memory alloc failed");
869 appcontrol->operation = strdup(tmp->operation);
871 appcontrol->uri = strdup(tmp->uri);
873 appcontrol->mime = strdup(tmp->mime);
878 static int _appinfo_copy_appinfo(application_x **application, application_x *data)
880 application_x *app_info;
883 app_info = calloc(1, sizeof(application_x));
884 if (app_info == NULL) {
885 LOGE("memory alloc failed");
886 return PMINFO_R_ERROR;
889 if (data->appid != NULL)
890 app_info->appid = strdup(data->appid);
891 if (data->exec != NULL)
892 app_info->exec = strdup(data->exec);
893 if (data->nodisplay != NULL)
894 app_info->nodisplay = strdup(data->nodisplay);
895 if (data->multiple != NULL)
896 app_info->multiple = strdup(data->multiple);
897 if (data->taskmanage != NULL)
898 app_info->taskmanage = strdup(data->taskmanage);
899 if (data->enabled != NULL)
900 app_info->enabled = strdup(data->enabled);
901 if (data->type != NULL)
902 app_info->type = strdup(data->type);
903 if (data->categories != NULL)
904 app_info->categories = strdup(data->categories);
905 if (data->hwacceleration != NULL)
906 app_info->hwacceleration = strdup(data->hwacceleration);
907 if (data->screenreader != NULL)
908 app_info->screenreader = strdup(data->screenreader);
909 if (data->mainapp != NULL)
910 app_info->mainapp = strdup(data->mainapp);
911 if (data->package != NULL)
912 app_info->package = strdup(data->package);
913 if (data->recentimage != NULL)
914 app_info->recentimage = strdup(data->recentimage);
915 if (data->launchcondition != NULL)
916 app_info->launchcondition = strdup(data->launchcondition);
917 if (data->indicatordisplay != NULL)
918 app_info->indicatordisplay = strdup(data->indicatordisplay);
919 if (data->portraitimg != NULL)
920 app_info->portraitimg = strdup(data->portraitimg);
921 if (data->landscapeimg != NULL)
922 app_info->landscapeimg = strdup(data->landscapeimg);
923 if (data->guestmode_visibility != NULL)
924 app_info->guestmode_visibility = strdup(data->guestmode_visibility);
925 if (data->component != NULL)
926 app_info->component = strdup(data->component);
927 if (data->permission_type != NULL)
928 app_info->permission_type = strdup(data->permission_type);
929 if (data->component_type != NULL)
930 app_info->component_type = strdup(data->component_type);
931 if (data->preload != NULL)
932 app_info->preload = strdup(data->preload);
933 if (data->submode != NULL)
934 app_info->submode = strdup(data->submode);
935 if (data->submode_mainid != NULL)
936 app_info->submode_mainid = strdup(data->submode_mainid);
937 if (data->process_pool != NULL)
938 app_info->process_pool = strdup(data->process_pool);
939 if (data->installed_storage != NULL)
940 app_info->installed_storage = strdup(data->installed_storage);
941 if (data->autorestart != NULL)
942 app_info->autorestart = strdup(data->autorestart);
943 if (data->onboot != NULL)
944 app_info->onboot = strdup(data->onboot);
945 if (data->support_disable != NULL)
946 app_info->support_disable = strdup(data->support_disable);
947 if (data->ui_gadget != NULL)
948 app_info->ui_gadget = strdup(data->ui_gadget);
949 if (data->launch_mode != NULL)
950 app_info->launch_mode = strdup(data->launch_mode);
951 if (data->package_type != NULL)
952 app_info->package_type = strdup(data->package_type);
956 app_info->label = g_list_copy_deep(data->label, __copy_label, &ret);
958 LOGE("memory alloc failed");
959 pkgmgrinfo_basic_free_application(app_info);
960 return PMINFO_R_ERROR;
964 app_info->icon = g_list_copy_deep(data->icon, __copy_icon, &ret);
966 LOGE("memory alloc failed");
967 pkgmgrinfo_basic_free_application(app_info);
968 return PMINFO_R_ERROR;
972 app_info->category = g_list_copy_deep(data->category, __copy_str, &ret);
974 LOGE("memory alloc failed");
975 pkgmgrinfo_basic_free_application(app_info);
976 return PMINFO_R_ERROR;
980 app_info->metadata = g_list_copy_deep(data->metadata, __copy_metadata, &ret);
982 LOGE("memory alloc failed");
983 pkgmgrinfo_basic_free_application(app_info);
984 return PMINFO_R_ERROR;
988 app_info->datacontrol = g_list_copy_deep(data->datacontrol, __copy_datacontrol, &ret);
990 LOGE("memory alloc failed");
991 pkgmgrinfo_basic_free_application(app_info);
992 return PMINFO_R_ERROR;
996 app_info->appcontrol = g_list_copy_deep(data->appcontrol, __copy_appcontrol, &ret);
998 LOGE("memory alloc failed");
999 pkgmgrinfo_basic_free_application(app_info);
1000 return PMINFO_R_ERROR;
1004 app_info->background_category = g_list_copy_deep(data->background_category, __copy_str, &ret);
1006 LOGE("memory alloc failed");
1007 pkgmgrinfo_basic_free_application(app_info);
1008 return PMINFO_R_ERROR;
1011 *application = app_info;
1016 API int pkgmgrinfo_appinfo_clone_appinfo(pkgmgrinfo_appinfo_h handle,
1017 pkgmgrinfo_appinfo_h *clone)
1019 pkgmgr_appinfo_x *info;
1020 pkgmgr_appinfo_x *temp = (pkgmgr_appinfo_x *)handle;
1023 return PMINFO_R_EINVAL;
1025 info = calloc(1, sizeof(pkgmgr_appinfo_x));
1027 LOGE("memory alloc failed");
1028 return PMINFO_R_ERROR;
1031 if (temp->package != NULL)
1032 info->package = strdup(temp->package);
1033 if (temp->locale != NULL)
1034 info->locale = strdup(temp->locale);
1036 info->app_component = temp->app_component;
1038 if (_appinfo_copy_appinfo(&info->app_info, temp->app_info) < 0) {
1039 LOGE("appinfo copy failed");
1041 free((void *)info->package);
1045 return PMINFO_R_ERROR;
1053 static int _appinfo_get_filtered_foreach_appinfo(uid_t uid,
1054 pkgmgrinfo_filter_x *filter, pkgmgrinfo_app_list_cb app_list_cb,
1058 pkgmgr_appinfo_x *info;
1064 ret = _appinfo_get_filtered_list(filter, uid, &list);
1065 if (ret != PMINFO_R_OK)
1066 return PMINFO_R_ERROR;
1068 for (tmp = list; tmp; tmp = tmp->next) {
1069 appid = (char *)tmp->data;
1071 ret = _appinfo_get_appinfo(appid, uid, &info);
1072 if (ret == PMINFO_R_ENOENT && uid != GLOBAL_USER)
1073 ret = _appinfo_get_appinfo(appid, GLOBAL_USER,
1075 if (ret != PMINFO_R_OK) {
1079 if (app_list_cb(info, user_data) < 0)
1081 pkgmgrinfo_appinfo_destroy_appinfo(info);
1091 API int pkgmgrinfo_appinfo_get_usr_list(pkgmgrinfo_pkginfo_h handle,
1092 pkgmgrinfo_app_component component,
1093 pkgmgrinfo_app_list_cb app_func, void *user_data, uid_t uid)
1096 pkgmgrinfo_appinfo_filter_h filter;
1098 const char *comp_str = NULL;
1100 if (handle == NULL || app_func == NULL) {
1101 LOGE("invalid parameter");
1102 return PMINFO_R_EINVAL;
1105 if (pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid)) {
1106 LOGE("invalid parameter");
1107 return PMINFO_R_EINVAL;
1110 if (pkgmgrinfo_appinfo_filter_create(&filter))
1111 return PMINFO_R_ERROR;
1113 if (pkgmgrinfo_appinfo_filter_add_string(filter,
1114 PMINFO_APPINFO_PROP_APP_PACKAGE, pkgid)) {
1115 pkgmgrinfo_appinfo_filter_destroy(filter);
1116 return PMINFO_R_ERROR;
1119 if (uid == GLOBAL_USER) {
1120 if (pkgmgrinfo_appinfo_filter_add_int(filter,
1121 PMINFO_APPINFO_PROP_APP_DISABLE_FOR_USER, (int)getuid())) {
1122 pkgmgrinfo_appinfo_filter_destroy(filter);
1123 return PMINFO_R_ERROR;
1127 switch (component) {
1129 comp_str = PMINFO_APPINFO_UI_APP;
1131 case PMINFO_SVC_APP:
1132 comp_str = PMINFO_APPINFO_SVC_APP;
1139 if (pkgmgrinfo_appinfo_filter_add_string(filter,
1140 PMINFO_APPINFO_PROP_APP_COMPONENT,
1142 pkgmgrinfo_appinfo_filter_destroy(filter);
1143 return PMINFO_R_ERROR;
1147 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter, app_func,
1150 pkgmgrinfo_appinfo_filter_destroy(filter);
1155 API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_component component,
1156 pkgmgrinfo_app_list_cb app_func, void *user_data)
1158 return pkgmgrinfo_appinfo_get_usr_list(handle, component, app_func, user_data, GLOBAL_USER);
1161 API int pkgmgrinfo_appinfo_get_usr_install_list(pkgmgrinfo_app_list_cb app_func, uid_t uid, void *user_data)
1163 if (app_func == NULL) {
1164 LOGE("invalid parameter");
1165 return PMINFO_R_EINVAL;
1168 return _appinfo_get_filtered_foreach_appinfo(uid, NULL, app_func,
1172 API int pkgmgrinfo_appinfo_get_install_list(pkgmgrinfo_app_list_cb app_func, void *user_data)
1174 return pkgmgrinfo_appinfo_get_usr_install_list(app_func, GLOBAL_USER, user_data);
1177 API int pkgmgrinfo_appinfo_get_usr_installed_list(pkgmgrinfo_app_list_cb app_func, uid_t uid, void *user_data)
1179 if (app_func == NULL) {
1180 LOGE("invalid parameter");
1181 return PMINFO_R_EINVAL;
1184 return _appinfo_get_filtered_foreach_appinfo(uid, NULL, app_func,
1188 API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func, void *user_data)
1190 return pkgmgrinfo_appinfo_get_usr_installed_list(app_func, GLOBAL_USER, user_data);
1193 API int pkgmgrinfo_appinfo_get_appid(pkgmgrinfo_appinfo_h handle, char **appid)
1195 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1197 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1198 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1200 if (info->app_info == NULL || info->app_info->appid == NULL)
1201 return PMINFO_R_ERROR;
1202 *appid = (char *)info->app_info->appid;
1207 API int pkgmgrinfo_appinfo_get_pkgname(pkgmgrinfo_appinfo_h handle, char **pkg_name)
1209 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1211 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1212 retvm_if(pkg_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1214 if (info->package == NULL)
1215 return PMINFO_R_ERROR;
1217 *pkg_name = (char *)info->package;
1222 API int pkgmgrinfo_appinfo_get_pkgid(pkgmgrinfo_appinfo_h handle, char **pkgid)
1224 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1226 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1227 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1229 if (info->package == NULL)
1230 return PMINFO_R_ERROR;
1232 *pkgid = (char *)info->package;
1237 API int pkgmgrinfo_appinfo_get_pkgtype(pkgmgrinfo_appinfo_h handle, char **pkgtype)
1239 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1240 retvm_if(pkgtype == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1241 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1243 *pkgtype = (char *)info->app_info->package_type;
1248 API int pkgmgrinfo_appinfo_get_exec(pkgmgrinfo_appinfo_h handle, char **exec)
1250 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1252 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1253 retvm_if(exec == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1255 if (info->app_info == NULL || info->app_info->exec == NULL)
1256 return PMINFO_R_ERROR;
1257 *exec = (char *)info->app_info->exec;
1263 API int pkgmgrinfo_appinfo_get_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1268 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1270 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1271 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1273 locale = info->locale;
1274 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
1276 if (info->app_info == NULL)
1277 return PMINFO_R_ERROR;
1279 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1280 ptr = (icon_x *)tmp->data;
1281 if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL ||
1282 !strcasecmp(ptr->text, "") ||
1283 strcmp(ptr->lang, locale))
1285 *icon = (char *)ptr->text;
1289 locale = DEFAULT_LOCALE;
1290 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1291 ptr = (icon_x *)tmp->data;
1292 if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL ||
1293 strcmp(ptr->lang, locale))
1295 *icon = (char *)ptr->text;
1299 return PMINFO_R_ERROR;
1303 API int pkgmgrinfo_appinfo_get_label(pkgmgrinfo_appinfo_h handle, char **label)
1308 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1310 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1311 retvm_if(label == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1313 locale = info->locale;
1314 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
1316 if (info->app_info == NULL)
1317 return PMINFO_R_ERROR;
1319 for (tmp = info->app_info->label; tmp; tmp = tmp->next) {
1320 ptr = (label_x *)tmp->data;
1321 if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL ||
1322 strcmp(ptr->lang, locale))
1324 *label = (char *)ptr->text;
1328 locale = DEFAULT_LOCALE;
1329 for (tmp = info->app_info->label; tmp; tmp = tmp->next) {
1330 ptr = (label_x *)tmp->data;
1331 if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL ||
1332 strcmp(ptr->lang, locale))
1334 *label = (char *)ptr->text;
1338 return PMINFO_R_ERROR;
1341 static char *_get_localed_label(const char *appid, const char *locale, uid_t uid)
1343 char *result = NULL;
1345 sqlite3_stmt *stmt = NULL;
1348 const char *manifest_db;
1350 manifest_db = getUserPkgParserDBPathUID(uid);
1351 if (manifest_db == NULL) {
1352 _LOGE("Failed to get manifest db path");
1356 if (sqlite3_open_v2(manifest_db, &db, SQLITE_OPEN_READONLY, NULL) != SQLITE_OK) {
1357 _LOGE("DB open fail\n");
1361 query = sqlite3_mprintf("select app_label from package_app_localized_info where app_id=%Q and app_locale=%Q", appid, locale);
1362 if (query == NULL) {
1363 _LOGE("Out of memory");
1367 if (sqlite3_prepare_v2(db, query, -1, &stmt, NULL) != SQLITE_OK) {
1368 _LOGE("prepare_v2 fail\n");
1372 if (sqlite3_step(stmt) == SQLITE_ROW) {
1373 val = (char *)sqlite3_column_text(stmt, 0);
1375 result = strdup(val);
1379 sqlite3_finalize(stmt);
1380 sqlite3_free(query);
1386 API int pkgmgrinfo_appinfo_usr_get_localed_label(const char *appid, const char *locale, uid_t uid, char **label)
1390 retvm_if(appid == NULL || locale == NULL || label == NULL, PMINFO_R_EINVAL, "Argument is NULL");
1392 val = _get_localed_label(appid, locale, uid);
1394 val = _get_localed_label(appid, DEFAULT_LOCALE, uid);
1397 return PMINFO_R_ERROR;
1404 API int pkgmgrinfo_appinfo_get_localed_label(const char *appid, const char *locale, char **label)
1406 return pkgmgrinfo_appinfo_usr_get_localed_label(appid, locale, GLOBAL_USER, label);
1409 static pkgmgrinfo_app_component __appcomponent_convert(const char *comp)
1411 if ( strcasecmp(comp, "uiapp") == 0)
1412 return PMINFO_UI_APP;
1413 else if ( strcasecmp(comp, "svcapp") == 0)
1414 return PMINFO_SVC_APP;
1419 API int pkgmgrinfo_appinfo_get_component(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_component *component)
1421 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1424 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1425 retvm_if(component == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1427 if (info->app_info == NULL)
1428 return PMINFO_R_ERROR;
1430 comp = __appcomponent_convert(info->app_info->component);
1432 return PMINFO_R_ERROR;
1439 API int pkgmgrinfo_appinfo_get_apptype(pkgmgrinfo_appinfo_h handle, char **app_type)
1441 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1443 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1444 retvm_if(app_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1446 if (info->app_info == NULL || info->app_info->type == NULL)
1447 return PMINFO_R_ERROR;
1448 *app_type = (char *)info->app_info->type;
1453 API int pkgmgrinfo_appinfo_get_operation(pkgmgrinfo_appcontrol_h handle,
1454 int *operation_count, char ***operation)
1456 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1457 retvm_if(operation == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1458 retvm_if(operation_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1459 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1460 *operation_count = data->operation_count;
1461 *operation = data->operation;
1465 API int pkgmgrinfo_appinfo_get_uri(pkgmgrinfo_appcontrol_h handle,
1466 int *uri_count, char ***uri)
1468 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1469 retvm_if(uri == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1470 retvm_if(uri_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1471 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1472 *uri_count = data->uri_count;
1477 API int pkgmgrinfo_appinfo_get_mime(pkgmgrinfo_appcontrol_h handle,
1478 int *mime_count, char ***mime)
1480 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1481 retvm_if(mime == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1482 retvm_if(mime_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1483 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1484 *mime_count = data->mime_count;
1489 API int pkgmgrinfo_appinfo_get_subapp(pkgmgrinfo_appcontrol_h handle,
1490 int *subapp_count, char ***subapp)
1492 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1493 retvm_if(subapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1494 retvm_if(subapp_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1495 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1496 *subapp_count = data->subapp_count;
1497 *subapp = data->subapp;
1501 API int pkgmgrinfo_appinfo_get_setting_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1506 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1508 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1509 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1511 if (info->app_info == NULL)
1512 return PMINFO_R_ERROR;
1514 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1515 ptr = (icon_x *)tmp->data;
1516 if (ptr == NULL || ptr->section == NULL)
1519 val = (char *)ptr->section;
1520 if (val && strcmp(val, "setting") == 0) {
1521 *icon = (char *)ptr->text;
1526 return PMINFO_R_ERROR;
1530 API int pkgmgrinfo_appinfo_get_notification_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1535 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1537 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1538 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1540 if (info->app_info == NULL)
1541 return PMINFO_R_ERROR;
1543 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1544 ptr = (icon_x *)tmp->data;
1545 if (ptr == NULL || ptr->section == NULL)
1548 val = (char *)ptr->section;
1549 if (val && strcmp(val, "notification") == 0){
1550 *icon = (char *)ptr->text;
1555 return PMINFO_R_ERROR;
1558 API int pkgmgrinfo_appinfo_get_recent_image_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_recentimage *type)
1561 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1563 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1564 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1566 if (info->app_info == NULL || info->app_info->recentimage == NULL)
1567 return PMINFO_R_ERROR;
1569 val = (char *)info->app_info->recentimage;
1570 if (strcasecmp(val, "capture") == 0)
1571 *type = PMINFO_RECENTIMAGE_USE_CAPTURE;
1572 else if (strcasecmp(val, "icon") == 0)
1573 *type = PMINFO_RECENTIMAGE_USE_ICON;
1575 *type = PMINFO_RECENTIMAGE_USE_NOTHING;
1580 API int pkgmgrinfo_appinfo_get_preview_image(pkgmgrinfo_appinfo_h handle, char **preview_img)
1585 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1587 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1588 retvm_if(preview_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1590 if (info->app_info == NULL)
1591 return PMINFO_R_ERROR;
1593 for (tmp = info->app_info->image; tmp; tmp = tmp->next) {
1594 ptr = (image_x *)tmp->data;
1595 if (ptr == NULL || ptr->section == NULL)
1598 val = (char *)ptr->section;
1599 if (val && strcmp(val, "preview") == 0) {
1600 *preview_img = (char *)ptr->text;
1605 return PMINFO_R_ERROR;
1608 API int pkgmgrinfo_appinfo_get_permission_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_permission_type *permission)
1611 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1613 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1614 retvm_if(permission == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1616 val = info->app_info->permission_type;
1618 return PMINFO_R_ERROR;
1620 if (strcmp(val, "signature") == 0)
1621 *permission = PMINFO_PERMISSION_SIGNATURE;
1622 else if (strcmp(val, "privilege") == 0)
1623 *permission = PMINFO_PERMISSION_PRIVILEGE;
1625 *permission = PMINFO_PERMISSION_NORMAL;
1630 API int pkgmgrinfo_appinfo_get_component_type(pkgmgrinfo_appinfo_h handle, char **component_type)
1632 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1634 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1635 retvm_if(component_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1637 if (info->app_info == NULL || info->app_info->component_type == NULL)
1638 return PMINFO_R_ERROR;
1640 *component_type = (char *)info->app_info->component_type;
1645 API int pkgmgrinfo_appinfo_get_hwacceleration(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_hwacceleration *hwacceleration)
1648 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1650 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1651 retvm_if(hwacceleration == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1653 if (info->app_info == NULL || info->app_info->hwacceleration == NULL)
1654 return PMINFO_R_ERROR;
1656 val = (char *)info->app_info->hwacceleration;
1657 if (strcasecmp(val, "not-use-GL") == 0)
1658 *hwacceleration = PMINFO_HWACCELERATION_NOT_USE_GL;
1659 else if (strcasecmp(val, "use-GL") == 0)
1660 *hwacceleration = PMINFO_HWACCELERATION_USE_GL;
1662 *hwacceleration = PMINFO_HWACCELERATION_USE_SYSTEM_SETTING;
1667 API int pkgmgrinfo_appinfo_get_screenreader(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_screenreader *screenreader)
1670 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1672 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1673 retvm_if(screenreader == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1675 if (info->app_info == NULL || info->app_info->screenreader == NULL)
1676 return PMINFO_R_ERROR;
1678 val = (char *)info->app_info->screenreader;
1679 if (strcasecmp(val, "screenreader-off") == 0)
1680 *screenreader = PMINFO_SCREENREADER_OFF;
1681 else if (strcasecmp(val, "screenreader-on") == 0)
1682 *screenreader = PMINFO_SCREENREADER_ON;
1684 *screenreader = PMINFO_SCREENREADER_USE_SYSTEM_SETTING;
1689 API int pkgmgrinfo_appinfo_get_effectimage(pkgmgrinfo_appinfo_h handle, char **portrait_img, char **landscape_img)
1691 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1693 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1694 retvm_if(portrait_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1695 retvm_if(landscape_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1697 if (info->app_info == NULL || info->app_info->portraitimg ||
1698 info->app_info->landscapeimg == NULL)
1699 return PMINFO_R_ERROR;
1701 *portrait_img = (char *)info->app_info->portraitimg;
1702 *landscape_img = (char *)info->app_info->landscapeimg;
1707 API int pkgmgrinfo_appinfo_get_effectimage_type(pkgmgrinfo_appinfo_h handle, char **effectimage_type)
1709 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1711 if (handle == NULL || effectimage_type == NULL) {
1712 LOGE("invalid parameter");
1713 return PMINFO_R_EINVAL;
1716 if (info->app_info == NULL || info->app_info->effectimage_type == NULL)
1717 return PMINFO_R_ERROR;
1719 *effectimage_type = (char *)info->app_info->effectimage_type;
1724 API int pkgmgrinfo_appinfo_get_submode_mainid(pkgmgrinfo_appinfo_h handle, char **submode_mainid)
1726 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1728 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1729 retvm_if(submode_mainid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1731 if (info->app_info == NULL || info->app_info->submode_mainid == NULL)
1732 return PMINFO_R_ERROR;
1734 *submode_mainid = (char *)info->app_info->submode_mainid;
1739 API int pkgmgrinfo_appinfo_get_installed_storage_location(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_installed_storage *storage)
1741 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1742 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1744 if (info->app_info && info->app_info->installed_storage){
1745 if (strcmp(info->app_info->installed_storage,"installed_internal") == 0)
1746 *storage = PMINFO_INTERNAL_STORAGE;
1747 else if (strcmp(info->app_info->installed_storage,"installed_external") == 0)
1748 *storage = PMINFO_EXTERNAL_STORAGE;
1750 return PMINFO_R_ERROR;
1752 return PMINFO_R_ERROR;
1757 API int pkgmgrinfo_appinfo_get_launch_mode(pkgmgrinfo_appinfo_h handle, char **mode)
1759 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1761 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1762 retvm_if(mode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1764 if (info->app_info->launch_mode == NULL)
1765 return PMINFO_R_ERROR;
1767 *mode = (char *)(info->app_info->launch_mode);
1772 API int pkgmgrinfo_appinfo_get_alias_appid(pkgmgrinfo_appinfo_h handle, char **alias_appid)
1774 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1776 if (handle == NULL || alias_appid == NULL) {
1777 LOGE("invalid parameter");
1778 return PMINFO_R_EINVAL;
1781 if (info->app_info == NULL || info->app_info->alias_appid == NULL)
1782 return PMINFO_R_ERROR;
1784 *alias_appid = (char *)info->app_info->alias_appid;
1789 API int pkgmgrinfo_appinfo_get_effective_appid(pkgmgrinfo_appinfo_h handle, char **effective_appid)
1791 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1793 if (handle == NULL || effective_appid == NULL) {
1794 LOGE("invalid parameter");
1795 return PMINFO_R_EINVAL;
1798 if (info->app_info == NULL || info->app_info->effective_appid == NULL)
1799 return PMINFO_R_ERROR;
1801 *effective_appid = (char *)info->app_info->effective_appid;
1806 API int pkgmgrinfo_appinfo_usr_get_datacontrol_info(const char *providerid, const char *type, uid_t uid, char **appid, char **access)
1808 retvm_if(providerid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
1809 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
1810 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1811 retvm_if(access == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1813 int ret = PMINFO_R_OK;
1815 sqlite3_stmt *stmt = NULL;
1818 ret = __open_manifest_db(uid, true);
1819 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
1821 /*Start constructing query*/
1822 query = sqlite3_mprintf("select * from package_app_data_control where providerid=%Q and type=%Q", providerid, type);
1825 ret = sqlite3_prepare_v2(GET_DB(manifest_db), query, strlen(query), &stmt, NULL);
1826 tryvm_if(ret != PMINFO_R_OK, ret = PMINFO_R_ERROR, "sqlite3_prepare_v2 failed[%s]\n", query);
1829 ret = sqlite3_step(stmt);
1830 tryvm_if((ret != SQLITE_ROW) || (ret == SQLITE_DONE), ret = PMINFO_R_ERROR, "No records found");
1832 *appid = strdup((char *)sqlite3_column_text(stmt, 0));
1833 *access = strdup((char *)sqlite3_column_text(stmt, 2));
1838 sqlite3_free(query);
1839 sqlite3_finalize(stmt);
1840 __close_manifest_db();
1844 API int pkgmgrinfo_appinfo_get_datacontrol_info(const char *providerid, const char *type, char **appid, char **access)
1846 return pkgmgrinfo_appinfo_usr_get_datacontrol_info(providerid, type, GLOBAL_USER, appid, access);
1849 API int pkgmgrinfo_appinfo_usr_get_datacontrol_appid(const char *providerid, uid_t uid, char **appid)
1851 retvm_if(providerid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
1852 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1854 int ret = PMINFO_R_OK;
1856 sqlite3_stmt *stmt = NULL;
1859 ret = __open_manifest_db(uid, true);
1860 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
1862 /*Start constructing query*/
1863 query = sqlite3_mprintf("select * from package_app_data_control where providerid=%Q", providerid);
1866 ret = sqlite3_prepare_v2(GET_DB(manifest_db), query, strlen(query), &stmt, NULL);
1867 tryvm_if(ret != PMINFO_R_OK, ret = PMINFO_R_ERROR, "sqlite3_prepare_v2 failed[%s]\n", query);
1870 ret = sqlite3_step(stmt);
1871 tryvm_if((ret != SQLITE_ROW) || (ret == SQLITE_DONE), ret = PMINFO_R_ERROR, "No records found");
1873 *appid = strdup((char *)sqlite3_column_text(stmt, 0));
1878 sqlite3_free(query);
1879 sqlite3_finalize(stmt);
1880 __close_manifest_db();
1884 API int pkgmgrinfo_appinfo_get_datacontrol_appid(const char *providerid, char **appid)
1886 return pkgmgrinfo_appinfo_usr_get_datacontrol_appid(providerid, GLOBAL_USER, appid);
1889 API int pkgmgrinfo_appinfo_foreach_permission(pkgmgrinfo_appinfo_h handle,
1890 pkgmgrinfo_app_permission_list_cb permission_func, void *user_data)
1892 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1893 retvm_if(permission_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
1897 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1899 if (info->app_info == NULL)
1900 return PMINFO_R_ERROR;
1902 for (tmp = info->app_info->permission; tmp; tmp = tmp->next) {
1903 ptr = (permission_x *)tmp->data;
1907 ret = permission_func(ptr->value, user_data);
1915 API int pkgmgrinfo_appinfo_foreach_category(pkgmgrinfo_appinfo_h handle,
1916 pkgmgrinfo_app_category_list_cb category_func, void *user_data)
1918 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1919 retvm_if(category_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
1921 const char *category;
1923 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1925 if (info->app_info == NULL)
1926 return PMINFO_R_ERROR;
1928 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
1929 category = (const char *)tmp->data;
1931 ret = category_func(category, user_data);
1939 API int pkgmgrinfo_appinfo_foreach_metadata(pkgmgrinfo_appinfo_h handle,
1940 pkgmgrinfo_app_metadata_list_cb metadata_func, void *user_data)
1942 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1943 retvm_if(metadata_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
1947 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1949 if (info->app_info == NULL)
1950 return PMINFO_R_ERROR;
1952 for (tmp = info->app_info->metadata; tmp; tmp = tmp->next) {
1953 ptr = (metadata_x *)tmp->data;
1957 ret = metadata_func(ptr->key, ptr->value, user_data);
1965 API int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
1966 pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
1968 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1969 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
1971 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1972 appcontrol_x *appcontrol;
1975 if (info->app_info == NULL)
1976 return PMINFO_R_ERROR;
1978 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
1979 appcontrol = (appcontrol_x *)tmp->data;
1980 if (appcontrol == NULL)
1982 ret = appcontrol_func(appcontrol->operation, appcontrol->uri, appcontrol->mime, user_data);
1990 API int pkgmgrinfo_appinfo_foreach_background_category(
1991 pkgmgrinfo_appinfo_h handle,
1992 pkgmgrinfo_app_background_category_list_cb category_func,
1995 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1999 if (handle == NULL || category_func == NULL || info->app_info == NULL) {
2000 LOGE("invalid parameter");
2001 return PMINFO_R_EINVAL;
2004 for (tmp = info->app_info->background_category; tmp; tmp = tmp->next) {
2005 category = (char *)tmp->data;
2006 if (category == NULL)
2009 if (category_func(category, user_data) < 0)
2016 API int pkgmgrinfo_appinfo_is_nodisplay(pkgmgrinfo_appinfo_h handle, bool *nodisplay)
2018 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2019 retvm_if(nodisplay == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2020 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2022 if (info->app_info == NULL || info->app_info->nodisplay == NULL)
2023 return PMINFO_R_ERROR;
2025 *nodisplay = _get_bool_value(info->app_info->nodisplay);
2030 API int pkgmgrinfo_appinfo_is_multiple(pkgmgrinfo_appinfo_h handle, bool *multiple)
2032 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2033 retvm_if(multiple == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2034 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2036 if (info->app_info == NULL || info->app_info->multiple == NULL)
2037 return PMINFO_R_ERROR;
2039 *multiple = _get_bool_value(info->app_info->multiple);
2044 API int pkgmgrinfo_appinfo_is_indicator_display_allowed(pkgmgrinfo_appinfo_h handle, bool *indicator_disp)
2046 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2047 retvm_if(indicator_disp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2048 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2050 if (info->app_info == NULL || info->app_info->indicatordisplay == NULL)
2051 return PMINFO_R_ERROR;
2053 *indicator_disp = _get_bool_value(info->app_info->indicatordisplay);
2058 API int pkgmgrinfo_appinfo_is_taskmanage(pkgmgrinfo_appinfo_h handle, bool *taskmanage)
2060 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2061 retvm_if(taskmanage == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2062 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2064 if (info->app_info == NULL || info->app_info->taskmanage == NULL)
2065 return PMINFO_R_ERROR;
2067 *taskmanage = _get_bool_value(info->app_info->taskmanage);
2072 API int pkgmgrinfo_appinfo_is_enabled(pkgmgrinfo_appinfo_h handle, bool *enabled)
2074 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2075 retvm_if(enabled == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2076 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2078 if (info->app_info == NULL || info->app_info->enabled == NULL)
2079 return PMINFO_R_ERROR;
2081 *enabled = _get_bool_value(info->app_info->enabled);
2086 API int pkgmgrinfo_appinfo_is_onboot(pkgmgrinfo_appinfo_h handle, bool *onboot)
2088 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2089 retvm_if(onboot == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2090 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2092 if (info->app_info == NULL || info->app_info->onboot == NULL)
2093 return PMINFO_R_ERROR;
2095 *onboot = _get_bool_value(info->app_info->onboot);
2100 API int pkgmgrinfo_appinfo_is_autorestart(pkgmgrinfo_appinfo_h handle, bool *autorestart)
2102 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2103 retvm_if(autorestart == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2104 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2106 if (info->app_info == NULL || info->app_info->autorestart == NULL)
2107 return PMINFO_R_ERROR;
2109 *autorestart = _get_bool_value(info->app_info->autorestart);
2114 API int pkgmgrinfo_appinfo_is_mainapp(pkgmgrinfo_appinfo_h handle, bool *mainapp)
2116 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2117 retvm_if(mainapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2118 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2120 if (info->app_info == NULL || info->app_info->mainapp == NULL)
2121 return PMINFO_R_ERROR;
2123 *mainapp = _get_bool_value(info->app_info->mainapp);
2128 API int pkgmgrinfo_appinfo_is_preload(pkgmgrinfo_appinfo_h handle, bool *preload)
2130 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2131 retvm_if(preload == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2132 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2134 if (info->app_info == NULL || info->app_info->preload == NULL)
2135 return PMINFO_R_ERROR;
2137 *preload = _get_bool_value(info->app_info->preload);
2142 API int pkgmgrinfo_appinfo_is_submode(pkgmgrinfo_appinfo_h handle, bool *submode)
2144 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2145 retvm_if(submode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2146 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2148 if (info->app_info == NULL || info->app_info->submode == NULL)
2149 return PMINFO_R_ERROR;
2151 *submode = _get_bool_value(info->app_info->submode);
2156 API int pkgmgrinfo_appinfo_is_process_pool(pkgmgrinfo_appinfo_h handle, bool *process_pool)
2158 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2160 if (handle == NULL || process_pool == NULL) {
2161 LOGE("invalid parameter");
2162 return PMINFO_R_EINVAL;
2165 if (info->app_info == NULL)
2166 return PMINFO_R_ERROR;
2168 *process_pool = _get_bool_value(info->app_info->process_pool);
2173 API int pkgmgrinfo_appinfo_is_category_exist(pkgmgrinfo_appinfo_h handle, const char *category, bool *exist)
2175 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2176 retvm_if(category == NULL, PMINFO_R_EINVAL, "category is NULL");
2177 retvm_if(exist == NULL, PMINFO_R_EINVAL, "exist is NULL");
2181 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2183 if (info->app_info == NULL)
2184 return PMINFO_R_ERROR;
2187 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
2188 val = (const char *)tmp->data;
2191 if (strcasecmp(val, category) == 0) {
2200 API int pkgmgrinfo_appinfo_is_ui_gadget(pkgmgrinfo_appinfo_h handle,
2203 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2205 if (info == NULL || info->app_info == NULL || ui_gadget == NULL) {
2206 _LOGE("invalid parameter");
2207 return PMINFO_R_EINVAL;
2210 *ui_gadget = _get_bool_value(info->app_info->ui_gadget);
2215 API int pkgmgrinfo_appinfo_is_support_disable(pkgmgrinfo_appinfo_h handle,
2216 bool *support_disable)
2218 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2220 if (info == NULL || info->app_info == NULL || support_disable == NULL) {
2221 _LOGE("invalid parameter");
2222 return PMINFO_R_EINVAL;
2225 *support_disable = _get_bool_value(info->app_info->support_disable);
2230 API int pkgmgrinfo_appinfo_destroy_appinfo(pkgmgrinfo_appinfo_h handle)
2232 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2233 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2234 __cleanup_appinfo(info);
2238 API int pkgmgrinfo_appinfo_filter_create(pkgmgrinfo_appinfo_filter_h *handle)
2240 return (pkgmgrinfo_pkginfo_filter_create(handle));
2243 API int pkgmgrinfo_appinfo_filter_destroy(pkgmgrinfo_appinfo_filter_h handle)
2245 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
2248 static gint __compare_func(gconstpointer data1, gconstpointer data2)
2250 pkgmgrinfo_node_x *node1 = (pkgmgrinfo_node_x*)data1;
2251 pkgmgrinfo_node_x *node2 = (pkgmgrinfo_node_x*)data2;
2252 if (node1->prop == node2->prop)
2254 else if (node1->prop > node2->prop)
2260 API int pkgmgrinfo_appinfo_filter_add_int(pkgmgrinfo_appinfo_filter_h handle,
2261 const char *property, const int value)
2263 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2264 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2265 char buf[PKG_VALUE_STRING_LEN_MAX] = {'\0'};
2267 GSList *link = NULL;
2269 prop = _pminfo_appinfo_convert_to_prop_int(property);
2270 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_INT ||
2271 prop > E_PMINFO_APPINFO_PROP_APP_MAX_INT) {
2272 _LOGE("Invalid Integer Property\n");
2273 return PMINFO_R_EINVAL;
2275 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
2276 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
2278 _LOGE("Out of Memory!!!\n");
2279 return PMINFO_R_ERROR;
2281 snprintf(buf, PKG_VALUE_STRING_LEN_MAX - 1, "%d", value);
2282 val = strndup(buf, PKG_VALUE_STRING_LEN_MAX - 1);
2284 _LOGE("Out of Memory\n");
2287 return PMINFO_R_ERROR;
2291 /*If API is called multiple times for same property, we should override the previous values.
2292 Last value set will be used for filtering.*/
2293 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2295 filter->list = g_slist_delete_link(filter->list, link);
2296 filter->list = g_slist_append(filter->list, (gpointer)node);
2301 API int pkgmgrinfo_appinfo_filter_add_bool(pkgmgrinfo_appinfo_filter_h handle,
2302 const char *property, const bool value)
2304 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2305 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2307 GSList *link = NULL;
2309 prop = _pminfo_appinfo_convert_to_prop_bool(property);
2310 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_BOOL ||
2311 prop > E_PMINFO_APPINFO_PROP_APP_MAX_BOOL) {
2312 _LOGE("Invalid Boolean Property\n");
2313 return PMINFO_R_EINVAL;
2315 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
2316 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
2318 _LOGE("Out of Memory!!!\n");
2319 return PMINFO_R_ERROR;
2322 val = strndup("('true','True')", 15);
2324 val = strndup("('false','False')", 17);
2326 _LOGE("Out of Memory\n");
2329 return PMINFO_R_ERROR;
2333 /*If API is called multiple times for same property, we should override the previous values.
2334 Last value set will be used for filtering.*/
2335 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2337 filter->list = g_slist_delete_link(filter->list, link);
2338 filter->list = g_slist_append(filter->list, (gpointer)node);
2343 API int pkgmgrinfo_appinfo_filter_add_string(pkgmgrinfo_appinfo_filter_h handle,
2344 const char *property, const char *value)
2346 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2347 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2348 retvm_if(value == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2350 pkgmgrinfo_node_x *ptr = NULL;
2351 char prev[PKG_STRING_LEN_MAX] = {'\0'};
2352 char temp[PKG_STRING_LEN_MAX] = {'\0'};
2353 GSList *link = NULL;
2355 prop = _pminfo_appinfo_convert_to_prop_str(property);
2356 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_STR ||
2357 prop > E_PMINFO_APPINFO_PROP_APP_MAX_STR) {
2358 _LOGE("Invalid String Property\n");
2359 return PMINFO_R_EINVAL;
2361 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
2362 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
2364 _LOGE("Out of Memory!!!\n");
2365 return PMINFO_R_ERROR;
2369 case E_PMINFO_APPINFO_PROP_APP_COMPONENT:
2370 if (strcmp(value, PMINFO_APPINFO_UI_APP) == 0)
2371 val = strndup("uiapp", PKG_STRING_LEN_MAX - 1);
2373 val = strndup("svcapp", PKG_STRING_LEN_MAX - 1);
2375 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2377 filter->list = g_slist_delete_link(filter->list, link);
2378 filter->list = g_slist_append(filter->list, (gpointer)node);
2380 case E_PMINFO_APPINFO_PROP_APP_CATEGORY:
2381 case E_PMINFO_APPINFO_PROP_APP_OPERATION:
2382 case E_PMINFO_APPINFO_PROP_APP_URI:
2383 case E_PMINFO_APPINFO_PROP_APP_MIME:
2384 val = (char *)calloc(1, PKG_STRING_LEN_MAX);
2386 _LOGE("Out of Memory\n");
2389 return PMINFO_R_ERROR;
2391 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2393 ptr = (pkgmgrinfo_node_x *)link->data;
2394 strncpy(prev, ptr->value, PKG_STRING_LEN_MAX - 1);
2395 _LOGE("Previous value is %s\n", prev);
2396 filter->list = g_slist_delete_link(filter->list, link);
2397 snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s , '%s'", prev, value);
2398 strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
2399 _LOGE("New value is %s\n", val);
2401 filter->list = g_slist_append(filter->list, (gpointer)node);
2402 memset(temp, '\0', PKG_STRING_LEN_MAX);
2404 snprintf(temp, PKG_STRING_LEN_MAX - 1, "'%s'", value);
2405 strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
2406 _LOGE("First value is %s\n", val);
2408 filter->list = g_slist_append(filter->list, (gpointer)node);
2409 memset(temp, '\0', PKG_STRING_LEN_MAX);
2413 node->value = strndup(value, PKG_STRING_LEN_MAX - 1);
2414 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2416 filter->list = g_slist_delete_link(filter->list, link);
2417 filter->list = g_slist_append(filter->list, (gpointer)node);
2423 API int pkgmgrinfo_appinfo_usr_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count, uid_t uid)
2428 if (handle == NULL || count == NULL) {
2429 _LOGE("invalid parameter");
2430 return PMINFO_R_EINVAL;
2433 ret = _appinfo_get_filtered_list(handle, uid, &list);
2434 if (ret != PMINFO_R_OK)
2435 return PMINFO_R_ERROR;
2437 *count = g_list_length(list);
2439 g_list_free_full(list, free);
2444 API int pkgmgrinfo_appinfo_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count)
2446 return pkgmgrinfo_appinfo_usr_filter_count(handle, count, GLOBAL_USER);
2449 API int pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(
2450 pkgmgrinfo_appinfo_filter_h handle,
2451 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
2453 if (handle == NULL || app_cb == NULL) {
2454 LOGE("invalid parameter");
2455 return PMINFO_R_EINVAL;
2458 return _appinfo_get_filtered_foreach_appinfo(uid, handle, app_cb,
2462 API int pkgmgrinfo_appinfo_filter_foreach_appinfo(pkgmgrinfo_appinfo_filter_h handle,
2463 pkgmgrinfo_app_list_cb app_cb, void * user_data)
2465 return pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(handle, app_cb, user_data, GLOBAL_USER);
2468 API int pkgmgrinfo_appinfo_metadata_filter_create(pkgmgrinfo_appinfo_metadata_filter_h *handle)
2470 return (pkgmgrinfo_pkginfo_filter_create(handle));
2473 API int pkgmgrinfo_appinfo_metadata_filter_destroy(pkgmgrinfo_appinfo_metadata_filter_h handle)
2475 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
2478 API int pkgmgrinfo_appinfo_metadata_filter_add(
2479 pkgmgrinfo_appinfo_metadata_filter_h handle,
2480 const char *key, const char *value)
2484 ret = pkgmgrinfo_appinfo_filter_add_string(handle,
2485 PMINFO_APPINFO_PROP_APP_METADATA_KEY, key);
2486 if (ret != PMINFO_R_OK)
2489 /* value can be NULL.
2490 * In that case all apps with specified key should be displayed
2493 ret = pkgmgrinfo_appinfo_filter_add_string(handle,
2494 PMINFO_APPINFO_PROP_APP_METADATA_VALUE, value);
2495 if (ret != PMINFO_R_OK)
2502 API int pkgmgrinfo_appinfo_usr_metadata_filter_foreach(
2503 pkgmgrinfo_appinfo_metadata_filter_h handle,
2504 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
2506 if (handle == NULL || app_cb == NULL) {
2507 LOGE("invalid parameter");
2508 return PMINFO_R_EINVAL;
2511 return _appinfo_get_filtered_foreach_appinfo(uid, handle, app_cb,
2515 API int pkgmgrinfo_appinfo_metadata_filter_foreach(
2516 pkgmgrinfo_appinfo_metadata_filter_h handle,
2517 pkgmgrinfo_app_list_cb app_cb, void *user_data)
2519 return pkgmgrinfo_appinfo_usr_metadata_filter_foreach(handle, app_cb,
2520 user_data, GLOBAL_USER);
2523 API int pkgmgrinfo_appinfo_is_guestmode_visibility(pkgmgrinfo_appinfo_h handle, bool *status)
2526 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2528 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2529 retvm_if(status == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2531 val = info->app_info->guestmode_visibility;
2532 *status = _get_bool_value(val);