/* Supported options */
/* Note: 'G' is reserved */
-const char *short_options = "iurwmcgCkaADL:lsd:p:t:n:T:S:e:M:X:Y:Z:qhG";
+const char *short_options = "iurwmcgxCkaADL:lsd:p:t:n:T:S:e:M:X:Y:Z:qhG";
const struct option long_options[] = {
{"install", 0, NULL, 'i'},
{"uninstall", 0, NULL, 'u'},
{"quiet", 0, NULL, 'q'},
{"help", 0, NULL, 'h'},
{"debug-mode", 0, NULL, 'G'},
+ {"getsizeinfo", 0, NULL, 'x'},
{0, 0, 0, 0} /* sentinel */
};
SHOW_REQ,
HELP_REQ,
CREATE_DELTA,
+ GET_PKG_SIZE_INFO_REQ
};
typedef enum pm_tool_request_e req_type;
return 0;
}
+static void __pkg_size_info_recv_cb(pkgmgr_client *pc, const char *pkgid, const pkg_size_info_t *size_info, void *user_data)
+{
+ printf("Called sizeinfo callback for pkgid(%s)\n", pkgid);
+ printf("Internal > data size: %lld, cache size: %lld, app size: %lld\n",
+ size_info->data_size, size_info->cache_size, size_info->app_size);
+ printf("External > data size: %lld, cache size: %lld, app size: %lld\n",
+ size_info->ext_data_size, size_info->ext_cache_size, size_info->ext_app_size);
+
+ g_main_loop_quit(main_loop);
+}
+
+static void __total_pkg_size_info_recv_cb(pkgmgr_client *pc, const pkg_size_info_t *size_info, void *user_data)
+{
+ printf("Called sizeinfo callback for total packages\n");
+ printf("Internal > data size: %lld, cache size: %lld, app size: %lld\n",
+ size_info->data_size, size_info->cache_size, size_info->app_size);
+ printf("External > data size: %lld, cache size: %lld, app size: %lld\n",
+ size_info->ext_data_size, size_info->ext_cache_size, size_info->ext_app_size);
+
+ g_main_loop_quit(main_loop);
+}
+
static int __process_request(uid_t uid)
{
int ret = -1;
ret = data.result;
break;
+ case GET_PKG_SIZE_INFO_REQ:
+ if (data.pkgid[0] == '\0') {
+ printf("Please provide the arguments.\n");
+ printf("use -h option to see usage\n");
+ ret = -1;
+ break;
+ }
+
+ main_loop = g_main_loop_new(NULL, FALSE);
+ pc = pkgmgr_client_new(PC_REQUEST);
+ if (pc == NULL) {
+ printf("PkgMgr Client Creation Failed\n");
+ data.result = PKGCMD_ERR_FATAL_ERROR;
+ break;
+ }
+
+ if (strcmp(data.pkgid, PKG_SIZE_INFO_TOTAL) == 0) {
+ ret = pkgmgr_client_get_total_package_size_info(pc, __total_pkg_size_info_recv_cb, NULL);
+
+ } else {
+ ret = pkgmgr_client_get_package_size_info(pc, data.pkgid, __pkg_size_info_recv_cb, NULL);
+ }
+ if (ret < 0) {
+ data.result = PKGCMD_ERR_FATAL_ERROR;
+ break;
+ }
+
+ printf("pkg[%s] ret: %d\n", data.pkgid, ret);
+ ret = data.result;
+
+ g_main_loop_run(main_loop);
+ break;
+
case HELP_REQ:
__print_usage();
ret = 0;
data.request = GETSIZE_REQ;
break;
+ case 'x': /* get pkg size info */
+ data.request = GET_PKG_SIZE_INFO_REQ;
+ break;
+
case 'm': /* move */
data.request = MOVE_REQ;
break;
#define OWNER_ROOT 0
#define GLOBAL_USER tzplatform_getuid(TZ_SYS_GLOBALAPP_USER)
-#if 0 /* installed at external storage is not supported yet */
+#if 0 /* TODO: installed at external storage is not supported yet */
#define APP_BASE_EXTERNAL_PATH ""
#endif
tzplatform_mkpath(__is_global(uid)
? TZ_SYS_RW_APP : TZ_USER_APP, pkgid));
tzplatform_reset_user();
-#if 0 /* installed at external storage is not supported yet */
+#if 0 /* TODO: installed at external storage is not supported yet */
} else if (type == STORAGE_TYPE_EXTERNAL) {
snprintf(app_root_dir, MAX_PATH_LENGTH, "%s%s/",
APP_BASE_EXTERNAL_PATH, pkgid);
ret = __calculate_pkg_size_info(STORAGE_TYPE_INTERNAL, pkgid,
&pkg_size_info->data_size, &pkg_size_info->cache_size,
&pkg_size_info->app_size);
- if (ret < 0)
- LOGD("Calculating internal package size info failed: %d", ret);
- LOGD("size_info: %lld %lld %lld", pkg_size_info->data_size,
+ if (ret < 0) {
+ LOGE("Calculating internal package size info failed: %d", ret);
+ } else {
+ LOGD("size_info: %lld %lld %lld", pkg_size_info->data_size,
pkg_size_info->cache_size, pkg_size_info->app_size);
+ }
-#if 0
+#if 0 /* TODO */
ret = __calculate_pkg_size_info(STORAGE_TYPE_EXTERNAL, pkgid,
&pkg_size_info->ext_data_size,
&pkg_size_info->ext_cache_size,
return -1;
}
- __get_pkg_size_info(pkgid, &temp_pkg_size_info);
+ ret = __get_pkg_size_info(pkgid, &temp_pkg_size_info);
+ if (ret < 0) {
+ LOGE("failed to get size");
+ return -1;
+ }
pkg_size_info->app_size += temp_pkg_size_info.app_size;
pkg_size_info->data_size += temp_pkg_size_info.data_size;
snprintf(info_file, sizeof(info_file), "%s/%s", PKG_SIZE_INFO_PATH,
req_key);
- LOGE("File path = %s", info_file);
+ LOGD("File path = (%s), size = (%lld)", info_file, size);
file = fopen(info_file, "w");
if (file == NULL) {
return -1;
}
- __get_pkg_size_info(pkgid, &temp_pkg_size_info);
+ ret = __get_pkg_size_info(pkgid, &temp_pkg_size_info);
+ if (ret < 0) {
+ LOGE("failed to get size");
+ return -1;
+ }
total_size = temp_pkg_size_info.app_size +
temp_pkg_size_info.data_size + temp_pkg_size_info.cache_size;
case PM_GET_PKG_SIZE_INFO:
/* send result to signal */
ret = __get_pkg_size_info(pkgid, &info);
- if (ret == 0)
+ if (ret == 0) {
ret = __send_result_to_signal(pi, req_key,
pkgid, &info);
- ret = __make_size_info_file(req_key, 0);
+ size = info.app_size + info.data_size + info.cache_size;
+ }
+ ret = __make_size_info_file(req_key, size);
break;
case PM_GET_TOTAL_PKG_SIZE_INFO:
/* send result to signal */
ret = pkgmgrinfo_pkginfo_get_usr_list(
__get_total_pkg_size_info_cb, &info, getuid());
- if (ret == 0)
+ if (ret == 0) {
ret = __send_result_to_signal(pi, req_key,
PKG_SIZE_INFO_TOTAL, &info);
- ret = __make_size_info_file(req_key, 0);
+ size = info.app_size + info.data_size + info.cache_size;
+ }
+ ret = __make_size_info_file(req_key, size);
break;
default:
ret = -1;