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)
20 if (str && !strcmp(str, "true"))
26 static void __cleanup_appinfo(pkgmgr_appinfo_x *data)
28 pkgmgr_appinfo_x *info = data;
32 free((void *)info->package);
34 free((void *)info->locale);
36 pkgmgrinfo_basic_free_application(info->app_info);
42 static const char join_localized_info[] =
43 " LEFT OUTER JOIN package_app_localized_info"
44 " ON ai.app_id=package_app_localized_info.app_id"
45 " AND package_app_localized_info.app_locale=?";
46 static const char join_category[] =
47 " LEFT OUTER JOIN package_app_app_category"
48 " ON ai.app_id=package_app_app_category.app_id";
49 static const char join_app_control[] =
50 " LEFT OUTER JOIN package_app_app_control"
51 " ON ai.app_id=package_app_app_control.app_id";
52 static const char join_metadata[] =
53 " LEFT OUTER JOIN package_app_app_metadata"
54 " ON ai.app_id=package_app_app_metadata.app_id ";
55 static const char join_privilege[] =
56 " LEFT OUTER JOIN package_privilege_info"
57 " ON ai.package=package_privilege_info.package ";
59 static int _get_filtered_query(pkgmgrinfo_filter_x *filter,
60 const char *locale, uid_t uid, char **query, GList **bind_params)
64 char *condition = NULL;
65 char buf[MAX_QUERY_LEN] = { '\0' };
66 char tmp_query[MAX_QUERY_LEN] = { '\0' };
71 strncat(buf, " WHERE 1=1", sizeof(buf) - strlen(buf) - 1);
73 for (list = filter->list; list; list = list->next) {
74 joined |= __get_filter_condition(list->data, uid, &condition, bind_params);
75 if (condition == NULL)
78 strncat(buf, " AND ", sizeof(buf) - strlen(buf) - 1);
80 strncat(buf, condition, sizeof(buf) - strlen(buf) - 1);
85 if (filter->list_metadata)
86 strncat(buf, " AND (", sizeof(buf) - strlen(buf) - 1);
87 for (list = filter->list_metadata; list; list = list->next) {
88 joined |= __get_metadata_filter_condition(list->data,
89 &condition, bind_params);
90 if (condition == NULL)
92 strncat(buf, condition, sizeof(buf) - strlen(buf) - 1);
96 strncat(buf, " OR ", sizeof(buf) - strlen(buf) - 1);
98 if (filter->list_metadata)
99 strncat(buf, "1=0)", sizeof(buf) - strlen(buf) - 1);
101 if (joined & E_PMINFO_APPINFO_JOIN_LOCALIZED_INFO) {
102 strncat(tmp_query, join_localized_info, sizeof(tmp_query) - strlen(tmp_query) - 1);
103 *bind_params = g_list_append(*bind_params, strdup(locale));
105 if (joined & E_PMINFO_APPINFO_JOIN_CATEGORY)
106 strncat(tmp_query, join_category, sizeof(tmp_query) - strlen(tmp_query) - 1);
107 if (joined & E_PMINFO_APPINFO_JOIN_APP_CONTROL)
108 strncat(tmp_query, join_app_control, sizeof(tmp_query) - strlen(tmp_query) - 1);
109 if (joined & E_PMINFO_APPINFO_JOIN_METADATA)
110 strncat(tmp_query, join_metadata, sizeof(tmp_query) - strlen(tmp_query) - 1);
111 if (joined & E_PMINFO_APPINFO_JOIN_PRIVILEGE)
112 strncat(tmp_query, join_privilege, sizeof(tmp_query) - strlen(tmp_query) - 1);
114 size = strlen(tmp_query) + strlen(buf) + 1;
115 *query = (char *)calloc(1, size);
117 return PMINFO_R_ERROR;
118 snprintf(*query, size, "%s%s", tmp_query, buf);
123 static int _appinfo_get_category(sqlite3 *db, const char *appid,
126 static const char query_raw[] =
127 "SELECT category FROM package_app_app_category WHERE app_id=%Q";
133 query = sqlite3_mprintf(query_raw, appid);
135 LOGE("out of memory");
136 return PMINFO_R_ERROR;
139 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
141 if (ret != SQLITE_OK) {
142 LOGE("prepare failed: %s", sqlite3_errmsg(db));
143 return PMINFO_R_ERROR;
146 while (sqlite3_step(stmt) == SQLITE_ROW) {
148 _save_column_str(stmt, 0, &val);
150 *category = g_list_append(*category, (gpointer)val);
153 sqlite3_finalize(stmt);
158 static void __parse_appcontrol(GList **appcontrol, char *appcontrol_str,
159 char *visibility, char *id)
166 if (appcontrol_str == NULL)
169 dup = strdup(appcontrol_str);
171 _LOGE("out of memory");
176 ac = calloc(1, sizeof(appcontrol_x));
178 _LOGE("out of memory");
181 token = strtok_r(dup, "|", &ptr);
182 if (token && strcmp(token, "NULL"))
183 ac->operation = strdup(token);
184 token = strtok_r(NULL, "|", &ptr);
185 if (token && strcmp(token, "NULL"))
186 ac->uri = strdup(token);
187 token = strtok_r(NULL, "|", &ptr);
188 if (token && strcmp(token, "NULL"))
189 ac->mime = strdup(token);
190 ac->visibility = strdup(visibility);
192 *appcontrol = g_list_append(*appcontrol, ac);
193 } while ((token = strtok_r(NULL, ";", &ptr)));
198 static int _appinfo_get_app_control(sqlite3 *db, const char *appid,
201 static const char query_raw[] =
202 "SELECT app_control, visibility, app_control_id "
203 "FROM package_app_app_control WHERE app_id=%Q";
212 query = sqlite3_mprintf(query_raw, appid);
214 LOGE("out of memory");
215 return PMINFO_R_ERROR;
218 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
220 if (ret != SQLITE_OK) {
221 LOGE("prepare failed: %s", sqlite3_errmsg(db));
222 return PMINFO_R_ERROR;
225 while (sqlite3_step(stmt) == SQLITE_ROW) {
230 _save_column_str(stmt, idx++, &str);
231 _save_column_str(stmt, idx++, &visibility);
232 _save_column_str(stmt, idx++, &id);
234 __parse_appcontrol(appcontrol, str, visibility, id);
240 sqlite3_finalize(stmt);
245 static int _appinfo_get_metadata(sqlite3 *db, const char *appid,
248 static const char query_raw[] =
249 "SELECT md_key, md_value "
250 "FROM package_app_app_metadata WHERE app_id=%Q";
257 query = sqlite3_mprintf(query_raw, appid);
259 LOGE("out of memory");
260 return PMINFO_R_ERROR;
263 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
265 if (ret != SQLITE_OK) {
266 LOGE("prepare failed: %s", sqlite3_errmsg(db));
267 return PMINFO_R_ERROR;
270 while (sqlite3_step(stmt) == SQLITE_ROW) {
271 info = calloc(1, sizeof(metadata_x));
273 LOGE("out of memory");
274 sqlite3_finalize(stmt);
275 return PMINFO_R_ERROR;
278 _save_column_str(stmt, idx++, &info->key);
279 _save_column_str(stmt, idx++, &info->value);
280 *metadata = g_list_append(*metadata, info);
283 sqlite3_finalize(stmt);
289 static int _appinfo_get_splashscreens(sqlite3 *db, const char *appid,
290 GList **splashscreens)
292 static const char query_raw[] =
293 "SELECT src, type, orientation, indicatordisplay, operation, color_depth "
294 "FROM package_app_splash_screen WHERE app_id=%Q";
299 splashscreen_x *info;
301 query = sqlite3_mprintf(query_raw, appid);
303 LOGE("out of memory");
304 return PMINFO_R_ERROR;
307 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
309 if (ret != SQLITE_OK) {
310 LOGE("prepare failed: %s", sqlite3_errmsg(db));
311 return PMINFO_R_ERROR;
314 while (sqlite3_step(stmt) == SQLITE_ROW) {
315 info = calloc(1, sizeof(splashscreen_x));
317 LOGE("out of memory");
318 sqlite3_finalize(stmt);
319 return PMINFO_R_ERROR;
322 _save_column_str(stmt, idx++, &info->src);
323 _save_column_str(stmt, idx++, &info->type);
324 _save_column_str(stmt, idx++, &info->orientation);
325 _save_column_str(stmt, idx++, &info->indicatordisplay);
326 _save_column_str(stmt, idx++, &info->operation);
327 _save_column_str(stmt, idx++, &info->color_depth);
328 *splashscreens = g_list_append(*splashscreens, info);
331 sqlite3_finalize(stmt);
336 static GList *__get_background_category(const char *value)
338 GList *category_list = NULL;
339 int convert_value = 0;
340 if (!value || strlen(value) == 0)
343 convert_value = atoi(value);
344 if (convert_value < 0)
347 if (convert_value & APP_BG_CATEGORY_USER_DISABLE_TRUE_VAL)
348 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_USER_DISABLE_TRUE_STR));
350 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_USER_DISABLE_FALSE_STR));
352 if (convert_value & APP_BG_CATEGORY_MEDIA_VAL)
353 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_MEDIA_STR));
355 if (convert_value & APP_BG_CATEGORY_DOWNLOAD_VAL)
356 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_DOWNLOAD_STR));
358 if (convert_value & APP_BG_CATEGORY_BGNETWORK_VAL)
359 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_BGNETWORK_STR));
361 if (convert_value & APP_BG_CATEGORY_LOCATION_VAL)
362 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_LOCATION_STR));
364 if (convert_value & APP_BG_CATEGORY_SENSOR_VAL)
365 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_SENSOR_STR));
367 if (convert_value & APP_BG_CATEGORY_IOTCOMM_VAL)
368 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_IOTCOMM_STR));
370 if (convert_value & APP_BG_CATEGORY_SYSTEM_VAL)
371 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_SYSTEM));
373 return category_list;
377 static void __free_applications(gpointer data)
379 pkgmgrinfo_basic_free_application((application_x *)data);
382 static gint __disable_chk_func(gconstpointer data1, gconstpointer data2)
384 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)data1;
385 pkgmgrinfo_appinfo_disable_type value = GPOINTER_TO_INT(data2);
387 if (value == E_APPINFO_DISABLE_TYPE_PKG)
388 return (node->prop == E_PMINFO_APPINFO_PROP_PKG_DISABLE)
391 return (node->prop == E_PMINFO_APPINFO_PROP_APP_DISABLE)
395 static bool __check_disable_filter_exist(pkgmgrinfo_filter_x *filter,
396 pkgmgrinfo_appinfo_disable_type type)
403 link = g_slist_find_custom(filter->list, GINT_TO_POINTER(type), __disable_chk_func);
410 static int __bind_params(sqlite3_stmt *stmt, GList *params)
412 GList *tmp_list = NULL;
416 if (stmt == NULL || params == NULL)
417 return PMINFO_R_EINVAL;
421 ret = sqlite3_bind_text(stmt, ++idx, (char *)tmp_list->data, -1, SQLITE_STATIC);
422 if (ret != SQLITE_OK)
423 return PMINFO_R_ERROR;
424 tmp_list = tmp_list->next;
430 static bool __check_app_storage_status(pkgmgrinfo_filter_x *tmp_filter)
432 GSList *tmp_list = NULL;
433 pkgmgrinfo_node_x *tmp_node = NULL;
436 if (tmp_filter == NULL)
439 property = _pminfo_appinfo_convert_to_prop_bool(PMINFO_APPINFO_PROP_APP_CHECK_STORAGE);
440 for (tmp_list = tmp_filter->list; tmp_list != NULL;
441 tmp_list = g_slist_next(tmp_list)) {
442 tmp_node = (pkgmgrinfo_node_x *)tmp_list->data;
443 if (property == tmp_node->prop) {
444 if (strcmp(tmp_node->value, "true") == 0)
454 static int _appinfo_get_applications(uid_t db_uid, uid_t uid,
455 const char *locale, pkgmgrinfo_filter_x *filter, int flag,
456 GHashTable *applications)
458 static const char query_raw[] =
459 "SELECT DISTINCT ai.app_id, ai.app_installed_storage, "
460 "ai.app_external_path";
461 static const char query_basic[] =
462 ", ai.app_component, ai.app_exec, "
463 "ai.app_nodisplay, ai.app_type, ai.app_onboot, "
464 "ai.app_multiple, ai.app_autorestart, ai.app_taskmanage, "
465 "ai.app_hwacceleration, ai.app_screenreader, "
466 "ai.app_mainapp, ai.app_recentimage, ai.app_launchcondition, "
467 "ai.app_indicatordisplay, ai.app_portraitimg, "
468 "ai.app_landscapeimg, ai.app_guestmodevisibility, "
469 "ai.app_permissiontype, ai.app_preload, ai.app_submode, "
470 "ai.app_submode_mainid, ai.app_launch_mode, ai.app_ui_gadget, "
471 "ai.app_support_disable, ai.app_process_pool, "
472 "ai.app_background_category, ai.app_package_type, "
473 "ai.app_root_path, ai.app_api_version, ai.app_effective_appid, "
474 "ai.app_disable, ai.app_splash_screen_display, ai.app_tep_name, "
475 "ai.app_zip_mount_file, ai.component_type, ai.package, "
476 "ai.app_package_system, ai.app_removable, "
477 "ai.app_package_installed_time, ai.app_support_mode, "
478 "ai.app_support_ambient, ai.app_setup_appid";
479 static const char query_uid_info[] =
480 ", ui.is_disabled, ui.is_splash_screen_enabled";
481 static const char query_label[] =
483 "(SELECT app_label FROM package_app_localized_info WHERE ai.app_id=app_id AND app_locale=?), "
484 "(SELECT app_label FROM package_app_localized_info WHERE ai.app_id=app_id AND app_locale='No Locale'))";
485 static const char query_icon[] =
487 "(SELECT app_icon FROM package_app_localized_info WHERE ai.app_id=app_id AND app_locale=?), "
488 "(SELECT app_icon FROM package_app_localized_info WHERE ai.app_id=app_id AND app_locale='No Locale'))";
489 static const char query_from_clause[] = " FROM package_app_info as ai";
490 static const char query_uid_info_clause[] =
491 " LEFT OUTER JOIN package_app_info_for_uid AS ui "
492 "ON (ai.app_id=ui.app_id AND ui.uid=?)";
493 int ret = PMINFO_R_ERROR;
496 char *bg_category_str = NULL;
497 char *constraint = NULL;
498 char *tmp_record = NULL;
499 char query[MAX_QUERY_LEN] = { '\0' };
500 char buf[BUFSIZE] = { '\0' };
501 application_x *info = NULL;
502 GList *bind_params = NULL;
504 sqlite3_stmt *stmt = NULL;
505 bool is_check_storage = true;
506 const uid_t global_user_uid = GLOBAL_USER;
508 dbpath = getUserPkgParserDBPathUID(db_uid);
510 return PMINFO_R_ERROR;
512 ret = __open_db(dbpath, &db, SQLITE_OPEN_READONLY);
513 if (ret != SQLITE_OK) {
514 _LOGE("failed to open db(%s): %d", dbpath, ret);
516 return PMINFO_R_ERROR;
520 snprintf(query, MAX_QUERY_LEN - 1, "%s", query_raw);
522 if (flag & PMINFO_APPINFO_GET_BASICINFO) {
523 strncat(query, query_basic, sizeof(query) - strlen(query) - 1);
524 strncat(query, query_uid_info, sizeof(query) - strlen(query) - 1);
526 if (flag & PMINFO_APPINFO_GET_LABEL) {
527 strncat(query, query_label, sizeof(query) - strlen(query) - 1);
528 bind_params = g_list_append(bind_params, strdup(locale));
530 if (flag & PMINFO_APPINFO_GET_ICON) {
531 strncat(query, query_icon, sizeof(query) - strlen(query) - 1);
532 bind_params = g_list_append(bind_params, strdup(locale));
535 snprintf(buf, MAX_QUERY_LEN - 1, "%d", uid);
536 bind_params = g_list_append(bind_params, strdup(buf));
538 is_check_storage = __check_app_storage_status(filter);
540 ret = _get_filtered_query(filter, locale, uid, &constraint, &bind_params);
541 if (ret != PMINFO_R_OK) {
542 LOGE("Failed to get WHERE clause");
545 strncat(query, query_from_clause, sizeof(query) - strlen(query) - 1);
547 strncat(query, query_uid_info_clause, sizeof(query) - strlen(query) - 1);
550 strncat(query, constraint, sizeof(query) - strlen(query) - 1);
552 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
553 if (ret != SQLITE_OK) {
554 LOGE("prepare failed: %s", sqlite3_errmsg(db));
555 ret = PMINFO_R_ERROR;
559 if (g_list_length(bind_params) != 0) {
560 ret = __bind_params(stmt, bind_params);
561 if (ret != SQLITE_OK) {
562 LOGE("Failed to bind parameters");
567 while (sqlite3_step(stmt) == SQLITE_ROW) {
568 info = calloc(1, sizeof(application_x));
570 LOGE("out of memory");
571 ret = PMINFO_R_ERROR;
575 _save_column_str(stmt, idx++, &info->appid);
576 _save_column_str(stmt, idx++, &info->installed_storage);
577 _save_column_str(stmt, idx++ , &info->external_path);
579 if (flag & PMINFO_APPINFO_GET_BASICINFO) {
580 _save_column_str(stmt, idx++, &info->component);
581 _save_column_str(stmt, idx++, &info->exec);
582 _save_column_str(stmt, idx++, &info->nodisplay);
583 _save_column_str(stmt, idx++, &info->type);
584 _save_column_str(stmt, idx++, &info->onboot);
585 _save_column_str(stmt, idx++, &info->multiple);
586 _save_column_str(stmt, idx++, &info->autorestart);
587 _save_column_str(stmt, idx++, &info->taskmanage);
588 _save_column_str(stmt, idx++, &info->hwacceleration);
589 _save_column_str(stmt, idx++, &info->screenreader);
590 _save_column_str(stmt, idx++, &info->mainapp);
591 _save_column_str(stmt, idx++, &info->recentimage);
592 _save_column_str(stmt, idx++, &info->launchcondition);
593 _save_column_str(stmt, idx++, &info->indicatordisplay);
594 _save_column_str(stmt, idx++, &info->portraitimg);
595 _save_column_str(stmt, idx++, &info->landscapeimg);
596 _save_column_str(stmt, idx++, &info->guestmode_visibility);
597 _save_column_str(stmt, idx++, &info->permission_type);
598 _save_column_str(stmt, idx++, &info->preload);
599 _save_column_str(stmt, idx++, &info->submode);
600 _save_column_str(stmt, idx++, &info->submode_mainid);
601 _save_column_str(stmt, idx++, &info->launch_mode);
602 _save_column_str(stmt, idx++, &info->ui_gadget);
603 _save_column_str(stmt, idx++, &info->support_disable);
604 _save_column_str(stmt, idx++, &info->process_pool);
605 _save_column_str(stmt, idx++, &bg_category_str);
606 _save_column_str(stmt, idx++, &info->package_type);
607 _save_column_str(stmt, idx++, &info->root_path);
608 _save_column_str(stmt, idx++, &info->api_version);
609 _save_column_str(stmt, idx++, &info->effective_appid);
610 _save_column_str(stmt, idx++, &info->is_disabled);
611 _save_column_str(stmt, idx++, &info->splash_screen_display);
612 _save_column_str(stmt, idx++, &info->tep_name);
613 _save_column_str(stmt, idx++, &info->zip_mount_file);
614 _save_column_str(stmt, idx++, &info->component_type);
615 _save_column_str(stmt, idx++, &info->package);
616 _save_column_str(stmt, idx++, &info->package_system);
617 _save_column_str(stmt, idx++, &info->removable);
618 _save_column_str(stmt, idx++, &info->package_installed_time);
619 _save_column_str(stmt, idx++, &info->support_mode);
620 _save_column_str(stmt, idx++, &info->support_ambient);
621 _save_column_str(stmt, idx++, &info->setup_appid);
622 info->background_category = __get_background_category(
624 free(bg_category_str);
625 bg_category_str = NULL;
628 info->for_all_users =
629 strdup((db_uid != global_user_uid) ? "false" : "true");
631 if (db_uid != global_user_uid) {
635 _save_column_str(stmt, idx++, &tmp_record);
636 if (tmp_record != NULL) {
637 if (strcasecmp(info->is_disabled, "false") == 0 &&
638 strcasecmp(tmp_record, "false") == 0) {
639 free(info->is_disabled);
640 info->is_disabled = tmp_record;
646 _save_column_str(stmt, idx++, &tmp_record);
647 if (tmp_record != NULL) {
648 if (strcasecmp(info->splash_screen_display, "false") == 0 &&
649 strcasecmp(tmp_record, "false") == 0) {
650 free(info->splash_screen_display);
651 info->splash_screen_display = tmp_record;
658 if (flag & PMINFO_APPINFO_GET_LABEL) {
660 _save_column_str(stmt, idx++, &tmp_record);
661 if (_add_label_info_into_list(locale, tmp_record, &info->label)) {
662 ret = PMINFO_R_ERROR;
667 if (flag & PMINFO_APPINFO_GET_ICON) {
669 _save_column_str(stmt, idx++, &tmp_record);
670 if (_add_icon_info_into_list(locale, tmp_record, &info->icon)) {
671 ret = PMINFO_R_ERROR;
676 if (flag & PMINFO_APPINFO_GET_CATEGORY) {
677 if (_appinfo_get_category(db, info->appid,
679 ret = PMINFO_R_ERROR;
684 if (flag & PMINFO_APPINFO_GET_APP_CONTROL) {
685 if (_appinfo_get_app_control(db, info->appid,
686 &info->appcontrol)) {
687 ret = PMINFO_R_ERROR;
692 if (flag & PMINFO_APPINFO_GET_METADATA) {
693 if (_appinfo_get_metadata(db, info->appid,
695 ret = PMINFO_R_ERROR;
700 if (flag & PMINFO_APPINFO_GET_SPLASH_SCREEN) {
701 if (_appinfo_get_splashscreens(db, info->appid,
702 &info->splashscreens)) {
703 ret = PMINFO_R_ERROR;
708 if (is_check_storage &&
709 __appinfo_check_installed_storage(info) != PMINFO_R_OK) {
710 ret = PMINFO_R_ERROR;
711 pkgmgrinfo_basic_free_application(info);
716 g_hash_table_insert(applications, (gpointer)info->appid,
723 sqlite3_finalize(stmt);
724 sqlite3_close_v2(db);
729 if (ret != PMINFO_R_OK && info != NULL)
730 pkgmgrinfo_basic_free_application(info);
732 g_list_free_full(bind_params, free);
737 static int _pkgmgrinfo_get_appinfo(const char *appid, uid_t uid,
738 pkgmgrinfo_appinfo_filter_h filter, pkgmgrinfo_appinfo_h *handle)
743 pkgmgr_appinfo_x *info;
745 if (appid == NULL || filter == NULL || handle == NULL) {
746 LOGE("invalid parameter");
747 return PMINFO_R_EINVAL;
750 locale = _get_system_locale();
752 return PMINFO_R_ERROR;
754 list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
755 __free_applications);
758 return PMINFO_R_ERROR;
761 ret = _appinfo_get_applications(uid, uid, locale, filter,
762 PMINFO_APPINFO_GET_ALL, list);
763 if (!g_hash_table_size(list) && uid != GLOBAL_USER)
764 ret = _appinfo_get_applications(GLOBAL_USER, uid, locale, filter,
765 PMINFO_APPINFO_GET_ALL, list);
767 if (ret != PMINFO_R_OK) {
768 g_hash_table_destroy(list);
773 if (!g_hash_table_size(list)) {
774 _LOGD("appinfo for [%s] is not existed for user [%d]",
776 g_hash_table_destroy(list);
778 return PMINFO_R_ENOENT;
781 info = calloc(1, sizeof(pkgmgr_appinfo_x));
783 _LOGE("out of memory");
784 g_hash_table_destroy(list);
786 return PMINFO_R_ERROR;
789 info->app_info = (application_x *)g_hash_table_lookup(list, appid);
790 if (!info->app_info || !info->app_info->package) {
791 _LOGD("appinfo for [%s] is not existed for user [%d]",
793 g_hash_table_destroy(list);
796 return PMINFO_R_ENOENT;
798 info->locale = locale;
799 info->package = strdup(info->app_info->package);
800 if (!info->package) {
801 _LOGE("out of memory");
802 g_hash_table_destroy(list);
805 return PMINFO_R_ERROR;
808 /* just free list only */
809 g_hash_table_steal(list, (gconstpointer)appid);
810 g_hash_table_destroy(list);
817 API int pkgmgrinfo_appinfo_get_usr_disabled_appinfo(const char *appid, uid_t uid,
818 pkgmgrinfo_appinfo_h *handle)
821 pkgmgrinfo_appinfo_filter_h filter;
823 if (appid == NULL || handle == NULL) {
824 LOGE("invalid parameter");
825 return PMINFO_R_EINVAL;
828 ret = pkgmgrinfo_appinfo_filter_create(&filter);
829 if (ret != PMINFO_R_OK)
832 ret = pkgmgrinfo_appinfo_filter_add_string(filter,
833 PMINFO_APPINFO_PROP_APP_ID, appid);
834 if (ret != PMINFO_R_OK) {
835 pkgmgrinfo_appinfo_filter_destroy(filter);
836 return PMINFO_R_ERROR;
839 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
840 PMINFO_APPINFO_PROP_APP_DISABLE, true);
841 if (ret != PMINFO_R_OK) {
842 pkgmgrinfo_appinfo_filter_destroy(filter);
843 return PMINFO_R_ERROR;
846 ret = _pkgmgrinfo_get_appinfo(appid, uid, filter, handle);
847 pkgmgrinfo_appinfo_filter_destroy(filter);
852 API int pkgmgrinfo_appinfo_get_disabled_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
854 return pkgmgrinfo_appinfo_get_usr_disabled_appinfo(appid, _getuid(), handle);
857 API int pkgmgrinfo_appinfo_get_usr_appinfo(const char *appid, uid_t uid,
858 pkgmgrinfo_appinfo_h *handle)
861 pkgmgrinfo_appinfo_filter_h filter;
863 if (appid == NULL || handle == NULL) {
864 LOGE("invalid parameter");
865 return PMINFO_R_EINVAL;
868 ret = pkgmgrinfo_appinfo_filter_create(&filter);
869 if (ret != PMINFO_R_OK)
872 ret = pkgmgrinfo_appinfo_filter_add_string(filter,
873 PMINFO_APPINFO_PROP_APP_ID, appid);
874 if (ret != PMINFO_R_OK) {
875 pkgmgrinfo_appinfo_filter_destroy(filter);
876 return PMINFO_R_ERROR;
879 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
880 PMINFO_APPINFO_PROP_APP_DISABLE, false);
881 if (ret != PMINFO_R_OK) {
882 pkgmgrinfo_appinfo_filter_destroy(filter);
883 return PMINFO_R_ERROR;
886 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
887 PMINFO_APPINFO_PROP_PKG_DISABLE, false);
888 if (ret != PMINFO_R_OK) {
889 pkgmgrinfo_appinfo_filter_destroy(filter);
890 return PMINFO_R_ERROR;
893 ret = _pkgmgrinfo_get_appinfo(appid, uid, filter, handle);
894 pkgmgrinfo_appinfo_filter_destroy(filter);
898 API int pkgmgrinfo_appinfo_get_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
900 return pkgmgrinfo_appinfo_get_usr_appinfo(appid, _getuid(), handle);
903 API int pkgmgrinfo_appinfo_get_usr_all_appinfo(const char *appid, uid_t uid,
904 pkgmgrinfo_appinfo_h *handle)
907 pkgmgrinfo_appinfo_filter_h filter;
909 if (appid == NULL || handle == NULL) {
910 LOGE("invalid parameter");
911 return PMINFO_R_EINVAL;
914 ret = pkgmgrinfo_appinfo_filter_create(&filter);
915 if (ret != PMINFO_R_OK)
918 ret = pkgmgrinfo_appinfo_filter_add_string(filter,
919 PMINFO_APPINFO_PROP_APP_ID, appid);
920 if (ret != PMINFO_R_OK) {
921 pkgmgrinfo_appinfo_filter_destroy(filter);
922 return PMINFO_R_ERROR;
925 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
926 PMINFO_APPINFO_PROP_APP_CHECK_STORAGE, false);
927 if (ret != PMINFO_R_OK) {
928 pkgmgrinfo_appinfo_filter_destroy(filter);
929 return PMINFO_R_ERROR;
932 ret = _pkgmgrinfo_get_appinfo(appid, uid, filter, handle);
933 pkgmgrinfo_appinfo_filter_destroy(filter);
938 API int pkgmgrinfo_appinfo_get_all_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
940 return pkgmgrinfo_appinfo_get_usr_all_appinfo(appid, _getuid(), handle);
943 static gpointer __copy_str(gconstpointer src, gpointer data)
945 const char *tmp = (const char *)src;
948 buffer = strdup(tmp);
949 if (buffer == NULL) {
950 LOGE("memory alloc failed");
958 static gpointer __copy_label(gconstpointer src, gpointer data)
960 label_x *tmp = (label_x *)src;
963 label = calloc(1, sizeof(label_x));
965 LOGE("memory alloc failed");
971 label->name = strdup(tmp->name);
973 label->text = strdup(tmp->text);
975 label->lang = strdup(tmp->lang);
980 static gpointer __copy_icon(gconstpointer src, gpointer data)
982 icon_x *tmp = (icon_x *)src;
985 icon = calloc(1, sizeof(icon_x));
987 LOGE("memory alloc failed");
993 icon->text = strdup(tmp->text);
995 icon->lang = strdup(tmp->lang);
997 icon->section = strdup(tmp->section);
999 icon->size = strdup(tmp->size);
1000 if (tmp->resolution)
1001 icon->resolution = strdup(tmp->resolution);
1006 static gpointer __copy_metadata(gconstpointer src, gpointer data)
1008 metadata_x *tmp = (metadata_x *)src;
1009 metadata_x *metadata;
1011 metadata = calloc(1, sizeof(metadata_x));
1012 if (metadata == NULL) {
1013 LOGE("memory alloc failed");
1019 metadata->key = strdup(tmp->key);
1021 metadata->value = strdup(tmp->value);
1026 static gpointer __copy_datacontrol(gconstpointer src, gpointer data)
1028 datacontrol_x *tmp = (datacontrol_x *)src;
1029 datacontrol_x *datacontrol;
1031 datacontrol = calloc(1, sizeof(datacontrol_x));
1032 if (datacontrol == NULL) {
1033 LOGE("memory alloc failed");
1038 if (tmp->providerid)
1039 datacontrol->providerid = strdup(tmp->providerid);
1041 datacontrol->access = strdup(tmp->access);
1043 datacontrol->type = strdup(tmp->type);
1045 datacontrol->trusted = strdup(tmp->trusted);
1050 static gpointer __copy_appcontrol(gconstpointer src, gpointer data)
1052 appcontrol_x *tmp = (appcontrol_x *)src;
1053 appcontrol_x *appcontrol;
1055 appcontrol = calloc(1, sizeof(appcontrol_x));
1056 if (appcontrol == NULL) {
1057 LOGE("memory alloc failed");
1063 appcontrol->operation = strdup(tmp->operation);
1065 appcontrol->uri = strdup(tmp->uri);
1067 appcontrol->mime = strdup(tmp->mime);
1072 static gpointer __copy_splashscreens(gconstpointer src, gpointer data)
1074 splashscreen_x *tmp = (splashscreen_x *)src;
1075 splashscreen_x *splashscreen;
1077 splashscreen = (splashscreen_x *)calloc(1, sizeof(splashscreen_x));
1078 if (splashscreen == NULL) {
1079 LOGE("memory alloc failed");
1085 splashscreen->src = strdup(tmp->src);
1087 splashscreen->type = strdup(tmp->type);
1088 if (tmp->orientation)
1089 splashscreen->orientation = strdup(tmp->orientation);
1090 if (tmp->indicatordisplay)
1091 splashscreen->indicatordisplay = strdup(tmp->indicatordisplay);
1093 splashscreen->operation = strdup(tmp->operation);
1094 if (tmp->color_depth)
1095 splashscreen->color_depth = strdup(tmp->color_depth);
1097 return splashscreen;
1100 static int _appinfo_copy_appinfo(application_x **application, application_x *data)
1102 application_x *app_info;
1105 app_info = calloc(1, sizeof(application_x));
1106 if (app_info == NULL) {
1107 LOGE("memory alloc failed");
1108 return PMINFO_R_ERROR;
1111 if (data->appid != NULL)
1112 app_info->appid = strdup(data->appid);
1113 if (data->exec != NULL)
1114 app_info->exec = strdup(data->exec);
1115 if (data->nodisplay != NULL)
1116 app_info->nodisplay = strdup(data->nodisplay);
1117 if (data->multiple != NULL)
1118 app_info->multiple = strdup(data->multiple);
1119 if (data->taskmanage != NULL)
1120 app_info->taskmanage = strdup(data->taskmanage);
1121 if (data->type != NULL)
1122 app_info->type = strdup(data->type);
1123 if (data->categories != NULL)
1124 app_info->categories = strdup(data->categories);
1125 if (data->hwacceleration != NULL)
1126 app_info->hwacceleration = strdup(data->hwacceleration);
1127 if (data->screenreader != NULL)
1128 app_info->screenreader = strdup(data->screenreader);
1129 if (data->mainapp != NULL)
1130 app_info->mainapp = strdup(data->mainapp);
1131 if (data->package != NULL)
1132 app_info->package = strdup(data->package);
1133 if (data->recentimage != NULL)
1134 app_info->recentimage = strdup(data->recentimage);
1135 if (data->launchcondition != NULL)
1136 app_info->launchcondition = strdup(data->launchcondition);
1137 if (data->indicatordisplay != NULL)
1138 app_info->indicatordisplay = strdup(data->indicatordisplay);
1139 if (data->portraitimg != NULL)
1140 app_info->portraitimg = strdup(data->portraitimg);
1141 if (data->landscapeimg != NULL)
1142 app_info->landscapeimg = strdup(data->landscapeimg);
1143 if (data->guestmode_visibility != NULL)
1144 app_info->guestmode_visibility = strdup(data->guestmode_visibility);
1145 if (data->component != NULL)
1146 app_info->component = strdup(data->component);
1147 if (data->permission_type != NULL)
1148 app_info->permission_type = strdup(data->permission_type);
1149 if (data->component_type != NULL)
1150 app_info->component_type = strdup(data->component_type);
1151 if (data->preload != NULL)
1152 app_info->preload = strdup(data->preload);
1153 if (data->submode != NULL)
1154 app_info->submode = strdup(data->submode);
1155 if (data->submode_mainid != NULL)
1156 app_info->submode_mainid = strdup(data->submode_mainid);
1157 if (data->process_pool != NULL)
1158 app_info->process_pool = strdup(data->process_pool);
1159 if (data->installed_storage != NULL)
1160 app_info->installed_storage = strdup(data->installed_storage);
1161 if (data->autorestart != NULL)
1162 app_info->autorestart = strdup(data->autorestart);
1163 if (data->onboot != NULL)
1164 app_info->onboot = strdup(data->onboot);
1165 if (data->support_disable != NULL)
1166 app_info->support_disable = strdup(data->support_disable);
1167 if (data->ui_gadget != NULL)
1168 app_info->ui_gadget = strdup(data->ui_gadget);
1169 if (data->launch_mode != NULL)
1170 app_info->launch_mode = strdup(data->launch_mode);
1171 if (data->package_type != NULL)
1172 app_info->package_type = strdup(data->package_type);
1173 if (data->effective_appid != NULL)
1174 app_info->effective_appid = strdup(data->effective_appid);
1175 if (data->splash_screen_display != NULL)
1176 app_info->splash_screen_display = strdup(data->splash_screen_display);
1180 app_info->label = g_list_copy_deep(data->label, __copy_label, &ret);
1182 LOGE("memory alloc failed");
1183 pkgmgrinfo_basic_free_application(app_info);
1184 return PMINFO_R_ERROR;
1188 app_info->icon = g_list_copy_deep(data->icon, __copy_icon, &ret);
1190 LOGE("memory alloc failed");
1191 pkgmgrinfo_basic_free_application(app_info);
1192 return PMINFO_R_ERROR;
1196 app_info->category = g_list_copy_deep(data->category, __copy_str, &ret);
1198 LOGE("memory alloc failed");
1199 pkgmgrinfo_basic_free_application(app_info);
1200 return PMINFO_R_ERROR;
1204 app_info->metadata = g_list_copy_deep(data->metadata, __copy_metadata, &ret);
1206 LOGE("memory alloc failed");
1207 pkgmgrinfo_basic_free_application(app_info);
1208 return PMINFO_R_ERROR;
1212 app_info->datacontrol = g_list_copy_deep(data->datacontrol, __copy_datacontrol, &ret);
1214 LOGE("memory alloc failed");
1215 pkgmgrinfo_basic_free_application(app_info);
1216 return PMINFO_R_ERROR;
1220 app_info->appcontrol = g_list_copy_deep(data->appcontrol, __copy_appcontrol, &ret);
1222 LOGE("memory alloc failed");
1223 pkgmgrinfo_basic_free_application(app_info);
1224 return PMINFO_R_ERROR;
1228 app_info->background_category = g_list_copy_deep(data->background_category, __copy_str, &ret);
1230 LOGE("memory alloc failed");
1231 pkgmgrinfo_basic_free_application(app_info);
1232 return PMINFO_R_ERROR;
1236 app_info->splashscreens = g_list_copy_deep(data->splashscreens, __copy_splashscreens, &ret);
1238 LOGE("memory alloc failed");
1239 pkgmgrinfo_basic_free_application(app_info);
1240 return PMINFO_R_ERROR;
1243 *application = app_info;
1248 API int pkgmgrinfo_appinfo_clone_appinfo(pkgmgrinfo_appinfo_h handle,
1249 pkgmgrinfo_appinfo_h *clone)
1251 pkgmgr_appinfo_x *info;
1252 pkgmgr_appinfo_x *temp = (pkgmgr_appinfo_x *)handle;
1255 return PMINFO_R_EINVAL;
1257 info = calloc(1, sizeof(pkgmgr_appinfo_x));
1259 LOGE("memory alloc failed");
1260 return PMINFO_R_ERROR;
1263 if (temp->package != NULL)
1264 info->package = strdup(temp->package);
1265 if (temp->locale != NULL)
1266 info->locale = strdup(temp->locale);
1268 info->app_component = temp->app_component;
1270 if (_appinfo_copy_appinfo(&info->app_info, temp->app_info) < 0) {
1271 LOGE("appinfo copy failed");
1273 free((void *)info->package);
1277 return PMINFO_R_ERROR;
1285 static int _appinfo_get_filtered_foreach_appinfo(uid_t uid,
1286 pkgmgrinfo_filter_x *filter, int flag, pkgmgrinfo_app_list_cb app_list_cb,
1292 pkgmgr_appinfo_x info;
1294 GHashTableIter iter;
1297 locale = _get_system_locale();
1299 return PMINFO_R_ERROR;
1301 list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
1302 __free_applications);
1305 return PMINFO_R_ERROR;
1308 ret = _appinfo_get_applications(uid, uid, locale, filter,
1309 flag | PMINFO_APPINFO_GET_BASICINFO, list);
1310 if (ret == PMINFO_R_OK && uid != GLOBAL_USER)
1311 ret = _appinfo_get_applications(GLOBAL_USER, uid, locale,
1312 filter, flag | PMINFO_APPINFO_GET_BASICINFO, list);
1314 if (ret != PMINFO_R_OK) {
1315 g_hash_table_destroy(list);
1320 g_hash_table_iter_init(&iter, list);
1321 while (g_hash_table_iter_next(&iter, NULL, &value)) {
1322 app = (application_x *)value;
1323 info.app_info = app;
1324 info.locale = locale;
1325 info.package = app->package;
1326 if (app_list_cb(&info, user_data) < 0)
1329 g_hash_table_destroy(list);
1335 static const char *__appcomponent_str(pkgmgrinfo_app_component comp);
1337 API int pkgmgrinfo_appinfo_get_usr_list(pkgmgrinfo_pkginfo_h handle,
1338 pkgmgrinfo_app_component component,
1339 pkgmgrinfo_app_list_cb app_func, void *user_data, uid_t uid)
1342 pkgmgrinfo_appinfo_filter_h filter;
1344 const char *comp_str = NULL;
1346 if (handle == NULL || app_func == NULL) {
1347 LOGE("invalid parameter");
1348 return PMINFO_R_EINVAL;
1351 if (pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid)) {
1352 LOGE("invalid parameter");
1353 return PMINFO_R_EINVAL;
1356 if (pkgmgrinfo_appinfo_filter_create(&filter))
1357 return PMINFO_R_ERROR;
1359 if (pkgmgrinfo_appinfo_filter_add_string(filter,
1360 PMINFO_APPINFO_PROP_APP_PACKAGE, pkgid)) {
1361 pkgmgrinfo_appinfo_filter_destroy(filter);
1362 return PMINFO_R_ERROR;
1365 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
1366 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
1367 pkgmgrinfo_appinfo_filter_destroy(filter);
1368 return PMINFO_R_ERROR;
1371 comp_str = __appcomponent_str(component);
1374 if (pkgmgrinfo_appinfo_filter_add_string(filter,
1375 PMINFO_APPINFO_PROP_APP_COMPONENT,
1377 pkgmgrinfo_appinfo_filter_destroy(filter);
1378 return PMINFO_R_ERROR;
1382 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter,
1383 PMINFO_APPINFO_GET_ALL, app_func, user_data);
1385 pkgmgrinfo_appinfo_filter_destroy(filter);
1390 API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle,
1391 pkgmgrinfo_app_component component,
1392 pkgmgrinfo_app_list_cb app_func, void *user_data)
1394 return pkgmgrinfo_appinfo_get_usr_list(handle, component, app_func, user_data, _getuid());
1397 API int pkgmgrinfo_appinfo_get_usr_installed_list_full(
1398 pkgmgrinfo_app_list_cb app_func, uid_t uid, int flag,
1402 pkgmgrinfo_appinfo_filter_h filter;
1404 if (app_func == NULL) {
1405 LOGE("invalid parameter");
1406 return PMINFO_R_EINVAL;
1409 if (pkgmgrinfo_appinfo_filter_create(&filter))
1410 return PMINFO_R_ERROR;
1412 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
1413 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
1414 pkgmgrinfo_appinfo_filter_destroy(filter);
1415 return PMINFO_R_ERROR;
1418 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
1419 PMINFO_APPINFO_PROP_PKG_DISABLE, false)) {
1420 pkgmgrinfo_appinfo_filter_destroy(filter);
1421 return PMINFO_R_ERROR;
1424 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
1425 PMINFO_APPINFO_PROP_APP_CHECK_STORAGE, false)) {
1426 pkgmgrinfo_appinfo_filter_destroy(filter);
1427 return PMINFO_R_ERROR;
1430 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter, flag, app_func,
1433 pkgmgrinfo_appinfo_filter_destroy(filter);
1438 API int pkgmgrinfo_appinfo_get_installed_list_full(
1439 pkgmgrinfo_app_list_cb app_func, int flag, void *user_data)
1441 return pkgmgrinfo_appinfo_get_usr_installed_list_full(app_func,
1442 _getuid(), flag, user_data);
1445 API int pkgmgrinfo_appinfo_get_usr_installed_list(
1446 pkgmgrinfo_app_list_cb app_func, uid_t uid, void *user_data)
1449 pkgmgrinfo_appinfo_filter_h filter;
1451 if (app_func == NULL) {
1452 LOGE("invalid parameter");
1453 return PMINFO_R_EINVAL;
1456 /* create an empty filter */
1457 ret = pkgmgrinfo_appinfo_filter_create(&filter);
1458 if (ret != PMINFO_R_OK)
1461 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
1462 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
1463 pkgmgrinfo_appinfo_filter_destroy(filter);
1464 return PMINFO_R_ERROR;
1467 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
1468 PMINFO_APPINFO_PROP_PKG_DISABLE, false)) {
1469 pkgmgrinfo_appinfo_filter_destroy(filter);
1470 return PMINFO_R_ERROR;
1473 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter,
1474 PMINFO_APPINFO_GET_ALL, app_func, user_data);
1476 pkgmgrinfo_appinfo_filter_destroy(filter);
1481 API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func,
1484 return pkgmgrinfo_appinfo_get_usr_installed_list(app_func, _getuid(),
1488 API int pkgmgrinfo_appinfo_get_appid(pkgmgrinfo_appinfo_h handle, char **appid)
1490 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1492 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1493 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1495 if (info->app_info == NULL || info->app_info->appid == NULL)
1496 return PMINFO_R_ERROR;
1497 *appid = (char *)info->app_info->appid;
1502 API int pkgmgrinfo_appinfo_get_pkgname(pkgmgrinfo_appinfo_h handle, char **pkg_name)
1504 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1506 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1507 retvm_if(pkg_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1509 if (info->package == NULL)
1510 return PMINFO_R_ERROR;
1512 *pkg_name = (char *)info->package;
1517 API int pkgmgrinfo_appinfo_get_pkgid(pkgmgrinfo_appinfo_h handle, char **pkgid)
1519 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1521 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1522 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1524 if (info->package == NULL)
1525 return PMINFO_R_ERROR;
1527 *pkgid = (char *)info->package;
1532 API int pkgmgrinfo_appinfo_get_pkgtype(pkgmgrinfo_appinfo_h handle, char **pkgtype)
1534 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1535 retvm_if(pkgtype == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1536 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1538 *pkgtype = (char *)info->app_info->package_type;
1543 API int pkgmgrinfo_appinfo_get_exec(pkgmgrinfo_appinfo_h handle, char **exec)
1545 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1547 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1548 retvm_if(exec == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1550 if (info->app_info == NULL || info->app_info->exec == NULL)
1551 return PMINFO_R_ERROR;
1552 *exec = (char *)info->app_info->exec;
1558 API int pkgmgrinfo_appinfo_get_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1561 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1563 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1564 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1566 if (info->app_info == NULL)
1567 return PMINFO_R_ERROR;
1569 if (info->app_info->icon == NULL) {
1574 ptr = (icon_x *)info->app_info->icon->data;
1576 return PMINFO_R_ERROR;
1578 if (ptr->text == NULL)
1579 return PMINFO_R_ERROR;
1587 API int pkgmgrinfo_appinfo_get_label(pkgmgrinfo_appinfo_h handle, char **label)
1590 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1595 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1596 retvm_if(label == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1598 if (info->app_info == NULL)
1599 return PMINFO_R_ERROR;
1601 locale = info->locale;
1603 locale = DEFAULT_LOCALE;
1605 for (tmp = info->app_info->label; tmp; tmp = tmp->next) {
1606 ptr = (label_x *)tmp->data;
1607 if (ptr == NULL || strcmp(locale, ptr->lang) != 0)
1618 for (tmp = info->app_info->label; tmp; tmp = tmp->next) {
1619 ptr = (label_x *)tmp->data;
1620 if (ptr == NULL || strcmp(DEFAULT_LOCALE, ptr->lang) != 0)
1626 *label = lbl ? lbl : "";
1631 static char *_get_localed_label(const char *appid, const char *locale, uid_t uid)
1633 char *result = NULL;
1635 sqlite3_stmt *stmt = NULL;
1640 parser_db = getUserPkgParserDBPathUID(uid);
1641 if (parser_db == NULL) {
1642 _LOGE("Failed to get parser db path");
1646 if (__open_db(parser_db, &db, SQLITE_OPEN_READONLY) != SQLITE_OK) {
1647 _LOGE("DB open fail\n");
1653 query = sqlite3_mprintf("select app_label from package_app_localized_info where app_id=%Q and app_locale=%Q", appid, locale);
1654 if (query == NULL) {
1655 _LOGE("Out of memory");
1659 if (sqlite3_prepare_v2(db, query, -1, &stmt, NULL) != SQLITE_OK) {
1660 _LOGE("prepare_v2 fail\n");
1664 if (sqlite3_step(stmt) == SQLITE_ROW) {
1665 val = (char *)sqlite3_column_text(stmt, 0);
1667 result = strdup(val);
1671 sqlite3_finalize(stmt);
1672 sqlite3_free(query);
1678 API int pkgmgrinfo_appinfo_usr_get_localed_label(const char *appid, const char *locale, uid_t uid, char **label)
1682 retvm_if(appid == NULL || locale == NULL || label == NULL, PMINFO_R_EINVAL, "Argument is NULL");
1684 val = _get_localed_label(appid, locale, uid);
1686 val = _get_localed_label(appid, DEFAULT_LOCALE, uid);
1689 val = _get_localed_label(appid, locale, GLOBAL_USER);
1691 val = _get_localed_label(appid, DEFAULT_LOCALE, GLOBAL_USER);
1695 return PMINFO_R_ERROR;
1702 API int pkgmgrinfo_appinfo_get_localed_label(const char *appid, const char *locale, char **label)
1704 return pkgmgrinfo_appinfo_usr_get_localed_label(appid, locale, _getuid(), label);
1707 API int pkgmgrinfo_appinfo_get_metadata_value(pkgmgrinfo_appinfo_h handle, const char *metadata_key, char **metadata_value)
1709 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1710 retvm_if(metadata_key == NULL, PMINFO_R_EINVAL, "metadata_key is NULL");
1711 retvm_if(metadata_value == NULL, PMINFO_R_EINVAL, "metadata_value is NULL");
1713 GList *list_md = NULL;
1714 metadata_x *metadata = NULL;
1715 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1717 list_md = info->app_info->metadata;
1719 for (; list_md; list_md = list_md->next) {
1720 metadata = (metadata_x *)list_md->data;
1721 if (metadata && metadata->key) {
1722 if (strcasecmp(metadata->key, metadata_key) == 0) {
1723 if (metadata->value == NULL)
1724 *metadata_value = "";
1726 *metadata_value = (char *)metadata->value;
1732 return PMINFO_R_EINVAL;
1735 static pkgmgrinfo_app_component __appcomponent_convert(const char *comp)
1737 if (strcasecmp(comp, "uiapp") == 0)
1738 return PMINFO_UI_APP;
1739 else if (strcasecmp(comp, "svcapp") == 0)
1740 return PMINFO_SVC_APP;
1741 else if (strcasecmp(comp, "widgetapp") == 0)
1742 return PMINFO_WIDGET_APP;
1743 else if (strcasecmp(comp, "watchapp") == 0)
1744 return PMINFO_WATCH_APP;
1745 else if (strcasecmp(comp, "componentbasedapp") == 0)
1746 return PMINFO_COMPONENT_BASED_APP;
1751 static const char *__appcomponent_str(pkgmgrinfo_app_component comp)
1756 case PMINFO_SVC_APP:
1758 case PMINFO_WIDGET_APP:
1760 case PMINFO_WATCH_APP:
1762 case PMINFO_COMPONENT_BASED_APP:
1763 return "componentbasedapp";
1769 API int pkgmgrinfo_appinfo_get_component(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_component *component)
1771 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1774 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1775 retvm_if(component == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1777 if (info->app_info == NULL)
1778 return PMINFO_R_ERROR;
1780 comp = __appcomponent_convert(info->app_info->component);
1782 return PMINFO_R_ERROR;
1789 API int pkgmgrinfo_appinfo_get_apptype(pkgmgrinfo_appinfo_h handle, char **app_type)
1791 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1793 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1794 retvm_if(app_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1796 if (info->app_info == NULL || info->app_info->type == NULL)
1797 return PMINFO_R_ERROR;
1798 *app_type = (char *)info->app_info->type;
1803 API int pkgmgrinfo_appinfo_get_operation(pkgmgrinfo_appcontrol_h handle,
1804 int *operation_count, char ***operation)
1806 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1807 retvm_if(operation == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1808 retvm_if(operation_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1809 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1810 *operation_count = data->operation_count;
1811 *operation = data->operation;
1815 API int pkgmgrinfo_appinfo_get_uri(pkgmgrinfo_appcontrol_h handle,
1816 int *uri_count, char ***uri)
1818 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1819 retvm_if(uri == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1820 retvm_if(uri_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1821 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1822 *uri_count = data->uri_count;
1827 API int pkgmgrinfo_appinfo_get_mime(pkgmgrinfo_appcontrol_h handle,
1828 int *mime_count, char ***mime)
1830 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1831 retvm_if(mime == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1832 retvm_if(mime_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1833 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1834 *mime_count = data->mime_count;
1839 API int pkgmgrinfo_appinfo_get_subapp(pkgmgrinfo_appcontrol_h handle,
1840 int *subapp_count, char ***subapp)
1842 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1843 retvm_if(subapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1844 retvm_if(subapp_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1845 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1846 *subapp_count = data->subapp_count;
1847 *subapp = data->subapp;
1851 API int pkgmgrinfo_appinfo_get_notification_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1856 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1858 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1859 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1861 if (info->app_info == NULL)
1862 return PMINFO_R_ERROR;
1864 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1865 ptr = (icon_x *)tmp->data;
1866 if (ptr == NULL || ptr->section == NULL)
1869 val = (char *)ptr->section;
1870 if (val && strcmp(val, "notification") == 0) {
1871 *icon = (char *)ptr->text;
1876 return PMINFO_R_ERROR;
1879 API int pkgmgrinfo_appinfo_get_recent_image_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_recentimage *type)
1882 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1884 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1885 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1887 if (info->app_info == NULL || info->app_info->recentimage == NULL)
1888 return PMINFO_R_ERROR;
1890 val = (char *)info->app_info->recentimage;
1891 if (strcasecmp(val, "capture") == 0)
1892 *type = PMINFO_RECENTIMAGE_USE_CAPTURE;
1893 else if (strcasecmp(val, "icon") == 0)
1894 *type = PMINFO_RECENTIMAGE_USE_ICON;
1896 *type = PMINFO_RECENTIMAGE_USE_NOTHING;
1901 API int pkgmgrinfo_appinfo_get_preview_image(pkgmgrinfo_appinfo_h handle, char **preview_img)
1906 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1908 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1909 retvm_if(preview_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1911 if (info->app_info == NULL)
1912 return PMINFO_R_ERROR;
1914 for (tmp = info->app_info->image; tmp; tmp = tmp->next) {
1915 ptr = (image_x *)tmp->data;
1916 if (ptr == NULL || ptr->section == NULL)
1919 val = (char *)ptr->section;
1920 if (val && strcmp(val, "preview") == 0) {
1921 *preview_img = (char *)ptr->text;
1926 return PMINFO_R_ERROR;
1929 API int pkgmgrinfo_appinfo_get_permission_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_permission_type *permission)
1932 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1934 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1935 retvm_if(permission == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1937 val = info->app_info->permission_type;
1939 return PMINFO_R_ERROR;
1941 if (strcmp(val, "signature") == 0)
1942 *permission = PMINFO_PERMISSION_SIGNATURE;
1943 else if (strcmp(val, "privilege") == 0)
1944 *permission = PMINFO_PERMISSION_PRIVILEGE;
1946 *permission = PMINFO_PERMISSION_NORMAL;
1951 API int pkgmgrinfo_appinfo_get_component_type(pkgmgrinfo_appinfo_h handle, char **component_type)
1953 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1955 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1956 retvm_if(component_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1958 if (info->app_info == NULL || info->app_info->component_type == NULL)
1959 return PMINFO_R_ERROR;
1961 *component_type = (char *)info->app_info->component_type;
1966 API int pkgmgrinfo_appinfo_get_hwacceleration(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_hwacceleration *hwacceleration)
1969 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1971 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1972 retvm_if(hwacceleration == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1974 if (info->app_info == NULL || info->app_info->hwacceleration == NULL)
1975 return PMINFO_R_ERROR;
1977 val = (char *)info->app_info->hwacceleration;
1978 if (strcasecmp(val, "off") == 0)
1979 *hwacceleration = PMINFO_HWACCELERATION_OFF;
1980 else if (strcasecmp(val, "on") == 0)
1981 *hwacceleration = PMINFO_HWACCELERATION_ON;
1983 *hwacceleration = PMINFO_HWACCELERATION_DEFAULT;
1988 API int pkgmgrinfo_appinfo_get_screenreader(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_screenreader *screenreader)
1991 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1993 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1994 retvm_if(screenreader == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1996 if (info->app_info == NULL || info->app_info->screenreader == NULL)
1997 return PMINFO_R_ERROR;
1999 val = (char *)info->app_info->screenreader;
2000 if (strcasecmp(val, "screenreader-off") == 0)
2001 *screenreader = PMINFO_SCREENREADER_OFF;
2002 else if (strcasecmp(val, "screenreader-on") == 0)
2003 *screenreader = PMINFO_SCREENREADER_ON;
2005 *screenreader = PMINFO_SCREENREADER_USE_SYSTEM_SETTING;
2010 API int pkgmgrinfo_appinfo_get_effectimage(pkgmgrinfo_appinfo_h handle, char **portrait_img, char **landscape_img)
2012 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2014 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2015 retvm_if(portrait_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2016 retvm_if(landscape_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2018 if (info->app_info == NULL)
2019 return PMINFO_R_ERROR;
2021 if (info->app_info->portraitimg == NULL)
2024 *portrait_img = (char *)info->app_info->portraitimg;
2026 if (info->app_info->landscapeimg == NULL)
2027 *landscape_img = "";
2029 *landscape_img = (char *)info->app_info->landscapeimg;
2034 API int pkgmgrinfo_appinfo_get_effectimage_type(pkgmgrinfo_appinfo_h handle, char **effectimage_type)
2036 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2038 if (handle == NULL || effectimage_type == NULL) {
2039 LOGE("invalid parameter");
2040 return PMINFO_R_EINVAL;
2043 if (info->app_info == NULL || info->app_info->effectimage_type == NULL)
2044 return PMINFO_R_ERROR;
2046 *effectimage_type = (char *)info->app_info->effectimage_type;
2051 API int pkgmgrinfo_appinfo_get_submode_mainid(pkgmgrinfo_appinfo_h handle, char **submode_mainid)
2053 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2055 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2056 retvm_if(submode_mainid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2058 if (info->app_info == NULL)
2059 return PMINFO_R_ERROR;
2061 if (info->app_info->submode_mainid == NULL)
2062 *submode_mainid = "";
2064 *submode_mainid = (char *)info->app_info->submode_mainid;
2069 API int pkgmgrinfo_appinfo_get_installed_storage_location(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_installed_storage *storage)
2071 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2072 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2074 if (info->app_info && info->app_info->installed_storage) {
2075 if (strcmp(info->app_info->installed_storage, "installed_internal") == 0)
2076 *storage = PMINFO_INTERNAL_STORAGE;
2077 else if (strcmp(info->app_info->installed_storage, "installed_external") == 0)
2078 *storage = PMINFO_EXTERNAL_STORAGE;
2080 return PMINFO_R_ERROR;
2082 return PMINFO_R_ERROR;
2088 API int pkgmgrinfo_appinfo_get_launch_mode(pkgmgrinfo_appinfo_h handle, char **mode)
2090 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2092 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2093 retvm_if(mode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2095 if (info->app_info->launch_mode == NULL)
2096 return PMINFO_R_ERROR;
2098 *mode = (char *)(info->app_info->launch_mode);
2103 API int pkgmgrinfo_appinfo_get_alias_appid(pkgmgrinfo_appinfo_h handle, char **alias_appid)
2105 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2107 if (handle == NULL || alias_appid == NULL) {
2108 LOGE("invalid parameter");
2109 return PMINFO_R_EINVAL;
2112 if (info->app_info == NULL || info->app_info->alias_appid == NULL)
2113 return PMINFO_R_ERROR;
2115 *alias_appid = (char *)info->app_info->alias_appid;
2120 API int pkgmgrinfo_appinfo_get_effective_appid(pkgmgrinfo_appinfo_h handle, char **effective_appid)
2122 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2124 if (handle == NULL || effective_appid == NULL) {
2125 LOGE("invalid parameter");
2126 return PMINFO_R_EINVAL;
2129 if (info->app_info == NULL)
2130 return PMINFO_R_ERROR;
2132 if (info->app_info->effective_appid == NULL)
2133 *effective_appid = "";
2135 *effective_appid = (char *)info->app_info->effective_appid;
2140 API int pkgmgrinfo_appinfo_get_tep_name(pkgmgrinfo_appinfo_h handle, char **tep_name)
2142 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2144 if (handle == NULL || tep_name == NULL) {
2145 LOGE("invalid parameter");
2146 return PMINFO_R_EINVAL;
2149 if (info->app_info == NULL)
2150 return PMINFO_R_ERROR;
2152 if (info->app_info->tep_name == NULL)
2155 *tep_name = (char *)info->app_info->tep_name;
2160 API int pkgmgrinfo_appinfo_get_zip_mount_file(pkgmgrinfo_appinfo_h handle, char **zip_mount_file)
2162 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2164 if (handle == NULL || zip_mount_file == NULL) {
2165 LOGE("invalid parameter");
2166 return PMINFO_R_EINVAL;
2169 if (info->app_info == NULL)
2170 return PMINFO_R_ERROR;
2172 if (info->app_info->zip_mount_file == NULL)
2173 *zip_mount_file = "";
2175 *zip_mount_file = (char *)info->app_info->zip_mount_file;
2180 API int pkgmgrinfo_appinfo_get_root_path(pkgmgrinfo_appinfo_h handle, char **root_path)
2182 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2184 if (handle == NULL || root_path == NULL) {
2185 LOGE("invalid parameter");
2186 return PMINFO_R_EINVAL;
2189 if (info->app_info == NULL || info->app_info->root_path == NULL)
2190 return PMINFO_R_ERROR;
2192 *root_path = (char *)info->app_info->root_path;
2197 API int pkgmgrinfo_appinfo_get_api_version(pkgmgrinfo_appinfo_h handle, char **api_version)
2199 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2201 if (handle == NULL || api_version == NULL) {
2202 LOGE("invalid parameter");
2203 return PMINFO_R_EINVAL;
2206 if (info->app_info == NULL || info->app_info->api_version == NULL)
2207 return PMINFO_R_ERROR;
2209 *api_version = (char *)info->app_info->api_version;
2214 API int pkgmgrinfo_appinfo_get_installed_time(pkgmgrinfo_appinfo_h handle, int *installed_time)
2216 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2218 if (handle == NULL || installed_time == NULL) {
2219 LOGE("invalid parameter");
2220 return PMINFO_R_EINVAL;
2223 if (info->app_info == NULL || info->app_info->package_installed_time == NULL)
2224 return PMINFO_R_ERROR;
2226 *installed_time = atoi(info->app_info->package_installed_time);
2231 static int _appinfo_get_datacontrol_info(sqlite3 *db, const char *providerid,
2232 const char *type, char **appid, char **access)
2234 static const char query[] =
2235 "SELECT app_id, access FROM package_app_data_control "
2236 "WHERE providerid=? AND type=?";
2240 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
2241 if (ret != SQLITE_OK) {
2242 LOGE("prepare failed: %s", sqlite3_errmsg(db));
2243 return PMINFO_R_ERROR;
2246 ret = sqlite3_bind_text(stmt, 1, providerid, -1, SQLITE_STATIC);
2247 if (ret != SQLITE_OK) {
2248 LOGE("bind failed: %s", sqlite3_errmsg(db));
2249 sqlite3_finalize(stmt);
2250 return PMINFO_R_ERROR;
2253 ret = sqlite3_bind_text(stmt, 2, type, -1, SQLITE_STATIC);
2254 if (ret != SQLITE_OK) {
2255 LOGE("bind failed: %s", sqlite3_errmsg(db));
2256 sqlite3_finalize(stmt);
2257 return PMINFO_R_ERROR;
2260 ret = sqlite3_step(stmt);
2261 if (ret != SQLITE_ROW) {
2262 sqlite3_finalize(stmt);
2263 if (ret == SQLITE_DONE) {
2264 return PMINFO_R_ENOENT;
2266 LOGE("step error: %s", sqlite3_errmsg(db));
2267 return PMINFO_R_ERROR;
2271 *appid = strdup((char *)sqlite3_column_text(stmt, 0));
2272 if (*appid == NULL) {
2273 LOGE("out of memory");
2274 sqlite3_finalize(stmt);
2275 return PMINFO_R_ERROR;
2277 *access = strdup((char *)sqlite3_column_text(stmt, 1));
2278 if (*access == NULL) {
2279 LOGE("out of memory");
2281 sqlite3_finalize(stmt);
2282 return PMINFO_R_ERROR;
2285 sqlite3_finalize(stmt);
2290 static int _pkgmgrinfo_appinfo_get_datacontrol_info(uid_t uid,
2291 const char *providerid, const char *type,
2292 char **appid, char **access)
2298 dbpath = getUserPkgParserDBPathUID(GLOBAL_USER);
2300 return PMINFO_R_ERROR;
2302 ret = __open_db(dbpath, &db, SQLITE_OPEN_READONLY);
2304 if (ret != SQLITE_OK) {
2305 LOGE("open db failed: %s", sqlite3_errmsg(db));
2306 return PMINFO_R_ERROR;
2309 ret = _appinfo_get_datacontrol_info(db, providerid, type, appid,
2311 sqlite3_close_v2(db);
2316 API int pkgmgrinfo_appinfo_usr_get_datacontrol_info(const char *providerid,
2317 const char *type, uid_t uid, char **appid, char **access)
2321 if (providerid == NULL || type == NULL || appid == NULL ||
2323 LOGE("invalid parameter");
2324 return PMINFO_R_EINVAL;
2327 ret = _pkgmgrinfo_appinfo_get_datacontrol_info(GLOBAL_USER, providerid,
2328 type, appid, access);
2329 if (ret == PMINFO_R_ENOENT && uid != GLOBAL_USER)
2330 ret = _pkgmgrinfo_appinfo_get_datacontrol_info(uid, providerid,
2331 type, appid, access);
2333 /* FIXME: It should return PMINFO_R_ENOENT but to keep previous
2334 * implementation, return PMINFO_R_ERROR. This should be
2337 if (ret == PMINFO_R_ENOENT) {
2338 LOGE("no datacontrol info of %s", providerid);
2339 ret = PMINFO_R_ERROR;
2345 API int pkgmgrinfo_appinfo_get_datacontrol_info(const char *providerid,
2346 const char *type, char **appid, char **access)
2348 return pkgmgrinfo_appinfo_usr_get_datacontrol_info(providerid,
2349 type, _getuid(), appid, access);
2352 static int _appinfo_get_datacontrol_appid(sqlite3 *db, const char *providerid,
2355 static const char query[] =
2356 "SELECT app_id FROM package_app_data_control "
2357 "WHERE providerid=?";
2361 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
2362 if (ret != SQLITE_OK) {
2363 LOGE("prepare failed: %s", sqlite3_errmsg(db));
2364 return PMINFO_R_ERROR;
2367 ret = sqlite3_bind_text(stmt, 1, providerid, -1, SQLITE_STATIC);
2368 if (ret != SQLITE_OK) {
2369 LOGE("bind failed: %s", sqlite3_errmsg(db));
2370 sqlite3_finalize(stmt);
2371 return PMINFO_R_ERROR;
2374 ret = sqlite3_step(stmt);
2375 if (ret != SQLITE_ROW) {
2376 sqlite3_finalize(stmt);
2377 if (ret == SQLITE_DONE) {
2378 return PMINFO_R_ENOENT;
2380 LOGE("step error: %s", sqlite3_errmsg(db));
2381 return PMINFO_R_ERROR;
2385 *appid = strdup((char *)sqlite3_column_text(stmt, 0));
2387 sqlite3_finalize(stmt);
2389 if (*appid == NULL) {
2390 LOGE("out of memory");
2391 return PMINFO_R_ERROR;
2397 static int _pkgmgrinfo_appinfo_get_datacontrol_appid(uid_t uid,
2398 const char *providerid, char **appid)
2404 dbpath = getUserPkgParserDBPathUID(GLOBAL_USER);
2406 return PMINFO_R_ERROR;
2408 ret = __open_db(dbpath, &db, SQLITE_OPEN_READONLY);
2410 if (ret != SQLITE_OK) {
2411 LOGE("open db failed: %s", sqlite3_errmsg(db));
2412 return PMINFO_R_ERROR;
2415 ret = _appinfo_get_datacontrol_appid(db, providerid, appid);
2416 sqlite3_close_v2(db);
2421 API int pkgmgrinfo_appinfo_usr_get_datacontrol_appid(const char *providerid,
2422 uid_t uid, char **appid)
2426 if (providerid == NULL || appid == NULL) {
2427 LOGE("invalid parameter");
2428 return PMINFO_R_EINVAL;
2431 ret = _pkgmgrinfo_appinfo_get_datacontrol_appid(GLOBAL_USER, providerid,
2433 if (ret == PMINFO_R_ENOENT && uid != GLOBAL_USER)
2434 ret = _pkgmgrinfo_appinfo_get_datacontrol_appid(uid, providerid,
2437 /* FIXME: It should return PMINFO_R_ENOENT but to keep previous
2438 * implementation, return PMINFO_R_ERROR. This should be
2441 if (ret == PMINFO_R_ENOENT) {
2442 LOGE("no datacontrol appid of %s", providerid);
2443 ret = PMINFO_R_ERROR;
2449 API int pkgmgrinfo_appinfo_get_datacontrol_appid(const char *providerid, char **appid)
2451 return pkgmgrinfo_appinfo_usr_get_datacontrol_appid(providerid, _getuid(), appid);
2454 static int _appinfo_get_datacontrol_trusted_info(sqlite3 *db,
2455 const char *providerid, const char *type, char **appid,
2458 static const char query[] =
2459 "SELECT app_id, trusted FROM package_app_data_control "
2460 "WHERE providerid=? AND type=?";
2464 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
2465 if (ret != SQLITE_OK) {
2466 LOGE("prepare failed: %s", sqlite3_errmsg(db));
2467 return PMINFO_R_ERROR;
2470 ret = sqlite3_bind_text(stmt, 1, providerid, -1, SQLITE_STATIC);
2471 if (ret != SQLITE_OK) {
2472 LOGE("bind failed: %s", sqlite3_errmsg(db));
2473 sqlite3_finalize(stmt);
2474 return PMINFO_R_ERROR;
2477 ret = sqlite3_bind_text(stmt, 2, type, -1, SQLITE_STATIC);
2478 if (ret != SQLITE_OK) {
2479 LOGE("bind failed: %s", sqlite3_errmsg(db));
2480 sqlite3_finalize(stmt);
2481 return PMINFO_R_ERROR;
2484 ret = sqlite3_step(stmt);
2485 if (ret != SQLITE_ROW) {
2486 sqlite3_finalize(stmt);
2487 if (ret == SQLITE_DONE) {
2488 return PMINFO_R_ENOENT;
2490 LOGE("step error: %s", sqlite3_errmsg(db));
2491 return PMINFO_R_ERROR;
2495 *appid = strdup((char *)sqlite3_column_text(stmt, 0));
2496 *is_trusted = _get_bool_value((char *)sqlite3_column_text(stmt, 1));
2498 sqlite3_finalize(stmt);
2500 if (*appid == NULL) {
2501 LOGE("out of memory");
2502 return PMINFO_R_ERROR;
2508 static int _pkgmgrinfo_appinfo_get_datacontrol_trusted_info(uid_t uid,
2509 const char *providerid, const char *type, char **appid,
2516 dbpath = getUserPkgParserDBPathUID(GLOBAL_USER);
2518 return PMINFO_R_ERROR;
2520 ret = __open_db(dbpath, &db, SQLITE_OPEN_READONLY);
2522 if (ret != SQLITE_OK) {
2523 LOGE("open db failed: %s", sqlite3_errmsg(db));
2524 return PMINFO_R_ERROR;
2527 ret = _appinfo_get_datacontrol_trusted_info(db, providerid, type, appid,
2529 sqlite3_close_v2(db);
2534 API int pkgmgrinfo_appinfo_usr_get_datacontrol_trusted_info(
2535 const char *providerid, const char *type, uid_t uid,
2536 char **appid, bool *is_trusted)
2540 if (providerid == NULL || type == NULL || appid == NULL ||
2541 is_trusted == NULL) {
2542 LOGE("invalid parameter");
2543 return PMINFO_R_EINVAL;
2546 ret = _pkgmgrinfo_appinfo_get_datacontrol_trusted_info(GLOBAL_USER,
2547 providerid, type, appid, is_trusted);
2548 if (ret == PMINFO_R_ENOENT && uid != GLOBAL_USER)
2549 ret = _pkgmgrinfo_appinfo_get_datacontrol_trusted_info(uid,
2550 providerid, type, appid, is_trusted);
2552 /* FIXME: It should return PMINFO_R_ENOENT but to keep previous
2553 * implementation, return PMINFO_R_ERROR. This should be
2556 if (ret == PMINFO_R_ENOENT) {
2557 LOGE("no datacontrol trusted info of %s", providerid);
2558 ret = PMINFO_R_ERROR;
2564 API int pkgmgrinfo_appinfo_get_datacontrol_trsuted_info(const char *providerid,
2565 const char *type, char **appid, bool *is_trusted)
2567 return pkgmgrinfo_appinfo_usr_get_datacontrol_trusted_info(providerid,
2568 type, _getuid(), appid, is_trusted);
2571 static int _appinfo_foreach_datacontrol_privileges(sqlite3 *db,
2572 const char *providerid, const char *type,
2573 pkgmgrinfo_pkg_privilege_list_cb callback, void *user_data)
2575 static const char query[] =
2576 "SELECT privilege FROM package_app_data_control_privilege "
2577 "WHERE providerid=? AND type=?";
2582 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
2583 if (ret != SQLITE_OK) {
2584 LOGE("prepare failed: %s", sqlite3_errmsg(db));
2585 return PMINFO_R_ERROR;
2588 ret = sqlite3_bind_text(stmt, 1, providerid, -1, SQLITE_STATIC);
2589 if (ret != SQLITE_OK) {
2590 LOGE("bind failed: %s", sqlite3_errmsg(db));
2591 sqlite3_finalize(stmt);
2592 return PMINFO_R_ERROR;
2595 ret = sqlite3_bind_text(stmt, 2, type, -1, SQLITE_STATIC);
2596 if (ret != SQLITE_OK) {
2597 LOGE("bind failed: %s", sqlite3_errmsg(db));
2598 sqlite3_finalize(stmt);
2599 return PMINFO_R_ERROR;
2602 while (sqlite3_step(stmt) == SQLITE_ROW) {
2604 ret = callback((const char *)sqlite3_column_text(stmt, 0),
2610 sqlite3_finalize(stmt);
2612 return count ? PMINFO_R_OK : PMINFO_R_ENOENT;
2615 static int _pkgmgrinfo_appinfo_foreach_datacontrol_privileges(uid_t uid,
2616 const char *providerid, const char *type,
2617 pkgmgrinfo_pkg_privilege_list_cb callback, void *user_data)
2623 dbpath = getUserPkgParserDBPathUID(GLOBAL_USER);
2625 return PMINFO_R_ERROR;
2627 ret = __open_db(dbpath, &db, SQLITE_OPEN_READONLY);
2629 if (ret != SQLITE_OK) {
2630 LOGE("open db failed: %s", sqlite3_errmsg(db));
2631 return PMINFO_R_ERROR;
2634 ret = _appinfo_foreach_datacontrol_privileges(db, providerid, type,
2635 callback, user_data);
2636 sqlite3_close_v2(db);
2641 API int pkgmgrinfo_appinfo_usr_foreach_datacontrol_privileges(
2642 const char *providerid, const char *type,
2643 pkgmgrinfo_pkg_privilege_list_cb privilege_func,
2644 void *user_data, uid_t uid)
2648 if (providerid == NULL || type == NULL || privilege_func == NULL) {
2649 LOGE("invalid parameter");
2650 return PMINFO_R_EINVAL;
2653 ret = _pkgmgrinfo_appinfo_foreach_datacontrol_privileges(GLOBAL_USER,
2654 providerid, type, privilege_func, user_data);
2655 if (ret == PMINFO_R_ENOENT && uid != GLOBAL_USER)
2656 ret = _pkgmgrinfo_appinfo_foreach_datacontrol_privileges(uid,
2657 providerid, type, privilege_func, user_data);
2659 if (ret == PMINFO_R_ENOENT)
2665 API int pkgmgrinfo_appinfo_foreach_datacontrol_privileges(
2666 const char *providerid, const char *type,
2667 pkgmgrinfo_pkg_privilege_list_cb privilege_func,
2670 return pkgmgrinfo_appinfo_usr_foreach_datacontrol_privileges(
2671 providerid, type, privilege_func, user_data, _getuid());
2674 API int pkgmgrinfo_appinfo_get_support_mode(pkgmgrinfo_appinfo_h handle, int *support_mode)
2676 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2677 retvm_if(support_mode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2679 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2680 if (info->app_info->support_mode)
2681 *support_mode = atoi(info->app_info->support_mode);
2688 API int pkgmgrinfo_appinfo_foreach_category(pkgmgrinfo_appinfo_h handle,
2689 pkgmgrinfo_app_category_list_cb category_func, void *user_data)
2691 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2692 retvm_if(category_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2694 const char *category;
2696 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2698 if (info->app_info == NULL)
2699 return PMINFO_R_ERROR;
2701 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
2702 category = (const char *)tmp->data;
2704 ret = category_func(category, user_data);
2712 API int pkgmgrinfo_appinfo_foreach_metadata(pkgmgrinfo_appinfo_h handle,
2713 pkgmgrinfo_app_metadata_list_cb metadata_func, void *user_data)
2715 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2716 retvm_if(metadata_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2720 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2722 if (info->app_info == NULL)
2723 return PMINFO_R_ERROR;
2725 for (tmp = info->app_info->metadata; tmp; tmp = tmp->next) {
2726 ptr = (metadata_x *)tmp->data;
2730 ret = metadata_func(ptr->key, ptr->value ? ptr->value : "", user_data);
2738 static int _appinfo_foreach_appcontrol_privileges(sqlite3 *db,
2739 const char *appid, const char *operation,
2740 pkgmgrinfo_pkg_privilege_list_cb callback, void *user_data)
2742 static const char query[] =
2743 "SELECT app_control, privilege FROM package_app_app_control_privilege "
2747 const char *app_control;
2748 char *dup_app_control;
2750 char *saveptr = NULL;
2751 const char *privilege;
2754 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
2755 if (ret != SQLITE_OK) {
2756 LOGE("prepare failed: %s", sqlite3_errmsg(db));
2757 return PMINFO_R_ERROR;
2760 ret = sqlite3_bind_text(stmt, 1, appid, -1, SQLITE_STATIC);
2761 if (ret != SQLITE_OK) {
2762 LOGE("bind failed: %s", sqlite3_errmsg(db));
2763 sqlite3_finalize(stmt);
2764 return PMINFO_R_ERROR;
2767 while (sqlite3_step(stmt) == SQLITE_ROW) {
2768 app_control = (const char *)sqlite3_column_text(stmt, 0);
2772 dup_app_control = strdup(app_control);
2773 if (!dup_app_control)
2776 token = strtok_r(dup_app_control, "|", &saveptr);
2777 if (token && !strcmp(token, operation)) {
2779 privilege = (const char *)sqlite3_column_text(stmt, 1);
2780 ret = callback(privilege, user_data);
2782 free(dup_app_control);
2786 free(dup_app_control);
2789 sqlite3_finalize(stmt);
2791 return count ? PMINFO_R_OK : PMINFO_R_ENOENT;
2794 static int _pkgmgrinfo_appinfo_foreach_appcontrol_privileges(uid_t uid,
2795 const char *appid, const char *operation,
2796 pkgmgrinfo_pkg_privilege_list_cb callback, void *user_data)
2802 dbpath = getUserPkgParserDBPathUID(uid);
2804 return PMINFO_R_ERROR;
2806 ret = __open_db(dbpath, &db, SQLITE_OPEN_READONLY);
2808 if (ret != SQLITE_OK) {
2809 LOGE("open db failed: %s", sqlite3_errmsg(db));
2810 return PMINFO_R_ERROR;
2813 ret = _appinfo_foreach_appcontrol_privileges(db, appid, operation,
2814 callback, user_data);
2815 sqlite3_close_v2(db);
2820 API int pkgmgrinfo_appinfo_usr_foreach_appcontrol_privileges(const char *appid,
2821 const char *operation,
2822 pkgmgrinfo_pkg_privilege_list_cb privilege_func,
2823 void *user_data, uid_t uid)
2827 if (appid == NULL || operation == NULL || privilege_func == NULL) {
2828 LOGE("invalid parameter");
2829 return PMINFO_R_EINVAL;
2832 ret = _pkgmgrinfo_appinfo_foreach_appcontrol_privileges(GLOBAL_USER,
2833 appid, operation, privilege_func, user_data);
2834 if (ret == PMINFO_R_ENOENT && uid != GLOBAL_USER)
2835 ret = _pkgmgrinfo_appinfo_foreach_appcontrol_privileges(uid,
2836 appid, operation, privilege_func, user_data);
2838 if (ret == PMINFO_R_ENOENT)
2844 API int pkgmgrinfo_appinfo_foreach_appcontrol_privileges(const char *appid,
2845 const char *operation,
2846 pkgmgrinfo_pkg_privilege_list_cb privilege_func,
2849 return pkgmgrinfo_appinfo_usr_foreach_appcontrol_privileges(appid,
2850 operation, privilege_func, user_data, _getuid());
2853 API int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
2854 pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
2856 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2857 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2859 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2860 appcontrol_x *appcontrol;
2863 if (info->app_info == NULL)
2864 return PMINFO_R_ERROR;
2866 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
2867 appcontrol = (appcontrol_x *)tmp->data;
2868 if (appcontrol == NULL || !strcasecmp(appcontrol->visibility, "remote-only"))
2870 ret = appcontrol_func(appcontrol->operation, appcontrol->uri, appcontrol->mime, user_data);
2878 API int pkgmgrinfo_appinfo_foreach_remote_appcontrol(pkgmgrinfo_appinfo_h handle,
2879 pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
2881 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2882 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2884 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2885 appcontrol_x *appcontrol;
2888 if (info->app_info == NULL)
2889 return PMINFO_R_ERROR;
2891 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
2892 appcontrol = (appcontrol_x *)tmp->data;
2893 if (appcontrol == NULL || !strcasecmp(appcontrol->visibility, "local-only"))
2895 ret = appcontrol_func(appcontrol->operation, appcontrol->uri, appcontrol->mime, user_data);
2903 API int pkgmgrinfo_appinfo_foreach_background_category(
2904 pkgmgrinfo_appinfo_h handle,
2905 pkgmgrinfo_app_background_category_list_cb category_func,
2908 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2912 if (handle == NULL || category_func == NULL || info->app_info == NULL) {
2913 LOGE("invalid parameter");
2914 return PMINFO_R_EINVAL;
2917 for (tmp = info->app_info->background_category; tmp; tmp = tmp->next) {
2918 category = (char *)tmp->data;
2919 if (category == NULL)
2922 if (category_func(category, user_data) < 0)
2929 API int pkgmgrinfo_appinfo_foreach_splash_screen(pkgmgrinfo_appinfo_h handle,
2930 pkgmgrinfo_app_splash_screen_list_cb splash_screen_func,
2933 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2934 splashscreen_x *splashscreen;
2938 if (info == NULL || info->app_info == NULL
2939 || splash_screen_func == NULL) {
2940 LOGE("invalid parameter");
2941 return PMINFO_R_EINVAL;
2944 for (tmp = info->app_info->splashscreens; tmp; tmp = tmp->next) {
2945 splashscreen = (splashscreen_x *)tmp->data;
2946 if (splashscreen == NULL)
2948 ret = splash_screen_func(splashscreen->src,
2950 splashscreen->orientation,
2951 splashscreen->indicatordisplay,
2952 splashscreen->operation,
2953 splashscreen->color_depth,
2962 API int pkgmgrinfo_appinfo_is_nodisplay(pkgmgrinfo_appinfo_h handle, bool *nodisplay)
2964 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2965 retvm_if(nodisplay == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2966 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2968 if (info->app_info == NULL || info->app_info->nodisplay == NULL)
2969 return PMINFO_R_ERROR;
2971 *nodisplay = _get_bool_value(info->app_info->nodisplay);
2976 API int pkgmgrinfo_appinfo_is_multiple(pkgmgrinfo_appinfo_h handle, bool *multiple)
2978 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2979 retvm_if(multiple == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2980 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2982 if (info->app_info == NULL || info->app_info->multiple == NULL)
2983 return PMINFO_R_ERROR;
2985 *multiple = _get_bool_value(info->app_info->multiple);
2990 API int pkgmgrinfo_appinfo_is_indicator_display_allowed(pkgmgrinfo_appinfo_h handle, bool *indicator_disp)
2992 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2993 retvm_if(indicator_disp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2994 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2996 if (info->app_info == NULL || info->app_info->indicatordisplay == NULL)
2997 return PMINFO_R_ERROR;
2999 *indicator_disp = _get_bool_value(info->app_info->indicatordisplay);
3004 API int pkgmgrinfo_appinfo_is_taskmanage(pkgmgrinfo_appinfo_h handle, bool *taskmanage)
3006 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
3007 retvm_if(taskmanage == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
3008 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3010 if (info->app_info == NULL || info->app_info->taskmanage == NULL)
3011 return PMINFO_R_ERROR;
3013 *taskmanage = _get_bool_value(info->app_info->taskmanage);
3018 API int pkgmgrinfo_appinfo_is_enabled(pkgmgrinfo_appinfo_h handle, bool *enabled)
3020 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
3021 retvm_if(enabled == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
3022 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3024 if (info->app_info == NULL || info->app_info->is_disabled == NULL)
3025 return PMINFO_R_ERROR;
3027 *enabled = !_get_bool_value(info->app_info->is_disabled);
3032 API int pkgmgrinfo_appinfo_is_onboot(pkgmgrinfo_appinfo_h handle, bool *onboot)
3034 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
3035 retvm_if(onboot == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
3036 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3038 if (info->app_info == NULL || info->app_info->onboot == NULL)
3039 return PMINFO_R_ERROR;
3041 *onboot = _get_bool_value(info->app_info->onboot);
3046 API int pkgmgrinfo_appinfo_is_autorestart(pkgmgrinfo_appinfo_h handle, bool *autorestart)
3048 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
3049 retvm_if(autorestart == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
3050 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3052 if (info->app_info == NULL || info->app_info->autorestart == NULL)
3053 return PMINFO_R_ERROR;
3055 *autorestart = _get_bool_value(info->app_info->autorestart);
3060 API int pkgmgrinfo_appinfo_is_mainapp(pkgmgrinfo_appinfo_h handle, bool *mainapp)
3062 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
3063 retvm_if(mainapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
3064 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3066 if (info->app_info == NULL || info->app_info->mainapp == NULL)
3067 return PMINFO_R_ERROR;
3069 *mainapp = _get_bool_value(info->app_info->mainapp);
3074 API int pkgmgrinfo_appinfo_is_preload(pkgmgrinfo_appinfo_h handle, bool *preload)
3076 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
3077 retvm_if(preload == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3078 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3080 if (info->app_info == NULL || info->app_info->preload == NULL)
3081 return PMINFO_R_ERROR;
3083 *preload = _get_bool_value(info->app_info->preload);
3088 API int pkgmgrinfo_appinfo_is_submode(pkgmgrinfo_appinfo_h handle, bool *submode)
3090 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
3091 retvm_if(submode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3092 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3094 if (info->app_info == NULL || info->app_info->submode == NULL)
3095 return PMINFO_R_ERROR;
3097 *submode = _get_bool_value(info->app_info->submode);
3102 API int pkgmgrinfo_appinfo_is_process_pool(pkgmgrinfo_appinfo_h handle, bool *process_pool)
3104 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3106 if (handle == NULL || process_pool == NULL) {
3107 LOGE("invalid parameter");
3108 return PMINFO_R_EINVAL;
3111 if (info->app_info == NULL)
3112 return PMINFO_R_ERROR;
3114 *process_pool = _get_bool_value(info->app_info->process_pool);
3119 API int pkgmgrinfo_appinfo_is_category_exist(pkgmgrinfo_appinfo_h handle, const char *category, bool *exist)
3121 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
3122 retvm_if(category == NULL, PMINFO_R_EINVAL, "category is NULL");
3123 retvm_if(exist == NULL, PMINFO_R_EINVAL, "exist is NULL");
3127 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3129 if (info->app_info == NULL)
3130 return PMINFO_R_ERROR;
3133 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
3134 val = (const char *)tmp->data;
3137 if (strcasecmp(val, category) == 0) {
3146 API int pkgmgrinfo_appinfo_is_ui_gadget(pkgmgrinfo_appinfo_h handle,
3149 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3151 if (info == NULL || info->app_info == NULL || ui_gadget == NULL) {
3152 _LOGE("invalid parameter");
3153 return PMINFO_R_EINVAL;
3155 if (info->app_info->ui_gadget == NULL)
3156 info->app_info->ui_gadget = strdup("false");
3158 *ui_gadget = _get_bool_value(info->app_info->ui_gadget);
3163 API int pkgmgrinfo_appinfo_is_support_disable(pkgmgrinfo_appinfo_h handle,
3164 bool *support_disable)
3166 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3168 if (info == NULL || info->app_info == NULL || support_disable == NULL) {
3169 _LOGE("invalid parameter");
3170 return PMINFO_R_EINVAL;
3173 *support_disable = _get_bool_value(info->app_info->support_disable);
3178 API int pkgmgrinfo_appinfo_is_removable(pkgmgrinfo_appinfo_h handle,
3181 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3183 if (info == NULL || info->app_info == NULL || removable == NULL) {
3184 _LOGE("invalid parameter");
3185 return PMINFO_R_EINVAL;
3188 *removable = _get_bool_value(info->app_info->removable);
3193 API int pkgmgrinfo_appinfo_is_system(pkgmgrinfo_appinfo_h handle, bool *system)
3195 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3197 if (info == NULL || info->app_info == NULL || system == NULL) {
3198 _LOGE("invalid parameter");
3199 return PMINFO_R_EINVAL;
3202 *system = _get_bool_value(info->app_info->package_system);
3207 API int pkgmgrinfo_appinfo_is_disabled(pkgmgrinfo_appinfo_h handle, bool *disabled)
3209 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
3210 retvm_if(disabled == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
3211 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3213 if (info->app_info == NULL || info->app_info->is_disabled == NULL)
3214 return PMINFO_R_ERROR;
3216 *disabled = _get_bool_value(info->app_info->is_disabled);
3221 API int pkgmgrinfo_appinfo_is_global(pkgmgrinfo_appinfo_h handle, bool *global)
3223 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3225 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
3226 retvm_if(global == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3228 if (info->app_info == NULL || info->app_info->for_all_users == NULL)
3229 return PMINFO_R_ERROR;
3231 *global = _get_bool_value(info->app_info->for_all_users);
3236 API int pkgmgrinfo_appinfo_get_splash_screen_display(pkgmgrinfo_appinfo_h handle, bool *splash_screen_display)
3238 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3240 if (info == NULL || splash_screen_display == NULL) {
3241 _LOGE("Invalid parameter");
3242 return PMINFO_R_EINVAL;
3245 if (info->app_info == NULL || info->app_info->splash_screen_display == NULL)
3246 return PMINFO_R_ERROR;
3248 *splash_screen_display = _get_bool_value(info->app_info->splash_screen_display);
3253 API int pkgmgrinfo_appinfo_get_setup_appid(pkgmgrinfo_appinfo_h handle, char **setup_appid)
3255 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3257 if (info == NULL || setup_appid == NULL) {
3258 _LOGE("Invalid parameter");
3259 return PMINFO_R_EINVAL;
3262 if (info->app_info == NULL || info->app_info->setup_appid == NULL)
3263 return PMINFO_R_ERROR;
3265 *setup_appid = info->app_info->setup_appid;
3269 API int pkgmgrinfo_appinfo_is_support_ambient(pkgmgrinfo_appinfo_h handle,
3270 bool *support_ambient)
3272 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3274 if (info == NULL || support_ambient == NULL) {
3275 _LOGE("Invalid parameter");
3276 return PMINFO_R_EINVAL;
3279 if (info->app_info == NULL || info->app_info->support_ambient == NULL)
3280 return PMINFO_R_ERROR;
3282 *support_ambient = _get_bool_value(info->app_info->support_ambient);
3287 API int pkgmgrinfo_appinfo_destroy_appinfo(pkgmgrinfo_appinfo_h handle)
3289 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
3290 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3291 __cleanup_appinfo(info);
3295 API int pkgmgrinfo_appinfo_filter_create(pkgmgrinfo_appinfo_filter_h *handle)
3297 return (pkgmgrinfo_pkginfo_filter_create(handle));
3300 API int pkgmgrinfo_appinfo_filter_destroy(pkgmgrinfo_appinfo_filter_h handle)
3302 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
3305 static gint __compare_func(gconstpointer data1, gconstpointer data2)
3307 pkgmgrinfo_node_x *node1 = (pkgmgrinfo_node_x *)data1;
3308 pkgmgrinfo_node_x *node2 = (pkgmgrinfo_node_x *)data2;
3309 if (node1->prop == node2->prop)
3311 else if (node1->prop > node2->prop)
3317 API int pkgmgrinfo_appinfo_filter_add_int(pkgmgrinfo_appinfo_filter_h handle,
3318 const char *property, const int value)
3320 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3321 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3322 char buf[PKG_VALUE_STRING_LEN_MAX] = {'\0'};
3324 GSList *link = NULL;
3326 prop = _pminfo_appinfo_convert_to_prop_int(property);
3327 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_INT ||
3328 prop > E_PMINFO_APPINFO_PROP_APP_MAX_INT) {
3329 _LOGE("Invalid Integer Property\n");
3330 return PMINFO_R_EINVAL;
3332 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
3333 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1, sizeof(pkgmgrinfo_node_x));
3335 _LOGE("Out of Memory!!!\n");
3336 return PMINFO_R_ERROR;
3338 snprintf(buf, PKG_VALUE_STRING_LEN_MAX - 1, "%d", value);
3339 val = strndup(buf, PKG_VALUE_STRING_LEN_MAX - 1);
3341 _LOGE("Out of Memory\n");
3344 return PMINFO_R_ERROR;
3348 /*If API is called multiple times for same property, we should override the previous values.
3349 Last value set will be used for filtering.*/
3350 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
3352 filter->list = g_slist_delete_link(filter->list, link);
3353 filter->list = g_slist_append(filter->list, (gpointer)node);
3358 API int pkgmgrinfo_appinfo_filter_add_bool(pkgmgrinfo_appinfo_filter_h handle,
3359 const char *property, const bool value)
3361 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3362 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3364 GSList *link = NULL;
3366 prop = _pminfo_appinfo_convert_to_prop_bool(property);
3367 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_BOOL ||
3368 prop > E_PMINFO_APPINFO_PROP_APP_MAX_BOOL) {
3369 _LOGE("Invalid Boolean Property\n");
3370 return PMINFO_R_EINVAL;
3372 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
3373 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1, sizeof(pkgmgrinfo_node_x));
3375 _LOGE("Out of Memory!!!\n");
3376 return PMINFO_R_ERROR;
3379 val = strndup("true", 4);
3381 val = strndup("false", 5);
3383 _LOGE("Out of Memory\n");
3386 return PMINFO_R_ERROR;
3390 /*If API is called multiple times for same property, we should override the previous values.
3391 Last value set will be used for filtering.*/
3392 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
3394 filter->list = g_slist_delete_link(filter->list, link);
3395 filter->list = g_slist_append(filter->list, (gpointer)node);
3400 API int pkgmgrinfo_appinfo_filter_add_string(pkgmgrinfo_appinfo_filter_h handle,
3401 const char *property, const char *value)
3403 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3404 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3405 retvm_if(value == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3407 pkgmgrinfo_node_x *ptr = NULL;
3408 char prev[PKG_STRING_LEN_MAX] = {'\0'};
3409 char temp[PKG_STRING_LEN_MAX] = {'\0'};
3410 GSList *link = NULL;
3413 prop = _pminfo_appinfo_convert_to_prop_str(property);
3414 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_STR ||
3415 prop > E_PMINFO_APPINFO_PROP_APP_MAX_STR) {
3416 _LOGE("Invalid String Property\n");
3417 return PMINFO_R_EINVAL;
3419 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
3420 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1, sizeof(pkgmgrinfo_node_x));
3422 _LOGE("Out of Memory!!!\n");
3423 return PMINFO_R_ERROR;
3427 case E_PMINFO_APPINFO_PROP_APP_COMPONENT:
3428 node->value = strdup(value);
3429 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
3431 filter->list = g_slist_delete_link(filter->list, link);
3432 filter->list = g_slist_append(filter->list, (gpointer)node);
3434 case E_PMINFO_APPINFO_PROP_APP_CATEGORY:
3435 val = (char *)calloc(1, PKG_STRING_LEN_MAX);
3437 _LOGE("Out of Memory\n");
3440 return PMINFO_R_ERROR;
3442 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
3444 ptr = (pkgmgrinfo_node_x *)link->data;
3445 strncpy(prev, ptr->value, PKG_STRING_LEN_MAX - 1);
3446 _LOGI("Previous value is %s\n", prev);
3447 filter->list = g_slist_delete_link(filter->list, link);
3448 ret = snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s,%s", prev, value);
3449 if (ret < 0 || ret > PKG_STRING_LEN_MAX - 1) {
3450 _LOGE("snprintf fail\n");
3453 return PMINFO_R_ERROR;
3455 strncpy(val, temp, PKG_STRING_LEN_MAX);
3456 _LOGI("New value is %s\n", val);
3458 filter->list = g_slist_append(filter->list, (gpointer)node);
3459 memset(temp, '\0', PKG_STRING_LEN_MAX);
3461 snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s", value);
3462 strncpy(val, temp, PKG_STRING_LEN_MAX);
3463 _LOGI("First value is %s\n", val);
3465 filter->list = g_slist_append(filter->list, (gpointer)node);
3466 memset(temp, '\0', PKG_STRING_LEN_MAX);
3470 node->value = strndup(value, PKG_STRING_LEN_MAX - 1);
3471 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
3473 filter->list = g_slist_delete_link(filter->list, link);
3474 filter->list = g_slist_append(filter->list, (gpointer)node);
3480 API int pkgmgrinfo_appinfo_usr_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count, uid_t uid)
3486 if (handle == NULL || count == NULL) {
3487 _LOGE("invalid parameter");
3488 return PMINFO_R_EINVAL;
3491 locale = _get_system_locale();
3493 return PMINFO_R_ERROR;
3495 list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
3496 __free_applications);
3499 return PMINFO_R_ERROR;
3502 if (__check_disable_filter_exist(
3503 handle, E_APPINFO_DISABLE_TYPE_APP) == false) {
3504 if (pkgmgrinfo_appinfo_filter_add_bool(handle,
3505 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
3506 g_hash_table_destroy(list);
3508 return PMINFO_R_ERROR;
3512 if (__check_disable_filter_exist(
3513 handle, E_APPINFO_DISABLE_TYPE_PKG) == false) {
3514 if (pkgmgrinfo_appinfo_filter_add_bool(handle,
3515 PMINFO_APPINFO_PROP_PKG_DISABLE, false)) {
3516 g_hash_table_destroy(list);
3518 return PMINFO_R_ERROR;
3522 ret = _appinfo_get_applications(uid, uid, locale, handle, 0, list);
3523 if (ret == PMINFO_R_OK && uid != GLOBAL_USER)
3524 ret = _appinfo_get_applications(GLOBAL_USER, uid, locale,
3527 if (ret != PMINFO_R_OK) {
3528 g_hash_table_destroy(list);
3530 return PMINFO_R_ERROR;
3533 *count = g_hash_table_size(list);
3534 g_hash_table_destroy(list);
3540 API int pkgmgrinfo_appinfo_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count)
3542 return pkgmgrinfo_appinfo_usr_filter_count(handle, count, _getuid());
3545 API int pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(
3546 pkgmgrinfo_appinfo_filter_h handle,
3547 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
3549 if (handle == NULL || app_cb == NULL) {
3550 LOGE("invalid parameter");
3551 return PMINFO_R_EINVAL;
3554 if (__check_disable_filter_exist(
3555 handle, E_APPINFO_DISABLE_TYPE_APP) == false) {
3556 if (pkgmgrinfo_appinfo_filter_add_bool(handle,
3557 PMINFO_APPINFO_PROP_APP_DISABLE, false))
3558 return PMINFO_R_ERROR;
3561 if (__check_disable_filter_exist(
3562 handle, E_APPINFO_DISABLE_TYPE_PKG) == false) {
3563 if (pkgmgrinfo_appinfo_filter_add_bool(handle,
3564 PMINFO_APPINFO_PROP_PKG_DISABLE, false))
3565 return PMINFO_R_ERROR;
3568 return _appinfo_get_filtered_foreach_appinfo(uid, handle, PMINFO_APPINFO_GET_ALL, app_cb,
3572 API int pkgmgrinfo_appinfo_filter_foreach_appinfo(pkgmgrinfo_appinfo_filter_h handle,
3573 pkgmgrinfo_app_list_cb app_cb, void *user_data)
3575 return pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(handle, app_cb, user_data, _getuid());
3578 API int pkgmgrinfo_appinfo_metadata_filter_create(pkgmgrinfo_appinfo_metadata_filter_h *handle)
3580 return (pkgmgrinfo_pkginfo_filter_create(handle));
3583 API int pkgmgrinfo_appinfo_metadata_filter_destroy(pkgmgrinfo_appinfo_metadata_filter_h handle)
3585 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
3588 API int pkgmgrinfo_appinfo_metadata_filter_add(
3589 pkgmgrinfo_appinfo_metadata_filter_h handle,
3590 const char *key, const char *value)
3592 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
3593 pkgmgrinfo_metadata_node_x *node;
3595 /* value can be NULL.
3596 * In that case all apps with specified key should be displayed
3599 LOGE("invalid parameter");
3600 return PMINFO_R_EINVAL;
3603 node = calloc(1, sizeof(pkgmgrinfo_metadata_node_x));
3605 LOGE("out of memory");
3606 return PMINFO_R_ERROR;
3609 node->key = strdup(key);
3610 if (value && strlen(value))
3611 node->value = strdup(value);
3613 filter->list_metadata = g_slist_append(filter->list_metadata,
3619 API int pkgmgrinfo_appinfo_usr_metadata_filter_foreach(
3620 pkgmgrinfo_appinfo_metadata_filter_h handle,
3621 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
3623 if (handle == NULL || app_cb == NULL) {
3624 LOGE("invalid parameter");
3625 return PMINFO_R_EINVAL;
3628 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
3629 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
3630 PMINFO_APPINFO_PROP_APP_DISABLE, false))
3631 return PMINFO_R_ERROR;
3633 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
3634 PMINFO_APPINFO_PROP_PKG_DISABLE, false))
3635 return PMINFO_R_ERROR;
3637 return _appinfo_get_filtered_foreach_appinfo(uid, handle, PMINFO_APPINFO_GET_ALL, app_cb,
3641 API int pkgmgrinfo_appinfo_metadata_filter_foreach(
3642 pkgmgrinfo_appinfo_metadata_filter_h handle,
3643 pkgmgrinfo_app_list_cb app_cb, void *user_data)
3645 return pkgmgrinfo_appinfo_usr_metadata_filter_foreach(handle, app_cb,
3646 user_data, _getuid());
3649 API int pkgmgrinfo_appinfo_is_guestmode_visibility(pkgmgrinfo_appinfo_h handle, bool *status)
3652 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3654 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
3655 retvm_if(status == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3657 val = info->app_info->guestmode_visibility;
3658 *status = _get_bool_value(val);
3662 API int pkgmgrinfo_appinfo_foreach_appcontrol_v2(pkgmgrinfo_appinfo_h handle,
3663 pkgmgrinfo_app_control_list_cb_v2 appcontrol_func,
3666 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
3667 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
3669 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3670 appcontrol_x *appcontrol;
3673 if (info->app_info == NULL)
3674 return PMINFO_R_ERROR;
3676 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
3677 appcontrol = (appcontrol_x *)tmp->data;
3678 if (appcontrol == NULL ||
3679 !strcasecmp(appcontrol->visibility, "remote-only"))
3681 ret = appcontrol_func(appcontrol->operation, appcontrol->uri,
3682 appcontrol->mime, appcontrol->id, user_data);
3690 API int pkgmgrinfo_appinfo_foreach_remote_appcontrol_v2(
3691 pkgmgrinfo_appinfo_h handle,
3692 pkgmgrinfo_app_control_list_cb_v2 appcontrol_func,
3695 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
3696 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
3698 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3699 appcontrol_x *appcontrol;
3702 if (info->app_info == NULL)
3703 return PMINFO_R_ERROR;
3705 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
3706 appcontrol = (appcontrol_x *)tmp->data;
3707 if (appcontrol == NULL ||
3708 !strcasecmp(appcontrol->visibility, "local-only"))
3710 ret = appcontrol_func(appcontrol->operation, appcontrol->uri,
3711 appcontrol->mime, appcontrol->id, user_data);