Fix "size zero in storage" problem 87/73887/1 submit/tizen/20160610.025305
authorkiso.chang <kiso.chang@samsung.com>
Fri, 10 Jun 2016 02:42:44 +0000 (11:42 +0900)
committerkiso.chang <kiso.chang@samsung.com>
Fri, 10 Jun 2016 02:45:58 +0000 (11:45 +0900)
- 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 <kiso.chang@samsung.com>
setting-storage/include/setting-storage-utils.h
setting-storage/src/setting-storage-main.c
setting-storage/src/setting-storage-utils.c

index 6a47d8c6f435290487e5902d67294081ca7f75e6..43285657509019575f6aa9550a0d1ad2c34ea392 100644 (file)
@@ -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);
 
index 8bc894b1cf1fe9451fac1eb0a10b3f65273e76b0..7f313abf9b807c97ebd1621937a9d7faaeac38fe 100644 (file)
@@ -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); */
index 4e05222c3398c1cd5dc3792939fe9398c5bb40e3..22197f963cc45e96b5403aa96728ffd201c00a4f 100644 (file)
@@ -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);
+
 }