From dfedc401f3c7c439184642c0f804291cd7d25b25 Mon Sep 17 00:00:00 2001 From: xsz233 Date: Tue, 6 Feb 2024 09:05:20 +0000 Subject: [PATCH] user mode Signed-off-by: xsz233 --- frameworks/include/bundle_command.h | 14 ++++++++++++++ frameworks/src/bundle_command.cpp | 20 +++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/frameworks/include/bundle_command.h b/frameworks/include/bundle_command.h index 4625b14..88369d2 100644 --- a/frameworks/include/bundle_command.h +++ b/frameworks/include/bundle_command.h @@ -42,6 +42,20 @@ const std::string HELP_MSG = "usage: bm \n" " dump-dependencies dump dependencies by given bundle name and module name\n" " dump-shared dump inter-application shared library information by bundle name\n"; +const std::string HELP_MSG_USER_MODE = "usage: bm \n" + "These are common bm commands list:\n" + " help list available commands\n" + " install install a bundle with options\n" + " uninstall uninstall a bundle with options\n" + " dump dump the bundle info\n" + " get obtain device udid\n" + " quickfix quick fix, including query and install\n" + " compile Compile the software package\n" + " dump-overlay dump overlay info of the specific overlay bundle\n" + " dump-target-overlay dump overlay info of the specific target bundle\n" + " dump-dependencies dump dependencies by given bundle name and module name\n" + " dump-shared dump inter-application shared library information by bundle name\n"; + const std::string HELP_MSG_COMPILE = "usage: bm compile [-m mode] [-r reset] (bundle-name | -a)\n" "options list:\n" diff --git a/frameworks/src/bundle_command.cpp b/frameworks/src/bundle_command.cpp index 46b81ec..fe760bd 100644 --- a/frameworks/src/bundle_command.cpp +++ b/frameworks/src/bundle_command.cpp @@ -45,6 +45,7 @@ const std::string OVERLAY_BUNDLE_INFOS = "overlayBundleInfos"; const std::string OVERLAY_MODULE_INFO = "overlayModuleInfo"; const std::string SHARED_BUNDLE_INFO = "sharedBundleInfo"; const std::string DEPENDENCIES = "dependencies"; +const char* IS_ROOT_MODE_PARAM = "const.debuggable"; const int32_t INDEX_OFFSET = 2; const int32_t MAX_WAITING_TIME = 3000; const int32_t DEVICE_UDID_LENGTH = 65; @@ -234,7 +235,11 @@ ErrCode BundleManagerShellCommand::Init() ErrCode BundleManagerShellCommand::RunAsHelpCommand() { - resultReceiver_.append(HELP_MSG); + if (GetIntParameter(IS_ROOT_MODE_PARAM, false)) { + resultReceiver_.append(HELP_MSG); + } else { + resultReceiver_.append(HELP_MSG_USER_MODE); + } return OHOS::ERR_OK; } @@ -933,6 +938,11 @@ ErrCode BundleManagerShellCommand::RunAsDumpCommand() ErrCode BundleManagerShellCommand::RunAsCleanCommand() { + if (!GetIntParameter(IS_ROOT_MODE_PARAM, false)) { + APP_LOGD("in user mode"); + return ERR_OK; + } + APP_LOGI("begin to RunAsCleanCommand"); int32_t result = OHOS::ERR_OK; int32_t counter = 0; @@ -1081,6 +1091,10 @@ ErrCode BundleManagerShellCommand::RunAsCleanCommand() ErrCode BundleManagerShellCommand::RunAsEnableCommand() { + if (!GetIntParameter(IS_ROOT_MODE_PARAM, false)) { + APP_LOGD("in user mode"); + return ERR_OK; + } APP_LOGI("begin to RunAsEnableCommand"); int result = OHOS::ERR_OK; int counter = 0; @@ -1216,6 +1230,10 @@ ErrCode BundleManagerShellCommand::RunAsEnableCommand() ErrCode BundleManagerShellCommand::RunAsDisableCommand() { + if (!GetIntParameter(IS_ROOT_MODE_PARAM, false)) { + APP_LOGD("in user mode"); + return ERR_OK; + } APP_LOGI("begin to RunAsDisableCommand"); int result = OHOS::ERR_OK; int counter = 0; -- Gitee