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 ";
56 static int _get_filtered_query(pkgmgrinfo_filter_x *filter,
57 const char *locale, char **query, GList **bind_params)
61 char *condition = NULL;
62 char buf[MAX_QUERY_LEN] = { '\0' };
63 char tmp_query[MAX_QUERY_LEN] = { '\0' };
64 static const char query_pkg_disable[] = " AND ai.package IN "
65 "(SELECT package FROM package_info WHERE package_disable='false')";
68 len += strlen(" WHERE 1=1");
69 strncat(buf, " WHERE 1=1", MAX_QUERY_LEN - len - 1);
72 strncat(buf, query_pkg_disable, MAX_QUERY_LEN - len - 1);
77 for (list = filter->list; list; list = list->next) {
78 joined |= __get_filter_condition(list->data, &condition, bind_params);
79 if (condition == NULL)
82 len += strlen(" AND ");
83 strncat(buf, " AND ", MAX_QUERY_LEN - len - 1);
85 len += strlen(condition);
86 strncat(buf, condition, sizeof(buf) - len - 1);
91 if (joined & E_PMINFO_APPINFO_JOIN_LOCALIZED_INFO) {
92 strncat(tmp_query, join_localized_info, MAX_QUERY_LEN - len - 1);
93 len += strlen(join_localized_info);
94 *bind_params = g_list_append(*bind_params, strdup(locale));
96 if (joined & E_PMINFO_APPINFO_JOIN_CATEGORY) {
97 strncat(tmp_query, join_category, MAX_QUERY_LEN - len - 1);
98 len += strlen(join_category);
100 if (joined & E_PMINFO_APPINFO_JOIN_APP_CONTROL) {
101 strncat(tmp_query, join_app_control, MAX_QUERY_LEN - len - 1);
102 len += strlen(join_app_control);
104 if (joined & E_PMINFO_APPINFO_JOIN_METADATA) {
105 strncat(tmp_query, join_metadata, MAX_QUERY_LEN - len - 1);
106 len += strlen(join_metadata);
108 strncat(tmp_query, buf, MAX_QUERY_LEN - len - 1);
111 strncat(tmp_query, query_pkg_disable, MAX_QUERY_LEN - len - 1);
113 *query = strdup(tmp_query);
115 return PMINFO_R_ERROR;
120 static int _appinfo_get_category(sqlite3 *db, const char *appid,
123 static const char query_raw[] =
124 "SELECT category FROM package_app_app_category WHERE app_id=%Q";
130 query = sqlite3_mprintf(query_raw, appid);
132 LOGE("out of memory");
133 return PMINFO_R_ERROR;
136 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
138 if (ret != SQLITE_OK) {
139 LOGE("prepare failed: %s", sqlite3_errmsg(db));
140 return PMINFO_R_ERROR;
143 while (sqlite3_step(stmt) == SQLITE_ROW) {
145 _save_column_str(stmt, 0, &val);
147 *category = g_list_append(*category, (gpointer)val);
150 sqlite3_finalize(stmt);
155 static void __parse_appcontrol(GList **appcontrol, char *appcontrol_str)
162 if (appcontrol_str == NULL)
165 dup = strdup(appcontrol_str);
167 ac = calloc(1, sizeof(appcontrol_x));
169 _LOGE("out of memory");
172 token = strtok_r(dup, "|", &ptr);
173 if (token && strcmp(token, "NULL"))
174 ac->operation = strdup(token);
175 token = strtok_r(NULL, "|", &ptr);
176 if (token && strcmp(token, "NULL"))
177 ac->uri = strdup(token);
178 token = strtok_r(NULL, "|", &ptr);
179 if (token && strcmp(token, "NULL"))
180 ac->mime = strdup(token);
181 *appcontrol = g_list_append(*appcontrol, ac);
182 } while ((token = strtok_r(NULL, ";", &ptr)));
187 static int _appinfo_get_app_control(sqlite3 *db, const char *appid,
190 static const char query_raw[] =
191 "SELECT app_control FROM package_app_app_control "
198 query = sqlite3_mprintf(query_raw, appid);
200 LOGE("out of memory");
201 return PMINFO_R_ERROR;
204 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
206 if (ret != SQLITE_OK) {
207 LOGE("prepare failed: %s", sqlite3_errmsg(db));
208 return PMINFO_R_ERROR;
211 while (sqlite3_step(stmt) == SQLITE_ROW) {
213 _save_column_str(stmt, 0, &str);
215 __parse_appcontrol(appcontrol, str);
219 sqlite3_finalize(stmt);
224 static int _appinfo_get_data_control(sqlite3 *db, const char *appid,
227 static const char query_raw[] =
228 "SELECT providerid, access, type "
229 "FROM package_app_data_control WHERE app_id=%Q";
236 query = sqlite3_mprintf(query_raw, appid);
238 LOGE("out of memory");
239 return PMINFO_R_ERROR;
242 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
244 if (ret != SQLITE_OK) {
245 LOGE("prepare failed: %s", sqlite3_errmsg(db));
246 return PMINFO_R_ERROR;
249 while (sqlite3_step(stmt) == SQLITE_ROW) {
250 info = calloc(1, sizeof(datacontrol_x));
252 LOGE("out of memory");
253 sqlite3_finalize(stmt);
254 return PMINFO_R_ERROR;
257 _save_column_str(stmt, idx++, &info->providerid);
258 _save_column_str(stmt, idx++, &info->access);
259 _save_column_str(stmt, idx++, &info->type);
260 *datacontrol = g_list_append(*datacontrol, info);
263 sqlite3_finalize(stmt);
268 static int _appinfo_get_metadata(sqlite3 *db, const char *appid,
271 static const char query_raw[] =
272 "SELECT md_key, md_value "
273 "FROM package_app_app_metadata WHERE app_id=%Q";
280 query = sqlite3_mprintf(query_raw, appid);
282 LOGE("out of memory");
283 return PMINFO_R_ERROR;
286 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
288 if (ret != SQLITE_OK) {
289 LOGE("prepare failed: %s", sqlite3_errmsg(db));
290 return PMINFO_R_ERROR;
293 while (sqlite3_step(stmt) == SQLITE_ROW) {
294 info = calloc(1, sizeof(metadata_x));
296 LOGE("out of memory");
297 sqlite3_finalize(stmt);
298 return PMINFO_R_ERROR;
301 _save_column_str(stmt, idx++, &info->key);
302 _save_column_str(stmt, idx++, &info->value);
303 *metadata = g_list_append(*metadata, info);
306 sqlite3_finalize(stmt);
312 static int _appinfo_get_splashscreens(sqlite3 *db, const char *appid,
313 GList **splashscreens)
315 static const char query_raw[] =
316 "SELECT src, type, orientation, indicatordisplay, operation, color_depth "
317 "FROM package_app_splash_screen WHERE app_id=%Q";
322 splashscreen_x *info;
324 query = sqlite3_mprintf(query_raw, appid);
326 LOGE("out of memory");
327 return PMINFO_R_ERROR;
330 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
332 if (ret != SQLITE_OK) {
333 LOGE("prepare failed: %s", sqlite3_errmsg(db));
334 return PMINFO_R_ERROR;
337 while (sqlite3_step(stmt) == SQLITE_ROW) {
338 info = calloc(1, sizeof(splashscreen_x));
340 LOGE("out of memory");
341 sqlite3_finalize(stmt);
342 return PMINFO_R_ERROR;
345 _save_column_str(stmt, idx++, &info->src);
346 _save_column_str(stmt, idx++, &info->type);
347 _save_column_str(stmt, idx++, &info->orientation);
348 _save_column_str(stmt, idx++, &info->indicatordisplay);
349 _save_column_str(stmt, idx++, &info->operation);
350 _save_column_str(stmt, idx++, &info->color_depth);
351 *splashscreens = g_list_append(*splashscreens, info);
354 sqlite3_finalize(stmt);
359 static GList *__get_background_category(const char *value)
361 GList *category_list = NULL;
362 int convert_value = 0;
363 if (!value || strlen(value) == 0)
366 convert_value = atoi(value);
367 if (convert_value < 0)
370 if (convert_value & APP_BG_CATEGORY_USER_DISABLE_TRUE_VAL)
371 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_USER_DISABLE_TRUE_STR));
373 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_USER_DISABLE_FALSE_STR));
375 if (convert_value & APP_BG_CATEGORY_MEDIA_VAL)
376 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_MEDIA_STR));
378 if (convert_value & APP_BG_CATEGORY_DOWNLOAD_VAL)
379 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_DOWNLOAD_STR));
381 if (convert_value & APP_BG_CATEGORY_BGNETWORK_VAL)
382 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_BGNETWORK_STR));
384 if (convert_value & APP_BG_CATEGORY_LOCATION_VAL)
385 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_LOCATION_STR));
387 if (convert_value & APP_BG_CATEGORY_SENSOR_VAL)
388 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_SENSOR_STR));
390 if (convert_value & APP_BG_CATEGORY_IOTCOMM_VAL)
391 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_IOTCOMM_STR));
393 if (convert_value & APP_BG_CATEGORY_SYSTEM_VAL)
394 category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_SYSTEM));
396 return category_list;
400 static void __get_splash_screen_display(sqlite3 *db, const char *appid, uid_t uid, char **value)
402 static const char query_raw[] =
403 "SELECT is_splash_screen_enabled FROM package_app_info_for_uid "
404 "WHERE app_id='%s' AND uid='%d'";
409 query = sqlite3_mprintf(query_raw, appid, uid);
411 LOGE("out of memory");
415 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
417 if (ret != SQLITE_OK) {
418 LOGE("sqlite3_prepare_v2() failed: %s", sqlite3_errmsg(db));
422 while (sqlite3_step(stmt) == SQLITE_ROW) {
425 _save_column_str(stmt, 0, value);
428 sqlite3_finalize(stmt);
431 static void __free_applications(gpointer data)
433 pkgmgrinfo_basic_free_application((application_x *)data);
436 static int __bind_params(sqlite3_stmt *stmt, GList *params)
438 GList *tmp_list = NULL;
442 if (stmt == NULL || params == NULL)
443 return PMINFO_R_EINVAL;
447 ret = sqlite3_bind_text(stmt, ++idx, (char *)tmp_list->data, -1, SQLITE_STATIC);
448 if (ret != SQLITE_OK)
449 return PMINFO_R_ERROR;
450 tmp_list = tmp_list->next;
456 static int _appinfo_get_applications(uid_t db_uid, uid_t uid,
457 const char *locale, pkgmgrinfo_filter_x *filter, int flag,
458 GHashTable *applications)
460 static const char query_raw[] =
461 "SELECT DISTINCT ai.app_id, ai.app_component, ai.app_exec, "
462 "ai.app_nodisplay, ai.app_type, ai.app_onboot, "
463 "ai.app_multiple, ai.app_autorestart, ai.app_taskmanage, "
464 "ai.app_enabled, ai.app_hwacceleration, ai.app_screenreader, "
465 "ai.app_mainapp, ai.app_recentimage, ai.app_launchcondition, "
466 "ai.app_indicatordisplay, ai.app_portraitimg, "
467 "ai.app_landscapeimg, ai.app_guestmodevisibility, "
468 "ai.app_permissiontype, ai.app_preload, ai.app_submode, "
469 "ai.app_submode_mainid, ai.app_launch_mode, ai.app_ui_gadget, "
470 "ai.app_support_disable, ai.app_process_pool, "
471 "ai.app_installed_storage, ai.app_background_category, "
472 "ai.app_package_type, ai.app_root_path, ai.app_api_version, "
473 "ai.app_effective_appid, ai.app_disable, "
474 "ai.app_splash_screen_display, ai.app_tep_name, "
475 "ai.app_zip_mount_file, ai.component_type, ai.package, "
476 "ai.app_external_path, ai.app_package_system, ai.app_removable, "
477 "ai.app_package_installed_time, ai.app_support_mode";
478 static const char query_label[] =
480 "(SELECT app_label FROM package_app_localized_info WHERE ai.app_id=app_id AND app_locale=?), "
481 "(SELECT app_label FROM package_app_localized_info WHERE ai.app_id=app_id AND app_locale='No Locale'))";
482 static const char query_icon[] =
484 "(SELECT app_icon FROM package_app_localized_info WHERE ai.app_id=app_id AND app_locale=?), "
485 "(SELECT app_icon FROM package_app_localized_info WHERE ai.app_id=app_id AND app_locale='No Locale'))";
486 static const char query_from_clause[] = " FROM package_app_info as ai";
487 int ret = PMINFO_R_ERROR;
491 char *bg_category_str = NULL;
492 char *constraint = NULL;
493 char *tmp_record = NULL;
494 char query[MAX_QUERY_LEN] = { '\0' };
495 application_x *info = NULL;
496 GList *bind_params = NULL;
498 sqlite3_stmt *stmt = NULL;
500 dbpath = getUserPkgParserDBPathUID(db_uid);
502 return PMINFO_R_ERROR;
504 ret = sqlite3_open_v2(dbpath, &db, SQLITE_OPEN_READONLY, NULL);
505 if (ret != SQLITE_OK) {
506 _LOGE("failed to open db: %d", ret);
508 return PMINFO_R_ERROR;
512 len = strlen(query_raw);
513 snprintf(query, MAX_QUERY_LEN - 1, "%s", query_raw);
514 if (flag & PMINFO_APPINFO_GET_LABEL) {
515 strncat(query, query_label, MAX_QUERY_LEN - len - 1);
516 len += strlen(query_label);
517 bind_params = g_list_append(bind_params, strdup(locale));
519 if (flag & PMINFO_APPINFO_GET_ICON) {
520 strncat(query, query_icon, MAX_QUERY_LEN - len - 1);
521 len += strlen(query_icon);
522 bind_params = g_list_append(bind_params, strdup(locale));
525 ret = _get_filtered_query(filter, locale, &constraint, &bind_params);
526 if (ret != PMINFO_R_OK) {
527 LOGE("Failed to get WHERE clause");
530 strncat(query, query_from_clause, MAX_QUERY_LEN - len - 1);
531 len += strlen(query_from_clause);
534 strncat(query, constraint, MAX_QUERY_LEN - len - 1);
536 ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
537 if (ret != SQLITE_OK) {
538 LOGE("prepare failed: %s", sqlite3_errmsg(db));
539 ret = PMINFO_R_ERROR;
543 if (g_list_length(bind_params) != 0) {
544 ret = __bind_params(stmt, bind_params);
545 if (ret != SQLITE_OK) {
546 LOGE("Failed to bind parameters");
551 while (sqlite3_step(stmt) == SQLITE_ROW) {
552 info = calloc(1, sizeof(application_x));
554 LOGE("out of memory");
555 ret = PMINFO_R_ERROR;
559 _save_column_str(stmt, idx++, &info->appid);
560 if (g_hash_table_contains(applications,
561 (gconstpointer)info->appid)) {
566 _save_column_str(stmt, idx++, &info->component);
567 _save_column_str(stmt, idx++, &info->exec);
568 _save_column_str(stmt, idx++, &info->nodisplay);
569 _save_column_str(stmt, idx++, &info->type);
570 _save_column_str(stmt, idx++, &info->onboot);
571 _save_column_str(stmt, idx++, &info->multiple);
572 _save_column_str(stmt, idx++, &info->autorestart);
573 _save_column_str(stmt, idx++, &info->taskmanage);
574 _save_column_str(stmt, idx++, &info->enabled);
575 _save_column_str(stmt, idx++, &info->hwacceleration);
576 _save_column_str(stmt, idx++, &info->screenreader);
577 _save_column_str(stmt, idx++, &info->mainapp);
578 _save_column_str(stmt, idx++, &info->recentimage);
579 _save_column_str(stmt, idx++, &info->launchcondition);
580 _save_column_str(stmt, idx++, &info->indicatordisplay);
581 _save_column_str(stmt, idx++, &info->portraitimg);
582 _save_column_str(stmt, idx++, &info->landscapeimg);
583 _save_column_str(stmt, idx++, &info->guestmode_visibility);
584 _save_column_str(stmt, idx++, &info->permission_type);
585 _save_column_str(stmt, idx++, &info->preload);
586 _save_column_str(stmt, idx++, &info->submode);
587 _save_column_str(stmt, idx++, &info->submode_mainid);
588 _save_column_str(stmt, idx++, &info->launch_mode);
589 _save_column_str(stmt, idx++, &info->ui_gadget);
590 _save_column_str(stmt, idx++, &info->support_disable);
591 _save_column_str(stmt, idx++, &info->process_pool);
592 _save_column_str(stmt, idx++, &info->installed_storage);
593 _save_column_str(stmt, idx++, &bg_category_str);
594 _save_column_str(stmt, idx++, &info->package_type);
595 _save_column_str(stmt, idx++, &info->root_path);
596 _save_column_str(stmt, idx++, &info->api_version);
597 _save_column_str(stmt, idx++, &info->effective_appid);
598 _save_column_str(stmt, idx++, &info->is_disabled);
599 _save_column_str(stmt, idx++, &info->splash_screen_display);
600 _save_column_str(stmt, idx++, &info->tep_name);
601 _save_column_str(stmt, idx++, &info->zip_mount_file);
602 _save_column_str(stmt, idx++, &info->component_type);
603 _save_column_str(stmt, idx++, &info->package);
604 _save_column_str(stmt, idx++, &info->external_path);
605 _save_column_str(stmt, idx++, &info->package_system);
606 _save_column_str(stmt, idx++, &info->removable);
607 _save_column_str(stmt, idx++, &info->package_installed_time);
608 _save_column_str(stmt, idx++, &info->support_mode);
610 info->for_all_users =
611 strdup((uid != GLOBAL_USER) ? "false" : "true");
613 if (db_uid == GLOBAL_USER)
614 __get_splash_screen_display(db, info->appid, db_uid,
615 &info->splash_screen_display);
617 info->background_category = __get_background_category(
619 free(bg_category_str);
621 if (flag & PMINFO_APPINFO_GET_LABEL) {
623 _save_column_str(stmt, idx++, &tmp_record);
624 if (_add_label_info_into_list(locale, tmp_record, &info->label)) {
625 ret = PMINFO_R_ERROR;
630 if (flag & PMINFO_APPINFO_GET_ICON) {
632 _save_column_str(stmt, idx++, &tmp_record);
633 if (_add_icon_info_into_list(locale, tmp_record, &info->icon)) {
634 ret = PMINFO_R_ERROR;
639 if (flag & PMINFO_APPINFO_GET_CATEGORY) {
640 if (_appinfo_get_category(db, info->appid,
642 ret = PMINFO_R_ERROR;
647 if (flag & PMINFO_APPINFO_GET_APP_CONTROL) {
648 if (_appinfo_get_app_control(db, info->appid,
649 &info->appcontrol)) {
650 ret = PMINFO_R_ERROR;
655 if (flag & PMINFO_APPINFO_GET_DATA_CONTROL) {
656 if (_appinfo_get_data_control(db, info->appid,
657 &info->datacontrol)) {
658 ret = PMINFO_R_ERROR;
663 if (flag & PMINFO_APPINFO_GET_METADATA) {
664 if (_appinfo_get_metadata(db, info->appid,
666 ret = PMINFO_R_ERROR;
671 if (flag & PMINFO_APPINFO_GET_SPLASH_SCREEN) {
672 if (_appinfo_get_splashscreens(db, info->appid,
673 &info->splashscreens)) {
674 ret = PMINFO_R_ERROR;
679 if (__appinfo_check_installed_storage(info) != PMINFO_R_OK) {
680 ret = PMINFO_R_ERROR;
681 pkgmgrinfo_basic_free_application(info);
686 g_hash_table_insert(applications, (gpointer)info->appid,
696 if (ret != PMINFO_R_OK && info != NULL)
697 pkgmgrinfo_basic_free_application(info);
699 g_list_free_full(bind_params, free);
700 sqlite3_close_v2(db);
701 sqlite3_finalize(stmt);
706 API int pkgmgrinfo_appinfo_get_usr_disabled_appinfo(const char *appid, uid_t uid,
707 pkgmgrinfo_appinfo_h *handle)
712 pkgmgrinfo_appinfo_filter_h filter;
713 pkgmgr_appinfo_x *info;
715 if (appid == NULL || handle == NULL) {
716 LOGE("invalid parameter");
717 return PMINFO_R_EINVAL;
720 locale = _get_system_locale();
722 return PMINFO_R_ERROR;
724 ret = pkgmgrinfo_appinfo_filter_create(&filter);
725 if (ret != PMINFO_R_OK) {
730 ret = pkgmgrinfo_appinfo_filter_add_string(filter,
731 PMINFO_APPINFO_PROP_APP_ID, appid);
732 if (ret != PMINFO_R_OK) {
733 pkgmgrinfo_appinfo_filter_destroy(filter);
735 return PMINFO_R_ERROR;
738 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
739 PMINFO_APPINFO_PROP_APP_DISABLE, true);
740 if (ret != PMINFO_R_OK) {
741 pkgmgrinfo_appinfo_filter_destroy(filter);
743 return PMINFO_R_ERROR;
746 list = g_hash_table_new(g_str_hash, g_str_equal);
748 pkgmgrinfo_appinfo_filter_destroy(filter);
750 return PMINFO_R_ERROR;
753 ret = _appinfo_get_applications(uid, uid, locale, filter,
754 PMINFO_APPINFO_GET_ALL, list);
755 if (!g_hash_table_size(list) && uid != GLOBAL_USER)
756 ret = _appinfo_get_applications(GLOBAL_USER, uid, locale,
757 filter, PMINFO_APPINFO_GET_ALL, list);
759 pkgmgrinfo_appinfo_filter_destroy(filter);
760 if (ret != PMINFO_R_OK) {
761 g_hash_table_destroy(list);
766 if (!g_hash_table_size(list)) {
767 _LOGI("Appinfo for [%s] is not existed for user [%d]",
769 g_hash_table_destroy(list);
771 return PMINFO_R_ENOENT;
774 info = calloc(1, sizeof(pkgmgr_appinfo_x));
776 _LOGE("out of memory");
778 return PMINFO_R_ERROR;
781 info->app_info = (application_x *)g_hash_table_lookup(list, appid);
782 info->locale = locale;
783 info->package = strdup(info->app_info->package);
785 /* just free list only */
786 g_hash_table_destroy(list);
793 API int pkgmgrinfo_appinfo_get_disabled_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
795 return pkgmgrinfo_appinfo_get_usr_disabled_appinfo(appid, _getuid(), handle);
798 API int pkgmgrinfo_appinfo_get_usr_appinfo(const char *appid, uid_t uid,
799 pkgmgrinfo_appinfo_h *handle)
804 pkgmgrinfo_appinfo_filter_h filter;
805 pkgmgr_appinfo_x *info;
807 if (appid == NULL || handle == NULL) {
808 LOGE("invalid parameter");
809 return PMINFO_R_EINVAL;
812 locale = _get_system_locale();
814 return PMINFO_R_ERROR;
816 ret = pkgmgrinfo_appinfo_filter_create(&filter);
817 if (ret != PMINFO_R_OK) {
822 ret = pkgmgrinfo_appinfo_filter_add_string(filter,
823 PMINFO_APPINFO_PROP_APP_ID, appid);
824 if (ret != PMINFO_R_OK) {
825 pkgmgrinfo_appinfo_filter_destroy(filter);
827 return PMINFO_R_ERROR;
830 ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
831 PMINFO_APPINFO_PROP_APP_DISABLE, false);
832 if (ret != PMINFO_R_OK) {
833 pkgmgrinfo_appinfo_filter_destroy(filter);
835 return PMINFO_R_ERROR;
838 list = g_hash_table_new(g_str_hash, g_str_equal);
840 pkgmgrinfo_appinfo_filter_destroy(filter);
842 return PMINFO_R_ERROR;
845 ret = _appinfo_get_applications(uid, uid, locale, filter,
846 PMINFO_APPINFO_GET_ALL, list);
847 if (!g_hash_table_size(list) && uid != GLOBAL_USER)
848 ret = _appinfo_get_applications(GLOBAL_USER, uid, locale,
849 filter, PMINFO_APPINFO_GET_ALL, list);
851 pkgmgrinfo_appinfo_filter_destroy(filter);
852 if (ret != PMINFO_R_OK) {
853 g_hash_table_destroy(list);
858 if (!g_hash_table_size(list)) {
859 _LOGI("Appinfo for [%s] is not existed for user [%d]", appid, uid);
860 g_hash_table_destroy(list);
862 return PMINFO_R_ENOENT;
865 info = calloc(1, sizeof(pkgmgr_appinfo_x));
867 _LOGE("out of memory");
869 return PMINFO_R_ERROR;
872 info->app_info = (application_x *)g_hash_table_lookup(list, appid);
873 info->locale = locale;
874 info->package = strdup(info->app_info->package);
876 /* just free list only */
877 g_hash_table_destroy(list);
884 API int pkgmgrinfo_appinfo_get_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
886 return pkgmgrinfo_appinfo_get_usr_appinfo(appid, _getuid(), handle);
889 static gpointer __copy_str(gconstpointer src, gpointer data)
891 const char *tmp = (const char *)src;
894 buffer = strdup(tmp);
895 if (buffer == NULL) {
896 LOGE("memory alloc failed");
904 static gpointer __copy_label(gconstpointer src, gpointer data)
906 label_x *tmp = (label_x *)src;
909 label = calloc(1, sizeof(label_x));
911 LOGE("memory alloc failed");
917 label->name = strdup(tmp->name);
919 label->text = strdup(tmp->text);
921 label->lang = strdup(tmp->lang);
926 static gpointer __copy_icon(gconstpointer src, gpointer data)
928 icon_x *tmp = (icon_x *)src;
931 icon = calloc(1, sizeof(icon_x));
933 LOGE("memory alloc failed");
939 icon->text = strdup(tmp->text);
941 icon->lang = strdup(tmp->lang);
943 icon->section = strdup(tmp->section);
945 icon->size = strdup(tmp->size);
947 icon->resolution = strdup(tmp->resolution);
952 static gpointer __copy_metadata(gconstpointer src, gpointer data)
954 metadata_x *tmp = (metadata_x *)src;
955 metadata_x *metadata;
957 metadata = calloc(1, sizeof(metadata_x));
958 if (metadata == NULL) {
959 LOGE("memory alloc failed");
965 metadata->key = strdup(tmp->key);
967 metadata->value = strdup(tmp->value);
972 static gpointer __copy_datacontrol(gconstpointer src, gpointer data)
974 datacontrol_x *tmp = (datacontrol_x *)src;
975 datacontrol_x *datacontrol;
977 datacontrol = calloc(1, sizeof(datacontrol_x));
978 if (datacontrol == NULL) {
979 LOGE("memory alloc failed");
985 datacontrol->providerid = strdup(tmp->providerid);
987 datacontrol->access = strdup(tmp->access);
989 datacontrol->type = strdup(tmp->type);
994 static gpointer __copy_appcontrol(gconstpointer src, gpointer data)
996 appcontrol_x *tmp = (appcontrol_x *)src;
997 appcontrol_x *appcontrol;
999 appcontrol = calloc(1, sizeof(appcontrol_x));
1000 if (appcontrol == NULL) {
1001 LOGE("memory alloc failed");
1007 appcontrol->operation = strdup(tmp->operation);
1009 appcontrol->uri = strdup(tmp->uri);
1011 appcontrol->mime = strdup(tmp->mime);
1016 static gpointer __copy_splashscreens(gconstpointer src, gpointer data)
1018 splashscreen_x *tmp = (splashscreen_x *)src;
1019 splashscreen_x *splashscreen;
1021 splashscreen = (splashscreen_x *)calloc(1, sizeof(splashscreen_x));
1022 if (splashscreen == NULL) {
1023 LOGE("memory alloc failed");
1029 splashscreen->src = strdup(tmp->src);
1031 splashscreen->type = strdup(tmp->type);
1032 if (tmp->orientation)
1033 splashscreen->orientation = strdup(tmp->orientation);
1034 if (tmp->indicatordisplay)
1035 splashscreen->indicatordisplay = strdup(tmp->indicatordisplay);
1037 splashscreen->operation = strdup(tmp->operation);
1038 if (tmp->color_depth)
1039 splashscreen->color_depth = strdup(tmp->color_depth);
1041 return splashscreen;
1044 static int _appinfo_copy_appinfo(application_x **application, application_x *data)
1046 application_x *app_info;
1049 app_info = calloc(1, sizeof(application_x));
1050 if (app_info == NULL) {
1051 LOGE("memory alloc failed");
1052 return PMINFO_R_ERROR;
1055 if (data->appid != NULL)
1056 app_info->appid = strdup(data->appid);
1057 if (data->exec != NULL)
1058 app_info->exec = strdup(data->exec);
1059 if (data->nodisplay != NULL)
1060 app_info->nodisplay = strdup(data->nodisplay);
1061 if (data->multiple != NULL)
1062 app_info->multiple = strdup(data->multiple);
1063 if (data->taskmanage != NULL)
1064 app_info->taskmanage = strdup(data->taskmanage);
1065 if (data->enabled != NULL)
1066 app_info->enabled = strdup(data->enabled);
1067 if (data->type != NULL)
1068 app_info->type = strdup(data->type);
1069 if (data->categories != NULL)
1070 app_info->categories = strdup(data->categories);
1071 if (data->hwacceleration != NULL)
1072 app_info->hwacceleration = strdup(data->hwacceleration);
1073 if (data->screenreader != NULL)
1074 app_info->screenreader = strdup(data->screenreader);
1075 if (data->mainapp != NULL)
1076 app_info->mainapp = strdup(data->mainapp);
1077 if (data->package != NULL)
1078 app_info->package = strdup(data->package);
1079 if (data->recentimage != NULL)
1080 app_info->recentimage = strdup(data->recentimage);
1081 if (data->launchcondition != NULL)
1082 app_info->launchcondition = strdup(data->launchcondition);
1083 if (data->indicatordisplay != NULL)
1084 app_info->indicatordisplay = strdup(data->indicatordisplay);
1085 if (data->portraitimg != NULL)
1086 app_info->portraitimg = strdup(data->portraitimg);
1087 if (data->landscapeimg != NULL)
1088 app_info->landscapeimg = strdup(data->landscapeimg);
1089 if (data->guestmode_visibility != NULL)
1090 app_info->guestmode_visibility = strdup(data->guestmode_visibility);
1091 if (data->component != NULL)
1092 app_info->component = strdup(data->component);
1093 if (data->permission_type != NULL)
1094 app_info->permission_type = strdup(data->permission_type);
1095 if (data->component_type != NULL)
1096 app_info->component_type = strdup(data->component_type);
1097 if (data->preload != NULL)
1098 app_info->preload = strdup(data->preload);
1099 if (data->submode != NULL)
1100 app_info->submode = strdup(data->submode);
1101 if (data->submode_mainid != NULL)
1102 app_info->submode_mainid = strdup(data->submode_mainid);
1103 if (data->process_pool != NULL)
1104 app_info->process_pool = strdup(data->process_pool);
1105 if (data->installed_storage != NULL)
1106 app_info->installed_storage = strdup(data->installed_storage);
1107 if (data->autorestart != NULL)
1108 app_info->autorestart = strdup(data->autorestart);
1109 if (data->onboot != NULL)
1110 app_info->onboot = strdup(data->onboot);
1111 if (data->support_disable != NULL)
1112 app_info->support_disable = strdup(data->support_disable);
1113 if (data->ui_gadget != NULL)
1114 app_info->ui_gadget = strdup(data->ui_gadget);
1115 if (data->launch_mode != NULL)
1116 app_info->launch_mode = strdup(data->launch_mode);
1117 if (data->package_type != NULL)
1118 app_info->package_type = strdup(data->package_type);
1119 if (data->effective_appid != NULL)
1120 app_info->effective_appid = strdup(data->effective_appid);
1121 if (data->splash_screen_display != NULL)
1122 app_info->splash_screen_display = strdup(data->splash_screen_display);
1126 app_info->label = g_list_copy_deep(data->label, __copy_label, &ret);
1128 LOGE("memory alloc failed");
1129 pkgmgrinfo_basic_free_application(app_info);
1130 return PMINFO_R_ERROR;
1134 app_info->icon = g_list_copy_deep(data->icon, __copy_icon, &ret);
1136 LOGE("memory alloc failed");
1137 pkgmgrinfo_basic_free_application(app_info);
1138 return PMINFO_R_ERROR;
1142 app_info->category = g_list_copy_deep(data->category, __copy_str, &ret);
1144 LOGE("memory alloc failed");
1145 pkgmgrinfo_basic_free_application(app_info);
1146 return PMINFO_R_ERROR;
1150 app_info->metadata = g_list_copy_deep(data->metadata, __copy_metadata, &ret);
1152 LOGE("memory alloc failed");
1153 pkgmgrinfo_basic_free_application(app_info);
1154 return PMINFO_R_ERROR;
1158 app_info->datacontrol = g_list_copy_deep(data->datacontrol, __copy_datacontrol, &ret);
1160 LOGE("memory alloc failed");
1161 pkgmgrinfo_basic_free_application(app_info);
1162 return PMINFO_R_ERROR;
1166 app_info->appcontrol = g_list_copy_deep(data->appcontrol, __copy_appcontrol, &ret);
1168 LOGE("memory alloc failed");
1169 pkgmgrinfo_basic_free_application(app_info);
1170 return PMINFO_R_ERROR;
1174 app_info->background_category = g_list_copy_deep(data->background_category, __copy_str, &ret);
1176 LOGE("memory alloc failed");
1177 pkgmgrinfo_basic_free_application(app_info);
1178 return PMINFO_R_ERROR;
1182 app_info->splashscreens = g_list_copy_deep(data->splashscreens, __copy_splashscreens, &ret);
1184 LOGE("memory alloc failed");
1185 pkgmgrinfo_basic_free_application(app_info);
1186 return PMINFO_R_ERROR;
1189 *application = app_info;
1194 API int pkgmgrinfo_appinfo_clone_appinfo(pkgmgrinfo_appinfo_h handle,
1195 pkgmgrinfo_appinfo_h *clone)
1197 pkgmgr_appinfo_x *info;
1198 pkgmgr_appinfo_x *temp = (pkgmgr_appinfo_x *)handle;
1201 return PMINFO_R_EINVAL;
1203 info = calloc(1, sizeof(pkgmgr_appinfo_x));
1205 LOGE("memory alloc failed");
1206 return PMINFO_R_ERROR;
1209 if (temp->package != NULL)
1210 info->package = strdup(temp->package);
1211 if (temp->locale != NULL)
1212 info->locale = strdup(temp->locale);
1214 info->app_component = temp->app_component;
1216 if (_appinfo_copy_appinfo(&info->app_info, temp->app_info) < 0) {
1217 LOGE("appinfo copy failed");
1219 free((void *)info->package);
1223 return PMINFO_R_ERROR;
1231 static int _appinfo_get_filtered_foreach_appinfo(uid_t uid,
1232 pkgmgrinfo_filter_x *filter, int flag, pkgmgrinfo_app_list_cb app_list_cb,
1238 pkgmgr_appinfo_x info;
1240 GHashTableIter iter;
1243 locale = _get_system_locale();
1245 return PMINFO_R_ERROR;
1247 list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
1248 __free_applications);
1251 return PMINFO_R_ERROR;
1254 ret = _appinfo_get_applications(uid, uid, locale, filter, flag, list);
1255 if (ret == PMINFO_R_OK && uid != GLOBAL_USER)
1256 ret = _appinfo_get_applications(GLOBAL_USER, uid, locale,
1257 filter, flag, list);
1259 if (ret != PMINFO_R_OK) {
1260 g_hash_table_destroy(list);
1265 g_hash_table_iter_init(&iter, list);
1266 while (g_hash_table_iter_next(&iter, NULL, &value)) {
1267 app = (application_x *)value;
1268 info.app_info = app;
1269 info.locale = locale;
1270 info.package = app->package;
1271 if (app_list_cb(&info, user_data) < 0)
1274 g_hash_table_destroy(list);
1280 static const char *__appcomponent_str(pkgmgrinfo_app_component comp);
1282 API int pkgmgrinfo_appinfo_get_usr_list(pkgmgrinfo_pkginfo_h handle,
1283 pkgmgrinfo_app_component component,
1284 pkgmgrinfo_app_list_cb app_func, void *user_data, uid_t uid)
1287 pkgmgrinfo_appinfo_filter_h filter;
1289 const char *comp_str = NULL;
1291 if (handle == NULL || app_func == NULL) {
1292 LOGE("invalid parameter");
1293 return PMINFO_R_EINVAL;
1296 if (pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid)) {
1297 LOGE("invalid parameter");
1298 return PMINFO_R_EINVAL;
1301 if (pkgmgrinfo_appinfo_filter_create(&filter))
1302 return PMINFO_R_ERROR;
1304 if (pkgmgrinfo_appinfo_filter_add_string(filter,
1305 PMINFO_APPINFO_PROP_APP_PACKAGE, pkgid)) {
1306 pkgmgrinfo_appinfo_filter_destroy(filter);
1307 return PMINFO_R_ERROR;
1310 if (uid == GLOBAL_USER) {
1311 if (pkgmgrinfo_appinfo_filter_add_int(filter,
1312 PMINFO_APPINFO_PROP_APP_DISABLE_FOR_USER,
1314 pkgmgrinfo_appinfo_filter_destroy(filter);
1315 return PMINFO_R_ERROR;
1319 comp_str = __appcomponent_str(component);
1322 if (pkgmgrinfo_appinfo_filter_add_string(filter,
1323 PMINFO_APPINFO_PROP_APP_COMPONENT,
1325 pkgmgrinfo_appinfo_filter_destroy(filter);
1326 return PMINFO_R_ERROR;
1330 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter,
1331 PMINFO_APPINFO_GET_ALL, app_func, user_data);
1333 pkgmgrinfo_appinfo_filter_destroy(filter);
1338 API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle,
1339 pkgmgrinfo_app_component component,
1340 pkgmgrinfo_app_list_cb app_func, void *user_data)
1342 return pkgmgrinfo_appinfo_get_usr_list(handle, component, app_func, user_data, _getuid());
1345 API int pkgmgrinfo_appinfo_get_usr_installed_list_full(
1346 pkgmgrinfo_app_list_cb app_func, uid_t uid, int flag,
1350 pkgmgrinfo_appinfo_filter_h filter;
1352 if (app_func == NULL) {
1353 LOGE("invalid parameter");
1354 return PMINFO_R_EINVAL;
1357 if (pkgmgrinfo_appinfo_filter_create(&filter))
1358 return PMINFO_R_ERROR;
1360 if (pkgmgrinfo_appinfo_filter_add_bool(filter,
1361 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
1362 pkgmgrinfo_appinfo_filter_destroy(filter);
1363 return PMINFO_R_ERROR;
1366 if (uid == GLOBAL_USER) {
1367 if (pkgmgrinfo_appinfo_filter_add_int(filter,
1368 PMINFO_APPINFO_PROP_APP_DISABLE_FOR_USER,
1370 pkgmgrinfo_appinfo_filter_destroy(filter);
1371 return PMINFO_R_ERROR;
1375 ret = _appinfo_get_filtered_foreach_appinfo(uid, filter, flag, app_func,
1378 pkgmgrinfo_appinfo_filter_destroy(filter);
1383 API int pkgmgrinfo_appinfo_get_installed_list_full(
1384 pkgmgrinfo_app_list_cb app_func, int flag, void *user_data)
1386 return pkgmgrinfo_appinfo_get_usr_installed_list_full(app_func,
1387 _getuid(), flag, user_data);
1390 API int pkgmgrinfo_appinfo_get_usr_install_list(pkgmgrinfo_app_list_cb app_func,
1391 uid_t uid, void *user_data)
1393 return pkgmgrinfo_appinfo_get_usr_installed_list_full(app_func,
1394 uid, PMINFO_APPINFO_GET_ALL, user_data);
1397 API int pkgmgrinfo_appinfo_get_install_list(pkgmgrinfo_app_list_cb app_func,
1400 return pkgmgrinfo_appinfo_get_usr_installed_list_full(app_func,
1401 _getuid(), PMINFO_APPINFO_GET_ALL, user_data);
1404 API int pkgmgrinfo_appinfo_get_usr_installed_list(
1405 pkgmgrinfo_app_list_cb app_func, uid_t uid, void *user_data)
1407 if (app_func == NULL) {
1408 LOGE("invalid parameter");
1409 return PMINFO_R_EINVAL;
1412 return _appinfo_get_filtered_foreach_appinfo(uid, NULL,
1413 PMINFO_APPINFO_GET_ALL, app_func, user_data);
1416 API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func,
1419 return pkgmgrinfo_appinfo_get_usr_installed_list(app_func, _getuid(),
1423 API int pkgmgrinfo_appinfo_get_appid(pkgmgrinfo_appinfo_h handle, char **appid)
1425 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1427 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1428 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1430 if (info->app_info == NULL || info->app_info->appid == NULL)
1431 return PMINFO_R_ERROR;
1432 *appid = (char *)info->app_info->appid;
1437 API int pkgmgrinfo_appinfo_get_pkgname(pkgmgrinfo_appinfo_h handle, char **pkg_name)
1439 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1441 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1442 retvm_if(pkg_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1444 if (info->package == NULL)
1445 return PMINFO_R_ERROR;
1447 *pkg_name = (char *)info->package;
1452 API int pkgmgrinfo_appinfo_get_pkgid(pkgmgrinfo_appinfo_h handle, char **pkgid)
1454 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1456 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1457 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1459 if (info->package == NULL)
1460 return PMINFO_R_ERROR;
1462 *pkgid = (char *)info->package;
1467 API int pkgmgrinfo_appinfo_get_pkgtype(pkgmgrinfo_appinfo_h handle, char **pkgtype)
1469 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1470 retvm_if(pkgtype == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1471 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1473 *pkgtype = (char *)info->app_info->package_type;
1478 API int pkgmgrinfo_appinfo_get_exec(pkgmgrinfo_appinfo_h handle, char **exec)
1480 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1482 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1483 retvm_if(exec == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1485 if (info->app_info == NULL || info->app_info->exec == NULL)
1486 return PMINFO_R_ERROR;
1487 *exec = (char *)info->app_info->exec;
1493 API int pkgmgrinfo_appinfo_get_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1496 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1498 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1499 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1501 if (info->app_info == NULL)
1502 return PMINFO_R_ERROR;
1504 if (info->app_info->icon == NULL) {
1509 ptr = (icon_x *)info->app_info->icon->data;
1511 return PMINFO_R_ERROR;
1513 if (ptr->text == NULL)
1514 return PMINFO_R_ERROR;
1522 API int pkgmgrinfo_appinfo_get_label(pkgmgrinfo_appinfo_h handle, char **label)
1525 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1527 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1528 retvm_if(label == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1530 if (info->app_info == NULL || info->app_info->label == NULL)
1531 return PMINFO_R_ERROR;
1533 ptr = (label_x *)info->app_info->label->data;
1535 return PMINFO_R_ERROR;
1537 if (ptr->text == NULL)
1538 return PMINFO_R_ERROR;
1545 static char *_get_localed_label(const char *appid, const char *locale, uid_t uid)
1547 char *result = NULL;
1549 sqlite3_stmt *stmt = NULL;
1554 parser_db = getUserPkgParserDBPathUID(uid);
1555 if (parser_db == NULL) {
1556 _LOGE("Failed to get parser db path");
1560 if (sqlite3_open_v2(parser_db, &db, SQLITE_OPEN_READONLY, NULL) != SQLITE_OK) {
1561 _LOGE("DB open fail\n");
1567 query = sqlite3_mprintf("select app_label from package_app_localized_info where app_id=%Q and app_locale=%Q", appid, locale);
1568 if (query == NULL) {
1569 _LOGE("Out of memory");
1573 if (sqlite3_prepare_v2(db, query, -1, &stmt, NULL) != SQLITE_OK) {
1574 _LOGE("prepare_v2 fail\n");
1578 if (sqlite3_step(stmt) == SQLITE_ROW) {
1579 val = (char *)sqlite3_column_text(stmt, 0);
1581 result = strdup(val);
1585 sqlite3_finalize(stmt);
1586 sqlite3_free(query);
1592 API int pkgmgrinfo_appinfo_usr_get_localed_label(const char *appid, const char *locale, uid_t uid, char **label)
1596 retvm_if(appid == NULL || locale == NULL || label == NULL, PMINFO_R_EINVAL, "Argument is NULL");
1598 val = _get_localed_label(appid, locale, uid);
1600 val = _get_localed_label(appid, DEFAULT_LOCALE, uid);
1603 val = _get_localed_label(appid, locale, GLOBAL_USER);
1605 val = _get_localed_label(appid, DEFAULT_LOCALE, GLOBAL_USER);
1609 return PMINFO_R_ERROR;
1616 API int pkgmgrinfo_appinfo_get_localed_label(const char *appid, const char *locale, char **label)
1618 return pkgmgrinfo_appinfo_usr_get_localed_label(appid, locale, _getuid(), label);
1621 API int pkgmgrinfo_appinfo_get_metadata_value(pkgmgrinfo_appinfo_h handle, const char *metadata_key, char **metadata_value)
1623 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1624 retvm_if(metadata_key == NULL, PMINFO_R_EINVAL, "metadata_key is NULL");
1625 retvm_if(metadata_value == NULL, PMINFO_R_EINVAL, "metadata_value is NULL");
1627 GList *list_md = NULL;
1628 metadata_x *metadata = NULL;
1629 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1631 list_md = info->app_info->metadata;
1633 for (; list_md; list_md = list_md->next) {
1634 metadata = (metadata_x *)list_md->data;
1635 if (metadata && metadata->key) {
1636 if (strcasecmp(metadata->key, metadata_key) == 0) {
1637 if (metadata->value == NULL)
1638 *metadata_value = "";
1640 *metadata_value = (char *)metadata->value;
1646 return PMINFO_R_EINVAL;
1649 static pkgmgrinfo_app_component __appcomponent_convert(const char *comp)
1651 if (strcasecmp(comp, "uiapp") == 0)
1652 return PMINFO_UI_APP;
1653 else if (strcasecmp(comp, "svcapp") == 0)
1654 return PMINFO_SVC_APP;
1655 else if (strcasecmp(comp, "widgetapp") == 0)
1656 return PMINFO_WIDGET_APP;
1657 else if (strcasecmp(comp, "watchapp") == 0)
1658 return PMINFO_WATCH_APP;
1663 static const char *__appcomponent_str(pkgmgrinfo_app_component comp)
1668 case PMINFO_SVC_APP:
1670 case PMINFO_WIDGET_APP:
1672 case PMINFO_WATCH_APP:
1679 API int pkgmgrinfo_appinfo_get_component(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_component *component)
1681 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1684 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1685 retvm_if(component == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1687 if (info->app_info == NULL)
1688 return PMINFO_R_ERROR;
1690 comp = __appcomponent_convert(info->app_info->component);
1692 return PMINFO_R_ERROR;
1699 API int pkgmgrinfo_appinfo_get_apptype(pkgmgrinfo_appinfo_h handle, char **app_type)
1701 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1703 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1704 retvm_if(app_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1706 if (info->app_info == NULL || info->app_info->type == NULL)
1707 return PMINFO_R_ERROR;
1708 *app_type = (char *)info->app_info->type;
1713 API int pkgmgrinfo_appinfo_get_operation(pkgmgrinfo_appcontrol_h handle,
1714 int *operation_count, char ***operation)
1716 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1717 retvm_if(operation == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1718 retvm_if(operation_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1719 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1720 *operation_count = data->operation_count;
1721 *operation = data->operation;
1725 API int pkgmgrinfo_appinfo_get_uri(pkgmgrinfo_appcontrol_h handle,
1726 int *uri_count, char ***uri)
1728 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1729 retvm_if(uri == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1730 retvm_if(uri_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1731 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1732 *uri_count = data->uri_count;
1737 API int pkgmgrinfo_appinfo_get_mime(pkgmgrinfo_appcontrol_h handle,
1738 int *mime_count, char ***mime)
1740 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1741 retvm_if(mime == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1742 retvm_if(mime_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1743 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1744 *mime_count = data->mime_count;
1749 API int pkgmgrinfo_appinfo_get_subapp(pkgmgrinfo_appcontrol_h handle,
1750 int *subapp_count, char ***subapp)
1752 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1753 retvm_if(subapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1754 retvm_if(subapp_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1755 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1756 *subapp_count = data->subapp_count;
1757 *subapp = data->subapp;
1761 API int pkgmgrinfo_appinfo_get_setting_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1766 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1768 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1769 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1771 if (info->app_info == NULL)
1772 return PMINFO_R_ERROR;
1774 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1775 ptr = (icon_x *)tmp->data;
1776 if (ptr == NULL || ptr->section == NULL)
1779 val = (char *)ptr->section;
1780 if (val && strcmp(val, "setting") == 0) {
1781 *icon = (char *)ptr->text;
1786 return PMINFO_R_ERROR;
1790 API int pkgmgrinfo_appinfo_get_notification_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1795 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1797 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1798 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1800 if (info->app_info == NULL)
1801 return PMINFO_R_ERROR;
1803 for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1804 ptr = (icon_x *)tmp->data;
1805 if (ptr == NULL || ptr->section == NULL)
1808 val = (char *)ptr->section;
1809 if (val && strcmp(val, "notification") == 0) {
1810 *icon = (char *)ptr->text;
1815 return PMINFO_R_ERROR;
1818 API int pkgmgrinfo_appinfo_get_recent_image_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_recentimage *type)
1821 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1823 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1824 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1826 if (info->app_info == NULL || info->app_info->recentimage == NULL)
1827 return PMINFO_R_ERROR;
1829 val = (char *)info->app_info->recentimage;
1830 if (strcasecmp(val, "capture") == 0)
1831 *type = PMINFO_RECENTIMAGE_USE_CAPTURE;
1832 else if (strcasecmp(val, "icon") == 0)
1833 *type = PMINFO_RECENTIMAGE_USE_ICON;
1835 *type = PMINFO_RECENTIMAGE_USE_NOTHING;
1840 API int pkgmgrinfo_appinfo_get_preview_image(pkgmgrinfo_appinfo_h handle, char **preview_img)
1845 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1847 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1848 retvm_if(preview_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1850 if (info->app_info == NULL)
1851 return PMINFO_R_ERROR;
1853 for (tmp = info->app_info->image; tmp; tmp = tmp->next) {
1854 ptr = (image_x *)tmp->data;
1855 if (ptr == NULL || ptr->section == NULL)
1858 val = (char *)ptr->section;
1859 if (val && strcmp(val, "preview") == 0) {
1860 *preview_img = (char *)ptr->text;
1865 return PMINFO_R_ERROR;
1868 API int pkgmgrinfo_appinfo_get_permission_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_permission_type *permission)
1871 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1873 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1874 retvm_if(permission == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1876 val = info->app_info->permission_type;
1878 return PMINFO_R_ERROR;
1880 if (strcmp(val, "signature") == 0)
1881 *permission = PMINFO_PERMISSION_SIGNATURE;
1882 else if (strcmp(val, "privilege") == 0)
1883 *permission = PMINFO_PERMISSION_PRIVILEGE;
1885 *permission = PMINFO_PERMISSION_NORMAL;
1890 API int pkgmgrinfo_appinfo_get_component_type(pkgmgrinfo_appinfo_h handle, char **component_type)
1892 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1894 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1895 retvm_if(component_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1897 if (info->app_info == NULL || info->app_info->component_type == NULL)
1898 return PMINFO_R_ERROR;
1900 *component_type = (char *)info->app_info->component_type;
1905 API int pkgmgrinfo_appinfo_get_hwacceleration(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_hwacceleration *hwacceleration)
1908 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1910 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1911 retvm_if(hwacceleration == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1913 if (info->app_info == NULL || info->app_info->hwacceleration == NULL)
1914 return PMINFO_R_ERROR;
1916 val = (char *)info->app_info->hwacceleration;
1917 if (strcasecmp(val, "off") == 0)
1918 *hwacceleration = PMINFO_HWACCELERATION_OFF;
1919 else if (strcasecmp(val, "on") == 0)
1920 *hwacceleration = PMINFO_HWACCELERATION_ON;
1922 *hwacceleration = PMINFO_HWACCELERATION_DEFAULT;
1927 API int pkgmgrinfo_appinfo_get_screenreader(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_screenreader *screenreader)
1930 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1932 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1933 retvm_if(screenreader == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1935 if (info->app_info == NULL || info->app_info->screenreader == NULL)
1936 return PMINFO_R_ERROR;
1938 val = (char *)info->app_info->screenreader;
1939 if (strcasecmp(val, "screenreader-off") == 0)
1940 *screenreader = PMINFO_SCREENREADER_OFF;
1941 else if (strcasecmp(val, "screenreader-on") == 0)
1942 *screenreader = PMINFO_SCREENREADER_ON;
1944 *screenreader = PMINFO_SCREENREADER_USE_SYSTEM_SETTING;
1949 API int pkgmgrinfo_appinfo_get_effectimage(pkgmgrinfo_appinfo_h handle, char **portrait_img, char **landscape_img)
1951 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1953 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1954 retvm_if(portrait_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1955 retvm_if(landscape_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1957 if (info->app_info == NULL)
1958 return PMINFO_R_ERROR;
1960 if (info->app_info->portraitimg == NULL)
1963 *portrait_img = (char *)info->app_info->portraitimg;
1965 if (info->app_info->landscapeimg == NULL)
1966 *landscape_img = "";
1968 *landscape_img = (char *)info->app_info->landscapeimg;
1973 API int pkgmgrinfo_appinfo_get_effectimage_type(pkgmgrinfo_appinfo_h handle, char **effectimage_type)
1975 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1977 if (handle == NULL || effectimage_type == NULL) {
1978 LOGE("invalid parameter");
1979 return PMINFO_R_EINVAL;
1982 if (info->app_info == NULL || info->app_info->effectimage_type == NULL)
1983 return PMINFO_R_ERROR;
1985 *effectimage_type = (char *)info->app_info->effectimage_type;
1990 API int pkgmgrinfo_appinfo_get_submode_mainid(pkgmgrinfo_appinfo_h handle, char **submode_mainid)
1992 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1994 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1995 retvm_if(submode_mainid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1997 if (info->app_info == NULL)
1998 return PMINFO_R_ERROR;
2000 if (info->app_info->submode_mainid == NULL)
2001 *submode_mainid = "";
2003 *submode_mainid = (char *)info->app_info->submode_mainid;
2008 API int pkgmgrinfo_appinfo_get_installed_storage_location(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_installed_storage *storage)
2010 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2011 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2013 if (info->app_info && info->app_info->installed_storage) {
2014 if (strcmp(info->app_info->installed_storage, "installed_internal") == 0)
2015 *storage = PMINFO_INTERNAL_STORAGE;
2016 else if (strcmp(info->app_info->installed_storage, "installed_external") == 0)
2017 *storage = PMINFO_EXTERNAL_STORAGE;
2019 return PMINFO_R_ERROR;
2021 return PMINFO_R_ERROR;
2027 API int pkgmgrinfo_appinfo_get_launch_mode(pkgmgrinfo_appinfo_h handle, char **mode)
2029 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2031 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2032 retvm_if(mode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2034 if (info->app_info->launch_mode == NULL)
2035 return PMINFO_R_ERROR;
2037 *mode = (char *)(info->app_info->launch_mode);
2042 API int pkgmgrinfo_appinfo_get_alias_appid(pkgmgrinfo_appinfo_h handle, char **alias_appid)
2044 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2046 if (handle == NULL || alias_appid == NULL) {
2047 LOGE("invalid parameter");
2048 return PMINFO_R_EINVAL;
2051 if (info->app_info == NULL || info->app_info->alias_appid == NULL)
2052 return PMINFO_R_ERROR;
2054 *alias_appid = (char *)info->app_info->alias_appid;
2059 API int pkgmgrinfo_appinfo_get_effective_appid(pkgmgrinfo_appinfo_h handle, char **effective_appid)
2061 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2063 if (handle == NULL || effective_appid == NULL) {
2064 LOGE("invalid parameter");
2065 return PMINFO_R_EINVAL;
2068 if (info->app_info == NULL)
2069 return PMINFO_R_ERROR;
2071 if (info->app_info->effective_appid == NULL)
2072 *effective_appid = "";
2074 *effective_appid = (char *)info->app_info->effective_appid;
2079 API int pkgmgrinfo_appinfo_get_tep_name(pkgmgrinfo_appinfo_h handle, char **tep_name)
2081 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2083 if (handle == NULL || tep_name == NULL) {
2084 LOGE("invalid parameter");
2085 return PMINFO_R_EINVAL;
2088 if (info->app_info == NULL)
2089 return PMINFO_R_ERROR;
2091 if (info->app_info->tep_name == NULL)
2094 *tep_name = (char *)info->app_info->tep_name;
2099 API int pkgmgrinfo_appinfo_get_zip_mount_file(pkgmgrinfo_appinfo_h handle, char **zip_mount_file)
2101 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2103 if (handle == NULL || zip_mount_file == NULL) {
2104 LOGE("invalid parameter");
2105 return PMINFO_R_EINVAL;
2108 if (info->app_info == NULL)
2109 return PMINFO_R_ERROR;
2111 if (info->app_info->zip_mount_file == NULL)
2112 *zip_mount_file = "";
2114 *zip_mount_file = (char *)info->app_info->zip_mount_file;
2119 API int pkgmgrinfo_appinfo_get_root_path(pkgmgrinfo_appinfo_h handle, char **root_path)
2121 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2123 if (handle == NULL || root_path == NULL) {
2124 LOGE("invalid parameter");
2125 return PMINFO_R_EINVAL;
2128 if (info->app_info == NULL || info->app_info->root_path == NULL)
2129 return PMINFO_R_ERROR;
2131 *root_path = (char *)info->app_info->root_path;
2136 API int pkgmgrinfo_appinfo_get_api_version(pkgmgrinfo_appinfo_h handle, char **api_version)
2138 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2140 if (handle == NULL || api_version == NULL) {
2141 LOGE("invalid parameter");
2142 return PMINFO_R_EINVAL;
2145 if (info->app_info == NULL || info->app_info->api_version == NULL)
2146 return PMINFO_R_ERROR;
2148 *api_version = (char *)info->app_info->api_version;
2153 API int pkgmgrinfo_appinfo_get_installed_time(pkgmgrinfo_appinfo_h handle, int *installed_time)
2155 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2157 if (handle == NULL || installed_time == NULL) {
2158 LOGE("invalid parameter");
2159 return PMINFO_R_EINVAL;
2162 if (info->app_info == NULL || info->app_info->package_installed_time == NULL)
2163 return PMINFO_R_ERROR;
2165 *installed_time = atoi(info->app_info->package_installed_time);
2170 API int pkgmgrinfo_appinfo_usr_get_datacontrol_info(const char *providerid, const char *type, uid_t uid, char **appid, char **access)
2172 retvm_if(providerid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
2173 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
2174 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2175 retvm_if(access == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2177 int ret = PMINFO_R_OK;
2179 sqlite3_stmt *stmt = NULL;
2182 ret = __open_manifest_db(uid, true);
2183 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
2185 /*Start constructing query*/
2186 query = sqlite3_mprintf("select * from package_app_data_control where providerid=%Q and type=%Q", providerid, type);
2187 tryvm_if(query == NULL, ret = PMINFO_R_ERROR, "Out of memory");
2190 ret = sqlite3_prepare_v2(GET_DB(manifest_db), query, strlen(query), &stmt, NULL);
2191 tryvm_if(ret != PMINFO_R_OK, ret = PMINFO_R_ERROR, "sqlite3_prepare_v2 failed[%s]\n", query);
2194 ret = sqlite3_step(stmt);
2195 tryvm_if((ret != SQLITE_ROW) || (ret == SQLITE_DONE), ret = PMINFO_R_ERROR, "No records found");
2197 *appid = strdup((char *)sqlite3_column_text(stmt, 0));
2198 *access = strdup((char *)sqlite3_column_text(stmt, 2));
2203 sqlite3_free(query);
2204 sqlite3_finalize(stmt);
2205 __close_manifest_db();
2209 API int pkgmgrinfo_appinfo_get_datacontrol_info(const char *providerid, const char *type, char **appid, char **access)
2211 return pkgmgrinfo_appinfo_usr_get_datacontrol_info(providerid, type, _getuid(), appid, access);
2214 API int pkgmgrinfo_appinfo_usr_get_datacontrol_appid(const char *providerid, uid_t uid, char **appid)
2216 retvm_if(providerid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
2217 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2219 int ret = PMINFO_R_OK;
2221 sqlite3_stmt *stmt = NULL;
2224 ret = __open_manifest_db(uid, true);
2225 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
2227 /*Start constructing query*/
2228 query = sqlite3_mprintf("select * from package_app_data_control where providerid=%Q", providerid);
2229 tryvm_if(query == NULL, ret = PMINFO_R_ERROR, "Out of memory");
2232 ret = sqlite3_prepare_v2(GET_DB(manifest_db), query, strlen(query), &stmt, NULL);
2233 tryvm_if(ret != PMINFO_R_OK, ret = PMINFO_R_ERROR, "sqlite3_prepare_v2 failed[%s]\n", query);
2236 ret = sqlite3_step(stmt);
2237 tryvm_if((ret != SQLITE_ROW) || (ret == SQLITE_DONE), ret = PMINFO_R_ERROR, "No records found");
2239 *appid = strdup((char *)sqlite3_column_text(stmt, 0));
2244 sqlite3_free(query);
2245 sqlite3_finalize(stmt);
2246 __close_manifest_db();
2250 API int pkgmgrinfo_appinfo_get_datacontrol_appid(const char *providerid, char **appid)
2252 return pkgmgrinfo_appinfo_usr_get_datacontrol_appid(providerid, _getuid(), appid);
2255 API int pkgmgrinfo_appinfo_get_support_mode(pkgmgrinfo_appinfo_h handle, int *support_mode)
2257 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2258 retvm_if(support_mode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2260 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2261 if (info->app_info->support_mode)
2262 *support_mode = atoi(info->app_info->support_mode);
2269 API int pkgmgrinfo_appinfo_foreach_permission(pkgmgrinfo_appinfo_h handle,
2270 pkgmgrinfo_app_permission_list_cb permission_func, void *user_data)
2272 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2273 retvm_if(permission_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2277 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2279 if (info->app_info == NULL)
2280 return PMINFO_R_ERROR;
2282 for (tmp = info->app_info->permission; tmp; tmp = tmp->next) {
2283 ptr = (permission_x *)tmp->data;
2287 ret = permission_func(ptr->value, user_data);
2295 API int pkgmgrinfo_appinfo_foreach_category(pkgmgrinfo_appinfo_h handle,
2296 pkgmgrinfo_app_category_list_cb category_func, void *user_data)
2298 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2299 retvm_if(category_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2301 const char *category;
2303 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2305 if (info->app_info == NULL)
2306 return PMINFO_R_ERROR;
2308 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
2309 category = (const char *)tmp->data;
2311 ret = category_func(category, user_data);
2319 API int pkgmgrinfo_appinfo_foreach_metadata(pkgmgrinfo_appinfo_h handle,
2320 pkgmgrinfo_app_metadata_list_cb metadata_func, void *user_data)
2322 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2323 retvm_if(metadata_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2327 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2329 if (info->app_info == NULL)
2330 return PMINFO_R_ERROR;
2332 for (tmp = info->app_info->metadata; tmp; tmp = tmp->next) {
2333 ptr = (metadata_x *)tmp->data;
2337 ret = metadata_func(ptr->key, ptr->value ? ptr->value : "", user_data);
2345 API int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
2346 pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
2348 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2349 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2351 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2352 appcontrol_x *appcontrol;
2355 if (info->app_info == NULL)
2356 return PMINFO_R_ERROR;
2358 for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
2359 appcontrol = (appcontrol_x *)tmp->data;
2360 if (appcontrol == NULL)
2362 ret = appcontrol_func(appcontrol->operation, appcontrol->uri, appcontrol->mime, user_data);
2370 API int pkgmgrinfo_appinfo_foreach_background_category(
2371 pkgmgrinfo_appinfo_h handle,
2372 pkgmgrinfo_app_background_category_list_cb category_func,
2375 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2379 if (handle == NULL || category_func == NULL || info->app_info == NULL) {
2380 LOGE("invalid parameter");
2381 return PMINFO_R_EINVAL;
2384 for (tmp = info->app_info->background_category; tmp; tmp = tmp->next) {
2385 category = (char *)tmp->data;
2386 if (category == NULL)
2389 if (category_func(category, user_data) < 0)
2396 API int pkgmgrinfo_appinfo_foreach_splash_screen(pkgmgrinfo_appinfo_h handle,
2397 pkgmgrinfo_app_splash_screen_list_cb splash_screen_func,
2400 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2401 splashscreen_x *splashscreen;
2405 if (info == NULL || info->app_info == NULL
2406 || splash_screen_func == NULL) {
2407 LOGE("invalid parameter");
2408 return PMINFO_R_EINVAL;
2411 for (tmp = info->app_info->splashscreens; tmp; tmp = tmp->next) {
2412 splashscreen = (splashscreen_x *)tmp->data;
2413 if (splashscreen == NULL)
2415 ret = splash_screen_func(splashscreen->src,
2417 splashscreen->orientation,
2418 splashscreen->indicatordisplay,
2419 splashscreen->operation,
2420 splashscreen->color_depth,
2429 API int pkgmgrinfo_appinfo_is_nodisplay(pkgmgrinfo_appinfo_h handle, bool *nodisplay)
2431 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2432 retvm_if(nodisplay == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2433 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2435 if (info->app_info == NULL || info->app_info->nodisplay == NULL)
2436 return PMINFO_R_ERROR;
2438 *nodisplay = _get_bool_value(info->app_info->nodisplay);
2443 API int pkgmgrinfo_appinfo_is_multiple(pkgmgrinfo_appinfo_h handle, bool *multiple)
2445 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2446 retvm_if(multiple == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2447 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2449 if (info->app_info == NULL || info->app_info->multiple == NULL)
2450 return PMINFO_R_ERROR;
2452 *multiple = _get_bool_value(info->app_info->multiple);
2457 API int pkgmgrinfo_appinfo_is_indicator_display_allowed(pkgmgrinfo_appinfo_h handle, bool *indicator_disp)
2459 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2460 retvm_if(indicator_disp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2461 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2463 if (info->app_info == NULL || info->app_info->indicatordisplay == NULL)
2464 return PMINFO_R_ERROR;
2466 *indicator_disp = _get_bool_value(info->app_info->indicatordisplay);
2471 API int pkgmgrinfo_appinfo_is_taskmanage(pkgmgrinfo_appinfo_h handle, bool *taskmanage)
2473 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2474 retvm_if(taskmanage == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2475 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2477 if (info->app_info == NULL || info->app_info->taskmanage == NULL)
2478 return PMINFO_R_ERROR;
2480 *taskmanage = _get_bool_value(info->app_info->taskmanage);
2485 API int pkgmgrinfo_appinfo_is_enabled(pkgmgrinfo_appinfo_h handle, bool *enabled)
2487 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2488 retvm_if(enabled == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2489 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2491 if (info->app_info == NULL || info->app_info->enabled == NULL)
2492 return PMINFO_R_ERROR;
2494 *enabled = _get_bool_value(info->app_info->enabled);
2499 API int pkgmgrinfo_appinfo_is_onboot(pkgmgrinfo_appinfo_h handle, bool *onboot)
2501 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2502 retvm_if(onboot == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2503 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2505 if (info->app_info == NULL || info->app_info->onboot == NULL)
2506 return PMINFO_R_ERROR;
2508 *onboot = _get_bool_value(info->app_info->onboot);
2513 API int pkgmgrinfo_appinfo_is_autorestart(pkgmgrinfo_appinfo_h handle, bool *autorestart)
2515 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2516 retvm_if(autorestart == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2517 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2519 if (info->app_info == NULL || info->app_info->autorestart == NULL)
2520 return PMINFO_R_ERROR;
2522 *autorestart = _get_bool_value(info->app_info->autorestart);
2527 API int pkgmgrinfo_appinfo_is_mainapp(pkgmgrinfo_appinfo_h handle, bool *mainapp)
2529 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2530 retvm_if(mainapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2531 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2533 if (info->app_info == NULL || info->app_info->mainapp == NULL)
2534 return PMINFO_R_ERROR;
2536 *mainapp = _get_bool_value(info->app_info->mainapp);
2541 API int pkgmgrinfo_appinfo_is_preload(pkgmgrinfo_appinfo_h handle, bool *preload)
2543 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2544 retvm_if(preload == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2545 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2547 if (info->app_info == NULL || info->app_info->preload == NULL)
2548 return PMINFO_R_ERROR;
2550 *preload = _get_bool_value(info->app_info->preload);
2555 API int pkgmgrinfo_appinfo_is_submode(pkgmgrinfo_appinfo_h handle, bool *submode)
2557 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2558 retvm_if(submode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2559 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2561 if (info->app_info == NULL || info->app_info->submode == NULL)
2562 return PMINFO_R_ERROR;
2564 *submode = _get_bool_value(info->app_info->submode);
2569 API int pkgmgrinfo_appinfo_is_process_pool(pkgmgrinfo_appinfo_h handle, bool *process_pool)
2571 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2573 if (handle == NULL || process_pool == NULL) {
2574 LOGE("invalid parameter");
2575 return PMINFO_R_EINVAL;
2578 if (info->app_info == NULL)
2579 return PMINFO_R_ERROR;
2581 *process_pool = _get_bool_value(info->app_info->process_pool);
2586 API int pkgmgrinfo_appinfo_is_category_exist(pkgmgrinfo_appinfo_h handle, const char *category, bool *exist)
2588 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2589 retvm_if(category == NULL, PMINFO_R_EINVAL, "category is NULL");
2590 retvm_if(exist == NULL, PMINFO_R_EINVAL, "exist is NULL");
2594 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2596 if (info->app_info == NULL)
2597 return PMINFO_R_ERROR;
2600 for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
2601 val = (const char *)tmp->data;
2604 if (strcasecmp(val, category) == 0) {
2613 API int pkgmgrinfo_appinfo_is_ui_gadget(pkgmgrinfo_appinfo_h handle,
2616 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2618 if (info == NULL || info->app_info == NULL || ui_gadget == NULL) {
2619 _LOGE("invalid parameter");
2620 return PMINFO_R_EINVAL;
2622 if (info->app_info->ui_gadget == NULL)
2623 info->app_info->ui_gadget = strdup("false");
2625 *ui_gadget = _get_bool_value(info->app_info->ui_gadget);
2630 API int pkgmgrinfo_appinfo_is_support_disable(pkgmgrinfo_appinfo_h handle,
2631 bool *support_disable)
2633 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2635 if (info == NULL || info->app_info == NULL || support_disable == NULL) {
2636 _LOGE("invalid parameter");
2637 return PMINFO_R_EINVAL;
2640 *support_disable = _get_bool_value(info->app_info->support_disable);
2645 API int pkgmgrinfo_appinfo_is_removable(pkgmgrinfo_appinfo_h handle,
2648 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2650 if (info == NULL || info->app_info == NULL || removable == NULL) {
2651 _LOGE("invalid parameter");
2652 return PMINFO_R_EINVAL;
2655 *removable = _get_bool_value(info->app_info->removable);
2660 API int pkgmgrinfo_appinfo_is_system(pkgmgrinfo_appinfo_h handle, bool *system)
2662 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2664 if (info == NULL || info->app_info == NULL || system == NULL) {
2665 _LOGE("invalid parameter");
2666 return PMINFO_R_EINVAL;
2669 *system = _get_bool_value(info->app_info->package_system);
2674 API int pkgmgrinfo_appinfo_is_disabled(pkgmgrinfo_appinfo_h handle, bool *disabled)
2676 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2677 retvm_if(disabled == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2678 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2680 if (info->app_info == NULL || info->app_info->is_disabled == NULL)
2681 return PMINFO_R_ERROR;
2683 *disabled = _get_bool_value(info->app_info->is_disabled);
2688 API int pkgmgrinfo_appinfo_is_global(pkgmgrinfo_appinfo_h handle, bool *global)
2690 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2692 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2693 retvm_if(global == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2695 if (info->app_info == NULL || info->app_info->for_all_users == NULL)
2696 return PMINFO_R_ERROR;
2698 *global = _get_bool_value(info->app_info->for_all_users);
2703 API int pkgmgrinfo_appinfo_get_splash_screen_display(pkgmgrinfo_appinfo_h handle, bool *splash_screen_display)
2705 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2707 if (info == NULL || splash_screen_display == NULL) {
2708 _LOGE("Invalid parameter");
2709 return PMINFO_R_EINVAL;
2712 if (info->app_info == NULL || info->app_info->splash_screen_display == NULL)
2713 return PMINFO_R_ERROR;
2715 *splash_screen_display = _get_bool_value(info->app_info->splash_screen_display);
2720 API int pkgmgrinfo_appinfo_destroy_appinfo(pkgmgrinfo_appinfo_h handle)
2722 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2723 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2724 __cleanup_appinfo(info);
2728 API int pkgmgrinfo_appinfo_filter_create(pkgmgrinfo_appinfo_filter_h *handle)
2730 return (pkgmgrinfo_pkginfo_filter_create(handle));
2733 API int pkgmgrinfo_appinfo_filter_destroy(pkgmgrinfo_appinfo_filter_h handle)
2735 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
2738 static gint __compare_func(gconstpointer data1, gconstpointer data2)
2740 pkgmgrinfo_node_x *node1 = (pkgmgrinfo_node_x *)data1;
2741 pkgmgrinfo_node_x *node2 = (pkgmgrinfo_node_x *)data2;
2742 if (node1->prop == node2->prop)
2744 else if (node1->prop > node2->prop)
2750 API int pkgmgrinfo_appinfo_filter_add_int(pkgmgrinfo_appinfo_filter_h handle,
2751 const char *property, const int value)
2753 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2754 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2755 char buf[PKG_VALUE_STRING_LEN_MAX] = {'\0'};
2757 GSList *link = NULL;
2759 prop = _pminfo_appinfo_convert_to_prop_int(property);
2760 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_INT ||
2761 prop > E_PMINFO_APPINFO_PROP_APP_MAX_INT) {
2762 _LOGE("Invalid Integer Property\n");
2763 return PMINFO_R_EINVAL;
2765 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2766 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1, sizeof(pkgmgrinfo_node_x));
2768 _LOGE("Out of Memory!!!\n");
2769 return PMINFO_R_ERROR;
2771 snprintf(buf, PKG_VALUE_STRING_LEN_MAX - 1, "%d", value);
2772 val = strndup(buf, PKG_VALUE_STRING_LEN_MAX - 1);
2774 _LOGE("Out of Memory\n");
2777 return PMINFO_R_ERROR;
2781 /*If API is called multiple times for same property, we should override the previous values.
2782 Last value set will be used for filtering.*/
2783 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2785 filter->list = g_slist_delete_link(filter->list, link);
2786 filter->list = g_slist_append(filter->list, (gpointer)node);
2791 API int pkgmgrinfo_appinfo_filter_add_bool(pkgmgrinfo_appinfo_filter_h handle,
2792 const char *property, const bool value)
2794 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2795 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2797 GSList *link = NULL;
2799 prop = _pminfo_appinfo_convert_to_prop_bool(property);
2800 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_BOOL ||
2801 prop > E_PMINFO_APPINFO_PROP_APP_MAX_BOOL) {
2802 _LOGE("Invalid Boolean Property\n");
2803 return PMINFO_R_EINVAL;
2805 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2806 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1, sizeof(pkgmgrinfo_node_x));
2808 _LOGE("Out of Memory!!!\n");
2809 return PMINFO_R_ERROR;
2812 val = strndup("true", 4);
2814 val = strndup("false", 5);
2816 _LOGE("Out of Memory\n");
2819 return PMINFO_R_ERROR;
2823 /*If API is called multiple times for same property, we should override the previous values.
2824 Last value set will be used for filtering.*/
2825 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2827 filter->list = g_slist_delete_link(filter->list, link);
2828 filter->list = g_slist_append(filter->list, (gpointer)node);
2833 API int pkgmgrinfo_appinfo_filter_add_string(pkgmgrinfo_appinfo_filter_h handle,
2834 const char *property, const char *value)
2836 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2837 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2838 retvm_if(value == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2840 pkgmgrinfo_node_x *ptr = NULL;
2841 char prev[PKG_STRING_LEN_MAX] = {'\0'};
2842 char temp[PKG_STRING_LEN_MAX] = {'\0'};
2843 GSList *link = NULL;
2845 prop = _pminfo_appinfo_convert_to_prop_str(property);
2846 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_STR ||
2847 prop > E_PMINFO_APPINFO_PROP_APP_MAX_STR) {
2848 _LOGE("Invalid String Property\n");
2849 return PMINFO_R_EINVAL;
2851 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2852 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1, sizeof(pkgmgrinfo_node_x));
2854 _LOGE("Out of Memory!!!\n");
2855 return PMINFO_R_ERROR;
2859 case E_PMINFO_APPINFO_PROP_APP_COMPONENT:
2860 node->value = strdup(value);
2861 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2863 filter->list = g_slist_delete_link(filter->list, link);
2864 filter->list = g_slist_append(filter->list, (gpointer)node);
2866 case E_PMINFO_APPINFO_PROP_APP_CATEGORY:
2867 val = (char *)calloc(1, PKG_STRING_LEN_MAX);
2869 _LOGE("Out of Memory\n");
2872 return PMINFO_R_ERROR;
2874 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2876 ptr = (pkgmgrinfo_node_x *)link->data;
2877 strncpy(prev, ptr->value, PKG_STRING_LEN_MAX - 1);
2878 _LOGI("Previous value is %s\n", prev);
2879 filter->list = g_slist_delete_link(filter->list, link);
2880 snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s,%s", prev, value);
2881 strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
2882 _LOGI("New value is %s\n", val);
2884 filter->list = g_slist_append(filter->list, (gpointer)node);
2885 memset(temp, '\0', PKG_STRING_LEN_MAX);
2887 snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s", value);
2888 strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
2889 _LOGI("First value is %s\n", val);
2891 filter->list = g_slist_append(filter->list, (gpointer)node);
2892 memset(temp, '\0', PKG_STRING_LEN_MAX);
2896 node->value = strndup(value, PKG_STRING_LEN_MAX - 1);
2897 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2899 filter->list = g_slist_delete_link(filter->list, link);
2900 filter->list = g_slist_append(filter->list, (gpointer)node);
2906 API int pkgmgrinfo_appinfo_usr_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count, uid_t uid)
2912 if (handle == NULL || count == NULL) {
2913 _LOGE("invalid parameter");
2914 return PMINFO_R_EINVAL;
2917 locale = _get_system_locale();
2919 return PMINFO_R_ERROR;
2921 list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
2922 __free_applications);
2925 return PMINFO_R_ERROR;
2928 ret = _appinfo_get_applications(uid, uid, locale, handle, 0, list);
2929 if (ret == PMINFO_R_OK && uid != GLOBAL_USER)
2930 ret = _appinfo_get_applications(GLOBAL_USER, uid, locale,
2933 if (ret != PMINFO_R_OK) {
2934 g_hash_table_destroy(list);
2936 return PMINFO_R_ERROR;
2939 *count = g_hash_table_size(list);
2940 g_hash_table_destroy(list);
2946 API int pkgmgrinfo_appinfo_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count)
2948 return pkgmgrinfo_appinfo_usr_filter_count(handle, count, _getuid());
2951 API int pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(
2952 pkgmgrinfo_appinfo_filter_h handle,
2953 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
2955 if (handle == NULL || app_cb == NULL) {
2956 LOGE("invalid parameter");
2957 return PMINFO_R_EINVAL;
2960 return _appinfo_get_filtered_foreach_appinfo(uid, handle, PMINFO_APPINFO_GET_ALL, app_cb,
2964 API int pkgmgrinfo_appinfo_filter_foreach_appinfo(pkgmgrinfo_appinfo_filter_h handle,
2965 pkgmgrinfo_app_list_cb app_cb, void *user_data)
2967 return pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(handle, app_cb, user_data, _getuid());
2970 API int pkgmgrinfo_appinfo_metadata_filter_create(pkgmgrinfo_appinfo_metadata_filter_h *handle)
2972 return (pkgmgrinfo_pkginfo_filter_create(handle));
2975 API int pkgmgrinfo_appinfo_metadata_filter_destroy(pkgmgrinfo_appinfo_metadata_filter_h handle)
2977 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
2980 API int pkgmgrinfo_appinfo_metadata_filter_add(
2981 pkgmgrinfo_appinfo_metadata_filter_h handle,
2982 const char *key, const char *value)
2986 ret = pkgmgrinfo_appinfo_filter_add_string(handle,
2987 PMINFO_APPINFO_PROP_APP_METADATA_KEY, key);
2988 if (ret != PMINFO_R_OK)
2991 /* value can be NULL.
2992 * In that case all apps with specified key should be displayed
2995 ret = pkgmgrinfo_appinfo_filter_add_string(handle,
2996 PMINFO_APPINFO_PROP_APP_METADATA_VALUE, value);
2997 if (ret != PMINFO_R_OK)
3004 API int pkgmgrinfo_appinfo_usr_metadata_filter_foreach(
3005 pkgmgrinfo_appinfo_metadata_filter_h handle,
3006 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
3008 if (handle == NULL || app_cb == NULL) {
3009 LOGE("invalid parameter");
3010 return PMINFO_R_EINVAL;
3013 return _appinfo_get_filtered_foreach_appinfo(uid, handle, PMINFO_APPINFO_GET_ALL, app_cb,
3017 API int pkgmgrinfo_appinfo_metadata_filter_foreach(
3018 pkgmgrinfo_appinfo_metadata_filter_h handle,
3019 pkgmgrinfo_app_list_cb app_cb, void *user_data)
3021 return pkgmgrinfo_appinfo_usr_metadata_filter_foreach(handle, app_cb,
3022 user_data, _getuid());
3025 API int pkgmgrinfo_appinfo_is_guestmode_visibility(pkgmgrinfo_appinfo_h handle, bool *status)
3028 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
3030 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
3031 retvm_if(status == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3033 val = info->app_info->guestmode_visibility;
3034 *status = _get_bool_value(val);