diff --git a/window_scene/session/host/include/session.h b/window_scene/session/host/include/session.h index b3ceea1827c68b5e9f666d5d5108133d9dfc859b..f79beaa73a562224ffb8b19a0f207285163e619c 100644 --- a/window_scene/session/host/include/session.h +++ b/window_scene/session/host/include/session.h @@ -547,6 +547,11 @@ public: std::optional GetClientDragEnable() const; std::shared_ptr GetEventHandler() const; + /** + * Screen Lock + */ + bool IsScreenLockWindow() const; + protected: class SessionLifeCycleTask : public virtual RefBase { public: @@ -842,6 +847,11 @@ private: * Window Layout */ std::optional clientDragEnable_; + + /** + * Screen Lock + */ + bool isScreenLockWindow_ { false }; }; } // namespace OHOS::Rosen diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 40b94fcac43159245f8e7a981b17e3a1381619c6..14e456797fab67f07e36ac3e2979873bc448d22d 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -213,11 +213,6 @@ bool SceneSession::IsShowOnLockScreen(uint32_t lockScreenZOrder) return false; } - if (!GetStateFromManager(ManagerState::MANAGER_STATE_SCREEN_LOCKED)) { - TLOGD(WmsLogTag::WMS_UIEXT, "UIExtOnLock: not in lock screen"); - return false; - } - // current window on lock screen jurded by zorder if (zOrder_ >= lockScreenZOrder) { TLOGI(WmsLogTag::WMS_UIEXT, "UIExtOnLock: zOrder_ is no more than lockScreenZOrder"); diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index 2a2bff423cc93f333d38ff14cf81dedf4b36dbc7..e71eea0f62fa7e46bc862e5531f1a17f80cd22a9 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -15,6 +15,8 @@ #include "session/host/include/session.h" +#include + #include "ability_info.h" #include "input_manager.h" #include "key_event.h" @@ -96,6 +98,12 @@ Session::Session(const SessionInfo& info) : sessionInfo_(info) TLOGI(WmsLogTag::WMS_FOCUS, "focusedOnShow:%{public}d", focusedOnShow); SetFocusedOnShow(focusedOnShow); } + + static const std::regex pattern(R"(^SCBScreenLock[0-9]+$)"); + if (std::regex_match(info.bundleName_, pattern)) { + TLOGD(WmsLogTag::DEFAULT, "bundleName: %{public}s", info.bundleName_.c_str()); + isScreenLockWindow_ = true; + } } Session::~Session() @@ -1411,6 +1419,11 @@ std::optional Session::GetClientDragEnable() const return clientDragEnable_; } +bool Session::IsScreenLockWindow() const +{ + return isScreenLockWindow_; +} + void Session::NotifyForegroundInteractiveStatus(bool interactive) { SetForegroundInteractiveStatus(interactive); diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 0e10c9b44ab2ea26927d77aeebc04ba3ebe0d2dc..d9eb8f74298e4de071a913dec15ec1f3355afb46 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -1455,15 +1455,8 @@ uint32_t SceneSessionManager::GetLockScreenZorder() { std::shared_lock lock(sceneSessionMapMutex_); for (const auto& [persistentId, session] : sceneSessionMap_) { - if (session && (session->GetWindowType() == WindowType::WINDOW_TYPE_KEYGUARD)) { - static const std::regex pattern(R"(^SCBScreenLock[0-9]+$)"); - auto& bundleName = session->GetSessionInfo().bundleName_; - if (!std::regex_match(bundleName, pattern)) { - TLOGD(WmsLogTag::WMS_UIEXT, " bundleName: %{public}s", bundleName.c_str()); - continue; - } - TLOGI(WmsLogTag::WMS_UIEXT, "UIExtOnLock: found window %{public}d, bundleName: %{public}s", persistentId, - bundleName.c_str()); + if (session && session->IsScreenLockWindow()) { + TLOGI(WmsLogTag::WMS_UIEXT, "UIExtOnLock: found window %{public}d", persistentId); return session->GetZOrder(); } } @@ -1483,6 +1476,11 @@ WMError SceneSessionManager::CheckUIExtensionCreation(int32_t windowId, uint32_t } pid = sceneSession->GetCallingPid(); + if (!sceneSession->GetStateFromManager(ManagerState::MANAGER_STATE_SCREEN_LOCKED)) { + TLOGND(WmsLogTag::WMS_UIEXT, "UIExtOnLock: not in lock screen"); + return WMError::WM_OK; + } + // 1. check window whether can show on main window if (!sceneSession->IsShowOnLockScreen(GetLockScreenZorder())) { TLOGNI(WmsLogTag::WMS_UIEXT, "UIExtOnLock: not called on lock screen");