diff --git a/wm/BUILD.gn b/wm/BUILD.gn index b1ccdf80f8fcead36767fbe1edcab38280b78065..866071a7e5bed2e95b0b86b39b07eaf0203d153a 100644 --- a/wm/BUILD.gn +++ b/wm/BUILD.gn @@ -77,6 +77,7 @@ ohos_shared_library("libwm") { "bundle_framework:appexecfwk_core", "bytrace_standard:bytrace_core", "graphic_standard:surface", + "graphic_standard:window_animation", "hilog_native:libhilog", "input:libmmi-client", "inputmethod_native:inputmethod_client", diff --git a/wm/include/window_adapter.h b/wm/include/window_adapter.h index 7f94e7c851d08e2e0973e22e743be9260b9de904..8d41337354326a3614a28ae37dfc1468ba539e71 100644 --- a/wm/include/window_adapter.h +++ b/wm/include/window_adapter.h @@ -58,6 +58,8 @@ public: virtual void UnregisterWindowManagerAgent(WindowManagerAgentType type, const sptr& windowManagerAgent); + virtual WMError SetWindowAnimationController(const sptr& controller); + virtual void ClearWindowAdapter(); virtual WMError GetAccessibilityWindowInfo(sptr& windowInfo); diff --git a/wm/src/window_adapter.cpp b/wm/src/window_adapter.cpp index 0e47353e954c4464653613d93ac8fcb4744b71c7..8c07ba5a1ed26da3b830db927029977ef66297ce 100644 --- a/wm/src/window_adapter.cpp +++ b/wm/src/window_adapter.cpp @@ -93,6 +93,12 @@ WMError WindowAdapter::GetAccessibilityWindowInfo(sptr& return windowManagerServiceProxy_->GetAccessibilityWindowInfo(windowInfo); } +WMError WindowAdapter::SetWindowAnimationController(const sptr& controller) +{ + INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR); + return windowManagerServiceProxy_->SetWindowAnimationController(controller); +} + WMError WindowAdapter::GetAvoidAreaByType(uint32_t windowId, AvoidAreaType type, std::vector& avoidRect) { INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR); diff --git a/wmserver/BUILD.gn b/wmserver/BUILD.gn index 9bdcf75323e2dd0f875517b60d7f41a698af9d72..fbfd1f9dc00daa36f7d1a765d19c6bf2a15060bc 100644 --- a/wmserver/BUILD.gn +++ b/wmserver/BUILD.gn @@ -90,6 +90,7 @@ ohos_shared_library("libwms") { "bytrace_standard:bytrace_core", "ces_standard:cesfwk_innerkits", "graphic_standard:surface", + "graphic_standard:window_animation", "hilog_native:libhilog", "hisysevent_native:libhisysevent", "input:libmmi-client", diff --git a/wmserver/include/window_controller.h b/wmserver/include/window_controller.h index 7116253573d9c498baf166a3cd27e02ef95a8e1e..c515f68fdfc61cbd7f98d997c87d2ad3c6715aaa 100644 --- a/wmserver/include/window_controller.h +++ b/wmserver/include/window_controller.h @@ -17,6 +17,8 @@ #define OHOS_ROSEN_WINDOW_CONTROLLER_H #include +#include + #include "input_window_monitor.h" #include "zidl/window_manager_agent_interface.h" #include "window_root.h" @@ -50,6 +52,7 @@ public: WMError SetWindowLayoutMode(DisplayId displayId, WindowLayoutMode mode); WMError UpdateProperty(sptr& property, PropertyChangeAction action); void NotifySystemBarTints(); + WMError SetWindowAnimationController(const sptr& controller); private: uint32_t GenWindowId(); @@ -66,6 +69,7 @@ private: sptr windowRoot_; sptr inputWindowMonitor_; + sptr windowAnimationController_; std::atomic windowId_ { INVALID_WINDOW_ID }; // Remove 'sysBarWinId_' after SystemUI resize 'systembar' std::unordered_map sysBarWinId_ { diff --git a/wmserver/include/window_manager_interface.h b/wmserver/include/window_manager_interface.h index 07e6c9acb343cf725ad83ac1e6c3a62304838bc1..275a9e635259438e383bf668bd67b55b2ce41a75 100644 --- a/wmserver/include/window_manager_interface.h +++ b/wmserver/include/window_manager_interface.h @@ -18,12 +18,15 @@ #include #include + #include "window_property.h" #include "window_interface.h" #include "zidl/window_manager_agent_interface.h" namespace OHOS { namespace Rosen { +class RSIWindowAnimationController; + class IWindowManager : public IRemoteBroker { public: DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.IWindowManager"); @@ -50,6 +53,7 @@ public: TRANS_ID_MAXMIZE_WINDOW, TRANS_ID_UPDATE_PROPERTY, TRANS_ID_GET_ACCCESSIBILITY_WIDDOW_INFO_ID, + TRANS_ID_ANIMATION_SET_CONTROLLER, }; virtual WMError CreateWindow(sptr& window, sptr& property, const std::shared_ptr& surfaceNode, @@ -74,6 +78,7 @@ public: virtual void UnregisterWindowManagerAgent(WindowManagerAgentType type, const sptr& windowManagerAgent) = 0; virtual WMError GetAccessibilityWindowInfo(sptr& windowInfo) = 0; + virtual WMError SetWindowAnimationController(const sptr& controller) = 0; }; } } diff --git a/wmserver/include/window_manager_proxy.h b/wmserver/include/window_manager_proxy.h index aae32080cd17392ff5c97d6530947ccae272fa8d..8051d20ced37b57cec23cca0fe3c0e1bb08d03b5 100644 --- a/wmserver/include/window_manager_proxy.h +++ b/wmserver/include/window_manager_proxy.h @@ -50,6 +50,7 @@ public: const sptr& windowManagerAgent) override; void UnregisterWindowManagerAgent(WindowManagerAgentType type, const sptr& windowManagerAgent) override; + WMError SetWindowAnimationController(const sptr& controller) override; WMError GetAccessibilityWindowInfo(sptr& windowInfo) override; diff --git a/wmserver/include/window_manager_service.h b/wmserver/include/window_manager_service.h index 42f2c83176e3ed1293af3ac1fbfb1135c68c5312..3523fc6b39404ee9963fd7177db4b8fb7876d735 100644 --- a/wmserver/include/window_manager_service.h +++ b/wmserver/include/window_manager_service.h @@ -71,6 +71,9 @@ public: const sptr& windowManagerAgent) override; void UnregisterWindowManagerAgent(WindowManagerAgentType type, const sptr& windowManagerAgent) override; + + WMError SetWindowAnimationController(const sptr& controller) override; + protected: WindowManagerService(); virtual ~WindowManagerService() = default; diff --git a/wmserver/src/window_controller.cpp b/wmserver/src/window_controller.cpp index 1d0d835350c04bc8b7f592cd99afa613401aa032..a02a7a3cd2815ae5369be7742dc2af870684c6ce 100644 --- a/wmserver/src/window_controller.cpp +++ b/wmserver/src/window_controller.cpp @@ -379,6 +379,22 @@ void WindowController::NotifySystemBarTints() windowRoot_->NotifySystemBarTints(); } +WMError WindowController::SetWindowAnimationController(const sptr& controller) +{ + if (controller == nullptr) { + WLOGFE("RSWindowAnimation: failed to set window animation controller, controller is null!"); + return WMError::WM_ERROR_NULLPTR; + } + + if (windowAnimationController_ != nullptr) { + WLOGFE("RSWindowAnimation: failed to set window animation controller, Already had a controller!"); + return WMError::WM_ERROR_INVALID_OPERATION; + } + + windowAnimationController_ = controller; + return WMError::WM_OK; +} + std::vector WindowController::GetAvoidAreaByType(uint32_t windowId, AvoidAreaType avoidAreaType) { std::vector avoidArea = windowRoot_->GetAvoidAreaByType(windowId, avoidAreaType); diff --git a/wmserver/src/window_manager_proxy.cpp b/wmserver/src/window_manager_proxy.cpp index a4b0ef123f502a32c3278f568f46ea071c15888f..af0416bb11ed56929ab2f06ec1424409e4f76321 100644 --- a/wmserver/src/window_manager_proxy.cpp +++ b/wmserver/src/window_manager_proxy.cpp @@ -15,6 +15,7 @@ #include "window_manager_proxy.h" #include +#include #include "window_manager_hilog.h" namespace OHOS { @@ -339,6 +340,38 @@ void WindowManagerProxy::UnregisterWindowManagerAgent(WindowManagerAgentType typ } } +WMError WindowManagerProxy::SetWindowAnimationController(const sptr& controller) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + if (controller == nullptr) { + WLOGFE("Failed to set window animation controller, controller is null!"); + return WMError::WM_ERROR_IPC_FAILED; + } + + if (!data.WriteInterfaceToken(GetDescriptor())) { + WLOGFE("Failed to WriteInterfaceToken!"); + return WMError::WM_ERROR_IPC_FAILED; + } + + if (!data.WriteParcelable(controller->AsObject())) { + WLOGFE("Failed to write controller!"); + return WMError::WM_ERROR_IPC_FAILED; + } + + auto error = Remote()->SendRequest(static_cast(WindowManagerMessage::TRANS_ID_ANIMATION_SET_CONTROLLER), + data, reply, option); + if (error != ERR_NONE) { + WLOGFE("Send request error: %{public}d", error); + return WMError::WM_ERROR_IPC_FAILED; + } + + int32_t ret = reply.ReadInt32(); + return static_cast(ret); +} + void WindowManagerProxy::ProcessPointDown(uint32_t windowId, bool isStartDrag) { MessageParcel data; diff --git a/wmserver/src/window_manager_service.cpp b/wmserver/src/window_manager_service.cpp index 4b97c54a47ba248adb2fc371e55703c4eb1fbce6..5908a374f4c9d40d665c43fddd0707dc921539ad 100644 --- a/wmserver/src/window_manager_service.cpp +++ b/wmserver/src/window_manager_service.cpp @@ -17,9 +17,10 @@ #include +#include #include +#include #include -#include #include "dm_common.h" #include "display_manager_service_inner.h" @@ -222,6 +223,17 @@ void WindowManagerService::UnregisterWindowManagerAgent(WindowManagerAgentType t WindowManagerAgentController::GetInstance().UnregisterWindowManagerAgent(windowManagerAgent, type); } +WMError WindowManagerService::SetWindowAnimationController(const sptr& controller) +{ + if (controller == nullptr) { + WLOGFE("Failed to set window animation controller, controller is null!"); + return WMError::WM_ERROR_NULLPTR; + } + + std::lock_guard lock(mutex_); + return windowController_->SetWindowAnimationController(controller); +} + void WindowManagerService::OnWindowEvent(Event event, uint32_t windowId) { if (event == Event::REMOTE_DIED) { diff --git a/wmserver/src/window_manager_stub.cpp b/wmserver/src/window_manager_stub.cpp index 68d46ce22c32995cd4c445f0abec1947d8e92892..991bf2f35217bd5dd6ecb0a61d06452b00c1e365 100644 --- a/wmserver/src/window_manager_stub.cpp +++ b/wmserver/src/window_manager_stub.cpp @@ -15,6 +15,7 @@ #include "window_manager_stub.h" #include +#include #include "window_manager_hilog.h" @@ -174,6 +175,12 @@ int32_t WindowManagerStub::OnRemoteRequest(uint32_t code, MessageParcel &data, M reply.WriteInt32(static_cast(errCode)); break; } + case WindowManagerMessage::TRANS_ID_ANIMATION_SET_CONTROLLER: { + auto controller = iface_cast(data.ReadParcelable()); + WMError errCode = SetWindowAnimationController(controller); + reply.WriteInt32(static_cast(errCode)); + break; + } default: WLOGFW("unknown transaction code"); return IPCObjectStub::OnRemoteRequest(code, data, reply, option);