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 static int _appinfo_copy_appinfo(application_x **application, application_x *data)
725 application_x *app_info;
727 app_info = calloc(1, sizeof(application_x));
728 if (app_info == NULL) {
729 LOGE("memory alloc failed");
730 return PMINFO_R_ERROR;
733 if (data->appid != NULL)
734 app_info->appid = strdup(data->appid);
735 if (data->exec != NULL)
736 app_info->exec = strdup(data->exec);
737 if (data->nodisplay != NULL)
738 app_info->nodisplay = strdup(data->nodisplay);
739 if (data->multiple != NULL)
740 app_info->multiple = strdup(data->multiple);
741 if (data->taskmanage != NULL)
742 app_info->taskmanage = strdup(data->taskmanage);
743 if (data->enabled != NULL)
744 app_info->enabled = strdup(data->enabled);
745 if (data->type != NULL)
746 app_info->type = strdup(data->type);
747 if (data->categories != NULL)
748 app_info->categories = strdup(data->categories);
749 if (data->extraid != NULL)
750 app_info->extraid = strdup(data->extraid);
751 if (data->hwacceleration != NULL)
752 app_info->hwacceleration = strdup(data->hwacceleration);
753 if (data->screenreader != NULL)
754 app_info->screenreader = strdup(data->screenreader);
755 if (data->mainapp != NULL)
756 app_info->mainapp = strdup(data->mainapp);
757 if (data->package != NULL)
758 app_info->package = strdup(data->package);
759 if (data->recentimage != NULL)
760 app_info->recentimage = strdup(data->recentimage);
761 if (data->launchcondition != NULL)
762 app_info->launchcondition = strdup(data->launchcondition);
763 if (data->indicatordisplay != NULL)
764 app_info->indicatordisplay = strdup(data->indicatordisplay);
765 if (data->portraitimg != NULL)
766 app_info->portraitimg = strdup(data->portraitimg);
767 if (data->landscapeimg != NULL)
768 app_info->landscapeimg = strdup(data->landscapeimg);
769 if (data->effectimage_type != NULL)
770 app_info->effectimage_type = strdup(data->effectimage_type);
771 if (data->guestmode_visibility != NULL)
772 app_info->guestmode_visibility = strdup(data->guestmode_visibility);
773 if (data->component != NULL)
774 app_info->component = strdup(data->component);
775 if (data->permission_type != NULL)
776 app_info->permission_type = strdup(data->permission_type);
777 if (data->component_type != NULL)
778 app_info->component_type = strdup(data->component_type);
779 if (data->preload != NULL)
780 app_info->preload = strdup(data->preload);
781 if (data->submode != NULL)
782 app_info->submode = strdup(data->submode);
783 if (data->submode_mainid != NULL)
784 app_info->submode_mainid = strdup(data->submode_mainid);
785 if (data->process_pool != NULL)
786 app_info->process_pool = strdup(data->process_pool);
787 if (data->installed_storage != NULL)
788 app_info->installed_storage = strdup(data->installed_storage);
789 if (data->autorestart != NULL)
790 app_info->autorestart = strdup(data->autorestart);
791 if (data->onboot != NULL)
792 app_info->onboot = strdup(data->onboot);
793 if (data->support_disable != NULL)
794 app_info->support_disable = strdup(data->support_disable);
795 if (data->ui_gadget != NULL)
796 app_info->ui_gadget = strdup(data->ui_gadget);
797 if (data->launch_mode != NULL)
798 app_info->launch_mode = strdup(data->launch_mode);
799 if (data->ambient_support != NULL)
800 app_info->ambient_support = strdup(data->ambient_support);
801 if (data->alias_appid != NULL)
802 app_info->alias_appid = strdup(data->alias_appid);
803 if (data->effective_appid != NULL)
804 app_info->effective_appid = strdup(data->effective_appid);
806 app_info->label = g_list_copy(data->label);
807 app_info->icon = g_list_copy(data->icon);
808 app_info->image = g_list_copy(data->image);
809 app_info->category = g_list_copy(data->category);
810 app_info->metadata = g_list_copy(data->metadata);
811 app_info->permission = g_list_copy(data->permission);
812 app_info->launchconditions = g_list_copy(data->launchconditions);
813 app_info->notification = g_list_copy(data->notification);
814 app_info->datashare = g_list_copy(data->datashare);
815 app_info->datacontrol = g_list_copy(data->datacontrol);
816 app_info->background_category = g_list_copy(data->background_category);
817 app_info->appcontrol = g_list_copy(data->appcontrol);
819 *application = app_info;
824 API int pkgmgrinfo_appinfo_get_usr_appinfo(const char *appid, uid_t uid,
825 pkgmgrinfo_appinfo_h *handle)
829 if (appid == NULL || handle == NULL) {
830 LOGE("invalid parameter");
831 return PMINFO_R_EINVAL;
834 ret = _appinfo_get_appinfo(appid, uid, (pkgmgr_appinfo_x **)handle);
835 if (ret == PMINFO_R_ENOENT && uid != GLOBAL_USER)
836 ret = _appinfo_get_appinfo(appid, GLOBAL_USER,
837 (pkgmgr_appinfo_x **)handle);
839 if (ret != PMINFO_R_OK)
840 _LOGE("failed to get appinfo of %s for user %d", appid, uid);
845 API int pkgmgrinfo_appinfo_get_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
847 return pkgmgrinfo_appinfo_get_usr_appinfo(appid, GLOBAL_USER, handle);
850 static int _appinfo_get_filtered_foreach_appinfo(uid_t uid,
851 pkgmgrinfo_filter_x *filter, pkgmgrinfo_app_list_cb app_list_cb,
855 pkgmgr_appinfo_x *info;
861 ret = _appinfo_get_filtered_list(filter, uid, &list);
862 if (ret != PMINFO_R_OK)
863 return PMINFO_R_ERROR;
865 for (tmp = list; tmp; tmp = tmp->next) {
866 appid = (char *)tmp->data;
868 ret = _appinfo_get_appinfo(appid, uid, &info);
869 if (ret == PMINFO_R_ENOENT && uid != GLOBAL_USER)
870 ret = _appinfo_get_appinfo(appid, GLOBAL_USER,
872 if (ret != PMINFO_R_OK) {
876 if (app_list_cb(info, user_data) < 0)
878 pkgmgrinfo_appinfo_destroy_appinfo(info);
888 API int pkgmgrinfo_appinfo_get_clone(pkgmgrinfo_appinfo_h *clone,
889 pkgmgrinfo_appinfo_h handle)
891 pkgmgr_appinfo_x *info;
892 pkgmgr_appinfo_x *temp = (pkgmgr_appinfo_x *)handle;
895 return PMINFO_R_EINVAL;
897 info = calloc(1, sizeof(pkgmgr_appinfo_x));
899 LOGE("memory alloc failed");
900 return PMINFO_R_ERROR;
903 if (temp->package != NULL)
904 info->package = strdup(temp->package);
905 if (temp->locale != NULL)
906 info->locale = strdup(temp->locale);
908 info->app_component = temp->app_component;
910 if (_appinfo_copy_appinfo(&info->app_info, temp->app_info) < 0) {
911 LOGE("appinfo copy failed");
917 return PMINFO_R_ERROR;
925 API int pkgmgrinfo_appinfo_get_usr_list(pkgmgrinfo_pkginfo_h handle,
926 pkgmgrinfo_app_component component,
927 pkgmgrinfo_app_list_cb app_func, void *user_data, uid_t uid)
930 pkgmgrinfo_appinfo_filter_h filter;
932 const char *comp_str = NULL;
934 if (handle == NULL || app_func == NULL) {
935 LOGE("invalid parameter");
936 return PMINFO_R_EINVAL;
939 if (pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid)) {
940 LOGE("invalid parameter");
941 return PMINFO_R_EINVAL;
944 if (pkgmgrinfo_appinfo_filter_create(&filter))
945 return PMINFO_R_ERROR;
947 if (pkgmgrinfo_appinfo_filter_add_string(filter,
948 PMINFO_APPINFO_PROP_APP_PACKAGE, pkgid)) {
949 pkgmgrinfo_appinfo_filter_destroy(filter);
950 return PMINFO_R_ERROR;
953 if (uid == GLOBAL_USER) {
954 if (pkgmgrinfo_appinfo_filter_add_int(filter,
955 PMINFO_APPINFO_PROP_APP_DISABLE_FOR_USER, (int)getuid())) {
956 pkgmgrinfo_appinfo_filter_destroy(filter);
957 return PMINFO_R_ERROR;
963 comp_str = PMINFO_APPINFO_UI_APP;
966 comp_str = PMINFO_APPINFO_SVC_APP;
973 if (pkgmgrinfo_appinfo_filter_add_string(filter,
974 PMINFO_APPINFO_PROP_APP_COMPONENT,
976 pkgmgrinfo_appinfo_filter_destroy(filter);
977 return PMINFO_R_ERROR;
981 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter, app_func,
984 pkgmgrinfo_appinfo_filter_destroy(filter);
989 API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_component component,
990 pkgmgrinfo_app_list_cb app_func, void *user_data)
992 return pkgmgrinfo_appinfo_get_usr_list(handle, component, app_func, user_data, GLOBAL_USER);
995 API int pkgmgrinfo_appinfo_get_usr_install_list(pkgmgrinfo_app_list_cb app_func, uid_t uid, void *user_data)
997 if (app_func == NULL) {
998 LOGE("invalid parameter");
999 return PMINFO_R_EINVAL;
1002 return _appinfo_get_filtered_foreach_appinfo(uid, NULL, app_func,
1006 API int pkgmgrinfo_appinfo_get_install_list(pkgmgrinfo_app_list_cb app_func, void *user_data)
1008 return pkgmgrinfo_appinfo_get_usr_install_list(app_func, GLOBAL_USER, user_data);
1011 API int pkgmgrinfo_appinfo_get_usr_installed_list(pkgmgrinfo_app_list_cb app_func, uid_t uid, void *user_data)
1013 if (app_func == NULL) {
1014 LOGE("invalid parameter");
1015 return PMINFO_R_EINVAL;
1018 return _appinfo_get_filtered_foreach_appinfo(uid, NULL, app_func,
1022 API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func, void *user_data)
1024 return pkgmgrinfo_appinfo_get_usr_installed_list(app_func, GLOBAL_USER, user_data);
1027 API int pkgmgrinfo_appinfo_get_appid(pkgmgrinfo_appinfo_h handle, char **appid)
1029 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1031 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1032 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1034 if (info->app_info == NULL || info->app_info->appid == NULL)
1035 return PMINFO_R_ERROR;
1036 *appid = (char *)info->app_info->appid;
1041 API int pkgmgrinfo_appinfo_get_pkgname(pkgmgrinfo_appinfo_h handle, char **pkg_name)
1043 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1045 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1046 retvm_if(pkg_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1048 if (info->package == NULL)
1049 return PMINFO_R_ERROR;
1051 *pkg_name = (char *)info->package;
1056 API int pkgmgrinfo_appinfo_get_pkgid(pkgmgrinfo_appinfo_h handle, char **pkgid)
1058 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1060 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1061 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1063 if (info->package == NULL)
1064 return PMINFO_R_ERROR;
1066 *pkgid = (char *)info->package;
1071 API int pkgmgrinfo_appinfo_get_pkgtype(pkgmgrinfo_appinfo_h handle, char **pkgtype)
1073 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1074 retvm_if(pkgtype == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1075 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1077 *pkgtype = (char *)info->app_info->package_type;
1082 API int pkgmgrinfo_appinfo_get_exec(pkgmgrinfo_appinfo_h handle, char **exec)
1084 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1086 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1087 retvm_if(exec == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1089 if (info->app_info == NULL || info->app_info->exec == NULL)
1090 return PMINFO_R_ERROR;
1091 *exec = (char *)info->app_info->exec;
1097 API int pkgmgrinfo_appinfo_get_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1102 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1104 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1105 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1107 locale = info->locale;
1108 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
1110 if (info->app_info == NULL)
1111 return PMINFO_R_ERROR;
1113 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1114 ptr = (icon_x *)tmp->data;
1115 if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL ||
1116 !strcasecmp(ptr->text, "") ||
1117 strcmp(ptr->lang, locale))
1119 *icon = (char *)ptr->text;
1123 locale = DEFAULT_LOCALE;
1124 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1125 ptr = (icon_x *)tmp->data;
1126 if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL ||
1127 strcmp(ptr->lang, locale))
1129 *icon = (char *)ptr->text;
1133 return PMINFO_R_ERROR;
1137 API int pkgmgrinfo_appinfo_get_label(pkgmgrinfo_appinfo_h handle, char **label)
1142 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1144 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1145 retvm_if(label == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1147 locale = info->locale;
1148 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
1150 if (info->app_info == NULL)
1151 return PMINFO_R_ERROR;
1153 for (tmp = info->app_info->label; tmp; tmp = tmp->next) {
1154 ptr = (label_x *)tmp->data;
1155 if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL ||
1156 strcmp(ptr->lang, locale))
1158 *label = (char *)ptr->text;
1162 locale = DEFAULT_LOCALE;
1163 for (tmp = info->app_info->label; tmp; tmp = tmp->next) {
1164 ptr = (label_x *)tmp->data;
1165 if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL ||
1166 strcmp(ptr->lang, locale))
1168 *label = (char *)ptr->text;
1172 return PMINFO_R_ERROR;
1175 static char *_get_localed_label(const char *appid, const char *locale, uid_t uid)
1177 char *result = NULL;
1179 sqlite3_stmt *stmt = NULL;
1182 const char *manifest_db;
1184 manifest_db = getUserPkgParserDBPathUID(uid);
1185 if (manifest_db == NULL) {
1186 _LOGE("Failed to get manifest db path");
1190 if (sqlite3_open_v2(manifest_db, &db, SQLITE_OPEN_READONLY, NULL) != SQLITE_OK) {
1191 _LOGE("DB open fail\n");
1195 query = sqlite3_mprintf("select app_label from package_app_localized_info where app_id=%Q and app_locale=%Q", appid, locale);
1196 if (query == NULL) {
1197 _LOGE("Out of memory");
1201 if (sqlite3_prepare_v2(db, query, -1, &stmt, NULL) != SQLITE_OK) {
1202 _LOGE("prepare_v2 fail\n");
1206 if (sqlite3_step(stmt) == SQLITE_ROW) {
1207 val = (char *)sqlite3_column_text(stmt, 0);
1209 result = strdup(val);
1213 sqlite3_finalize(stmt);
1214 sqlite3_free(query);
1220 API int pkgmgrinfo_appinfo_usr_get_localed_label(const char *appid, const char *locale, uid_t uid, char **label)
1224 retvm_if(appid == NULL || locale == NULL || label == NULL, PMINFO_R_EINVAL, "Argument is NULL");
1226 val = _get_localed_label(appid, locale, uid);
1228 val = _get_localed_label(appid, DEFAULT_LOCALE, uid);
1231 return PMINFO_R_ERROR;
1238 API int pkgmgrinfo_appinfo_get_localed_label(const char *appid, const char *locale, char **label)
1240 return pkgmgrinfo_appinfo_usr_get_localed_label(appid, locale, GLOBAL_USER, label);
1243 static pkgmgrinfo_app_component __appcomponent_convert(const char *comp)
1245 if ( strcasecmp(comp, "uiapp") == 0)
1246 return PMINFO_UI_APP;
1247 else if ( strcasecmp(comp, "svcapp") == 0)
1248 return PMINFO_SVC_APP;
1253 API int pkgmgrinfo_appinfo_get_component(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_component *component)
1255 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1258 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1259 retvm_if(component == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1261 if (info->app_info == NULL)
1262 return PMINFO_R_ERROR;
1264 comp = __appcomponent_convert(info->app_info->component);
1266 return PMINFO_R_ERROR;
1273 API int pkgmgrinfo_appinfo_get_apptype(pkgmgrinfo_appinfo_h handle, char **app_type)
1275 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1277 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1278 retvm_if(app_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1280 if (info->app_info == NULL || info->app_info->type == NULL)
1281 return PMINFO_R_ERROR;
1282 *app_type = (char *)info->app_info->type;
1287 API int pkgmgrinfo_appinfo_get_operation(pkgmgrinfo_appcontrol_h handle,
1288 int *operation_count, char ***operation)
1290 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1291 retvm_if(operation == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1292 retvm_if(operation_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1293 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1294 *operation_count = data->operation_count;
1295 *operation = data->operation;
1299 API int pkgmgrinfo_appinfo_get_uri(pkgmgrinfo_appcontrol_h handle,
1300 int *uri_count, char ***uri)
1302 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1303 retvm_if(uri == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1304 retvm_if(uri_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1305 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1306 *uri_count = data->uri_count;
1311 API int pkgmgrinfo_appinfo_get_mime(pkgmgrinfo_appcontrol_h handle,
1312 int *mime_count, char ***mime)
1314 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1315 retvm_if(mime == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1316 retvm_if(mime_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1317 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1318 *mime_count = data->mime_count;
1323 API int pkgmgrinfo_appinfo_get_subapp(pkgmgrinfo_appcontrol_h handle,
1324 int *subapp_count, char ***subapp)
1326 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1327 retvm_if(subapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1328 retvm_if(subapp_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1329 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1330 *subapp_count = data->subapp_count;
1331 *subapp = data->subapp;
1335 API int pkgmgrinfo_appinfo_get_setting_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1340 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1342 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1343 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1345 if (info->app_info == NULL)
1346 return PMINFO_R_ERROR;
1348 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1349 ptr = (icon_x *)tmp->data;
1350 if (ptr == NULL || ptr->section == NULL)
1353 val = (char *)ptr->section;
1354 if (val && strcmp(val, "setting") == 0) {
1355 *icon = (char *)ptr->text;
1360 return PMINFO_R_ERROR;
1364 API int pkgmgrinfo_appinfo_get_notification_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1369 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1371 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1372 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1374 if (info->app_info == NULL)
1375 return PMINFO_R_ERROR;
1377 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1378 ptr = (icon_x *)tmp->data;
1379 if (ptr == NULL || ptr->section == NULL)
1382 val = (char *)ptr->section;
1383 if (val && strcmp(val, "notification") == 0){
1384 *icon = (char *)ptr->text;
1389 return PMINFO_R_ERROR;
1392 API int pkgmgrinfo_appinfo_get_recent_image_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_recentimage *type)
1395 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1397 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1398 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1400 if (info->app_info == NULL || info->app_info->recentimage == NULL)
1401 return PMINFO_R_ERROR;
1403 val = (char *)info->app_info->recentimage;
1404 if (strcasecmp(val, "capture") == 0)
1405 *type = PMINFO_RECENTIMAGE_USE_CAPTURE;
1406 else if (strcasecmp(val, "icon") == 0)
1407 *type = PMINFO_RECENTIMAGE_USE_ICON;
1409 *type = PMINFO_RECENTIMAGE_USE_NOTHING;
1414 API int pkgmgrinfo_appinfo_get_preview_image(pkgmgrinfo_appinfo_h handle, char **preview_img)
1419 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1421 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1422 retvm_if(preview_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1424 if (info->app_info == NULL)
1425 return PMINFO_R_ERROR;
1427 for (tmp = info->app_info->image; tmp; tmp = tmp->next) {
1428 ptr = (image_x *)tmp->data;
1429 if (ptr == NULL || ptr->section == NULL)
1432 val = (char *)ptr->section;
1433 if (val && strcmp(val, "preview") == 0) {
1434 *preview_img = (char *)ptr->text;
1439 return PMINFO_R_ERROR;
1442 API int pkgmgrinfo_appinfo_get_permission_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_permission_type *permission)
1445 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1447 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1448 retvm_if(permission == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1450 val = info->app_info->permission_type;
1452 return PMINFO_R_ERROR;
1454 if (strcmp(val, "signature") == 0)
1455 *permission = PMINFO_PERMISSION_SIGNATURE;
1456 else if (strcmp(val, "privilege") == 0)
1457 *permission = PMINFO_PERMISSION_PRIVILEGE;
1459 *permission = PMINFO_PERMISSION_NORMAL;
1464 API int pkgmgrinfo_appinfo_get_component_type(pkgmgrinfo_appinfo_h handle, char **component_type)
1466 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1468 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1469 retvm_if(component_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1471 if (info->app_info == NULL || info->app_info->component_type == NULL)
1472 return PMINFO_R_ERROR;
1474 *component_type = (char *)info->app_info->component_type;
1479 API int pkgmgrinfo_appinfo_get_hwacceleration(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_hwacceleration *hwacceleration)
1482 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1484 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1485 retvm_if(hwacceleration == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1487 if (info->app_info == NULL || info->app_info->hwacceleration == NULL)
1488 return PMINFO_R_ERROR;
1490 val = (char *)info->app_info->hwacceleration;
1491 if (strcasecmp(val, "not-use-GL") == 0)
1492 *hwacceleration = PMINFO_HWACCELERATION_NOT_USE_GL;
1493 else if (strcasecmp(val, "use-GL") == 0)
1494 *hwacceleration = PMINFO_HWACCELERATION_USE_GL;
1496 *hwacceleration = PMINFO_HWACCELERATION_USE_SYSTEM_SETTING;
1501 API int pkgmgrinfo_appinfo_get_screenreader(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_screenreader *screenreader)
1504 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1506 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1507 retvm_if(screenreader == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1509 if (info->app_info == NULL || info->app_info->screenreader == NULL)
1510 return PMINFO_R_ERROR;
1512 val = (char *)info->app_info->screenreader;
1513 if (strcasecmp(val, "screenreader-off") == 0)
1514 *screenreader = PMINFO_SCREENREADER_OFF;
1515 else if (strcasecmp(val, "screenreader-on") == 0)
1516 *screenreader = PMINFO_SCREENREADER_ON;
1518 *screenreader = PMINFO_SCREENREADER_USE_SYSTEM_SETTING;
1523 API int pkgmgrinfo_appinfo_get_effectimage(pkgmgrinfo_appinfo_h handle, char **portrait_img, char **landscape_img)
1525 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1527 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1528 retvm_if(portrait_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1529 retvm_if(landscape_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1531 if (info->app_info == NULL || info->app_info->portraitimg ||
1532 info->app_info->landscapeimg == NULL)
1533 return PMINFO_R_ERROR;
1535 *portrait_img = (char *)info->app_info->portraitimg;
1536 *landscape_img = (char *)info->app_info->landscapeimg;
1541 API int pkgmgrinfo_appinfo_get_effectimage_type(pkgmgrinfo_appinfo_h handle, char **effectimage_type)
1543 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1545 if (handle == NULL || effectimage_type == NULL) {
1546 LOGE("invalid parameter");
1547 return PMINFO_R_EINVAL;
1550 if (info->app_info == NULL || info->app_info->effectimage_type == NULL)
1551 return PMINFO_R_ERROR;
1553 *effectimage_type = (char *)info->app_info->effectimage_type;
1558 API int pkgmgrinfo_appinfo_get_submode_mainid(pkgmgrinfo_appinfo_h handle, char **submode_mainid)
1560 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1562 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1563 retvm_if(submode_mainid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1565 if (info->app_info == NULL || info->app_info->submode_mainid == NULL)
1566 return PMINFO_R_ERROR;
1568 *submode_mainid = (char *)info->app_info->submode_mainid;
1573 API int pkgmgrinfo_appinfo_get_installed_storage_location(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_installed_storage *storage)
1575 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1576 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1578 if (info->app_info && info->app_info->installed_storage){
1579 if (strcmp(info->app_info->installed_storage,"installed_internal") == 0)
1580 *storage = PMINFO_INTERNAL_STORAGE;
1581 else if (strcmp(info->app_info->installed_storage,"installed_external") == 0)
1582 *storage = PMINFO_EXTERNAL_STORAGE;
1584 return PMINFO_R_ERROR;
1586 return PMINFO_R_ERROR;
1591 API int pkgmgrinfo_appinfo_get_launch_mode(pkgmgrinfo_appinfo_h handle, char **mode)
1593 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1595 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1596 retvm_if(mode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1598 if (info->app_info->launch_mode == NULL)
1599 return PMINFO_R_ERROR;
1601 *mode = (char *)(info->app_info->launch_mode);
1606 API int pkgmgrinfo_appinfo_get_alias_appid(pkgmgrinfo_appinfo_h handle, char **alias_appid)
1608 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1610 if (handle == NULL || alias_appid == NULL) {
1611 LOGE("invalid parameter");
1612 return PMINFO_R_EINVAL;
1615 if (info->app_info == NULL || info->app_info->alias_appid == NULL)
1616 return PMINFO_R_ERROR;
1618 *alias_appid = (char *)info->app_info->alias_appid;
1623 API int pkgmgrinfo_appinfo_get_effective_appid(pkgmgrinfo_appinfo_h handle, char **effective_appid)
1625 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1627 if (handle == NULL || effective_appid == NULL) {
1628 LOGE("invalid parameter");
1629 return PMINFO_R_EINVAL;
1632 if (info->app_info == NULL || info->app_info->effective_appid == NULL)
1633 return PMINFO_R_ERROR;
1635 *effective_appid = (char *)info->app_info->effective_appid;
1640 API int pkgmgrinfo_appinfo_usr_get_datacontrol_info(const char *providerid, const char *type, uid_t uid, char **appid, char **access)
1642 retvm_if(providerid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
1643 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
1644 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1645 retvm_if(access == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1647 int ret = PMINFO_R_OK;
1649 sqlite3_stmt *stmt = NULL;
1652 ret = __open_manifest_db(uid, true);
1653 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
1655 /*Start constructing query*/
1656 query = sqlite3_mprintf("select * from package_app_data_control where providerid=%Q and type=%Q", providerid, type);
1659 ret = sqlite3_prepare_v2(GET_DB(manifest_db), query, strlen(query), &stmt, NULL);
1660 tryvm_if(ret != PMINFO_R_OK, ret = PMINFO_R_ERROR, "sqlite3_prepare_v2 failed[%s]\n", query);
1663 ret = sqlite3_step(stmt);
1664 tryvm_if((ret != SQLITE_ROW) || (ret == SQLITE_DONE), ret = PMINFO_R_ERROR, "No records found");
1666 *appid = strdup((char *)sqlite3_column_text(stmt, 0));
1667 *access = strdup((char *)sqlite3_column_text(stmt, 2));
1672 sqlite3_free(query);
1673 sqlite3_finalize(stmt);
1674 __close_manifest_db();
1678 API int pkgmgrinfo_appinfo_get_datacontrol_info(const char *providerid, const char *type, char **appid, char **access)
1680 return pkgmgrinfo_appinfo_usr_get_datacontrol_info(providerid, type, GLOBAL_USER, appid, access);
1683 API int pkgmgrinfo_appinfo_usr_get_datacontrol_appid(const char *providerid, uid_t uid, char **appid)
1685 retvm_if(providerid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
1686 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1688 int ret = PMINFO_R_OK;
1690 sqlite3_stmt *stmt = NULL;
1693 ret = __open_manifest_db(uid, true);
1694 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
1696 /*Start constructing query*/
1697 query = sqlite3_mprintf("select * from package_app_data_control where providerid=%Q", providerid);
1700 ret = sqlite3_prepare_v2(GET_DB(manifest_db), query, strlen(query), &stmt, NULL);
1701 tryvm_if(ret != PMINFO_R_OK, ret = PMINFO_R_ERROR, "sqlite3_prepare_v2 failed[%s]\n", query);
1704 ret = sqlite3_step(stmt);
1705 tryvm_if((ret != SQLITE_ROW) || (ret == SQLITE_DONE), ret = PMINFO_R_ERROR, "No records found");
1707 *appid = strdup((char *)sqlite3_column_text(stmt, 0));
1712 sqlite3_free(query);
1713 sqlite3_finalize(stmt);
1714 __close_manifest_db();
1718 API int pkgmgrinfo_appinfo_get_datacontrol_appid(const char *providerid, char **appid)
1720 return pkgmgrinfo_appinfo_usr_get_datacontrol_appid(providerid, GLOBAL_USER, appid);
1723 API int pkgmgrinfo_appinfo_foreach_permission(pkgmgrinfo_appinfo_h handle,
1724 pkgmgrinfo_app_permission_list_cb permission_func, void *user_data)
1726 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1727 retvm_if(permission_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
1731 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1733 if (info->app_info == NULL)
1734 return PMINFO_R_ERROR;
1736 for (tmp = info->app_info->permission; tmp; tmp = tmp->next) {
1737 ptr = (permission_x *)tmp->data;
1741 ret = permission_func(ptr->value, user_data);
1749 API int pkgmgrinfo_appinfo_foreach_category(pkgmgrinfo_appinfo_h handle,
1750 pkgmgrinfo_app_category_list_cb category_func, void *user_data)
1752 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1753 retvm_if(category_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
1755 const char *category;
1757 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1759 if (info->app_info == NULL)
1760 return PMINFO_R_ERROR;
1762 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
1763 category = (const char *)tmp->data;
1765 ret = category_func(category, user_data);
1773 API int pkgmgrinfo_appinfo_foreach_metadata(pkgmgrinfo_appinfo_h handle,
1774 pkgmgrinfo_app_metadata_list_cb metadata_func, void *user_data)
1776 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1777 retvm_if(metadata_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
1781 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1783 if (info->app_info == NULL)
1784 return PMINFO_R_ERROR;
1786 for (tmp = info->app_info->metadata; tmp; tmp = tmp->next) {
1787 ptr = (metadata_x *)tmp->data;
1791 ret = metadata_func(ptr->key, ptr->value, user_data);
1799 API int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
1800 pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
1802 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1803 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
1805 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1806 appcontrol_x *appcontrol;
1809 if (info->app_info == NULL)
1810 return PMINFO_R_ERROR;
1812 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
1813 appcontrol = (appcontrol_x *)tmp->data;
1814 if (appcontrol == NULL)
1816 ret = appcontrol_func(appcontrol->operation, appcontrol->uri, appcontrol->mime, user_data);
1824 API int pkgmgrinfo_appinfo_foreach_background_category(
1825 pkgmgrinfo_appinfo_h handle,
1826 pkgmgrinfo_app_background_category_list_cb category_func,
1829 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1833 if (handle == NULL || category_func == NULL || info->app_info == NULL) {
1834 LOGE("invalid parameter");
1835 return PMINFO_R_EINVAL;
1838 for (tmp = info->app_info->background_category; tmp; tmp = tmp->next) {
1839 category = (char *)tmp->data;
1840 if (category == NULL)
1843 if (category_func(category, user_data) < 0)
1850 API int pkgmgrinfo_appinfo_is_nodisplay(pkgmgrinfo_appinfo_h handle, bool *nodisplay)
1852 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1853 retvm_if(nodisplay == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1854 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1856 if (info->app_info == NULL || info->app_info->nodisplay == NULL)
1857 return PMINFO_R_ERROR;
1859 *nodisplay = _get_bool_value(info->app_info->nodisplay);
1864 API int pkgmgrinfo_appinfo_is_multiple(pkgmgrinfo_appinfo_h handle, bool *multiple)
1866 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1867 retvm_if(multiple == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1868 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1870 if (info->app_info == NULL || info->app_info->multiple == NULL)
1871 return PMINFO_R_ERROR;
1873 *multiple = _get_bool_value(info->app_info->multiple);
1878 API int pkgmgrinfo_appinfo_is_indicator_display_allowed(pkgmgrinfo_appinfo_h handle, bool *indicator_disp)
1880 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1881 retvm_if(indicator_disp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1882 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1884 if (info->app_info == NULL || info->app_info->indicatordisplay == NULL)
1885 return PMINFO_R_ERROR;
1887 *indicator_disp = _get_bool_value(info->app_info->indicatordisplay);
1892 API int pkgmgrinfo_appinfo_is_taskmanage(pkgmgrinfo_appinfo_h handle, bool *taskmanage)
1894 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1895 retvm_if(taskmanage == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1896 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1898 if (info->app_info == NULL || info->app_info->taskmanage == NULL)
1899 return PMINFO_R_ERROR;
1901 *taskmanage = _get_bool_value(info->app_info->taskmanage);
1906 API int pkgmgrinfo_appinfo_is_enabled(pkgmgrinfo_appinfo_h handle, bool *enabled)
1908 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1909 retvm_if(enabled == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1910 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1912 if (info->app_info == NULL || info->app_info->enabled == NULL)
1913 return PMINFO_R_ERROR;
1915 *enabled = _get_bool_value(info->app_info->enabled);
1920 API int pkgmgrinfo_appinfo_is_onboot(pkgmgrinfo_appinfo_h handle, bool *onboot)
1922 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1923 retvm_if(onboot == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1924 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1926 if (info->app_info == NULL || info->app_info->onboot == NULL)
1927 return PMINFO_R_ERROR;
1929 *onboot = _get_bool_value(info->app_info->onboot);
1934 API int pkgmgrinfo_appinfo_is_autorestart(pkgmgrinfo_appinfo_h handle, bool *autorestart)
1936 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1937 retvm_if(autorestart == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1938 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1940 if (info->app_info == NULL || info->app_info->autorestart == NULL)
1941 return PMINFO_R_ERROR;
1943 *autorestart = _get_bool_value(info->app_info->autorestart);
1948 API int pkgmgrinfo_appinfo_is_mainapp(pkgmgrinfo_appinfo_h handle, bool *mainapp)
1950 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1951 retvm_if(mainapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1952 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1954 if (info->app_info == NULL || info->app_info->mainapp == NULL)
1955 return PMINFO_R_ERROR;
1957 *mainapp = _get_bool_value(info->app_info->mainapp);
1962 API int pkgmgrinfo_appinfo_is_preload(pkgmgrinfo_appinfo_h handle, bool *preload)
1964 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1965 retvm_if(preload == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1966 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1968 if (info->app_info == NULL || info->app_info->preload == NULL)
1969 return PMINFO_R_ERROR;
1971 *preload = _get_bool_value(info->app_info->preload);
1976 API int pkgmgrinfo_appinfo_is_submode(pkgmgrinfo_appinfo_h handle, bool *submode)
1978 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1979 retvm_if(submode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1980 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1982 if (info->app_info == NULL || info->app_info->submode == NULL)
1983 return PMINFO_R_ERROR;
1985 *submode = _get_bool_value(info->app_info->submode);
1990 API int pkgmgrinfo_appinfo_is_process_pool(pkgmgrinfo_appinfo_h handle, bool *process_pool)
1992 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1994 if (handle == NULL || process_pool == NULL) {
1995 LOGE("invalid parameter");
1996 return PMINFO_R_EINVAL;
1999 if (info->app_info == NULL)
2000 return PMINFO_R_ERROR;
2002 *process_pool = _get_bool_value(info->app_info->process_pool);
2007 API int pkgmgrinfo_appinfo_is_category_exist(pkgmgrinfo_appinfo_h handle, const char *category, bool *exist)
2009 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2010 retvm_if(category == NULL, PMINFO_R_EINVAL, "category is NULL");
2011 retvm_if(exist == NULL, PMINFO_R_EINVAL, "exist is NULL");
2015 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2017 if (info->app_info == NULL)
2018 return PMINFO_R_ERROR;
2021 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
2022 val = (const char *)tmp->data;
2025 if (strcasecmp(val, category) == 0) {
2034 API int pkgmgrinfo_appinfo_is_ui_gadget(pkgmgrinfo_appinfo_h handle,
2037 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2039 if (info == NULL || info->app_info == NULL || ui_gadget == NULL) {
2040 _LOGE("invalid parameter");
2041 return PMINFO_R_EINVAL;
2044 *ui_gadget = _get_bool_value(info->app_info->ui_gadget);
2049 API int pkgmgrinfo_appinfo_is_support_disable(pkgmgrinfo_appinfo_h handle,
2050 bool *support_disable)
2052 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2054 if (info == NULL || info->app_info == NULL || support_disable == NULL) {
2055 _LOGE("invalid parameter");
2056 return PMINFO_R_EINVAL;
2059 *support_disable = _get_bool_value(info->app_info->support_disable);
2064 API int pkgmgrinfo_appinfo_destroy_appinfo(pkgmgrinfo_appinfo_h handle)
2066 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2067 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2068 __cleanup_appinfo(info);
2072 API int pkgmgrinfo_appinfo_filter_create(pkgmgrinfo_appinfo_filter_h *handle)
2074 return (pkgmgrinfo_pkginfo_filter_create(handle));
2077 API int pkgmgrinfo_appinfo_filter_destroy(pkgmgrinfo_appinfo_filter_h handle)
2079 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
2082 static gint __compare_func(gconstpointer data1, gconstpointer data2)
2084 pkgmgrinfo_node_x *node1 = (pkgmgrinfo_node_x*)data1;
2085 pkgmgrinfo_node_x *node2 = (pkgmgrinfo_node_x*)data2;
2086 if (node1->prop == node2->prop)
2088 else if (node1->prop > node2->prop)
2094 API int pkgmgrinfo_appinfo_filter_add_int(pkgmgrinfo_appinfo_filter_h handle,
2095 const char *property, const int value)
2097 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2098 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2099 char buf[PKG_VALUE_STRING_LEN_MAX] = {'\0'};
2101 GSList *link = NULL;
2103 prop = _pminfo_appinfo_convert_to_prop_int(property);
2104 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_INT ||
2105 prop > E_PMINFO_APPINFO_PROP_APP_MAX_INT) {
2106 _LOGE("Invalid Integer Property\n");
2107 return PMINFO_R_EINVAL;
2109 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
2110 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
2112 _LOGE("Out of Memory!!!\n");
2113 return PMINFO_R_ERROR;
2115 snprintf(buf, PKG_VALUE_STRING_LEN_MAX - 1, "%d", value);
2116 val = strndup(buf, PKG_VALUE_STRING_LEN_MAX - 1);
2118 _LOGE("Out of Memory\n");
2121 return PMINFO_R_ERROR;
2125 /*If API is called multiple times for same property, we should override the previous values.
2126 Last value set will be used for filtering.*/
2127 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2129 filter->list = g_slist_delete_link(filter->list, link);
2130 filter->list = g_slist_append(filter->list, (gpointer)node);
2135 API int pkgmgrinfo_appinfo_filter_add_bool(pkgmgrinfo_appinfo_filter_h handle,
2136 const char *property, const bool value)
2138 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2139 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2141 GSList *link = NULL;
2143 prop = _pminfo_appinfo_convert_to_prop_bool(property);
2144 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_BOOL ||
2145 prop > E_PMINFO_APPINFO_PROP_APP_MAX_BOOL) {
2146 _LOGE("Invalid Boolean Property\n");
2147 return PMINFO_R_EINVAL;
2149 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
2150 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
2152 _LOGE("Out of Memory!!!\n");
2153 return PMINFO_R_ERROR;
2156 val = strndup("('true','True')", 15);
2158 val = strndup("('false','False')", 17);
2160 _LOGE("Out of Memory\n");
2163 return PMINFO_R_ERROR;
2167 /*If API is called multiple times for same property, we should override the previous values.
2168 Last value set will be used for filtering.*/
2169 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2171 filter->list = g_slist_delete_link(filter->list, link);
2172 filter->list = g_slist_append(filter->list, (gpointer)node);
2177 API int pkgmgrinfo_appinfo_filter_add_string(pkgmgrinfo_appinfo_filter_h handle,
2178 const char *property, const char *value)
2180 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2181 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2182 retvm_if(value == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2184 pkgmgrinfo_node_x *ptr = NULL;
2185 char prev[PKG_STRING_LEN_MAX] = {'\0'};
2186 char temp[PKG_STRING_LEN_MAX] = {'\0'};
2187 GSList *link = NULL;
2189 prop = _pminfo_appinfo_convert_to_prop_str(property);
2190 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_STR ||
2191 prop > E_PMINFO_APPINFO_PROP_APP_MAX_STR) {
2192 _LOGE("Invalid String Property\n");
2193 return PMINFO_R_EINVAL;
2195 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
2196 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
2198 _LOGE("Out of Memory!!!\n");
2199 return PMINFO_R_ERROR;
2203 case E_PMINFO_APPINFO_PROP_APP_COMPONENT:
2204 if (strcmp(value, PMINFO_APPINFO_UI_APP) == 0)
2205 val = strndup("uiapp", PKG_STRING_LEN_MAX - 1);
2207 val = strndup("svcapp", PKG_STRING_LEN_MAX - 1);
2209 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2211 filter->list = g_slist_delete_link(filter->list, link);
2212 filter->list = g_slist_append(filter->list, (gpointer)node);
2214 case E_PMINFO_APPINFO_PROP_APP_CATEGORY:
2215 case E_PMINFO_APPINFO_PROP_APP_OPERATION:
2216 case E_PMINFO_APPINFO_PROP_APP_URI:
2217 case E_PMINFO_APPINFO_PROP_APP_MIME:
2218 val = (char *)calloc(1, PKG_STRING_LEN_MAX);
2220 _LOGE("Out of Memory\n");
2223 return PMINFO_R_ERROR;
2225 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2227 ptr = (pkgmgrinfo_node_x *)link->data;
2228 strncpy(prev, ptr->value, PKG_STRING_LEN_MAX - 1);
2229 _LOGE("Previous value is %s\n", prev);
2230 filter->list = g_slist_delete_link(filter->list, link);
2231 snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s , '%s'", prev, value);
2232 strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
2233 _LOGE("New value is %s\n", val);
2235 filter->list = g_slist_append(filter->list, (gpointer)node);
2236 memset(temp, '\0', PKG_STRING_LEN_MAX);
2238 snprintf(temp, PKG_STRING_LEN_MAX - 1, "'%s'", value);
2239 strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
2240 _LOGE("First value is %s\n", val);
2242 filter->list = g_slist_append(filter->list, (gpointer)node);
2243 memset(temp, '\0', PKG_STRING_LEN_MAX);
2247 node->value = strndup(value, PKG_STRING_LEN_MAX - 1);
2248 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2250 filter->list = g_slist_delete_link(filter->list, link);
2251 filter->list = g_slist_append(filter->list, (gpointer)node);
2257 API int pkgmgrinfo_appinfo_usr_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count, uid_t uid)
2262 if (handle == NULL || count == NULL) {
2263 _LOGE("invalid parameter");
2264 return PMINFO_R_EINVAL;
2267 ret = _appinfo_get_filtered_list(handle, uid, &list);
2268 if (ret != PMINFO_R_OK)
2269 return PMINFO_R_ERROR;
2271 *count = g_list_length(list);
2273 g_list_free_full(list, free);
2278 API int pkgmgrinfo_appinfo_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count)
2280 return pkgmgrinfo_appinfo_usr_filter_count(handle, count, GLOBAL_USER);
2283 API int pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(
2284 pkgmgrinfo_appinfo_filter_h handle,
2285 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
2287 if (handle == NULL || app_cb == NULL) {
2288 LOGE("invalid parameter");
2289 return PMINFO_R_EINVAL;
2292 return _appinfo_get_filtered_foreach_appinfo(uid, handle, app_cb,
2296 API int pkgmgrinfo_appinfo_filter_foreach_appinfo(pkgmgrinfo_appinfo_filter_h handle,
2297 pkgmgrinfo_app_list_cb app_cb, void * user_data)
2299 return pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(handle, app_cb, user_data, GLOBAL_USER);
2302 API int pkgmgrinfo_appinfo_metadata_filter_create(pkgmgrinfo_appinfo_metadata_filter_h *handle)
2304 return (pkgmgrinfo_pkginfo_filter_create(handle));
2307 API int pkgmgrinfo_appinfo_metadata_filter_destroy(pkgmgrinfo_appinfo_metadata_filter_h handle)
2309 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
2312 API int pkgmgrinfo_appinfo_metadata_filter_add(
2313 pkgmgrinfo_appinfo_metadata_filter_h handle,
2314 const char *key, const char *value)
2318 ret = pkgmgrinfo_appinfo_filter_add_string(handle,
2319 PMINFO_APPINFO_PROP_APP_METADATA_KEY, key);
2320 if (ret != PMINFO_R_OK)
2323 /* value can be NULL.
2324 * In that case all apps with specified key should be displayed
2327 ret = pkgmgrinfo_appinfo_filter_add_string(handle,
2328 PMINFO_APPINFO_PROP_APP_METADATA_VALUE, value);
2329 if (ret != PMINFO_R_OK)
2336 API int pkgmgrinfo_appinfo_usr_metadata_filter_foreach(
2337 pkgmgrinfo_appinfo_metadata_filter_h handle,
2338 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
2340 if (handle == NULL || app_cb == NULL) {
2341 LOGE("invalid parameter");
2342 return PMINFO_R_EINVAL;
2345 return _appinfo_get_filtered_foreach_appinfo(uid, handle, app_cb,
2349 API int pkgmgrinfo_appinfo_metadata_filter_foreach(
2350 pkgmgrinfo_appinfo_metadata_filter_h handle,
2351 pkgmgrinfo_app_list_cb app_cb, void *user_data)
2353 return pkgmgrinfo_appinfo_usr_metadata_filter_foreach(handle, app_cb,
2354 user_data, GLOBAL_USER);
2357 API int pkgmgrinfo_appinfo_is_guestmode_visibility(pkgmgrinfo_appinfo_h handle, bool *status)
2360 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2362 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2363 retvm_if(status == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2365 val = info->app_info->guestmode_visibility;
2366 *status = _get_bool_value(val);