diff --git a/README_zh.md b/README_zh.md index e5b714cf9ec5a887ec581c78ec3b41832c678550..944382e512c291a72765111dfd2182ea126c451f 100644 --- a/README_zh.md +++ b/README_zh.md @@ -42,9 +42,6 @@ bm help | bm install -h | 显示install支持的命令信息 | | bm install -p    | 安装应用,支持指定路径和多个hap、hsp同时安装 | | bm install -p -u    |给指定用户安装一个应用 | -| bm install -r -p | 覆盖安装一个应用 | -| bm install -r -p -u | 给指定用户覆盖安装一个应用 | -| bm install -r -p -u -w | 安装时指定bm工具等待时间,最小的等待时长为180s,最大的等待时长为600s, 默认缺省为5s | | bm install -s | 安装应用间共享库 | | bm install -p -s | 同时安装使用方应用和其依赖的应用间共享库 | @@ -52,8 +49,6 @@ bm help ```Bash # 安装一个hap bm install -p /data/app/ohosapp.hap -# 覆盖安装一个hap -bm install -p /data/app/ohosapp.hap -r # 安装一个应用间共享库 bm install -s xxx.hsp # 同时安装多个应用间共享库 diff --git a/frameworks/include/bundle_command.h b/frameworks/include/bundle_command.h index ca30488eddebd5a534da059b4cc1c86e86f33edd..ffd98f59da682deac896005c66b7d9414d122d4e 100644 --- a/frameworks/include/bundle_command.h +++ b/frameworks/include/bundle_command.h @@ -49,9 +49,7 @@ const std::string HELP_MSG_INSTALL = " -p, --bundle-path ... install one bundle by some hap or hsp paths\n" " -p, --bundle-path install one bundle by a direction,\n" " under which are some hap or hsp files\n" - " -r -p replace an existing bundle\n" - " -r --bundle-path replace an existing bundle\n" - " -s, --shared-bundle-dir-path install inter-application hsp files\n" + " -s, --shared-bundle-dir-path install cross-app hsp files\n" " -u, --user-id specify a user id\n" " -w, --waitting-time specify waitting time for installation, the minimum\n" " waitting time is 180s, the maximum waitting\n" diff --git a/frameworks/src/bundle_command.cpp b/frameworks/src/bundle_command.cpp index 6d931d2f7fadf179d9581580e333d6e7184018c4..d68f1eb5b47a4b0e5b9592478ffcbcf8de06dd34 100644 --- a/frameworks/src/bundle_command.cpp +++ b/frameworks/src/bundle_command.cpp @@ -57,7 +57,6 @@ const std::string SHORT_OPTIONS = "hp:rn:m:a:cdu:w:s:"; const struct option LONG_OPTIONS[] = { {"help", no_argument, nullptr, 'h'}, {"bundle-path", required_argument, nullptr, 'p'}, - {"replace", no_argument, nullptr, 'r'}, {"bundle-name", required_argument, nullptr, 'n'}, {"module-name", required_argument, nullptr, 'm'}, {"ability-name", required_argument, nullptr, 'a'}, @@ -235,8 +234,7 @@ bool BundleManagerShellCommand::IsInstallOption(int index) const if (index >= argc_ || index < INDEX_OFFSET) { return false; } - if (argList_[index - INDEX_OFFSET] == "-r" || argList_[index - INDEX_OFFSET] == "--replace" || - argList_[index - INDEX_OFFSET] == "-p" || argList_[index - INDEX_OFFSET] == "--bundle-path" || + if (argList_[index - INDEX_OFFSET] == "-p" || argList_[index - INDEX_OFFSET] == "--bundle-path" || argList_[index - INDEX_OFFSET] == "-u" || argList_[index - INDEX_OFFSET] == "--user-id" || argList_[index - INDEX_OFFSET] == "-w" || argList_[index - INDEX_OFFSET] == "--waitting-time" || argList_[index - INDEX_OFFSET] == "-s" || argList_[index - INDEX_OFFSET] == "--shared-bundle-dir-path") { @@ -338,12 +336,6 @@ ErrCode BundleManagerShellCommand::RunAsInstallCommand() index = optind; break; } - case 'r': { - // 'bm install -r' - // 'bm install --replace' - installFlag = InstallFlag::REPLACE_EXISTING; - break; - } case 'u': { // 'bm install -p -u userId' // 'bm install --bundle-path --user-id userId' @@ -452,9 +444,8 @@ ErrCode BundleManagerShellCommand::GetBundlePath(const std::string& param, if (param.empty()) { return OHOS::ERR_INVALID_VALUE; } - if (param == "-r" || param == "--replace" || param == "-p" || - param == "--bundle-path" || param == "-u" || param == "--user-id" || - param == "-w" || param == "--waitting-time") { + if (param == "-p" || param == "--bundle-path" || param == "-u" || + param == "--user-id" || param == "-w" || param == "--waitting-time") { return OHOS::ERR_INVALID_VALUE; } bundlePaths.emplace_back(param); diff --git a/frameworks/src/bundle_test_tool.cpp b/frameworks/src/bundle_test_tool.cpp index beb3c39bb3a5ee85053c63617134463d1a1e51d8..06bc2a35204c9f4389a1c5a02b9473635135bd55 100644 --- a/frameworks/src/bundle_test_tool.cpp +++ b/frameworks/src/bundle_test_tool.cpp @@ -513,13 +513,12 @@ const struct option LONG_OPTIONS_GET[] = { {nullptr, 0, nullptr, 0}, }; -const std::string SHORT_OPTIONS_RULE = "ha:c:n:e:r:t:u:"; +const std::string SHORT_OPTIONS_RULE = "ha:c:n:e:t:u:"; const struct option LONG_OPTIONS_RULE[] = { {"help", no_argument, nullptr, 'h'}, {"app-id", required_argument, nullptr, 'a'}, {"control-rule", required_argument, nullptr, 'c'}, {"bundle-name", required_argument, nullptr, 'n'}, - {"bundle-name", required_argument, nullptr, 'n'}, {"euid", required_argument, nullptr, 'e'}, {"control-rule-type", required_argument, nullptr, 't'}, {"user-id", required_argument, nullptr, 'u'}, diff --git a/test/moduletest/bm/bm_command_install_module_test.cpp b/test/moduletest/bm/bm_command_install_module_test.cpp index 71593d3cb14794e57a02960dd962b8980ef9b2fd..a3967c38f38b362d6df2124c8f9f9e2af2ee3e85 100644 --- a/test/moduletest/bm/bm_command_install_module_test.cpp +++ b/test/moduletest/bm/bm_command_install_module_test.cpp @@ -109,29 +109,3 @@ HWTEST_F(BmCommandInstallModuleTest, Bm_Command_Install_ModuleTest_0100, Functio EXPECT_EQ(cmd.ExecCommand(), STRING_INSTALL_BUNDLE_OK + "\n"); } - -/** - * @tc.number: Bm_Command_Install_ModuleTest_0200 - * @tc.name: ExecCommand - * @tc.desc: Verify the "bm install -p -r" command. - */ -HWTEST_F(BmCommandInstallModuleTest, Bm_Command_Install_ModuleTest_0200, Function | MediumTest | Level1) -{ - // install a bundle - char *argv[] = { - const_cast(TOOL_NAME.c_str()), - const_cast(cmd_.c_str()), - const_cast("-p"), - const_cast(STRING_BUNDLE_PATH.c_str()), - const_cast("-r"), - const_cast(""), - }; - int argc = sizeof(argv) / sizeof(argv[0]) - 1; - - BundleManagerShellCommand cmd(argc, argv); - - // set the mock objects - SetMockObjects(cmd); - - EXPECT_EQ(cmd.ExecCommand(), STRING_INSTALL_BUNDLE_OK + "\n"); -} diff --git a/test/systemtest/bm/bm_command_install_system_test.cpp b/test/systemtest/bm/bm_command_install_system_test.cpp index b4ffb608f9956de3bfa8620de7a4801a3b4bad3a..2afbbf53cc6107b179ee9dca4895f9a296a89be3 100644 --- a/test/systemtest/bm/bm_command_install_system_test.cpp +++ b/test/systemtest/bm/bm_command_install_system_test.cpp @@ -82,27 +82,4 @@ HWTEST_F(BmCommandInstallSystemTest, Bm_Command_Install_SystemTest_0200, Functio std::string commandResult = ToolSystemTest::ExecuteCommand(command); EXPECT_EQ(commandResult, STRING_INSTALL_BUNDLE_NG + "\n" + INSTALL_FALSE + "\n"); -} - -/** - * @tc.number: Bm_Command_Install_SystemTest_0300 - * @tc.name: ExecCommand - * @tc.desc: Verify the "bm install -p -r" command. - */ -HWTEST_F(BmCommandInstallSystemTest, Bm_Command_Install_SystemTest_0300, Function | MediumTest | Level1) -{ - // uninstall the bundle - ToolSystemTest::UninstallBundle(STRING_BUNDLE_NAME); - - // install a valid bundle - ToolSystemTest::InstallBundle(STRING_BUNDLE_PATH, true); - - // install the same bundle - std::string command = "bm install -p " + STRING_BUNDLE_PATH + " -r"; - std::string commandResult = ToolSystemTest::ExecuteCommand(command); - - EXPECT_EQ(commandResult, STRING_INSTALL_BUNDLE_OK + "\n"); - - // uninstall the bundle - ToolSystemTest::UninstallBundle(STRING_BUNDLE_NAME); } \ No newline at end of file diff --git a/test/unittest/bm/bm_command_install_test.cpp b/test/unittest/bm/bm_command_install_test.cpp index ad6665b57a24fff1670d1c55c04b411cf1d8f936..6a98d4a0ab7e78ec1328e2127f46da844e21fb8b 100644 --- a/test/unittest/bm/bm_command_install_test.cpp +++ b/test/unittest/bm/bm_command_install_test.cpp @@ -291,30 +291,6 @@ HWTEST_F(BmCommandInstallTest, Bm_Command_Install_0900, Function | MediumTest | EXPECT_EQ(cmd.ExecCommand(), STRING_REQUIRE_CORRECT_VALUE + HELP_MSG_INSTALL); } -/** - * @tc.number: Bm_Command_Install_1000 - * @tc.name: ExecCommand - * @tc.desc: Verify the "bm install -r" command. - */ -HWTEST_F(BmCommandInstallTest, Bm_Command_Install_1000, Function | MediumTest | Level1) -{ - char *argv[] = { - const_cast(TOOL_NAME.c_str()), - const_cast(cmd_.c_str()), - const_cast("-r"), - const_cast(""), - }; - int argc = sizeof(argv) / sizeof(argv[0]) - 1; - - BundleManagerShellCommand cmd(argc, argv); - - // set the mock objects - SetMockObjects(cmd); - - EXPECT_EQ( - cmd.ExecCommand(), "error: you must specify a bundle path with '-p' or '--bundle-path'.\n" + HELP_MSG_INSTALL); -} - /** * @tc.number: Bm_Command_Install_1100 * @tc.name: ExecCommand @@ -340,58 +316,6 @@ HWTEST_F(BmCommandInstallTest, Bm_Command_Install_1100, Function | MediumTest | EXPECT_EQ(cmd.ExecCommand(), STRING_INSTALL_BUNDLE_OK + "\n"); } -/** - * @tc.number: Bm_Command_Install_1200 - * @tc.name: ExecCommand - * @tc.desc: Verify the "bm install -p -r" command. - */ -HWTEST_F(BmCommandInstallTest, Bm_Command_Install_1200, Function | MediumTest | Level1) -{ - // install a bundle - char *argv[] = { - const_cast(TOOL_NAME.c_str()), - const_cast(cmd_.c_str()), - const_cast("-p"), - const_cast(STRING_BUNDLE_PATH.c_str()), - const_cast("-r"), - const_cast(""), - }; - int argc = sizeof(argv) / sizeof(argv[0]) - 1; - - BundleManagerShellCommand cmd(argc, argv); - - // set the mock objects - SetMockObjects(cmd); - - EXPECT_EQ(cmd.ExecCommand(), STRING_INSTALL_BUNDLE_OK + "\n"); -} - -/** - * @tc.number: Bm_Command_Install_1300 - * @tc.name: ExecCommand - * @tc.desc: Verify the "bm install -r -p " command. - */ -HWTEST_F(BmCommandInstallTest, Bm_Command_Install_1300, Function | MediumTest | Level1) -{ - // install a bundle - char *argv[] = { - const_cast(TOOL_NAME.c_str()), - const_cast(cmd_.c_str()), - const_cast("-r"), - const_cast("-p"), - const_cast(STRING_BUNDLE_PATH.c_str()), - const_cast(""), - }; - int argc = sizeof(argv) / sizeof(argv[0]) - 1; - - BundleManagerShellCommand cmd(argc, argv); - - // set the mock objects - SetMockObjects(cmd); - - EXPECT_EQ(cmd.ExecCommand(), STRING_INSTALL_BUNDLE_OK + "\n"); -} - /** * @tc.number: Bm_Command_Install_1600 * @tc.name: ExecCommand @@ -548,87 +472,6 @@ HWTEST_F(BmCommandInstallTest, Bm_Command_Install_2100, Function | MediumTest | EXPECT_EQ(cmd.ExecCommand(), STRING_INSTALL_BUNDLE_OK + "\n"); } -/** - * @tc.number: Bm_Command_Install_2300 - * @tc.name: ExecCommand - * @tc.desc: Verify the "bm install -p -r" command. - */ -HWTEST_F(BmCommandInstallTest, Bm_Command_Install_2300, Function | MediumTest | Level1) -{ - // install a bundle - char *argv[] = { - const_cast(TOOL_NAME.c_str()), - const_cast(cmd_.c_str()), - const_cast("-p"), - const_cast(STRING_BUNDLE_PATH.c_str()), - const_cast(STRING_OTHER_BUNDLE_PATH.c_str()), - const_cast("-r"), - const_cast(""), - }; - int argc = sizeof(argv) / sizeof(argv[0]) - 1; - - BundleManagerShellCommand cmd(argc, argv); - - // set the mock objects - SetMockObjects(cmd); - - EXPECT_EQ(cmd.ExecCommand(), STRING_INSTALL_BUNDLE_OK + "\n"); -} - -/** - * @tc.number: Bm_Command_Install_2400 - * @tc.name: ExecCommand - * @tc.desc: Verify the "bm install -r -p " command. - */ -HWTEST_F(BmCommandInstallTest, Bm_Command_Install_2400, Function | MediumTest | Level1) -{ - // install a bundle - char *argv[] = { - const_cast(TOOL_NAME.c_str()), - const_cast(cmd_.c_str()), - const_cast("-r"), - const_cast("-p"), - const_cast(STRING_BUNDLE_PATH.c_str()), - const_cast(STRING_OTHER_BUNDLE_PATH.c_str()), - const_cast(""), - }; - int argc = sizeof(argv) / sizeof(argv[0]) - 1; - - BundleManagerShellCommand cmd(argc, argv); - - // set the mock objects - SetMockObjects(cmd); - - EXPECT_EQ(cmd.ExecCommand(), STRING_INSTALL_BUNDLE_OK + "\n"); -} - -/** - * @tc.number: Bm_Command_Install_2600 - * @tc.name: ExecCommand - * @tc.desc: Verify the "bm install -p -r " command. - */ -HWTEST_F(BmCommandInstallTest, Bm_Command_Install_2600, Function | MediumTest | Level1) -{ - // install a bundle - char *argv[] = { - const_cast(TOOL_NAME.c_str()), - const_cast(cmd_.c_str()), - const_cast("-p"), - const_cast("-r"), - const_cast(STRING_BUNDLE_PATH.c_str()), - const_cast(STRING_OTHER_BUNDLE_PATH.c_str()), - const_cast(""), - }; - int argc = sizeof(argv) / sizeof(argv[0]) - 1; - - BundleManagerShellCommand cmd(argc, argv); - - // set the mock objects - SetMockObjects(cmd); - - EXPECT_EQ(cmd.ExecCommand(), STRING_REQUIRE_CORRECT_VALUE); -} - /** * @tc.number: Bm_Command_Install_2700 * @tc.name: ExecCommand @@ -933,7 +776,6 @@ HWTEST_F(BmCommandInstallTest, Bm_Command_Install_3800, Function | MediumTest | const_cast(TOOL_NAME.c_str()), const_cast(cmd_.c_str()), const_cast("-s"), - const_cast("-r"), const_cast("xxx"), const_cast(""), }; diff --git a/test/unittest/bm/bm_command_test.cpp b/test/unittest/bm/bm_command_test.cpp index 8e1d5e63d396737e95c736717ee5ddffbaca2cfd..a522fee5eb2f0955fce6d8150345daf09ad2222a 100644 --- a/test/unittest/bm/bm_command_test.cpp +++ b/test/unittest/bm/bm_command_test.cpp @@ -1297,14 +1297,6 @@ HWTEST_F(BmCommandTest, GetBundlePath_0001, Function | MediumTest | Level1) auto res = cmd.GetBundlePath(param, bundlePaths); EXPECT_EQ(res, ERR_INVALID_VALUE); - param = "-r"; - res = cmd.GetBundlePath(param, bundlePaths); - EXPECT_EQ(res, ERR_INVALID_VALUE); - - param = "--replace"; - res = cmd.GetBundlePath(param, bundlePaths); - EXPECT_EQ(res, ERR_INVALID_VALUE); - param = "-p"; res = cmd.GetBundlePath(param, bundlePaths); EXPECT_EQ(res, ERR_INVALID_VALUE);