From 6c27fef16e2f60c4daba778f003c958747351c31 Mon Sep 17 00:00:00 2001 From: lanhaoyu Date: Sun, 29 Jun 2025 18:47:13 +0800 Subject: [PATCH] add quick fix idl Signed-off-by: lanhaoyu --- .../bundle_mgr_helper.cpp | 13 ------------ .../src/quick_fix_manager_client.cpp | 8 ++----- .../quick_fix/src/quick_fix_utils.cpp | 18 ---------------- .../bundle_mgr_helper.h | 1 - .../include/quick_fix_manager_apply_task.h | 2 +- .../include/quick_fix_manager_service.h | 2 +- .../src/quick_fix_manager_apply_task.cpp | 21 ++++++++++++++----- .../bundlemgrhelper_fuzzer.cpp | 1 - .../include/mock_bundle_manager.h | 6 ------ .../mock/src/mock_bundle_mgr_helper.cpp | 5 ----- .../mock/include/mock_bundle_mgr_helper.h | 1 - .../mock/src/mock_bundle_mgr_helper.cpp | 5 ----- .../mock/src/mock_bundle_mgr_helper.cpp | 5 ----- .../mock/src/mock_bundle_mgr_helper.cpp | 5 ----- .../mock/include/mock_bundle_mgr_helper.h | 1 - .../bundle_mgr_helper_test.cpp | 11 ---------- .../mock/src/mock_quick_fix_util.cpp | 19 ----------------- 17 files changed, 20 insertions(+), 104 deletions(-) diff --git a/frameworks/native/appkit/ability_bundle_manager_helper/bundle_mgr_helper.cpp b/frameworks/native/appkit/ability_bundle_manager_helper/bundle_mgr_helper.cpp index 94c8a8e6dde..ac47fe1f752 100644 --- a/frameworks/native/appkit/ability_bundle_manager_helper/bundle_mgr_helper.cpp +++ b/frameworks/native/appkit/ability_bundle_manager_helper/bundle_mgr_helper.cpp @@ -541,19 +541,6 @@ bool BundleMgrHelper::GetBundleInfos(const BundleFlag flag, std::vectorGetBundleInfos(flag, bundleInfos, userId); } -sptr BundleMgrHelper::GetQuickFixManagerProxy() -{ - TAG_LOGD(AAFwkTag::BUNDLEMGRHELPER, "called"); - auto bundleMgr = Connect(); - if (bundleMgr == nullptr) { - TAG_LOGE(AAFwkTag::BUNDLEMGRHELPER, "null bundleMgr"); - return nullptr; - } - - HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); - return bundleMgr->GetQuickFixManagerProxy(); -} - bool BundleMgrHelper::ProcessPreload(const Want &want) { TAG_LOGD(AAFwkTag::BUNDLEMGRHELPER, "called"); 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 35e8b4d652f..51392fb8977 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 @@ -20,6 +20,7 @@ #include "hitrace_meter.h" #include "if_system_ability_manager.h" #include "iservice_registry.h" +#include "quick_fix/quick_fix_manager_client.h" #include "quick_fix_error_utils.h" #include "quick_fix_load_callback.h" #include "quick_fix_manager_proxy.h" @@ -44,14 +45,9 @@ int32_t QuickFixManagerClient::ApplyQuickFix(const std::vector &qui return QUICK_FIX_CONNECT_FAILED; } - auto bundleQuickFixMgr = QuickFixUtil::GetBundleQuickFixMgrProxy(); - if (bundleQuickFixMgr == nullptr) { - return QUICK_FIX_CONNECT_FAILED; - } - TAG_LOGD(AAFwkTag::QUICKFIX, "hqf file number need to apply: %{public}zu", quickFixFiles.size()); std::vector destFiles; - auto copyRet = bundleQuickFixMgr->CopyFiles(quickFixFiles, destFiles); + auto copyRet = AppExecFwk::QuickFixManagerClient::GetInstance().CopyFiles(quickFixFiles, destFiles); if (copyRet != 0) { TAG_LOGE(AAFwkTag::QUICKFIX, "Copy files failed."); return (copyRet == ERR_BUNDLEMANAGER_QUICK_FIX_PERMISSION_DENIED) ? QUICK_FIX_VERIFY_PERMISSION_FAILED : diff --git a/interfaces/inner_api/quick_fix/src/quick_fix_utils.cpp b/interfaces/inner_api/quick_fix/src/quick_fix_utils.cpp index 97350523727..15d72672613 100644 --- a/interfaces/inner_api/quick_fix/src/quick_fix_utils.cpp +++ b/interfaces/inner_api/quick_fix/src/quick_fix_utils.cpp @@ -45,23 +45,5 @@ sptr QuickFixUtil::GetAppManagerProxy() { return iface_cast(GetRemoteObjectOfSystemAbility(APP_MGR_SERVICE_ID)); } - -sptr QuickFixUtil::GetBundleQuickFixMgrProxy() -{ - TAG_LOGD(AAFwkTag::QUICKFIX, "called"); - auto bundleMgrHelper = DelayedSingleton::GetInstance(); - if (bundleMgrHelper == nullptr) { - TAG_LOGE(AAFwkTag::QUICKFIX, "The bundleMgrHelper is nullptr"); - return nullptr; - } - - auto bundleQuickFixMgr = bundleMgrHelper->GetQuickFixManagerProxy(); - if (bundleQuickFixMgr == nullptr) { - TAG_LOGE(AAFwkTag::QUICKFIX, "The bundleQuickFixMgr is nullptr"); - return nullptr; - } - - return bundleQuickFixMgr; -} } // namespace AAFwk } // namespace OHOS diff --git a/interfaces/kits/native/appkit/ability_bundle_manager_helper/bundle_mgr_helper.h b/interfaces/kits/native/appkit/ability_bundle_manager_helper/bundle_mgr_helper.h index 3862786ed6c..bd558a6430a 100644 --- a/interfaces/kits/native/appkit/ability_bundle_manager_helper/bundle_mgr_helper.h +++ b/interfaces/kits/native/appkit/ability_bundle_manager_helper/bundle_mgr_helper.h @@ -65,7 +65,6 @@ public: bool QueryAbilityInfo(const Want &want, int32_t flags, int32_t userId, AbilityInfo &abilityInfo); bool GetBundleInfos(int32_t flags, std::vector &bundleInfos, int32_t userId = Constants::UNSPECIFIED_USERID); - sptr GetQuickFixManagerProxy(); bool ProcessPreload(const Want &want); sptr GetAppControlProxy(); bool QueryExtensionAbilityInfos(const Want &want, const int32_t &flag, const int32_t &userId, diff --git a/services/quickfixmgr/include/quick_fix_manager_apply_task.h b/services/quickfixmgr/include/quick_fix_manager_apply_task.h index aa3baea1eb0..8ace6a1fbf3 100644 --- a/services/quickfixmgr/include/quick_fix_manager_apply_task.h +++ b/services/quickfixmgr/include/quick_fix_manager_apply_task.h @@ -17,10 +17,10 @@ #define OHOS_ABILITY_RUNTIME_QUICK_FIX_MANAGER_APPLY_TASK_H #include "app_mgr_interface.h" +#include "appexecfwk_core/iquick_fix_manager.h" #include "cJSON.h" #include "event_handler.h" #include "quick_fix_result_info.h" -#include "quick_fix/quick_fix_manager_interface.h" namespace OHOS { namespace AAFwk { diff --git a/services/quickfixmgr/include/quick_fix_manager_service.h b/services/quickfixmgr/include/quick_fix_manager_service.h index 59573e3e997..0553ef3b0bf 100644 --- a/services/quickfixmgr/include/quick_fix_manager_service.h +++ b/services/quickfixmgr/include/quick_fix_manager_service.h @@ -18,9 +18,9 @@ #include +#include "appexecfwk_core/iquick_fix_manager.h" #include "event_runner.h" #include "event_handler.h" -#include "quick_fix/quick_fix_manager_interface.h" #include "quick_fix_manager_apply_task.h" #include "quick_fix_manager_stub.h" diff --git a/services/quickfixmgr/src/quick_fix_manager_apply_task.cpp b/services/quickfixmgr/src/quick_fix_manager_apply_task.cpp index 7c72d1af32e..9d2471ddb96 100644 --- a/services/quickfixmgr/src/quick_fix_manager_apply_task.cpp +++ b/services/quickfixmgr/src/quick_fix_manager_apply_task.cpp @@ -412,7 +412,10 @@ void QuickFixManagerApplyTask::PostDeployQuickFixTask(const std::vectorbundleQfMgr_->DeployQuickFix(quickFixFiles, callback, isDebug, "", isReplace); + int32_t funcResult = -1; + auto ret = applyTask->bundleQfMgr_->DeployQuickFix( + quickFixFiles, callback, isDebug, "", isReplace, funcResult); + ret = (ret == 0) ? funcResult : ret; if (ret != 0) { TAG_LOGE(AAFwkTag::QUICKFIX, "failed: %{public}d", ret); applyTask->NotifyApplyStatus(QUICK_FIX_DEPLOY_FAILED); @@ -451,7 +454,9 @@ void QuickFixManagerApplyTask::PostSwitchQuickFixTask() return; } - auto ret = applyTask->bundleQfMgr_->SwitchQuickFix(applyTask->bundleName_, true, callback); + int32_t funcResult = -1; + auto ret = applyTask->bundleQfMgr_->SwitchQuickFix(applyTask->bundleName_, true, callback, funcResult); + ret = (ret == 0) ? funcResult : ret; if (ret != 0) { TAG_LOGE(AAFwkTag::QUICKFIX, "failed: %{public}d", ret); applyTask->NotifyApplyStatus(QUICK_FIX_SWICH_FAILED); @@ -490,7 +495,9 @@ void QuickFixManagerApplyTask::PostDeleteQuickFixTask() return; } - auto ret = applyTask->bundleQfMgr_->DeleteQuickFix(applyTask->bundleName_, callback); + int32_t funcResult = -1; + auto ret = applyTask->bundleQfMgr_->DeleteQuickFix(applyTask->bundleName_, callback, funcResult); + ret = (ret == 0) ? funcResult : ret; if (ret != 0) { TAG_LOGE(AAFwkTag::QUICKFIX, "delete quick fix failed: %{public}d", ret); applyTask->NotifyApplyStatus(QUICK_FIX_DELETE_FAILED); @@ -912,7 +919,9 @@ void QuickFixManagerApplyTask::PostRevokeQuickFixDeleteTask() } // call delete patch to bms - auto ret = bundleQfMgr_->DeleteQuickFix(bundleName_, callback); + int32_t funcResult = -1; + auto ret = bundleQfMgr_->DeleteQuickFix(bundleName_, callback, funcResult); + ret = (ret == 0) ? funcResult : ret; if (ret != ERR_OK) { TAG_LOGE(AAFwkTag::QUICKFIX, "failed: %{public}d", ret); NotifyApplyStatus(QUICK_FIX_DELETE_FAILED); @@ -939,7 +948,9 @@ void QuickFixManagerApplyTask::HandleRevokeQuickFixAppStop() return; } - auto ret = bundleQfMgr_->SwitchQuickFix(bundleName_, false, callback); + int32_t funcResult = -1; + auto ret = bundleQfMgr_->SwitchQuickFix(bundleName_, false, callback, funcResult); + ret = (ret == 0) ? funcResult : ret; if (ret != ERR_OK) { TAG_LOGE(AAFwkTag::QUICKFIX, "failed: %{public}d", ret); NotifyApplyStatus(QUICK_FIX_SWICH_FAILED); diff --git a/test/fuzztest/bundlemgrhelper_fuzzer/bundlemgrhelper_fuzzer.cpp b/test/fuzztest/bundlemgrhelper_fuzzer/bundlemgrhelper_fuzzer.cpp index a6731b31a39..4a56feee0c4 100755 --- a/test/fuzztest/bundlemgrhelper_fuzzer/bundlemgrhelper_fuzzer.cpp +++ b/test/fuzztest/bundlemgrhelper_fuzzer/bundlemgrhelper_fuzzer.cpp @@ -99,7 +99,6 @@ void BundleMgrHelperFuzztest1(bool boolParam, std::string &stringParam, int32_t std::vector bundleInfos; bmHelper->GetBundleInfos(int32Param, bundleInfos, int32Param); bmHelper->GetBundleInfos(static_cast(int32Param), bundleInfos, int32Param); - bmHelper->GetQuickFixManagerProxy(); bmHelper->ProcessPreload(want); bmHelper->GetAppControlProxy(); bmHelper->QueryExtensionAbilityInfos(want, int32Param, int32Param, extensionInfos); diff --git a/test/mock/services_appmgr_test/include/mock_bundle_manager.h b/test/mock/services_appmgr_test/include/mock_bundle_manager.h index 78c15388e17..c5545123632 100644 --- a/test/mock/services_appmgr_test/include/mock_bundle_manager.h +++ b/test/mock/services_appmgr_test/include/mock_bundle_manager.h @@ -176,12 +176,6 @@ public: MOCK_METHOD2(DeleteQuickFix, ErrCode(const std::string& bundleName, const sptr& statusCallback)); MOCK_METHOD3(CreateFd, ErrCode(const std::string& fileName, int32_t& fd, std::string& path)); - - virtual ErrCode CopyFiles(const std::vector& sourceFiles, std::vector& destFiles) override - { - destFiles = sourceFiles; - return 0; - } }; } // namespace AppExecFwk } // namespace OHOS diff --git a/test/unittest/ability_permission_util_second_test/mock/src/mock_bundle_mgr_helper.cpp b/test/unittest/ability_permission_util_second_test/mock/src/mock_bundle_mgr_helper.cpp index b49f03f696f..e05f9ee6d2f 100755 --- a/test/unittest/ability_permission_util_second_test/mock/src/mock_bundle_mgr_helper.cpp +++ b/test/unittest/ability_permission_util_second_test/mock/src/mock_bundle_mgr_helper.cpp @@ -176,11 +176,6 @@ bool BundleMgrHelper::GetBundleInfos( return false; } -sptr BundleMgrHelper::GetQuickFixManagerProxy() -{ - return nullptr; -} - bool BundleMgrHelper::ProcessPreload(const Want& want) { return false; diff --git a/test/unittest/app_mgr_service_fourth_test/mock/include/mock_bundle_mgr_helper.h b/test/unittest/app_mgr_service_fourth_test/mock/include/mock_bundle_mgr_helper.h index 68693fbcd7d..1b56b245c39 100755 --- a/test/unittest/app_mgr_service_fourth_test/mock/include/mock_bundle_mgr_helper.h +++ b/test/unittest/app_mgr_service_fourth_test/mock/include/mock_bundle_mgr_helper.h @@ -60,7 +60,6 @@ public: bool QueryAbilityInfo(const Want& want, int32_t flags, int32_t userId, AbilityInfo& abilityInfo); bool GetBundleInfos( int32_t flags, std::vector& bundleInfos, int32_t userId = Constants::UNSPECIFIED_USERID); - sptr GetQuickFixManagerProxy(); bool ProcessPreload(const Want& want); sptr GetAppControlProxy(); bool QueryExtensionAbilityInfos(const Want& want, const int32_t& flag, const int32_t& userId, diff --git a/test/unittest/app_mgr_service_inner_eighth_test/mock/src/mock_bundle_mgr_helper.cpp b/test/unittest/app_mgr_service_inner_eighth_test/mock/src/mock_bundle_mgr_helper.cpp index 817574298de..0f4a2e4587c 100755 --- a/test/unittest/app_mgr_service_inner_eighth_test/mock/src/mock_bundle_mgr_helper.cpp +++ b/test/unittest/app_mgr_service_inner_eighth_test/mock/src/mock_bundle_mgr_helper.cpp @@ -171,11 +171,6 @@ bool BundleMgrHelper::GetBundleInfos( return false; } -sptr BundleMgrHelper::GetQuickFixManagerProxy() -{ - return nullptr; -} - bool BundleMgrHelper::ProcessPreload(const Want& want) { return false; diff --git a/test/unittest/app_mgr_service_inner_ninth_test/mock/src/mock_bundle_mgr_helper.cpp b/test/unittest/app_mgr_service_inner_ninth_test/mock/src/mock_bundle_mgr_helper.cpp index 817574298de..0f4a2e4587c 100644 --- a/test/unittest/app_mgr_service_inner_ninth_test/mock/src/mock_bundle_mgr_helper.cpp +++ b/test/unittest/app_mgr_service_inner_ninth_test/mock/src/mock_bundle_mgr_helper.cpp @@ -171,11 +171,6 @@ bool BundleMgrHelper::GetBundleInfos( return false; } -sptr BundleMgrHelper::GetQuickFixManagerProxy() -{ - return nullptr; -} - bool BundleMgrHelper::ProcessPreload(const Want& want) { return false; diff --git a/test/unittest/app_mgr_service_inner_seventh_test/mock/src/mock_bundle_mgr_helper.cpp b/test/unittest/app_mgr_service_inner_seventh_test/mock/src/mock_bundle_mgr_helper.cpp index 88fbfdea14d..b1eff9e9e1a 100755 --- a/test/unittest/app_mgr_service_inner_seventh_test/mock/src/mock_bundle_mgr_helper.cpp +++ b/test/unittest/app_mgr_service_inner_seventh_test/mock/src/mock_bundle_mgr_helper.cpp @@ -170,11 +170,6 @@ bool BundleMgrHelper::GetBundleInfos( return false; } -sptr BundleMgrHelper::GetQuickFixManagerProxy() -{ - return nullptr; -} - bool BundleMgrHelper::ProcessPreload(const Want& want) { return false; diff --git a/test/unittest/app_mgr_service_inner_sixth_test/mock/include/mock_bundle_mgr_helper.h b/test/unittest/app_mgr_service_inner_sixth_test/mock/include/mock_bundle_mgr_helper.h index e6862802f30..0c63ce8414b 100755 --- a/test/unittest/app_mgr_service_inner_sixth_test/mock/include/mock_bundle_mgr_helper.h +++ b/test/unittest/app_mgr_service_inner_sixth_test/mock/include/mock_bundle_mgr_helper.h @@ -62,7 +62,6 @@ public: bool QueryAbilityInfo(const Want& want, int32_t flags, int32_t userId, AbilityInfo& abilityInfo); bool GetBundleInfos( int32_t flags, std::vector& bundleInfos, int32_t userId = Constants::UNSPECIFIED_USERID); - sptr GetQuickFixManagerProxy(); bool ProcessPreload(const Want& want); sptr GetAppControlProxy(); bool QueryExtensionAbilityInfos(const Want& want, const int32_t& flag, const int32_t& userId, diff --git a/test/unittest/bundle_mgr_helper_test/bundle_mgr_helper_test.cpp b/test/unittest/bundle_mgr_helper_test/bundle_mgr_helper_test.cpp index 7624899366b..c1432e2958f 100644 --- a/test/unittest/bundle_mgr_helper_test/bundle_mgr_helper_test.cpp +++ b/test/unittest/bundle_mgr_helper_test/bundle_mgr_helper_test.cpp @@ -279,17 +279,6 @@ HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_RegisterBundleEventCallback_00 EXPECT_EQ(ret, false); } -/** - * @tc.name: BundleMgrHelperTest_GetQuickFixManagerProxy_001 - * @tc.desc: GetQuickFixManagerProxy - * @tc.type: FUNC - */ -HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_GetQuickFixManagerProxy_001, TestSize.Level1) -{ - auto ret = bundleMgrHelper->GetQuickFixManagerProxy(); - EXPECT_NE(ret, nullptr); -} - /** * @tc.name: BundleMgrHelperTest_QueryExtensionAbilityInfos_002 * @tc.desc: QueryExtensionAbilityInfos diff --git a/test/unittest/quick_fix/mock/src/mock_quick_fix_util.cpp b/test/unittest/quick_fix/mock/src/mock_quick_fix_util.cpp index 6d6c4e9bc35..142f48f02a1 100644 --- a/test/unittest/quick_fix/mock/src/mock_quick_fix_util.cpp +++ b/test/unittest/quick_fix/mock/src/mock_quick_fix_util.cpp @@ -60,25 +60,6 @@ sptr QuickFixUtil::GetBundleManagerProxy() return iface_cast(GetRemoteObjectOfSystemAbility(BUNDLE_MGR_SERVICE_SYS_ABILITY_ID)); } -sptr QuickFixUtil::GetBundleQuickFixMgrProxy() -{ - TAG_LOGD(AAFwkTag::TEST, "function called."); - auto bundleMgr = GetBundleManagerProxy(); - if (bundleMgr == nullptr) { - TAG_LOGE(AAFwkTag::TEST, "Failed to get bms."); - return nullptr; - } - - auto bundleQuickFixMgr = bundleMgr->GetQuickFixManagerProxy(); - if (bundleQuickFixMgr == nullptr) { - TAG_LOGE(AAFwkTag::TEST, "Failed to get bundle quick fix manager."); - return nullptr; - } - - TAG_LOGD(AAFwkTag::TEST, "function finished."); - return bundleQuickFixMgr; -} - void QuickFixUtil::RegisterSystemAbility(const int32_t systemAbilityId, sptr object) { std::lock_guard lock(saMutex_); -- Gitee