From 50d95e08f8dfad8af516a9fa6582dd77d9c72d97 Mon Sep 17 00:00:00 2001 From: liaoqingxing Date: Fri, 7 Mar 2025 19:34:49 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=94=AF=E6=8C=81=E8=BE=93=E5=85=A5?= =?UTF-8?q?=E6=B3=95=E6=A1=86=E6=9E=B6=E6=9F=A5=E8=AF=A2=E7=9B=91=E5=90=AC?= =?UTF-8?q?=E8=BE=93=E5=85=A5=E6=B3=95=E5=AE=BF=E4=B8=BB=E7=AA=97=E5=8F=A3?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liaoqingxing --- interfaces/innerkits/wm/window_manager.h | 40 +++++++ interfaces/innerkits/wm/window_manager_lite.h | 27 +++++ interfaces/innerkits/wm/wm_common.h | 32 ++++++ .../include/scene_session_manager.h | 1 + .../include/scene_session_manager_lite.h | 1 + .../session_manager_agent_controller.h | 1 + .../scene_session_manager_lite_interface.h | 1 + .../zidl/scene_session_manager_lite_proxy.h | 1 + .../zidl/scene_session_manager_lite_stub.h | 1 + .../src/scene_session_manager.cpp | 36 ++++++ .../src/scene_session_manager_lite.cpp | 5 + .../src/session_manager_agent_controller.cpp | 13 +++ .../zidl/scene_session_manager_lite_proxy.cpp | 32 ++++++ .../zidl/scene_session_manager_lite_stub.cpp | 23 ++++ .../scene_session_manager_lite_stub_test.cpp | 4 + wm/include/window_adapter_lite.h | 1 + wm/include/window_manager_agent.h | 3 +- wm/include/window_manager_agent_lite.h | 1 + .../zidl/window_manager_agent_interface.h | 3 + wm/include/zidl/window_manager_agent_proxy.h | 1 + wm/src/window_adapter_lite.cpp | 10 ++ wm/src/window_manager.cpp | 2 + wm/src/window_manager_agent_lite.cpp | 5 + wm/src/window_manager_lite.cpp | 103 ++++++++++++++++++ wm/src/zidl/window_manager_agent_proxy.cpp | 25 +++++ wm/src/zidl/window_manager_agent_stub.cpp | 9 ++ .../zidl/window_manager_lite_interface.h | 1 + 27 files changed, 381 insertions(+), 1 deletion(-) diff --git a/interfaces/innerkits/wm/window_manager.h b/interfaces/innerkits/wm/window_manager.h index 666d173153..be154c0340 100644 --- a/interfaces/innerkits/wm/window_manager.h +++ b/interfaces/innerkits/wm/window_manager.h @@ -193,6 +193,21 @@ public: virtual void OnWindowStyleUpdate(WindowStyleType styleType) = 0; }; +/** + * @class IKeyboardCallingWindowDisplayChangeListener + * + * @brief Observe the display change of keyboard callingWindow. + */ +class IKeyboardCallingWindowDisplayChangeListener : virtual public RefBase { +public: + /** + * @brief Notify caller when calling window display changed. + * + * @param callingWindowInfo The information about the calling window. + */ + virtual void OnCallingWindowDisplayChanged(CallingWindowInfo callingWindowInfo) = 0; +}; + /** * @class IWindowPidVisibilityChangedListener * @@ -920,6 +935,30 @@ public: */ WMError UnregisterWindowStyleChangedListener(const sptr& listener); + /** + * @brief Register keyboard calling window display change listener. + * + * @param listener IKeyboardCallingWindowDisplayChangeListener + * @return WM_OK means register success, others means unregister failed. + */ + WMError RegisterCallingWindowDisplayChangeListener( + const sptr& listener) + { + return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; + } + + /** + * @brief Unregister keyboard calling window display change listener. + * + * @param listener IKeyboardCallingWindowDisplayChangeListener + * @return WM_OK means unregister success, others means unregister failed. + */ + WMError UnregisterCallingWindowDisplayChangeListener( + const sptr& listener) + { + return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; + } + /** * @brief Skip Snapshot for app process. * @@ -1054,6 +1093,7 @@ private: void NotifyGestureNavigationEnabledResult(bool enable) const; void UpdateVisibleWindowNum(const std::vector& visibleWindowNumInfo); WMError NotifyWindowStyleChange(WindowStyleType type); + WMError NotifyCallingWindowDisplayChanged(const CallingWindowInfo& callingWindowInfo) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; } void NotifyWindowPidVisibilityChanged(const sptr& info) const; }; } // namespace Rosen diff --git a/interfaces/innerkits/wm/window_manager_lite.h b/interfaces/innerkits/wm/window_manager_lite.h index 14c7c6b40e..839a009586 100644 --- a/interfaces/innerkits/wm/window_manager_lite.h +++ b/interfaces/innerkits/wm/window_manager_lite.h @@ -154,6 +154,14 @@ public: */ WMError GetMainWindowInfos(int32_t topNum, std::vector& topNInfo); + /** + * @brief Get keyboard calling window info. + * + * @param callingWindowInfo calling window info + * @return WM_OK means get success, others means get failed. + */ + WMError GetCallingWindowInfo(CallingWindowInfo& callingWindowInfo); + /** * @brief Get all main window info. * @@ -222,6 +230,24 @@ public: */ WMError UnregisterWindowStyleChangedListener(const sptr& listener); + /** + * @brief Register keyboard calling window display change listener. + * + * @param listener IKeyboardCallingWindowDisplayChangeListener + * @return WM_OK means register success, others means unregister failed. + */ + WMError RegisterCallingWindowDisplayChangeListener( + const sptr& listener); + + /** + * @brief Unregister keyboard calling window display change listener. + * + * @param listener IKeyboardCallingWindowDisplayChangeListener + * @return WM_OK means unregister success, others means unregister failed. + */ + WMError UnregisterCallingWindowDisplayChangeListener( + const sptr& listener); + /** * @brief Get window style type. * @@ -325,6 +351,7 @@ private: WMError NotifyWindowStyleChange(WindowStyleType type); void NotifyAccessibilityWindowInfo(const std::vector>& infos, WindowUpdateType type) const; + WMError NotifyCallingWindowDisplayChanged(const CallingWindowInfo& callingWindowInfo); }; } // namespace Rosen } // namespace OHOS diff --git a/interfaces/innerkits/wm/wm_common.h b/interfaces/innerkits/wm/wm_common.h index 23b7885550..3ccaa1fef4 100644 --- a/interfaces/innerkits/wm/wm_common.h +++ b/interfaces/innerkits/wm/wm_common.h @@ -939,6 +939,38 @@ struct KeyboardPanelInfo : public Parcelable { } }; +/** + * @struct CallingWindowInfo + * + * @brief Info of keyboard calling window + */ +struct CallingWindowInfo : public Parcelable { + int32_t windowId_ = 0; + int32_t callingPid_ = -1; + DisplayId displayId_ = 0; + int32_t userId_ = 0; + + CallingWindowInfo() {} + CallingWindowInfo(int32_t windowId, int32_t callingPid, DisplayId displayId, int32_t userId) + : windowId_(windowId), callingPid_(callingPid), displayId_(displayId), userId_(userId) {} + + bool Marshalling(Parcel& parcel) const + { + return parcel.WriteInt32(windowId_) && parcel.WriteInt32(callingPid_) && + parcel.WriteUint64(displayId_) && parcel.WriteInt32(userId_); + } + + static CallingWindowInfo* Unmarshalling(Parcel& parcel) + { + sptr callingWindowInfo = sptr::MakeSptr(); + if (!(parcel.ReadInt32(callingWindowInfo->windowId_) && parcel.ReadInt32(callingWindowInfo->callingPid_) && + parcel.ReadUint64(callingWindowInfo->displayId_) && parcel.ReadInt32(callingWindowInfo->userId_))) { + callingWindowInfo = nullptr; + } + return callingWindowInfo; + } +}; + /** * @brief Enumerates avoid area type. */ diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index c17491dd47..00e09dbdea 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -609,6 +609,7 @@ public: int32_t StartUIAbilityBySCB(sptr& abilitySessionInfo); int32_t StartUIAbilityBySCB(sptr& sceneSessions); WMError GetMainWindowInfos(int32_t topNum, std::vector& topNInfo); + WMError GetCallingWindowInfo(CallingWindowInfo& callingWindowInfo); WMError GetAllMainWindowInfos(std::vector& infos) const; WMError ClearMainSessions(const std::vector& persistentIds, std::vector& clearFailedIds); WMError TerminateSessionByPersistentId(int32_t persistentId); diff --git a/window_scene/session_manager/include/scene_session_manager_lite.h b/window_scene/session_manager/include/scene_session_manager_lite.h index 0344a2b55a..2729d586a3 100644 --- a/window_scene/session_manager/include/scene_session_manager_lite.h +++ b/window_scene/session_manager/include/scene_session_manager_lite.h @@ -83,6 +83,7 @@ public: WMError LockSessionByAbilityInfo(const AbilityInfoBase& abilityInfo, bool isLock) override; WMError HasFloatingWindowForeground(const sptr& abilityToken, bool& hasOrNot) override; + WMError GetCallingWindowInfo(CallingWindowInfo& callingWindowInfo) override; }; } // namespace OHOS::Rosen diff --git a/window_scene/session_manager/include/session_manager_agent_controller.h b/window_scene/session_manager/include/session_manager_agent_controller.h index 0e4a06a87e..8fdbf54293 100644 --- a/window_scene/session_manager/include/session_manager_agent_controller.h +++ b/window_scene/session_manager/include/session_manager_agent_controller.h @@ -47,6 +47,7 @@ public: void UpdateCameraWindowStatus(uint32_t accessTokenId, bool isShowing); void NotifyGestureNavigationEnabledResult(bool enable); void NotifyWindowStyleChange(WindowStyleType type); + void NotifyCallingWindowDisplayChanged(const CallingWindowInfo& callingWindowInfo); void NotifyWindowPidVisibilityChanged(const sptr& info); void UpdatePiPWindowStateChanged(const std::string& bundleName, bool isForeground); diff --git a/window_scene/session_manager/include/zidl/scene_session_manager_lite_interface.h b/window_scene/session_manager/include/zidl/scene_session_manager_lite_interface.h index fc488ac4e2..e87b77490b 100644 --- a/window_scene/session_manager/include/zidl/scene_session_manager_lite_interface.h +++ b/window_scene/session_manager/include/zidl/scene_session_manager_lite_interface.h @@ -86,6 +86,7 @@ public: TRANS_ID_MINIMIZE_MAIN_SESSION, TRANS_ID_LOCK_SESSION_BY_ABILITY_INFO, TRANS_ID_HAS_FLOAT_FOREGROUND, + TRANS_ID_GET_CALLING_WINDOW_INFO, }; /* diff --git a/window_scene/session_manager/include/zidl/scene_session_manager_lite_proxy.h b/window_scene/session_manager/include/zidl/scene_session_manager_lite_proxy.h index 117a325f0c..fecc8177c4 100644 --- a/window_scene/session_manager/include/zidl/scene_session_manager_lite_proxy.h +++ b/window_scene/session_manager/include/zidl/scene_session_manager_lite_proxy.h @@ -73,6 +73,7 @@ public: WMError GetVisibilityWindowInfo(std::vector>& infos) override; WMError GetWindowModeType(WindowModeType& windowModeType) override; WMError GetMainWindowInfos(int32_t topNum, std::vector& topNInfo) override; + WMError GetCallingWindowInfo(CallingWindowInfo& callingWindowInfo) override; WMError GetAllMainWindowInfos(std::vector& infos) override; WMError ClearMainSessions(const std::vector& persistentIds, std::vector& clearFailedIds) override; WSError RaiseWindowToTop(int32_t persistentId) override; diff --git a/window_scene/session_manager/include/zidl/scene_session_manager_lite_stub.h b/window_scene/session_manager/include/zidl/scene_session_manager_lite_stub.h index be33ba7416..3fc7d34602 100644 --- a/window_scene/session_manager/include/zidl/scene_session_manager_lite_stub.h +++ b/window_scene/session_manager/include/zidl/scene_session_manager_lite_stub.h @@ -63,6 +63,7 @@ private: int HandleGetVisibilityWindowInfo(MessageParcel& data, MessageParcel& reply); int HandleGetWindowModeType(MessageParcel& data, MessageParcel& reply); int HandleGetMainWinodowInfo(MessageParcel& data, MessageParcel& reply); + int HandleGetCallingWindowInfo(MessageParcel& data, MessageParcel& reply); int HandleGetAllMainWindowInfos(MessageParcel& data, MessageParcel& reply); int HandleClearMainSessions(MessageParcel& data, MessageParcel& reply); int HandleRaiseWindowToTop(MessageParcel& data, MessageParcel& reply); diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index e7339c99fa..a0993b14fb 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -10373,6 +10373,20 @@ WSError SceneSessionManager::UpdateSessionDisplayId(int32_t persistentId, uint64 NotifySessionUpdate(sceneSession->GetSessionInfo(), ActionType::MOVE_DISPLAY, fromScreenId); sceneSession->NotifyDisplayMove(fromScreenId, screenId); sceneSession->UpdateDensity(); + + const auto& keyboardSessionVec = GetSceneSessionVectorByType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT); + for (const auto& keyboardSession : keyboardSessionVec) { + if (keyboardSession) { + TLOGI(WmsLogTag::WMS_KEYBOARD, "isSystemKeyboard: %{public}d, callingSessionId: %{public}d", + keyboardSession->IsSystemKeyboard(), keyboardSession->GetCallingSessionId()); + } + if (keyboardSession && !keyboardSession->IsSystemKeyboard() && + static_cast(keyboardSession->GetCallingSessionId()) == persistentId) { + CallingWindowInfo callingWindowInfo(persistentId, sceneSession->GetCallingPid(), screenId, sceneSession->GetCallingUid()); + SessionManagerAgentController::GetInstance().NotifyCallingWindowDisplayChanged(callingWindowInfo); + break; + } + } return WSError::WS_OK; } @@ -12140,6 +12154,28 @@ WMError SceneSessionManager::GetMainWindowInfos(int32_t topNum, std::vector
GetCallingUid(); + if (curUserId != callingWindowInfo.userId_) { + TLOGE(WmsLogTag::WMS_KEYBOARD, "Target user not exists,targetUserId: %{public}d, curUserId: %{public}d, id: %{public}d", + callingWindowInfo.userId_, curUserId, callingWindowInfo.windowId_); + return WMError::WM_ERROR_INVALID_PARAM; + } + + callingWindowInfo.callingPid_ = sceneSession->GetCallingPid(); + callingWindowInfo.displayId_ = sceneSession->GetSessionProperty()->GetDisplayId(); + TLOGI(WmsLogTag::WMS_KEYBOARD, "callingWindow id: %{public}d,pid: %{public}d,displayId: %{public}" PRIu64" , curUserId: %{public}d", + callingWindowInfo.windowId_, callingWindowInfo.callingPid_, callingWindowInfo.displayId_, curUserId); + return WMError::WM_OK; +} + WMError SceneSessionManager::GetWindowIdsByCoordinate(DisplayId displayId, int32_t windowNumber, int32_t x, int32_t y, std::vector& windowIds) { diff --git a/window_scene/session_manager/src/scene_session_manager_lite.cpp b/window_scene/session_manager/src/scene_session_manager_lite.cpp index e97ed30f31..9c0ba6faa5 100644 --- a/window_scene/session_manager/src/scene_session_manager_lite.cpp +++ b/window_scene/session_manager/src/scene_session_manager_lite.cpp @@ -217,6 +217,11 @@ WMError SceneSessionManagerLite::GetMainWindowInfos(int32_t topNum, std::vector< return SceneSessionManager::GetInstance().GetMainWindowInfos(topNum, topNInfo); } +WMError SceneSessionManagerLite::GetCallingWindowInfo(CallingWindowInfo& callingWindowInfo) +{ + return SceneSessionManager::GetInstance().GetCallingWindowInfo(callingWindowInfo); +} + WMError SceneSessionManagerLite::GetAllMainWindowInfos(std::vector& infos) { return SceneSessionManager::GetInstance().GetAllMainWindowInfos(infos); diff --git a/window_scene/session_manager/src/session_manager_agent_controller.cpp b/window_scene/session_manager/src/session_manager_agent_controller.cpp index 1ef677777b..e721a20f94 100644 --- a/window_scene/session_manager/src/session_manager_agent_controller.cpp +++ b/window_scene/session_manager/src/session_manager_agent_controller.cpp @@ -228,6 +228,19 @@ void SessionManagerAgentController::NotifyWindowStyleChange(WindowStyleType type } } +void SessionManagerAgentController::NotifyCallingWindowDisplayChanged(const CallingWindowInfo& callingWindowInfo) +{ + TLOGD(WmsLogTag::WMS_KEYBOARD, + "notify userId: %{public}d, displayId: %{public}d, persistentId: %{public}d", + callingWindowInfo.userId_, static_cast(callingWindowInfo.displayId_), callingWindowInfo.windowId_); + for (const auto& agent : smAgentContainer_.GetAgentsByType( + WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_CALLING_DISPLAY)) { + if (agent != nullptr) { + agent->NotifyCallingWindowDisplayChanged(callingWindowInfo); + } + } +} + void SessionManagerAgentController::NotifyWindowPidVisibilityChanged( const sptr& info) { diff --git a/window_scene/session_manager/src/zidl/scene_session_manager_lite_proxy.cpp b/window_scene/session_manager/src/zidl/scene_session_manager_lite_proxy.cpp index 803b001c11..ddd57643aa 100644 --- a/window_scene/session_manager/src/zidl/scene_session_manager_lite_proxy.cpp +++ b/window_scene/session_manager/src/zidl/scene_session_manager_lite_proxy.cpp @@ -1048,6 +1048,38 @@ WMError SceneSessionManagerLiteProxy::GetMainWindowInfos(int32_t topNum, std::ve return static_cast(reply.ReadInt32()); } +WMError SceneSessionManagerLiteProxy::GetCallingWindowInfo(CallingWindowInfo& callingWindowInfo) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + if (!data.WriteInterfaceToken(GetDescriptor())) { + TLOGE(WmsLogTag::WMS_KEYBOARD, "WriteInterfaceToken failed"); + return WMError::WM_ERROR_IPC_FAILED; + } + if (!data.WriteParcelable(&callingWindowInfo)) { + TLOGE(WmsLogTag::WMS_KEYBOARD, "persistentId and userId write failed, id: %{public}d, userId: %{public}d", + callingWindowInfo.windowId_, callingWindowInfo.userId_); + return WMError::WM_ERROR_IPC_FAILED; + } + sptr remote = Remote(); + if (remote == nullptr) { + TLOGE(WmsLogTag::WMS_KEYBOARD, "remote is null"); + return WMError::WM_ERROR_IPC_FAILED; + } + if (remote->SendRequest(static_cast(SceneSessionManagerLiteMessage::TRANS_ID_GET_CALLING_WINDOW_INFO), + data, reply, option) != ERR_NONE) { + TLOGE(WmsLogTag::WMS_KEYBOARD, "SendRequest failed"); + return WMError::WM_ERROR_IPC_FAILED; + } + + if (!(static_cast(reply.ReadInt32()) == WMError::WM_OK && reply.ReadParcelable())) { + TLOGE(WmsLogTag::WMS_KEYBOARD, "Read callingWindow info failed"); + return WMError::WM_ERROR_IPC_FAILED; + } + return WMError::WM_OK; +} + WSError SceneSessionManagerLiteProxy::RegisterIAbilityManagerCollaborator(int32_t type, const sptr& impl) { diff --git a/window_scene/session_manager/src/zidl/scene_session_manager_lite_stub.cpp b/window_scene/session_manager/src/zidl/scene_session_manager_lite_stub.cpp index 92ff36763d..33409de024 100644 --- a/window_scene/session_manager/src/zidl/scene_session_manager_lite_stub.cpp +++ b/window_scene/session_manager/src/zidl/scene_session_manager_lite_stub.cpp @@ -135,6 +135,8 @@ int SceneSessionManagerLiteStub::ProcessRemoteRequest(uint32_t code, MessageParc return HandleHasFloatingWindowForeground(data, reply); case static_cast(SceneSessionManagerLiteMessage::TRANS_ID_LOCK_SESSION_BY_ABILITY_INFO): return HandleLockSessionByAbilityInfo(data, reply); + case static_cast(SceneSessionManagerLiteMessage::TRANS_ID_GET_CALLING_WINDOW_INFO): + return HandleGetCallingWindowInfo(data, reply); default: WLOGFE("Failed to find function handler!"); return IPCObjectStub::OnRemoteRequest(code, data, reply, option); @@ -696,6 +698,27 @@ int SceneSessionManagerLiteStub::HandleGetMainWinodowInfo(MessageParcel& data, M return ERR_NONE; } +int SceneSessionManagerLiteStub::HandleGetCallingWindowInfo(MessageParcel& data, MessageParcel& reply) +{ + TLOGD(WmsLogTag::WMS_KEYBOARD, "In"); + sptr callingWindowInfo = data.ReadParcelable(); + if (callingWindowInfo == nullptr) { + TLOGE(WmsLogTag::WMS_KEYBOARD, "Read persistentId and userId failed."); + return ERR_INVALID_DATA; + } + WMError ret = GetCallingWindowInfo(*callingWindowInfo); + if (ret != WMError::WM_OK) { + TLOGE(WmsLogTag::WMS_KEYBOARD, "id: %{public}d, failed to get calling window info", + callingWindowInfo->windowId_); + return ERR_INVALID_DATA; + } + if (!(reply.WriteInt32(static_cast(ret)) && reply.WriteParcelable(callingWindowInfo))) { + TLOGE(WmsLogTag::WMS_KEYBOARD, "Write callingWindowInfo failed, id: %{public}d", callingWindowInfo->windowId_); + return ERR_INVALID_DATA; + } + return ERR_NONE; +} + int SceneSessionManagerLiteStub::HandleGetAllMainWindowInfos(MessageParcel& data, MessageParcel& reply) { std::vector infos; diff --git a/window_scene/test/unittest/scene_session_manager_lite_stub_test.cpp b/window_scene/test/unittest/scene_session_manager_lite_stub_test.cpp index 4721c84e56..1628c47a77 100644 --- a/window_scene/test/unittest/scene_session_manager_lite_stub_test.cpp +++ b/window_scene/test/unittest/scene_session_manager_lite_stub_test.cpp @@ -146,6 +146,10 @@ class MockSceneSessionManagerLiteStub : public SceneSessionManagerLiteStub { infos.push_back(mainWindowInfo); return WMError::WM_OK; } + WMError GetCallingWindowInfo(CallingWindowInfo& callingWindowInfo) override + { + return WMError::WM_OK; + } WMError ClearMainSessions(const std::vector& persistentIds, std::vector& clearFailedIds) override { diff --git a/wm/include/window_adapter_lite.h b/wm/include/window_adapter_lite.h index 85e052f600..6fbfcd2fa4 100644 --- a/wm/include/window_adapter_lite.h +++ b/wm/include/window_adapter_lite.h @@ -47,6 +47,7 @@ public: virtual WMError GetWindowModeType(WindowModeType& windowModeType); virtual WMError RaiseWindowToTop(int32_t persistentId); virtual WMError GetMainWindowInfos(int32_t topNum, std::vector& topNInfo); + virtual WMError GetCallingWindowInfo(CallingWindowInfo& callingWindowInfo); WMError RegisterWMSConnectionChangedListener(const WMSConnectionChangedCallbackFunc& callbackFunc); virtual WMError GetAllMainWindowInfos(std::vector& infos); virtual WMError ClearMainSessions(const std::vector& persistentIds); diff --git a/wm/include/window_manager_agent.h b/wm/include/window_manager_agent.h index 8b21346c8b..5f8a3a5cb7 100644 --- a/wm/include/window_manager_agent.h +++ b/wm/include/window_manager_agent.h @@ -40,9 +40,10 @@ public: void NotifyGestureNavigationEnabledResult(bool enable) override; void UpdateCameraWindowStatus(uint32_t accessTokenId, bool isShowing) override {}; void NotifyWindowStyleChange(WindowStyleType type) override; + void NotifyCallingWindowDisplayChanged(const CallingWindowInfo& callingWindowInfo) override {}; void NotifyWindowPidVisibilityChanged(const sptr& info) override; void UpdatePiPWindowStateChanged(const std::string& bundleName, bool isForeground) override {} }; } // namespace Rosen } // namespace OHOS -#endif // OHOS_WINDOW_MANAGER_AGENT_H +#endif // OHOS_WINDOW_MANAGER_AGENT_H \ No newline at end of file diff --git a/wm/include/window_manager_agent_lite.h b/wm/include/window_manager_agent_lite.h index 37a7fab769..baa4a98447 100644 --- a/wm/include/window_manager_agent_lite.h +++ b/wm/include/window_manager_agent_lite.h @@ -40,6 +40,7 @@ public: void NotifyGestureNavigationEnabledResult(bool enable) override {}; void UpdateCameraWindowStatus(uint32_t accessTokenId, bool isShowing) override; void NotifyWindowStyleChange(WindowStyleType type) override; + void NotifyCallingWindowDisplayChanged(const CallingWindowInfo& callingWindowInfo) override; void NotifyWindowPidVisibilityChanged(const sptr& info) override {}; void UpdatePiPWindowStateChanged(const std::string& bundleName, bool isForeground) override; }; diff --git a/wm/include/zidl/window_manager_agent_interface.h b/wm/include/zidl/window_manager_agent_interface.h index ed46d94843..cbedaa767c 100644 --- a/wm/include/zidl/window_manager_agent_interface.h +++ b/wm/include/zidl/window_manager_agent_interface.h @@ -37,6 +37,7 @@ enum class WindowManagerAgentType : uint32_t { WINDOW_MANAGER_AGENT_TYPE_WINDOW_STYLE, WINDOW_MANAGER_AGENT_TYPE_WINDOW_PID_VISIBILITY, WINDOW_MANAGER_AGENT_TYPE_PIP, + WINDOW_MANAGER_AGENT_TYPE_CALLING_DISPLAY, WINDOW_MANAGER_AGENT_TYPE_END, }; @@ -59,6 +60,7 @@ public: TRANS_ID_UPDATE_WINDOW_STYLE_TYPE, TRANS_ID_NOTIFY_WINDOW_PID_VISIBILITY, TRANS_ID_UPDATE_PIP_WINDOW_STATE_CHANGED, + TRANS_ID_NOTIFY_CALLING_DISPLAY_CHANGE, }; virtual void UpdateFocusChangeInfo(const sptr& focusChangeInfo, bool focused) = 0; @@ -75,6 +77,7 @@ public: virtual void NotifyGestureNavigationEnabledResult(bool enable) = 0; virtual void UpdateCameraWindowStatus(uint32_t accessTokenId, bool isShowing) = 0; virtual void NotifyWindowStyleChange(WindowStyleType type) = 0; + virtual void NotifyCallingWindowDisplayChanged(const CallingWindowInfo& callingWindowInfo) = 0; virtual void NotifyWindowPidVisibilityChanged(const sptr& info) = 0; virtual void UpdatePiPWindowStateChanged(const std::string& bundleName, bool isForeground) = 0; }; diff --git a/wm/include/zidl/window_manager_agent_proxy.h b/wm/include/zidl/window_manager_agent_proxy.h index 20885b62a6..1116d1527e 100644 --- a/wm/include/zidl/window_manager_agent_proxy.h +++ b/wm/include/zidl/window_manager_agent_proxy.h @@ -41,6 +41,7 @@ public: void NotifyGestureNavigationEnabledResult(bool enable) override; void UpdateCameraWindowStatus(uint32_t accessTokenId, bool isShowing) override; void NotifyWindowStyleChange(WindowStyleType type) override; + void NotifyCallingWindowDisplayChanged(const CallingWindowInfo& callingWindowInfo) override; void NotifyWindowPidVisibilityChanged(const sptr& info) override; void UpdatePiPWindowStateChanged(const std::string& bundleName, bool isForeground) override; diff --git a/wm/src/window_adapter_lite.cpp b/wm/src/window_adapter_lite.cpp index 5c85744170..b1f6b90fca 100644 --- a/wm/src/window_adapter_lite.cpp +++ b/wm/src/window_adapter_lite.cpp @@ -229,6 +229,16 @@ WMError WindowAdapterLite::GetMainWindowInfos(int32_t topNum, std::vectorGetMainWindowInfos(topNum, topNInfo); } +WMError WindowAdapterLite::GetCallingWindowInfo(CallingWindowInfo& callingWindowInfo) +{ + INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR); + TLOGD(WmsLogTag::WMS_KEYBOARD, "get calling window info"); + + auto wmsProxy = GetWindowManagerServiceProxy(); + CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_ERROR_SAMGR); + return wmsProxy->GetCallingWindowInfo(callingWindowInfo); +} + WMError WindowAdapterLite::GetAllMainWindowInfos(std::vector& infos) { INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR); diff --git a/wm/src/window_manager.cpp b/wm/src/window_manager.cpp index fec4c9740b..e32cea768f 100644 --- a/wm/src/window_manager.cpp +++ b/wm/src/window_manager.cpp @@ -97,6 +97,8 @@ public: std::vector>> displayInfoChangedListeners_; std::vector> windowPidVisibilityListeners_; sptr windowPidVisibilityListenerAgent_; + std::vector> callingDisplayChangedListeners_; + sptr callingDisplayListenerAgent_; }; void WindowManager::Impl::NotifyWMSConnected(int32_t userId, int32_t screenId) diff --git a/wm/src/window_manager_agent_lite.cpp b/wm/src/window_manager_agent_lite.cpp index df0825c826..1afd779885 100644 --- a/wm/src/window_manager_agent_lite.cpp +++ b/wm/src/window_manager_agent_lite.cpp @@ -52,6 +52,11 @@ void WindowManagerAgentLite::NotifyWindowStyleChange(WindowStyleType type) SingletonContainer::Get().NotifyWindowStyleChange(type); } +void WindowManagerAgentLite::NotifyCallingWindowDisplayChanged(const CallingWindowInfo& callingWindowInfo) +{ + SingletonContainer::Get().NotifyCallingWindowDisplayChanged(callingWindowInfo); +} + void WindowManagerAgentLite::UpdatePiPWindowStateChanged(const std::string& bundleName, bool isForeground) { SingletonContainer::Get().UpdatePiPWindowStateChanged(bundleName, isForeground); diff --git a/wm/src/window_manager_lite.cpp b/wm/src/window_manager_lite.cpp index 2a0274eccb..f2d5cd188d 100644 --- a/wm/src/window_manager_lite.cpp +++ b/wm/src/window_manager_lite.cpp @@ -49,6 +49,7 @@ public: void NotifyWMSConnected(int32_t userId, int32_t screenId); void NotifyWMSDisconnected(int32_t userId, int32_t screenId); void NotifyWindowStyleChange(WindowStyleType type); + void NotifyCallingWindowDisplayChanged(const CallingWindowInfo& callingWindowInfo); void UpdatePiPWindowStateChanged(const std::string& bundleName, bool isForeground); void NotifyAccessibilityWindowInfo(const std::vector>& infos, WindowUpdateType type); @@ -73,6 +74,8 @@ public: sptr windowStyleListenerAgent_; std::vector> pipStateChangedListeners_; sptr pipStateChangedListenerAgent_; + std::vector>callingDisplayChangedListeners_; + sptr callingDisplayListenerAgent_; }; void WindowManagerLite::Impl::NotifyWMSConnected(int32_t userId, int32_t screenId) @@ -258,6 +261,28 @@ void WindowManagerLite::Impl::NotifyWindowStyleChange(WindowStyleType type) } } +void WindowManagerLite::Impl::NotifyCallingWindowDisplayChanged(const CallingWindowInfo& callingWindowInfo) +{ + std::vector> displayChangeListeners; + { + std::lock_guard lock(mutex_); + displayChangeListeners = callingDisplayChangedListeners_; + } + + TLOGI(WmsLogTag::WMS_KEYBOARD, "notify userId: %{public}d, displayId: %{public}" PRIu64 + " ,persistentId: %{public}d, num: %{public}" PRIu32" ", + callingWindowInfo.userId_, callingWindowInfo.displayId_, + callingWindowInfo.windowId_, static_cast(callingDisplayChangedListeners_.size())); + + for (const auto& listener : callingDisplayChangedListeners_) { + if (!listener) { + TLOGE(WmsLogTag::WMS_KEYBOARD, "listener is nullptr"); + continue; + } + listener->OnCallingWindowDisplayChanged(callingWindowInfo); + } +} + void WindowManagerLite::Impl::UpdatePiPWindowStateChanged(const std::string& bundleName, bool isForeground) { std::vector> pipStateChangedListeners; @@ -645,6 +670,11 @@ WMError WindowManagerLite::GetMainWindowInfos(int32_t topNum, std::vector().GetMainWindowInfos(topNum, topNInfo); } +WMError WindowManagerLite::GetCallingWindowInfo(CallingWindowInfo& callingWindowInfo) +{ + return SingletonContainer::Get().GetCallingWindowInfo(callingWindowInfo); +} + WMError WindowManagerLite::RegisterWMSConnectionChangedListener(const sptr& listener) { int32_t clientUserId = GetUserIdByUid(getuid()); @@ -725,6 +755,12 @@ WMError WindowManagerLite::NotifyWindowStyleChange(WindowStyleType type) return WMError::WM_OK; } +WMError WindowManagerLite::NotifyCallingWindowDisplayChanged(const CallingWindowInfo& callingWindowInfo) +{ + pImpl_->NotifyCallingWindowDisplayChanged(callingWindowInfo); + return WMError::WM_OK; +} + WMError WindowManagerLite::RegisterWindowStyleChangedListener(const sptr& listener) { TLOGI(WmsLogTag::WMS_MAIN, "start register windowStyleChangedListener"); @@ -787,6 +823,73 @@ WMError WindowManagerLite::UnregisterWindowStyleChangedListener(const sptr& listener) +{ + TLOGI(WmsLogTag::WMS_KEYBOARD, "start register callingDisplayChangeListener"); + if (listener == nullptr) { + TLOGE(WmsLogTag::WMS_KEYBOARD, "listener could not be null"); + return WMError::WM_ERROR_NULLPTR; + } + { + std::lock_guard lock(pImpl_->mutex_); + if (pImpl_->callingDisplayListenerAgent_ == nullptr) { + pImpl_->callingDisplayListenerAgent_ = new WindowManagerAgentLite(); + } + auto iter = std::find(pImpl_->callingDisplayChangedListeners_.begin(), + pImpl_->callingDisplayChangedListeners_.end(), listener); + if (iter != pImpl_->callingDisplayChangedListeners_.end()) { + TLOGE(WmsLogTag::WMS_KEYBOARD, "listener is already registered"); + return WMError::WM_OK; + } + pImpl_->callingDisplayChangedListeners_.emplace_back(listener); + } + WMError ret = WMError::WM_OK; + ret = SingletonContainer::Get().RegisterWindowManagerAgent( + WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_CALLING_DISPLAY, pImpl_->callingDisplayListenerAgent_); + if (ret != WMError::WM_OK) { + TLOGW(WmsLogTag::WMS_KEYBOARD, "Register agent failed!"); + std::lock_guard lock(pImpl_->mutex_); + pImpl_->callingDisplayListenerAgent_ = nullptr; + auto iter = std::find(pImpl_->callingDisplayChangedListeners_.begin(), + pImpl_->callingDisplayChangedListeners_.end(), listener); + if (iter != pImpl_->callingDisplayChangedListeners_.end()) { + pImpl_->callingDisplayChangedListeners_.erase(iter); + } + } + return ret; +} + +WMError WindowManagerLite::UnregisterCallingWindowDisplayChangeListener( + const sptr& listener) +{ + TLOGI(WmsLogTag::WMS_KEYBOARD, "start unRegister callingDisplayChangeListener"); + if (listener == nullptr) { + TLOGE(WmsLogTag::WMS_KEYBOARD, "listener could not be null"); + return WMError::WM_ERROR_NULLPTR; + } + { + std::lock_guard lock(pImpl_->mutex_); + auto iter = std::find(pImpl_->callingDisplayChangedListeners_.begin(), + pImpl_->callingDisplayChangedListeners_.end(), listener); + if (iter == pImpl_->callingDisplayChangedListeners_.end()) { + TLOGE(WmsLogTag::WMS_KEYBOARD, "could not find this listener"); + return WMError::WM_OK; + } + pImpl_->callingDisplayChangedListeners_.erase(iter); + } + WMError ret = WMError::WM_OK; + if (pImpl_->callingDisplayChangedListeners_.empty() && pImpl_->callingDisplayListenerAgent_ != nullptr) { + ret = SingletonContainer::Get().UnregisterWindowManagerAgent( + WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_CALLING_DISPLAY, pImpl_->callingDisplayListenerAgent_); + if (ret == WMError::WM_OK) { + std::lock_guard lock(pImpl_->mutex_); + pImpl_->callingDisplayListenerAgent_ = nullptr; + } + } + return ret; +} + WindowStyleType WindowManagerLite::GetWindowStyleType() { WindowStyleType styleType; diff --git a/wm/src/zidl/window_manager_agent_proxy.cpp b/wm/src/zidl/window_manager_agent_proxy.cpp index cdacca9865..b1f6d88a19 100644 --- a/wm/src/zidl/window_manager_agent_proxy.cpp +++ b/wm/src/zidl/window_manager_agent_proxy.cpp @@ -381,6 +381,31 @@ void WindowManagerAgentProxy::NotifyWindowStyleChange(WindowStyleType type) } } +void WindowManagerAgentProxy::NotifyCallingWindowDisplayChanged(const CallingWindowInfo& callingWindowInfo) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option(MessageOption::TF_ASYNC); + if (!data.WriteInterfaceToken(GetDescriptor())) { + TLOGE(WmsLogTag::WMS_KEYBOARD, "WriteInterfaceToken failed"); + return; + } + if (!data.WriteParcelable(&callingWindowInfo)) { + TLOGE(WmsLogTag::WMS_KEYBOARD, "Write callingWindowInfo failed"); + return; + } + + sptr remote = Remote(); + if (remote == nullptr) { + TLOGE(WmsLogTag::WMS_KEYBOARD, "remote is null"); + return; + } + if (remote->SendRequest(static_cast(WindowManagerAgentMsg::TRANS_ID_NOTIFY_CALLING_DISPLAY_CHANGE), + data, reply, option) != ERR_NONE) { + TLOGE(WmsLogTag::WMS_KEYBOARD, "SendRequest calling display info change failed"); + } +} + void WindowManagerAgentProxy::NotifyWindowPidVisibilityChanged(const sptr& info) { MessageParcel data; diff --git a/wm/src/zidl/window_manager_agent_stub.cpp b/wm/src/zidl/window_manager_agent_stub.cpp index 39bea2a1dc..f44435f626 100644 --- a/wm/src/zidl/window_manager_agent_stub.cpp +++ b/wm/src/zidl/window_manager_agent_stub.cpp @@ -192,6 +192,15 @@ int WindowManagerAgentStub::OnRemoteRequest(uint32_t code, MessageParcel& data, UpdatePiPWindowStateChanged(bundleName, isForeground); break; } + case WindowManagerAgentMsg::TRANS_ID_NOTIFY_CALLING_DISPLAY_CHANGE: { + sptr callingWindowInfo = data.ReadParcelable(); + if (callingWindowInfo == nullptr) { + TLOGE(WmsLogTag::WMS_KEYBOARD, "callingWindowInfo is nullptr!"); + return ERR_INVALID_VALUE; + } + NotifyCallingWindowDisplayChanged(*callingWindowInfo); + break; + } default: WLOGFW("unknown transaction code %{public}d", code); return IPCObjectStub::OnRemoteRequest(code, data, reply, option); diff --git a/wmserver/include/zidl/window_manager_lite_interface.h b/wmserver/include/zidl/window_manager_lite_interface.h index a88866d401..a375b867a4 100644 --- a/wmserver/include/zidl/window_manager_lite_interface.h +++ b/wmserver/include/zidl/window_manager_lite_interface.h @@ -44,6 +44,7 @@ public: AppExecFwk::ExtensionAbilityType extensionAbilityType, int32_t& pid) = 0; virtual WMError GetWindowModeType(WindowModeType& windowModeType) { return WMError::WM_OK; } virtual WMError GetMainWindowInfos(int32_t topNum, std::vector& topNInfo) = 0; + virtual WMError GetCallingWindowInfo(CallingWindowInfo& callingWindowInfo) = 0; virtual WMError GetAllMainWindowInfos(std::vector& infos) = 0; virtual WMError ClearMainSessions(const std::vector& persistentIds, std::vector& clearFailedIds) = 0; -- Gitee From e965cef0c99cfa4076af8044b6a1d2aa648035d0 Mon Sep 17 00:00:00 2001 From: liaoqingxing Date: Fri, 7 Mar 2025 20:42:19 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=A3=80=E8=A7=86?= =?UTF-8?q?=E6=84=8F=E8=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liaoqingxing --- interfaces/innerkits/wm/window_manager.h | 2 +- interfaces/innerkits/wm/wm_common.h | 10 +++++---- .../src/scene_session_manager.cpp | 18 +++++++-------- .../zidl/scene_session_manager_lite_proxy.cpp | 14 +++++++----- .../zidl/scene_session_manager_lite_stub.cpp | 22 +++++++++++-------- wm/src/window_manager.cpp | 5 +++++ wm/src/window_manager_lite.cpp | 2 +- 7 files changed, 42 insertions(+), 31 deletions(-) diff --git a/interfaces/innerkits/wm/window_manager.h b/interfaces/innerkits/wm/window_manager.h index be154c0340..e2dfa7df73 100644 --- a/interfaces/innerkits/wm/window_manager.h +++ b/interfaces/innerkits/wm/window_manager.h @@ -1093,7 +1093,7 @@ private: void NotifyGestureNavigationEnabledResult(bool enable) const; void UpdateVisibleWindowNum(const std::vector& visibleWindowNumInfo); WMError NotifyWindowStyleChange(WindowStyleType type); - WMError NotifyCallingWindowDisplayChanged(const CallingWindowInfo& callingWindowInfo) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; } + WMError NotifyCallingWindowDisplayChanged(const CallingWindowInfo& callingWindowInfo); void NotifyWindowPidVisibilityChanged(const sptr& info) const; }; } // namespace Rosen diff --git a/interfaces/innerkits/wm/wm_common.h b/interfaces/innerkits/wm/wm_common.h index 3ccaa1fef4..c24ce1108f 100644 --- a/interfaces/innerkits/wm/wm_common.h +++ b/interfaces/innerkits/wm/wm_common.h @@ -962,10 +962,12 @@ struct CallingWindowInfo : public Parcelable { static CallingWindowInfo* Unmarshalling(Parcel& parcel) { - sptr callingWindowInfo = sptr::MakeSptr(); - if (!(parcel.ReadInt32(callingWindowInfo->windowId_) && parcel.ReadInt32(callingWindowInfo->callingPid_) && - parcel.ReadUint64(callingWindowInfo->displayId_) && parcel.ReadInt32(callingWindowInfo->userId_))) { - callingWindowInfo = nullptr; + CallingWindowInfo* callingWindowInfo = new CallingWindowInfo(); + bool res = parcel.ReadInt32(callingWindowInfo->windowId_) && parcel.ReadInt32(callingWindowInfo->callingPid_) && + parcel.ReadUint64(callingWindowInfo->displayId_) && parcel.ReadInt32(callingWindowInfo->userId_); + if (!res) { + delete callingWindowInfo; + return nullptr; } return callingWindowInfo; } diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index a0993b14fb..95fb8eb10c 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -10377,12 +10377,12 @@ WSError SceneSessionManager::UpdateSessionDisplayId(int32_t persistentId, uint64 const auto& keyboardSessionVec = GetSceneSessionVectorByType(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT); for (const auto& keyboardSession : keyboardSessionVec) { if (keyboardSession) { - TLOGI(WmsLogTag::WMS_KEYBOARD, "isSystemKeyboard: %{public}d, callingSessionId: %{public}d", + TLOGD(WmsLogTag::WMS_KEYBOARD, "isSystemKeyboard: %{public}d, callingSessionId: %{public}d", keyboardSession->IsSystemKeyboard(), keyboardSession->GetCallingSessionId()); } if (keyboardSession && !keyboardSession->IsSystemKeyboard() && static_cast(keyboardSession->GetCallingSessionId()) == persistentId) { - CallingWindowInfo callingWindowInfo(persistentId, sceneSession->GetCallingPid(), screenId, sceneSession->GetCallingUid()); + CallingWindowInfo callingWindowInfo(persistentId, sceneSession->GetCallingPid(), screenId, GetUserIdByUid(getuid())); SessionManagerAgentController::GetInstance().NotifyCallingWindowDisplayChanged(callingWindowInfo); break; } @@ -12156,19 +12156,17 @@ WMError SceneSessionManager::GetMainWindowInfos(int32_t topNum, std::vector
GetCallingUid(); + int32_t curUserId = GetUserIdByUid(getuid()); if (curUserId != callingWindowInfo.userId_) { TLOGE(WmsLogTag::WMS_KEYBOARD, "Target user not exists,targetUserId: %{public}d, curUserId: %{public}d, id: %{public}d", callingWindowInfo.userId_, curUserId, callingWindowInfo.windowId_); return WMError::WM_ERROR_INVALID_PARAM; } - + auto sceneSession = GetSceneSession(callingWindowInfo.windowId_); + if (sceneSession == nullptr) { + TLOGE(WmsLogTag::WMS_KEYBOARD, "sceneSession is nullptr,id: %{public}d", callingWindowInfo.windowId_); + return WMError::WM_ERROR_NULLPTR; + } callingWindowInfo.callingPid_ = sceneSession->GetCallingPid(); callingWindowInfo.displayId_ = sceneSession->GetSessionProperty()->GetDisplayId(); TLOGI(WmsLogTag::WMS_KEYBOARD, "callingWindow id: %{public}d,pid: %{public}d,displayId: %{public}" PRIu64" , curUserId: %{public}d", diff --git a/window_scene/session_manager/src/zidl/scene_session_manager_lite_proxy.cpp b/window_scene/session_manager/src/zidl/scene_session_manager_lite_proxy.cpp index ddd57643aa..fa58dbfe39 100644 --- a/window_scene/session_manager/src/zidl/scene_session_manager_lite_proxy.cpp +++ b/window_scene/session_manager/src/zidl/scene_session_manager_lite_proxy.cpp @@ -1057,7 +1057,7 @@ WMError SceneSessionManagerLiteProxy::GetCallingWindowInfo(CallingWindowInfo& ca TLOGE(WmsLogTag::WMS_KEYBOARD, "WriteInterfaceToken failed"); return WMError::WM_ERROR_IPC_FAILED; } - if (!data.WriteParcelable(&callingWindowInfo)) { + if (!data.WriteInt32(callingWindowInfo.windowId_) || !data.WriteInt32(callingWindowInfo.userId_)) { TLOGE(WmsLogTag::WMS_KEYBOARD, "persistentId and userId write failed, id: %{public}d, userId: %{public}d", callingWindowInfo.windowId_, callingWindowInfo.userId_); return WMError::WM_ERROR_IPC_FAILED; @@ -1072,12 +1072,14 @@ WMError SceneSessionManagerLiteProxy::GetCallingWindowInfo(CallingWindowInfo& ca TLOGE(WmsLogTag::WMS_KEYBOARD, "SendRequest failed"); return WMError::WM_ERROR_IPC_FAILED; } - - if (!(static_cast(reply.ReadInt32()) == WMError::WM_OK && reply.ReadParcelable())) { - TLOGE(WmsLogTag::WMS_KEYBOARD, "Read callingWindow info failed"); - return WMError::WM_ERROR_IPC_FAILED; + auto ret = static_cast(reply.ReadInt32()); + if (ret == WMError::WM_OK) { + callingWindowInfo.windowId_ = reply.ReadInt32(); + callingWindowInfo.callingPid_ = reply.ReadInt32(); + callingWindowInfo.displayId_ = reply.ReadUint64(); + callingWindowInfo.userId_ = reply.ReadInt32(); } - return WMError::WM_OK; + return ret; } WSError SceneSessionManagerLiteProxy::RegisterIAbilityManagerCollaborator(int32_t type, diff --git a/window_scene/session_manager/src/zidl/scene_session_manager_lite_stub.cpp b/window_scene/session_manager/src/zidl/scene_session_manager_lite_stub.cpp index 33409de024..a2ee20b9a6 100644 --- a/window_scene/session_manager/src/zidl/scene_session_manager_lite_stub.cpp +++ b/window_scene/session_manager/src/zidl/scene_session_manager_lite_stub.cpp @@ -701,21 +701,25 @@ int SceneSessionManagerLiteStub::HandleGetMainWinodowInfo(MessageParcel& data, M int SceneSessionManagerLiteStub::HandleGetCallingWindowInfo(MessageParcel& data, MessageParcel& reply) { TLOGD(WmsLogTag::WMS_KEYBOARD, "In"); - sptr callingWindowInfo = data.ReadParcelable(); - if (callingWindowInfo == nullptr) { + int32_t persistentId; + int32_t userId; + if (!data.ReadInt32(persistentId) || !data.ReadInt32(userId)) { TLOGE(WmsLogTag::WMS_KEYBOARD, "Read persistentId and userId failed."); return ERR_INVALID_DATA; } - WMError ret = GetCallingWindowInfo(*callingWindowInfo); + CallingWindowInfo callingWindowInfo; + callingWindowInfo.windowId_ = persistentId; + callingWindowInfo.userId_ = userId; + WMError ret = GetCallingWindowInfo(callingWindowInfo); if (ret != WMError::WM_OK) { - TLOGE(WmsLogTag::WMS_KEYBOARD, "id: %{public}d, failed to get calling window info", - callingWindowInfo->windowId_); - return ERR_INVALID_DATA; - } - if (!(reply.WriteInt32(static_cast(ret)) && reply.WriteParcelable(callingWindowInfo))) { - TLOGE(WmsLogTag::WMS_KEYBOARD, "Write callingWindowInfo failed, id: %{public}d", callingWindowInfo->windowId_); + TLOGE(WmsLogTag::WMS_KEYBOARD, "id: %{public}d, failed to get calling window info", persistentId); return ERR_INVALID_DATA; } + reply.WriteInt32(static_cast(ret)); + reply.WriteInt32(callingWindowInfo.windowId_); + reply.WriteInt32(callingWindowInfo.callingPid_); + reply.WriteUint64(callingWindowInfo.displayId_); + reply.WriteInt32(callingWindowInfo.userId_); return ERR_NONE; } diff --git a/wm/src/window_manager.cpp b/wm/src/window_manager.cpp index e32cea768f..68cc5c67d7 100644 --- a/wm/src/window_manager.cpp +++ b/wm/src/window_manager.cpp @@ -1234,6 +1234,11 @@ WMError WindowManager::NotifyWindowStyleChange(WindowStyleType type) return WMError::WM_OK; } +WMError NotifyCallingWindowDisplayChanged(const CallingWindowInfo& callingWindowInfo) +{ + return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; +} + WMError WindowManager::RegisterDrawingContentChangedListener(const sptr& listener) { if (listener == nullptr) { diff --git a/wm/src/window_manager_lite.cpp b/wm/src/window_manager_lite.cpp index f2d5cd188d..4e00fa5df9 100644 --- a/wm/src/window_manager_lite.cpp +++ b/wm/src/window_manager_lite.cpp @@ -74,7 +74,7 @@ public: sptr windowStyleListenerAgent_; std::vector> pipStateChangedListeners_; sptr pipStateChangedListenerAgent_; - std::vector>callingDisplayChangedListeners_; + std::vector> callingDisplayChangedListeners_; sptr callingDisplayListenerAgent_; }; -- Gitee