From f36bbd991f130841512f8ee918f8369dd66d9050 Mon Sep 17 00:00:00 2001 From: zhaoqi209 <18872749497@163.com> Date: Tue, 26 Aug 2025 22:47:56 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E8=87=AA=E7=94=B1=E5=A4=9A=E7=AA=97?= =?UTF-8?q?=E9=94=81=E5=B1=8F=E4=B9=8B=E4=B8=8A=E4=B8=8D=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E6=A0=87=E9=A2=98=E6=A0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhaoqi209 <18872749497@163.com> --- .../common/include/window_session_property.h | 5 +++ .../common/src/window_session_property.cpp | 10 ++++++ .../js_scene_session_manager.cpp | 31 ------------------- .../js_scene_session_manager.h | 4 --- .../include/zidl/session_stage_interface.h | 10 ++++++ .../zidl/session_stage_ipc_interface_code.h | 1 + .../include/zidl/session_stage_proxy.h | 1 + .../include/zidl/session_stage_stub.h | 1 + .../src/scene_session_manager.cpp | 7 ----- 9 files changed, 28 insertions(+), 42 deletions(-) diff --git a/window_scene/common/include/window_session_property.h b/window_scene/common/include/window_session_property.h index 14ecb65fc9..b6c955743b 100755 --- a/window_scene/common/include/window_session_property.h +++ b/window_scene/common/include/window_session_property.h @@ -350,6 +350,9 @@ public: void SetExclusivelyHighlighted(bool isExclusivelyHighlighted); mutable std::mutex windowMaskMutex_; + void SetScreenLocked(bool isScreenLocked); + bool GetScreenLocked() const; + private: void setTouchHotAreasInner(const std::vector& rects, std::vector& touchHotAreas); bool MarshallingTouchHotAreasInner(const std::vector& touchHotAreas, Parcel& parcel) const; @@ -595,6 +598,8 @@ private: * Window Transition Animation For PC */ std::unordered_map> transitionAnimationConfig_; + + bool isScreenLocked_ { false }; }; class CompatibleModeProperty : public Parcelable { diff --git a/window_scene/common/src/window_session_property.cpp b/window_scene/common/src/window_session_property.cpp index 761ba1ae98..b2849ebe44 100755 --- a/window_scene/common/src/window_session_property.cpp +++ b/window_scene/common/src/window_session_property.cpp @@ -2590,5 +2590,15 @@ void SystemSessionConfig::ConvertSupportUIExtensionSubWindow(const std::string& { supportUIExtensionSubWindow_ = StringUtil::ConvertStringToBool(itemValue); } + +void WindowSessionProperty::SetScreenLocked(bool isScreenLocked) +{ + isScreenLocked_ = isScreenLocked; +} + +bool WindowSessionProperty::GetScreenLocked() const +{ + return isScreenLocked_; +} } // namespace Rosen } // namespace OHOS \ No newline at end of file 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 e9dff81a97..3f9ed348e2 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 @@ -324,8 +324,6 @@ napi_value JsSceneSessionManager::Init(napi_env env, napi_value exportObj) JsSceneSessionManager::SetUIEffectControllerAliveInUI); BindNativeFunction(env, exportObj, "setPiPSettingSwitchStatus", moduleName, JsSceneSessionManager::SetPiPSettingSwitchStatus); - BindNativeFunction(env, exportObj, "UpdateSystemDecorEnable", moduleName, - JsSceneSessionManager::UpdateSystemDecorEnable); BindNativeFunction(env, exportObj, "applyFeatureConfig", moduleName, JsSceneSessionManager::ApplyFeatureConfig); return NapiGetUndefined(env); @@ -5327,33 +5325,4 @@ napi_value JsSceneSessionManager::OnSetPiPSettingSwitchStatus(napi_env env, napi SceneSessionManager::GetInstance().SetPiPSettingSwitchStatus(switchStatus); return NapiGetUndefined(env); } - -napi_value JsSceneSessionManager::UpdateSystemDecorEnable(napi_env env, napi_callback_info info) -{ - TLOGI(WmsLogTag::WMS_DECOR, "in"); - JsSceneSessionManager* me = CheckParamsAndGetThis(env, info); - return (me != nullptr) ? me->OnUpdateSystemDecorEnable(env, info) : nullptr; -} - -napi_value JsSceneSessionManager::OnUpdateSystemDecorEnable(napi_env env, napi_callback_info info) -{ - size_t argc = ARGC_ONE; - napi_value argv[ARGC_ONE] = { nullptr }; - napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); - if (argc != ARGC_ONE) { - TLOGE(WmsLogTag::WMS_DECOR, "Argc is invalid: %{public}zu", argc); - napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_INVALID_PARAM), - "Input parameter is missing or invalid")); - return NapiGetUndefined(env); - } - bool enable = true; - if (!ConvertFromJsValue(env, argv[0], enable)) { - TLOGE(WmsLogTag::WMS_DECOR, "Failed to convert parameter to enable"); - napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_INVALID_PARAM), - "Input parameter is missing or invalid")); - return NapiGetUndefined(env); - } - SceneSessionManager::GetInstance().UpdateSystemDecorEnable(enable); - return NapiGetUndefined(env); -} } // namespace OHOS::Rosen \ No newline at end of file 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 8e0172a96c..d06130ea2d 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 @@ -178,8 +178,6 @@ public: */ static napi_value SetPiPSettingSwitchStatus(napi_env env, napi_callback_info info); - static napi_value UpdateSystemDecorEnable(napi_env env, napi_callback_info info); - private: napi_value OnSetBehindWindowFilterEnabled(napi_env env, napi_callback_info info); napi_value OnRegisterCallback(napi_env env, napi_callback_info info); @@ -404,8 +402,6 @@ private: */ napi_value OnSupportSnapshotAllSessionStatus(napi_env env, napi_callback_info info); napi_value OnSupportPreloadStartingWindow(napi_env env, napi_callback_info info); - - napi_value OnUpdateSystemDecorEnable(napi_env env, napi_callback_info info); }; } // namespace OHOS::Rosen diff --git a/window_scene/session/container/include/zidl/session_stage_interface.h b/window_scene/session/container/include/zidl/session_stage_interface.h index c08cbf3016..1d53be9afc 100644 --- a/window_scene/session/container/include/zidl/session_stage_interface.h +++ b/window_scene/session/container/include/zidl/session_stage_interface.h @@ -287,6 +287,16 @@ public: * @return Returns WSError::WS_OK if called success, otherwise failed. */ virtual WSError SendFbActionEvent(const std::string& action) = 0; + + /** + * @brief Set screen lock status . + * + * Set screen lock status. Such as true or false. + * + * @param isScreenLock Indicates if the screen locked. + * @return Returns WSError::WS_OK if called success, otherwise failed. + */ + virtual WSError SetScreenLocked(bool isScreenLock) = 0; }; } // namespace OHOS::Rosen #endif // OHOS_WINDOW_SCENE_SESSION_STAGE_INTERFACE_H diff --git a/window_scene/session/container/include/zidl/session_stage_ipc_interface_code.h b/window_scene/session/container/include/zidl/session_stage_ipc_interface_code.h index 99cacaf6c4..6d107a9142 100644 --- a/window_scene/session/container/include/zidl/session_stage_ipc_interface_code.h +++ b/window_scene/session/container/include/zidl/session_stage_ipc_interface_code.h @@ -97,6 +97,7 @@ enum class SessionStageInterfaceCode { TRANS_ID_UPDATE_GLOBAL_DISPLAY_RECT, // Floating ball TRANS_ID_SEND_FB_ACTION_EVENT, + TRANS_ID_NOTIFY_SET_SCREENLOCKED, }; } // namespace Rosen } // namespace OHOS diff --git a/window_scene/session/container/include/zidl/session_stage_proxy.h b/window_scene/session/container/include/zidl/session_stage_proxy.h index 700cc196d9..57f8cd011a 100644 --- a/window_scene/session/container/include/zidl/session_stage_proxy.h +++ b/window_scene/session/container/include/zidl/session_stage_proxy.h @@ -114,6 +114,7 @@ public: void NotifyAppUseControlStatus(bool isUseControl) override; WMError GetRouterStackInfo(std::string& routerStackInfo) override; WSError SendFbActionEvent(const std::string& action) override; + WSError SetScreenLocked(bool isSCreenLocked) override; private: static inline BrokerDelegator delegator_; diff --git a/window_scene/session/container/include/zidl/session_stage_stub.h b/window_scene/session/container/include/zidl/session_stage_stub.h index 79e0024968..f44f72c03e 100644 --- a/window_scene/session/container/include/zidl/session_stage_stub.h +++ b/window_scene/session/container/include/zidl/session_stage_stub.h @@ -105,6 +105,7 @@ private: int HandleGetRouterStackInfo(MessageParcel& data, MessageParcel& reply); int HandleCloseSpecificScene(MessageParcel& data, MessageParcel& reply); int HandleSendFbActionEvent(MessageParcel& data, MessageParcel& reply); + int HandleSetScreenLocked(MessageParcel& data, MessageParcel& reply); }; } // namespace OHOS::Rosen #endif // OHOS_WINDOW_SCENE_SESSION_STAGE_STUB_H diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index bc453222bc..4b76618674 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -17462,11 +17462,4 @@ WMError SceneSessionManager::UpdateScreenLockState(int32_t persistentId) }, __func__); return WMError::WM_OK; } - -WMError SceneSessionManager::UpdateSystemDecorEnable(bool enable) -{ - TLOGI(WmsLogTag::WMS_DECOR, "set system decor enable: %{public}d", enable); - systemConfig_.isSystemDecorEnable_ = enable; - return WMError::WM_OK; -} } // namespace OHOS::Rosen -- Gitee From b8d6a45d1c02180925c524f14d5440b13f3f5c46 Mon Sep 17 00:00:00 2001 From: zhaoqi209 <18872749497@163.com> Date: Tue, 26 Aug 2025 22:47:56 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E8=87=AA=E7=94=B1=E5=A4=9A=E7=AA=97?= =?UTF-8?q?=E9=94=81=E5=B1=8F=E4=B9=8B=E4=B8=8A=E4=B8=8D=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E6=A0=87=E9=A2=98=E6=A0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhaoqi209 <18872749497@163.com> --- .../common/include/window_session_property.h | 5 +++ .../common/src/window_session_property.cpp | 10 ++++++ .../js_scene_session_manager.cpp | 31 ------------------- .../js_scene_session_manager.h | 4 --- .../include/zidl/session_stage_interface.h | 10 ++++++ .../zidl/session_stage_ipc_interface_code.h | 1 + .../include/zidl/session_stage_proxy.h | 1 + .../include/zidl/session_stage_stub.h | 1 + .../src/zidl/session_stage_proxy.cpp | 31 +++++++++++++++++++ .../container/src/zidl/session_stage_stub.cpp | 11 +++++++ window_scene/session/host/include/session.h | 2 ++ window_scene/session/host/src/session.cpp | 20 ++++++++++++ .../session/host/src/zidl/session_proxy.cpp | 1 + .../session/host/src/zidl/session_stub.cpp | 1 + .../include/scene_session_manager.h | 5 +-- .../src/scene_session_manager.cpp | 15 ++++++--- window_scene/test/mock/mock_session_stage.h | 1 + window_scene/test/mock/mock_session_stub.h | 1 + .../unittest/scene_session_manager_test12.cpp | 30 ++++++++++-------- .../unittest/session_stage_proxy_test.cpp | 29 +++++++++++++++++ .../test/unittest/session_stage_stub_test.cpp | 13 ++++++++ window_scene/test/unittest/session_test4.cpp | 21 +++++++++++++ .../unittest/window_session_property_test.cpp | 30 ++++++++++++++++++ wm/include/window_session_impl.h | 2 ++ wm/src/window_session_impl.cpp | 13 ++++++-- .../unittest/window_session_impl_test2.cpp | 4 +++ .../unittest/window_session_impl_test5.cpp | 14 +++++++++ 27 files changed, 250 insertions(+), 57 deletions(-) diff --git a/window_scene/common/include/window_session_property.h b/window_scene/common/include/window_session_property.h index 14ecb65fc9..b6c955743b 100755 --- a/window_scene/common/include/window_session_property.h +++ b/window_scene/common/include/window_session_property.h @@ -350,6 +350,9 @@ public: void SetExclusivelyHighlighted(bool isExclusivelyHighlighted); mutable std::mutex windowMaskMutex_; + void SetScreenLocked(bool isScreenLocked); + bool GetScreenLocked() const; + private: void setTouchHotAreasInner(const std::vector& rects, std::vector& touchHotAreas); bool MarshallingTouchHotAreasInner(const std::vector& touchHotAreas, Parcel& parcel) const; @@ -595,6 +598,8 @@ private: * Window Transition Animation For PC */ std::unordered_map> transitionAnimationConfig_; + + bool isScreenLocked_ { false }; }; class CompatibleModeProperty : public Parcelable { diff --git a/window_scene/common/src/window_session_property.cpp b/window_scene/common/src/window_session_property.cpp index 761ba1ae98..b2849ebe44 100755 --- a/window_scene/common/src/window_session_property.cpp +++ b/window_scene/common/src/window_session_property.cpp @@ -2590,5 +2590,15 @@ void SystemSessionConfig::ConvertSupportUIExtensionSubWindow(const std::string& { supportUIExtensionSubWindow_ = StringUtil::ConvertStringToBool(itemValue); } + +void WindowSessionProperty::SetScreenLocked(bool isScreenLocked) +{ + isScreenLocked_ = isScreenLocked; +} + +bool WindowSessionProperty::GetScreenLocked() const +{ + return isScreenLocked_; +} } // namespace Rosen } // namespace OHOS \ No newline at end of file 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 e9dff81a97..3f9ed348e2 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 @@ -324,8 +324,6 @@ napi_value JsSceneSessionManager::Init(napi_env env, napi_value exportObj) JsSceneSessionManager::SetUIEffectControllerAliveInUI); BindNativeFunction(env, exportObj, "setPiPSettingSwitchStatus", moduleName, JsSceneSessionManager::SetPiPSettingSwitchStatus); - BindNativeFunction(env, exportObj, "UpdateSystemDecorEnable", moduleName, - JsSceneSessionManager::UpdateSystemDecorEnable); BindNativeFunction(env, exportObj, "applyFeatureConfig", moduleName, JsSceneSessionManager::ApplyFeatureConfig); return NapiGetUndefined(env); @@ -5327,33 +5325,4 @@ napi_value JsSceneSessionManager::OnSetPiPSettingSwitchStatus(napi_env env, napi SceneSessionManager::GetInstance().SetPiPSettingSwitchStatus(switchStatus); return NapiGetUndefined(env); } - -napi_value JsSceneSessionManager::UpdateSystemDecorEnable(napi_env env, napi_callback_info info) -{ - TLOGI(WmsLogTag::WMS_DECOR, "in"); - JsSceneSessionManager* me = CheckParamsAndGetThis(env, info); - return (me != nullptr) ? me->OnUpdateSystemDecorEnable(env, info) : nullptr; -} - -napi_value JsSceneSessionManager::OnUpdateSystemDecorEnable(napi_env env, napi_callback_info info) -{ - size_t argc = ARGC_ONE; - napi_value argv[ARGC_ONE] = { nullptr }; - napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); - if (argc != ARGC_ONE) { - TLOGE(WmsLogTag::WMS_DECOR, "Argc is invalid: %{public}zu", argc); - napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_INVALID_PARAM), - "Input parameter is missing or invalid")); - return NapiGetUndefined(env); - } - bool enable = true; - if (!ConvertFromJsValue(env, argv[0], enable)) { - TLOGE(WmsLogTag::WMS_DECOR, "Failed to convert parameter to enable"); - napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_INVALID_PARAM), - "Input parameter is missing or invalid")); - return NapiGetUndefined(env); - } - SceneSessionManager::GetInstance().UpdateSystemDecorEnable(enable); - return NapiGetUndefined(env); -} } // namespace OHOS::Rosen \ No newline at end of file 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 8e0172a96c..d06130ea2d 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 @@ -178,8 +178,6 @@ public: */ static napi_value SetPiPSettingSwitchStatus(napi_env env, napi_callback_info info); - static napi_value UpdateSystemDecorEnable(napi_env env, napi_callback_info info); - private: napi_value OnSetBehindWindowFilterEnabled(napi_env env, napi_callback_info info); napi_value OnRegisterCallback(napi_env env, napi_callback_info info); @@ -404,8 +402,6 @@ private: */ napi_value OnSupportSnapshotAllSessionStatus(napi_env env, napi_callback_info info); napi_value OnSupportPreloadStartingWindow(napi_env env, napi_callback_info info); - - napi_value OnUpdateSystemDecorEnable(napi_env env, napi_callback_info info); }; } // namespace OHOS::Rosen diff --git a/window_scene/session/container/include/zidl/session_stage_interface.h b/window_scene/session/container/include/zidl/session_stage_interface.h index c08cbf3016..1d53be9afc 100644 --- a/window_scene/session/container/include/zidl/session_stage_interface.h +++ b/window_scene/session/container/include/zidl/session_stage_interface.h @@ -287,6 +287,16 @@ public: * @return Returns WSError::WS_OK if called success, otherwise failed. */ virtual WSError SendFbActionEvent(const std::string& action) = 0; + + /** + * @brief Set screen lock status . + * + * Set screen lock status. Such as true or false. + * + * @param isScreenLock Indicates if the screen locked. + * @return Returns WSError::WS_OK if called success, otherwise failed. + */ + virtual WSError SetScreenLocked(bool isScreenLock) = 0; }; } // namespace OHOS::Rosen #endif // OHOS_WINDOW_SCENE_SESSION_STAGE_INTERFACE_H diff --git a/window_scene/session/container/include/zidl/session_stage_ipc_interface_code.h b/window_scene/session/container/include/zidl/session_stage_ipc_interface_code.h index 99cacaf6c4..6d107a9142 100644 --- a/window_scene/session/container/include/zidl/session_stage_ipc_interface_code.h +++ b/window_scene/session/container/include/zidl/session_stage_ipc_interface_code.h @@ -97,6 +97,7 @@ enum class SessionStageInterfaceCode { TRANS_ID_UPDATE_GLOBAL_DISPLAY_RECT, // Floating ball TRANS_ID_SEND_FB_ACTION_EVENT, + TRANS_ID_NOTIFY_SET_SCREENLOCKED, }; } // namespace Rosen } // namespace OHOS diff --git a/window_scene/session/container/include/zidl/session_stage_proxy.h b/window_scene/session/container/include/zidl/session_stage_proxy.h index 700cc196d9..57f8cd011a 100644 --- a/window_scene/session/container/include/zidl/session_stage_proxy.h +++ b/window_scene/session/container/include/zidl/session_stage_proxy.h @@ -114,6 +114,7 @@ public: void NotifyAppUseControlStatus(bool isUseControl) override; WMError GetRouterStackInfo(std::string& routerStackInfo) override; WSError SendFbActionEvent(const std::string& action) override; + WSError SetScreenLocked(bool isSCreenLocked) override; private: static inline BrokerDelegator delegator_; diff --git a/window_scene/session/container/include/zidl/session_stage_stub.h b/window_scene/session/container/include/zidl/session_stage_stub.h index 79e0024968..f44f72c03e 100644 --- a/window_scene/session/container/include/zidl/session_stage_stub.h +++ b/window_scene/session/container/include/zidl/session_stage_stub.h @@ -105,6 +105,7 @@ private: int HandleGetRouterStackInfo(MessageParcel& data, MessageParcel& reply); int HandleCloseSpecificScene(MessageParcel& data, MessageParcel& reply); int HandleSendFbActionEvent(MessageParcel& data, MessageParcel& reply); + int HandleSetScreenLocked(MessageParcel& data, MessageParcel& reply); }; } // namespace OHOS::Rosen #endif // OHOS_WINDOW_SCENE_SESSION_STAGE_STUB_H diff --git a/window_scene/session/container/src/zidl/session_stage_proxy.cpp b/window_scene/session/container/src/zidl/session_stage_proxy.cpp index 05c8b318be..3ad7c3566e 100644 --- a/window_scene/session/container/src/zidl/session_stage_proxy.cpp +++ b/window_scene/session/container/src/zidl/session_stage_proxy.cpp @@ -2248,4 +2248,35 @@ WSError SessionStageProxy::CloseSpecificScene() } return WSError::WS_OK; } + +WSError SessionStageProxy::SetScreenLocked(bool isScreenLocked) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option(MessageOption::TF_ASYNC); + if (!data.WriteInterfaceToken(GetDescriptor())) { + TLOGE(WmsLogTag::WMS_ATTRIBUTE, "WriteInterfaceToken failed"); + return WSError::WS_ERROR_IPC_FAILED; + } + if (!data.WriteBool(isScreenLocked)) { + TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write isScreenLocked failed"); + return WSError::WS_ERROR_IPC_FAILED; + } + + sptr remote = Remote(); + if (remote == nullptr) { + TLOGE(WmsLogTag::WMS_ATTRIBUTE, "remote is null"); + return WSError::WS_ERROR_IPC_FAILED; + } + + if (remote->SendRequest(static_cast(SessionStageInterfaceCode::TRANS_ID_NOTIFY_SET_SCREENLOCKED), + data, reply, option) != ERR_NONE) { + TLOGE(WmsLogTag::WMS_ATTRIBUTE, "SendRequest failed"); + return WSError::WS_ERROR_IPC_FAILED; + } + int32_t ret = reply.ReadInt32(); + return static_cast(ret); +} + + } // namespace OHOS::Rosen diff --git a/window_scene/session/container/src/zidl/session_stage_stub.cpp b/window_scene/session/container/src/zidl/session_stage_stub.cpp index c52c1d0969..c17436d811 100644 --- a/window_scene/session/container/src/zidl/session_stage_stub.cpp +++ b/window_scene/session/container/src/zidl/session_stage_stub.cpp @@ -236,6 +236,8 @@ int SessionStageStub::OnRemoteRequest(uint32_t code, MessageParcel& data, Messag return HandleUpdateGlobalDisplayRectFromServer(data, reply); case static_cast(SessionStageInterfaceCode::TRANS_ID_SEND_FB_ACTION_EVENT): return HandleSendFbActionEvent(data, reply); + case static_cast(SessionStageInterfaceCode::TRANS_ID_NOTIFY_SET_SCREENLOCKED): + return HandleSetScreenLocked(data, reply); default: WLOGFE("Failed to find function handler!"); return IPCObjectStub::OnRemoteRequest(code, data, reply, option); @@ -1224,4 +1226,13 @@ int SessionStageStub::HandleCloseSpecificScene(MessageParcel& data, MessageParce CloseSpecificScene(); return ERR_NONE; } + +int SessionStageStub::HandleSetScreenLocked(MessageParcel& data, MessageParcel& reply) +{ + TLOGD(WmsLogTag::WMS_LAYOUT_PC, "called!"); + bool isScreenLocked = data.ReadBool(); + WSError errCode = SetScreenLocked(isScreenLocked); + reply.WriteInt32(static_cast(errCode)); + return ERR_NONE; +} } // namespace OHOS::Rosen diff --git a/window_scene/session/host/include/session.h b/window_scene/session/host/include/session.h index bf4151007d..b26076e7d9 100644 --- a/window_scene/session/host/include/session.h +++ b/window_scene/session/host/include/session.h @@ -758,6 +758,8 @@ public: */ std::shared_ptr GetRSUIContext(const char* caller = ""); + WSError SetScreenLocked(bool isScreenLocked); + protected: class SessionLifeCycleTask : public virtual RefBase { public: diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index 328e19761e..84f3f430ce 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -1357,6 +1357,7 @@ void Session::InitSessionPropertyWhenConnect(const sptr& property->SetPcAppInpadCompatibleMode(GetSessionProperty()->GetPcAppInpadCompatibleMode()); property->SetPcAppInpadSpecificSystemBarInvisible(GetSessionProperty()->GetPcAppInpadSpecificSystemBarInvisible()); property->SetPcAppInpadOrientationLandscape(GetSessionProperty()->GetPcAppInpadOrientationLandscape()); + property->SetScreenLocked(isScreenLockedCallback_ && isScreenLockedCallback_()); SetSessionProperty(property); GetSessionProperty()->SetIsNeedUpdateWindowMode(false); } @@ -4880,4 +4881,23 @@ std::shared_ptr Session::GetRSUIContext(const char* caller) caller, RSAdapterUtil::RSUIContextToStr(rsUIContext_).c_str(), GetPersistentId(), screenId); return rsUIContext_; } + +WSError Session::SetScreenLocked(bool isScreenLocked) +{ + if (!IsSessionValid()) { + TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Session is invalid, id: %{public}d state: %{public}u", + GetPersistentId(), GetSessionState()); + return WSError::WS_ERROR_INVALID_SESSION; + } + if (!sessionStage_) { + TLOGE(WmsLogTag::WMS_ATTRIBUTE, "sessionStage_ is null"); + return WSError::WS_ERROR_NULLPTR; + } + if (WindowHelper::IsMainWindow(GetWindowType())) { + TLOGI(WmsLogTag::WMS_ATTRIBUTE, "id: %{public}d isScreenLocked: %{public}d", + GetPersistentId(), isScreenLocked); + return sessionStage_->SetScreenLocked(isScreenLocked); + } + return WSError::WS_OK; +} } // namespace OHOS::Rosen \ No newline at end of file diff --git a/window_scene/session/host/src/zidl/session_proxy.cpp b/window_scene/session/host/src/zidl/session_proxy.cpp index 5378b0d241..0be523903f 100644 --- a/window_scene/session/host/src/zidl/session_proxy.cpp +++ b/window_scene/session/host/src/zidl/session_proxy.cpp @@ -343,6 +343,7 @@ WSError SessionProxy::Connect(const sptr& sessionStage, const spt return WSError::WS_ERROR_IPC_FAILED; } property->SetMissionInfo(*missionInfo); + property->SetScreenLocked(reply.ReadBool()); } int32_t ret = reply.ReadInt32(); return static_cast(ret); diff --git a/window_scene/session/host/src/zidl/session_stub.cpp b/window_scene/session/host/src/zidl/session_stub.cpp index db49aa8677..9d560e11df 100644 --- a/window_scene/session/host/src/zidl/session_stub.cpp +++ b/window_scene/session/host/src/zidl/session_stub.cpp @@ -507,6 +507,7 @@ int SessionStub::HandleConnect(MessageParcel& data, MessageParcel& reply) reply.WriteString(property->GetAncoRealBundleName()); MissionInfo missionInfo = property->GetMissionInfo(); reply.WriteParcelable(&missionInfo); + reply.WriteBool(property->GetScreenLocked()); } reply.WriteUint32(static_cast(errCode)); return ERR_NONE; diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index 1c09a1cdeb..5c8f8c7ac5 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -808,8 +808,9 @@ public: const WindowAnimationOption& animationOption) override; std::vector> GetSceneSessions(ScreenId screenId); - WMError UpdateScreenLockState(int32_t persistentId); - WMError UpdateSystemDecorEnable(bool enable); + WMError UpdateScreenLockState(int32_t persistentId); + void NotifySessionScreenLockedChange(bool isScreenLocked); + protected: SceneSessionManager(); diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index bc453222bc..9e2d41fcaa 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -8513,6 +8513,7 @@ void SceneSessionManager::SetScreenLocked(const bool isScreenLocked) isScreenLocked_ = isScreenLocked; DeleteStateDetectTask(); NotifyPiPWindowVisibleChange(isScreenLocked); + NotifySessionScreenLockedChange(isScreenLocked); }, __func__); } @@ -17463,10 +17464,14 @@ WMError SceneSessionManager::UpdateScreenLockState(int32_t persistentId) return WMError::WM_OK; } -WMError SceneSessionManager::UpdateSystemDecorEnable(bool enable) -{ - TLOGI(WmsLogTag::WMS_DECOR, "set system decor enable: %{public}d", enable); - systemConfig_.isSystemDecorEnable_ = enable; - return WMError::WM_OK; +void SceneSessionManager::NotifySessionScreenLockedChange(bool isScreenLocked) { + std::shared_lock lock(sceneSessionMapMutex_); + for (const auto& [_, sceneSession] : sceneSessionMap_) { + if (sceneSession == nullptr) { + continue; + } + sceneSession->GetSessionProperty()->SetScreenLocked(isScreenLocked); + sceneSession->SetScreenLocked(isScreenLocked); + } } } // namespace OHOS::Rosen diff --git a/window_scene/test/mock/mock_session_stage.h b/window_scene/test/mock/mock_session_stage.h index 08d8e34420..d0f17f5fb7 100644 --- a/window_scene/test/mock/mock_session_stage.h +++ b/window_scene/test/mock/mock_session_stage.h @@ -92,6 +92,7 @@ public: MOCK_METHOD1(NotifyExtensionSecureLimitChange, WSError(bool isLimit)); MOCK_METHOD1(GetRouterStackInfo, WMError(std::string& routerStackInfo)); MOCK_METHOD1(SendFbActionEvent, WSError(const std::string& action)); + MOCK_METHOD1(SetScreenLocked, WSError(bool isScreenLocked)); }; } // namespace Rosen } // namespace OHOS diff --git a/window_scene/test/mock/mock_session_stub.h b/window_scene/test/mock/mock_session_stub.h index ec39d858b2..a0d14e9997 100644 --- a/window_scene/test/mock/mock_session_stub.h +++ b/window_scene/test/mock/mock_session_stub.h @@ -87,6 +87,7 @@ public: MOCK_METHOD1(GetFloatingBallWindowId, WMError(uint32_t& windowId)); MOCK_METHOD1(SendFbActionEvent, WSError(const std::string& action)); MOCK_METHOD1(RestoreFbMainWindow, WMError(const std::shared_ptr& want)); + MOCK_METHOD1(SetScreenLocked, WSError(bool& isScreenLocked)); }; } // namespace Rosen } // namespace OHOS diff --git a/window_scene/test/unittest/scene_session_manager_test12.cpp b/window_scene/test/unittest/scene_session_manager_test12.cpp index 470112c748..08763b96bc 100644 --- a/window_scene/test/unittest/scene_session_manager_test12.cpp +++ b/window_scene/test/unittest/scene_session_manager_test12.cpp @@ -2986,19 +2986,6 @@ HWTEST_F(SceneSessionManagerTest12, UpdateScreenLockState, Function | SmallTest EXPECT_EQ(result, WMError::WM_OK); } -/** - * @tc.name: UpdateScreenLockState - * @tc.desc: test function : UpdateScreenLockState - * @tc.type: FUNC - */ -HWTEST_F(SceneSessionManagerTest12, UpdateSystemDecorEnable, Function | SmallTest | Level2) -{ - bool enable = false; - auto result = ssm_->UpdateSystemDecorEnable(enable); - EXPECT_EQ(result, WMError::WM_OK); - EXPECT_EQ(ssm_->systemConfig_.isSystemDecorEnable_, enable); -} - /** * @tc.name: IsFocusWindowParent * @tc.desc: test function : IsFocusWindowParent @@ -3034,6 +3021,23 @@ HWTEST_F(SceneSessionManagerTest12, IsFocusWindowParent, Function | SmallTest | EXPECT_EQ(WSError::WS_OK, ssm_->IsFocusWindowParent(token, isParent)); EXPECT_EQ(false, isParent); } + +/** + * @tc.name: NotifySessionScreenLockedChange + * @tc.desc: test function : NotifySessionScreenLockedChange + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest12, NotifySessionScreenLockedChange, TestSize.Level1) +{ + bool isScreenLocked = true; + ssm_->NotifySessionScreenLockedChange(isScreenLocked); + for (const auto& [, sceneSession] : ssm->sceneSessionMap_) { + if (sceneSession == nullptr) { + continue; + } + EXPECT_EQ(isScreenLocked, sceneSession->GetSessionProperty()->GetScreenLocked()); + } +} } // namespace } // namespace Rosen } // namespace OHOS diff --git a/window_scene/test/unittest/session_stage_proxy_test.cpp b/window_scene/test/unittest/session_stage_proxy_test.cpp index 270ff05d8c..cce38697ad 100755 --- a/window_scene/test/unittest/session_stage_proxy_test.cpp +++ b/window_scene/test/unittest/session_stage_proxy_test.cpp @@ -1011,6 +1011,35 @@ HWTEST_F(SessionStageProxyTest, TestUpdateGlobalDisplayRectFromServer, TestSize. sptr successProxy = sptr::MakeSptr(remoteMock); EXPECT_EQ(WSError::WS_OK, successProxy->UpdateGlobalDisplayRectFromServer(rect, reason)); } + +/** + * @tc.name: SetScreenLocked + * @tc.desc: Test SetScreenLocked + * @tc.type: FUNC + */ +HWTEST_F(SessionStageProxyTest, SetScreenLocked, TestSize.Level1) +{ + ASSERT_TRUE(sessionStage_ != nullptr); + bool isScreenLocked = true; + MockMessageParcel::SetWriteInterfaceTokenErrorFlag(true); + ASSERT_EQ(WSError::WS_ERROR_IPC_FAILED, sessionStage_->SetScreenLocked(isScreenLocked)); + + MockMessageParcel::SetWriteInterfaceTokenErrorFlag(false); + + ASSERT_EQ(WSError::WS_OK, sessionStage_->SetScreenLocked(isScreenLocked)); + sptr sProxy = sptr::MakeSptr(nullptr); + ASSERT_EQ(WSError::WS_ERROR_IPC_FAILED, sProxy->SetScreenLocked(isScreenLocked)); + + auto remoteMocker = sptr::MakeSptr(); + remoteMocker->sendRequestResult_ = 1; + sptr sessionStage = sptr::MakeSptr(remoteMocker); + ASSERT_EQ(WSError::WS_ERROR_IPC_FAILED, sessionStage->SetScreenLocked(isScreenLocked)); + + MockMessageParcel::SetWriteBoolErrorFlag(true); + ASSERT_EQ(WSError::WS_ERROR_IPC_FAILED, sessionStage_->SetScreenLocked(isScreenLocked)); + MockMessageParcel::SetWriteStringErrorFlag(false); + MockMessageParcel::ClearAllErrorFlag(); +} } // namespace } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/session_stage_stub_test.cpp b/window_scene/test/unittest/session_stage_stub_test.cpp index dd2777cac6..8cb3b39950 100644 --- a/window_scene/test/unittest/session_stage_stub_test.cpp +++ b/window_scene/test/unittest/session_stage_stub_test.cpp @@ -1286,6 +1286,19 @@ HWTEST_F(SessionStageStubTest, HandleNotifyAppHookWindowInfoUpdated, TestSize.Le ASSERT_TRUE(sessionStageStub_ != nullptr); EXPECT_EQ(ERR_NONE, sessionStageStub_->OnRemoteRequest(code, data, reply, option)); } + +/** + * @tc.name: HandleSetScreenLocked + * @tc.desc: test function : HandleSetScreenLocked + * @tc.type: FUNC + */ +HWTEST_F(SessionStageStubTest, HandleSetScreenLocked, TestSize.Level1) +{ + MessageParcel data; + MessageParcel reply; + ASSERT_TRUE(sessionStageStub_ != nullptr); + EXPECT_EQ(ERR_NONE, sessionStageStub_->HandleSetScreenLocked(data, reply)); +} } // namespace } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/session_test4.cpp b/window_scene/test/unittest/session_test4.cpp index eb6e1063de..cd06f30443 100644 --- a/window_scene/test/unittest/session_test4.cpp +++ b/window_scene/test/unittest/session_test4.cpp @@ -1503,6 +1503,27 @@ HWTEST_F(WindowSessionTest4, HasParentSessionWithToken, TestSize.Level1) ret = session->HasParentSessionWithToken(token); EXPECT_EQ(ret, true); } + +/** + * @tc.name: SetScreenLocked + * @tc.desc: Test Case SetScreenLocked + * @tc.type: FUNC + */ +HWTEST_F(WindowSessionTest4, SetScreenLocked, TestSize.Level1) +{ + ASSERT_NE(session_, nullptr); + + bool isScreenLocked = true; + session_->state_ = SessionState::STATE_DISCONNECT; + WSError result = session_->SetScreenLocked(isScreenLocked); + EXPECT_EQ(result, WSError::WS_ERROR_INVALID_SESSION); + + session_->state_ = SessionState::STATE_CONNECT; + session_->sessionStage_ = sptr::MakeSptr(); + session_->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE); + WSError result02 = session_->SetScreenLocked(isScreenLocked); + EXPECT_EQ(result02, WSError::WS_OK); +} } // namespace } // namespace Rosen } // namespace OHOS diff --git a/window_scene/test/unittest/window_session_property_test.cpp b/window_scene/test/unittest/window_session_property_test.cpp index 0200eb1545..141c091315 100755 --- a/window_scene/test/unittest/window_session_property_test.cpp +++ b/window_scene/test/unittest/window_session_property_test.cpp @@ -1654,6 +1654,36 @@ HWTEST_F(WindowSessionPropertyTest, UnmarshallingFbTemplateInfoTest, TestSize.Le ASSERT_EQ(property->GetFbTemplateInfo().backgroundColor_, fbTemplateInfo.backgroundColor_); ASSERT_EQ(property->GetFbTemplateInfo().icon_, fbTemplateInfo.icon_); } + +/** + * @tc.name: SetScreenLocked + * @tc.desc: Test SetScreenLocked + * @tc.type: FUNC + */ +HWTEST_F(WindowSessionPropertyTest, SetScreenLocked, TestSize.Level1) +{ + sptr property = sptr::MakeSptr(); + bool isScreenLocked = true; + property->SetScreenLocked(isScreenLocked); + ASSERT_EQ(isScreenLocked, property->GetScreenLocked()); + isScreenLocked = false; + property->SetScreenLocked(isScreenLocked); + ASSERT_EQ(isScreenLocked, property->GetScreenLocked()); +} + +/** + * @tc.name: GetScreenLocked + * @tc.desc: Test GetScreenLocked + * @tc.type: FUNC + */ +HWTEST_F(WindowSessionPropertyTest, GetScreenLocked, TestSize.Level1) +{ + sptr property = sptr::MakeSptr(); + bool isScreenLocked = true; + property->SetScreenLocked(isScreenLocked); + ASSERT_EQ(true, property->GetScreenLocked()); +} + } // namespace } // namespace Rosen } // namespace OHOS diff --git a/wm/include/window_session_impl.h b/wm/include/window_session_impl.h index ec8fad751c..8eb4e9ff96 100644 --- a/wm/include/window_session_impl.h +++ b/wm/include/window_session_impl.h @@ -584,6 +584,8 @@ public: WMError GetRouterStackInfo(std::string& routerStackInfo) override; void SetNavDestinationInfo(const std::string& navDestinationInfo) override; + WSError SetScreenLocked(bool isScreenLocked) override; + protected: WMError Connect(); bool IsWindowSessionInvalid() const; diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index 5c13479c74..7d0e3b8002 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -2337,7 +2337,8 @@ void WindowSessionImpl::UpdateDecorEnableToAce(bool isDecorEnable) auto isSubWindow = WindowHelper::IsSubWindow(GetType()); decorVisible = decorVisible && (windowSystemConfig_.freeMultiWindowEnable_ || (property_->GetIsPcAppInPad() && isSubWindow)) && - !(mode == WindowMode::WINDOW_MODE_FULLSCREEN && property_->GetCompatibleModeProperty()); + !(mode == WindowMode::WINDOW_MODE_FULLSCREEN && property_->GetCompatibleModeProperty()) && + !property_->GetScreenLocked(); } uiContent->UpdateDecorVisible(decorVisible, isDecorEnable); return; @@ -2366,7 +2367,8 @@ void WindowSessionImpl::UpdateDecorEnable(bool needNotify, WindowMode mode) auto isSubWindow = WindowHelper::IsSubWindow(GetType()); decorVisible = decorVisible && (windowSystemConfig_.freeMultiWindowEnable_ || (property_->GetIsPcAppInPad() && isSubWindow)) && - !(mode == WindowMode::WINDOW_MODE_FULLSCREEN && property_->GetCompatibleModeProperty()); + !(mode == WindowMode::WINDOW_MODE_FULLSCREEN && property_->GetCompatibleModeProperty()) && + !property_->GetScreenLocked(); } if (GetWindowMode() == WindowMode::WINDOW_MODE_FULLSCREEN && property_->IsDecorFullscreenDisabled()) { decorVisible = false; @@ -8111,5 +8113,12 @@ void WindowSessionImpl::SetNotifySizeChangeFlag(bool flag) notifySizeChangeFlag_ = false; } +WSError WindowSessionImpl::SetScreenLocked(bool isScreenLocked) +{ + TLOGI(WmsLogTag::WMS_ATTRIBUTE, "isScreenLocked: %{public}d", isScreenLocked); + property_->SetScreenLocked(isScreenLocked); + return WSError::WS_OK; +} + } // namespace Rosen } // namespace OHOS diff --git a/wm/test/unittest/window_session_impl_test2.cpp b/wm/test/unittest/window_session_impl_test2.cpp index 76c7ca9005..1f11520853 100644 --- a/wm/test/unittest/window_session_impl_test2.cpp +++ b/wm/test/unittest/window_session_impl_test2.cpp @@ -1289,6 +1289,7 @@ HWTEST_F(WindowSessionImplTest2, UpdateDecorEnableToAce, TestSize.Level1) listeners.insert(listeners.begin(), nullListener); window->windowChangeListeners_.insert({ window->GetPersistentId(), listeners }); window->windowSystemConfig_.freeMultiWindowSupport_ = false; + window->property_->SetScreenLocked(false); window->UpdateDecorEnableToAce(false); window->uiContent_ = nullptr; @@ -1307,6 +1308,7 @@ HWTEST_F(WindowSessionImplTest2, UpdateDecorEnable, TestSize.Level1) ASSERT_NE(window, nullptr); window->uiContent_ = std::make_unique(); window->windowSystemConfig_.freeMultiWindowSupport_ = true; + window->property_->SetScreenLocked(false); window->UpdateDecorEnable(true, WindowMode::WINDOW_MODE_UNDEFINED); window->windowSystemConfig_.freeMultiWindowSupport_ = false; @@ -2734,6 +2736,8 @@ HWTEST_F(WindowSessionImplTest2, NotifyKeyboardAnimationWillBegin, TestSize.Leve EXPECT_TRUE(logMsg.find("handler is nullptr") == std::string::npos); } + + } // namespace } // namespace Rosen } // namespace OHOS diff --git a/wm/test/unittest/window_session_impl_test5.cpp b/wm/test/unittest/window_session_impl_test5.cpp index b19ea601b1..07e9fb3752 100644 --- a/wm/test/unittest/window_session_impl_test5.cpp +++ b/wm/test/unittest/window_session_impl_test5.cpp @@ -1969,6 +1969,20 @@ HWTEST_F(WindowSessionImplTest5, NotifySizeChangeFlag, Function | SmallTest | Le window->SetNotifySizeChangeFlag(true); ASSERT_EQ(window->notifySizeChangeFlag_, false); } + +/** + * @tc.name: SetScreenLocked + * @tc.desc: SetScreenLocked + * @tc.type: FUNC + */ +HWTEST_F(WindowSessionImplTest5, SetScreenLocked, Function | SmallTest | Level1) +{ + sptr option = sptr::MakeSptr(); + option->SetWindowName("SetScreenLocked"); + sptr window = sptr::MakeSptr(option); + bool isScreenLocked = true; + ASSERT_EQ(WSError::WS_OK, window->SetScreenLocked(isScreenLocked)); +} } // namespace } // namespace Rosen } // namespace OHOS -- Gitee