From 5a84259ce9e7be3cea2e02c156a834a9044126c6 Mon Sep 17 00:00:00 2001 From: libing23 Date: Thu, 9 Nov 2023 22:48:48 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=89=E5=85=A8=E6=8E=A7=E4=BB=B6=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0keyevent=E4=BA=8B=E4=BB=B6=20Signed-off-by:=20libing23?= =?UTF-8?q?=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- README_zh.md | 2 +- .../include/sec_comp_enhance_adapter.h | 4 +- .../src/sec_comp_enhance_adapter.cpp | 4 +- .../include/sec_comp_click_event_parcel.h | 6 +- .../src/sec_comp_click_event_parcel.cpp | 132 +++++++++++++---- .../include/i_sec_comp_service.h | 2 +- .../include/sec_comp_client.h | 2 +- .../include/sec_comp_info.h | 26 +++- .../security_component/include/sec_comp_kit.h | 2 +- .../include/sec_comp_proxy.h | 2 +- .../src/sec_comp_client.cpp | 4 +- .../security_component/src/sec_comp_kit.cpp | 4 +- .../security_component/src/sec_comp_proxy.cpp | 6 +- .../test/unittest/src/sec_comp_kit_test.cpp | 15 +- .../src/sec_comp_register_callback_test.cpp | 133 ++++++++++-------- .../sa/sa_main/sec_comp_entity.cpp | 50 +++++-- .../sa/sa_main/sec_comp_entity.h | 4 +- .../sa/sa_main/sec_comp_manager.cpp | 4 +- .../sa/sa_main/sec_comp_manager.h | 2 +- .../sa/sa_main/sec_comp_service.cpp | 4 +- .../sa/sa_main/sec_comp_service.h | 2 +- .../sa/sa_main/sec_comp_stub.cpp | 8 +- .../mock/src/sec_comp_enhance_adapter.cpp | 2 +- .../unittest/src/sec_comp_entity_test.cpp | 27 ++-- .../unittest/src/sec_comp_manager_test.cpp | 12 +- .../src/sec_comp_service_mock_test.cpp | 55 +++++--- .../unittest/src/sec_comp_service_test.cpp | 8 +- .../test/unittest/src/sec_comp_stub_test.cpp | 5 +- .../sa/test/unittest/src/sec_comp_stub_test.h | 2 +- ...portsecuritycomponentclickevent_fuzzer.cpp | 15 +- 31 files changed, 348 insertions(+), 198 deletions(-) diff --git a/README.md b/README.md index b5c4582..563ffe3 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ The security component manager service provides the following functions: | int32_t RegisterSecurityComponent(SecCompType type, const std::string& componentInfo, int32_t& scId); | Registers a security component.| | int32_t UpdateSecurityComponent(int32_t scId, const std::string& componentInfo); | Updates security component information.| | int32_t UnregisterSecurityComponent(int32_t scId); | Unregisters a security component.| -| int32_t ReportSecurityComponentClickEvent(int32_t scId, const std::string& componentInfo, const SecCompClickEvent& touchInfo, sptr<IRemoteObject> callerToken); | Reports a click event to apply for temporary authorization.| +| int32_t ReportSecurityComponentClickEvent(int32_t scId, const std::string& componentInfo, const SecCompClickEvent& clickInfo, sptr<IRemoteObject> callerToken); | Reports a click event to apply for temporary authorization.| | int32_t SetEnhanceCfg(uint8_t* cfg, uint32_t cfgLen); | Sets enhanced configuration of the security component for multimodal services.| | int32_t GetPointerEventEnhanceData(void* data, uint32_t dataLen, uint8_t* enhanceData, uint32_t& enHancedataLen); | Obtains security enhancement data of the click event for multimodal services.| | bool ReduceAfterVerifySavePermission(AccessToken::AccessTokenID tokenId); | Cancels the saving of the component permissions after verification.| diff --git a/README_zh.md b/README_zh.md index 8b12d6b..0fc7a2c 100644 --- a/README_zh.md +++ b/README_zh.md @@ -49,7 +49,7 @@ | int32_t RegisterSecurityComponent(SecCompType type, const std::string& componentInfo, int32_t& scId); | 注册安全控件 | | int32_t UpdateSecurityComponent(int32_t scId, const std::string& componentInfo); | 更新安全控件信息 | | int32_t UnregisterSecurityComponent(int32_t scId); | 取消注册安全控件 | -| int32_t ReportSecurityComponentClickEvent(int32_t scId, const std::string& componentInfo, const SecCompClickEvent& touchInfo, sptr<IRemoteObject> callerToken); | 上报点击事件,申请临时授权 | +| int32_t ReportSecurityComponentClickEvent(int32_t scId, const std::string& componentInfo, const SecCompClickEvent& clickInfo, sptr<IRemoteObject> callerToken); | 上报点击事件,申请临时授权 | | int32_t SetEnhanceCfg(uint8_t* cfg, uint32_t cfgLen); | 设置安全控件增强的配置,供多模服务使用 | | int32_t GetPointerEventEnhanceData(void* data, uint32_t dataLen, uint8_t* enhanceData, uint32_t& enHancedataLen); | 获取点击事件的安全增强数据,供多模服务使用 | | bool VerifySavePermission(AccessToken::AccessTokenID tokenId); | 校验保存控件权限 | diff --git a/frameworks/enhance_adapter/include/sec_comp_enhance_adapter.h b/frameworks/enhance_adapter/include/sec_comp_enhance_adapter.h index 5aad9b0..65ff6ba 100644 --- a/frameworks/enhance_adapter/include/sec_comp_enhance_adapter.h +++ b/frameworks/enhance_adapter/include/sec_comp_enhance_adapter.h @@ -51,7 +51,7 @@ public: virtual int32_t DisableInputEnhance() = 0; // send click event to enhance service for checking extra data validity - virtual int32_t CheckExtraInfo(const SecCompClickEvent& touchInfo) = 0; + virtual int32_t CheckExtraInfo(const SecCompClickEvent& clickInfo) = 0; // send component info to enhance service for checking its validity virtual int32_t CheckComponentInfoEnhnace(int32_t pid, std::shared_ptr& compInfo, @@ -90,7 +90,7 @@ public: static int32_t GetPointerEventEnhanceData(void* data, uint32_t dataLen, uint8_t* enhanceData, uint32_t& enHancedataLen); - static int32_t CheckExtraInfo(const SecCompClickEvent& touchInfo); + static int32_t CheckExtraInfo(const SecCompClickEvent& clickInfo); static int32_t EnableInputEnhance(); static int32_t DisableInputEnhance(); static int32_t CheckComponentInfoEnhnace(int32_t pid, std::shared_ptr& compInfo, diff --git a/frameworks/enhance_adapter/src/sec_comp_enhance_adapter.cpp b/frameworks/enhance_adapter/src/sec_comp_enhance_adapter.cpp index 28d1aa9..8478062 100644 --- a/frameworks/enhance_adapter/src/sec_comp_enhance_adapter.cpp +++ b/frameworks/enhance_adapter/src/sec_comp_enhance_adapter.cpp @@ -94,13 +94,13 @@ int32_t SecCompEnhanceAdapter::GetPointerEventEnhanceData(void* data, uint32_t d return SC_ENHANCE_ERROR_NOT_EXIST_ENHANCE; } -int32_t SecCompEnhanceAdapter::CheckExtraInfo(const SecCompClickEvent& touchInfo) +int32_t SecCompEnhanceAdapter::CheckExtraInfo(const SecCompClickEvent& clickInfo) { if (!isEnhanceSrvHandlerInit) { InitEnhanceHandler(SEC_COMP_ENHANCE_SRV_INTERFACE); } if (srvHandler != nullptr) { - return srvHandler->CheckExtraInfo(touchInfo); + return srvHandler->CheckExtraInfo(clickInfo); } return SC_ENHANCE_ERROR_NOT_EXIST_ENHANCE; } diff --git a/frameworks/security_component/include/sec_comp_click_event_parcel.h b/frameworks/security_component/include/sec_comp_click_event_parcel.h index ea39a20..333ebb5 100644 --- a/frameworks/security_component/include/sec_comp_click_event_parcel.h +++ b/frameworks/security_component/include/sec_comp_click_event_parcel.h @@ -26,11 +26,15 @@ struct SecCompClickEventParcel final : public Parcelable { ~SecCompClickEventParcel() override = default; + bool MarshallingPointEvent(Parcel& out) const; + bool MarshallingKeyEvent(Parcel& out) const; bool Marshalling(Parcel& out) const override; + static bool UnmarshallingPointEvent(Parcel& in, SecCompClickEvent& clickInfo); + static bool UnmarshallingKeyEvent(Parcel& in, SecCompClickEvent& clickInfo); static SecCompClickEventParcel* Unmarshalling(Parcel& in); - SecCompClickEvent touchInfoParams_; + SecCompClickEvent clickInfoParams_; }; } // namespace SecurityComponent } // namespace Security diff --git a/frameworks/security_component/src/sec_comp_click_event_parcel.cpp b/frameworks/security_component/src/sec_comp_click_event_parcel.cpp index 55390c9..52f4bdf 100644 --- a/frameworks/security_component/src/sec_comp_click_event_parcel.cpp +++ b/frameworks/security_component/src/sec_comp_click_event_parcel.cpp @@ -25,77 +25,153 @@ static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, SECURITY_DOMAIN_SECURITY_COMPONENT, "SecCompClickEventParcel"}; } -bool SecCompClickEventParcel::Marshalling(Parcel& out) const +bool SecCompClickEventParcel::MarshallingPointEvent(Parcel& out) const { - if (!(out.WriteDouble(this->touchInfoParams_.touchX)) || !(out.WriteDouble(this->touchInfoParams_.touchY))) { + if (!(out.WriteDouble(this->clickInfoParams_.point.touchX)) || + !(out.WriteDouble(this->clickInfoParams_.point.touchY))) { SC_LOG_ERROR(LABEL, "Write touch xy pointer fail"); return false; } - if (!(out.WriteUint64(this->touchInfoParams_.timestamp))) { + if (!(out.WriteUint64(this->clickInfoParams_.point.timestamp))) { SC_LOG_ERROR(LABEL, "Write touch timestamp fail"); return false; } + return true; +} - if (!(out.WriteUint32(this->touchInfoParams_.extraInfo.dataSize))) { +bool SecCompClickEventParcel::MarshallingKeyEvent(Parcel& out) const +{ + if (!(out.WriteUint64(this->clickInfoParams_.key.timestamp))) { + SC_LOG_ERROR(LABEL, "Write key timestamp fail"); + return false; + } + + if (!(out.WriteInt32(this->clickInfoParams_.key.keyCode))) { + SC_LOG_ERROR(LABEL, "Write key code fail"); + return false; + } + return true; +} + +bool SecCompClickEventParcel::Marshalling(Parcel& out) const +{ + if (!(out.WriteInt32(static_cast(this->clickInfoParams_.type)))) { + SC_LOG_ERROR(LABEL, "Write click type fail"); + return false; + } + + if (this->clickInfoParams_.type == ClickEventType::POINT_EVENT_TYPE) { + if (!MarshallingPointEvent(out)) { + return false; + } + } else if (this->clickInfoParams_.type == ClickEventType::KEY_EVENT_TYPE) { + if (!MarshallingKeyEvent(out)) { + return false; + } + } else { + SC_LOG_ERROR(LABEL, "click type %{public}d is error", this->clickInfoParams_.type); + return false; + } + + if (!(out.WriteUint32(this->clickInfoParams_.extraInfo.dataSize))) { SC_LOG_ERROR(LABEL, "Write extraInfo dataSize fail"); return false; } + if (this->clickInfoParams_.extraInfo.dataSize != 0 && + !(out.WriteBuffer(this->clickInfoParams_.extraInfo.data, this->clickInfoParams_.extraInfo.dataSize))) { + SC_LOG_ERROR(LABEL, "Write click extraInfo data fail"); + return false; + } + + return true; +} - if (this->touchInfoParams_.extraInfo.dataSize != 0 && - !(out.WriteBuffer(this->touchInfoParams_.extraInfo.data, this->touchInfoParams_.extraInfo.dataSize))) { - SC_LOG_ERROR(LABEL, "Write touch extraInfo data fail"); +bool SecCompClickEventParcel::UnmarshallingPointEvent(Parcel& in, SecCompClickEvent& clickInfo) +{ + if (!in.ReadDouble(clickInfo.point.touchX) || !in.ReadDouble(clickInfo.point.touchY)) { + SC_LOG_ERROR(LABEL, "Read touch xy porinter fail"); return false; } + if (!in.ReadUint64(clickInfo.point.timestamp)) { + SC_LOG_ERROR(LABEL, "Read timestamp fail"); + return false; + } + return true; +} + +bool SecCompClickEventParcel::UnmarshallingKeyEvent(Parcel& in, SecCompClickEvent& clickInfo) +{ + if (!in.ReadUint64(clickInfo.key.timestamp)) { + SC_LOG_ERROR(LABEL, "Read timestamp fail"); + return false; + } + + if (!in.ReadInt32(clickInfo.key.keyCode)) { + SC_LOG_ERROR(LABEL, "Read keyCode fail"); + return false; + } return true; } SecCompClickEventParcel* SecCompClickEventParcel::Unmarshalling(Parcel& in) { - SecCompClickEventParcel* touchInfoParcel = new (std::nothrow) SecCompClickEventParcel(); - if (touchInfoParcel == nullptr) { + SecCompClickEventParcel* clickInfoParcel = new (std::nothrow) SecCompClickEventParcel(); + if (clickInfoParcel == nullptr) { SC_LOG_ERROR(LABEL, "Alloc policy parcel fail"); return nullptr; } - SecCompClickEvent touchInfo; - if (!in.ReadDouble(touchInfo.touchX) || !in.ReadDouble(touchInfo.touchY)) { - SC_LOG_ERROR(LABEL, "Read touch xy porinter fail"); - delete touchInfoParcel; + SecCompClickEvent clickInfo; + int32_t type; + if (!in.ReadInt32(type)) { + SC_LOG_ERROR(LABEL, "Read click type fail"); + delete clickInfoParcel; return nullptr; } + clickInfo.type = static_cast(type); - if (!in.ReadUint64(touchInfo.timestamp)) { - SC_LOG_ERROR(LABEL, "Read timestamp fail"); - delete touchInfoParcel; + if (clickInfo.type == ClickEventType::POINT_EVENT_TYPE) { + if (!UnmarshallingPointEvent(in, clickInfo)) { + delete clickInfoParcel; + return nullptr; + } + } else if (clickInfo.type == ClickEventType::KEY_EVENT_TYPE) { + if (!UnmarshallingKeyEvent(in, clickInfo)) { + delete clickInfoParcel; + return nullptr; + } + } else { + SC_LOG_ERROR(LABEL, "click type %{public}d is error", clickInfo.type); + delete clickInfoParcel; return nullptr; } - if (!in.ReadUint32(touchInfo.extraInfo.dataSize)) { + if (!in.ReadUint32(clickInfo.extraInfo.dataSize)) { SC_LOG_ERROR(LABEL, "Read extraInfo data size fail"); - delete touchInfoParcel; + delete clickInfoParcel; return nullptr; } - if (touchInfo.extraInfo.dataSize == 0) { - touchInfoParcel->touchInfoParams_ = touchInfo; - return touchInfoParcel; - } else if (touchInfo.extraInfo.dataSize > MAX_EXTRA_SIZE) { + if (clickInfo.extraInfo.dataSize == 0) { + clickInfoParcel->clickInfoParams_ = clickInfo; + return clickInfoParcel; + } else if (clickInfo.extraInfo.dataSize > MAX_EXTRA_SIZE) { SC_LOG_ERROR(LABEL, "Read extraInfo data size invalid"); - delete touchInfoParcel; + delete clickInfoParcel; return nullptr; } - touchInfo.extraInfo.data = const_cast(in.ReadBuffer(touchInfo.extraInfo.dataSize)); - if (touchInfo.extraInfo.data == nullptr) { + clickInfo.extraInfo.data = const_cast(in.ReadBuffer(clickInfo.extraInfo.dataSize)); + if (clickInfo.extraInfo.data == nullptr) { SC_LOG_ERROR(LABEL, "Read extraInfo data failed"); - delete touchInfoParcel; + delete clickInfoParcel; return nullptr; } - touchInfoParcel->touchInfoParams_ = touchInfo; - return touchInfoParcel; + clickInfoParcel->clickInfoParams_ = clickInfo; + return clickInfoParcel; } } // namespace SecurityComponent } // namespace Security diff --git a/interfaces/inner_api/security_component/include/i_sec_comp_service.h b/interfaces/inner_api/security_component/include/i_sec_comp_service.h index 1b69e6a..8df9269 100644 --- a/interfaces/inner_api/security_component/include/i_sec_comp_service.h +++ b/interfaces/inner_api/security_component/include/i_sec_comp_service.h @@ -35,7 +35,7 @@ public: virtual int32_t UpdateSecurityComponent(int32_t scId, const std::string& componentInfo) = 0; virtual int32_t UnregisterSecurityComponent(int32_t scId) = 0; virtual int32_t ReportSecurityComponentClickEvent(int32_t scId, const std::string& componentInfo, - const SecCompClickEvent& touchInfo, sptr callerToken) = 0; + const SecCompClickEvent& clickInfo, sptr callerToken) = 0; virtual bool VerifySavePermission(AccessToken::AccessTokenID tokenId) = 0; virtual sptr GetEnhanceRemoteObject() = 0; }; diff --git a/interfaces/inner_api/security_component/include/sec_comp_client.h b/interfaces/inner_api/security_component/include/sec_comp_client.h index 704f91f..719489f 100644 --- a/interfaces/inner_api/security_component/include/sec_comp_client.h +++ b/interfaces/inner_api/security_component/include/sec_comp_client.h @@ -34,7 +34,7 @@ public: int32_t UpdateSecurityComponent(int32_t scId, const std::string& componentInfo); int32_t UnregisterSecurityComponent(int32_t scId); int32_t ReportSecurityComponentClickEvent(int32_t scId, - const std::string& componentInfo, const SecCompClickEvent& touchInfo, sptr callerToken); + const std::string& componentInfo, const SecCompClickEvent& clickInfo, sptr callerToken); bool VerifySavePermission(AccessToken::AccessTokenID tokenId); sptr GetEnhanceRemoteObject(bool doLoadSa); diff --git a/interfaces/inner_api/security_component/include/sec_comp_info.h b/interfaces/inner_api/security_component/include/sec_comp_info.h index d02ebb2..7d174b2 100644 --- a/interfaces/inner_api/security_component/include/sec_comp_info.h +++ b/interfaces/inner_api/security_component/include/sec_comp_info.h @@ -30,6 +30,9 @@ static constexpr DimensionT MIN_PADDING_SIZE = 0.0; static constexpr DimensionT MIN_PADDING_WITHOUT_BG = 4.0; static constexpr uint32_t MAX_EXTRA_SIZE = 0x1000; +static constexpr int32_t KEY_SPACE = 2050; +static constexpr int32_t KEY_ENTER = 2054; + struct PaddingSize { DimensionT top = DEFAULT_DIMENSION; DimensionT right = DEFAULT_DIMENSION; @@ -112,11 +115,10 @@ struct ExtraInfo { uint8_t* data; }; -struct SecCompClickEvent { - double touchX; - double touchY; - uint64_t timestamp; - ExtraInfo extraInfo; +enum class ClickEventType : int32_t { + UNKNOWN_EVENT_TYPE, + POINT_EVENT_TYPE, + KEY_EVENT_TYPE }; struct SecCompPointEvent { @@ -124,6 +126,20 @@ struct SecCompPointEvent { double touchY; uint64_t timestamp; }; + +struct SecCompKeyEvent { + uint64_t timestamp; + int32_t keyCode; +}; + +struct SecCompClickEvent { + ClickEventType type; + union { + SecCompPointEvent point; + SecCompKeyEvent key; + }; + ExtraInfo extraInfo; +}; } // namespace SecurityComponent } // namespace Security } // namespace OHOS diff --git a/interfaces/inner_api/security_component/include/sec_comp_kit.h b/interfaces/inner_api/security_component/include/sec_comp_kit.h index 4d66a3a..0f0ee94 100644 --- a/interfaces/inner_api/security_component/include/sec_comp_kit.h +++ b/interfaces/inner_api/security_component/include/sec_comp_kit.h @@ -30,7 +30,7 @@ public: static int32_t UpdateSecurityComponent(int32_t scId, std::string& componentInfo); static int32_t UnregisterSecurityComponent(int32_t scId); static int32_t ReportSecurityComponentClickEvent(int32_t scId, - std::string& componentInfo, const SecCompClickEvent& touchInfo, sptr callerToken = nullptr); + std::string& componentInfo, const SecCompClickEvent& clickInfo, sptr callerToken = nullptr); static bool VerifySavePermission(AccessToken::AccessTokenID tokenId); static sptr GetEnhanceRemoteObject(bool isLoad); }; diff --git a/interfaces/inner_api/security_component/include/sec_comp_proxy.h b/interfaces/inner_api/security_component/include/sec_comp_proxy.h index 7351d69..9b5b4e2 100644 --- a/interfaces/inner_api/security_component/include/sec_comp_proxy.h +++ b/interfaces/inner_api/security_component/include/sec_comp_proxy.h @@ -30,7 +30,7 @@ public: int32_t UpdateSecurityComponent(int32_t scId, const std::string& componentInfo) override; int32_t UnregisterSecurityComponent(int32_t scId) override; int32_t ReportSecurityComponentClickEvent(int32_t scId, - const std::string& componentInfo, const SecCompClickEvent& touchInfo, sptr callerToken) override; + const std::string& componentInfo, const SecCompClickEvent& clickInfo, sptr callerToken) override; bool VerifySavePermission(AccessToken::AccessTokenID tokenId) override; sptr GetEnhanceRemoteObject() override; diff --git a/interfaces/inner_api/security_component/src/sec_comp_client.cpp b/interfaces/inner_api/security_component/src/sec_comp_client.cpp index e658b77..27545fa 100644 --- a/interfaces/inner_api/security_component/src/sec_comp_client.cpp +++ b/interfaces/inner_api/security_component/src/sec_comp_client.cpp @@ -81,7 +81,7 @@ int32_t SecCompClient::UnregisterSecurityComponent(int32_t scId) } int32_t SecCompClient::ReportSecurityComponentClickEvent(int32_t scId, - const std::string& componentInfo, const SecCompClickEvent& touchInfo, sptr callerToken) + const std::string& componentInfo, const SecCompClickEvent& clickInfo, sptr callerToken) { auto proxy = GetProxy(true); if (proxy == nullptr) { @@ -89,7 +89,7 @@ int32_t SecCompClient::ReportSecurityComponentClickEvent(int32_t scId, return SC_SERVICE_ERROR_VALUE_INVALID; } - return proxy->ReportSecurityComponentClickEvent(scId, componentInfo, touchInfo, callerToken); + return proxy->ReportSecurityComponentClickEvent(scId, componentInfo, clickInfo, callerToken); } bool SecCompClient::VerifySavePermission(AccessToken::AccessTokenID tokenId) diff --git a/interfaces/inner_api/security_component/src/sec_comp_kit.cpp b/interfaces/inner_api/security_component/src/sec_comp_kit.cpp index ad21dec..04562ca 100644 --- a/interfaces/inner_api/security_component/src/sec_comp_kit.cpp +++ b/interfaces/inner_api/security_component/src/sec_comp_kit.cpp @@ -95,7 +95,7 @@ int32_t SecCompKit::UnregisterSecurityComponent(int32_t scId) } int32_t SecCompKit::ReportSecurityComponentClickEvent(int32_t scId, - std::string& componentInfo, const SecCompClickEvent& touchInfo, sptr callerToken) + std::string& componentInfo, const SecCompClickEvent& clickInfo, sptr callerToken) { if (!SecCompCallerAuthorization::GetInstance().IsKitCaller( reinterpret_cast(__builtin_return_address(0)))) { @@ -112,7 +112,7 @@ int32_t SecCompKit::ReportSecurityComponentClickEvent(int32_t scId, } int32_t res = - SecCompClient::GetInstance().ReportSecurityComponentClickEvent(scId, componentInfo, touchInfo, callerToken); + SecCompClient::GetInstance().ReportSecurityComponentClickEvent(scId, componentInfo, clickInfo, callerToken); if (res != SC_OK) { SC_LOG_ERROR(LABEL, "report click event fail, error: %{public}d", res); } diff --git a/interfaces/inner_api/security_component/src/sec_comp_proxy.cpp b/interfaces/inner_api/security_component/src/sec_comp_proxy.cpp index a1c2368..3b56769 100644 --- a/interfaces/inner_api/security_component/src/sec_comp_proxy.cpp +++ b/interfaces/inner_api/security_component/src/sec_comp_proxy.cpp @@ -150,7 +150,7 @@ int32_t SecCompProxy::UnregisterSecurityComponent(int32_t scId) } int32_t SecCompProxy::ReportSecurityComponentClickEvent(int32_t scId, - const std::string& componentInfo, const SecCompClickEvent& touchInfo, sptr callerToken) + const std::string& componentInfo, const SecCompClickEvent& clickInfo, sptr callerToken) { MessageParcel data; if (!data.WriteInterfaceToken(SecCompProxy::GetDescriptor())) { @@ -173,9 +173,9 @@ int32_t SecCompProxy::ReportSecurityComponentClickEvent(int32_t scId, SC_LOG_ERROR(LABEL, "Report new click event parcel failed"); return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; } - parcel->touchInfoParams_ = touchInfo; + parcel->clickInfoParams_ = clickInfo; if (!data.WriteParcelable(parcel)) { - SC_LOG_ERROR(LABEL, "Report write touchInfo fail"); + SC_LOG_ERROR(LABEL, "Report write clickInfo fail"); return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; } diff --git a/interfaces/inner_api/security_component/test/unittest/src/sec_comp_kit_test.cpp b/interfaces/inner_api/security_component/test/unittest/src/sec_comp_kit_test.cpp index 983b4ea..4c82ffc 100644 --- a/interfaces/inner_api/security_component/test/unittest/src/sec_comp_kit_test.cpp +++ b/interfaces/inner_api/security_component/test/unittest/src/sec_comp_kit_test.cpp @@ -36,11 +36,11 @@ static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { static void TestInCallerNotCheckList() { int32_t scId = -1; - struct SecCompClickEvent touch; + struct SecCompClickEvent click; std::string emptyStr = ""; int registerRes = SecCompKit::RegisterSecurityComponent(LOCATION_COMPONENT, emptyStr, scId); int updateRes = SecCompKit::UpdateSecurityComponent(scId, emptyStr); - int reportRes = SecCompKit::ReportSecurityComponentClickEvent(scId, emptyStr, touch, nullptr); + int reportRes = SecCompKit::ReportSecurityComponentClickEvent(scId, emptyStr, click, nullptr); EXPECT_EQ(registerRes, SC_SERVICE_ERROR_CALLER_INVALID); EXPECT_EQ(updateRes, SC_SERVICE_ERROR_CALLER_INVALID); @@ -50,11 +50,11 @@ static void TestInCallerNotCheckList() static void TestInCallerCheckList() { int32_t scId = -1; - struct SecCompClickEvent touch; + struct SecCompClickEvent click; std::string emptyStr = ""; int registerRes = SecCompKit::RegisterSecurityComponent(LOCATION_COMPONENT, emptyStr, scId); int updateRes = SecCompKit::UpdateSecurityComponent(scId, emptyStr); - int reportRes = SecCompKit::ReportSecurityComponentClickEvent(scId, emptyStr, touch, nullptr); + int reportRes = SecCompKit::ReportSecurityComponentClickEvent(scId, emptyStr, click, nullptr); EXPECT_NE(registerRes, SC_SERVICE_ERROR_CALLER_INVALID); EXPECT_NE(updateRes, SC_SERVICE_ERROR_CALLER_INVALID); @@ -118,9 +118,10 @@ HWTEST_F(SecCompKitTest, ExceptCall001, TestSize.Level1) ASSERT_NE(SC_OK, SecCompKit::UpdateSecurityComponent(scId, jsonStr)); struct SecCompClickEvent touch = { - .touchX = TestCommon::TEST_COORDINATE, - .touchY = TestCommon::TEST_COORDINATE, - .timestamp = static_cast(std::chrono::high_resolution_clock::now().time_since_epoch().count()) + .type = ClickEventType::POINT_EVENT_TYPE, + .point.touchX = TestCommon::TEST_COORDINATE, + .point.touchY = TestCommon::TEST_COORDINATE, + .point.timestamp = static_cast(std::chrono::high_resolution_clock::now().time_since_epoch().count()) }; EXPECT_NE(SC_OK, SecCompKit::ReportSecurityComponentClickEvent(scId, jsonStr, touch, nullptr)); EXPECT_NE(SC_OK, SecCompKit::UnregisterSecurityComponent(scId)); diff --git a/interfaces/inner_api/security_component/test/unittest/src/sec_comp_register_callback_test.cpp b/interfaces/inner_api/security_component/test/unittest/src/sec_comp_register_callback_test.cpp index 8bec6fa..2be03f7 100644 --- a/interfaces/inner_api/security_component/test/unittest/src/sec_comp_register_callback_test.cpp +++ b/interfaces/inner_api/security_component/test/unittest/src/sec_comp_register_callback_test.cpp @@ -205,16 +205,17 @@ HWTEST_F(SecCompRegisterCallbackTest, RegisterSecurityComponent004, TestSize.Lev EXPECT_EQ(SC_OK, SecCompKit::RegisterSecurityComponent(SAVE_COMPONENT, saveInfo, scId)); uint8_t data[TestCommon::MAX_HMAC_SIZE] = { 0 }; - struct SecCompClickEvent touchInfo = { - .touchX = TestCommon::TEST_COORDINATE, - .touchY = TestCommon::TEST_COORDINATE, - .timestamp = static_cast( + struct SecCompClickEvent clickInfo = { + .type = ClickEventType::POINT_EVENT_TYPE, + .point.touchX = TestCommon::TEST_COORDINATE, + .point.touchY = TestCommon::TEST_COORDINATE, + .point.timestamp = static_cast( std::chrono::high_resolution_clock::now().time_since_epoch().count()) }; - touchInfo.extraInfo.dataSize = TestCommon::MAX_HMAC_SIZE; - touchInfo.extraInfo.data = data; + clickInfo.extraInfo.dataSize = TestCommon::MAX_HMAC_SIZE; + clickInfo.extraInfo.data = data; EXPECT_EQ(SC_SERVICE_ERROR_CLICK_EVENT_INVALID, - SecCompKit::ReportSecurityComponentClickEvent(scId, saveInfo, touchInfo, nullptr)); + SecCompKit::ReportSecurityComponentClickEvent(scId, saveInfo, clickInfo, nullptr)); EXPECT_EQ(SC_OK, SecCompKit::UnregisterSecurityComponent(scId)); system("param set sec.comp.enhance 0"); } @@ -235,15 +236,16 @@ HWTEST_F(SecCompRegisterCallbackTest, RegisterSecurityComponent005, TestSize.Lev EXPECT_EQ(SC_OK, SecCompKit::RegisterSecurityComponent(SAVE_COMPONENT, saveInfo, scId)); uint8_t data[TestCommon::MAX_HMAC_SIZE] = { 0 }; - struct SecCompClickEvent touchInfo = { - .touchX = TestCommon::TEST_COORDINATE, - .touchY = TestCommon::TEST_COORDINATE, - .timestamp = static_cast( + struct SecCompClickEvent clickInfo = { + .type = ClickEventType::POINT_EVENT_TYPE, + .point.touchX = TestCommon::TEST_COORDINATE, + .point.touchY = TestCommon::TEST_COORDINATE, + .point.timestamp = static_cast( std::chrono::high_resolution_clock::now().time_since_epoch().count()) / TestCommon::TIME_CONVERSION_UNIT }; - touchInfo.extraInfo.dataSize = TestCommon::MAX_HMAC_SIZE; - touchInfo.extraInfo.data = data; - EXPECT_EQ(SC_OK, SecCompKit::ReportSecurityComponentClickEvent(scId, saveInfo, touchInfo, nullptr)); + clickInfo.extraInfo.dataSize = TestCommon::MAX_HMAC_SIZE; + clickInfo.extraInfo.data = data; + EXPECT_EQ(SC_OK, SecCompKit::ReportSecurityComponentClickEvent(scId, saveInfo, clickInfo, nullptr)); EXPECT_EQ(SC_OK, SecCompKit::UnregisterSecurityComponent(scId)); system("param set sec.comp.enhance 0"); } @@ -280,16 +282,17 @@ HWTEST_F(SecCompRegisterCallbackTest, ReportSecurityComponentClickEvent001, Test EXPECT_EQ(SC_OK, SecCompKit::RegisterSecurityComponent(SAVE_COMPONENT, saveInfo, scId)); uint8_t data[TestCommon::MAX_HMAC_SIZE] = { 0 }; - struct SecCompClickEvent touchInfo = { - .touchX = TestCommon::TEST_COORDINATE, - .touchY = TestCommon::TEST_COORDINATE, - .timestamp = static_cast( + struct SecCompClickEvent clickInfo = { + .type = ClickEventType::POINT_EVENT_TYPE, + .point.touchX = TestCommon::TEST_COORDINATE, + .point.touchY = TestCommon::TEST_COORDINATE, + .point.timestamp = static_cast( std::chrono::high_resolution_clock::now().time_since_epoch().count()) / TestCommon::TIME_CONVERSION_UNIT }; - touchInfo.extraInfo.dataSize = TestCommon::MAX_HMAC_SIZE; - touchInfo.extraInfo.data = data; + clickInfo.extraInfo.dataSize = TestCommon::MAX_HMAC_SIZE; + clickInfo.extraInfo.data = data; - ASSERT_EQ(SC_OK, SecCompKit::ReportSecurityComponentClickEvent(scId, saveInfo, touchInfo, nullptr)); + ASSERT_EQ(SC_OK, SecCompKit::ReportSecurityComponentClickEvent(scId, saveInfo, clickInfo, nullptr)); uint32_t selfTokenId = GetSelfTokenID(); ASSERT_TRUE(SecCompKit::VerifySavePermission(selfTokenId)); EXPECT_EQ(SC_OK, SecCompKit::UnregisterSecurityComponent(scId)); @@ -313,18 +316,19 @@ HWTEST_F(SecCompRegisterCallbackTest, ReportSecurityComponentClickEvent002, Test EXPECT_EQ(SC_OK, SecCompKit::RegisterSecurityComponent(SAVE_COMPONENT, saveInfo, scId)); uint8_t data[TestCommon::MAX_HMAC_SIZE] = { 0 }; - struct SecCompClickEvent touchInfo = { - .touchX = TestCommon::TEST_COORDINATE, - .touchY = TestCommon::TEST_COORDINATE, - .timestamp = static_cast( + struct SecCompClickEvent clickInfo = { + .type = ClickEventType::POINT_EVENT_TYPE, + .point.touchX = TestCommon::TEST_COORDINATE, + .point.touchY = TestCommon::TEST_COORDINATE, + .point.timestamp = static_cast( std::chrono::high_resolution_clock::now().time_since_epoch().count()) / TestCommon::TIME_CONVERSION_UNIT }; - touchInfo.extraInfo.dataSize = TestCommon::MAX_HMAC_SIZE; - touchInfo.extraInfo.data = data; + clickInfo.extraInfo.dataSize = TestCommon::MAX_HMAC_SIZE; + clickInfo.extraInfo.data = data; setuid(100); ASSERT_EQ(SC_SERVICE_ERROR_VALUE_INVALID, - SecCompKit::ReportSecurityComponentClickEvent(scId, saveInfo, touchInfo, nullptr)); + SecCompKit::ReportSecurityComponentClickEvent(scId, saveInfo, clickInfo, nullptr)); setuid(g_selfUid); EXPECT_EQ(SC_OK, SecCompKit::UnregisterSecurityComponent(scId)); system("param set sec.comp.enhance 0"); @@ -346,18 +350,19 @@ HWTEST_F(SecCompRegisterCallbackTest, ReportSecurityComponentClickEvent003, Test EXPECT_EQ(SC_OK, SecCompKit::RegisterSecurityComponent(SAVE_COMPONENT, saveInfo, scId)); - struct SecCompClickEvent touchInfo = { - .touchX = TestCommon::TEST_COORDINATE, - .touchY = TestCommon::TEST_COORDINATE, - .timestamp = static_cast( + struct SecCompClickEvent clickInfo = { + .type = ClickEventType::POINT_EVENT_TYPE, + .point.touchX = TestCommon::TEST_COORDINATE, + .point.touchY = TestCommon::TEST_COORDINATE, + .point.timestamp = static_cast( std::chrono::high_resolution_clock::now().time_since_epoch().count()) / TestCommon::TIME_CONVERSION_UNIT }; #ifdef SECURITY_COMPONENT_ENHANCE_ENABLE ASSERT_EQ(SC_SERVICE_ERROR_CLICK_EVENT_INVALID, - SecCompKit::ReportSecurityComponentClickEvent(scId, saveInfo, touchInfo, nullptr)); + SecCompKit::ReportSecurityComponentClickEvent(scId, saveInfo, clickInfo, nullptr)); #else ASSERT_EQ(SC_OK, - SecCompKit::ReportSecurityComponentClickEvent(scId, saveInfo, touchInfo, nullptr)); + SecCompKit::ReportSecurityComponentClickEvent(scId, saveInfo, clickInfo, nullptr)); #endif EXPECT_EQ(SC_OK, SecCompKit::UnregisterSecurityComponent(scId)); } @@ -381,16 +386,17 @@ HWTEST_F(SecCompRegisterCallbackTest, ReportClickWithoutHmac001, TestSize.Level1 ASSERT_EQ(SC_OK, SecCompKit::RegisterSecurityComponent(LOCATION_COMPONENT, locationInfo, scId)); ASSERT_NE(-1, scId); uint8_t data[TestCommon::MAX_HMAC_SIZE] = { 0 }; - struct SecCompClickEvent touch = { - .touchX = TestCommon::TEST_COORDINATE, - .touchY = TestCommon::TEST_COORDINATE, - .timestamp = static_cast( + struct SecCompClickEvent clickInfo = { + .type = ClickEventType::POINT_EVENT_TYPE, + .point.touchX = TestCommon::TEST_COORDINATE, + .point.touchY = TestCommon::TEST_COORDINATE, + .point.timestamp = static_cast( std::chrono::high_resolution_clock::now().time_since_epoch().count()) / TestCommon::TIME_CONVERSION_UNIT }; - touch.extraInfo.dataSize = TestCommon::MAX_HMAC_SIZE; - touch.extraInfo.data = data; + clickInfo.extraInfo.dataSize = TestCommon::MAX_HMAC_SIZE; + clickInfo.extraInfo.data = data; EXPECT_EQ(SC_SERVICE_ERROR_PERMISSION_OPER_FAIL, - SecCompKit::ReportSecurityComponentClickEvent(scId, locationInfo, touch, nullptr)); + SecCompKit::ReportSecurityComponentClickEvent(scId, locationInfo, clickInfo, nullptr)); EXPECT_EQ(SC_OK, SecCompKit::UnregisterSecurityComponent(scId)); system("param set sec.comp.enhance 0"); } @@ -412,16 +418,17 @@ HWTEST_F(SecCompRegisterCallbackTest, VerifySavePermission001, TestSize.Level1) EXPECT_EQ(SC_OK, SecCompKit::RegisterSecurityComponent(SAVE_COMPONENT, saveInfo, scId)); uint8_t data[TestCommon::MAX_HMAC_SIZE] = { 0 }; - struct SecCompClickEvent touchInfo = { - .touchX = TestCommon::TEST_COORDINATE, - .touchY = TestCommon::TEST_COORDINATE, - .timestamp = static_cast( + struct SecCompClickEvent clickInfo = { + .type = ClickEventType::POINT_EVENT_TYPE, + .point.touchX = TestCommon::TEST_COORDINATE, + .point.touchY = TestCommon::TEST_COORDINATE, + .point.timestamp = static_cast( std::chrono::high_resolution_clock::now().time_since_epoch().count()) / TestCommon::TIME_CONVERSION_UNIT }; - touchInfo.extraInfo.dataSize = TestCommon::MAX_HMAC_SIZE; - touchInfo.extraInfo.data = data; + clickInfo.extraInfo.dataSize = TestCommon::MAX_HMAC_SIZE; + clickInfo.extraInfo.data = data; - ASSERT_EQ(SC_OK, SecCompKit::ReportSecurityComponentClickEvent(scId, saveInfo, touchInfo, nullptr)); + ASSERT_EQ(SC_OK, SecCompKit::ReportSecurityComponentClickEvent(scId, saveInfo, clickInfo, nullptr)); setuid(100); ASSERT_FALSE(SecCompKit::VerifySavePermission(TestCommon::HAP_TOKEN_ID)); // mediaLibraryTokenId_ != 0 @@ -447,16 +454,17 @@ HWTEST_F(SecCompRegisterCallbackTest, VerifySavePermission002, TestSize.Level1) EXPECT_EQ(SC_OK, SecCompKit::RegisterSecurityComponent(SAVE_COMPONENT, saveInfo, scId)); uint8_t data[TestCommon::MAX_HMAC_SIZE] = { 0 }; - struct SecCompClickEvent touchInfo = { - .touchX = TestCommon::TEST_COORDINATE, - .touchY = TestCommon::TEST_COORDINATE, - .timestamp = static_cast( + struct SecCompClickEvent clickInfo = { + .type = ClickEventType::POINT_EVENT_TYPE, + .point.touchX = TestCommon::TEST_COORDINATE, + .point.touchY = TestCommon::TEST_COORDINATE, + .point.timestamp = static_cast( std::chrono::high_resolution_clock::now().time_since_epoch().count()) / TestCommon::TIME_CONVERSION_UNIT }; - touchInfo.extraInfo.dataSize = TestCommon::MAX_HMAC_SIZE; - touchInfo.extraInfo.data = data; + clickInfo.extraInfo.dataSize = TestCommon::MAX_HMAC_SIZE; + clickInfo.extraInfo.data = data; - ASSERT_EQ(SC_OK, SecCompKit::ReportSecurityComponentClickEvent(scId, saveInfo, touchInfo, nullptr)); + ASSERT_EQ(SC_OK, SecCompKit::ReportSecurityComponentClickEvent(scId, saveInfo, clickInfo, nullptr)); ASSERT_FALSE(SecCompKit::VerifySavePermission(0)); EXPECT_EQ(SC_OK, SecCompKit::UnregisterSecurityComponent(scId)); system("param set sec.comp.enhance 0"); @@ -478,15 +486,16 @@ HWTEST_F(SecCompRegisterCallbackTest, UnregisterSecurityComponent001, TestSize.L EXPECT_EQ(SC_OK, SecCompKit::RegisterSecurityComponent(SAVE_COMPONENT, saveInfo, scId)); uint8_t data[TestCommon::MAX_HMAC_SIZE] = { 0 }; - struct SecCompClickEvent touchInfo = { - .touchX = TestCommon::TEST_COORDINATE, - .touchY = TestCommon::TEST_COORDINATE, - .timestamp = static_cast( + struct SecCompClickEvent clickInfo = { + .type = ClickEventType::POINT_EVENT_TYPE, + .point.touchX = TestCommon::TEST_COORDINATE, + .point.touchY = TestCommon::TEST_COORDINATE, + .point.timestamp = static_cast( std::chrono::high_resolution_clock::now().time_since_epoch().count()) / TestCommon::TIME_CONVERSION_UNIT }; - touchInfo.extraInfo.dataSize = TestCommon::MAX_HMAC_SIZE; - touchInfo.extraInfo.data = data; - EXPECT_EQ(SC_OK, SecCompKit::ReportSecurityComponentClickEvent(scId, saveInfo, touchInfo, nullptr)); + clickInfo.extraInfo.dataSize = TestCommon::MAX_HMAC_SIZE; + clickInfo.extraInfo.data = data; + EXPECT_EQ(SC_OK, SecCompKit::ReportSecurityComponentClickEvent(scId, saveInfo, clickInfo, nullptr)); setuid(100); EXPECT_EQ(SC_SERVICE_ERROR_VALUE_INVALID, SecCompKit::UnregisterSecurityComponent(scId)); setuid(g_selfUid); 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 1543bb8..f1a3f9b 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 @@ -42,28 +42,56 @@ bool SecCompEntity::CompareComponentBasicInfo(SecCompBase* other, bool isRectChe return componentInfo_->CompareComponentBasicInfo(other, isRectCheck); } -int32_t SecCompEntity::CheckTouchInfo(const SecCompClickEvent& touchInfo) const +int32_t SecCompEntity::CheckPointEvent(const SecCompClickEvent& clickInfo) const { auto current = static_cast( std::chrono::high_resolution_clock::now().time_since_epoch().count()) / TIME_CONVERSION_UNIT; - if (touchInfo.timestamp < current - MAX_TOUCH_INTERVAL || touchInfo.timestamp > current) { - SC_LOG_ERROR(LABEL, "touch timestamp invalid touchInfo. timestamp: %{public}llu, current: %{public}llu", - static_cast(touchInfo.timestamp), static_cast(current)); + if (clickInfo.point.timestamp < current - MAX_TOUCH_INTERVAL || clickInfo.point.timestamp > current) { + SC_LOG_ERROR(LABEL, "touch timestamp invalid clickInfo. timestamp: %{public}llu, current: %{public}llu", + static_cast(clickInfo.point.timestamp), static_cast(current)); return SC_SERVICE_ERROR_CLICK_EVENT_INVALID; } - if (!componentInfo_->rect_.IsInRect(touchInfo.touchX, touchInfo.touchY)) { + if (!componentInfo_->rect_.IsInRect(clickInfo.point.touchX, clickInfo.point.touchY)) { SC_LOG_ERROR(LABEL, "touch point is not in component rect, %{public}lf, %{public}lf", - touchInfo.touchX, touchInfo.touchY); + clickInfo.point.touchX, clickInfo.point.touchY); return SC_SERVICE_ERROR_CLICK_EVENT_INVALID; } + return SC_OK; +} + +int32_t SecCompEntity::CheckKeyEvent(const SecCompClickEvent& clickInfo) const +{ + auto current = static_cast( + std::chrono::high_resolution_clock::now().time_since_epoch().count()) / TIME_CONVERSION_UNIT; + if (clickInfo.key.timestamp < current - MAX_TOUCH_INTERVAL || clickInfo.key.timestamp > current) { + SC_LOG_ERROR(LABEL, "keyboard timestamp invalid clickInfo. timestamp: %{public}llu, current: %{public}llu", + static_cast(clickInfo.key.timestamp), static_cast(current)); + return SC_SERVICE_ERROR_CLICK_EVENT_INVALID; + } + if ((clickInfo.key.keyCode != KEY_SPACE) && (clickInfo.key.keyCode != KEY_ENTER)) { + SC_LOG_ERROR(LABEL, "keyboard keyCode invalid. keyCode: %{public}d", clickInfo.key.keyCode); + return SC_SERVICE_ERROR_CLICK_EVENT_INVALID; + } + + return SC_OK; +} + +int32_t SecCompEntity::CheckClickInfo(const SecCompClickEvent& clickInfo) const +{ + int32_t res = SC_SERVICE_ERROR_CLICK_EVENT_INVALID; + if (clickInfo.type == ClickEventType::POINT_EVENT_TYPE) { + res = CheckPointEvent(clickInfo); + } else if (clickInfo.type == ClickEventType::KEY_EVENT_TYPE) { + res = CheckKeyEvent(clickInfo); + } + if (res != SC_OK) { + return res; + } - int32_t res = SecCompEnhanceAdapter::CheckExtraInfo(touchInfo); + res = SecCompEnhanceAdapter::CheckExtraInfo(clickInfo); if ((res != SC_OK) && (res != SC_ENHANCE_ERROR_NOT_EXIST_ENHANCE)) { - SC_LOG_ERROR(LABEL, "HMAC checkout failed," - "touchX:%{public}f, touchY:%{public}f, timestamp:%{public}llu, dataSize:%{public}d", - touchInfo.touchX, touchInfo.touchY, static_cast(touchInfo.timestamp), - touchInfo.extraInfo.dataSize); + SC_LOG_ERROR(LABEL, "HMAC checkout failed"); HiSysEventWrite(HiviewDFX::HiSysEvent::Domain::SEC_COMPONENT, "CLICK_INFO_CHECK_FAILED", HiviewDFX::HiSysEvent::EventType::SECURITY, "CALLER_UID", IPCSkeleton::GetCallingUid(), "CALLER_PID", IPCSkeleton::GetCallingPid(), "SC_ID", scId_, "SC_TYPE", componentInfo_->type_); diff --git a/services/security_component_service/sa/sa_main/sec_comp_entity.h b/services/security_component_service/sa/sa_main/sec_comp_entity.h index 5c78fa4..be72760 100644 --- a/services/security_component_service/sa/sa_main/sec_comp_entity.h +++ b/services/security_component_service/sa/sa_main/sec_comp_entity.h @@ -66,9 +66,11 @@ public: }; bool CompareComponentBasicInfo(SecCompBase* other, bool isRectCheck) const; - int32_t CheckTouchInfo(const SecCompClickEvent& touchInfo) const; + int32_t CheckClickInfo(const SecCompClickEvent& clickInfo) const; private: + int32_t CheckKeyEvent(const SecCompClickEvent& clickInfo) const; + int32_t CheckPointEvent(const SecCompClickEvent& clickInfo) const; std::shared_ptr componentInfo_; bool isGrant_ = false; AccessToken::AccessTokenID tokenId_; 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 be4936f..f4bd825 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 @@ -412,7 +412,7 @@ int32_t SecCompManager::CheckClickSecurityComponentInfo(SecCompEntity* sc, int32 int32_t SecCompManager::ReportSecurityComponentClickEvent(int32_t scId, const nlohmann::json& jsonComponent, const SecCompCallerInfo& caller, - const SecCompClickEvent& touchInfo, sptr callerToken) + const SecCompClickEvent& clickInfo, sptr callerToken) { if (malicious_.IsInMaliciousAppList(caller.pid, caller.uid)) { SC_LOG_ERROR(LABEL, "app is in MaliciousAppList, never allow it"); @@ -431,7 +431,7 @@ int32_t SecCompManager::ReportSecurityComponentClickEvent(int32_t scId, return res; } - res = sc->CheckTouchInfo(touchInfo); + res = sc->CheckClickInfo(clickInfo); if (res != SC_OK) { HiSysEventWrite(HiviewDFX::HiSysEvent::Domain::SEC_COMPONENT, "CLICK_INFO_CHECK_FAILED", HiviewDFX::HiSysEvent::EventType::SECURITY, "CALLER_UID", IPCSkeleton::GetCallingUid(), diff --git a/services/security_component_service/sa/sa_main/sec_comp_manager.h b/services/security_component_service/sa/sa_main/sec_comp_manager.h index c30cdc0..d6a79fa 100644 --- a/services/security_component_service/sa/sa_main/sec_comp_manager.h +++ b/services/security_component_service/sa/sa_main/sec_comp_manager.h @@ -57,7 +57,7 @@ public: const SecCompCallerInfo& caller); int32_t UnregisterSecurityComponent(int32_t scId, const SecCompCallerInfo& caller); int32_t ReportSecurityComponentClickEvent(int32_t scId, const nlohmann::json& jsonComponent, - const SecCompCallerInfo& caller, const SecCompClickEvent& touchInfo, sptr callerToken); + const SecCompCallerInfo& caller, const SecCompClickEvent& clickInfo, sptr callerToken); void NotifyProcessForeground(int32_t pid); void NotifyProcessBackground(int32_t pid); void NotifyProcessDied(int32_t pid); diff --git a/services/security_component_service/sa/sa_main/sec_comp_service.cpp b/services/security_component_service/sa/sa_main/sec_comp_service.cpp index 08d6367..19451bd 100644 --- a/services/security_component_service/sa/sa_main/sec_comp_service.cpp +++ b/services/security_component_service/sa/sa_main/sec_comp_service.cpp @@ -221,7 +221,7 @@ int32_t SecCompService::UnregisterSecurityComponent(int32_t scId) } int32_t SecCompService::ReportSecurityComponentClickEvent(int32_t scId, - const std::string& componentInfo, const SecCompClickEvent& touchInfo, sptr callerToken) + const std::string& componentInfo, const SecCompClickEvent& clickInfo, sptr callerToken) { StartTrace(HITRACE_TAG_ACCESS_CONTROL, "SecurityComponentClick"); SecCompCallerInfo caller; @@ -231,7 +231,7 @@ int32_t SecCompService::ReportSecurityComponentClickEvent(int32_t scId, return SC_SERVICE_ERROR_VALUE_INVALID; } int32_t res = - SecCompManager::GetInstance().ReportSecurityComponentClickEvent(scId, jsonRes, caller, touchInfo, callerToken); + SecCompManager::GetInstance().ReportSecurityComponentClickEvent(scId, jsonRes, caller, clickInfo, callerToken); FinishTrace(HITRACE_TAG_ACCESS_CONTROL); return res; } diff --git a/services/security_component_service/sa/sa_main/sec_comp_service.h b/services/security_component_service/sa/sa_main/sec_comp_service.h index 48b4992..f9b43de 100644 --- a/services/security_component_service/sa/sa_main/sec_comp_service.h +++ b/services/security_component_service/sa/sa_main/sec_comp_service.h @@ -44,7 +44,7 @@ public: int32_t UpdateSecurityComponent(int32_t scId, const std::string& componentInfo) override; int32_t UnregisterSecurityComponent(int32_t scId) override; int32_t ReportSecurityComponentClickEvent(int32_t scId, - const std::string& componentInfo, const SecCompClickEvent& touchInfo, sptr callerToken) override; + const std::string& componentInfo, const SecCompClickEvent& clickInfo, sptr callerToken) override; bool VerifySavePermission(AccessToken::AccessTokenID tokenId) override; sptr GetEnhanceRemoteObject() override; diff --git a/services/security_component_service/sa/sa_main/sec_comp_stub.cpp b/services/security_component_service/sa/sa_main/sec_comp_stub.cpp index 26e88a9..9f1b1f1 100644 --- a/services/security_component_service/sa/sa_main/sec_comp_stub.cpp +++ b/services/security_component_service/sa/sa_main/sec_comp_stub.cpp @@ -150,15 +150,15 @@ int32_t SecCompStub::ReportSecurityComponentClickEventInner(MessageParcel& data, SC_LOG_ERROR(LABEL, "Report read component info fail"); return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; } - sptr touchInfoParcel = data.ReadParcelable(); - if (touchInfoParcel == nullptr) { - SC_LOG_ERROR(LABEL, "Report read touchInfo info fail"); + sptr clickInfoParcel = data.ReadParcelable(); + if (clickInfoParcel == nullptr) { + SC_LOG_ERROR(LABEL, "Report read clickInfo info fail"); return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; } sptr callerToken = data.ReadRemoteObject(); int32_t res = - this->ReportSecurityComponentClickEvent(scId, componentInfo, touchInfoParcel->touchInfoParams_, callerToken); + this->ReportSecurityComponentClickEvent(scId, componentInfo, clickInfoParcel->clickInfoParams_, callerToken); if (!reply.WriteInt32(res)) { SC_LOG_ERROR(LABEL, "Report security component result fail"); return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; diff --git a/services/security_component_service/sa/test/mock/src/sec_comp_enhance_adapter.cpp b/services/security_component_service/sa/test/mock/src/sec_comp_enhance_adapter.cpp index 812f046..d6259e3 100644 --- a/services/security_component_service/sa/test/mock/src/sec_comp_enhance_adapter.cpp +++ b/services/security_component_service/sa/test/mock/src/sec_comp_enhance_adapter.cpp @@ -38,7 +38,7 @@ int32_t SecCompEnhanceAdapter::GetPointerEventEnhanceData(void* data, uint32_t d return SC_OK; } -int32_t SecCompEnhanceAdapter::CheckExtraInfo(const SecCompClickEvent& touchInfo) +int32_t SecCompEnhanceAdapter::CheckExtraInfo(const SecCompClickEvent& clickInfo) { SC_LOG_DEBUG(LABEL, "CheckExtraInfo success"); return SC_OK; 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 2562e4d..4809666 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 @@ -100,40 +100,41 @@ HWTEST_F(SecCompEntityTest, GrantTempPermission002, TestSize.Level1) } /** - * @tc.name: CheckTouchInfo001 + * @tc.name: CheckClickInfo001 * @tc.desc: Test touch info * @tc.type: FUNC * @tc.require: AR000HO9J7 */ -HWTEST_F(SecCompEntityTest, CheckTouchInfo001, TestSize.Level1) +HWTEST_F(SecCompEntityTest, CheckClickInfo001, TestSize.Level1) { SecCompClickEvent touch = { - .touchX = ServiceTestCommon::TEST_COORDINATE, - .touchY = ServiceTestCommon::TEST_COORDINATE, - .timestamp = 0, + .type = ClickEventType::POINT_EVENT_TYPE, + .point.touchX = ServiceTestCommon::TEST_COORDINATE, + .point.touchY = ServiceTestCommon::TEST_COORDINATE, + .point.timestamp = 0, }; - ASSERT_NE(entity_->CheckTouchInfo(touch), SC_OK); + ASSERT_NE(entity_->CheckClickInfo(touch), SC_OK); uint64_t current = static_cast(std::chrono::high_resolution_clock::now().time_since_epoch().count()); - touch.timestamp = current + 10000L; // 10s - ASSERT_NE(entity_->CheckTouchInfo(touch), SC_OK); + touch.point.timestamp = current + 10000L; // 10s + ASSERT_NE(entity_->CheckClickInfo(touch), SC_OK); entity_->componentInfo_->rect_.x_ = ServiceTestCommon::TEST_DIFF_COORDINATE; // click event will not hit this rect entity_->componentInfo_->rect_.y_ = ServiceTestCommon::TEST_DIFF_COORDINATE; entity_->componentInfo_->rect_.width_ = ServiceTestCommon::TEST_DIFF_COORDINATE; entity_->componentInfo_->rect_.height_ = ServiceTestCommon::TEST_DIFF_COORDINATE; - touch.timestamp = static_cast( + touch.point.timestamp = static_cast( std::chrono::high_resolution_clock::now().time_since_epoch().count()) / ServiceTestCommon::TIME_CONVERSION_UNIT; - ASSERT_NE(entity_->CheckTouchInfo(touch), SC_OK); + ASSERT_NE(entity_->CheckClickInfo(touch), SC_OK); entity_->componentInfo_->rect_.x_ = ServiceTestCommon::TEST_COORDINATE; entity_->componentInfo_->rect_.y_ = ServiceTestCommon::TEST_COORDINATE; - touch.timestamp = static_cast( + touch.point.timestamp = static_cast( std::chrono::high_resolution_clock::now().time_since_epoch().count()) / ServiceTestCommon::TIME_CONVERSION_UNIT; #ifdef SECURITY_COMPONENT_ENHANCE_ENABLE - ASSERT_NE(entity_->CheckTouchInfo(touch), SC_OK); + ASSERT_NE(entity_->CheckClickInfo(touch), SC_OK); #else - ASSERT_EQ(entity_->CheckTouchInfo(touch), SC_OK); + ASSERT_EQ(entity_->CheckClickInfo(touch), SC_OK); #endif } diff --git a/services/security_component_service/sa/test/unittest/src/sec_comp_manager_test.cpp b/services/security_component_service/sa/test/unittest/src/sec_comp_manager_test.cpp index bbec7b0..8207e36 100644 --- a/services/security_component_service/sa/test/unittest/src/sec_comp_manager_test.cpp +++ b/services/security_component_service/sa/test/unittest/src/sec_comp_manager_test.cpp @@ -409,12 +409,12 @@ HWTEST_F(SecCompManagerTest, ReportSecurityComponentClickEvent001, TestSize.Leve .tokenId = ServiceTestCommon::TEST_TOKEN_ID, .pid = ServiceTestCommon::TEST_PID_1 }; - SecCompClickEvent touchInfo; + SecCompClickEvent clickInfo; nlohmann::json jsonVaild; LocationButton buttonValid = BuildValidLocationComponent(); buttonValid.ToJson(jsonVaild); ASSERT_NE(SC_OK, - SecCompManager::GetInstance().ReportSecurityComponentClickEvent(1, jsonVaild, caller, touchInfo, nullptr)); + SecCompManager::GetInstance().ReportSecurityComponentClickEvent(1, jsonVaild, caller, clickInfo, nullptr)); } /** @@ -456,22 +456,22 @@ HWTEST_F(SecCompManagerTest, CheckClickSecurityComponentInfo001, TestSize.Level1 ASSERT_EQ(SC_OK, SecCompManager::GetInstance().AddSecurityComponentToList(ServiceTestCommon::TEST_PID_1, 0, entity)); - SecCompClickEvent touchInfo; + SecCompClickEvent clickInfo; nlohmann::json jsonVaild; LocationButton buttonValid = BuildValidLocationComponent(); buttonValid.ToJson(jsonVaild); jsonVaild[JsonTagConstants::JSON_SC_TYPE] = UNKNOWN_SC_TYPE; ASSERT_EQ(SC_SERVICE_ERROR_COMPONENT_INFO_INVALID, SecCompManager::GetInstance().ReportSecurityComponentClickEvent( - ServiceTestCommon::TEST_SC_ID_1, jsonVaild, caller, touchInfo, nullptr)); + ServiceTestCommon::TEST_SC_ID_1, jsonVaild, caller, clickInfo, nullptr)); jsonVaild[JsonTagConstants::JSON_SC_TYPE] = LOCATION_COMPONENT; jsonVaild[JsonTagConstants::JSON_RECT][JsonTagConstants::JSON_RECT_X] = ServiceTestCommon::TEST_INVALID_DIMENSION; ASSERT_EQ(SC_SERVICE_ERROR_COMPONENT_INFO_INVALID, SecCompManager::GetInstance().ReportSecurityComponentClickEvent( - ServiceTestCommon::TEST_SC_ID_1, jsonVaild, caller, touchInfo, nullptr)); + ServiceTestCommon::TEST_SC_ID_1, jsonVaild, caller, clickInfo, nullptr)); jsonVaild[JsonTagConstants::JSON_RECT][JsonTagConstants::JSON_RECT_X] = ServiceTestCommon::TEST_COORDINATE - 1; ASSERT_EQ(SC_SERVICE_ERROR_COMPONENT_INFO_INVALID, SecCompManager::GetInstance().ReportSecurityComponentClickEvent( - ServiceTestCommon::TEST_SC_ID_1, jsonVaild, caller, touchInfo, nullptr)); + ServiceTestCommon::TEST_SC_ID_1, jsonVaild, caller, clickInfo, nullptr)); } /** diff --git a/services/security_component_service/sa/test/unittest/src/sec_comp_service_mock_test.cpp b/services/security_component_service/sa/test/unittest/src/sec_comp_service_mock_test.cpp index 12fb9da..e38ee11 100644 --- a/services/security_component_service/sa/test/unittest/src/sec_comp_service_mock_test.cpp +++ b/services/security_component_service/sa/test/unittest/src/sec_comp_service_mock_test.cpp @@ -98,9 +98,11 @@ HWTEST_F(SecCompServiceMockTest, RegisterSecurityComponent001, TestSize.Level1) EXPECT_EQ(SC_OK, secCompService_->RegisterSecurityComponent(SAVE_COMPONENT, saveInfo, scId)); EXPECT_EQ(SC_OK, secCompService_->UpdateSecurityComponent(scId, saveInfo)); struct SecCompClickEvent touch = { - .touchX = 100, - .touchY = 100, - .timestamp = static_cast(std::chrono::high_resolution_clock::now().time_since_epoch().count()) / + .type = ClickEventType::POINT_EVENT_TYPE, + .point.touchX = 100, + .point.touchY = 100, + .point.timestamp = + static_cast(std::chrono::high_resolution_clock::now().time_since_epoch().count()) / ServiceTestCommon::TIME_CONVERSION_UNIT }; @@ -132,9 +134,10 @@ HWTEST_F(SecCompServiceMockTest, RegisterSecurityComponent002, TestSize.Level1) // register security component ok EXPECT_EQ(SC_OK, secCompService_->RegisterSecurityComponent(SAVE_COMPONENT, saveInfo, scId)); struct SecCompClickEvent touch = { - .touchX = 100, - .touchY = 100, - .timestamp = static_cast( + .type = ClickEventType::POINT_EVENT_TYPE, + .point.touchX = 100, + .point.touchY = 100, + .point.timestamp = static_cast( std::chrono::high_resolution_clock::now().time_since_epoch().count()) }; EXPECT_EQ(SC_SERVICE_ERROR_CLICK_EVENT_INVALID, @@ -166,9 +169,11 @@ HWTEST_F(SecCompServiceMockTest, RegisterSecurityComponent003, TestSize.Level1) // register security component ok EXPECT_EQ(SC_OK, secCompService_->RegisterSecurityComponent(SAVE_COMPONENT, saveInfo, scId)); struct SecCompClickEvent touch = { - .touchX = 100, - .touchY = 100, - .timestamp = static_cast(std::chrono::high_resolution_clock::now().time_since_epoch().count()) / + .type = ClickEventType::POINT_EVENT_TYPE, + .point.touchX = 100, + .point.touchY = 100, + .point.timestamp = + static_cast(std::chrono::high_resolution_clock::now().time_since_epoch().count()) / ServiceTestCommon::TIME_CONVERSION_UNIT }; EXPECT_EQ(SC_SERVICE_ERROR_PERMISSION_OPER_FAIL, @@ -199,14 +204,16 @@ HWTEST_F(SecCompServiceMockTest, ReportSecurityComponentClickEvent001, TestSize. secCompService_->appStateObserver_->AddProcessToForegroundSet(stateData); // register security component ok EXPECT_EQ(SC_OK, secCompService_->RegisterSecurityComponent(SAVE_COMPONENT, saveInfo, scId)); - struct SecCompClickEvent touchInfo = { - .touchX = 100, - .touchY = 100, - .timestamp = static_cast(std::chrono::high_resolution_clock::now().time_since_epoch().count()) / + struct SecCompClickEvent clickInfo = { + .type = ClickEventType::POINT_EVENT_TYPE, + .point.touchX = 100, + .point.touchY = 100, + .point.timestamp = + static_cast(std::chrono::high_resolution_clock::now().time_since_epoch().count()) / ServiceTestCommon::TIME_CONVERSION_UNIT }; - ASSERT_EQ(SC_OK, secCompService_->ReportSecurityComponentClickEvent(scId, saveInfo, touchInfo, nullptr)); + ASSERT_EQ(SC_OK, secCompService_->ReportSecurityComponentClickEvent(scId, saveInfo, clickInfo, nullptr)); // test 10s valid ASSERT_TRUE(secCompService_->VerifySavePermission(ServiceTestCommon::HAP_TOKEN_ID)); @@ -215,13 +222,13 @@ HWTEST_F(SecCompServiceMockTest, ReportSecurityComponentClickEvent001, TestSize. ASSERT_FALSE(secCompService_->VerifySavePermission(ServiceTestCommon::HAP_TOKEN_ID)); // test 10s multiple clicks - touchInfo.timestamp = static_cast( + clickInfo.point.timestamp = static_cast( std::chrono::high_resolution_clock::now().time_since_epoch().count()) / ServiceTestCommon::TIME_CONVERSION_UNIT; - ASSERT_EQ(SC_OK, secCompService_->ReportSecurityComponentClickEvent(scId, saveInfo, touchInfo, nullptr)); + ASSERT_EQ(SC_OK, secCompService_->ReportSecurityComponentClickEvent(scId, saveInfo, clickInfo, nullptr)); sleep(3); - touchInfo.timestamp = static_cast( + clickInfo.point.timestamp = static_cast( std::chrono::high_resolution_clock::now().time_since_epoch().count()) / ServiceTestCommon::TIME_CONVERSION_UNIT; - ASSERT_EQ(SC_OK, secCompService_->ReportSecurityComponentClickEvent(scId, saveInfo, touchInfo, nullptr)); + ASSERT_EQ(SC_OK, secCompService_->ReportSecurityComponentClickEvent(scId, saveInfo, clickInfo, nullptr)); sleep(8); ASSERT_TRUE(secCompService_->VerifySavePermission(ServiceTestCommon::HAP_TOKEN_ID)); sleep(2); @@ -251,14 +258,16 @@ HWTEST_F(SecCompServiceMockTest, ReportSecurityComponentClickEvent002, TestSize. secCompService_->appStateObserver_->AddProcessToForegroundSet(stateData); // register security component ok EXPECT_EQ(SC_OK, secCompService_->RegisterSecurityComponent(LOCATION_COMPONENT, locationInfo, scId)); - struct SecCompClickEvent touchInfo1 = { - .touchX = 100, - .touchY = 100, - .timestamp = static_cast(std::chrono::high_resolution_clock::now().time_since_epoch().count()) / + struct SecCompClickEvent clickInfo1 = { + .type = ClickEventType::POINT_EVENT_TYPE, + .point.touchX = 100, + .point.touchY = 100, + .point.timestamp = + static_cast(std::chrono::high_resolution_clock::now().time_since_epoch().count()) / ServiceTestCommon::TIME_CONVERSION_UNIT }; - ASSERT_EQ(SC_OK, secCompService_->ReportSecurityComponentClickEvent(scId, locationInfo, touchInfo1, nullptr)); + ASSERT_EQ(SC_OK, secCompService_->ReportSecurityComponentClickEvent(scId, locationInfo, clickInfo1, nullptr)); // test 10s valid ASSERT_EQ(AccessTokenKit::VerifyAccessToken(ServiceTestCommon::HAP_TOKEN_ID, "ohos.permission.LOCATION"), 0); diff --git a/services/security_component_service/sa/test/unittest/src/sec_comp_service_test.cpp b/services/security_component_service/sa/test/unittest/src/sec_comp_service_test.cpp index b4204a3..3f40e5c 100644 --- a/services/security_component_service/sa/test/unittest/src/sec_comp_service_test.cpp +++ b/services/security_component_service/sa/test/unittest/src/sec_comp_service_test.cpp @@ -267,9 +267,11 @@ HWTEST_F(SecCompServiceTest, ReportSecurityComponentClickEvent001, TestSize.Leve #endif uint8_t data[16] = { 0 }; struct SecCompClickEvent touch = { - .touchX = 100, - .touchY = 100, - .timestamp = static_cast(std::chrono::high_resolution_clock::now().time_since_epoch().count()) / + .type = ClickEventType::POINT_EVENT_TYPE, + .point.touchX = 100, + .point.touchY = 100, + .point.timestamp = + static_cast(std::chrono::high_resolution_clock::now().time_since_epoch().count()) / ServiceTestCommon::TIME_CONVERSION_UNIT, .extraInfo.data = data, .extraInfo.dataSize = 16, diff --git a/services/security_component_service/sa/test/unittest/src/sec_comp_stub_test.cpp b/services/security_component_service/sa/test/unittest/src/sec_comp_stub_test.cpp index ce45f6b..5d7b137 100644 --- a/services/security_component_service/sa/test/unittest/src/sec_comp_stub_test.cpp +++ b/services/security_component_service/sa/test/unittest/src/sec_comp_stub_test.cpp @@ -169,9 +169,10 @@ HWTEST_F(SecCompStubTest, ReportSecurityComponentClickEventInner001, TestSize.Le data.WriteInt32(1); data.WriteString(""); - SecCompClickEvent touchInfo; + SecCompClickEvent clickInfo; + clickInfo.type = ClickEventType::POINT_EVENT_TYPE; sptr parcel = new (std::nothrow) SecCompClickEventParcel(); - parcel->touchInfoParams_ = touchInfo; + parcel->clickInfoParams_ = clickInfo; data.WriteParcelable(parcel); ASSERT_EQ(SC_OK, stub_->ReportSecurityComponentClickEventInner(data, reply)); } diff --git a/services/security_component_service/sa/test/unittest/src/sec_comp_stub_test.h b/services/security_component_service/sa/test/unittest/src/sec_comp_stub_test.h index efe7cb0..27d6f0e 100644 --- a/services/security_component_service/sa/test/unittest/src/sec_comp_stub_test.h +++ b/services/security_component_service/sa/test/unittest/src/sec_comp_stub_test.h @@ -44,7 +44,7 @@ public: }; int32_t ReportSecurityComponentClickEvent(int32_t scId, const std::string& componentInfo, - const SecCompClickEvent& touchInfo, sptr callerToken) override + const SecCompClickEvent& clickInfo, sptr callerToken) override { return 0; }; diff --git a/test/fuzztest/security_component/reportsecuritycomponentclickevent_fuzzer/reportsecuritycomponentclickevent_fuzzer.cpp b/test/fuzztest/security_component/reportsecuritycomponentclickevent_fuzzer/reportsecuritycomponentclickevent_fuzzer.cpp index 89477c3..fb8770a 100644 --- a/test/fuzztest/security_component/reportsecuritycomponentclickevent_fuzzer/reportsecuritycomponentclickevent_fuzzer.cpp +++ b/test/fuzztest/security_component/reportsecuritycomponentclickevent_fuzzer/reportsecuritycomponentclickevent_fuzzer.cpp @@ -32,13 +32,14 @@ static void ReportSecurityComponentClickEventFuzzTest(const uint8_t *data, size_ const double touchX = size; const double touchY = size; const uint64_t timesStamp = size; - struct SecCompClickEvent touchInfo; - touchInfo.touchX = touchX; - touchInfo.touchY = touchY; - touchInfo.timestamp = timesStamp; - touchInfo.extraInfo.data = data1; - touchInfo.extraInfo.dataSize = size; - SecCompKit::ReportSecurityComponentClickEvent(size, componentInfo, touchInfo); + struct SecCompClickEvent clickInfo; + clickInfo.type = ClickEventType::POINT_EVENT_TYPE, + clickInfo.point.touchX = touchX; + clickInfo.point.touchY = touchY; + clickInfo.point.timestamp = timesStamp; + clickInfo.extraInfo.data = data1; + clickInfo.extraInfo.dataSize = size; + SecCompKit::ReportSecurityComponentClickEvent(size, componentInfo, clickInfo); } } // namespace OHOS -- Gitee