From 248a501b1f4e338aa1df98ed5fcc9dac38d32717 Mon Sep 17 00:00:00 2001 From: koroltang Date: Wed, 26 Feb 2025 21:17:57 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E5=A2=9E=E5=8A=A0IPC=E5=AF=B9=E7=AB=AF?= =?UTF-8?q?=E8=BF=9B=E7=A8=8B=E5=86=BB=E7=BB=93=E7=AD=89=E5=BE=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: koroltang --- window_scene/session/container/src/zidl/session_stage_proxy.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 cd6780fbd1..5aa81eb1ce 100644 --- a/window_scene/session/container/src/zidl/session_stage_proxy.cpp +++ b/window_scene/session/container/src/zidl/session_stage_proxy.cpp @@ -1643,7 +1643,7 @@ WSError SessionStageProxy::NotifyWindowAttachStateChange(bool isAttach) { MessageParcel data; MessageParcel reply; - MessageOption option(MessageOption::TF_ASYNC); + MessageOption option(MessageOption::TF_ASYNC | MessageOption::TF_ASYNC_WAKEUP_LATER); if (!data.WriteInterfaceToken(GetDescriptor())) { TLOGE(WmsLogTag::WMS_SUB, "WriteInterfaceToken failed"); return WSError::WS_ERROR_IPC_FAILED; -- Gitee From 794678a650bbfba644bf9bdd7b9d155c49d1c0b2 Mon Sep 17 00:00:00 2001 From: koroltang Date: Wed, 26 Feb 2025 22:41:01 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E6=94=AF=E6=8C=81=E4=BB=85=E9=80=9A?= =?UTF-8?q?=E7=9F=A5=E6=B3=A8=E5=86=8C=E7=9B=91=E5=90=AC=E7=9A=84=E7=AA=97?= =?UTF-8?q?=E5=8F=A3=E6=8E=A5=E6=94=B6=E9=80=9A=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: koroltang --- .../session/host/include/scene_session.h | 5 ++++ window_scene/session/host/include/session.h | 2 ++ .../host/include/zidl/session_interface.h | 8 ++++++ .../include/zidl/session_ipc_interface_code.h | 3 +++ .../session/host/include/zidl/session_proxy.h | 5 ++++ .../session/host/include/zidl/session_stub.h | 3 +++ .../session/host/src/scene_session.cpp | 6 +++++ window_scene/session/host/src/session.cpp | 7 ++++- .../session/host/src/zidl/session_proxy.cpp | 27 +++++++++++++++++++ .../session/host/src/zidl/session_stub.cpp | 15 +++++++++++ wm/src/window_scene_session_impl.cpp | 4 ++- 11 files changed, 83 insertions(+), 2 deletions(-) diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index c0e6621fde..a43a8481f7 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -657,6 +657,11 @@ public: WSError SetWindowCornerRadius(float cornerRadius) override; void SetPrivacyModeChangeNotifyFunc(NotifyPrivacyModeChangeFunc&& func); + /* + * Window Pattern + */ + WSError NotifyWindowAttachStateListenerRegistered(bool registered) override; + protected: void NotifyIsCustomAnimationPlaying(bool isPlaying); void SetMoveDragCallback(); diff --git a/window_scene/session/host/include/session.h b/window_scene/session/host/include/session.h index ad18d4db0a..67e82a3c0c 100644 --- a/window_scene/session/host/include/session.h +++ b/window_scene/session/host/include/session.h @@ -540,6 +540,7 @@ public: void SetAttachState(bool isAttach, WindowMode windowMode = WindowMode::WINDOW_MODE_UNDEFINED); bool GetAttachState() const; void RegisterDetachCallback(const sptr& callback); + void SetNeedNotifyAttachState(bool needNotify); SystemSessionConfig GetSystemConfig() const; void RectCheckProcess(); @@ -957,6 +958,7 @@ private: */ Task saveSnapshotCallback_ = []() {}; Task removeSnapshotCallback_ = []() {}; + std::atomic needNotifyAttachState_ = { true }; }; } // namespace OHOS::Rosen diff --git a/window_scene/session/host/include/zidl/session_interface.h b/window_scene/session/host/include/zidl/session_interface.h index 208f760508..2009e1e62f 100644 --- a/window_scene/session/host/include/zidl/session_interface.h +++ b/window_scene/session/host/include/zidl/session_interface.h @@ -379,6 +379,14 @@ public: virtual WSError StartMovingWithCoordinate(int32_t offsetX, int32_t offsetY, int32_t pointerPosX, int32_t pointerPosY) { return WSError::WS_OK; } virtual WSError GetCrossAxisState(CrossAxisState& state) { return WSError::WS_OK; }; + + /** + * @brief Notify the window attach state listener is registered or not. + * + * @param registered true means register success. + * @return Returns WSError::WS_OK if called success, otherwise failed. + */ + virtual WSError NotifyWindowAttachStateListenerRegistered(bool registered) { return WSError::WS_OK; } }; } // namespace OHOS::Rosen diff --git a/window_scene/session/host/include/zidl/session_ipc_interface_code.h b/window_scene/session/host/include/zidl/session_ipc_interface_code.h index 2a94d45926..79bfb112c2 100644 --- a/window_scene/session/host/include/zidl/session_ipc_interface_code.h +++ b/window_scene/session/host/include/zidl/session_ipc_interface_code.h @@ -104,6 +104,9 @@ enum class SessionInterfaceCode { TRANS_ID_UPDATE_PIP_RECT, TRANS_ID_UPDATE_PIP_CONTROL_STATUS, TRANS_ID_SET_AUTOSTART_PIP, + + // Window Pattern + TRANS_ID_NOTIFY_WINDOW_ATTACH_STATE_LISTENER_REGISTERED, }; } // namespace Rosen } // namespace OHOS diff --git a/window_scene/session/host/include/zidl/session_proxy.h b/window_scene/session/host/include/zidl/session_proxy.h index a43a631346..18251dfd48 100644 --- a/window_scene/session/host/include/zidl/session_proxy.h +++ b/window_scene/session/host/include/zidl/session_proxy.h @@ -145,6 +145,11 @@ public: int32_t pointerPosX, int32_t pointerPosY) override; WSError OnContainerModalEvent(const std::string& eventName, const std::string& eventValue) override; + /* + * Window Pattern + */ + WSError NotifyWindowAttachStateListenerRegistered(bool registered) override; + private: static inline BrokerDelegator delegator_; }; diff --git a/window_scene/session/host/include/zidl/session_stub.h b/window_scene/session/host/include/zidl/session_stub.h index 7a65c6cdde..1ee034031b 100644 --- a/window_scene/session/host/include/zidl/session_stub.h +++ b/window_scene/session/host/include/zidl/session_stub.h @@ -109,6 +109,9 @@ private: int HandleUpdatePiPControlStatus(MessageParcel& data, MessageParcel& reply); int HandleSetAutoStartPiP(MessageParcel& data, MessageParcel& reply); + // Window Pattern + int HandleNotifyWindowAttachStateListenerRegistered(MessageParcel& data, MessageParcel& reply); + // PC Window int HandleSetWindowRectAutoSave(MessageParcel& data, MessageParcel& reply); int HandleSetSupportedWindowModes(MessageParcel& data, MessageParcel& reply); diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index bcc899ddd0..d27d7f52ba 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -6864,4 +6864,10 @@ void SceneSession::SetSidebarMaskColorModifier(bool needBlur) maskColorValue_->Set(Rosen::RSColor::FromArgbInt(snapshotMaskColor_)); } } + +WSError SceneSession::NotifyWindowAttachStateListenerRegistered(bool registered) +{ + SetNeedNotifyAttachState(registered); + return WSError::WS_OK; +} } // namespace OHOS::Rosen diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index ef6a441528..d11238825f 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -1579,7 +1579,7 @@ void Session::SetAttachState(bool isAttach, WindowMode windowMode) TLOGND(WmsLogTag::WMS_LIFE, "session is null"); return; } - if (session->sessionStage_) { + if (session->needNotifyAttachState_.load() && session->sessionStage_) { session->sessionStage_->NotifyWindowAttachStateChange(isAttach); } TLOGND(WmsLogTag::WMS_LIFE, "isAttach:%{public}d persistentId:%{public}d", isAttach, @@ -1593,6 +1593,11 @@ void Session::SetAttachState(bool isAttach, WindowMode windowMode) CreateDetectStateTask(isAttach, windowMode); } +void Session::SetNeedNotifyAttachState(bool needNotify) +{ + needNotifyAttachState_.store(needNotify); +} + void Session::CreateDetectStateTask(bool isAttach, WindowMode windowMode) { if (!IsSupportDetectWindow(isAttach)) { diff --git a/window_scene/session/host/src/zidl/session_proxy.cpp b/window_scene/session/host/src/zidl/session_proxy.cpp index 0896fdcdd9..572d73c7f6 100644 --- a/window_scene/session/host/src/zidl/session_proxy.cpp +++ b/window_scene/session/host/src/zidl/session_proxy.cpp @@ -2508,4 +2508,31 @@ WSError SessionProxy::OnContainerModalEvent(const std::string& eventName, const } return WSError::WS_OK; } + +WSError SessionProxy::NotifyWindowAttachStateListenerRegistered(bool registered) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option(MessageOption::TF_ASYNC); + if (!data.WriteInterfaceToken(GetDescriptor())) { + TLOGE(WmsLogTag::WMS_MAIN, "WriteInterfaceToken failed"); + return WSError::WS_ERROR_IPC_FAILED; + } + if (!data.WriteBool(registered)) { + TLOGE(WmsLogTag::WMS_MAIN, "Write enable failed"); + return WSError::WS_ERROR_IPC_FAILED; + } + sptr remote = Remote(); + if (remote == nullptr) { + TLOGE(WmsLogTag::WMS_MAIN, "remote is null"); + return WSError::WS_ERROR_IPC_FAILED; + } + if (remote->SendRequest( + static_cast(SessionInterfaceCode::TRANS_ID_NOTIFY_WINDOW_ATTACH_STATE_LISTENER_REGISTERED), + data, reply, option) != ERR_NONE) { + TLOGE(WmsLogTag::WMS_MAIN, "SendRequest failed"); + return WSError::WS_ERROR_IPC_FAILED; + } + return WSError::WS_OK; +} } // namespace OHOS::Rosen diff --git a/window_scene/session/host/src/zidl/session_stub.cpp b/window_scene/session/host/src/zidl/session_stub.cpp index 8a772fdbd8..753e52e9fd 100644 --- a/window_scene/session/host/src/zidl/session_stub.cpp +++ b/window_scene/session/host/src/zidl/session_stub.cpp @@ -246,6 +246,8 @@ int SessionStub::ProcessRemoteRequest(uint32_t code, MessageParcel& data, Messag return HandleGetCrossAxisState(data, reply); case static_cast(SessionInterfaceCode::TRANS_ID_CONTAINER_MODAL_EVENT): return HandleContainerModalEvent(data, reply); + case static_cast(SessionInterfaceCode::TRANS_ID_NOTIFY_WINDOW_ATTACH_STATE_LISTENER_REGISTERED): + return HandleNotifyWindowAttachStateListenerRegistered(data, reply); default: WLOGFE("Failed to find function handler!"); return IPCObjectStub::OnRemoteRequest(code, data, reply, option); @@ -1541,4 +1543,17 @@ int SessionStub::HandleContainerModalEvent(MessageParcel& data, MessageParcel& r OnContainerModalEvent(eventName, eventValue); return ERR_NONE; } + +int SessionStub::HandleNotifyWindowAttachStateListenerRegistered(MessageParcel& data, MessageParcel& reply) +{ + bool registered = false; + if (!data.ReadBool(registered)) { + TLOGE(WmsLogTag::WMS_PATTERN, "read registered failed"); + return ERR_INVALID_DATA; + } + TLOGD(WmsLogTag::WMS_PATTERN, "registered: %{public}d", registered); + WSError errcode = NotifyWindowAttachStateListenerRegistered(registered); + reply.WriteInt32(static_cast(errcode)); + return ERR_NONE; +} } // namespace OHOS::Rosen diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index fa9e183d2c..bbbed3b65e 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -4690,7 +4690,9 @@ WMError WindowSceneSessionImpl::RegisterWindowAttachStateChangeListener( } windowAttachStateChangeListener_ = listener; TLOGD(WmsLogTag::WMS_SUB, "id: %{public}d listener registered", GetPersistentId()); - return WMError::WM_OK; + auto hostSession = GetHostSession(); + CHECK_HOST_SESSION_RETURN_ERROR_IF_NULL(hostSession, WMError::WM_ERROR_NULLPTR); + return static_cast(hostSession->NotifyWindowAttachStateListenerRegistered(true)); } WMError WindowSceneSessionImpl::UnregisterWindowAttachStateChangeListener() -- Gitee From 240d3f8038df949fb097badb81c112b8533a740c Mon Sep 17 00:00:00 2001 From: koroltang Date: Sat, 1 Mar 2025 18:33:18 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=89=80=E6=9C=89?= =?UTF-8?q?=E8=BF=9B=E7=A8=8B=E9=BB=98=E8=AE=A4=E4=B8=8D=E6=8E=A5=E5=8F=97?= =?UTF-8?q?=E9=80=9A=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: koroltang --- window_scene/session/host/include/session.h | 2 +- wm/src/window_scene_session_impl.cpp | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/window_scene/session/host/include/session.h b/window_scene/session/host/include/session.h index 67e82a3c0c..caf751ef9b 100644 --- a/window_scene/session/host/include/session.h +++ b/window_scene/session/host/include/session.h @@ -958,7 +958,7 @@ private: */ Task saveSnapshotCallback_ = []() {}; Task removeSnapshotCallback_ = []() {}; - std::atomic needNotifyAttachState_ = { true }; + std::atomic needNotifyAttachState_ = { false }; }; } // namespace OHOS::Rosen diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index bbbed3b65e..dd19478e36 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -4699,8 +4699,10 @@ WMError WindowSceneSessionImpl::UnregisterWindowAttachStateChangeListener() { std::lock_guard lockListener(windowAttachStateChangeListenerMutex_); windowAttachStateChangeListener_ = nullptr; - TLOGI(WmsLogTag::WMS_SUB, "id: %{public}d", GetPersistentId()); - return WMError::WM_OK; + TLOGD(WmsLogTag::WMS_SUB, "id: %{public}d listener unregistered", GetPersistentId()); + auto hostSession = GetHostSession(); + CHECK_HOST_SESSION_RETURN_ERROR_IF_NULL(hostSession, WMError::WM_ERROR_NULLPTR); + return static_cast(hostSession->NotifyWindowAttachStateListenerRegistered(false)); } WSError WindowSceneSessionImpl::NotifyWindowAttachStateChange(bool isAttach) -- Gitee From 26f302ea418e54ba18e995a1915b2910a7ba80d6 Mon Sep 17 00:00:00 2001 From: koroltang Date: Sat, 1 Mar 2025 19:23:40 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=8A=A0=E9=8E=96?= =?UTF-8?q?=E7=AF=84=E5=9C=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: koroltang --- window_scene/session/host/src/zidl/session_stub.cpp | 7 +++++-- wm/src/window_scene_session_impl.cpp | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/window_scene/session/host/src/zidl/session_stub.cpp b/window_scene/session/host/src/zidl/session_stub.cpp index 753e52e9fd..b46c49ad77 100644 --- a/window_scene/session/host/src/zidl/session_stub.cpp +++ b/window_scene/session/host/src/zidl/session_stub.cpp @@ -1552,8 +1552,11 @@ int SessionStub::HandleNotifyWindowAttachStateListenerRegistered(MessageParcel& return ERR_INVALID_DATA; } TLOGD(WmsLogTag::WMS_PATTERN, "registered: %{public}d", registered); - WSError errcode = NotifyWindowAttachStateListenerRegistered(registered); - reply.WriteInt32(static_cast(errcode)); + WSError errCode = NotifyWindowAttachStateListenerRegistered(registered); + if (!reply.WriteInt32(static_cast(errCode))) { + TLOGE(WmsLogTag::WMS_PATTERN, "write errCode fail."); + return ERR_INVALID_DATA; + } return ERR_NONE; } } // namespace OHOS::Rosen diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index dd19478e36..f6c527196d 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -4683,11 +4683,11 @@ WMError WindowSceneSessionImpl::RegisterKeyboardPanelInfoChangeListener( WMError WindowSceneSessionImpl::RegisterWindowAttachStateChangeListener( const sptr& listener) { - std::lock_guard lockListener(windowAttachStateChangeListenerMutex_); if (listener == nullptr) { TLOGE(WmsLogTag::WMS_SUB, "id: %{public}d, listener is null", GetPersistentId()); return WMError::WM_ERROR_NULLPTR; } + std::lock_guard lockListener(windowAttachStateChangeListenerMutex_); windowAttachStateChangeListener_ = listener; TLOGD(WmsLogTag::WMS_SUB, "id: %{public}d listener registered", GetPersistentId()); auto hostSession = GetHostSession(); @@ -4708,6 +4708,7 @@ WMError WindowSceneSessionImpl::UnregisterWindowAttachStateChangeListener() WSError WindowSceneSessionImpl::NotifyWindowAttachStateChange(bool isAttach) { TLOGD(WmsLogTag::WMS_SUB, "id: %{public}d", GetPersistentId()); + std::lock_guard lockListener(windowAttachStateChangeListenerMutex_); if (!windowAttachStateChangeListener_) { TLOGW(WmsLogTag::WMS_SUB, "listener is null"); return WSError::WS_ERROR_NULLPTR; -- Gitee From 0eff0eada6c390640b656fc0eb420e173aa12d99 Mon Sep 17 00:00:00 2001 From: koroltang Date: Sat, 1 Mar 2025 22:26:28 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E6=A3=80=E8=A7=86=E6=84=8F=E8=A7=81?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: koroltang --- window_scene/session/host/include/scene_session.h | 2 +- .../session/host/include/zidl/session_interface.h | 3 +-- window_scene/session/host/include/zidl/session_proxy.h | 2 +- window_scene/session/host/src/scene_session.cpp | 3 +-- window_scene/session/host/src/zidl/session_proxy.cpp | 10 ++++------ window_scene/session/host/src/zidl/session_stub.cpp | 6 +----- wm/src/window_scene_session_impl.cpp | 6 ++++-- 7 files changed, 13 insertions(+), 19 deletions(-) diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index a43a8481f7..76f83c687d 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -660,7 +660,7 @@ public: /* * Window Pattern */ - WSError NotifyWindowAttachStateListenerRegistered(bool registered) override; + void NotifyWindowAttachStateListenerRegistered(bool registered) override; protected: void NotifyIsCustomAnimationPlaying(bool isPlaying); diff --git a/window_scene/session/host/include/zidl/session_interface.h b/window_scene/session/host/include/zidl/session_interface.h index 2009e1e62f..4aa350eb98 100644 --- a/window_scene/session/host/include/zidl/session_interface.h +++ b/window_scene/session/host/include/zidl/session_interface.h @@ -384,9 +384,8 @@ public: * @brief Notify the window attach state listener is registered or not. * * @param registered true means register success. - * @return Returns WSError::WS_OK if called success, otherwise failed. */ - virtual WSError NotifyWindowAttachStateListenerRegistered(bool registered) { return WSError::WS_OK; } + virtual void NotifyWindowAttachStateListenerRegistered(bool registered) { } }; } // namespace OHOS::Rosen diff --git a/window_scene/session/host/include/zidl/session_proxy.h b/window_scene/session/host/include/zidl/session_proxy.h index 18251dfd48..7424f0175d 100644 --- a/window_scene/session/host/include/zidl/session_proxy.h +++ b/window_scene/session/host/include/zidl/session_proxy.h @@ -148,7 +148,7 @@ public: /* * Window Pattern */ - WSError NotifyWindowAttachStateListenerRegistered(bool registered) override; + void NotifyWindowAttachStateListenerRegistered(bool registered) override; private: static inline BrokerDelegator delegator_; diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index d27d7f52ba..0dccca35af 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -6865,9 +6865,8 @@ void SceneSession::SetSidebarMaskColorModifier(bool needBlur) } } -WSError SceneSession::NotifyWindowAttachStateListenerRegistered(bool registered) +void SceneSession::NotifyWindowAttachStateListenerRegistered(bool registered) { SetNeedNotifyAttachState(registered); - return WSError::WS_OK; } } // namespace OHOS::Rosen diff --git a/window_scene/session/host/src/zidl/session_proxy.cpp b/window_scene/session/host/src/zidl/session_proxy.cpp index 572d73c7f6..fc203cd449 100644 --- a/window_scene/session/host/src/zidl/session_proxy.cpp +++ b/window_scene/session/host/src/zidl/session_proxy.cpp @@ -2509,30 +2509,28 @@ WSError SessionProxy::OnContainerModalEvent(const std::string& eventName, const return WSError::WS_OK; } -WSError SessionProxy::NotifyWindowAttachStateListenerRegistered(bool registered) +void SessionProxy::NotifyWindowAttachStateListenerRegistered(bool registered) { MessageParcel data; MessageParcel reply; MessageOption option(MessageOption::TF_ASYNC); if (!data.WriteInterfaceToken(GetDescriptor())) { TLOGE(WmsLogTag::WMS_MAIN, "WriteInterfaceToken failed"); - return WSError::WS_ERROR_IPC_FAILED; + return; } if (!data.WriteBool(registered)) { TLOGE(WmsLogTag::WMS_MAIN, "Write enable failed"); - return WSError::WS_ERROR_IPC_FAILED; + return; } sptr remote = Remote(); if (remote == nullptr) { TLOGE(WmsLogTag::WMS_MAIN, "remote is null"); - return WSError::WS_ERROR_IPC_FAILED; + return; } if (remote->SendRequest( static_cast(SessionInterfaceCode::TRANS_ID_NOTIFY_WINDOW_ATTACH_STATE_LISTENER_REGISTERED), data, reply, option) != ERR_NONE) { TLOGE(WmsLogTag::WMS_MAIN, "SendRequest failed"); - return WSError::WS_ERROR_IPC_FAILED; } - return WSError::WS_OK; } } // namespace OHOS::Rosen diff --git a/window_scene/session/host/src/zidl/session_stub.cpp b/window_scene/session/host/src/zidl/session_stub.cpp index b46c49ad77..77ca1968b1 100644 --- a/window_scene/session/host/src/zidl/session_stub.cpp +++ b/window_scene/session/host/src/zidl/session_stub.cpp @@ -1552,11 +1552,7 @@ int SessionStub::HandleNotifyWindowAttachStateListenerRegistered(MessageParcel& return ERR_INVALID_DATA; } TLOGD(WmsLogTag::WMS_PATTERN, "registered: %{public}d", registered); - WSError errCode = NotifyWindowAttachStateListenerRegistered(registered); - if (!reply.WriteInt32(static_cast(errCode))) { - TLOGE(WmsLogTag::WMS_PATTERN, "write errCode fail."); - return ERR_INVALID_DATA; - } + NotifyWindowAttachStateListenerRegistered(registered); return ERR_NONE; } } // namespace OHOS::Rosen diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index f6c527196d..ede12aa3b0 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -4692,7 +4692,8 @@ WMError WindowSceneSessionImpl::RegisterWindowAttachStateChangeListener( TLOGD(WmsLogTag::WMS_SUB, "id: %{public}d listener registered", GetPersistentId()); auto hostSession = GetHostSession(); CHECK_HOST_SESSION_RETURN_ERROR_IF_NULL(hostSession, WMError::WM_ERROR_NULLPTR); - return static_cast(hostSession->NotifyWindowAttachStateListenerRegistered(true)); + hostSession->NotifyWindowAttachStateListenerRegistered(true); + return WMError::WM_OK; } WMError WindowSceneSessionImpl::UnregisterWindowAttachStateChangeListener() @@ -4702,7 +4703,8 @@ WMError WindowSceneSessionImpl::UnregisterWindowAttachStateChangeListener() TLOGD(WmsLogTag::WMS_SUB, "id: %{public}d listener unregistered", GetPersistentId()); auto hostSession = GetHostSession(); CHECK_HOST_SESSION_RETURN_ERROR_IF_NULL(hostSession, WMError::WM_ERROR_NULLPTR); - return static_cast(hostSession->NotifyWindowAttachStateListenerRegistered(false)); + hostSession->NotifyWindowAttachStateListenerRegistered(false); + return WMError::WM_OK; } WSError WindowSceneSessionImpl::NotifyWindowAttachStateChange(bool isAttach) -- Gitee