• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef OHOS_WINDOW_MANAGER_INTERFACE_H
17 #define OHOS_WINDOW_MANAGER_INTERFACE_H
18 
19 #include <iremote_broker.h>
20 #include <rs_iwindow_animation_finished_callback.h>
21 
22 #include "common/include/window_session_property.h"
23 #include "interfaces/include/ws_common_inner.h"
24 #include "pixel_map.h"
25 #include "session/container/include/zidl/session_stage_interface.h"
26 #include "session/container/include/zidl/window_event_channel_interface.h"
27 #include "window_property.h"
28 #include "window_transition_info.h"
29 #include "mission_snapshot.h"
30 #include "zidl/window_interface.h"
31 #include "zidl/window_manager_agent_interface.h"
32 #include "interfaces/include/ws_common.h"
33 
34 namespace OHOS {
35 namespace Rosen {
36 class RSIWindowAnimationController;
37 class RSSurfaceNode;
38 
39 class IWindowManager : public IRemoteBroker {
40 public:
41     DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.IWindowManager");
42 
43     enum class WindowManagerMessage : uint32_t {
44         TRANS_ID_CREATE_WINDOW,
45         TRANS_ID_ADD_WINDOW,
46         TRANS_ID_REMOVE_WINDOW,
47         TRANS_ID_DESTROY_WINDOW,
48         TRANS_ID_REQUEST_FOCUS,
49         TRANS_ID_REGISTER_FOCUS_CHANGED_LISTENER,
50         TRANS_ID_UNREGISTER_FOCUS_CHANGED_LISTENER,
51         TRANS_ID_REGISTER_WINDOW_MANAGER_AGENT,
52         TRANS_ID_UNREGISTER_WINDOW_MANAGER_AGENT,
53         TRANS_ID_GET_AVOID_AREA,
54         TRANS_ID_GET_TOP_WINDOW_ID,
55         TRANS_ID_PROCESS_POINT_DOWN,
56         TRANS_ID_PROCESS_POINT_UP,
57         TRANS_ID_MINIMIZE_ALL_APP_WINDOWS,
58         TRANS_ID_TOGGLE_SHOWN_STATE_FOR_ALL_APP_WINDOWS,
59         TRANS_ID_SET_BACKGROUND_BLUR,
60         TRANS_ID_SET_ALPHA,
61         TRANS_ID_UPDATE_LAYOUT_MODE,
62         TRANS_ID_UPDATE_PROPERTY,
63         TRANS_ID_GET_ACCESSIBILITY_WINDOW_INFO_ID,
64         TRANS_ID_LIST_WINDOW_INFO,
65         TRANS_ID_GET_WINDOW_LAYOUT_INFO,
66         TRANS_ID_GET_VISIBILITY_WINDOW_INFO_ID,
67         TRANS_ID_ANIMATION_SET_CONTROLLER,
68         TRANS_ID_GET_SYSTEM_CONFIG,
69         TRANS_ID_NOTIFY_WINDOW_TRANSITION,
70         TRANS_ID_GET_FULLSCREEN_AND_SPLIT_HOT_ZONE,
71         TRANS_ID_GET_ANIMATION_CALLBACK,
72         TRANS_ID_UPDATE_AVOIDAREA_LISTENER,
73         TRANS_ID_UPDATE_RS_TREE,
74         TRANS_ID_BIND_DIALOG_TARGET,
75         TRANS_ID_NOTIFY_READY_MOVE_OR_DRAG,
76         TRANS_ID_SET_ANCHOR_AND_SCALE,
77         TRANS_ID_SET_ANCHOR_OFFSET,
78         TRANS_ID_OFF_WINDOW_ZOOM,
79         TRANS_ID_RAISE_WINDOW_Z_ORDER,
80         TRANS_ID_GET_SNAPSHOT,
81         TRANS_ID_GESTURE_NAVIGATION_ENABLED,
82         TRANS_ID_SET_WINDOW_GRAVITY,
83         TRANS_ID_DISPATCH_KEY_EVENT,
84         TRANS_ID_NOTIFY_DUMP_INFO_RESULT,
85         TRANS_ID_GET_WINDOW_ANIMATION_TARGETS,
86         TRANS_ID_SET_MAXIMIZE_MODE,
87         TRANS_ID_GET_MAXIMIZE_MODE,
88         TRANS_ID_GET_FOCUS_WINDOW_INFO,
89         TRANS_ID_ADD_EXTENSION_WINDOW_STAGE_TO_SCB,
90         TRANS_ID_UPDATE_MODALEXTENSION_RECT_TO_SCB,
91         TRANS_ID_PROCESS_MODALEXTENSION_POINTDOWN_TO_SCB,
92         TRANS_ID_UPDATE_EXTENSION_WINDOW_FLAGS,
93         TRANS_ID_GET_HOST_WINDOW_RECT,
94         TRANS_ID_GET_UNRELIABLE_WINDOW_INFO_ID,
95         TRANS_ID_GET_FREE_MULTI_WINDOW_ENABLE_STATE,
96     };
97     virtual WMError CreateWindow(sptr<IWindow>& window, sptr<WindowProperty>& property,
98         const std::shared_ptr<RSSurfaceNode>& surfaceNode,
99         uint32_t& windowId, sptr<IRemoteObject> token) = 0;
100     virtual WMError AddWindow(sptr<WindowProperty>& property) = 0;
101     virtual WMError RemoveWindow(uint32_t windowId, bool isFromInnerkits) = 0;
102     virtual WMError DestroyWindow(uint32_t windowId, bool onlySelf = false) = 0;
103     virtual WMError RequestFocus(uint32_t windowId) = 0;
104     virtual AvoidArea GetAvoidAreaByType(uint32_t windowId, AvoidAreaType type,
105         const Rect& rect = Rect::EMPTY_RECT) = 0;
106     virtual WMError GetTopWindowId(uint32_t mainWinId, uint32_t& topWinId) = 0;
107     virtual void NotifyServerReadyToMoveOrDrag(uint32_t windowId, sptr<WindowProperty>& windowProperty,
108         sptr<MoveDragProperty>& moveDragProperty) = 0;
109     virtual void ProcessPointDown(uint32_t windowId, bool isPointDown) = 0;
110     virtual void ProcessPointUp(uint32_t windowId) = 0;
111     virtual WMError MinimizeAllAppWindows(DisplayId displayId) = 0;
112     virtual WMError ToggleShownStateForAllAppWindows() = 0;
113     virtual WMError SetWindowLayoutMode(WindowLayoutMode mode) = 0;
114     virtual WMError UpdateProperty(sptr<WindowProperty>& windowProperty, PropertyChangeAction action,
115         bool isAsyncTask = false) = 0;
116     virtual WMError SetWindowGravity(uint32_t windowId, WindowGravity gravity, uint32_t percent) = 0;
117     virtual WMError RegisterWindowManagerAgent(WindowManagerAgentType type,
118         const sptr<IWindowManagerAgent>& windowManagerAgent) = 0;
119     virtual WMError UnregisterWindowManagerAgent(WindowManagerAgentType type,
120         const sptr<IWindowManagerAgent>& windowManagerAgent) = 0;
121     virtual WMError GetAccessibilityWindowInfo(std::vector<sptr<AccessibilityWindowInfo>>& infos) = 0;
122     virtual WMError GetUnreliableWindowInfo(int32_t windowId, std::vector<sptr<UnreliableWindowInfo>>& infos) = 0;
ListWindowInfo(const WindowInfoOption & windowInfoOption,std::vector<sptr<WindowInfo>> & infos)123     virtual WMError ListWindowInfo(const WindowInfoOption& windowInfoOption,
124         std::vector<sptr<WindowInfo>>& infos) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; }
GetAllWindowLayoutInfo(DisplayId displayId,std::vector<sptr<WindowLayoutInfo>> & infos)125     virtual WMError GetAllWindowLayoutInfo(DisplayId displayId,
126         std::vector<sptr<WindowLayoutInfo>>& infos) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; }
127     virtual WMError GetVisibilityWindowInfo(std::vector<sptr<WindowVisibilityInfo>>& infos) = 0;
128     virtual WMError SetWindowAnimationController(const sptr<RSIWindowAnimationController>& controller) = 0;
129     virtual WMError GetSystemConfig(SystemConfig& systemConfig) = 0;
130     virtual WMError NotifyWindowTransition(sptr<WindowTransitionInfo>& from, sptr<WindowTransitionInfo>& to,
131         bool isFromClient = false) = 0;
132     virtual WMError GetModeChangeHotZones(DisplayId displayId, ModeChangeHotZones& hotZones) = 0;
133     virtual void MinimizeWindowsByLauncher(std::vector<uint32_t> windowIds, bool isAnimated,
134         sptr<RSIWindowAnimationFinishedCallback>& finishCallback) = 0;
135     virtual WMError UpdateAvoidAreaListener(uint32_t windowId, bool haveListener) = 0;
136     virtual WMError UpdateRsTree(uint32_t windowId, bool isAdd) = 0;
137     virtual WMError BindDialogTarget(uint32_t& windowId, sptr<IRemoteObject> targetToken) = 0;
138     virtual void SetAnchorAndScale(int32_t x, int32_t y, float scale) = 0;
139     virtual void SetAnchorOffset(int32_t deltaX, int32_t deltaY) = 0;
140     virtual void OffWindowZoom() = 0;
141     virtual WMError RaiseToAppTop(uint32_t windowId) = 0;
142     virtual std::shared_ptr<Media::PixelMap> GetSnapshot(int32_t windowId) = 0;
143     virtual WMError SetGestureNavigationEnabled(bool enable) = 0;
144     virtual void DispatchKeyEvent(uint32_t windowId, std::shared_ptr<MMI::KeyEvent> event) = 0;
NotifyDumpInfoResult(const std::vector<std::string> & info)145     virtual void NotifyDumpInfoResult(const std::vector<std::string>& info) {};
DumpSessionAll(std::vector<std::string> & infos)146     virtual WSError DumpSessionAll(std::vector<std::string>& infos) { return WSError::WS_OK; }
DumpSessionWithId(int32_t persistentId,std::vector<std::string> & infos)147     virtual WSError DumpSessionWithId(int32_t persistentId, std::vector<std::string>& infos) { return WSError::WS_OK; }
GetUIContentRemoteObj(int32_t persistentId,sptr<IRemoteObject> & uiContentRemoteObj)148     virtual WSError GetUIContentRemoteObj(int32_t persistentId, sptr<IRemoteObject>& uiContentRemoteObj)
149     {
150         return WSError::WS_OK;
151     }
152     virtual WMError GetWindowAnimationTargets(std::vector<uint32_t> missionIds,
153         std::vector<sptr<RSWindowAnimationTarget>>& targets) = 0;
154     virtual void SetMaximizeMode(MaximizeMode maximizeMode) = 0;
155     virtual MaximizeMode GetMaximizeMode() = 0;
156     virtual void GetFocusWindowInfo(FocusChangeInfo& focusInfo, DisplayId displayId = DEFAULT_DISPLAY_ID) = 0;
CheckWindowId(int32_t windowId,int32_t & pid)157     virtual WMError CheckWindowId(int32_t windowId, int32_t& pid) { return WMError::WM_OK; }
UpdateSessionAvoidAreaListener(int32_t persistentId,bool haveListener)158     virtual WSError UpdateSessionAvoidAreaListener(int32_t persistentId, bool haveListener) { return WSError::WS_OK; }
UpdateSessionTouchOutsideListener(int32_t & persistentId,bool haveListener)159     virtual WSError UpdateSessionTouchOutsideListener(int32_t& persistentId, bool haveListener)
160     {
161         return WSError::WS_OK;
162     }
NotifyWindowExtensionVisibilityChange(int32_t pid,int32_t uid,bool visible)163     virtual WSError NotifyWindowExtensionVisibilityChange(int32_t pid, int32_t uid, bool visible)
164     {
165         return WSError::WS_OK;
166     }
RaiseWindowToTop(int32_t persistentId)167     virtual WSError RaiseWindowToTop(int32_t persistentId) { return WSError::WS_OK; }
UpdateSessionWindowVisibilityListener(int32_t persistentId,bool haveListener)168     virtual WSError UpdateSessionWindowVisibilityListener(int32_t persistentId, bool haveListener)
169     {
170         return WSError::WS_OK;
171     }
ShiftAppWindowFocus(int32_t sourcePersistentId,int32_t targetPersistentId)172     virtual WSError ShiftAppWindowFocus(int32_t sourcePersistentId, int32_t targetPersistentId)
173     {
174         return WSError::WS_ERROR_DEVICE_NOT_SUPPORT;
175     }
176     virtual WSError CreateAndConnectSpecificSession(const sptr<ISessionStage>& sessionStage,
177         const sptr<IWindowEventChannel>& eventChannel, const std::shared_ptr<RSSurfaceNode>& surfaceNode,
178         sptr<WindowSessionProperty> property, int32_t& persistentId, sptr<ISession>& session,
179         SystemSessionConfig& systemConfig, sptr<IRemoteObject> token = nullptr) { return WSError::WS_OK; }
180     virtual WSError RecoverAndConnectSpecificSession(const sptr<ISessionStage>& sessionStage,
181         const sptr<IWindowEventChannel>& eventChannel, const std::shared_ptr<RSSurfaceNode>& surfaceNode,
182         sptr<WindowSessionProperty> property, sptr<ISession>& session, sptr<IRemoteObject> token = nullptr)
183     {
184         return WSError::WS_OK;
185     }
DestroyAndDisconnectSpecificSession(const int32_t persistentId)186     virtual WSError DestroyAndDisconnectSpecificSession(const int32_t persistentId) { return WSError::WS_OK; }
DestroyAndDisconnectSpecificSessionWithDetachCallback(const int32_t persistentId,const sptr<IRemoteObject> & callback)187     virtual WSError DestroyAndDisconnectSpecificSessionWithDetachCallback(const int32_t persistentId,
188         const sptr<IRemoteObject>& callback) { return WSError::WS_OK; }
189     virtual WSError RecoverAndReconnectSceneSession(const sptr<ISessionStage>& sessionStage,
190         const sptr<IWindowEventChannel>& eventChannel, const std::shared_ptr<RSSurfaceNode>& surfaceNode,
191         sptr<ISession>& session, sptr<WindowSessionProperty> property, sptr<IRemoteObject> token = nullptr)
192     {
193         return WSError::WS_OK;
194     }
BindDialogSessionTarget(uint64_t persistentId,sptr<IRemoteObject> targetToken)195     virtual WSError BindDialogSessionTarget(uint64_t persistentId, sptr<IRemoteObject> targetToken)
196     {
197         return WSError::WS_OK;
198     }
SetSessionGravity(int32_t persistentId,SessionGravity gravity,uint32_t percent)199     virtual WSError SetSessionGravity(int32_t persistentId, SessionGravity gravity, uint32_t percent)
200     {
201         return WSError::WS_OK;
202     }
203     virtual WMError RequestFocusStatus(int32_t persistentId, bool isFocused, bool byForeground = true,
204         FocusChangeReason reason = FocusChangeReason::DEFAULT)
205     {
206         return WMError::WM_OK;
207     }
208     virtual WMError RequestFocusStatusBySA(int32_t persistentId, bool isFocused = true,
209         bool byForeground = true, FocusChangeReason reason = FocusChangeReason::SA_REQUEST)
210     {
211         return WMError::WM_ERROR_DEVICE_NOT_SUPPORT;
212     }
GetSnapshotByWindowId(int32_t persistentId,std::shared_ptr<Media::PixelMap> & pixelMap)213     virtual WMError GetSnapshotByWindowId(int32_t persistentId, std::shared_ptr<Media::PixelMap>& pixelMap)
214     {
215         return WMError::WM_OK;
216     }
217     virtual void AddExtensionWindowStageToSCB(const sptr<ISessionStage>& sessionStage,
218         const sptr<IRemoteObject>& token, uint64_t surfaceNodeId, bool isConstrainedModal = false) {}
219     virtual void RemoveExtensionWindowStageFromSCB(const sptr<ISessionStage>& sessionStage,
220         const sptr<IRemoteObject>& token, bool isConstrainedModal = false) {}
UpdateModalExtensionRect(const sptr<IRemoteObject> & token,Rect rect)221     virtual void UpdateModalExtensionRect(const sptr<IRemoteObject>& token, Rect rect) {}
ProcessModalExtensionPointDown(const sptr<IRemoteObject> & token,int32_t posX,int32_t posY)222     virtual void ProcessModalExtensionPointDown(const sptr<IRemoteObject>& token, int32_t posX, int32_t posY) {}
AddOrRemoveSecureSession(int32_t persistentId,bool shouldHide)223     virtual WSError AddOrRemoveSecureSession(int32_t persistentId, bool shouldHide)
224     {
225         return WSError::WS_OK;
226     }
UpdateExtWindowFlags(const sptr<IRemoteObject> & token,uint32_t extWindowFlags,uint32_t extWindowActions)227     virtual WSError UpdateExtWindowFlags(const sptr<IRemoteObject>& token, uint32_t extWindowFlags,
228         uint32_t extWindowActions)
229     {
230         return WSError::WS_OK;
231     }
GetHostWindowRect(int32_t hostWindowId,Rect & rect)232     virtual WSError GetHostWindowRect(int32_t hostWindowId, Rect& rect)
233     {
234         return WSError::WS_OK;
235     }
GetFreeMultiWindowEnableState(bool & enable)236     virtual WSError GetFreeMultiWindowEnableState(bool& enable) { return WSError::WS_OK; }
GetCallingWindowWindowStatus(int32_t persistentId,WindowStatus & windowStatus)237     virtual WMError GetCallingWindowWindowStatus(int32_t persistentId, WindowStatus& windowStatus)
238     {
239         return WMError::WM_OK;
240     }
GetCallingWindowRect(int32_t persistentId,Rect & rect)241     virtual WMError GetCallingWindowRect(int32_t persistentId, Rect& rect)
242     {
243         return WMError::WM_OK;
244     }
GetWindowModeType(WindowModeType & windowModeType)245     virtual WMError GetWindowModeType(WindowModeType& windowModeType)
246     {
247         return WMError::WM_OK;
248     };
GetWindowStyleType(WindowStyleType & windowStyleType)249     virtual WMError GetWindowStyleType(WindowStyleType& windowStyleType)
250     {
251         return WMError::WM_OK;
252     };
SkipSnapshotForAppProcess(int32_t pid,bool skip)253     virtual WMError SkipSnapshotForAppProcess(int32_t pid, bool skip) { return WMError::WM_OK; }
SetProcessWatermark(int32_t pid,const std::string & watermarkName,bool isEnabled)254     virtual WMError SetProcessWatermark(int32_t pid, const std::string& watermarkName,
255         bool isEnabled) { return WMError::WM_OK; }
GetWindowIdsByCoordinate(DisplayId displayId,int32_t windowNumber,int32_t x,int32_t y,std::vector<int32_t> & windowIds)256     virtual WMError GetWindowIdsByCoordinate(DisplayId displayId, int32_t windowNumber,
257         int32_t x, int32_t y, std::vector<int32_t>& windowIds) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; }
GetParentMainWindowId(int32_t windowId,int32_t & mainWindowId)258     virtual WMError GetParentMainWindowId(int32_t windowId, int32_t& mainWindowId) { return WMError::WM_OK; }
UpdateScreenLockStatusForApp(const std::string & bundleName,bool isRelease)259     virtual WMError UpdateScreenLockStatusForApp(
260         const std::string& bundleName, bool isRelease) { return WMError::WM_OK; }
IsPcWindow(bool & isPcWindow)261     virtual WMError IsPcWindow(bool& isPcWindow) { return WMError::WM_OK; }
IsPcOrPadFreeMultiWindowMode(bool & isPcOrPadFreeMultiWindowMode)262     virtual WMError IsPcOrPadFreeMultiWindowMode(bool& isPcOrPadFreeMultiWindowMode) { return WMError::WM_OK; }
IsWindowRectAutoSave(const std::string & key,bool & enabled,int persistentId)263     virtual WMError IsWindowRectAutoSave(const std::string& key, bool& enabled,
264         int persistentId) { return WMError::WM_OK; }
GetDisplayIdByWindowId(const std::vector<uint64_t> & windowIds,std::unordered_map<uint64_t,DisplayId> & windowDisplayIdMap)265     virtual WMError GetDisplayIdByWindowId(const std::vector<uint64_t>& windowIds,
266         std::unordered_map<uint64_t, DisplayId>& windowDisplayIdMap) { return WMError::WM_OK; }
SetGlobalDragResizeType(DragResizeType dragResizeType)267     virtual WMError SetGlobalDragResizeType(DragResizeType dragResizeType) { return WMError::WM_OK; }
GetGlobalDragResizeType(DragResizeType & dragResizeType)268     virtual WMError GetGlobalDragResizeType(DragResizeType& dragResizeType) { return WMError::WM_OK; }
SetAppDragResizeType(const std::string & bundleName,DragResizeType dragResizeType)269     virtual WMError SetAppDragResizeType(const std::string& bundleName,
270         DragResizeType dragResizeType) { return WMError::WM_OK; }
GetAppDragResizeType(const std::string & bundleName,DragResizeType & dragResizeType)271     virtual WMError GetAppDragResizeType(const std::string& bundleName,
272         DragResizeType& dragResizeType) { return WMError::WM_OK; }
NotifyWatchGestureConsumeResult(int32_t keyCode,bool isConsumed)273     virtual WMError NotifyWatchGestureConsumeResult(int32_t keyCode,
274         bool isConsumed) { return WMError::WM_OK; }
NotifyWatchFocusActiveChange(bool isActive)275     virtual WMError NotifyWatchFocusActiveChange(bool isActive) { return WMError::WM_OK; }
ShiftAppWindowPointerEvent(int32_t sourcePersistentId,int32_t targetPersistentId)276     virtual WMError ShiftAppWindowPointerEvent(int32_t sourcePersistentId,
277         int32_t targetPersistentId) { return WMError::WM_ERROR_DEVICE_NOT_SUPPORT; }
HasFloatingWindowForeground(const sptr<IRemoteObject> & abilityToken,bool & hasOrNot)278     virtual WMError HasFloatingWindowForeground(const sptr<IRemoteObject>& abilityToken,
279         bool& hasOrNot) { return WMError::WM_OK; }
MinimizeByWindowId(const std::vector<int32_t> & windowIds)280     virtual WMError MinimizeByWindowId(const std::vector<int32_t>& windowIds) { return WMError::WM_OK; }
281 
282     /*
283      * Sub Window
284      */
SetParentWindow(int32_t subWindowId,int32_t newParentWindowId)285     virtual WMError SetParentWindow(int32_t subWindowId, int32_t newParentWindowId) { return WMError::WM_OK; }
286 };
287 }
288 }
289 #endif // OHOS_WINDOW_MANAGER_INTERFACE_H
290