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, app_process_pool, app_installed_storage "
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);
572 _save_column_str(stmt, idx++, &info->process_pool);
573 _save_column_str(stmt, idx++, &info->installed_storage);
575 if (_appinfo_get_label(db, info->appid, locale, &info->label)) {
576 pkgmgrinfo_basic_free_application(info);
577 sqlite3_finalize(stmt);
578 return PMINFO_R_ERROR;
581 if (_appinfo_get_icon(db, info->appid, locale, &info->icon)) {
582 pkgmgrinfo_basic_free_application(info);
583 sqlite3_finalize(stmt);
584 return PMINFO_R_ERROR;
587 if (_appinfo_get_category(db, info->appid, &info->category)) {
588 pkgmgrinfo_basic_free_application(info);
589 sqlite3_finalize(stmt);
590 return PMINFO_R_ERROR;
593 if (_appinfo_get_app_control(db, info->appid, &info->appcontrol)) {
594 pkgmgrinfo_basic_free_application(info);
595 sqlite3_finalize(stmt);
596 return PMINFO_R_ERROR;
599 if (_appinfo_get_data_control(db, info->appid, &info->datacontrol)) {
600 pkgmgrinfo_basic_free_application(info);
601 sqlite3_finalize(stmt);
602 return PMINFO_R_ERROR;
605 if (_appinfo_get_metadata(db, info->appid, &info->metadata)) {
606 pkgmgrinfo_basic_free_application(info);
607 sqlite3_finalize(stmt);
608 return PMINFO_R_ERROR;
613 sqlite3_finalize(stmt);
618 static int _appinfo_get_appinfo(const char *appid, uid_t uid,
619 pkgmgr_appinfo_x **appinfo)
625 pkgmgr_appinfo_x *info;
627 dbpath = getUserPkgParserDBPathUID(uid);
629 return PMINFO_R_ERROR;
631 locale = _get_system_locale();
633 return PMINFO_R_ERROR;
635 ret = sqlite3_open_v2(dbpath, &db, SQLITE_OPEN_READONLY, NULL);
636 if (ret != SQLITE_OK) {
637 _LOGE("failed to open db: %d", ret);
639 return PMINFO_R_ERROR;
642 info = calloc(1, sizeof(pkgmgr_appinfo_x));
644 _LOGE("out of memory");
646 sqlite3_close_v2(db);
647 return PMINFO_R_ERROR;
650 ret = _appinfo_get_application(db, appid, locale, &info->app_info);
651 if (ret != PMINFO_R_OK) {
654 sqlite3_close_v2(db);
658 info->locale = locale;
659 info->package = strdup(info->app_info->package);
663 sqlite3_close_v2(db);
668 API int pkgmgrinfo_appinfo_get_usr_appinfo(const char *appid, uid_t uid,
669 pkgmgrinfo_appinfo_h *handle)
673 if (appid == NULL || handle == NULL) {
674 LOGE("invalid parameter");
675 return PMINFO_R_EINVAL;
678 ret = _appinfo_get_appinfo(appid, uid, (pkgmgr_appinfo_x **)handle);
679 if (ret == PMINFO_R_ENOENT && uid != GLOBAL_USER)
680 ret = _appinfo_get_appinfo(appid, GLOBAL_USER,
681 (pkgmgr_appinfo_x **)handle);
683 if (ret != PMINFO_R_OK)
684 _LOGE("failed to get appinfo of %s for user %d", appid, uid);
689 API int pkgmgrinfo_appinfo_get_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
691 return pkgmgrinfo_appinfo_get_usr_appinfo(appid, GLOBAL_USER, handle);
694 static int _appinfo_get_filtered_foreach_appinfo(uid_t uid,
695 pkgmgrinfo_filter_x *filter, pkgmgrinfo_app_list_cb app_list_cb,
699 pkgmgr_appinfo_x *info;
705 ret = _appinfo_get_filtered_list(filter, uid, &list);
706 if (ret != PMINFO_R_OK)
707 return PMINFO_R_ERROR;
709 for (tmp = list; tmp; tmp = tmp->next) {
710 appid = (char *)tmp->data;
712 ret = _appinfo_get_appinfo(appid, uid, &info);
713 if (ret == PMINFO_R_ENOENT && uid != GLOBAL_USER)
714 ret = _appinfo_get_appinfo(appid, GLOBAL_USER,
716 if (ret != PMINFO_R_OK) {
720 if (app_list_cb(info, user_data) < 0)
722 pkgmgrinfo_appinfo_destroy_appinfo(info);
732 API int pkgmgrinfo_appinfo_get_usr_list(pkgmgrinfo_pkginfo_h handle,
733 pkgmgrinfo_app_component component,
734 pkgmgrinfo_app_list_cb app_func, void *user_data, uid_t uid)
737 pkgmgrinfo_appinfo_filter_h filter;
739 const char *comp_str = NULL;
741 if (handle == NULL || app_func == NULL) {
742 LOGE("invalied parameter");
743 return PMINFO_R_EINVAL;
746 if (pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid)) {
747 LOGE("invalid parameter");
748 return PMINFO_R_EINVAL;
751 if (pkgmgrinfo_appinfo_filter_create(&filter))
752 return PMINFO_R_ERROR;
754 if (pkgmgrinfo_appinfo_filter_add_string(filter,
755 PMINFO_APPINFO_PROP_APP_PACKAGE, pkgid)) {
756 pkgmgrinfo_appinfo_filter_destroy(filter);
757 return PMINFO_R_ERROR;
763 comp_str = PMINFO_APPINFO_UI_APP;
766 comp_str = PMINFO_APPINFO_SVC_APP;
773 if (pkgmgrinfo_appinfo_filter_add_string(filter,
774 PMINFO_APPINFO_PROP_APP_COMPONENT,
776 pkgmgrinfo_appinfo_filter_destroy(filter);
777 return PMINFO_R_ERROR;
781 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter, app_func,
784 pkgmgrinfo_appinfo_filter_destroy(filter);
789 API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_component component,
790 pkgmgrinfo_app_list_cb app_func, void *user_data)
792 return pkgmgrinfo_appinfo_get_usr_list(handle, component, app_func, user_data, GLOBAL_USER);
795 API int pkgmgrinfo_appinfo_get_usr_install_list(pkgmgrinfo_app_list_cb app_func, uid_t uid, void *user_data)
797 if (app_func == NULL) {
798 LOGE("invalid parameter");
799 return PMINFO_R_EINVAL;
802 return _appinfo_get_filtered_foreach_appinfo(uid, NULL, app_func,
806 API int pkgmgrinfo_appinfo_get_install_list(pkgmgrinfo_app_list_cb app_func, void *user_data)
808 return pkgmgrinfo_appinfo_get_usr_install_list(app_func, GLOBAL_USER, user_data);
811 API int pkgmgrinfo_appinfo_get_usr_installed_list(pkgmgrinfo_app_list_cb app_func, uid_t uid, void *user_data)
813 if (app_func == NULL) {
814 LOGE("invalid parameter");
815 return PMINFO_R_EINVAL;
818 return _appinfo_get_filtered_foreach_appinfo(uid, NULL, app_func,
822 API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func, void *user_data)
824 return pkgmgrinfo_appinfo_get_usr_installed_list(app_func, GLOBAL_USER, user_data);
827 API int pkgmgrinfo_appinfo_get_appid(pkgmgrinfo_appinfo_h handle, char **appid)
829 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
831 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
832 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
834 if (info->app_info == NULL || info->app_info->appid == NULL)
835 return PMINFO_R_ERROR;
836 *appid = (char *)info->app_info->appid;
841 API int pkgmgrinfo_appinfo_get_pkgname(pkgmgrinfo_appinfo_h handle, char **pkg_name)
843 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
845 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
846 retvm_if(pkg_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
848 if (info->package == NULL)
849 return PMINFO_R_ERROR;
851 *pkg_name = (char *)info->package;
856 API int pkgmgrinfo_appinfo_get_pkgid(pkgmgrinfo_appinfo_h handle, char **pkgid)
858 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
860 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
861 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
863 if (info->package == NULL)
864 return PMINFO_R_ERROR;
866 *pkgid = (char *)info->package;
871 API int pkgmgrinfo_appinfo_get_exec(pkgmgrinfo_appinfo_h handle, char **exec)
873 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
875 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
876 retvm_if(exec == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
878 if (info->app_info == NULL || info->app_info->exec == NULL)
879 return PMINFO_R_ERROR;
880 *exec = (char *)info->app_info->exec;
886 API int pkgmgrinfo_appinfo_get_icon(pkgmgrinfo_appinfo_h handle, char **icon)
891 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
893 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
894 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
896 locale = info->locale;
897 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
899 if (info->app_info == NULL)
900 return PMINFO_R_ERROR;
902 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
903 ptr = (icon_x *)tmp->data;
904 if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL ||
905 !strcasecmp(ptr->text, "(null)") ||
906 strcmp(ptr->lang, locale))
908 *icon = (char *)ptr->text;
912 locale = DEFAULT_LOCALE;
913 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
914 ptr = (icon_x *)tmp->data;
915 if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL ||
916 strcmp(ptr->lang, locale))
918 *icon = (char *)ptr->text;
922 return PMINFO_R_ERROR;
926 API int pkgmgrinfo_appinfo_get_label(pkgmgrinfo_appinfo_h handle, char **label)
931 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
933 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
934 retvm_if(label == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
936 locale = info->locale;
937 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
939 if (info->app_info == NULL)
940 return PMINFO_R_ERROR;
942 for (tmp = info->app_info->label; tmp; tmp = tmp->next) {
943 ptr = (label_x *)tmp->data;
944 if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL ||
945 strcmp(ptr->lang, locale))
947 *label = (char *)ptr->text;
951 locale = DEFAULT_LOCALE;
952 for (tmp = info->app_info->label; tmp; tmp = tmp->next) {
953 ptr = (label_x *)tmp->data;
954 if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL ||
955 strcmp(ptr->lang, locale))
957 *label = (char *)ptr->text;
961 return PMINFO_R_ERROR;
964 static char *_get_localed_label(const char *appid, const char *locale, uid_t uid)
968 sqlite3_stmt *stmt = NULL;
971 const char *manifest_db;
973 manifest_db = getUserPkgParserDBPathUID(uid);
974 if (manifest_db == NULL) {
975 _LOGE("Failed to get manifest db path");
979 if (sqlite3_open_v2(manifest_db, &db, SQLITE_OPEN_READONLY, NULL) != SQLITE_OK) {
980 _LOGE("DB open fail\n");
984 query = sqlite3_mprintf("select app_label from package_app_localized_info where app_id=%Q and app_locale=%Q", appid, locale);
986 _LOGE("Out of memory");
990 if (sqlite3_prepare_v2(db, query, -1, &stmt, NULL) != SQLITE_OK) {
991 _LOGE("prepare_v2 fail\n");
995 if (sqlite3_step(stmt) == SQLITE_ROW) {
996 val = (char *)sqlite3_column_text(stmt, 0);
998 result = strdup(val);
1002 sqlite3_finalize(stmt);
1003 sqlite3_free(query);
1009 API int pkgmgrinfo_appinfo_usr_get_localed_label(const char *appid, const char *locale, uid_t uid, char **label)
1013 retvm_if(appid == NULL || locale == NULL || label == NULL, PMINFO_R_EINVAL, "Argument is NULL");
1015 val = _get_localed_label(appid, locale, uid);
1017 val = _get_localed_label(appid, DEFAULT_LOCALE, uid);
1020 return PMINFO_R_ERROR;
1027 API int pkgmgrinfo_appinfo_get_localed_label(const char *appid, const char *locale, char **label)
1029 return pkgmgrinfo_appinfo_usr_get_localed_label(appid, locale, GLOBAL_USER, label);
1032 static pkgmgrinfo_app_component __appcomponent_convert(const char *comp)
1034 if ( strcasecmp(comp, "uiapp") == 0)
1035 return PMINFO_UI_APP;
1036 else if ( strcasecmp(comp, "svcapp") == 0)
1037 return PMINFO_SVC_APP;
1042 API int pkgmgrinfo_appinfo_get_component(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_component *component)
1044 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1047 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1048 retvm_if(component == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1050 if (info->app_info == NULL)
1051 return PMINFO_R_ERROR;
1053 comp = __appcomponent_convert(info->app_info->component);
1055 return PMINFO_R_ERROR;
1062 API int pkgmgrinfo_appinfo_get_apptype(pkgmgrinfo_appinfo_h handle, char **app_type)
1064 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1066 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1067 retvm_if(app_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1069 if (info->app_info == NULL || info->app_info->type == NULL)
1070 return PMINFO_R_ERROR;
1071 *app_type = (char *)info->app_info->type;
1076 API int pkgmgrinfo_appinfo_get_operation(pkgmgrinfo_appcontrol_h handle,
1077 int *operation_count, char ***operation)
1079 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1080 retvm_if(operation == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1081 retvm_if(operation_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1082 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1083 *operation_count = data->operation_count;
1084 *operation = data->operation;
1088 API int pkgmgrinfo_appinfo_get_uri(pkgmgrinfo_appcontrol_h handle,
1089 int *uri_count, char ***uri)
1091 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1092 retvm_if(uri == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1093 retvm_if(uri_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1094 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1095 *uri_count = data->uri_count;
1100 API int pkgmgrinfo_appinfo_get_mime(pkgmgrinfo_appcontrol_h handle,
1101 int *mime_count, char ***mime)
1103 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1104 retvm_if(mime == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1105 retvm_if(mime_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1106 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1107 *mime_count = data->mime_count;
1112 API int pkgmgrinfo_appinfo_get_subapp(pkgmgrinfo_appcontrol_h handle,
1113 int *subapp_count, char ***subapp)
1115 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1116 retvm_if(subapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1117 retvm_if(subapp_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1118 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1119 *subapp_count = data->subapp_count;
1120 *subapp = data->subapp;
1124 API int pkgmgrinfo_appinfo_get_setting_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1129 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1131 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1132 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1134 if (info->app_info == NULL)
1135 return PMINFO_R_ERROR;
1137 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1138 ptr = (icon_x *)tmp->data;
1139 if (ptr == NULL || ptr->section == NULL)
1142 val = (char *)ptr->section;
1143 if (val && strcmp(val, "setting") == 0) {
1144 *icon = (char *)ptr->text;
1149 return PMINFO_R_ERROR;
1153 API int pkgmgrinfo_appinfo_get_notification_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1158 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1160 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1161 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1163 if (info->app_info == NULL)
1164 return PMINFO_R_ERROR;
1166 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1167 ptr = (icon_x *)tmp->data;
1168 if (ptr == NULL || ptr->section == NULL)
1171 val = (char *)ptr->section;
1172 if (val && strcmp(val, "notification") == 0){
1173 *icon = (char *)ptr->text;
1178 return PMINFO_R_ERROR;
1181 API int pkgmgrinfo_appinfo_get_recent_image_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_recentimage *type)
1184 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1186 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1187 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1189 if (info->app_info == NULL || info->app_info->recentimage == NULL)
1190 return PMINFO_R_ERROR;
1192 val = (char *)info->app_info->recentimage;
1193 if (strcasecmp(val, "capture") == 0)
1194 *type = PMINFO_RECENTIMAGE_USE_CAPTURE;
1195 else if (strcasecmp(val, "icon") == 0)
1196 *type = PMINFO_RECENTIMAGE_USE_ICON;
1198 *type = PMINFO_RECENTIMAGE_USE_NOTHING;
1203 API int pkgmgrinfo_appinfo_get_preview_image(pkgmgrinfo_appinfo_h handle, char **preview_img)
1208 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1210 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1211 retvm_if(preview_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1213 if (info->app_info == NULL)
1214 return PMINFO_R_ERROR;
1216 for (tmp = info->app_info->image; tmp; tmp = tmp->next) {
1217 ptr = (image_x *)tmp->data;
1218 if (ptr == NULL || ptr->section == NULL)
1221 val = (char *)ptr->section;
1222 if (val && strcmp(val, "preview") == 0) {
1223 *preview_img = (char *)ptr->text;
1228 return PMINFO_R_ERROR;
1231 API int pkgmgrinfo_appinfo_get_permission_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_permission_type *permission)
1234 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1236 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1237 retvm_if(permission == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1239 val = info->app_info->permission_type;
1241 return PMINFO_R_ERROR;
1243 if (strcmp(val, "signature") == 0)
1244 *permission = PMINFO_PERMISSION_SIGNATURE;
1245 else if (strcmp(val, "privilege") == 0)
1246 *permission = PMINFO_PERMISSION_PRIVILEGE;
1248 *permission = PMINFO_PERMISSION_NORMAL;
1253 API int pkgmgrinfo_appinfo_get_component_type(pkgmgrinfo_appinfo_h handle, char **component_type)
1255 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1257 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1258 retvm_if(component_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1260 if (info->app_info == NULL || info->app_info->component_type == NULL)
1261 return PMINFO_R_ERROR;
1263 *component_type = (char *)info->app_info->component_type;
1268 API int pkgmgrinfo_appinfo_get_hwacceleration(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_hwacceleration *hwacceleration)
1271 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1273 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1274 retvm_if(hwacceleration == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1276 if (info->app_info == NULL || info->app_info->hwacceleration == NULL)
1277 return PMINFO_R_ERROR;
1279 val = (char *)info->app_info->hwacceleration;
1280 if (strcasecmp(val, "not-use-GL") == 0)
1281 *hwacceleration = PMINFO_HWACCELERATION_NOT_USE_GL;
1282 else if (strcasecmp(val, "use-GL") == 0)
1283 *hwacceleration = PMINFO_HWACCELERATION_USE_GL;
1285 *hwacceleration = PMINFO_HWACCELERATION_USE_SYSTEM_SETTING;
1290 API int pkgmgrinfo_appinfo_get_screenreader(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_screenreader *screenreader)
1293 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1295 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1296 retvm_if(screenreader == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1298 if (info->app_info == NULL || info->app_info->screenreader == NULL)
1299 return PMINFO_R_ERROR;
1301 val = (char *)info->app_info->screenreader;
1302 if (strcasecmp(val, "screenreader-off") == 0)
1303 *screenreader = PMINFO_SCREENREADER_OFF;
1304 else if (strcasecmp(val, "screenreader-on") == 0)
1305 *screenreader = PMINFO_SCREENREADER_ON;
1307 *screenreader = PMINFO_SCREENREADER_USE_SYSTEM_SETTING;
1312 API int pkgmgrinfo_appinfo_get_effectimage(pkgmgrinfo_appinfo_h handle, char **portrait_img, char **landscape_img)
1314 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1316 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1317 retvm_if(portrait_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1318 retvm_if(landscape_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1320 if (info->app_info == NULL || info->app_info->portraitimg ||
1321 info->app_info->landscapeimg == NULL)
1322 return PMINFO_R_ERROR;
1324 *portrait_img = (char *)info->app_info->portraitimg;
1325 *landscape_img = (char *)info->app_info->landscapeimg;
1330 API int pkgmgrinfo_appinfo_get_effectimage_type(pkgmgrinfo_appinfo_h handle, char **effectimage_type)
1332 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1334 if (handle == NULL || effectimage_type == NULL) {
1335 LOGE("invalid parameter");
1336 return PMINFO_R_EINVAL;
1339 if (info->app_info == NULL || info->app_info->effectimage_type == NULL)
1340 return PMINFO_R_ERROR;
1342 *effectimage_type = (char *)info->app_info->effectimage_type;
1347 API int pkgmgrinfo_appinfo_get_submode_mainid(pkgmgrinfo_appinfo_h handle, char **submode_mainid)
1349 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1351 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1352 retvm_if(submode_mainid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1354 if (info->app_info == NULL || info->app_info->submode_mainid == NULL)
1355 return PMINFO_R_ERROR;
1357 *submode_mainid = (char *)info->app_info->submode_mainid;
1362 API int pkgmgrinfo_appinfo_get_installed_storage_location(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_installed_storage *storage)
1364 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1365 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1367 if (info->app_info && info->app_info->installed_storage){
1368 if (strcmp(info->app_info->installed_storage,"installed_internal") == 0)
1369 *storage = PMINFO_INTERNAL_STORAGE;
1370 else if (strcmp(info->app_info->installed_storage,"installed_external") == 0)
1371 *storage = PMINFO_EXTERNAL_STORAGE;
1373 return PMINFO_R_ERROR;
1375 return PMINFO_R_ERROR;
1380 API int pkgmgrinfo_appinfo_get_launch_mode(pkgmgrinfo_appinfo_h handle, char **mode)
1382 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1384 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1385 retvm_if(mode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1387 if (info->app_info->launch_mode == NULL)
1388 return PMINFO_R_ERROR;
1390 *mode = (char *)(info->app_info->launch_mode);
1395 API int pkgmgrinfo_appinfo_get_alias_appid(pkgmgrinfo_appinfo_h handle, char **alias_appid)
1397 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1399 if (handle == NULL || alias_appid == NULL) {
1400 LOGE("invalid parameter");
1401 return PMINFO_R_EINVAL;
1404 if (info->app_info == NULL || info->app_info->alias_appid == NULL)
1405 return PMINFO_R_ERROR;
1407 *alias_appid = (char *)info->app_info->alias_appid;
1412 API int pkgmgrinfo_appinfo_get_effective_appid(pkgmgrinfo_appinfo_h handle, char **effective_appid)
1414 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1416 if (handle == NULL || effective_appid == NULL) {
1417 LOGE("invalid parameter");
1418 return PMINFO_R_EINVAL;
1421 if (info->app_info == NULL || info->app_info->effective_appid == NULL)
1422 return PMINFO_R_ERROR;
1424 *effective_appid = (char *)info->app_info->effective_appid;
1429 API int pkgmgrinfo_appinfo_usr_get_datacontrol_info(const char *providerid, const char *type, uid_t uid, char **appid, char **access)
1431 retvm_if(providerid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
1432 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
1433 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1434 retvm_if(access == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1436 int ret = PMINFO_R_OK;
1438 sqlite3_stmt *stmt = NULL;
1441 ret = __open_manifest_db(uid, true);
1442 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
1444 /*Start constructing query*/
1445 query = sqlite3_mprintf("select * from package_app_data_control where providerid=%Q and type=%Q", providerid, type);
1448 ret = sqlite3_prepare_v2(GET_DB(manifest_db), query, strlen(query), &stmt, NULL);
1449 tryvm_if(ret != PMINFO_R_OK, ret = PMINFO_R_ERROR, "sqlite3_prepare_v2 failed[%s]\n", query);
1452 ret = sqlite3_step(stmt);
1453 tryvm_if((ret != SQLITE_ROW) || (ret == SQLITE_DONE), ret = PMINFO_R_ERROR, "No records found");
1455 *appid = strdup((char *)sqlite3_column_text(stmt, 0));
1456 *access = strdup((char *)sqlite3_column_text(stmt, 2));
1461 sqlite3_free(query);
1462 sqlite3_finalize(stmt);
1463 __close_manifest_db();
1467 API int pkgmgrinfo_appinfo_get_datacontrol_info(const char *providerid, const char *type, char **appid, char **access)
1469 return pkgmgrinfo_appinfo_usr_get_datacontrol_info(providerid, type, GLOBAL_USER, appid, access);
1472 API int pkgmgrinfo_appinfo_usr_get_datacontrol_appid(const char *providerid, uid_t uid, char **appid)
1474 retvm_if(providerid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
1475 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1477 int ret = PMINFO_R_OK;
1479 sqlite3_stmt *stmt = NULL;
1482 ret = __open_manifest_db(uid, true);
1483 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
1485 /*Start constructing query*/
1486 query = sqlite3_mprintf("select * from package_app_data_control where providerid=%Q", providerid);
1489 ret = sqlite3_prepare_v2(GET_DB(manifest_db), query, strlen(query), &stmt, NULL);
1490 tryvm_if(ret != PMINFO_R_OK, ret = PMINFO_R_ERROR, "sqlite3_prepare_v2 failed[%s]\n", query);
1493 ret = sqlite3_step(stmt);
1494 tryvm_if((ret != SQLITE_ROW) || (ret == SQLITE_DONE), ret = PMINFO_R_ERROR, "No records found");
1496 *appid = strdup((char *)sqlite3_column_text(stmt, 0));
1501 sqlite3_free(query);
1502 sqlite3_finalize(stmt);
1503 __close_manifest_db();
1507 API int pkgmgrinfo_appinfo_get_datacontrol_appid(const char *providerid, char **appid)
1509 return pkgmgrinfo_appinfo_usr_get_datacontrol_appid(providerid, GLOBAL_USER, appid);
1512 API int pkgmgrinfo_appinfo_foreach_permission(pkgmgrinfo_appinfo_h handle,
1513 pkgmgrinfo_app_permission_list_cb permission_func, void *user_data)
1515 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1516 retvm_if(permission_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
1520 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1522 if (info->app_info == NULL)
1523 return PMINFO_R_ERROR;
1525 for (tmp = info->app_info->permission; tmp; tmp = tmp->next) {
1526 ptr = (permission_x *)tmp->data;
1530 ret = permission_func(ptr->value, user_data);
1538 API int pkgmgrinfo_appinfo_foreach_category(pkgmgrinfo_appinfo_h handle,
1539 pkgmgrinfo_app_category_list_cb category_func, void *user_data)
1541 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1542 retvm_if(category_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
1544 const char *category;
1546 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1548 if (info->app_info == NULL)
1549 return PMINFO_R_ERROR;
1551 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
1552 category = (const char *)tmp->data;
1554 ret = category_func(category, user_data);
1562 API int pkgmgrinfo_appinfo_foreach_metadata(pkgmgrinfo_appinfo_h handle,
1563 pkgmgrinfo_app_metadata_list_cb metadata_func, void *user_data)
1565 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1566 retvm_if(metadata_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
1570 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1572 if (info->app_info == NULL)
1573 return PMINFO_R_ERROR;
1575 for (tmp = info->app_info->metadata; tmp; tmp = tmp->next) {
1576 ptr = (metadata_x *)tmp->data;
1580 ret = metadata_func(ptr->key, ptr->value, user_data);
1588 API int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
1589 pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
1591 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1592 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
1594 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1595 appcontrol_x *appcontrol;
1598 if (info->app_info == NULL)
1599 return PMINFO_R_ERROR;
1601 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
1602 appcontrol = (appcontrol_x *)tmp->data;
1603 if (appcontrol == NULL)
1605 ret = appcontrol_func(appcontrol->operation, appcontrol->uri, appcontrol->mime, user_data);
1613 API int pkgmgrinfo_appinfo_foreach_background_category(
1614 pkgmgrinfo_appinfo_h handle,
1615 pkgmgrinfo_app_background_category_list_cb category_func,
1618 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1622 if (handle == NULL || category_func == NULL || info->app_info == NULL) {
1623 LOGE("invalid parameter");
1624 return PMINFO_R_EINVAL;
1627 for (tmp = info->app_info->background_category; tmp; tmp = tmp->next) {
1628 category = (char *)tmp->data;
1629 if (category == NULL)
1632 if (category_func(category, user_data) < 0)
1639 API int pkgmgrinfo_appinfo_is_nodisplay(pkgmgrinfo_appinfo_h handle, bool *nodisplay)
1641 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1642 retvm_if(nodisplay == 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->nodisplay == NULL)
1646 return PMINFO_R_ERROR;
1648 *nodisplay = _get_bool_value(info->app_info->nodisplay);
1653 API int pkgmgrinfo_appinfo_is_multiple(pkgmgrinfo_appinfo_h handle, bool *multiple)
1655 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1656 retvm_if(multiple == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1657 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1659 if (info->app_info == NULL || info->app_info->multiple == NULL)
1660 return PMINFO_R_ERROR;
1662 *multiple = _get_bool_value(info->app_info->multiple);
1667 API int pkgmgrinfo_appinfo_is_indicator_display_allowed(pkgmgrinfo_appinfo_h handle, bool *indicator_disp)
1669 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1670 retvm_if(indicator_disp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1671 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1673 if (info->app_info == NULL || info->app_info->indicatordisplay == NULL)
1674 return PMINFO_R_ERROR;
1676 *indicator_disp = _get_bool_value(info->app_info->indicatordisplay);
1681 API int pkgmgrinfo_appinfo_is_taskmanage(pkgmgrinfo_appinfo_h handle, bool *taskmanage)
1683 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1684 retvm_if(taskmanage == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1685 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1687 if (info->app_info == NULL || info->app_info->taskmanage == NULL)
1688 return PMINFO_R_ERROR;
1690 *taskmanage = _get_bool_value(info->app_info->taskmanage);
1695 API int pkgmgrinfo_appinfo_is_enabled(pkgmgrinfo_appinfo_h handle, bool *enabled)
1697 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1698 retvm_if(enabled == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1699 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1701 if (info->app_info == NULL || info->app_info->enabled == NULL)
1702 return PMINFO_R_ERROR;
1704 *enabled = _get_bool_value(info->app_info->enabled);
1709 API int pkgmgrinfo_appinfo_is_onboot(pkgmgrinfo_appinfo_h handle, bool *onboot)
1711 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1712 retvm_if(onboot == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1713 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1715 if (info->app_info == NULL || info->app_info->onboot == NULL)
1716 return PMINFO_R_ERROR;
1718 *onboot = _get_bool_value(info->app_info->onboot);
1723 API int pkgmgrinfo_appinfo_is_autorestart(pkgmgrinfo_appinfo_h handle, bool *autorestart)
1725 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1726 retvm_if(autorestart == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1727 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1729 if (info->app_info == NULL || info->app_info->autorestart == NULL)
1730 return PMINFO_R_ERROR;
1732 *autorestart = _get_bool_value(info->app_info->autorestart);
1737 API int pkgmgrinfo_appinfo_is_mainapp(pkgmgrinfo_appinfo_h handle, bool *mainapp)
1739 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1740 retvm_if(mainapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1741 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1743 if (info->app_info == NULL || info->app_info->mainapp == NULL)
1744 return PMINFO_R_ERROR;
1746 *mainapp = _get_bool_value(info->app_info->mainapp);
1751 API int pkgmgrinfo_appinfo_is_preload(pkgmgrinfo_appinfo_h handle, bool *preload)
1753 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1754 retvm_if(preload == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1755 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1757 if (info->app_info == NULL || info->app_info->preload == NULL)
1758 return PMINFO_R_ERROR;
1760 *preload = _get_bool_value(info->app_info->preload);
1765 API int pkgmgrinfo_appinfo_is_submode(pkgmgrinfo_appinfo_h handle, bool *submode)
1767 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1768 retvm_if(submode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1769 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1771 if (info->app_info == NULL || info->app_info->submode == NULL)
1772 return PMINFO_R_ERROR;
1774 *submode = _get_bool_value(info->app_info->submode);
1779 API int pkgmgrinfo_appinfo_is_process_pool(pkgmgrinfo_appinfo_h handle, bool *process_pool)
1781 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1783 if (handle == NULL || process_pool == NULL) {
1784 LOGE("invalid parameter");
1785 return PMINFO_R_EINVAL;
1788 if (info->app_info == NULL)
1789 return PMINFO_R_ERROR;
1791 *process_pool = _get_bool_value(info->app_info->process_pool);
1796 API int pkgmgrinfo_appinfo_is_category_exist(pkgmgrinfo_appinfo_h handle, const char *category, bool *exist)
1798 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1799 retvm_if(category == NULL, PMINFO_R_EINVAL, "category is NULL");
1800 retvm_if(exist == NULL, PMINFO_R_EINVAL, "exist is NULL");
1804 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1806 if (info->app_info == NULL)
1807 return PMINFO_R_ERROR;
1810 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
1811 val = (const char *)tmp->data;
1814 if (strcasecmp(val, category) == 0) {
1823 API int pkgmgrinfo_appinfo_is_ui_gadget(pkgmgrinfo_appinfo_h handle,
1826 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1828 if (info == NULL || info->app_info == NULL || ui_gadget == NULL) {
1829 _LOGE("invalid parameter");
1830 return PMINFO_R_EINVAL;
1833 *ui_gadget = _get_bool_value(info->app_info->ui_gadget);
1838 API int pkgmgrinfo_appinfo_is_support_disable(pkgmgrinfo_appinfo_h handle,
1839 bool *support_disable)
1841 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1843 if (info == NULL || info->app_info == NULL || support_disable == NULL) {
1844 _LOGE("invalid parameter");
1845 return PMINFO_R_EINVAL;
1848 *support_disable = _get_bool_value(info->app_info->support_disable);
1853 API int pkgmgrinfo_appinfo_destroy_appinfo(pkgmgrinfo_appinfo_h handle)
1855 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1856 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1857 __cleanup_appinfo(info);
1861 API int pkgmgrinfo_appinfo_filter_create(pkgmgrinfo_appinfo_filter_h *handle)
1863 return (pkgmgrinfo_pkginfo_filter_create(handle));
1866 API int pkgmgrinfo_appinfo_filter_destroy(pkgmgrinfo_appinfo_filter_h handle)
1868 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
1871 static gint __compare_func(gconstpointer data1, gconstpointer data2)
1873 pkgmgrinfo_node_x *node1 = (pkgmgrinfo_node_x*)data1;
1874 pkgmgrinfo_node_x *node2 = (pkgmgrinfo_node_x*)data2;
1875 if (node1->prop == node2->prop)
1877 else if (node1->prop > node2->prop)
1883 API int pkgmgrinfo_appinfo_filter_add_int(pkgmgrinfo_appinfo_filter_h handle,
1884 const char *property, const int value)
1886 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
1887 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
1888 char buf[PKG_VALUE_STRING_LEN_MAX] = {'\0'};
1890 GSList *link = NULL;
1892 prop = _pminfo_appinfo_convert_to_prop_int(property);
1893 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_INT ||
1894 prop > E_PMINFO_APPINFO_PROP_APP_MAX_INT) {
1895 _LOGE("Invalid Integer Property\n");
1896 return PMINFO_R_EINVAL;
1898 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
1899 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
1901 _LOGE("Out of Memory!!!\n");
1902 return PMINFO_R_ERROR;
1904 snprintf(buf, PKG_VALUE_STRING_LEN_MAX - 1, "%d", value);
1905 val = strndup(buf, PKG_VALUE_STRING_LEN_MAX - 1);
1907 _LOGE("Out of Memory\n");
1910 return PMINFO_R_ERROR;
1914 /*If API is called multiple times for same property, we should override the previous values.
1915 Last value set will be used for filtering.*/
1916 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
1918 filter->list = g_slist_delete_link(filter->list, link);
1919 filter->list = g_slist_append(filter->list, (gpointer)node);
1924 API int pkgmgrinfo_appinfo_filter_add_bool(pkgmgrinfo_appinfo_filter_h handle,
1925 const char *property, const bool value)
1927 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
1928 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
1930 GSList *link = NULL;
1932 prop = _pminfo_appinfo_convert_to_prop_bool(property);
1933 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_BOOL ||
1934 prop > E_PMINFO_APPINFO_PROP_APP_MAX_BOOL) {
1935 _LOGE("Invalid Boolean Property\n");
1936 return PMINFO_R_EINVAL;
1938 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
1939 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
1941 _LOGE("Out of Memory!!!\n");
1942 return PMINFO_R_ERROR;
1945 val = strndup("('true','True')", 15);
1947 val = strndup("('false','False')", 17);
1949 _LOGE("Out of Memory\n");
1952 return PMINFO_R_ERROR;
1956 /*If API is called multiple times for same property, we should override the previous values.
1957 Last value set will be used for filtering.*/
1958 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
1960 filter->list = g_slist_delete_link(filter->list, link);
1961 filter->list = g_slist_append(filter->list, (gpointer)node);
1966 API int pkgmgrinfo_appinfo_filter_add_string(pkgmgrinfo_appinfo_filter_h handle,
1967 const char *property, const char *value)
1969 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
1970 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
1971 retvm_if(value == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
1973 pkgmgrinfo_node_x *ptr = NULL;
1974 char prev[PKG_STRING_LEN_MAX] = {'\0'};
1975 char temp[PKG_STRING_LEN_MAX] = {'\0'};
1976 GSList *link = NULL;
1978 prop = _pminfo_appinfo_convert_to_prop_str(property);
1979 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_STR ||
1980 prop > E_PMINFO_APPINFO_PROP_APP_MAX_STR) {
1981 _LOGE("Invalid String Property\n");
1982 return PMINFO_R_EINVAL;
1984 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
1985 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
1987 _LOGE("Out of Memory!!!\n");
1988 return PMINFO_R_ERROR;
1992 case E_PMINFO_APPINFO_PROP_APP_COMPONENT:
1993 if (strcmp(value, PMINFO_APPINFO_UI_APP) == 0)
1994 val = strndup("uiapp", PKG_STRING_LEN_MAX - 1);
1996 val = strndup("svcapp", PKG_STRING_LEN_MAX - 1);
1998 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2000 filter->list = g_slist_delete_link(filter->list, link);
2001 filter->list = g_slist_append(filter->list, (gpointer)node);
2003 case E_PMINFO_APPINFO_PROP_APP_CATEGORY:
2004 case E_PMINFO_APPINFO_PROP_APP_OPERATION:
2005 case E_PMINFO_APPINFO_PROP_APP_URI:
2006 case E_PMINFO_APPINFO_PROP_APP_MIME:
2007 val = (char *)calloc(1, PKG_STRING_LEN_MAX);
2009 _LOGE("Out of Memory\n");
2012 return PMINFO_R_ERROR;
2014 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2016 ptr = (pkgmgrinfo_node_x *)link->data;
2017 strncpy(prev, ptr->value, PKG_STRING_LEN_MAX - 1);
2018 _LOGE("Previous value is %s\n", prev);
2019 filter->list = g_slist_delete_link(filter->list, link);
2020 snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s , '%s'", prev, value);
2021 strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
2022 _LOGE("New value is %s\n", val);
2024 filter->list = g_slist_append(filter->list, (gpointer)node);
2025 memset(temp, '\0', PKG_STRING_LEN_MAX);
2027 snprintf(temp, PKG_STRING_LEN_MAX - 1, "'%s'", value);
2028 strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
2029 _LOGE("First value is %s\n", val);
2031 filter->list = g_slist_append(filter->list, (gpointer)node);
2032 memset(temp, '\0', PKG_STRING_LEN_MAX);
2036 node->value = strndup(value, PKG_STRING_LEN_MAX - 1);
2037 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2039 filter->list = g_slist_delete_link(filter->list, link);
2040 filter->list = g_slist_append(filter->list, (gpointer)node);
2046 API int pkgmgrinfo_appinfo_usr_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count, uid_t uid)
2051 if (handle == NULL || count == NULL) {
2052 _LOGE("invalid parameter");
2053 return PMINFO_R_EINVAL;
2056 ret = _appinfo_get_filtered_list(handle, uid, &list);
2057 if (ret != PMINFO_R_OK)
2058 return PMINFO_R_ERROR;
2060 *count = g_list_length(list);
2062 g_list_free_full(list, free);
2067 API int pkgmgrinfo_appinfo_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count)
2069 return pkgmgrinfo_appinfo_usr_filter_count(handle, count, GLOBAL_USER);
2072 API int pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(
2073 pkgmgrinfo_appinfo_filter_h handle,
2074 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
2076 if (handle == NULL || app_cb == NULL) {
2077 LOGE("invalid parameter");
2078 return PMINFO_R_EINVAL;
2081 return _appinfo_get_filtered_foreach_appinfo(uid, handle, app_cb,
2085 API int pkgmgrinfo_appinfo_filter_foreach_appinfo(pkgmgrinfo_appinfo_filter_h handle,
2086 pkgmgrinfo_app_list_cb app_cb, void * user_data)
2088 return pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(handle, app_cb, user_data, GLOBAL_USER);
2091 API int pkgmgrinfo_appinfo_metadata_filter_create(pkgmgrinfo_appinfo_metadata_filter_h *handle)
2093 return (pkgmgrinfo_pkginfo_filter_create(handle));
2096 API int pkgmgrinfo_appinfo_metadata_filter_destroy(pkgmgrinfo_appinfo_metadata_filter_h handle)
2098 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
2101 API int pkgmgrinfo_appinfo_metadata_filter_add(
2102 pkgmgrinfo_appinfo_metadata_filter_h handle,
2103 const char *key, const char *value)
2107 ret = pkgmgrinfo_appinfo_filter_add_string(handle,
2108 PMINFO_APPINFO_PROP_APP_METADATA_KEY, key);
2109 if (ret != PMINFO_R_OK)
2112 /* value can be NULL.
2113 * In that case all apps with specified key should be displayed
2116 ret = pkgmgrinfo_appinfo_filter_add_string(handle,
2117 PMINFO_APPINFO_PROP_APP_METADATA_VALUE, value);
2118 if (ret != PMINFO_R_OK)
2125 API int pkgmgrinfo_appinfo_usr_metadata_filter_foreach(
2126 pkgmgrinfo_appinfo_metadata_filter_h handle,
2127 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
2129 if (handle == NULL || app_cb == NULL) {
2130 LOGE("invalid parameter");
2131 return PMINFO_R_EINVAL;
2134 return _appinfo_get_filtered_foreach_appinfo(uid, handle, app_cb,
2138 API int pkgmgrinfo_appinfo_metadata_filter_foreach(
2139 pkgmgrinfo_appinfo_metadata_filter_h handle,
2140 pkgmgrinfo_app_list_cb app_cb, void *user_data)
2142 return pkgmgrinfo_appinfo_usr_metadata_filter_foreach(handle, app_cb,
2143 user_data, GLOBAL_USER);
2146 API int pkgmgrinfo_appinfo_is_guestmode_visibility(pkgmgrinfo_appinfo_h handle, bool *status)
2149 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2151 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2152 retvm_if(status == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2154 val = info->app_info->guestmode_visibility;
2155 *status = _get_bool_value(val);