From 4671ca1e1a720fce171d34a56232d1743d6caf25 Mon Sep 17 00:00:00 2001 From: lanhaoyu Date: Fri, 18 Apr 2025 15:07:15 +0800 Subject: [PATCH 1/2] =?UTF-8?q?external=5Fdeps=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lanhaoyu --- bundle.json | 1 + frameworks/BUILD.gn | 1 + 2 files changed, 2 insertions(+) diff --git a/bundle.json b/bundle.json index bfdeaab..9ffd410 100644 --- a/bundle.json +++ b/bundle.json @@ -24,6 +24,7 @@ "bundle_framework", "common_event_service", "c_utils", + "cJSON", "distributed_bundle_framework", "hilog", "init", diff --git a/frameworks/BUILD.gn b/frameworks/BUILD.gn index f86974a..93eb295 100644 --- a/frameworks/BUILD.gn +++ b/frameworks/BUILD.gn @@ -148,6 +148,7 @@ ohos_source_set("tools_test_bm_source_set") { "bundle_framework:appexecfwk_core", "bundle_framework:bundle_tool_libs", "c_utils:utils", + "cJSON:cjson_static", "common_event_service:cesfwk_innerkits", "hilog:libhilog", "init:libbegetutil", -- Gitee From 1da5f8784f0577cbb5d46c69731851e50724370e Mon Sep 17 00:00:00 2001 From: lanhaoyu Date: Wed, 23 Apr 2025 11:10:03 +0800 Subject: [PATCH 2/2] debug and metadata Signed-off-by: lanhaoyu --- frameworks/include/bundle_test_tool.h | 2 + frameworks/src/bundle_test_tool.cpp | 56 +++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/frameworks/include/bundle_test_tool.h b/frameworks/include/bundle_test_tool.h index 25f84f1..d77a26b 100644 --- a/frameworks/include/bundle_test_tool.h +++ b/frameworks/include/bundle_test_tool.h @@ -74,6 +74,8 @@ private: ErrCode RunAsSwitchQuickFix(); ErrCode RunAsDeleteQuickFix(); ErrCode RunAsSetDebugMode(); + ErrCode RunAsIsDebugMode(); + ErrCode RunAsGetModuleMetadata(); ErrCode RunAsGetBundleStats(); ErrCode RunAsGetAppProvisionInfo(); ErrCode RunAsGetContinueBundleName(); diff --git a/frameworks/src/bundle_test_tool.cpp b/frameworks/src/bundle_test_tool.cpp index 70b8cc1..eba282e 100644 --- a/frameworks/src/bundle_test_tool.cpp +++ b/frameworks/src/bundle_test_tool.cpp @@ -172,6 +172,8 @@ static const std::string HELP_MSG = " 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" + " isDebugMode get is debug mode\n" + " getModuleMetadata get module metadata\n" " getBundleStats get bundle stats\n" " getAppProvisionInfo get appProvisionInfo\n" " getDistributedBundleName get distributedBundleName\n" @@ -435,6 +437,18 @@ const std::string HELP_MSG_SET_DEBUG_MODE = " -e, --enable enable signature debug mode, 1 represents enable debug mode and 0\n" " represents disable debug mode\n"; +const std::string HELP_MSG_IS_DEBUG_MODE = + "usage: bundle_test_tool isDebugMode \n" + "eg:bundle_test_tool isDebugMode\n" + "options list:\n" + " -h, --help list available commands\n"; + +const std::string HELP_MSG_GET_MODULE_METADATA = + "usage: bundle_test_tool getModuleMetadata \n" + "eg:bundle_test_tool getModuleMetadata\n" + "options list:\n" + " -h, --help list available commands\n"; + const std::string HELP_MSG_GET_BUNDLE_STATS = "usage: bundle_test_tool getBundleStats \n" "eg:bundle_test_tool getBundleStats -n \n" @@ -711,6 +725,12 @@ const std::string STRING_DELETE_QUICK_FIX_NG = "delete quick fix failed\n"; const std::string STRING_SET_DEBUG_MODE_OK = "set debug mode successfully\n"; const std::string STRING_SET_DEBUG_MODE_NG = "set debug mode failed\n"; +const std::string STRING_IS_DEBUG_MODE_OK = "get debug mode successfully\n"; +const std::string STRING_IS_DEBUG_MODE_NG = "get debug mode failed\n"; + +const std::string STRING_GET_MODULE_METADATA_OK = "get module metadata successfully\n"; +const std::string STRING_GET_MODULE_METADATA_NG = "get module metadata failed\n"; + const std::string STRING_GET_BUNDLE_STATS_OK = "get bundle stats successfully\n"; const std::string STRING_GET_BUNDLE_STATS_NG = "get bundle stats failed\n"; @@ -1194,6 +1214,8 @@ ErrCode BundleTestTool::CreateCommandMap() {"switchQuickFix", std::bind(&BundleTestTool::RunAsSwitchQuickFix, this)}, {"deleteQuickFix", std::bind(&BundleTestTool::RunAsDeleteQuickFix, this)}, {"setDebugMode", std::bind(&BundleTestTool::RunAsSetDebugMode, this)}, + {"isDebugMode", std::bind(&BundleTestTool::RunAsIsDebugMode, this)}, + {"getModuleMetadata", std::bind(&BundleTestTool::RunAsGetModuleMetadata, this)}, {"getBundleStats", std::bind(&BundleTestTool::RunAsGetBundleStats, this)}, {"getAppProvisionInfo", std::bind(&BundleTestTool::RunAsGetAppProvisionInfo, this)}, {"getDistributedBundleName", std::bind(&BundleTestTool::RunAsGetDistributedBundleName, this)}, @@ -3714,6 +3736,40 @@ ErrCode BundleTestTool::RunAsSetDebugMode() return setResult; } +ErrCode BundleTestTool::RunAsIsDebugMode() +{ + if (bundleMgrProxy_ == nullptr) { + APP_LOGE("bundleMgrProxy_ is nullptr"); + return ERR_BUNDLEMANAGER_IS_DEBUG_MODE_INTERNAL_ERROR; + } + bool isDebugMode = false; + ErrCode result = bundleMgrProxy_->IsDebugMode(&isDebugMode); + if (result != OHOS::ERR_OK) { + APP_LOGE("IsDebugMode failed"); + resultReceiver_ = STRING_IS_DEBUG_MODE_NG; + } else { + resultReceiver_ = STRING_IS_DEBUG_MODE_OK + std::to_string(isDebugMode); + } + return result; +} + +ErrCode BundleTestTool::RunAsGetModuleMetadata() +{ + if (bundleMgrProxy_ == nullptr) { + APP_LOGE("bundleMgrProxy_ is nullptr"); + return ERR_BUNDLEMANAGER_GET_MODULE_METADATA_INTERNAL_ERROR; + } + std::vector moduleMetadataInfos; + auto result = bundleMgrProxy_->GetModuleMetadata(moduleMetadataInfos); + if (result != OHOS::ERR_OK) { + APP_LOGE("GetModuleMetadata failed"); + resultReceiver_ = STRING_GET_MODULE_METADATA_NG; + } else { + resultReceiver_ = STRING_GET_MODULE_METADATA_OK; + } + return result; +} + ErrCode BundleTestTool::SetDebugMode(int32_t debugMode) { if (debugMode != 0 && debugMode != 1) { -- Gitee