From bd4bb0b2765a3404ba72fb4e6be0a5b71c38f4f8 Mon Sep 17 00:00:00 2001 From: hanchen45 Date: Tue, 7 Jul 2026 15:17:33 +0800 Subject: [PATCH 01/16] =?UTF-8?q?PC=E6=A8=A1=E5=BC=8F=E5=AF=86=E7=A0=81?= =?UTF-8?q?=E4=BF=9D=E9=99=A9=E7=AE=B1=E7=BB=A7=E6=89=BFPC=E4=BD=93?= =?UTF-8?q?=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Agent Signed-off-by: hanchen45 πŸ€–β€ AI[0%] πŸ‘Œ AI Adopted[0%] πŸ§‘ Human[100%] --- .../inner_api/auto_fill_manager/src/auto_fill_manager.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/interfaces/inner_api/auto_fill_manager/src/auto_fill_manager.cpp b/interfaces/inner_api/auto_fill_manager/src/auto_fill_manager.cpp index 15a48834a7..b941479168 100644 --- a/interfaces/inner_api/auto_fill_manager/src/auto_fill_manager.cpp +++ b/interfaces/inner_api/auto_fill_manager/src/auto_fill_manager.cpp @@ -29,6 +29,8 @@ namespace { const std::string WANT_PARAMS_EXTENSION_TYPE = "autoFill/password"; const std::string WANT_PARAMS_SMART_EXTENSION_TYPE = "autoFill/smart"; const std::string AUTO_FILL_START_POPUP_WINDOW = "persist.sys.abilityms.autofill.is_passwd_popup_window"; +const std::string IS_SUPPORT_PC_MODE = "const.window.support_window_pcmode_switch"; +const std::string IS_PC_MODE = "persist.sceneboard.ispcmode"; constexpr static char WANT_PARAMS_VIEW_DATA_KEY[] = "ohos.ability.params.viewData"; constexpr static char WANT_PARAMS_AUTO_FILL_CMD_KEY[] = "ohos.ability.params.autoFillCmd"; constexpr static char WANT_PARAMS_AUTO_FILL_POPUP_WINDOW_KEY[] = "ohos.ability.params.popupWindow"; @@ -262,6 +264,9 @@ bool AutoFillManager::ConvertAutoFillWindowType(const AutoFill::AutoFillRequest autoFillType == AbilityBase::AutoFillType::NEW_PASSWORD) { if (system::GetBoolParameter(AUTO_FILL_START_POPUP_WINDOW, false)) { autoFillWindowType = AutoFill::AutoFillWindowType::POPUP_WINDOW; + } else if (system::GetParameter(IS_SUPPORT_PC_MODE, "false") == "true" + && system::GetParameter(IS_PC_MODE, "false") == "true") { + autoFillWindowType = AutoFill::AutoFillWindowType::POPUP_WINDOW; } else { autoFillWindowType = AutoFill::AutoFillWindowType::MODAL_WINDOW; } @@ -339,6 +344,9 @@ bool AutoFillManager::IsNeedToCreatePopupWindow(const AbilityBase::AutoFillType autoFillType == AbilityBase::AutoFillType::NEW_PASSWORD) { if (system::GetBoolParameter(AUTO_FILL_START_POPUP_WINDOW, false)) { return true; + } else if (system::GetParameter(IS_SUPPORT_PC_MODE, "false") == "true" + && system::GetParameter(IS_PC_MODE, "false") == "true") { + return true; } else { return false; } From e51ed367714dbabc9282461a71a59d0e9cf93243 Mon Sep 17 00:00:00 2001 From: SKY2001 Date: Fri, 3 Jul 2026 10:22:07 +0800 Subject: [PATCH 02/16] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dappms=E6=A8=A1=E5=9D=97?= =?UTF-8?q?-AI=E6=89=AB=E6=8F=8F=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: SKY2001 --- services/appmgr/src/app_mgr_service.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/services/appmgr/src/app_mgr_service.cpp b/services/appmgr/src/app_mgr_service.cpp index 7de63079a2..21234f2f45 100644 --- a/services/appmgr/src/app_mgr_service.cpp +++ b/services/appmgr/src/app_mgr_service.cpp @@ -192,15 +192,15 @@ ErrCode AppMgrService::Init() if (FAILED(openErr)) { TAG_LOGW(AAFwkTag::APPMGR, "fail, errCode: %{public}08x", openErr); } - if (!Publish(this)) { - TAG_LOGE(AAFwkTag::APPMGR, " publish fail"); - return ERR_APPEXECFWK_SERVICE_NOT_CONNECTED; - } amsMgrScheduler_ = new (std::nothrow) AmsMgrScheduler(appMgrServiceInner_, taskHandler_); if (!amsMgrScheduler_) { TAG_LOGE(AAFwkTag::APPMGR, "init failed"); return ERR_INVALID_OPERATION; } + if (!Publish(this)) { + TAG_LOGE(AAFwkTag::APPMGR, " publish fail"); + return ERR_APPEXECFWK_SERVICE_NOT_CONNECTED; + } TAG_LOGI(AAFwkTag::APPMGR, "init success"); return ERR_OK; } From e8ab6cd752f00c00615bfb5683453d61cb26d63c Mon Sep 17 00:00:00 2001 From: RuiChen_01 Date: Fri, 10 Jul 2026 14:13:14 +0800 Subject: [PATCH 03/16] add tdd MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: RuiChen_01 πŸ€–β€ AI[0%] πŸ‘Œ AI Adopted[0%] πŸ§‘ Human[100%] --- ...bility_manager_client_branch_third_test.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/unittest/ability_manager_client_branch_third_test/ability_manager_client_branch_third_test.cpp b/test/unittest/ability_manager_client_branch_third_test/ability_manager_client_branch_third_test.cpp index a93fa210d5..c7de94dfe7 100644 --- a/test/unittest/ability_manager_client_branch_third_test/ability_manager_client_branch_third_test.cpp +++ b/test/unittest/ability_manager_client_branch_third_test/ability_manager_client_branch_third_test.cpp @@ -1581,6 +1581,24 @@ HWTEST_F(AbilityManagerClientBranchThirdTest, ExecuteInAppSkillWithTokenId_0300, EXPECT_EQ(ret, ERR_CODE_INVALID_ID); } +/** + * @tc.name: NotifySkillFunctionInvoked_0100 + * @tc.desc: Test NotifySkillFunctionInvoked with proxy not connected + * @tc.type: FUNC + */ +HWTEST_F(AbilityManagerClientBranchThirdTest, NotifySkillFunctionInvoked_0100, TestSize.Level1) +{ + client_->proxy_ = nullptr; + EXPECT_CALL(Rosen::SceneBoardJudgement::GetInstance(), MockIsSceneBoardEnabled()) + .WillRepeatedly(testing::Return(false)); + EXPECT_CALL(*mockSystemAbility_, GetSystemAbility(testing::_)).WillRepeatedly(Return(nullptr)); + SystemAbilityManagerClient::GetInstance().systemAbilityManager_ = mockSystemAbility_; + + sptr token = sptr::MakeSptr(); + auto ret = client_->NotifySkillFunctionInvoked(token, "requestCode"); + EXPECT_EQ(ret, ABILITY_SERVICE_NOT_CONNECTED); +} + /** * @tc.name: ExecuteIntentWithResult_0100 * @tc.desc: Test ExecuteIntentWithResult with proxy not connected From bff70a61eee004d55d5d931e3338a094f0edf81e Mon Sep 17 00:00:00 2001 From: hanson027 Date: Mon, 13 Jul 2026 12:02:54 +0800 Subject: [PATCH 04/16] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9EDumpJsHandleMap?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hanson027 --- .../app_lifecycle_deal_test.cpp | 16 +++ .../app_mgr_service_inner_seventh_test.cpp | 21 ++++ .../app_mgr_stub_test/app_mgr_stub_test.cpp | 67 ++++++++++ .../dump_runtime_helper_second_test.cpp | 36 +++++- .../unittest/runtime_test/js_runtime_test.cpp | 118 +++++++++++++++++- 5 files changed, 249 insertions(+), 9 deletions(-) diff --git a/test/unittest/app_lifecycle_deal_test/app_lifecycle_deal_test.cpp b/test/unittest/app_lifecycle_deal_test/app_lifecycle_deal_test.cpp index ad9bce1c4e..81356f03a0 100644 --- a/test/unittest/app_lifecycle_deal_test/app_lifecycle_deal_test.cpp +++ b/test/unittest/app_lifecycle_deal_test/app_lifecycle_deal_test.cpp @@ -360,6 +360,22 @@ HWTEST_F(AppLifecycleDealTest, ScheduleJsHandleMap_001, TestSize.Level1) appLifeCycle->ScheduleJsHandleMap(info); } +/** + * @tc.name: ScheduleJsHandleMap_002 + * @tc.desc: Test ScheduleJsHandleMap when appThread is nullptr + * @tc.type: FUNC + */ +HWTEST_F(AppLifecycleDealTest, ScheduleJsHandleMap_002, TestSize.Level1) +{ + TAG_LOGD(AAFwkTag::TEST, "ScheduleJsHandleMap_002 start."); + auto appLifeCycle = std::make_shared(); + OHOS::AppExecFwk::JsHandleMapInfo info; + info.pid = 1; + appLifeCycle->ScheduleJsHandleMap(info); + EXPECT_EQ(appLifeCycle->GetApplicationClient(), nullptr); + TAG_LOGD(AAFwkTag::TEST, "ScheduleJsHandleMap_002 end."); +} + /** * @tc.name: ScheduleClearPageStack_001 * @tc.desc: Test the normal state of ScheduleClearPageStack diff --git a/test/unittest/app_mgr_service_inner_seventh_test/app_mgr_service_inner_seventh_test.cpp b/test/unittest/app_mgr_service_inner_seventh_test/app_mgr_service_inner_seventh_test.cpp index 58776068b6..e3741ce2f7 100644 --- a/test/unittest/app_mgr_service_inner_seventh_test/app_mgr_service_inner_seventh_test.cpp +++ b/test/unittest/app_mgr_service_inner_seventh_test/app_mgr_service_inner_seventh_test.cpp @@ -974,6 +974,27 @@ HWTEST_F(AppMgrServiceInnerSeventhTest, DumpJsHandleMap_001, TestSize.Level1) TAG_LOGI(AAFwkTag::TEST, "DumpJsHandleMap_001 end"); } +/** +* @tc.name: DumpJsHandleMap_002 +* @tc.desc: test DumpJsHandleMap when caller is not SA +* @tc.type: FUNC +*/ +HWTEST_F(AppMgrServiceInnerSeventhTest, DumpJsHandleMap_002, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "DumpJsHandleMap_002 start"); + auto appMgrServiceInner = std::make_shared(); + bool originalIsSACall = AAFwk::MyStatus::GetInstance().isSACall_; + AAFwk::MyStatus::GetInstance().isSACall_ = false; + + OHOS::AppExecFwk::JsHandleMapInfo info; + info.pid = 1; + int32_t ret = appMgrServiceInner->DumpJsHandleMap(info); + EXPECT_EQ(ret, ERR_INVALID_VALUE); + + AAFwk::MyStatus::GetInstance().isSACall_ = originalIsSACall; + TAG_LOGI(AAFwkTag::TEST, "DumpJsHandleMap_002 end"); +} + /** * @tc.name: GetRunningProcesses_001 * @tc.desc: test GetRunningProcesses_001 diff --git a/test/unittest/app_mgr_stub_test/app_mgr_stub_test.cpp b/test/unittest/app_mgr_stub_test/app_mgr_stub_test.cpp index 3c30a75677..3c33359f04 100644 --- a/test/unittest/app_mgr_stub_test/app_mgr_stub_test.cpp +++ b/test/unittest/app_mgr_stub_test/app_mgr_stub_test.cpp @@ -1613,6 +1613,73 @@ HWTEST_F(AppMgrStubTest, HandleDumpJsHandleMap_001, TestSize.Level1) TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); } +/** + * @tc.name: HandleDumpJsHandleMap_002 + * @tc.desc: Handle dump js handle map with null parcelable. + * @tc.type: FUNC + */ +HWTEST_F(AppMgrStubTest, HandleDumpJsHandleMap_002, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); + MessageParcel data; + MessageParcel reply; + MessageOption option; + WriteInterfaceToken(data); + + EXPECT_CALL(*mockAppMgrService_, DumpJsHandleMap(_)).Times(0); + auto result = mockAppMgrService_->OnRemoteRequest( + static_cast(AppMgrInterfaceCode::DUMP_JSHANDLE_MAP_PROCESS), data, reply, option); + EXPECT_EQ(result, ERR_INVALID_VALUE); + + TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); +} + +/** + * @tc.name: JsHandleMapInfo_Marshalling_001 + * @tc.desc: Test JsHandleMapInfo Marshalling and Unmarshalling. + * @tc.type: FUNC + */ +HWTEST_F(AppMgrStubTest, JsHandleMapInfo_Marshalling_001, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); + JsHandleMapInfo info; + info.pid = 100; + info.tid = 200; + + MessageParcel parcel; + EXPECT_TRUE(info.Marshalling(parcel)); + + auto *readInfo = JsHandleMapInfo::Unmarshalling(parcel); + ASSERT_NE(readInfo, nullptr); + EXPECT_EQ(readInfo->pid, 100); + EXPECT_EQ(readInfo->tid, 200); + delete readInfo; + + TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); +} + +/** + * @tc.name: JsHandleMapInfo_Marshalling_002 + * @tc.desc: Test JsHandleMapInfo Marshalling and Unmarshalling with default values. + * @tc.type: FUNC + */ +HWTEST_F(AppMgrStubTest, JsHandleMapInfo_Marshalling_002, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); + JsHandleMapInfo info; + + MessageParcel parcel; + EXPECT_TRUE(info.Marshalling(parcel)); + + auto *readInfo = JsHandleMapInfo::Unmarshalling(parcel); + ASSERT_NE(readInfo, nullptr); + EXPECT_EQ(readInfo->pid, 0); + EXPECT_EQ(readInfo->tid, 0); + delete readInfo; + + TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); +} + /** * @tc.name: HandleReportDumpMemResult_001 * @tc.desc: Handle report dump mem result with valid callback. diff --git a/test/unittest/frameworks_kits_appkit_native_test/dump_runtime_helper_second_test.cpp b/test/unittest/frameworks_kits_appkit_native_test/dump_runtime_helper_second_test.cpp index c77fc72300..e01989216e 100644 --- a/test/unittest/frameworks_kits_appkit_native_test/dump_runtime_helper_second_test.cpp +++ b/test/unittest/frameworks_kits_appkit_native_test/dump_runtime_helper_second_test.cpp @@ -137,40 +137,66 @@ HWTEST_F(DumpRuntimeHelperTestSecond, DumpJsHeap_0400, TestSize.Level1) /** * @tc.number: DumpJsHandleMap_0100 * @tc.name: DumpJsHandleMap - * @tc.desc: Test whether DumpJsHandleMap and are called normally. + * @tc.desc: Test DumpJsHandleMap when application_ is nullptr (early return path). */ HWTEST_F(DumpRuntimeHelperTestSecond, DumpJsHandleMap_0100, TestSize.Level1) { std::shared_ptr application = nullptr; auto helper = std::make_shared(application); + EXPECT_EQ(helper->application_, nullptr); OHOS::AppExecFwk::JsHandleMapInfo info; info.tid = 1; helper->DumpJsHandleMap(info); - EXPECT_EQ(application, nullptr); + EXPECT_EQ(helper->application_, nullptr); } /** * @tc.number: DumpJsHandleMap_0200 * @tc.name: DumpJsHandleMap - * @tc.desc: Test whether DumpJsHandleMap and are called normally. + * @tc.desc: Test DumpJsHandleMap with null runtime then with JS runtime. */ HWTEST_F(DumpRuntimeHelperTestSecond, DumpJsHandleMap_0200, TestSize.Level1) { std::shared_ptr application = std::shared_ptr( ApplicationLoader::GetInstance().GetApplicationByName()); + ASSERT_NE(application, nullptr); std::shared_ptr appInfo = std::make_shared(); auto helper = std::make_shared(application, appInfo); + EXPECT_EQ(application->GetRuntime(), nullptr); OHOS::AppExecFwk::JsHandleMapInfo info; info.tid = 1; helper->DumpJsHandleMap(info); - EXPECT_NE(application, nullptr); AbilityRuntime::Runtime::Options options; + options.lang = AbilityRuntime::Runtime::Language::JS; auto runtime = AbilityRuntime::Runtime::Create(options); application->SetRuntime(std::move(runtime)); + ASSERT_NE(application->GetRuntime(), nullptr); + EXPECT_EQ(application->GetRuntime()->GetLanguage(), AbilityRuntime::Runtime::Language::JS); helper = std::make_shared(application); helper->DumpJsHandleMap(info); - EXPECT_NE(application, nullptr); +} + +/** + * @tc.number: DumpJsHandleMap_0300 + * @tc.name: DumpJsHandleMap + * @tc.desc: Test DumpJsHandleMap when runtime language is not JS or ETS. + */ +HWTEST_F(DumpRuntimeHelperTestSecond, DumpJsHandleMap_0300, TestSize.Level1) +{ + std::shared_ptr application = std::shared_ptr( + ApplicationLoader::GetInstance().GetApplicationByName()); + ASSERT_NE(application, nullptr); + AbilityRuntime::Runtime::Options options; + options.lang = AbilityRuntime::Runtime::Language::UNKNOWN; + auto runtime = AbilityRuntime::Runtime::Create(options); + application->SetRuntime(std::move(runtime)); + ASSERT_NE(application->GetRuntime(), nullptr); + EXPECT_EQ(application->GetRuntime()->GetLanguage(), AbilityRuntime::Runtime::Language::UNKNOWN); + auto helper = std::make_shared(application); + OHOS::AppExecFwk::JsHandleMapInfo info; + info.tid = 1; + helper->DumpJsHandleMap(info); } /** diff --git a/test/unittest/runtime_test/js_runtime_test.cpp b/test/unittest/runtime_test/js_runtime_test.cpp index f6b18d7303..5883f9315e 100755 --- a/test/unittest/runtime_test/js_runtime_test.cpp +++ b/test/unittest/runtime_test/js_runtime_test.cpp @@ -280,16 +280,126 @@ HWTEST_F(JsRuntimeTest, JsRuntimeDumpHeapSnapshotTest_0100, TestSize.Level2) /** * @tc.name: JsRuntimeDumpJsHandleMapTest_0100 - * @tc.desc: JsRuntime test for JsRuntimeDumpJsHandleMap. + * @tc.desc: JsRuntime test for DumpJsHandleMap with default-constructed runtime (no jsEnv_). * @tc.type: FUNC */ HWTEST_F(JsRuntimeTest, JsRuntimeDumpJsHandleMapTest_0100, TestSize.Level2) { - TAG_LOGI(AAFwkTag::TEST, "DumpJsHandleMap start"); + TAG_LOGI(AAFwkTag::TEST, "DumpJsHandleMap_0100 start"); std::unique_ptr jsRuntime = std::make_unique(); + ASSERT_NE(jsRuntime, nullptr); + EXPECT_EQ(jsRuntime->GetEcmaVm(), nullptr); jsRuntime->DumpJsHandleMap(); - EXPECT_TRUE(jsRuntime != nullptr); - TAG_LOGI(AAFwkTag::TEST, "DumpJsHandleMap end"); + EXPECT_EQ(jsRuntime->GetEcmaVm(), nullptr); + TAG_LOGI(AAFwkTag::TEST, "DumpJsHandleMap_0100 end"); +} + +/** + * @tc.name: JsRuntimeDumpJsHandleMapTest_0200 + * @tc.desc: JsRuntime test for DumpJsHandleMap when jsEnv_ is nullptr. + * @tc.type: FUNC + */ +HWTEST_F(JsRuntimeTest, JsRuntimeDumpJsHandleMapTest_0200, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "DumpJsHandleMap_0200 start"); + auto jsRuntime = std::make_unique(); + ASSERT_NE(jsRuntime, nullptr); + jsRuntime->jsEnv_ = nullptr; + EXPECT_EQ(jsRuntime->GetEcmaVm(), nullptr); + jsRuntime->DumpJsHandleMap(); + EXPECT_EQ(jsRuntime->GetEcmaVm(), nullptr); + jsRuntime.reset(); + std::this_thread::sleep_for(std::chrono::milliseconds(200)); + TAG_LOGI(AAFwkTag::TEST, "DumpJsHandleMap_0200 end"); +} + +/** + * @tc.name: JsRuntimeDumpJsHandleMapTest_0300 + * @tc.desc: JsRuntime test for DumpJsHandleMap when jsEnv_ exists but vm_ is nullptr. + * @tc.type: FUNC + */ +HWTEST_F(JsRuntimeTest, JsRuntimeDumpJsHandleMapTest_0300, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "DumpJsHandleMap_0300 start"); + auto jsRuntime = std::make_unique(); + ASSERT_NE(jsRuntime, nullptr); + jsRuntime->jsEnv_ = std::make_shared(); + jsRuntime->jsEnv_->vm_ = nullptr; + EXPECT_EQ(jsRuntime->GetEcmaVm(), nullptr); + jsRuntime->DumpJsHandleMap(); + EXPECT_EQ(jsRuntime->GetEcmaVm(), nullptr); + jsRuntime.reset(); + std::this_thread::sleep_for(std::chrono::milliseconds(200)); + TAG_LOGI(AAFwkTag::TEST, "DumpJsHandleMap_0300 end"); +} + +/** + * @tc.name: JsRuntimeDumpJsHandleMapTest_0400 + * @tc.desc: JsRuntime test for DumpJsHandleMap with valid VM. + * @tc.type: FUNC + */ +HWTEST_F(JsRuntimeTest, JsRuntimeDumpJsHandleMapTest_0400, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "DumpJsHandleMap_0400 start"); + auto jsRuntime = std::make_unique(); + ASSERT_NE(jsRuntime, nullptr); + jsRuntime->jsEnv_ = std::make_shared(); + panda::RuntimeOption pandaOption; + jsRuntime->jsEnv_->vm_ = panda::JSNApi::CreateJSVM(pandaOption); + ASSERT_NE(jsRuntime->jsEnv_->vm_, nullptr); + EXPECT_NE(jsRuntime->GetEcmaVm(), nullptr); + jsRuntime->DumpJsHandleMap(); + EXPECT_NE(jsRuntime->GetEcmaVm(), nullptr); + panda::JSNApi::DestroyJSVM(jsRuntime->jsEnv_->vm_); + jsRuntime->jsEnv_->vm_ = nullptr; + jsRuntime.reset(); + std::this_thread::sleep_for(std::chrono::milliseconds(200)); + TAG_LOGI(AAFwkTag::TEST, "DumpJsHandleMap_0400 end"); +} + +/** + * @tc.name: JsRuntimeDumpJsHandleMapTest_0500 + * @tc.desc: JsRuntime test for DumpJsHandleMap called through Runtime base class pointer. + * @tc.type: FUNC + */ +HWTEST_F(JsRuntimeTest, JsRuntimeDumpJsHandleMapTest_0500, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "DumpJsHandleMap_0500 start"); + std::unique_ptr runtime = std::make_unique(); + ASSERT_NE(runtime, nullptr); + auto* jsRuntime = static_cast(runtime.get()); + EXPECT_EQ(jsRuntime->GetEcmaVm(), nullptr); + runtime->DumpJsHandleMap(); + EXPECT_EQ(jsRuntime->GetEcmaVm(), nullptr); + runtime.reset(); + std::this_thread::sleep_for(std::chrono::milliseconds(200)); + TAG_LOGI(AAFwkTag::TEST, "DumpJsHandleMap_0500 end"); +} + +/** + * @tc.name: JsRuntimeDumpJsHandleMapTest_0600 + * @tc.desc: JsRuntime test for DumpJsHandleMap with JsRuntime created by Create(). + * @tc.type: FUNC + */ +HWTEST_F(JsRuntimeTest, JsRuntimeDumpJsHandleMapTest_0600, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "DumpJsHandleMap_0600 start"); + Runtime::Options options; + options.bundleName = TEST_BUNDLE_NAME; + options.codePath = TEST_CODE_PATH; + options.loadAce = false; + options.isBundle = true; + options.preload = false; + std::shared_ptr eventRunner = AppExecFwk::EventRunner::Create(TEST_ABILITY_NAME); + options.eventRunner = eventRunner; + auto jsRuntime = JsRuntime::Create(options); + ASSERT_NE(jsRuntime, nullptr); + EXPECT_NE(jsRuntime->GetEcmaVm(), nullptr); + jsRuntime->DumpJsHandleMap(); + EXPECT_NE(jsRuntime->GetEcmaVm(), nullptr); + jsRuntime.reset(); + std::this_thread::sleep_for(std::chrono::milliseconds(200)); + TAG_LOGI(AAFwkTag::TEST, "DumpJsHandleMap_0600 end"); } /** From c33f5dd5492517e39a6c74ba26eb3b3a52d12db3 Mon Sep 17 00:00:00 2001 From: z00797421 Date: Mon, 13 Jul 2026 16:32:31 +0800 Subject: [PATCH 05/16] taskmgr sainterceptor adapter Change-Id: I3ae4da16afa23e89fed9057f0ecb5f7c2622b965 Signed-off-by: z00797421 --- .../include/ability_manager_client.h | 2 ++ .../include/ability_manager_errors.h | 5 +++ .../include/ability_manager_interface.h | 5 +++ .../ability_manager_ipc_interface_code.h | 3 ++ .../inner_api/ability_manager/include/rule.h | 3 +- .../include/ability_manager_proxy.h | 2 ++ .../include/ability_manager_service.h | 2 ++ .../abilitymgr/include/ability_manager_stub.h | 1 + .../include/sa_interceptor_manager.h | 1 + .../abilitymgr/src/ability_manager_client.cpp | 8 +++++ .../abilitymgr/src/ability_manager_proxy.cpp | 29 +++++++++++++++++ .../src/ability_manager_service.cpp | 31 ++++++++++++++++--- .../abilitymgr/src/ability_manager_stub.cpp | 19 ++++++++++++ .../abilitymgr/src/sa_interceptor_manager.cpp | 23 ++++++++++++++ 14 files changed, 129 insertions(+), 5 deletions(-) diff --git a/interfaces/inner_api/ability_manager/include/ability_manager_client.h b/interfaces/inner_api/ability_manager/include/ability_manager_client.h index 5d44e1f188..ba50dbb0f1 100644 --- a/interfaces/inner_api/ability_manager/include/ability_manager_client.h +++ b/interfaces/inner_api/ability_manager/include/ability_manager_client.h @@ -2161,6 +2161,8 @@ public: */ ErrCode RegisterSAInterceptor(sptr interceptor); + ErrCode UnregisterSAInterceptor(sptr interceptor); + /** * SuspendExtensionAbility, suspend session with service ability. * diff --git a/interfaces/inner_api/ability_manager/include/ability_manager_errors.h b/interfaces/inner_api/ability_manager/include/ability_manager_errors.h index 2e05f953ae..deda9965c6 100644 --- a/interfaces/inner_api/ability_manager/include/ability_manager_errors.h +++ b/interfaces/inner_api/ability_manager/include/ability_manager_errors.h @@ -1017,6 +1017,11 @@ enum { */ ERR_INVALID_FD = 2097403, + /** + * Result (2097404) for all apps are blocked from starting due to deep frozen . + */ + ERR_LOW_MEM_SAINTERCEPTOR_START_BLOCK = 2097404, + /** * Result (2098000-2098049) Error code refinement INVALID_VALUE. */ diff --git a/interfaces/inner_api/ability_manager/include/ability_manager_interface.h b/interfaces/inner_api/ability_manager/include/ability_manager_interface.h index 304cc22ad3..47c5df4035 100644 --- a/interfaces/inner_api/ability_manager/include/ability_manager_interface.h +++ b/interfaces/inner_api/ability_manager/include/ability_manager_interface.h @@ -2682,6 +2682,11 @@ public: return 0; } + virtual int32_t UnregisterSAInterceptor(sptr interceptor) + { + return 0; + } + virtual int32_t SetOnNewWantSkipScenarios(sptr callerToken, int32_t scenarios) { return 0; diff --git a/interfaces/inner_api/ability_manager/include/ability_manager_ipc_interface_code.h b/interfaces/inner_api/ability_manager/include/ability_manager_ipc_interface_code.h index 983d575d65..ba7c56de30 100644 --- a/interfaces/inner_api/ability_manager/include/ability_manager_ipc_interface_code.h +++ b/interfaces/inner_api/ability_manager/include/ability_manager_ipc_interface_code.h @@ -779,6 +779,9 @@ enum class AbilityManagerInterfaceCode { // notify JS function was successfully invoked by napi_call_function NOTIFY_SKILL_FUNCTION_INVOKED = 6177, + + // unregister sa interceptor + UNREGISTER_SA_INTERCEPTOR = 6178, }; } // namespace AAFwk } // namespace OHOS diff --git a/interfaces/inner_api/ability_manager/include/rule.h b/interfaces/inner_api/ability_manager/include/rule.h index 6034523184..44ed1051d9 100644 --- a/interfaces/inner_api/ability_manager/include/rule.h +++ b/interfaces/inner_api/ability_manager/include/rule.h @@ -25,7 +25,8 @@ namespace AbilityRuntime { enum class RuleType { ALLOW = 0, NOT_ALLOW, - USER_SELECTION + USER_SELECTION, + NOT_ALLOW_FROZEN }; /** diff --git a/services/abilitymgr/include/ability_manager_proxy.h b/services/abilitymgr/include/ability_manager_proxy.h index 84fe52c8be..592dbe4aac 100644 --- a/services/abilitymgr/include/ability_manager_proxy.h +++ b/services/abilitymgr/include/ability_manager_proxy.h @@ -2047,6 +2047,8 @@ public: */ virtual ErrCode RegisterSAInterceptor(sptr interceptor) override; + virtual ErrCode UnregisterSAInterceptor(sptr interceptor) override; + /** * SuspendExtensionAbility, suspend session with service ability. * diff --git a/services/abilitymgr/include/ability_manager_service.h b/services/abilitymgr/include/ability_manager_service.h index be770b011b..49f362b9e1 100644 --- a/services/abilitymgr/include/ability_manager_service.h +++ b/services/abilitymgr/include/ability_manager_service.h @@ -2670,6 +2670,8 @@ public: */ virtual int32_t RegisterSAInterceptor(sptr interceptor) override; + virtual int32_t UnregisterSAInterceptor(sptr interceptor) override; + virtual int32_t NotifyStartupExceptionBySCB(int32_t requestId) override; /** diff --git a/services/abilitymgr/include/ability_manager_stub.h b/services/abilitymgr/include/ability_manager_stub.h index 83ac0e14c4..3079784416 100644 --- a/services/abilitymgr/include/ability_manager_stub.h +++ b/services/abilitymgr/include/ability_manager_stub.h @@ -371,6 +371,7 @@ private: int32_t StartUIAbilityWithCallbackInner(MessageParcel &data, MessageParcel &reply); int32_t RestartSelfAtomicServiceInner(MessageParcel &data, MessageParcel &reply); int32_t RegisterSAInterceptorInner(MessageParcel &data, MessageParcel &reply); + int32_t UnregisterSAInterceptorInner(MessageParcel &data, MessageParcel &reply); int32_t SuspendExtensionAbilityInner(MessageParcel &data, MessageParcel &reply); int32_t ResumeExtensionAbilityInner(MessageParcel &data, MessageParcel &reply); int32_t SetOnNewWantSkipScenariosInner(MessageParcel &data, MessageParcel &reply); diff --git a/services/abilitymgr/include/sa_interceptor_manager.h b/services/abilitymgr/include/sa_interceptor_manager.h index 43621d741d..a15c0d37ce 100644 --- a/services/abilitymgr/include/sa_interceptor_manager.h +++ b/services/abilitymgr/include/sa_interceptor_manager.h @@ -33,6 +33,7 @@ public: static SAInterceptorManager &GetInstance(); int32_t AddSAInterceptor(sptr interceptor); + int32_t RemoveSAInterceptor(sptr interceptor); int32_t ExecuteSAInterceptor(const std::string ¶ms, Rule &rule); void OnObserverDied(const wptr &remote); diff --git a/services/abilitymgr/src/ability_manager_client.cpp b/services/abilitymgr/src/ability_manager_client.cpp index 808d8df111..2a8d296f08 100644 --- a/services/abilitymgr/src/ability_manager_client.cpp +++ b/services/abilitymgr/src/ability_manager_client.cpp @@ -2666,6 +2666,14 @@ ErrCode AbilityManagerClient::RegisterSAInterceptor(sptrRegisterSAInterceptor(interceptor); } +ErrCode AbilityManagerClient::UnregisterSAInterceptor(sptr interceptor) +{ + TAG_LOGD(AAFwkTag::ABILITYMGR, "call UnregisterSAInterceptor"); + auto abms = GetAbilityManager(); + CHECK_POINTER_RETURN_NOT_CONNECTED(abms); + return abms->UnregisterSAInterceptor(interceptor); +} + ErrCode AbilityManagerClient::SuspendExtensionAbility(sptr connect) { HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); diff --git a/services/abilitymgr/src/ability_manager_proxy.cpp b/services/abilitymgr/src/ability_manager_proxy.cpp index 53c3831e7c..fd13698ddc 100644 --- a/services/abilitymgr/src/ability_manager_proxy.cpp +++ b/services/abilitymgr/src/ability_manager_proxy.cpp @@ -7848,6 +7848,35 @@ ErrCode AbilityManagerProxy::RegisterSAInterceptor(sptr interceptor) +{ + TAG_LOGD(AAFwkTag::ABILITYMGR, "call UnregisterSAInterceptor"); + if (!interceptor) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "interceptor null"); + return ERR_NULL_SA_INTERCEPTOR_EXECUTER; + } + + MessageParcel data; + MessageParcel reply; + MessageOption option; + + if (!WriteInterfaceToken(data)) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "writeInterfaceToken failed"); + return ERR_WRITE_INTERFACE_TOKEN_FAILED; + } + if (!data.WriteRemoteObject(interceptor)) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "interceptor write failed."); + return ERR_WRITE_SA_INTERCEPTOR_FAILED; + } + + auto error = SendRequest(AbilityManagerInterfaceCode::UNREGISTER_SA_INTERCEPTOR, data, reply, option); + if (error != NO_ERROR) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "Send request error: %{public}d", error); + return error; + } + return reply.ReadInt32(); +} + int32_t AbilityManagerProxy::QueryKeepAliveAppServiceExtensions(std::vector &list) { MessageParcel data; diff --git a/services/abilitymgr/src/ability_manager_service.cpp b/services/abilitymgr/src/ability_manager_service.cpp index 7ee1781d15..c2daa32416 100644 --- a/services/abilitymgr/src/ability_manager_service.cpp +++ b/services/abilitymgr/src/ability_manager_service.cpp @@ -216,6 +216,7 @@ constexpr int32_t APP_ALIVE_TIME_MS = 1000; // Allow background startup within constexpr int32_t REGISTER_FOCUS_DELAY = 5000; constexpr size_t OFFSET = 32; constexpr int32_t PENG_LAI_UID = 7655; +constexpr int32_t TASKMGR_UID = 7005; constexpr int32_t RSS_UID = 1096; constexpr const char* IS_DELEGATOR_CALL = "isDelegatorCall"; @@ -3345,6 +3346,9 @@ int AbilityManagerService::StartUIAbilityBySCBDefault(sptr sessionI sessionInfo->want.RemoveParam(AbilityRuntime::GlobalConstant::SANDBOX_CLONE_INDEX); sessionInfo->want.RemoveParam(AbilityRuntime::GlobalConstant::CLI_CALLER_BUNDLE_NAME); sessionInfo->want.RemoveParam(AbilityRuntime::GlobalConstant::CLI_CALLER_TOKEN_ID); + if (!HandleExecuteSAInterceptor(sessionInfo->want, sessionInfo->callerToken, abilityRequest, result)) { + return result; + } if (sessionInfo->want.GetBoolParam(ServerConstant::IS_CALL_BY_SCB, true)) { TAG_LOGD(AAFwkTag::ABILITYMGR, "interceptorExecuter_ called"); (sessionInfo->want).RemoveParam(IS_CALLING_FROM_DMS); @@ -3360,9 +3364,6 @@ int AbilityManagerService::StartUIAbilityBySCBDefault(sptr sessionI } abilityRequest.userId = currentUserId; abilityRequest.sessionInfo = sessionInfo; - if (!HandleExecuteSAInterceptor(sessionInfo->want, sessionInfo->callerToken, abilityRequest, result)) { - return result; - } } if (sessionInfo->want.GetBoolParam(ServerConstant::IS_CALL_BY_SCB, true)) { if (sessionInfo->startSetting != nullptr) { @@ -18433,7 +18434,7 @@ std::shared_ptr AbilityManagerService::GetAbilityInt int32_t AbilityManagerService::RegisterSAInterceptor(sptr interceptor) { TAG_LOGI(AAFwkTag::ABILITYMGR, "call RegisterSaInterceptor, callingPid:%{public}d", IPCSkeleton::GetCallingPid()); - if (IPCSkeleton::GetCallingUid() != PENG_LAI_UID) { + if (IPCSkeleton::GetCallingUid() != PENG_LAI_UID && IPCSkeleton::GetCallingUid() != TASKMGR_UID) { TAG_LOGE(AAFwkTag::ABILITYMGR, "no permission call"); return CHECK_PERMISSION_FAILED; } @@ -18441,6 +18442,22 @@ int32_t AbilityManagerService::RegisterSAInterceptor(sptr interceptor) +{ + TAG_LOGI(AAFwkTag::ABILITYMGR, "call UnregisterSaInterceptor"); + if (IPCSkeleton::GetCallingUid() != TASKMGR_UID) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "no permission call"); + return CHECK_PERMISSION_FAILED; + } + + auto ISAInterceptor = iface_cast(interceptor); + if (ISAInterceptor == nullptr) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "ISAInterceptor cast failed"); + return ERR_NULL_SA_INTERCEPTOR_EXECUTER; + } + return SAInterceptorManager::GetInstance().RemoveSAInterceptor(ISAInterceptor); +} + bool AbilityManagerService::HandleExecuteSAInterceptor(const Want &want, sptr callerToken, AbilityRequest &abilityRequest, int32_t &result) { @@ -18459,6 +18476,12 @@ bool AbilityManagerService::HandleExecuteSAInterceptor(const Want &want, sptr(ERR_LOW_MEM_SAINTERCEPTOR_START_BLOCK); + return false; + } + if (rule.type == RuleType::USER_SELECTION) { TAG_LOGW(AAFwkTag::ABILITYMGR, "sa interceptor OnCheckStarting failed, set dialog caller info"); DialogSessionManager::GetInstance().OnlySetDialogCallerInfo(abilityRequest, abilityRequest.userId, diff --git a/services/abilitymgr/src/ability_manager_stub.cpp b/services/abilitymgr/src/ability_manager_stub.cpp index 3aaa13f018..65db1b7d38 100644 --- a/services/abilitymgr/src/ability_manager_stub.cpp +++ b/services/abilitymgr/src/ability_manager_stub.cpp @@ -357,6 +357,9 @@ int AbilityManagerStub::OnRemoteRequestInnerSeventh(uint32_t code, MessageParcel if (interfaceCode == AbilityManagerInterfaceCode::START_SELF_UI_ABILITY_IN_CHILD_PROCESS) { return StartSelfUIAbilityInChildProcessInner(data, reply); } + if (interfaceCode == AbilityManagerInterfaceCode::UNREGISTER_SA_INTERCEPTOR) { + return UnregisterSAInterceptorInner(data, reply); + } return ERR_CODE_NOT_EXIST; } @@ -5541,6 +5544,22 @@ int32_t AbilityManagerStub::RegisterSAInterceptorInner(MessageParcel &data, Mess return NO_ERROR; } +int32_t AbilityManagerStub::UnregisterSAInterceptorInner(MessageParcel &data, MessageParcel &reply) +{ + TAG_LOGI(AAFwkTag::ABILITYMGR, "call UnregisterSaInterceptorInner"); + sptr interceptor = data.ReadRemoteObject(); + if (interceptor == nullptr) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "interceptor is null."); + return ERR_NULL_SA_INTERCEPTOR_EXECUTER; + } + int32_t result = UnregisterSAInterceptor(interceptor); + if (!reply.WriteInt32(result)) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "Fail to write result."); + return ERR_WRITE_RESULT_CODE_FAILED; + } + return NO_ERROR; +} + int AbilityManagerStub::SetAppServiceExtensionKeepAliveInner(MessageParcel &data, MessageParcel &reply) { HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); diff --git a/services/abilitymgr/src/sa_interceptor_manager.cpp b/services/abilitymgr/src/sa_interceptor_manager.cpp index 4c0af34a49..a0913e0f57 100644 --- a/services/abilitymgr/src/sa_interceptor_manager.cpp +++ b/services/abilitymgr/src/sa_interceptor_manager.cpp @@ -68,6 +68,29 @@ int32_t SAInterceptorManager::AddSAInterceptor(sptr interceptor) return ERR_OK; } +int32_t SAInterceptorManager::RemoveSAInterceptor(sptr interceptor) +{ + if (interceptor == nullptr) { + TAG_LOGE(AAFwkTag::SA_INTERCEPTOR, "null interceptor"); + return AAFwk::ERR_NULL_SA_INTERCEPTOR_EXECUTER; + } + + auto observerObj = interceptor->AsObject(); + std::lock_guard lock(saInterceptorLock_); + for (auto interceptorIter = saInterceptors_.begin(); interceptorIter != saInterceptors_.end(); interceptorIter++) { + if (*interceptorIter && (*interceptorIter)->AsObject() == observerObj) { + if (observerObj && deathRecipient_) { + observerObj->RemoveDeathRecipient(deathRecipient_); + } + saInterceptors_.erase(interceptorIter); + TAG_LOGI(AAFwkTag::ABILITYMGR, "interceptor removed"); + return ERR_OK; + } + } + TAG_LOGW(AAFwkTag::ABILITYMGR, "interceptor not found"); + return ERR_OK; +} + bool SAInterceptorManager::SAInterceptorListIsEmpty() { std::lock_guard lock(saInterceptorLock_); From 1fe6f88ef62cb022240cc940a17f58394bf50c60 Mon Sep 17 00:00:00 2001 From: liuzongze Date: Mon, 13 Jul 2026 19:17:51 +0800 Subject: [PATCH 06/16] =?UTF-8?q?=E5=91=8A=E8=AD=A6=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Agent Signed-off-by: liuzongze πŸ€– AI[100%] πŸ”§ Human Fixed[0%] πŸ§‘ Human[0%] πŸ‘Œ AI Adopted[100%] Co-authored-by: opencode (glm-5.2) Change-Id: Icd267c47c6071b35ae50e0f818e4f64e534318dd --- .../mock/configuration/configuration.h | 2 +- .../configuration_test/configuration_test.cpp | 189 ++++++++++++++++++ 2 files changed, 190 insertions(+), 1 deletion(-) diff --git a/test/new_test/mock/configuration/configuration.h b/test/new_test/mock/configuration/configuration.h index 4d4b85d092..78674cfa46 100644 --- a/test/new_test/mock/configuration/configuration.h +++ b/test/new_test/mock/configuration/configuration.h @@ -28,7 +28,7 @@ class Configuration final: public Parcelable { public: Configuration(); - void CompareDifferent(std::vector &diffKeyV, const Configuration &other) {} + void CompareDifferent(std::vector &diffKeyV, const Configuration &other) const {} void Merge(const std::vector &diffKeyV, const Configuration &other) {} diff --git a/test/unittest/configuration_test/configuration_test.cpp b/test/unittest/configuration_test/configuration_test.cpp index 863db3771b..8ee6caaae1 100644 --- a/test/unittest/configuration_test/configuration_test.cpp +++ b/test/unittest/configuration_test/configuration_test.cpp @@ -331,6 +331,7 @@ HWTEST_F(ConfigurationTest, CompareDifferent_001, TestSize.Level1) std::vector changeKeyV; config.CompareDifferent(changeKeyV, config2); + EXPECT_EQ(config.GetItemSize(), 1); int size = changeKeyV.size(); EXPECT_EQ(size, 1); } @@ -359,6 +360,7 @@ HWTEST_F(ConfigurationTest, CompareDifferent_002, TestSize.Level1) std::vector changeKeyV; config.CompareDifferent(changeKeyV, config2); + EXPECT_EQ(config.GetItemSize(), 1); int size = changeKeyV.size(); EXPECT_EQ(size, 1); } @@ -389,8 +391,10 @@ HWTEST_F(ConfigurationTest, Merge_001, TestSize.Level1) config.CompareDifferent(changeKeyV, config2); int size = changeKeyV.size(); EXPECT_EQ(size, 1); + EXPECT_EQ(config.GetItemSize(), 1); config.Merge(changeKeyV, config2); + EXPECT_EQ(config.GetItemSize(), 2); auto item = config.GetItem(displayId2, AAFwk::GlobalConfigurationKey::SYSTEM_LANGUAGE); EXPECT_EQ(item, English); @@ -427,6 +431,191 @@ HWTEST_F(ConfigurationTest, Merge_002, TestSize.Level1) auto item = config.GetItem(displayId, AAFwk::GlobalConfigurationKey::SYSTEM_LANGUAGE); EXPECT_EQ(item, english); } + +/* + * Feature: Configuration + * Function: CompareDifferent + * SubFunction: Process Configuration Change Inner + * FunctionPoints: NA + * EnvConditions:NA + * CaseDescription: CompareDifferent must not insert keys from other into this + */ +HWTEST_F(ConfigurationTest, CompareDifferent_003, TestSize.Level1) +{ + AppExecFwk::Configuration config; + int displayId = 1001; + config.AddItem(displayId, AAFwk::GlobalConfigurationKey::SYSTEM_LANGUAGE, "zh"); + EXPECT_EQ(config.GetItemSize(), 1); + + AppExecFwk::Configuration config2; + config2.AddItem(displayId, AAFwk::GlobalConfigurationKey::SYSTEM_LANGUAGE, "en"); + config2.AddItem(1002, AAFwk::GlobalConfigurationKey::SYSTEM_COLORMODE, "dark"); + EXPECT_EQ(config2.GetItemSize(), 2); + + std::vector changeKeyV; + config.CompareDifferent(changeKeyV, config2); + + EXPECT_EQ(config.GetItemSize(), 1); + EXPECT_EQ(changeKeyV.size(), static_cast(2)); +} + +/* + * Feature: Configuration + * Function: CompareDifferent + * SubFunction: Process Configuration Change Inner + * FunctionPoints: NA + * EnvConditions:NA + * CaseDescription: Identical configs produce empty diff + */ +HWTEST_F(ConfigurationTest, CompareDifferent_004, TestSize.Level1) +{ + AppExecFwk::Configuration config; + config.AddItem(AAFwk::GlobalConfigurationKey::SYSTEM_LANGUAGE, "en"); + config.AddItem(AAFwk::GlobalConfigurationKey::SYSTEM_COLORMODE, "dark"); + + AppExecFwk::Configuration config2; + config2.AddItem(AAFwk::GlobalConfigurationKey::SYSTEM_LANGUAGE, "en"); + config2.AddItem(AAFwk::GlobalConfigurationKey::SYSTEM_COLORMODE, "dark"); + + std::vector changeKeyV; + config.CompareDifferent(changeKeyV, config2); + + EXPECT_TRUE(changeKeyV.empty()); + EXPECT_EQ(config.GetItemSize(), 2); +} + +/* + * Feature: Configuration + * Function: CompareDifferent + * SubFunction: Process Configuration Change Inner + * FunctionPoints: NA + * EnvConditions:NA + * CaseDescription: diffKeyV is cleared when other is empty + */ +HWTEST_F(ConfigurationTest, CompareDifferent_005, TestSize.Level1) +{ + AppExecFwk::Configuration config; + config.AddItem(AAFwk::GlobalConfigurationKey::SYSTEM_LANGUAGE, "en"); + + AppExecFwk::Configuration emptyConfig; + + std::vector changeKeyV; + changeKeyV.push_back("dummy_key"); + ASSERT_EQ(changeKeyV.size(), static_cast(1)); + + config.CompareDifferent(changeKeyV, emptyConfig); + + EXPECT_TRUE(changeKeyV.empty()); +} + +/* + * Feature: Configuration + * Function: Marshalling + * SubFunction: Process Configuration Change Inner + * FunctionPoints: NA + * EnvConditions:NA + * CaseDescription: Marshalling and Unmarshalling round-trip preserves data + */ +HWTEST_F(ConfigurationTest, Marshalling_001, TestSize.Level1) +{ + AppExecFwk::Configuration config; + int displayId = 1001; + config.AddItem(displayId, AAFwk::GlobalConfigurationKey::SYSTEM_LANGUAGE, "zh"); + config.AddItem(AAFwk::GlobalConfigurationKey::SYSTEM_COLORMODE, "dark"); + EXPECT_EQ(config.GetItemSize(), 2); + + Parcel parcel; + EXPECT_TRUE(config.Marshalling(parcel)); + + parcel.RewindRead(0); + auto *newConfig = AppExecFwk::Configuration::Unmarshalling(parcel); + ASSERT_NE(newConfig, nullptr); + EXPECT_EQ(newConfig->GetItemSize(), 2); + EXPECT_EQ(newConfig->GetItem(displayId, AAFwk::GlobalConfigurationKey::SYSTEM_LANGUAGE), "zh"); + EXPECT_EQ(newConfig->GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_COLORMODE), "dark"); + delete newConfig; +} + +/* + * Feature: Configuration + * Function: Marshalling + * SubFunction: Process Configuration Change Inner + * FunctionPoints: NA + * EnvConditions:NA + * CaseDescription: Marshalling returns false when Parcel buffer is full + */ +HWTEST_F(ConfigurationTest, Marshalling_002, TestSize.Level1) +{ + Parcel parcel; + int fillCount = 0; + while (parcel.WriteInt32(0) && fillCount < 100000) { + fillCount++; + } + ASSERT_GT(fillCount, 0); + + AppExecFwk::Configuration config; + config.AddItem(AAFwk::GlobalConfigurationKey::SYSTEM_LANGUAGE, "en"); + EXPECT_FALSE(config.Marshalling(parcel)); +} + +/* + * Feature: Configuration + * Function: ReadFromParcel + * SubFunction: Process Configuration Change Inner + * FunctionPoints: NA + * EnvConditions:NA + * CaseDescription: ReadFromParcel clears existing data before writing new data + */ +HWTEST_F(ConfigurationTest, ReadFromParcel_001, TestSize.Level1) +{ + AppExecFwk::Configuration config; + config.AddItem(AAFwk::GlobalConfigurationKey::SYSTEM_LANGUAGE, "old_en"); + config.AddItem(AAFwk::GlobalConfigurationKey::SYSTEM_COLORMODE, "light"); + EXPECT_EQ(config.GetItemSize(), 2); + + AppExecFwk::Configuration newConfig; + newConfig.AddItem(AAFwk::GlobalConfigurationKey::SYSTEM_LANGUAGE, "new_en"); + EXPECT_EQ(newConfig.GetItemSize(), 1); + + Parcel parcel; + EXPECT_TRUE(newConfig.Marshalling(parcel)); + + parcel.RewindRead(0); + EXPECT_TRUE(config.ReadFromParcel(parcel)); + + EXPECT_EQ(config.GetItemSize(), 1); + EXPECT_EQ(config.GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_LANGUAGE), "new_en"); + EXPECT_TRUE(config.GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_COLORMODE).empty()); +} + +/* + * Feature: Configuration + * Function: ReadFromParcel + * SubFunction: Process Configuration Change Inner + * FunctionPoints: NA + * EnvConditions:NA + * CaseDescription: ReadFromParcel failure does not modify object state + */ +HWTEST_F(ConfigurationTest, ReadFromParcel_002, TestSize.Level1) +{ + AppExecFwk::Configuration config; + config.AddItem(AAFwk::GlobalConfigurationKey::SYSTEM_LANGUAGE, "en"); + config.AddItem(AAFwk::GlobalConfigurationKey::SYSTEM_COLORMODE, "dark"); + EXPECT_EQ(config.GetItemSize(), 2); + int32_t originalDisplayId = config.defaultDisplayId_; + + Parcel parcel; + parcel.WriteInt32(999); + parcel.WriteInt32(1); + + EXPECT_FALSE(config.ReadFromParcel(parcel)); + + EXPECT_EQ(config.defaultDisplayId_, originalDisplayId); + EXPECT_EQ(config.GetItemSize(), 2); + EXPECT_EQ(config.GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_LANGUAGE), "en"); + EXPECT_EQ(config.GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_COLORMODE), "dark"); +} + /* * Feature: Configuration * Function: GetName From 313abbc393f95870350fca4359d46ad4383d6e2a Mon Sep 17 00:00:00 2001 From: z00797421 Date: Mon, 13 Jul 2026 19:25:44 +0800 Subject: [PATCH 07/16] modify clean code Change-Id: I2b06c532f5f287f747e55c3b52824d3bd7d546d9 Signed-off-by: z00797421 --- services/abilitymgr/src/ability_manager_stub.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/services/abilitymgr/src/ability_manager_stub.cpp b/services/abilitymgr/src/ability_manager_stub.cpp index 65db1b7d38..2634183812 100644 --- a/services/abilitymgr/src/ability_manager_stub.cpp +++ b/services/abilitymgr/src/ability_manager_stub.cpp @@ -357,9 +357,6 @@ int AbilityManagerStub::OnRemoteRequestInnerSeventh(uint32_t code, MessageParcel if (interfaceCode == AbilityManagerInterfaceCode::START_SELF_UI_ABILITY_IN_CHILD_PROCESS) { return StartSelfUIAbilityInChildProcessInner(data, reply); } - if (interfaceCode == AbilityManagerInterfaceCode::UNREGISTER_SA_INTERCEPTOR) { - return UnregisterSAInterceptorInner(data, reply); - } return ERR_CODE_NOT_EXIST; } @@ -400,6 +397,9 @@ int AbilityManagerStub::OnRemoteRequestInnerEighth(uint32_t code, MessageParcel if (interfaceCode == AbilityManagerInterfaceCode::EXECUTE_INTENT_BY_FUNCTION_CALL) { return ExecuteIntentByFunctionCallInner(data, reply); } + if (interfaceCode == AbilityManagerInterfaceCode::UNREGISTER_SA_INTERCEPTOR) { + return UnregisterSAInterceptorInner(data, reply); + } return ERR_CODE_NOT_EXIST; } From e5f8fcf5f6ab573d8a73b0eb2d0822e4a33f0f0d Mon Sep 17 00:00:00 2001 From: z00797421 Date: Mon, 13 Jul 2026 21:56:30 +0800 Subject: [PATCH 08/16] modify review suggestion Change-Id: I276781a24e87bec69ac4f70728c16a0131d73102 Signed-off-by: z00797421 --- .../include/sa_interceptor_manager.h | 2 +- .../src/ability_manager_service.cpp | 11 +++------- .../abilitymgr/src/sa_interceptor_manager.cpp | 11 +++++----- .../sa_interceptor_manager_test.cpp | 21 +++++++++++++++++++ 4 files changed, 30 insertions(+), 15 deletions(-) diff --git a/services/abilitymgr/include/sa_interceptor_manager.h b/services/abilitymgr/include/sa_interceptor_manager.h index a15c0d37ce..4be3144f09 100644 --- a/services/abilitymgr/include/sa_interceptor_manager.h +++ b/services/abilitymgr/include/sa_interceptor_manager.h @@ -33,7 +33,7 @@ public: static SAInterceptorManager &GetInstance(); int32_t AddSAInterceptor(sptr interceptor); - int32_t RemoveSAInterceptor(sptr interceptor); + int32_t RemoveSAInterceptor(sptr interceptor); int32_t ExecuteSAInterceptor(const std::string ¶ms, Rule &rule); void OnObserverDied(const wptr &remote); diff --git a/services/abilitymgr/src/ability_manager_service.cpp b/services/abilitymgr/src/ability_manager_service.cpp index c2daa32416..42f85e3a9e 100644 --- a/services/abilitymgr/src/ability_manager_service.cpp +++ b/services/abilitymgr/src/ability_manager_service.cpp @@ -18449,13 +18449,8 @@ int32_t AbilityManagerService::UnregisterSAInterceptor(sptr inter TAG_LOGE(AAFwkTag::ABILITYMGR, "no permission call"); return CHECK_PERMISSION_FAILED; } - - auto ISAInterceptor = iface_cast(interceptor); - if (ISAInterceptor == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "ISAInterceptor cast failed"); - return ERR_NULL_SA_INTERCEPTOR_EXECUTER; - } - return SAInterceptorManager::GetInstance().RemoveSAInterceptor(ISAInterceptor); + + return SAInterceptorManager::GetInstance().RemoveSAInterceptor(interceptor); } bool AbilityManagerService::HandleExecuteSAInterceptor(const Want &want, sptr callerToken, @@ -18476,7 +18471,7 @@ bool AbilityManagerService::HandleExecuteSAInterceptor(const Want &want, sptr(ERR_LOW_MEM_SAINTERCEPTOR_START_BLOCK); return false; diff --git a/services/abilitymgr/src/sa_interceptor_manager.cpp b/services/abilitymgr/src/sa_interceptor_manager.cpp index a0913e0f57..3483df7b70 100644 --- a/services/abilitymgr/src/sa_interceptor_manager.cpp +++ b/services/abilitymgr/src/sa_interceptor_manager.cpp @@ -74,20 +74,19 @@ int32_t SAInterceptorManager::RemoveSAInterceptor(sptr intercept TAG_LOGE(AAFwkTag::SA_INTERCEPTOR, "null interceptor"); return AAFwk::ERR_NULL_SA_INTERCEPTOR_EXECUTER; } - - auto observerObj = interceptor->AsObject(); + std::lock_guard lock(saInterceptorLock_); for (auto interceptorIter = saInterceptors_.begin(); interceptorIter != saInterceptors_.end(); interceptorIter++) { - if (*interceptorIter && (*interceptorIter)->AsObject() == observerObj) { - if (observerObj && deathRecipient_) { - observerObj->RemoveDeathRecipient(deathRecipient_); + if (*interceptorIter && (*interceptorIter)->AsObject() == interceptor) { + if (interceptor && deathRecipient_) { + interceptor->RemoveDeathRecipient(deathRecipient_); } saInterceptors_.erase(interceptorIter); TAG_LOGI(AAFwkTag::ABILITYMGR, "interceptor removed"); return ERR_OK; } } - TAG_LOGW(AAFwkTag::ABILITYMGR, "interceptor not found"); + TAG_LOGE(AAFwkTag::ABILITYMGR, "interceptor not found"); return ERR_OK; } diff --git a/test/unittest/sa_interceptor_manager_test/sa_interceptor_manager_test.cpp b/test/unittest/sa_interceptor_manager_test/sa_interceptor_manager_test.cpp index 60715aae51..a829a49d7c 100644 --- a/test/unittest/sa_interceptor_manager_test/sa_interceptor_manager_test.cpp +++ b/test/unittest/sa_interceptor_manager_test/sa_interceptor_manager_test.cpp @@ -84,6 +84,27 @@ HWTEST_F(SAInterceptorManagerTest, AddSAInterceptor_0100, TestSize.Level1) EXPECT_EQ(result, ERR_OK); } +/* + * @tc.number: RemoveSAInterceptor_0100 + * @tc.name: RemoveSAInterceptor + * @tc.desc: Verify RemoveSAInterceptor with null interceptor and non-exist interceptor + */ +HWTEST_F(SAInterceptorManagerTest, RemoveSAInterceptor_0100, TestSize.Level1) +{ + SAInterceptorManager::GetInstance().saInterceptors_.clear(); + int32_t result = SAInterceptorManager::GetInstance().RemoveSAInterceptor(nullptr); + EXPECT_EQ(result, ERR_NULL_SA_INTERCEPTOR_EXECUTER); + sptr interceptor = new MockSAInterceptor(); + result = SAInterceptorManager::GetInstance().RemoveSAInterceptor(interceptor->AsObject()); + EXPECT_EQ(result, ERR_SA_INTERCEPTOR_NOT_EXIST); + result = SAInterceptorManager::GetInstance().AddSAInterceptor(interceptor); + EXPECT_EQ(result, ERR_OK); + EXPECT_EQ(SAInterceptorManager::GetInstance().saInterceptors_.size(), 1); + result = SAInterceptorManager::GetInstance().RemoveSAInterceptor(interceptor->AsObject()); + EXPECT_EQ(result, ERR_OK); + EXPECT_EQ(SAInterceptorManager::GetInstance().saInterceptors_.size(), 0); +} + /* * @tc.number: ExecuteSAInterceptor_0100 * @tc.name: ExecuteSAInterceptor From 86e237e5ca5c1f318bdb45781266cbb44b702e4e Mon Sep 17 00:00:00 2001 From: RuiChen_01 Date: Mon, 13 Jul 2026 21:42:09 +0800 Subject: [PATCH 09/16] fix(insight-intent): prefer background execute mode for Entry when supported MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GetExecuteModeFromMatched picked executeMode.front() for Entry, which could miss UI_ABILITY_BACKGROUND when the candidate supported multiple modes. Search for BACKGROUND first and use it when present; fall back to front() otherwise. Function and Page branches unchanged. Co-Authored-By: Agent Signed-off-by: RuiChen_01 πŸ€– AI[0%] πŸ”§ Human Fixed[0%] πŸ§‘ Human[100%] πŸ‘Œ AI Adopted[0%] --- .../insight_intent_param_parser.cpp | 9 ++- .../insight_intent_param_parser_test.cpp | 67 ++++++++++++++++--- 2 files changed, 65 insertions(+), 11 deletions(-) diff --git a/services/abilitymgr/src/insight_intent/insight_intent_param_parser.cpp b/services/abilitymgr/src/insight_intent/insight_intent_param_parser.cpp index cd1843b901..ce628d0f6c 100644 --- a/services/abilitymgr/src/insight_intent/insight_intent_param_parser.cpp +++ b/services/abilitymgr/src/insight_intent/insight_intent_param_parser.cpp @@ -15,6 +15,7 @@ #include "insight_intent_param_parser.h" +#include #include #include #include @@ -74,12 +75,18 @@ std::string GetAbilityNameFromMatched(const ExtractInsightIntentGenericInfo &inf } // Extract executeMode from representative candidate variant. -// Entry: first value from executeMode vector; Function: forced to UI_ABILITY_BACKGROUND. +// Entry: prefer UI_ABILITY_BACKGROUND when supported, else first of executeMode vector; +// Function: forced to UI_ABILITY_BACKGROUND. int32_t GetExecuteModeFromMatched(const ExtractInsightIntentGenericInfo &info) { if (info.currentType == InfoType::Entry) { const auto &entry = info.get(); if (!entry.executeMode.empty()) { + auto it = std::find(entry.executeMode.begin(), entry.executeMode.end(), + AppExecFwk::ExecuteMode::UI_ABILITY_BACKGROUND); + if (it != entry.executeMode.end()) { + return static_cast(AppExecFwk::ExecuteMode::UI_ABILITY_BACKGROUND); + } return static_cast(entry.executeMode.front()); } } diff --git a/test/unittest/insight_intent/insight_intent_param_parser_test/insight_intent_param_parser_test.cpp b/test/unittest/insight_intent/insight_intent_param_parser_test/insight_intent_param_parser_test.cpp index 2bd8736fb9..19f978e988 100644 --- a/test/unittest/insight_intent/insight_intent_param_parser_test/insight_intent_param_parser_test.cpp +++ b/test/unittest/insight_intent/insight_intent_param_parser_test/insight_intent_param_parser_test.cpp @@ -30,12 +30,12 @@ using namespace OHOS::AbilityRuntime; namespace { ExtractInsightIntentGenericInfo MakeBgUiAbilityCandidate(const std::string &bundle, - const std::string &module, const std::string &intent, const std::string &ability) + const std::string &module, const std::string &intentName, const std::string &ability) { ExtractInsightIntentGenericInfo info; info.bundleName = bundle; info.moduleName = module; - info.intentName = intent; + info.intentName = intentName; info.decoratorType = INSIGHT_INTENTS_DECORATOR_TYPE_ENTRY; info.set(); auto &entry = info.get(); @@ -45,12 +45,12 @@ ExtractInsightIntentGenericInfo MakeBgUiAbilityCandidate(const std::string &bund } ExtractInsightIntentGenericInfo MakeFgUiAbilityCandidate(const std::string &bundle, - const std::string &module, const std::string &intent, const std::string &ability) + const std::string &module, const std::string &intentName, const std::string &ability) { ExtractInsightIntentGenericInfo info; info.bundleName = bundle; info.moduleName = module; - info.intentName = intent; + info.intentName = intentName; info.decoratorType = INSIGHT_INTENTS_DECORATOR_TYPE_ENTRY; info.set(); auto &entry = info.get(); @@ -58,6 +58,22 @@ ExtractInsightIntentGenericInfo MakeFgUiAbilityCandidate(const std::string &bund entry.executeMode = {AppExecFwk::ExecuteMode::UI_ABILITY_FOREGROUND}; return info; } + +ExtractInsightIntentGenericInfo MakeMultiModeEntryCandidate(const std::string &bundle, + const std::string &module, const std::string &intentName, const std::string &ability, + const std::vector &modes) +{ + ExtractInsightIntentGenericInfo info; + info.bundleName = bundle; + info.moduleName = module; + info.intentName = intentName; + info.decoratorType = INSIGHT_INTENTS_DECORATOR_TYPE_ENTRY; + info.set(); + auto &entry = info.get(); + entry.abilityName = ability; + entry.executeMode = modes; + return info; +} } // namespace class InsightIntentParamParserTest : public Test {}; @@ -67,7 +83,7 @@ HWTEST_F(InsightIntentParamParserTest, Build_EmptyBundleName_ReturnsInvalidValue InsightIntentParamParser parser; WantParams wantParam; InsightIntentParamParser::ParseResult out; - auto ret = parser.Build("", "intent", wantParam, {}, 0, out); + auto ret = parser.Build("", "intentName", wantParam, {}, 0, out); EXPECT_NE(ret, 0); } @@ -85,19 +101,19 @@ HWTEST_F(InsightIntentParamParserTest, Build_NoCandidate_ReturnsInvalidValue, Te InsightIntentParamParser parser; WantParams wantParam; InsightIntentParamParser::ParseResult out; - auto ret = parser.Build("bundle", "intent", wantParam, {}, 0, out); + auto ret = parser.Build("bundle", "intentName", wantParam, {}, 0, out); EXPECT_NE(ret, 0); } HWTEST_F(InsightIntentParamParserTest, Build_AllFgCandidates_ReturnsInvalidValue, TestSize.Level1) { std::vector candidates = { - MakeFgUiAbilityCandidate("bundle", "entry", "intent", "MainAbility"), + MakeFgUiAbilityCandidate("bundle", "entry", "intentName", "MainAbility"), }; InsightIntentParamParser parser; WantParams wantParam; InsightIntentParamParser::ParseResult out; - auto ret = parser.Build("bundle", "intent", wantParam, candidates, 0, out); + auto ret = parser.Build("bundle", "intentName", wantParam, candidates, 0, out); EXPECT_NE(ret, 0); } @@ -106,16 +122,47 @@ HWTEST_F(InsightIntentParamParserTest, Build_SingleBgUiAbilityCandidate_ReturnsP const std::string expectedModule = "entry"; const std::string expectedAbility = "BgAbility"; std::vector candidates = { - MakeBgUiAbilityCandidate("bundle", expectedModule, "intent", expectedAbility), + MakeBgUiAbilityCandidate("bundle", expectedModule, "intentName", expectedAbility), }; InsightIntentParamParser parser; WantParams wantParam; InsightIntentParamParser::ParseResult out; - auto ret = parser.Build("bundle", "intent", wantParam, candidates, 0, out); + auto ret = parser.Build("bundle", "intentName", wantParam, candidates, 0, out); EXPECT_EQ(ret, 0); ASSERT_NE(out.param, nullptr); EXPECT_EQ(out.param->moduleName_, expectedModule); EXPECT_EQ(out.param->abilityName_, expectedAbility); + EXPECT_EQ(out.param->executeMode_, AppExecFwk::ExecuteMode::UI_ABILITY_BACKGROUND); EXPECT_FALSE(out.ignoreAbilityName); EXPECT_FALSE(out.openLinkExecuteFlag); } + +HWTEST_F(InsightIntentParamParserTest, Build_MultiModeEntryWithBg_PrefersBg, TestSize.Level1) +{ + std::vector candidates = { + MakeMultiModeEntryCandidate("bundle", "entry", "intentName", "MainAbility", + {AppExecFwk::ExecuteMode::UI_ABILITY_FOREGROUND, AppExecFwk::ExecuteMode::UI_ABILITY_BACKGROUND}), + }; + InsightIntentParamParser parser; + WantParams wantParam; + InsightIntentParamParser::ParseResult out; + auto ret = parser.Build("bundle", "intentName", wantParam, candidates, 0, out); + EXPECT_EQ(ret, 0); + ASSERT_NE(out.param, nullptr); + EXPECT_EQ(out.param->executeMode_, AppExecFwk::ExecuteMode::UI_ABILITY_BACKGROUND); +} + +HWTEST_F(InsightIntentParamParserTest, Build_MultiModeEntryWithoutBg_FallsBackToFront, TestSize.Level1) +{ + std::vector candidates = { + MakeMultiModeEntryCandidate("bundle", "entry", "intentName", "MainAbility", + {AppExecFwk::ExecuteMode::UI_ABILITY_FOREGROUND, AppExecFwk::ExecuteMode::SERVICE_EXTENSION_ABILITY}), + }; + InsightIntentParamParser parser; + WantParams wantParam; + InsightIntentParamParser::ParseResult out; + auto ret = parser.Build("bundle", "intentName", wantParam, candidates, 0, out); + EXPECT_EQ(ret, 0); + ASSERT_NE(out.param, nullptr); + EXPECT_EQ(out.param->executeMode_, AppExecFwk::ExecuteMode::UI_ABILITY_FOREGROUND); +} From 8b2bf84937492505639cedd1a38ddb811126bde6 Mon Sep 17 00:00:00 2001 From: z00797421 Date: Mon, 13 Jul 2026 22:31:35 +0800 Subject: [PATCH 10/16] modify review suggestion Change-Id: Ia64b065ec88b25867200e0301f6980d183da77c2 Signed-off-by: z00797421 --- services/abilitymgr/src/sa_interceptor_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/abilitymgr/src/sa_interceptor_manager.cpp b/services/abilitymgr/src/sa_interceptor_manager.cpp index 3483df7b70..f7a775660e 100644 --- a/services/abilitymgr/src/sa_interceptor_manager.cpp +++ b/services/abilitymgr/src/sa_interceptor_manager.cpp @@ -68,7 +68,7 @@ int32_t SAInterceptorManager::AddSAInterceptor(sptr interceptor) return ERR_OK; } -int32_t SAInterceptorManager::RemoveSAInterceptor(sptr interceptor) +int32_t SAInterceptorManager::RemoveSAInterceptor(sptr interceptor) { if (interceptor == nullptr) { TAG_LOGE(AAFwkTag::SA_INTERCEPTOR, "null interceptor"); From d1926e4e953f0af195cecf29360fdb0ff31c8bd4 Mon Sep 17 00:00:00 2001 From: z00797421 Date: Tue, 14 Jul 2026 00:46:16 +0800 Subject: [PATCH 11/16] modify review suggestion Change-Id: I65968877cad11544bd71b46a41ea1c63b758657b Signed-off-by: z00797421 --- .../ability_manager/include/ability_manager_errors.h | 5 +++++ services/abilitymgr/src/sa_interceptor_manager.cpp | 2 +- .../sa_interceptor_manager_test.cpp | 12 +++--------- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/interfaces/inner_api/ability_manager/include/ability_manager_errors.h b/interfaces/inner_api/ability_manager/include/ability_manager_errors.h index deda9965c6..ab7f8f4416 100644 --- a/interfaces/inner_api/ability_manager/include/ability_manager_errors.h +++ b/interfaces/inner_api/ability_manager/include/ability_manager_errors.h @@ -938,6 +938,11 @@ enum { */ ERR_PRELOAD_NOT_ENTRY_MODULE = 2097368, + /** + * Result (2097369) for sa interceptor not found when unregister. + */ + ERR_SA_INTERCEPTOR_NOT_EXIST = 2097369, + /** * Result (2097370-2097379) for StartUIAbilities Error. */ diff --git a/services/abilitymgr/src/sa_interceptor_manager.cpp b/services/abilitymgr/src/sa_interceptor_manager.cpp index f7a775660e..90ca4c27f5 100644 --- a/services/abilitymgr/src/sa_interceptor_manager.cpp +++ b/services/abilitymgr/src/sa_interceptor_manager.cpp @@ -87,7 +87,7 @@ int32_t SAInterceptorManager::RemoveSAInterceptor(sptr intercepto } } TAG_LOGE(AAFwkTag::ABILITYMGR, "interceptor not found"); - return ERR_OK; + return AAFwk::ERR_SA_INTERCEPTOR_NOT_EXIST; } bool SAInterceptorManager::SAInterceptorListIsEmpty() diff --git a/test/unittest/sa_interceptor_manager_test/sa_interceptor_manager_test.cpp b/test/unittest/sa_interceptor_manager_test/sa_interceptor_manager_test.cpp index a829a49d7c..f6c3d0db8e 100644 --- a/test/unittest/sa_interceptor_manager_test/sa_interceptor_manager_test.cpp +++ b/test/unittest/sa_interceptor_manager_test/sa_interceptor_manager_test.cpp @@ -87,22 +87,16 @@ HWTEST_F(SAInterceptorManagerTest, AddSAInterceptor_0100, TestSize.Level1) /* * @tc.number: RemoveSAInterceptor_0100 * @tc.name: RemoveSAInterceptor - * @tc.desc: Verify RemoveSAInterceptor with null interceptor and non-exist interceptor + * @tc.desc: Verify RemoveSAInterceptor with null interceptor */ HWTEST_F(SAInterceptorManagerTest, RemoveSAInterceptor_0100, TestSize.Level1) { SAInterceptorManager::GetInstance().saInterceptors_.clear(); int32_t result = SAInterceptorManager::GetInstance().RemoveSAInterceptor(nullptr); EXPECT_EQ(result, ERR_NULL_SA_INTERCEPTOR_EXECUTER); - sptr interceptor = new MockSAInterceptor(); - result = SAInterceptorManager::GetInstance().RemoveSAInterceptor(interceptor->AsObject()); + sptr remoteObj = new MockIRemoteObject(); + result = SAInterceptorManager::GetInstance().RemoveSAInterceptor(remoteObj); EXPECT_EQ(result, ERR_SA_INTERCEPTOR_NOT_EXIST); - result = SAInterceptorManager::GetInstance().AddSAInterceptor(interceptor); - EXPECT_EQ(result, ERR_OK); - EXPECT_EQ(SAInterceptorManager::GetInstance().saInterceptors_.size(), 1); - result = SAInterceptorManager::GetInstance().RemoveSAInterceptor(interceptor->AsObject()); - EXPECT_EQ(result, ERR_OK); - EXPECT_EQ(SAInterceptorManager::GetInstance().saInterceptors_.size(), 0); } /* From e1613a2a1c2230f32513c455d7222501bcb94e39 Mon Sep 17 00:00:00 2001 From: acdemicJava Date: Mon, 13 Jul 2026 16:39:07 +0800 Subject: [PATCH 12/16] =?UTF-8?q?=E5=90=8E=E5=8F=B0=E6=9F=A5=E6=9D=80?= =?UTF-8?q?=E5=8A=A0=E5=9B=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: acdemicJava --- services/appdfr/include/appfreeze_manager.h | 2 +- services/appdfr/src/appfreeze_manager.cpp | 4 ++-- services/appmgr/src/app_mgr_service_inner.cpp | 9 +++++---- .../appfreeze_manager_test.cpp | 16 ++++++++++------ 4 files changed, 18 insertions(+), 13 deletions(-) diff --git a/services/appdfr/include/appfreeze_manager.h b/services/appdfr/include/appfreeze_manager.h index 662d682645..dae4324c43 100644 --- a/services/appdfr/include/appfreeze_manager.h +++ b/services/appdfr/include/appfreeze_manager.h @@ -134,7 +134,7 @@ public: bool IsFreezeExcludedPid(int32_t targetPid); bool CheckPreloadUIExtension(const std::string& message, const std::string& bundleName, int32_t pid, const std::string& eventName); - bool CheckProcessExit(const std::string& eventName, bool foreground); + bool CheckProcessExit(const std::string& processName, const std::string& eventName, bool foreground); private: struct PeerBinderInfo { diff --git a/services/appdfr/src/appfreeze_manager.cpp b/services/appdfr/src/appfreeze_manager.cpp index a43775b238..96e7485102 100644 --- a/services/appdfr/src/appfreeze_manager.cpp +++ b/services/appdfr/src/appfreeze_manager.cpp @@ -1539,9 +1539,9 @@ bool AppfreezeManager::CheckPreloadUIExtension(const std::string& message, const return false; } -bool AppfreezeManager::CheckProcessExit(const std::string& eventName, bool foreground) +bool AppfreezeManager::CheckProcessExit(const std::string& processName, const std::string& eventName, bool foreground) { - return foreground || (eventName != AppFreezeType::THREAD_BLOCK_6S); + return foreground || eventName != AppFreezeType::THREAD_BLOCK_6S || processName == "com.ohos.sceneboard"; } } // namespace AppExecFwk } // namespace OHOS \ No newline at end of file diff --git a/services/appmgr/src/app_mgr_service_inner.cpp b/services/appmgr/src/app_mgr_service_inner.cpp index 00bc6be2da..2ed497caf8 100644 --- a/services/appmgr/src/app_mgr_service_inner.cpp +++ b/services/appmgr/src/app_mgr_service_inner.cpp @@ -9388,8 +9388,9 @@ int32_t AppMgrServiceInner::NotifyAppFault(const FaultData &faultData) FaultData& nonConstFaultData = const_cast(faultData); nonConstFaultData.isInForeground = UpdateForeground(appRecord, eventName); - bool isExit = AppExecFwk::AppfreezeManager::GetInstance()->CheckProcessExit(eventName, - nonConstFaultData.isInForeground); + std::string processName = appRecord->GetProcessName(); + bool isExit = AppExecFwk::AppfreezeManager::GetInstance()->CheckProcessExit(processName, + eventName, nonConstFaultData.isInForeground); if (faultData.faultType == FaultDataType::APP_FREEZE) { if (CheckAppFault(appRecord, faultData)) { return ERR_OK; @@ -9430,8 +9431,8 @@ int32_t AppMgrServiceInner::NotifyAppFault(const FaultData &faultData) if (isExit) { KillFaultApp(pid, bundleName, faultData, false, recordId); } else { - TAG_LOGW(AAFwkTag::APPMGR, "Process does not exit, pid:%{public}d, isExit:%{public}d, eventName:%{public}s", - pid, isExit, eventName.c_str()); + TAG_LOGW(AAFwkTag::APPMGR, "Process does not exit, pid:%{public}d, isExit:%{public}d, " + "eventName:%{public}s, processName:%{public}s", pid, isExit, eventName.c_str(), processName.c_str()); } #endif diff --git a/test/unittest/dfr_test/appfreeze_manager_test/appfreeze_manager_test.cpp b/test/unittest/dfr_test/appfreeze_manager_test/appfreeze_manager_test.cpp index c7cc9e46f6..56e38033b6 100644 --- a/test/unittest/dfr_test/appfreeze_manager_test/appfreeze_manager_test.cpp +++ b/test/unittest/dfr_test/appfreeze_manager_test/appfreeze_manager_test.cpp @@ -999,19 +999,23 @@ HWTEST_F(AppfreezeManagerTest, AppfreezeManagerTest_CheckPreloadUIExtension_Test HWTEST_F(AppfreezeManagerTest, AppfreezeManagerTest_CheckProcessExit_Test001, TestSize.Level1) { std::string eventName = AppFreezeType::THREAD_BLOCK_6S; - bool result = appfreezeManager->CheckProcessExit(eventName, false); + std::string processName = "AppfreezeManagerTest"; + bool result = appfreezeManager->CheckProcessExit(processName, eventName, false); EXPECT_EQ(result, false); - eventName = AppFreezeType::THREAD_BLOCK_6S; - result = appfreezeManager->CheckProcessExit(eventName, true); + processName = "com.ohos.sceneboard"; + result = appfreezeManager->CheckProcessExit(processName, eventName, false); + EXPECT_EQ(result, true); + + processName = "AppfreezeManagerTest"; + result = appfreezeManager->CheckProcessExit(processName, eventName, true); EXPECT_EQ(result, true); eventName = AppFreezeType::THREAD_BLOCK_3S; - result = appfreezeManager->CheckProcessExit(eventName, false); + result = appfreezeManager->CheckProcessExit(processName, eventName, false); EXPECT_EQ(result, true); - eventName = AppFreezeType::THREAD_BLOCK_3S; - result = appfreezeManager->CheckProcessExit(eventName, true); + result = appfreezeManager->CheckProcessExit(processName, eventName, true); EXPECT_EQ(result, true); } From e0995f7db4819f1adf30d847208744b049763c5d Mon Sep 17 00:00:00 2001 From: wangzhen Date: Tue, 14 Jul 2026 15:29:05 +0800 Subject: [PATCH 13/16] Add cfi/pac config Co-Authored-By: Agent MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangzhen πŸ€–β€ AI[0%] πŸ‘Œ AI Adopted[0%] πŸ§‘ Human[100%] --- .../frameworks/js/napi/agent_manager/BUILD.gn | 2 + .../interfaces/inner_api/BUILD.gn | 6 + .../js/napi/cli_tool_manager/BUILD.gn | 3 + .../js/napi/function_manager/BUILD.gn | 1 + .../js/napi/script_manager/BUILD.gn | 1 + .../interfaces/cli_tool/BUILD.gn | 1 + .../interfaces/function/BUILD.gn | 1 + cli_tool_framework/services/climgr/BUILD.gn | 1 + cli_tool_framework/services/common/BUILD.gn | 1 + .../cli_event_reply_manager_test/BUILD.gn | 7 ++ .../unittest/cli_event_report_test/BUILD.gn | 119 +++++++++--------- .../cli_tool_mgr_client_test/BUILD.gn | 7 ++ .../cli_tool_mgr_service_test/BUILD.gn | 7 ++ .../test/unittest/function_info_test/BUILD.gn | 7 ++ .../invoke_function_executor_test/BUILD.gn | 7 ++ .../unittest/process_manager_test/BUILD.gn | 7 ++ frameworks/cj/ffi/ark_interop_helper/BUILD.gn | 2 + .../ets/ani/share_extension_ability/BUILD.gn | 2 + .../js/napi/abilityDataUriUtils/BUILD.gn | 2 + .../ability_auto_startup_callback/BUILD.gn | 2 + .../ability_auto_startup_manager/BUILD.gn | 2 + frameworks/js/napi/ability_constant/BUILD.gn | 4 + frameworks/js/napi/ability_context/BUILD.gn | 2 + .../js/napi/ability_vertical_panel/BUILD.gn | 2 + .../js/napi/action_extension_ability/BUILD.gn | 2 + .../app/ability_lifecycle_callback/BUILD.gn | 2 + frameworks/js/napi/app/ability_stage/BUILD.gn | 4 + .../napi/app/ability_stage_context/BUILD.gn | 2 + frameworks/js/napi/app/app_manager/BUILD.gn | 2 + .../js/napi/app/application_context/BUILD.gn | 2 + .../BUILD.gn | 2 + frameworks/js/napi/app/context/BUILD.gn | 2 + .../js/napi/app/environment_callback/BUILD.gn | 2 + .../js/napi/app/js_app_manager/BUILD.gn | 2 + frameworks/js/napi/app/test_runner/BUILD.gn | 2 + .../application_context_constant/BUILD.gn | 2 + .../napi/auto_fill_extension_ability/BUILD.gn | 2 + .../napi/auto_fill_extension_context/BUILD.gn | 2 + frameworks/js/napi/auto_fill_manager/BUILD.gn | 2 + frameworks/js/napi/callee/BUILD.gn | 2 + frameworks/js/napi/caller/BUILD.gn | 2 + .../BUILD.gn | 2 + .../BUILD.gn | 2 + .../js/napi/configuration_constant/BUILD.gn | 4 + .../js/napi/embeddable_ui_ability/BUILD.gn | 2 + .../embeddable_ui_ability_context/BUILD.gn | 2 + frameworks/js/napi/errorcode/BUILD.gn | 2 + frameworks/js/napi/extension_ability/BUILD.gn | 2 + frameworks/js/napi/extensioncontext/BUILD.gn | 2 + frameworks/js/napi/featureAbility/BUILD.gn | 2 + frameworks/js/napi/feature_ability/BUILD.gn | 2 + .../napi/inner/napi_ability_common/BUILD.gn | 2 + .../insight_intent/insight_intent/BUILD.gn | 2 + .../insight_intent_decorator/BUILD.gn | 2 + .../insight_intent_driver/BUILD.gn | 2 + .../insight_intent_executor/BUILD.gn | 2 + .../insight_intent_provider/BUILD.gn | 2 + .../js/napi/insight_intent_context/BUILD.gn | 2 + frameworks/js/napi/js_child_process/BUILD.gn | 2 + .../js/napi/js_child_process_manager/BUILD.gn | 2 + frameworks/js/napi/js_dialog_request/BUILD.gn | 2 + frameworks/js/napi/js_dialog_session/BUILD.gn | 2 + .../js/napi/js_mission_manager/BUILD.gn | 2 + frameworks/js/napi/mission_manager/BUILD.gn | 4 + frameworks/js/napi/particleAbility/BUILD.gn | 2 + .../photo_editor_extension_ability/BUILD.gn | 2 + .../photo_editor_extension_context/BUILD.gn | 2 + frameworks/js/napi/quick_fix/BUILD.gn | 2 + .../napi/service_extension_ability/BUILD.gn | 4 + .../napi/service_extension_context/BUILD.gn | 2 + .../js/napi/share_extension_ability/BUILD.gn | 2 + .../js/napi/ui_extension_ability/BUILD.gn | 2 + .../js/napi/ui_extension_context/BUILD.gn | 2 + frameworks/js/napi/uri_permission/BUILD.gn | 2 + frameworks/js/napi/wantConstant/BUILD.gn | 4 + frameworks/js/napi/wantagent/BUILD.gn | 2 + .../wantagent/ability_want_agent/BUILD.gn | 2 + .../ability_runtime/local_call_container.cpp | 8 +- frameworks/native/ability/native/BUILD.gn | 76 +++++++++++ frameworks/native/appkit/BUILD.gn | 10 ++ .../ability_runtime/context/context_impl.cpp | 14 +-- frameworks/native/appkit/app/context_deal.cpp | 2 +- .../insight_intent_context/BUILD.gn | 4 + .../simulator/ability_simulator/BUILD.gn | 2 + .../simulator/napi_module/ability/BUILD.gn | 2 + .../napi_module/ability_constant/BUILD.gn | 2 + .../napi_module/ability_context/BUILD.gn | 2 + .../napi_module/ability_stage/BUILD.gn | 2 + .../ability_stage_context/BUILD.gn | 2 + .../napi_module/application_context/BUILD.gn | 2 + .../simulator/napi_module/callee/BUILD.gn | 2 + .../simulator/napi_module/caller/BUILD.gn | 2 + .../configuration_constant/BUILD.gn | 2 + .../simulator/napi_module/context/BUILD.gn | 2 + .../embeddable_ui_ability/BUILD.gn | 2 + .../embeddable_ui_ability_context/BUILD.gn | 2 + .../simulator/napi_module/uiability/BUILD.gn | 2 + .../napi_module/want_constant/BUILD.gn | 2 + frameworks/simulator/osal/BUILD.gn | 2 + frameworks/simulator/test/BUILD.gn | 2 + interfaces/inner_api/ability_manager/BUILD.gn | 30 +++++ .../inner_api/ani_base_context/BUILD.gn | 2 + interfaces/inner_api/app_manager/BUILD.gn | 10 ++ .../inner_api/child_process_manager/BUILD.gn | 2 + .../inner_api/connectionobs_manager/BUILD.gn | 10 ++ interfaces/inner_api/deps_wrapper/BUILD.gn | 6 + .../include/os_account_manager_wrapper.h | 15 +-- .../src/os_account_manager_wrapper.cpp | 8 +- interfaces/inner_api/error_utils/BUILD.gn | 6 + .../inner_api/napi_base_context/BUILD.gn | 2 + interfaces/inner_api/quick_fix/BUILD.gn | 8 ++ interfaces/inner_api/runtime/BUILD.gn | 10 ++ interfaces/inner_api/session_handler/BUILD.gn | 6 + .../frameworks/js_environment/BUILD.gn | 6 + .../interfaces/inner_api/BUILD.gn | 6 + .../src/ability_manager_service.cpp | 9 +- services/abilitymgr/src/ability_record.cpp | 2 +- .../src/app_exit_reason_data_manager.cpp | 2 +- .../abilitymgr/src/app_exit_reason_helper.cpp | 16 +-- .../abilitymgr/src/modular_object_utils.cpp | 3 +- .../abilitymgr/src/sub_managers_helper.cpp | 6 +- services/appmgr/src/app_mgr_service_inner.cpp | 35 ++---- services/appmgr/src/app_running_manager.cpp | 4 +- services/appmgr/src/app_spawn_client.cpp | 8 +- services/common/BUILD.gn | 15 +++ .../src/user_controller/user_controller.cpp | 2 +- services/quickfixmgr/BUILD.gn | 6 + .../src/file_uri_distribution_utils.cpp | 2 +- test/moduletest/mission_dump_test/BUILD.gn | 7 ++ .../quick_fix_manager_module_test/BUILD.gn | 7 ++ .../os_account_manager_wrapper.h | 7 +- .../BUILD.gn | 2 +- .../BUILD.gn | 5 +- .../ability_cache_manager_test/BUILD.gn | 1 - .../BUILD.gn | 4 +- .../BUILD.gn | 15 ++- .../BUILD.gn | 1 - .../BUILD.gn | 1 - .../BUILD.gn | 3 - .../ability_connect_manager_test/BUILD.gn | 1 - .../ability_event_handler_test/BUILD.gn | 4 +- .../ability_extension_base_test.cpp | 15 +-- .../ability_interceptor_second_test/BUILD.gn | 2 - .../ability_interceptor_test/BUILD.gn | 2 - .../ability_interceptor_third_test/BUILD.gn | 3 - .../BUILD.gn | 2 - .../BUILD.gn | 2 - .../BUILD.gn | 2 - .../BUILD.gn | 1 - .../BUILD.gn | 8 +- .../BUILD.gn | 2 - .../ability_manager_proxy_sixth_test/BUILD.gn | 2 - .../ability_manager_proxy_test/BUILD.gn | 8 +- .../ability_manager_proxy_third_test/BUILD.gn | 2 - .../BUILD.gn | 7 ++ .../ability_manager_service_account_test.cpp | 4 +- .../BUILD.gn | 5 - .../BUILD.gn | 1 - .../mock/include/os_account_manager_wrapper.h | 16 +-- .../ability_manager_stub_second_test/BUILD.gn | 2 - .../ability_manager_stub_test/BUILD.gn | 2 - test/unittest/ability_record_test/BUILD.gn | 2 - .../ability_scheduler_proxy_test/BUILD.gn | 4 +- .../BUILD.gn | 3 - .../ability_scheduler_stub_test/BUILD.gn | 3 - .../ability_service_start_test/BUILD.gn | 2 - .../ability_token_proxy_test/BUILD.gn | 4 +- .../unittest/ability_token_stub_test/BUILD.gn | 4 +- .../ag_convert_callback_impl_test/BUILD.gn | 2 +- .../unittest/ams_app_mgr_client_test/BUILD.gn | 25 ++-- .../mock/include/os_account_manager_wrapper.h | 16 +-- .../unittest/app_lifecycle_deal_test/BUILD.gn | 6 + test/unittest/app_mgr_client_test/BUILD.gn | 6 + .../unittest/app_scheduler_host_test/BUILD.gn | 6 + .../app_scheduler_proxy_test/BUILD.gn | 6 + test/unittest/app_scheduler_test/BUILD.gn | 2 - .../BUILD.gn | 4 +- .../mock/include/os_account_manager_wrapper.h | 15 ++- .../ohos_application_first_test.cpp | 3 + .../BUILD.gn | 4 +- .../background_task_observer_test/BUILD.gn | 4 +- test/unittest/call_record_test/BUILD.gn | 5 +- .../unittest/child_process_capi_test/BUILD.gn | 7 ++ .../child_process_manager_test/BUILD.gn | 7 ++ test/unittest/configuration_test/BUILD.gn | 4 +- .../BUILD.gn | 4 +- .../connection_observer_test/BUILD.gn | 6 + test/unittest/connection_record_test/BUILD.gn | 1 - .../connection_state_item_test/BUILD.gn | 4 +- .../connection_state_manager_test/BUILD.gn | 4 +- .../data_ability_manager_test/BUILD.gn | 1 - .../data_ability_record_second_test/BUILD.gn | 2 - .../data_ability_record_test/BUILD.gn | 2 - test/unittest/dlp_state_item_test/BUILD.gn | 4 +- .../ecological_rule_interceptor_test/BUILD.gn | 3 - .../exit_info_data_manager_test/BUILD.gn | 1 - test/unittest/exit_reason_test/BUILD.gn | 1 - test/unittest/extension_record_test/BUILD.gn | 1 - .../BUILD.gn | 4 +- .../mock/include/os_account_manager_wrapper.h | 3 +- .../mock/src/os_account_manager_wrapper.cpp | 10 -- .../js_auto_fill_extension_test.cpp | 4 +- .../js_photo_editor_extension_impl_test.cpp | 14 ++- test/unittest/lifecycle_deal_test/BUILD.gn | 2 - test/unittest/lifecycle_test/BUILD.gn | 7 ++ .../unittest/main_element_utils_test/BUILD.gn | 3 - .../mission_ability_record_test/BUILD.gn | 1 - .../mission_data_storage_test/BUILD.gn | 4 +- .../mission_info_mgr_second_test/BUILD.gn | 4 +- test/unittest/mission_info_mgr_test/BUILD.gn | 4 +- test/unittest/mission_info_test/BUILD.gn | 4 +- .../mission_list_manager_first_test/BUILD.gn | 4 +- .../mission_list_manager_second_test/BUILD.gn | 4 +- .../mission_list_manager_test/BUILD.gn | 4 +- .../mission_list_manager_third_test/BUILD.gn | 4 +- .../mission_list_manager_ut_test/BUILD.gn | 3 - test/unittest/mission_list_test/BUILD.gn | 5 +- .../mission_listener_proxy_test/BUILD.gn | 4 +- test/unittest/mission_listener_test/BUILD.gn | 4 +- test/unittest/mission_test/BUILD.gn | 4 +- .../BUILD.gn | 3 - .../modular_object_connect_test/BUILD.gn | 2 - .../mock/include/os_account_manager_wrapper.h | 3 +- .../os_account_manager_wrapper_test.cpp | 14 +-- test/unittest/pending_want_key_test/BUILD.gn | 4 +- .../pending_want_manager_test/BUILD.gn | 3 +- .../pending_want_record_test/BUILD.gn | 1 - .../BUILD.gn | 4 +- .../BUILD.gn | 1 - .../BUILD.gn | 7 ++ .../quick_fix_manager_service_test/BUILD.gn | 14 +++ .../recovery_info_timer_test/BUILD.gn | 4 +- .../BUILD.gn | 4 +- .../resident_process_manager_test/BUILD.gn | 3 - .../restart_app_manager_test/BUILD.gn | 4 +- test/unittest/sender_info_test/BUILD.gn | 4 +- .../service_extension_context_test/BUILD.gn | 4 +- .../BUILD.gn | 3 +- .../skill_execute_callback_stub_test/BUILD.gn | 3 +- .../specified_mission_list_test/BUILD.gn | 4 +- test/unittest/start_options_test/BUILD.gn | 3 - .../stop_user_callback_proxy_test/BUILD.gn | 4 +- .../stop_user_callback_stub_test/BUILD.gn | 4 +- .../BUILD.gn | 3 - .../task_data_persistence_mgr_test/BUILD.gn | 4 +- .../BUILD.gn | 1 - .../BUILD.gn | 1 - .../ui_extension_record_factory_test/BUILD.gn | 4 +- .../want_receiver_proxy_test/BUILD.gn | 4 +- .../unittest/want_receiver_stub_test/BUILD.gn | 4 +- test/unittest/want_sender_info_test/BUILD.gn | 32 +---- .../want_sender_info_test.cpp | 21 ---- test/unittest/want_sender_proxy_test/BUILD.gn | 4 +- test/unittest/want_sender_stub_test/BUILD.gn | 4 +- test/unittest/wants_info_test/BUILD.gn | 26 +--- .../wants_info_test/wants_info_test.cpp | 16 --- test/unittest/window_config_test/BUILD.gn | 3 - .../BUILD.gn | 4 +- tools/aa/BUILD.gn | 4 + tools/ohos-aa/BUILD.gn | 2 + tools/ohos-aa/tests/BUILD.gn | 21 ++++ utils/global/freeze/BUILD.gn | 6 + 262 files changed, 832 insertions(+), 553 deletions(-) diff --git a/agent_runtime_framework/frameworks/js/napi/agent_manager/BUILD.gn b/agent_runtime_framework/frameworks/js/napi/agent_manager/BUILD.gn index cbff06c0ce..5fa70ef014 100644 --- a/agent_runtime_framework/frameworks/js/napi/agent_manager/BUILD.gn +++ b/agent_runtime_framework/frameworks/js/napi/agent_manager/BUILD.gn @@ -51,6 +51,8 @@ ohos_shared_library("js_agent_manager_utils") { } ohos_shared_library("agentmanager_napi") { + branch_protector_ret = "pac_ret" + sanitize = { cfi = true cfi_cross_dso = true diff --git a/agent_runtime_framework/interfaces/inner_api/BUILD.gn b/agent_runtime_framework/interfaces/inner_api/BUILD.gn index ad91963178..258ae50539 100644 --- a/agent_runtime_framework/interfaces/inner_api/BUILD.gn +++ b/agent_runtime_framework/interfaces/inner_api/BUILD.gn @@ -16,6 +16,8 @@ import("//build/ohos.gni") import("//foundation/ability/ability_runtime/ability_runtime.gni") ohos_shared_library("agent_fwk") { + branch_protector_ret = "pac_ret" + sanitize = { cfi = true cfi_cross_dso = true @@ -50,6 +52,8 @@ ohos_shared_library("agent_fwk") { } ohos_shared_library("agent_connection_manager") { + branch_protector_ret = "pac_ret" + sanitize = { cfi = true cfi_cross_dso = true @@ -114,6 +118,8 @@ config("agent_manager_config") { } ohos_shared_library("agent_manager") { + branch_protector_ret = "pac_ret" + sanitize = { cfi = true cfi_cross_dso = true diff --git a/cli_tool_framework/frameworks/js/napi/cli_tool_manager/BUILD.gn b/cli_tool_framework/frameworks/js/napi/cli_tool_manager/BUILD.gn index 59ab20e3b1..6e5c7d874e 100644 --- a/cli_tool_framework/frameworks/js/napi/cli_tool_manager/BUILD.gn +++ b/cli_tool_framework/frameworks/js/napi/cli_tool_manager/BUILD.gn @@ -20,6 +20,7 @@ ohos_source_set("cli_manager_error_utils_src") { cfi_cross_dso = true debug = false } + branch_protector_ret = "pac_ret" include_dirs = [ "include", @@ -51,6 +52,7 @@ ohos_source_set("js_cli_event_handler_manager_src") { cfi_cross_dso = true debug = false } + branch_protector_ret = "pac_ret" include_dirs = [ "include", @@ -75,6 +77,7 @@ ohos_shared_library("climanager_napi") { cfi_cross_dso = true debug = false } + branch_protector_ret = "pac_ret" include_dirs = [ "include", diff --git a/cli_tool_framework/frameworks/js/napi/function_manager/BUILD.gn b/cli_tool_framework/frameworks/js/napi/function_manager/BUILD.gn index e1683ca8ff..286df9355a 100644 --- a/cli_tool_framework/frameworks/js/napi/function_manager/BUILD.gn +++ b/cli_tool_framework/frameworks/js/napi/function_manager/BUILD.gn @@ -20,6 +20,7 @@ ohos_shared_library("functionmanager_napi") { cfi_cross_dso = true debug = false } + branch_protector_ret = "pac_ret" include_dirs = [ "include", diff --git a/cli_tool_framework/frameworks/js/napi/script_manager/BUILD.gn b/cli_tool_framework/frameworks/js/napi/script_manager/BUILD.gn index fc8313a871..6a5d2ab004 100644 --- a/cli_tool_framework/frameworks/js/napi/script_manager/BUILD.gn +++ b/cli_tool_framework/frameworks/js/napi/script_manager/BUILD.gn @@ -20,6 +20,7 @@ ohos_shared_library("scriptmanager_napi") { cfi_cross_dso = true debug = false } + branch_protector_ret = "pac_ret" include_dirs = [ "include", diff --git a/cli_tool_framework/interfaces/cli_tool/BUILD.gn b/cli_tool_framework/interfaces/cli_tool/BUILD.gn index c94c83b666..b939ea08c5 100644 --- a/cli_tool_framework/interfaces/cli_tool/BUILD.gn +++ b/cli_tool_framework/interfaces/cli_tool/BUILD.gn @@ -47,6 +47,7 @@ ohos_shared_library("cli_tool_client") { cfi_cross_dso = true debug = false } + branch_protector_ret = "pac_ret" public_configs = [ ":cli_tool_client_config" ] diff --git a/cli_tool_framework/interfaces/function/BUILD.gn b/cli_tool_framework/interfaces/function/BUILD.gn index cbc9aa5c20..4f42104c76 100644 --- a/cli_tool_framework/interfaces/function/BUILD.gn +++ b/cli_tool_framework/interfaces/function/BUILD.gn @@ -29,6 +29,7 @@ ohos_source_set("function_info") { cfi_cross_dso = true debug = false } + branch_protector_ret = "pac_ret" public_configs = [ ":function_info_config" ] diff --git a/cli_tool_framework/services/climgr/BUILD.gn b/cli_tool_framework/services/climgr/BUILD.gn index c1778e87c8..1da8c70bea 100644 --- a/cli_tool_framework/services/climgr/BUILD.gn +++ b/cli_tool_framework/services/climgr/BUILD.gn @@ -36,6 +36,7 @@ ohos_shared_library("climgr") { cfi_cross_dso = true debug = false } + branch_protector_ret = "pac_ret" shlib_type = "sa" configs = [ ":clisa_config" ] include_dirs = [ "${ability_runtime_path}/interfaces/kits/native/appkit/ability_bundle_manager_helper" ] diff --git a/cli_tool_framework/services/common/BUILD.gn b/cli_tool_framework/services/common/BUILD.gn index 661e18fc83..06ac08ea18 100644 --- a/cli_tool_framework/services/common/BUILD.gn +++ b/cli_tool_framework/services/common/BUILD.gn @@ -20,6 +20,7 @@ ohos_source_set("cli_common") { cfi_cross_dso = true debug = false } + branch_protector_ret = "pac_ret" include_dirs = [ "include", diff --git a/cli_tool_framework/test/unittest/cli_event_reply_manager_test/BUILD.gn b/cli_tool_framework/test/unittest/cli_event_reply_manager_test/BUILD.gn index 4788d7c946..556690bf7e 100644 --- a/cli_tool_framework/test/unittest/cli_event_reply_manager_test/BUILD.gn +++ b/cli_tool_framework/test/unittest/cli_event_reply_manager_test/BUILD.gn @@ -17,6 +17,13 @@ import("//foundation/ability/ability_runtime/ability_runtime.gni") module_output_path = "ability_runtime/ability_runtime/clitool" ohos_unittest("cli_event_reply_manager_test") { + branch_protector_ret = "pac_ret" + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + module_out_path = module_output_path include_dirs = [ diff --git a/cli_tool_framework/test/unittest/cli_event_report_test/BUILD.gn b/cli_tool_framework/test/unittest/cli_event_report_test/BUILD.gn index 6f8adc27e9..956671caf8 100644 --- a/cli_tool_framework/test/unittest/cli_event_report_test/BUILD.gn +++ b/cli_tool_framework/test/unittest/cli_event_report_test/BUILD.gn @@ -1,57 +1,62 @@ -# Copyright (c) 2026 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("//build/test.gni") -import("//foundation/ability/ability_runtime/ability_runtime.gni") - -module_output_path = "ability_runtime/ability_runtime/clitool" - -ohos_unittest("cli_event_report_test") { - module_out_path = module_output_path - - sources = [ - "cli_event_report_test.cpp", - "${cli_tool_framework_path}/services/common/src/cli_event_report.cpp", - ] - - include_dirs = [ - "${ability_runtime_services_path}/common/include", - "${ability_runtime_innerkits_path}/ability_manager/include/appmgr", - "${cli_tool_framework_path}/services/common/include", - "${cli_tool_framework_path}/interfaces/cli_tool/include", - ] - - deps = [ - "${ability_runtime_innerkits_path}/ability_manager:ability_manager", - "${ability_runtime_services_path}/common:hisysevent_report_static", - ] - - external_deps = [ - "ability_base:want", - "access_token:libaccesstoken_sdk", - "bundle_framework:appexecfwk_base", - "c_utils:utils", - "googletest:gmock_main", - "googletest:gtest_main", - "hilog:libhilog", - "hisysevent:libhisysevent", - "ipc:ipc_core", - ] - - defines = [ "AMS_LOG_TAG = \"CliEventReportTest\"" ] -} - -group("unittest") { - testonly = true - deps = [ ":cli_event_report_test" ] -} \ No newline at end of file +# Copyright (c) 2026 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/test.gni") +import("//foundation/ability/ability_runtime/ability_runtime.gni") + +module_output_path = "ability_runtime/ability_runtime/clitool" + +ohos_unittest("cli_event_report_test") { + module_out_path = module_output_path + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + + sources = [ + "cli_event_report_test.cpp", + "${cli_tool_framework_path}/services/common/src/cli_event_report.cpp", + ] + + include_dirs = [ + "${ability_runtime_services_path}/common/include", + "${ability_runtime_innerkits_path}/ability_manager/include/appmgr", + "${cli_tool_framework_path}/services/common/include", + "${cli_tool_framework_path}/interfaces/cli_tool/include", + ] + + deps = [ + "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_services_path}/common:hisysevent_report_static", + ] + + external_deps = [ + "ability_base:want", + "access_token:libaccesstoken_sdk", + "bundle_framework:appexecfwk_base", + "c_utils:utils", + "googletest:gmock_main", + "googletest:gtest_main", + "hilog:libhilog", + "hisysevent:libhisysevent", + "ipc:ipc_core", + ] + + defines = [ "AMS_LOG_TAG = \"CliEventReportTest\"" ] +} + +group("unittest") { + testonly = true + deps = [ ":cli_event_report_test" ] +} diff --git a/cli_tool_framework/test/unittest/cli_tool_mgr_client_test/BUILD.gn b/cli_tool_framework/test/unittest/cli_tool_mgr_client_test/BUILD.gn index da137fd5f4..74fac0316a 100644 --- a/cli_tool_framework/test/unittest/cli_tool_mgr_client_test/BUILD.gn +++ b/cli_tool_framework/test/unittest/cli_tool_mgr_client_test/BUILD.gn @@ -17,6 +17,13 @@ import("//foundation/ability/ability_runtime/ability_runtime.gni") module_output_path = "ability_runtime/ability_runtime/clitool" ohos_unittest("cli_tool_mgr_client_test") { + branch_protector_ret = "pac_ret" + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + module_out_path = module_output_path include_dirs = [ diff --git a/cli_tool_framework/test/unittest/cli_tool_mgr_service_test/BUILD.gn b/cli_tool_framework/test/unittest/cli_tool_mgr_service_test/BUILD.gn index 2c05a92c4c..934976f320 100644 --- a/cli_tool_framework/test/unittest/cli_tool_mgr_service_test/BUILD.gn +++ b/cli_tool_framework/test/unittest/cli_tool_mgr_service_test/BUILD.gn @@ -17,6 +17,13 @@ import("//foundation/ability/ability_runtime/ability_runtime.gni") module_output_path = "ability_runtime/ability_runtime/clitool" ohos_unittest("cli_tool_mgr_service_test") { + branch_protector_ret = "pac_ret" + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + module_out_path = module_output_path include_dirs = [ diff --git a/cli_tool_framework/test/unittest/function_info_test/BUILD.gn b/cli_tool_framework/test/unittest/function_info_test/BUILD.gn index 3c2d33517e..e41846f295 100644 --- a/cli_tool_framework/test/unittest/function_info_test/BUILD.gn +++ b/cli_tool_framework/test/unittest/function_info_test/BUILD.gn @@ -17,6 +17,13 @@ import("//foundation/ability/ability_runtime/ability_runtime.gni") module_output_path = "ability_runtime/ability_runtime/clitool" ohos_unittest("function_info_test") { + branch_protector_ret = "pac_ret" + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + module_out_path = module_output_path include_dirs = [ "${cli_tool_framework_path}/interfaces/function/include" ] diff --git a/cli_tool_framework/test/unittest/invoke_function_executor_test/BUILD.gn b/cli_tool_framework/test/unittest/invoke_function_executor_test/BUILD.gn index 906701066f..89c527b372 100644 --- a/cli_tool_framework/test/unittest/invoke_function_executor_test/BUILD.gn +++ b/cli_tool_framework/test/unittest/invoke_function_executor_test/BUILD.gn @@ -17,6 +17,13 @@ import("//foundation/ability/ability_runtime/ability_runtime.gni") module_output_path = "ability_runtime/ability_runtime/clitool" ohos_unittest("invoke_function_executor_test") { + branch_protector_ret = "pac_ret" + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + module_out_path = module_output_path # "mock/include" MUST come before the real interfaces/cli_tool/include so the diff --git a/cli_tool_framework/test/unittest/process_manager_test/BUILD.gn b/cli_tool_framework/test/unittest/process_manager_test/BUILD.gn index ddcc7885f5..575356a613 100644 --- a/cli_tool_framework/test/unittest/process_manager_test/BUILD.gn +++ b/cli_tool_framework/test/unittest/process_manager_test/BUILD.gn @@ -17,6 +17,13 @@ import("//foundation/ability/ability_runtime/ability_runtime.gni") module_output_path = "ability_runtime/ability_runtime/clitool" ohos_unittest("process_manager_test") { + branch_protector_ret = "pac_ret" + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + module_out_path = module_output_path include_dirs = [ diff --git a/frameworks/cj/ffi/ark_interop_helper/BUILD.gn b/frameworks/cj/ffi/ark_interop_helper/BUILD.gn index 3777db8e5d..f55168ee28 100644 --- a/frameworks/cj/ffi/ark_interop_helper/BUILD.gn +++ b/frameworks/cj/ffi/ark_interop_helper/BUILD.gn @@ -15,6 +15,8 @@ import("//build/ohos.gni") import("//foundation/ability/ability_runtime/ability_runtime.gni") ohos_shared_library("ark_interop_helper_ffi") { + branch_protector_ret = "pac_ret" + defines = [] sources = [ "ark_interop_helper.cpp" ] diff --git a/frameworks/ets/ani/share_extension_ability/BUILD.gn b/frameworks/ets/ani/share_extension_ability/BUILD.gn index 49e53ff9ff..6ff78a76a3 100644 --- a/frameworks/ets/ani/share_extension_ability/BUILD.gn +++ b/frameworks/ets/ani/share_extension_ability/BUILD.gn @@ -16,6 +16,8 @@ import("//build/ohos.gni") import("//foundation/ability/ability_runtime/ability_runtime.gni") ohos_shared_library("share_extension_ani") { + branch_protector_ret = "pac_ret" + sanitize = { cfi = true cfi_cross_dso = true diff --git a/frameworks/js/napi/abilityDataUriUtils/BUILD.gn b/frameworks/js/napi/abilityDataUriUtils/BUILD.gn index b0a1bd7857..39b7c339f9 100644 --- a/frameworks/js/napi/abilityDataUriUtils/BUILD.gn +++ b/frameworks/js/napi/abilityDataUriUtils/BUILD.gn @@ -35,6 +35,8 @@ gen_js_obj("ability_data_uri_utils_abc") { } ohos_shared_library("datauriutils") { + branch_protector_ret = "pac_ret" + sources = [ "ability_data_uri_utils_module.cpp" ] deps = [ diff --git a/frameworks/js/napi/ability_auto_startup_callback/BUILD.gn b/frameworks/js/napi/ability_auto_startup_callback/BUILD.gn index 876ebd20ad..0d7ff03df7 100644 --- a/frameworks/js/napi/ability_auto_startup_callback/BUILD.gn +++ b/frameworks/js/napi/ability_auto_startup_callback/BUILD.gn @@ -15,6 +15,8 @@ import("//build/ohos.gni") import("//foundation/ability/ability_runtime/ability_runtime.gni") ohos_shared_library("autostartupcallback") { + branch_protector_ret = "pac_ret" + include_dirs = [ "./", "${ability_runtime_napi_path}/inner/napi_common/", diff --git a/frameworks/js/napi/ability_auto_startup_manager/BUILD.gn b/frameworks/js/napi/ability_auto_startup_manager/BUILD.gn index d00e1a890e..833c072e98 100644 --- a/frameworks/js/napi/ability_auto_startup_manager/BUILD.gn +++ b/frameworks/js/napi/ability_auto_startup_manager/BUILD.gn @@ -15,6 +15,8 @@ import("//build/ohos.gni") import("//foundation/ability/ability_runtime/ability_runtime.gni") ohos_shared_library("autostartupmanager") { + branch_protector_ret = "pac_ret" + include_dirs = [ "${ability_runtime_napi_path}/ability_auto_startup_callback", "${ability_runtime_services_path}/common/include", diff --git a/frameworks/js/napi/ability_constant/BUILD.gn b/frameworks/js/napi/ability_constant/BUILD.gn index 8afff20fd0..b0357a6bbe 100644 --- a/frameworks/js/napi/ability_constant/BUILD.gn +++ b/frameworks/js/napi/ability_constant/BUILD.gn @@ -15,6 +15,8 @@ import("//build/ohos.gni") import("//foundation/ability/ability_runtime/ability_runtime.gni") ohos_shared_library("abilityconstant_napi") { + branch_protector_ret = "pac_ret" + include_dirs = [ "${ability_runtime_innerkits_path}/ability_manager/include", "${ability_runtime_services_path}/common/include", @@ -41,6 +43,8 @@ ohos_shared_library("abilityconstant_napi") { } ohos_shared_library("abilityconstant") { + branch_protector_ret = "pac_ret" + include_dirs = [ "${ability_runtime_innerkits_path}/ability_manager/include", "${ability_runtime_services_path}/common/include", diff --git a/frameworks/js/napi/ability_context/BUILD.gn b/frameworks/js/napi/ability_context/BUILD.gn index 7ebbdffb5c..a21e5d9cef 100644 --- a/frameworks/js/napi/ability_context/BUILD.gn +++ b/frameworks/js/napi/ability_context/BUILD.gn @@ -35,6 +35,8 @@ gen_js_obj("ability_context_abc") { } ohos_shared_library("abilitycontext_napi") { + branch_protector_ret = "pac_ret" + sources = [ "ability_context_module.cpp" ] cflags = [ diff --git a/frameworks/js/napi/ability_vertical_panel/BUILD.gn b/frameworks/js/napi/ability_vertical_panel/BUILD.gn index 2a8cde4aff..bfefa583c4 100644 --- a/frameworks/js/napi/ability_vertical_panel/BUILD.gn +++ b/frameworks/js/napi/ability_vertical_panel/BUILD.gn @@ -15,6 +15,8 @@ import("//build/ohos.gni") import("//foundation/ability/ability_runtime/ability_runtime.gni") ohos_shared_library("verticalpanelmanager_napi") { + branch_protector_ret = "pac_ret" + sanitize = { integer_overflow = true ubsan = true diff --git a/frameworks/js/napi/action_extension_ability/BUILD.gn b/frameworks/js/napi/action_extension_ability/BUILD.gn index 0553ca9e05..a08803e43c 100755 --- a/frameworks/js/napi/action_extension_ability/BUILD.gn +++ b/frameworks/js/napi/action_extension_ability/BUILD.gn @@ -35,6 +35,8 @@ gen_js_obj("action_extension_ability_abc") { } ohos_shared_library("actionextensionability_napi") { + branch_protector_ret = "pac_ret" + sources = [ "action_extension_ability_module.cpp" ] deps = [ diff --git a/frameworks/js/napi/app/ability_lifecycle_callback/BUILD.gn b/frameworks/js/napi/app/ability_lifecycle_callback/BUILD.gn index b06d092825..428015ec84 100644 --- a/frameworks/js/napi/app/ability_lifecycle_callback/BUILD.gn +++ b/frameworks/js/napi/app/ability_lifecycle_callback/BUILD.gn @@ -35,6 +35,8 @@ gen_js_obj("ability_lifecycle_callback_abc") { } ohos_shared_library("abilitylifecyclecallback") { + branch_protector_ret = "pac_ret" + sources = [ "ability_lifecycle_callback_module.cpp" ] deps = [ diff --git a/frameworks/js/napi/app/ability_stage/BUILD.gn b/frameworks/js/napi/app/ability_stage/BUILD.gn index 8379ecdda4..3f6e52046c 100644 --- a/frameworks/js/napi/app/ability_stage/BUILD.gn +++ b/frameworks/js/napi/app/ability_stage/BUILD.gn @@ -35,6 +35,8 @@ gen_js_obj("ability_stage_abc") { } ohos_shared_library("abilitystage") { + branch_protector_ret = "pac_ret" + sources = [ "ability_stage_module.cpp" ] deps = [ @@ -52,6 +54,8 @@ ohos_shared_library("abilitystage") { } ohos_shared_library("abilitystage_napi") { + branch_protector_ret = "pac_ret" + sources = [ "ability_stage_napi_module.cpp" ] deps = [ diff --git a/frameworks/js/napi/app/ability_stage_context/BUILD.gn b/frameworks/js/napi/app/ability_stage_context/BUILD.gn index c0508957bb..a2dc517c46 100644 --- a/frameworks/js/napi/app/ability_stage_context/BUILD.gn +++ b/frameworks/js/napi/app/ability_stage_context/BUILD.gn @@ -35,6 +35,8 @@ gen_js_obj("ability_stage_context_abc") { } ohos_shared_library("abilitystagecontext_napi") { + branch_protector_ret = "pac_ret" + sources = [ "ability_stage_context_module.cpp" ] deps = [ diff --git a/frameworks/js/napi/app/app_manager/BUILD.gn b/frameworks/js/napi/app/app_manager/BUILD.gn index bb5de575f8..7887c14562 100644 --- a/frameworks/js/napi/app/app_manager/BUILD.gn +++ b/frameworks/js/napi/app/app_manager/BUILD.gn @@ -15,6 +15,8 @@ import("//build/ohos.gni") import("//foundation/ability/ability_runtime/ability_runtime.gni") ohos_shared_library("appmanager_napi") { + branch_protector_ret = "pac_ret" + include_dirs = [] if (ability_runtime_graphics) { diff --git a/frameworks/js/napi/app/application_context/BUILD.gn b/frameworks/js/napi/app/application_context/BUILD.gn index 279eeab424..a816279e09 100644 --- a/frameworks/js/napi/app/application_context/BUILD.gn +++ b/frameworks/js/napi/app/application_context/BUILD.gn @@ -35,6 +35,8 @@ gen_js_obj("application_context_abc") { } ohos_shared_library("applicationcontext_napi") { + branch_protector_ret = "pac_ret" + sources = [ "application_context_module.cpp" ] cflags = [ diff --git a/frameworks/js/napi/app/application_state_change_callback/BUILD.gn b/frameworks/js/napi/app/application_state_change_callback/BUILD.gn index 39fc58e92a..49c60b079a 100644 --- a/frameworks/js/napi/app/application_state_change_callback/BUILD.gn +++ b/frameworks/js/napi/app/application_state_change_callback/BUILD.gn @@ -37,6 +37,8 @@ gen_js_obj("application_state_change_callback_abc") { } ohos_shared_library("applicationstatechangecallback") { + branch_protector_ret = "pac_ret" + sources = [ "application_state_change_callback_module.cpp" ] deps = [ diff --git a/frameworks/js/napi/app/context/BUILD.gn b/frameworks/js/napi/app/context/BUILD.gn index 831af0e667..5291777e2c 100644 --- a/frameworks/js/napi/app/context/BUILD.gn +++ b/frameworks/js/napi/app/context/BUILD.gn @@ -34,6 +34,8 @@ gen_js_obj("context_abc") { } ohos_shared_library("context_napi") { + branch_protector_ret = "pac_ret" + sources = [ "context_module.cpp" ] cflags = [ diff --git a/frameworks/js/napi/app/environment_callback/BUILD.gn b/frameworks/js/napi/app/environment_callback/BUILD.gn index 4aefb70ebe..8df46538cb 100644 --- a/frameworks/js/napi/app/environment_callback/BUILD.gn +++ b/frameworks/js/napi/app/environment_callback/BUILD.gn @@ -35,6 +35,8 @@ gen_js_obj("environment_callback_abc") { } ohos_shared_library("environmentcallback") { + branch_protector_ret = "pac_ret" + sources = [ "environment_callback_module.cpp" ] deps = [ diff --git a/frameworks/js/napi/app/js_app_manager/BUILD.gn b/frameworks/js/napi/app/js_app_manager/BUILD.gn index 795a168a38..e1b3b6a36f 100644 --- a/frameworks/js/napi/app/js_app_manager/BUILD.gn +++ b/frameworks/js/napi/app/js_app_manager/BUILD.gn @@ -15,6 +15,8 @@ import("//build/ohos.gni") import("//foundation/ability/ability_runtime/ability_runtime.gni") ohos_shared_library("appmanager") { + branch_protector_ret = "pac_ret" + include_dirs = ["${ability_runtime_utils_path}/global/common/include"] if (ability_runtime_graphics) { diff --git a/frameworks/js/napi/app/test_runner/BUILD.gn b/frameworks/js/napi/app/test_runner/BUILD.gn index 4d9da6349c..f6e6457e4a 100644 --- a/frameworks/js/napi/app/test_runner/BUILD.gn +++ b/frameworks/js/napi/app/test_runner/BUILD.gn @@ -35,6 +35,8 @@ gen_js_obj("test_runner_abc") { } ohos_shared_library("testrunner_napi") { + branch_protector_ret = "pac_ret" + sources = [ "test_runner_module.cpp" ] deps = [ diff --git a/frameworks/js/napi/application_context_constant/BUILD.gn b/frameworks/js/napi/application_context_constant/BUILD.gn index a916c487c7..6c812a9922 100644 --- a/frameworks/js/napi/application_context_constant/BUILD.gn +++ b/frameworks/js/napi/application_context_constant/BUILD.gn @@ -15,6 +15,8 @@ import("//build/ohos.gni") import("//foundation/ability/ability_runtime/ability_runtime.gni") ohos_shared_library("contextconstant_napi") { + branch_protector_ret = "pac_ret" + include_dirs = [] sources = [ "application_context_constant_module.cpp" ] diff --git a/frameworks/js/napi/auto_fill_extension_ability/BUILD.gn b/frameworks/js/napi/auto_fill_extension_ability/BUILD.gn index f1757b2157..818aa29180 100644 --- a/frameworks/js/napi/auto_fill_extension_ability/BUILD.gn +++ b/frameworks/js/napi/auto_fill_extension_ability/BUILD.gn @@ -35,6 +35,8 @@ gen_js_obj("auto_fill_extension_ability_abc") { } ohos_shared_library("autofillextensionability_napi") { + branch_protector_ret = "pac_ret" + sources = [ "auto_fill_extension_ability_module.cpp" ] deps = [ diff --git a/frameworks/js/napi/auto_fill_extension_context/BUILD.gn b/frameworks/js/napi/auto_fill_extension_context/BUILD.gn index cdb3cee610..da36c650d9 100755 --- a/frameworks/js/napi/auto_fill_extension_context/BUILD.gn +++ b/frameworks/js/napi/auto_fill_extension_context/BUILD.gn @@ -35,6 +35,8 @@ gen_js_obj("auto_fill_extension_context_abc") { } ohos_shared_library("autofillextensioncontext_napi") { + branch_protector_ret = "pac_ret" + sources = [ "auto_fill_extension_context_module.cpp" ] deps = [ diff --git a/frameworks/js/napi/auto_fill_manager/BUILD.gn b/frameworks/js/napi/auto_fill_manager/BUILD.gn index 3a829b67cd..f836678275 100644 --- a/frameworks/js/napi/auto_fill_manager/BUILD.gn +++ b/frameworks/js/napi/auto_fill_manager/BUILD.gn @@ -15,6 +15,8 @@ import("//build/ohos.gni") import("//foundation/ability/ability_runtime/ability_runtime.gni") ohos_shared_library("autofillmanager_napi") { + branch_protector_ret = "pac_ret" + sources = [ "auto_fill_manager_module.cpp", "js_auto_fill_manager.cpp", diff --git a/frameworks/js/napi/callee/BUILD.gn b/frameworks/js/napi/callee/BUILD.gn index 802a96d09b..b37e8b95a0 100644 --- a/frameworks/js/napi/callee/BUILD.gn +++ b/frameworks/js/napi/callee/BUILD.gn @@ -34,6 +34,8 @@ gen_js_obj("callee_abc") { } ohos_shared_library("callee_napi") { + branch_protector_ret = "pac_ret" + sources = [ "callee_module.cpp" ] deps = [ diff --git a/frameworks/js/napi/caller/BUILD.gn b/frameworks/js/napi/caller/BUILD.gn index 2a0d347f9c..9938cbb742 100644 --- a/frameworks/js/napi/caller/BUILD.gn +++ b/frameworks/js/napi/caller/BUILD.gn @@ -34,6 +34,8 @@ gen_js_obj("caller_abc") { } ohos_shared_library("caller_napi") { + branch_protector_ret = "pac_ret" + sources = [ "caller_module.cpp" ] cflags = [ diff --git a/frameworks/js/napi/completion_handler_for_abilitystartcallback/BUILD.gn b/frameworks/js/napi/completion_handler_for_abilitystartcallback/BUILD.gn index cf4e945310..07c4b7bdbc 100644 --- a/frameworks/js/napi/completion_handler_for_abilitystartcallback/BUILD.gn +++ b/frameworks/js/napi/completion_handler_for_abilitystartcallback/BUILD.gn @@ -15,6 +15,8 @@ import("//build/ohos.gni") import("//foundation/ability/ability_runtime/ability_runtime.gni") ohos_shared_library("completionhandlerforabilitystartcallback") { + branch_protector_ret = "pac_ret" + sanitize = { cfi = true cfi_cross_dso = true diff --git a/frameworks/js/napi/completion_handler_for_atomic_service/BUILD.gn b/frameworks/js/napi/completion_handler_for_atomic_service/BUILD.gn index 8605b4a49a..a56b74b7f1 100644 --- a/frameworks/js/napi/completion_handler_for_atomic_service/BUILD.gn +++ b/frameworks/js/napi/completion_handler_for_atomic_service/BUILD.gn @@ -15,6 +15,8 @@ import("//build/ohos.gni") import("//foundation/ability/ability_runtime/ability_runtime.gni") ohos_shared_library("completionhandlerforatomicservice") { + branch_protector_ret = "pac_ret" + sanitize = { cfi = true cfi_cross_dso = true diff --git a/frameworks/js/napi/configuration_constant/BUILD.gn b/frameworks/js/napi/configuration_constant/BUILD.gn index dad8c16a0c..67640da0fa 100644 --- a/frameworks/js/napi/configuration_constant/BUILD.gn +++ b/frameworks/js/napi/configuration_constant/BUILD.gn @@ -14,6 +14,8 @@ import("//build/ohos.gni") ohos_shared_library("configurationconstant_napi") { + branch_protector_ret = "pac_ret" + include_dirs = [] sources = [ "configuration_constant_napi_module.cpp" ] @@ -34,6 +36,8 @@ ohos_shared_library("configurationconstant_napi") { } ohos_shared_library("configurationconstant") { + branch_protector_ret = "pac_ret" + include_dirs = [] sources = [ "configuration_constant_module.cpp" ] diff --git a/frameworks/js/napi/embeddable_ui_ability/BUILD.gn b/frameworks/js/napi/embeddable_ui_ability/BUILD.gn index a0ba11cdd6..8a74ca6d86 100644 --- a/frameworks/js/napi/embeddable_ui_ability/BUILD.gn +++ b/frameworks/js/napi/embeddable_ui_ability/BUILD.gn @@ -35,6 +35,8 @@ gen_js_obj("embeddable_ui_ability_abc") { } ohos_shared_library("embeddableuiability_napi") { + branch_protector_ret = "pac_ret" + sources = [ "embeddable_ui_ability_module.cpp" ] deps = [ diff --git a/frameworks/js/napi/embeddable_ui_ability_context/BUILD.gn b/frameworks/js/napi/embeddable_ui_ability_context/BUILD.gn index 025fab8fd7..47e5bcb7ad 100644 --- a/frameworks/js/napi/embeddable_ui_ability_context/BUILD.gn +++ b/frameworks/js/napi/embeddable_ui_ability_context/BUILD.gn @@ -36,6 +36,8 @@ gen_js_obj("embeddable_ui_ability_context_abc") { } ohos_shared_library("embeddableuiabilitycontext_napi") { + branch_protector_ret = "pac_ret" + sources = [ "embeddable_ui_ability_context_module.cpp" ] deps = [ diff --git a/frameworks/js/napi/errorcode/BUILD.gn b/frameworks/js/napi/errorcode/BUILD.gn index 4adf473202..ccf1f9f61e 100644 --- a/frameworks/js/napi/errorcode/BUILD.gn +++ b/frameworks/js/napi/errorcode/BUILD.gn @@ -15,6 +15,8 @@ import("//build/ohos.gni") import("//foundation/ability/ability_runtime/ability_runtime.gni") ohos_shared_library("errorcode_napi") { + branch_protector_ret = "pac_ret" + include_dirs = [ "${ability_runtime_services_path}/common/include", ] diff --git a/frameworks/js/napi/extension_ability/BUILD.gn b/frameworks/js/napi/extension_ability/BUILD.gn index f5e6b15ae9..f907243218 100644 --- a/frameworks/js/napi/extension_ability/BUILD.gn +++ b/frameworks/js/napi/extension_ability/BUILD.gn @@ -35,6 +35,8 @@ gen_js_obj("extension_ability_abc") { } ohos_shared_library("extensionability_napi") { + branch_protector_ret = "pac_ret" + sources = [ "extension_ability_module.cpp" ] deps = [ diff --git a/frameworks/js/napi/extensioncontext/BUILD.gn b/frameworks/js/napi/extensioncontext/BUILD.gn index 512f486185..2c38e4c888 100644 --- a/frameworks/js/napi/extensioncontext/BUILD.gn +++ b/frameworks/js/napi/extensioncontext/BUILD.gn @@ -35,6 +35,8 @@ gen_js_obj("extension_context_abc") { } ohos_shared_library("extensioncontext_napi") { + branch_protector_ret = "pac_ret" + sources = [ "extension_context_module.cpp" ] deps = [ diff --git a/frameworks/js/napi/featureAbility/BUILD.gn b/frameworks/js/napi/featureAbility/BUILD.gn index 00283603a5..3eb9b85d9b 100644 --- a/frameworks/js/napi/featureAbility/BUILD.gn +++ b/frameworks/js/napi/featureAbility/BUILD.gn @@ -15,6 +15,8 @@ import("//build/ohos.gni") import("//foundation/ability/ability_runtime/ability_runtime.gni") ohos_shared_library("featureability") { + branch_protector_ret = "pac_ret" + configs = [ "${ability_runtime_services_path}/common:optimize_config" ] include_dirs = [ "./" ] diff --git a/frameworks/js/napi/feature_ability/BUILD.gn b/frameworks/js/napi/feature_ability/BUILD.gn index 1525b43f55..bbb63e54e9 100644 --- a/frameworks/js/napi/feature_ability/BUILD.gn +++ b/frameworks/js/napi/feature_ability/BUILD.gn @@ -15,6 +15,8 @@ import("//build/ohos.gni") import("//foundation/ability/ability_runtime/ability_runtime.gni") ohos_shared_library("featureability_napi") { + branch_protector_ret = "pac_ret" + include_dirs = [] sources = [ diff --git a/frameworks/js/napi/inner/napi_ability_common/BUILD.gn b/frameworks/js/napi/inner/napi_ability_common/BUILD.gn index e8c211b7d3..957fbc9117 100644 --- a/frameworks/js/napi/inner/napi_ability_common/BUILD.gn +++ b/frameworks/js/napi/inner/napi_ability_common/BUILD.gn @@ -19,6 +19,8 @@ config("napi_ability_common_public_config") { } ohos_shared_library("napi_ability_common") { + branch_protector_ret = "pac_ret" + public_configs = [ ":napi_ability_common_public_config", "${ability_runtime_native_path}/ability/native:ability_public_config", diff --git a/frameworks/js/napi/insight_intent/insight_intent/BUILD.gn b/frameworks/js/napi/insight_intent/insight_intent/BUILD.gn index b4b106633e..c8ab8bf7e1 100644 --- a/frameworks/js/napi/insight_intent/insight_intent/BUILD.gn +++ b/frameworks/js/napi/insight_intent/insight_intent/BUILD.gn @@ -15,6 +15,8 @@ import("//build/ohos.gni") import("//foundation/ability/ability_runtime/ability_runtime.gni") ohos_shared_library("insightintent_napi") { + branch_protector_ret = "pac_ret" + sources = [ "js_insight_intent.cpp", "native_module.cpp", diff --git a/frameworks/js/napi/insight_intent/insight_intent_decorator/BUILD.gn b/frameworks/js/napi/insight_intent/insight_intent_decorator/BUILD.gn index 4d88d54daa..53102e832d 100644 --- a/frameworks/js/napi/insight_intent/insight_intent_decorator/BUILD.gn +++ b/frameworks/js/napi/insight_intent/insight_intent_decorator/BUILD.gn @@ -15,6 +15,8 @@ import("//build/ohos.gni") import("//foundation/ability/ability_runtime/ability_runtime.gni") ohos_shared_library("insightintentdecorator_napi") { + branch_protector_ret = "pac_ret" + sources = [ "js_insight_intent_decorator.cpp", "native_module.cpp", diff --git a/frameworks/js/napi/insight_intent/insight_intent_driver/BUILD.gn b/frameworks/js/napi/insight_intent/insight_intent_driver/BUILD.gn index e53e9392c1..7efebbfb56 100644 --- a/frameworks/js/napi/insight_intent/insight_intent_driver/BUILD.gn +++ b/frameworks/js/napi/insight_intent/insight_intent_driver/BUILD.gn @@ -15,6 +15,8 @@ import("//build/ohos.gni") import("//foundation/ability/ability_runtime/ability_runtime.gni") ohos_shared_library("insightintentdriver_napi") { + branch_protector_ret = "pac_ret" + sources = [ "js_insight_intent_driver.cpp", "js_insight_intent_driver_utils.cpp", diff --git a/frameworks/js/napi/insight_intent/insight_intent_executor/BUILD.gn b/frameworks/js/napi/insight_intent/insight_intent_executor/BUILD.gn index add8c609eb..65b0560347 100644 --- a/frameworks/js/napi/insight_intent/insight_intent_executor/BUILD.gn +++ b/frameworks/js/napi/insight_intent/insight_intent_executor/BUILD.gn @@ -35,6 +35,8 @@ gen_js_obj("insight_intent_executor_abc") { } ohos_shared_library("insightintentexecutor_napi") { + branch_protector_ret = "pac_ret" + sources = [ "insight_intent_executor_module.cpp" ] deps = [ diff --git a/frameworks/js/napi/insight_intent/insight_intent_provider/BUILD.gn b/frameworks/js/napi/insight_intent/insight_intent_provider/BUILD.gn index e3c8287e28..873f7bcf4c 100644 --- a/frameworks/js/napi/insight_intent/insight_intent_provider/BUILD.gn +++ b/frameworks/js/napi/insight_intent/insight_intent_provider/BUILD.gn @@ -15,6 +15,8 @@ import("//build/ohos.gni") import("//foundation/ability/ability_runtime/ability_runtime.gni") ohos_shared_library("insightintentprovider_napi") { + branch_protector_ret = "pac_ret" + sanitize = { integer_overflow = true ubsan = true diff --git a/frameworks/js/napi/insight_intent_context/BUILD.gn b/frameworks/js/napi/insight_intent_context/BUILD.gn index 481434a247..4cc102afda 100644 --- a/frameworks/js/napi/insight_intent_context/BUILD.gn +++ b/frameworks/js/napi/insight_intent_context/BUILD.gn @@ -35,6 +35,8 @@ gen_js_obj("insight_intent_context_abc") { } ohos_shared_library("insightintentcontext_napi") { + branch_protector_ret = "pac_ret" + sources = [ "insight_intent_context_module.cpp" ] deps = [ diff --git a/frameworks/js/napi/js_child_process/BUILD.gn b/frameworks/js/napi/js_child_process/BUILD.gn index f3402e8fdc..a9b7df9fff 100644 --- a/frameworks/js/napi/js_child_process/BUILD.gn +++ b/frameworks/js/napi/js_child_process/BUILD.gn @@ -35,6 +35,8 @@ gen_js_obj("child_process_abc") { } ohos_shared_library("childprocess_napi") { + branch_protector_ret = "pac_ret" + sources = [ "native_module.cpp" ] deps = [ diff --git a/frameworks/js/napi/js_child_process_manager/BUILD.gn b/frameworks/js/napi/js_child_process_manager/BUILD.gn index f1878bb22f..70d1fc8e72 100644 --- a/frameworks/js/napi/js_child_process_manager/BUILD.gn +++ b/frameworks/js/napi/js_child_process_manager/BUILD.gn @@ -15,6 +15,8 @@ import("//build/ohos.gni") import("//foundation/ability/ability_runtime/ability_runtime.gni") ohos_shared_library("childprocessmanager_napi") { + branch_protector_ret = "pac_ret" + sources = [] configs = [ diff --git a/frameworks/js/napi/js_dialog_request/BUILD.gn b/frameworks/js/napi/js_dialog_request/BUILD.gn index 67289e22ac..544a11ea64 100755 --- a/frameworks/js/napi/js_dialog_request/BUILD.gn +++ b/frameworks/js/napi/js_dialog_request/BUILD.gn @@ -19,6 +19,8 @@ config("dialog_request_external_config") { } ohos_shared_library("dialogrequest_napi") { + branch_protector_ret = "pac_ret" + sources = [ "js_dialog_request.cpp", "js_dialog_request_callback.cpp", diff --git a/frameworks/js/napi/js_dialog_session/BUILD.gn b/frameworks/js/napi/js_dialog_session/BUILD.gn index b856b6ad4e..9071dfbfa6 100644 --- a/frameworks/js/napi/js_dialog_session/BUILD.gn +++ b/frameworks/js/napi/js_dialog_session/BUILD.gn @@ -15,6 +15,8 @@ import("//build/ohos.gni") import("//foundation/ability/ability_runtime/ability_runtime.gni") ohos_shared_library("dialogsession_napi") { + branch_protector_ret = "pac_ret" + sources = [ "js_dialog_session.cpp", "js_dialog_session_utils.cpp", diff --git a/frameworks/js/napi/js_mission_manager/BUILD.gn b/frameworks/js/napi/js_mission_manager/BUILD.gn index 9ef83552e7..b3781595f3 100755 --- a/frameworks/js/napi/js_mission_manager/BUILD.gn +++ b/frameworks/js/napi/js_mission_manager/BUILD.gn @@ -15,6 +15,8 @@ import("//build/ohos.gni") import("//foundation/ability/ability_runtime/ability_runtime.gni") ohos_shared_library("missionmanager") { + branch_protector_ret = "pac_ret" + sources = [ "js_mission_info_utils.cpp", "js_mission_listener.cpp", diff --git a/frameworks/js/napi/mission_manager/BUILD.gn b/frameworks/js/napi/mission_manager/BUILD.gn index d14259fc1c..60e6b4dac2 100644 --- a/frameworks/js/napi/mission_manager/BUILD.gn +++ b/frameworks/js/napi/mission_manager/BUILD.gn @@ -15,6 +15,8 @@ import("//build/ohos.gni") import("//foundation/ability/ability_runtime/ability_runtime.gni") ohos_shared_library("missionmanager_napi") { + branch_protector_ret = "pac_ret" + sources = [ "js_mission_info_utils.cpp", "js_mission_listener.cpp", @@ -75,6 +77,8 @@ ohos_shared_library("missionmanager_napi") { } ohos_shared_library("distributedmissionmanager") { + branch_protector_ret = "pac_ret" + include_dirs = [] configs = [ diff --git a/frameworks/js/napi/particleAbility/BUILD.gn b/frameworks/js/napi/particleAbility/BUILD.gn index 2a94331f47..5666faf399 100644 --- a/frameworks/js/napi/particleAbility/BUILD.gn +++ b/frameworks/js/napi/particleAbility/BUILD.gn @@ -15,6 +15,8 @@ import("//build/ohos.gni") import("//foundation/ability/ability_runtime/ability_runtime.gni") ohos_shared_library("particleability") { + branch_protector_ret = "pac_ret" + include_dirs = [ "${ability_runtime_napi_path}/featureAbility", "${ability_runtime_services_path}/common/include", diff --git a/frameworks/js/napi/photo_editor_extension_ability/BUILD.gn b/frameworks/js/napi/photo_editor_extension_ability/BUILD.gn index fd0678d174..bb05efc31f 100755 --- a/frameworks/js/napi/photo_editor_extension_ability/BUILD.gn +++ b/frameworks/js/napi/photo_editor_extension_ability/BUILD.gn @@ -36,6 +36,8 @@ gen_js_obj("photo_editor_extension_ability_abc") { } ohos_shared_library("photoeditorextensionability_napi") { + branch_protector_ret = "pac_ret" + sanitize = { integer_overflow = true ubsan = true diff --git a/frameworks/js/napi/photo_editor_extension_context/BUILD.gn b/frameworks/js/napi/photo_editor_extension_context/BUILD.gn index 3a0250fa49..dc2864b2f9 100755 --- a/frameworks/js/napi/photo_editor_extension_context/BUILD.gn +++ b/frameworks/js/napi/photo_editor_extension_context/BUILD.gn @@ -36,6 +36,8 @@ gen_js_obj("photo_editor_extension_context_abc") { } ohos_shared_library("photoeditorextensioncontext_napi") { + branch_protector_ret = "pac_ret" + sanitize = { integer_overflow = true ubsan = true diff --git a/frameworks/js/napi/quick_fix/BUILD.gn b/frameworks/js/napi/quick_fix/BUILD.gn index e32ebb2f20..42cf829b7b 100644 --- a/frameworks/js/napi/quick_fix/BUILD.gn +++ b/frameworks/js/napi/quick_fix/BUILD.gn @@ -15,6 +15,8 @@ import("//build/ohos.gni") import("//foundation/ability/ability_runtime/ability_runtime.gni") ohos_shared_library("quickfixmanager_napi") { + branch_protector_ret = "pac_ret" + sources = [ "js_application_quick_fix_info.cpp", "js_quick_fix_manager.cpp", diff --git a/frameworks/js/napi/service_extension_ability/BUILD.gn b/frameworks/js/napi/service_extension_ability/BUILD.gn index 91abec9b79..f60850e5a0 100644 --- a/frameworks/js/napi/service_extension_ability/BUILD.gn +++ b/frameworks/js/napi/service_extension_ability/BUILD.gn @@ -35,6 +35,8 @@ gen_js_obj("service_extension_ability_abc") { } ohos_shared_library("serviceextensionability_napi") { + branch_protector_ret = "pac_ret" + sources = [ "service_extension_ability_napi_module.cpp" ] deps = [ @@ -50,6 +52,8 @@ ohos_shared_library("serviceextensionability_napi") { } ohos_shared_library("serviceextensionability") { + branch_protector_ret = "pac_ret" + sources = [ "service_extension_ability_module.cpp" ] deps = [ diff --git a/frameworks/js/napi/service_extension_context/BUILD.gn b/frameworks/js/napi/service_extension_context/BUILD.gn index 84cd644117..1152ac05cb 100644 --- a/frameworks/js/napi/service_extension_context/BUILD.gn +++ b/frameworks/js/napi/service_extension_context/BUILD.gn @@ -35,6 +35,8 @@ gen_js_obj("service_extension_context_abc") { } ohos_shared_library("serviceextensioncontext_napi") { + branch_protector_ret = "pac_ret" + sources = [ "service_extension_context_module.cpp" ] deps = [ diff --git a/frameworks/js/napi/share_extension_ability/BUILD.gn b/frameworks/js/napi/share_extension_ability/BUILD.gn index 9388f58551..3fc34d0f8f 100755 --- a/frameworks/js/napi/share_extension_ability/BUILD.gn +++ b/frameworks/js/napi/share_extension_ability/BUILD.gn @@ -35,6 +35,8 @@ gen_js_obj("share_extension_ability_abc") { } ohos_shared_library("shareextensionability_napi") { + branch_protector_ret = "pac_ret" + sources = [ "share_extension_ability_module.cpp" ] deps = [ diff --git a/frameworks/js/napi/ui_extension_ability/BUILD.gn b/frameworks/js/napi/ui_extension_ability/BUILD.gn index af23dfd573..2718c9d450 100755 --- a/frameworks/js/napi/ui_extension_ability/BUILD.gn +++ b/frameworks/js/napi/ui_extension_ability/BUILD.gn @@ -35,6 +35,8 @@ gen_js_obj("ui_extension_ability_abc") { } ohos_shared_library("uiextensionability_napi") { + branch_protector_ret = "pac_ret" + sources = [ "ui_extension_ability_module.cpp" ] deps = [ diff --git a/frameworks/js/napi/ui_extension_context/BUILD.gn b/frameworks/js/napi/ui_extension_context/BUILD.gn index e49ad18138..453b372917 100755 --- a/frameworks/js/napi/ui_extension_context/BUILD.gn +++ b/frameworks/js/napi/ui_extension_context/BUILD.gn @@ -35,6 +35,8 @@ gen_js_obj("ui_extension_context_abc") { } ohos_shared_library("uiextensioncontext_napi") { + branch_protector_ret = "pac_ret" + sources = [ "ui_extension_context_module.cpp" ] deps = [ diff --git a/frameworks/js/napi/uri_permission/BUILD.gn b/frameworks/js/napi/uri_permission/BUILD.gn index 803fe38afd..b1bfd7f06d 100644 --- a/frameworks/js/napi/uri_permission/BUILD.gn +++ b/frameworks/js/napi/uri_permission/BUILD.gn @@ -15,6 +15,8 @@ import("//build/ohos.gni") import("//foundation/ability/ability_runtime/ability_runtime.gni") ohos_shared_library("uripermissionmanager_napi") { + branch_protector_ret = "pac_ret" + sources = [ "js_uri_perm_mgr.cpp", "native_module.cpp", diff --git a/frameworks/js/napi/wantConstant/BUILD.gn b/frameworks/js/napi/wantConstant/BUILD.gn index c52bde3d84..e92ab1f0e1 100644 --- a/frameworks/js/napi/wantConstant/BUILD.gn +++ b/frameworks/js/napi/wantConstant/BUILD.gn @@ -15,6 +15,8 @@ import("//build/ohos.gni") import("//foundation/ability/ability_runtime/ability_runtime.gni") ohos_shared_library("wantconstant") { + branch_protector_ret = "pac_ret" + include_dirs = [ "${ability_runtime_services_path}/common/include" ] sources = [ @@ -41,6 +43,8 @@ ohos_shared_library("wantconstant") { } ohos_shared_library("wantconstant_napi") { + branch_protector_ret = "pac_ret" + include_dirs = [ "${ability_runtime_services_path}/common/include" ] sources = [ diff --git a/frameworks/js/napi/wantagent/BUILD.gn b/frameworks/js/napi/wantagent/BUILD.gn index e22a82fa6d..347a2253c2 100644 --- a/frameworks/js/napi/wantagent/BUILD.gn +++ b/frameworks/js/napi/wantagent/BUILD.gn @@ -15,6 +15,8 @@ import("//build/ohos.gni") import("//foundation/ability/ability_runtime/ability_runtime.gni") ohos_shared_library("wantagent") { + branch_protector_ret = "pac_ret" + include_dirs = [ "${ability_runtime_services_path}/common/include", "${ability_runtime_path}/interfaces/kits/native/appkit/ability_runtime", diff --git a/frameworks/js/napi/wantagent/ability_want_agent/BUILD.gn b/frameworks/js/napi/wantagent/ability_want_agent/BUILD.gn index c4e3ebe814..79f58f0155 100644 --- a/frameworks/js/napi/wantagent/ability_want_agent/BUILD.gn +++ b/frameworks/js/napi/wantagent/ability_want_agent/BUILD.gn @@ -15,6 +15,8 @@ import("//build/ohos.gni") import("//foundation/ability/ability_runtime/ability_runtime.gni") ohos_shared_library("wantagent_napi") { + branch_protector_ret = "pac_ret" + configs = [ "${ability_runtime_services_path}/common:optimize_config" ] include_dirs = [ diff --git a/frameworks/native/ability/ability_runtime/local_call_container.cpp b/frameworks/native/ability/ability_runtime/local_call_container.cpp index 5b1e2ce0bf..7da50f54cf 100644 --- a/frameworks/native/ability/ability_runtime/local_call_container.cpp +++ b/frameworks/native/ability/ability_runtime/local_call_container.cpp @@ -464,13 +464,7 @@ void CallerConnection::OnRemoteStateChanged(const AppExecFwk::ElementName &eleme int32_t LocalCallContainer::GetCurrentUserId() { if (currentUserId_ == DEFAULT_INVAL_VALUE) { - auto osAccount = DelayedSingleton::GetInstance(); - if (osAccount == nullptr) { - TAG_LOGE(AAFwkTag::LOCAL_CALL, "null osAccount"); - return DEFAULT_INVAL_VALUE; - } - - osAccount->GetOsAccountLocalIdFromProcess(currentUserId_); + AppExecFwk::OsAccountManagerWrapper::GetOsAccountLocalIdFromProcess(currentUserId_); } TAG_LOGD(AAFwkTag::LOCAL_CALL, "currentUserId %{public}d", currentUserId_); return currentUserId_; diff --git a/frameworks/native/ability/native/BUILD.gn b/frameworks/native/ability/native/BUILD.gn index 1e09763745..9b8130f7cf 100644 --- a/frameworks/native/ability/native/BUILD.gn +++ b/frameworks/native/ability/native/BUILD.gn @@ -641,6 +641,8 @@ config("extensionkit_public_config") { } ohos_shared_library("extensionkit_native") { + branch_protector_ret = "pac_ret" + defines = [ "AMS_LOG_TAG = \"Ability\"" ] defines += [ "AMS_LOG_DOMAIN = 0xD001300" ] include_dirs = [ @@ -721,6 +723,8 @@ ohos_shared_library("extensionkit_native") { } ohos_shared_library("cj_extensionkit_native") { + branch_protector_ret = "pac_ret" + sanitize = { integer_overflow = true ubsan = true @@ -793,6 +797,8 @@ config("insight_intent_executor_public_config") { } ohos_shared_library("insight_intent_executor") { + branch_protector_ret = "pac_ret" + sources = [ "${ability_runtime_native_path}/ability/native/insight_intent_executor/ets_insight_intent_executor_instance.cpp", "${ability_runtime_native_path}/ability/native/insight_intent_executor/insight_intent_delay_result_callback_mgr.cpp", @@ -849,6 +855,8 @@ ohos_shared_library("insight_intent_executor") { } ohos_shared_library("insight_intent_executor_ani") { + branch_protector_ret = "pac_ret" + sanitize = { cfi = true cfi_cross_dso = true @@ -916,6 +924,8 @@ ohos_shared_library("insight_intent_executor_ani") { } ohos_shared_library("cj_insight_intent_executor") { + branch_protector_ret = "pac_ret" + sanitize = { integer_overflow = true ubsan = true @@ -1124,6 +1134,8 @@ ohos_shared_library("ui_ability_ani") { } ohos_shared_library("uiabilitykit_native") { + branch_protector_ret = "pac_ret" + include_dirs = [ "${ability_runtime_path}/interfaces/kits/native/ability/native", "${ability_runtime_path}/interfaces/kits/native/ability/native/ability_runtime", @@ -1263,6 +1275,8 @@ ohos_shared_library("uiabilitykit_native") { } ohos_shared_library("ability_thread") { + branch_protector_ret = "pac_ret" + configs = [ "${ability_runtime_services_path}/common:optimize_config" ] include_dirs = [ @@ -1332,6 +1346,8 @@ ohos_shared_library("ability_thread") { } ohos_shared_library("ets_form_extension") { + branch_protector_ret = "pac_ret" + sanitize = { integer_overflow = true ubsan = true @@ -1413,6 +1429,8 @@ ohos_shared_library("ets_form_extension") { } ohos_shared_library("form_extension") { + branch_protector_ret = "pac_ret" + defines = [ "AMS_LOG_TAG = \"Ability\"" ] defines += [ "AMS_LOG_DOMAIN = 0xD001300" ] if (ability_runtime_graphics) { @@ -1484,6 +1502,8 @@ ohos_shared_library("form_extension") { } ohos_shared_library("cj_form_extension") { + branch_protector_ret = "pac_ret" + sanitize = { integer_overflow = true ubsan = true @@ -1554,6 +1574,8 @@ ohos_shared_library("cj_form_extension") { } ohos_shared_library("form_extension_module") { + branch_protector_ret = "pac_ret" + include_dirs = [ "${ability_runtime_path}/interfaces/inner_api/ability_manager/include", "${ability_runtime_path}/interfaces/inner_api/runtime/include", @@ -1603,6 +1625,8 @@ ohos_shared_library("form_extension_module") { } ohos_shared_library("service_extension") { + branch_protector_ret = "pac_ret" + configs = [ "${ability_runtime_services_path}/common:optimize_config" ] defines = [ "AMS_LOG_TAG = \"Ability\"" ] @@ -1757,6 +1781,8 @@ ohos_shared_library("app_service_extension_ani") { } ohos_shared_library("service_extension_ani") { + branch_protector_ret = "pac_ret" + sanitize = { cfi = true cfi_cross_dso = true @@ -2307,6 +2333,8 @@ ohos_shared_library("continuation_ipc") { } ohos_shared_library("data_ability_helper") { + branch_protector_ret = "pac_ret" + include_dirs = [ "${ability_runtime_path}/interfaces/kits/native/ability/native" ] @@ -2360,6 +2388,8 @@ ohos_shared_library("data_ability_helper") { } ohos_shared_library("service_extension_module") { + branch_protector_ret = "pac_ret" + include_dirs = [ "${ability_runtime_path}/interfaces/inner_api/ability_manager/include", "${ability_runtime_path}/interfaces/inner_api/runtime/include", @@ -2427,6 +2457,12 @@ config("ability_business_error_public_config") { ohos_shared_library("ability_business_error") { branch_protector_ret = "pac_ret" + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + sources = [ "${ability_runtime_native_path}/ability/native/ability_business_error/ability_business_error.cpp" ] configs = [ ":ability_business_error_config" ] @@ -2535,6 +2571,8 @@ config("ui_extension_public_config") { } ohos_shared_library("ui_extension") { + branch_protector_ret = "pac_ret" + include_dirs = [ "${ability_runtime_path}/interfaces/kits/native/ability/native/ui_service_extension_ability/connection", "${ability_runtime_path}/frameworks/ets/ani/ui_extension_ability/include", @@ -2614,6 +2652,8 @@ ohos_shared_library("ui_extension") { } ohos_shared_library("photo_editor_extension_ani") { + branch_protector_ret = "pac_ret" + sanitize = { integer_overflow = true ubsan = true @@ -2714,6 +2754,8 @@ config("ui_extension_ani_public_config") { } ohos_shared_library("ui_extension_ani") { + branch_protector_ret = "pac_ret" + sanitize = { cfi = true cfi_cross_dso = true @@ -2813,6 +2855,8 @@ ohos_shared_library("ui_extension_ani") { } ohos_shared_library("cj_ui_extension") { + branch_protector_ret = "pac_ret" + sanitize = { integer_overflow = true ubsan = true @@ -2890,6 +2934,8 @@ ohos_shared_library("cj_ui_extension") { } ohos_shared_library("ui_extension_module") { + branch_protector_ret = "pac_ret" + include_dirs = [ "${ability_runtime_path}/interfaces/kits/native/ability/native/ui_extension_ability" ] sources = [ "${ability_runtime_native_path}/ability/native/ui_extension_ability/ui_extension_module_loader.cpp" ] @@ -2944,6 +2990,8 @@ config("share_extension_config") { } ohos_shared_library("share_extension") { + branch_protector_ret = "pac_ret" + configs = [ ":share_extension_config", "${ability_runtime_services_path}/common:optimize_config", @@ -2996,6 +3044,8 @@ ohos_shared_library("share_extension") { } ohos_shared_library("cj_share_extension") { + branch_protector_ret = "pac_ret" + sanitize = { integer_overflow = true ubsan = true @@ -3058,6 +3108,8 @@ config("action_extension_config") { } ohos_shared_library("action_extension") { + branch_protector_ret = "pac_ret" + configs = [ ":action_extension_config", "${ability_runtime_services_path}/common:optimize_config", @@ -3110,6 +3162,8 @@ ohos_shared_library("action_extension") { } ohos_shared_library("cj_action_extension") { + branch_protector_ret = "pac_ret" + sanitize = { integer_overflow = true ubsan = true @@ -3159,6 +3213,8 @@ ohos_shared_library("cj_action_extension") { } ohos_shared_library("share_extension_module") { + branch_protector_ret = "pac_ret" + sources = [ "${ability_runtime_native_path}/ability/native/share_extension_ability/share_extension_module_loader.cpp" ] configs = [ @@ -3204,6 +3260,12 @@ ohos_shared_library("share_extension_module") { ohos_shared_library("auto_startup_callback") { branch_protector_ret = "pac_ret" + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + include_dirs = [ "${ability_runtime_path}/interfaces/kits/native/ability/native/ability_business_error" ] sources = [ @@ -3229,6 +3291,8 @@ ohos_shared_library("auto_startup_callback") { } ohos_shared_library("action_extension_module") { + branch_protector_ret = "pac_ret" + sources = [ "${ability_runtime_native_path}/ability/native/action_extension_ability/action_extension_module_loader.cpp" ] configs = [ @@ -3520,6 +3584,8 @@ config("auto_fill_extension_config") { } ohos_shared_library("auto_fill_extension") { + branch_protector_ret = "pac_ret" + public_configs = [ ":auto_fill_extension_config" ] configs = [ "${ability_runtime_services_path}/common:optimize_config" ] @@ -3653,6 +3719,8 @@ ohos_shared_library("auto_fill_extension_ani") { } ohos_shared_library("auto_fill_extension_util") { + branch_protector_ret = "pac_ret" + sanitize = { integer_overflow = true ubsan = true @@ -3687,6 +3755,8 @@ ohos_shared_library("auto_fill_extension_util") { } ohos_shared_library("auto_fill_extension_module") { + branch_protector_ret = "pac_ret" + sources = [ "${ability_runtime_native_path}/ability/native/auto_fill_extension_ability/auto_fill_extension_module_loader.cpp" ] configs = [ @@ -3745,6 +3815,8 @@ config("photo_editor_extension_config") { } ohos_shared_library("photo_editor_extension") { + branch_protector_ret = "pac_ret" + sanitize = { integer_overflow = true ubsan = true @@ -3811,6 +3883,8 @@ ohos_shared_library("photo_editor_extension") { } ohos_shared_library("cj_photo_editor_extension") { + branch_protector_ret = "pac_ret" + sanitize = { integer_overflow = true ubsan = true @@ -3871,6 +3945,8 @@ ohos_shared_library("cj_photo_editor_extension") { } ohos_shared_library("photo_editor_extension_module") { + branch_protector_ret = "pac_ret" + sanitize = { integer_overflow = true ubsan = true diff --git a/frameworks/native/appkit/BUILD.gn b/frameworks/native/appkit/BUILD.gn index 0ac6e8bb9c..b83fe7645f 100644 --- a/frameworks/native/appkit/BUILD.gn +++ b/frameworks/native/appkit/BUILD.gn @@ -75,6 +75,8 @@ config("appkit_public_config") { # build so ohos_shared_library("appkit_native") { + branch_protector_ret = "pac_ret" + include_dirs = [ "native", "${ability_runtime_path}/ets_environment/interfaces/inner_api", @@ -353,6 +355,8 @@ ohos_shared_library("appkit_native") { } ohos_shared_library("ability_stage_ani") { + branch_protector_ret = "pac_ret" + sanitize = { cfi = true cfi_cross_dso = true @@ -784,6 +788,12 @@ config("application_context_manager_config") { ohos_shared_library("appkit_manager_helper") { branch_protector_ret = "pac_ret" + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + include_dirs = [ "native", "${ability_runtime_path}/interfaces/kits/native/appkit/ability_runtime/app", diff --git a/frameworks/native/appkit/ability_runtime/context/context_impl.cpp b/frameworks/native/appkit/ability_runtime/context/context_impl.cpp index 0879f77393..2753c7a58d 100644 --- a/frameworks/native/appkit/ability_runtime/context/context_impl.cpp +++ b/frameworks/native/appkit/ability_runtime/context/context_impl.cpp @@ -839,12 +839,7 @@ int ContextImpl::GetCurrentAccountId() const { HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); int userId = 0; - auto instance = DelayedSingleton::GetInstance(); - if (instance == nullptr) { - TAG_LOGE(AAFwkTag::APPKIT, "null instance"); - return userId; - } - instance->GetOsAccountLocalIdFromProcess(userId); + AppExecFwk::OsAccountManagerWrapper::GetOsAccountLocalIdFromProcess(userId); TAG_LOGD(AAFwkTag::APPKIT, "userId: %{public}d", userId); return userId; } @@ -853,12 +848,7 @@ int ContextImpl::GetCurrentActiveAccountId() const { HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); std::vector accountIds; - auto instance = DelayedSingleton::GetInstance(); - if (instance == nullptr) { - TAG_LOGE(AAFwkTag::APPKIT, "null instance"); - return 0; - } - ErrCode ret = instance->QueryActiveOsAccountIds(accountIds); + ErrCode ret = AppExecFwk::OsAccountManagerWrapper::QueryActiveOsAccountIds(accountIds); if (ret != ERR_OK) { TAG_LOGE(AAFwkTag::APPKIT, "ContextImpl::GetCurrentActiveAccountId error. ret: %{public}d", ret); return 0; diff --git a/frameworks/native/appkit/app/context_deal.cpp b/frameworks/native/appkit/app/context_deal.cpp index c7e94f17c6..8fe51488b9 100644 --- a/frameworks/native/appkit/app/context_deal.cpp +++ b/frameworks/native/appkit/app/context_deal.cpp @@ -236,7 +236,7 @@ bool ContextDeal::IsCreateBySystemApp() const int ContextDeal::GetCurrentAccountId() const { int userId = 0; - DelayedSingleton::GetInstance()->GetOsAccountLocalIdFromProcess(userId); + OsAccountManagerWrapper::GetOsAccountLocalIdFromProcess(userId); TAG_LOGD(AAFwkTag::APPKIT, "userId: %{public}d", userId); return userId; } diff --git a/frameworks/native/insight_intent/insight_intent_context/BUILD.gn b/frameworks/native/insight_intent/insight_intent_context/BUILD.gn index d1bfb62e43..20ec2daaa1 100644 --- a/frameworks/native/insight_intent/insight_intent_context/BUILD.gn +++ b/frameworks/native/insight_intent/insight_intent_context/BUILD.gn @@ -22,6 +22,8 @@ config("insight_intent_context_public_config") { } ohos_shared_library("insightintentcontext") { + branch_protector_ret = "pac_ret" + sources = [ "insight_intent_context.cpp", "js_insight_intent_context.cpp", @@ -58,6 +60,8 @@ ohos_shared_library("insightintentcontext") { } ohos_shared_library("cj_insightintentcontext") { + branch_protector_ret = "pac_ret" + sanitize = { integer_overflow = true ubsan = true diff --git a/frameworks/simulator/ability_simulator/BUILD.gn b/frameworks/simulator/ability_simulator/BUILD.gn index cbe9c17249..5ff9a639cf 100644 --- a/frameworks/simulator/ability_simulator/BUILD.gn +++ b/frameworks/simulator/ability_simulator/BUILD.gn @@ -21,6 +21,8 @@ config("ability_simulator_public_config") { } ohos_shared_library("ability_simulator_inner") { + branch_protector_ret = "pac_ret" + if (is_mingw || is_mac) { defines = [] if (is_mingw) { diff --git a/frameworks/simulator/napi_module/ability/BUILD.gn b/frameworks/simulator/napi_module/ability/BUILD.gn index c297b1fd52..003a60c2a2 100644 --- a/frameworks/simulator/napi_module/ability/BUILD.gn +++ b/frameworks/simulator/napi_module/ability/BUILD.gn @@ -21,6 +21,8 @@ gen_js_src_binary("ability") { } ohos_shared_library("ability_napi") { + branch_protector_ret = "pac_ret" + if (is_mingw) { defines = [ "WINDOWS_PLATFORM" ] } else { diff --git a/frameworks/simulator/napi_module/ability_constant/BUILD.gn b/frameworks/simulator/napi_module/ability_constant/BUILD.gn index 6f237cd40b..6f9f4c82c5 100644 --- a/frameworks/simulator/napi_module/ability_constant/BUILD.gn +++ b/frameworks/simulator/napi_module/ability_constant/BUILD.gn @@ -15,6 +15,8 @@ import("//build/ohos.gni") import("//foundation/ability/ability_runtime/ability_runtime.gni") ohos_shared_library("abilityconstant") { + branch_protector_ret = "pac_ret" + include_dirs = [ "${ability_runtime_innerkits_path}/ability_manager/include", "${ability_runtime_innerkits_path}/ability_manager/include/continuation", diff --git a/frameworks/simulator/napi_module/ability_context/BUILD.gn b/frameworks/simulator/napi_module/ability_context/BUILD.gn index 91e6fb824d..47034568ad 100644 --- a/frameworks/simulator/napi_module/ability_context/BUILD.gn +++ b/frameworks/simulator/napi_module/ability_context/BUILD.gn @@ -21,6 +21,8 @@ gen_js_src_binary("ability_context") { } ohos_shared_library("abilitycontext_napi") { + branch_protector_ret = "pac_ret" + if (is_mingw) { defines = [ "WINDOWS_PLATFORM" ] } else { diff --git a/frameworks/simulator/napi_module/ability_stage/BUILD.gn b/frameworks/simulator/napi_module/ability_stage/BUILD.gn index e3d2244c07..37af53189e 100644 --- a/frameworks/simulator/napi_module/ability_stage/BUILD.gn +++ b/frameworks/simulator/napi_module/ability_stage/BUILD.gn @@ -21,6 +21,8 @@ gen_js_src_binary("ability_stage") { } ohos_shared_library("abilitystage") { + branch_protector_ret = "pac_ret" + if (is_mingw) { defines = [ "WINDOWS_PLATFORM" ] } else { diff --git a/frameworks/simulator/napi_module/ability_stage_context/BUILD.gn b/frameworks/simulator/napi_module/ability_stage_context/BUILD.gn index a53ad22969..32b5f8e999 100644 --- a/frameworks/simulator/napi_module/ability_stage_context/BUILD.gn +++ b/frameworks/simulator/napi_module/ability_stage_context/BUILD.gn @@ -21,6 +21,8 @@ gen_js_src_binary("ability_stage_context") { } ohos_shared_library("abilitystagecontext_napi") { + branch_protector_ret = "pac_ret" + if (is_mingw) { defines = [ "WINDOWS_PLATFORM" ] } else { diff --git a/frameworks/simulator/napi_module/application_context/BUILD.gn b/frameworks/simulator/napi_module/application_context/BUILD.gn index 533fbf9c15..d078495dfd 100644 --- a/frameworks/simulator/napi_module/application_context/BUILD.gn +++ b/frameworks/simulator/napi_module/application_context/BUILD.gn @@ -21,6 +21,8 @@ gen_js_src_binary("application_context") { } ohos_shared_library("applicationcontext_napi") { + branch_protector_ret = "pac_ret" + if (is_mingw) { defines = [ "WINDOWS_PLATFORM" ] } else { diff --git a/frameworks/simulator/napi_module/callee/BUILD.gn b/frameworks/simulator/napi_module/callee/BUILD.gn index 7fc28faf74..28b188da71 100644 --- a/frameworks/simulator/napi_module/callee/BUILD.gn +++ b/frameworks/simulator/napi_module/callee/BUILD.gn @@ -21,6 +21,8 @@ gen_js_src_binary("callee") { } ohos_shared_library("callee") { + branch_protector_ret = "pac_ret" + if (is_mingw) { defines = [ "WINDOWS_PLATFORM" ] } else { diff --git a/frameworks/simulator/napi_module/caller/BUILD.gn b/frameworks/simulator/napi_module/caller/BUILD.gn index cd8058c5bf..5b4df12793 100644 --- a/frameworks/simulator/napi_module/caller/BUILD.gn +++ b/frameworks/simulator/napi_module/caller/BUILD.gn @@ -21,6 +21,8 @@ gen_js_src_binary("caller") { } ohos_shared_library("caller_napi") { + branch_protector_ret = "pac_ret" + if (is_mingw) { defines = [ "WINDOWS_PLATFORM" ] } else { diff --git a/frameworks/simulator/napi_module/configuration_constant/BUILD.gn b/frameworks/simulator/napi_module/configuration_constant/BUILD.gn index 3d837aa8a2..652a6a7a70 100644 --- a/frameworks/simulator/napi_module/configuration_constant/BUILD.gn +++ b/frameworks/simulator/napi_module/configuration_constant/BUILD.gn @@ -15,6 +15,8 @@ import("//build/ohos.gni") import("//foundation/ability/ability_runtime/ability_runtime.gni") ohos_shared_library("configurationconstant") { + branch_protector_ret = "pac_ret" + include_dirs = [ "${resource_management_path}/interfaces/inner_api/include" ] sources = [ "${ability_runtime_napi_path}/configuration_constant/configuration_constant_module.cpp" ] diff --git a/frameworks/simulator/napi_module/context/BUILD.gn b/frameworks/simulator/napi_module/context/BUILD.gn index 0b612f4e58..dbb3e03764 100644 --- a/frameworks/simulator/napi_module/context/BUILD.gn +++ b/frameworks/simulator/napi_module/context/BUILD.gn @@ -21,6 +21,8 @@ gen_js_src_binary("context") { } ohos_shared_library("context_napi") { + branch_protector_ret = "pac_ret" + if (is_mingw) { defines = [ "WINDOWS_PLATFORM" ] } else { diff --git a/frameworks/simulator/napi_module/embeddable_ui_ability/BUILD.gn b/frameworks/simulator/napi_module/embeddable_ui_ability/BUILD.gn index ab430a396b..d1afb57af7 100644 --- a/frameworks/simulator/napi_module/embeddable_ui_ability/BUILD.gn +++ b/frameworks/simulator/napi_module/embeddable_ui_ability/BUILD.gn @@ -20,6 +20,8 @@ gen_js_src_binary("embeddable_ui_ability") { } ohos_shared_library("embeddableuiability_napi") { + branch_protector_ret = "pac_ret" + if (is_mingw) { defines = [ "WINDOWS_PLATFORM" ] } else { diff --git a/frameworks/simulator/napi_module/embeddable_ui_ability_context/BUILD.gn b/frameworks/simulator/napi_module/embeddable_ui_ability_context/BUILD.gn index 7dd5205e2e..77ef4be910 100644 --- a/frameworks/simulator/napi_module/embeddable_ui_ability_context/BUILD.gn +++ b/frameworks/simulator/napi_module/embeddable_ui_ability_context/BUILD.gn @@ -20,6 +20,8 @@ gen_js_src_binary("embeddable_ui_ability_context") { } ohos_shared_library("embeddeduiextensionability_napi") { + branch_protector_ret = "pac_ret" + if (is_mingw) { defines = [ "WINDOWS_PLATFORM" ] } else { diff --git a/frameworks/simulator/napi_module/uiability/BUILD.gn b/frameworks/simulator/napi_module/uiability/BUILD.gn index 9aae2ff096..e251749f03 100644 --- a/frameworks/simulator/napi_module/uiability/BUILD.gn +++ b/frameworks/simulator/napi_module/uiability/BUILD.gn @@ -21,6 +21,8 @@ gen_js_src_binary("ability") { } ohos_shared_library("uiability") { + branch_protector_ret = "pac_ret" + if (is_mingw) { defines = [ "WINDOWS_PLATFORM" ] } else { diff --git a/frameworks/simulator/napi_module/want_constant/BUILD.gn b/frameworks/simulator/napi_module/want_constant/BUILD.gn index a1d4a08214..5c9ebac1f0 100644 --- a/frameworks/simulator/napi_module/want_constant/BUILD.gn +++ b/frameworks/simulator/napi_module/want_constant/BUILD.gn @@ -15,6 +15,8 @@ import("//build/ohos.gni") import("//foundation/ability/ability_runtime/ability_runtime.gni") ohos_shared_library("wantconstant_napi") { + branch_protector_ret = "pac_ret" + sources = [ "${ability_runtime_napi_path}/wantConstant/native_module.cpp", "${ability_runtime_napi_path}/wantConstant/want_constant.cpp", diff --git a/frameworks/simulator/osal/BUILD.gn b/frameworks/simulator/osal/BUILD.gn index c886210738..7387e4d44b 100644 --- a/frameworks/simulator/osal/BUILD.gn +++ b/frameworks/simulator/osal/BUILD.gn @@ -22,6 +22,8 @@ config("simulator_osal_public_config") { } ohos_source_set("simulator_osal") { + branch_protector_ret = "pac_ret" + sources = [] public_configs = [ ":simulator_osal_public_config" ] diff --git a/frameworks/simulator/test/BUILD.gn b/frameworks/simulator/test/BUILD.gn index 83cbc861ba..7b871e6f61 100644 --- a/frameworks/simulator/test/BUILD.gn +++ b/frameworks/simulator/test/BUILD.gn @@ -15,6 +15,8 @@ import("//build/ohos.gni") import("//foundation/ability/ability_runtime/ability_runtime.gni") ohos_executable("ability_simulator_test") { + branch_protector_ret = "pac_ret" + sources = [ "src/main.cpp" ] deps = [ "${ability_runtime_path}/frameworks/simulator/ability_simulator:ability_simulator" ] diff --git a/interfaces/inner_api/ability_manager/BUILD.gn b/interfaces/inner_api/ability_manager/BUILD.gn index 9c74375c1f..e1db218a9b 100644 --- a/interfaces/inner_api/ability_manager/BUILD.gn +++ b/interfaces/inner_api/ability_manager/BUILD.gn @@ -65,6 +65,16 @@ config("ability_manager_public_config") { ohos_shared_library("ability_manager") { use_exceptions = true branch_protector_ret = "pac_ret" + sanitize = { + integer_overflow = true + ubsan = true + boundary_sanitize = true + cfi = true + cfi_cross_dso = true + cfi_vcall_icall_only = true + cfi_policy = "adaptive" + debug = false + } sources = [ "${ability_runtime_native_path}/ability/native/data_ability_operation.cpp", @@ -270,6 +280,12 @@ ohos_shared_library("ability_start_options") { ohos_shared_library("mission_info") { branch_protector_ret = "pac_ret" + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + sources = [ "${ability_runtime_services_path}/abilitymgr/src/mission/mission_info.cpp", "${ability_runtime_services_path}/abilitymgr/src/mission/mission_snapshot.cpp", @@ -300,6 +316,8 @@ ohos_shared_library("mission_info") { } ohos_shared_library("ability_manager_c") { + branch_protector_ret = "pac_ret" + include_dirs = [ "include" ] sources = [ "src/ability_manager_client_c.cpp" ] libs = [] @@ -320,6 +338,12 @@ ohos_shared_library("ability_manager_c") { ohos_shared_library("ability_start_setting") { branch_protector_ret = "pac_ret" + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + sources = [ "${ability_runtime_services_path}/abilitymgr/src/ability_start_setting.cpp", ] @@ -418,6 +442,12 @@ ohos_shared_library("start_window_option") { ohos_shared_library("ability_connect_callback_stub") { branch_protector_ret = "pac_ret" + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + defines = [ "AMS_LOG_TAG = \"Ability\"" ] defines += [ "AMS_LOG_DOMAIN = 0xD001300" ] include_dirs = [ diff --git a/interfaces/inner_api/ani_base_context/BUILD.gn b/interfaces/inner_api/ani_base_context/BUILD.gn index 20df9f6f4c..d5e9378931 100644 --- a/interfaces/inner_api/ani_base_context/BUILD.gn +++ b/interfaces/inner_api/ani_base_context/BUILD.gn @@ -20,6 +20,8 @@ config("ani_context_base_public_config") { } ohos_shared_library("ani_base_context") { + branch_protector_ret = "pac_ret" + sanitize = { cfi = true cfi_cross_dso = true diff --git a/interfaces/inner_api/app_manager/BUILD.gn b/interfaces/inner_api/app_manager/BUILD.gn index 3121413848..213a43af3f 100644 --- a/interfaces/inner_api/app_manager/BUILD.gn +++ b/interfaces/inner_api/app_manager/BUILD.gn @@ -42,6 +42,16 @@ config("appmgr_core_config") { ohos_shared_library("app_manager") { branch_protector_ret = "pac_ret" + sanitize = { + integer_overflow = true + ubsan = true + boundary_sanitize = true + cfi = true + cfi_cross_dso = true + cfi_vcall_icall_only = true + cfi_policy = "adaptive" + debug = false + } include_dirs = [ "${ability_runtime_path}/interfaces/kits/native/appkit/dfr", diff --git a/interfaces/inner_api/child_process_manager/BUILD.gn b/interfaces/inner_api/child_process_manager/BUILD.gn index c15b50529a..624a2b5821 100644 --- a/interfaces/inner_api/child_process_manager/BUILD.gn +++ b/interfaces/inner_api/child_process_manager/BUILD.gn @@ -27,6 +27,8 @@ config("child_process_manager_config") { } ohos_shared_library("child_process_manager") { + branch_protector_ret = "pac_ret" + include_dirs = [ "${ability_runtime_path}/frameworks/ets/ani/child_process_manager/include", "${ability_runtime_path}/frameworks/ets/ani/ani_common/include", diff --git a/interfaces/inner_api/connectionobs_manager/BUILD.gn b/interfaces/inner_api/connectionobs_manager/BUILD.gn index fc4b3cfe6c..984ad937ae 100644 --- a/interfaces/inner_api/connectionobs_manager/BUILD.gn +++ b/interfaces/inner_api/connectionobs_manager/BUILD.gn @@ -32,6 +32,16 @@ config("connection_obs_manager_public_config") { ohos_shared_library("connection_obs_manager") { branch_protector_ret = "pac_ret" + sanitize = { + integer_overflow = true + ubsan = true + boundary_sanitize = true + cfi = true + cfi_cross_dso = true + cfi_vcall_icall_only = true + cfi_policy = "adaptive" + debug = false + } sources = [ "src/connection_data.cpp", diff --git a/interfaces/inner_api/deps_wrapper/BUILD.gn b/interfaces/inner_api/deps_wrapper/BUILD.gn index df5773767c..bc111c41dc 100644 --- a/interfaces/inner_api/deps_wrapper/BUILD.gn +++ b/interfaces/inner_api/deps_wrapper/BUILD.gn @@ -33,6 +33,12 @@ config("ability_deps_wrapper_config") { ohos_shared_library("ability_deps_wrapper") { branch_protector_ret = "pac_ret" + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + sources = [ "src/os_account_manager_wrapper.cpp", "src/sa_mgr_client.cpp", diff --git a/interfaces/inner_api/deps_wrapper/include/os_account_manager_wrapper.h b/interfaces/inner_api/deps_wrapper/include/os_account_manager_wrapper.h index 826ca5b843..110ec9cb67 100644 --- a/interfaces/inner_api/deps_wrapper/include/os_account_manager_wrapper.h +++ b/interfaces/inner_api/deps_wrapper/include/os_account_manager_wrapper.h @@ -16,6 +16,7 @@ #ifndef OHOS_ABILITY_RUNTIME_OS_ACCOUNT_MANAGER_WRAPPER_H #define OHOS_ABILITY_RUNTIME_OS_ACCOUNT_MANAGER_WRAPPER_H +#include #include #include "errors.h" @@ -23,7 +24,7 @@ namespace OHOS { namespace AppExecFwk { -class OsAccountManagerWrapper : public DelayedSingleton { +class OsAccountManagerWrapper { public: OsAccountManagerWrapper() = default; virtual ~OsAccountManagerWrapper() = default; @@ -34,7 +35,7 @@ public: * @param ids The local IDs of all activated OS accounts. * @return error code, ERR_OK on success, others on failure. */ - ErrCode QueryActiveOsAccountIds(std::vector& ids); + static ErrCode QueryActiveOsAccountIds(std::vector& ids); /** * @brief Gets the local ID of an OS account from the process UID @@ -43,7 +44,7 @@ public: * @param id The local ID of the OS account associated with the specified UID. * @return error code, ERR_OK on success, others on failure. */ - ErrCode GetOsAccountLocalIdFromUid(const int32_t uid, int32_t &id); + static ErrCode GetOsAccountLocalIdFromUid(const int32_t uid, int32_t &id); /** * @brief Gets the local ID of the current OS account. @@ -51,7 +52,7 @@ public: * @param id The local ID of the current OS account. * @return error code, ERR_OK on success, others on failure. */ - ErrCode GetOsAccountLocalIdFromProcess(int &id); + static ErrCode GetOsAccountLocalIdFromProcess(int &id); /** * @brief Checks whether the specified OS account exists. @@ -60,7 +61,7 @@ public: * @param isOsAccountExists Indicates whether the specified OS account exists. * @return error code, ERR_OK on success, others on failure. */ - ErrCode IsOsAccountExists(const int id, bool &isOsAccountExists); + static ErrCode IsOsAccountExists(const int id, bool &isOsAccountExists); /** * @brief Creates an OS account using the local name and account type. @@ -69,7 +70,7 @@ public: * @param osAccountUserId The local id of the created OS account. * @return error code, ERR_OK on success, others on failure. */ - ErrCode CreateOsAccount(const std::string &name, int32_t &osAccountUserId); + static ErrCode CreateOsAccount(const std::string &name, int32_t &osAccountUserId); /** * @brief Removes an OS account based on its local ID. @@ -77,7 +78,7 @@ public: * @param id The local ID of the OS account. * @return error code, ERR_OK on success, others on failure. */ - ErrCode RemoveOsAccount(const int id); + static ErrCode RemoveOsAccount(const int id); /** * @brief Get the current active user ID. diff --git a/interfaces/inner_api/deps_wrapper/src/os_account_manager_wrapper.cpp b/interfaces/inner_api/deps_wrapper/src/os_account_manager_wrapper.cpp index 388620c093..30db16d96e 100644 --- a/interfaces/inner_api/deps_wrapper/src/os_account_manager_wrapper.cpp +++ b/interfaces/inner_api/deps_wrapper/src/os_account_manager_wrapper.cpp @@ -108,13 +108,7 @@ ErrCode OsAccountManagerWrapper::RemoveOsAccount(const int id) int32_t OsAccountManagerWrapper::GetCurrentActiveAccountId() { std::vector accountIds; - auto instance = DelayedSingleton::GetInstance(); - if (instance == nullptr) { - TAG_LOGE(AAFwkTag::DEFAULT, "Get OsAccountManager Failed"); - return 0; - } - - ErrCode ret = instance->QueryActiveOsAccountIds(accountIds); + ErrCode ret = QueryActiveOsAccountIds(accountIds); if (ret != ERR_OK) { TAG_LOGE(AAFwkTag::DEFAULT, "Query active id failed. ret: %{public}d", ret); return 0; diff --git a/interfaces/inner_api/error_utils/BUILD.gn b/interfaces/inner_api/error_utils/BUILD.gn index 7b6a188f87..5b0c7d7236 100644 --- a/interfaces/inner_api/error_utils/BUILD.gn +++ b/interfaces/inner_api/error_utils/BUILD.gn @@ -28,6 +28,12 @@ config("error_utils_config") { ohos_shared_library("ability_runtime_error_util") { branch_protector_ret = "pac_ret" + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + sources = [ "src/ability_runtime_error_util.cpp" ] public_configs = [ ":error_utils_config" ] diff --git a/interfaces/inner_api/napi_base_context/BUILD.gn b/interfaces/inner_api/napi_base_context/BUILD.gn index d8de1c399e..d159da42b8 100644 --- a/interfaces/inner_api/napi_base_context/BUILD.gn +++ b/interfaces/inner_api/napi_base_context/BUILD.gn @@ -19,6 +19,8 @@ config("napi_context_base_public_config") { } ohos_shared_library("napi_base_context") { + branch_protector_ret = "pac_ret" + sources = [ "src/napi_base_context.cpp" ] configs = [] diff --git a/interfaces/inner_api/quick_fix/BUILD.gn b/interfaces/inner_api/quick_fix/BUILD.gn index 9a0ceb0132..d832f21c8a 100644 --- a/interfaces/inner_api/quick_fix/BUILD.gn +++ b/interfaces/inner_api/quick_fix/BUILD.gn @@ -41,6 +41,14 @@ config("quickfix_config") { } ohos_shared_library("quickfix_manager") { + branch_protector_ret = "pac_ret" + + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + include_dirs = [ "${ability_runtime_path}/interfaces/kits/native/appkit/ability_bundle_manager_helper" ] configs = [ "${ability_runtime_services_path}/common:common_config", diff --git a/interfaces/inner_api/runtime/BUILD.gn b/interfaces/inner_api/runtime/BUILD.gn index f3f41f3749..ddcea81dfb 100644 --- a/interfaces/inner_api/runtime/BUILD.gn +++ b/interfaces/inner_api/runtime/BUILD.gn @@ -50,6 +50,16 @@ config("runtime_all_deps_config") { ohos_shared_library("runtime") { branch_protector_ret = "pac_ret" + sanitize = { + integer_overflow = true + ubsan = true + boundary_sanitize = true + cfi = true + cfi_cross_dso = true + cfi_vcall_icall_only = true + cfi_policy = "adaptive" + debug = false + } include_dirs = [ "${ability_runtime_path}/ets_environment/interfaces/inner_api", diff --git a/interfaces/inner_api/session_handler/BUILD.gn b/interfaces/inner_api/session_handler/BUILD.gn index 264abf10b1..5e95b7a4a8 100644 --- a/interfaces/inner_api/session_handler/BUILD.gn +++ b/interfaces/inner_api/session_handler/BUILD.gn @@ -34,6 +34,12 @@ config("session_handler_config") { ohos_shared_library("session_handler") { branch_protector_ret = "pac_ret" + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + sources = [ "src/session_handler_proxy.cpp", "src/session_handler_stub.cpp", diff --git a/js_environment/frameworks/js_environment/BUILD.gn b/js_environment/frameworks/js_environment/BUILD.gn index bbc4380620..e2c1aa6f9e 100644 --- a/js_environment/frameworks/js_environment/BUILD.gn +++ b/js_environment/frameworks/js_environment/BUILD.gn @@ -30,6 +30,12 @@ config("public_js_environment_config") { ohos_shared_library("js_environment") { branch_protector_ret = "pac_ret" + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + sources = [ "${utils_path}/src/js_env_logger.cpp", "src/js_environment.cpp", diff --git a/service_router_framework/interfaces/inner_api/BUILD.gn b/service_router_framework/interfaces/inner_api/BUILD.gn index 73297cbccb..863069a6ff 100755 --- a/service_router_framework/interfaces/inner_api/BUILD.gn +++ b/service_router_framework/interfaces/inner_api/BUILD.gn @@ -32,6 +32,8 @@ config("srms_fwk_config") { } ohos_source_set("service_router_mgr_proxy") { + branch_protector_ret = "pac_ret" + sanitize = { cfi = true cfi_cross_dso = true @@ -57,6 +59,8 @@ ohos_source_set("service_router_mgr_proxy") { } ohos_source_set("service_router_mgr_stub") { + branch_protector_ret = "pac_ret" + sanitize = { cfi = true cfi_cross_dso = true @@ -85,6 +89,8 @@ ohos_source_set("service_router_mgr_stub") { } ohos_shared_library("srms_fwk") { + branch_protector_ret = "pac_ret" + sanitize = { cfi = true cfi_cross_dso = true diff --git a/services/abilitymgr/src/ability_manager_service.cpp b/services/abilitymgr/src/ability_manager_service.cpp index 7ee1781d15..40b59eae4b 100644 --- a/services/abilitymgr/src/ability_manager_service.cpp +++ b/services/abilitymgr/src/ability_manager_service.cpp @@ -6939,7 +6939,7 @@ sptr AbilityManagerService::GetWantSenderByUserId(const WantSenderI appIndex = wantSenderInfo.appIndex; appUid = (uid >= 0) ? uid : GetUidByCloneBundleInfo(bundleName, callerUid, userId, appIndex); } else if (uid >= 0) { - if (DelayedSingleton::GetInstance()-> + if (AppExecFwk::OsAccountManagerWrapper:: GetOsAccountLocalIdFromUid(callerUid, userId) != 0) { TAG_LOGE(AAFwkTag::WANTAGENT, "getOsAccountLocalIdFromUid failed uid=%{public}d", callerUid); return nullptr; @@ -6989,7 +6989,7 @@ sptr AbilityManagerService::GetWantSender( CHECK_POINTER_AND_RETURN(bms, nullptr); int32_t bundleMgrResult = 0; - if (DelayedSingleton::GetInstance()-> + if (AppExecFwk::OsAccountManagerWrapper:: GetOsAccountLocalIdFromUid(callerUid, userId) != 0) { TAG_LOGE(AAFwkTag::WANTAGENT, "getOsAccountLocalIdFromUid failed uid=%{public}d", callerUid); return nullptr; @@ -13784,7 +13784,7 @@ int AbilityManagerService::VerifyPermission(const std::string &permission, int p } int account = -1; - DelayedSingleton::GetInstance()->GetOsAccountLocalIdFromUid(uid, account); + AppExecFwk::OsAccountManagerWrapper::GetOsAccountLocalIdFromUid(uid, account); TAG_LOGD(AAFwkTag::ABILITYMGR, "bundleName: %{public}s, account: %{private}d", bundleName.c_str(), account); AppExecFwk::ApplicationInfo appInfo; if (!IN_PROCESS_CALL(bms->GetApplicationInfo(bundleName, AppExecFwk::BundleFlag::GET_BUNDLE_DEFAULT, @@ -14092,8 +14092,7 @@ bool AbilityManagerService::ProcessLowMemoryKill(int32_t pid, const ExitReason & bool AbilityManagerService::ProcessLowMemoryKillUIExtension(int32_t pid, int32_t uid) { int32_t userId = INVALID_USER_ID; - auto ret = DelayedSingleton::GetInstance() - ->GetOsAccountLocalIdFromUid(uid, userId); + auto ret = AppExecFwk::OsAccountManagerWrapper::GetOsAccountLocalIdFromUid(uid, userId); if (ret == 0) { auto uiExtManager = GetUIExtensionAbilityManagerByUserId(userId); if (uiExtManager != nullptr && uiExtManager->IsUIExtensionStarting(uid, pid)) { diff --git a/services/abilitymgr/src/ability_record.cpp b/services/abilitymgr/src/ability_record.cpp index 680e99fd2d..fcd06173a3 100644 --- a/services/abilitymgr/src/ability_record.cpp +++ b/services/abilitymgr/src/ability_record.cpp @@ -2967,7 +2967,7 @@ void AbilityRecord::NotifyMissionBindPid() int32_t AbilityRecord::GetCurrentAccountId() const { std::vector osActiveAccountIds; - ErrCode ret = DelayedSingleton::GetInstance()-> + ErrCode ret = AppExecFwk::OsAccountManagerWrapper:: QueryActiveOsAccountIds(osActiveAccountIds); if (ret != ERR_OK) { TAG_LOGE(AAFwkTag::ABILITYMGR, "queryActiveOsAccountIds failed"); diff --git a/services/abilitymgr/src/app_exit_reason_data_manager.cpp b/services/abilitymgr/src/app_exit_reason_data_manager.cpp index 50eb3a14b0..ad06a33203 100644 --- a/services/abilitymgr/src/app_exit_reason_data_manager.cpp +++ b/services/abilitymgr/src/app_exit_reason_data_manager.cpp @@ -133,7 +133,7 @@ int32_t AppExitReasonDataManager::SetAppExitReason(const std::string &bundleName int32_t AppExitReasonDataManager::DeleteAppExitReason(const std::string &bundleName, int32_t uid, int32_t appIndex) { int32_t userId; - if (DelayedSingleton::GetInstance()-> + if (AppExecFwk::OsAccountManagerWrapper:: GetOsAccountLocalIdFromUid(uid, userId) != ERR_OK) { TAG_LOGE(AAFwkTag::ABILITYMGR, "get GetOsAccountLocalIdFromUid failed"); return ERR_INVALID_VALUE; diff --git a/services/abilitymgr/src/app_exit_reason_helper.cpp b/services/abilitymgr/src/app_exit_reason_helper.cpp index 1d29b261d5..f97f989ab0 100644 --- a/services/abilitymgr/src/app_exit_reason_helper.cpp +++ b/services/abilitymgr/src/app_exit_reason_helper.cpp @@ -47,7 +47,7 @@ int32_t AppExitReasonHelper::RecordAppWithReason(int32_t pid, int32_t uid, const TAG_LOGE(AAFwkTag::ABILITYMGR, "GetNameAndIndexForUid failed, ret: %{public}d", ret); return ret; } - int32_t getOsAccountRet = DelayedSingleton::GetInstance()-> + int32_t getOsAccountRet = AppExecFwk::OsAccountManagerWrapper:: GetOsAccountLocalIdFromUid(uid, userId); if (getOsAccountRet != ERR_OK) { TAG_LOGE(AAFwkTag::ABILITYMGR, "get GetOsAccountLocalIdFromUid failed. ret: %{public}d", getOsAccountRet); @@ -143,7 +143,7 @@ int32_t AppExitReasonHelper::RecordAppExitReason(const ExitReason &exitReason) int32_t pid = exitReason.reason != Reason::REASON_CPP_CRASH ? IPCSkeleton::GetCallingPid() : NO_PID; AppExecFwk::RunningProcessInfo processInfo; int32_t userId = -1; - int32_t getOsAccountRet = DelayedSingleton::GetInstance()-> + int32_t getOsAccountRet = AppExecFwk::OsAccountManagerWrapper:: GetOsAccountLocalIdFromUid(uid, userId); GetRunningProcessInfo(pid, userId, bundleName, processInfo); int32_t resultCode = RecordProcessExtensionExitReason(pid, bundleName, exitReason, processInfo, false); @@ -195,7 +195,7 @@ int32_t AppExitReasonHelper::RecordProcessExitReasonForTimeout(const AppExecFwk: } int32_t targetUserId; - int32_t getOsAccountRet = DelayedSingleton::GetInstance()-> + int32_t getOsAccountRet = AppExecFwk::OsAccountManagerWrapper:: GetOsAccountLocalIdFromUid(uid, targetUserId); if (getOsAccountRet != ERR_OK) { TAG_LOGE(AAFwkTag::ABILITYMGR, "get GetOsAccountLocalIdFromUid failed. ret: %{public}d", getOsAccountRet); @@ -249,7 +249,7 @@ int32_t AppExitReasonHelper::RecordAppExitReason(const std::string &bundleName, const ExitReason &exitReason) { int32_t userId; - int32_t getOsAccountRet = DelayedSingleton::GetInstance()-> + int32_t getOsAccountRet = AppExecFwk::OsAccountManagerWrapper:: GetOsAccountLocalIdFromUid(uid, userId); if (getOsAccountRet != ERR_OK) { TAG_LOGE(AAFwkTag::ABILITYMGR, "get GetOsAccountLocalIdFromUid failed. ret: %{public}d", getOsAccountRet); @@ -287,7 +287,7 @@ int32_t AppExitReasonHelper::RecordProcessExitReason(const int32_t pid, const st } int32_t targetUserId; - int32_t getOsAccountRet = DelayedSingleton::GetInstance()-> + int32_t getOsAccountRet = AppExecFwk::OsAccountManagerWrapper:: GetOsAccountLocalIdFromUid(uid, targetUserId); if (getOsAccountRet != ERR_OK) { TAG_LOGE(AAFwkTag::ABILITYMGR, "get GetOsAccountLocalIdFromUid failed. ret: %{public}d", getOsAccountRet); @@ -364,7 +364,7 @@ int32_t AppExitReasonHelper::AddAppExitReason(const std::string &bundleName, int const ExitReasonCompability &exitReason) { int32_t userId = -1; - int32_t getOsAccountRet = DelayedSingleton::GetInstance()-> + int32_t getOsAccountRet = AppExecFwk::OsAccountManagerWrapper:: GetOsAccountLocalIdFromUid(uid, userId); if (getOsAccountRet != ERR_OK) { TAG_LOGE(AAFwkTag::ABILITYMGR, "get GetOsAccountLocalIdFromUid failed. ret: %{public}d", getOsAccountRet); @@ -425,7 +425,7 @@ void AppExitReasonHelper::GetActiveAbilityList(int32_t uid, std::vector::GetInstance()-> + int32_t getOsAccountRet = AppExecFwk::OsAccountManagerWrapper:: GetOsAccountLocalIdFromUid(uid, targetUserId); if (getOsAccountRet != ERR_OK) { TAG_LOGE(AAFwkTag::ABILITYMGR, "get GetOsAccountLocalIdFromUid failed. ret: %{public}d", getOsAccountRet); @@ -456,7 +456,7 @@ void AppExitReasonHelper::GetActiveAbilityListFromUIAbilityManager(int32_t uid, { CHECK_POINTER(subManagersHelper_); int32_t targetUserId; - int32_t getOsAccountRet = DelayedSingleton::GetInstance()-> + int32_t getOsAccountRet = AppExecFwk::OsAccountManagerWrapper:: GetOsAccountLocalIdFromUid(uid, targetUserId); if (getOsAccountRet != ERR_OK) { TAG_LOGE(AAFwkTag::ABILITYMGR, "get GetOsAccountLocalIdFromUid failed. ret: %{public}d", getOsAccountRet); diff --git a/services/abilitymgr/src/modular_object_utils.cpp b/services/abilitymgr/src/modular_object_utils.cpp index f3cb0b2e9a..6b23c3146a 100644 --- a/services/abilitymgr/src/modular_object_utils.cpp +++ b/services/abilitymgr/src/modular_object_utils.cpp @@ -274,8 +274,7 @@ int32_t ModularObjectUtils::GetCallerAppInfo(AppExecFwk::ApplicationInfo &caller return INNER_ERR; } int32_t callerUserId = -1; - auto osAccountRet = DelayedSingleton::GetInstance() - ->GetOsAccountLocalIdFromUid(callingUid, callerUserId); + auto osAccountRet = AppExecFwk::OsAccountManagerWrapper::GetOsAccountLocalIdFromUid(callingUid, callerUserId); if (osAccountRet != 0) { TAG_LOGE(AAFwkTag::EXT, "getUserId fail, callingUid: %{public}d, ret:%{public}d", callingUid, osAccountRet); return INNER_ERR; diff --git a/services/abilitymgr/src/sub_managers_helper.cpp b/services/abilitymgr/src/sub_managers_helper.cpp index 8f21031037..302980bce5 100644 --- a/services/abilitymgr/src/sub_managers_helper.cpp +++ b/services/abilitymgr/src/sub_managers_helper.cpp @@ -439,7 +439,7 @@ std::shared_ptr SubManagersHelper::GetMissionListMa { int32_t userId = INVALID_USER_ID; int32_t getOsAccountRet = - DelayedSingleton::GetInstance()->GetOsAccountLocalIdFromUid(uid, userId); + AppExecFwk::OsAccountManagerWrapper::GetOsAccountLocalIdFromUid(uid, userId); if (getOsAccountRet != 0) { TAG_LOGE(AAFwkTag::ABILITYMGR, "GetOsAccountLocalIdFromUid() failed. ret: %{public}d", getOsAccountRet); return nullptr; @@ -479,7 +479,7 @@ std::shared_ptr SubManagersHelper::GetUIAbilityManage { int32_t userId = INVALID_USER_ID; int32_t getOsAccountRet = - DelayedSingleton::GetInstance()->GetOsAccountLocalIdFromUid(uid, userId); + AppExecFwk::OsAccountManagerWrapper::GetOsAccountLocalIdFromUid(uid, userId); if (getOsAccountRet != 0) { TAG_LOGE(AAFwkTag::ABILITYMGR, "GetOsAccountLocalIdFromUid() failed. ret: %{public}d", getOsAccountRet); return nullptr; @@ -496,7 +496,7 @@ void SubManagersHelper::UninstallApp(const std::string &bundleName, int32_t uid) { int32_t userId = INVALID_USER_ID; int32_t getOsAccountRet = - DelayedSingleton::GetInstance()->GetOsAccountLocalIdFromUid(uid, userId); + AppExecFwk::OsAccountManagerWrapper::GetOsAccountLocalIdFromUid(uid, userId); if (getOsAccountRet != 0) { TAG_LOGE(AAFwkTag::ABILITYMGR, "GetOsAccountLocalIdFromUid() failed. ret: %{public}d", getOsAccountRet); return; diff --git a/services/appmgr/src/app_mgr_service_inner.cpp b/services/appmgr/src/app_mgr_service_inner.cpp index 00bc6be2da..c7fc748fc4 100644 --- a/services/appmgr/src/app_mgr_service_inner.cpp +++ b/services/appmgr/src/app_mgr_service_inner.cpp @@ -8587,12 +8587,7 @@ int AppMgrServiceInner::StartRenderProcessImpl(const std::shared_ptr::GetInstance(); - if (osAccountMgr == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "osAccountMgr is nullptr"); - return ERR_INVALID_VALUE; - } - int32_t errCode = osAccountMgr->GetOsAccountLocalIdFromUid(appRecord->GetUid(), userId); + int32_t errCode = OsAccountManagerWrapper::GetOsAccountLocalIdFromUid(appRecord->GetUid(), userId); if (errCode != ERR_OK) { TAG_LOGE(AAFwkTag::APPMGR, "GetOsAccountLocalIdFromUid failed,errcode=%{public}d", errCode); return errCode; @@ -10825,12 +10820,7 @@ int32_t AppMgrServiceInner::StartChildProcessImpl(const std::shared_ptr::GetInstance(); - if (osAccountMgr == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "osAccountMgr is nullptr"); - return ERR_INVALID_VALUE; - } - int32_t errCode = osAccountMgr->GetOsAccountLocalIdFromUid(appRecord->GetUid(), userId); + int32_t errCode = OsAccountManagerWrapper::GetOsAccountLocalIdFromUid(appRecord->GetUid(), userId); if (errCode != ERR_OK) { TAG_LOGE(AAFwkTag::APPMGR, "GetOsAccountLocalIdFromUid failed,errcode=%{public}d", errCode); return errCode; @@ -10948,13 +10938,8 @@ int32_t AppMgrServiceInner::GetChildProcessInfoEx(const std::shared_ptr::GetInstance(); - if (osAccountMgr == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "osAccountMgr is nullptr"); - return ERR_INVALID_VALUE; - } int32_t userId = -1; - errCode = osAccountMgr->GetOsAccountLocalIdFromUid(appRecord->GetUid(), userId); + errCode = OsAccountManagerWrapper::GetOsAccountLocalIdFromUid(appRecord->GetUid(), userId); if (errCode != ERR_OK) { TAG_LOGE(AAFwkTag::APPMGR, "GetOsAccountLocalIdFromUid failed,errcode=%{public}d", errCode); return errCode; @@ -11005,13 +10990,8 @@ int32_t AppMgrServiceInner::GetChildProcessInfo(const std::shared_ptr::GetInstance(); - if (osAccountMgr == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "osAccountMgr is nullptr"); - return ERR_INVALID_VALUE; - } int32_t userId = -1; - int errCode = osAccountMgr->GetOsAccountLocalIdFromUid(appRecord->GetUid(), userId); + int errCode = OsAccountManagerWrapper::GetOsAccountLocalIdFromUid(appRecord->GetUid(), userId); if (errCode != ERR_OK) { TAG_LOGE(AAFwkTag::APPMGR, "GetOsAccountLocalIdFromUid failed,errcode=%{public}d", errCode); return errCode; @@ -12453,14 +12433,13 @@ int32_t AppMgrServiceInner::GetSupportedProcessCachePids(const std::string &bund std::vector &pidList) { auto cachePrcoMgr = DelayedSingleton::GetInstance(); - auto osAccountMgr = DelayedSingleton::GetInstance(); - if (cachePrcoMgr == nullptr || osAccountMgr == nullptr || appRunningManager_ == nullptr) { + if (cachePrcoMgr == nullptr || appRunningManager_ == nullptr) { TAG_LOGE(AAFwkTag::APPMGR, "inner manager null"); return AAFwk::INNER_ERR; } pidList.clear(); int32_t callderUserId = -1; - int32_t getOsAccountRet = osAccountMgr->GetOsAccountLocalIdFromUid(IPCSkeleton::GetCallingUid(), callderUserId); + int32_t getOsAccountRet = OsAccountManagerWrapper::GetOsAccountLocalIdFromUid(IPCSkeleton::GetCallingUid(), callderUserId); if (getOsAccountRet != 0) { TAG_LOGE(AAFwkTag::APPMGR, "get caller local id fail. ret: %{public}d", getOsAccountRet); return AAFwk::INNER_ERR; @@ -12472,7 +12451,7 @@ int32_t AppMgrServiceInner::GetSupportedProcessCachePids(const std::string &bund continue; } int32_t procUserId = -1; - int32_t procGetOsAccountRet = osAccountMgr->GetOsAccountLocalIdFromUid(appRecord->GetUid(), procUserId); + int32_t procGetOsAccountRet = OsAccountManagerWrapper::GetOsAccountLocalIdFromUid(appRecord->GetUid(), procUserId); if (appRecord->GetBundleName() == bundleName && procGetOsAccountRet == 0 && procUserId == callderUserId && cachePrcoMgr->IsAppSupportProcessCache(appRecord) && appRecord->GetPriorityObject() != nullptr) { diff --git a/services/appmgr/src/app_running_manager.cpp b/services/appmgr/src/app_running_manager.cpp index ed37130026..971d52e2be 100644 --- a/services/appmgr/src/app_running_manager.cpp +++ b/services/appmgr/src/app_running_manager.cpp @@ -519,7 +519,7 @@ bool AppRunningManager::GetPidsByUserId(int32_t userId, std::list &pids) const auto &appRecord = item.second; if (appRecord) { int32_t id = -1; - if ((DelayedSingleton::GetInstance()-> + if ((OsAccountManagerWrapper:: GetOsAccountLocalIdFromUid(appRecord->GetUid(), id) == 0) && (id == userId)) { TAG_LOGD(AAFwkTag::APPMGR, "GetOsAccountLocalIdFromUid id: %{public}d", id); pid_t pid = appRecord->GetPid(); @@ -543,7 +543,7 @@ bool AppRunningManager::GetProcessInfosByUserId(int32_t userId, std::list::GetInstance()-> + if ((OsAccountManagerWrapper:: GetOsAccountLocalIdFromUid(appRecord->GetUid(), id) == 0) && (id == userId)) { TAG_LOGD(AAFwkTag::APPMGR, "GetOsAccountLocalIdFromUid id: %{public}d", id); pid_t pid = appRecord->GetPid(); diff --git a/services/appmgr/src/app_spawn_client.cpp b/services/appmgr/src/app_spawn_client.cpp index 5d54c67d3c..d04454adae 100644 --- a/services/appmgr/src/app_spawn_client.cpp +++ b/services/appmgr/src/app_spawn_client.cpp @@ -465,14 +465,8 @@ int32_t AppSpawnClient::SetUserIdInfo(const AppSpawnStartMsg &startMsg, AppSpawn if (startMsg.uid < 0) { return ERR_INVALID_VALUE; } - auto osAccountMgr = DelayedSingleton::GetInstance(); - if (osAccountMgr == nullptr) { - TAG_LOGW(AAFwkTag::APPMGR, "osAccountMgr is nullptr"); - return ERR_NULL_OBJECT; - } - int32_t userId = -1; - auto errCode = osAccountMgr->GetOsAccountLocalIdFromUid(startMsg.uid, userId); + auto errCode = OsAccountManagerWrapper::GetOsAccountLocalIdFromUid(startMsg.uid, userId); if (errCode != ERR_OK) { TAG_LOGW(AAFwkTag::APPMGR, "GetOsAccountLocalIdFromUid failed, uid=%{public}d, errcode=%{public}d", startMsg.uid, errCode); diff --git a/services/common/BUILD.gn b/services/common/BUILD.gn index a140289713..06c2a4bb90 100644 --- a/services/common/BUILD.gn +++ b/services/common/BUILD.gn @@ -107,6 +107,11 @@ config("tdd_config") { #build so ohos_shared_library("perm_verification") { branch_protector_ret = "pac_ret" + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } include_dirs = [ "${ability_runtime_utils_path}/server/constant" ] @@ -183,6 +188,11 @@ ohos_static_library("perm_verification_static") { ohos_shared_library("task_handler_wrap") { branch_protector_ret = "pac_ret" + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } configs = [ "${ability_runtime_services_path}/common:optimize_config" ] public_configs = [ ":common_config" ] @@ -290,6 +300,11 @@ ohos_static_library("hisysevent_report_static") { ohos_shared_library("app_util") { branch_protector_ret = "pac_ret" + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } configs = [ "${ability_runtime_services_path}/common:optimize_config" ] public_configs = [ ":common_config" ] diff --git a/services/common/src/user_controller/user_controller.cpp b/services/common/src/user_controller/user_controller.cpp index 4f07720ff2..1b4be731f7 100644 --- a/services/common/src/user_controller/user_controller.cpp +++ b/services/common/src/user_controller/user_controller.cpp @@ -145,7 +145,7 @@ void UserController::SetFreezingNewUserId(int32_t userId) bool UserController::IsExistOsAccount(int32_t userId) const { bool isExist = false; - auto errCode = DelayedSingleton::GetInstance()->IsOsAccountExists(userId, + auto errCode = AppExecFwk::OsAccountManagerWrapper::IsOsAccountExists(userId, isExist); return (errCode == 0) && isExist; } diff --git a/services/quickfixmgr/BUILD.gn b/services/quickfixmgr/BUILD.gn index d845102734..1456700fe7 100644 --- a/services/quickfixmgr/BUILD.gn +++ b/services/quickfixmgr/BUILD.gn @@ -88,6 +88,12 @@ ohos_shared_library("quickfixms") { # Note: Just for test ohos_static_library("quickfixms_static") { + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + branch_protector_ret = "pac_ret" include_dirs = [ "${ability_runtime_path}/interfaces/kits/native/appkit/ability_bundle_manager_helper" ] configs = [ "${ability_runtime_services_path}/common:common_config" ] public_configs = [ ":quickfixms_config" ] diff --git a/services/uripermmgr/src/file_uri_distribution_utils.cpp b/services/uripermmgr/src/file_uri_distribution_utils.cpp index 47f0ad73d1..c1c4a89008 100644 --- a/services/uripermmgr/src/file_uri_distribution_utils.cpp +++ b/services/uripermmgr/src/file_uri_distribution_utils.cpp @@ -110,7 +110,7 @@ bool FUDUtils::CheckAndCreateEventInfo(uint32_t callerTokenId, uint32_t targetTo int32_t FUDUtils::GetCurrentAccountId() { std::vector osActiveAccountIds; - auto ret = DelayedSingleton::GetInstance()->QueryActiveOsAccountIds( + auto ret = AppExecFwk::OsAccountManagerWrapper::QueryActiveOsAccountIds( osActiveAccountIds); if (ret != ERR_OK) { TAG_LOGE(AAFwkTag::URIPERMMGR, "QueryActiveOsAccountIds error. ret: %{public}d", ret); diff --git a/test/moduletest/mission_dump_test/BUILD.gn b/test/moduletest/mission_dump_test/BUILD.gn index 9fe701d847..c521a24b14 100644 --- a/test/moduletest/mission_dump_test/BUILD.gn +++ b/test/moduletest/mission_dump_test/BUILD.gn @@ -17,6 +17,13 @@ import("//foundation/ability/ability_runtime/ability_runtime.gni") module_output_path = "ability_runtime/ability_runtime/mstabilitymgrservice" ohos_moduletest("mission_dump_test") { + branch_protector_ret = "pac_ret" + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + module_out_path = module_output_path include_dirs = [ diff --git a/test/moduletest/quick_fix/quick_fix_manager_module_test/BUILD.gn b/test/moduletest/quick_fix/quick_fix_manager_module_test/BUILD.gn index ee5242505d..659816ca08 100644 --- a/test/moduletest/quick_fix/quick_fix_manager_module_test/BUILD.gn +++ b/test/moduletest/quick_fix/quick_fix_manager_module_test/BUILD.gn @@ -16,6 +16,13 @@ import("//build/test.gni") import("//foundation/ability/ability_runtime/ability_runtime.gni") ohos_moduletest("quick_fix_manager_module_test") { + branch_protector_ret = "pac_ret" + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + module_out_path = "ability_runtime/ability_runtime/quick_fix" include_dirs = [ diff --git a/test/new_test/mock/os_account_manager_wrapper/os_account_manager_wrapper.h b/test/new_test/mock/os_account_manager_wrapper/os_account_manager_wrapper.h index 0831aad853..3a714d7fba 100644 --- a/test/new_test/mock/os_account_manager_wrapper/os_account_manager_wrapper.h +++ b/test/new_test/mock/os_account_manager_wrapper/os_account_manager_wrapper.h @@ -17,19 +17,18 @@ #define MOCK_OHOS_ABILITY_RUNTIME_OS_ACCOUNT_MANAGER_WRAPPER_H #include "errors.h" -#include "singleton.h" #include "oh_mock_utils.h" namespace OHOS { namespace AppExecFwk { -class OsAccountManagerWrapper : public DelayedSingleton { +class OsAccountManagerWrapper { public: - ErrCode GetOsAccountLocalIdFromUid(const int32_t uid, int32_t &id) + static ErrCode GetOsAccountLocalIdFromUid(const int32_t uid, int32_t &id) { return 0; } - OH_MOCK_METHOD_WITH_OUTPUT_1(ErrCode, isOsAccountExists, OsAccountManagerWrapper, + OH_MOCK_METHOD_WITH_DECORATOR_AND_OUTPUT_1(static, ErrCode, isOsAccountExists, OsAccountManagerWrapper, IsOsAccountExists, const int, bool& isOsAccountExists); }; } // namespace AppExecFwk diff --git a/test/unittest/ability_background_connection_test/BUILD.gn b/test/unittest/ability_background_connection_test/BUILD.gn index 92d1d9c664..da50426d4c 100644 --- a/test/unittest/ability_background_connection_test/BUILD.gn +++ b/test/unittest/ability_background_connection_test/BUILD.gn @@ -49,7 +49,6 @@ ohos_unittest("ability_background_connection_test") { "${ability_runtime_services_path}/common:app_util", "${ability_runtime_services_path}/common:perm_verification", "${ability_runtime_services_path}/common:task_handler_wrap", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", ] external_deps = [ @@ -68,6 +67,7 @@ ohos_unittest("ability_background_connection_test") { "hisysevent:libhisysevent", "init:libbeget_proxy", "init:libbegetutil", + "ipc:ipc_single", "kv_store:distributeddata_inner", "window_manager:libwsutils", "window_manager:sms", diff --git a/test/unittest/ability_bundle_event_callback_test/BUILD.gn b/test/unittest/ability_bundle_event_callback_test/BUILD.gn index b6204a1261..3ccef3bdd0 100644 --- a/test/unittest/ability_bundle_event_callback_test/BUILD.gn +++ b/test/unittest/ability_bundle_event_callback_test/BUILD.gn @@ -51,16 +51,16 @@ ohos_unittest("ability_bundle_event_callback_test") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_innerkits_path}/deps_wrapper:ability_deps_wrapper", "${ability_runtime_native_path}/ability/native:auto_startup_callback", "${ability_runtime_native_path}/appkit:appkit_manager_helper", "${ability_runtime_services_path}/abilitymgr:abilityms", - "${cli_tool_framework_path}/interfaces/cli_tool:cli_tool_client", "${ability_runtime_services_path}/common:app_util", "${ability_runtime_services_path}/common:perm_verification", "${ability_runtime_services_path}/common:task_handler_wrap", "${ability_runtime_services_path}/common:user_controller", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", + "${cli_tool_framework_path}/interfaces/cli_tool:cli_tool_client", ] external_deps = [ @@ -84,6 +84,7 @@ ohos_unittest("ability_bundle_event_callback_test") { "image_framework:image_native", "init:libbeget_proxy", "init:libbegetutil", + "ipc:ipc_single", "json:nlohmann_json_static", "kv_store:distributeddata_inner", "safwk:api_cache_manager", diff --git a/test/unittest/ability_cache_manager_test/BUILD.gn b/test/unittest/ability_cache_manager_test/BUILD.gn index bb75a9fe35..e1eeb122e8 100644 --- a/test/unittest/ability_cache_manager_test/BUILD.gn +++ b/test/unittest/ability_cache_manager_test/BUILD.gn @@ -51,7 +51,6 @@ ohos_unittest("ability_cache_manager_test") { "${ability_runtime_services_path}/common:perm_verification", "${ability_runtime_services_path}/common:task_handler_wrap", "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] diff --git a/test/unittest/ability_connect_callback_proxy_test/BUILD.gn b/test/unittest/ability_connect_callback_proxy_test/BUILD.gn index e21a8de939..5dfabbfe58 100644 --- a/test/unittest/ability_connect_callback_proxy_test/BUILD.gn +++ b/test/unittest/ability_connect_callback_proxy_test/BUILD.gn @@ -37,14 +37,12 @@ ohos_unittest("ability_connect_callback_proxy_test") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_connect_callback_stub", "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_native_path}/appkit:app_context_utils", "${ability_runtime_path}/services/abilitymgr:abilityms_target", "${ability_runtime_services_path}/abilitymgr:abilityms", "${ability_runtime_services_path}/common:perm_verification", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ diff --git a/test/unittest/ability_connect_callback_stub_test/BUILD.gn b/test/unittest/ability_connect_callback_stub_test/BUILD.gn index 9f1a27922c..c240abb33e 100644 --- a/test/unittest/ability_connect_callback_stub_test/BUILD.gn +++ b/test/unittest/ability_connect_callback_stub_test/BUILD.gn @@ -37,12 +37,10 @@ ohos_unittest("ability_connect_callback_stub_test") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_connect_callback_stub", "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", "${ability_runtime_services_path}/common:perm_verification", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ @@ -70,6 +68,13 @@ ohos_unittest("ability_connect_callback_stub_test") { } ohos_unittest("ability_connect_callback_recipient_test") { + branch_protector_ret = "pac_ret" + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + module_out_path = module_output_path include_dirs = [ "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/system_ability_mock" ] @@ -90,13 +95,11 @@ ohos_unittest("ability_connect_callback_recipient_test") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_connect_callback_stub", "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_path}/services/abilitymgr:abilityms_target", "${ability_runtime_services_path}/abilitymgr:abilityms", "${ability_runtime_services_path}/common:perm_verification", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ diff --git a/test/unittest/ability_connect_manager_first_test/BUILD.gn b/test/unittest/ability_connect_manager_first_test/BUILD.gn index 114822b559..56049cebe5 100644 --- a/test/unittest/ability_connect_manager_first_test/BUILD.gn +++ b/test/unittest/ability_connect_manager_first_test/BUILD.gn @@ -60,7 +60,6 @@ ohos_unittest("ability_connect_manager_first_test") { "${ability_runtime_services_path}/common:perm_verification", "${ability_runtime_services_path}/common:task_handler_wrap", "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] diff --git a/test/unittest/ability_connect_manager_fourth_test/BUILD.gn b/test/unittest/ability_connect_manager_fourth_test/BUILD.gn index 84a911e617..cebd21c5db 100644 --- a/test/unittest/ability_connect_manager_fourth_test/BUILD.gn +++ b/test/unittest/ability_connect_manager_fourth_test/BUILD.gn @@ -57,7 +57,6 @@ ohos_unittest("ability_connect_manager_fourth_test") { "${ability_runtime_services_path}/common:perm_verification", "${ability_runtime_services_path}/common:task_handler_wrap", "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] diff --git a/test/unittest/ability_connect_manager_second_test/BUILD.gn b/test/unittest/ability_connect_manager_second_test/BUILD.gn index 4b9b594cde..9ab0765534 100644 --- a/test/unittest/ability_connect_manager_second_test/BUILD.gn +++ b/test/unittest/ability_connect_manager_second_test/BUILD.gn @@ -49,9 +49,6 @@ ohos_unittest("ability_connect_manager_second_test") { "${ability_runtime_services_path}/abilitymgr:abilityms", "${ability_runtime_services_path}/common:perm_verification", "${ability_runtime_services_path}/common:task_handler_wrap", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ diff --git a/test/unittest/ability_connect_manager_test/BUILD.gn b/test/unittest/ability_connect_manager_test/BUILD.gn index 485ce42b94..bd8f851967 100644 --- a/test/unittest/ability_connect_manager_test/BUILD.gn +++ b/test/unittest/ability_connect_manager_test/BUILD.gn @@ -60,7 +60,6 @@ ohos_unittest("ability_connect_manager_test") { "${ability_runtime_services_path}/common:perm_verification", "${ability_runtime_services_path}/common:task_handler_wrap", "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] diff --git a/test/unittest/ability_event_handler_test/BUILD.gn b/test/unittest/ability_event_handler_test/BUILD.gn index 38533ec258..85e0dad327 100644 --- a/test/unittest/ability_event_handler_test/BUILD.gn +++ b/test/unittest/ability_event_handler_test/BUILD.gn @@ -36,13 +36,11 @@ ohos_unittest("ability_event_handler_test") { } deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", "${ability_runtime_services_path}/common:perm_verification", "${ability_runtime_services_path}/common:task_handler_wrap", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ diff --git a/test/unittest/ability_extension_base_test/ability_extension_base_test.cpp b/test/unittest/ability_extension_base_test/ability_extension_base_test.cpp index 007cb2baac..904e652564 100644 --- a/test/unittest/ability_extension_base_test/ability_extension_base_test.cpp +++ b/test/unittest/ability_extension_base_test/ability_extension_base_test.cpp @@ -29,8 +29,6 @@ #include "mock_ability_token.h" #include "ohos_application.h" #include "extension_context.h" -#include "js_runtime.h" -#include "js_extension_common.h" #include "want.h" using namespace testing::ext; @@ -38,6 +36,12 @@ using OHOS::AppExecFwk::ElementName; namespace OHOS { namespace AbilityRuntime { +class MockExtensionCommon : public ExtensionCommon { +public: + void OnConfigurationUpdated(const std::shared_ptr &configuration) override {} + void OnMemoryLevel(int level) override {} +}; + class AbilityExtensionBaseTest : public testing::Test { public: static void SetUpTestCase(); @@ -232,11 +236,8 @@ HWTEST_F(AbilityExtensionBaseTest, SetExtensionCommon_0100, TestSize.Level1) ExtensionBase extensionBase; extensionBase.Init(record, application, handler, token); - Runtime::Options options; - std::unique_ptr jsRuntime = JsRuntime::Create(options); - std::unique_ptr jsObj; - extensionBase.SetExtensionCommon(JsExtensionCommon::Create( - static_cast(*jsRuntime), static_cast(*jsObj), nullptr)); + auto common = std::make_shared(); + extensionBase.SetExtensionCommon(common); EXPECT_NE(extensionBase.extensionCommon_, nullptr); TAG_LOGI(AAFwkTag::TEST, "SetExtensionCommon end"); diff --git a/test/unittest/ability_interceptor_second_test/BUILD.gn b/test/unittest/ability_interceptor_second_test/BUILD.gn index 0ffe2ad4f3..87d71ba9ab 100644 --- a/test/unittest/ability_interceptor_second_test/BUILD.gn +++ b/test/unittest/ability_interceptor_second_test/BUILD.gn @@ -53,8 +53,6 @@ ohos_unittest("ability_interceptor_second_test") { "${ability_runtime_services_path}/abilitymgr:abilityms", "${ability_runtime_services_path}/common:app_util", "${ability_runtime_services_path}/common:perm_verification", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] diff --git a/test/unittest/ability_interceptor_test/BUILD.gn b/test/unittest/ability_interceptor_test/BUILD.gn index 5e8e5abae0..dc9391b7a5 100644 --- a/test/unittest/ability_interceptor_test/BUILD.gn +++ b/test/unittest/ability_interceptor_test/BUILD.gn @@ -53,8 +53,6 @@ ohos_unittest("ability_interceptor_test") { "${ability_runtime_services_path}/abilitymgr:abilityms", "${ability_runtime_services_path}/common:app_util", "${ability_runtime_services_path}/common:perm_verification", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] diff --git a/test/unittest/ability_interceptor_third_test/BUILD.gn b/test/unittest/ability_interceptor_third_test/BUILD.gn index 980c5840e8..46891d698b 100644 --- a/test/unittest/ability_interceptor_third_test/BUILD.gn +++ b/test/unittest/ability_interceptor_third_test/BUILD.gn @@ -55,9 +55,6 @@ ohos_unittest("ability_interceptor_third_test") { "${ability_runtime_services_path}/common:app_util", "${ability_runtime_services_path}/common:perm_verification", "${ability_runtime_services_path}/common:task_handler_wrap", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ diff --git a/test/unittest/ability_manager_client_branch_second_test/BUILD.gn b/test/unittest/ability_manager_client_branch_second_test/BUILD.gn index e0bf190629..b5726b7fc7 100644 --- a/test/unittest/ability_manager_client_branch_second_test/BUILD.gn +++ b/test/unittest/ability_manager_client_branch_second_test/BUILD.gn @@ -46,8 +46,6 @@ ohos_unittest("ability_manager_client_branch_second_test") { "${ability_runtime_services_path}/abilitymgr:abilityms", "${ability_runtime_services_path}/common:perm_verification", "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ diff --git a/test/unittest/ability_manager_client_branch_test/BUILD.gn b/test/unittest/ability_manager_client_branch_test/BUILD.gn index 0fdef420d9..d39e252253 100644 --- a/test/unittest/ability_manager_client_branch_test/BUILD.gn +++ b/test/unittest/ability_manager_client_branch_test/BUILD.gn @@ -47,8 +47,6 @@ ohos_unittest("ability_manager_client_branch_test") { "${ability_runtime_services_path}/abilitymgr:abilityms", "${ability_runtime_services_path}/common:perm_verification", "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ diff --git a/test/unittest/ability_manager_client_branch_third_test/BUILD.gn b/test/unittest/ability_manager_client_branch_third_test/BUILD.gn index d978d28dc7..8e3c2bb065 100644 --- a/test/unittest/ability_manager_client_branch_third_test/BUILD.gn +++ b/test/unittest/ability_manager_client_branch_third_test/BUILD.gn @@ -51,8 +51,6 @@ ohos_unittest("ability_manager_client_branch_third_test") { "${ability_runtime_services_path}/abilitymgr:abilityms", "${ability_runtime_services_path}/common:perm_verification", "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ diff --git a/test/unittest/ability_manager_event_subscriber_test/BUILD.gn b/test/unittest/ability_manager_event_subscriber_test/BUILD.gn index 09e98b5ff0..6945d55c17 100644 --- a/test/unittest/ability_manager_event_subscriber_test/BUILD.gn +++ b/test/unittest/ability_manager_event_subscriber_test/BUILD.gn @@ -50,7 +50,6 @@ ohos_unittest("ability_manager_event_subscriber_test") { "${ability_runtime_services_path}/common:perm_verification", "${ability_runtime_services_path}/common:task_handler_wrap", "${ability_runtime_services_path}/common:user_controller", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", ] external_deps = [ diff --git a/test/unittest/ability_manager_proxy_fourth_test/BUILD.gn b/test/unittest/ability_manager_proxy_fourth_test/BUILD.gn index 2da3f2a974..5e4d626c4e 100644 --- a/test/unittest/ability_manager_proxy_fourth_test/BUILD.gn +++ b/test/unittest/ability_manager_proxy_fourth_test/BUILD.gn @@ -18,6 +18,12 @@ module_output_path = "ability_runtime/ability_runtime/abilitymgr" ohos_unittest("ability_manager_proxy_fourth_test") { module_out_path = module_output_path + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + blocklist = "../../cfi_blocklist.txt" + } include_dirs = [ "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/system_ability_mock", @@ -59,8 +65,6 @@ ohos_unittest("ability_manager_proxy_fourth_test") { "${ability_runtime_services_path}/abilitymgr:wantagent_manager", "${ability_runtime_services_path}/common:perm_verification", "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ diff --git a/test/unittest/ability_manager_proxy_second_test/BUILD.gn b/test/unittest/ability_manager_proxy_second_test/BUILD.gn index 3d141989af..eb198fc67a 100644 --- a/test/unittest/ability_manager_proxy_second_test/BUILD.gn +++ b/test/unittest/ability_manager_proxy_second_test/BUILD.gn @@ -57,8 +57,6 @@ ohos_unittest("ability_manager_proxy_second_test") { "${ability_runtime_services_path}/abilitymgr:wantagent_manager", "${ability_runtime_services_path}/common:perm_verification", "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ diff --git a/test/unittest/ability_manager_proxy_sixth_test/BUILD.gn b/test/unittest/ability_manager_proxy_sixth_test/BUILD.gn index c93ae61974..0ba14aab5b 100644 --- a/test/unittest/ability_manager_proxy_sixth_test/BUILD.gn +++ b/test/unittest/ability_manager_proxy_sixth_test/BUILD.gn @@ -57,8 +57,6 @@ ohos_unittest("ability_manager_proxy_sixth_test") { "${ability_runtime_services_path}/common:image_native_bridge", "${ability_runtime_services_path}/common:perm_verification", "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ diff --git a/test/unittest/ability_manager_proxy_test/BUILD.gn b/test/unittest/ability_manager_proxy_test/BUILD.gn index 59b5762b6b..2d651a699b 100644 --- a/test/unittest/ability_manager_proxy_test/BUILD.gn +++ b/test/unittest/ability_manager_proxy_test/BUILD.gn @@ -18,6 +18,12 @@ module_output_path = "ability_runtime/ability_runtime/abilitymgr" ohos_unittest("ability_manager_proxy_test") { module_out_path = module_output_path + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + blocklist = "../../cfi_blocklist.txt" + } include_dirs = [ "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/system_ability_mock", @@ -52,8 +58,6 @@ ohos_unittest("ability_manager_proxy_test") { "${ability_runtime_services_path}/abilitymgr:wantagent_manager", "${ability_runtime_services_path}/common:perm_verification", "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ diff --git a/test/unittest/ability_manager_proxy_third_test/BUILD.gn b/test/unittest/ability_manager_proxy_third_test/BUILD.gn index 5875173ca2..0856b1cdf5 100644 --- a/test/unittest/ability_manager_proxy_third_test/BUILD.gn +++ b/test/unittest/ability_manager_proxy_third_test/BUILD.gn @@ -56,8 +56,6 @@ ohos_unittest("ability_manager_proxy_third_test") { "${ability_runtime_services_path}/abilitymgr:wantagent_manager", "${ability_runtime_services_path}/common:perm_verification", "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ diff --git a/test/unittest/ability_manager_service_account_test/BUILD.gn b/test/unittest/ability_manager_service_account_test/BUILD.gn index 1c30fcd098..adab711b5e 100644 --- a/test/unittest/ability_manager_service_account_test/BUILD.gn +++ b/test/unittest/ability_manager_service_account_test/BUILD.gn @@ -17,6 +17,13 @@ import("//foundation/ability/ability_runtime/ability_runtime.gni") module_output_path = "ability_runtime/ability_runtime/abilitymgr" ohos_unittest("ability_manager_service_account_test") { + branch_protector_ret = "pac_ret" + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + module_out_path = module_output_path cflags_cc = [] include_dirs = [ diff --git a/test/unittest/ability_manager_service_account_test/ability_manager_service_account_test.cpp b/test/unittest/ability_manager_service_account_test/ability_manager_service_account_test.cpp index dd06b6bf37..d20151ee21 100644 --- a/test/unittest/ability_manager_service_account_test/ability_manager_service_account_test.cpp +++ b/test/unittest/ability_manager_service_account_test/ability_manager_service_account_test.cpp @@ -103,7 +103,7 @@ void AbilityManagerServiceAccountTest::SetUpTestCase() GTEST_LOG_(INFO) << "AbilityManagerServiceAccountTest SetUpTestCase called"; OHOS::DelayedSingleton::GetInstance()->RegisterSystemAbility( OHOS::BUNDLE_MGR_SERVICE_SYS_ABILITY_ID, new BundleMgrService()); - DelayedSingleton::GetInstance()-> + OsAccountManagerWrapper:: CreateOsAccount("testAccount", newUserId); abilityMs_ = OHOS::DelayedSingleton::GetInstance(); abilityMs_->OnStart(); @@ -117,7 +117,7 @@ void AbilityManagerServiceAccountTest::TearDownTestCase() abilityMs_->OnStop(); OHOS::DelayedSingleton::DestroyInstance(); OHOS::DelayedSingleton::DestroyInstance(); - DelayedSingleton::GetInstance()->RemoveOsAccount(newUserId); + OsAccountManagerWrapper::RemoveOsAccount(newUserId); } void AbilityManagerServiceAccountTest::SetUp() diff --git a/test/unittest/ability_manager_service_distributed_test/BUILD.gn b/test/unittest/ability_manager_service_distributed_test/BUILD.gn index abc2fe573b..b870088c7d 100755 --- a/test/unittest/ability_manager_service_distributed_test/BUILD.gn +++ b/test/unittest/ability_manager_service_distributed_test/BUILD.gn @@ -27,11 +27,6 @@ ohos_unittest("ability_manager_service_distributed_test") { "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", "${ability_runtime_services_path}/common:perm_verification", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", - "//third_party/googletest:gmock_main", - "//third_party/googletest:gtest_main", ] external_deps = [ diff --git a/test/unittest/ability_manager_service_sixth_test/BUILD.gn b/test/unittest/ability_manager_service_sixth_test/BUILD.gn index 547e014c79..9b09c07f5a 100644 --- a/test/unittest/ability_manager_service_sixth_test/BUILD.gn +++ b/test/unittest/ability_manager_service_sixth_test/BUILD.gn @@ -107,7 +107,6 @@ ohos_unittest("ability_manager_service_sixth_test") { "${ability_runtime_services_path}/common:image_native_bridge", "${ability_runtime_services_path}/common:task_handler_wrap", "${ability_runtime_services_path}/common:user_controller", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", "${agent_runtime_framework_path}/interfaces/inner_api:agent_manager", "${agent_runtime_framework_path}/interfaces/kits/native/agent_extension/connection:agent_extension_connection", ] diff --git a/test/unittest/ability_manager_service_thirteenth_test/mock/include/os_account_manager_wrapper.h b/test/unittest/ability_manager_service_thirteenth_test/mock/include/os_account_manager_wrapper.h index 6bf7268c98..c903596e00 100644 --- a/test/unittest/ability_manager_service_thirteenth_test/mock/include/os_account_manager_wrapper.h +++ b/test/unittest/ability_manager_service_thirteenth_test/mock/include/os_account_manager_wrapper.h @@ -16,24 +16,24 @@ #ifndef OHOS_ABILITY_RUNTIME_OS_ACCOUNT_MANAGER_WRAPPER_H #define OHOS_ABILITY_RUNTIME_OS_ACCOUNT_MANAGER_WRAPPER_H +#include #include #include "errors.h" -#include "singleton.h" namespace OHOS { namespace AppExecFwk { -class OsAccountManagerWrapper : public DelayedSingleton { +class OsAccountManagerWrapper { public: OsAccountManagerWrapper() {}; virtual ~OsAccountManagerWrapper() {}; - ErrCode QueryActiveOsAccountIds(std::vector& ids); - ErrCode GetOsAccountLocalIdFromUid(const int32_t uid, int32_t& id); - ErrCode GetOsAccountLocalIdFromProcess(int& id); - ErrCode IsOsAccountExists(const int id, bool& isOsAccountExists); - ErrCode CreateOsAccount(const std::string& name, int32_t& osAccountUserId); - ErrCode RemoveOsAccount(const int id); + static ErrCode QueryActiveOsAccountIds(std::vector& ids); + static ErrCode GetOsAccountLocalIdFromUid(const int32_t uid, int32_t& id); + static ErrCode GetOsAccountLocalIdFromProcess(int& id); + static ErrCode IsOsAccountExists(const int id, bool& isOsAccountExists); + static ErrCode CreateOsAccount(const std::string& name, int32_t& osAccountUserId); + static ErrCode RemoveOsAccount(const int id); static int32_t GetCurrentActiveAccountId(); }; } // namespace AppExecFwk diff --git a/test/unittest/ability_manager_stub_second_test/BUILD.gn b/test/unittest/ability_manager_stub_second_test/BUILD.gn index a9652e4753..f97cb00379 100644 --- a/test/unittest/ability_manager_stub_second_test/BUILD.gn +++ b/test/unittest/ability_manager_stub_second_test/BUILD.gn @@ -55,8 +55,6 @@ ohos_unittest("ability_manager_stub_second_test") { "${ability_runtime_services_path}/common:perm_verification", "${ability_runtime_services_path}/common:task_handler_wrap", "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ diff --git a/test/unittest/ability_manager_stub_test/BUILD.gn b/test/unittest/ability_manager_stub_test/BUILD.gn index 8c84e88efe..b11d21e366 100644 --- a/test/unittest/ability_manager_stub_test/BUILD.gn +++ b/test/unittest/ability_manager_stub_test/BUILD.gn @@ -57,8 +57,6 @@ ohos_unittest("ability_manager_stub_test") { "${ability_runtime_services_path}/common:perm_verification", "${ability_runtime_services_path}/common:task_handler_wrap", "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ diff --git a/test/unittest/ability_record_test/BUILD.gn b/test/unittest/ability_record_test/BUILD.gn index 127c3c2dc2..5ef0424d2d 100644 --- a/test/unittest/ability_record_test/BUILD.gn +++ b/test/unittest/ability_record_test/BUILD.gn @@ -62,7 +62,6 @@ ohos_unittest("ability_record_test") { "${ability_runtime_services_path}/common:app_util", "${ability_runtime_services_path}/common:perm_verification", "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] @@ -164,7 +163,6 @@ ohos_unittest("ability_record_test_call") { "${ability_runtime_services_path}/common:app_util", "${ability_runtime_services_path}/common:perm_verification", "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] diff --git a/test/unittest/ability_scheduler_proxy_test/BUILD.gn b/test/unittest/ability_scheduler_proxy_test/BUILD.gn index 13c59edf0d..a9a1f9c753 100644 --- a/test/unittest/ability_scheduler_proxy_test/BUILD.gn +++ b/test/unittest/ability_scheduler_proxy_test/BUILD.gn @@ -45,12 +45,10 @@ ohos_unittest("ability_scheduler_proxy_test") { } deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", "${ability_runtime_services_path}/common:perm_verification", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ diff --git a/test/unittest/ability_scheduler_stub_second_test/BUILD.gn b/test/unittest/ability_scheduler_stub_second_test/BUILD.gn index 9d281f3e11..7bf5aa6a1f 100644 --- a/test/unittest/ability_scheduler_stub_second_test/BUILD.gn +++ b/test/unittest/ability_scheduler_stub_second_test/BUILD.gn @@ -42,9 +42,6 @@ ohos_unittest("ability_scheduler_stub_second_test") { "${ability_runtime_innerkits_path}/dataobs_manager:dataobs_manager", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/common:perm_verification", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ diff --git a/test/unittest/ability_scheduler_stub_test/BUILD.gn b/test/unittest/ability_scheduler_stub_test/BUILD.gn index 30363c4ee8..4dbe9cc429 100644 --- a/test/unittest/ability_scheduler_stub_test/BUILD.gn +++ b/test/unittest/ability_scheduler_stub_test/BUILD.gn @@ -38,9 +38,6 @@ ohos_unittest("ability_scheduler_stub_test") { "${ability_runtime_innerkits_path}/ability_manager:ability_manager", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/common:perm_verification", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ diff --git a/test/unittest/ability_service_start_test/BUILD.gn b/test/unittest/ability_service_start_test/BUILD.gn index 1aab058f22..b4923e0bd3 100644 --- a/test/unittest/ability_service_start_test/BUILD.gn +++ b/test/unittest/ability_service_start_test/BUILD.gn @@ -41,8 +41,6 @@ ohos_unittest("ability_service_start_test") { "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", "${ability_runtime_services_path}/common:perm_verification", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] diff --git a/test/unittest/ability_token_proxy_test/BUILD.gn b/test/unittest/ability_token_proxy_test/BUILD.gn index cdc3562796..f0a9f3d4b1 100644 --- a/test/unittest/ability_token_proxy_test/BUILD.gn +++ b/test/unittest/ability_token_proxy_test/BUILD.gn @@ -36,12 +36,10 @@ ohos_unittest("ability_token_proxy_test") { } deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", "${ability_runtime_services_path}/common:perm_verification", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ diff --git a/test/unittest/ability_token_stub_test/BUILD.gn b/test/unittest/ability_token_stub_test/BUILD.gn index 5b9cd72f17..b9be3b56d5 100644 --- a/test/unittest/ability_token_stub_test/BUILD.gn +++ b/test/unittest/ability_token_stub_test/BUILD.gn @@ -36,12 +36,10 @@ ohos_unittest("ability_token_stub_test") { } deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", "${ability_runtime_services_path}/common:perm_verification", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ diff --git a/test/unittest/ag_convert_callback_impl_test/BUILD.gn b/test/unittest/ag_convert_callback_impl_test/BUILD.gn index d04df8528b..d4c2f170ed 100644 --- a/test/unittest/ag_convert_callback_impl_test/BUILD.gn +++ b/test/unittest/ag_convert_callback_impl_test/BUILD.gn @@ -50,7 +50,6 @@ ohos_unittest("ag_convert_callback_impl_test") { "${ability_runtime_services_path}/common:app_util", "${ability_runtime_services_path}/common:perm_verification", "${ability_runtime_services_path}/common:task_handler_wrap", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", ] external_deps = [ @@ -70,6 +69,7 @@ ohos_unittest("ag_convert_callback_impl_test") { "hisysevent:libhisysevent", "init:libbeget_proxy", "init:libbegetutil", + "ipc:ipc_single", "kv_store:distributeddata_inner", "window_manager:libwsutils", "window_manager:sms", diff --git a/test/unittest/ams_app_mgr_client_test/BUILD.gn b/test/unittest/ams_app_mgr_client_test/BUILD.gn index b94d263092..7e7bcbaa3b 100644 --- a/test/unittest/ams_app_mgr_client_test/BUILD.gn +++ b/test/unittest/ams_app_mgr_client_test/BUILD.gn @@ -35,10 +35,15 @@ ohos_unittest("AmsAppMgrClientTest") { "ams_app_mgr_client_test.cpp", ] - include_dirs = [ "${ability_runtime_test_path}/mock/common/include" ] + include_dirs = [ + "${ability_runtime_test_path}/mock/common/include", + "${ability_runtime_test_path}/mock/services_appmgr_test/include", + ] - configs = - [ "${ability_runtime_innerkits_path}/app_manager:appmgr_sdk_config" ] + configs = [ + "${ability_runtime_innerkits_path}/app_manager:appmgr_sdk_config", + "${ability_runtime_services_path}/appmgr:appmgr_config", + ] cflags = [] if (target_cpu == "arm") { cflags += [ "-DBINDER_IPC_32BIT" ] @@ -46,32 +51,32 @@ ohos_unittest("AmsAppMgrClientTest") { deps = [ "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_path}/utils/server/startup:startup_util", - "${ability_runtime_services_path}/common:perm_verification", - "${ability_runtime_test_path}/unittest:appmgr_test_source", ] external_deps = [ + "ability_base:base", "ability_base:configuration", "ability_base:want", "access_token:libnativetoken", "access_token:libtoken_setproc", "appspawn:appspawn_client", + "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", - "cJSON:cjson", "c_utils:utils", - "common_event_service:cesfwk_innerkits", "ffrt:libffrt", + "googletest:gmock_main", + "googletest:gtest_main", "hilog:libhilog", "hisysevent:libhisysevent", "hitrace:hitrace_meter", "ipc:ipc_core", - "safwk:system_ability_fwk", + "json:nlohmann_json_static", "samgr:samgr_proxy", - "selinux_adapter:librestorecon", ] + defines = [ "AMS_LOG_TAG=\"AppMgrService\"" ] if (ability_runtime_child_process) { - defines = [ "SUPPORT_CHILD_PROCESS" ] + defines += [ "SUPPORT_CHILD_PROCESS" ] } if (ability_runtime_graphics) { external_deps += [ "window_manager:libwm" ] diff --git a/test/unittest/app_exit_reason_helper_fourth_test/mock/include/os_account_manager_wrapper.h b/test/unittest/app_exit_reason_helper_fourth_test/mock/include/os_account_manager_wrapper.h index ffba6fc221..28d5803df9 100644 --- a/test/unittest/app_exit_reason_helper_fourth_test/mock/include/os_account_manager_wrapper.h +++ b/test/unittest/app_exit_reason_helper_fourth_test/mock/include/os_account_manager_wrapper.h @@ -16,14 +16,14 @@ #ifndef OHOS_ABILITY_RUNTIME_OS_ACCOUNT_MANAGER_WRAPPER_H #define OHOS_ABILITY_RUNTIME_OS_ACCOUNT_MANAGER_WRAPPER_H +#include #include #include "errors.h" -#include "singleton.h" namespace OHOS { namespace AppExecFwk { -class OsAccountManagerWrapper : public DelayedSingleton { +class OsAccountManagerWrapper { public: OsAccountManagerWrapper() {}; virtual ~OsAccountManagerWrapper() {}; @@ -34,7 +34,7 @@ public: * @param ids The local IDs of all activated OS accounts. * @return error code, ERR_OK on success, others on failure. */ - ErrCode QueryActiveOsAccountIds(std::vector& ids); + static ErrCode QueryActiveOsAccountIds(std::vector& ids); /** * @brief Gets the local ID of an OS account from the process UID @@ -43,7 +43,7 @@ public: * @param id The local ID of the OS account associated with the specified UID. * @return error code, ERR_OK on success, others on failure. */ - ErrCode GetOsAccountLocalIdFromUid(const int32_t uid, int32_t& id); + static ErrCode GetOsAccountLocalIdFromUid(const int32_t uid, int32_t& id); /** * @brief Gets the local ID of the current OS account. @@ -51,7 +51,7 @@ public: * @param id The local ID of the current OS account. * @return error code, ERR_OK on success, others on failure. */ - ErrCode GetOsAccountLocalIdFromProcess(int& id); + static ErrCode GetOsAccountLocalIdFromProcess(int& id); /** * @brief Checks whether the specified OS account exists. @@ -60,7 +60,7 @@ public: * @param isOsAccountExists Indicates whether the specified OS account exists. * @return error code, ERR_OK on success, others on failure. */ - ErrCode IsOsAccountExists(const int id, bool& isOsAccountExists); + static ErrCode IsOsAccountExists(const int id, bool& isOsAccountExists); /** * @brief Creates an OS account using the local name and account type. @@ -69,7 +69,7 @@ public: * @param osAccountUserId The local id of the created OS account. * @return error code, ERR_OK on success, others on failure. */ - ErrCode CreateOsAccount(const std::string& name, int32_t& osAccountUserId); + static ErrCode CreateOsAccount(const std::string& name, int32_t& osAccountUserId); /** * @brief Removes an OS account based on its local ID. @@ -77,7 +77,7 @@ public: * @param id The local ID of the OS account. * @return error code, ERR_OK on success, others on failure. */ - ErrCode RemoveOsAccount(const int id); + static ErrCode RemoveOsAccount(const int id); /** * @brief Get the current active user ID. diff --git a/test/unittest/app_lifecycle_deal_test/BUILD.gn b/test/unittest/app_lifecycle_deal_test/BUILD.gn index 36856d37e4..8495b722ee 100644 --- a/test/unittest/app_lifecycle_deal_test/BUILD.gn +++ b/test/unittest/app_lifecycle_deal_test/BUILD.gn @@ -18,6 +18,12 @@ module_output_path = "ability_runtime/ability_runtime/appmgrservice" ohos_unittest("app_lifecycle_deal_test") { module_out_path = module_output_path + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + blocklist = "../../cfi_blocklist.txt" + } configs = [ "${ability_runtime_services_path}/common:common_config", diff --git a/test/unittest/app_mgr_client_test/BUILD.gn b/test/unittest/app_mgr_client_test/BUILD.gn index 6f31cb7f27..9f051c3468 100644 --- a/test/unittest/app_mgr_client_test/BUILD.gn +++ b/test/unittest/app_mgr_client_test/BUILD.gn @@ -18,6 +18,12 @@ module_output_path = "ability_runtime/ability_runtime/appmgrservice" ohos_unittest("AppMgrClientTest") { module_out_path = module_output_path + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + blocklist = "../../cfi_blocklist.txt" + } configs = [ "${ability_runtime_services_path}/common:common_config", diff --git a/test/unittest/app_scheduler_host_test/BUILD.gn b/test/unittest/app_scheduler_host_test/BUILD.gn index d73977a1e2..4df95d48cb 100644 --- a/test/unittest/app_scheduler_host_test/BUILD.gn +++ b/test/unittest/app_scheduler_host_test/BUILD.gn @@ -18,6 +18,12 @@ module_output_path = "ability_runtime/ability_runtime/appmgrservice" ohos_unittest("app_scheduler_host_test") { module_out_path = module_output_path + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + blocklist = "../../cfi_blocklist.txt" + } configs = [ "${ability_runtime_services_path}/common:common_config", diff --git a/test/unittest/app_scheduler_proxy_test/BUILD.gn b/test/unittest/app_scheduler_proxy_test/BUILD.gn index 42b57721bb..54cd8bbea7 100644 --- a/test/unittest/app_scheduler_proxy_test/BUILD.gn +++ b/test/unittest/app_scheduler_proxy_test/BUILD.gn @@ -18,6 +18,12 @@ module_output_path = "ability_runtime/ability_runtime/appmgrservice" ohos_unittest("app_scheduler_proxy_test") { module_out_path = module_output_path + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + blocklist = "../../cfi_blocklist.txt" + } configs = [ "${ability_runtime_services_path}/common:common_config", diff --git a/test/unittest/app_scheduler_test/BUILD.gn b/test/unittest/app_scheduler_test/BUILD.gn index ad435261c1..e10e201b56 100644 --- a/test/unittest/app_scheduler_test/BUILD.gn +++ b/test/unittest/app_scheduler_test/BUILD.gn @@ -53,9 +53,7 @@ ohos_unittest("app_scheduler_test") { "${ability_runtime_path}/utils/server/startup:startup_util", "${ability_runtime_services_path}/abilitymgr:abilityms", "${ability_runtime_services_path}/common:perm_verification", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ diff --git a/test/unittest/app_service_extension_context_test/BUILD.gn b/test/unittest/app_service_extension_context_test/BUILD.gn index 1969cd8e46..0bd270f815 100644 --- a/test/unittest/app_service_extension_context_test/BUILD.gn +++ b/test/unittest/app_service_extension_context_test/BUILD.gn @@ -41,6 +41,7 @@ ohos_unittest("app_service_extension_context_test") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_connect_callback_stub", "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_innerkits_path}/runtime:runtime", "${ability_runtime_napi_path}/inner/napi_common:napi_common", "${ability_runtime_native_path}/ability/native:ability_business_error", @@ -52,9 +53,6 @@ ohos_unittest("app_service_extension_context_test") { "${ability_runtime_path}/services/abilitymgr:abilityms_target", "${ability_runtime_services_path}/abilitymgr:abilityms", "${ability_runtime_services_path}/common:perm_verification", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ diff --git a/test/unittest/app_spawn_client_second_test/mock/include/os_account_manager_wrapper.h b/test/unittest/app_spawn_client_second_test/mock/include/os_account_manager_wrapper.h index 8a20fb440a..5c4fd573c1 100644 --- a/test/unittest/app_spawn_client_second_test/mock/include/os_account_manager_wrapper.h +++ b/test/unittest/app_spawn_client_second_test/mock/include/os_account_manager_wrapper.h @@ -19,11 +19,10 @@ #include #include "errors.h" -#include "singleton.h" namespace OHOS { namespace AppExecFwk { -class OsAccountManagerWrapper : public DelayedSingleton { +class OsAccountManagerWrapper { public: OsAccountManagerWrapper() {}; virtual ~OsAccountManagerWrapper() {}; @@ -34,7 +33,7 @@ public: * @param ids The local IDs of all activated OS accounts. * @return error code, ERR_OK on success, others on failure. */ - ErrCode QueryActiveOsAccountIds(std::vector& ids); + static ErrCode QueryActiveOsAccountIds(std::vector& ids); /** * @brief Gets the local ID of an OS account from the process UID @@ -43,7 +42,7 @@ public: * @param id The local ID of the OS account associated with the specified UID. * @return error code, ERR_OK on success, others on failure. */ - ErrCode GetOsAccountLocalIdFromUid(const int32_t uid, int32_t& id); + static ErrCode GetOsAccountLocalIdFromUid(const int32_t uid, int32_t& id); /** * @brief Gets the local ID of the current OS account. @@ -51,7 +50,7 @@ public: * @param id The local ID of the current OS account. * @return error code, ERR_OK on success, others on failure. */ - ErrCode GetOsAccountLocalIdFromProcess(int& id); + static ErrCode GetOsAccountLocalIdFromProcess(int& id); /** * @brief Checks whether the specified OS account exists. @@ -60,7 +59,7 @@ public: * @param isOsAccountExists Indicates whether the specified OS account exists. * @return error code, ERR_OK on success, others on failure. */ - ErrCode IsOsAccountExists(const int id, bool& isOsAccountExists); + static ErrCode IsOsAccountExists(const int id, bool& isOsAccountExists); /** * @brief Creates an OS account using the local name and account type. @@ -69,7 +68,7 @@ public: * @param osAccountUserId The local id of the created OS account. * @return error code, ERR_OK on success, others on failure. */ - ErrCode CreateOsAccount(const std::string& name, int32_t& osAccountUserId); + static ErrCode CreateOsAccount(const std::string& name, int32_t& osAccountUserId); /** * @brief Removes an OS account based on its local ID. @@ -77,7 +76,7 @@ public: * @param id The local ID of the OS account. * @return error code, ERR_OK on success, others on failure. */ - ErrCode RemoveOsAccount(const int id); + static ErrCode RemoveOsAccount(const int id); /** * @brief Get the current active user ID. diff --git a/test/unittest/appkit/ohos_application_first_test/ohos_application_first_test.cpp b/test/unittest/appkit/ohos_application_first_test/ohos_application_first_test.cpp index 000b46a196..5cf2bd3211 100644 --- a/test/unittest/appkit/ohos_application_first_test/ohos_application_first_test.cpp +++ b/test/unittest/appkit/ohos_application_first_test/ohos_application_first_test.cpp @@ -69,6 +69,7 @@ void OHOSApplicationFirstTest::SetUp() void OHOSApplicationFirstTest::TearDown() { + abilityStages_.clear(); ohosApplication_ = nullptr; } @@ -104,6 +105,7 @@ HWTEST_F(OHOSApplicationFirstTest, CleanEmptyAbilityStage_0200, TestSize.Level2) EXPECT_FALSE(ohosApplication_->abilityStages_.empty()); ohosApplication_->CleanEmptyAbilityStage(); EXPECT_TRUE(ohosApplication_->abilityStages_.empty()); + abilityStages_.clear(); TAG_LOGI(AAFwkTag::TEST, "CleanEmptyAbilityStage_0200 end"); } @@ -128,6 +130,7 @@ HWTEST_F(OHOSApplicationFirstTest, CleanEmptyAbilityStage_0300, TestSize.Level2) EXPECT_FALSE(ohosApplication_->abilityStages_.empty()); ohosApplication_->CleanEmptyAbilityStage(); EXPECT_TRUE(ohosApplication_->abilityStages_.empty()); + abilityStages_.clear(); TAG_LOGI(AAFwkTag::TEST, "CleanEmptyAbilityStage_0300 end"); } diff --git a/test/unittest/assert_fault_callback_death_mgr_test/BUILD.gn b/test/unittest/assert_fault_callback_death_mgr_test/BUILD.gn index 53f66cf1a2..5d24385498 100644 --- a/test/unittest/assert_fault_callback_death_mgr_test/BUILD.gn +++ b/test/unittest/assert_fault_callback_death_mgr_test/BUILD.gn @@ -54,15 +54,13 @@ ohos_unittest("assert_fault_callback_death_mgr_test") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_connect_callback_stub", "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_path}/utils/server/startup:startup_util", "${ability_runtime_services_path}/abilitymgr:abilityms", "${ability_runtime_services_path}/common:app_util", "${ability_runtime_services_path}/common:perm_verification", "${ability_runtime_services_path}/common:task_handler_wrap", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ diff --git a/test/unittest/background_task_observer_test/BUILD.gn b/test/unittest/background_task_observer_test/BUILD.gn index 811f34b56c..2ed7dc11c1 100755 --- a/test/unittest/background_task_observer_test/BUILD.gn +++ b/test/unittest/background_task_observer_test/BUILD.gn @@ -36,12 +36,10 @@ ohos_unittest("background_task_observer_test") { } deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", "${ability_runtime_services_path}/common:perm_verification", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ diff --git a/test/unittest/call_record_test/BUILD.gn b/test/unittest/call_record_test/BUILD.gn index b60d657d61..0a715c3de6 100644 --- a/test/unittest/call_record_test/BUILD.gn +++ b/test/unittest/call_record_test/BUILD.gn @@ -40,18 +40,19 @@ ohos_unittest("call_record_test") { cflags += [ "-DBINDER_IPC_32BIT" ] } deps = [ + "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", ] external_deps = [ "ability_base:configuration", "ability_base:want", + "c_utils:utils", "ffrt:libffrt", "googletest:gmock_main", "hilog:libhilog", - "napi:ace_napi", + "ipc:ipc_single", "samgr:samgr_proxy", ] diff --git a/test/unittest/child_process_capi_test/BUILD.gn b/test/unittest/child_process_capi_test/BUILD.gn index d9571aeb13..5cd287bb38 100644 --- a/test/unittest/child_process_capi_test/BUILD.gn +++ b/test/unittest/child_process_capi_test/BUILD.gn @@ -17,6 +17,13 @@ import("//foundation/ability/ability_runtime/ability_runtime.gni") module_output_path = "ability_runtime/ability_runtime/child_process_capi" ohos_unittest("child_process_capi_test") { + branch_protector_ret = "pac_ret" + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + use_exceptions = true module_out_path = module_output_path diff --git a/test/unittest/child_process_manager_test/BUILD.gn b/test/unittest/child_process_manager_test/BUILD.gn index 20d2dad608..4fc5de4b10 100644 --- a/test/unittest/child_process_manager_test/BUILD.gn +++ b/test/unittest/child_process_manager_test/BUILD.gn @@ -17,6 +17,13 @@ import("//foundation/ability/ability_runtime/ability_runtime.gni") module_output_path = "ability_runtime/ability_runtime/child_process_manager" ohos_unittest("child_process_manager_test") { + branch_protector_ret = "pac_ret" + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + module_out_path = module_output_path configs = [ "${ability_runtime_services_path}/common:common_config" ] diff --git a/test/unittest/configuration_test/BUILD.gn b/test/unittest/configuration_test/BUILD.gn index 0fa23035a4..7984a43941 100644 --- a/test/unittest/configuration_test/BUILD.gn +++ b/test/unittest/configuration_test/BUILD.gn @@ -40,14 +40,12 @@ ohos_unittest("configuration_test") { } deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_native_path}/ability/native:abilitykit_utils", "${ability_runtime_services_path}/abilitymgr:abilityms", "${ability_runtime_services_path}/common:perm_verification", "${ability_runtime_services_path}/common:task_handler_wrap", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ diff --git a/test/unittest/connection_observer_controller_test/BUILD.gn b/test/unittest/connection_observer_controller_test/BUILD.gn index 524ea60fcd..fb453a787e 100755 --- a/test/unittest/connection_observer_controller_test/BUILD.gn +++ b/test/unittest/connection_observer_controller_test/BUILD.gn @@ -36,13 +36,11 @@ ohos_unittest("connection_observer_controller_test") { } deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_innerkits_path}/connectionobs_manager:connection_obs_manager", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", "${ability_runtime_services_path}/common:perm_verification", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ diff --git a/test/unittest/connection_observer_test/BUILD.gn b/test/unittest/connection_observer_test/BUILD.gn index a4e5e40580..6e8344e433 100644 --- a/test/unittest/connection_observer_test/BUILD.gn +++ b/test/unittest/connection_observer_test/BUILD.gn @@ -18,6 +18,12 @@ module_output_path = "ability_runtime/ability_runtime/abilitymgr" ohos_unittest("connection_observer_test") { module_out_path = module_output_path + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + blocklist = "../../cfi_blocklist.txt" + } include_dirs = [ "${ability_runtime_innerkits_path}/connectionobs_manager/include", diff --git a/test/unittest/connection_record_test/BUILD.gn b/test/unittest/connection_record_test/BUILD.gn index b813ee7bad..dcdc84e29c 100644 --- a/test/unittest/connection_record_test/BUILD.gn +++ b/test/unittest/connection_record_test/BUILD.gn @@ -52,7 +52,6 @@ ohos_unittest("connection_record_test") { "${ability_runtime_services_path}/common:perm_verification", "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ diff --git a/test/unittest/connection_state_item_test/BUILD.gn b/test/unittest/connection_state_item_test/BUILD.gn index bbd544e47e..33b96cfce8 100755 --- a/test/unittest/connection_state_item_test/BUILD.gn +++ b/test/unittest/connection_state_item_test/BUILD.gn @@ -42,13 +42,11 @@ ohos_unittest("connection_state_item_test") { } deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_innerkits_path}/connectionobs_manager:connection_obs_manager", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", "${ability_runtime_services_path}/common:perm_verification", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ diff --git a/test/unittest/connection_state_manager_test/BUILD.gn b/test/unittest/connection_state_manager_test/BUILD.gn index 100a0c290b..b4b2132bd4 100755 --- a/test/unittest/connection_state_manager_test/BUILD.gn +++ b/test/unittest/connection_state_manager_test/BUILD.gn @@ -42,13 +42,11 @@ ohos_unittest("connection_state_manager_test") { } deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_innerkits_path}/connectionobs_manager:connection_obs_manager", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", "${ability_runtime_services_path}/common:perm_verification", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ diff --git a/test/unittest/data_ability_manager_test/BUILD.gn b/test/unittest/data_ability_manager_test/BUILD.gn index b604bd28a1..6217ee31f4 100644 --- a/test/unittest/data_ability_manager_test/BUILD.gn +++ b/test/unittest/data_ability_manager_test/BUILD.gn @@ -60,7 +60,6 @@ ohos_unittest("data_ability_manager_test") { "${ability_runtime_services_path}/abilitymgr:abilityms", "${ability_runtime_services_path}/common:app_util", "${ability_runtime_services_path}/common:perm_verification", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", ] diff --git a/test/unittest/data_ability_record_second_test/BUILD.gn b/test/unittest/data_ability_record_second_test/BUILD.gn index 6564d2693f..6bc4b7ab7a 100644 --- a/test/unittest/data_ability_record_second_test/BUILD.gn +++ b/test/unittest/data_ability_record_second_test/BUILD.gn @@ -50,9 +50,7 @@ ohos_unittest("data_ability_record_second_test") { "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", "${ability_runtime_services_path}/common:perm_verification", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ diff --git a/test/unittest/data_ability_record_test/BUILD.gn b/test/unittest/data_ability_record_test/BUILD.gn index bfeebed529..2f070b46b8 100644 --- a/test/unittest/data_ability_record_test/BUILD.gn +++ b/test/unittest/data_ability_record_test/BUILD.gn @@ -51,9 +51,7 @@ ohos_unittest("data_ability_record_test") { "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", "${ability_runtime_services_path}/common:perm_verification", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ diff --git a/test/unittest/dlp_state_item_test/BUILD.gn b/test/unittest/dlp_state_item_test/BUILD.gn index d1817b23dd..0d6f2b9593 100644 --- a/test/unittest/dlp_state_item_test/BUILD.gn +++ b/test/unittest/dlp_state_item_test/BUILD.gn @@ -37,13 +37,11 @@ ohos_unittest("dlp_state_item_test") { } deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_innerkits_path}/connectionobs_manager:connection_obs_manager", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", "${ability_runtime_services_path}/common:perm_verification", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ diff --git a/test/unittest/ecological_rule_interceptor_test/BUILD.gn b/test/unittest/ecological_rule_interceptor_test/BUILD.gn index 20077ef09c..b085b11dbd 100644 --- a/test/unittest/ecological_rule_interceptor_test/BUILD.gn +++ b/test/unittest/ecological_rule_interceptor_test/BUILD.gn @@ -54,9 +54,6 @@ ohos_unittest("ecological_rule_interceptor_test") { "${ability_runtime_services_path}/common:app_util", "${ability_runtime_services_path}/common:perm_verification", "${ability_runtime_services_path}/common:task_handler_wrap", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ diff --git a/test/unittest/exit_info_data_manager_test/BUILD.gn b/test/unittest/exit_info_data_manager_test/BUILD.gn index d6b9f45257..a9cb085a80 100644 --- a/test/unittest/exit_info_data_manager_test/BUILD.gn +++ b/test/unittest/exit_info_data_manager_test/BUILD.gn @@ -53,7 +53,6 @@ ohos_unittest("exit_info_data_manager_test") { "${ability_runtime_services_path}/common:perm_verification", "${ability_runtime_services_path}/common:task_handler_wrap", "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] diff --git a/test/unittest/exit_reason_test/BUILD.gn b/test/unittest/exit_reason_test/BUILD.gn index 7cb53ddfa5..6981f5afe8 100644 --- a/test/unittest/exit_reason_test/BUILD.gn +++ b/test/unittest/exit_reason_test/BUILD.gn @@ -55,7 +55,6 @@ ohos_unittest("exit_reason_test") { "${ability_runtime_services_path}/common:perm_verification", "${ability_runtime_services_path}/common:task_handler_wrap", "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] diff --git a/test/unittest/extension_record_test/BUILD.gn b/test/unittest/extension_record_test/BUILD.gn index 89df4207b8..f4bf459a8c 100644 --- a/test/unittest/extension_record_test/BUILD.gn +++ b/test/unittest/extension_record_test/BUILD.gn @@ -56,7 +56,6 @@ ohos_unittest("extension_record_test") { "${ability_runtime_services_path}/common:perm_verification", "${ability_runtime_services_path}/common:task_handler_wrap", "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] diff --git a/test/unittest/foreground_app_connection_manager_test/BUILD.gn b/test/unittest/foreground_app_connection_manager_test/BUILD.gn index 091d0cec79..84f934e9b3 100644 --- a/test/unittest/foreground_app_connection_manager_test/BUILD.gn +++ b/test/unittest/foreground_app_connection_manager_test/BUILD.gn @@ -41,13 +41,11 @@ ohos_unittest("foreground_app_connection_manager_test") { } deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_innerkits_path}/foreground_app_obs_manager:foreground_app_obs_manager", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", "${ability_runtime_services_path}/common:perm_verification", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ diff --git a/test/unittest/frameworks_kits_appkit_native_test/mock/include/os_account_manager_wrapper.h b/test/unittest/frameworks_kits_appkit_native_test/mock/include/os_account_manager_wrapper.h index 7d9584f7c2..4e5fae1bd1 100644 --- a/test/unittest/frameworks_kits_appkit_native_test/mock/include/os_account_manager_wrapper.h +++ b/test/unittest/frameworks_kits_appkit_native_test/mock/include/os_account_manager_wrapper.h @@ -24,8 +24,7 @@ namespace OHOS { namespace AppExecFwk { class OsAccountManagerWrapper { public: - static std::shared_ptr GetInstance(); - ErrCode GetOsAccountLocalIdFromProcess(int32_t &id); + static ErrCode GetOsAccountLocalIdFromProcess(int32_t &id); }; } // namespace AppExecFwk } // namespace OHOS diff --git a/test/unittest/frameworks_kits_appkit_native_test/mock/src/os_account_manager_wrapper.cpp b/test/unittest/frameworks_kits_appkit_native_test/mock/src/os_account_manager_wrapper.cpp index 467830f06c..7e533d0b64 100644 --- a/test/unittest/frameworks_kits_appkit_native_test/mock/src/os_account_manager_wrapper.cpp +++ b/test/unittest/frameworks_kits_appkit_native_test/mock/src/os_account_manager_wrapper.cpp @@ -15,20 +15,10 @@ #include "os_account_manager_wrapper.h" -#include #include "mock_my_status.h" namespace OHOS { namespace AppExecFwk { -std::shared_ptr OsAccountManagerWrapper::GetInstance() -{ - static std::shared_ptr instance = std::make_shared(); - if (MyStatus::GetInstance().instanceStatus_) { - return instance; - } - return nullptr; -} - ErrCode OsAccountManagerWrapper::GetOsAccountLocalIdFromProcess(int& id) { id = 0; diff --git a/test/unittest/js_auto_fill_extension_test/js_auto_fill_extension_test.cpp b/test/unittest/js_auto_fill_extension_test/js_auto_fill_extension_test.cpp index f9ce763e4f..e86272ea6a 100644 --- a/test/unittest/js_auto_fill_extension_test/js_auto_fill_extension_test.cpp +++ b/test/unittest/js_auto_fill_extension_test/js_auto_fill_extension_test.cpp @@ -83,7 +83,9 @@ void JsAutoFillExtensionTest::SetUp() } void JsAutoFillExtensionTest::TearDown() -{} +{ + jsAutoFillExtension_ = nullptr; +} void JsAutoFillExtensionTest::CreateJsAutoFillExtension() { diff --git a/test/unittest/js_photo_editor_extension_impl_test/js_photo_editor_extension_impl_test.cpp b/test/unittest/js_photo_editor_extension_impl_test/js_photo_editor_extension_impl_test.cpp index 0968b8bc64..1c5a296708 100644 --- a/test/unittest/js_photo_editor_extension_impl_test/js_photo_editor_extension_impl_test.cpp +++ b/test/unittest/js_photo_editor_extension_impl_test/js_photo_editor_extension_impl_test.cpp @@ -20,15 +20,21 @@ #undef private #undef protected #include "hilog_tag_wrapper.h" +#include "event_runner.h" +#include "js_runtime.h" #include "napi/native_api.h" #include "napi/native_node_api.h" #include "js_photo_editor_extension_context.h" #include "js_ui_extension_content_session.h" #include "napi_common_want.h" +#include "runtime.h" #include "session_info.h" namespace OHOS { namespace AbilityRuntime { using namespace testing::ext; +namespace { +constexpr char JS_PHOTO_EDITOR_EXTENSION_TASK_RUNNER[] = "JsPhotoEditorExtension"; +} // namespace class JsPhotoEditorExtensionImplTest : public testing::Test { public: static void SetUpTestCase(void); @@ -57,7 +63,12 @@ void JsPhotoEditorExtensionImplTest::TearDown(void) HWTEST_F(JsPhotoEditorExtensionImplTest, OnStartContentEditingTest_0100, TestSize.Level1) { TAG_LOGI(AAFwkTag::TEST, "OnStartContentEditingTest_0100 start"); - std::unique_ptr runtime; + auto eventRunner = AppExecFwk::EventRunner::Create(JS_PHOTO_EDITOR_EXTENSION_TASK_RUNNER); + Runtime::Options options; + options.preload = true; + options.eventRunner = eventRunner; + std::unique_ptr runtime = JsRuntime::Create(options); + ASSERT_NE(runtime, nullptr); auto jsExtension = std::make_shared(runtime); AAFwk::Want want; sptr sessionInfo; @@ -65,6 +76,7 @@ HWTEST_F(JsPhotoEditorExtensionImplTest, OnStartContentEditingTest_0100, TestSiz imageUri = want.GetStringParam("ability.params.stream"); jsExtension->OnStartContentEditing(want, sessionInfo); EXPECT_EQ(imageUri.empty(), true); + jsExtension = nullptr; TAG_LOGI(AAFwkTag::TEST, "OnStartContentEditingTest_0100 end"); } } // namespace AbilityRuntime diff --git a/test/unittest/lifecycle_deal_test/BUILD.gn b/test/unittest/lifecycle_deal_test/BUILD.gn index d62b7e0e8e..9682062e1f 100644 --- a/test/unittest/lifecycle_deal_test/BUILD.gn +++ b/test/unittest/lifecycle_deal_test/BUILD.gn @@ -43,9 +43,7 @@ ohos_unittest("lifecycle_deal_test") { "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/common:perm_verification", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ diff --git a/test/unittest/lifecycle_test/BUILD.gn b/test/unittest/lifecycle_test/BUILD.gn index b2d3e16eae..9fa6adb84c 100644 --- a/test/unittest/lifecycle_test/BUILD.gn +++ b/test/unittest/lifecycle_test/BUILD.gn @@ -17,6 +17,13 @@ import("//foundation/ability/ability_runtime/ability_runtime.gni") module_output_path = "ability_runtime/ability_runtime/abilitymgr" ohos_unittest("lifecycle_test") { + branch_protector_ret = "pac_ret" + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + module_out_path = module_output_path include_dirs = [ diff --git a/test/unittest/main_element_utils_test/BUILD.gn b/test/unittest/main_element_utils_test/BUILD.gn index f6911bd827..6e725566b3 100755 --- a/test/unittest/main_element_utils_test/BUILD.gn +++ b/test/unittest/main_element_utils_test/BUILD.gn @@ -47,9 +47,6 @@ ohos_unittest("main_element_utils_test") { "${ability_runtime_innerkits_path}/ability_manager:ability_manager", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/common:perm_verification", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", "${ability_runtime_path}/utils/server/startup:startup_util", ] diff --git a/test/unittest/mission_ability_record_test/BUILD.gn b/test/unittest/mission_ability_record_test/BUILD.gn index 347a077cfa..66ee642f32 100644 --- a/test/unittest/mission_ability_record_test/BUILD.gn +++ b/test/unittest/mission_ability_record_test/BUILD.gn @@ -65,7 +65,6 @@ ohos_unittest("mission_ability_record_test") { "${ability_runtime_services_path}/common:app_util", "${ability_runtime_services_path}/common:perm_verification", "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] diff --git a/test/unittest/mission_data_storage_test/BUILD.gn b/test/unittest/mission_data_storage_test/BUILD.gn index c33bfa7f99..bbabe77807 100755 --- a/test/unittest/mission_data_storage_test/BUILD.gn +++ b/test/unittest/mission_data_storage_test/BUILD.gn @@ -36,15 +36,13 @@ ohos_unittest("mission_data_storage_test") { } deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_innerkits_path}/ability_manager:mission_info", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", "${ability_runtime_services_path}/abilitymgr:mission_list", "${ability_runtime_services_path}/common:perm_verification", "${ability_runtime_services_path}/common:task_handler_wrap", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ diff --git a/test/unittest/mission_info_mgr_second_test/BUILD.gn b/test/unittest/mission_info_mgr_second_test/BUILD.gn index a1291231d5..6e1dbf3165 100644 --- a/test/unittest/mission_info_mgr_second_test/BUILD.gn +++ b/test/unittest/mission_info_mgr_second_test/BUILD.gn @@ -42,14 +42,12 @@ ohos_unittest("mission_info_mgr_second_test") { } deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_innerkits_path}/ability_manager:mission_info", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", "${ability_runtime_services_path}/abilitymgr:mission_list", "${ability_runtime_services_path}/common:perm_verification", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ diff --git a/test/unittest/mission_info_mgr_test/BUILD.gn b/test/unittest/mission_info_mgr_test/BUILD.gn index 8735ba0398..f8800a7159 100755 --- a/test/unittest/mission_info_mgr_test/BUILD.gn +++ b/test/unittest/mission_info_mgr_test/BUILD.gn @@ -39,14 +39,12 @@ ohos_unittest("mission_info_mgr_test") { } deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_innerkits_path}/ability_manager:mission_info", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", "${ability_runtime_services_path}/abilitymgr:mission_list", "${ability_runtime_services_path}/common:perm_verification", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ diff --git a/test/unittest/mission_info_test/BUILD.gn b/test/unittest/mission_info_test/BUILD.gn index 1da5092dbe..6404285bdf 100755 --- a/test/unittest/mission_info_test/BUILD.gn +++ b/test/unittest/mission_info_test/BUILD.gn @@ -36,13 +36,11 @@ ohos_unittest("mission_info_test") { } deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_innerkits_path}/ability_manager:mission_info", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", "${ability_runtime_services_path}/common:perm_verification", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ diff --git a/test/unittest/mission_list_manager_first_test/BUILD.gn b/test/unittest/mission_list_manager_first_test/BUILD.gn index 58e027f09b..a524505684 100644 --- a/test/unittest/mission_list_manager_first_test/BUILD.gn +++ b/test/unittest/mission_list_manager_first_test/BUILD.gn @@ -46,6 +46,7 @@ ohos_unittest("mission_list_manager_first_test") { } deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_innerkits_path}/ability_manager:mission_info", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_path}/utils/server/startup:startup_util", @@ -53,9 +54,6 @@ ohos_unittest("mission_list_manager_first_test") { "${ability_runtime_services_path}/abilitymgr:mission_list", "${ability_runtime_services_path}/common:perm_verification", "${ability_runtime_services_path}/common:task_handler_wrap", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ diff --git a/test/unittest/mission_list_manager_second_test/BUILD.gn b/test/unittest/mission_list_manager_second_test/BUILD.gn index 280b5f4482..55c8f7049b 100644 --- a/test/unittest/mission_list_manager_second_test/BUILD.gn +++ b/test/unittest/mission_list_manager_second_test/BUILD.gn @@ -46,6 +46,7 @@ ohos_unittest("mission_list_manager_second_test") { } deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_innerkits_path}/ability_manager:mission_info", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_path}/utils/server/startup:startup_util", @@ -53,9 +54,6 @@ ohos_unittest("mission_list_manager_second_test") { "${ability_runtime_services_path}/abilitymgr:mission_list", "${ability_runtime_services_path}/common:perm_verification", "${ability_runtime_services_path}/common:task_handler_wrap", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ diff --git a/test/unittest/mission_list_manager_test/BUILD.gn b/test/unittest/mission_list_manager_test/BUILD.gn index db23668ea1..082f4431cf 100644 --- a/test/unittest/mission_list_manager_test/BUILD.gn +++ b/test/unittest/mission_list_manager_test/BUILD.gn @@ -46,15 +46,13 @@ ohos_unittest("mission_list_manager_test") { } deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_innerkits_path}/ability_manager:mission_info", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_path}/utils/server/startup:startup_util", "${ability_runtime_services_path}/abilitymgr:abilityms", "${ability_runtime_services_path}/abilitymgr:mission_list", "${ability_runtime_services_path}/common:perm_verification", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ diff --git a/test/unittest/mission_list_manager_third_test/BUILD.gn b/test/unittest/mission_list_manager_third_test/BUILD.gn index ccc976b25b..2ad84c6344 100644 --- a/test/unittest/mission_list_manager_third_test/BUILD.gn +++ b/test/unittest/mission_list_manager_third_test/BUILD.gn @@ -46,6 +46,7 @@ ohos_unittest("mission_list_manager_third_test") { } deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_innerkits_path}/ability_manager:mission_info", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_path}/utils/server/startup:startup_util", @@ -53,9 +54,6 @@ ohos_unittest("mission_list_manager_third_test") { "${ability_runtime_services_path}/abilitymgr:mission_list", "${ability_runtime_services_path}/common:perm_verification", "${ability_runtime_services_path}/common:task_handler_wrap", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ diff --git a/test/unittest/mission_list_manager_ut_test/BUILD.gn b/test/unittest/mission_list_manager_ut_test/BUILD.gn index 059973f28b..22da4ada9e 100644 --- a/test/unittest/mission_list_manager_ut_test/BUILD.gn +++ b/test/unittest/mission_list_manager_ut_test/BUILD.gn @@ -46,9 +46,6 @@ ohos_unittest("mission_list_manager_ut_test") { "${ability_runtime_services_path}/abilitymgr:abilityms", "${ability_runtime_services_path}/abilitymgr:mission_list", "${ability_runtime_services_path}/common:perm_verification", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ diff --git a/test/unittest/mission_list_test/BUILD.gn b/test/unittest/mission_list_test/BUILD.gn index 3d1a7ef107..934d09c898 100644 --- a/test/unittest/mission_list_test/BUILD.gn +++ b/test/unittest/mission_list_test/BUILD.gn @@ -35,13 +35,11 @@ ohos_unittest("mission_list_test") { cflags += [ "-DBINDER_IPC_32BIT" ] } deps = [ + "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", "${ability_runtime_services_path}/abilitymgr:mission_list", "${ability_runtime_services_path}/common:perm_verification", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ @@ -84,6 +82,7 @@ ohos_unittest("mission_list_test_call") { cflags += [ "-DBINDER_IPC_32BIT" ] } deps = [ + "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", "${ability_runtime_services_path}/abilitymgr:mission_list", diff --git a/test/unittest/mission_listener_proxy_test/BUILD.gn b/test/unittest/mission_listener_proxy_test/BUILD.gn index 1a5d686b24..9c02e562b9 100755 --- a/test/unittest/mission_listener_proxy_test/BUILD.gn +++ b/test/unittest/mission_listener_proxy_test/BUILD.gn @@ -42,12 +42,10 @@ ohos_unittest("mission_listener_proxy_test") { } deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", "${ability_runtime_services_path}/common:perm_verification", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ diff --git a/test/unittest/mission_listener_test/BUILD.gn b/test/unittest/mission_listener_test/BUILD.gn index 87a9b2443f..807ea12c5d 100644 --- a/test/unittest/mission_listener_test/BUILD.gn +++ b/test/unittest/mission_listener_test/BUILD.gn @@ -44,12 +44,10 @@ ohos_unittest("mission_listener_test") { } deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", "${ability_runtime_services_path}/common:perm_verification", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ diff --git a/test/unittest/mission_test/BUILD.gn b/test/unittest/mission_test/BUILD.gn index ab1c9dc9b8..8ab9f79a9b 100644 --- a/test/unittest/mission_test/BUILD.gn +++ b/test/unittest/mission_test/BUILD.gn @@ -36,13 +36,11 @@ ohos_unittest("mission_test") { } deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", "${ability_runtime_services_path}/abilitymgr:mission_list", "${ability_runtime_services_path}/common:perm_verification", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ diff --git a/test/unittest/modal_system_app_freeze_uiextension_test/BUILD.gn b/test/unittest/modal_system_app_freeze_uiextension_test/BUILD.gn index 0daac9e660..c3bbb78fdf 100644 --- a/test/unittest/modal_system_app_freeze_uiextension_test/BUILD.gn +++ b/test/unittest/modal_system_app_freeze_uiextension_test/BUILD.gn @@ -49,9 +49,6 @@ ohos_unittest("modal_system_app_freeze_uiextension_test") { "${ability_runtime_services_path}/common:app_util", "${ability_runtime_services_path}/common:perm_verification", "${ability_runtime_services_path}/common:task_handler_wrap", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ diff --git a/test/unittest/modular_object_connect_test/BUILD.gn b/test/unittest/modular_object_connect_test/BUILD.gn index 43c10f9435..b1044168e8 100644 --- a/test/unittest/modular_object_connect_test/BUILD.gn +++ b/test/unittest/modular_object_connect_test/BUILD.gn @@ -64,8 +64,6 @@ ohos_unittest("modular_object_connect_test") { "${ability_runtime_services_path}/common:task_handler_wrap", "${ability_runtime_path}/utils/server/startup:startup_util", "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ diff --git a/test/unittest/modular_object_utils_test/mock/include/os_account_manager_wrapper.h b/test/unittest/modular_object_utils_test/mock/include/os_account_manager_wrapper.h index 0edbcceb0d..093720f80b 100644 --- a/test/unittest/modular_object_utils_test/mock/include/os_account_manager_wrapper.h +++ b/test/unittest/modular_object_utils_test/mock/include/os_account_manager_wrapper.h @@ -23,9 +23,8 @@ namespace OHOS { namespace AppExecFwk { class OsAccountManagerWrapper { - DECLARE_DELAYED_SINGLETON(OsAccountManagerWrapper); public: - int32_t GetOsAccountLocalIdFromUid(int32_t uid, int32_t &id) + static int32_t GetOsAccountLocalIdFromUid(int32_t uid, int32_t &id) { if (MockFlag::getOsAccountRet != 0) { return MockFlag::getOsAccountRet; diff --git a/test/unittest/os_account_manager_wrapper_test/os_account_manager_wrapper_test.cpp b/test/unittest/os_account_manager_wrapper_test/os_account_manager_wrapper_test.cpp index 0ab7ca0038..131785add0 100644 --- a/test/unittest/os_account_manager_wrapper_test/os_account_manager_wrapper_test.cpp +++ b/test/unittest/os_account_manager_wrapper_test/os_account_manager_wrapper_test.cpp @@ -59,7 +59,7 @@ void OsAccountManagerWrapperTest::TearDown() HWTEST_F(OsAccountManagerWrapperTest, GetOsAccountLocalIdFromUid_0100, TestSize.Level1) { int account = ACCOUNT_VALUE; - int ret = DelayedSingleton::GetInstance()->GetOsAccountLocalIdFromUid(UID, account); + int ret = OsAccountManagerWrapper::GetOsAccountLocalIdFromUid(UID, account); EXPECT_EQ(account, ACCOUNT_ID); EXPECT_EQ(ret, RESULT_OK); } @@ -72,7 +72,7 @@ HWTEST_F(OsAccountManagerWrapperTest, GetOsAccountLocalIdFromUid_0100, TestSize. HWTEST_F(OsAccountManagerWrapperTest, GetOsAccountLocalIdFromProcess_0100, TestSize.Level1) { int account = ACCOUNT_VALUE; - int ret = DelayedSingleton::GetInstance()->GetOsAccountLocalIdFromProcess(account); + int ret = OsAccountManagerWrapper::GetOsAccountLocalIdFromProcess(account); EXPECT_EQ(ret, RESULT_OK); } @@ -84,7 +84,7 @@ HWTEST_F(OsAccountManagerWrapperTest, GetOsAccountLocalIdFromProcess_0100, TestS HWTEST_F(OsAccountManagerWrapperTest, IsOsAccountExists_0100, TestSize.Level2) { bool isOsAccountExists = false; - DelayedSingleton::GetInstance()->IsOsAccountExists(ACCOUNT_VALUE, isOsAccountExists); + OsAccountManagerWrapper::IsOsAccountExists(ACCOUNT_VALUE, isOsAccountExists); EXPECT_EQ(isOsAccountExists, false); } @@ -97,7 +97,7 @@ HWTEST_F(OsAccountManagerWrapperTest, CreateOsAccount_0100, TestSize.Level1) { AAFwk::IsMockSaCall::IsMockSpecificSystemAbilityAccessPermission(); int account = ACCOUNT_VALUE; - int ret = DelayedSingleton::GetInstance()->CreateOsAccount(ACCOUNT_NAME, account); + int ret = OsAccountManagerWrapper::CreateOsAccount(ACCOUNT_NAME, account); EXPECT_NE(ret, ERR_ACCOUNT_COMMON_ACCOUNT_NOT_EXIST_ERROR); } @@ -110,9 +110,9 @@ HWTEST_F(OsAccountManagerWrapperTest, RemoveOsAccount_0100, TestSize.Level1) { AAFwk::IsMockSaCall::IsMockSpecificSystemAbilityAccessPermission(); int account = ACCOUNT_VALUE; - int ret = DelayedSingleton::GetInstance()->CreateOsAccount(ACCOUNT_NAME, account); + int ret = OsAccountManagerWrapper::CreateOsAccount(ACCOUNT_NAME, account); EXPECT_NE(ret, ERR_OK); - ret = DelayedSingleton::GetInstance()->RemoveOsAccount(account); + ret = OsAccountManagerWrapper::RemoveOsAccount(account); EXPECT_EQ(ret, ERR_ACCOUNT_COMMON_ACCOUNT_NOT_EXIST_ERROR); } @@ -123,7 +123,7 @@ HWTEST_F(OsAccountManagerWrapperTest, RemoveOsAccount_0100, TestSize.Level1) */ HWTEST_F(OsAccountManagerWrapperTest, GetCurrentActiveAccountId_0100, TestSize.Level1) { - int ret = DelayedSingleton::GetInstance()->GetCurrentActiveAccountId(); + int ret = OsAccountManagerWrapper::GetCurrentActiveAccountId(); EXPECT_EQ(ret, 100); } } // namespace AAFwk diff --git a/test/unittest/pending_want_key_test/BUILD.gn b/test/unittest/pending_want_key_test/BUILD.gn index 9cb5953f49..7d470059eb 100644 --- a/test/unittest/pending_want_key_test/BUILD.gn +++ b/test/unittest/pending_want_key_test/BUILD.gn @@ -30,13 +30,11 @@ ohos_unittest("pending_want_key_test") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", "${ability_runtime_services_path}/abilitymgr:wantagent_manager", "${ability_runtime_services_path}/common:perm_verification", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ diff --git a/test/unittest/pending_want_manager_test/BUILD.gn b/test/unittest/pending_want_manager_test/BUILD.gn index 539c37b000..e9372a896e 100644 --- a/test/unittest/pending_want_manager_test/BUILD.gn +++ b/test/unittest/pending_want_manager_test/BUILD.gn @@ -46,14 +46,13 @@ ohos_unittest("pending_want_manager_test") { } deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_innerkits_path}/deps_wrapper:ability_deps_wrapper", "${ability_runtime_innerkits_path}/wantagent:wantagent_innerkits", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", "${ability_runtime_services_path}/abilitymgr:wantagent_manager", "${ability_runtime_services_path}/common:perm_verification", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] diff --git a/test/unittest/pending_want_record_test/BUILD.gn b/test/unittest/pending_want_record_test/BUILD.gn index e4adc78ec5..4a16a36698 100644 --- a/test/unittest/pending_want_record_test/BUILD.gn +++ b/test/unittest/pending_want_record_test/BUILD.gn @@ -48,7 +48,6 @@ ohos_unittest("pending_want_record_test") { "${ability_runtime_services_path}/abilitymgr:wantagent_manager", "${ability_runtime_services_path}/common:perm_verification", "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] diff --git a/test/unittest/preload_uiext_state_observer_test/BUILD.gn b/test/unittest/preload_uiext_state_observer_test/BUILD.gn index da06caa4bc..a03f6685d8 100644 --- a/test/unittest/preload_uiext_state_observer_test/BUILD.gn +++ b/test/unittest/preload_uiext_state_observer_test/BUILD.gn @@ -49,12 +49,10 @@ ohos_unittest("preload_uiext_state_observer_test") { } deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", "${ability_runtime_services_path}/common:perm_verification", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ diff --git a/test/unittest/prepare_terminate_callback_proxy_test/BUILD.gn b/test/unittest/prepare_terminate_callback_proxy_test/BUILD.gn index 0c06fa6c02..bcefd7bfca 100644 --- a/test/unittest/prepare_terminate_callback_proxy_test/BUILD.gn +++ b/test/unittest/prepare_terminate_callback_proxy_test/BUILD.gn @@ -48,7 +48,6 @@ ohos_unittest("prepare_terminate_callback_proxy_test") { "${ability_runtime_services_path}/abilitymgr:wantagent_manager", "${ability_runtime_services_path}/common:perm_verification", "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] diff --git a/test/unittest/quick_fix/quick_fix_manager_service_second_test/BUILD.gn b/test/unittest/quick_fix/quick_fix_manager_service_second_test/BUILD.gn index dca90bc201..f0f8c1a0f3 100644 --- a/test/unittest/quick_fix/quick_fix_manager_service_second_test/BUILD.gn +++ b/test/unittest/quick_fix/quick_fix_manager_service_second_test/BUILD.gn @@ -16,6 +16,13 @@ import("//build/test.gni") import("//foundation/ability/ability_runtime/ability_runtime.gni") ohos_unittest("quick_fix_manager_service_second_test") { + branch_protector_ret = "pac_ret" + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + module_out_path = "ability_runtime/ability_runtime/quick_fix" include_dirs = [ diff --git a/test/unittest/quick_fix/quick_fix_manager_service_test/BUILD.gn b/test/unittest/quick_fix/quick_fix_manager_service_test/BUILD.gn index f23381ada2..048c38aafd 100644 --- a/test/unittest/quick_fix/quick_fix_manager_service_test/BUILD.gn +++ b/test/unittest/quick_fix/quick_fix_manager_service_test/BUILD.gn @@ -16,6 +16,13 @@ import("//build/test.gni") import("//foundation/ability/ability_runtime/ability_runtime.gni") ohos_unittest("quick_fix_manager_service_test") { + branch_protector_ret = "pac_ret" + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + module_out_path = "ability_runtime/ability_runtime/quick_fix" include_dirs = [ @@ -67,6 +74,13 @@ ohos_unittest("quick_fix_manager_service_test") { } ohos_unittest("quick_fix_manager_apply_task_test") { + branch_protector_ret = "pac_ret" + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + module_out_path = "ability_runtime/ability_runtime/quick_fix" include_dirs = [ diff --git a/test/unittest/recovery_info_timer_test/BUILD.gn b/test/unittest/recovery_info_timer_test/BUILD.gn index a481c370d2..6884947d96 100644 --- a/test/unittest/recovery_info_timer_test/BUILD.gn +++ b/test/unittest/recovery_info_timer_test/BUILD.gn @@ -43,12 +43,10 @@ ohos_unittest("recovery_info_timer_test") { } deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", "${ability_runtime_services_path}/common:perm_verification", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ diff --git a/test/unittest/remote_mission_listener_proxy_test/BUILD.gn b/test/unittest/remote_mission_listener_proxy_test/BUILD.gn index aff0e07808..39ed5123f7 100755 --- a/test/unittest/remote_mission_listener_proxy_test/BUILD.gn +++ b/test/unittest/remote_mission_listener_proxy_test/BUILD.gn @@ -43,12 +43,10 @@ ohos_unittest("remote_mission_listener_proxy_test") { } deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", "${ability_runtime_services_path}/common:perm_verification", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ diff --git a/test/unittest/resident_process_manager_test/BUILD.gn b/test/unittest/resident_process_manager_test/BUILD.gn index e3d2f590a9..34150012a8 100755 --- a/test/unittest/resident_process_manager_test/BUILD.gn +++ b/test/unittest/resident_process_manager_test/BUILD.gn @@ -46,9 +46,6 @@ ohos_unittest("resident_process_manager_test") { "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", "${ability_runtime_services_path}/common:perm_verification", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ diff --git a/test/unittest/restart_app_manager_test/BUILD.gn b/test/unittest/restart_app_manager_test/BUILD.gn index 05127dcf78..12c97619bd 100644 --- a/test/unittest/restart_app_manager_test/BUILD.gn +++ b/test/unittest/restart_app_manager_test/BUILD.gn @@ -43,12 +43,10 @@ ohos_unittest("restart_app_manager_test") { } deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", "${ability_runtime_services_path}/common:perm_verification", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ diff --git a/test/unittest/sender_info_test/BUILD.gn b/test/unittest/sender_info_test/BUILD.gn index d20919b99c..1f0dc22074 100644 --- a/test/unittest/sender_info_test/BUILD.gn +++ b/test/unittest/sender_info_test/BUILD.gn @@ -39,13 +39,11 @@ ohos_unittest("sender_info_test") { } deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", "${ability_runtime_services_path}/abilitymgr:wantagent_manager", "${ability_runtime_services_path}/common:perm_verification", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ diff --git a/test/unittest/service_extension_context_test/BUILD.gn b/test/unittest/service_extension_context_test/BUILD.gn index 1c511bc5e1..195d846a81 100644 --- a/test/unittest/service_extension_context_test/BUILD.gn +++ b/test/unittest/service_extension_context_test/BUILD.gn @@ -41,6 +41,7 @@ ohos_unittest("service_extension_context_test") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_connect_callback_stub", "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_innerkits_path}/runtime:runtime", "${ability_runtime_napi_path}/inner/napi_common:napi_common", "${ability_runtime_native_path}/ability/native:ability_business_error", @@ -52,9 +53,6 @@ ohos_unittest("service_extension_context_test") { "${ability_runtime_path}/services/abilitymgr:abilityms_target", "${ability_runtime_services_path}/abilitymgr:abilityms", "${ability_runtime_services_path}/common:perm_verification", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ diff --git a/test/unittest/skill_execute_callback_proxy_test/BUILD.gn b/test/unittest/skill_execute_callback_proxy_test/BUILD.gn index 2472fe7b30..e63522e05f 100644 --- a/test/unittest/skill_execute_callback_proxy_test/BUILD.gn +++ b/test/unittest/skill_execute_callback_proxy_test/BUILD.gn @@ -38,12 +38,11 @@ ohos_unittest("skill_execute_callback_proxy_test") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_innerkits_path}/deps_wrapper:ability_deps_wrapper", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", "${ability_runtime_services_path}/abilitymgr:abilityms_target", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ diff --git a/test/unittest/skill_execute_callback_stub_test/BUILD.gn b/test/unittest/skill_execute_callback_stub_test/BUILD.gn index 803b2a083d..338671e6cb 100644 --- a/test/unittest/skill_execute_callback_stub_test/BUILD.gn +++ b/test/unittest/skill_execute_callback_stub_test/BUILD.gn @@ -38,12 +38,11 @@ ohos_unittest("skill_execute_callback_stub_test") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_innerkits_path}/deps_wrapper:ability_deps_wrapper", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", "${ability_runtime_services_path}/abilitymgr:abilityms_target", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ diff --git a/test/unittest/specified_mission_list_test/BUILD.gn b/test/unittest/specified_mission_list_test/BUILD.gn index 0c646d7d8a..5b9c7ba94a 100644 --- a/test/unittest/specified_mission_list_test/BUILD.gn +++ b/test/unittest/specified_mission_list_test/BUILD.gn @@ -45,6 +45,7 @@ ohos_unittest("specified_mission_list_test") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", "${ability_runtime_innerkits_path}/ability_manager:ability_start_setting", + "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_native_path}/ability/native:auto_startup_callback", "${ability_runtime_native_path}/appkit:appkit_manager_helper", @@ -52,9 +53,6 @@ ohos_unittest("specified_mission_list_test") { "${ability_runtime_services_path}/abilitymgr:mission_list", "${ability_runtime_services_path}/common:app_util", "${ability_runtime_services_path}/common:perm_verification", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ diff --git a/test/unittest/start_options_test/BUILD.gn b/test/unittest/start_options_test/BUILD.gn index ee5e5e48d3..6d32b177d5 100755 --- a/test/unittest/start_options_test/BUILD.gn +++ b/test/unittest/start_options_test/BUILD.gn @@ -34,9 +34,6 @@ ohos_unittest("start_options_test") { "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", "${ability_runtime_services_path}/common:perm_verification", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ diff --git a/test/unittest/stop_user_callback_proxy_test/BUILD.gn b/test/unittest/stop_user_callback_proxy_test/BUILD.gn index 1453a09457..4542160757 100755 --- a/test/unittest/stop_user_callback_proxy_test/BUILD.gn +++ b/test/unittest/stop_user_callback_proxy_test/BUILD.gn @@ -36,12 +36,10 @@ ohos_unittest("stop_user_callback_proxy_test") { } deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", "${ability_runtime_services_path}/common:perm_verification", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ diff --git a/test/unittest/stop_user_callback_stub_test/BUILD.gn b/test/unittest/stop_user_callback_stub_test/BUILD.gn index 1e77ad3d5a..cc9b5d3b90 100644 --- a/test/unittest/stop_user_callback_stub_test/BUILD.gn +++ b/test/unittest/stop_user_callback_stub_test/BUILD.gn @@ -39,12 +39,10 @@ ohos_unittest("stop_user_callback_stub_test") { } deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", "${ability_runtime_services_path}/common:perm_verification", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ diff --git a/test/unittest/system_ability_token_callback_stub_test/BUILD.gn b/test/unittest/system_ability_token_callback_stub_test/BUILD.gn index 3abba1b25a..816883fba3 100644 --- a/test/unittest/system_ability_token_callback_stub_test/BUILD.gn +++ b/test/unittest/system_ability_token_callback_stub_test/BUILD.gn @@ -36,9 +36,6 @@ ohos_unittest("system_ability_token_callback_stub_test") { "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", "${ability_runtime_services_path}/common:perm_verification", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ diff --git a/test/unittest/task_data_persistence_mgr_test/BUILD.gn b/test/unittest/task_data_persistence_mgr_test/BUILD.gn index 13676d5655..23051530e7 100755 --- a/test/unittest/task_data_persistence_mgr_test/BUILD.gn +++ b/test/unittest/task_data_persistence_mgr_test/BUILD.gn @@ -37,13 +37,11 @@ ohos_unittest("task_data_persistence_mgr_test") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", "${ability_runtime_innerkits_path}/ability_manager:mission_info", + "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", "${ability_runtime_services_path}/abilitymgr:mission_list", "${ability_runtime_services_path}/common:perm_verification", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ diff --git a/test/unittest/ui_extension_ability_manager_second_test/BUILD.gn b/test/unittest/ui_extension_ability_manager_second_test/BUILD.gn index 673adb729d..a9db178cc8 100644 --- a/test/unittest/ui_extension_ability_manager_second_test/BUILD.gn +++ b/test/unittest/ui_extension_ability_manager_second_test/BUILD.gn @@ -55,7 +55,6 @@ ohos_unittest("ui_extension_ability_manager_second_test") { "${ability_runtime_services_path}/common:perm_verification", "${ability_runtime_services_path}/common:task_handler_wrap", "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] diff --git a/test/unittest/ui_extension_ability_manager_test/BUILD.gn b/test/unittest/ui_extension_ability_manager_test/BUILD.gn index 9c2cf32fce..820391f972 100644 --- a/test/unittest/ui_extension_ability_manager_test/BUILD.gn +++ b/test/unittest/ui_extension_ability_manager_test/BUILD.gn @@ -55,7 +55,6 @@ ohos_unittest("ui_extension_ability_manager_test") { "${ability_runtime_services_path}/common:perm_verification", "${ability_runtime_services_path}/common:task_handler_wrap", "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] diff --git a/test/unittest/ui_extension_record_factory_test/BUILD.gn b/test/unittest/ui_extension_record_factory_test/BUILD.gn index 5c0d266370..7972e9814a 100644 --- a/test/unittest/ui_extension_record_factory_test/BUILD.gn +++ b/test/unittest/ui_extension_record_factory_test/BUILD.gn @@ -59,6 +59,7 @@ ohos_unittest("ui_extension_record_factory_test") { "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/ability_manager:ability_start_setting", "${ability_runtime_innerkits_path}/ability_manager:mission_info", + "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_innerkits_path}/deps_wrapper:ability_deps_wrapper", "${ability_runtime_innerkits_path}/uri_permission:uri_permission_mgr", "${ability_runtime_native_path}/ability/native:abilitykit_native", @@ -72,9 +73,6 @@ ohos_unittest("ui_extension_record_factory_test") { "${ability_runtime_services_path}/abilitymgr:mission_list", "${ability_runtime_services_path}/common:app_util", "${ability_runtime_services_path}/common:perm_verification", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] if (ability_runtime_upms) { diff --git a/test/unittest/want_receiver_proxy_test/BUILD.gn b/test/unittest/want_receiver_proxy_test/BUILD.gn index 4b2cdb9320..38ef501771 100644 --- a/test/unittest/want_receiver_proxy_test/BUILD.gn +++ b/test/unittest/want_receiver_proxy_test/BUILD.gn @@ -42,13 +42,11 @@ ohos_unittest("want_receiver_proxy_test") { } deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", "${ability_runtime_services_path}/abilitymgr:wantagent_manager", "${ability_runtime_services_path}/common:perm_verification", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ diff --git a/test/unittest/want_receiver_stub_test/BUILD.gn b/test/unittest/want_receiver_stub_test/BUILD.gn index efd7739e41..997a40a72f 100644 --- a/test/unittest/want_receiver_stub_test/BUILD.gn +++ b/test/unittest/want_receiver_stub_test/BUILD.gn @@ -42,13 +42,11 @@ ohos_unittest("want_receiver_stub_test") { } deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", "${ability_runtime_services_path}/abilitymgr:wantagent_manager", "${ability_runtime_services_path}/common:perm_verification", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ diff --git a/test/unittest/want_sender_info_test/BUILD.gn b/test/unittest/want_sender_info_test/BUILD.gn index 407ba0a5d8..527ef04fb6 100644 --- a/test/unittest/want_sender_info_test/BUILD.gn +++ b/test/unittest/want_sender_info_test/BUILD.gn @@ -19,50 +19,24 @@ module_output_path = "ability_runtime/ability_runtime/abilitymgr" ohos_unittest("want_sender_info_test") { module_out_path = module_output_path - include_dirs = [ "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/system_ability_mock" ] - sources = [ - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core/src/appmgr/mock_app_scheduler.cpp", + "${ability_runtime_services_path}/abilitymgr/src/want_sender_info.cpp", + "${ability_runtime_services_path}/abilitymgr/src/wants_info.cpp", "want_sender_info_test.cpp", ] - configs = [ - "${ability_runtime_services_path}/abilitymgr:abilityms_config", - "${ability_runtime_test_path}/mock/services_abilitymgr_test:aafwk_mock_config", - ] + configs = [ "${ability_runtime_services_path}/abilitymgr:abilityms_config" ] cflags = [] if (target_cpu == "arm") { cflags += [ "-DBINDER_IPC_32BIT" ] } - deps = [ - "${ability_runtime_innerkits_path}/ability_manager:ability_manager", - "${ability_runtime_native_path}/ability/native:abilitykit_native", - "${ability_runtime_services_path}/abilitymgr:abilityms", - "${ability_runtime_services_path}/abilitymgr:wantagent_manager", - "${ability_runtime_services_path}/common:perm_verification", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", - ] external_deps = [ "ability_base:want", - "ability_base:zuri", - "access_token:libaccesstoken_sdk", "c_utils:utils", - "common_event_service:cesfwk_innerkits", - "ffrt:libffrt", - "googletest:gmock_main", - "googletest:gtest_main", "hilog:libhilog", "ipc:ipc_core", - "napi:ace_napi", - "samgr:samgr_proxy", ] - - if (background_task_mgr_continuous_task_enable) { - external_deps += [ "background_task_mgr:bgtaskmgr_innerkits" ] - } } group("unittest") { diff --git a/test/unittest/want_sender_info_test/want_sender_info_test.cpp b/test/unittest/want_sender_info_test/want_sender_info_test.cpp index 226a6597b1..bae9e9020b 100644 --- a/test/unittest/want_sender_info_test/want_sender_info_test.cpp +++ b/test/unittest/want_sender_info_test/want_sender_info_test.cpp @@ -15,14 +15,11 @@ #include #include "parcel.h" -#include "sender_info.h" -#include "wants_info.h" #define private public #define protected public #include "want_sender_info.h" #undef private #undef protected -#include "want_receiver_stub.h" using namespace testing; using namespace testing::ext; @@ -31,32 +28,14 @@ using OHOS::AppExecFwk::ElementName; namespace OHOS { namespace AAFwk { -#define SLEEP(milli) std::this_thread::sleep_for(std::chrono::seconds(milli)) -namespace {} // namespace class WantSenderInfoTest : public testing::Test { public: static void SetUpTestCase(); static void TearDownTestCase(); void SetUp(); void TearDown(); - static constexpr int TEST_WAIT_TIME = 100000; - class CancelReceiver : public AAFwk::WantReceiverStub { - public: - int performReceiveCount = 0; - void Send(const int32_t resultCode) override; - void PerformReceive(const AAFwk::Want& want, int resultCode, const std::string& data, - const AAFwk::WantParams& extras, bool serialized, bool sticky, int sendingUser) override; - }; - -public: }; -void WantSenderInfoTest::CancelReceiver::Send(const int32_t resultCode) -{} -void WantSenderInfoTest::CancelReceiver::PerformReceive(const AAFwk::Want& want, int resultCode, - const std::string& data, const AAFwk::WantParams& extras, bool serialized, bool sticky, int sendingUser) -{} - void WantSenderInfoTest::SetUpTestCase() {} diff --git a/test/unittest/want_sender_proxy_test/BUILD.gn b/test/unittest/want_sender_proxy_test/BUILD.gn index 889e8ca2fd..86f575e239 100644 --- a/test/unittest/want_sender_proxy_test/BUILD.gn +++ b/test/unittest/want_sender_proxy_test/BUILD.gn @@ -42,13 +42,11 @@ ohos_unittest("want_sender_proxy_test") { } deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", "${ability_runtime_services_path}/abilitymgr:wantagent_manager", "${ability_runtime_services_path}/common:perm_verification", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ diff --git a/test/unittest/want_sender_stub_test/BUILD.gn b/test/unittest/want_sender_stub_test/BUILD.gn index 52e4c0acd9..b5d29ad4be 100644 --- a/test/unittest/want_sender_stub_test/BUILD.gn +++ b/test/unittest/want_sender_stub_test/BUILD.gn @@ -42,13 +42,11 @@ ohos_unittest("want_sender_stub_test") { } deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", "${ability_runtime_services_path}/abilitymgr:wantagent_manager", "${ability_runtime_services_path}/common:perm_verification", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ diff --git a/test/unittest/wants_info_test/BUILD.gn b/test/unittest/wants_info_test/BUILD.gn index 04fbf643b1..b18ad3db2b 100644 --- a/test/unittest/wants_info_test/BUILD.gn +++ b/test/unittest/wants_info_test/BUILD.gn @@ -19,10 +19,8 @@ module_output_path = "ability_runtime/ability_runtime/abilitymgr" ohos_unittest("wants_info_test") { module_out_path = module_output_path - include_dirs = [ "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/system_ability_mock" ] - sources = [ - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core/src/appmgr/mock_app_scheduler.cpp", + "${ability_runtime_services_path}/abilitymgr/src/wants_info.cpp", "wants_info_test.cpp", ] @@ -31,34 +29,12 @@ ohos_unittest("wants_info_test") { if (target_cpu == "arm") { cflags += [ "-DBINDER_IPC_32BIT" ] } - deps = [ - "${ability_runtime_innerkits_path}/ability_manager:ability_manager", - "${ability_runtime_native_path}/ability/native:abilitykit_native", - "${ability_runtime_services_path}/abilitymgr:wantagent_manager", - "${ability_runtime_services_path}/common:perm_verification", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", - ] external_deps = [ "ability_base:want", - "ability_base:zuri", - "access_token:libaccesstoken_sdk", "c_utils:utils", - "common_event_service:cesfwk_innerkits", - "ffrt:libffrt", - "googletest:gmock_main", - "googletest:gtest_main", - "hilog:libhilog", "ipc:ipc_core", - "napi:ace_napi", - "samgr:samgr_proxy", ] - - if (background_task_mgr_continuous_task_enable) { - external_deps += [ "background_task_mgr:bgtaskmgr_innerkits" ] - } } group("unittest") { diff --git a/test/unittest/wants_info_test/wants_info_test.cpp b/test/unittest/wants_info_test/wants_info_test.cpp index 1c96533508..891799db69 100644 --- a/test/unittest/wants_info_test/wants_info_test.cpp +++ b/test/unittest/wants_info_test/wants_info_test.cpp @@ -15,13 +15,11 @@ #include #include "parcel.h" -#include "sender_info.h" #define private public #define protected public #include "wants_info.h" #undef private #undef protected -#include "want_receiver_stub.h" using namespace testing; using namespace testing::ext; @@ -38,24 +36,10 @@ public: static void TearDownTestCase(); void SetUp(); void TearDown(); - static constexpr int TEST_WAIT_TIME = 100000; - class CancelReceiver : public AAFwk::WantReceiverStub { - public: - int performReceiveCount = 0; - void Send(const int32_t resultCode) override; - void PerformReceive(const AAFwk::Want& want, int resultCode, const std::string& data, - const AAFwk::WantParams& extras, bool serialized, bool sticky, int sendingUser) override; - }; public: }; -void WantsInfoTest::CancelReceiver::Send(const int32_t resultCode) -{} -void WantsInfoTest::CancelReceiver::PerformReceive(const AAFwk::Want& want, int resultCode, const std::string& data, - const AAFwk::WantParams& extras, bool serialized, bool sticky, int sendingUser) -{} - void WantsInfoTest::SetUpTestCase() {} diff --git a/test/unittest/window_config_test/BUILD.gn b/test/unittest/window_config_test/BUILD.gn index 2d53f89cf2..1f9ff7e614 100644 --- a/test/unittest/window_config_test/BUILD.gn +++ b/test/unittest/window_config_test/BUILD.gn @@ -50,9 +50,6 @@ ohos_unittest("window_config_test") { "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", "${ability_runtime_services_path}/common:perm_verification", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ diff --git a/test/unittest/window_focus_changed_listener_test/BUILD.gn b/test/unittest/window_focus_changed_listener_test/BUILD.gn index 731369cc70..8f509c5045 100644 --- a/test/unittest/window_focus_changed_listener_test/BUILD.gn +++ b/test/unittest/window_focus_changed_listener_test/BUILD.gn @@ -64,6 +64,7 @@ ohos_unittest("window_focus_changed_listener_test") { "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/ability_manager:ability_start_setting", "${ability_runtime_innerkits_path}/ability_manager:mission_info", + "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_innerkits_path}/deps_wrapper:ability_deps_wrapper", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_native_path}/ability/native:auto_startup_callback", @@ -74,9 +75,6 @@ ohos_unittest("window_focus_changed_listener_test") { "${ability_runtime_services_path}/abilitymgr:abilityms", "${ability_runtime_services_path}/abilitymgr:mission_list", "${ability_runtime_services_path}/common:perm_verification", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", ] external_deps = [ diff --git a/tools/aa/BUILD.gn b/tools/aa/BUILD.gn index 922d702312..294318fd3b 100644 --- a/tools/aa/BUILD.gn +++ b/tools/aa/BUILD.gn @@ -28,6 +28,8 @@ config("ability_command_exception_config") { } ohos_static_library("tools_aa_source_set") { + branch_protector_ret = "pac_ret" + sources = [ "src/ability_command.cpp", "src/ability_start_with_observer.cpp", @@ -86,6 +88,8 @@ ohos_static_library("tools_aa_source_set") { } ohos_executable("aa") { + branch_protector_ret = "pac_ret" + sources = [ "src/main.cpp" ] cflags = [] diff --git a/tools/ohos-aa/BUILD.gn b/tools/ohos-aa/BUILD.gn index ed7fade19c..5660619999 100644 --- a/tools/ohos-aa/BUILD.gn +++ b/tools/ohos-aa/BUILD.gn @@ -30,6 +30,8 @@ config("ohos_aa_command_exception_config") { } ohos_static_library("ohos_aa_cli_source_set") { + branch_protector_ret = "pac_ret" + sources = [ "src/ohos_aa_command.cpp", "${ability_runtime_path}/tools/aa/src/ability_start_with_observer.cpp", diff --git a/tools/ohos-aa/tests/BUILD.gn b/tools/ohos-aa/tests/BUILD.gn index 3a3bfe4a24..14dbe55d96 100644 --- a/tools/ohos-aa/tests/BUILD.gn +++ b/tools/ohos-aa/tests/BUILD.gn @@ -24,6 +24,13 @@ tools_ohos_aa_mock_sources = [ "${ability_runtime_path}/tools/test/mock/mock_ability_manager_stub.cpp" ] ohos_unittest("ohos_aa_command_start_test") { + branch_protector_ret = "pac_ret" + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + module_out_path = module_output_path sources = [ "ohos_aa_command_start_test.cpp" ] @@ -53,6 +60,13 @@ ohos_unittest("ohos_aa_command_start_test") { } ohos_unittest("ohos_aa_command_force_stop_test") { + branch_protector_ret = "pac_ret" + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + module_out_path = module_output_path sources = [ "ohos_aa_command_force_stop_test.cpp" ] @@ -82,6 +96,13 @@ ohos_unittest("ohos_aa_command_force_stop_test") { } ohos_unittest("ohos_aa_command_util_test") { + branch_protector_ret = "pac_ret" + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + module_out_path = module_output_path sources = [ "ohos_aa_command_util_test.cpp" ] diff --git a/utils/global/freeze/BUILD.gn b/utils/global/freeze/BUILD.gn index 8b5e161a24..aa5e728cd9 100644 --- a/utils/global/freeze/BUILD.gn +++ b/utils/global/freeze/BUILD.gn @@ -21,6 +21,12 @@ config("freeze_util_config") { ohos_shared_library("freeze_util") { branch_protector_ret = "pac_ret" + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + include_dirs = [ "${ability_runtime_path}/utils/global/time/include", "${ability_runtime_services_path}/common/include", From 87308b49f869dd7c23af374995f1600dfa3640e6 Mon Sep 17 00:00:00 2001 From: xhz-sz Date: Tue, 14 Jul 2026 15:35:22 +0800 Subject: [PATCH 14/16] Fix multithreading Signed-off-by: xhz-sz AI[100%] Human Fixed[0%] Human[0%] AI Adopted[100%] Co-authored-by: claude (glm-5.2) --- ...s_preload_ui_extension_callback_client.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/frameworks/js/napi/ability_manager/js_preload_ui_extension_callback_client.cpp b/frameworks/js/napi/ability_manager/js_preload_ui_extension_callback_client.cpp index 8dfb3c1611..2ecb9cee4c 100644 --- a/frameworks/js/napi/ability_manager/js_preload_ui_extension_callback_client.cpp +++ b/frameworks/js/napi/ability_manager/js_preload_ui_extension_callback_client.cpp @@ -25,9 +25,22 @@ namespace AbilityRuntime { using namespace OHOS::AppExecFwk; JsPreloadUIExtensionCallbackClient::~JsPreloadUIExtensionCallbackClient() { - if (callbackRef_ != nullptr) { - napi_delete_reference(env_, callbackRef_); - callbackRef_ = nullptr; + if (callbackRef_ == nullptr || env_ == nullptr) { + return; + } + napi_env env = env_; + napi_ref ref = callbackRef_; + callbackRef_ = nullptr; + auto deleteTask = [env, ref]() { + napi_status status = napi_delete_reference(env, ref); + if (status != napi_ok) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "napi_delete_reference failed: %{public}d", status); + } + }; + if (napi_send_event(env, deleteTask, napi_eprio_high) != napi_ok) { + // Never call napi_delete_reference on the current (Binder) thread; if the JS event loop is + // unavailable, leak the reference rather than risk a cross-thread N-API call. + TAG_LOGE(AAFwkTag::ABILITYMGR, "napi_send_event failed, skip cross-thread reference release"); } } From 0bce2798c266852a52871cfe11cbd06c87b56d25 Mon Sep 17 00:00:00 2001 From: zexin_c Date: Wed, 15 Jul 2026 16:18:22 +0800 Subject: [PATCH 15/16] fix runtime MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zexin_c πŸ€– AI[48%] πŸ”§ Human Fixed[0%] πŸ§‘ Human[53%] πŸ‘Œ AI Adopted[100%] --- frameworks/native/runtime/js_runtime.cpp | 15 ++++++++++++++- .../native/runtime/js_runtime_utils.cpp | 6 ++++++ .../inner_api/runtime/include/js_runtime.h | 1 + .../unittest/runtime_test/js_runtime_test.cpp | 19 +++++++++++++++++++ 4 files changed, 40 insertions(+), 1 deletion(-) diff --git a/frameworks/native/runtime/js_runtime.cpp b/frameworks/native/runtime/js_runtime.cpp index 9cd15703ac..36880bb87d 100644 --- a/frameworks/native/runtime/js_runtime.cpp +++ b/frameworks/native/runtime/js_runtime.cpp @@ -1155,7 +1155,11 @@ std::unique_ptr JsRuntime::LoadModule(const std::string& module } napi_ref tmpRef = nullptr; - napi_create_reference(env, classValue, 1, &tmpRef); + napi_status status = napi_create_reference(env, classValue, 1, &tmpRef); + if (status != napi_ok || tmpRef == nullptr) { + TAG_LOGE(AAFwkTag::JSRUNTIME, "create reference failed"); + return std::unique_ptr(); + } modules_.emplace(modulePath, reinterpret_cast(tmpRef)); } @@ -1180,6 +1184,11 @@ std::unique_ptr JsRuntime::LoadSystemModule( HandleScope handleScope(*this); + if (methodRequireNapiRef_ == nullptr) { + TAG_LOGE(AAFwkTag::JSRUNTIME, "null methodRequireNapiRef_"); + return std::unique_ptr(); + } + napi_value className = nullptr; napi_create_string_utf8(env, moduleName.c_str(), moduleName.length(), &className); napi_value globalObj = nullptr; @@ -1554,6 +1563,10 @@ void JsRuntime::PreloadSystemModule(const std::string& moduleName) HandleScope handleScope(*this); auto env = GetNapiEnv(); CHECK_POINTER(env); + if (methodRequireNapiRef_ == nullptr) { + TAG_LOGE(AAFwkTag::JSRUNTIME, "null methodRequireNapiRef_"); + return; + } napi_value className = nullptr; napi_create_string_utf8(env, moduleName.c_str(), moduleName.length(), &className); napi_value globalObj = nullptr; diff --git a/frameworks/native/runtime/js_runtime_utils.cpp b/frameworks/native/runtime/js_runtime_utils.cpp index 7c3cdc0471..1bc2eff225 100644 --- a/frameworks/native/runtime/js_runtime_utils.cpp +++ b/frameworks/native/runtime/js_runtime_utils.cpp @@ -507,6 +507,12 @@ void ReleaseNativeReference(napi_env env, NativeReference* ref) TAG_LOGD(AAFwkTag::JSRUNTIME, "null ref"); return; } + if (env == nullptr) { + TAG_LOGE(AAFwkTag::JSRUNTIME, "null env"); + delete ref; + return; + } + uv_work_t *work = new (std::nothrow) uv_work_t; if (work == nullptr) { TAG_LOGE(AAFwkTag::JSRUNTIME, "null work"); diff --git a/interfaces/inner_api/runtime/include/js_runtime.h b/interfaces/inner_api/runtime/include/js_runtime.h index 7b5d1d3156..db3fa0f04a 100644 --- a/interfaces/inner_api/runtime/include/js_runtime.h +++ b/interfaces/inner_api/runtime/include/js_runtime.h @@ -198,6 +198,7 @@ private: std::string codePath_; std::string moduleName_; std::unique_ptr methodRequireNapiRef_; + // Keep the reference std::unordered_map modules_; std::shared_ptr jsEnv_ = nullptr; uint32_t instanceId_ = 0; diff --git a/test/unittest/runtime_test/js_runtime_test.cpp b/test/unittest/runtime_test/js_runtime_test.cpp index f6b18d7303..ddf237e22f 100755 --- a/test/unittest/runtime_test/js_runtime_test.cpp +++ b/test/unittest/runtime_test/js_runtime_test.cpp @@ -2286,5 +2286,24 @@ HWTEST_F(JsRuntimeTest, DumpHeapSnapshot_1800, TestSize.Level1) EXPECT_TRUE(jsRuntime != nullptr); TAG_LOGI(AAFwkTag::TEST, "DumpHeapSnapshot_1800 end"); } + +/** + * @tc.name: LoadSystemModule_0200 + * @tc.desc: LoadSystemModule returns nullptr when methodRequireNapiRef_ is null. + * @tc.type: FUNC + */ +HWTEST_F(JsRuntimeTest, LoadSystemModule_0200, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "LoadSystemModule_0200 start"); + + auto savedRef = std::move(jsRuntimePtr->methodRequireNapiRef_); + jsRuntimePtr->methodRequireNapiRef_ = nullptr; + std::string moduleName = "TestSystemModule"; + auto ref = jsRuntimePtr->LoadSystemModule(moduleName, nullptr, 0); + EXPECT_EQ(ref, nullptr); + jsRuntimePtr->methodRequireNapiRef_ = std::move(savedRef); + + TAG_LOGI(AAFwkTag::TEST, "LoadSystemModule_0200 end"); +} } // namespace AbilityRuntime } // namespace OHOS \ No newline at end of file From 6294738fa2f4fbdaf4bfa129662f72f6961c9f18 Mon Sep 17 00:00:00 2001 From: duansizhao Date: Wed, 15 Jul 2026 19:32:31 +0800 Subject: [PATCH 16/16] =?UTF-8?q?=E6=9B=B4=E6=96=B0PULL=5FREQUEST=5FTEMPLA?= =?UTF-8?q?TE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: duansizhao πŸ€– AI[0%] πŸ”§ Human Fixed[0%] πŸ§‘ Human[100%] πŸ‘Œ AI Adopted[0%] Change-Id: I5c92bc6ff5f72f21493b75aa109e5f1836c72fbc --- .gitee/PULL_REQUEST_TEMPLATE.zh-CN.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md b/.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md index 4c1372c109..f5db72fbb0 100644 --- a/.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md +++ b/.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md @@ -56,3 +56,6 @@ ### ζ˜―ε¦ε·²ζ‰§θ‘ŒL0用例 - [ ] ε·²ιͺŒθ― - [ ] δΈζΆ‰εŠγ€‚ε¦‚δΈζΆ‰εŠοΌŒθ―·ε†™ζ˜Žη†η”± + +### AIζ£€θ§†θ―„εˆ†οΌˆδ½Ώη”¨ζœ¬εœ°δ»£η ζ£€θ§†skills扫描): +