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;
31 pkgmgr_appinfo_x *tmp;
33 while (info != NULL) {
36 free((void *)info->package);
38 free((void *)info->locale);
40 pkgmgrinfo_basic_free_application(info->app_info);
47 static char *_get_filtered_query(const char *query_raw,
48 pkgmgrinfo_filter_x *filter)
50 char buf[MAX_QUERY_LEN] = { 0, };
59 strncat(buf, query_raw, MAX_QUERY_LEN - 1);
61 for (list = head; list; list = list->next) {
62 /* TODO: revise condition getter function */
63 __get_filter_condition(list->data, &condition);
64 if (condition == NULL)
66 if (buf[strlen(query_raw)] == '\0') {
67 len += strlen(" WHERE ");
68 strncat(buf, " WHERE ", MAX_QUERY_LEN - len - 1);
70 len += strlen(" AND ");
71 strncat(buf, " AND ", MAX_QUERY_LEN -len - 1);
73 len += strlen(condition);
74 strncat(buf, condition, sizeof(buf) - len - 1);
82 static gint __list_strcmp(gconstpointer a, gconstpointer b)
84 return strcmp((char *)a, (char *)b);
87 static gint _appinfo_get_list(sqlite3 *db, const char *locale,
88 pkgmgrinfo_filter_x *filter, GList **list)
90 static const char query_raw[] =
91 "SELECT DISTINCT package_app_info.app_id FROM package_app_info"
92 " LEFT OUTER JOIN package_app_localized_info"
93 " ON package_app_info.app_id=package_app_localized_info.app_id"
94 " AND package_app_localized_info.app_locale=%Q"
95 " LEFT OUTER JOIN package_app_app_category"
96 " ON package_app_info.app_id=package_app_app_category.app_id"
97 " LEFT OUTER JOIN package_app_app_control"
98 " ON package_app_info.app_id=package_app_app_control.app_id"
99 " LEFT OUTER JOIN package_app_app_metadata"
100 " ON package_app_info.app_id=package_app_app_metadata.app_id ";
103 char *query_localized;
107 query = _get_filtered_query(query_raw, filter);
109 return PMINFO_R_ERROR;
110 query_localized = sqlite3_mprintf(query, locale);
112 if (query_localized == NULL)
113 return PMINFO_R_ERROR;
115 ret = sqlite3_prepare_v2(db, query_localized,
116 strlen(query_localized), &stmt, NULL);
117 sqlite3_free(query_localized);
118 if (ret != SQLITE_OK) {
119 LOGE("prepare failed: %s", sqlite3_errmsg(db));
120 return PMINFO_R_ERROR;
123 while (sqlite3_step(stmt) == SQLITE_ROW) {
124 _save_column_str(stmt, 0, (const char **)&appid);
126 *list = g_list_insert_sorted(*list, appid,
130 sqlite3_finalize(stmt);
135 static int _appinfo_get_filtered_list(pkgmgrinfo_filter_x *filter, uid_t uid,
145 locale = _get_system_locale();
147 return PMINFO_R_ERROR;
149 dbpath = getUserPkgParserDBPathUID(uid);
150 if (dbpath == NULL) {
152 return PMINFO_R_ERROR;
155 ret = sqlite3_open_v2(dbpath, &db, SQLITE_OPEN_READONLY, NULL);
156 if (ret != SQLITE_OK) {
157 _LOGE("failed to open db: %d", ret);
159 return PMINFO_R_ERROR;
162 if (_appinfo_get_list(db, locale, filter, list)) {
164 sqlite3_close_v2(db);
165 return PMINFO_R_ERROR;
167 sqlite3_close_v2(db);
169 if (uid == GLOBAL_USER) {
174 /* search again from global */
175 dbpath = getUserPkgParserDBPathUID(GLOBAL_USER);
176 if (dbpath == NULL) {
178 return PMINFO_R_ERROR;
181 ret = sqlite3_open_v2(dbpath, &db, SQLITE_OPEN_READONLY, NULL);
182 if (ret != SQLITE_OK) {
183 _LOGE("failed to open db: %d", ret);
185 return PMINFO_R_ERROR;
188 if (_appinfo_get_list(db, locale, filter, list)) {
190 sqlite3_close_v2(db);
191 return PMINFO_R_ERROR;
193 sqlite3_close_v2(db);
195 /* remove duplicate element:
196 * since the list is sorted, we can remove duplicates in linear time
198 for (tmp = *list, tmp2 = g_list_next(tmp); tmp;
199 tmp = tmp2, tmp2 = g_list_next(tmp)) {
200 if (tmp->prev == NULL || tmp->data == NULL)
202 if (strcmp((const char *)tmp->prev->data,
203 (const char *)tmp->data) == 0)
204 *list = g_list_delete_link(*list, tmp);
212 static int _appinfo_get_label(sqlite3 *db, const char *appid,
213 const char *locale, GList **label)
215 static const char query_raw[] =
216 "SELECT app_label, app_locale "
217 "FROM package_app_localized_info "
218 "WHERE app_id=%Q AND app_locale IN (%Q, %Q)";
225 query = sqlite3_mprintf(query_raw, appid, locale, DEFAULT_LOCALE);
227 LOGE("out of memory");
228 return PMINFO_R_ERROR;
231 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
233 if (ret != SQLITE_OK) {
234 LOGE("prepare failed: %s", sqlite3_errmsg(db));
235 return PMINFO_R_ERROR;
238 while (sqlite3_step(stmt) == SQLITE_ROW) {
239 info = calloc(1, sizeof(label_x));
241 LOGE("out of memory");
242 sqlite3_finalize(stmt);
243 return PMINFO_R_ERROR;
246 _save_column_str(stmt, idx++, &info->text);
247 _save_column_str(stmt, idx++, &info->lang);
248 *label = g_list_append(*label, info);
251 sqlite3_finalize(stmt);
256 static int _appinfo_get_icon(sqlite3 *db, const char *appid, const char *locale,
259 static const char query_raw[] =
260 "SELECT app_icon, app_locale "
261 "FROM package_app_localized_info "
262 "WHERE app_id=%Q AND app_locale IN (%Q, %Q)";
269 query = sqlite3_mprintf(query_raw, appid, locale, DEFAULT_LOCALE);
271 LOGE("out of memory");
272 return PMINFO_R_ERROR;
275 ret = sqlite3_prepare_v2(db, query, strlen(query),
278 if (ret != SQLITE_OK) {
279 LOGE("prepare failed: %s", sqlite3_errmsg(db));
280 return PMINFO_R_ERROR;
283 while (sqlite3_step(stmt) == SQLITE_ROW) {
284 info = calloc(1, sizeof(icon_x));
286 LOGE("out of memory");
287 sqlite3_finalize(stmt);
288 return PMINFO_R_ERROR;
291 _save_column_str(stmt, idx++, &info->text);
292 _save_column_str(stmt, idx++, &info->lang);
293 *icon = g_list_append(*icon, info);
296 sqlite3_finalize(stmt);
301 static int _appinfo_get_category(sqlite3 *db, const char *appid,
304 static const char query_raw[] =
305 "SELECT category FROM package_app_app_category WHERE app_id=%Q";
311 query = sqlite3_mprintf(query_raw, appid);
313 LOGE("out of memory");
314 return PMINFO_R_ERROR;
317 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
319 if (ret != SQLITE_OK) {
320 LOGE("prepare failed: %s", sqlite3_errmsg(db));
321 return PMINFO_R_ERROR;
324 while (sqlite3_step(stmt) == SQLITE_ROW) {
326 _save_column_str(stmt, 0, &val);
328 *category = g_list_append(*category, (gpointer)val);
331 sqlite3_finalize(stmt);
336 static void __parse_appcontrol(GList **appcontrol, char *appcontrol_str)
343 if (appcontrol_str == NULL)
346 dup = strdup(appcontrol_str);
348 ac = calloc(1, sizeof(appcontrol_x));
350 _LOGE("out of memory");
353 token = strtok_r(dup, "|", &ptr);
354 if (token && strcmp(token, "NULL"))
355 ac->operation = strdup(token);
356 token = strtok_r(NULL, "|", &ptr);
357 if (token && strcmp(token, "NULL"))
358 ac->uri = strdup(token);
359 token = strtok_r(NULL, "|", &ptr);
360 if (token && strcmp(token, "NULL"))
361 ac->mime = strdup(token);
362 *appcontrol = g_list_append(*appcontrol, ac);
363 } while ((token = strtok_r(NULL, ";", &ptr)));
368 static int _appinfo_get_app_control(sqlite3 *db, const char *appid,
371 static const char query_raw[] =
372 "SELECT app_control FROM package_app_app_control "
379 query = sqlite3_mprintf(query_raw, appid);
381 LOGE("out of memory");
382 return PMINFO_R_ERROR;
385 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
387 if (ret != SQLITE_OK) {
388 LOGE("prepare failed: %s", sqlite3_errmsg(db));
389 return PMINFO_R_ERROR;
392 while (sqlite3_step(stmt) == SQLITE_ROW) {
394 _save_column_str(stmt, 0, (const char **)&str);
396 __parse_appcontrol(appcontrol, str);
400 sqlite3_finalize(stmt);
405 static int _appinfo_get_data_control(sqlite3 *db, const char *appid,
408 static const char query_raw[] =
409 "SELECT providerid, access, type "
410 "FROM package_app_data_control WHERE app_id=%Q";
417 query = sqlite3_mprintf(query_raw, appid);
419 LOGE("out of memory");
420 return PMINFO_R_ERROR;
423 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
425 if (ret != SQLITE_OK) {
426 LOGE("prepare failed: %s", sqlite3_errmsg(db));
427 return PMINFO_R_ERROR;
430 while (sqlite3_step(stmt) == SQLITE_ROW) {
431 info = calloc(1, sizeof(datacontrol_x));
433 LOGE("out of memory");
434 sqlite3_finalize(stmt);
435 return PMINFO_R_ERROR;
438 _save_column_str(stmt, idx++, &info->providerid);
439 _save_column_str(stmt, idx++, &info->access);
440 _save_column_str(stmt, idx++, &info->type);
441 *datacontrol = g_list_append(*datacontrol, info);
444 sqlite3_finalize(stmt);
449 static int _appinfo_get_metadata(sqlite3 *db, const char *appid,
452 static const char query_raw[] =
453 "SELECT md_key, md_value "
454 "FROM package_app_app_metadata WHERE app_id=%Q";
461 query = sqlite3_mprintf(query_raw, appid);
463 LOGE("out of memory");
464 return PMINFO_R_ERROR;
467 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
469 if (ret != SQLITE_OK) {
470 LOGE("prepare failed: %s", sqlite3_errmsg(db));
471 return PMINFO_R_ERROR;
474 while (sqlite3_step(stmt) == SQLITE_ROW) {
475 info = calloc(1, sizeof(metadata_x));
477 LOGE("out of memory");
478 sqlite3_finalize(stmt);
479 return PMINFO_R_ERROR;
482 _save_column_str(stmt, idx++, &info->key);
483 _save_column_str(stmt, idx++, &info->value);
484 *metadata = g_list_append(*metadata, info);
487 sqlite3_finalize(stmt);
493 static int _appinfo_get_application(sqlite3 *db, const char *appid,
494 const char *locale, application_x **application)
496 static const char query_raw[] =
497 "SELECT app_id, app_component, app_exec, app_nodisplay, "
498 "app_type, app_onboot, app_multiple, app_autorestart, "
499 "app_taskmanage, app_enabled, app_hwacceleration, "
500 "app_screenreader, app_mainapp, app_recentimage, "
501 "app_launchcondition, app_indicatordisplay, app_portraitimg, "
502 "app_landscapeimg, app_guestmodevisibility, "
503 "app_permissiontype, app_preload, app_submode, "
504 "app_submode_mainid, app_launch_mode, app_ui_gadget, "
505 "app_support_disable, "
506 "component_type, package "
507 "FROM package_app_info WHERE app_id=%Q";
514 query = sqlite3_mprintf(query_raw, appid);
516 LOGE("out of memory");
517 return PMINFO_R_ERROR;
520 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
522 if (ret != SQLITE_OK) {
523 LOGE("prepare failed: %s", sqlite3_errmsg(db));
524 return PMINFO_R_ERROR;
527 ret = sqlite3_step(stmt);
528 if (ret == SQLITE_DONE) {
529 sqlite3_finalize(stmt);
530 return PMINFO_R_ENOENT;
531 } else if (ret != SQLITE_ROW) {
532 LOGE("step failed: %s", sqlite3_errmsg(db));
533 sqlite3_finalize(stmt);
534 return PMINFO_R_ERROR;
537 info = calloc(1, sizeof(application_x));
539 LOGE("out of memory");
540 sqlite3_finalize(stmt);
541 return PMINFO_R_ERROR;
544 _save_column_str(stmt, idx++, &info->appid);
545 _save_column_str(stmt, idx++, &info->component);
546 _save_column_str(stmt, idx++, &info->exec);
547 _save_column_str(stmt, idx++, &info->nodisplay);
548 _save_column_str(stmt, idx++, &info->type);
549 _save_column_str(stmt, idx++, &info->onboot);
550 _save_column_str(stmt, idx++, &info->multiple);
551 _save_column_str(stmt, idx++, &info->autorestart);
552 _save_column_str(stmt, idx++, &info->taskmanage);
553 _save_column_str(stmt, idx++, &info->enabled);
554 _save_column_str(stmt, idx++, &info->hwacceleration);
555 _save_column_str(stmt, idx++, &info->screenreader);
556 _save_column_str(stmt, idx++, &info->mainapp);
557 _save_column_str(stmt, idx++, &info->recentimage);
558 _save_column_str(stmt, idx++, &info->launchcondition);
559 _save_column_str(stmt, idx++, &info->indicatordisplay);
560 _save_column_str(stmt, idx++, &info->portraitimg);
561 _save_column_str(stmt, idx++, &info->landscapeimg);
562 _save_column_str(stmt, idx++, &info->guestmode_visibility);
563 _save_column_str(stmt, idx++, &info->permission_type);
564 _save_column_str(stmt, idx++, &info->preload);
565 _save_column_str(stmt, idx++, &info->submode);
566 _save_column_str(stmt, idx++, &info->submode_mainid);
567 _save_column_str(stmt, idx++, &info->launch_mode);
568 _save_column_str(stmt, idx++, &info->ui_gadget);
569 _save_column_str(stmt, idx++, &info->support_disable);
570 _save_column_str(stmt, idx++, &info->component_type);
571 _save_column_str(stmt, idx++, &info->package);
573 if (_appinfo_get_label(db, info->appid, locale, &info->label)) {
574 pkgmgrinfo_basic_free_application(info);
575 sqlite3_finalize(stmt);
576 return PMINFO_R_ERROR;
579 if (_appinfo_get_icon(db, info->appid, locale, &info->icon)) {
580 pkgmgrinfo_basic_free_application(info);
581 sqlite3_finalize(stmt);
582 return PMINFO_R_ERROR;
585 if (_appinfo_get_category(db, info->appid, &info->category)) {
586 pkgmgrinfo_basic_free_application(info);
587 sqlite3_finalize(stmt);
588 return PMINFO_R_ERROR;
591 if (_appinfo_get_app_control(db, info->appid, &info->appcontrol)) {
592 pkgmgrinfo_basic_free_application(info);
593 sqlite3_finalize(stmt);
594 return PMINFO_R_ERROR;
597 if (_appinfo_get_data_control(db, info->appid, &info->datacontrol)) {
598 pkgmgrinfo_basic_free_application(info);
599 sqlite3_finalize(stmt);
600 return PMINFO_R_ERROR;
603 if (_appinfo_get_metadata(db, info->appid, &info->metadata)) {
604 pkgmgrinfo_basic_free_application(info);
605 sqlite3_finalize(stmt);
606 return PMINFO_R_ERROR;
611 sqlite3_finalize(stmt);
616 static int _appinfo_get_appinfo(const char *appid, uid_t uid,
617 pkgmgr_appinfo_x **appinfo)
623 pkgmgr_appinfo_x *info;
625 dbpath = getUserPkgParserDBPathUID(uid);
627 return PMINFO_R_ERROR;
629 locale = _get_system_locale();
631 return PMINFO_R_ERROR;
633 ret = sqlite3_open_v2(dbpath, &db, SQLITE_OPEN_READONLY, NULL);
634 if (ret != SQLITE_OK) {
635 _LOGE("failed to open db: %d", ret);
637 return PMINFO_R_ERROR;
640 info = calloc(1, sizeof(pkgmgr_appinfo_x));
642 _LOGE("out of memory");
644 sqlite3_close_v2(db);
645 return PMINFO_R_ERROR;
648 ret = _appinfo_get_application(db, appid, locale, &info->app_info);
649 if (ret != PMINFO_R_OK) {
652 sqlite3_close_v2(db);
656 info->locale = locale;
657 info->package = strdup(info->app_info->package);
661 sqlite3_close_v2(db);
666 API int pkgmgrinfo_appinfo_get_usr_appinfo(const char *appid, uid_t uid,
667 pkgmgrinfo_appinfo_h *handle)
671 if (appid == NULL || handle == NULL) {
672 LOGE("invalid parameter");
673 return PMINFO_R_EINVAL;
676 ret = _appinfo_get_appinfo(appid, uid, (pkgmgr_appinfo_x **)handle);
677 if (ret == PMINFO_R_ENOENT && uid != GLOBAL_USER)
678 ret = _appinfo_get_appinfo(appid, GLOBAL_USER,
679 (pkgmgr_appinfo_x **)handle);
681 if (ret != PMINFO_R_OK)
682 _LOGE("failed to get appinfo of %s for user %d", appid, uid);
687 API int pkgmgrinfo_appinfo_get_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
689 return pkgmgrinfo_appinfo_get_usr_appinfo(appid, GLOBAL_USER, handle);
692 static int _appinfo_get_filtered_foreach_appinfo(uid_t uid,
693 pkgmgrinfo_filter_x *filter, pkgmgrinfo_app_list_cb app_list_cb,
697 pkgmgr_appinfo_x *info;
703 ret = _appinfo_get_filtered_list(filter, uid, &list);
704 if (ret != PMINFO_R_OK)
705 return PMINFO_R_ERROR;
707 for (tmp = list; tmp; tmp = tmp->next) {
708 appid = (char *)tmp->data;
710 ret = _appinfo_get_appinfo(appid, uid, &info);
711 if (ret == PMINFO_R_ENOENT && uid != GLOBAL_USER)
712 ret = _appinfo_get_appinfo(appid, GLOBAL_USER,
714 if (ret != PMINFO_R_OK) {
718 if (app_list_cb(info, user_data) < 0)
720 pkgmgrinfo_appinfo_destroy_appinfo(info);
730 API int pkgmgrinfo_appinfo_get_usr_list(pkgmgrinfo_pkginfo_h handle,
731 pkgmgrinfo_app_component component,
732 pkgmgrinfo_app_list_cb app_func, void *user_data, uid_t uid)
735 pkgmgrinfo_appinfo_filter_h filter;
737 const char *comp_str = NULL;
739 if (handle == NULL || app_func == NULL) {
740 LOGE("invalied parameter");
741 return PMINFO_R_EINVAL;
744 if (pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid)) {
745 LOGE("invalid parameter");
746 return PMINFO_R_EINVAL;
749 if (pkgmgrinfo_appinfo_filter_create(&filter))
750 return PMINFO_R_ERROR;
752 if (pkgmgrinfo_appinfo_filter_add_string(filter,
753 PMINFO_APPINFO_PROP_APP_PACKAGE, pkgid)) {
754 pkgmgrinfo_appinfo_filter_destroy(filter);
755 return PMINFO_R_ERROR;
761 comp_str = PMINFO_APPINFO_UI_APP;
764 comp_str = PMINFO_APPINFO_SVC_APP;
771 if (pkgmgrinfo_appinfo_filter_add_string(filter,
772 PMINFO_APPINFO_PROP_APP_COMPONENT,
774 pkgmgrinfo_appinfo_filter_destroy(filter);
775 return PMINFO_R_ERROR;
779 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter, app_func,
782 pkgmgrinfo_appinfo_filter_destroy(filter);
787 API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_component component,
788 pkgmgrinfo_app_list_cb app_func, void *user_data)
790 return pkgmgrinfo_appinfo_get_usr_list(handle, component, app_func, user_data, GLOBAL_USER);
793 API int pkgmgrinfo_appinfo_get_usr_install_list(pkgmgrinfo_app_list_cb app_func, uid_t uid, void *user_data)
795 if (app_func == NULL) {
796 LOGE("invalid parameter");
797 return PMINFO_R_EINVAL;
800 return _appinfo_get_filtered_foreach_appinfo(uid, NULL, app_func,
804 API int pkgmgrinfo_appinfo_get_install_list(pkgmgrinfo_app_list_cb app_func, void *user_data)
806 return pkgmgrinfo_appinfo_get_usr_install_list(app_func, GLOBAL_USER, user_data);
809 API int pkgmgrinfo_appinfo_get_usr_installed_list(pkgmgrinfo_app_list_cb app_func, uid_t uid, void *user_data)
811 if (app_func == NULL) {
812 LOGE("invalid parameter");
813 return PMINFO_R_EINVAL;
816 return _appinfo_get_filtered_foreach_appinfo(uid, NULL, app_func,
820 API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func, void *user_data)
822 return pkgmgrinfo_appinfo_get_usr_installed_list(app_func, GLOBAL_USER, user_data);
825 API int pkgmgrinfo_appinfo_get_appid(pkgmgrinfo_appinfo_h handle, char **appid)
827 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
829 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
830 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
832 if (info->app_info == NULL || info->app_info->appid == NULL)
833 return PMINFO_R_ERROR;
834 *appid = (char *)info->app_info->appid;
839 API int pkgmgrinfo_appinfo_get_pkgname(pkgmgrinfo_appinfo_h handle, char **pkg_name)
841 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
843 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
844 retvm_if(pkg_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
846 if (info->package == NULL)
847 return PMINFO_R_ERROR;
849 *pkg_name = (char *)info->package;
854 API int pkgmgrinfo_appinfo_get_pkgid(pkgmgrinfo_appinfo_h handle, char **pkgid)
856 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
858 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
859 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
861 if (info->package == NULL)
862 return PMINFO_R_ERROR;
864 *pkgid = (char *)info->package;
869 API int pkgmgrinfo_appinfo_get_exec(pkgmgrinfo_appinfo_h handle, char **exec)
871 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
873 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
874 retvm_if(exec == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
876 if (info->app_info == NULL || info->app_info->exec == NULL)
877 return PMINFO_R_ERROR;
878 *exec = (char *)info->app_info->exec;
884 API int pkgmgrinfo_appinfo_get_icon(pkgmgrinfo_appinfo_h handle, char **icon)
889 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
891 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
892 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
894 locale = info->locale;
895 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
897 if (info->app_info == NULL)
898 return PMINFO_R_ERROR;
900 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
901 ptr = (icon_x *)tmp->data;
902 if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL ||
903 strcmp(ptr->lang, locale))
905 *icon = (char *)ptr->text;
909 locale = DEFAULT_LOCALE;
910 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
911 ptr = (icon_x *)tmp->data;
912 if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL ||
913 strcmp(ptr->lang, locale))
915 *icon = (char *)ptr->text;
919 return PMINFO_R_ERROR;
923 API int pkgmgrinfo_appinfo_get_label(pkgmgrinfo_appinfo_h handle, char **label)
928 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
930 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
931 retvm_if(label == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
933 locale = info->locale;
934 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
936 if (info->app_info == NULL)
937 return PMINFO_R_ERROR;
939 for (tmp = info->app_info->label; tmp; tmp = tmp->next) {
940 ptr = (label_x *)tmp->data;
941 if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL ||
942 strcmp(ptr->lang, locale))
944 *label = (char *)ptr->text;
948 locale = DEFAULT_LOCALE;
949 for (tmp = info->app_info->label; tmp; tmp = tmp->next) {
950 ptr = (label_x *)tmp->data;
951 if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL ||
952 strcmp(ptr->lang, locale))
954 *label = (char *)ptr->text;
958 return PMINFO_R_ERROR;
961 static char *_get_localed_label(const char *appid, const char *locale, uid_t uid)
965 sqlite3_stmt *stmt = NULL;
968 const char *manifest_db;
970 manifest_db = getUserPkgParserDBPathUID(uid);
971 if (manifest_db == NULL) {
972 _LOGE("Failed to get manifest db path");
976 if (sqlite3_open_v2(manifest_db, &db, SQLITE_OPEN_READONLY, NULL) != SQLITE_OK) {
977 _LOGE("DB open fail\n");
981 query = sqlite3_mprintf("select app_label from package_app_localized_info where app_id=%Q and app_locale=%Q", appid, locale);
983 _LOGE("Out of memory");
987 if (sqlite3_prepare_v2(db, query, -1, &stmt, NULL) != SQLITE_OK) {
988 _LOGE("prepare_v2 fail\n");
992 if (sqlite3_step(stmt) == SQLITE_ROW) {
993 val = (char *)sqlite3_column_text(stmt, 0);
995 result = strdup(val);
999 sqlite3_finalize(stmt);
1000 sqlite3_free(query);
1006 API int pkgmgrinfo_appinfo_usr_get_localed_label(const char *appid, const char *locale, uid_t uid, char **label)
1010 retvm_if(appid == NULL || locale == NULL || label == NULL, PMINFO_R_EINVAL, "Argument is NULL");
1012 val = _get_localed_label(appid, locale, uid);
1014 val = _get_localed_label(appid, DEFAULT_LOCALE, uid);
1017 return PMINFO_R_ERROR;
1024 API int pkgmgrinfo_appinfo_get_localed_label(const char *appid, const char *locale, char **label)
1026 return pkgmgrinfo_appinfo_usr_get_localed_label(appid, locale, GLOBAL_USER, label);
1029 static pkgmgrinfo_app_component __appcomponent_convert(const char *comp)
1031 if ( strcasecmp(comp, "uiapp") == 0)
1032 return PMINFO_UI_APP;
1033 else if ( strcasecmp(comp, "svcapp") == 0)
1034 return PMINFO_SVC_APP;
1039 API int pkgmgrinfo_appinfo_get_component(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_component *component)
1041 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1044 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1045 retvm_if(component == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1047 if (info->app_info == NULL)
1048 return PMINFO_R_ERROR;
1050 comp = __appcomponent_convert(info->app_info->component);
1052 return PMINFO_R_ERROR;
1059 API int pkgmgrinfo_appinfo_get_apptype(pkgmgrinfo_appinfo_h handle, char **app_type)
1061 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1063 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1064 retvm_if(app_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1066 if (info->app_info == NULL || info->app_info->type == NULL)
1067 return PMINFO_R_ERROR;
1068 *app_type = (char *)info->app_info->type;
1073 API int pkgmgrinfo_appinfo_get_operation(pkgmgrinfo_appcontrol_h handle,
1074 int *operation_count, char ***operation)
1076 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1077 retvm_if(operation == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1078 retvm_if(operation_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1079 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1080 *operation_count = data->operation_count;
1081 *operation = data->operation;
1085 API int pkgmgrinfo_appinfo_get_uri(pkgmgrinfo_appcontrol_h handle,
1086 int *uri_count, char ***uri)
1088 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1089 retvm_if(uri == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1090 retvm_if(uri_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1091 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1092 *uri_count = data->uri_count;
1097 API int pkgmgrinfo_appinfo_get_mime(pkgmgrinfo_appcontrol_h handle,
1098 int *mime_count, char ***mime)
1100 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1101 retvm_if(mime == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1102 retvm_if(mime_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1103 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1104 *mime_count = data->mime_count;
1109 API int pkgmgrinfo_appinfo_get_subapp(pkgmgrinfo_appcontrol_h handle,
1110 int *subapp_count, char ***subapp)
1112 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1113 retvm_if(subapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1114 retvm_if(subapp_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1115 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1116 *subapp_count = data->subapp_count;
1117 *subapp = data->subapp;
1121 API int pkgmgrinfo_appinfo_get_setting_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1126 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1128 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1129 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1131 if (info->app_info == NULL)
1132 return PMINFO_R_ERROR;
1134 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1135 ptr = (icon_x *)tmp->data;
1136 if (ptr == NULL || ptr->section == NULL)
1139 val = (char *)ptr->section;
1140 if (val && strcmp(val, "setting") == 0) {
1141 *icon = (char *)ptr->text;
1146 return PMINFO_R_ERROR;
1150 API int pkgmgrinfo_appinfo_get_notification_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1155 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1157 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1158 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1160 if (info->app_info == NULL)
1161 return PMINFO_R_ERROR;
1163 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1164 ptr = (icon_x *)tmp->data;
1165 if (ptr == NULL || ptr->section == NULL)
1168 val = (char *)ptr->section;
1169 if (val && strcmp(val, "notification") == 0){
1170 *icon = (char *)ptr->text;
1175 return PMINFO_R_ERROR;
1178 API int pkgmgrinfo_appinfo_get_recent_image_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_recentimage *type)
1181 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1183 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1184 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1186 if (info->app_info == NULL || info->app_info->recentimage == NULL)
1187 return PMINFO_R_ERROR;
1189 val = (char *)info->app_info->recentimage;
1190 if (strcasecmp(val, "capture") == 0)
1191 *type = PMINFO_RECENTIMAGE_USE_CAPTURE;
1192 else if (strcasecmp(val, "icon") == 0)
1193 *type = PMINFO_RECENTIMAGE_USE_ICON;
1195 *type = PMINFO_RECENTIMAGE_USE_NOTHING;
1200 API int pkgmgrinfo_appinfo_get_preview_image(pkgmgrinfo_appinfo_h handle, char **preview_img)
1205 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1207 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1208 retvm_if(preview_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1210 if (info->app_info == NULL)
1211 return PMINFO_R_ERROR;
1213 for (tmp = info->app_info->image; tmp; tmp = tmp->next) {
1214 ptr = (image_x *)tmp->data;
1215 if (ptr == NULL || ptr->section == NULL)
1218 val = (char *)ptr->section;
1219 if (val && strcmp(val, "preview") == 0) {
1220 *preview_img = (char *)ptr->text;
1225 return PMINFO_R_ERROR;
1228 API int pkgmgrinfo_appinfo_get_permission_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_permission_type *permission)
1231 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1233 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1234 retvm_if(permission == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1236 val = info->app_info->permission_type;
1238 return PMINFO_R_ERROR;
1240 if (strcmp(val, "signature") == 0)
1241 *permission = PMINFO_PERMISSION_SIGNATURE;
1242 else if (strcmp(val, "privilege") == 0)
1243 *permission = PMINFO_PERMISSION_PRIVILEGE;
1245 *permission = PMINFO_PERMISSION_NORMAL;
1250 API int pkgmgrinfo_appinfo_get_component_type(pkgmgrinfo_appinfo_h handle, char **component_type)
1252 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1254 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1255 retvm_if(component_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1257 if (info->app_info == NULL || info->app_info->component_type == NULL)
1258 return PMINFO_R_ERROR;
1260 *component_type = (char *)info->app_info->component_type;
1265 API int pkgmgrinfo_appinfo_get_hwacceleration(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_hwacceleration *hwacceleration)
1268 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1270 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1271 retvm_if(hwacceleration == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1273 if (info->app_info == NULL || info->app_info->hwacceleration == NULL)
1274 return PMINFO_R_ERROR;
1276 val = (char *)info->app_info->hwacceleration;
1277 if (strcasecmp(val, "not-use-GL") == 0)
1278 *hwacceleration = PMINFO_HWACCELERATION_NOT_USE_GL;
1279 else if (strcasecmp(val, "use-GL") == 0)
1280 *hwacceleration = PMINFO_HWACCELERATION_USE_GL;
1282 *hwacceleration = PMINFO_HWACCELERATION_USE_SYSTEM_SETTING;
1287 API int pkgmgrinfo_appinfo_get_screenreader(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_screenreader *screenreader)
1290 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1292 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1293 retvm_if(screenreader == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1295 if (info->app_info == NULL || info->app_info->screenreader == NULL)
1296 return PMINFO_R_ERROR;
1298 val = (char *)info->app_info->screenreader;
1299 if (strcasecmp(val, "screenreader-off") == 0)
1300 *screenreader = PMINFO_SCREENREADER_OFF;
1301 else if (strcasecmp(val, "screenreader-on") == 0)
1302 *screenreader = PMINFO_SCREENREADER_ON;
1304 *screenreader = PMINFO_SCREENREADER_USE_SYSTEM_SETTING;
1309 API int pkgmgrinfo_appinfo_get_effectimage(pkgmgrinfo_appinfo_h handle, char **portrait_img, char **landscape_img)
1311 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1313 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1314 retvm_if(portrait_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1315 retvm_if(landscape_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1317 if (info->app_info == NULL || info->app_info->portraitimg ||
1318 info->app_info->landscapeimg == NULL)
1319 return PMINFO_R_ERROR;
1321 *portrait_img = (char *)info->app_info->portraitimg;
1322 *landscape_img = (char *)info->app_info->landscapeimg;
1327 API int pkgmgrinfo_appinfo_get_submode_mainid(pkgmgrinfo_appinfo_h handle, char **submode_mainid)
1329 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1331 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1332 retvm_if(submode_mainid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1334 if (info->app_info == NULL || info->app_info->submode_mainid == NULL)
1335 return PMINFO_R_ERROR;
1337 *submode_mainid = (char *)info->app_info->submode_mainid;
1342 API int pkgmgrinfo_appinfo_get_launch_mode(pkgmgrinfo_appinfo_h handle, char **mode)
1344 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1346 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1347 retvm_if(mode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1349 if (info->app_info->launch_mode == NULL)
1350 return PMINFO_R_ERROR;
1352 *mode = (char *)(info->app_info->launch_mode);
1357 API int pkgmgrinfo_appinfo_usr_get_datacontrol_info(const char *providerid, const char *type, uid_t uid, char **appid, char **access)
1359 retvm_if(providerid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
1360 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
1361 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1362 retvm_if(access == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1364 int ret = PMINFO_R_OK;
1366 sqlite3_stmt *stmt = NULL;
1369 ret = __open_manifest_db(uid, true);
1370 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
1372 /*Start constructing query*/
1373 query = sqlite3_mprintf("select * from package_app_data_control where providerid=%Q and type=%Q", providerid, type);
1376 ret = sqlite3_prepare_v2(GET_DB(manifest_db), query, strlen(query), &stmt, NULL);
1377 tryvm_if(ret != PMINFO_R_OK, ret = PMINFO_R_ERROR, "sqlite3_prepare_v2 failed[%s]\n", query);
1380 ret = sqlite3_step(stmt);
1381 tryvm_if((ret != SQLITE_ROW) || (ret == SQLITE_DONE), ret = PMINFO_R_ERROR, "No records found");
1383 *appid = strdup((char *)sqlite3_column_text(stmt, 0));
1384 *access = strdup((char *)sqlite3_column_text(stmt, 2));
1389 sqlite3_free(query);
1390 sqlite3_finalize(stmt);
1391 __close_manifest_db();
1395 API int pkgmgrinfo_appinfo_get_datacontrol_info(const char *providerid, const char *type, char **appid, char **access)
1397 return pkgmgrinfo_appinfo_usr_get_datacontrol_info(providerid, type, GLOBAL_USER, appid, access);
1400 API int pkgmgrinfo_appinfo_usr_get_datacontrol_appid(const char *providerid, uid_t uid, char **appid)
1402 retvm_if(providerid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
1403 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1405 int ret = PMINFO_R_OK;
1407 sqlite3_stmt *stmt = NULL;
1410 ret = __open_manifest_db(uid, true);
1411 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
1413 /*Start constructing query*/
1414 query = sqlite3_mprintf("select * from package_app_data_control where providerid=%Q", providerid);
1417 ret = sqlite3_prepare_v2(GET_DB(manifest_db), query, strlen(query), &stmt, NULL);
1418 tryvm_if(ret != PMINFO_R_OK, ret = PMINFO_R_ERROR, "sqlite3_prepare_v2 failed[%s]\n", query);
1421 ret = sqlite3_step(stmt);
1422 tryvm_if((ret != SQLITE_ROW) || (ret == SQLITE_DONE), ret = PMINFO_R_ERROR, "No records found");
1424 *appid = strdup((char *)sqlite3_column_text(stmt, 0));
1429 sqlite3_free(query);
1430 sqlite3_finalize(stmt);
1431 __close_manifest_db();
1435 API int pkgmgrinfo_appinfo_get_datacontrol_appid(const char *providerid, char **appid)
1437 return pkgmgrinfo_appinfo_usr_get_datacontrol_appid(providerid, GLOBAL_USER, appid);
1440 API int pkgmgrinfo_appinfo_foreach_permission(pkgmgrinfo_appinfo_h handle,
1441 pkgmgrinfo_app_permission_list_cb permission_func, void *user_data)
1443 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1444 retvm_if(permission_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
1448 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1450 if (info->app_info == NULL)
1451 return PMINFO_R_ERROR;
1453 for (tmp = info->app_info->permission; tmp; tmp = tmp->next) {
1454 ptr = (permission_x *)tmp->data;
1458 ret = permission_func(ptr->value, user_data);
1466 API int pkgmgrinfo_appinfo_foreach_category(pkgmgrinfo_appinfo_h handle,
1467 pkgmgrinfo_app_category_list_cb category_func, void *user_data)
1469 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1470 retvm_if(category_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
1472 const char *category;
1474 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1476 if (info->app_info == NULL)
1477 return PMINFO_R_ERROR;
1479 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
1480 category = (const char *)tmp->data;
1482 ret = category_func(category, user_data);
1490 API int pkgmgrinfo_appinfo_foreach_metadata(pkgmgrinfo_appinfo_h handle,
1491 pkgmgrinfo_app_metadata_list_cb metadata_func, void *user_data)
1493 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1494 retvm_if(metadata_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
1498 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1500 if (info->app_info == NULL)
1501 return PMINFO_R_ERROR;
1503 for (tmp = info->app_info->metadata; tmp; tmp = tmp->next) {
1504 ptr = (metadata_x *)tmp->data;
1508 ret = metadata_func(ptr->key, ptr->value, user_data);
1516 API int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
1517 pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
1519 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1520 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
1522 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1523 appcontrol_x *appcontrol;
1526 if (info->app_info == NULL)
1527 return PMINFO_R_ERROR;
1529 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
1530 appcontrol = (appcontrol_x *)tmp->data;
1531 if (appcontrol == NULL)
1533 ret = appcontrol_func(appcontrol->operation, appcontrol->uri, appcontrol->mime, user_data);
1541 API int pkgmgrinfo_appinfo_is_nodisplay(pkgmgrinfo_appinfo_h handle, bool *nodisplay)
1543 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1544 retvm_if(nodisplay == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1545 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1547 if (info->app_info == NULL || info->app_info->nodisplay == NULL)
1548 return PMINFO_R_ERROR;
1550 *nodisplay = _get_bool_value(info->app_info->nodisplay);
1555 API int pkgmgrinfo_appinfo_is_multiple(pkgmgrinfo_appinfo_h handle, bool *multiple)
1557 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1558 retvm_if(multiple == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1559 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1561 if (info->app_info == NULL || info->app_info->multiple == NULL)
1562 return PMINFO_R_ERROR;
1564 *multiple = _get_bool_value(info->app_info->multiple);
1569 API int pkgmgrinfo_appinfo_is_indicator_display_allowed(pkgmgrinfo_appinfo_h handle, bool *indicator_disp)
1571 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1572 retvm_if(indicator_disp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1573 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1575 if (info->app_info == NULL || info->app_info->indicatordisplay == NULL)
1576 return PMINFO_R_ERROR;
1578 *indicator_disp = _get_bool_value(info->app_info->indicatordisplay);
1583 API int pkgmgrinfo_appinfo_is_taskmanage(pkgmgrinfo_appinfo_h handle, bool *taskmanage)
1585 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1586 retvm_if(taskmanage == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1587 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1589 if (info->app_info == NULL || info->app_info->taskmanage == NULL)
1590 return PMINFO_R_ERROR;
1592 *taskmanage = _get_bool_value(info->app_info->taskmanage);
1597 API int pkgmgrinfo_appinfo_is_enabled(pkgmgrinfo_appinfo_h handle, bool *enabled)
1599 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1600 retvm_if(enabled == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1601 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1603 if (info->app_info == NULL || info->app_info->enabled == NULL)
1604 return PMINFO_R_ERROR;
1606 *enabled = _get_bool_value(info->app_info->enabled);
1611 API int pkgmgrinfo_appinfo_is_onboot(pkgmgrinfo_appinfo_h handle, bool *onboot)
1613 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1614 retvm_if(onboot == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1615 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1617 if (info->app_info == NULL || info->app_info->onboot == NULL)
1618 return PMINFO_R_ERROR;
1620 *onboot = _get_bool_value(info->app_info->onboot);
1625 API int pkgmgrinfo_appinfo_is_autorestart(pkgmgrinfo_appinfo_h handle, bool *autorestart)
1627 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1628 retvm_if(autorestart == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1629 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1631 if (info->app_info == NULL || info->app_info->autorestart == NULL)
1632 return PMINFO_R_ERROR;
1634 *autorestart = _get_bool_value(info->app_info->autorestart);
1639 API int pkgmgrinfo_appinfo_is_mainapp(pkgmgrinfo_appinfo_h handle, bool *mainapp)
1641 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1642 retvm_if(mainapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1643 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1645 if (info->app_info == NULL || info->app_info->mainapp == NULL)
1646 return PMINFO_R_ERROR;
1648 *mainapp = _get_bool_value(info->app_info->mainapp);
1653 API int pkgmgrinfo_appinfo_is_preload(pkgmgrinfo_appinfo_h handle, bool *preload)
1655 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1656 retvm_if(preload == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1657 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1659 if (info->app_info == NULL || info->app_info->preload == NULL)
1660 return PMINFO_R_ERROR;
1662 *preload = _get_bool_value(info->app_info->preload);
1667 API int pkgmgrinfo_appinfo_is_submode(pkgmgrinfo_appinfo_h handle, bool *submode)
1669 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1670 retvm_if(submode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1671 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1673 if (info->app_info == NULL || info->app_info->submode == NULL)
1674 return PMINFO_R_ERROR;
1676 *submode = _get_bool_value(info->app_info->submode);
1681 API int pkgmgrinfo_appinfo_is_category_exist(pkgmgrinfo_appinfo_h handle, const char *category, bool *exist)
1683 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1684 retvm_if(category == NULL, PMINFO_R_EINVAL, "category is NULL");
1685 retvm_if(exist == NULL, PMINFO_R_EINVAL, "exist is NULL");
1689 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1691 if (info->app_info == NULL)
1692 return PMINFO_R_ERROR;
1695 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
1696 val = (const char *)tmp->data;
1699 if (strcasecmp(val, category) == 0) {
1708 API int pkgmgrinfo_appinfo_is_ui_gadget(pkgmgrinfo_appinfo_h handle,
1711 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1713 if (info == NULL || info->app_info == NULL || ui_gadget == NULL) {
1714 _LOGE("invalid parameter");
1715 return PMINFO_R_EINVAL;
1718 *ui_gadget = _get_bool_value(info->app_info->ui_gadget);
1723 API int pkgmgrinfo_appinfo_is_support_disable(pkgmgrinfo_appinfo_h handle,
1724 bool *support_disable)
1726 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1728 if (info == NULL || info->app_info == NULL || support_disable == NULL) {
1729 _LOGE("invalid parameter");
1730 return PMINFO_R_EINVAL;
1733 *support_disable = _get_bool_value(info->app_info->support_disable);
1738 API int pkgmgrinfo_appinfo_destroy_appinfo(pkgmgrinfo_appinfo_h handle)
1740 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1741 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1742 __cleanup_appinfo(info);
1746 API int pkgmgrinfo_appinfo_filter_create(pkgmgrinfo_appinfo_filter_h *handle)
1748 return (pkgmgrinfo_pkginfo_filter_create(handle));
1751 API int pkgmgrinfo_appinfo_filter_destroy(pkgmgrinfo_appinfo_filter_h handle)
1753 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
1756 static gint __compare_func(gconstpointer data1, gconstpointer data2)
1758 pkgmgrinfo_node_x *node1 = (pkgmgrinfo_node_x*)data1;
1759 pkgmgrinfo_node_x *node2 = (pkgmgrinfo_node_x*)data2;
1760 if (node1->prop == node2->prop)
1762 else if (node1->prop > node2->prop)
1768 API int pkgmgrinfo_appinfo_filter_add_int(pkgmgrinfo_appinfo_filter_h handle,
1769 const char *property, const int value)
1771 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
1772 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
1773 char buf[PKG_VALUE_STRING_LEN_MAX] = {'\0'};
1775 GSList *link = NULL;
1777 prop = _pminfo_appinfo_convert_to_prop_int(property);
1778 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_INT ||
1779 prop > E_PMINFO_APPINFO_PROP_APP_MAX_INT) {
1780 _LOGE("Invalid Integer Property\n");
1781 return PMINFO_R_EINVAL;
1783 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
1784 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
1786 _LOGE("Out of Memory!!!\n");
1787 return PMINFO_R_ERROR;
1789 snprintf(buf, PKG_VALUE_STRING_LEN_MAX - 1, "%d", value);
1790 val = strndup(buf, PKG_VALUE_STRING_LEN_MAX - 1);
1792 _LOGE("Out of Memory\n");
1795 return PMINFO_R_ERROR;
1799 /*If API is called multiple times for same property, we should override the previous values.
1800 Last value set will be used for filtering.*/
1801 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
1803 filter->list = g_slist_delete_link(filter->list, link);
1804 filter->list = g_slist_append(filter->list, (gpointer)node);
1809 API int pkgmgrinfo_appinfo_filter_add_bool(pkgmgrinfo_appinfo_filter_h handle,
1810 const char *property, const bool value)
1812 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
1813 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
1815 GSList *link = NULL;
1817 prop = _pminfo_appinfo_convert_to_prop_bool(property);
1818 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_BOOL ||
1819 prop > E_PMINFO_APPINFO_PROP_APP_MAX_BOOL) {
1820 _LOGE("Invalid Boolean Property\n");
1821 return PMINFO_R_EINVAL;
1823 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
1824 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
1826 _LOGE("Out of Memory!!!\n");
1827 return PMINFO_R_ERROR;
1830 val = strndup("('true','True')", 15);
1832 val = strndup("('false','False')", 17);
1834 _LOGE("Out of Memory\n");
1837 return PMINFO_R_ERROR;
1841 /*If API is called multiple times for same property, we should override the previous values.
1842 Last value set will be used for filtering.*/
1843 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
1845 filter->list = g_slist_delete_link(filter->list, link);
1846 filter->list = g_slist_append(filter->list, (gpointer)node);
1851 API int pkgmgrinfo_appinfo_filter_add_string(pkgmgrinfo_appinfo_filter_h handle,
1852 const char *property, const char *value)
1854 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
1855 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
1856 retvm_if(value == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
1858 pkgmgrinfo_node_x *ptr = NULL;
1859 char prev[PKG_STRING_LEN_MAX] = {'\0'};
1860 char temp[PKG_STRING_LEN_MAX] = {'\0'};
1861 GSList *link = NULL;
1863 prop = _pminfo_appinfo_convert_to_prop_str(property);
1864 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_STR ||
1865 prop > E_PMINFO_APPINFO_PROP_APP_MAX_STR) {
1866 _LOGE("Invalid String Property\n");
1867 return PMINFO_R_EINVAL;
1869 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
1870 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
1872 _LOGE("Out of Memory!!!\n");
1873 return PMINFO_R_ERROR;
1877 case E_PMINFO_APPINFO_PROP_APP_COMPONENT:
1878 if (strcmp(value, PMINFO_APPINFO_UI_APP) == 0)
1879 val = strndup("uiapp", PKG_STRING_LEN_MAX - 1);
1881 val = strndup("svcapp", PKG_STRING_LEN_MAX - 1);
1883 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
1885 filter->list = g_slist_delete_link(filter->list, link);
1886 filter->list = g_slist_append(filter->list, (gpointer)node);
1888 case E_PMINFO_APPINFO_PROP_APP_CATEGORY:
1889 case E_PMINFO_APPINFO_PROP_APP_OPERATION:
1890 case E_PMINFO_APPINFO_PROP_APP_URI:
1891 case E_PMINFO_APPINFO_PROP_APP_MIME:
1892 val = (char *)calloc(1, PKG_STRING_LEN_MAX);
1894 _LOGE("Out of Memory\n");
1897 return PMINFO_R_ERROR;
1899 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
1901 ptr = (pkgmgrinfo_node_x *)link->data;
1902 strncpy(prev, ptr->value, PKG_STRING_LEN_MAX - 1);
1903 _LOGE("Previous value is %s\n", prev);
1904 filter->list = g_slist_delete_link(filter->list, link);
1905 snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s , '%s'", prev, value);
1906 strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
1907 _LOGE("New value is %s\n", val);
1909 filter->list = g_slist_append(filter->list, (gpointer)node);
1910 memset(temp, '\0', PKG_STRING_LEN_MAX);
1912 snprintf(temp, PKG_STRING_LEN_MAX - 1, "'%s'", value);
1913 strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
1914 _LOGE("First value is %s\n", val);
1916 filter->list = g_slist_append(filter->list, (gpointer)node);
1917 memset(temp, '\0', PKG_STRING_LEN_MAX);
1921 node->value = strndup(value, PKG_STRING_LEN_MAX - 1);
1922 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
1924 filter->list = g_slist_delete_link(filter->list, link);
1925 filter->list = g_slist_append(filter->list, (gpointer)node);
1931 API int pkgmgrinfo_appinfo_usr_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count, uid_t uid)
1936 if (handle == NULL || count == NULL) {
1937 _LOGE("invalid parameter");
1938 return PMINFO_R_EINVAL;
1941 ret = _appinfo_get_filtered_list(handle, uid, &list);
1942 if (ret != PMINFO_R_OK)
1943 return PMINFO_R_ERROR;
1945 *count = g_list_length(list);
1947 g_list_free_full(list, free);
1952 API int pkgmgrinfo_appinfo_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count)
1954 return pkgmgrinfo_appinfo_usr_filter_count(handle, count, GLOBAL_USER);
1957 API int pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(
1958 pkgmgrinfo_appinfo_filter_h handle,
1959 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
1961 if (handle == NULL || app_cb == NULL) {
1962 LOGE("invalid parameter");
1963 return PMINFO_R_EINVAL;
1966 return _appinfo_get_filtered_foreach_appinfo(uid, handle, app_cb,
1970 API int pkgmgrinfo_appinfo_filter_foreach_appinfo(pkgmgrinfo_appinfo_filter_h handle,
1971 pkgmgrinfo_app_list_cb app_cb, void * user_data)
1973 return pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(handle, app_cb, user_data, GLOBAL_USER);
1976 API int pkgmgrinfo_appinfo_metadata_filter_create(pkgmgrinfo_appinfo_metadata_filter_h *handle)
1978 return (pkgmgrinfo_pkginfo_filter_create(handle));
1981 API int pkgmgrinfo_appinfo_metadata_filter_destroy(pkgmgrinfo_appinfo_metadata_filter_h handle)
1983 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
1986 API int pkgmgrinfo_appinfo_metadata_filter_add(
1987 pkgmgrinfo_appinfo_metadata_filter_h handle,
1988 const char *key, const char *value)
1992 ret = pkgmgrinfo_appinfo_filter_add_string(handle,
1993 PMINFO_APPINFO_PROP_APP_METADATA_KEY, key);
1994 if (ret != PMINFO_R_OK)
1997 /* value can be NULL.
1998 * In that case all apps with specified key should be displayed
2001 ret = pkgmgrinfo_appinfo_filter_add_string(handle,
2002 PMINFO_APPINFO_PROP_APP_METADATA_VALUE, value);
2003 if (ret != PMINFO_R_OK)
2010 API int pkgmgrinfo_appinfo_usr_metadata_filter_foreach(
2011 pkgmgrinfo_appinfo_metadata_filter_h handle,
2012 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
2014 if (handle == NULL || app_cb == NULL) {
2015 LOGE("invalid parameter");
2016 return PMINFO_R_EINVAL;
2019 return _appinfo_get_filtered_foreach_appinfo(uid, handle, app_cb,
2023 API int pkgmgrinfo_appinfo_metadata_filter_foreach(
2024 pkgmgrinfo_appinfo_metadata_filter_h handle,
2025 pkgmgrinfo_app_list_cb app_cb, void *user_data)
2027 return pkgmgrinfo_appinfo_usr_metadata_filter_foreach(handle, app_cb,
2028 user_data, GLOBAL_USER);
2031 API int pkgmgrinfo_appinfo_is_guestmode_visibility(pkgmgrinfo_appinfo_h handle, bool *status)
2034 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2036 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2037 retvm_if(status == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2039 val = info->app_info->guestmode_visibility;
2040 *status = _get_bool_value(val);