• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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_WINDOW_SESSION_PROPERTY_H
17 #define OHOS_ROSEN_WINDOW_SESSION_PROPERTY_H
18 
19 #include <refbase.h>
20 #include <string>
21 #include <unordered_map>
22 #include <parcel.h>
23 #include "interfaces/include/ws_common.h"
24 #include "interfaces/include/ws_common_inner.h"
25 #include "wm_common.h"
26 #include "dm_common.h"
27 #include <cfloat>
28 #include "pixel_map.h"
29 
30 namespace OHOS {
31 namespace Rosen {
32 class WindowSessionProperty;
33 using HandlWritePropertyFunc = bool (WindowSessionProperty::*)(Parcel& parcel);
34 using HandlReadPropertyFunc = void (WindowSessionProperty::*)(Parcel& parcel);
35 
36 class WindowSessionProperty : public Parcelable {
37 public:
38     WindowSessionProperty() = default;
39     ~WindowSessionProperty() = default;
40     explicit WindowSessionProperty(const sptr<WindowSessionProperty>& property);
41     void CopyFrom(const sptr<WindowSessionProperty>& property);
42     void SetWindowName(const std::string& name);
43     void SetSessionInfo(const SessionInfo& info);
44     void SetRequestRect(const struct Rect& rect);
45     void SetWindowRect(const struct Rect& rect);
46     void SetFocusable(bool isFocusable);
47     void SetFocusableOnShow(bool isFocusableOnShow);
48     void SetTouchable(bool isTouchable);
49     void SetDragEnabled(bool dragEnabled);
50     void SetHideNonSystemFloatingWindows(bool hide);
51     void SetForceHide(bool hide);
52     void SetRaiseEnabled(bool raiseEnabled);
53     void SetSystemCalling(bool isSystemCalling);
54     void SetTurnScreenOn(bool turnScreenOn);
55     void SetKeepScreenOn(bool keepScreenOn);
56     void SetRequestedOrientation(Orientation orientation);
57     void SetDefaultRequestedOrientation(Orientation orientation);
58     void SetPrivacyMode(bool isPrivate);
59     void SetSystemPrivacyMode(bool isSystemPrivate);
60     void SetSnapshotSkip(bool isSkip);
61     void SetBrightness(float brightness);
62     void SetDisplayId(uint64_t displayId);
63     void SetWindowType(WindowType type);
64     void SetParentId(int32_t parentId);
65     void SetPersistentId(int32_t persistentId);
66     void SetParentPersistentId(int32_t persistentId);
67     void SetAccessTokenId(uint32_t accessTokenId);
68     void SetTokenState(bool hasToken);
69     void SetMaximizeMode(MaximizeMode mode);
70     void SetWindowMode(WindowMode mode);
71     void SetWindowLimits(const WindowLimits& windowLimits);
72     void SetUserWindowLimits(const WindowLimits& windowLimits);
73     void SetConfigWindowLimitsVP(const WindowLimits& windowLimitsVP);
74     void SetLastLimitsVpr(float vpr);
75     void SetSystemBarProperty(WindowType type, const SystemBarProperty& property);
76     void SetKeyboardLayoutParams(const KeyboardLayoutParams& params);
77     void SetDecorEnable(bool isDecorEnable);
78     void SetAnimationFlag(uint32_t animationFlag);
79     void SetTransform(const Transform& trans);
80     void SetWindowFlags(uint32_t flags);
81     void SetTopmost(bool topmost);
82     bool IsTopmost() const;
83     void SetMainWindowTopmost(bool isTopmost);
84     bool IsMainWindowTopmost() const;
85     void AddWindowFlag(WindowFlag flag);
86     void SetWindowModeSupportType(uint32_t windowModeSupportType);
87     void SetFloatingWindowAppType(bool isAppType);
88     void SetTouchHotAreas(const std::vector<Rect>& rects);
89     void SetKeyboardTouchHotAreas(const KeyboardTouchHotAreas& keyboardTouchHotAreas);
90     void KeepKeyboardOnFocus(bool keepKeyboardFlag);
91     void SetIsNeedUpdateWindowMode(bool isNeedUpdateWindowMode);
92     void SetCallingSessionId(uint32_t sessionId);
93     void SetPiPTemplateInfo(const PiPTemplateInfo& pipTemplateInfo);
94     void SetWindowMask(const std::shared_ptr<Media::PixelMap>& windowMask);
95     void SetIsShaped(bool isShaped);
96     void SetCompatibleModeInPc(bool compatibleModeInPc);
97     void SetCompatibleWindowSizeInPc(int32_t portraitWidth, int32_t portraitHeight,
98         int32_t landscapeWidth, int32_t landscapeHeight);
99     void SetIsAppSupportPhoneInPc(bool isSupportPhone);
100     void SetIsSupportDragInPcCompatibleMode(bool isSupportDragInPcCompatibleMode);
101     void SetIsPcAppInPad(bool isPcAppInPad);
102     void SetCompatibleModeEnableInPad(bool enable);
103 
104     bool GetIsNeedUpdateWindowMode() const;
105     const std::string& GetWindowName() const;
106     const SessionInfo& GetSessionInfo() const;
107     SessionInfo& EditSessionInfo();
108     Rect GetWindowRect() const;
109     Rect GetRequestRect() const;
110     WindowType GetWindowType() const;
111     bool GetTouchable() const;
112     bool GetDragEnabled() const;
113     bool GetHideNonSystemFloatingWindows() const;
114     bool GetForceHide() const;
115     bool GetRaiseEnabled() const;
116     bool GetSystemCalling() const;
117     bool IsTurnScreenOn() const;
118     bool IsKeepScreenOn() const;
119     Orientation GetRequestedOrientation() const;
120     Orientation GetDefaultRequestedOrientation() const;
121     bool GetPrivacyMode() const;
122     bool GetSystemPrivacyMode() const;
123     bool GetSnapshotSkip() const;
124     float GetBrightness() const;
125     int32_t GetParentId() const;
126     uint32_t GetWindowFlags() const;
127     uint64_t GetDisplayId() const;
128     int32_t GetPersistentId() const;
129     int32_t GetParentPersistentId() const;
130     uint32_t GetAccessTokenId() const;
131     bool GetTokenState() const;
132     MaximizeMode GetMaximizeMode() const;
133     WindowMode GetWindowMode() const;
134     WindowLimits GetWindowLimits() const;
135     WindowLimits GetUserWindowLimits() const;
136     WindowLimits GetConfigWindowLimitsVP() const;
137     float GetLastLimitsVpr() const;
138     uint32_t GetWindowModeSupportType() const;
139     std::unordered_map<WindowType, SystemBarProperty> GetSystemBarProperty() const;
140     bool IsDecorEnable();
141     uint32_t GetAnimationFlag() const;
142     const Transform& GetTransform() const;
143     bool IsFloatingWindowAppType() const;
144     void GetTouchHotAreas(std::vector<Rect>& rects) const;
145     KeyboardTouchHotAreas GetKeyboardTouchHotAreas() const;
146     bool GetKeepKeyboardFlag() const;
147     uint32_t GetCallingSessionId() const;
148     PiPTemplateInfo GetPiPTemplateInfo() const;
149     std::shared_ptr<Media::PixelMap> GetWindowMask() const;
150     bool GetIsShaped() const;
151     KeyboardLayoutParams GetKeyboardLayoutParams() const;
152     bool GetCompatibleModeInPc() const;
153     int32_t GetCompatibleInPcPortraitWidth() const;
154     int32_t GetCompatibleInPcPortraitHeight() const;
155     int32_t GetCompatibleInPcLandscapeWidth() const;
156     int32_t GetCompatibleInPcLandscapeHeight() const;
157     bool GetIsAppSupportPhoneInPc() const;
158     bool GetIsPcAppInPad() const;
159     bool GetIsSupportDragInPcCompatibleMode() const;
160     bool GetCompatibleModeEnableInPad() const;
161 
162     bool MarshallingWindowLimits(Parcel& parcel) const;
163     static void UnmarshallingWindowLimits(Parcel& parcel, WindowSessionProperty* property);
164     bool MarshallingSystemBarMap(Parcel& parcel) const;
165     static void UnMarshallingSystemBarMap(Parcel& parcel, WindowSessionProperty* property);
166     bool MarshallingPiPTemplateInfo(Parcel& parcel) const;
167     static void UnmarshallingPiPTemplateInfo(Parcel& parcel, WindowSessionProperty* property);
168     bool Marshalling(Parcel& parcel) const override;
169     static WindowSessionProperty* Unmarshalling(Parcel& parcel);
170     bool MarshallingWindowMask(Parcel& parcel) const;
171     static void UnmarshallingWindowMask(Parcel& parcel, WindowSessionProperty* property);
172     bool MarshallingMainWindowTopmost(Parcel& parcel) const;
173     static void UnmarshallingMainWindowTopmost(Parcel& parcel, WindowSessionProperty* property);
174     bool MarshallingSessionInfo(Parcel& parcel) const;
175     static bool UnmarshallingSessionInfo(Parcel& parcel, WindowSessionProperty* property);
176 
177     void SetTextFieldPositionY(double textFieldPositionY);
178     void SetTextFieldHeight(double textFieldHeight);
179 
180     WindowState GetWindowState() const;
181     void SetWindowState(WindowState state);
182 
183     double GetTextFieldPositionY() const;
184     double GetTextFieldHeight() const;
185     void SetSessionPropertyChangeCallback(std::function<void()>&& callback);
186     bool IsLayoutFullScreen() const;
187     void SetIsLayoutFullScreen(bool isLayoutFullScreen);
188     int32_t GetCollaboratorType() const;
189     void SetCollaboratorType(int32_t collaboratorType);
190     bool Write(Parcel& parcel, WSPropertyChangeAction action);
191     void Read(Parcel& parcel, WSPropertyChangeAction action);
192     void SetFullScreenStart(bool fullScreenStart);
193     bool GetFullScreenStart() const;
194 
195     /**
196      * Sub Window
197      */
198     void SetSubWindowLevel(uint32_t subWindowLevel);
199     uint32_t GetSubWindowLevel() const;
200 
201     /*
202      * UIExtension
203      */
204     void SetRealParentId(int32_t realParentId);
205     int32_t GetRealParentId() const;
206     void SetUIExtensionUsage(UIExtensionUsage uiExtensionUsage);
207     UIExtensionUsage GetUIExtensionUsage() const;
208     void SetExtensionFlag(bool isExtensionFlag);
209     bool GetExtensionFlag() const;
210     void SetParentWindowType(WindowType parentWindowType);
211     WindowType GetParentWindowType() const;
212     void SetIsUIExtensionSubWindowFlag(bool isUIExtensionSubWindowFlag);
213     bool GetIsUIExtensionSubWindowFlag() const;
214     void SetIsUIExtensionAbilityProcess(bool isUIExtensionAbilityProcess);
215     bool GetIsUIExtensionAbilityProcess() const;
216     void SetConstrainedModal(bool isConstrainedModal);
217     bool IsConstrainedModal() const;
218 
219     /**
220      * PC Window
221      */
222     void SetSupportedWindowModes(const std::vector<AppExecFwk::SupportWindowMode>& supportedWindowModes);
223     void GetSupportedWindowModes(std::vector<AppExecFwk::SupportWindowMode>& supportedWindowModes) const;
224 
225     /*
226      * Keyboard
227      */
228     void SetKeyboardViewMode(KeyboardViewMode mode);
229     KeyboardViewMode GetKeyboardViewMode() const;
230 
231     /*
232      * Window focus
233      */
234     bool GetFocusable() const;
235     bool GetFocusableOnShow() const;
236     bool GetExclusivelyHighlighted() const;
237     void SetExclusivelyHighlighted(bool isExclusivelyHighlighted);
238 
239 private:
240     void SetTouchHotAreasInner(const std::vector<Rect>& rects, std::vector<Rect>& touchHotAreas);
241     bool MarshallingTouchHotAreasInner(const std::vector<Rect>& touchHotAreas, Parcel& parcel) const;
242     bool MarshallingTouchHotAreas(Parcel& parcel) const;
243     bool MarshallingKeyboardTouchHotAreas(Parcel& parcel) const;
244     static void UnmarshallingTouchHotAreasInner(Parcel& parcel, std::vector<Rect>& touchHotAreas);
245     static void UnmarshallingTouchHotAreas(Parcel& parcel, WindowSessionProperty* property);
246     static void UnmarshallingKeyboardTouchHotAreas(Parcel& parcel, WindowSessionProperty* property);
247     bool WriteActionUpdateTurnScreenOn(Parcel& parcel);
248     bool WriteActionUpdateKeepScreenOn(Parcel& parcel);
249     bool WriteActionUpdateFocusable(Parcel& parcel);
250     bool WriteActionUpdateTouchable(Parcel& parcel);
251     bool WriteActionUpdateSetBrightness(Parcel& parcel);
252     bool WriteActionUpdateOrientation(Parcel& parcel);
253     bool WriteActionUpdatePrivacyMode(Parcel& parcel);
254     bool WriteActionUpdateSnapshotSkip(Parcel& parcel);
255     bool WriteActionUpdateMaximizeState(Parcel& parcel);
256     bool WriteActionUpdateSystemBar(Parcel& parcel);
257     bool WriteActionUpdateFlags(Parcel& parcel);
258     bool WriteActionUpdateMode(Parcel& parcel);
259     bool WriteActionUpdateAnimationFlag(Parcel& parcel);
260     bool WriteActionUpdateTouchHotArea(Parcel& parcel);
261     bool WriteActionUpdateKeyboardTouchHotArea(Parcel& parcel);
262     bool WriteActionUpdateDecorEnable(Parcel& parcel);
263     bool WriteActionUpdateWindowLimits(Parcel& parcel);
264     bool WriteActionUpdateDragenabled(Parcel& parcel);
265     bool WriteActionUpdateRaiseenabled(Parcel& parcel);
266     bool WriteActionUpdateHideNonSystemFloatingWindows(Parcel& parcel);
267     bool WriteActionUpdateTextfieldAvoidInfo(Parcel& parcel);
268     bool WriteActionUpdateWindowMask(Parcel& parcel);
269     bool WriteActionUpdateTopmost(Parcel& parcel);
270     bool WriteActionUpdateMainWindowTopmost(Parcel& parcel);
271     bool WriteActionUpdateWindowModeSupportType(Parcel& parcel);
272     bool WriteActionUpdateExclusivelyHighlighted(Parcel& parcel);
273     void ReadActionUpdateTurnScreenOn(Parcel& parcel);
274     void ReadActionUpdateKeepScreenOn(Parcel& parcel);
275     void ReadActionUpdateFocusable(Parcel& parcel);
276     void ReadActionUpdateTouchable(Parcel& parcel);
277     void ReadActionUpdateSetBrightness(Parcel& parcel);
278     void ReadActionUpdateOrientation(Parcel& parcel);
279     void ReadActionUpdatePrivacyMode(Parcel& parcel);
280     void ReadActionUpdateSnapshotSkip(Parcel& parcel);
281     void ReadActionUpdateMaximizeState(Parcel& parcel);
282     void ReadActionUpdateSystemBar(Parcel& parcel);
283     void ReadActionUpdateFlags(Parcel& parcel);
284     void ReadActionUpdateMode(Parcel& parcel);
285     void ReadActionUpdateAnimationFlag(Parcel& parcel);
286     void ReadActionUpdateTouchHotArea(Parcel& parcel);
287     void ReadActionUpdateKeyboardTouchHotArea(Parcel& parcel);
288     void ReadActionUpdateDecorEnable(Parcel& parcel);
289     void ReadActionUpdateWindowLimits(Parcel& parcel);
290     void ReadActionUpdateDragenabled(Parcel& parcel);
291     void ReadActionUpdateRaiseenabled(Parcel& parcel);
292     void ReadActionUpdateHideNonSystemFloatingWindows(Parcel& parcel);
293     void ReadActionUpdateTextfieldAvoidInfo(Parcel& parcel);
294     void ReadActionUpdateWindowMask(Parcel& parcel);
295     void ReadActionUpdateTopmost(Parcel& parcel);
296     void ReadActionUpdateMainWindowTopmost(Parcel& parcel);
297     void ReadActionUpdateWindowModeSupportType(Parcel& parcel);
298     void ReadActionUpdateExclusivelyHighlighted(Parcel& parcel);
299     std::string windowName_;
300     SessionInfo sessionInfo_;
301     mutable std::mutex requestRectMutex_;
302     Rect requestRect_ { 0, 0, 0, 0 }; // window rect requested by the client (without decoration size)
303     mutable std::mutex windowRectMutex_;
304     Rect windowRect_ { 0, 0, 0, 0 }; // actual window rect
305     WindowType type_ { WindowType::WINDOW_TYPE_APP_MAIN_WINDOW }; // type main window
306     bool touchable_ { true };
307     bool dragEnabled_ = { true };
308     bool raiseEnabled_ = { true };
309     bool isSystemCalling_ = { false };
310     bool tokenState_ { false };
311     bool turnScreenOn_ = false;
312     bool keepScreenOn_ = false;
313     bool topmost_ = false;
314     bool mainWindowTopmost_ = false;
315     Orientation requestedOrientation_ = Orientation::UNSPECIFIED;
316     Orientation defaultRequestedOrientation_ = Orientation::UNSPECIFIED; // only accessed on SSM thread
317     bool isPrivacyMode_ { false };
318     bool isSystemPrivacyMode_ { false };
319     bool isSnapshotSkip_ { false };
320     float brightness_ = UNDEFINED_BRIGHTNESS;
321     uint64_t displayId_ = 0;
322     int32_t parentId_ = INVALID_SESSION_ID; // parentId of sceneSession, which is low 32 bite of parentPersistentId_
323     uint32_t flags_ = 0;
324     int32_t persistentId_ = INVALID_SESSION_ID;
325     int32_t parentPersistentId_ = INVALID_SESSION_ID;
326     uint32_t accessTokenId_ = INVALID_SESSION_ID;
327     MaximizeMode maximizeMode_ = MaximizeMode::MODE_RECOVER;
328     WindowMode windowMode_ = WindowMode::WINDOW_MODE_FULLSCREEN;
329     WindowState windowState_ = WindowState::STATE_INITIAL;
330     WindowLimits limits_;
331     WindowLimits userLimits_;
332     WindowLimits configLimitsVP_;
333     float lastVpr_ = 0.0f;
334     PiPTemplateInfo pipTemplateInfo_ = {0, 0, {}};
335     KeyboardLayoutParams keyboardLayoutParams_;
336     uint32_t windowModeSupportType_ {WindowModeSupport::WINDOW_MODE_SUPPORT_ALL};
337     std::unordered_map<WindowType, SystemBarProperty> sysBarPropMap_ {
338         { WindowType::WINDOW_TYPE_STATUS_BAR,           SystemBarProperty(true, 0x00FFFFFF, 0xFF000000) },
339         { WindowType::WINDOW_TYPE_NAVIGATION_BAR,       SystemBarProperty(true, 0x00FFFFFF, 0xFF000000) },
340         { WindowType::WINDOW_TYPE_NAVIGATION_INDICATOR, SystemBarProperty(true, 0x00FFFFFF, 0xFF000000) },
341     };
342     bool isDecorEnable_ = false;
343     uint32_t animationFlag_ { static_cast<uint32_t>(WindowAnimation::DEFAULT) };
344     // Transform info
345     Transform trans_;
346     bool isFloatingWindowAppType_ = false;
347     mutable std::mutex touchHotAreasMutex_;
348     std::vector<Rect> touchHotAreas_;  // coordinates relative to window.
349     KeyboardTouchHotAreas keyboardTouchHotAreas_;  // coordinates relative to window.
350     bool hideNonSystemFloatingWindows_ = false;
351     bool forceHide_ = false;
352     bool keepKeyboardFlag_ = false;
353     uint32_t callingSessionId_ = INVALID_SESSION_ID;
354 
355     double textFieldPositionY_ = 0.0;
356     double textFieldHeight_ = 0.0;
357 
358     bool isNeedUpdateWindowMode_ = false;
359     std::function<void()> touchHotAreasChangeCallback_;
360     bool isLayoutFullScreen_ = false;
361 
362     bool isShaped_ = false;
363     bool fullScreenStart_ = false;
364     std::shared_ptr<Media::PixelMap> windowMask_ = nullptr;
365     int32_t collaboratorType_ = CollaboratorType::DEFAULT_TYPE;
366     static const std::map<uint32_t, HandlWritePropertyFunc> writeFuncMap_;
367     static const std::map<uint32_t, HandlReadPropertyFunc> readFuncMap_;
368     bool compatibleModeInPc_ = false;
369     int32_t compatibleInPcPortraitWidth_ = 0;
370     int32_t compatibleInPcPortraitHeight_ = 0;
371     int32_t compatibleInPcLandscapeWidth_ = 0;
372     int32_t compatibleInPcLandscapeHeight_ = 0;
373     bool isAppSupportPhoneInPc_ = false;
374     bool isSupportDragInPcCompatibleMode_ = false;
375     bool isPcAppInPad_ = false;
376     mutable std::mutex compatibleModeMutex_;
377     bool compatibleModeEnableInPad_ = false;
378 
379     /**
380      * Sub Window
381      */
382     uint32_t subWindowLevel_ = 1;
383 
384     /*
385      * UIExtension
386      */
387     int32_t realParentId_ = INVALID_SESSION_ID;
388     UIExtensionUsage uiExtensionUsage_ { UIExtensionUsage::EMBEDDED };
389     bool isExtensionFlag_ = false;
390     bool isUIExtensionSubWindowFlag_ = false;
391     bool isUIExtensionAbilityProcess_ = false;
392     WindowType parentWindowType_ = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW;
393     bool isConstrainedModal_ = false;
394 
395     /**
396      * PC Window
397      */
398     mutable std::mutex supportWindowModesMutex_;
399     std::vector<AppExecFwk::SupportWindowMode> supportedWindowModes_;
400 
401     /*
402      * Keyboard
403      */
404     KeyboardViewMode keyboardViewMode_ = KeyboardViewMode::NON_IMMERSIVE_MODE;
405 
406     /*
407      * Window Focus
408      */
409     bool focusable_ { true };
410     bool focusableOnShow_ { true };
411     bool isExclusivelyHighlighted_ { true };
412 };
413 
414 struct FreeMultiWindowConfig : public Parcelable {
415     bool isSystemDecorEnable_ = true;
416     uint32_t decorWindowModeSupportType_ = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL;
417     WindowMode defaultWindowMode_ = WindowMode::WINDOW_MODE_FULLSCREEN;
418     uint32_t maxMainFloatingWindowNumber_ = 0;
419 
MarshallingFreeMultiWindowConfig420     virtual bool Marshalling(Parcel& parcel) const override
421     {
422         if (!parcel.WriteBool(isSystemDecorEnable_) ||
423             !parcel.WriteUint32(decorWindowModeSupportType_)) {
424             return false;
425         }
426 
427         if (!parcel.WriteUint32(static_cast<uint32_t>(defaultWindowMode_)) ||
428             !parcel.WriteUint32(maxMainFloatingWindowNumber_)) {
429             return false;
430         }
431         return true;
432     }
433 
UnmarshallingFreeMultiWindowConfig434     static FreeMultiWindowConfig* Unmarshalling(Parcel& parcel)
435     {
436         FreeMultiWindowConfig* config = new (std::nothrow) FreeMultiWindowConfig();
437         if (config == nullptr) {
438             return nullptr;
439         }
440         config->isSystemDecorEnable_ = parcel.ReadBool();
441         config->decorWindowModeSupportType_ = parcel.ReadUint32();
442         config->defaultWindowMode_ = static_cast<WindowMode>(parcel.ReadUint32());
443         config->maxMainFloatingWindowNumber_ = parcel.ReadUint32();
444         return config;
445     }
446 };
447 
448 struct AppForceLandscapeConfig : public Parcelable {
449     int32_t mode_ = 0;
450     std::string homePage_;
451 
AppForceLandscapeConfigAppForceLandscapeConfig452     AppForceLandscapeConfig() {}
AppForceLandscapeConfigAppForceLandscapeConfig453     AppForceLandscapeConfig(int32_t mode, const std::string& homePage) : mode_(mode), homePage_(homePage) {}
454 
MarshallingAppForceLandscapeConfig455     virtual bool Marshalling(Parcel& parcel) const override
456     {
457         if (!parcel.WriteInt32(mode_) ||
458             !parcel.WriteString(homePage_)) {
459             return false;
460         }
461         return true;
462     }
463 
UnmarshallingAppForceLandscapeConfig464     static AppForceLandscapeConfig* Unmarshalling(Parcel& parcel)
465     {
466         AppForceLandscapeConfig* config = new (std::nothrow) AppForceLandscapeConfig();
467         if (config == nullptr) {
468             return nullptr;
469         }
470         config->mode_ = parcel.ReadInt32();
471         config->homePage_ = parcel.ReadString();
472         return config;
473     }
474 };
475 
476 struct SystemSessionConfig : public Parcelable {
477     bool isSystemDecorEnable_ = true;
478     uint32_t decorWindowModeSupportType_ = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL;
479     bool isStretchable_ = false;
480     WindowMode defaultWindowMode_ = WindowMode::WINDOW_MODE_FULLSCREEN;
481     KeyboardAnimationCurve animationIn_;
482     KeyboardAnimationCurve animationOut_;
483     // 1920: default max window size
484     uint32_t maxFloatingWindowSize_ = 1920;
485     // 320: default minWidth main window size
486     uint32_t miniWidthOfMainWindow_ = 320;
487     // 240: default minHeight main window size
488     uint32_t miniHeightOfMainWindow_ = 240;
489     // 320: default minWidth sub window size
490     uint32_t miniWidthOfSubWindow_ = 320;
491     // 240: default minHeight sub window size
492     uint32_t miniHeightOfSubWindow_ = 240;
493     bool backgroundswitch = false;
494     bool freeMultiWindowEnable_ = false;
495     bool freeMultiWindowSupport_ = false;
496     FreeMultiWindowConfig freeMultiWindowConfig_;
497     std::string uiType_;
498     bool supportTypeFloatWindow_ = false;
499     // 4: default max mid scene num
500     uint32_t maxMidSceneNum_ = 4;
501 
MarshallingSystemSessionConfig502     virtual bool Marshalling(Parcel& parcel) const override
503     {
504         if (!parcel.WriteBool(isSystemDecorEnable_) || !parcel.WriteBool(isStretchable_) ||
505             !parcel.WriteUint32(decorWindowModeSupportType_)) {
506             return false;
507         }
508 
509         if (!parcel.WriteUint32(static_cast<uint32_t>(defaultWindowMode_)) ||
510             !parcel.WriteParcelable(&animationIn_) || !parcel.WriteParcelable(&animationOut_) ||
511             !parcel.WriteUint32(maxFloatingWindowSize_)) {
512             return false;
513         }
514 
515         if (!parcel.WriteUint32(miniWidthOfMainWindow_) || !parcel.WriteUint32(miniHeightOfMainWindow_) ||
516             !parcel.WriteUint32(miniWidthOfSubWindow_) || !parcel.WriteUint32(miniHeightOfSubWindow_)) {
517             return false;
518         }
519 
520         if (!parcel.WriteBool(backgroundswitch)) {
521             return false;
522         }
523 
524         if (!parcel.WriteBool(freeMultiWindowEnable_)) {
525             return false;
526         }
527 
528         if (!parcel.WriteBool(freeMultiWindowSupport_)) {
529             return false;
530         }
531         if (!parcel.WriteParcelable(&freeMultiWindowConfig_)) {
532             return false;
533         }
534         if (!parcel.WriteString(uiType_)) {
535             return false;
536         }
537         if (!parcel.WriteBool(supportTypeFloatWindow_)) {
538             return false;
539         }
540         if (!parcel.WriteBool(maxMidSceneNum_)) {
541             return false;
542         }
543         return true;
544     }
545 
UnmarshallingSystemSessionConfig546     static SystemSessionConfig* Unmarshalling(Parcel& parcel)
547     {
548         SystemSessionConfig* config = new (std::nothrow) SystemSessionConfig();
549         if (config == nullptr) {
550             return nullptr;
551         }
552         config->isSystemDecorEnable_ = parcel.ReadBool();
553         config->isStretchable_ = parcel.ReadBool();
554         config->decorWindowModeSupportType_ = parcel.ReadUint32();
555         config->defaultWindowMode_ = static_cast<WindowMode>(parcel.ReadUint32());
556         sptr<KeyboardAnimationCurve> animationIn = parcel.ReadParcelable<KeyboardAnimationCurve>();
557         if (animationIn == nullptr) {
558             delete config;
559             return nullptr;
560         }
561         config->animationIn_ = *animationIn;
562         sptr<KeyboardAnimationCurve> animationOut = parcel.ReadParcelable<KeyboardAnimationCurve>();
563         if (animationOut == nullptr) {
564             delete config;
565             return nullptr;
566         }
567         config->animationOut_ = *animationOut;
568         config->maxFloatingWindowSize_ = parcel.ReadUint32();
569         config->miniWidthOfMainWindow_ = parcel.ReadUint32();
570         config->miniHeightOfMainWindow_ = parcel.ReadUint32();
571         config->miniWidthOfSubWindow_ = parcel.ReadUint32();
572         config->miniHeightOfSubWindow_ = parcel.ReadUint32();
573         config->backgroundswitch = parcel.ReadBool();
574         config->freeMultiWindowEnable_ = parcel.ReadBool();
575         config->freeMultiWindowSupport_ = parcel.ReadBool();
576         sptr<FreeMultiWindowConfig> freeMultiWindowConfig = parcel.ReadParcelable<FreeMultiWindowConfig>();
577         if (freeMultiWindowConfig == nullptr) {
578             delete config;
579             return nullptr;
580         }
581         config->freeMultiWindowConfig_ = *freeMultiWindowConfig;
582         config->uiType_ = parcel.ReadString();
583         config->supportTypeFloatWindow_ = parcel.ReadBool();
584         config->maxMidSceneNum_ = parcel.ReadUint32();
585         return config;
586     }
587 
IsFreeMultiWindowModeSystemSessionConfig588     bool IsFreeMultiWindowMode() const
589     {
590         return freeMultiWindowEnable_ && freeMultiWindowSupport_;
591     }
592 };
593 } // namespace Rosen
594 } // namespace OHOS
595 #endif // OHOS_ROSEN_WINDOW_PROPERTY_H
596