From: kiso.chang Date: Fri, 10 Jun 2016 02:42:44 +0000 (+0900) Subject: Fix "size zero in storage" problem X-Git-Tag: submit/tizen/20160610.025305^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cfb15a903496e6821266b4300361fc63d0ef559f;p=profile%2Fmobile%2Fapps%2Fnative%2Fsettings.git Fix "size zero in storage" problem - Fix TSAM-4131,TSAM-1875,TSAM-2200 - media.db update is fixed - change api of pkgmgr for getting app&cache size Change-Id: I7b8ae60d0cb04072d5463836ba52eec93aab0295 Signed-off-by: kiso.chang --- diff --git a/setting-storage/include/setting-storage-utils.h b/setting-storage/include/setting-storage-utils.h index 6a47d8c6..43285657 100644 --- a/setting-storage/include/setting-storage-utils.h +++ b/setting-storage/include/setting-storage-utils.h @@ -26,7 +26,8 @@ void storageUg_get_internal_storage_status(); void storageUg_get_external_storage_status(const char *path, double *total, double *avail); -void storageUG_update_apps_info(SettingStorageUG *ad); +void storageUG_update_apps_cache_info(SettingStorageUG *ad); + void storageUg_size_to_str(double size, char *desc, int desc_size); void storageUg_ug_layout_cb(ui_gadget_h ug, enum ug_mode mode, void *priv); void storageUg_ug_destroy_cb(ui_gadget_h ug, void *priv); @@ -36,7 +37,6 @@ void storageUg_manage_app_ug(SettingStorageUG *ad); int storageUg_get_internal_detail(SettingStorageUG *ad); void storageUg_get_internal_detail_cb(int fn_result, SettingStorageUG *ad); -void storageUG_update_cache_info(SettingStorageUG *ad); void storageug_genlist_text_update(Setting_GenGroupItem_Data *item_data, double size); diff --git a/setting-storage/src/setting-storage-main.c b/setting-storage/src/setting-storage-main.c index 8bc894b1..7f313abf 100644 --- a/setting-storage/src/setting-storage-main.c +++ b/setting-storage/src/setting-storage-main.c @@ -739,8 +739,7 @@ static int storageUg_main_create(void *data) storageUg_get_internal_detail_cb, ad); - storageUG_update_apps_info(ad); - storageUG_update_cache_info(ad); + storageUG_update_apps_cache_info(ad); if (!isEmulBin()) { ret = vconf_get_int(storageUg_MMC_stat, &ad->mmc_status); @@ -858,7 +857,7 @@ static int storageUg_main_update(void *data) retv_if(data == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER); /*storageUg_main_update_media_data(ad); */ - storageUG_update_apps_info(ad); + storageUG_update_apps_cache_info(ad); if (ad->misces_list) { /*setting_view_update(ad->misces_view, ad); */ diff --git a/setting-storage/src/setting-storage-utils.c b/setting-storage/src/setting-storage-utils.c index 4e05222c..22197f96 100644 --- a/setting-storage/src/setting-storage-utils.c +++ b/setting-storage/src/setting-storage-utils.c @@ -330,27 +330,6 @@ static int storageUG_get_media_info(const char *cond, media_info_cb cb, return ret; } -static void storageUG_get_cache_files_size(pkgmgr_client *pc, - const pkg_size_info_t *size_info, void *user_data) -{ - SETTING_TRACE_BEGIN; - setting_retm_if(NULL == user_data, "user_data is NULL"); - setting_retm_if(NULL == size_info, "size_info is NULL"); - /*char * path = app_get_cache_path(); */ - /*SETTING_TRACE_DEBUG("cache path:%s",path); */ - SettingStorageUG *ad = user_data; - ad->sz_caches = (double) (size_info->cache_size - + size_info->ext_cache_size); - SETTING_TRACE_DEBUG("ad->sz_caches:%lf", ad->sz_caches); - storageug_genlist_text_update(ad->caches, ad->sz_caches); - - setting_retm_if(!ad->pie_it, "!ad->pie_it"); - elm_genlist_item_update(ad->pie_it); - - pkgmgr_client_free(ad->pc_total_size); - ad->pc_total_size = NULL; - SETTING_TRACE_END; -} int storageUg_get_internal_detail(SettingStorageUG *ad) { @@ -386,65 +365,58 @@ int storageUg_get_internal_detail(SettingStorageUG *ad) return SETTING_RETURN_SUCCESS; } -void storageUG_update_cache_info(SettingStorageUG *ad) +static void storageUG_get_app_cache_size_cb(pkgmgr_client *pc, + const pkg_size_info_t *size_info, void *user_data) { + SETTING_TRACE_BEGIN; + setting_retm_if(NULL == user_data, "user_data is NULL"); + setting_retm_if(NULL == size_info, "size_info is NULL"); - /*package_manager_get_total_package_size_info( - * storageUG_get_cache_files_size, ad); */ - int ret; - - ret_if(NULL == ad); - if (ad->pc_total_size) - pkgmgr_client_free(ad->pc_total_size); + /*char * path = app_get_cache_path(); */ + /*SETTING_TRACE_DEBUG("cache path:%s",path); */ + + SettingStorageUG *ad = user_data; - ad->pc_total_size = pkgmgr_client_new(PC_REQUEST); - if (NULL == ad->pc_total_size) { - SETTING_TRACE_ERROR("pkgmgr_client_new() Fail"); - return; - } + ad->sz_apps = (double) (size_info->app_size + size_info->ext_app_size); + ad->sz_caches = (double) (size_info->cache_size + size_info->ext_cache_size); + + SETTING_TRACE_DEBUG("size_info->app_size : %ld", ad->sz_apps); + SETTING_TRACE_DEBUG("ad->sz_caches:%lf", ad->sz_caches); + + storageug_genlist_text_update(ad->apps, ad->sz_apps); + storageug_genlist_text_update(ad->caches, ad->sz_caches); - ret = pkgmgr_client_get_total_package_size_info(ad->pc_total_size, - storageUG_get_cache_files_size, ad); + setting_retm_if(!ad->pie_it, "!ad->pie_it"); + elm_genlist_item_update(ad->pie_it); - warn_if(ret, "pkgmgr_client_get_total_package_size_info() Fail(%d)", - ret); + pkgmgr_client_free(ad->pc_total_size); + ad->pc_total_size = NULL; + SETTING_TRACE_END; } -static int storageUg_get_apps_info(uid_t target_uid, int req_id, - const char *pkg_type, const char *pkgid, const char *key, - const char *val, const void *pmsg, void *data) +void storageUG_update_apps_cache_info(SettingStorageUG *ad) { - SettingStorageUG *ad = data; - - retv_if(NULL == data, 0); - retv_if(NULL == val, 0); - - ad->sz_apps = atof(val); - - storageug_genlist_text_update(ad->apps, ad->sz_apps); - setting_retvm_if(!ad->pie_it, 0, "!ad->pie_it"); - elm_genlist_item_update(ad->pie_it); - return 0; -} + SETTING_TRACE_BEGIN; + -void storageUG_update_apps_info(SettingStorageUG *ad) -{ int ret; ret_if(NULL == ad); - if (ad->pc) - pkgmgr_client_free(ad->pc); + if (ad->pc_total_size) + pkgmgr_client_free(ad->pc_total_size); - ad->pc = pkgmgr_client_new(PC_REQUEST); - if (NULL == ad->pc) { + ad->pc_total_size = pkgmgr_client_new(PC_REQUEST); + if (NULL == ad->pc_total_size) { SETTING_TRACE_ERROR("pkgmgr_client_new() Fail"); return; } - ret = pkgmgr_client_get_size(ad->pc, "get", PM_GET_ALL_PKGS, - &storageUg_get_apps_info, ad); - warn_if(ret, "pkgmgr_client_get_size() Fail(%d)", ret); + ret = pkgmgr_client_get_total_package_size_info(ad->pc_total_size, + storageUG_get_app_cache_size_cb, ad); + + setting_retm_if(ret, "pkgmgr_client_get_total_package_size_info() Fail(%d)", ret); + }