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 1b8dfd799ff444ea84cbba9f0a83a897296aeb70..7ce03fcb382be0cefd174e280d900555bd7bb472 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 @@ -72,6 +72,7 @@ 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; } void TestCommon::BuildSaveComponentInfo(nlohmann::json& jsonComponent) @@ -129,6 +130,7 @@ 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; } void TestCommon::BuildPasteComponentInfo(nlohmann::json& jsonComponent) @@ -186,6 +188,7 @@ 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; } } // 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 f61707afa0d265fb581ecbdb6ed4b69ab76eccc0..323d9e3ba54765130e45dfe6c76c65bfb94c826b 100644 --- a/frameworks/security_component/src/sec_comp_base.cpp +++ b/frameworks/security_component/src/sec_comp_base.cpp @@ -63,6 +63,7 @@ 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"; +const std::string JsonTagConstants::JSON_CROSS_AXIS_STATE = "crossAxisState"; bool SecCompBase::ParseDimension(const nlohmann::json& json, const std::string& tag, DimensionT& res) { @@ -245,15 +246,13 @@ bool SecCompBase::ParseRect(const nlohmann::json& json, const std::string& tag, return true; } -bool SecCompBase::FromJson(const nlohmann::json& jsonSrc) +bool SecCompBase::ParseType(const nlohmann::json& json, const std::string& tag) { - SC_LOG_DEBUG(LABEL, "Button info %{public}s.", jsonSrc.dump().c_str()); - if ((jsonSrc.find(JsonTagConstants::JSON_SC_TYPE) == jsonSrc.end()) || - !jsonSrc.at(JsonTagConstants::JSON_SC_TYPE).is_number()) { - SC_LOG_ERROR(LABEL, "json: %{public}s tag invalid.", JsonTagConstants::JSON_SC_TYPE.c_str()); + if ((json.find(tag) == json.end()) || !json.at(tag).is_number()) { + SC_LOG_ERROR(LABEL, "json: %{public}s tag invalid.", tag.c_str()); return false; } - int32_t value = jsonSrc.at(JsonTagConstants::JSON_SC_TYPE).get(); + int32_t value = json.at(tag).get(); if ((value <= static_cast(SecCompType::UNKNOWN_SC_TYPE)) || (value >= static_cast(SecCompType::MAX_SC_TYPE))) { SC_LOG_ERROR(LABEL, "scType value is invalid."); @@ -261,13 +260,57 @@ bool SecCompBase::FromJson(const nlohmann::json& jsonSrc) } type_ = static_cast(value); - if ((jsonSrc.find(JsonTagConstants::JSON_NODE_ID) == jsonSrc.end()) || - !jsonSrc.at(JsonTagConstants::JSON_NODE_ID).is_number()) { - SC_LOG_ERROR(LABEL, "json: %{public}s tag invalid.", JsonTagConstants::JSON_NODE_ID.c_str()); + return true; +} + +bool SecCompBase::ParseValue(const nlohmann::json& json, const std::string& tag, int32_t& value) +{ + if ((json.find(tag) == json.end()) || !json.at(tag).is_number()) { + SC_LOG_ERROR(LABEL, "json: %{public}s tag invalid.", tag.c_str()); return false; } - nodeId_ = jsonSrc.at(JsonTagConstants::JSON_NODE_ID).get(); + value = json.at(tag).get(); + return true; +} + +bool SecCompBase::ParseDisplayId(const nlohmann::json& json, const std::string& tag) +{ + if ((json.find(tag) == json.end()) || !json.at(tag).is_number()) { + SC_LOG_ERROR(LABEL, "json: %{public}s tag invalid.", tag.c_str()); + return false; + } + displayId_ = json.at(tag).get(); + + return true; +} + +bool SecCompBase::ParseCrossAxisState(const nlohmann::json& json, const std::string& tag) +{ + if ((json.find(tag) == json.end()) || !json.at(tag).is_number()) { + SC_LOG_ERROR(LABEL, "json: %{public}s tag invalid.", tag.c_str()); + return false; + } + int32_t value = json.at(tag).get(); + if ((value < static_cast(CrossAxisState::STATE_INVALID)) || + (value > static_cast(CrossAxisState::STATE_NO_CROSS))) { + SC_LOG_ERROR(LABEL, "Cross axis state value is invalid."); + return false; + } + crossAxisState_ = static_cast(value); + + return true; +} + +bool SecCompBase::FromJson(const nlohmann::json& jsonSrc) +{ + SC_LOG_DEBUG(LABEL, "Button info %{public}s.", jsonSrc.dump().c_str()); + if (!ParseType(jsonSrc, JsonTagConstants::JSON_SC_TYPE)) { + return false; + } + if (!ParseValue(jsonSrc, JsonTagConstants::JSON_NODE_ID, nodeId_)) { + return false; + } if (!ParseRect(jsonSrc, JsonTagConstants::JSON_RECT, rect_)) { return false; } @@ -289,20 +332,16 @@ bool SecCompBase::FromJson(const nlohmann::json& jsonSrc) if (!ParseStyle(jsonSrc, JsonTagConstants::JSON_STYLE_TAG)) { return false; } - - if ((jsonSrc.find(JsonTagConstants::JSON_WINDOW_ID) == jsonSrc.end()) || - !jsonSrc.at(JsonTagConstants::JSON_WINDOW_ID).is_number()) { - SC_LOG_ERROR(LABEL, "json: %{public}s tag invalid.", JsonTagConstants::JSON_WINDOW_ID.c_str()); + if (!ParseValue(jsonSrc, JsonTagConstants::JSON_WINDOW_ID, windowId_)) { 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()); + if (!ParseDisplayId(jsonSrc, JsonTagConstants::JSON_DISPLAY_ID)) { return false; } - displayId_ = jsonSrc.at(JsonTagConstants::JSON_DISPLAY_ID).get(); + if (!ParseCrossAxisState(jsonSrc, JsonTagConstants::JSON_CROSS_AXIS_STATE)) { + return false; + } + return true; } @@ -362,6 +401,7 @@ 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_; } 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 2f127baeecf207065afc2392743ed6105093e3bd..02f77402da8dc9bff59b4d75b12ce79ece8328eb 100644 --- a/interfaces/inner_api/security_component/include/sec_comp_base.h +++ b/interfaces/inner_api/security_component/include/sec_comp_base.h @@ -80,6 +80,7 @@ public: static const std::string JSON_BG_TAG; static const std::string JSON_WINDOW_ID; static const std::string JSON_DISPLAY_ID; + static const std::string JSON_CROSS_AXIS_STATE; }; class __attribute__((visibility("default"))) SecCompBase { @@ -135,6 +136,7 @@ public: int32_t windowId_ = 0; uint64_t displayId_ = 0; int32_t nodeId_ = 0; + CrossAxisState crossAxisState_ = CrossAxisState::STATE_INVALID; protected: virtual bool IsTextIconTypeValid() = 0; virtual bool IsCorrespondenceType() = 0; @@ -150,6 +152,10 @@ private: bool ParseParent(const nlohmann::json& json, const std::string& tag); bool ParseRect(const nlohmann::json& json, const std::string& tag, SecCompRect& rect); bool ParseStyle(const nlohmann::json& json, const std::string& tag); + bool ParseType(const nlohmann::json& json, const std::string& tag); + bool ParseValue(const nlohmann::json& json, const std::string& tag, int32_t& value); + bool ParseDisplayId(const nlohmann::json& json, const std::string& tag); + bool ParseCrossAxisState(const nlohmann::json& json, const std::string& tag); }; } // namespace SecurityComponent } // namespace Security 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 39afc04e58e754815bd642f0854044879382cbe9..edb2056102c4b5070b7abc0d40bea462c851f4f9 100644 --- a/interfaces/inner_api/security_component/include/sec_comp_info.h +++ b/interfaces/inner_api/security_component/include/sec_comp_info.h @@ -63,6 +63,12 @@ union SecCompColor { uint32_t value; }; +enum CrossAxisState { + STATE_INVALID = 0, + STATE_CROSS, + STATE_NO_CROSS, +}; + inline bool IsComponentTypeValid(int32_t type) { return (type > UNKNOWN_SC_TYPE && type < MAX_SC_TYPE); 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 d6c8209e92ae2196930cd6bcc2276a9a76787c4e..42005c932bf5c3120e733d45488469c0561ab94a 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 @@ -39,7 +39,7 @@ public: static SecCompBase* ParseComponent(SecCompType type, const nlohmann::json& jsonComponent, std::string& message); static bool CheckComponentValid(SecCompBase* comp, std::string& message); static bool CheckRectValid(const SecCompRect& rect, const SecCompRect& windowRect, const uint64_t displayId, - std::string& message); + const CrossAxisState crossAxisState, std::string& message); 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 5d8ab5d832f6c8d3a4c31323a361614d5b34b597..d06e4c7f4a74152c53505e1c8668b2b40611fca3 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 @@ -22,13 +22,15 @@ #include "ability_manager_client.h" #include "accesstoken_kit.h" #include "bundle_mgr_client.h" +#include "display.h" +#include "display_info.h" +#include "display_manager.h" #include "hisysevent.h" #include "ipc_skeleton.h" #include "sec_comp_dialog_callback_proxy.h" #include "sec_comp_err.h" #include "sec_comp_log.h" #include "want_params_wrapper.h" -#include "want.h" namespace OHOS { namespace Security { @@ -47,8 +49,11 @@ 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"; +const std::string DISPLAY_WIDTH = "ohos.display.width"; +const std::string DISPLAY_HEIGHT = "ohos.display.height"; +const std::string DIALOG_OFFSET = "ohos.dialog.offset"; +constexpr int32_t DISPLAY_HALF_RATIO = 2; constexpr uint32_t MAX_CFG_FILE_SIZE = 100 * 1024; // 100k constexpr uint64_t LOCATION_BUTTON_FIRST_USE = 1 << 0; constexpr uint64_t SAVE_BUTTON_FIRST_USE = 1 << 1; @@ -296,8 +301,40 @@ int32_t FirstUseDialog::GrantDialogWaitEntity(int32_t scId) return res; } -void FirstUseDialog::StartDialogAbility(std::shared_ptr entity, - sptr callerToken, sptr dialogCallback, const uint64_t displayId) +bool FirstUseDialog::GetDialogInfo(AAFwk::Want& want, const uint64_t displayId, const CrossAxisState crossAxisState) +{ + sptr display = + OHOS::Rosen::DisplayManager::GetInstance().GetDisplayById(displayId); + if (display == nullptr) { + SC_LOG_ERROR(LABEL, "Get display manager failed"); + return false; + } + + auto info = display->GetDisplayInfo(); + if (info == nullptr) { + SC_LOG_ERROR(LABEL, "Get display info failed"); + return false; + } + /* crossAxisState is INVALID or NO_CROSS */ + int32_t width = info->GetWidth(); + int32_t height = info->GetHeight(); + int32_t offset = 0; + /* crossAxisState is CROSS */ + if (crossAxisState == CrossAxisState::STATE_CROSS) { + height = info->GetPhysicalHeight(); + offset = info->GetAvailableHeight() / DISPLAY_HALF_RATIO; + } + SC_LOG_INFO(LABEL, "Display info width %{public}d height %{public}d, dialog offset %{public}d", + width, height, offset); + + want.SetParam(DISPLAY_WIDTH, width); + want.SetParam(DISPLAY_HEIGHT, height); + want.SetParam(DIALOG_OFFSET, offset); + return true; +} + +void FirstUseDialog::StartDialogAbility(std::shared_ptr entity, sptr callerToken, + sptr dialogCallback, const uint64_t displayId, const CrossAxisState crossAxisState) { int32_t typeNum; SecCompType type = entity->GetType(); @@ -324,7 +361,11 @@ 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)); + if (!GetDialogInfo(want, displayId, crossAxisState)) { + SC_LOG_ERROR(LABEL, "Get display info failed."); + return; + } + int startRes = AAFwk::AbilityManagerClient::GetInstance()->StartExtensionAbility(want, callerToken); SC_LOG_INFO(LABEL, "start ability res %{public}d", startRes); if (startRes != 0) { @@ -374,8 +415,8 @@ bool FirstUseDialog::SetFirstUseMap(std::shared_ptr entity) return true; } -int32_t FirstUseDialog::NotifyFirstUseDialog(std::shared_ptr entity, - sptr callerToken, sptr dialogCallback, const uint64_t displayId) +int32_t FirstUseDialog::NotifyFirstUseDialog(std::shared_ptr entity, sptr callerToken, + sptr dialogCallback, const uint64_t displayId, const CrossAxisState crossAxisState) { if (entity == nullptr) { SC_LOG_ERROR(LABEL, "Entity is invalid."); @@ -411,7 +452,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, displayId); + StartDialogAbility(entity, callerToken, dialogCallback, displayId, crossAxisState); return SC_SERVICE_ERROR_WAIT_FOR_DIALOG_CLOSE; } @@ -420,7 +461,7 @@ int32_t FirstUseDialog::NotifyFirstUseDialog(std::shared_ptr enti SC_LOG_INFO(LABEL, "no need notify again."); return SC_OK; } - StartDialogAbility(entity, callerToken, dialogCallback, displayId); + StartDialogAbility(entity, callerToken, dialogCallback, displayId, crossAxisState); 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 ecf5af65e052512a8f2363be1c065ec3a06c53e6..96e1bc4e425aef77815a4729908a1a2078080f05 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 @@ -27,6 +27,7 @@ #include "sec_comp_err.h" #include "sec_comp_info.h" #include "sec_event_handler.h" +#include "want.h" namespace OHOS { namespace Security { @@ -53,8 +54,8 @@ public: static FirstUseDialog& GetInstance(); ~FirstUseDialog() = default; - int32_t NotifyFirstUseDialog(std::shared_ptr entity, - sptr callerToken, sptr dialogCallback, const uint64_t displayId); + int32_t NotifyFirstUseDialog(std::shared_ptr entity, sptr callerToken, + sptr dialogCallback, const uint64_t displayId, const CrossAxisState crossAxisState); void Init(std::shared_ptr secHandler); int32_t GrantDialogWaitEntity(int32_t scId); void RemoveDialogWaitEntitys(int32_t pid); @@ -72,8 +73,9 @@ private: void ParseRecords(nlohmann::json& jsonRes); void LoadFirstUseRecord(void); void SaveFirstUseRecord(void); - void StartDialogAbility(std::shared_ptr entity, - sptr callerToken, sptr dialogCallback, const uint64_t displayId); + void StartDialogAbility(std::shared_ptr entity, sptr callerToken, + sptr dialogCallback, const uint64_t displayId, const CrossAxisState crossAxisState); + bool GetDialogInfo(AAFwk::Want& want, const uint64_t displayId, const CrossAxisState crossAxisState); void SendSaveEventHandler(void); std::mutex useMapMutex_; 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 bf235f49bb8dce73078502d19387b80837340128..bff6ef24454e07a723c10c7eb9f25864ac9fef88 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 @@ -34,6 +34,7 @@ namespace { constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, SECURITY_DOMAIN_SECURITY_COMPONENT, "SecCompEntity"}; static constexpr uint64_t MAX_TOUCH_INTERVAL = 1000000L; // 1000ms static constexpr uint64_t TIME_CONVERSION_UNIT = 1000; +static constexpr uint32_t FOLD_VIRTUAL_DISPLAY_ID = 999; constexpr const char *SETTINGS_DATA_EXT_URI = "datashare:///com.ohos.settingsdata.DataAbility"; constexpr const char *SETTINGS_DATASHARE_URI = "datashare:///com.ohos.settingsdata/entry/settingsdata/SETTINGSDATA?Proxy=true"; @@ -57,7 +58,8 @@ bool SecCompEntity::CompareComponentBasicInfo(SecCompBase* other, bool isRectChe return componentInfo_->CompareComponentBasicInfo(other, isRectCheck); } -int32_t SecCompEntity::CheckPointEvent(const SecCompClickEvent& clickInfo) const +int32_t SecCompEntity::CheckPointEvent(SecCompClickEvent& clickInfo, int32_t superFoldOffsetY, + const CrossAxisState crossAxisState) const { auto current = static_cast( std::chrono::high_resolution_clock::now().time_since_epoch().count()) / TIME_CONVERSION_UNIT; @@ -68,6 +70,11 @@ int32_t SecCompEntity::CheckPointEvent(const SecCompClickEvent& clickInfo) const } if (!componentInfo_->rect_.IsInRect(clickInfo.point.touchX, clickInfo.point.touchY)) { + if ((crossAxisState == CrossAxisState::STATE_CROSS) && + componentInfo_->rect_.IsInRect(clickInfo.point.touchX, clickInfo.point.touchY + superFoldOffsetY)) { + clickInfo.point.touchY += superFoldOffsetY; + return SC_OK; + } SC_LOG_ERROR(LABEL, "touch point is not in component rect = (%{public}f, %{public}f)" \ "left top point of component rect = (%{public}f, %{public}f)" \ "right bottom point of component rect = (%{public}f, %{public}f)", @@ -97,18 +104,23 @@ int32_t SecCompEntity::CheckKeyEvent(const SecCompClickEvent& clickInfo) const return SC_OK; } -int32_t SecCompEntity::CheckClickInfo(const SecCompClickEvent& clickInfo, std::string& message) const +int32_t SecCompEntity::CheckClickInfo(SecCompClickEvent& clickInfo, int32_t superFoldOffsetY, + const CrossAxisState crossAxisState, std::string& message) const { if (!WindowInfoHelper::CheckOtherWindowCoverComp(componentInfo_->windowId_, componentInfo_->rect_, message)) { SC_LOG_ERROR(LABEL, "Component may be covered by other window"); return SC_SERVICE_ERROR_CLICK_EVENT_INVALID; } + if (componentInfo_->displayId_ == FOLD_VIRTUAL_DISPLAY_ID) { + clickInfo.point.touchY += superFoldOffsetY; + componentInfo_->rect_.y_ += superFoldOffsetY; + } int32_t res = SC_SERVICE_ERROR_CLICK_EVENT_INVALID; bool isScreenReadMode = IsScreenReadMode(); if (clickInfo.type == ClickEventType::POINT_EVENT_TYPE && !isScreenReadMode) { - res = CheckPointEvent(clickInfo); + res = CheckPointEvent(clickInfo, superFoldOffsetY, crossAxisState); } else if (clickInfo.type == ClickEventType::POINT_EVENT_TYPE && isScreenReadMode) { SC_LOG_WARN(LABEL, "Device is in screen read mode, skip event check."); return SC_OK; 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 4998d42ac6953e06395ef6644e31c52ebf83fc33..fb9d7badf02bc8d3db9aa0b24a1d9d5b7a98dde8 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 @@ -46,7 +46,8 @@ public: } bool CompareComponentBasicInfo(SecCompBase* other, bool isRectCheck) const; - int32_t CheckClickInfo(const SecCompClickEvent& clickInfo, std::string& message) const; + int32_t CheckClickInfo(SecCompClickEvent& clickInfo, int32_t superFoldOffsetY, const CrossAxisState crossAxisState, + std::string& message) const; std::shared_ptr componentInfo_; AccessToken::AccessTokenID tokenId_; @@ -56,7 +57,8 @@ public: private: int32_t CheckKeyEvent(const SecCompClickEvent& clickInfo) const; - int32_t CheckPointEvent(const SecCompClickEvent& clickInfo) const; + int32_t CheckPointEvent(SecCompClickEvent& clickInfo, int32_t superFoldOffsetY, + const CrossAxisState crossAxisState) const; bool isGrant_ = false; }; } // namespace SecurityComponent 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 0bcc777cc0457a9de406485df0c30365ecba9875..6c2a3c9fee91997c350c10a8e772911072524feb 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 @@ -82,7 +82,7 @@ SecCompBase* SecCompInfoHelper::ParseComponent(SecCompType type, const nlohmann: return comp; } -static bool GetScreenSize(double& width, double& height, const uint64_t displayId) +static bool GetScreenSize(double& width, double& height, const uint64_t displayId, const CrossAxisState crossAxisState) { sptr display = OHOS::Rosen::DisplayManager::GetInstance().GetDisplayById(displayId); @@ -98,18 +98,22 @@ static bool GetScreenSize(double& width, double& height, const uint64_t displayI } width = static_cast(info->GetWidth()); - height = static_cast(info->GetHeight()); + if (crossAxisState == CrossAxisState::STATE_CROSS) { + height = static_cast(info->GetPhysicalHeight()); + } else { + height = static_cast(info->GetHeight()); + } SC_LOG_DEBUG(LABEL, "display manager Screen width %{public}f height %{public}f", width, height); return true; } bool SecCompInfoHelper::CheckRectValid(const SecCompRect& rect, const SecCompRect& windowRect, - const uint64_t displayId, std::string& message) + const uint64_t displayId, const CrossAxisState crossAxisState, std::string& message) { double curScreenWidth = 0.0F; double curScreenHeight = 0.0F; - if (!GetScreenSize(curScreenWidth, curScreenHeight, displayId)) { + if (!GetScreenSize(curScreenWidth, curScreenHeight, displayId, crossAxisState)) { 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 b5b9ff574b3162254060d61e7546fc9fef04a8f6..98e41dec86b5adeec63b65f4332e2c6de5db44fb 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 @@ -16,6 +16,9 @@ #include "bundle_mgr_client.h" #include "delay_exit_task.h" +#include "display.h" +#include "display_info.h" +#include "display_manager.h" #include "hisysevent.h" #include "i_sec_comp_service.h" #include "ipc_skeleton.h" @@ -471,7 +474,7 @@ int32_t SecCompManager::CheckClickSecurityComponentInfo(std::shared_ptrrect_, reportComponentInfo->windowRect_, - report->displayId_, message))) { + report->displayId_, report->crossAxisState_, message))) { 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, @@ -504,6 +507,21 @@ static void ReportEvent(std::string eventName, HiviewDFX::HiSysEvent::EventType "CALLER_PID", IPCSkeleton::GetCallingPid(), "SC_ID", scId, "SC_TYPE", scType); } +void SecCompManager::GetFoldOffsetY() +{ + if (superFoldOffsetY_ != 0) { + return; + } + auto foldCreaseRegion = OHOS::Rosen::DisplayManager::GetInstance().GetCurrentFoldCreaseRegion(); + if (foldCreaseRegion != nullptr) { + const auto& creaseRects = foldCreaseRegion->GetCreaseRects(); + if (!creaseRects.empty()) { + const auto& rect = creaseRects.front(); + superFoldOffsetY_ = rect.height_ + rect.posY_; + } + } +} + int32_t SecCompManager::ReportSecurityComponentClickEvent(SecCompInfo& info, const nlohmann::json& compJson, const SecCompCallerInfo& caller, const std::vector>& remote, std::string& message) { @@ -527,8 +545,14 @@ int32_t SecCompManager::ReportSecurityComponentClickEvent(SecCompInfo& info, con if (res != SC_OK) { return res; } + SecCompBase* report = SecCompInfoHelper::ParseComponent(sc->GetType(), compJson, message); + if (report == nullptr) { + return SC_SERVICE_ERROR_COMPONENT_INFO_INVALID; + } + + GetFoldOffsetY(); - res = sc->CheckClickInfo(info.clickInfo, message); + res = sc->CheckClickInfo(info.clickInfo, superFoldOffsetY_, report->crossAxisState_, message); if (res != SC_OK) { ReportEvent("CLICK_INFO_CHECK_FAILED", HiviewDFX::HiSysEvent::EventType::SECURITY, info.scId, sc->GetType()); @@ -539,12 +563,8 @@ int32_t SecCompManager::ReportSecurityComponentClickEvent(SecCompInfo& info, con return SC_SERVICE_ERROR_CLICK_EVENT_INVALID; } - SecCompBase* report = SecCompInfoHelper::ParseComponent(sc->GetType(), compJson, message); - if (report == nullptr) { - return SC_SERVICE_ERROR_COMPONENT_INFO_INVALID; - } - if (FirstUseDialog::GetInstance().NotifyFirstUseDialog(sc, remote[0], remote[1], report->displayId_) == - SC_SERVICE_ERROR_WAIT_FOR_DIALOG_CLOSE) { + if (FirstUseDialog::GetInstance().NotifyFirstUseDialog(sc, remote[0], remote[1], report->displayId_, + report->crossAxisState_) == 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/sa_main/sec_comp_manager.h b/services/security_component_service/sa/sa_main/sec_comp_manager.h index af40df827ad5c2ace05ca60ae0505c85d60aa981..30de2ddecb21dcae455a860f01e3b3097d13276a 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 @@ -81,17 +81,19 @@ private: void SendCheckInfoEnhanceSysEvent(int32_t scId, SecCompType type, const std::string& scene, int32_t res); int32_t CreateScId(); + void GetFoldOffsetY(); OHOS::Utils::RWLock componentInfoLock_; std::mutex scIdMtx_; std::unordered_map componentMap_; int32_t scIdStart_; bool isSaExit_ = false; + int32_t superFoldOffsetY_ = 0; std::shared_ptr secRunner_; std::shared_ptr secHandler_; SecCompMaliciousApps malicious_; - + std::function exitSaProcessFunc_ = []() { return; }; DISALLOW_COPY_AND_MOVE(SecCompManager); }; 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 7164ffe3a859a3f1bf4eb33915159cd8975e98a2..d0a5901147127a14b0ddc4c6e8c367b518866b77 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,51 @@ HWTEST_F(FirstUseDialogTest, NotifyFirstUseDialog001, TestSize.Level1) diag.secHandler_ = nullptr; // no entity - EXPECT_EQ(diag.NotifyFirstUseDialog(nullptr, nullptr, nullptr, 0), SC_SERVICE_ERROR_VALUE_INVALID); + EXPECT_EQ(diag.NotifyFirstUseDialog(nullptr, nullptr, nullptr, 0, CrossAxisState::STATE_INVALID), + 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, 0), SC_SERVICE_ERROR_VALUE_INVALID); + EXPECT_EQ(diag.NotifyFirstUseDialog(entity, nullptr, nullptr, 0, CrossAxisState::STATE_INVALID), + 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, 0), SC_SERVICE_ERROR_VALUE_INVALID); + EXPECT_EQ(diag.NotifyFirstUseDialog(entity, nullptr, nullptr, 0, CrossAxisState::STATE_INVALID), + SC_SERVICE_ERROR_VALUE_INVALID); // no dialogCallback sptr testRemoteObject = new TestRemoteObject(std::u16string()); - EXPECT_EQ(diag.NotifyFirstUseDialog(entity, testRemoteObject, nullptr, 0), SC_SERVICE_ERROR_VALUE_INVALID); + EXPECT_EQ(diag.NotifyFirstUseDialog(entity, testRemoteObject, nullptr, 0, CrossAxisState::STATE_INVALID), + SC_SERVICE_ERROR_VALUE_INVALID); // type invalid - EXPECT_EQ(diag.NotifyFirstUseDialog(entity, testRemoteObject, testRemoteObject, 0), SC_OK); + EXPECT_EQ(diag.NotifyFirstUseDialog(entity, testRemoteObject, testRemoteObject, 0, CrossAxisState::STATE_INVALID), + 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, 0), + EXPECT_EQ(diag.NotifyFirstUseDialog(entity, testRemoteObject, testRemoteObject, 0, CrossAxisState::STATE_INVALID), 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, 0), + EXPECT_EQ(diag.NotifyFirstUseDialog(entity, testRemoteObject, testRemoteObject, 0, CrossAxisState::STATE_INVALID), 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, 0), + EXPECT_EQ(diag.NotifyFirstUseDialog(entity, testRemoteObject, testRemoteObject, 0, CrossAxisState::STATE_INVALID), SC_SERVICE_ERROR_WAIT_FOR_DIALOG_CLOSE); EXPECT_EQ(0, static_cast(diag.firstUseMap_[0])); - diag.StartDialogAbility(entity, testRemoteObject, testRemoteObject, 0); + diag.StartDialogAbility(entity, testRemoteObject, testRemoteObject, 0, CrossAxisState::STATE_INVALID); // wait for event handler done sleep(3); 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 fbd951395ff25f901b9094d2dab49305d0754fc2..24731538fd0f2b446c38877c85fd8f8350e4f2ee 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 @@ -117,11 +117,11 @@ HWTEST_F(SecCompEntityTest, CheckClickInfo001, TestSize.Level1) .point.timestamp = 0, }; std::string message; - ASSERT_NE(entity_->CheckClickInfo(touch, message), SC_OK); + ASSERT_NE(entity_->CheckClickInfo(touch, 0, CrossAxisState::STATE_INVALID, message), SC_OK); uint64_t current = static_cast(std::chrono::high_resolution_clock::now().time_since_epoch().count()); touch.point.timestamp = current + 10000L; // 10s - ASSERT_NE(entity_->CheckClickInfo(touch, message), SC_OK); + ASSERT_NE(entity_->CheckClickInfo(touch, 0, CrossAxisState::STATE_INVALID, message), 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; @@ -129,7 +129,7 @@ HWTEST_F(SecCompEntityTest, CheckClickInfo001, TestSize.Level1) entity_->componentInfo_->rect_.height_ = ServiceTestCommon::TEST_DIFF_COORDINATE; touch.point.timestamp = static_cast( std::chrono::high_resolution_clock::now().time_since_epoch().count()) / ServiceTestCommon::TIME_CONVERSION_UNIT; - ASSERT_NE(entity_->CheckClickInfo(touch, message), SC_OK); + ASSERT_NE(entity_->CheckClickInfo(touch, 0, CrossAxisState::STATE_INVALID, message), SC_OK); entity_->componentInfo_->rect_.x_ = ServiceTestCommon::TEST_COORDINATE; entity_->componentInfo_->rect_.y_ = ServiceTestCommon::TEST_COORDINATE; @@ -138,7 +138,7 @@ HWTEST_F(SecCompEntityTest, CheckClickInfo001, TestSize.Level1) touch.extraInfo.data = buffer; touch.point.timestamp = static_cast( std::chrono::high_resolution_clock::now().time_since_epoch().count()) / ServiceTestCommon::TIME_CONVERSION_UNIT; - ASSERT_EQ(entity_->CheckClickInfo(touch, message), SC_OK); + ASSERT_EQ(entity_->CheckClickInfo(touch, 0, CrossAxisState::STATE_INVALID, message), SC_OK); } /** @@ -156,7 +156,7 @@ HWTEST_F(SecCompEntityTest, CheckClickInfo002, TestSize.Level1) .point.timestamp = static_cast(std::chrono::high_resolution_clock::now().time_since_epoch().count()), }; std::string message; - ASSERT_NE(entity_->CheckClickInfo(touch, message), SC_OK); + ASSERT_NE(entity_->CheckClickInfo(touch, 0, CrossAxisState::STATE_INVALID, message), SC_OK); entity_->componentInfo_->rect_.x_ = ServiceTestCommon::TEST_COORDINATE; entity_->componentInfo_->rect_.y_ = ServiceTestCommon::TEST_COORDINATE; @@ -165,7 +165,8 @@ HWTEST_F(SecCompEntityTest, CheckClickInfo002, TestSize.Level1) // GetAccessibilityWindowInfo failed OHOS::Rosen::WindowManager::GetInstance().result_ = static_cast(-1); - ASSERT_EQ(entity_->CheckClickInfo(touch, message), SC_SERVICE_ERROR_CLICK_EVENT_INVALID); + ASSERT_EQ(entity_->CheckClickInfo(touch, 0, CrossAxisState::STATE_INVALID, message), + SC_SERVICE_ERROR_CLICK_EVENT_INVALID); } /** @@ -198,14 +199,17 @@ HWTEST_F(SecCompEntityTest, CheckKeyEvent001, TestSize.Level1) std::chrono::high_resolution_clock::now().time_since_epoch().count()) / 1000; clickInfo.key.timestamp = current - 1000000L - 1; std::string message; - ASSERT_EQ(SC_SERVICE_ERROR_CLICK_EVENT_INVALID, entity_->CheckClickInfo(clickInfo, message)); + ASSERT_EQ(SC_SERVICE_ERROR_CLICK_EVENT_INVALID, entity_->CheckClickInfo(clickInfo, 0, + CrossAxisState::STATE_INVALID, message)); clickInfo.key.timestamp = current + 1; - ASSERT_EQ(SC_SERVICE_ERROR_CLICK_EVENT_INVALID, entity_->CheckClickInfo(clickInfo, message)); + ASSERT_EQ(SC_SERVICE_ERROR_CLICK_EVENT_INVALID, entity_->CheckClickInfo(clickInfo, 0, + CrossAxisState::STATE_INVALID, message)); clickInfo.key.timestamp = current - 1; clickInfo.key.keyCode = 1; - ASSERT_EQ(SC_SERVICE_ERROR_CLICK_EVENT_INVALID, entity_->CheckClickInfo(clickInfo, message)); + ASSERT_EQ(SC_SERVICE_ERROR_CLICK_EVENT_INVALID, entity_->CheckClickInfo(clickInfo, 0, + CrossAxisState::STATE_INVALID, message)); clickInfo.key.keyCode = KEY_SPACE; ASSERT_EQ(SC_OK, entity_->CheckKeyEvent(clickInfo)); 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 748b4501d56bc616e3c587f6796d78604ddf6656..2f1a9769ed07d6067c58b8eb487fbbde9103fb22 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 @@ -153,36 +153,36 @@ HWTEST_F(SecCompInfoHelperTest, ParseComponent004, TestSize.Level1) SecCompRect rect = GetDefaultRect(); SecCompRect windowRect = GetDefaultRect(); std::string message; - ASSERT_TRUE(SecCompInfoHelper::CheckRectValid(rect, windowRect, 0, message)); + ASSERT_TRUE(SecCompInfoHelper::CheckRectValid(rect, windowRect, 0, CrossAxisState::STATE_INVALID, message)); rect.x_ = ServiceTestCommon::TEST_INVALID_DIMENSION; - ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect, 0, message)); + ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect, 0, CrossAxisState::STATE_INVALID, message)); rect.x_ = g_testWidth; rect.y_ = ServiceTestCommon::TEST_INVALID_DIMENSION; - ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect, 0, message)); + ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect, 0, CrossAxisState::STATE_INVALID, message)); rect.y_ = g_testHeight; rect.x_ = g_curScreenWidth + 1; - ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect, 0, message)); + ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect, 0, CrossAxisState::STATE_INVALID, message)); rect.x_ = g_testWidth; rect.y_ = g_curScreenHeight + 1; - ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect, 0, message)); + ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect, 0, CrossAxisState::STATE_INVALID, message)); rect.y_ = g_testHeight; rect.width_ = g_curScreenWidth; rect.height_ = g_curScreenHeight; - ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect, 0, message)); + ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect, 0, CrossAxisState::STATE_INVALID, message)); rect.width_ = g_testWidth; rect.height_ = g_testHeight; rect.x_ = g_curScreenWidth - g_testWidth; - ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect, 0, message)); + ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect, 0, CrossAxisState::STATE_INVALID, message)); rect.x_ = g_testWidth; rect.y_ = g_curScreenHeight - g_testHeight; - ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect, 0, message)); + ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect, 0, CrossAxisState::STATE_INVALID, message)); rect.y_ = g_testHeight; } @@ -197,30 +197,30 @@ HWTEST_F(SecCompInfoHelperTest, ParseComponent005, TestSize.Level1) SecCompRect rect = GetDefaultRect(); SecCompRect windowRect = GetDefaultRect(); std::string message; - ASSERT_TRUE(SecCompInfoHelper::CheckRectValid(rect, windowRect, 0, message)); + ASSERT_TRUE(SecCompInfoHelper::CheckRectValid(rect, windowRect, 0, CrossAxisState::STATE_INVALID, message)); windowRect.x_ = g_testWidth + 1; - ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect, 0, message)); + ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect, 0, CrossAxisState::STATE_INVALID, message)); windowRect.x_ = g_testWidth; windowRect.y_ = g_testHeight + 1; - ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect, 0, message)); + ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect, 0, CrossAxisState::STATE_INVALID, message)); windowRect.y_ = g_testHeight; windowRect.width_ = g_testWidth - 1; - ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect, 0, message)); + ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect, 0, CrossAxisState::STATE_INVALID, message)); windowRect.width_ = g_testWidth; windowRect.height_ = g_testHeight - 1; - ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect, 0, message)); + ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect, 0, CrossAxisState::STATE_INVALID, message)); windowRect.height_ = g_testHeight; windowRect.width_ = ServiceTestCommon::TEST_INVALID_DIMENSION; - ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect, 0, message)); + ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect, 0, CrossAxisState::STATE_INVALID, message)); windowRect.width_ = g_testWidth; windowRect.height_ = ServiceTestCommon::TEST_INVALID_DIMENSION; - ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect, 0, message)); + ASSERT_FALSE(SecCompInfoHelper::CheckRectValid(rect, windowRect, 0, CrossAxisState::STATE_INVALID, message)); 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 c96c74426240d6382191f10d8fc0f969c40bab6b..75db0fce98012b4220dc9e09c4ab0862def7688f 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 @@ -72,6 +72,7 @@ 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; } void ServiceTestCommon::BuildSaveComponentJson(nlohmann::json& jsonComponent) @@ -129,6 +130,7 @@ 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; } void ServiceTestCommon::BuildPasteComponentJson(nlohmann::json& jsonComponent) @@ -186,6 +188,7 @@ 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; } } // 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 9233160deb9da38a6c0b7747575b20b50dc239a5..184b1fa6cc22c76295c941fa189e2c94d111d830 100644 --- a/test/fuzztest/security_component/common/fuzz_common.cpp +++ b/test/fuzztest/security_component/common/fuzz_common.cpp @@ -97,6 +97,7 @@ std::string CompoRandomGenerator::ConstructLocationJson() }; jsonComponent[JsonTagConstants::JSON_WINDOW_ID] = 0; jsonComponent[JsonTagConstants::JSON_DISPLAY_ID] = 0; + jsonComponent[JsonTagConstants::JSON_CROSS_AXIS_STATE] = 0; compoJson_ = jsonComponent; return compoJson_.dump(); } @@ -140,6 +141,7 @@ std::string CompoRandomGenerator::ConstructSaveJson() }; jsonComponent[JsonTagConstants::JSON_WINDOW_ID] = 0; jsonComponent[JsonTagConstants::JSON_DISPLAY_ID] = 0; + jsonComponent[JsonTagConstants::JSON_CROSS_AXIS_STATE] = 0; compoJson_ = jsonComponent; return compoJson_.dump(); } @@ -183,6 +185,7 @@ std::string CompoRandomGenerator::ConstructPasteJson() }; jsonComponent[JsonTagConstants::JSON_WINDOW_ID] = 0; jsonComponent[JsonTagConstants::JSON_DISPLAY_ID] = 0; + jsonComponent[JsonTagConstants::JSON_CROSS_AXIS_STATE] = 0; compoJson_ = jsonComponent; return compoJson_.dump(); } diff --git a/test/fuzztest/security_component/mock/display_info.h b/test/fuzztest/security_component/mock/display_info.h index be427e2e1b1a92f33469a40bd51f97a3dffb4b7c..f13fcb4c44115200bff393653af2eacc4108e50e 100644 --- a/test/fuzztest/security_component/mock/display_info.h +++ b/test/fuzztest/security_component/mock/display_info.h @@ -16,6 +16,7 @@ #ifndef SECURITY_COMPONENT_MANAGER_DISPLAY_INFO_MOCK_H #define SECURITY_COMPONENT_MANAGER_DISPLAY_INFO_MOCK_H #include +#include namespace OHOS::Rosen { namespace { @@ -38,6 +39,16 @@ public: { return DEFAULT_SCREEN_SIZE; } + + int32_t GetPhysicalHeight() const + { + return DEFAULT_SCREEN_SIZE; + } + + std::vector GetCreaseRects() const + { + return std::vector(); + } }; } -#endif // SECURITY_COMPONENT_MANAGER_DISPLAY_INFO_MOCK_H \ No newline at end of file +#endif // SECURITY_COMPONENT_MANAGER_DISPLAY_INFO_MOCK_H diff --git a/test/fuzztest/security_component/mock/display_manager.h b/test/fuzztest/security_component/mock/display_manager.h index 2a3fe2d1929458a4d5c645e4bb0807d4ac3a6d6a..7861d6b536222f4b7d70580f73bac5cf6f504e93 100644 --- a/test/fuzztest/security_component/mock/display_manager.h +++ b/test/fuzztest/security_component/mock/display_manager.h @@ -16,6 +16,7 @@ #ifndef SECURITY_COMPONENT_MANAGER_DISPLAY_MANAGER_MOCK_H #define SECURITY_COMPONENT_MANAGER_DISPLAY_MANAGER_MOCK_H #include "display.h" +#include "display_info.h" namespace OHOS::Rosen { class DisplayManager { @@ -35,6 +36,11 @@ public: { return sptr::MakeSptr(); } + + sptr GetCurrentFoldCreaseRegion() + { + return sptr::MakeSptr(); + } }; } -#endif // SECURITY_COMPONENT_MANAGER_DISPLAY_MANAGER_MOCK_H \ No newline at end of file +#endif // SECURITY_COMPONENT_MANAGER_DISPLAY_MANAGER_MOCK_H diff --git a/test/fuzztest/security_component/mock/first_use_dialog.cpp b/test/fuzztest/security_component/mock/first_use_dialog.cpp index 2dd63eef87d2192d199bf852cb5490c3c8decf71..f00a8533a4df8e23bb632b4b5f9b555e4965e142 100644 --- a/test/fuzztest/security_component/mock/first_use_dialog.cpp +++ b/test/fuzztest/security_component/mock/first_use_dialog.cpp @@ -85,8 +85,8 @@ int32_t FirstUseDialog::GrantDialogWaitEntity(int32_t scId) return SC_OK; } -void FirstUseDialog::StartDialogAbility(std::shared_ptr entity, - sptr callerToken, sptr dialogCallback, const uint64_t displayId) +void FirstUseDialog::StartDialogAbility(std::shared_ptr entity, sptr callerToken, + sptr dialogCallback, const uint64_t displayId, const CrossAxisState crossAxisState) { return; } @@ -101,8 +101,8 @@ bool FirstUseDialog::SetFirstUseMap(std::shared_ptr entity) return true; } -int32_t FirstUseDialog::NotifyFirstUseDialog(std::shared_ptr entity, - sptr callerToken, sptr dialogCallback, const uint64_t displayId) +int32_t FirstUseDialog::NotifyFirstUseDialog(std::shared_ptr entity, sptr callerToken, + sptr dialogCallback, const uint64_t displayId, const CrossAxisState crossAxisState) { return SC_OK; } @@ -113,4 +113,4 @@ void FirstUseDialog::Init(std::shared_ptr secHandler) } } // namespace SecurityComponent } // namespace Security -} // namespace OHOS \ No newline at end of file +} // namespace OHOS