From 954c9f86b75b3707e0fcad4db6d3d1a62c4e5067 Mon Sep 17 00:00:00 2001 From: AXYChen Date: Mon, 28 Jul 2025 11:32:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=9D=E5=AD=98=E6=8E=A7=E4=BB=B6=E6=94=BE?= =?UTF-8?q?=E5=BC=80=E9=83=A8=E5=88=86=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: AXYChen Change-Id: Ia58882935e8b6fb053c006be6d5e9928d6eb8cd3 --- .../src/sec_comp_register_callback_test.cpp | 48 +++++++++---------- .../sa/sa_main/sec_comp_entity.cpp | 4 +- .../unittest/src/sec_comp_entity_test.cpp | 4 ++ 3 files changed, 30 insertions(+), 26 deletions(-) diff --git a/frameworks/inner_api/security_component/test/unittest/src/sec_comp_register_callback_test.cpp b/frameworks/inner_api/security_component/test/unittest/src/sec_comp_register_callback_test.cpp index 97f5689..54da9da 100644 --- a/frameworks/inner_api/security_component/test/unittest/src/sec_comp_register_callback_test.cpp +++ b/frameworks/inner_api/security_component/test/unittest/src/sec_comp_register_callback_test.cpp @@ -238,11 +238,11 @@ HWTEST_F(SecCompRegisterCallbackTest, RegisterSecurityComponent005, TestSize.Lev { system("param set sec.comp.enhance 1"); nlohmann::json jsonRes; - TestCommon::BuildSaveComponentInfo(jsonRes); - std::string saveInfo = jsonRes.dump(); + TestCommon::BuildPasteComponentInfo(jsonRes); + std::string pasteInfo = jsonRes.dump(); int32_t scId; - EXPECT_EQ(SC_OK, RegisterSecurityComponent(SAVE_COMPONENT, saveInfo, scId)); + EXPECT_EQ(SC_OK, RegisterSecurityComponent(PASTE_COMPONENT, pasteInfo, scId)); uint8_t data[TestCommon::MAX_HMAC_SIZE] = { 0 }; struct SecCompClickEvent clickInfo = { .type = ClickEventType::POINT_EVENT_TYPE, @@ -257,7 +257,7 @@ HWTEST_F(SecCompRegisterCallbackTest, RegisterSecurityComponent005, TestSize.Lev ASSERT_NE(callback, nullptr); auto token = callback->AsObject(); OnFirstUseDialogCloseFunc func = [] (int32_t) {}; - SecCompInfo secCompInfo{ scId, saveInfo, clickInfo }; + SecCompInfo secCompInfo{ scId, pasteInfo, clickInfo }; std::string message; EXPECT_EQ(SC_SERVICE_ERROR_CLICK_EVENT_INVALID, ReportSecurityComponentClickEvent(secCompInfo, token, std::move(func), message)); @@ -291,11 +291,11 @@ HWTEST_F(SecCompRegisterCallbackTest, ReportSecurityComponentClickEvent001, Test { system("param set sec.comp.enhance 1"); nlohmann::json jsonRes; - TestCommon::BuildSaveComponentInfo(jsonRes); - std::string saveInfo = jsonRes.dump(); + TestCommon::BuildPasteComponentInfo(jsonRes); + std::string pasteInfo = jsonRes.dump(); int32_t scId; - EXPECT_EQ(SC_OK, RegisterSecurityComponent(SAVE_COMPONENT, saveInfo, scId)); + EXPECT_EQ(SC_OK, RegisterSecurityComponent(PASTE_COMPONENT, pasteInfo, scId)); uint8_t data[TestCommon::MAX_HMAC_SIZE] = { 0 }; struct SecCompClickEvent clickInfo = { .type = ClickEventType::POINT_EVENT_TYPE, @@ -311,7 +311,7 @@ HWTEST_F(SecCompRegisterCallbackTest, ReportSecurityComponentClickEvent001, Test ASSERT_NE(callback, nullptr); auto token = callback->AsObject(); OnFirstUseDialogCloseFunc func = [] (int32_t) {}; - SecCompInfo secCompInfo{ scId, saveInfo, clickInfo }; + SecCompInfo secCompInfo{ scId, pasteInfo, clickInfo }; std::string message; ASSERT_EQ(SC_SERVICE_ERROR_CLICK_EVENT_INVALID, ReportSecurityComponentClickEvent(secCompInfo, token, std::move(func), message)); @@ -370,13 +370,13 @@ HWTEST_F(SecCompRegisterCallbackTest, ReportSecurityComponentClickEvent002, Test HWTEST_F(SecCompRegisterCallbackTest, ReportSecurityComponentClickEvent003, TestSize.Level0) { nlohmann::json jsonRes; - TestCommon::BuildSaveComponentInfo(jsonRes); - std::string saveInfo = jsonRes.dump(); + TestCommon::BuildPasteComponentInfo(jsonRes); + std::string pasteInfo = jsonRes.dump(); int32_t scId; ASSERT_EQ(0, SetSelfTokenID(TestCommon::HAP_TOKEN_ID + g_token_sum)); g_token_sum ++; - EXPECT_EQ(SC_OK, RegisterSecurityComponent(SAVE_COMPONENT, saveInfo, scId)); + EXPECT_EQ(SC_OK, RegisterSecurityComponent(PASTE_COMPONENT, pasteInfo, scId)); struct SecCompClickEvent clickInfo = { .type = ClickEventType::POINT_EVENT_TYPE, @@ -389,7 +389,7 @@ HWTEST_F(SecCompRegisterCallbackTest, ReportSecurityComponentClickEvent003, Test ASSERT_NE(callback, nullptr); auto token = callback->AsObject(); OnFirstUseDialogCloseFunc func = [] (int32_t) {}; - SecCompInfo secCompInfo{ scId, saveInfo, clickInfo }; + SecCompInfo secCompInfo{ scId, pasteInfo, clickInfo }; std::string message; #ifdef SECURITY_COMPONENT_ENHANCE_ENABLE ASSERT_EQ(SC_SERVICE_ERROR_CLICK_EVENT_INVALID, @@ -486,13 +486,13 @@ HWTEST_F(SecCompRegisterCallbackTest, VerifySavePermission001, TestSize.Level0) { system("param set sec.comp.enhance 1"); nlohmann::json jsonRes; - TestCommon::BuildSaveComponentInfo(jsonRes); - std::string saveInfo = jsonRes.dump(); + TestCommon::BuildPasteComponentInfo(jsonRes); + std::string pasteInfo = jsonRes.dump(); int32_t scId; ASSERT_EQ(0, SetSelfTokenID(TestCommon::HAP_TOKEN_ID + g_token_sum)); g_token_sum ++; - EXPECT_EQ(SC_OK, RegisterSecurityComponent(SAVE_COMPONENT, saveInfo, scId)); + EXPECT_EQ(SC_OK, RegisterSecurityComponent(PASTE_COMPONENT, pasteInfo, scId)); uint8_t data[TestCommon::MAX_HMAC_SIZE] = { 0 }; struct SecCompClickEvent clickInfo = { .type = ClickEventType::POINT_EVENT_TYPE, @@ -507,7 +507,7 @@ HWTEST_F(SecCompRegisterCallbackTest, VerifySavePermission001, TestSize.Level0) ASSERT_NE(callback, nullptr); auto token = callback->AsObject(); OnFirstUseDialogCloseFunc func = [] (int32_t) {}; - SecCompInfo secCompInfo{ scId, saveInfo, clickInfo }; + SecCompInfo secCompInfo{ scId, pasteInfo, clickInfo }; std::string message; ASSERT_EQ(SC_SERVICE_ERROR_CLICK_EVENT_INVALID, ReportSecurityComponentClickEvent(secCompInfo, token, std::move(func), message)); @@ -530,11 +530,11 @@ HWTEST_F(SecCompRegisterCallbackTest, VerifySavePermission002, TestSize.Level0) { system("param set sec.comp.enhance 1"); nlohmann::json jsonRes; - TestCommon::BuildSaveComponentInfo(jsonRes); - std::string saveInfo = jsonRes.dump(); + TestCommon::BuildPasteComponentInfo(jsonRes); + std::string pasteInfo = jsonRes.dump(); int32_t scId; - EXPECT_EQ(SC_OK, RegisterSecurityComponent(SAVE_COMPONENT, saveInfo, scId)); + EXPECT_EQ(SC_OK, RegisterSecurityComponent(PASTE_COMPONENT, pasteInfo, scId)); uint8_t data[TestCommon::MAX_HMAC_SIZE] = { 0 }; struct SecCompClickEvent clickInfo = { .type = ClickEventType::POINT_EVENT_TYPE, @@ -549,7 +549,7 @@ HWTEST_F(SecCompRegisterCallbackTest, VerifySavePermission002, TestSize.Level0) ASSERT_NE(callback, nullptr); auto token = callback->AsObject(); OnFirstUseDialogCloseFunc func = [] (int32_t) {}; - SecCompInfo secCompInfo{ scId, saveInfo, clickInfo }; + SecCompInfo secCompInfo{ scId, pasteInfo, clickInfo }; std::string message; ASSERT_EQ(SC_SERVICE_ERROR_CLICK_EVENT_INVALID, ReportSecurityComponentClickEvent(secCompInfo, token, std::move(func), message)); @@ -567,11 +567,11 @@ HWTEST_F(SecCompRegisterCallbackTest, UnregisterSecurityComponent001, TestSize.L { system("param set sec.comp.enhance 1"); nlohmann::json jsonRes; - TestCommon::BuildSaveComponentInfo(jsonRes); - std::string saveInfo = jsonRes.dump(); + TestCommon::BuildPasteComponentInfo(jsonRes); + std::string pasteInfo = jsonRes.dump(); int32_t scId; - EXPECT_EQ(SC_OK, RegisterSecurityComponent(SAVE_COMPONENT, saveInfo, scId)); + EXPECT_EQ(SC_OK, RegisterSecurityComponent(PASTE_COMPONENT, pasteInfo, scId)); uint8_t data[TestCommon::MAX_HMAC_SIZE] = { 0 }; struct SecCompClickEvent clickInfo = { .type = ClickEventType::POINT_EVENT_TYPE, @@ -586,7 +586,7 @@ HWTEST_F(SecCompRegisterCallbackTest, UnregisterSecurityComponent001, TestSize.L ASSERT_NE(callback, nullptr); auto token = callback->AsObject(); OnFirstUseDialogCloseFunc func = [] (int32_t) {}; - SecCompInfo secCompInfo{ scId, saveInfo, clickInfo }; + SecCompInfo secCompInfo{ scId, pasteInfo, clickInfo }; std::string message; EXPECT_EQ(SC_SERVICE_ERROR_CLICK_EVENT_INVALID, ReportSecurityComponentClickEvent(secCompInfo, token, std::move(func), message)); diff --git a/services/security_component_service/sa/sa_main/sec_comp_entity.cpp b/services/security_component_service/sa/sa_main/sec_comp_entity.cpp index b6d7b3f..79a09d3 100644 --- a/services/security_component_service/sa/sa_main/sec_comp_entity.cpp +++ b/services/security_component_service/sa/sa_main/sec_comp_entity.cpp @@ -131,8 +131,8 @@ int32_t SecCompEntity::CheckClickInfo(SecCompClickEvent& clickInfo, int32_t supe componentInfo_->rect_.y_ += superFoldOffsetY; } message.clear(); - if (!WindowInfoHelper::CheckOtherWindowCoverComp(componentInfo_->windowId_, - componentInfo_->rect_, message)) { + if ((GetType() != SecCompType::SAVE_COMPONENT) && + !WindowInfoHelper::CheckOtherWindowCoverComp(componentInfo_->windowId_, componentInfo_->rect_, message)) { SC_LOG_ERROR(LABEL, "Component may be covered by other window"); if (!AllowToBypassSecurityCheck(message)) { return SC_SERVICE_ERROR_CLICK_EVENT_INVALID; diff --git a/services/security_component_service/sa/test/unittest/src/sec_comp_entity_test.cpp b/services/security_component_service/sa/test/unittest/src/sec_comp_entity_test.cpp index a5a3302..bff32c5 100644 --- a/services/security_component_service/sa/test/unittest/src/sec_comp_entity_test.cpp +++ b/services/security_component_service/sa/test/unittest/src/sec_comp_entity_test.cpp @@ -139,6 +139,10 @@ HWTEST_F(SecCompEntityTest, CheckClickInfo001, TestSize.Level0) touch.point.timestamp = static_cast( std::chrono::high_resolution_clock::now().time_since_epoch().count()) / ServiceTestCommon::TIME_CONVERSION_UNIT; ASSERT_EQ(entity_->CheckClickInfo(touch, 0, CrossAxisState::STATE_INVALID, message), SC_OK); + + OHOS::Rosen::WindowManager::GetInstance().result_ = static_cast(-1); + entity_->componentInfo_->type_ = SAVE_COMPONENT; + ASSERT_EQ(entity_->CheckClickInfo(touch, 0, CrossAxisState::STATE_INVALID, message), SC_OK); } /** -- Gitee