diff --git a/frameworks/src/bundle_command.cpp b/frameworks/src/bundle_command.cpp index f285733ddd8e88289172dbbeebead029212a0bd6..75d5fbb694a5526dc5da70b31cd6449f5eab0bf4 100644 --- a/frameworks/src/bundle_command.cpp +++ b/frameworks/src/bundle_command.cpp @@ -38,6 +38,7 @@ #include "string_ex.h" #include "app_mgr_client.h" #include "directory_ex.h" +#include namespace OHOS { namespace AppExecFwk { @@ -1080,6 +1081,7 @@ ErrCode BundleManagerShellCommand::RunAsCleanCommand() return ERR_OK; } + std::cout << "tracing enter clean command" << std::endl; APP_LOGI("begin to RunAsCleanCommand"); int32_t result = OHOS::ERR_OK; int32_t counter = 0; @@ -1177,6 +1179,7 @@ ErrCode BundleManagerShellCommand::RunAsCleanCommand() // 'bm clean --data' APP_LOGD("'bm clean %{public}s '", argv_[optind - OFFSET_REQUIRED_ARGUMENT]); cleanData = cleanCache ? false : true; + std::cout << "tracing enter handle d cleanData" << cleanData << std::endl; break; } case 'u': { @@ -1205,6 +1208,8 @@ ErrCode BundleManagerShellCommand::RunAsCleanCommand() } } + std::cout << "tracing enter parse finished" << std::endl; + if (result == OHOS::ERR_OK) { if (resultReceiver_ == "" && bundleName.size() == 0) { // 'bm clean ...' with no bundle name option @@ -1222,6 +1227,7 @@ ErrCode BundleManagerShellCommand::RunAsCleanCommand() if (result != OHOS::ERR_OK) { resultReceiver_.append(HELP_MSG_CLEAN); } else { + std::cout << "tracing enter last phrase begin" << std::endl; // bm clean -c if (cleanCache) { if (CleanBundleCacheFilesOperation(bundleName, userId, appIndex)) { @@ -1232,13 +1238,17 @@ ErrCode BundleManagerShellCommand::RunAsCleanCommand() } // bm clean -d if (cleanData) { + std::cout << "tracing cleanData:true, start, -n " << bundleName << ", -u " << userId << ", appIndex: " << appIndex << std::endl; if (CleanBundleDataFilesOperation(bundleName, userId, appIndex)) { + std::cout << "tracing cleanData:true, return ok" << std::endl; resultReceiver_.append(STRING_CLEAN_DATA_BUNDLE_OK + "\n"); } else { + std::cout << "tracing cleanData:true, return ng" << std::endl; resultReceiver_.append(STRING_CLEAN_DATA_BUNDLE_NG + "\n"); } } } + std::cout << "tracing end" << std::endl; APP_LOGI("end"); return result; } @@ -2229,6 +2239,7 @@ bool BundleManagerShellCommand::CleanBundleDataFilesOperation(const std::string ErrCode cleanRetAms = appMgrClient->ClearUpApplicationData(bundleName, appIndex, userId); bool cleanRetBms = bundleMgrProxy_->CleanBundleDataFiles(bundleName, userId, appIndex); APP_LOGD("cleanRetAms: %{public}d, cleanRetBms: %{public}d", cleanRetAms, cleanRetBms); + std::cout << "cleanRetAms: " << cleanRetAms << ", cleanRetBms: " << cleanRetBms << std::endl; if ((cleanRetAms == ERR_OK) && cleanRetBms) { return true; } diff --git a/test/mock/mock_bundle_mgr_host.cpp b/test/mock/mock_bundle_mgr_host.cpp index 91a67043fe568fcd5c4400e1e3efad686af6f3cf..93c3d1501b1b91d1fdac344f46a5d4824dab4d5c 100644 --- a/test/mock/mock_bundle_mgr_host.cpp +++ b/test/mock/mock_bundle_mgr_host.cpp @@ -14,6 +14,7 @@ */ #include "mock_bundle_mgr_host.h" +#include using namespace OHOS::AAFwk; namespace OHOS { @@ -49,6 +50,7 @@ bool MockBundleMgrHost::CleanBundleDataFiles(const std::string &bundleName, cons { APP_LOGD("enter"); APP_LOGD("bundleName: %{public}s", bundleName.c_str()); + std::cout << "tracing Mock Clean BundleDataFiles success" << std::endl; return true; } diff --git a/test/unittest/bm/bm_command_test.cpp b/test/unittest/bm/bm_command_test.cpp index 1173c76b8d5bcc565bbec4ec3b32568528e174f3..85e4af42400fa609e67f83f5b3729385dbede475 100644 --- a/test/unittest/bm/bm_command_test.cpp +++ b/test/unittest/bm/bm_command_test.cpp @@ -376,6 +376,7 @@ HWTEST_F(BmCommandTest, Bm_Command_Clean_0006, Function | MediumTest | Level1) BundleManagerShellCommand cmd(argc, argv); // set the mock objects SetMockObjects(cmd); + EXPECT_EQ(cmd.ExecCommand(), STRING_CLEAN_DATA_BUNDLE_NG + "\n"); }