• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2023 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_WM_COMMON_H
17 #define OHOS_ROSEN_WM_COMMON_H
18 
19 #include <iomanip>
20 #include <map>
21 #include <sstream>
22 #include <string>
23 #include <unordered_set>
24 #include <variant>
25 #include <vector>
26 
27 #include <float.h>
28 
29 #include <parcel.h>
30 
31 #include "dm_common.h"
32 #include "securec.h"
33 #include "wm_animation_common.h"
34 #include "wm_math.h"
35 #include "wm_type.h"
36 
37 namespace OHOS {
38 namespace Rosen {
39 namespace {
40 constexpr uint32_t DEFAULT_SPACING_BETWEEN_BUTTONS = 12;
41 constexpr uint32_t DEFAULT_BUTTON_BACKGROUND_SIZE = 28;
42 constexpr uint32_t DEFAULT_CLOSE_BUTTON_RIGHT_MARGIN = 20;
43 constexpr uint32_t DEFAULT_BUTTON_ICON_SIZE = 20;
44 constexpr uint32_t DEFAULT_BUTTON_BACKGROUND_CORNER_RADIUS = 4;
45 constexpr int32_t DEFAULT_COLOR_MODE = -1;
46 constexpr int32_t MIN_COLOR_MODE = -1;
47 constexpr int32_t MAX_COLOR_MODE = 1;
48 constexpr int32_t LIGHT_COLOR_MODE = 0;
49 constexpr int32_t DARK_COLOR_MODE = 1;
50 constexpr uint32_t MIN_SPACING_BETWEEN_BUTTONS = 8;
51 constexpr uint32_t MAX_SPACING_BETWEEN_BUTTONS = 24;
52 constexpr uint32_t MIN_BUTTON_BACKGROUND_SIZE = 20;
53 constexpr uint32_t MAX_BUTTON_BACKGROUND_SIZE = 40;
54 constexpr uint32_t MIN_CLOSE_BUTTON_RIGHT_MARGIN = 6;
55 constexpr uint32_t MAX_CLOSE_BUTTON_RIGHT_MARGIN = 22;
56 constexpr uint32_t MIN_BUTTON_ICON_SIZE = 16;
57 constexpr uint32_t MAX_BUTTON_ICON_SIZE = 24;
58 constexpr uint32_t MIN_BUTTON_BACKGROUND_CORNER_RADIUS = 4;
59 constexpr uint32_t MAX_BUTTON_BACKGROUND_CORNER_RADIUS = 8;
60 constexpr int32_t API_VERSION_INVALID = -1;
61 constexpr uint32_t MAX_SIZE_PIP_CONTROL_GROUP = 8;
62 constexpr uint32_t MAX_SIZE_PIP_CONTROL = 9;
63 constexpr int32_t SPECIFIC_ZINDEX_INVALID = -1;
64 constexpr double POS_ZERO = 0.001f;
65 /*
66  * PC Window Sidebar Blur
67  */
68 constexpr float SIDEBAR_BLUR_NUMBER_ZERO = 0.0f;
69 constexpr float SIDEBAR_DEFAULT_RADIUS_LIGHT = 57.0f;
70 constexpr float SIDEBAR_DEFAULT_RADIUS_DARK = 57.0f;
71 constexpr float SIDEBAR_DEFAULT_SATURATION_LIGHT = 2.0f;
72 constexpr float SIDEBAR_DEFAULT_SATURATION_DARK = 2.6f;
73 constexpr float SIDEBAR_DEFAULT_BRIGHTNESS_LIGHT = 1.0f;
74 constexpr float SIDEBAR_DEFAULT_BRIGHTNESS_DARK = 0.4f;
75 constexpr uint32_t SIDEBAR_DEFAULT_MASKCOLOR_LIGHT = 0xdbf1f1f1;
76 constexpr uint32_t SIDEBAR_DEFAULT_MASKCOLOR_DARK = 0xe61a1a1a;
77 constexpr float SIDEBAR_MAXIMIZE_RADIUS_LIGHT = 57.0f;
78 constexpr float SIDEBAR_MAXIMIZE_RADIUS_DARK = 57.0f;
79 constexpr float SIDEBAR_MAXIMIZE_SATURATION_LIGHT = 2.0f;
80 constexpr float SIDEBAR_MAXIMIZE_SATURATION_DARK = 1.0f;
81 constexpr float SIDEBAR_MAXIMIZE_BRIGHTNESS_LIGHT = 1.0f;
82 constexpr float SIDEBAR_MAXIMIZE_BRIGHTNESS_DARK = 0.9f;
83 constexpr uint32_t SIDEBAR_MAXIMIZE_MASKCOLOR_LIGHT = 0xf2f1f1f1;
84 constexpr uint32_t SIDEBAR_MAXIMIZE_MASKCOLOR_DARK = 0xf21a1a1a;
85 constexpr uint32_t SIDEBAR_SNAPSHOT_MASKCOLOR_LIGHT = 0xffe5e5e5;
86 constexpr uint32_t SIDEBAR_SNAPSHOT_MASKCOLOR_DARK = 0xff414141;
87 
88 /*
89  * Compatible Mode
90  */
91 constexpr float COMPACT_SIMULATION_SCALE_DPI = 3.25f;
92 constexpr float COMPACT_NORMAL_SCALE = 1.0f;
93 }
94 
95 /**
96  * @brief Enumerates type of window.
97  */
98 enum class WindowType : uint32_t {
99     APP_WINDOW_BASE = 1,
100     APP_MAIN_WINDOW_BASE = APP_WINDOW_BASE,
101     WINDOW_TYPE_APP_MAIN_WINDOW = APP_MAIN_WINDOW_BASE,
102     APP_MAIN_WINDOW_END,
103 
104     APP_SUB_WINDOW_BASE = 1000,
105     WINDOW_TYPE_MEDIA = APP_SUB_WINDOW_BASE,
106     WINDOW_TYPE_APP_SUB_WINDOW,
107     WINDOW_TYPE_APP_COMPONENT,
108     APP_SUB_WINDOW_END,
109     APP_WINDOW_END = APP_SUB_WINDOW_END,
110 
111     SYSTEM_WINDOW_BASE = 2000,
112     BELOW_APP_SYSTEM_WINDOW_BASE = SYSTEM_WINDOW_BASE,
113     WINDOW_TYPE_WALLPAPER = SYSTEM_WINDOW_BASE,
114     WINDOW_TYPE_DESKTOP,
115     BELOW_APP_SYSTEM_WINDOW_END,
116 
117     ABOVE_APP_SYSTEM_WINDOW_BASE = 2100,
118     WINDOW_TYPE_APP_LAUNCHING = ABOVE_APP_SYSTEM_WINDOW_BASE,
119     WINDOW_TYPE_DOCK_SLICE,
120     WINDOW_TYPE_INCOMING_CALL,
121     WINDOW_TYPE_SEARCHING_BAR,
122     WINDOW_TYPE_SYSTEM_ALARM_WINDOW,
123     WINDOW_TYPE_INPUT_METHOD_FLOAT,
124     WINDOW_TYPE_FLOAT,
125     WINDOW_TYPE_TOAST,
126     WINDOW_TYPE_STATUS_BAR,
127     WINDOW_TYPE_PANEL,
128     WINDOW_TYPE_KEYGUARD,
129     WINDOW_TYPE_VOLUME_OVERLAY,
130     WINDOW_TYPE_NAVIGATION_BAR,
131     WINDOW_TYPE_DRAGGING_EFFECT,
132     WINDOW_TYPE_POINTER,
133     WINDOW_TYPE_LAUNCHER_RECENT,
134     WINDOW_TYPE_LAUNCHER_DOCK,
135     WINDOW_TYPE_BOOT_ANIMATION,
136     WINDOW_TYPE_FREEZE_DISPLAY,
137     WINDOW_TYPE_VOICE_INTERACTION,
138     WINDOW_TYPE_FLOAT_CAMERA,
139     WINDOW_TYPE_PLACEHOLDER,
140     WINDOW_TYPE_DIALOG,
141     WINDOW_TYPE_SCREENSHOT,
142     WINDOW_TYPE_INPUT_METHOD_STATUS_BAR,
143     WINDOW_TYPE_GLOBAL_SEARCH,
144     WINDOW_TYPE_NEGATIVE_SCREEN,
145     WINDOW_TYPE_SYSTEM_TOAST,
146     WINDOW_TYPE_SYSTEM_FLOAT,
147     WINDOW_TYPE_PIP,
148     WINDOW_TYPE_THEME_EDITOR,
149     WINDOW_TYPE_NAVIGATION_INDICATOR,
150     WINDOW_TYPE_HANDWRITE,
151     WINDOW_TYPE_SCENE_BOARD,
152     WINDOW_TYPE_KEYBOARD_PANEL,
153     WINDOW_TYPE_SCB_DEFAULT,
154     WINDOW_TYPE_TRANSPARENT_VIEW,
155     WINDOW_TYPE_WALLET_SWIPE_CARD,
156     WINDOW_TYPE_SCREEN_CONTROL,
157     WINDOW_TYPE_FLOAT_NAVIGATION,
158     WINDOW_TYPE_MUTISCREEN_COLLABORATION,
159     WINDOW_TYPE_DYNAMIC,
160     WINDOW_TYPE_MAGNIFICATION,
161     WINDOW_TYPE_MAGNIFICATION_MENU,
162     WINDOW_TYPE_SELECTION,
163     WINDOW_TYPE_FB,
164     ABOVE_APP_SYSTEM_WINDOW_END,
165 
166     SYSTEM_SUB_WINDOW_BASE = 2500,
167     WINDOW_TYPE_SYSTEM_SUB_WINDOW = SYSTEM_SUB_WINDOW_BASE,
168     SYSTEM_SUB_WINDOW_END,
169 
170     SYSTEM_WINDOW_END = SYSTEM_SUB_WINDOW_END,
171 
172     WINDOW_TYPE_UI_EXTENSION = 3000
173 };
174 
175 /**
176  * @struct HookInfo.
177  *
178  * @brief hook diaplayinfo deepending on the window size.
179  */
180 struct HookInfo {
181     uint32_t width_;
182     uint32_t height_;
183     float_t density_;
184     uint32_t rotation_;
185     bool enableHookRotation_;
186     uint32_t displayOrientation_;
187     bool enableHookDisplayOrientation_;
188 
ToStringHookInfo189     std::string ToString() const
190     {
191         std::ostringstream oss;
192         oss << "width: " << width_ << ", height: " << height_ << ", density: " << density_
193             << ", rotation: " << rotation_
194             << ", enableHookRotation: " << (enableHookRotation_ ? "true" : "false")
195             << ", orientation: " << displayOrientation_
196             << ", enableHookOrientation: " << (enableHookDisplayOrientation_ ? "true" : "false");
197         return oss.str();
198     }
199 };
200 
201 /**
202  * @brief Enumerates mode of window.
203  */
204 enum class WindowMode : uint32_t {
205     WINDOW_MODE_UNDEFINED = 0,
206     WINDOW_MODE_FULLSCREEN = 1,
207     WINDOW_MODE_SPLIT_PRIMARY = 100,
208     WINDOW_MODE_SPLIT_SECONDARY,
209     WINDOW_MODE_FLOATING,
210     WINDOW_MODE_PIP,
211     WINDOW_MODE_FB,
212     END = WINDOW_MODE_FB,
213 };
214 
215 /**
216  * @brief Enumerates modeType of window.
217  */
218 enum class WindowModeType : uint8_t {
219     WINDOW_MODE_SPLIT_FLOATING = 0,
220     WINDOW_MODE_SPLIT = 1,
221     WINDOW_MODE_FLOATING = 2,
222     WINDOW_MODE_FULLSCREEN = 3,
223     WINDOW_MODE_FULLSCREEN_FLOATING = 4,
224     WINDOW_MODE_OTHER = 5
225 };
226 
227 /**
228  * @brief Enumerates global mode of window.
229  */
230 enum class GlobalWindowMode : uint32_t {
231     UNKNOWN = 0,
232     FULLSCREEN = 1,
233     SPLIT = 1 << 1,
234     FLOAT = 1 << 2,
235     PIP = 1 << 3,
236     ALL = FULLSCREEN | SPLIT | FLOAT | PIP
237 };
238 
239 inline GlobalWindowMode operator|(GlobalWindowMode lhs, GlobalWindowMode rhs)
240 {
241     return static_cast<GlobalWindowMode>(static_cast<uint32_t>(lhs) | static_cast<uint32_t>(rhs));
242 }
243 
244 /**
245  * @brief Enumerates modal of sub session.
246  */
247 enum class SubWindowModalType : uint32_t {
248     BEGIN = 0,
249     TYPE_UNDEFINED = BEGIN,
250     TYPE_NORMAL,
251     TYPE_DIALOG,
252     TYPE_WINDOW_MODALITY,
253     TYPE_TOAST,
254     TYPE_APPLICATION_MODALITY,
255     TYPE_TEXT_MENU,
256     END = TYPE_TEXT_MENU,
257 };
258 
259 /**
260  * @brief Enumerates mode supported of window.
261  */
262 enum WindowModeSupport : uint32_t {
263     WINDOW_MODE_SUPPORT_FULLSCREEN = 1 << 0,
264     WINDOW_MODE_SUPPORT_FLOATING = 1 << 1,
265     WINDOW_MODE_SUPPORT_SPLIT_PRIMARY = 1 << 2,
266     WINDOW_MODE_SUPPORT_SPLIT_SECONDARY = 1 << 3,
267     WINDOW_MODE_SUPPORT_PIP = 1 << 4,
268     WINDOW_MODE_SUPPORT_FB = 1 << 5,
269     WINDOW_MODE_SUPPORT_ALL = WINDOW_MODE_SUPPORT_FULLSCREEN |
270                               WINDOW_MODE_SUPPORT_SPLIT_PRIMARY |
271                               WINDOW_MODE_SUPPORT_SPLIT_SECONDARY |
272                               WINDOW_MODE_SUPPORT_FLOATING |
273                               WINDOW_MODE_SUPPORT_PIP |
274                               WINDOW_MODE_SUPPORT_FB
275 };
276 
277 /**
278  * @brief Enumerates blur style of window.
279  */
280 enum class WindowBlurStyle : uint32_t {
281     WINDOW_BLUR_OFF = 0,
282     WINDOW_BLUR_THIN,
283     WINDOW_BLUR_REGULAR,
284     WINDOW_BLUR_THICK
285 };
286 
287 /**
288  * @brief Enumerates cross axis state of window.
289  */
290 enum class CrossAxisState : uint32_t {
291     STATE_INVALID = 0,
292     STATE_CROSS,
293     STATE_NO_CROSS,
294     STATE_END,
295 };
296 
297 /**
298  * @brief Enumerates state of window.
299  */
300 enum class WindowState : uint32_t {
301     STATE_INITIAL,
302     STATE_CREATED,
303     STATE_SHOWN,
304     STATE_HIDDEN,
305     STATE_FROZEN,
306     STATE_UNFROZEN,
307     STATE_DESTROYED,
308     STATE_BOTTOM = STATE_DESTROYED, // Add state type after STATE_DESTROYED is not allowed
309 };
310 
311 /**
312  * @brief Enumerates error code of window.
313  */
314 enum class WMError : int32_t {
315     WM_OK = 0,
316     WM_DO_NOTHING,
317     WM_ERROR_NO_MEM,
318     WM_ERROR_DESTROYED_OBJECT,
319     WM_ERROR_INVALID_WINDOW,
320     WM_ERROR_INVALID_WINDOW_MODE_OR_SIZE,
321     WM_ERROR_INVALID_OPERATION,
322     WM_ERROR_INVALID_PERMISSION,
323     WM_ERROR_NOT_SYSTEM_APP,
324     WM_ERROR_NO_REMOTE_ANIMATION,
325     WM_ERROR_INVALID_DISPLAY,
326     WM_ERROR_INVALID_PARENT,
327     WM_ERROR_INVALID_OP_IN_CUR_STATUS,
328     WM_ERROR_REPEAT_OPERATION,
329     WM_ERROR_INVALID_SESSION,
330     WM_ERROR_INVALID_CALLING,
331     WM_ERROR_SYSTEM_ABNORMALLY,
332 
333     WM_ERROR_DEVICE_NOT_SUPPORT = 801, // the value do not change.It is defined on all system
334 
335     WM_ERROR_NEED_REPORT_BASE = 1000, // error code > 1000 means need report
336     WM_ERROR_NULLPTR,
337     WM_ERROR_INVALID_TYPE,
338     WM_ERROR_INVALID_PARAM,
339     WM_ERROR_SAMGR,
340     WM_ERROR_IPC_FAILED,
341     WM_ERROR_NEED_REPORT_END,
342     WM_ERROR_START_ABILITY_FAILED,
343     WM_ERROR_PIP_DESTROY_FAILED,
344     WM_ERROR_PIP_STATE_ABNORMALLY,
345     WM_ERROR_PIP_CREATE_FAILED,
346     WM_ERROR_PIP_INTERNAL_ERROR,
347     WM_ERROR_PIP_REPEAT_OPERATION,
348     WM_ERROR_ILLEGAL_PARAM,
349     WM_ERROR_UI_EFFECT_ERROR,
350     WM_ERROR_TIMEOUT,
351     WM_ERROR_FB_PARAM_INVALID,
352     WM_ERROR_FB_CREATE_FAILED,
353     WM_ERROR_FB_REPEAT_CONTROLLER,
354     WM_ERROR_FB_REPEAT_OPERATION,
355     WM_ERROR_FB_INTERNAL_ERROR,
356     WM_ERROR_FB_STATE_ABNORMALLY,
357     WM_ERROR_FB_INVALID_STATE,
358     WM_ERROR_FB_RESTORE_MAIN_WINDOW_FAILED,
359     WM_ERROR_FB_UPDATE_TEMPLATE_TYPE_DENIED,
360     WM_ERROR_FB_UPDATE_STATIC_TEMPLATE_DENIED,
361 };
362 
363 /**
364  * @brief Enumerates error code of window only used for js api.
365  */
366 enum class WmErrorCode : int32_t {
367     WM_OK = 0,
368     WM_ERROR_NO_PERMISSION = 201,
369     WM_ERROR_NOT_SYSTEM_APP = 202,
370     WM_ERROR_INVALID_PARAM = 401,
371     WM_ERROR_DEVICE_NOT_SUPPORT = 801,
372     WM_ERROR_REPEAT_OPERATION = 1300001,
373     WM_ERROR_STATE_ABNORMALLY = 1300002,
374     WM_ERROR_SYSTEM_ABNORMALLY = 1300003,
375     WM_ERROR_INVALID_CALLING = 1300004,
376     WM_ERROR_STAGE_ABNORMALLY = 1300005,
377     WM_ERROR_CONTEXT_ABNORMALLY = 1300006,
378     WM_ERROR_START_ABILITY_FAILED = 1300007,
379     WM_ERROR_INVALID_DISPLAY = 1300008,
380     WM_ERROR_INVALID_PARENT = 1300009,
381     WM_ERROR_INVALID_OP_IN_CUR_STATUS = 1300010,
382     WM_ERROR_PIP_DESTROY_FAILED = 1300011,
383     WM_ERROR_PIP_STATE_ABNORMALLY = 1300012,
384     WM_ERROR_PIP_CREATE_FAILED = 1300013,
385     WM_ERROR_PIP_INTERNAL_ERROR = 1300014,
386     WM_ERROR_PIP_REPEAT_OPERATION = 1300015,
387     WM_ERROR_ILLEGAL_PARAM = 1300016,
388     WM_ERROR_UI_EFFECT_ERROR = 1300017,
389     WM_ERROR_TIMEOUT = 1300018,
390     WM_ERROR_FB_PARAM_INVALID = 1300019,
391     WM_ERROR_FB_CREATE_FAILED = 1300020,
392     WM_ERROR_FB_REPEAT_CONTROLLER = 1300021,
393     WM_ERROR_FB_REPEAT_OPERATION = 1300022,
394     WM_ERROR_FB_INTERNAL_ERROR = 1300023,
395     WM_ERROR_FB_STATE_ABNORMALLY = 1300024,
396     WM_ERROR_FB_INVALID_STATE = 1300025,
397     WM_ERROR_FB_RESTORE_MAIN_WINDOW_FAILED = 1300026,
398     WM_ERROR_FB_UPDATE_TEMPLATE_TYPE_DENIED = 1300027,
399     WM_ERROR_FB_UPDATE_STATIC_TEMPLATE_DENIED = 1300028,
400 };
401 
402 /**
403  * @brief Enumerates status of window.
404  */
405 enum class WindowStatus : uint32_t {
406     WINDOW_STATUS_UNDEFINED = 0,
407     WINDOW_STATUS_FULLSCREEN = 1,
408     WINDOW_STATUS_MAXIMIZE,
409     WINDOW_STATUS_MINIMIZE,
410     WINDOW_STATUS_FLOATING,
411     WINDOW_STATUS_SPLITSCREEN
412 };
413 
414 /**
415  * @brief Enumerates setting flag of systemStatusBar
416  */
417 enum class SystemBarSettingFlag : uint32_t {
418     DEFAULT_SETTING = 0,
419     COLOR_SETTING = 1,
420     ENABLE_SETTING = 1 << 1,
421     ALL_SETTING = COLOR_SETTING | ENABLE_SETTING,
422     FOLLOW_SETTING = 1 << 2
423 };
424 
425 inline SystemBarSettingFlag operator|(SystemBarSettingFlag lhs, SystemBarSettingFlag rhs)
426 {
427     using T = std::underlying_type_t<SystemBarSettingFlag>;
428     return static_cast<SystemBarSettingFlag>(static_cast<T>(lhs) | static_cast<T>(rhs));
429 }
430 
431 inline SystemBarSettingFlag& operator|=
432     (SystemBarSettingFlag& lhs, SystemBarSettingFlag rhs) { return lhs = lhs | rhs; }
433 
434 /**
435  * @brief Enumerates flag of ControlAppType.
436  */
437 enum class ControlAppType : uint8_t {
438     CONTROL_APP_TYPE_BEGIN = 0,
439     APP_LOCK = 1,
440     PARENT_CONTROL,
441     PRIVACY_WINDOW,
442     CONTROL_APP_TYPE_END,
443 };
444 
445 /**
446  * @brief Enumerates flag of multiWindowUIType.
447  */
448 enum class WindowUIType : uint8_t {
449     PHONE_WINDOW = 0,
450     PC_WINDOW,
451     PAD_WINDOW,
452     INVALID_WINDOW
453 };
454 
455 /**
456  * @brief Used to map from WMError to WmErrorCode.
457  */
458 extern const std::map<WMError, WmErrorCode> WM_JS_TO_ERROR_CODE_MAP;
459 WmErrorCode ConvertErrorToCode(WMError error);
460 
461 /**
462  * @brief Enumerates flag of window.
463  */
464 enum class WindowFlag : uint32_t {
465     WINDOW_FLAG_NEED_AVOID = 1,
466     WINDOW_FLAG_PARENT_LIMIT = 1 << 1,
467     WINDOW_FLAG_SHOW_WHEN_LOCKED = 1 << 2,
468     WINDOW_FLAG_FORBID_SPLIT_MOVE = 1 << 3,
469     WINDOW_FLAG_WATER_MARK = 1 << 4,
470     WINDOW_FLAG_IS_MODAL = 1 << 5,
471     WINDOW_FLAG_HANDWRITING = 1 << 6,
472     WINDOW_FLAG_IS_TOAST = 1 << 7,
473     WINDOW_FLAG_IS_APPLICATION_MODAL = 1 << 8,
474     WINDOW_FLAG_IS_TEXT_MENU = 1 << 9,
475     WINDOW_FLAG_END = 1 << 10,
476 };
477 
478 /**
479  * @brief Enumerates system and app sub window avoid area options
480  */
481 enum class AvoidAreaOption : uint32_t {
482     ENABLE_SYSTEM_WINDOW = 1,
483     ENABLE_APP_SUB_WINDOW = 1 << 1,
484 };
485 
486 /**
487  * @brief Flag of uiextension window.
488  */
489 union ExtensionWindowFlags {
490     uint32_t bitData;
491     struct {
492         // Each flag should be false default, true when active
493         bool hideNonSecureWindowsFlag : 1;
494         bool waterMarkFlag : 1;
495         bool privacyModeFlag : 1;
496     };
ExtensionWindowFlags()497     ExtensionWindowFlags() : bitData(0) {}
ExtensionWindowFlags(uint32_t bits)498     ExtensionWindowFlags(uint32_t bits) : bitData(bits) {}
~ExtensionWindowFlags()499     ~ExtensionWindowFlags() {}
SetAllActive()500     void SetAllActive()
501     {
502         hideNonSecureWindowsFlag = true;
503         waterMarkFlag = true;
504         privacyModeFlag = true;
505     }
506 };
507 
508 /**
509  * @brief Enumerates window size change reason.
510  */
511 enum class WindowSizeChangeReason : uint32_t {
512     UNDEFINED = 0,
513     MAXIMIZE,
514     RECOVER,
515     ROTATION,
516     DRAG,
517     DRAG_START,
518     DRAG_END,
519     RESIZE,
520     RESIZE_WITH_ANIMATION,
521     MOVE,
522     MOVE_WITH_ANIMATION,
523     HIDE,
524     TRANSFORM,
525     CUSTOM_ANIMATION_SHOW,
526     FULL_TO_SPLIT,
527     SPLIT_TO_FULL,
528     FULL_TO_FLOATING,
529     FLOATING_TO_FULL,
530     PIP_START,
531     PIP_SHOW,
532     PIP_AUTO_START,
533     PIP_RATIO_CHANGE,
534     PIP_RESTORE,
535     UPDATE_DPI_SYNC,
536     DRAG_MOVE,
537     AVOID_AREA_CHANGE,
538     MAXIMIZE_TO_SPLIT,
539     SPLIT_TO_MAXIMIZE,
540     PAGE_ROTATION,
541     SPLIT_DRAG_START,
542     SPLIT_DRAG,
543     SPLIT_DRAG_END,
544     RESIZE_BY_LIMIT,
545     MAXIMIZE_IN_IMPLICT = 32,
546     RECOVER_IN_IMPLICIT = 33,
547     OCCUPIED_AREA_CHANGE = 34,
548     SCREEN_RELATIVE_POSITION_CHANGE,
549     ROOT_SCENE_CHANGE,
550     SNAPSHOT_ROTATION = 37,
551     END,
552 };
553 
IsMoveToOrDragMove(WindowSizeChangeReason reason)554 inline bool IsMoveToOrDragMove(WindowSizeChangeReason reason)
555 {
556     return reason == WindowSizeChangeReason::MOVE || reason == WindowSizeChangeReason::DRAG_MOVE;
557 }
558 
559 /**
560  * @brief Enumerates layout mode of window.
561  */
562 enum class WindowLayoutMode : uint32_t {
563     BASE = 0,
564     CASCADE = BASE,
565     TILE = 1,
566     END,
567 };
568 
569 /**
570  * @brief Enumerates drag event.
571  */
572 enum class DragEvent : uint32_t {
573     DRAG_EVENT_IN  = 1,
574     DRAG_EVENT_OUT,
575     DRAG_EVENT_MOVE,
576     DRAG_EVENT_END,
577 };
578 
579 /**
580  * @brief Enumerates drag resize type.
581  */
582 enum class DragResizeType : uint32_t {
583     RESIZE_TYPE_UNDEFINED = 0,
584     RESIZE_EACH_FRAME = 1,
585     RESIZE_WHEN_DRAG_END = 2,
586     RESIZE_KEY_FRAME = 3,
587     RESIZE_SCALE = 4,
588     RESIZE_MAX_VALUE,  // invalid value begin, add new value above
589 };
590 
591 /**
592  * @struct KeyFramePolicy
593  *
594  * @brief info for drag key frame policy.
595  */
596 struct KeyFramePolicy : public Parcelable {
597     DragResizeType dragResizeType_ = DragResizeType::RESIZE_TYPE_UNDEFINED;
598     uint32_t interval_ = 1000;
599     uint32_t distance_ = 1000;
600     uint32_t animationDuration_ = 100;
601     uint32_t animationDelay_ = 100;
602     bool running_ = false;
603     bool stopping_ = false;
604 
605     bool operator==(const KeyFramePolicy& right) const
606     {
607         return dragResizeType_ == right.dragResizeType_ &&
608             interval_ == right.interval_ &&
609             distance_ == right.distance_ &&
610             animationDuration_ == right.animationDuration_ &&
611             animationDelay_ == right.animationDelay_ &&
612             running_ == right.running_ &&
613             stopping_ == right.stopping_;
614     }
615 
616     bool operator!=(const KeyFramePolicy& right) const
617     {
618         return !(*this == right);
619     }
620 
enabledKeyFramePolicy621     bool enabled() const
622     {
623         return dragResizeType_ == DragResizeType::RESIZE_KEY_FRAME;
624     }
625 
MarshallingKeyFramePolicy626     bool Marshalling(Parcel& parcel) const override
627     {
628         return parcel.WriteUint32(static_cast<uint32_t>(dragResizeType_)) &&
629             parcel.WriteUint32(interval_) && parcel.WriteUint32(distance_) &&
630             parcel.WriteUint32(animationDuration_) && parcel.WriteUint32(animationDelay_) &&
631             parcel.WriteBool(running_) && parcel.WriteBool(stopping_);
632     }
633 
UnmarshallingKeyFramePolicy634     static KeyFramePolicy* Unmarshalling(Parcel& parcel)
635     {
636         KeyFramePolicy* keyFramePolicy = new KeyFramePolicy();
637         uint32_t dragResizeType;
638         if (!parcel.ReadUint32(dragResizeType) || !parcel.ReadUint32(keyFramePolicy->interval_) ||
639             !parcel.ReadUint32(keyFramePolicy->distance_) || !parcel.ReadUint32(keyFramePolicy->animationDuration_) ||
640             !parcel.ReadUint32(keyFramePolicy->animationDelay_) || !parcel.ReadBool(keyFramePolicy->running_) ||
641             !parcel.ReadBool(keyFramePolicy->stopping_)) {
642             delete keyFramePolicy;
643             return nullptr;
644         }
645         if (dragResizeType >= static_cast<uint32_t>(DragResizeType::RESIZE_MAX_VALUE)) {
646             delete keyFramePolicy;
647             return nullptr;
648         }
649         keyFramePolicy->dragResizeType_ = static_cast<DragResizeType>(dragResizeType);
650         return keyFramePolicy;
651     }
652 
ToStringKeyFramePolicy653     inline std::string ToString() const
654     {
655         std::ostringstream oss;
656         oss << "[" << static_cast<uint32_t>(dragResizeType_) << " " << interval_ << " " << distance_;
657         oss << " " << animationDuration_ << " " << animationDelay_ << "]";
658         return oss.str();
659     }
660 };
661 
662 /**
663  * @struct HookWindowInfo.
664  *
665  * @brief Configures window hook behavior based on window size ratios.
666  */
667 struct HookWindowInfo : public Parcelable {
668     bool enableHookWindow{ false };
669     float widthHookRatio{ 1.0f };
670 
671     static constexpr float DEFAULT_WINDOW_SIZE_HOOK_RATIO = 1.0f;
672 
MarshallingHookWindowInfo673     bool Marshalling(Parcel& parcel) const override
674     {
675         return WriteAllFields(parcel);
676     }
677 
UnmarshallingHookWindowInfo678     static HookWindowInfo* Unmarshalling(Parcel& parcel)
679     {
680         auto hookWindowInfo = std::make_unique<HookWindowInfo>();
681         if (!hookWindowInfo || !ReadAllFields(parcel, *hookWindowInfo)) {
682             return nullptr;
683         }
684         return hookWindowInfo.release();
685     }
686 
ToStringHookWindowInfo687     std::string ToString() const
688     {
689         constexpr int precision = 6; // Print float with precision of 6 decimal places.
690         std::ostringstream oss;
691         oss << std::boolalpha  // For true/false instead of 1/0
692             << "enableHookWindow: " << enableHookWindow
693             << ", widthHookRatio: " << std::fixed << std::setprecision(precision) << widthHookRatio;
694         return oss.str();
695     }
696 
697 private:
WriteAllFieldsHookWindowInfo698     bool WriteAllFields(Parcel& parcel) const
699     {
700         return parcel.WriteBool(enableHookWindow) &&
701                parcel.WriteFloat(widthHookRatio);
702     }
703 
ReadAllFieldsHookWindowInfo704     static bool ReadAllFields(Parcel& parcel, HookWindowInfo& info)
705     {
706         return parcel.ReadBool(info.enableHookWindow) &&
707                parcel.ReadFloat(info.widthHookRatio);
708     }
709 };
710 
711 /**
712  * @brief Enumerates window tag.
713  */
714 enum class WindowTag : uint32_t {
715     MAIN_WINDOW = 0,
716     SUB_WINDOW = 1,
717     SYSTEM_WINDOW = 2,
718 };
719 
720 /**
721  * @brief Enumerates window session type.
722  */
723 enum class WindowSessionType : uint32_t {
724     SCENE_SESSION = 0,
725     EXTENSION_SESSION = 1,
726 };
727 
728 /**
729  * @brief Enumerates window gravity.
730  */
731 enum class WindowGravity : uint32_t {
732     WINDOW_GRAVITY_FLOAT = 0,
733     WINDOW_GRAVITY_BOTTOM,
734     WINDOW_GRAVITY_DEFAULT,
735 };
736 
737 /**
738  * @brief Enumerates window setuicontent type.
739  */
740 enum class WindowSetUIContentType : uint32_t {
741     DEFAULT,
742     RESTORE,
743     BY_NAME,
744     BY_ABC,
745     BY_SHARED,
746 };
747 
748 /**
749  * @brief Enumerates restore type.
750  */
751 enum class BackupAndRestoreType : int32_t {
752     NONE = 0,                       // no backup and restore
753     CONTINUATION = 1,               // distribute
754     APP_RECOVERY = 2,               // app recovery
755     RESOURCESCHEDULE_RECOVERY = 3,  // app is killed due to resource schedule
756 };
757 
758 /**
759  * @brief Enumerates window Style type.
760  */
761 enum class WindowStyleType : uint8_t {
762     WINDOW_STYLE_DEFAULT = 0,
763     WINDOW_STYLE_FREE_MULTI_WINDOW = 1,
764 };
765 
766 /**
767  * @brief Enumerates window style status
768  */
769 enum class WindowManagementMode : uint32_t {
770     UNDEFINED,
771     FREEFORM,
772     FULLSCREEN
773 };
774 
775 /**
776  * @brief Disable Gesture Back Type
777  */
778 enum class GestureBackType : uint8_t {
779     GESTURE_SIDE = 0,
780     GESTURE_SWIPE_UP = 1,
781     GESTURE_ALL = 2,
782 };
783 
784 /**
785  * @struct PointInfo.
786  *
787  * @brief point Info.
788  */
789 struct PointInfo {
790     int32_t x;
791     int32_t y;
792 };
793 
794 /**
795  * @struct MainWindowInfo.
796  *
797  * @brief topN main window info.
798  */
799 struct MainWindowInfo : public Parcelable {
MarshallingMainWindowInfo800     virtual bool Marshalling(Parcel& parcel) const override
801     {
802         if (!parcel.WriteInt32(pid_)) {
803             return false;
804         }
805 
806         if (!parcel.WriteString(bundleName_)) {
807             return false;
808         }
809 
810         if (!parcel.WriteInt32(persistentId_)) {
811             return false;
812         }
813 
814         if (!parcel.WriteInt32(bundleType_)) {
815             return false;
816         }
817         return true;
818     }
819 
UnmarshallingMainWindowInfo820     static MainWindowInfo* Unmarshalling(Parcel& parcel)
821     {
822         MainWindowInfo* mainWindowInfo = new MainWindowInfo;
823         mainWindowInfo->pid_ = parcel.ReadInt32();
824         mainWindowInfo->bundleName_ = parcel.ReadString();
825         mainWindowInfo->persistentId_ = parcel.ReadInt32();
826         mainWindowInfo->bundleType_ = parcel.ReadInt32();
827         return mainWindowInfo;
828     }
829 
830     int32_t pid_ = 0;
831     std::string bundleName_ = "";
832     int32_t persistentId_ = 0;
833     int32_t bundleType_ = 0;
834 };
835 
836 /**
837  * @struct MainWindowState.
838  *
839  * @brief main window state info.
840  */
841 struct MainWindowState : public Parcelable {
MarshallingMainWindowState842     bool Marshalling(Parcel& parcel) const override
843     {
844         if (!parcel.WriteInt32(state_)) {
845             return false;
846         }
847         if (!parcel.WriteBool(isVisible_)) {
848             return false;
849         }
850         if (!parcel.WriteBool(isForegroundInteractive_)) {
851             return false;
852         }
853         if (!parcel.WriteBool(isPcOrPadEnableActivation_)) {
854             return false;
855         }
856         return true;
857     }
858 
UnmarshallingMainWindowState859     static MainWindowState* Unmarshalling(Parcel& parcel)
860     {
861         MainWindowState* mainWindowState = new MainWindowState();
862         if (!mainWindowState) {
863             return nullptr;
864         }
865         if (!parcel.ReadInt32(mainWindowState->state_) ||
866             !parcel.ReadBool(mainWindowState->isVisible_) ||
867             !parcel.ReadBool(mainWindowState->isForegroundInteractive_) ||
868             !parcel.ReadBool(mainWindowState->isPcOrPadEnableActivation_)) {
869             delete mainWindowState;
870             return nullptr;
871         }
872         return mainWindowState;
873     }
874 
875     int32_t state_ = 0;
876     bool isVisible_ = false;
877     bool isForegroundInteractive_ = false;
878     bool isPcOrPadEnableActivation_ = false;
879 };
880 
881 namespace {
882 constexpr uint32_t SYSTEM_COLOR_WHITE = 0xE5FFFFFF;
883 constexpr uint32_t SYSTEM_COLOR_BLACK = 0x66000000;
884 constexpr uint32_t INVALID_WINDOW_ID = 0;
885 constexpr float UNDEFINED_BRIGHTNESS = -1.0f;
886 constexpr float MINIMUM_BRIGHTNESS = 0.0f;
887 constexpr float MAXIMUM_BRIGHTNESS = 1.0f;
888 constexpr float INVALID_BRIGHTNESS = 999.0f;
889 constexpr int32_t INVALID_PID = -1;
890 constexpr int32_t INVALID_UID = -1;
891 constexpr int32_t INVALID_USER_ID = -1;
892 constexpr int32_t SYSTEM_USERID = 0;
893 constexpr int32_t BASE_USER_RANGE = 200000;
894 constexpr int32_t DEFAULT_SCREEN_ID = 0;
895 constexpr int32_t ZERO_CIRCLE_DEGREE = 0;
896 constexpr int32_t FULL_CIRCLE_DEGREE = 360;
897 constexpr int32_t ONE_FOURTH_FULL_CIRCLE_DEGREE = 90;
898 constexpr float UNDEFINED_DENSITY = -1.0f;
899 constexpr float MINIMUM_CUSTOM_DENSITY = 0.5f;
900 constexpr float MAXIMUM_CUSTOM_DENSITY = 4.0f;
901 constexpr int32_t MINIMUM_Z_LEVEL = -10000;
902 constexpr int32_t MAXIMUM_Z_LEVEL = 10000;
903 constexpr int32_t NORMAL_SUB_WINDOW_Z_LEVEL = 0;
904 constexpr int32_t MODALITY_SUB_WINDOW_Z_LEVEL = 13000;
905 constexpr int32_t DIALOG_SUB_WINDOW_Z_LEVEL = 13000;
906 constexpr int32_t TEXT_MENU_SUB_WINDOW_Z_LEVEL = 13500;
907 constexpr int32_t TOAST_SUB_WINDOW_Z_LEVEL = 14000;
908 constexpr int32_t APPLICATION_MODALITY_SUB_WINDOW_Z_LEVEL = 20000;
909 constexpr int32_t TOPMOST_SUB_WINDOW_Z_LEVEL = 2000;
910 constexpr int32_t INVALID_FINGER_ID = -1;
911 }
912 
GetUserIdByUid(int32_t uid)913 inline int32_t GetUserIdByUid(int32_t uid)
914 {
915     return uid / BASE_USER_RANGE;
916 }
917 
918 /**
919  * @class Transform
920  *
921  * @brief parameter of transform and rotate.
922  */
923 class Transform {
924 public:
Transform()925     Transform()
926         : pivotX_(0.5f), pivotY_(0.5f), scaleX_(1.f), scaleY_(1.f), scaleZ_(1.f), rotationX_(0.f),
927           rotationY_(0.f), rotationZ_(0.f), translateX_(0.f), translateY_(0.f), translateZ_(0.f)
928     {}
~Transform()929     ~Transform() {}
930 
931     bool operator==(const Transform& right) const
932     {
933         return NearZero(pivotX_ - right.pivotX_) &&
934             NearZero(pivotY_ - right.pivotY_) &&
935             NearZero(scaleX_ - right.scaleX_) &&
936             NearZero(scaleY_ - right.scaleY_) &&
937             NearZero(scaleZ_ - right.scaleZ_) &&
938             NearZero(rotationX_ - right.rotationX_) &&
939             NearZero(rotationY_ - right.rotationY_) &&
940             NearZero(rotationZ_ - right.rotationZ_) &&
941             NearZero(translateX_ - right.translateX_) &&
942             NearZero(translateY_ - right.translateY_) &&
943             NearZero(translateZ_ - right.translateZ_);
944     }
945 
946     bool operator!=(const Transform& right) const
947     {
948         return !(*this == right);
949     }
950 
951     float pivotX_;
952     float pivotY_;
953     float scaleX_;
954     float scaleY_;
955     float scaleZ_;
956     float rotationX_;
957     float rotationY_;
958     float rotationZ_;
959     float translateX_;
960     float translateY_;
961     float translateZ_;
962 
Identity()963     static const Transform& Identity()
964     {
965         static Transform I;
966         return I;
967     }
968 
Marshalling(Parcel & parcel)969     bool Marshalling(Parcel& parcel) const
970     {
971         return parcel.WriteFloat(pivotX_) && parcel.WriteFloat(pivotY_) &&
972                parcel.WriteFloat(scaleX_) && parcel.WriteFloat(scaleY_) && parcel.WriteFloat(scaleZ_) &&
973                parcel.WriteFloat(rotationX_) && parcel.WriteFloat(rotationY_) && parcel.WriteFloat(rotationZ_) &&
974                parcel.WriteFloat(translateX_) && parcel.WriteFloat(translateY_) && parcel.WriteFloat(translateZ_);
975     }
976 
Unmarshalling(Parcel & parcel)977     void Unmarshalling(Parcel& parcel)
978     {
979         pivotX_ = parcel.ReadFloat();
980         pivotY_ = parcel.ReadFloat();
981         scaleX_ = parcel.ReadFloat();
982         scaleY_ = parcel.ReadFloat();
983         scaleZ_ = parcel.ReadFloat();
984         rotationX_ = parcel.ReadFloat();
985         rotationY_ = parcel.ReadFloat();
986         rotationZ_ = parcel.ReadFloat();
987         translateX_ = parcel.ReadFloat();
988         translateY_ = parcel.ReadFloat();
989         translateZ_ = parcel.ReadFloat();
990     }
991 private:
NearZero(float val)992     static inline bool NearZero(float val)
993     {
994         return val < 0.001f && val > -0.001f;
995     }
996 };
997 
998 /**
999  * @struct SingleHandTransform
1000  *
1001  * @brief parameter of transform in single hand mode.
1002  */
1003 struct SingleHandTransform {
1004     int32_t posX = 0;
1005     int32_t posY = 0;
1006     float scaleX = 1.0f;
1007     float scaleY = 1.0f;
1008 
1009     bool operator==(const SingleHandTransform& right) const
1010     {
1011         return posX == right.posX && MathHelper::NearEqual(scaleX, right.scaleX) &&
1012                posY == right.posY && MathHelper::NearEqual(scaleY, right.scaleY);
1013     }
1014 
1015     bool operator!=(const SingleHandTransform& right) const
1016     {
1017         return !(*this == right);
1018     }
1019 
MarshallingSingleHandTransform1020     bool Marshalling(Parcel& parcel) const
1021     {
1022         return parcel.WriteInt32(posX) && parcel.WriteInt32(posY) &&
1023                parcel.WriteFloat(scaleX) && parcel.WriteFloat(scaleY);
1024     }
1025 
UnmarshallingSingleHandTransform1026     void Unmarshalling(Parcel& parcel)
1027     {
1028         posX = parcel.ReadInt32();
1029         posY = parcel.ReadInt32();
1030         scaleX = parcel.ReadFloat();
1031         scaleY = parcel.ReadFloat();
1032     }
1033 };
1034 
1035 /**
1036  * @struct SystemBarProperty
1037  *
1038  * @brief Property of system bar
1039  */
1040 struct SystemBarProperty {
1041     bool enable_;
1042     uint32_t backgroundColor_;
1043     uint32_t contentColor_;
1044     bool enableAnimation_;
1045     SystemBarSettingFlag settingFlag_;
SystemBarPropertySystemBarProperty1046     SystemBarProperty() : enable_(true), backgroundColor_(SYSTEM_COLOR_BLACK), contentColor_(SYSTEM_COLOR_WHITE),
1047                           enableAnimation_(false), settingFlag_(SystemBarSettingFlag::DEFAULT_SETTING) {}
SystemBarPropertySystemBarProperty1048     SystemBarProperty(bool enable, uint32_t background, uint32_t content)
1049         : enable_(enable), backgroundColor_(background), contentColor_(content), enableAnimation_(false),
1050           settingFlag_(SystemBarSettingFlag::DEFAULT_SETTING) {}
SystemBarPropertySystemBarProperty1051     SystemBarProperty(bool enable, uint32_t background, uint32_t content, bool enableAnimation)
1052         : enable_(enable), backgroundColor_(background), contentColor_(content), enableAnimation_(enableAnimation),
1053           settingFlag_(SystemBarSettingFlag::DEFAULT_SETTING) {}
SystemBarPropertySystemBarProperty1054     SystemBarProperty(bool enable, uint32_t background, uint32_t content,
1055                       bool enableAnimation, SystemBarSettingFlag settingFlag)
1056         : enable_(enable), backgroundColor_(background), contentColor_(content), enableAnimation_(enableAnimation),
1057           settingFlag_(settingFlag) {}
1058     bool operator == (const SystemBarProperty& a) const
1059     {
1060         return (enable_ == a.enable_ && backgroundColor_ == a.backgroundColor_ && contentColor_ == a.contentColor_ &&
1061             enableAnimation_ == a.enableAnimation_);
1062     }
1063 };
1064 
1065 /**
1066  * @struct SystemBarPropertyFlag
1067  *
1068  * @brief Flag of system bar
1069  */
1070 struct SystemBarPropertyFlag {
1071     bool enableFlag = false;
1072     bool backgroundColorFlag = false;
1073     bool contentColorFlag = false;
1074     bool enableAnimationFlag = false;
1075 };
1076 
1077 /**
1078  * @struct Rect
1079  *
1080  * @brief Window Rect
1081  */
1082 struct Rect {
1083     int32_t posX_;
1084     int32_t posY_;
1085     uint32_t width_;
1086     uint32_t height_;
1087 
1088     bool operator==(const Rect& a) const
1089     {
1090         return (posX_ == a.posX_ && posY_ == a.posY_ && width_ == a.width_ && height_ == a.height_);
1091     }
1092 
1093     bool operator!=(const Rect& a) const
1094     {
1095         return !this->operator==(a);
1096     }
1097 
IsUninitializedRectRect1098     bool IsUninitializedRect() const
1099     {
1100         return (posX_ == 0 && posY_ == 0 && width_ == 0 && height_ == 0);
1101     }
1102 
IsUninitializedSizeRect1103     bool IsUninitializedSize() const
1104     {
1105         return width_ == 0 && height_ == 0;
1106     }
1107 
IsInsideOfRect1108     bool IsInsideOf(const Rect& a) const
1109     {
1110         return (posX_ >= a.posX_ && posY_ >= a.posY_ &&
1111             posX_ + width_ <= a.posX_ + a.width_ && posY_ + height_ <= a.posY_ + a.height_);
1112     }
1113 
IsSamePositionRect1114     bool IsSamePosition(int32_t x, int32_t y) const
1115     {
1116         return posX_ == x && posY_ == y;
1117     }
1118 
ToStringRect1119     inline std::string ToString() const
1120     {
1121         std::ostringstream oss;
1122         oss << "[" << posX_ << " " << posY_ << " " << width_ << " " << height_ << "]";
1123         return oss.str();
1124     }
1125 
1126     static const Rect EMPTY_RECT;
1127 
1128     /**
1129      * @brief Checks whether the right-bottom corner of a rectangle stays within the valid range.
1130      *
1131      * @param x The x-coordinate of the left-top corner.
1132      * @param y The y-coordinate of the left-top corner.
1133      * @param width The rectangle's width.
1134      * @param height The rectangle's height.
1135      * @return true if right-bottom corner stays within int32_t range; false if overflow happens.
1136      */
IsRightBottomValidRect1137     static bool IsRightBottomValid(int32_t x, int32_t y, uint32_t width, uint32_t height)
1138     {
1139         int64_t right = static_cast<int64_t>(x) + static_cast<int64_t>(width);
1140         int64_t bottom = static_cast<int64_t>(y) + static_cast<int64_t>(height);
1141         return right <= INT32_MAX && bottom <= INT32_MAX;
1142     }
1143 };
1144 
1145 inline constexpr Rect Rect::EMPTY_RECT { 0, 0, 0, 0 };
1146 
1147 /**
1148  * @struct RectAnimationConfig
1149  *
1150  * @brief Window RectAnimationConfig
1151  */
1152 struct RectAnimationConfig {
1153     uint32_t duration = 0; // Duartion of the animation, in milliseconds.
1154     float x1 = 0.0f;       // X coordinate of the first point on the Bezier curve.
1155     float y1 = 0.0f;       // Y coordinate of the first point on the Bezier curve.
1156     float x2 = 0.0f;       // X coordinate of the second point on the Bezier curve.
1157     float y2 = 0.0f;       // Y coordinate of the second point on the Bezier curve.
1158 };
1159 
1160 /**
1161  * @brief UIExtension usage
1162  */
1163 enum class UIExtensionUsage : uint32_t {
1164     MODAL = 0,
1165     EMBEDDED,
1166     CONSTRAINED_EMBEDDED,
1167     PREVIEW_EMBEDDED,
1168     UIEXTENSION_USAGE_END
1169 };
1170 
1171 /**
1172  * @brief UIExtension info for event
1173  */
1174 struct ExtensionWindowEventInfo {
1175     int32_t persistentId = 0;
1176     int32_t pid = -1;
1177     Rect windowRect { 0, 0, 0, 0 }; // Calculated from global rect and UIExtension windowRect
1178     Rect uiExtRect { 0, 0, 0, 0 };  // Transferred from arkUI
1179     bool hasUpdatedRect = false;
1180     bool isConstrainedModal = false;
1181 };
1182 
1183 /**
1184  * @brief UIExtension info from ability
1185  */
1186 struct ExtensionWindowAbilityInfo {
1187     int32_t persistentId  { 0 };
1188     int32_t parentId { 0 };
1189     UIExtensionUsage usage { UIExtensionUsage::UIEXTENSION_USAGE_END };
1190 };
1191 
1192 /**
1193  * @struct KeyboardPanelInfo
1194  *
1195  * @brief Info of keyboard panel
1196  */
1197 struct KeyboardPanelInfo : public Parcelable {
1198     Rect rect_ = {0, 0, 0, 0};
1199     Rect beginRect_ = {0, 0, 0, 0};
1200     Rect endRect_ = {0, 0, 0, 0};
1201     WindowGravity gravity_ = WindowGravity::WINDOW_GRAVITY_BOTTOM;
1202     bool isShowing_ = false;
1203 
MarshallingKeyboardPanelInfo1204     bool Marshalling(Parcel& parcel) const
1205     {
1206         return parcel.WriteInt32(rect_.posX_) && parcel.WriteInt32(rect_.posY_) &&
1207                parcel.WriteUint32(rect_.width_) && parcel.WriteUint32(rect_.height_) &&
1208                parcel.WriteInt32(beginRect_.posX_) && parcel.WriteInt32(beginRect_.posY_) &&
1209                parcel.WriteUint32(beginRect_.width_) && parcel.WriteUint32(beginRect_.height_) &&
1210                parcel.WriteInt32(endRect_.posX_) && parcel.WriteInt32(endRect_.posY_) &&
1211                parcel.WriteUint32(endRect_.width_) && parcel.WriteUint32(endRect_.height_) &&
1212                parcel.WriteUint32(static_cast<uint32_t>(gravity_)) && parcel.WriteBool(isShowing_);
1213     }
1214 
UnmarshallingKeyboardPanelInfo1215     static KeyboardPanelInfo* Unmarshalling(Parcel& parcel)
1216     {
1217         KeyboardPanelInfo* panelInfo = new KeyboardPanelInfo;
1218         bool res = parcel.ReadInt32(panelInfo->rect_.posX_) && parcel.ReadInt32(panelInfo->rect_.posY_) &&
1219             parcel.ReadUint32(panelInfo->rect_.width_) && parcel.ReadUint32(panelInfo->rect_.height_) &&
1220             parcel.ReadInt32(panelInfo->beginRect_.posX_) && parcel.ReadInt32(panelInfo->beginRect_.posY_) &&
1221             parcel.ReadUint32(panelInfo->beginRect_.width_) && parcel.ReadUint32(panelInfo->beginRect_.height_) &&
1222             parcel.ReadInt32(panelInfo->endRect_.posX_) && parcel.ReadInt32(panelInfo->endRect_.posY_) &&
1223             parcel.ReadUint32(panelInfo->endRect_.width_) && parcel.ReadUint32(panelInfo->endRect_.height_);
1224         if (!res) {
1225             delete panelInfo;
1226             return nullptr;
1227         }
1228         panelInfo->gravity_ = static_cast<WindowGravity>(parcel.ReadUint32());
1229         panelInfo->isShowing_ = parcel.ReadBool();
1230 
1231         return panelInfo;
1232     }
1233 };
1234 
1235 /**
1236  * @struct CallingWindowInfo
1237  *
1238  * @brief Information of keyboard calling window.
1239  */
1240 struct CallingWindowInfo : public Parcelable {
1241     int32_t windowId_ = 0;
1242     int32_t callingPid_ = -1;
1243     DisplayId displayId_ = 0;
1244     int32_t userId_ = 0;
1245 
CallingWindowInfoCallingWindowInfo1246     CallingWindowInfo() {}
CallingWindowInfoCallingWindowInfo1247     CallingWindowInfo(int32_t windowId, int32_t callingPid, DisplayId displayId, int32_t userId)
1248         : windowId_(windowId), callingPid_(callingPid), displayId_(displayId), userId_(userId) {}
1249 
MarshallingCallingWindowInfo1250     bool Marshalling(Parcel& parcel) const
1251     {
1252         return parcel.WriteInt32(windowId_) && parcel.WriteInt32(callingPid_) &&
1253                parcel.WriteUint64(displayId_) && parcel.WriteInt32(userId_);
1254     }
1255 
UnmarshallingCallingWindowInfo1256     static CallingWindowInfo* Unmarshalling(Parcel& parcel)
1257     {
1258         CallingWindowInfo* callingWindowInfo = new CallingWindowInfo();
1259         bool res = parcel.ReadInt32(callingWindowInfo->windowId_) && parcel.ReadInt32(callingWindowInfo->callingPid_) &&
1260                    parcel.ReadUint64(callingWindowInfo->displayId_) && parcel.ReadInt32(callingWindowInfo->userId_);
1261         if (!res) {
1262             delete callingWindowInfo;
1263             return nullptr;
1264         }
1265         return callingWindowInfo;
1266     }
1267 };
1268 
1269 /**
1270  * @brief Enumerates avoid area type.
1271  */
1272 enum class AvoidAreaType : uint32_t {
1273     TYPE_START = 0,
1274     TYPE_SYSTEM = TYPE_START,           // area of SystemUI
1275     TYPE_CUTOUT,                        // cutout of screen
1276     TYPE_SYSTEM_GESTURE,                // area for system gesture
1277     TYPE_KEYBOARD,                      // area for soft input keyboard
1278     TYPE_NAVIGATION_INDICATOR,          // area for navigation indicator
1279     TYPE_END,
1280 };
1281 
1282 /**
1283  * @brief Enumerates occupied area type.
1284  */
1285 enum class OccupiedAreaType : uint32_t {
1286     TYPE_INPUT, // area of input window
1287 };
1288 
1289 /**
1290  * @brief Enumerates color space.
1291  */
1292 enum class ColorSpace : uint32_t {
1293     COLOR_SPACE_DEFAULT = 0, // Default color space.
1294     COLOR_SPACE_WIDE_GAMUT,  // Wide gamut color space. The specific wide color gamut depends on the screen.
1295 };
1296 
1297 /**
1298  * @brief Enumerates window animation.
1299  */
1300 enum class WindowAnimation : uint32_t {
1301     NONE,
1302     DEFAULT,
1303     INPUTE,
1304     CUSTOM,
1305 };
1306 
1307 /**
1308  * @brief Enumerates window anchor.
1309  */
1310 enum class WindowAnchor : uint32_t {
1311     TOP_START = 0,
1312     TOP,
1313     TOP_END,
1314     START,
1315     CENTER,
1316     END,
1317     BOTTOM_START,
1318     BOTTOM,
1319     BOTTOM_END,
1320 };
1321 
1322 /**
1323  * @struct WindowAnchorInfo
1324  *
1325  * @brief Window anchor info
1326  */
1327 struct WindowAnchorInfo : public Parcelable {
1328     bool isAnchorEnabled_ = false;
1329     WindowAnchor windowAnchor_ = WindowAnchor::TOP_START;
1330     int32_t offsetX_ = 0;
1331     int32_t offsetY_ = 0;
1332 
WindowAnchorInfoWindowAnchorInfo1333     WindowAnchorInfo() {}
WindowAnchorInfoWindowAnchorInfo1334     WindowAnchorInfo(bool isAnchorEnabled) : isAnchorEnabled_(isAnchorEnabled) {}
WindowAnchorInfoWindowAnchorInfo1335     WindowAnchorInfo(bool isAnchorEnabled, WindowAnchor windowAnchor, int32_t offsetX,
1336         int32_t offsetY) : isAnchorEnabled_(isAnchorEnabled),  windowAnchor_(windowAnchor),
1337         offsetX_(offsetX), offsetY_(offsetY) {}
1338 
1339     bool operator==(const WindowAnchorInfo& other) const
1340     {
1341         return isAnchorEnabled_ == other.isAnchorEnabled_ && windowAnchor_ == other.windowAnchor_ &&
1342             offsetX_ == other.offsetX_ && offsetY_ == other.offsetY_;
1343     }
1344 
1345     bool operator!=(const WindowAnchorInfo& other) const
1346     {
1347         return !(*this == other);
1348     }
1349 
MarshallingWindowAnchorInfo1350     bool Marshalling(Parcel& parcel) const override
1351     {
1352         return parcel.WriteBool(isAnchorEnabled_) && parcel.WriteUint32(static_cast<uint32_t>(windowAnchor_)) &&
1353             parcel.WriteInt32(offsetX_) && parcel.WriteInt32(offsetY_);
1354     }
1355 
UnmarshallingWindowAnchorInfo1356     static WindowAnchorInfo* Unmarshalling(Parcel& parcel)
1357     {
1358         uint32_t windowAnchorMode = 0;
1359         WindowAnchorInfo* windowAnchorInfo = new(std::nothrow) WindowAnchorInfo();
1360         if (windowAnchorInfo == nullptr) {
1361             return nullptr;
1362         }
1363         if (!parcel.ReadBool(windowAnchorInfo->isAnchorEnabled_) || !parcel.ReadUint32(windowAnchorMode) ||
1364             !parcel.ReadInt32(windowAnchorInfo->offsetX_) || !parcel.ReadInt32(windowAnchorInfo->offsetY_)) {
1365             delete windowAnchorInfo;
1366             return nullptr;
1367         }
1368         windowAnchorInfo->windowAnchor_ = static_cast<WindowAnchor>(windowAnchorMode);
1369         return windowAnchorInfo;
1370     }
1371 };
1372 
1373 /**
1374  * @brief Enumerates window maximize mode.
1375  */
1376 enum class MaximizeMode : uint32_t {
1377     MODE_AVOID_SYSTEM_BAR,
1378     MODE_FULL_FILL,
1379     MODE_RECOVER,
1380     MODE_END,
1381 };
1382 
1383 /**
1384  * @class AvoidArea
1385  *
1386  * @brief Area needed to avoid.
1387  */
1388 class AvoidArea : public Parcelable {
1389 public:
1390     Rect topRect_ { 0, 0, 0, 0 };
1391     Rect leftRect_ { 0, 0, 0, 0 };
1392     Rect rightRect_ { 0, 0, 0, 0 };
1393     Rect bottomRect_ { 0, 0, 0, 0 };
1394 
1395     bool operator==(const AvoidArea& a) const
1396     {
1397         return (leftRect_ == a.leftRect_ && topRect_ == a.topRect_ &&
1398             rightRect_ == a.rightRect_ && bottomRect_ == a.bottomRect_);
1399     }
1400 
1401     bool operator!=(const AvoidArea& a) const
1402     {
1403         return !this->operator==(a);
1404     }
1405 
isEmptyAvoidArea()1406     bool isEmptyAvoidArea() const
1407     {
1408         return topRect_.IsUninitializedRect() && leftRect_.IsUninitializedRect() &&
1409             rightRect_.IsUninitializedRect() && bottomRect_.IsUninitializedRect();
1410     }
1411 
WriteParcel(Parcel & parcel,const Rect & rect)1412     static inline bool WriteParcel(Parcel& parcel, const Rect& rect)
1413     {
1414         return parcel.WriteInt32(rect.posX_) && parcel.WriteInt32(rect.posY_) &&
1415             parcel.WriteUint32(rect.width_) && parcel.WriteUint32(rect.height_);
1416     }
1417 
ReadParcel(Parcel & parcel,Rect & rect)1418     static inline bool ReadParcel(Parcel& parcel, Rect& rect)
1419     {
1420         return parcel.ReadInt32(rect.posX_) && parcel.ReadInt32(rect.posY_) &&
1421             parcel.ReadUint32(rect.width_) && parcel.ReadUint32(rect.height_);
1422     }
1423 
Marshalling(Parcel & parcel)1424     virtual bool Marshalling(Parcel& parcel) const override
1425     {
1426         return (WriteParcel(parcel, leftRect_) && WriteParcel(parcel, topRect_) &&
1427             WriteParcel(parcel, rightRect_) && WriteParcel(parcel, bottomRect_));
1428     }
1429 
Unmarshalling(Parcel & parcel)1430     static AvoidArea* Unmarshalling(Parcel& parcel)
1431     {
1432         AvoidArea *avoidArea = new(std::nothrow) AvoidArea();
1433         if (avoidArea == nullptr) {
1434             return nullptr;
1435         }
1436         if (ReadParcel(parcel, avoidArea->leftRect_) && ReadParcel(parcel, avoidArea->topRect_) &&
1437             ReadParcel(parcel, avoidArea->rightRect_) && ReadParcel(parcel, avoidArea->bottomRect_)) {
1438             return avoidArea;
1439         }
1440         delete avoidArea;
1441         return nullptr;
1442     }
1443 
ToString()1444     std::string ToString() const
1445     {
1446         std::stringstream ss;
1447         if (isEmptyAvoidArea()) {
1448             ss << "empty";
1449             return ss.str();
1450         }
1451         if (!topRect_.IsUninitializedRect()) {
1452             ss << "top " << topRect_.ToString() << " ";
1453         }
1454         if (!bottomRect_.IsUninitializedRect()) {
1455             ss << "bottom " << bottomRect_.ToString() << " ";
1456         }
1457         if (!leftRect_.IsUninitializedRect()) {
1458             ss << "left " << leftRect_.ToString() << " ";
1459         }
1460         if (!rightRect_.IsUninitializedRect()) {
1461             ss << "right " << rightRect_.ToString() << " ";
1462         }
1463         return ss.str();
1464     }
1465 };
1466 
1467 /**
1468  * @struct ExceptionInfo
1469  *
1470  * @brief Exception info.
1471  */
1472 struct ExceptionInfo : public Parcelable {
1473     /**
1474      * @brief Marshalling ExceptionInfo.
1475      *
1476      * @param parcel Package of ExceptionInfo.
1477      * @return True means marshall success, false means marshall failed.
1478      */
MarshallingExceptionInfo1479     bool Marshalling(Parcel& parcel) const override
1480     {
1481         return parcel.WriteBool(needRemoveSession) &&
1482                parcel.WriteBool(needClearCallerLink);
1483     }
1484 
1485     /**
1486      * @brief Unmarshalling ExceptionInfo.
1487      *
1488      * @param parcel Package of ExceptionInfo.
1489      * @return ExceptionInfo object.
1490      */
UnmarshallingExceptionInfo1491     static ExceptionInfo* Unmarshalling(Parcel& parcel)
1492     {
1493         auto info = new ExceptionInfo();
1494         if (!parcel.ReadBool(info->needRemoveSession) ||
1495             !parcel.ReadBool(info->needClearCallerLink)) {
1496             delete info;
1497             return nullptr;
1498         }
1499         return info;
1500     }
1501 
1502     bool needRemoveSession = false;
1503     bool needClearCallerLink = true;
1504 };
1505 
1506 /**
1507  * @brief Enumerates window update type.
1508  */
1509 enum class WindowUpdateType : int32_t {
1510     WINDOW_UPDATE_ADDED = 1,
1511     WINDOW_UPDATE_REMOVED,
1512     WINDOW_UPDATE_FOCUSED,
1513     WINDOW_UPDATE_BOUNDS,
1514     WINDOW_UPDATE_ACTIVE,
1515     WINDOW_UPDATE_PROPERTY,
1516     WINDOW_UPDATE_ALL,
1517 };
1518 
1519 /**
1520  * @brief Enumerates picture in picture window state.
1521  */
1522 enum class PiPWindowState : uint32_t {
1523     STATE_UNDEFINED = 0,
1524     STATE_STARTING = 1,
1525     STATE_STARTED = 2,
1526     STATE_STOPPING = 3,
1527     STATE_STOPPED = 4,
1528     STATE_RESTORING = 5,
1529 };
1530 
1531 /**
1532  * @brief Enumerates picture in picture template type.
1533  */
1534 enum class PiPTemplateType : uint32_t {
1535     VIDEO_PLAY = 0,
1536     VIDEO_CALL = 1,
1537     VIDEO_MEETING = 2,
1538     VIDEO_LIVE = 3,
1539     END,
1540 };
1541 
1542 /**
1543  * @brief Enumerates picture in picture control group.
1544  */
1545 enum class PiPControlGroup : uint32_t {
1546     VIDEO_PLAY_START = 100,
1547     VIDEO_PREVIOUS_NEXT = 101,
1548     FAST_FORWARD_BACKWARD = 102,
1549     VIDEO_PLAY_END,
1550 
1551     VIDEO_CALL_START = 200,
1552     VIDEO_CALL_MICROPHONE_SWITCH = 201,
1553     VIDEO_CALL_HANG_UP_BUTTON = 202,
1554     VIDEO_CALL_CAMERA_SWITCH = 203,
1555     VIDEO_CALL_MUTE_SWITCH = 204,
1556     VIDEO_CALL_END,
1557 
1558     VIDEO_MEETING_START = 300,
1559     VIDEO_MEETING_HANG_UP_BUTTON = 301,
1560     VIDEO_MEETING_CAMERA_SWITCH = 302,
1561     VIDEO_MEETING_MUTE_SWITCH = 303,
1562     VIDEO_MEETING_MICROPHONE_SWITCH = 304,
1563     VIDEO_MEETING_END,
1564 
1565     VIDEO_LIVE_START = 400,
1566     VIDEO_PLAY_PAUSE = 401,
1567     VIDEO_LIVE_MUTE_SWITCH = 402,
1568     VIDEO_LIVE_END,
1569     END,
1570 };
1571 
1572 /**
1573  * @brief Enumerates picture in picture state.
1574  */
1575 enum class PiPState : int32_t {
1576     ABOUT_TO_START = 1,
1577     STARTED = 2,
1578     ABOUT_TO_STOP = 3,
1579     STOPPED = 4,
1580     ABOUT_TO_RESTORE = 5,
1581     ERROR = 6,
1582 };
1583 
1584 /**
1585  * @brief Enumerates picture in picture control status.
1586  */
1587 enum class PiPControlStatus : int32_t {
1588     PLAY = 1,
1589     PAUSE = 0,
1590     OPEN = 1,
1591     CLOSE = 0,
1592     ENABLED = -2,
1593     DISABLED = -3,
1594 };
1595 
1596 /**
1597  * @brief Enumerates picture in picture control type.
1598  */
1599 enum class PiPControlType : uint32_t {
1600     VIDEO_PLAY_PAUSE = 0,
1601     VIDEO_PREVIOUS = 1,
1602     VIDEO_NEXT = 2,
1603     FAST_FORWARD = 3,
1604     FAST_BACKWARD = 4,
1605     HANG_UP_BUTTON = 5,
1606     MICROPHONE_SWITCH = 6,
1607     CAMERA_SWITCH = 7,
1608     MUTE_SWITCH = 8,
1609     END,
1610 };
1611 
1612 struct PiPControlStatusInfo {
1613     PiPControlType controlType;
1614     PiPControlStatus status;
1615 };
1616 
1617 struct PiPControlEnableInfo {
1618     PiPControlType controlType;
1619     PiPControlStatus enabled;
1620 };
1621 
1622 struct PiPTemplateInfo : public Parcelable {
1623     uint32_t pipTemplateType{0};
1624     uint32_t priority{0};
1625     std::vector<uint32_t> controlGroup;
1626     std::vector<PiPControlStatusInfo> pipControlStatusInfoList;
1627     std::vector<PiPControlEnableInfo> pipControlEnableInfoList;
1628     uint32_t defaultWindowSizeType{0};
1629 
PiPTemplateInfoPiPTemplateInfo1630     PiPTemplateInfo() {}
1631 
MarshallingPiPTemplateInfo1632     bool Marshalling(Parcel& parcel) const override
1633     {
1634         if (!(parcel.WriteUint32(pipTemplateType) && parcel.WriteUint32(priority))) {
1635             return false;
1636         }
1637         if (controlGroup.size() > MAX_SIZE_PIP_CONTROL_GROUP || !parcel.WriteUInt32Vector(controlGroup)) {
1638             return false;
1639         }
1640         auto controlStatusSize = pipControlStatusInfoList.size();
1641         if (controlStatusSize > MAX_SIZE_PIP_CONTROL || !parcel.WriteUint32(static_cast<uint32_t>(controlStatusSize))) {
1642             return false;
1643         }
1644         for (auto& info : pipControlStatusInfoList) {
1645             if (!parcel.WriteUint32(static_cast<uint32_t>(info.controlType)) ||
1646                 !parcel.WriteInt32(static_cast<int32_t>(info.status))) {
1647                 return false;
1648             }
1649         }
1650         auto controlEnableSize = pipControlEnableInfoList.size();
1651         if (controlEnableSize > MAX_SIZE_PIP_CONTROL || !parcel.WriteUint32(static_cast<uint32_t>(controlEnableSize))) {
1652             return false;
1653         }
1654         for (auto& info : pipControlEnableInfoList) {
1655             if (!parcel.WriteUint32(static_cast<uint32_t>(info.controlType)) ||
1656                 !parcel.WriteInt32(static_cast<int32_t>(info.enabled))) {
1657                 return false;
1658             }
1659         }
1660         if (!parcel.WriteUint32(defaultWindowSizeType)) {
1661             return false;
1662         }
1663         return true;
1664     }
1665 
UnmarshallingPiPTemplateInfo1666     static PiPTemplateInfo* Unmarshalling(Parcel& parcel)
1667     {
1668         auto* pipTemplateInfo = new PiPTemplateInfo();
1669         if (!parcel.ReadUint32(pipTemplateInfo->pipTemplateType) || !parcel.ReadUint32(pipTemplateInfo->priority)) {
1670             delete pipTemplateInfo;
1671             return nullptr;
1672         }
1673         uint32_t controlStatusSize = 0;
1674         if (!parcel.ReadUInt32Vector(&pipTemplateInfo->controlGroup) ||
1675             pipTemplateInfo->controlGroup.size() > MAX_SIZE_PIP_CONTROL_GROUP ||
1676             !parcel.ReadUint32(controlStatusSize) || controlStatusSize > MAX_SIZE_PIP_CONTROL) {
1677             delete pipTemplateInfo;
1678             return nullptr;
1679         }
1680         for (uint32_t i = 0; i < controlStatusSize; i++) {
1681             uint32_t controlType;
1682             int32_t status;
1683             if (!parcel.ReadUint32(controlType) || !parcel.ReadInt32(status)) {
1684                 break;
1685             }
1686             PiPControlStatusInfo info{};
1687             info.controlType = static_cast<PiPControlType>(controlType);
1688             info.status = static_cast<PiPControlStatus>(status);
1689             pipTemplateInfo->pipControlStatusInfoList.emplace_back(info);
1690         }
1691         uint32_t controlEnableSize = 0;
1692         if (!parcel.ReadUint32(controlEnableSize) || controlEnableSize > MAX_SIZE_PIP_CONTROL) {
1693             delete pipTemplateInfo;
1694             return nullptr;
1695         }
1696         for (uint32_t i = 0; i < controlEnableSize; i++) {
1697             uint32_t controlType;
1698             int32_t enabled;
1699             if (!parcel.ReadUint32(controlType) || !parcel.ReadInt32(enabled)) {
1700                 break;
1701             }
1702             PiPControlEnableInfo info{};
1703             info.controlType = static_cast<PiPControlType>(controlType);
1704             info.enabled = static_cast<PiPControlStatus>(enabled);
1705             pipTemplateInfo->pipControlEnableInfoList.emplace_back(info);
1706         }
1707         if (!parcel.ReadUint32(pipTemplateInfo->defaultWindowSizeType)) {
1708             delete pipTemplateInfo;
1709             return nullptr;
1710         }
1711         return pipTemplateInfo;
1712     }
1713 };
1714 
1715 
1716 /**
1717  * @brief Enumerates floating ball state.
1718  */
1719 enum class FloatingBallState : uint32_t {
1720     STARTED = 1,
1721     STOPPED = 2,
1722     ERROR = 3,
1723 };
1724 
1725 /**
1726  * @brief Enumerates floating ball template.
1727  */
1728 enum class FloatingBallTemplate : uint32_t {
1729     STATIC = 1,
1730     NORMAL = 2,
1731     EMPHATIC = 3,
1732     SIMPLE = 4,
1733     END = 5,
1734 };
1735 
1736 struct PiPWindowSize {
1737     uint32_t width;
1738     uint32_t height;
1739     double scale;
1740 };
1741 
1742 /**
1743  * @brief Enumerates floating ball window state.
1744  */
1745 enum class FbWindowState : uint32_t {
1746     STATE_UNDEFINED = 0,
1747     STATE_STARTING = 1,
1748     STATE_STARTED = 2,
1749     STATE_STOPPING = 3,
1750     STATE_STOPPED = 4,
1751 };
1752 
1753 /**
1754  * @struct VsyncCallback
1755  *
1756  * @brief Vsync callback
1757  */
1758 struct VsyncCallback {
1759     OnCallback onCallback;
1760 };
1761 
1762 struct WindowLimits {
1763     uint32_t maxWidth_ = static_cast<uint32_t>(INT32_MAX); // The width and height are no larger than INT32_MAX.
1764     uint32_t maxHeight_ = static_cast<uint32_t>(INT32_MAX);
1765     uint32_t minWidth_ = 1; // The width and height of the window cannot be less than or equal to 0.
1766     uint32_t minHeight_ = 1;
1767     float maxRatio_ = FLT_MAX;
1768     float minRatio_ = 0.0f;
1769     float vpRatio_ = 1.0f;
1770 
WindowLimitsWindowLimits1771     WindowLimits() {}
WindowLimitsWindowLimits1772     WindowLimits(uint32_t maxWidth, uint32_t maxHeight, uint32_t minWidth, uint32_t minHeight, float maxRatio,
1773         float minRatio) : maxWidth_(maxWidth), maxHeight_(maxHeight), minWidth_(minWidth), minHeight_(minHeight),
1774         maxRatio_(maxRatio), minRatio_(minRatio) {}
WindowLimitsWindowLimits1775     WindowLimits(uint32_t maxWidth, uint32_t maxHeight, uint32_t minWidth, uint32_t minHeight, float maxRatio,
1776         float minRatio, float vpRatio) : maxWidth_(maxWidth), maxHeight_(maxHeight), minWidth_(minWidth),
1777         minHeight_(minHeight), maxRatio_(maxRatio), minRatio_(minRatio), vpRatio_(vpRatio) {}
1778 
IsEmptyWindowLimits1779     bool IsEmpty() const
1780     {
1781         return (maxWidth_ == 0 || minWidth_ == 0 || maxHeight_ == 0 || minHeight_ == 0);
1782     }
1783 
ToStringWindowLimits1784     std::string ToString() const
1785     {
1786         constexpr int precision = 6;
1787         std::ostringstream oss;
1788         oss << "[" << maxWidth_ << " " << maxHeight_ << " " << minWidth_ << " " << minHeight_
1789             << " " << std::fixed << std::setprecision(precision) << maxRatio_ << " " << minRatio_
1790             << " " << vpRatio_ << "]";
1791         return oss.str();
1792     }
1793 };
1794 
1795 /**
1796  * @struct TitleButtonRect
1797  *
1798  * @brief An area of title buttons relative to the upper right corner of the window.
1799  */
1800 struct TitleButtonRect {
1801     int32_t posX_ = 0;
1802     int32_t posY_ = 0;
1803     uint32_t width_ = 0;
1804     uint32_t height_ = 0;
1805 
1806     bool operator==(const TitleButtonRect& a) const
1807     {
1808         return (posX_ == a.posX_ && posY_ == a.posY_ && width_ == a.width_ && height_ == a.height_);
1809     }
1810 
1811     bool operator!=(const TitleButtonRect& a) const
1812     {
1813         return !this->operator==(a);
1814     }
1815 
ResetRectTitleButtonRect1816     void ResetRect()
1817     {
1818         posX_ = 0;
1819         posY_ = 0;
1820         width_ = 0;
1821         height_ = 0;
1822     }
1823 
IsUninitializedRectTitleButtonRect1824     bool IsUninitializedRect() const
1825     {
1826         return (posX_ == 0 && posY_ == 0 && width_ == 0 && height_ == 0);
1827     }
1828 
IsInsideOfTitleButtonRect1829     bool IsInsideOf(const TitleButtonRect& a) const
1830     {
1831         return (posX_ >= a.posX_ && posY_ >= a.posY_ &&
1832             posX_ + width_ <= a.posX_ + a.width_ && posY_ + height_ <= a.posY_ + a.height_);
1833     }
1834 };
1835 
1836 /**
1837  * @brief WindowInfo filter Option
1838  */
1839 enum class WindowInfoFilterOption : WindowInfoFilterOptionDataType {
1840     ALL = 0,
1841     EXCLUDE_SYSTEM = 1,
1842     VISIBLE = 1 << 1,
1843     FOREGROUND = 1 << 2,
1844 };
1845 
1846 inline WindowInfoFilterOption operator|(WindowInfoFilterOption lhs, WindowInfoFilterOption rhs)
1847 {
1848     return static_cast<WindowInfoFilterOption>(static_cast<WindowInfoFilterOptionDataType>(lhs) |
1849         static_cast<WindowInfoFilterOptionDataType>(rhs));
1850 }
1851 
IsChosenWindowOption(WindowInfoFilterOption options,WindowInfoFilterOption option)1852 inline bool IsChosenWindowOption(WindowInfoFilterOption options, WindowInfoFilterOption option)
1853 {
1854     return (static_cast<WindowInfoFilterOptionDataType>(options) &
1855         static_cast<WindowInfoFilterOptionDataType>(option)) != 0;
1856 }
1857 
1858 /**
1859  * @brief WindowInfo Type Option
1860  */
1861 enum class WindowInfoTypeOption : WindowInfoTypeOptionDataType {
1862     WINDOW_UI_INFO = 1,
1863     WINDOW_DISPLAY_INFO = 1 << 1,
1864     WINDOW_LAYOUT_INFO = 1 << 2,
1865     WINDOW_META_INFO = 1 << 3,
1866     ALL = ~0,
1867 };
1868 
1869 inline WindowInfoTypeOption operator|(WindowInfoTypeOption lhs, WindowInfoTypeOption rhs)
1870 {
1871     return static_cast<WindowInfoTypeOption>(static_cast<WindowInfoTypeOptionDataType>(lhs) |
1872         static_cast<WindowInfoTypeOptionDataType>(rhs));
1873 }
1874 
IsChosenWindowOption(WindowInfoTypeOption options,WindowInfoTypeOption option)1875 inline bool IsChosenWindowOption(WindowInfoTypeOption options, WindowInfoTypeOption option)
1876 {
1877     return (static_cast<WindowInfoTypeOptionDataType>(options) &
1878         static_cast<WindowInfoTypeOptionDataType>(option)) != 0;
1879 }
1880 
1881 /**
1882  * @enum WindowVisibilityState
1883  *
1884  * @brief Visibility state of a window
1885  */
1886 enum WindowVisibilityState : uint32_t {
1887     START = 0,
1888     WINDOW_VISIBILITY_STATE_NO_OCCLUSION = START,
1889     WINDOW_VISIBILITY_STATE_PARTICALLY_OCCLUSION,
1890     WINDOW_VISIBILITY_STATE_TOTALLY_OCCUSION,
1891     WINDOW_LAYER_STATE_MAX,
1892     END = WINDOW_LAYER_STATE_MAX,
1893 };
1894 
1895 /**
1896  * @struct WindowUIInfo
1897  *
1898  * @brief Window UI info
1899  */
1900 struct WindowUIInfo : public Parcelable {
1901     WindowVisibilityState visibilityState = WINDOW_LAYER_STATE_MAX;
1902 
MarshallingWindowUIInfo1903     bool Marshalling(Parcel& parcel) const override
1904     {
1905         return parcel.WriteUint32(static_cast<uint32_t>(visibilityState));
1906     }
1907 
UnmarshallingWindowUIInfo1908     static WindowUIInfo* Unmarshalling(Parcel& parcel)
1909     {
1910         WindowUIInfo* windowUIInfo = new WindowUIInfo();
1911         uint32_t visibilityState = 0;
1912         if (!parcel.ReadUint32(visibilityState)) {
1913             delete windowUIInfo;
1914             return nullptr;
1915         }
1916         windowUIInfo->visibilityState = static_cast<WindowVisibilityState>(visibilityState);
1917         return windowUIInfo;
1918     }
1919 };
1920 
1921 /**
1922  * @struct WindowDisplayInfo
1923  *
1924  * @brief Window display info
1925  */
1926 struct WindowDisplayInfo : public Parcelable {
1927     DisplayId displayId = DISPLAY_ID_INVALID;
MarshallingWindowDisplayInfo1928     bool Marshalling(Parcel& parcel) const override
1929     {
1930         return parcel.WriteUint64(displayId);
1931     }
1932 
UnmarshallingWindowDisplayInfo1933     static WindowDisplayInfo* Unmarshalling(Parcel& parcel)
1934     {
1935         WindowDisplayInfo* windowDisplayInfo = new WindowDisplayInfo();
1936         if (!parcel.ReadUint64(windowDisplayInfo->displayId)) {
1937             delete windowDisplayInfo;
1938             return nullptr;
1939         }
1940         return windowDisplayInfo;
1941     }
1942 };
1943 
1944 /**
1945  * @struct WindowLayoutInfo
1946  *
1947  * @brief Layout info for all windows on the screen.
1948  */
1949 struct WindowLayoutInfo : public Parcelable {
1950     Rect rect = Rect::EMPTY_RECT;
1951     uint32_t zOrder = 0;
1952 
MarshallingWindowLayoutInfo1953     bool Marshalling(Parcel& parcel) const override
1954     {
1955         return parcel.WriteInt32(rect.posX_) && parcel.WriteInt32(rect.posY_) && parcel.WriteUint32(rect.width_) &&
1956                parcel.WriteUint32(rect.height_) && parcel.WriteUint32(zOrder);
1957     }
1958 
UnmarshallingWindowLayoutInfo1959     static WindowLayoutInfo* Unmarshalling(Parcel& parcel)
1960     {
1961         WindowLayoutInfo* windowLayoutInfo = new WindowLayoutInfo();
1962         if (!parcel.ReadInt32(windowLayoutInfo->rect.posX_) || !parcel.ReadInt32(windowLayoutInfo->rect.posY_) ||
1963             !parcel.ReadUint32(windowLayoutInfo->rect.width_) || !parcel.ReadUint32(windowLayoutInfo->rect.height_) ||
1964             !parcel.ReadUint32(windowLayoutInfo->zOrder)) {
1965             delete windowLayoutInfo;
1966             return nullptr;
1967         }
1968         return windowLayoutInfo;
1969     }
1970 };
1971 
1972 /**
1973  * @struct WindowMetaInfo
1974  *
1975  * @brief Window meta info
1976  */
1977 struct WindowMetaInfo : public Parcelable {
1978     int32_t windowId = 0;
1979     std::string windowName;
1980     std::string bundleName;
1981     std::string abilityName;
1982     int32_t appIndex = 0;
1983     int32_t pid = -1;
1984     WindowType windowType = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW;
1985     uint32_t parentWindowId = INVALID_WINDOW_ID;
1986     uint64_t surfaceNodeId = 0;
1987     uint64_t leashWinSurfaceNodeId = 0;
1988     bool isPrivacyMode = false;
1989     WindowMode windowMode = WindowMode::WINDOW_MODE_UNDEFINED;
1990     bool isMidScene = false;
1991     bool isFocused = false;
1992 
MarshallingWindowMetaInfo1993     bool Marshalling(Parcel& parcel) const override
1994     {
1995         return parcel.WriteInt32(windowId) && parcel.WriteString(windowName) && parcel.WriteString(bundleName) &&
1996                parcel.WriteString(abilityName) && parcel.WriteInt32(appIndex) && parcel.WriteInt32(pid) &&
1997                parcel.WriteUint32(static_cast<uint32_t>(windowType)) && parcel.WriteUint32(parentWindowId) &&
1998                parcel.WriteUint64(surfaceNodeId) && parcel.WriteUint64(leashWinSurfaceNodeId) &&
1999                parcel.WriteBool(isPrivacyMode) && parcel.WriteBool(isMidScene) &&
2000                parcel.WriteBool(isFocused) && parcel.WriteUint32(static_cast<uint32_t>(windowMode));
2001     }
2002 
UnmarshallingWindowMetaInfo2003     static WindowMetaInfo* Unmarshalling(Parcel& parcel)
2004     {
2005         uint32_t windowTypeValue = 1;
2006         uint32_t windowModeValue = 1;
2007         WindowMetaInfo* windowMetaInfo = new WindowMetaInfo();
2008         if (!parcel.ReadInt32(windowMetaInfo->windowId) || !parcel.ReadString(windowMetaInfo->windowName) ||
2009             !parcel.ReadString(windowMetaInfo->bundleName) || !parcel.ReadString(windowMetaInfo->abilityName) ||
2010             !parcel.ReadInt32(windowMetaInfo->appIndex) || !parcel.ReadInt32(windowMetaInfo->pid) ||
2011             !parcel.ReadUint32(windowTypeValue) || !parcel.ReadUint32(windowMetaInfo->parentWindowId) ||
2012             !parcel.ReadUint64(windowMetaInfo->surfaceNodeId) ||
2013             !parcel.ReadUint64(windowMetaInfo->leashWinSurfaceNodeId) ||
2014             !parcel.ReadBool(windowMetaInfo->isPrivacyMode) || !parcel.ReadBool(windowMetaInfo->isMidScene) ||
2015             !parcel.ReadBool(windowMetaInfo->isFocused) || !parcel.ReadUint32(windowModeValue)) {
2016             delete windowMetaInfo;
2017             return nullptr;
2018         }
2019         windowMetaInfo->windowType = static_cast<WindowType>(windowTypeValue);
2020         windowMetaInfo->windowMode = static_cast<WindowMode>(windowModeValue);
2021         return windowMetaInfo;
2022     }
2023 };
2024 
2025 /**
2026  * @struct WindowInfo
2027  *
2028  * @brief Classified window info
2029  */
2030 struct WindowInfo : public Parcelable {
2031     WindowUIInfo windowUIInfo;
2032     WindowDisplayInfo windowDisplayInfo;
2033     WindowLayoutInfo windowLayoutInfo;
2034     WindowMetaInfo windowMetaInfo;
2035 
MarshallingWindowInfo2036     bool Marshalling(Parcel& parcel) const override
2037     {
2038         return parcel.WriteParcelable(&windowUIInfo) && parcel.WriteParcelable(&windowDisplayInfo) &&
2039                parcel.WriteParcelable(&windowLayoutInfo) && parcel.WriteParcelable(&windowMetaInfo);
2040     }
2041 
UnmarshallingWindowInfo2042     static WindowInfo* Unmarshalling(Parcel& parcel)
2043     {
2044         WindowInfo* windowInfo = new WindowInfo();
2045         sptr<WindowUIInfo> windowUIInfo = parcel.ReadParcelable<WindowUIInfo>();
2046         sptr<WindowDisplayInfo> windowDisplayInfo = parcel.ReadParcelable<WindowDisplayInfo>();
2047         sptr<WindowLayoutInfo> windowLayoutInfo = parcel.ReadParcelable<WindowLayoutInfo>();
2048         sptr<WindowMetaInfo> windowMetaInfo = parcel.ReadParcelable<WindowMetaInfo>();
2049         if (!windowUIInfo || !windowDisplayInfo || !windowLayoutInfo || !windowMetaInfo) {
2050             delete windowInfo;
2051             return nullptr;
2052         }
2053         windowInfo->windowUIInfo = *windowUIInfo;
2054         windowInfo->windowDisplayInfo = *windowDisplayInfo;
2055         windowInfo->windowLayoutInfo = *windowLayoutInfo;
2056         windowInfo->windowMetaInfo = *windowMetaInfo;
2057         return windowInfo;
2058     }
2059 };
2060 
2061 /**
2062  * @struct WindowInfoOption
2063  *
2064  * @brief Option of list window info
2065  */
2066 struct WindowInfoOption : public Parcelable {
2067     WindowInfoFilterOption windowInfoFilterOption = WindowInfoFilterOption::ALL;
2068     WindowInfoTypeOption windowInfoTypeOption = WindowInfoTypeOption::ALL;
2069     DisplayId displayId = DISPLAY_ID_INVALID;
2070     int32_t windowId = 0;
2071 
MarshallingWindowInfoOption2072     bool Marshalling(Parcel& parcel) const override
2073     {
2074         return parcel.WriteUint32(static_cast<uint32_t>(windowInfoFilterOption)) &&
2075                parcel.WriteUint32(static_cast<uint32_t>(windowInfoTypeOption)) &&
2076                parcel.WriteUint64(displayId) &&
2077                parcel.WriteInt32(windowId);
2078     }
2079 
UnmarshallingWindowInfoOption2080     static WindowInfoOption* Unmarshalling(Parcel& parcel)
2081     {
2082         WindowInfoOption* windowInfoOption = new WindowInfoOption();
2083         uint32_t windowInfoFilterOption;
2084         uint32_t windowInfoTypeOption;
2085         if (!parcel.ReadUint32(windowInfoFilterOption) || !parcel.ReadUint32(windowInfoTypeOption) ||
2086             !parcel.ReadUint64(windowInfoOption->displayId) || !parcel.ReadInt32(windowInfoOption->windowId)) {
2087             delete windowInfoOption;
2088             return nullptr;
2089         }
2090         windowInfoOption->windowInfoFilterOption = static_cast<WindowInfoFilterOption>(windowInfoFilterOption);
2091         windowInfoOption->windowInfoTypeOption = static_cast<WindowInfoTypeOption>(windowInfoTypeOption);
2092         return windowInfoOption;
2093     }
2094 };
2095 
2096 /**
2097  * Config of keyboard animation
2098  */
2099 class KeyboardAnimationCurve : public Parcelable {
2100 public:
2101     KeyboardAnimationCurve() = default;
KeyboardAnimationCurve(const std::string & curveType,const std::vector<float> & curveParams,uint32_t duration)2102     KeyboardAnimationCurve(const std::string& curveType, const std::vector<float>& curveParams, uint32_t duration)
2103         : curveType_(curveType), duration_(duration)
2104     {
2105         curveParams_.assign(curveParams.begin(), curveParams.end());
2106     }
2107 
Marshalling(Parcel & parcel)2108     virtual bool Marshalling(Parcel& parcel) const override
2109     {
2110         if (!parcel.WriteString(curveType_)) {
2111             return false;
2112         }
2113 
2114         auto paramSize = curveParams_.size();
2115         if (paramSize == 4) { // 4: param size
2116             if (!parcel.WriteUint32(static_cast<uint32_t>(paramSize))) {
2117                 return false;
2118             }
2119             for (auto& param : curveParams_) {
2120                 if (!parcel.WriteFloat(param)) {
2121                     return false;
2122                 }
2123             }
2124         } else {
2125             if (!parcel.WriteUint32(0)) {
2126                 return false;
2127             }
2128         }
2129 
2130         if (!parcel.WriteUint32(duration_)) {
2131             return false;
2132         }
2133         return true;
2134     }
2135 
Unmarshalling(Parcel & parcel)2136     static KeyboardAnimationCurve* Unmarshalling(Parcel& parcel)
2137     {
2138         KeyboardAnimationCurve* config = new KeyboardAnimationCurve;
2139         uint32_t paramSize = 0;
2140         if (!parcel.ReadString(config->curveType_) || !parcel.ReadUint32(paramSize)) {
2141             delete config;
2142             return nullptr;
2143         }
2144 
2145         if (paramSize == 4) { // 4: paramSize
2146             for (uint32_t i = 0; i < paramSize; i++) {
2147                 float param = 0.0f;
2148                 if (!parcel.ReadFloat(param)) {
2149                     delete config;
2150                     return nullptr;
2151                 } else {
2152                     config->curveParams_.push_back(param);
2153                 }
2154             }
2155         }
2156 
2157         if (!parcel.ReadUint32(config->duration_)) {
2158             delete config;
2159             return nullptr;
2160         }
2161         return config;
2162     }
2163 
2164     std::string curveType_ = "";
2165     std::vector<float> curveParams_ = {};
2166     uint32_t duration_ = 0;
2167 };
2168 
2169 /**
2170  * @struct KeyboardAnimationInfo
2171  *
2172  * @brief Info of keyboard animation
2173  */
2174 struct KeyboardAnimationInfo: public Parcelable {
2175     Rect beginRect { 0, 0, 0, 0 };
2176     Rect endRect { 0, 0, 0, 0 };
2177     bool isShow { false };
2178     bool withAnimation { false };
2179 
MarshallingKeyboardAnimationInfo2180     bool Marshalling(Parcel& parcel) const
2181     {
2182         bool result = parcel.WriteInt32(beginRect.posX_) &&
2183             parcel.WriteInt32(beginRect.posY_) &&
2184             parcel.WriteUint32(beginRect.width_) &&
2185             parcel.WriteUint32(beginRect.height_) &&
2186             parcel.WriteInt32(endRect.posX_) && parcel.WriteInt32(endRect.posY_) &&
2187             parcel.WriteUint32(endRect.width_) && parcel.WriteUint32(endRect.height_) &&
2188             parcel.WriteBool(isShow) && parcel.WriteBool(withAnimation);
2189         return result;
2190     }
2191 
UnmarshallingKeyboardAnimationInfo2192     static KeyboardAnimationInfo* Unmarshalling(Parcel& parcel)
2193     {
2194         KeyboardAnimationInfo* animationInfo = new KeyboardAnimationInfo();
2195         bool res = parcel.ReadInt32(animationInfo->beginRect.posX_) &&
2196             parcel.ReadInt32(animationInfo->beginRect.posY_) &&
2197             parcel.ReadUint32(animationInfo->beginRect.width_) &&
2198             parcel.ReadUint32(animationInfo->beginRect.height_) &&
2199             parcel.ReadInt32(animationInfo->endRect.posX_) &&
2200             parcel.ReadInt32(animationInfo->endRect.posY_) &&
2201             parcel.ReadUint32(animationInfo->endRect.width_) &&
2202             parcel.ReadUint32(animationInfo->endRect.height_) &&
2203             parcel.ReadBool(animationInfo->isShow) &&
2204             parcel.ReadBool(animationInfo->withAnimation);
2205         if (!res) {
2206             delete animationInfo;
2207             return nullptr;
2208         }
2209         return animationInfo;
2210     }
2211 };
2212 
2213 struct KeyboardAnimationConfig {
2214     KeyboardAnimationCurve curveIn;
2215     KeyboardAnimationCurve curveOut;
2216 };
2217 
2218 struct MoveConfiguration {
2219     DisplayId displayId = DISPLAY_ID_INVALID;
2220     RectAnimationConfig rectAnimationConfig = { 0, 0.0f, 0.0f, 0.0f, 0.0f };
ToStringMoveConfiguration2221     std::string ToString() const
2222     {
2223         std::string str;
2224         constexpr int BUFFER_SIZE = 1024;
2225         char buffer[BUFFER_SIZE] = { 0 };
2226         if (snprintf_s(buffer, sizeof(buffer), sizeof(buffer) - 1,
2227             "[displayId: %llu, rectAnimationConfig: [%u, %f, %f, %f, %f]]", displayId, rectAnimationConfig.duration,
2228             rectAnimationConfig.x1, rectAnimationConfig.y1, rectAnimationConfig.x2, rectAnimationConfig.y2) > 0) {
2229             str.append(buffer);
2230         }
2231         return str;
2232     }
2233 };
2234 
2235 enum class CaseType {
2236     CASE_WINDOW_MANAGER = 0,
2237     CASE_WINDOW,
2238     CASE_STAGE
2239 };
2240 
2241 enum class MaximizePresentation {
2242     FOLLOW_APP_IMMERSIVE_SETTING = 0,  // follow app set immersiveStateEnable
2243     EXIT_IMMERSIVE = 1,                // immersiveStateEnable will be set as false
2244     ENTER_IMMERSIVE = 2,               // immersiveStateEnable will be set as true
2245     // immersiveStateEnable will be set as true, titleHoverShowEnabled and dockHoverShowEnabled will be set as false
2246     ENTER_IMMERSIVE_DISABLE_TITLE_AND_DOCK_HOVER = 3,
2247 };
2248 
2249 enum ForceHideState : uint32_t {
2250     NOT_HIDDEN = 0,
2251     HIDDEN_WHEN_FOCUSED,
2252     HIDDEN_WHEN_UNFOCUSED
2253 };
2254 
2255 enum class ExtensionWindowAttribute : int32_t {
2256     SYSTEM_WINDOW = 0,
2257     SUB_WINDOW = 1,
2258     UNKNOWN = 2
2259 };
2260 
2261 struct SystemWindowOptions {
2262     int32_t windowType = -1;
2263 };
2264 
2265 enum class ModalityType : uint8_t {
2266     WINDOW_MODALITY,
2267     APPLICATION_MODALITY,
2268 };
2269 
2270 struct SubWindowOptions {
2271     std::string title;
2272     bool decorEnabled = false;
2273     bool isModal = false;
2274     bool isTopmost = false;
2275     int32_t zLevel = 0;
2276     bool maximizeSupported = false;
2277     ModalityType modalityType = ModalityType::WINDOW_MODALITY;
2278 };
2279 
2280 struct DecorButtonStyle {
2281     int32_t  colorMode = DEFAULT_COLOR_MODE;
2282     uint32_t spacingBetweenButtons = DEFAULT_SPACING_BETWEEN_BUTTONS;
2283     uint32_t closeButtonRightMargin = DEFAULT_CLOSE_BUTTON_RIGHT_MARGIN;
2284     uint32_t buttonBackgroundSize = DEFAULT_BUTTON_BACKGROUND_SIZE;
2285     uint32_t buttonIconSize = DEFAULT_BUTTON_ICON_SIZE;
2286     uint32_t buttonBackgroundCornerRadius = DEFAULT_BUTTON_BACKGROUND_CORNER_RADIUS;
2287 };
2288 
2289 struct ExtensionWindowConfig {
2290     std::string windowName;
2291     ExtensionWindowAttribute windowAttribute = ExtensionWindowAttribute::UNKNOWN;
2292     Rect windowRect;
2293     SubWindowOptions subWindowOptions;
2294     SystemWindowOptions systemWindowOptions;
2295 };
2296 
2297 template <typename T>
2298 struct SptrHash {
operatorSptrHash2299     std::size_t operator()(const sptr<T>& ptr) const
2300     {
2301         return std::hash<T*>{}(ptr.GetRefPtr());
2302     }
2303 };
2304 
2305 /**
2306  * @struct WindowDensityInfo
2307  *
2308  * @brief Currently available density
2309  */
2310 struct WindowDensityInfo {
2311     float systemDensity = UNDEFINED_DENSITY;
2312     float defaultDensity = UNDEFINED_DENSITY;
2313     float customDensity = UNDEFINED_DENSITY;
2314 
ToStringWindowDensityInfo2315     std::string ToString() const
2316     {
2317         std::string str;
2318         constexpr int BUFFER_SIZE = 64;
2319         char buffer[BUFFER_SIZE] = { 0 };
2320         if (snprintf_s(buffer, sizeof(buffer), sizeof(buffer) - 1,
2321             "[%f, %f, %f]", systemDensity, defaultDensity, customDensity) > 0) {
2322             str.append(buffer);
2323         }
2324         return str;
2325     }
2326 };
2327 
2328 /**
2329  * @struct WindowPropertyInfo
2330  *
2331  * @brief Currently available window property
2332  */
2333 struct WindowPropertyInfo {
2334     Rect windowRect { 0, 0, 0, 0 };
2335     Rect drawableRect { 0, 0, 0, 0 };
2336     Rect globalDisplayRect { 0, 0, 0, 0 };
2337     uint32_t apiCompatibleVersion = 0;
2338     WindowType type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW;
2339     bool isLayoutFullScreen = false;
2340     bool isFullScreen = false;
2341     bool isTouchable = false;
2342     bool isFocusable = false;
2343     std::string name;
2344     bool isPrivacyMode = false;
2345     bool isKeepScreenOn = false;
2346     float brightness = 0.0f;
2347     bool isTransparent = false;
2348     bool isRoundCorner = false;
2349     float dimBehindValue = 0.0f;
2350     uint32_t id = INVALID_WINDOW_ID;
2351     DisplayId displayId = DISPLAY_ID_INVALID;
2352 };
2353 
2354 /**
2355  * @struct KeyboardLayoutParams
2356  *
2357  * @brief Keyboard needs to adjust layout
2358  */
2359 struct KeyboardLayoutParams : public Parcelable {
2360     WindowGravity gravity_ = WindowGravity::WINDOW_GRAVITY_BOTTOM;
2361     int32_t landscapeAvoidHeight_ = -1;
2362     int32_t portraitAvoidHeight_ = -1;
2363     Rect LandscapeKeyboardRect_ { 0, 0, 0, 0 };
2364     Rect PortraitKeyboardRect_ { 0, 0, 0, 0 };
2365     Rect LandscapePanelRect_ { 0, 0, 0, 0 };
2366     Rect PortraitPanelRect_ { 0, 0, 0, 0 };
2367     uint64_t displayId_ = DISPLAY_ID_INVALID;
2368 
2369     bool operator==(const KeyboardLayoutParams& other) const
2370     {
2371         return (gravity_ == other.gravity_ &&
2372                 landscapeAvoidHeight_ == other.landscapeAvoidHeight_ &&
2373                 portraitAvoidHeight_ == other.portraitAvoidHeight_ &&
2374                 LandscapeKeyboardRect_ == other.LandscapeKeyboardRect_ &&
2375                 PortraitKeyboardRect_ == other.PortraitKeyboardRect_ &&
2376                 LandscapePanelRect_ == other.LandscapePanelRect_ &&
2377                 PortraitPanelRect_ == other.PortraitPanelRect_ &&
2378                 displayId_ == other.displayId_);
2379     }
2380 
2381     bool operator!=(const KeyboardLayoutParams& params) const
2382     {
2383         return !this->operator==(params);
2384     }
2385 
isEmptyKeyboardLayoutParams2386     bool isEmpty() const
2387     {
2388         return LandscapeKeyboardRect_.IsUninitializedRect() && PortraitKeyboardRect_.IsUninitializedRect() &&
2389                LandscapePanelRect_.IsUninitializedRect() && PortraitPanelRect_.IsUninitializedRect();
2390     }
2391 
WriteParcelKeyboardLayoutParams2392     static inline bool WriteParcel(Parcel& parcel, const Rect& rect)
2393     {
2394         return parcel.WriteInt32(rect.posX_) && parcel.WriteInt32(rect.posY_) &&
2395                parcel.WriteUint32(rect.width_) && parcel.WriteUint32(rect.height_);
2396     }
2397 
ReadParcelKeyboardLayoutParams2398     static inline bool ReadParcel(Parcel& parcel, Rect& rect)
2399     {
2400         return parcel.ReadInt32(rect.posX_) && parcel.ReadInt32(rect.posY_) &&
2401                parcel.ReadUint32(rect.width_) && parcel.ReadUint32(rect.height_);
2402     }
2403 
MarshallingKeyboardLayoutParams2404     virtual bool Marshalling(Parcel& parcel) const override
2405     {
2406         return (parcel.WriteUint32(static_cast<uint32_t>(gravity_)) &&
2407                 parcel.WriteInt32(landscapeAvoidHeight_) &&
2408                 parcel.WriteInt32(portraitAvoidHeight_) &&
2409                 WriteParcel(parcel, LandscapeKeyboardRect_) &&
2410                 WriteParcel(parcel, PortraitKeyboardRect_) &&
2411                 WriteParcel(parcel, LandscapePanelRect_) &&
2412                 WriteParcel(parcel, PortraitPanelRect_));
2413     }
2414 
UnmarshallingKeyboardLayoutParams2415     static KeyboardLayoutParams* Unmarshalling(Parcel& parcel)
2416     {
2417         KeyboardLayoutParams* params = new KeyboardLayoutParams();
2418         uint32_t gravity;
2419         if (parcel.ReadUint32(gravity) &&
2420             parcel.ReadInt32(params->landscapeAvoidHeight_) &&
2421             parcel.ReadInt32(params->portraitAvoidHeight_) &&
2422             ReadParcel(parcel, params->LandscapeKeyboardRect_) &&
2423             ReadParcel(parcel, params->PortraitKeyboardRect_) &&
2424             ReadParcel(parcel, params->LandscapePanelRect_) &&
2425             ReadParcel(parcel, params->PortraitPanelRect_)) {
2426             params->gravity_ = static_cast<WindowGravity>(gravity);
2427             return params;
2428         }
2429         delete params;
2430         return nullptr;
2431     }
2432 };
2433 
2434 /**
2435  * @struct KeyboardTouchHotAreas
2436  *
2437  * @brief Keyboard needs to set hotArea
2438  */
2439 struct KeyboardTouchHotAreas {
2440     std::vector<Rect> landscapeKeyboardHotAreas_;
2441     std::vector<Rect> portraitKeyboardHotAreas_;
2442     std::vector<Rect> landscapePanelHotAreas_;
2443     std::vector<Rect> portraitPanelHotAreas_;
2444 
isKeyboardEmptyKeyboardTouchHotAreas2445     bool isKeyboardEmpty() const
2446     {
2447         return (landscapeKeyboardHotAreas_.empty() || portraitKeyboardHotAreas_.empty());
2448     }
2449 
isPanelEmptyKeyboardTouchHotAreas2450     bool isPanelEmpty() const
2451     {
2452         return (landscapePanelHotAreas_.empty() || portraitPanelHotAreas_.empty());
2453     }
2454 };
2455 
2456 enum class KeyboardViewMode: uint32_t {
2457     NON_IMMERSIVE_MODE = 0,
2458     IMMERSIVE_MODE,
2459     LIGHT_IMMERSIVE_MODE,
2460     DARK_IMMERSIVE_MODE,
2461     VIEW_MODE_END,
2462 };
2463 
2464 enum class KeyboardFlowLightMode: uint32_t {
2465     NONE = 0,
2466     BACKGROUND_FLOW_LIGHT,
2467     END,
2468 };
2469 
2470 enum class KeyboardGradientMode: uint32_t {
2471     NONE = 0,
2472     LINEAR_GRADIENT,
2473     END,
2474 };
2475 
2476 struct KeyboardEffectOption : public Parcelable {
2477     KeyboardViewMode viewMode_ = KeyboardViewMode::NON_IMMERSIVE_MODE;
2478     KeyboardFlowLightMode flowLightMode_ = KeyboardFlowLightMode::NONE;
2479     KeyboardGradientMode gradientMode_ = KeyboardGradientMode::NONE;
2480     uint32_t blurHeight_ = 0;
2481 
MarshallingKeyboardEffectOption2482     virtual bool Marshalling(Parcel& parcel) const override
2483     {
2484         return (parcel.WriteUint32(static_cast<uint32_t>(viewMode_)) &&
2485                 parcel.WriteUint32(static_cast<uint32_t>(flowLightMode_)) &&
2486                 parcel.WriteUint32(static_cast<uint32_t>(gradientMode_)) &&
2487                 parcel.WriteUint32(blurHeight_));
2488     }
2489 
UnmarshallingKeyboardEffectOption2490     static KeyboardEffectOption* Unmarshalling(Parcel& parcel)
2491     {
2492         KeyboardEffectOption* option = new KeyboardEffectOption();
2493         uint32_t viewMode = 0;
2494         uint32_t flowLightMode = 0;
2495         uint32_t gradientMode = 0;
2496         if (!parcel.ReadUint32(viewMode) ||
2497             !parcel.ReadUint32(flowLightMode) ||
2498             !parcel.ReadUint32(gradientMode) ||
2499             !parcel.ReadUint32(option->blurHeight_)) {
2500             delete option;
2501             return nullptr;
2502         }
2503         option->viewMode_ = static_cast<KeyboardViewMode>(viewMode);
2504         option->flowLightMode_ = static_cast<KeyboardFlowLightMode>(flowLightMode);
2505         option->gradientMode_ = static_cast<KeyboardGradientMode>(gradientMode);
2506         return option;
2507     }
2508 
2509     bool operator==(const KeyboardEffectOption& option) const
2510     {
2511         return (viewMode_ == option.viewMode_ &&
2512                 flowLightMode_ == option.flowLightMode_ &&
2513                 gradientMode_ == option.gradientMode_ &&
2514                 blurHeight_ == option.blurHeight_);
2515     }
2516 
ToStringKeyboardEffectOption2517     std::string ToString() const
2518     {
2519         std::ostringstream oss;
2520         oss << "[" << static_cast<uint32_t>(viewMode_) << ", "
2521             << static_cast<uint32_t>(flowLightMode_) << ", "
2522             << static_cast<uint32_t>(gradientMode_) << ", "
2523             << blurHeight_ << "]";
2524         return oss.str();
2525     }
2526 };
2527 
2528 /*
2529  * Multi User
2530  */
2531 enum class UserSwitchEventType: uint32_t {
2532     SWITCHING,
2533     SWITCHED,
2534 };
2535 
2536 /**
2537  * @brief Enumerates window focus change reason
2538  */
2539 enum class WindowFocusChangeReason : int32_t {
2540     /**
2541      * default focus change reason
2542      */
2543     DEFAULT = 0,
2544 
2545     /**
2546      * focus change for move up
2547      */
2548     MOVE_UP,
2549 
2550     /**
2551      * focus change for click
2552      */
2553     CLICK,
2554 
2555     /**
2556      * focus change for foreground
2557      */
2558     FOREGROUND,
2559 
2560     /**
2561      * focus change for background
2562      */
2563     BACKGROUND,
2564 
2565     /**
2566      * focus change for split screen.5
2567      */
2568     SPLIT_SCREEN,
2569 
2570     /**
2571      * focus change for full screen
2572      */
2573     FULL_SCREEN,
2574 
2575     /**
2576      * focus change for global search
2577      */
2578     SCB_SESSION_REQUEST,
2579 
2580     /**
2581      * focus change for floating scene
2582      */
2583     FLOATING_SCENE,
2584 
2585     /**
2586      * focus change for losing focus
2587      */
2588     SCB_SESSION_REQUEST_UNFOCUS,
2589 
2590     /**
2591      * focus change for client requerst.10
2592      */
2593     CLIENT_REQUEST,
2594 
2595     /**
2596      * focus change for wind
2597      */
2598     WIND,
2599 
2600     /**
2601      * focus change for app foreground
2602      */
2603     APP_FOREGROUND,
2604 
2605     /**
2606      * focus change for app background
2607      */
2608     APP_BACKGROUND,
2609 
2610     /**
2611      * focus change for recent,Multitasking
2612      */
2613     RECENT,
2614 
2615     /**
2616      * focus change for inner app.
2617      */
2618     SCB_START_APP,
2619 
2620     /**
2621      * focus for setting focuable.
2622      */
2623     FOCUSABLE,
2624 
2625     /**
2626      * select last focused app when requestSessionUnFocus.
2627      */
2628     LAST_FOCUSED_APP,
2629 
2630     /**
2631      * focus for zOrder pass through VOICE_INTERACTION.
2632      */
2633     VOICE_INTERACTION,
2634 
2635     /**
2636      * focus change for SA requerst.19
2637      */
2638     SA_REQUEST,
2639 
2640     /**
2641      * focus on previous window for system keyboard
2642      */
2643     SYSTEM_KEYBOARD,
2644 
2645     /**
2646      * focus change max.
2647      */
2648     MAX,
2649 };
2650 
2651 /**
2652  * @brief Windowinfokey
2653  */
2654 enum class WindowInfoKey : int32_t {
2655     NONE = 0,
2656     WINDOW_ID = 1,
2657     BUNDLE_NAME = 1 << 1,
2658     ABILITY_NAME = 1 << 2,
2659     APP_INDEX = 1 << 3,
2660     VISIBILITY_STATE = 1 << 4,
2661     DISPLAY_ID = 1 << 5,
2662     WINDOW_RECT = 1 << 6,
2663     WINDOW_MODE = 1 << 7,
2664     FLOATING_SCALE = 1 << 8,
2665 };
2666 
2667 /**
2668  * @struct OrientationInfo
2669  *
2670  * @brief orientation info
2671  */
2672 struct OrientationInfo {
2673     uint32_t rotation = 0;
2674     Rect rect = {0, 0, 0, 0};
2675     std::map<AvoidAreaType, AvoidArea> avoidAreas;
2676 };
2677 
2678 /*
2679  * @brief Enumerates rotation change type.
2680  */
2681 enum class RotationChangeType : uint32_t {
2682     /**
2683      * rotate will begin.
2684      */
2685     WINDOW_WILL_ROTATE = 0,
2686 
2687     /**
2688      * rotate end.
2689      */
2690     WINDOW_DID_ROTATE,
2691 };
2692 
2693 /**
2694  * @brief Enumerates rect type
2695  */
2696 enum class RectType : uint32_t {
2697     /**
2698      * the window rect of app relative to screen.
2699      */
2700     RELATIVE_TO_SCREEN = 0,
2701 
2702     /**
2703      * the window rect of app relative to parent window.
2704      */
2705     RELATIVE_TO_PARENT_WINDOW,
2706 };
2707 
2708 /**
2709  * @brief rotation change info to notify listener.
2710  */
2711 struct RotationChangeInfo {
2712     RotationChangeType type_;
2713     uint32_t orientation_;
2714     DisplayId displayId_;
2715     Rect displayRect_;
2716 };
2717 
2718 /**
2719  * @brief rotation change result return from listener.
2720  */
2721 struct RotationChangeResult {
2722     RectType rectType_;
2723     Rect windowRect_;
2724 };
2725 
2726 /**
2727  * @brief default zIndex for specific window.
2728  */
2729 enum DefaultSpecificZIndex {
2730     MUTISCREEN_COLLABORATION = 930,
2731     SUPER_PRIVACY_ANIMATION = 1100,
2732 };
2733 
2734 /**
2735  * @brief Enumerates support function type
2736  */
2737 enum SupportFunctionType : uint32_t {
2738     /**
2739      * Supports callbacks triggered before the keyboard show/hide animations begin.
2740      */
2741     ALLOW_KEYBOARD_WILL_ANIMATION_NOTIFICATION = 1 << 0,
2742 
2743     /**
2744      * Supports callbacks triggered after the keyboard show/hide animations complete.
2745      */
2746     ALLOW_KEYBOARD_DID_ANIMATION_NOTIFICATION = 1 << 1,
2747 };
2748 
2749 /**
2750  * @struct ShadowsInfo
2751  *
2752  * @brief window shadows info
2753  */
2754 struct ShadowsInfo : public Parcelable {
2755     float radius_ = 0.0f;
2756     std::string color_;
2757     float offsetX_ = 0.0f;
2758     float offsetY_ = 0.0f;
2759     bool hasRadiusValue_ = false;
2760     bool hasColorValue_ = false;
2761     bool hasOffsetXValue_ = false;
2762     bool hasOffsetYValue_ = false;
2763 
ShadowsInfoShadowsInfo2764     ShadowsInfo() {}
ShadowsInfoShadowsInfo2765     ShadowsInfo(float radius, std::string color, float offsetX, float offsetY, bool hasRadiusValue,
2766         bool hasColorValue, bool hasOffsetXValue, bool hasOffsetYValue) : radius_(radius), color_(color),
2767         offsetX_(offsetX), offsetY_(offsetY), hasRadiusValue_(hasRadiusValue), hasColorValue_(hasColorValue),
2768         hasOffsetXValue_(hasOffsetXValue), hasOffsetYValue_(hasOffsetYValue) {}
2769 
2770     bool operator==(const ShadowsInfo& other) const
2771     {
2772         return (NearEqual(radius_, other.radius_) && color_ == other.color_ &&
2773             NearEqual(offsetX_, other.offsetX_) && NearEqual(offsetY_, other.offsetY_));
2774     }
2775 
2776     bool operator!=(const ShadowsInfo& other) const
2777     {
2778         return !this->operator==(other);
2779     }
2780 
NearEqualShadowsInfo2781     static inline bool NearEqual(float left, float right) { return std::abs(left - right) < POS_ZERO; }
2782 
MarshallingShadowsInfo2783     bool Marshalling(Parcel& parcel) const override
2784     {
2785         if (!parcel.WriteBool(hasRadiusValue_)) {
2786             return false;
2787         }
2788 
2789         if (!parcel.WriteBool(hasColorValue_)) {
2790             return false;
2791         }
2792 
2793         if (!parcel.WriteBool(hasOffsetXValue_)) {
2794             return false;
2795         }
2796 
2797         if (!parcel.WriteBool(hasOffsetYValue_)) {
2798             return false;
2799         }
2800 
2801         if (hasRadiusValue_ && !parcel.WriteFloat(radius_)) {
2802             return false;
2803         }
2804 
2805         if (hasColorValue_ && !parcel.WriteString(color_)) {
2806             return false;
2807         }
2808 
2809         if (hasOffsetXValue_ && !parcel.WriteFloat(offsetX_)) {
2810             return false;
2811         }
2812 
2813         if (hasOffsetYValue_ && !parcel.WriteFloat(offsetY_)) {
2814             return false;
2815         }
2816         return true;
2817     }
2818 
UnmarshallingShadowsInfo2819     static ShadowsInfo* Unmarshalling(Parcel& parcel)
2820     {
2821         ShadowsInfo* shadowsInfo = new ShadowsInfo();
2822         if (!parcel.ReadBool(shadowsInfo->hasRadiusValue_)) {
2823             delete shadowsInfo;
2824             return nullptr;
2825         }
2826 
2827         if (!parcel.ReadBool(shadowsInfo->hasColorValue_)) {
2828             delete shadowsInfo;
2829             return nullptr;
2830         }
2831 
2832         if (!parcel.ReadBool(shadowsInfo->hasOffsetXValue_)) {
2833             delete shadowsInfo;
2834             return nullptr;
2835         }
2836 
2837         if (!parcel.ReadBool(shadowsInfo->hasOffsetYValue_)) {
2838             delete shadowsInfo;
2839             return nullptr;
2840         }
2841 
2842         if (shadowsInfo->hasRadiusValue_ && !parcel.ReadFloat(shadowsInfo->radius_)) {
2843             delete shadowsInfo;
2844             return nullptr;
2845         }
2846 
2847         if (shadowsInfo->hasColorValue_ && !parcel.ReadString(shadowsInfo->color_)) {
2848             delete shadowsInfo;
2849             return nullptr;
2850         }
2851 
2852         if (shadowsInfo->hasOffsetXValue_ && !parcel.ReadFloat(shadowsInfo->offsetX_)) {
2853             delete shadowsInfo;
2854             return nullptr;
2855         }
2856 
2857         if (shadowsInfo->hasOffsetYValue_ && !parcel.ReadFloat(shadowsInfo->offsetY_)) {
2858             delete shadowsInfo;
2859             return nullptr;
2860         }
2861         return shadowsInfo;
2862     }
2863 };
2864 
2865 /**
2866  * @brief Enumerates session state of recent session
2867  */
2868 enum class RecentSessionState : uint32_t {
2869     DISCONNECT = 0,
2870     CONNECT,
2871     FOREGROUND,
2872     BACKGROUND,
2873     ACTIVE,
2874     INACTIVE,
2875     END,
2876 };
2877 
2878 /**
2879  * @struct RecentSessionInfo
2880  *
2881  * @brief infos of recent sessions
2882  */
2883 struct RecentSessionInfo : public Parcelable {
2884     RecentSessionInfo() = default;
RecentSessionInfoRecentSessionInfo2885     RecentSessionInfo(int32_t persistentId) : missionId(persistentId) {}
2886 
MarshallingRecentSessionInfo2887     bool Marshalling(Parcel& parcel) const override
2888     {
2889         return parcel.WriteInt32(missionId) &&
2890                parcel.WriteString(bundleName) &&
2891                parcel.WriteString(moduleName) &&
2892                parcel.WriteString(abilityName) &&
2893                parcel.WriteInt32(appIndex) &&
2894                parcel.WriteUint32(static_cast<uint32_t>(windowType)) &&
2895                parcel.WriteUint32(static_cast<uint32_t>(sessionState));
2896     }
2897 
UnmarshallingRecentSessionInfo2898     static RecentSessionInfo* Unmarshalling(Parcel& parcel)
2899     {
2900         RecentSessionInfo* recentSessionInfo = new RecentSessionInfo();
2901         uint32_t windowType;
2902         uint32_t sessionState;
2903         if (!parcel.ReadInt32(recentSessionInfo->missionId) ||
2904             !parcel.ReadString(recentSessionInfo->bundleName) ||
2905             !parcel.ReadString(recentSessionInfo->moduleName) ||
2906             !parcel.ReadString(recentSessionInfo->abilityName) ||
2907             !parcel.ReadInt32(recentSessionInfo->appIndex) ||
2908             !parcel.ReadUint32(windowType) ||
2909             !parcel.ReadUint32(sessionState)) {
2910             delete recentSessionInfo;
2911             return nullptr;
2912         }
2913         recentSessionInfo->windowType = static_cast<WindowType>(windowType);
2914         recentSessionInfo->sessionState = static_cast<RecentSessionState>(sessionState);
2915         return recentSessionInfo;
2916     }
2917 
2918     int32_t missionId = -1;
2919     std::string bundleName;
2920     std::string moduleName;
2921     std::string abilityName;
2922     int32_t appIndex = 0;
2923     WindowType windowType = WindowType::APP_MAIN_WINDOW_BASE;
2924     RecentSessionState sessionState = RecentSessionState::DISCONNECT;
2925 };
2926 
2927 /**
2928  * @brief Enumerates source of sub session.
2929  */
2930 enum class SubWindowSource : uint32_t {
2931     SUB_WINDOW_SOURCE_UNKNOWN = 0,
2932     SUB_WINDOW_SOURCE_ARKUI = 1,
2933 };
2934 
2935 /**
2936  * @brief Screenshot event type.
2937  */
2938 enum class ScreenshotEventType : int32_t {
2939     START = 0,
2940 
2941     /**
2942      * System screenshot.
2943      */
2944     SYSTEM_SCREENSHOT = START,
2945 
2946     /**
2947      * System screenshot abort.
2948      */
2949     SYSTEM_SCREENSHOT_ABORT = 1,
2950 
2951     /**
2952      * Scroll shot start.
2953      */
2954     SCROLL_SHOT_START = 2,
2955 
2956     /**
2957      * Scroll shot end.
2958      */
2959     SCROLL_SHOT_END = 3,
2960 
2961     /**
2962      * Scroll shot abort.
2963      */
2964     SCROLL_SHOT_ABORT = 4,
2965 
2966     END,
2967 };
2968 
2969 enum class RequestResultCode: uint32_t {
2970     INIT = 0,
2971     SUCCESS = 1,
2972     FAIL,
2973 };
2974 }
2975 }
2976 #endif // OHOS_ROSEN_WM_COMMON_H
2977