diff --git a/interfaces/inner_api/quick_fix/include/quick_fix_manager_client.h b/interfaces/inner_api/quick_fix/include/quick_fix_manager_client.h index b7bca985da2ccf9d4b442f367d792bc8194b2048..baa5f4224553fd018c2b9bbfcebf72b7bc4a221b 100644 --- a/interfaces/inner_api/quick_fix/include/quick_fix_manager_client.h +++ b/interfaces/inner_api/quick_fix/include/quick_fix_manager_client.h @@ -38,9 +38,10 @@ public: * @brief Apply quick fix. * * @param quickFixFiles quick fix files need to apply, this value should include file path and file name. + * @param isDebug this value is for the quick fix debug mode selection. * @return returns 0 on success, error code on failure. */ - int32_t ApplyQuickFix(const std::vector &quickFixFiles); + int32_t ApplyQuickFix(const std::vector &quickFixFiles, bool isDebug = false); /** * @brief Get applyed quick fix info. diff --git a/interfaces/inner_api/quick_fix/include/quick_fix_manager_interface.h b/interfaces/inner_api/quick_fix/include/quick_fix_manager_interface.h index 12bf6184cf493d1562b62bd130c1bde0b7ba19b3..b2a7ba479eb6de044e2865a4bcd5e884da24effb 100644 --- a/interfaces/inner_api/quick_fix/include/quick_fix_manager_interface.h +++ b/interfaces/inner_api/quick_fix/include/quick_fix_manager_interface.h @@ -29,9 +29,10 @@ public: * @brief Apply quick fix. * * @param quickFixFiles quick fix files need to apply, this value should include file path and file name. + * @param isDebug this value is for the quick fix debug mode selection. * @return returns 0 on success, error code on failure. */ - virtual int32_t ApplyQuickFix(const std::vector &quickFixFiles) = 0; + virtual int32_t ApplyQuickFix(const std::vector &quickFixFiles, bool isDebug = false) = 0; /** * @brief Get applyed quick fix info. diff --git a/interfaces/inner_api/quick_fix/include/quick_fix_manager_proxy.h b/interfaces/inner_api/quick_fix/include/quick_fix_manager_proxy.h index 20d7fa9229bbcc78fe5f71276b4dcd361dab33c6..5942d464f5ccd563f97fbc430da2d4a9ad34f056 100644 --- a/interfaces/inner_api/quick_fix/include/quick_fix_manager_proxy.h +++ b/interfaces/inner_api/quick_fix/include/quick_fix_manager_proxy.h @@ -31,9 +31,10 @@ public: * @brief Apply quick fix. * * @param quickFixFiles quick fix files need to apply, this value should include file path and file name. + * @param isDebug this value is for the quick fix debug mode selection. * @return returns 0 on success, error code on failure. */ - int32_t ApplyQuickFix(const std::vector &quickFixFiles) override; + int32_t ApplyQuickFix(const std::vector &quickFixFiles, bool isDebug = false) override; /** * @brief Get applyed quick fix info. diff --git a/interfaces/inner_api/quick_fix/src/quick_fix_manager_client.cpp b/interfaces/inner_api/quick_fix/src/quick_fix_manager_client.cpp index 510611f638e9ba5a478f7ce60fb1c7b1cc654d88..504c4f5383a418b014876d474265b05c9172af71 100644 --- a/interfaces/inner_api/quick_fix/src/quick_fix_manager_client.cpp +++ b/interfaces/inner_api/quick_fix/src/quick_fix_manager_client.cpp @@ -30,7 +30,7 @@ namespace { const int LOAD_SA_TIMEOUT_MS = 4 * 1000; } // namespace -int32_t QuickFixManagerClient::ApplyQuickFix(const std::vector &quickFixFiles) +int32_t QuickFixManagerClient::ApplyQuickFix(const std::vector &quickFixFiles, bool isDebug) { HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); HILOG_DEBUG("function called."); @@ -40,8 +40,7 @@ int32_t QuickFixManagerClient::ApplyQuickFix(const std::vector &qui HILOG_ERROR("Get quick fix manager service failed."); return QUICK_FIX_CONNECT_FAILED; } - - return quickFixMgr->ApplyQuickFix(quickFixFiles); + return quickFixMgr->ApplyQuickFix(quickFixFiles, isDebug); } int32_t QuickFixManagerClient::GetApplyedQuickFixInfo(const std::string &bundleName, diff --git a/interfaces/inner_api/quick_fix/src/quick_fix_manager_proxy.cpp b/interfaces/inner_api/quick_fix/src/quick_fix_manager_proxy.cpp index b950a0c6085940dde3431f1915c86614318a0b30..e277529abbe4a681eaf9e09fd3261589425f5a4d 100644 --- a/interfaces/inner_api/quick_fix/src/quick_fix_manager_proxy.cpp +++ b/interfaces/inner_api/quick_fix/src/quick_fix_manager_proxy.cpp @@ -24,7 +24,7 @@ namespace OHOS { namespace AAFwk { -int32_t QuickFixManagerProxy::ApplyQuickFix(const std::vector &quickFixFiles) +int32_t QuickFixManagerProxy::ApplyQuickFix(const std::vector &quickFixFiles, bool isDebug) { HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); HILOG_DEBUG("function called."); @@ -54,6 +54,11 @@ int32_t QuickFixManagerProxy::ApplyQuickFix(const std::vector &quic return QUICK_FIX_WRITE_PARCEL_FAILED; } + if (!data.WriteBool(isDebug)) { + HILOG_ERROR("Write quick fix debug failed."); + return QUICK_FIX_WRITE_PARCEL_FAILED; + } + MessageParcel reply; MessageOption option(MessageOption::TF_SYNC); auto ret = SendTransactCmd(QuickFixMgrCmd::ON_APPLY_QUICK_FIX, data, reply, option); diff --git a/interfaces/inner_api/quick_fix/src/quick_fix_manager_stub.cpp b/interfaces/inner_api/quick_fix/src/quick_fix_manager_stub.cpp index 13e1114111418df41d8a2f050ac99590c9670ddf..48b486030feaee9075d66ef1ab716769166ae67c 100644 --- a/interfaces/inner_api/quick_fix/src/quick_fix_manager_stub.cpp +++ b/interfaces/inner_api/quick_fix/src/quick_fix_manager_stub.cpp @@ -61,8 +61,8 @@ int32_t QuickFixManagerStub::ApplyQuickFixInner(MessageParcel &data, MessageParc HILOG_ERROR("Read quick fix files failed."); return QUICK_FIX_READ_PARCEL_FAILED; } - - auto ret = ApplyQuickFix(hapQuickFixFiles); + bool isDebug = data.ReadBool(); + auto ret = ApplyQuickFix(hapQuickFixFiles, isDebug); reply.WriteInt32(ret); return QUICK_FIX_OK; } diff --git a/services/quickfixmgr/include/quick_fix_manager_apply_task.h b/services/quickfixmgr/include/quick_fix_manager_apply_task.h index 1d13716180850961e2a4477979dafae4c428cfeb..299f427bcb1aeca0a41e7c90f9b8deb15066765a 100644 --- a/services/quickfixmgr/include/quick_fix_manager_apply_task.h +++ b/services/quickfixmgr/include/quick_fix_manager_apply_task.h @@ -38,7 +38,7 @@ public: QUICK_FIX_REVOKE, }; - void Run(const std::vector &quickFixFiles); + void Run(const std::vector &quickFixFiles, bool isDebug = false); void HandlePatchDeployed(); void HandlePatchSwitched(); void HandlePatchDeleted(); @@ -64,7 +64,7 @@ public: void PostRevokeQuickFixDeleteTask(); void PostRevokeQuickFixProcessDiedTask(); private: - void PostDeployQuickFixTask(const std::vector &quickFixFiles); + void PostDeployQuickFixTask(const std::vector &quickFixFiles, bool isDebug = false); void PostTimeOutTask(); void PostNotifyLoadRepairPatchTask(); void PostNotifyUnloadRepairPatchTask(); diff --git a/services/quickfixmgr/include/quick_fix_manager_service.h b/services/quickfixmgr/include/quick_fix_manager_service.h index 2a3df8b92526ad948642fde566ab60ca0660b7f4..9d6898151ca42be1d4044618171f5433be0285a4 100644 --- a/services/quickfixmgr/include/quick_fix_manager_service.h +++ b/services/quickfixmgr/include/quick_fix_manager_service.h @@ -50,9 +50,10 @@ public: * @brief Apply quick fix. * * @param quickFixFiles Quick fix files need to apply, this value should include file path and file name. + * @param isDebug this value is for the quick fix debug mode selection. * @return Returns 0 on success, error code on failure. */ - int32_t ApplyQuickFix(const std::vector &quickFixFiles) override; + int32_t ApplyQuickFix(const std::vector &quickFixFiles, bool isDebug = false) override; /** * @brief Get applyed quick fix info. diff --git a/services/quickfixmgr/src/quick_fix_manager_apply_task.cpp b/services/quickfixmgr/src/quick_fix_manager_apply_task.cpp index 8f8c20bdb687735840be30754a67009b351601da..27492be9b032ddf99887c0a94f25c21112dca032 100644 --- a/services/quickfixmgr/src/quick_fix_manager_apply_task.cpp +++ b/services/quickfixmgr/src/quick_fix_manager_apply_task.cpp @@ -307,12 +307,12 @@ QuickFixManagerApplyTask::~QuickFixManagerApplyTask() HILOG_DEBUG("destroyed."); } -void QuickFixManagerApplyTask::Run(const std::vector &quickFixFiles) +void QuickFixManagerApplyTask::Run(const std::vector &quickFixFiles, bool isDebug) { HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); HILOG_INFO("Run apply task."); taskType_ = TaskType::QUICK_FIX_APPLY; - PostDeployQuickFixTask(quickFixFiles); + PostDeployQuickFixTask(quickFixFiles, isDebug); } void QuickFixManagerApplyTask::RunRevoke() @@ -385,12 +385,12 @@ void QuickFixManagerApplyTask::HandlePatchDeleted() RemoveSelf(); } -void QuickFixManagerApplyTask::PostDeployQuickFixTask(const std::vector &quickFixFiles) +void QuickFixManagerApplyTask::PostDeployQuickFixTask(const std::vector &quickFixFiles, bool isDebug) { sptr callback = new (std::nothrow) QuickFixManagerStatusCallback( shared_from_this()); std::weak_ptr thisWeakPtr(weak_from_this()); - auto deployTask = [thisWeakPtr, quickFixFiles, callback]() { + auto deployTask = [thisWeakPtr, quickFixFiles, callback, isDebug]() { auto applyTask = thisWeakPtr.lock(); if (applyTask == nullptr) { HILOG_ERROR("PostDeployQuickFixTask, Apply task is nullptr."); @@ -404,7 +404,8 @@ void QuickFixManagerApplyTask::PostDeployQuickFixTask(const std::vectorbundleQfMgr_->DeployQuickFix(quickFixFiles, callback); + HILOG_DEBUG("isDebug is %d", isDebug); + auto ret = applyTask->bundleQfMgr_->DeployQuickFix(quickFixFiles, callback, isDebug); if (ret != 0) { HILOG_ERROR("PostDeployQuickFixTask, Deploy quick fix failed with %{public}d.", ret); applyTask->NotifyApplyStatus(QUICK_FIX_DEPLOY_FAILED); diff --git a/services/quickfixmgr/src/quick_fix_manager_service.cpp b/services/quickfixmgr/src/quick_fix_manager_service.cpp index e248b37d08ce3069eeacc5a067853141ccaee4ef..982c5a612d59b6c915c145604b2d7cfb47fc2202 100644 --- a/services/quickfixmgr/src/quick_fix_manager_service.cpp +++ b/services/quickfixmgr/src/quick_fix_manager_service.cpp @@ -54,7 +54,7 @@ bool QuickFixManagerService::Init() return true; } -int32_t QuickFixManagerService::ApplyQuickFix(const std::vector &quickFixFiles) +int32_t QuickFixManagerService::ApplyQuickFix(const std::vector &quickFixFiles, bool isDebug) { HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); HILOG_DEBUG("function called."); @@ -77,10 +77,9 @@ int32_t QuickFixManagerService::ApplyQuickFix(const std::vector &qu HILOG_ERROR("App manager is nullptr."); return QUICK_FIX_CONNECT_FAILED; } - auto applyTask = std::make_shared(bundleQfMgr, appMgr, eventHandler_, this); AddApplyTask(applyTask); - applyTask->Run(quickFixFiles); + applyTask->Run(quickFixFiles, isDebug); HILOG_DEBUG("function finished."); return QUICK_FIX_OK; diff --git a/test/unittest/quick_fix/mock/include/mock_quick_fix_manager_stub.h b/test/unittest/quick_fix/mock/include/mock_quick_fix_manager_stub.h index d4f0220c614713774948be4bdf08325c45dbf71e..b459885482a1797394e0b1d1f2715b7be227357e 100644 --- a/test/unittest/quick_fix/mock/include/mock_quick_fix_manager_stub.h +++ b/test/unittest/quick_fix/mock/include/mock_quick_fix_manager_stub.h @@ -24,7 +24,7 @@ namespace AAFwk { class MockQuickFixManagerStub : public QuickFixManagerStub { public: MOCK_METHOD4(SendRequest, int(uint32_t, MessageParcel&, MessageParcel&, MessageOption&)); - MOCK_METHOD1(ApplyQuickFix, int32_t(const std::vector&)); + MOCK_METHOD2(ApplyQuickFix, int32_t(const std::vector&, bool isDebug)); MOCK_METHOD2(GetApplyedQuickFixInfo, int32_t(const std::string&, ApplicationQuickFixInfo&)); MOCK_METHOD1(RevokeQuickFix, int32_t(const std::string &)); diff --git a/test/unittest/quick_fix/quick_fix_manager_client_test/quick_fix_manager_client_test.cpp b/test/unittest/quick_fix/quick_fix_manager_client_test/quick_fix_manager_client_test.cpp index 694b8e3eae53864a1107c275a52f5625eac670c6..02e1f02c53392bda99fe7d0e2b8720a3daa1c487 100644 --- a/test/unittest/quick_fix/quick_fix_manager_client_test/quick_fix_manager_client_test.cpp +++ b/test/unittest/quick_fix/quick_fix_manager_client_test/quick_fix_manager_client_test.cpp @@ -67,10 +67,11 @@ HWTEST_F(QuickFixManagerClientTest, ApplyQuickFix_0100, TestSize.Level1) HILOG_INFO("%{public}s start", __func__); quickFixClient_->quickFixMgr_ = mockQuickFixMgrService_; - EXPECT_CALL(*mockQuickFixMgrService_, ApplyQuickFix(_)).Times(1); + EXPECT_CALL(*mockQuickFixMgrService_, ApplyQuickFix(_, _)).Times(1); std::vector quickfixFiles; - auto ret = quickFixClient_->ApplyQuickFix(quickfixFiles); + bool isDebug = false; + auto ret = quickFixClient_->ApplyQuickFix(quickfixFiles, isDebug); EXPECT_EQ(ret, QUICK_FIX_OK); HILOG_INFO("%{public}s end", __func__); diff --git a/test/unittest/quick_fix/quick_fix_manager_service_ability_test/mock/mock_quick_fix_manager_service.cpp b/test/unittest/quick_fix/quick_fix_manager_service_ability_test/mock/mock_quick_fix_manager_service.cpp index 21125eb3ead5d88d16fd422a5c65dd26af3d2e5a..af63c494490a3cfd1582382f23624891453bc2ce 100644 --- a/test/unittest/quick_fix/quick_fix_manager_service_ability_test/mock/mock_quick_fix_manager_service.cpp +++ b/test/unittest/quick_fix/quick_fix_manager_service_ability_test/mock/mock_quick_fix_manager_service.cpp @@ -58,7 +58,7 @@ bool QuickFixManagerService::Init() return g_mockInitState; } -int32_t QuickFixManagerService::ApplyQuickFix(const std::vector& quickFixFiles) +int32_t QuickFixManagerService::ApplyQuickFix(const std::vector& quickFixFiles, bool isDebug) { return 0; } diff --git a/test/unittest/quick_fix/quick_fix_manager_stub_test/quick_fix_manager_stub_test.cpp b/test/unittest/quick_fix/quick_fix_manager_stub_test/quick_fix_manager_stub_test.cpp index fbc14817d9a8516e1b6336f5191a8a498e87ecc9..6f3ce405b17402b896a4d2f586d3128758b8125c 100644 --- a/test/unittest/quick_fix/quick_fix_manager_stub_test/quick_fix_manager_stub_test.cpp +++ b/test/unittest/quick_fix/quick_fix_manager_stub_test/quick_fix_manager_stub_test.cpp @@ -74,8 +74,9 @@ HWTEST_F(QuickFixManagerStubTest, ApplyQuickFix_0100, TestSize.Level1) quickFixFiles.push_back("/data/storage/el2/base/entry1.hqf"); quickFixFiles.push_back("/data/storage/el2/base/entry2.hqf"); data.WriteStringVector(quickFixFiles); - - EXPECT_CALL(*mockQuickFixMgrService_, ApplyQuickFix(_)).Times(1); + bool isDebug = false; + data.WriteBool(isDebug); + EXPECT_CALL(*mockQuickFixMgrService_, ApplyQuickFix(_, _)).Times(1); auto result = mockQuickFixMgrService_->OnRemoteRequest( IQuickFixManager::QuickFixMgrCmd::ON_APPLY_QUICK_FIX, data, reply, option);