From 47fca35ff0e2b0d775d9f7dd0229cbbb65bf6194 Mon Sep 17 00:00:00 2001 From: huimingzhu Date: Fri, 17 May 2024 16:11:31 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=8F=90=E4=BE=9Bcache=E7=A9=BA=E9=97=B4?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E6=B8=85=E7=90=86=E8=83=BD=E5=8A=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frameworks/include/bundle_test_tool.h | 5 ++ frameworks/src/bundle_test_tool.cpp | 106 +++++++++++++++++++++++++- 2 files changed, 109 insertions(+), 2 deletions(-) diff --git a/frameworks/include/bundle_test_tool.h b/frameworks/include/bundle_test_tool.h index bfe1094..77fc886 100644 --- a/frameworks/include/bundle_test_tool.h +++ b/frameworks/include/bundle_test_tool.h @@ -94,6 +94,7 @@ private: const std::string &type, std::string &msg); ErrCode RunAsImplicitQuerySkillUriInfo(); ErrCode RunAsQueryAbilityInfoByContinueType(); + ErrCode RunAsCleanBundleCacheFilesAutomaticCommand(); std::condition_variable cv_; std::mutex mutex_; @@ -139,6 +140,8 @@ private: ErrCode DumpSandboxBundleInfo(const std::string &bundleName, const int32_t appIndex, const int32_t userId, std::string &dumpResults); ErrCode StringToInt(std::string option, const std::string &commandName, int &temp, bool &result); + ErrCode StringToUnsignedLongLong(std::string optarg, const std::string &commandName, + uint64_t &temp, bool &result); ErrCode DeployQuickFix(const std::vector &quickFixPaths, std::shared_ptr &quickFixRes, bool isDebug); ErrCode SwitchQuickFix(const std::string &bundleName, int32_t enable, @@ -162,6 +165,8 @@ private: ErrCode CheckGetGroupIdCorrectOption(int32_t option, std::string &dataGroupId); bool GetGroupDir(const std::string &dataGroupId, std::string& msg); ErrCode CheckGetBundleNameOption(int32_t option, std::string &bundleName); + ErrCode CheckCleanBundleCacheFilesAutomaticOption(int option, const std::string &commandName, + uint64_t &cacheSize); }; } // namespace AppExecFwk } // namespace OHOS diff --git a/frameworks/src/bundle_test_tool.cpp b/frameworks/src/bundle_test_tool.cpp index 665afc2..0a8d36e 100644 --- a/frameworks/src/bundle_test_tool.cpp +++ b/frameworks/src/bundle_test_tool.cpp @@ -166,7 +166,8 @@ static const std::string HELP_MSG = " getJsonProfile obtain the json string of the specified module\n" " getOdid obtain the odid of the application\n" " implicitQuerySkillUriInfo obtain the skill uri info of the implicit query ability\n" - " queryAbilityInfoByContinueType get ability info by continue type\n"; + " queryAbilityInfoByContinueType get ability info by continue type\n" + " cleanBundleCacheFilesAutomatic clear cache data of a specified size\n"; const std::string HELP_MSG_GET_REMOVABLE = "usage: bundle_test_tool getrm \n" @@ -328,6 +329,13 @@ const std::string HELP_MSG_GET_APP_RUNNING_RESULT_RULE = " -n, --bundle-name specify bundle name of the application\n" " -u, --user-id specify a user id\n"; +const std::string HELP_MSG_AUTO_CLEAN_CACHE_RULE = + "usage: bundle_test_tool \n" + "eg:bundle_test_tool cleanBundleCacheFilesAutomatic -s \n" + "options list:\n" + " -h, --help list available commands\n" + " -s, --cache-size specify the cache size that needs to be cleaned\n"; + const std::string HELP_MSG_NO_ADD_INSTALL_RULE_OPTION = "error: you must specify a app id with '-a' or '--app-id' \n" "and a control type with '-t' or '--control-rule-type' \n" @@ -360,6 +368,9 @@ const std::string HELP_MSG_NO_GET_APP_RUNNING_RULE_OPTION = "error: you must specify a app running type with '-n' or '--bundle-name' \n" "and a userid with '-u' or '--user-id' \n"; +const std::string HELP_MSG_NO_AUTO_CLEAN_CACHE_OPTION = + "error: you must specify a cache size with '-s' or '--cache-size' \n"; + const std::string HELP_MSG_DEPLOY_QUICK_FIX = "usage: bundle_test_tool deploy quick fix \n" "eg:bundle_test_tool deployQuickFix -p \n" @@ -652,6 +663,13 @@ const struct option LONG_OPTIONS_RULE[] = { {nullptr, 0, nullptr, 0}, }; +const std::string SHORT_OPTIONS_AUTO_CLEAN_CACHE = "h:s"; +const struct option LONG_OPTIONS_AUTO_CLEAN_CACHE[] = { + {"help", no_argument, nullptr, 'h'}, + {"cache-size", required_argument, nullptr, 's'}, + {nullptr, 0, nullptr, 0}, +}; + const std::string SHORT_OPTIONS_QUICK_FIX = "hp:n:e:d:"; const struct option LONG_OPTIONS_QUICK_FIX[] = { {"help", no_argument, nullptr, 'h'}, @@ -848,7 +866,9 @@ ErrCode BundleTestTool::CreateCommandMap() {"implicitQuerySkillUriInfo", std::bind(&BundleTestTool::RunAsImplicitQuerySkillUriInfo, this)}, {"queryAbilityInfoByContinueType", - std::bind(&BundleTestTool::RunAsQueryAbilityInfoByContinueType, this)} + std::bind(&BundleTestTool::RunAsQueryAbilityInfoByContinueType, this)}, + {"cleanBundleCacheFilesAutomatic", + std::bind(&BundleTestTool::RunAsCleanBundleCacheFilesAutomaticCommand, this)} }; return OHOS::ERR_OK; @@ -1548,6 +1568,20 @@ ErrCode BundleTestTool::StringToInt( return OHOS::ERR_OK; } +ErrCode BundleTestTool::StringToUnsignedLongLong( + std::string optarg, const std::string &commandName, uint64_t &temp, bool &result) +{ + try { + temp = std::stoull(optarg); + APP_LOGD("bundle_test_tool %{public}s %{public}llu %{public}s", + commandName.c_str(), temp, argv_[optind - 1]); + } catch (const std::exception& e) { + std::cerr << e.what() << std::endl; + result = false; + } + return OHOS::ERR_OK; +} + bool BundleTestTool::CheckGetStringCorrectOption( int option, const std::string &commandName, int &temp, std::string &name) { @@ -2804,6 +2838,74 @@ ErrCode BundleTestTool::RunAsGetAppRunningControlRuleResultCommand() return result; } +ErrCode BundleTestTool::CheckCleanBundleCacheFilesAutomaticOption( + int option, const std::string &commandName, uint64_t &cacheSize) +{ + bool ret = true; + switch (option) { + case 'h': { + APP_LOGD("bundle_test_tool %{public}s %{public}s", commandName.c_str(), argv_[optind - 1]); + return OHOS::ERR_INVALID_VALUE; + } + case 's': { + APP_LOGD("bundle_test_tool %{public}s %{public}s", commandName.c_str(), argv_[optind - 1]); + StringToUnsignedLongLong(optarg, commandName, cacheSize, ret); + if (ret == false) { + APP_LOGE("StringToUnsignedLongLong failed."); + return OHOS::ERR_INVALID_VALUE; + } + break; + } + default: { + std::string unknownOption = ""; + std::string unknownOptionMsg = GetUnknownOptionMsg(unknownOption); + APP_LOGD("bundle_test_tool %{public}s with an unknown option.", commandName.c_str()); + resultReceiver_.append(unknownOptionMsg); + return OHOS::ERR_INVALID_VALUE; + } + } + return OHOS::ERR_OK; +} + +ErrCode BundleTestTool::RunAsCleanBundleCacheFilesAutomaticCommand() +{ + ErrCode result = OHOS::ERR_OK; + int counter = 0; + std::string commandName = "cleanBundleCacheFilesAutomatic"; + uint64_t cacheSize; + APP_LOGD("RunAsCleanBundleCacheFilesAutomaticCommand is start"); + while (true) { + counter++; + int option = getopt_long(argc_, argv_, SHORT_OPTIONS_AUTO_CLEAN_CACHE.c_str(), + LONG_OPTIONS_AUTO_CLEAN_CACHE, nullptr); + APP_LOGD("option: %{public}d, optopt: %{public}d, optind: %{public}d", option, optopt, optind); + if (optind < 0 || optind > argc_) { + return OHOS::ERR_INVALID_VALUE; + } + if (option == -1) { + if ((counter == 1) && (strcmp(argv_[optind], cmd_.c_str()) == 0)) { + APP_LOGD("bundle_test_tool getRule with no option."); + resultReceiver_.append(HELP_MSG_NO_AUTO_CLEAN_CACHE_OPTION); + return OHOS::ERR_INVALID_VALUE; + } + break; + } + result = CheckCleanBundleCacheFilesAutomaticOption(option, commandName, cacheSize); + if (result != OHOS::ERR_OK) { + resultReceiver_.append(HELP_MSG_AUTO_CLEAN_CACHE_RULE); + return OHOS::ERR_INVALID_VALUE; + } + } + + APP_LOGI("CleanBundleCacheFilesAutomatic cache-size: %{public}llu", cacheSize); + int32_t res = bundleMgrProxy_->CleanBundleCacheFilesAutomatic(cacheSize); + if (res != OHOS::ERR_OK) { + APP_LOGI("CleanBundleCacheFilesAutomatic result: %{public}d", res); + return res; + } + return result; +} + ErrCode BundleTestTool::RunAsDeployQuickFix() { int32_t result = OHOS::ERR_OK; -- Gitee From d7236bb1218a1b9b226ed9937a42364e74da4823 Mon Sep 17 00:00:00 2001 From: huimingzhu Date: Mon, 20 May 2024 15:43:53 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=8F=90=E4=BE=9Bcache=E7=A9=BA=E9=97=B4?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E6=B8=85=E7=90=86=E8=83=BD=E5=8A=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frameworks/src/bundle_test_tool.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frameworks/src/bundle_test_tool.cpp b/frameworks/src/bundle_test_tool.cpp index 0a8d36e..473c109 100644 --- a/frameworks/src/bundle_test_tool.cpp +++ b/frameworks/src/bundle_test_tool.cpp @@ -663,7 +663,7 @@ const struct option LONG_OPTIONS_RULE[] = { {nullptr, 0, nullptr, 0}, }; -const std::string SHORT_OPTIONS_AUTO_CLEAN_CACHE = "h:s"; +const std::string SHORT_OPTIONS_AUTO_CLEAN_CACHE = "hs:"; const struct option LONG_OPTIONS_AUTO_CLEAN_CACHE[] = { {"help", no_argument, nullptr, 'h'}, {"cache-size", required_argument, nullptr, 's'}, -- Gitee From 8d614fdd40fa2564caa3788937f8c4b8257ac8e7 Mon Sep 17 00:00:00 2001 From: huimingzhu Date: Tue, 21 May 2024 11:17:08 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=8F=90=E4=BE=9Bcache=E7=A9=BA=E9=97=B4?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E6=B8=85=E7=90=86=E8=83=BD=E5=8A=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bundletool.gni | 1 + frameworks/BUILD.gn | 4 ++ frameworks/include/bundle_test_tool.h | 6 ++ frameworks/src/bundle_test_tool.cpp | 99 ++++++++++++++++++++++----- 4 files changed, 93 insertions(+), 17 deletions(-) diff --git a/bundletool.gni b/bundletool.gni index 23f332b..af08fea 100644 --- a/bundletool.gni +++ b/bundletool.gni @@ -26,6 +26,7 @@ declare_args() { overlay_install_bm = true quick_fix_bm = true distributed_bundle_framework_bm = true + bundle_framework_auto_clean_cache_tool = true if (defined(global_parts_info) && !defined(global_parts_info.account_os_account)) { diff --git a/frameworks/BUILD.gn b/frameworks/BUILD.gn index 283c3f1..cb6aad6 100644 --- a/frameworks/BUILD.gn +++ b/frameworks/BUILD.gn @@ -139,6 +139,10 @@ ohos_source_set("tools_test_bm_source_set") { sources += [ "src/quick_fix_status_callback_host_impl.cpp" ] } + if (bundle_framework_auto_clean_cache_tool) { + defines += [ "BUNDLE_FRAMEWORK_AUTO_CLEAN_CACHE" ] + } + if (account_enable_bm) { external_deps += [ "os_account:os_account_innerkits" ] defines += [ "ACCOUNT_ENABLE" ] diff --git a/frameworks/include/bundle_test_tool.h b/frameworks/include/bundle_test_tool.h index 77fc886..770ae86 100644 --- a/frameworks/include/bundle_test_tool.h +++ b/frameworks/include/bundle_test_tool.h @@ -94,7 +94,9 @@ private: const std::string &type, std::string &msg); ErrCode RunAsImplicitQuerySkillUriInfo(); ErrCode RunAsQueryAbilityInfoByContinueType(); +#ifdef BUNDLE_FRAMEWORK_AUTO_CLEAN_CACHE ErrCode RunAsCleanBundleCacheFilesAutomaticCommand(); +#endif std::condition_variable cv_; std::mutex mutex_; @@ -140,8 +142,10 @@ private: ErrCode DumpSandboxBundleInfo(const std::string &bundleName, const int32_t appIndex, const int32_t userId, std::string &dumpResults); ErrCode StringToInt(std::string option, const std::string &commandName, int &temp, bool &result); +#ifdef BUNDLE_FRAMEWORK_AUTO_CLEAN_CACHE ErrCode StringToUnsignedLongLong(std::string optarg, const std::string &commandName, uint64_t &temp, bool &result); +#endif ErrCode DeployQuickFix(const std::vector &quickFixPaths, std::shared_ptr &quickFixRes, bool isDebug); ErrCode SwitchQuickFix(const std::string &bundleName, int32_t enable, @@ -165,8 +169,10 @@ private: ErrCode CheckGetGroupIdCorrectOption(int32_t option, std::string &dataGroupId); bool GetGroupDir(const std::string &dataGroupId, std::string& msg); ErrCode CheckGetBundleNameOption(int32_t option, std::string &bundleName); +#ifdef BUNDLE_FRAMEWORK_AUTO_CLEAN_CACHE ErrCode CheckCleanBundleCacheFilesAutomaticOption(int option, const std::string &commandName, uint64_t &cacheSize); +#endif }; } // namespace AppExecFwk } // namespace OHOS diff --git a/frameworks/src/bundle_test_tool.cpp b/frameworks/src/bundle_test_tool.cpp index 473c109..71ec881 100644 --- a/frameworks/src/bundle_test_tool.cpp +++ b/frameworks/src/bundle_test_tool.cpp @@ -121,6 +121,7 @@ const std::string MSG_ERR_BUNDLEMANAGER_SET_DEBUG_MODE_SEND_REQUEST_ERROR = "err const std::string MSG_ERR_BUNDLEMANAGER_SET_DEBUG_MODE_UID_CHECK_FAILED = "error: uid check failed.\n"; static const std::string TOOL_NAME = "bundle_test_tool"; +#ifdef BUNDLE_FRAMEWORK_AUTO_CLEAN_CACHE static const std::string HELP_MSG = "usage: bundle_test_tool \n" "These are common bundle_test_tool commands list:\n" @@ -168,6 +169,54 @@ static const std::string HELP_MSG = " implicitQuerySkillUriInfo obtain the skill uri info of the implicit query ability\n" " queryAbilityInfoByContinueType get ability info by continue type\n" " cleanBundleCacheFilesAutomatic clear cache data of a specified size\n"; +#else +static const std::string HELP_MSG = + "usage: bundle_test_tool \n" + "These are common bundle_test_tool commands list:\n" + " help list available commands\n" + " setrm set module isRemovable by given bundle name and module name\n" + " getrm obtain the value of isRemovable by given bundle name and module name\n" + " installSandbox indicates install sandbox\n" + " uninstallSandbox indicates uninstall sandbox\n" + " dumpSandbox indicates dump sandbox info\n" + " getStr obtain the value of label by given bundle name, module name and label id\n" + " getIcon obtain the value of icon by given bundle name, module name, " + "density and icon id\n" + " addAppInstallRule obtain the value of install controlRule by given some app id " + "control rule type, user id and euid\n" + " getAppInstallRule obtain the value of install controlRule by given some app id " + "rule type, user id and euid\n" + " deleteAppInstallRule obtain the value of install controlRule by given some app id " + "user id and euid\n" + " cleanAppInstallRule obtain the value of install controlRule by given rule type " + "user id and euid\n" + " addAppRunningRule obtain the value of app running control rule " + "by given controlRule user id and euidn\n" + " deleteAppRunningRule obtain the value of app running control rule " + "by given controlRule user id and euid\n" + " cleanAppRunningRule obtain the value of app running control " + "rule by given user id and euid\n" + " getAppRunningControlRule obtain the value of app running control rule " + "by given user id and euid and some app id\n" + " getAppRunningControlRuleResult obtain the value of app running control rule " + "by given bundleName user id, euid and controlRuleResult\n" + " deployQuickFix deploy a quick fix patch of an already installed bundle\n" + " switchQuickFix switch a quick fix patch of an already installed bundle\n" + " deleteQuickFix delete a quick fix patch of an already installed bundle\n" + " setDebugMode enable signature debug mode\n" + " getBundleStats get bundle stats\n" + " getAppProvisionInfo get appProvisionInfo\n" + " getDistributedBundleName get distributedBundleName\n" + " eventCB register then unregister bundle event callback\n" + " resetAOTCompileStatus reset AOTCompileStatus\n" + " sendCommonEvent send common event\n" + " queryDataGroupInfos obtain the data group infos of the application\n" + " getGroupDir obtain the data group dir path by data group id\n" + " getJsonProfile obtain the json string of the specified module\n" + " getOdid obtain the odid of the application\n" + " implicitQuerySkillUriInfo obtain the skill uri info of the implicit query ability\n" + " queryAbilityInfoByContinueType get ability info by continue type\n"; +#endif const std::string HELP_MSG_GET_REMOVABLE = "usage: bundle_test_tool getrm \n" @@ -329,12 +378,14 @@ const std::string HELP_MSG_GET_APP_RUNNING_RESULT_RULE = " -n, --bundle-name specify bundle name of the application\n" " -u, --user-id specify a user id\n"; +#ifdef BUNDLE_FRAMEWORK_AUTO_CLEAN_CACHE const std::string HELP_MSG_AUTO_CLEAN_CACHE_RULE = "usage: bundle_test_tool \n" "eg:bundle_test_tool cleanBundleCacheFilesAutomatic -s \n" "options list:\n" " -h, --help list available commands\n" " -s, --cache-size specify the cache size that needs to be cleaned\n"; +#endif const std::string HELP_MSG_NO_ADD_INSTALL_RULE_OPTION = "error: you must specify a app id with '-a' or '--app-id' \n" @@ -368,8 +419,10 @@ const std::string HELP_MSG_NO_GET_APP_RUNNING_RULE_OPTION = "error: you must specify a app running type with '-n' or '--bundle-name' \n" "and a userid with '-u' or '--user-id' \n"; +#ifdef BUNDLE_FRAMEWORK_AUTO_CLEAN_CACHE const std::string HELP_MSG_NO_AUTO_CLEAN_CACHE_OPTION = "error: you must specify a cache size with '-s' or '--cache-size' \n"; +#endif const std::string HELP_MSG_DEPLOY_QUICK_FIX = "usage: bundle_test_tool deploy quick fix \n" @@ -663,12 +716,14 @@ const struct option LONG_OPTIONS_RULE[] = { {nullptr, 0, nullptr, 0}, }; +#ifdef BUNDLE_FRAMEWORK_AUTO_CLEAN_CACHE const std::string SHORT_OPTIONS_AUTO_CLEAN_CACHE = "hs:"; const struct option LONG_OPTIONS_AUTO_CLEAN_CACHE[] = { {"help", no_argument, nullptr, 'h'}, {"cache-size", required_argument, nullptr, 's'}, {nullptr, 0, nullptr, 0}, }; +#endif const std::string SHORT_OPTIONS_QUICK_FIX = "hp:n:e:d:"; const struct option LONG_OPTIONS_QUICK_FIX[] = { @@ -867,8 +922,9 @@ ErrCode BundleTestTool::CreateCommandMap() std::bind(&BundleTestTool::RunAsImplicitQuerySkillUriInfo, this)}, {"queryAbilityInfoByContinueType", std::bind(&BundleTestTool::RunAsQueryAbilityInfoByContinueType, this)}, - {"cleanBundleCacheFilesAutomatic", - std::bind(&BundleTestTool::RunAsCleanBundleCacheFilesAutomaticCommand, this)} +#ifdef BUNDLE_FRAMEWORK_AUTO_CLEAN_CACHE + {"cleanBundleCacheFilesAutomatic", std::bind(&BundleTestTool::RunAsCleanBundleCacheFilesAutomaticCommand, this)} +#endif }; return OHOS::ERR_OK; @@ -1568,12 +1624,18 @@ ErrCode BundleTestTool::StringToInt( return OHOS::ERR_OK; } +#ifdef BUNDLE_FRAMEWORK_AUTO_CLEAN_CACHE ErrCode BundleTestTool::StringToUnsignedLongLong( std::string optarg, const std::string &commandName, uint64_t &temp, bool &result) { try { + APP_LOGI("StringToUnsignedLongLong start, optarg : %{public}s", optarg.c_str()); + if ((optarg == "") || (optarg[0] == '0') || (!isdigit(optarg[0]))) { + resultReceiver_.append("error: parameter error, cache size must be greater than 0\n"); + return OHOS::ERR_INVALID_VALUE; + } temp = std::stoull(optarg); - APP_LOGD("bundle_test_tool %{public}s %{public}llu %{public}s", + APP_LOGI("bundle_test_tool %{public}s %{public}llu %{public}s", commandName.c_str(), temp, argv_[optind - 1]); } catch (const std::exception& e) { std::cerr << e.what() << std::endl; @@ -1581,6 +1643,7 @@ ErrCode BundleTestTool::StringToUnsignedLongLong( } return OHOS::ERR_OK; } +#endif bool BundleTestTool::CheckGetStringCorrectOption( int option, const std::string &commandName, int &temp, std::string &name) @@ -2838,28 +2901,25 @@ ErrCode BundleTestTool::RunAsGetAppRunningControlRuleResultCommand() return result; } +#ifdef BUNDLE_FRAMEWORK_AUTO_CLEAN_CACHE ErrCode BundleTestTool::CheckCleanBundleCacheFilesAutomaticOption( int option, const std::string &commandName, uint64_t &cacheSize) { bool ret = true; switch (option) { case 'h': { - APP_LOGD("bundle_test_tool %{public}s %{public}s", commandName.c_str(), argv_[optind - 1]); + APP_LOGI("bundle_test_tool %{public}s %{public}s", commandName.c_str(), argv_[optind - 1]); return OHOS::ERR_INVALID_VALUE; } case 's': { - APP_LOGD("bundle_test_tool %{public}s %{public}s", commandName.c_str(), argv_[optind - 1]); + APP_LOGI("bundle_test_tool %{public}s %{public}s", commandName.c_str(), argv_[optind - 1]); StringToUnsignedLongLong(optarg, commandName, cacheSize, ret); - if (ret == false) { - APP_LOGE("StringToUnsignedLongLong failed."); - return OHOS::ERR_INVALID_VALUE; - } break; } default: { std::string unknownOption = ""; std::string unknownOptionMsg = GetUnknownOptionMsg(unknownOption); - APP_LOGD("bundle_test_tool %{public}s with an unknown option.", commandName.c_str()); + APP_LOGE("bundle_test_tool %{public}s with an unknown option.", commandName.c_str()); resultReceiver_.append(unknownOptionMsg); return OHOS::ERR_INVALID_VALUE; } @@ -2873,18 +2933,18 @@ ErrCode BundleTestTool::RunAsCleanBundleCacheFilesAutomaticCommand() int counter = 0; std::string commandName = "cleanBundleCacheFilesAutomatic"; uint64_t cacheSize; - APP_LOGD("RunAsCleanBundleCacheFilesAutomaticCommand is start"); + APP_LOGE("RunAsCleanBundleCacheFilesAutomaticCommand is start"); while (true) { counter++; int option = getopt_long(argc_, argv_, SHORT_OPTIONS_AUTO_CLEAN_CACHE.c_str(), LONG_OPTIONS_AUTO_CLEAN_CACHE, nullptr); - APP_LOGD("option: %{public}d, optopt: %{public}d, optind: %{public}d", option, optopt, optind); + APP_LOGE("option: %{public}d, optopt: %{public}d, optind: %{public}d", option, optopt, optind); if (optind < 0 || optind > argc_) { return OHOS::ERR_INVALID_VALUE; } if (option == -1) { if ((counter == 1) && (strcmp(argv_[optind], cmd_.c_str()) == 0)) { - APP_LOGD("bundle_test_tool getRule with no option."); + APP_LOGE("bundle_test_tool getRule with no option."); resultReceiver_.append(HELP_MSG_NO_AUTO_CLEAN_CACHE_OPTION); return OHOS::ERR_INVALID_VALUE; } @@ -2898,13 +2958,18 @@ ErrCode BundleTestTool::RunAsCleanBundleCacheFilesAutomaticCommand() } APP_LOGI("CleanBundleCacheFilesAutomatic cache-size: %{public}llu", cacheSize); - int32_t res = bundleMgrProxy_->CleanBundleCacheFilesAutomatic(cacheSize); - if (res != OHOS::ERR_OK) { - APP_LOGI("CleanBundleCacheFilesAutomatic result: %{public}d", res); + ErrCode res = bundleMgrProxy_->CleanBundleCacheFilesAutomatic(cacheSize); + if (res == ERR_OK) { + resultReceiver_.append("clean fixed size cache successfully\n"); + } else { + resultReceiver_.append("clean fixed size cache failed, errCode is "+ std::to_string(res) + "\n"); + APP_LOGE("CleanBundleCacheFilesAutomatic failed, result: %{public}d", res); return res; } - return result; + + return res; } +#endif ErrCode BundleTestTool::RunAsDeployQuickFix() { -- Gitee