From 9aaf4952bd2f8368f8d0619086ca5da9fddeb144 Mon Sep 17 00:00:00 2001 From: baoyang Date: Tue, 26 Nov 2024 20:23:43 +0800 Subject: [PATCH] fit multi-display Signed-off-by: baoyang Change-Id: Ibd6c68f3e0bd083952028b9aeef328a31fa23163 --- .../test/unittest/src/test_common.cpp | 3 ++ .../security_component/src/sec_comp_base.cpp | 9 ++++++ .../include/sec_comp_base.h | 2 ++ .../sec_comp_info_helper.h | 2 +- .../sa/sa_main/first_use_dialog.cpp | 10 ++++--- .../sa/sa_main/first_use_dialog.h | 4 +-- .../sa/sa_main/sec_comp_info_helper.cpp | 9 +++--- .../sa/sa_main/sec_comp_manager.cpp | 6 ++-- .../unittest/src/first_use_dialog_test.cpp | 18 +++++------ .../src/sec_comp_info_helper_test.cpp | 30 +++++++++---------- .../test/unittest/src/service_test_common.cpp | 3 ++ .../security_component/common/fuzz_common.cpp | 3 ++ .../security_component/mock/display_manager.h | 5 ++++ .../mock/first_use_dialog.cpp | 4 +-- 14 files changed, 69 insertions(+), 39 deletions(-) diff --git a/frameworks/inner_api/security_component/test/unittest/src/test_common.cpp b/frameworks/inner_api/security_component/test/unittest/src/test_common.cpp index 2c602e3..1b8dfd7 100644 --- a/frameworks/inner_api/security_component/test/unittest/src/test_common.cpp +++ b/frameworks/inner_api/security_component/test/unittest/src/test_common.cpp @@ -71,6 +71,7 @@ void TestCommon::BuildLocationComponentInfo(nlohmann::json& jsonComponent) { JsonTagConstants::JSON_BG_TAG, SecCompBackground::CIRCLE }, }; jsonComponent[JsonTagConstants::JSON_WINDOW_ID] = 0; + jsonComponent[JsonTagConstants::JSON_DISPLAY_ID] = 0; } void TestCommon::BuildSaveComponentInfo(nlohmann::json& jsonComponent) @@ -127,6 +128,7 @@ void TestCommon::BuildSaveComponentInfo(nlohmann::json& jsonComponent) { JsonTagConstants::JSON_BG_TAG, SecCompBackground::CIRCLE }, }; jsonComponent[JsonTagConstants::JSON_WINDOW_ID] = 0; + jsonComponent[JsonTagConstants::JSON_DISPLAY_ID] = 0; } void TestCommon::BuildPasteComponentInfo(nlohmann::json& jsonComponent) @@ -183,6 +185,7 @@ void TestCommon::BuildPasteComponentInfo(nlohmann::json& jsonComponent) { JsonTagConstants::JSON_BG_TAG, SecCompBackground::CIRCLE }, }; jsonComponent[JsonTagConstants::JSON_WINDOW_ID] = 0; + jsonComponent[JsonTagConstants::JSON_DISPLAY_ID] = 0; } } // namespace SecurityComponent } // namespace Security diff --git a/frameworks/security_component/src/sec_comp_base.cpp b/frameworks/security_component/src/sec_comp_base.cpp index 22d10f3..92705ab 100644 --- a/frameworks/security_component/src/sec_comp_base.cpp +++ b/frameworks/security_component/src/sec_comp_base.cpp @@ -62,6 +62,7 @@ const std::string JsonTagConstants::JSON_TEXT_TAG = "text"; const std::string JsonTagConstants::JSON_ICON_TAG = "icon"; const std::string JsonTagConstants::JSON_BG_TAG = "bg"; const std::string JsonTagConstants::JSON_WINDOW_ID = "windowId"; +const std::string JsonTagConstants::JSON_DISPLAY_ID = "displayId"; bool SecCompBase::ParseDimension(const nlohmann::json& json, const std::string& tag, DimensionT& res) { @@ -295,6 +296,13 @@ bool SecCompBase::FromJson(const nlohmann::json& jsonSrc) return false; } windowId_ = jsonSrc.at(JsonTagConstants::JSON_WINDOW_ID).get(); + + if ((jsonSrc.find(JsonTagConstants::JSON_DISPLAY_ID) == jsonSrc.end()) || + !jsonSrc.at(JsonTagConstants::JSON_DISPLAY_ID).is_number()) { + SC_LOG_ERROR(LABEL, "json: %{public}s tag invalid.", JsonTagConstants::JSON_DISPLAY_ID.c_str()); + return false; + } + displayId_ = jsonSrc.at(JsonTagConstants::JSON_DISPLAY_ID).get(); return true; } @@ -353,6 +361,7 @@ void SecCompBase::ToJson(nlohmann::json& jsonRes) const { JsonTagConstants::JSON_BG_TAG, bg_ }, }; jsonRes[JsonTagConstants::JSON_WINDOW_ID] = windowId_; + jsonRes[JsonTagConstants::JSON_DISPLAY_ID] = displayId_; } std::string SecCompBase::ToJsonStr() const diff --git a/interfaces/inner_api/security_component/include/sec_comp_base.h b/interfaces/inner_api/security_component/include/sec_comp_base.h index f7c0130..a7bbd78 100644 --- a/interfaces/inner_api/security_component/include/sec_comp_base.h +++ b/interfaces/inner_api/security_component/include/sec_comp_base.h @@ -78,6 +78,7 @@ public: static const std::string JSON_ICON_TAG; static const std::string JSON_BG_TAG; static const std::string JSON_WINDOW_ID; + static const std::string JSON_DISPLAY_ID; }; class __attribute__((visibility("default"))) SecCompBase { @@ -131,6 +132,7 @@ public: SecCompBackground bg_ = SecCompBackground::UNKNOWN_BG; int32_t windowId_ = 0; + uint64_t displayId_ = 0; int32_t nodeId_ = 0; protected: virtual bool IsTextIconTypeValid() = 0; diff --git a/interfaces/inner_api/security_component_common/sec_comp_info_helper.h b/interfaces/inner_api/security_component_common/sec_comp_info_helper.h index fd3262e..f9b6a8c 100644 --- a/interfaces/inner_api/security_component_common/sec_comp_info_helper.h +++ b/interfaces/inner_api/security_component_common/sec_comp_info_helper.h @@ -38,7 +38,7 @@ class __attribute__((visibility("default"))) SecCompInfoHelper { public: static SecCompBase* ParseComponent(SecCompType type, const nlohmann::json& jsonComponent); static bool CheckComponentValid(SecCompBase* comp); - static bool CheckRectValid(const SecCompRect& rect, const SecCompRect& windowRect); + static bool CheckRectValid(const SecCompRect& rect, const SecCompRect& windowRect, const uint64_t displayId); private: static float GetWindowScale(int32_t windowId); diff --git a/services/security_component_service/sa/sa_main/first_use_dialog.cpp b/services/security_component_service/sa/sa_main/first_use_dialog.cpp index f06604f..5d8ab5d 100644 --- a/services/security_component_service/sa/sa_main/first_use_dialog.cpp +++ b/services/security_component_service/sa/sa_main/first_use_dialog.cpp @@ -47,6 +47,7 @@ const std::string TYPE_KEY = "ohos.user.security.type"; const std::string TOKEN_KEY = "ohos.ability.params.token"; const std::string CALLBACK_KEY = "ohos.ability.params.callback"; const std::string CALLER_UID_KEY = "ohos.caller.uid"; +const std::string DISPLAY_ID = "ohos.display.id"; constexpr uint32_t MAX_CFG_FILE_SIZE = 100 * 1024; // 100k constexpr uint64_t LOCATION_BUTTON_FIRST_USE = 1 << 0; @@ -296,7 +297,7 @@ int32_t FirstUseDialog::GrantDialogWaitEntity(int32_t scId) } void FirstUseDialog::StartDialogAbility(std::shared_ptr entity, - sptr callerToken, sptr dialogCallback) + sptr callerToken, sptr dialogCallback, const uint64_t displayId) { int32_t typeNum; SecCompType type = entity->GetType(); @@ -323,6 +324,7 @@ void FirstUseDialog::StartDialogAbility(std::shared_ptr entity, want.SetParam(CALLBACK_KEY, srvCallback); int32_t uid = IPCSkeleton::GetCallingUid(); want.SetParam(CALLER_UID_KEY, uid); + want.SetParam(DISPLAY_ID, static_cast(displayId)); int startRes = AAFwk::AbilityManagerClient::GetInstance()->StartExtensionAbility(want, callerToken); SC_LOG_INFO(LABEL, "start ability res %{public}d", startRes); if (startRes != 0) { @@ -373,7 +375,7 @@ bool FirstUseDialog::SetFirstUseMap(std::shared_ptr entity) } int32_t FirstUseDialog::NotifyFirstUseDialog(std::shared_ptr entity, - sptr callerToken, sptr dialogCallback) + sptr callerToken, sptr dialogCallback, const uint64_t displayId) { if (entity == nullptr) { SC_LOG_ERROR(LABEL, "Entity is invalid."); @@ -409,7 +411,7 @@ int32_t FirstUseDialog::NotifyFirstUseDialog(std::shared_ptr enti auto iter = firstUseMap_.find(tokenId); if (iter == firstUseMap_.end()) { SC_LOG_INFO(LABEL, "has not use record, start dialog"); - StartDialogAbility(entity, callerToken, dialogCallback); + StartDialogAbility(entity, callerToken, dialogCallback, displayId); return SC_SERVICE_ERROR_WAIT_FOR_DIALOG_CLOSE; } @@ -418,7 +420,7 @@ int32_t FirstUseDialog::NotifyFirstUseDialog(std::shared_ptr enti SC_LOG_INFO(LABEL, "no need notify again."); return SC_OK; } - StartDialogAbility(entity, callerToken, dialogCallback); + StartDialogAbility(entity, callerToken, dialogCallback, displayId); return SC_SERVICE_ERROR_WAIT_FOR_DIALOG_CLOSE; } diff --git a/services/security_component_service/sa/sa_main/first_use_dialog.h b/services/security_component_service/sa/sa_main/first_use_dialog.h index ea80cad..ecf5af6 100644 --- a/services/security_component_service/sa/sa_main/first_use_dialog.h +++ b/services/security_component_service/sa/sa_main/first_use_dialog.h @@ -54,7 +54,7 @@ public: ~FirstUseDialog() = default; int32_t NotifyFirstUseDialog(std::shared_ptr entity, - sptr callerToken, sptr dialogCallback); + sptr callerToken, sptr dialogCallback, const uint64_t displayId); void Init(std::shared_ptr secHandler); int32_t GrantDialogWaitEntity(int32_t scId); void RemoveDialogWaitEntitys(int32_t pid); @@ -73,7 +73,7 @@ private: void LoadFirstUseRecord(void); void SaveFirstUseRecord(void); void StartDialogAbility(std::shared_ptr entity, - sptr callerToken, sptr dialogCallback); + sptr callerToken, sptr dialogCallback, const uint64_t displayId); void SendSaveEventHandler(void); std::mutex useMapMutex_; diff --git a/services/security_component_service/sa/sa_main/sec_comp_info_helper.cpp b/services/security_component_service/sa/sa_main/sec_comp_info_helper.cpp index cce6667..a92c0d8 100644 --- a/services/security_component_service/sa/sa_main/sec_comp_info_helper.cpp +++ b/services/security_component_service/sa/sa_main/sec_comp_info_helper.cpp @@ -72,10 +72,10 @@ SecCompBase* SecCompInfoHelper::ParseComponent(SecCompType type, const nlohmann: return comp; } -static bool GetScreenSize(double& width, double& height) +static bool GetScreenSize(double& width, double& height, const uint64_t displayId) { sptr display = - OHOS::Rosen::DisplayManager::GetInstance().GetDefaultDisplaySync(); + OHOS::Rosen::DisplayManager::GetInstance().GetDisplayById(displayId); if (display == nullptr) { SC_LOG_ERROR(LABEL, "Get display manager failed"); return false; @@ -94,11 +94,12 @@ static bool GetScreenSize(double& width, double& height) return true; } -bool SecCompInfoHelper::CheckRectValid(const SecCompRect& rect, const SecCompRect& windowRect) +bool SecCompInfoHelper::CheckRectValid(const SecCompRect& rect, const SecCompRect& windowRect, + const uint64_t displayId) { double curScreenWidth = 0.0F; double curScreenHeight = 0.0F; - if (!GetScreenSize(curScreenWidth, curScreenHeight)) { + if (!GetScreenSize(curScreenWidth, curScreenHeight, displayId)) { SC_LOG_ERROR(LABEL, "Get screen size is invalid"); return false; } diff --git a/services/security_component_service/sa/sa_main/sec_comp_manager.cpp b/services/security_component_service/sa/sa_main/sec_comp_manager.cpp index 1c78e2d..bda0d42 100644 --- a/services/security_component_service/sa/sa_main/sec_comp_manager.cpp +++ b/services/security_component_service/sa/sa_main/sec_comp_manager.cpp @@ -467,7 +467,8 @@ int32_t SecCompManager::CheckClickSecurityComponentInfo(std::shared_ptrrect_, reportComponentInfo->windowRect_))) { + if ((!SecCompInfoHelper::CheckRectValid(reportComponentInfo->rect_, reportComponentInfo->windowRect_, + report->displayId_))) { SC_LOG_ERROR(LABEL, "compare component info failed."); HiSysEventWrite(HiviewDFX::HiSysEvent::Domain::SEC_COMPONENT, "COMPONENT_INFO_CHECK_FAILED", HiviewDFX::HiSysEvent::EventType::SECURITY, "CALLER_UID", uid, "CALLER_BUNDLE_NAME", bundleName, @@ -538,7 +539,8 @@ int32_t SecCompManager::ReportSecurityComponentClickEvent(int32_t scId, return SC_SERVICE_ERROR_CLICK_EVENT_INVALID; } - if (FirstUseDialog::GetInstance().NotifyFirstUseDialog(sc, callerToken, dialogCallback) == + SecCompBase* report = SecCompInfoHelper::ParseComponent(sc->GetType(), jsonComponent); + if (FirstUseDialog::GetInstance().NotifyFirstUseDialog(sc, callerToken, dialogCallback, report->displayId_) == SC_SERVICE_ERROR_WAIT_FOR_DIALOG_CLOSE) { SC_LOG_INFO(LABEL, "start dialog, onclick will be trap after dialog closed."); return SC_SERVICE_ERROR_WAIT_FOR_DIALOG_CLOSE; diff --git a/services/security_component_service/sa/test/unittest/src/first_use_dialog_test.cpp b/services/security_component_service/sa/test/unittest/src/first_use_dialog_test.cpp index fc4d4a0..7164ffe 100644 --- a/services/security_component_service/sa/test/unittest/src/first_use_dialog_test.cpp +++ b/services/security_component_service/sa/test/unittest/src/first_use_dialog_test.cpp @@ -407,46 +407,46 @@ HWTEST_F(FirstUseDialogTest, NotifyFirstUseDialog001, TestSize.Level1) diag.secHandler_ = nullptr; // no entity - EXPECT_EQ(diag.NotifyFirstUseDialog(nullptr, nullptr, nullptr), SC_SERVICE_ERROR_VALUE_INVALID); + EXPECT_EQ(diag.NotifyFirstUseDialog(nullptr, nullptr, nullptr, 0), SC_SERVICE_ERROR_VALUE_INVALID); std::shared_ptr entity = std::make_shared(nullptr, 0, 0, 0, 0); // no handler - EXPECT_EQ(diag.NotifyFirstUseDialog(entity, nullptr, nullptr), SC_SERVICE_ERROR_VALUE_INVALID); + EXPECT_EQ(diag.NotifyFirstUseDialog(entity, nullptr, nullptr, 0), SC_SERVICE_ERROR_VALUE_INVALID); // no calltoken std::shared_ptr runner = AppExecFwk::EventRunner::Create(true); ASSERT_NE(nullptr, runner); std::shared_ptr handler = std::make_shared(runner); diag.secHandler_ = handler; - EXPECT_EQ(diag.NotifyFirstUseDialog(entity, nullptr, nullptr), SC_SERVICE_ERROR_VALUE_INVALID); + EXPECT_EQ(diag.NotifyFirstUseDialog(entity, nullptr, nullptr, 0), SC_SERVICE_ERROR_VALUE_INVALID); // no dialogCallback sptr testRemoteObject = new TestRemoteObject(std::u16string()); - EXPECT_EQ(diag.NotifyFirstUseDialog(entity, testRemoteObject, nullptr), SC_SERVICE_ERROR_VALUE_INVALID); + EXPECT_EQ(diag.NotifyFirstUseDialog(entity, testRemoteObject, nullptr, 0), SC_SERVICE_ERROR_VALUE_INVALID); // type invalid - EXPECT_EQ(diag.NotifyFirstUseDialog(entity, testRemoteObject, testRemoteObject), SC_OK); + EXPECT_EQ(diag.NotifyFirstUseDialog(entity, testRemoteObject, testRemoteObject, 0), SC_OK); // first use location button entity->componentInfo_ = std::make_shared(); entity->componentInfo_->type_ = LOCATION_COMPONENT; entity->tokenId_ = 0; - EXPECT_EQ(diag.NotifyFirstUseDialog(entity, testRemoteObject, testRemoteObject), + EXPECT_EQ(diag.NotifyFirstUseDialog(entity, testRemoteObject, testRemoteObject, 0), SC_SERVICE_ERROR_WAIT_FOR_DIALOG_CLOSE); EXPECT_EQ(0, static_cast(diag.firstUseMap_[0])); // first use save button entity->componentInfo_->type_ = SAVE_COMPONENT; - EXPECT_EQ(diag.NotifyFirstUseDialog(entity, testRemoteObject, testRemoteObject), + EXPECT_EQ(diag.NotifyFirstUseDialog(entity, testRemoteObject, testRemoteObject, 0), SC_SERVICE_ERROR_WAIT_FOR_DIALOG_CLOSE); EXPECT_EQ(0, static_cast(diag.firstUseMap_[0])); // second use save button - EXPECT_EQ(diag.NotifyFirstUseDialog(entity, testRemoteObject, testRemoteObject), + EXPECT_EQ(diag.NotifyFirstUseDialog(entity, testRemoteObject, testRemoteObject, 0), SC_SERVICE_ERROR_WAIT_FOR_DIALOG_CLOSE); EXPECT_EQ(0, static_cast(diag.firstUseMap_[0])); - diag.StartDialogAbility(entity, testRemoteObject, testRemoteObject); + diag.StartDialogAbility(entity, testRemoteObject, testRemoteObject, 0); // wait for event handler done sleep(3); diff --git a/services/security_component_service/sa/test/unittest/src/sec_comp_info_helper_test.cpp b/services/security_component_service/sa/test/unittest/src/sec_comp_info_helper_test.cpp index a33b8df..25e66cf 100644 --- a/services/security_component_service/sa/test/unittest/src/sec_comp_info_helper_test.cpp +++ b/services/security_component_service/sa/test/unittest/src/sec_comp_info_helper_test.cpp @@ -149,36 +149,36 @@ HWTEST_F(SecCompInfoHelperTest, ParseComponent004, TestSize.Level1) { SecCompRect rect = GetDefaultRect(); SecCompRect windowRect = GetDefaultRect(); - ASSERT_TRUE(SecCompInfoHelper::CheckRectValid(rect, windowRect)); + ASSERT_TRUE(SecCompInfoHelper::CheckRectValid(rect, windowRect, 0)); rect.x_ = ServiceTestCommon::TEST_INVALID_DIMENSION; - ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect)); + ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect, 0)); rect.x_ = g_testWidth; rect.y_ = ServiceTestCommon::TEST_INVALID_DIMENSION; - ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect)); + ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect, 0)); rect.y_ = g_testHeight; rect.x_ = g_curScreenWidth + 1; - ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect)); + ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect, 0)); rect.x_ = g_testWidth; rect.y_ = g_curScreenHeight + 1; - ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect)); + ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect, 0)); rect.y_ = g_testHeight; rect.width_ = g_curScreenWidth; rect.height_ = g_curScreenHeight; - ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect)); + ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect, 0)); rect.width_ = g_testWidth; rect.height_ = g_testHeight; rect.x_ = g_curScreenWidth - g_testWidth; - ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect)); + ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect, 0)); rect.x_ = g_testWidth; rect.y_ = g_curScreenHeight - g_testHeight; - ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect)); + ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect, 0)); rect.y_ = g_testHeight; } @@ -192,30 +192,30 @@ HWTEST_F(SecCompInfoHelperTest, ParseComponent005, TestSize.Level1) { SecCompRect rect = GetDefaultRect(); SecCompRect windowRect = GetDefaultRect(); - ASSERT_TRUE(SecCompInfoHelper::CheckRectValid(rect, windowRect)); + ASSERT_TRUE(SecCompInfoHelper::CheckRectValid(rect, windowRect, 0)); windowRect.x_ = g_testWidth + 1; - ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect)); + ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect, 0)); windowRect.x_ = g_testWidth; windowRect.y_ = g_testHeight + 1; - ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect)); + ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect, 0)); windowRect.y_ = g_testHeight; windowRect.width_ = g_testWidth - 1; - ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect)); + ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect, 0)); windowRect.width_ = g_testWidth; windowRect.height_ = g_testHeight - 1; - ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect)); + ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect, 0)); windowRect.height_ = g_testHeight; windowRect.width_ = ServiceTestCommon::TEST_INVALID_DIMENSION; - ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect)); + ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect, 0)); windowRect.width_ = g_testWidth; windowRect.height_ = ServiceTestCommon::TEST_INVALID_DIMENSION; - ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect)); + ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect, 0)); windowRect.height_ = g_testHeight; } diff --git a/services/security_component_service/sa/test/unittest/src/service_test_common.cpp b/services/security_component_service/sa/test/unittest/src/service_test_common.cpp index d3433d1..c96c744 100644 --- a/services/security_component_service/sa/test/unittest/src/service_test_common.cpp +++ b/services/security_component_service/sa/test/unittest/src/service_test_common.cpp @@ -71,6 +71,7 @@ void ServiceTestCommon::BuildLocationComponentJson(nlohmann::json& jsonComponent { JsonTagConstants::JSON_BG_TAG, SecCompBackground::CIRCLE }, }; jsonComponent[JsonTagConstants::JSON_WINDOW_ID] = 0; + jsonComponent[JsonTagConstants::JSON_DISPLAY_ID] = 0; } void ServiceTestCommon::BuildSaveComponentJson(nlohmann::json& jsonComponent) @@ -127,6 +128,7 @@ void ServiceTestCommon::BuildSaveComponentJson(nlohmann::json& jsonComponent) { JsonTagConstants::JSON_BG_TAG, SecCompBackground::CIRCLE }, }; jsonComponent[JsonTagConstants::JSON_WINDOW_ID] = 0; + jsonComponent[JsonTagConstants::JSON_DISPLAY_ID] = 0; } void ServiceTestCommon::BuildPasteComponentJson(nlohmann::json& jsonComponent) @@ -183,6 +185,7 @@ void ServiceTestCommon::BuildPasteComponentJson(nlohmann::json& jsonComponent) { JsonTagConstants::JSON_BG_TAG, SecCompBackground::CIRCLE }, }; jsonComponent[JsonTagConstants::JSON_WINDOW_ID] = 0; + jsonComponent[JsonTagConstants::JSON_DISPLAY_ID] = 0; } } // namespace SecurityComponent } // namespace Security diff --git a/test/fuzztest/security_component/common/fuzz_common.cpp b/test/fuzztest/security_component/common/fuzz_common.cpp index 1d49bfb..9233160 100644 --- a/test/fuzztest/security_component/common/fuzz_common.cpp +++ b/test/fuzztest/security_component/common/fuzz_common.cpp @@ -96,6 +96,7 @@ std::string CompoRandomGenerator::ConstructLocationJson() GetData() % static_cast(SecCompBackground::MAX_BG_TYPE) }, }; jsonComponent[JsonTagConstants::JSON_WINDOW_ID] = 0; + jsonComponent[JsonTagConstants::JSON_DISPLAY_ID] = 0; compoJson_ = jsonComponent; return compoJson_.dump(); } @@ -138,6 +139,7 @@ std::string CompoRandomGenerator::ConstructSaveJson() GetData() % static_cast(SecCompBackground::MAX_BG_TYPE) }, }; jsonComponent[JsonTagConstants::JSON_WINDOW_ID] = 0; + jsonComponent[JsonTagConstants::JSON_DISPLAY_ID] = 0; compoJson_ = jsonComponent; return compoJson_.dump(); } @@ -180,6 +182,7 @@ std::string CompoRandomGenerator::ConstructPasteJson() GetData() % static_cast(SecCompBackground::MAX_BG_TYPE) }, }; jsonComponent[JsonTagConstants::JSON_WINDOW_ID] = 0; + jsonComponent[JsonTagConstants::JSON_DISPLAY_ID] = 0; compoJson_ = jsonComponent; return compoJson_.dump(); } diff --git a/test/fuzztest/security_component/mock/display_manager.h b/test/fuzztest/security_component/mock/display_manager.h index ac0f7b8..2a3fe2d 100644 --- a/test/fuzztest/security_component/mock/display_manager.h +++ b/test/fuzztest/security_component/mock/display_manager.h @@ -30,6 +30,11 @@ public: { return sptr::MakeSptr(); } + + sptr GetDisplayById(uint64_t displayId) + { + return sptr::MakeSptr(); + } }; } #endif // SECURITY_COMPONENT_MANAGER_DISPLAY_MANAGER_MOCK_H \ No newline at end of file diff --git a/test/fuzztest/security_component/mock/first_use_dialog.cpp b/test/fuzztest/security_component/mock/first_use_dialog.cpp index 69e5fac..2dd63ee 100644 --- a/test/fuzztest/security_component/mock/first_use_dialog.cpp +++ b/test/fuzztest/security_component/mock/first_use_dialog.cpp @@ -86,7 +86,7 @@ int32_t FirstUseDialog::GrantDialogWaitEntity(int32_t scId) } void FirstUseDialog::StartDialogAbility(std::shared_ptr entity, - sptr callerToken, sptr dialogCallback) + sptr callerToken, sptr dialogCallback, const uint64_t displayId) { return; } @@ -102,7 +102,7 @@ bool FirstUseDialog::SetFirstUseMap(std::shared_ptr entity) } int32_t FirstUseDialog::NotifyFirstUseDialog(std::shared_ptr entity, - sptr callerToken, sptr dialogCallback) + sptr callerToken, sptr dialogCallback, const uint64_t displayId) { return SC_OK; }