From 8f09380397ff3fc6800450e1859ec8f2a0e41b24 Mon Sep 17 00:00:00 2001 From: Haryslee Date: Wed, 12 Mar 2025 17:56:03 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=89=E5=85=A8=E6=8E=A7=E4=BB=B6?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=89=93=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Haryslee --- .../test/unittest/src/test_common.cpp | 6 ++++++ frameworks/security_component/src/sec_comp_base.cpp | 10 ++++++++++ .../security_component/include/sec_comp_base.h | 4 ++++ .../sa/test/unittest/src/service_test_common.cpp | 6 ++++++ .../fuzztest/security_component/common/fuzz_common.cpp | 6 ++++++ 5 files changed, 32 insertions(+) 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 3ba019d..37f4d34 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 @@ -82,6 +82,8 @@ void TestCommon::BuildLocationComponentInfo(nlohmann::json& jsonComponent) jsonComponent[JsonTagConstants::JSON_WINDOW_ID] = 0; jsonComponent[JsonTagConstants::JSON_DISPLAY_ID] = 0; jsonComponent[JsonTagConstants::JSON_CROSS_AXIS_STATE] = 0; + jsonComponent[JsonTagConstants::JSON_IS_ICON_EXCEEDED_TAG] = false; + jsonComponent[JsonTagConstants::JSON_IS_BORDER_COVERED_TAG] = false; jsonComponent[JsonTagConstants::JSON_NON_COMPATIBLE_CHANGE_TAG] = false; jsonComponent[JsonTagConstants::JSON_LINEAR_GRADIENT_BLUR_RADIUS_TAG] = 0.0; } @@ -151,6 +153,8 @@ void TestCommon::BuildSaveComponentInfo(nlohmann::json& jsonComponent) jsonComponent[JsonTagConstants::JSON_WINDOW_ID] = 0; jsonComponent[JsonTagConstants::JSON_DISPLAY_ID] = 0; jsonComponent[JsonTagConstants::JSON_CROSS_AXIS_STATE] = 0; + jsonComponent[JsonTagConstants::JSON_IS_ICON_EXCEEDED_TAG] = false; + jsonComponent[JsonTagConstants::JSON_IS_BORDER_COVERED_TAG] = false; jsonComponent[JsonTagConstants::JSON_NON_COMPATIBLE_CHANGE_TAG] = false; jsonComponent[JsonTagConstants::JSON_LINEAR_GRADIENT_BLUR_RADIUS_TAG] = 0.0; } @@ -220,6 +224,8 @@ void TestCommon::BuildPasteComponentInfo(nlohmann::json& jsonComponent) jsonComponent[JsonTagConstants::JSON_WINDOW_ID] = 0; jsonComponent[JsonTagConstants::JSON_DISPLAY_ID] = 0; jsonComponent[JsonTagConstants::JSON_CROSS_AXIS_STATE] = 0; + jsonComponent[JsonTagConstants::JSON_IS_ICON_EXCEEDED_TAG] = false; + jsonComponent[JsonTagConstants::JSON_IS_BORDER_COVERED_TAG] = false; jsonComponent[JsonTagConstants::JSON_NON_COMPATIBLE_CHANGE_TAG] = false; jsonComponent[JsonTagConstants::JSON_LINEAR_GRADIENT_BLUR_RADIUS_TAG] = 0.0; } diff --git a/frameworks/security_component/src/sec_comp_base.cpp b/frameworks/security_component/src/sec_comp_base.cpp index acd00ea..0afa931 100644 --- a/frameworks/security_component/src/sec_comp_base.cpp +++ b/frameworks/security_component/src/sec_comp_base.cpp @@ -70,6 +70,8 @@ const std::string JsonTagConstants::JSON_BG_TAG = "bg"; const std::string JsonTagConstants::JSON_WINDOW_ID = "windowId"; const std::string JsonTagConstants::JSON_DISPLAY_ID = "displayId"; const std::string JsonTagConstants::JSON_CROSS_AXIS_STATE = "crossAxisState"; +const std::string JsonTagConstants::JSON_IS_ICON_EXCEEDED_TAG = "isIconExceeded"; +const std::string JsonTagConstants::JSON_IS_BORDER_COVERED_TAG = "isBorderCovered"; const std::string JsonTagConstants::JSON_NON_COMPATIBLE_CHANGE_TAG = "hasNonCompatileChange"; const std::string JsonTagConstants::JSON_LINEAR_GRADIENT_BLUR_RADIUS_TAG = "blurRadius"; @@ -82,6 +84,12 @@ bool SecCompBase::ParseNonCompatibleChange(const nlohmann::json& json) } hasNonCompatileChange_ = json.at(tag).get(); + if (!ParseBool(json, JsonTagConstants::JSON_IS_ICON_EXCEEDED_TAG, isIconExceeded_)) { + return false; + } + if (!ParseBool(json, JsonTagConstants::JSON_IS_BORDER_COVERED_TAG, isBorderCovered_)) { + return false; + } if (!ParseDimension(json, JsonTagConstants::JSON_LINEAR_GRADIENT_BLUR_RADIUS_TAG, blurRadius_)) { return false; } @@ -480,6 +488,8 @@ void SecCompBase::ToJson(nlohmann::json& jsonRes) const jsonRes[JsonTagConstants::JSON_WINDOW_ID] = windowId_; jsonRes[JsonTagConstants::JSON_DISPLAY_ID] = displayId_; jsonRes[JsonTagConstants::JSON_CROSS_AXIS_STATE] = crossAxisState_; + jsonRes[JsonTagConstants::JSON_IS_ICON_EXCEEDED_TAG] = isIconExceeded_; + jsonRes[JsonTagConstants::JSON_IS_BORDER_COVERED_TAG] = isBorderCovered_; jsonRes[JsonTagConstants::JSON_NON_COMPATIBLE_CHANGE_TAG] = hasNonCompatileChange_; jsonRes[JsonTagConstants::JSON_LINEAR_GRADIENT_BLUR_RADIUS_TAG] = blurRadius_; } 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 6ded581..1758e08 100644 --- a/interfaces/inner_api/security_component/include/sec_comp_base.h +++ b/interfaces/inner_api/security_component/include/sec_comp_base.h @@ -87,6 +87,8 @@ public: static const std::string JSON_WINDOW_ID; static const std::string JSON_DISPLAY_ID; static const std::string JSON_CROSS_AXIS_STATE; + static const std::string JSON_IS_ICON_EXCEEDED_TAG; + static const std::string JSON_IS_BORDER_COVERED_TAG; static const std::string JSON_NON_COMPATIBLE_CHANGE_TAG; static const std::string JSON_LINEAR_GRADIENT_BLUR_RADIUS_TAG; }; @@ -148,6 +150,8 @@ public: uint64_t displayId_ = 0; int32_t nodeId_ = 0; CrossAxisState crossAxisState_ = CrossAxisState::STATE_INVALID; + bool isIconExceeded_ = false; + bool isBorderCovered_ = false; bool isWearableDevice_ = false; protected: virtual bool IsTextIconTypeValid(std::string& message, bool isClicked) = 0; 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 6de9eca..dec5aff 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 @@ -83,6 +83,8 @@ void ServiceTestCommon::BuildLocationComponentJson(nlohmann::json& jsonComponent jsonComponent[JsonTagConstants::JSON_WINDOW_ID] = 0; jsonComponent[JsonTagConstants::JSON_DISPLAY_ID] = 0; jsonComponent[JsonTagConstants::JSON_CROSS_AXIS_STATE] = 0; + jsonComponent[JsonTagConstants::JSON_IS_ICON_EXCEEDED_TAG] = false; + jsonComponent[JsonTagConstants::JSON_IS_BORDER_COVERED_TAG] = false; jsonComponent[JsonTagConstants::JSON_NON_COMPATIBLE_CHANGE_TAG] = false; jsonComponent[JsonTagConstants::JSON_LINEAR_GRADIENT_BLUR_RADIUS_TAG] = 0.0; } @@ -152,6 +154,8 @@ void ServiceTestCommon::BuildSaveComponentJson(nlohmann::json& jsonComponent) jsonComponent[JsonTagConstants::JSON_WINDOW_ID] = 0; jsonComponent[JsonTagConstants::JSON_DISPLAY_ID] = 0; jsonComponent[JsonTagConstants::JSON_CROSS_AXIS_STATE] = 0; + jsonComponent[JsonTagConstants::JSON_IS_ICON_EXCEEDED_TAG] = false; + jsonComponent[JsonTagConstants::JSON_IS_BORDER_COVERED_TAG] = false; jsonComponent[JsonTagConstants::JSON_NON_COMPATIBLE_CHANGE_TAG] = false; jsonComponent[JsonTagConstants::JSON_LINEAR_GRADIENT_BLUR_RADIUS_TAG] = 0.0; } @@ -221,6 +225,8 @@ void ServiceTestCommon::BuildPasteComponentJson(nlohmann::json& jsonComponent) jsonComponent[JsonTagConstants::JSON_WINDOW_ID] = 0; jsonComponent[JsonTagConstants::JSON_DISPLAY_ID] = 0; jsonComponent[JsonTagConstants::JSON_CROSS_AXIS_STATE] = 0; + jsonComponent[JsonTagConstants::JSON_IS_ICON_EXCEEDED_TAG] = false; + jsonComponent[JsonTagConstants::JSON_IS_BORDER_COVERED_TAG] = false; jsonComponent[JsonTagConstants::JSON_NON_COMPATIBLE_CHANGE_TAG] = false; jsonComponent[JsonTagConstants::JSON_LINEAR_GRADIENT_BLUR_RADIUS_TAG] = 0.0; } diff --git a/test/fuzztest/security_component/common/fuzz_common.cpp b/test/fuzztest/security_component/common/fuzz_common.cpp index d83d2b9..5c165ef 100644 --- a/test/fuzztest/security_component/common/fuzz_common.cpp +++ b/test/fuzztest/security_component/common/fuzz_common.cpp @@ -100,6 +100,8 @@ std::string CompoRandomGenerator::ConstructLocationJson() jsonComponent[JsonTagConstants::JSON_WINDOW_ID] = 0; jsonComponent[JsonTagConstants::JSON_DISPLAY_ID] = 0; jsonComponent[JsonTagConstants::JSON_CROSS_AXIS_STATE] = 0; + jsonComponent[JsonTagConstants::JSON_IS_ICON_EXCEEDED_TAG] = false; + jsonComponent[JsonTagConstants::JSON_IS_BORDER_COVERED_TAG] = false; jsonComponent[JsonTagConstants::JSON_NON_COMPATIBLE_CHANGE_TAG] = false; jsonComponent[JsonTagConstants::JSON_LINEAR_GRADIENT_BLUR_RADIUS_TAG] = 0.0; compoJson_ = jsonComponent; @@ -148,6 +150,8 @@ std::string CompoRandomGenerator::ConstructSaveJson() jsonComponent[JsonTagConstants::JSON_WINDOW_ID] = 0; jsonComponent[JsonTagConstants::JSON_DISPLAY_ID] = 0; jsonComponent[JsonTagConstants::JSON_CROSS_AXIS_STATE] = 0; + jsonComponent[JsonTagConstants::JSON_IS_ICON_EXCEEDED_TAG] = false; + jsonComponent[JsonTagConstants::JSON_IS_BORDER_COVERED_TAG] = false; jsonComponent[JsonTagConstants::JSON_NON_COMPATIBLE_CHANGE_TAG] = false; jsonComponent[JsonTagConstants::JSON_LINEAR_GRADIENT_BLUR_RADIUS_TAG] = 0.0; compoJson_ = jsonComponent; @@ -196,6 +200,8 @@ std::string CompoRandomGenerator::ConstructPasteJson() jsonComponent[JsonTagConstants::JSON_WINDOW_ID] = 0; jsonComponent[JsonTagConstants::JSON_DISPLAY_ID] = 0; jsonComponent[JsonTagConstants::JSON_CROSS_AXIS_STATE] = 0; + jsonComponent[JsonTagConstants::JSON_IS_ICON_EXCEEDED_TAG] = false; + jsonComponent[JsonTagConstants::JSON_IS_BORDER_COVERED_TAG] = false; jsonComponent[JsonTagConstants::JSON_NON_COMPATIBLE_CHANGE_TAG] = false; jsonComponent[JsonTagConstants::JSON_LINEAR_GRADIENT_BLUR_RADIUS_TAG] = 0.0; compoJson_ = jsonComponent; -- Gitee