From b56b0291c1be7cbe7f4d9743fc64b2dae034d844 Mon Sep 17 00:00:00 2001 From: zhaoleyi Date: Thu, 9 Nov 2023 15:50:40 +0800 Subject: [PATCH] Signed-off-by: zhaoleyi Change-Id: I8bd465efc64907b18a3d6ac30b1691935a03984b Change-Id: I62e27641679e68b86e422b144e05394fb927070d --- frameworks/include/bundle_command.h | 1 + frameworks/include/quick_fix_command.h | 3 ++- frameworks/src/bundle_command.cpp | 8 ++++++-- frameworks/src/quick_fix_command.cpp | 11 +++++++++-- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/frameworks/include/bundle_command.h b/frameworks/include/bundle_command.h index 742a2fb..7208e5f 100644 --- a/frameworks/include/bundle_command.h +++ b/frameworks/include/bundle_command.h @@ -122,6 +122,7 @@ const std::string HELP_MSG_QUICK_FIX = "-h, --help list available commands\n" "-q, --query indicates query quickfix, used with -b or --bundle-name\n" "-b, --bundle-name query quickfix status and information by a specified bundle name\n" + "-d, --debug query quickfix debug mode\n" "-a, --apply indicates apply quickfix, used with -f or --file-path\n" "-f, --file-path apply a quickfix file by a specified path\n" "-f, --file-path ... apply some quickfix files of one bundle\n" diff --git a/frameworks/include/quick_fix_command.h b/frameworks/include/quick_fix_command.h index 7f3c0d6..3fcaf7b 100644 --- a/frameworks/include/quick_fix_command.h +++ b/frameworks/include/quick_fix_command.h @@ -24,7 +24,8 @@ namespace OHOS { namespace AppExecFwk { class QuickFixCommand { public: -static int32_t ApplyQuickFix(const std::vector &quickFixFiles, std::string &resultInfo); +static int32_t ApplyQuickFix(const std::vector &quickFixFiles, std::string &resultInfo, + bool isDebug = false); static int32_t GetApplyedQuickFixInfo(const std::string &bundleName, std::string &resultInfo); static std::string GetQuickFixInfoString(const AAFwk::ApplicationQuickFixInfo &quickFixInfo); }; diff --git a/frameworks/src/bundle_command.cpp b/frameworks/src/bundle_command.cpp index c2eb6ed..be82ded 100644 --- a/frameworks/src/bundle_command.cpp +++ b/frameworks/src/bundle_command.cpp @@ -21,7 +21,7 @@ #include #include #include - +#include #include "app_log_wrapper.h" #include "appexecfwk_errors.h" #include "bundle_command_common.h" @@ -1337,6 +1337,7 @@ ErrCode BundleManagerShellCommand::RunAsQuickFixCommand() index++; if (argKey == "-f" || argKey == "--file-path") { std::vector quickFixFiles; + bool isDebug = false; // collect value of multi file-path. for (; index < argc_ && index >= INDEX_OFFSET; ++index) { if (argList_[index - INDEX_OFFSET] == "-q" || argList_[index - INDEX_OFFSET] == "--query" || @@ -1344,11 +1345,14 @@ ErrCode BundleManagerShellCommand::RunAsQuickFixCommand() argList_[index - INDEX_OFFSET] == "-a" || argList_[index - INDEX_OFFSET] == "--apply" || argList_[index - INDEX_OFFSET] == "-f" || argList_[index - INDEX_OFFSET] == "--file-path") { break; + } else if (argList_[index - INDEX_OFFSET] == "-d" || argList_[index - INDEX_OFFSET] == "--debug") { + std::istringstream(argList_[++index - INDEX_OFFSET]) >> std::boolalpha >> isDebug; + break; } quickFixFiles.emplace_back(argList_[index - INDEX_OFFSET]); } - return QuickFixCommand::ApplyQuickFix(quickFixFiles, resultReceiver_); + return QuickFixCommand::ApplyQuickFix(quickFixFiles, resultReceiver_, isDebug); } } else if ((opt == "-q") || (opt == "--query")) { if (index >= argc_ - INDEX_OFFSET) { diff --git a/frameworks/src/quick_fix_command.cpp b/frameworks/src/quick_fix_command.cpp index 86fa3c4..b664cd4 100644 --- a/frameworks/src/quick_fix_command.cpp +++ b/frameworks/src/quick_fix_command.cpp @@ -57,7 +57,8 @@ private: std::string resultInfo_; }; -int32_t QuickFixCommand::ApplyQuickFix(const std::vector &quickFixFiles, std::string &resultInfo) +int32_t QuickFixCommand::ApplyQuickFix(const std::vector &quickFixFiles, std::string &resultInfo, + bool isDebug) { if (quickFixFiles.empty()) { resultInfo.append("quick fix file is empty.\n"); @@ -68,6 +69,12 @@ int32_t QuickFixCommand::ApplyQuickFix(const std::vector &quickFixF APP_LOGI("apply hqf file %{private}s.", file.c_str()); } + if (isDebug == true) { + APP_LOGI("isDebug is true"); + } else { + APP_LOGI("isDebug is false"); + } + sptr statusReceiver(new (std::nothrow) StatusReceiverImpl()); if (statusReceiver == nullptr) { resultInfo.append("Create status receiver failed.\n"); @@ -80,7 +87,7 @@ int32_t QuickFixCommand::ApplyQuickFix(const std::vector &quickFixF auto applyMonitor = std::make_shared(subscribeInfo, statusReceiver); EventFwk::CommonEventManager::SubscribeCommonEvent(applyMonitor); - auto result = DelayedSingleton::GetInstance()->ApplyQuickFix(quickFixFiles); + auto result = DelayedSingleton::GetInstance()->ApplyQuickFix(quickFixFiles, isDebug); if (result == ERR_OK) { APP_LOGD("Waiting apply finished."); result = statusReceiver->GetResultCode(); -- Gitee