• 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 SetPrivacyMode(bool isPrivate);
58     void SetSystemPrivacyMode(bool isSystemPrivate);
59     void SetSnapshotSkip(bool isSkip);
60     void SetBrightness(float brightness);
61     void SetDisplayId(uint64_t displayId);
62     void SetWindowType(WindowType type);
63     void SetParentId(int32_t parentId);
64     void SetPersistentId(int32_t persistentId);
65     void SetParentPersistentId(int32_t persistentId);
66     void SetAccessTokenId(uint32_t accessTokenId);
67     void SetTokenState(bool hasToken);
68     void SetMaximizeMode(MaximizeMode mode);
69     void SetWindowMode(WindowMode mode);
70     void SetWindowLimits(const WindowLimits& windowLimits);
71     void SetUserWindowLimits(const WindowLimits& windowLimits);
72     void SetConfigWindowLimitsVP(const WindowLimits& windowLimitsVP);
73     void SetLastLimitsVpr(float vpr);
74     void SetSystemBarProperty(WindowType type, const SystemBarProperty& property);
75     void SetKeyboardSessionGravity(SessionGravity gravity_, uint32_t percent);
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 AddWindowFlag(WindowFlag flag);
84     void SetModeSupportInfo(uint32_t modeSupportInfo);
85     void SetFloatingWindowAppType(bool isAppType);
86     void SetTouchHotAreas(const std::vector<Rect>& rects);
87     void KeepKeyboardOnFocus(bool keepKeyboardFlag);
88     void SetIsNeedUpdateWindowMode(bool isNeedUpdateWindowMode);
89     void SetCallingSessionId(uint32_t sessionId);
90     void SetPiPTemplateInfo(const PiPTemplateInfo& pipTemplateInfo);
91     void SetWindowMask(const std::shared_ptr<Media::PixelMap>& windowMask);
92     void SetIsShaped(bool isShaped);
93     void SetCompatibleModeInPc(bool compatibleModeInPc);
94     void SetCompatibleWindowSizeInPc(int32_t portraitWidth, int32_t portraitHeight,
95         int32_t landscapeWidth, int32_t landscapeHeight);
96     void SetIsSupportDragInPcCompatibleMode(bool isSupportDragInPcCompatibleMode);
97     void SetIsPcAppInPad(bool isPcAppInPad);
98     void SetCompatibleModeEnableInPad(bool enable);
99 
100     bool GetIsNeedUpdateWindowMode() const;
101     const std::string& GetWindowName() const;
102     const SessionInfo& GetSessionInfo() const;
103     SessionInfo& EditSessionInfo();
104     Rect GetWindowRect() const;
105     Rect GetRequestRect() const;
106     WindowType GetWindowType() const;
107     bool GetFocusable() const;
108     bool GetFocusableOnShow() const;
109     bool GetTouchable() const;
110     bool GetDragEnabled() const;
111     bool GetHideNonSystemFloatingWindows() const;
112     bool GetForceHide() const;
113     bool GetRaiseEnabled() const;
114     bool GetSystemCalling() const;
115     bool IsTurnScreenOn() const;
116     bool IsKeepScreenOn() const;
117     Orientation GetRequestedOrientation() const;
118     bool GetPrivacyMode() const;
119     bool GetSystemPrivacyMode() const;
120     bool GetSnapshotSkip() const;
121     float GetBrightness() const;
122     int32_t GetParentId() const;
123     uint32_t GetWindowFlags() const;
124     uint64_t GetDisplayId() const;
125     int32_t GetPersistentId() const;
126     int32_t GetParentPersistentId() const;
127     uint32_t GetAccessTokenId() const;
128     bool GetTokenState() const;
129     MaximizeMode GetMaximizeMode() const;
130     WindowMode GetWindowMode() const;
131     WindowLimits GetWindowLimits() const;
132     WindowLimits GetUserWindowLimits() const;
133     WindowLimits GetConfigWindowLimitsVP() const;
134     float GetLastLimitsVpr() const;
135     uint32_t GetModeSupportInfo() const;
136     std::unordered_map<WindowType, SystemBarProperty> GetSystemBarProperty() const;
137     void GetSessionGravity(SessionGravity& gravity, uint32_t& percent);
138     bool IsDecorEnable();
139     uint32_t GetAnimationFlag() const;
140     const Transform& GetTransform() const;
141     bool IsFloatingWindowAppType() const;
142     void GetTouchHotAreas(std::vector<Rect>& rects) const;
143     bool GetKeepKeyboardFlag() const;
144     uint32_t GetCallingSessionId() const;
145     PiPTemplateInfo GetPiPTemplateInfo() const;
146     std::shared_ptr<Media::PixelMap> GetWindowMask() const;
147     bool GetIsShaped() const;
148     KeyboardLayoutParams GetKeyboardLayoutParams() const;
149     bool GetCompatibleModeInPc() const;
150     int32_t GetCompatibleInPcPortraitWidth() const;
151     int32_t GetCompatibleInPcPortraitHeight() const;
152     int32_t GetCompatibleInPcLandscapeWidth() const;
153     int32_t GetCompatibleInPcLandscapeHeight() const;
154     bool GetIsPcAppInPad() const;
155     bool GetIsSupportDragInPcCompatibleMode() const;
156     bool GetCompatibleModeEnableInPad() const;
157 
158     bool MarshallingWindowLimits(Parcel& parcel) const;
159     static void UnmarshallingWindowLimits(Parcel& parcel, WindowSessionProperty* property);
160     bool MarshallingSystemBarMap(Parcel& parcel) const;
161     static void UnMarshallingSystemBarMap(Parcel& parcel, WindowSessionProperty* property);
162     bool MarshallingPiPTemplateInfo(Parcel& parcel) const;
163     static void UnmarshallingPiPTemplateInfo(Parcel& parcel, WindowSessionProperty* property);
164     bool Marshalling(Parcel& parcel) const override;
165     static WindowSessionProperty* Unmarshalling(Parcel& parcel);
166     bool MarshallingWindowMask(Parcel& parcel) const;
167     static void UnmarshallingWindowMask(Parcel& parcel, WindowSessionProperty* property);
168     bool MarshallingSessionInfo(Parcel& parcel) const;
169     static bool UnmarshallingSessionInfo(Parcel& parcel, WindowSessionProperty* property);
170 
171     void SetTextFieldPositionY(double textFieldPositionY);
172     void SetTextFieldHeight(double textFieldHeight);
173 
174     WindowState GetWindowState() const;
175     void SetWindowState(WindowState state);
176 
177     double GetTextFieldPositionY() const;
178     double GetTextFieldHeight() const;
179     void SetSessionPropertyChangeCallback(std::function<void()>&& callback);
180     bool IsLayoutFullScreen() const;
181     void SetIsLayoutFullScreen(bool isLayoutFullScreen);
182     int32_t GetCollaboratorType() const;
183     void SetCollaboratorType(int32_t collaboratorType);
184     bool Write(Parcel& parcel, WSPropertyChangeAction action);
185     void Read(Parcel& parcel, WSPropertyChangeAction action);
186     void SetFullScreenStart(bool fullScreenStart);
187     bool GetFullScreenStart() const;
188 
189     /**
190      * Sub Window
191      */
192     void SetSubWindowLevel(uint32_t subWindowLevel);
193     uint32_t GetSubWindowLevel() const;
194 
195     /*
196      * UIExtension
197      */
198     void SetRealParentId(int32_t realParentId);
199     int32_t GetRealParentId() const;
200     void SetUIExtensionUsage(UIExtensionUsage uiExtensionUsage);
201     UIExtensionUsage GetUIExtensionUsage() const;
202     void SetExtensionFlag(bool isExtensionFlag);
203     bool GetExtensionFlag() const;
204     void SetParentWindowType(WindowType parentWindowType);
205     WindowType GetParentWindowType() const;
206     void SetIsUIExtensionSubWindowFlag(bool isUIExtensionSubWindowFlag);
207     bool GetIsUIExtensionSubWindowFlag() const;
208 
209 private:
210     bool MarshallingTouchHotAreas(Parcel& parcel) const;
211     static void UnmarshallingTouchHotAreas(Parcel& parcel, WindowSessionProperty* property);
212     bool WriteActionUpdateTurnScreenOn(Parcel& parcel);
213     bool WriteActionUpdateKeepScreenOn(Parcel& parcel);
214     bool WriteActionUpdateFocusable(Parcel& parcel);
215     bool WriteActionUpdateTouchable(Parcel& parcel);
216     bool WriteActionUpdateSetBrightness(Parcel& parcel);
217     bool WriteActionUpdateOrientation(Parcel& parcel);
218     bool WriteActionUpdatePrivacyMode(Parcel& parcel);
219     bool WriteActionUpdateSnapshotSkip(Parcel& parcel);
220     bool WriteActionUpdateMaximizeState(Parcel& parcel);
221     bool WriteActionUpdateSystemBar(Parcel& parcel);
222     bool WriteActionUpdateFlags(Parcel& parcel);
223     bool WriteActionUpdateMode(Parcel& parcel);
224     bool WriteActionUpdateAnimationFlag(Parcel& parcel);
225     bool WriteActionUpdateTouchHotArea(Parcel& parcel);
226     bool WriteActionUpdateDecorEnable(Parcel& parcel);
227     bool WriteActionUpdateWindowLimits(Parcel& parcel);
228     bool WriteActionUpdateDragenabled(Parcel& parcel);
229     bool WriteActionUpdateRaiseenabled(Parcel& parcel);
230     bool WriteActionUpdateHideNonSystemFloatingWindows(Parcel& parcel);
231     bool WriteActionUpdateTextfieldAvoidInfo(Parcel& parcel);
232     bool WriteActionUpdateWindowMask(Parcel& parcel);
233     bool WriteActionUpdateTopmost(Parcel& parcel);
234     bool WriteActionUpdateModeSupportInfo(Parcel& parcel);
235     void ReadActionUpdateTurnScreenOn(Parcel& parcel);
236     void ReadActionUpdateKeepScreenOn(Parcel& parcel);
237     void ReadActionUpdateFocusable(Parcel& parcel);
238     void ReadActionUpdateTouchable(Parcel& parcel);
239     void ReadActionUpdateSetBrightness(Parcel& parcel);
240     void ReadActionUpdateOrientation(Parcel& parcel);
241     void ReadActionUpdatePrivacyMode(Parcel& parcel);
242     void ReadActionUpdateSnapshotSkip(Parcel& parcel);
243     void ReadActionUpdateMaximizeState(Parcel& parcel);
244     void ReadActionUpdateSystemBar(Parcel& parcel);
245     void ReadActionUpdateFlags(Parcel& parcel);
246     void ReadActionUpdateMode(Parcel& parcel);
247     void ReadActionUpdateAnimationFlag(Parcel& parcel);
248     void ReadActionUpdateTouchHotArea(Parcel& parcel);
249     void ReadActionUpdateDecorEnable(Parcel& parcel);
250     void ReadActionUpdateWindowLimits(Parcel& parcel);
251     void ReadActionUpdateDragenabled(Parcel& parcel);
252     void ReadActionUpdateRaiseenabled(Parcel& parcel);
253     void ReadActionUpdateHideNonSystemFloatingWindows(Parcel& parcel);
254     void ReadActionUpdateTextfieldAvoidInfo(Parcel& parcel);
255     void ReadActionUpdateWindowMask(Parcel& parcel);
256     void ReadActionUpdateTopmost(Parcel& parcel);
257     void ReadActionUpdateModeSupportInfo(Parcel& parcel);
258     std::string windowName_;
259     SessionInfo sessionInfo_;
260     Rect requestRect_ { 0, 0, 0, 0 }; // window rect requested by the client (without decoration size)
261     mutable std::mutex windowRectMutex_;
262     Rect windowRect_ { 0, 0, 0, 0 }; // actual window rect
263     WindowType type_ { WindowType::WINDOW_TYPE_APP_MAIN_WINDOW }; // type main window
264     bool focusable_ { true };
265     bool focusableOnShow_ { true };
266     bool touchable_ { true };
267     bool dragEnabled_ = { true };
268     bool raiseEnabled_ = { true };
269     bool isSystemCalling_ = { false };
270     bool tokenState_ { false };
271     bool turnScreenOn_ = false;
272     bool keepScreenOn_ = false;
273     bool topmost_ = false;
274     Orientation requestedOrientation_ = Orientation::UNSPECIFIED;
275     bool isPrivacyMode_ { false };
276     bool isSystemPrivacyMode_ { false };
277     bool isSnapshotSkip_ { false };
278     float brightness_ = UNDEFINED_BRIGHTNESS;
279     uint64_t displayId_ = 0;
280     int32_t parentId_ = INVALID_SESSION_ID; // parentId of sceneSession, which is low 32 bite of parentPersistentId_
281     uint32_t flags_ = 0;
282     int32_t persistentId_ = INVALID_SESSION_ID;
283     int32_t parentPersistentId_ = INVALID_SESSION_ID;
284     uint32_t accessTokenId_ = INVALID_SESSION_ID;
285     MaximizeMode maximizeMode_ = MaximizeMode::MODE_RECOVER;
286     WindowMode windowMode_ = WindowMode::WINDOW_MODE_FULLSCREEN;
287     WindowState windowState_ = WindowState::STATE_INITIAL;
288     WindowLimits limits_;
289     WindowLimits userLimits_;
290     WindowLimits configLimitsVP_;
291     float lastVpr_ = 0.0f;
292     PiPTemplateInfo pipTemplateInfo_ = {0, 0, {}};
293     SessionGravity sessionGravity_ = SessionGravity::SESSION_GRAVITY_DEFAULT;
294     KeyboardLayoutParams keyboardLayoutParams_;
295     uint32_t sessionGravitySizePercent_ = 0;
296     uint32_t modeSupportInfo_ {WindowModeSupport::WINDOW_MODE_SUPPORT_ALL};
297     std::unordered_map<WindowType, SystemBarProperty> sysBarPropMap_ {
298         { WindowType::WINDOW_TYPE_STATUS_BAR,           SystemBarProperty(true, 0x00FFFFFF, 0xFF000000) },
299         { WindowType::WINDOW_TYPE_NAVIGATION_BAR,       SystemBarProperty(true, 0x00FFFFFF, 0xFF000000) },
300         { WindowType::WINDOW_TYPE_NAVIGATION_INDICATOR, SystemBarProperty(true, 0x00FFFFFF, 0xFF000000) },
301     };
302     bool isDecorEnable_ = false;
303     uint32_t animationFlag_ { static_cast<uint32_t>(WindowAnimation::DEFAULT) };
304     // Transform info
305     Transform trans_;
306     bool isFloatingWindowAppType_ = false;
307     mutable std::mutex touchHotAreasMutex_;
308     std::vector<Rect> touchHotAreas_;  // coordinates relative to window.
309     bool hideNonSystemFloatingWindows_ = false;
310     bool forceHide_ = false;
311     bool keepKeyboardFlag_ = false;
312     uint32_t callingSessionId_ = INVALID_SESSION_ID;
313 
314     double textFieldPositionY_ = 0.0;
315     double textFieldHeight_ = 0.0;
316 
317     bool isNeedUpdateWindowMode_ = false;
318     std::function<void()> touchHotAreasChangeCallback_;
319     bool isLayoutFullScreen_ = false;
320 
321     bool isShaped_ = false;
322     bool fullScreenStart_ = false;
323     std::shared_ptr<Media::PixelMap> windowMask_ = nullptr;
324     int32_t collaboratorType_ = CollaboratorType::DEFAULT_TYPE;
325     static const std::map<uint32_t, HandlWritePropertyFunc> writeFuncMap_;
326     static const std::map<uint32_t, HandlReadPropertyFunc> readFuncMap_;
327     bool compatibleModeInPc_ = false;
328     int32_t compatibleInPcPortraitWidth_ = 0;
329     int32_t compatibleInPcPortraitHeight_ = 0;
330     int32_t compatibleInPcLandscapeWidth_ = 0;
331     int32_t compatibleInPcLandscapeHeight_ = 0;
332     bool isSupportDragInPcCompatibleMode_ = false;
333     bool isPcAppInPad_ = false;
334     mutable std::mutex compatibleModeMutex_;
335     bool compatibleModeEnableInPad_ = false;
336 
337     /**
338      * Sub Window
339      */
340     uint32_t subWindowLevel_ = 1;
341 
342     /*
343      * UIExtension
344      */
345     int32_t realParentId_ = INVALID_SESSION_ID;
346     UIExtensionUsage uiExtensionUsage_ { UIExtensionUsage::EMBEDDED };
347     bool isExtensionFlag_ = false;
348     bool isUIExtensionSubWindowFlag_ = false;
349     WindowType parentWindowType_ = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW;
350 };
351 
352 struct FreeMultiWindowConfig : public Parcelable {
353     bool isSystemDecorEnable_ = true;
354     uint32_t decorModeSupportInfo_ = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL;
355     WindowMode defaultWindowMode_ = WindowMode::WINDOW_MODE_FULLSCREEN;
356     uint32_t maxMainFloatingWindowNumber_ = 0;
357 
MarshallingFreeMultiWindowConfig358     virtual bool Marshalling(Parcel& parcel) const override
359     {
360         if (!parcel.WriteBool(isSystemDecorEnable_) ||
361             !parcel.WriteUint32(decorModeSupportInfo_)) {
362             return false;
363         }
364 
365         if (!parcel.WriteUint32(static_cast<uint32_t>(defaultWindowMode_)) ||
366             !parcel.WriteUint32(maxMainFloatingWindowNumber_)) {
367             return false;
368         }
369         return true;
370     }
371 
UnmarshallingFreeMultiWindowConfig372     static FreeMultiWindowConfig* Unmarshalling(Parcel& parcel)
373     {
374         FreeMultiWindowConfig* config = new (std::nothrow) FreeMultiWindowConfig();
375         if (config == nullptr) {
376             return nullptr;
377         }
378         config->isSystemDecorEnable_ = parcel.ReadBool();
379         config->decorModeSupportInfo_ = parcel.ReadUint32();
380         config->defaultWindowMode_ = static_cast<WindowMode>(parcel.ReadUint32());
381         config->maxMainFloatingWindowNumber_ = parcel.ReadUint32();
382         return config;
383     }
384 };
385 
386 struct AppForceLandscapeConfig : public Parcelable {
387     int32_t mode_ = 0;
388     std::string homePage_;
389 
AppForceLandscapeConfigAppForceLandscapeConfig390     AppForceLandscapeConfig() {}
AppForceLandscapeConfigAppForceLandscapeConfig391     AppForceLandscapeConfig(int32_t mode, const std::string& homePage) : mode_(mode), homePage_(homePage) {}
392 
MarshallingAppForceLandscapeConfig393     virtual bool Marshalling(Parcel& parcel) const override
394     {
395         if (!parcel.WriteInt32(mode_) ||
396             !parcel.WriteString(homePage_)) {
397             return false;
398         }
399         return true;
400     }
401 
UnmarshallingAppForceLandscapeConfig402     static AppForceLandscapeConfig* Unmarshalling(Parcel& parcel)
403     {
404         AppForceLandscapeConfig* config = new (std::nothrow) AppForceLandscapeConfig();
405         if (config == nullptr) {
406             return nullptr;
407         }
408         config->mode_ = parcel.ReadInt32();
409         config->homePage_ = parcel.ReadString();
410         return config;
411     }
412 };
413 
414 struct SystemSessionConfig : public Parcelable {
415     bool isSystemDecorEnable_ = true;
416     uint32_t decorModeSupportInfo_ = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL;
417     bool isStretchable_ = false;
418     WindowMode defaultWindowMode_ = WindowMode::WINDOW_MODE_FULLSCREEN;
419     KeyboardAnimationCurve animationIn_;
420     KeyboardAnimationCurve animationOut_;
421     // 1920: default max window size
422     uint32_t maxFloatingWindowSize_ = 1920;
423     // 320: default minWidth main window size
424     uint32_t miniWidthOfMainWindow_ = 320;
425     // 240: default minHeight main window size
426     uint32_t miniHeightOfMainWindow_ = 240;
427     // 320: default minWidth sub window size
428     uint32_t miniWidthOfSubWindow_ = 320;
429     // 240: default minHeight sub window size
430     uint32_t miniHeightOfSubWindow_ = 240;
431     bool backgroundswitch = false;
432     bool freeMultiWindowEnable_ = false;
433     bool freeMultiWindowSupport_ = false;
434     FreeMultiWindowConfig freeMultiWindowConfig_;
435     std::string uiType_;
436     bool supportTypeFloatWindow_ = false;
437 
MarshallingSystemSessionConfig438     virtual bool Marshalling(Parcel& parcel) const override
439     {
440         if (!parcel.WriteBool(isSystemDecorEnable_) || !parcel.WriteBool(isStretchable_) ||
441             !parcel.WriteUint32(decorModeSupportInfo_)) {
442             return false;
443         }
444 
445         if (!parcel.WriteUint32(static_cast<uint32_t>(defaultWindowMode_)) ||
446             !parcel.WriteParcelable(&animationIn_) || !parcel.WriteParcelable(&animationOut_) ||
447             !parcel.WriteUint32(maxFloatingWindowSize_)) {
448             return false;
449         }
450 
451         if (!parcel.WriteUint32(miniWidthOfMainWindow_) || !parcel.WriteUint32(miniHeightOfMainWindow_) ||
452             !parcel.WriteUint32(miniWidthOfSubWindow_) || !parcel.WriteUint32(miniHeightOfSubWindow_)) {
453             return false;
454         }
455 
456         if (!parcel.WriteBool(backgroundswitch)) {
457             return false;
458         }
459 
460         if (!parcel.WriteBool(freeMultiWindowEnable_)) {
461             return false;
462         }
463 
464         if (!parcel.WriteBool(freeMultiWindowSupport_)) {
465             return false;
466         }
467         if (!parcel.WriteParcelable(&freeMultiWindowConfig_)) {
468             return false;
469         }
470         if (!parcel.WriteString(uiType_)) {
471             return false;
472         }
473         if (!parcel.WriteBool(supportTypeFloatWindow_)) {
474             return false;
475         }
476         return true;
477     }
478 
UnmarshallingSystemSessionConfig479     static SystemSessionConfig* Unmarshalling(Parcel& parcel)
480     {
481         SystemSessionConfig* config = new (std::nothrow) SystemSessionConfig();
482         if (config == nullptr) {
483             return nullptr;
484         }
485         config->isSystemDecorEnable_ = parcel.ReadBool();
486         config->isStretchable_ = parcel.ReadBool();
487         config->decorModeSupportInfo_ = parcel.ReadUint32();
488         config->defaultWindowMode_ = static_cast<WindowMode>(parcel.ReadUint32());
489         sptr<KeyboardAnimationCurve> animationIn = parcel.ReadParcelable<KeyboardAnimationCurve>();
490         if (animationIn == nullptr) {
491             delete config;
492             return nullptr;
493         }
494         config->animationIn_ = *animationIn;
495         sptr<KeyboardAnimationCurve> animationOut = parcel.ReadParcelable<KeyboardAnimationCurve>();
496         if (animationOut == nullptr) {
497             delete config;
498             return nullptr;
499         }
500         config->animationOut_ = *animationOut;
501         config->maxFloatingWindowSize_ = parcel.ReadUint32();
502         config->miniWidthOfMainWindow_ = parcel.ReadUint32();
503         config->miniHeightOfMainWindow_ = parcel.ReadUint32();
504         config->miniWidthOfSubWindow_ = parcel.ReadUint32();
505         config->miniHeightOfSubWindow_ = parcel.ReadUint32();
506         config->backgroundswitch = parcel.ReadBool();
507         config->freeMultiWindowEnable_ = parcel.ReadBool();
508         config->freeMultiWindowSupport_ = parcel.ReadBool();
509         sptr<FreeMultiWindowConfig> freeMultiWindowConfig = parcel.ReadParcelable<FreeMultiWindowConfig>();
510         if (freeMultiWindowConfig == nullptr) {
511             delete config;
512             return nullptr;
513         }
514         config->freeMultiWindowConfig_ = *freeMultiWindowConfig;
515         config->uiType_ = parcel.ReadString();
516         config->supportTypeFloatWindow_ = parcel.ReadBool();
517         return config;
518     }
519 
IsFreeMultiWindowModeSystemSessionConfig520     bool IsFreeMultiWindowMode() const
521     {
522         return freeMultiWindowEnable_ && freeMultiWindowSupport_;
523     }
524 };
525 } // namespace Rosen
526 } // namespace OHOS
527 #endif // OHOS_ROSEN_WINDOW_PROPERTY_H
528