From 682aa6336565e0d9e15703dde7240caa54de6228 Mon Sep 17 00:00:00 2001 From: Junghyun Yeon Date: Fri, 11 Mar 2016 19:35:03 +0900 Subject: [PATCH] fix queries to send all appinfo to AMD Change-Id: I2385dc8828b7066fb2fdfefebfbd64657d107cb4 Signed-off-by: Junghyun Yeon --- include/pkgmgr-info.h | 36 ++++++++++++++++++++++++++++++++++++ include/pkgmgrinfo_basic.h | 2 ++ src/pkgmgrinfo_appinfo.c | 25 +++++++++++++++++++++---- src/pkgmgrinfo_basic.c | 2 ++ 4 files changed, 61 insertions(+), 4 deletions(-) diff --git a/include/pkgmgr-info.h b/include/pkgmgr-info.h index e5c4a02..1fa977d 100644 --- a/include/pkgmgr-info.h +++ b/include/pkgmgr-info.h @@ -4321,6 +4321,42 @@ static int get_app_support_disable(const char *appid) int pkgmgrinfo_appinfo_is_support_disable(pkgmgrinfo_appinfo_h handle, bool *support_disable); /** + * @fn int pkgmgrinfo_appinfo_is_disabled(pkgmgrinfo_appinfo_h handle, bool *disabled) + * @brief This API gets the application 'is_disable' value from the app ID + * + * @par This API is for package-manager client application + * @par Sync (or) Async : Synchronous API + * + * @param[in] handle pointer to application info handle + * @param[out] disabled pointer to hold application is_disabled value + * @return 0 if success, error code(<0) if fail + * @retval PMINFO_R_OK success + * @retval PMINFO_R_EINVAL invalid argument + * @pre pkgmgrinfo_appinfo_get_appinfo() + * @post pkgmgrinfo_appinfo_destroy_appinfo() + * @code +static int get_app_is_disable(const char *appid) +{ + int ret = 0; + bool is_disable; + pkgmgrinfo_appinfo_h handle = NULL; + ret = pkgmgrinfo_appinfo_get_appinfo(appid, &handle); + if (ret != PMINFO_R_OK) + return -1; + ret = pkgmgrinfo_appinfo_is_disabled(handle, &is_disable); + if (ret != PMINFO_R_OK) { + pkgmgrinfo_appinfo_destroy_appinfo(handle); + return -1; + } + printf("app is_disable: %d\n", is_disable); + pkgmgrinfo_appinfo_destroy_appinfo(handle); + return 0; +} + * @endcode + */ +int pkgmgrinfo_appinfo_is_disabled(pkgmgrinfo_appinfo_h handle, bool *disabled); + +/** * @fn int pkgmgrinfo_appinfo_is_global(pkgmgrinfo_appinfo_h handle, bool *global) * @brief This API gets whethere the given application is global application or user application * diff --git a/include/pkgmgrinfo_basic.h b/include/pkgmgrinfo_basic.h index 0cd0059..c14a553 100644 --- a/include/pkgmgrinfo_basic.h +++ b/include/pkgmgrinfo_basic.h @@ -141,6 +141,8 @@ typedef struct application_x { char *root_path; /*set from package_x*/ char *api_version; /*set from package_x*/ char *for_all_users; /**< Flag that indicates if the package is available for everyone or for current user only, no xml part*/ + char *is_disabled; /**< Flag that indicates if the application is disabled or not, no xml part*/ + GList *label; /*element*/ GList *icon; /*element*/ GList *image; /*element*/ diff --git a/src/pkgmgrinfo_appinfo.c b/src/pkgmgrinfo_appinfo.c index d43f019..27e9534 100644 --- a/src/pkgmgrinfo_appinfo.c +++ b/src/pkgmgrinfo_appinfo.c @@ -806,10 +806,11 @@ int _appinfo_get_applist(uid_t uid, const char *locale, GHashTable **appinfo_tab "app_installed_storage, app_process_pool, app_launch_mode, " "app_package_type, component_type, package, app_tep_name, " "app_background_category, app_root_path, app_api_version, " - "app_effective_appid " - "FROM package_app_info WHERE app_disable='false' AND app_id NOT IN " - "(SELECT app_id FROM package_app_disable_for_user WHERE uid='%d')", - (int)getuid()); + "app_effective_appid, (CASE WHEN A.app_disable='true' THEN 'true' " + "ELSE (CASE WHEN (SELECT app_id FROM package_app_disable_for_user " + "WHERE app_id=A.app_id AND uid='%d') IS NULL " + "THEN 'false' ELSE 'true' END) END) AS app_disable " + "FROM package_app_info A", (int)getuid()); if (query == NULL) { _LOGE("Out of memory"); @@ -858,7 +859,9 @@ int _appinfo_get_applist(uid_t uid, const char *locale, GHashTable **appinfo_tab _save_column_str(stmt, idx++, &bg_category_str); _save_column_str(stmt, idx++, &appinfo->root_path); _save_column_str(stmt, idx++, &appinfo->api_version); + _save_column_str(stmt, idx++, &appinfo->effective_appid); + _save_column_str(stmt, idx++, &appinfo->is_disabled); appinfo->background_category = __get_background_category(bg_category_str); free(bg_category_str); @@ -2587,6 +2590,20 @@ API int pkgmgrinfo_appinfo_is_support_disable(pkgmgrinfo_appinfo_h handle, return PMINFO_R_OK; } +API int pkgmgrinfo_appinfo_is_disabled(pkgmgrinfo_appinfo_h handle, bool *disabled) +{ + retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL"); + retvm_if(disabled == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL"); + pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle; + + if (info->app_info == NULL || info->app_info->is_disabled == NULL) + return PMINFO_R_ERROR; + + *disabled = _get_bool_value(info->app_info->is_disabled); + + return PMINFO_R_OK; +} + API int pkgmgrinfo_appinfo_is_global(pkgmgrinfo_appinfo_h handle, bool *global) { pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle; diff --git a/src/pkgmgrinfo_basic.c b/src/pkgmgrinfo_basic.c index 502bd92..85f8144 100644 --- a/src/pkgmgrinfo_basic.c +++ b/src/pkgmgrinfo_basic.c @@ -299,6 +299,8 @@ static void __ps_free_application(gpointer data) free((void *)application->for_all_users); if (application->effective_appid) free((void *)application->effective_appid); + if (application->is_disabled) + free((void *)application->is_disabled); /*Free Label*/ g_list_free_full(application->label, __ps_free_label); -- 2.7.4