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