1 /*
2  * Copyright (c) 2021-2022 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_ROSEN_WINDOW_MANAGER_H
17 #define OHOS_ROSEN_WINDOW_MANAGER_H
18 
19 #include <memory>
20 #include <mutex>
21 #include <refbase.h>
22 #include <vector>
23 #include <iremote_object.h>
24 #include "wm_single_instance.h"
25 #include "wm_common.h"
26 #include "dm_common.h"
27 #include "focus_change_info.h"
28 #include "window_visibility_info.h"
29 #include "window_drawing_content_info.h"
30 #include "window.h"
31 
32 namespace OHOS {
33 namespace Rosen {
34 struct SystemBarRegionTint {
35     WindowType type_;
36     SystemBarProperty prop_;
37     Rect region_;
SystemBarRegionTintSystemBarRegionTint38     SystemBarRegionTint()
39         : type_(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW), prop_(), region_{ 0, 0, 0, 0 } {}
SystemBarRegionTintSystemBarRegionTint40     SystemBarRegionTint(WindowType type, SystemBarProperty prop, Rect region)
41         : type_(type), prop_(prop), region_(region) {}
42 };
43 using SystemBarRegionTints = std::vector<SystemBarRegionTint>;
44 
45 struct VisibleWindowNumInfo {
46     uint32_t displayId;
47     uint32_t visibleWindowNum;
48 };
49 
50 struct WindowSnapshotDataPack {
51     std::shared_ptr<Media::PixelMap> pixelMap = nullptr;
52     WMError result = WMError::WM_OK;
53 };
54 
55 /**
56  * @class IWMSConnectionChangedListener
57  *
58  * @brief Listener to observe WMS connection status.
59  */
60 class IWMSConnectionChangedListener : virtual public RefBase {
61 public:
62     /**
63      * @brief Notify caller when WMS connected
64      *
65      * @param userId ID of the user who has connected to the WMS.
66      *
67      * @param screenId ID of the screen that is connected to the WMS, screenId is currently always 0.
68      */
69     virtual void OnConnected(int32_t userId, int32_t screenId) = 0;
70     /**
71      * @brief Notify caller when WMS disconnected
72      *
73      * @param userId ID of the user who has disconnected to the WMS.
74      *
75      * @param screenId ID of the screen that is disconnected to the WMS, screenId is currently always 0.
76      */
77     virtual void OnDisconnected(int32_t userId, int32_t screenId) = 0;
78 };
79 
80 /**
81  * @class IFocusChangedListener
82  *
83  * @brief Listener to observe focus changed.
84  */
85 class IFocusChangedListener : virtual public RefBase {
86 public:
87     /**
88      * @brief Notify caller when window get focus
89      *
90      * @param focusChangeInfo Window info while its focus status changed.
91      */
92     virtual void OnFocused(const sptr<FocusChangeInfo>& focusChangeInfo) = 0;
93     /**
94      * @brief Notify caller when window lose focus
95      *
96      * @param focusChangeInfo Window info while its focus status changed.
97      */
98     virtual void OnUnfocused(const sptr<FocusChangeInfo>& focusChangeInfo) = 0;
99 };
100 
101 /**
102  * @class IWindowModeChangedListener
103  *
104  * @brief Listener to observe window mode change.
105  */
106 class IWindowModeChangedListener : virtual public RefBase {
107 public:
108     /**
109      * @brief Notify caller when window mode update.
110      *
111      * @param mode Window mode.
112      */
113     virtual void OnWindowModeUpdate(WindowModeType mode) = 0;
114 };
115 
116 
117 /**
118  * @class ISystemBarChangedListener
119  *
120  * @brief Listener to observe systembar changed.
121  */
122 class ISystemBarChangedListener : virtual public RefBase {
123 public:
124     /**
125      * @brief Notify caller when system bar property changed
126      *
127      * @param displayId ID of display.
128      * @param tints Tint of system bar region.
129      */
130     virtual void OnSystemBarPropertyChange(DisplayId displayId, const SystemBarRegionTints& tints) = 0;
131 };
132 
133 /**
134  * @class IGestureNavigationEnabledChangedListener
135  *
136  * @brief Listener to observe GestureNavigationEnabled changed.
137  */
138 class IGestureNavigationEnabledChangedListener : virtual public RefBase {
139 public:
140     /**
141      * @brief Notify caller when GestureNavigationEnabled changed.
142      *
143      * @param enable True means set Gesture on, false means set Gesture off.
144      */
145     virtual void OnGestureNavigationEnabledUpdate(bool enable) = 0;
146 };
147 
148 /**
149  * @class IVisibilityChangedListener
150  *
151  * @brief Listener to observe visibility changed.
152  */
153 class IVisibilityChangedListener : virtual public RefBase {
154 public:
155     /**
156      * @brief Notify caller when window visibility changed.
157      *
158      * @param windowVisibilityInfo Window visibility info.
159      */
160     virtual void OnWindowVisibilityChanged(const std::vector<sptr<WindowVisibilityInfo>>& windowVisibilityInfo) = 0;
161 };
162 
163 /**
164  * @class IDrawingContentChangedListener
165  *
166  * @brief Listener to observe drawing content changed.
167  */
168 class IDrawingContentChangedListener : virtual public RefBase {
169 public:
170     /**
171      * @brief Notify caller when window DrawingContent changed.
172      *
173      * @param windowDrawingInfo Window DrawingContent info.
174      */
175     virtual void OnWindowDrawingContentChanged(const std::vector<sptr<WindowDrawingContentInfo>>&
176         windowDrawingInfo) = 0;
177 };
178 
179 /**
180  * @class IWindowStyleChangedListener
181  *
182  * @brief Listener to observe windowStyle changed.
183  */
184 class IWindowStyleChangedListener : virtual public RefBase {
185 public:
186     /**
187      * @brief Notify caller when window style changed.
188      *
189      * @param styleType
190      */
191     virtual void OnWindowStyleUpdate(WindowStyleType styleType) = 0;
192 };
193 
194 /**
195  * @class AccessibilityWindowInfo
196  *
197  * @brief Window info used for Accessibility.
198  */
199 class AccessibilityWindowInfo : public Parcelable {
200 public:
201     /**
202      * @brief Default construct of AccessibilityWindowInfo.
203      */
204     AccessibilityWindowInfo() = default;
205     /**
206      * @brief Default deconstruct of AccessibilityWindowInfo.
207      */
208     ~AccessibilityWindowInfo() = default;
209 
210     /**
211      * @brief Marshalling AccessibilityWindowInfo.
212      *
213      * @param parcel Package of AccessibilityWindowInfo.
214      * @return True means marshall success, false means marshall failed.
215      */
216     virtual bool Marshalling(Parcel& parcel) const override;
217     /**
218      * @brief Unmarshalling AccessibilityWindowInfo.
219      *
220      * @param parcel Package of AccessibilityWindowInfo.
221      * @return AccessibilityWindowInfo object.
222      */
223     static AccessibilityWindowInfo* Unmarshalling(Parcel& parcel);
224 
225     int32_t wid_;
226     int32_t innerWid_;
227     int32_t uiNodeId_;
228     Rect windowRect_;
229     bool focused_ { false };
230     bool isDecorEnable_ { false };
231     DisplayId displayId_;
232     uint32_t layer_;
233     WindowMode mode_;
234     WindowType type_;
235     float scaleVal_;
236     float scaleX_;
237     float scaleY_;
238     std::string bundleName_;
239     std::vector<Rect> touchHotAreas_;
240 };
241 
242 /**
243  * @class AppUseControlInfo
244  *
245  * @brief Window info used for AppUseControlInfo.
246  */
247 struct AppUseControlInfo : public Parcelable {
248     /**
249      * @brief Marshalling AppUseControlInfo.
250      *
251      * @param parcel Package of AppUseControlInfo.
252      * @return True means marshall success, false means marshall failed.
253      */
MarshallingAppUseControlInfo254     virtual bool Marshalling(Parcel& parcel) const override
255     {
256         return parcel.WriteString(bundleName_) &&
257                parcel.WriteInt32(appIndex_) &&
258                parcel.WriteBool(isNeedControl_);
259     }
260 
261     /**
262      * @brief Unmarshalling AppUseControlInfo.
263      *
264      * @param parcel Package of AppUseControlInfo.
265      * @return AppUseControlInfo object.
266      */
UnmarshallingAppUseControlInfo267     static AppUseControlInfo* Unmarshalling(Parcel& parcel)
268     {
269         auto info = new AppUseControlInfo();
270         if (!parcel.ReadString(info->bundleName_) ||
271             !parcel.ReadInt32(info->appIndex_) ||
272             !parcel.ReadBool(info->isNeedControl_)) {
273             delete info;
274             return nullptr;
275         }
276         return info;
277     }
278 
279     std::string bundleName_ = "";
280     int32_t appIndex_ = 0;
281     bool isNeedControl_ = false;
282 };
283 
284 /**
285  * @class UnreliableWindowInfo
286  *
287  * @brief Unreliable Window Info.
288  */
289 class UnreliableWindowInfo : public Parcelable {
290 public:
291     /**
292      * @brief Default construct of UnreliableWindowInfo.
293      */
294     UnreliableWindowInfo() = default;
295     /**
296      * @brief Default deconstruct of UnreliableWindowInfo.
297      */
298     ~UnreliableWindowInfo() = default;
299 
300     /**
301      * @brief Marshalling UnreliableWindowInfo.
302      *
303      * @param parcel Package of UnreliableWindowInfo.
304      * @return True means marshall success, false means marshall failed.
305      */
306     virtual bool Marshalling(Parcel& parcel) const override;
307     /**
308      * @brief Unmarshalling UnreliableWindowInfo.
309      *
310      * @param parcel Package of UnreliableWindowInfo.
311      * @return UnreliableWindowInfo object.
312      */
313     static UnreliableWindowInfo* Unmarshalling(Parcel& parcel);
314 
315     int32_t windowId_ { 0 };
316     Rect windowRect_;
317     uint32_t zOrder_ { 0 };
318     float floatingScale_ { 1.0f };
319     float scaleX_ { 1.0f };
320     float scaleY_ { 1.0f };
321 };
322 
323 /**
324  * @class IWindowUpdateListener
325  *
326  * @brief Listener to observe window update.
327  */
328 class IWindowUpdateListener : virtual public RefBase {
329 public:
330     /**
331      * @brief Notify caller when AccessibilityWindowInfo update.
332      *
333      * @param infos Window info used for Accessibility.
334      * @param type Type for window update.
335      */
336     virtual void OnWindowUpdate(const std::vector<sptr<AccessibilityWindowInfo>>& infos, WindowUpdateType type) = 0;
337 };
338 
339 /**
340  * @class IWaterMarkFlagChangedListener
341  *
342  * @brief Listener to observe water mark flag changed.
343  */
344 class IWaterMarkFlagChangedListener : virtual public RefBase {
345 public:
346     /**
347      * @brief Notify caller when water mark flag changed.
348      *
349      * @param showWaterMark True means show water mark, false means the opposite.
350      */
351     virtual void OnWaterMarkFlagUpdate(bool showWaterMark) = 0;
352 };
353 
354 /**
355  * @class IVisibleWindowNumChangedListener
356  *
357  * @brief Listener to observe visible main window num changed.
358  */
359 class IVisibleWindowNumChangedListener : virtual public RefBase {
360 public:
361     /**
362      * @brief Notify caller when visible window num changed
363      *
364      * @param visibleWindowNum visible window num .
365      */
366     virtual void OnVisibleWindowNumChange(const std::vector<VisibleWindowNumInfo>& visibleWindowNumInfo) = 0;
367 };
368 
369 /**
370  * @class ICameraFloatWindowChangedListener
371  *
372  * @brief Listener to observe camera window changed.
373  */
374 class ICameraFloatWindowChangedListener : virtual public RefBase {
375 public:
376     /**
377      * @brief Notify caller when camera window changed.
378      *
379      * @param accessTokenId Token id of camera window.
380      * @param isShowing True means camera is shown, false means the opposite.
381      */
382     virtual void OnCameraFloatWindowChange(uint32_t accessTokenId, bool isShowing) = 0;
383 };
384 
385 /**
386  * @class ICameraWindowChangedListener
387  *
388  * @brief Listener to observe camera window changed.
389  */
390 class ICameraWindowChangedListener : virtual public RefBase {
391 public:
392     /**
393      * @brief Notify caller when camera window changed.
394      *
395      * @param accessTokenId Token id of camera window.
396      * @param isShowing True means camera is shown, false means the opposite.
397      */
398     virtual void OnCameraWindowChange(uint32_t accessTokenId, bool isShowing) = 0;
399 };
400 
401 /**
402  * @class IDisplayInfoChangedListener
403  *
404  * @brief Listener to observe display information changed.
405  */
406 class IDisplayInfoChangedListener : virtual public RefBase {
407 public:
408     /**
409      * @brief Notify caller when display information changed.
410      *
411      * @param token token of ability.
412      * @param displayId ID of the display where the main window of the ability is located.
413      * @param density density of the display where the main window of the ability is located.
414      * @param orientation orientation of the display where the main window of the ability is located.
415      */
416     virtual void OnDisplayInfoChange(const sptr<IRemoteObject>& token,
417         DisplayId displayId, float density, DisplayOrientation orientation) = 0;
418 };
419 
420 /**
421  * @class IPiPStateChangedListener
422  *
423  * @brief Listener to observe PiP State changed.
424  */
425 class IPiPStateChangedListener : virtual public RefBase {
426 public:
427     /**
428      * @brief Notify caller when PiP State changed.
429      *
430      * @param bundleName the name of the bundle in PiP state changed.
431      * @param isForeground the state of the bundle in PiP State.
432      */
433     virtual void OnPiPStateChanged(const std::string& bundleName, bool isForeground) = 0;
434 };
435 
436 /**
437  * @class WindowManager
438  *
439  * @brief WindowManager used to manage window.
440  */
441 class WindowManager {
442 WM_DECLARE_SINGLE_INSTANCE_BASE(WindowManager);
443 friend class WindowManagerAgent;
444 friend class WMSDeathRecipient;
445 friend class SSMDeathRecipient;
446 public:
447     /**
448      * @brief Register WMS connection status changed listener.
449      * @attention Callable only by u0 system user. A process only supports successful registration once.
450      * When the foundation service restarts, you need to re-register the listener.
451      * If you want to re-register, please call UnregisterWMSConnectionChangedListener first.
452      *
453      * @param listener IWMSConnectionChangedListener.
454      * @return WM_OK means register success, others means register failed.
455      */
456     WMError RegisterWMSConnectionChangedListener(const sptr<IWMSConnectionChangedListener>& listener);
457     /**
458      * @brief Unregister WMS connection status changed listener.
459      * @attention Callable only by u0 system user.
460      *
461      * @return WM_OK means unregister success, others means unregister failed.
462      */
463     WMError UnregisterWMSConnectionChangedListener();
464     /**
465      * @brief Register focus changed listener.
466      *
467      * @param listener IFocusChangedListener.
468      * @return WM_OK means register success, others means register failed.
469      */
470     WMError RegisterFocusChangedListener(const sptr<IFocusChangedListener>& listener);
471     /**
472      * @brief Unregister focus changed listener.
473      *
474      * @param listener IFocusChangedListener.
475      * @return WM_OK means unregister success, others means unregister failed.
476      */
477     WMError UnregisterFocusChangedListener(const sptr<IFocusChangedListener>& listener);
478     /**
479      * @brief Register window mode listener.
480      *
481      * @param listener IWindowModeChangedListener.
482      * @return WM_OK means register success, others means register failed.
483      */
484     WMError RegisterWindowModeChangedListener(const sptr<IWindowModeChangedListener>& listener);
485     /**
486      * @brief Unregister window mode listener.
487      *
488      * @param listener IWindowModeChangedListener.
489      * @return WM_OK means unregister success, others means unregister failed.
490      */
491     WMError UnregisterWindowModeChangedListener(const sptr<IWindowModeChangedListener>& listener);
492     /**
493      * @brief Get window mode type.
494      *
495      * @param void
496      * @return WM_OK means get success, others means get failed.
497      */
498     WMError GetWindowModeType(WindowModeType& windowModeType) const;
499     /**
500      * @brief Register system bar changed listener.
501      *
502      * @param listener ISystemBarChangedListener.
503      * @return WM_OK means register success, others means register failed.
504      */
505     WMError RegisterSystemBarChangedListener(const sptr<ISystemBarChangedListener>& listener);
506     /**
507      * @brief Unregister system bar changed listener.
508      *
509      * @param listener ISystemBarChangedListener.
510      * @return WM_OK means unregister success, others means unregister failed.
511      */
512     WMError UnregisterSystemBarChangedListener(const sptr<ISystemBarChangedListener>& listener);
513     /**
514      * @brief Register window updated listener.
515      *
516      * @param listener IWindowUpdateListener.
517      * @return WM_OK means register success, others means register failed.
518      */
519     WMError RegisterWindowUpdateListener(const sptr<IWindowUpdateListener>& listener);
520     /**
521      * @brief Unregister window updated listener.
522      *
523      * @param listener IWindowUpdateListener.
524      * @return WM_OK means unregister success, others means unregister failed.
525      */
526     WMError UnregisterWindowUpdateListener(const sptr<IWindowUpdateListener>& listener);
527     /**
528      * @brief Register visibility changed listener.
529      *
530      * @param listener IVisibilityChangedListener.
531      * @return WM_OK means register success, others means register failed.
532      */
533     WMError RegisterVisibilityChangedListener(const sptr<IVisibilityChangedListener>& listener);
534     /**
535      * @brief Unregister visibility changed listener.
536      *
537      * @param listener IVisibilityChangedListener.
538      * @return WM_OK means unregister success, others means unregister failed.
539      */
540     WMError UnregisterVisibilityChangedListener(const sptr<IVisibilityChangedListener>& listener);
541     /**
542  * @brief Register drawingcontent changed listener.
543  *
544  * @param listener IDrawingContentChangedListener.
545  * @return WM_OK means register success, others means register failed.
546  */
547     WMError RegisterDrawingContentChangedListener(const sptr<IDrawingContentChangedListener>& listener);
548 
549     /**
550      * @brief Unregister drawingcontent changed listener.
551      *
552      * @param listener IDrawingContentChangedListener.
553      * @return WM_OK means unregister success, others means unregister failed.
554      */
555     WMError UnregisterDrawingContentChangedListener(const sptr<IDrawingContentChangedListener>& listener);
556 
557     /**
558      * @brief Register camera float window changed listener.
559      *
560      * @param listener ICameraFloatWindowChangedListener.
561      * @return WM_OK means register success, others means register failed.
562      */
563     WMError RegisterCameraFloatWindowChangedListener(const sptr<ICameraFloatWindowChangedListener>& listener);
564     /**
565      * @brief Unregister camera float window changed listener.
566      *
567      * @param listener ICameraFloatWindowChangedListener.
568      * @return WM_OK means unregister success, others means unregister failed.
569      */
570     WMError UnregisterCameraFloatWindowChangedListener(const sptr<ICameraFloatWindowChangedListener>& listener);
571     /**
572      * @brief Register water mark flag changed listener.
573      *
574      * @param listener IWaterMarkFlagChangedListener.
575      * @return WM_OK means register success, others means register failed.
576      */
577     WMError RegisterWaterMarkFlagChangedListener(const sptr<IWaterMarkFlagChangedListener>& listener);
578     /**
579      * @brief Unregister water mark flag changed listener.
580      *
581      * @param listener IWaterMarkFlagChangedListener.
582      * @return WM_OK means unregister success, others means unregister failed.
583      */
584     WMError UnregisterWaterMarkFlagChangedListener(const sptr<IWaterMarkFlagChangedListener>& listener);
585     /**
586      * @brief Register gesture navigation enabled changed listener.
587      *
588      * @param listener IGestureNavigationEnabledChangedListener.
589      * @return WM_OK means register success, others means register failed.
590      */
591     WMError RegisterGestureNavigationEnabledChangedListener(
592         const sptr<IGestureNavigationEnabledChangedListener>& listener);
593     /**
594      * @brief Unregister gesture navigation enabled changed listener.
595      *
596      * @param listener IGestureNavigationEnabledChangedListener.
597      * @return WM_OK means unregister success, others means unregister failed.
598      */
599     WMError UnregisterGestureNavigationEnabledChangedListener(
600         const sptr<IGestureNavigationEnabledChangedListener>& listener);
601 
602     /**
603      * @brief register display information changed listener.
604      *
605      * @param token token of ability.
606      * @param listener IDisplayInfoChangedListener.
607      * @return WM_OK means register success, others means register failed.
608      */
609     WMError RegisterDisplayInfoChangedListener(const sptr<IRemoteObject>& token,
610         const sptr<IDisplayInfoChangedListener>& listener);
611 
612     /**
613      * @brief unregister display info changed listener.Before the ability is destroyed, the
614      * UnregisterDisplayInfoChangedListener interface must be invoked.
615      * Otherwise, the sptr token may be destroyed abnormally.
616      *
617      * @param token token of ability.
618      * @param listener IDisplayInfoChangedListener.
619      * @return WM_OK means unregister success, others means unregister failed.
620      */
621     WMError UnregisterDisplayInfoChangedListener(const sptr<IRemoteObject>& token,
622         const sptr<IDisplayInfoChangedListener>& listener);
623 
624     /**
625      * @brief notify display information change.
626      *
627      * @param token ability token.
628      * @param displayid ID of the display where the main window of the ability is located
629      * @param density density of the display where the main window of the ability is located.
630      * @param orientation orientation of the display where the main window of the ability is located.
631      * @return WM_OK means notify success, others means notify failed.
632     */
633     WMError NotifyDisplayInfoChange(const sptr<IRemoteObject>& token, DisplayId displayId,
634         float density, DisplayOrientation orientation);
635 
636     /**
637      * @brief Minimize all app window.
638      *
639      * @param displayId Display id.
640      * @return WM_OK means minimize success, others means minimize failed.
641      */
642     WMError MinimizeAllAppWindows(DisplayId displayId);
643     /**
644      * @brief Toggle all app windows to the foreground.
645      *
646      * @return WM_OK means toggle success, others means toggle failed.
647      */
648     WMError ToggleShownStateForAllAppWindows();
649     /**
650      * @brief Set window layout mode.
651      *
652      * @param mode Window layout mode.
653      * @return WM_OK means set success, others means set failed.
654      */
655     WMError SetWindowLayoutMode(WindowLayoutMode mode);
656     /**
657      * @brief Get accessibility window info.
658      *
659      * @param infos WindowInfos used for Accessibility.
660      * @return WM_OK means get success, others means get failed.
661      */
662     WMError GetAccessibilityWindowInfo(std::vector<sptr<AccessibilityWindowInfo>>& infos) const;
663     /**
664      * @brief Get unreliable window info.
665      *
666      * @param infos Unreliable Window Info.
667      * @return WM_OK means get success, others means get failed.
668      */
669     WMError GetUnreliableWindowInfo(int32_t windowId,
670         std::vector<sptr<UnreliableWindowInfo>>& infos) const;
671     /**
672      * @brief Get visibility window info.
673      *
674      * @param infos Visible window infos
675      * @return WM_OK means get success, others means get failed.
676      */
677     WMError GetVisibilityWindowInfo(std::vector<sptr<WindowVisibilityInfo>>& infos) const;
678     /**
679      * @brief Set gesture navigaion enabled.
680      *
681      * @param enable True means set gesture on, false means set gesture off.
682      * @return WM_OK means set success, others means set failed.
683      */
684     WMError SetGestureNavigaionEnabled(bool enable) const;
685 
686     /**
687      * @brief Get focus window.
688      *
689      * @param focusInfo Focus window info.
690      * @return FocusChangeInfo object about focus window.
691      */
692     void GetFocusWindowInfo(FocusChangeInfo& focusInfo);
693 
694     /**
695      * @brief Dump all session info
696      *
697      * @param infos session infos
698      * @return WM_OK means set success, others means set failed.
699      */
700     WMError DumpSessionAll(std::vector<std::string> &infos);
701 
702     /**
703      * @brief Dump session info with id
704      *
705      * @param infos session infos
706      * @return WM_OK means set success, others means set failed.
707      */
708     WMError DumpSessionWithId(int32_t persistentId, std::vector<std::string> &infos);
709 
710     /**
711      * @brief Get uiContent remote object
712      *
713      * @param windowId windowId
714      * @param uiContentRemoteObj uiContentRemoteObj
715      * @return WM_OK if successfully retrieved uiContentRemoteObj
716      */
717     WMError GetUIContentRemoteObj(int32_t windowId, sptr<IRemoteObject>& uiContentRemoteObj);
718 
719     /**
720      * @brief raise window to top by windowId
721      *
722      * @param persistentId this window to raise
723      * @return WM_OK if raise success
724      */
725     WMError RaiseWindowToTop(int32_t persistentId);
726 
727     /**
728      * @brief notify window extension visibility change
729      *
730      * @param pid process id
731      * @param uid user id
732      * @param visible visibility
733      * @return WM_OK means notify success, others means notify failed.
734     */
735     WMError NotifyWindowExtensionVisibilityChange(int32_t pid, int32_t uid, bool visible);
736 
737     /**
738      * @brief Shift window focus within the same application. Only main window and subwindow.
739      *
740      * @param sourcePersistentId Window id which the focus shift from
741      * @param targetPersistentId Window id which the focus shift to
742      * @return WM_OK means shift window focus success, others means failed.
743     */
744     WMError ShiftAppWindowFocus(int32_t sourcePersistentId, int32_t targetPersistentId);
745 
746     /**
747      * @brief Get snapshot by window id.
748      *
749      * @param windowId Window id which want to snapshot.
750      * @param pixelMap Snapshot output pixel map.
751      * @return WM_OK means get snapshot success, others means failed.
752     */
753     WMError GetSnapshotByWindowId(int32_t windowId, std::shared_ptr<Media::PixelMap>& pixelMap);
754 
755     /**
756      * @brief Register visible main window num changed listener.
757      *
758      * @param listener IVisibleWindowNumChangedListener.
759      * @return WM_OK means register success, others means register failed.
760      */
761     WMError RegisterVisibleWindowNumChangedListener(const sptr<IVisibleWindowNumChangedListener>& listener);
762     /**
763      * @brief Unregister visible main window num changed listener.
764      *
765      * @param listener IVisibleWindowNumChangedListener.
766      * @return WM_OK means unregister success, others means unregister failed.
767      */
768     WMError UnregisterVisibleWindowNumChangedListener(const sptr<IVisibleWindowNumChangedListener>& listener);
769 
770     /**
771      * @brief Register WindowStyle changed listener.
772      *
773      * @param listener IWindowStyleChangedListener
774      * @return WM_OK means register success, others means unregister failed.
775      */
776     WMError RegisterWindowStyleChangedListener(const sptr<IWindowStyleChangedListener>& listener);
777 
778     /**
779     * @brief Unregister WindowStyle changed listener.
780     *
781     * @param listener IWindowStyleChangedListener
782     * @return WM_OK means unregister success, others means unregister failed.
783     */
784     WMError UnregisterWindowStyleChangedListener(const sptr<IWindowStyleChangedListener>& listener);
785 
786     /**
787      * @brief Get window style type.
788      *
789      * @param windowStyleType WindowType
790      * @return @return WM_OK means get window style success, others means failed.
791      */
792     WindowStyleType GetWindowStyleType();
793 
794     /**
795      * @brief Get window ids by coordinate.
796      *
797      * @param displayId display id
798      * @param windowNumber indicates the number of query windows
799      * @param x x-coordinate of the window
800      * @param y y-coordinate of the window
801      * @param windowIds array of window id
802      * @return WM_OK means get success, others means get failed.
803      */
804     WMError GetWindowIdsByCoordinate(DisplayId displayId, int32_t windowNumber,
805         int32_t x, int32_t y, std::vector<int32_t>& windowIds) const;
806 
807     /**
808      * @brief Release screen lock of foreground sessions.
809      *
810      * @return WM_OK means release success, others means failed.
811      */
812     WMError ReleaseForegroundSessionScreenLock();
813 
814     /**
815      * @brief Get displayId by windowId.
816      *
817      * @param windowIds list of window ids that need to get screen ids
818      * @param windowDisplayIdMap map of windows and displayIds
819      * @return WM_OK means get success, others means failed.
820      */
821     WMError GetDisplayIdByWindowId(const std::vector<uint64_t>& windowIds,
822         std::unordered_map<uint64_t, DisplayId>& windowDisplayIdMap);
823 
824     /**
825      * @brief Set global drag resize type.
826      * this priority is highest.
827      *
828      * @param dragResizeType global drag resize type to set
829      * @return WM_OK means get success, others means failed.
830      */
831     WMError SetGlobalDragResizeType(DragResizeType dragResizeType);
832 
833     /**
834      * @brief Get global drag resize type.
835      * if it is RESIZE_TYPE_UNDEFINED, return default value.
836      *
837      * @param dragResizeType global drag resize type to get
838      * @return WM_OK means get success, others means failed.
839      */
840     WMError GetGlobalDragResizeType(DragResizeType& dragResizeType);
841 
842     /**
843      * @brief Set drag resize type of specific app.
844      * only when global value is RESIZE_TYPE_UNDEFINED, this value take effect.
845      *
846      * @param bundleName bundleName of specific app
847      * @param dragResizeType drag resize type to set
848      * @return WM_OK means get success, others means failed.
849      */
850     WMError SetAppDragResizeType(const std::string& bundleName, DragResizeType dragResizeType);
851 
852     /**
853      * @brief Get drag resize type of specific app.
854      * effective order:
855      *  1. global value
856      *  2. app value
857      *  3. default value
858      *
859      * @param bundleName bundleName of specific app
860      * @param dragResizeType drag resize type to get
861      * @return WM_OK means get success, others means failed.
862      */
863     WMError GetAppDragResizeType(const std::string& bundleName, DragResizeType& dragResizeType);
864 
865 private:
866     WindowManager();
867     ~WindowManager();
868     std::recursive_mutex mutex_;
869     class Impl;
870     std::unique_ptr<Impl> pImpl_;
871     bool destroyed_ = false;
872 
873     void OnWMSConnectionChanged(int32_t userId, int32_t screenId, bool isConnected) const;
874     void UpdateFocusStatus(uint32_t windowId, const sptr<IRemoteObject>& abilityToken, WindowType windowType,
875         DisplayId displayId, bool focused) const;
876     void UpdateFocusChangeInfo(const sptr<FocusChangeInfo>& focusChangeInfo, bool focused) const;
877     void UpdateWindowModeTypeInfo(WindowModeType type) const;
878     void UpdateSystemBarRegionTints(DisplayId displayId, const SystemBarRegionTints& tints) const;
879     void NotifyAccessibilityWindowInfo(const std::vector<sptr<AccessibilityWindowInfo>>& infos,
880         WindowUpdateType type) const;
881     void UpdateWindowVisibilityInfo(
882         const std::vector<sptr<WindowVisibilityInfo>>& windowVisibilityInfos) const;
883     void UpdateWindowDrawingContentInfo(
884         const std::vector<sptr<WindowDrawingContentInfo>>& windowDrawingContentInfos) const;
885     void UpdateCameraFloatWindowStatus(uint32_t accessTokenId, bool isShowing) const;
886     void NotifyWaterMarkFlagChangedResult(bool showWaterMark) const;
887     void NotifyGestureNavigationEnabledResult(bool enable) const;
888     void UpdateVisibleWindowNum(const std::vector<VisibleWindowNumInfo>& visibleWindowNumInfo);
889     WMError NotifyWindowStyleChange(WindowStyleType type);
890 };
891 } // namespace Rosen
892 } // namespace OHOS
893 
894 #endif // OHOS_ROSEN_WINDOW_MANAGER_H
895