From 372c0ab091f9f88b57d424f92e21fe54cb836745 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E9=9D=92=E9=9D=92?= Date: Tue, 29 Jul 2025 15:55:33 +0800 Subject: [PATCH] =?UTF-8?q?screenlock=E9=9A=94=E7=A6=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王青青 --- window_scene/screen_session_manager/BUILD.gn | 10 +++++++++- .../include/screen_power_utils.h | 2 ++ .../screen_session_manager/src/screen_power_utils.cpp | 8 ++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/window_scene/screen_session_manager/BUILD.gn b/window_scene/screen_session_manager/BUILD.gn index 4c7311cbc7..619592dd56 100644 --- a/window_scene/screen_session_manager/BUILD.gn +++ b/window_scene/screen_session_manager/BUILD.gn @@ -136,7 +136,6 @@ ohos_shared_library("screen_session_manager") { "libxml2:libxml2", "safwk:system_ability_fwk", "samgr:samgr_proxy", - "screenlock_mgr:screenlock_client", ] defines = [] @@ -267,6 +266,15 @@ ohos_shared_library("screen_session_manager") { print("window manager screen multi usr ability is disabled.") } + if (defined(global_parts_info) && + defined(global_parts_info.theme_screenlock_mgr)) { + defines += [ "WM_SCREENLOCK_MANAGER_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + print("window manager screen lock manager ability is enabled.") + } else { + print("window manager screen lock manager ability is disabled.") + } + innerapi_tags = [ "platformsdk" ] part_name = "window_manager" subsystem_name = "window" diff --git a/window_scene/screen_session_manager/include/screen_power_utils.h b/window_scene/screen_session_manager/include/screen_power_utils.h index ab6bedba2a..7b95f8535d 100644 --- a/window_scene/screen_session_manager/include/screen_power_utils.h +++ b/window_scene/screen_session_manager/include/screen_power_utils.h @@ -32,7 +32,9 @@ public: private: static std::mutex powerTimingMutex_; +#ifdef WM_SCREENLOCK_MANAGER_ENABLED static std::mutex powerLockMutex_; +#endif static bool isEnablePowerForceTimingOut_; }; } // Rosen diff --git a/window_scene/screen_session_manager/src/screen_power_utils.cpp b/window_scene/screen_session_manager/src/screen_power_utils.cpp index 98abcb279b..a75850be7c 100644 --- a/window_scene/screen_session_manager/src/screen_power_utils.cpp +++ b/window_scene/screen_session_manager/src/screen_power_utils.cpp @@ -15,7 +15,9 @@ #include "screen_power_utils.h" #include "power_mgr_client.h" +#ifdef WM_SCREENLOCK_MANAGER_ENABLED #include "screenlock_manager.h" +#endif #include "screen_session_manager.h" #include "window_manager_hilog.h" @@ -25,7 +27,9 @@ namespace OHOS { namespace Rosen { std::mutex ScreenPowerUtils::powerTimingMutex_; +#ifdef WM_SCREENLOCK_MANAGER_ENABLED std::mutex ScreenPowerUtils::powerLockMutex_; +#endif bool ScreenPowerUtils::isEnablePowerForceTimingOut_ = false; void ScreenPowerUtils::EnablePowerForceTimingOut() @@ -77,6 +81,9 @@ void ScreenPowerUtils::DisablePowerForceTimingOut() void ScreenPowerUtils::LightAndLockScreen(const std::string& detail) { +#ifndef WM_SCREENLOCK_MANAGER_ENABLED + return; +#else std::lock_guard lock(powerLockMutex_); auto& powerMgrClient = PowerMgrClient::GetInstance(); auto lockManager = OHOS::ScreenLock::ScreenLockManager::GetInstance(); @@ -95,6 +102,7 @@ void ScreenPowerUtils::LightAndLockScreen(const std::string& detail) IPCSkeleton::SetCallingIdentity(identity); TLOGI(WmsLogTag::DMS, "wakeupRet: %{public}d, lockRet: %{public}d", wakeupRet, lockRet); } +#endif } bool ScreenPowerUtils::GetEnablePowerForceTimingOut() { -- Gitee