diff --git a/window_scene/common/include/window_session_property.h b/window_scene/common/include/window_session_property.h index 8374e5e13b303c2299bb988b018b31f71e8bd28b..0e20162f838a9cc8eec814a31ed502bb22f2bab2 100755 --- a/window_scene/common/include/window_session_property.h +++ b/window_scene/common/include/window_session_property.h @@ -219,11 +219,16 @@ struct SystemSessionConfig : public Parcelable { bool isStretchable_ = false; WindowMode defaultWindowMode_ = WindowMode::WINDOW_MODE_FULLSCREEN; KeyboardAnimationConfig keyboardAnimationConfig_; - uint32_t maxFloatingWindowSize_ = UINT32_MAX; - uint32_t miniWidthOfMainWindow_ = 0; - uint32_t miniHeightOfMainWindow_ = 0; - uint32_t miniWidthOfSubWindow_ = 0; - uint32_t miniHeightOfSubWindow_ = 0; + // 1920: default max window size + uint32_t maxFloatingWindowSize_ = 1920; + // 320: default minWidth main window size + uint32_t miniWidthOfMainWindow_ = 320; + // 240: default minHeight main window size + uint32_t miniHeightOfMainWindow_ = 240; + // 320: default minWidth sub window size + uint32_t miniWidthOfSubWindow_ = 320; + // 240: default minHeight sub window size + uint32_t miniHeightOfSubWindow_ = 240; bool backgroundswitch = false; virtual bool Marshalling(Parcel& parcel) const override diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp index 6707b16def0fc61e6b6af257a13f1a1c2771d5a8..d381ca3abdb595e16df685bbc99e0ba8a88285db 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp @@ -98,6 +98,7 @@ napi_value JsSceneSessionManager::Init(napi_env env, napi_value exportObj) BindNativeFunction(env, exportObj, "getWindowSceneConfig", moduleName, JsSceneSessionManager::GetWindowSceneConfig); BindNativeFunction(env, exportObj, "processBackEvent", moduleName, JsSceneSessionManager::ProcessBackEvent); + BindNativeFunction(env, exportObj, "checkSceneZOrder", moduleName, JsSceneSessionManager::CheckSceneZOrder); BindNativeFunction(env, exportObj, "updateFocus", moduleName, JsSceneSessionManager::UpdateFocus); BindNativeFunction(env, exportObj, "switchUser", moduleName, JsSceneSessionManager::SwitchUser); BindNativeFunction(env, exportObj, "requestSceneSessionByCall", moduleName, @@ -456,6 +457,13 @@ napi_value JsSceneSessionManager::ProcessBackEvent(napi_env env, napi_callback_i return (me != nullptr) ? me->OnProcessBackEvent(env, info) : nullptr; } +napi_value JsSceneSessionManager::CheckSceneZOrder(napi_env env, napi_callback_info info) +{ + WLOGD("[NAPI]CheckSceneZOrder"); + JsSceneSessionManager* me = CheckParamsAndGetThis(env, info); + return (me != nullptr) ? me->OnCheckSceneZOrder(env, info) : nullptr; +} + napi_value JsSceneSessionManager::SwitchUser(napi_env env, napi_callback_info info) { WLOGFI("[NAPI]SwitchUser"); @@ -801,6 +809,12 @@ napi_value JsSceneSessionManager::OnProcessBackEvent(napi_env env, napi_callback return NapiGetUndefined(env); } +napi_value JsSceneSessionManager::OnCheckSceneZOrder(napi_env env, napi_callback_info info) +{ + SceneSessionManager::GetInstance().CheckSceneZOrder(); + return NapiGetUndefined(env); +} + napi_value JsSceneSessionManager::OnGetAllAbilityInfos(napi_env env, napi_callback_info info) { size_t argc = 4; diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.h b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.h index d4b84f9c87ccab644cfabf097e18932fee14be07..80585cc83445b2d0f591f6b0d718de01c50a05c1 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.h +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.h @@ -50,6 +50,7 @@ public: static napi_value RegisterCallback(napi_env env, napi_callback_info info); static napi_value GetWindowSceneConfig(napi_env env, napi_callback_info info); static napi_value ProcessBackEvent(napi_env env, napi_callback_info info); + static napi_value CheckSceneZOrder(napi_env env, napi_callback_info info); static napi_value UpdateFocus(napi_env env, napi_callback_info info); static napi_value SwitchUser(napi_env env, napi_callback_info info); static napi_value GetSessionSnapshotFilePath(napi_env env, napi_callback_info info); @@ -89,6 +90,7 @@ private: napi_value OnChangeUIAbilityVisibilityBySCB(napi_env env, napi_callback_info info); napi_value OnGetWindowSceneConfig(napi_env env, napi_callback_info info); napi_value OnProcessBackEvent(napi_env env, napi_callback_info info); + napi_value OnCheckSceneZOrder(napi_env env, napi_callback_info info); napi_value OnUpdateFocus(napi_env env, napi_callback_info info); napi_value OnSwitchUser(napi_env env, napi_callback_info info); napi_value OnGetSessionSnapshotFilePath(napi_env env, napi_callback_info info); diff --git a/window_scene/session/host/include/main_session.h b/window_scene/session/host/include/main_session.h index 1108fe97b2d3ecaa372e1fe5ae95268fe9c9d180..4ec4354134a96d402de65c7aa95da5832777df3d 100644 --- a/window_scene/session/host/include/main_session.h +++ b/window_scene/session/host/include/main_session.h @@ -32,6 +32,7 @@ public: WSError TransferKeyEvent(const std::shared_ptr& keyEvent) override; WSError SetTopmost(bool topmost) override; bool IsTopmost() const override; + void RectCheck(uint32_t curWidth, uint32_t curHeight) override; protected: void UpdatePointerArea(const WSRect& rect) override; diff --git a/window_scene/session/host/include/session.h b/window_scene/session/host/include/session.h index 3a72762049ac0532a454c7acc729615d92038cec..a86729f678090bc81a4e94b444b87dceba936c0e 100644 --- a/window_scene/session/host/include/session.h +++ b/window_scene/session/host/include/session.h @@ -274,6 +274,7 @@ public: bool NeedNotify() const; void SetNeedNotify(bool needNotify); bool GetFocusable() const; + bool IsFocused() const; WSError SetTouchable(bool touchable); bool GetTouchable() const; void SetForceTouchable(bool touchable); @@ -381,6 +382,11 @@ public: void SetAttachState(bool isAttach); void RegisterDetachCallback(const sptr& callback); void RegisterWindowBackHomeCallback(const std::function& callback) {}; + SystemSessionConfig GetSystemConfig() const; + void RectCheckProcess(); + virtual void RectCheck(uint32_t curWidth, uint32_t curHeight) {}; + void RectSizeCheckProcess(uint32_t curWidth, uint32_t curHeight, uint32_t minWidth, + uint32_t minHeight, uint32_t maxFloatingWindowSize); protected: class SessionLifeCycleTask : public virtual RefBase { diff --git a/window_scene/session/host/include/sub_session.h b/window_scene/session/host/include/sub_session.h index 4a6791b72fd3aebee7ca15a04f43fa811575915e..7835983dd623551a5454f9b51c24a7aeaf3e4ff3 100644 --- a/window_scene/session/host/include/sub_session.h +++ b/window_scene/session/host/include/sub_session.h @@ -33,6 +33,7 @@ public: WSError TransferKeyEvent(const std::shared_ptr& keyEvent) override; int32_t GetMissionId() const override; + void RectCheck(uint32_t curWidth, uint32_t curHeight) override; protected: void UpdatePointerArea(const WSRect& rect) override; bool CheckPointerEventDispatch(const std::shared_ptr& pointerEvent) const override; diff --git a/window_scene/session/host/include/system_session.h b/window_scene/session/host/include/system_session.h index 96213823feef4ad87b5dea7a88ec65126bc0423d..4b72a6ad91a920d96331c2377ec612551e95b3ad 100644 --- a/window_scene/session/host/include/system_session.h +++ b/window_scene/session/host/include/system_session.h @@ -38,6 +38,7 @@ public: WSError NotifyClientToUpdateRect(std::shared_ptr rsTransaction) override; int32_t GetMissionId() const override; + void RectCheck(uint32_t curWidth, uint32_t curHeight) override; protected: bool CheckKeyEventDispatch(const std::shared_ptr& keyEvent) const; diff --git a/window_scene/session/host/src/main_session.cpp b/window_scene/session/host/src/main_session.cpp index 5863e4d62bd2cedb8a6cbf4f8215640bd4a7bf18..6c13253f5b99c864f941af561b82e7b5db99657b 100644 --- a/window_scene/session/host/src/main_session.cpp +++ b/window_scene/session/host/src/main_session.cpp @@ -194,4 +194,12 @@ bool MainSession::IfNotNeedAvoidKeyBoardForSplit() } return true; } + +void MainSession::RectCheck(uint32_t curWidth, uint32_t curHeight) +{ + uint32_t minWidth = GetSystemConfig().miniWidthOfMainWindow_; + uint32_t minHeight = GetSystemConfig().miniHeightOfMainWindow_; + uint32_t maxFloatingWindowSize = GetSystemConfig().maxFloatingWindowSize_; + RectSizeCheckProcess(curWidth, curHeight, minWidth, minHeight, maxFloatingWindowSize); +} } // namespace OHOS::Rosen diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index b5a678aaf41abce3c5f56ba173bb26e9b96ab34f..9a85d730e78539412360d5f68a4ec6f5cfd7b460 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -35,6 +35,7 @@ #include "parameters.h" #include #include "hitrace_meter.h" +#include "screen_session_manager/include/screen_session_manager_client.h" namespace OHOS::Rosen { namespace { @@ -422,6 +423,11 @@ bool Session::GetFocusable() const return true; } +bool Session::IsFocused() const +{ + return isFocused_; +} + void Session::SetNeedNotify(bool needNotify) { needNotify_ = needNotify; @@ -736,6 +742,7 @@ WSError Session::UpdateRect(const WSRect& rect, SizeChangeReason reason, winRect_ = rect; if (sessionStage_ != nullptr) { sessionStage_->UpdateRect(rect, reason, rsTransaction); + RectCheckProcess(); } else { WLOGFE("sessionStage_ is nullptr"); } @@ -1977,6 +1984,41 @@ sptr Session::GetSessionProperty() const return property_; } +void Session::RectSizeCheckProcess(uint32_t curWidth, uint32_t curHeight, uint32_t minWidth, + uint32_t minHeight, uint32_t maxFloatingWindowSize) +{ + if ((curWidth < minWidth) || (curWidth > maxFloatingWindowSize) || + (curHeight < minHeight) || (curHeight > maxFloatingWindowSize)) { + TLOGE(WmsLogTag::WMS_LAYOUT, "RectCheck err sessionID: %{public}d rect %{public}s", + GetPersistentId(), GetSessionRect().ToString().c_str()); + } +} + +void Session::RectCheckProcess() +{ + if (!(IsSessionForeground() || isVisible_)) { + return; + } + auto displayId = GetSessionProperty()->GetDisplayId(); + std::map screensProperties = + Rosen::ScreenSessionManagerClient::GetInstance().GetAllScreensProperties(); + if (screensProperties.find(displayId) == screensProperties.end()) { + return; + } + auto screenProperty = screensProperties[displayId]; + float density = screenProperty.GetDensity(); + if (!NearZero(density) && (GetSessionRect().height_ != 0)) { + uint32_t curWidth = static_cast(GetSessionRect().width_ / density); + uint32_t curHeight = static_cast(GetSessionRect().height_ / density); + float ratio = GetAspectRatio(); + float actRatio = static_cast(curWidth) / curHeight; + if ((ratio != 0) && !NearEqual(ratio, actRatio)) { + TLOGE(WmsLogTag::WMS_LAYOUT, "RectCheck err ratio %{public}f != actRatio: %{public}f", ratio, actRatio); + } + RectCheck(curWidth, curHeight); + } +} + void Session::SetSessionRect(const WSRect& rect) { if (winRect_ == rect) { @@ -1985,6 +2027,7 @@ void Session::SetSessionRect(const WSRect& rect) } winRect_ = rect; isDirty_ = true; + RectCheckProcess(); } WSRect Session::GetSessionRect() const @@ -2031,6 +2074,11 @@ void Session::SetSystemConfig(const SystemSessionConfig& systemConfig) systemConfig_ = systemConfig; } +SystemSessionConfig Session::GetSystemConfig() const +{ + return systemConfig_; +} + void Session::SetSnapshotScale(const float snapshotScale) { snapshotScale_ = snapshotScale; diff --git a/window_scene/session/host/src/sub_session.cpp b/window_scene/session/host/src/sub_session.cpp index bdbc9c2e1545b0d8ed521fb35f7899543914d2be..d6d0057daad0c5f1b9ce83620dc724f37502e9d9 100644 --- a/window_scene/session/host/src/sub_session.cpp +++ b/window_scene/session/host/src/sub_session.cpp @@ -185,4 +185,12 @@ bool SubSession::IfNotNeedAvoidKeyBoardForSplit() } return true; } + +void SubSession::RectCheck(uint32_t curWidth, uint32_t curHeight) +{ + uint32_t minWidth = GetSystemConfig().miniWidthOfSubWindow_; + uint32_t minHeight = GetSystemConfig().miniHeightOfSubWindow_; + uint32_t maxFloatingWindowSize = GetSystemConfig().maxFloatingWindowSize_; + RectSizeCheckProcess(curWidth, curHeight, minWidth, minHeight, maxFloatingWindowSize); +} } // namespace OHOS::Rosen diff --git a/window_scene/session/host/src/system_session.cpp b/window_scene/session/host/src/system_session.cpp index ae7554948357454395f16f2df7b3ef693e0c5172..1f81b658e53485a7330f07c83fc3557039e5e5ce 100644 --- a/window_scene/session/host/src/system_session.cpp +++ b/window_scene/session/host/src/system_session.cpp @@ -26,6 +26,9 @@ namespace { constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_WINDOW, "SystemSession" }; } // namespace +constexpr uint32_t MIN_SYSTEM_WINDOW_WIDTH = 5; +constexpr uint32_t MIN_SYSTEM_WINDOW_HEIGHT = 5; + SystemSession::SystemSession(const SessionInfo& info, const sptr& specificCallback) : SceneSession(info, specificCallback) { @@ -306,4 +309,12 @@ bool SystemSession::NeedSystemPermission(WindowType type) type == WindowType::WINDOW_TYPE_DRAGGING_EFFECT || type == WindowType::WINDOW_TYPE_APP_LAUNCHING || type == WindowType::WINDOW_TYPE_PIP); } + +void SystemSession::RectCheck(uint32_t curWidth, uint32_t curHeight) +{ + uint32_t minWidth = MIN_SYSTEM_WINDOW_WIDTH; + uint32_t minHeight = MIN_SYSTEM_WINDOW_HEIGHT; + uint32_t maxFloatingWindowSize = GetSystemConfig().maxFloatingWindowSize_; + RectSizeCheckProcess(curWidth, curHeight, minWidth, minHeight, maxFloatingWindowSize); +} } // namespace OHOS::Rosen diff --git a/window_scene/session_manager/BUILD.gn b/window_scene/session_manager/BUILD.gn index e1aaf8f97d95a8283433be2a86cf72bd55530351..df77eaf5417ed4f45643d383438e8040bed4a9e2 100644 --- a/window_scene/session_manager/BUILD.gn +++ b/window_scene/session_manager/BUILD.gn @@ -65,6 +65,7 @@ ohos_shared_library("scene_session_manager") { } sources = [ "../../wm/src/zidl/window_manager_agent_proxy.cpp", + "src/anomaly_detection.cpp", "src/distributed_client.cpp", "src/extension_session_manager.cpp", "src/scb_session_handler.cpp", diff --git a/window_scene/session_manager/include/anomaly_detection.h b/window_scene/session_manager/include/anomaly_detection.h new file mode 100644 index 0000000000000000000000000000000000000000..76f981eb87ddbe6b23cd56eccc228ace5859f928 --- /dev/null +++ b/window_scene/session_manager/include/anomaly_detection.h @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ROSEN_WINDOW_ANOMALY_DETECTION_H +#define OHOS_ROSEN_WINDOW_ANOMALY_DETECTION_H + +#include "session/host/include/scene_session.h" + +namespace OHOS { +namespace Rosen { + +enum class WindowDFXHelperType : uint32_t { + WINDOW_RECT_CHECK, + WINDOW_ZORDER_CHECK, + WINDOW_FOCUS_CHECK, +}; + +class AnomalyDetection { +public: + static void SceneZOrderCheckProcess(); + static void FocusCheckProcess(int32_t focusedId, int32_t nextId); +}; +} // namespace Rosen +} // namespace OHOS +#endif // OHOS_ROSEN_WINDOW_ANOMALY_DETECTION_H \ No newline at end of file diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index f8d66b8276b1ae026c571f46267acf13cd2ae6a9..1aa68c3d13a41e979cfb227f83d0f78db923512b 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -103,6 +103,7 @@ public: class SceneSessionManager : public SceneSessionManagerStub { WM_DECLARE_SINGLE_INSTANCE_BASE(SceneSessionManager) public: + friend class AnomalyDetection; bool IsSessionVisible(const sptr& session); sptr RequestSceneSession(const SessionInfo& sessionInfo, sptr property = nullptr); @@ -288,6 +289,7 @@ public: int32_t parentId) override; WSError AddOrRemoveSecureSession(int32_t persistentId, bool shouldHide) override; WSError AddOrRemoveSecureExtSession(int32_t persistentId, int32_t parentId, bool shouldHide) override; + void CheckSceneZOrder(); int32_t StartUIAbilityBySCB(sptr& abilitySessionInfo); int32_t StartUIAbilityBySCB(sptr& sceneSessions); int32_t ChangeUIAbilityVisibilityBySCB(sptr& sceneSessions, bool visibility); diff --git a/window_scene/session_manager/src/anomaly_detection.cpp b/window_scene/session_manager/src/anomaly_detection.cpp new file mode 100644 index 0000000000000000000000000000000000000000..20b56f0136094db2f387a69bae2c45dbcbd360c8 --- /dev/null +++ b/window_scene/session_manager/src/anomaly_detection.cpp @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "anomaly_detection.h" + +#include "dfx_hisysevent.h" +#include "interfaces/include/ws_common.h" +#include "session_manager/include/scene_session_manager.h" +#include "window_helper.h" +#include "screen_session_manager/include/screen_session_manager_client.h" + +namespace OHOS { +namespace Rosen { +namespace { +constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_WINDOW, "AnomalyDetection" }; +} + +void AnomalyDetection::SceneZOrderCheckProcess() +{ + bool keyGuardFlag = false; + uint32_t curZOrder = 0; + auto func = [&curZOrder, &keyGuardFlag](sptr session) { + if ((session == nullptr) || (!SceneSessionManager::GetInstance().IsSessionVisible(session))) { + return false; + } + // check zorder = 0 + if (session->GetZOrder() == 0) { + TLOGE(WmsLogTag::WMS_FOCUS, "ZOrderCheck err, zorder 0"); + } + // repetitive zorder + if (session->GetZOrder() == curZOrder) { + TLOGE(WmsLogTag::WMS_FOCUS, "ZOrderCheck err, repetitive zorder %{public}d", session->GetZOrder()); + } + curZOrder = session->GetZOrder(); + // callingSession check for input method + if (session->GetWindowType() == WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT) { + uint32_t callingWindowId = session->GetSessionProperty()->GetCallingSessionId(); + const auto& callingSession = + SceneSessionManager::GetInstance().GetSceneSession(static_cast(callingWindowId)); + if ((callingSession != nullptr) && (callingSession->GetZOrder() > session->GetZOrder())) { + TLOGE(WmsLogTag::WMS_FOCUS, "ZOrderCheck err, callingSession: %{public}d curSession: %{public}d", + callingSession->GetZOrder(), session->GetZOrder()); + } + } + // subWindow/dialogWindow + if (WindowHelper::IsSubWindow(session->GetWindowType()) || + session->GetWindowType() == WindowType::WINDOW_TYPE_DIALOG) { + auto mainSession = session->GetParentSession(); + if ((mainSession != nullptr) && (session->GetZOrder() < mainSession->GetZOrder())) { + TLOGE(WmsLogTag::WMS_FOCUS, "ZOrderCheck err, subSession %{public}d mainSession %{public}d", + session->GetZOrder(), mainSession->GetZOrder()); + } + } + if (session->GetWindowType() == WindowType::WINDOW_TYPE_KEYGUARD) { + keyGuardFlag = true; + return false; + } + if (keyGuardFlag && (!session->IsShowWhenLocked())) { + TLOGE(WmsLogTag::WMS_FOCUS, "ZOrderCheck err %{public}d IsShowWhenLocked", session->GetZOrder()); + } + return false; + }; + SceneSessionManager::GetInstance().TraverseSessionTree(func, false); +} + +void AnomalyDetection::FocusCheckProcess(int32_t focusedId, int32_t nextId) +{ + if (nextId == INVALID_SESSION_ID) { + TLOGE(WmsLogTag::WMS_FOCUS, "FocusCheck err: invalid id, focusedId:%{public}d nextId:%{public}d", + focusedId, nextId); + } + bool focusSessionFlag = false; + auto func = [&focusSessionFlag](sptr session) { + if (session == nullptr) { + return false; + } + if (session->IsFocused()) { + focusSessionFlag = true; + return false; + } + if (focusSessionFlag && session->GetBlockingFocus() && + SceneSessionManager::GetInstance().IsSessionVisible(session)) { + TLOGE(WmsLogTag::WMS_FOCUS, "FocusCheck err: blockingFocus, sessionId:%{public}d", + session->GetPersistentId()); + } + return false; + }; + SceneSessionManager::GetInstance().TraverseSessionTree(func, false); +} +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index f358315fe9481dbb5cab4ed981b7fa63a8eeae73..acc5b0d881891461fb5fab31c4cff37a20ea4a49 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -95,6 +95,7 @@ #include "window_visibility_info.h" #include "window_drawing_content_info.h" +#include "anomaly_detection.h" #ifdef MEMMGR_WINDOW_ENABLE #include "mem_mgr_client.h" #include "mem_mgr_window_info.h" @@ -3973,6 +3974,7 @@ WSError SceneSessionManager::ShiftFocus(sptr& nextSession) UpdateFocusStatus(nextSession, true); bool scbPrevFocus = focusedSession && focusedSession->GetSessionInfo().isSystem_; bool scbCurrFocus = nextSession && nextSession->GetSessionInfo().isSystem_; + AnomalyDetection::FocusCheckProcess(focusedId, nextId); if (!scbPrevFocus && scbCurrFocus) { if (notifySCBAfterFocusedFunc_ != nullptr) { notifySCBAfterFocusedFunc_(); @@ -7563,6 +7565,14 @@ WMError SceneSessionManager::GetCallingWindowRect(int32_t persistentId, Rect& re return WMError::WM_OK; } +void SceneSessionManager::CheckSceneZOrder() +{ + auto task = [this]() { + AnomalyDetection::SceneZOrderCheckProcess(); + }; + taskScheduler_->PostAsyncTask(task, "CheckSceneZOrder"); +} + WMError SceneSessionManager::GetWindowBackHomeStatus(bool &isBackHome) { if (!SessionPermission::IsSACalling()) {