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 KeepKeyboardOnFocus(bool keepKeyboardFlag); 90 void SetIsNeedUpdateWindowMode(bool isNeedUpdateWindowMode); 91 void SetCallingSessionId(uint32_t sessionId); 92 void SetPiPTemplateInfo(const PiPTemplateInfo& pipTemplateInfo); 93 void SetWindowMask(const std::shared_ptr<Media::PixelMap>& windowMask); 94 void SetIsShaped(bool isShaped); 95 void SetCompatibleModeInPc(bool compatibleModeInPc); 96 void SetCompatibleWindowSizeInPc(int32_t portraitWidth, int32_t portraitHeight, 97 int32_t landscapeWidth, int32_t landscapeHeight); 98 void SetIsAppSupportPhoneInPc(bool isSupportPhone); 99 void SetIsSupportDragInPcCompatibleMode(bool isSupportDragInPcCompatibleMode); 100 void SetIsPcAppInPad(bool isPcAppInPad); 101 void SetCompatibleModeEnableInPad(bool enable); 102 103 bool GetIsNeedUpdateWindowMode() const; 104 const std::string& GetWindowName() const; 105 const SessionInfo& GetSessionInfo() const; 106 SessionInfo& EditSessionInfo(); 107 Rect GetWindowRect() const; 108 Rect GetRequestRect() const; 109 WindowType GetWindowType() const; 110 bool GetFocusable() const; 111 bool GetFocusableOnShow() const; 112 bool GetTouchable() const; 113 bool GetDragEnabled() const; 114 bool GetHideNonSystemFloatingWindows() const; 115 bool GetForceHide() const; 116 bool GetRaiseEnabled() const; 117 bool GetSystemCalling() const; 118 bool IsTurnScreenOn() const; 119 bool IsKeepScreenOn() const; 120 Orientation GetRequestedOrientation() const; 121 Orientation GetDefaultRequestedOrientation() const; 122 bool GetPrivacyMode() const; 123 bool GetSystemPrivacyMode() const; 124 bool GetSnapshotSkip() const; 125 float GetBrightness() const; 126 int32_t GetParentId() const; 127 uint32_t GetWindowFlags() const; 128 uint64_t GetDisplayId() const; 129 int32_t GetPersistentId() const; 130 int32_t GetParentPersistentId() const; 131 uint32_t GetAccessTokenId() const; 132 bool GetTokenState() const; 133 MaximizeMode GetMaximizeMode() const; 134 WindowMode GetWindowMode() const; 135 WindowLimits GetWindowLimits() const; 136 WindowLimits GetUserWindowLimits() const; 137 WindowLimits GetConfigWindowLimitsVP() const; 138 float GetLastLimitsVpr() const; 139 uint32_t GetWindowModeSupportType() const; 140 std::unordered_map<WindowType, SystemBarProperty> GetSystemBarProperty() const; 141 bool IsDecorEnable(); 142 uint32_t GetAnimationFlag() const; 143 const Transform& GetTransform() const; 144 bool IsFloatingWindowAppType() const; 145 void GetTouchHotAreas(std::vector<Rect>& rects) 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 217 /** 218 * PC Window 219 */ 220 void SetSupportWindowModes(const std::vector<AppExecFwk::SupportWindowMode>& supportWindowModes); 221 void GetSupportWindowModes(std::vector<AppExecFwk::SupportWindowMode>& supportWindowModes) const; 222 223 private: 224 bool MarshallingTouchHotAreas(Parcel& parcel) const; 225 static void UnmarshallingTouchHotAreas(Parcel& parcel, WindowSessionProperty* property); 226 bool WriteActionUpdateTurnScreenOn(Parcel& parcel); 227 bool WriteActionUpdateKeepScreenOn(Parcel& parcel); 228 bool WriteActionUpdateFocusable(Parcel& parcel); 229 bool WriteActionUpdateTouchable(Parcel& parcel); 230 bool WriteActionUpdateSetBrightness(Parcel& parcel); 231 bool WriteActionUpdateOrientation(Parcel& parcel); 232 bool WriteActionUpdatePrivacyMode(Parcel& parcel); 233 bool WriteActionUpdateSnapshotSkip(Parcel& parcel); 234 bool WriteActionUpdateMaximizeState(Parcel& parcel); 235 bool WriteActionUpdateSystemBar(Parcel& parcel); 236 bool WriteActionUpdateFlags(Parcel& parcel); 237 bool WriteActionUpdateMode(Parcel& parcel); 238 bool WriteActionUpdateAnimationFlag(Parcel& parcel); 239 bool WriteActionUpdateTouchHotArea(Parcel& parcel); 240 bool WriteActionUpdateDecorEnable(Parcel& parcel); 241 bool WriteActionUpdateWindowLimits(Parcel& parcel); 242 bool WriteActionUpdateDragenabled(Parcel& parcel); 243 bool WriteActionUpdateRaiseenabled(Parcel& parcel); 244 bool WriteActionUpdateHideNonSystemFloatingWindows(Parcel& parcel); 245 bool WriteActionUpdateTextfieldAvoidInfo(Parcel& parcel); 246 bool WriteActionUpdateWindowMask(Parcel& parcel); 247 bool WriteActionUpdateTopmost(Parcel& parcel); 248 bool WriteActionUpdateMainWindowTopmost(Parcel& parcel); 249 bool WriteActionUpdateWindowModeSupportType(Parcel& parcel); 250 void ReadActionUpdateTurnScreenOn(Parcel& parcel); 251 void ReadActionUpdateKeepScreenOn(Parcel& parcel); 252 void ReadActionUpdateFocusable(Parcel& parcel); 253 void ReadActionUpdateTouchable(Parcel& parcel); 254 void ReadActionUpdateSetBrightness(Parcel& parcel); 255 void ReadActionUpdateOrientation(Parcel& parcel); 256 void ReadActionUpdatePrivacyMode(Parcel& parcel); 257 void ReadActionUpdateSnapshotSkip(Parcel& parcel); 258 void ReadActionUpdateMaximizeState(Parcel& parcel); 259 void ReadActionUpdateSystemBar(Parcel& parcel); 260 void ReadActionUpdateFlags(Parcel& parcel); 261 void ReadActionUpdateMode(Parcel& parcel); 262 void ReadActionUpdateAnimationFlag(Parcel& parcel); 263 void ReadActionUpdateTouchHotArea(Parcel& parcel); 264 void ReadActionUpdateDecorEnable(Parcel& parcel); 265 void ReadActionUpdateWindowLimits(Parcel& parcel); 266 void ReadActionUpdateDragenabled(Parcel& parcel); 267 void ReadActionUpdateRaiseenabled(Parcel& parcel); 268 void ReadActionUpdateHideNonSystemFloatingWindows(Parcel& parcel); 269 void ReadActionUpdateTextfieldAvoidInfo(Parcel& parcel); 270 void ReadActionUpdateWindowMask(Parcel& parcel); 271 void ReadActionUpdateTopmost(Parcel& parcel); 272 void ReadActionUpdateMainWindowTopmost(Parcel& parcel); 273 void ReadActionUpdateWindowModeSupportType(Parcel& parcel); 274 std::string windowName_; 275 SessionInfo sessionInfo_; 276 mutable std::mutex requestRectMutex_; 277 Rect requestRect_ { 0, 0, 0, 0 }; // window rect requested by the client (without decoration size) 278 mutable std::mutex windowRectMutex_; 279 Rect windowRect_ { 0, 0, 0, 0 }; // actual window rect 280 WindowType type_ { WindowType::WINDOW_TYPE_APP_MAIN_WINDOW }; // type main window 281 bool focusable_ { true }; 282 bool focusableOnShow_ { true }; 283 bool touchable_ { true }; 284 bool dragEnabled_ = { true }; 285 bool raiseEnabled_ = { true }; 286 bool isSystemCalling_ = { false }; 287 bool tokenState_ { false }; 288 bool turnScreenOn_ = false; 289 bool keepScreenOn_ = false; 290 bool topmost_ = false; 291 bool mainWindowTopmost_ = false; 292 Orientation requestedOrientation_ = Orientation::UNSPECIFIED; 293 Orientation defaultRequestedOrientation_ = Orientation::UNSPECIFIED; // only accessed on SSM thread 294 bool isPrivacyMode_ { false }; 295 bool isSystemPrivacyMode_ { false }; 296 bool isSnapshotSkip_ { false }; 297 float brightness_ = UNDEFINED_BRIGHTNESS; 298 uint64_t displayId_ = 0; 299 int32_t parentId_ = INVALID_SESSION_ID; // parentId of sceneSession, which is low 32 bite of parentPersistentId_ 300 uint32_t flags_ = 0; 301 int32_t persistentId_ = INVALID_SESSION_ID; 302 int32_t parentPersistentId_ = INVALID_SESSION_ID; 303 uint32_t accessTokenId_ = INVALID_SESSION_ID; 304 MaximizeMode maximizeMode_ = MaximizeMode::MODE_RECOVER; 305 WindowMode windowMode_ = WindowMode::WINDOW_MODE_FULLSCREEN; 306 WindowState windowState_ = WindowState::STATE_INITIAL; 307 WindowLimits limits_; 308 WindowLimits userLimits_; 309 WindowLimits configLimitsVP_; 310 float lastVpr_ = 0.0f; 311 PiPTemplateInfo pipTemplateInfo_ = {0, 0, {}}; 312 KeyboardLayoutParams keyboardLayoutParams_; 313 uint32_t windowModeSupportType_ {WindowModeSupport::WINDOW_MODE_SUPPORT_ALL}; 314 std::unordered_map<WindowType, SystemBarProperty> sysBarPropMap_ { 315 { WindowType::WINDOW_TYPE_STATUS_BAR, SystemBarProperty(true, 0x00FFFFFF, 0xFF000000) }, 316 { WindowType::WINDOW_TYPE_NAVIGATION_BAR, SystemBarProperty(true, 0x00FFFFFF, 0xFF000000) }, 317 { WindowType::WINDOW_TYPE_NAVIGATION_INDICATOR, SystemBarProperty(true, 0x00FFFFFF, 0xFF000000) }, 318 }; 319 bool isDecorEnable_ = false; 320 uint32_t animationFlag_ { static_cast<uint32_t>(WindowAnimation::DEFAULT) }; 321 // Transform info 322 Transform trans_; 323 bool isFloatingWindowAppType_ = false; 324 mutable std::mutex touchHotAreasMutex_; 325 std::vector<Rect> touchHotAreas_; // coordinates relative to window. 326 bool hideNonSystemFloatingWindows_ = false; 327 bool forceHide_ = false; 328 bool keepKeyboardFlag_ = false; 329 uint32_t callingSessionId_ = INVALID_SESSION_ID; 330 331 double textFieldPositionY_ = 0.0; 332 double textFieldHeight_ = 0.0; 333 334 bool isNeedUpdateWindowMode_ = false; 335 std::function<void()> touchHotAreasChangeCallback_; 336 bool isLayoutFullScreen_ = false; 337 338 bool isShaped_ = false; 339 bool fullScreenStart_ = false; 340 std::shared_ptr<Media::PixelMap> windowMask_ = nullptr; 341 int32_t collaboratorType_ = CollaboratorType::DEFAULT_TYPE; 342 static const std::map<uint32_t, HandlWritePropertyFunc> writeFuncMap_; 343 static const std::map<uint32_t, HandlReadPropertyFunc> readFuncMap_; 344 bool compatibleModeInPc_ = false; 345 int32_t compatibleInPcPortraitWidth_ = 0; 346 int32_t compatibleInPcPortraitHeight_ = 0; 347 int32_t compatibleInPcLandscapeWidth_ = 0; 348 int32_t compatibleInPcLandscapeHeight_ = 0; 349 bool isAppSupportPhoneInPc_ = false; 350 bool isSupportDragInPcCompatibleMode_ = false; 351 bool isPcAppInPad_ = false; 352 mutable std::mutex compatibleModeMutex_; 353 bool compatibleModeEnableInPad_ = false; 354 355 /** 356 * Sub Window 357 */ 358 uint32_t subWindowLevel_ = 1; 359 360 /* 361 * UIExtension 362 */ 363 int32_t realParentId_ = INVALID_SESSION_ID; 364 UIExtensionUsage uiExtensionUsage_ { UIExtensionUsage::EMBEDDED }; 365 bool isExtensionFlag_ = false; 366 bool isUIExtensionSubWindowFlag_ = false; 367 bool isUIExtensionAbilityProcess_ = false; 368 WindowType parentWindowType_ = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW; 369 370 /** 371 * PC Window 372 */ 373 mutable std::mutex supportWindowModesMutex_; 374 std::vector<AppExecFwk::SupportWindowMode> supportWindowModes_; 375 }; 376 377 struct FreeMultiWindowConfig : public Parcelable { 378 bool isSystemDecorEnable_ = true; 379 uint32_t decorWindowModeSupportType_ = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL; 380 WindowMode defaultWindowMode_ = WindowMode::WINDOW_MODE_FULLSCREEN; 381 uint32_t maxMainFloatingWindowNumber_ = 0; 382 MarshallingFreeMultiWindowConfig383 virtual bool Marshalling(Parcel& parcel) const override 384 { 385 if (!parcel.WriteBool(isSystemDecorEnable_) || 386 !parcel.WriteUint32(decorWindowModeSupportType_)) { 387 return false; 388 } 389 390 if (!parcel.WriteUint32(static_cast<uint32_t>(defaultWindowMode_)) || 391 !parcel.WriteUint32(maxMainFloatingWindowNumber_)) { 392 return false; 393 } 394 return true; 395 } 396 UnmarshallingFreeMultiWindowConfig397 static FreeMultiWindowConfig* Unmarshalling(Parcel& parcel) 398 { 399 FreeMultiWindowConfig* config = new (std::nothrow) FreeMultiWindowConfig(); 400 if (config == nullptr) { 401 return nullptr; 402 } 403 config->isSystemDecorEnable_ = parcel.ReadBool(); 404 config->decorWindowModeSupportType_ = parcel.ReadUint32(); 405 config->defaultWindowMode_ = static_cast<WindowMode>(parcel.ReadUint32()); 406 config->maxMainFloatingWindowNumber_ = parcel.ReadUint32(); 407 return config; 408 } 409 }; 410 411 struct AppForceLandscapeConfig : public Parcelable { 412 int32_t mode_ = 0; 413 std::string homePage_; 414 AppForceLandscapeConfigAppForceLandscapeConfig415 AppForceLandscapeConfig() {} AppForceLandscapeConfigAppForceLandscapeConfig416 AppForceLandscapeConfig(int32_t mode, const std::string& homePage) : mode_(mode), homePage_(homePage) {} 417 MarshallingAppForceLandscapeConfig418 virtual bool Marshalling(Parcel& parcel) const override 419 { 420 if (!parcel.WriteInt32(mode_) || 421 !parcel.WriteString(homePage_)) { 422 return false; 423 } 424 return true; 425 } 426 UnmarshallingAppForceLandscapeConfig427 static AppForceLandscapeConfig* Unmarshalling(Parcel& parcel) 428 { 429 AppForceLandscapeConfig* config = new (std::nothrow) AppForceLandscapeConfig(); 430 if (config == nullptr) { 431 return nullptr; 432 } 433 config->mode_ = parcel.ReadInt32(); 434 config->homePage_ = parcel.ReadString(); 435 return config; 436 } 437 }; 438 439 struct SystemSessionConfig : public Parcelable { 440 bool isSystemDecorEnable_ = true; 441 uint32_t decorWindowModeSupportType_ = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL; 442 bool isStretchable_ = false; 443 WindowMode defaultWindowMode_ = WindowMode::WINDOW_MODE_FULLSCREEN; 444 KeyboardAnimationCurve animationIn_; 445 KeyboardAnimationCurve animationOut_; 446 // 1920: default max window size 447 uint32_t maxFloatingWindowSize_ = 1920; 448 // 320: default minWidth main window size 449 uint32_t miniWidthOfMainWindow_ = 320; 450 // 240: default minHeight main window size 451 uint32_t miniHeightOfMainWindow_ = 240; 452 // 320: default minWidth sub window size 453 uint32_t miniWidthOfSubWindow_ = 320; 454 // 240: default minHeight sub window size 455 uint32_t miniHeightOfSubWindow_ = 240; 456 bool backgroundswitch = false; 457 bool freeMultiWindowEnable_ = false; 458 bool freeMultiWindowSupport_ = false; 459 FreeMultiWindowConfig freeMultiWindowConfig_; 460 std::string uiType_; 461 bool supportTypeFloatWindow_ = false; 462 // 4: default max mid scene num 463 uint32_t maxMidSceneNum_ = 4; 464 MarshallingSystemSessionConfig465 virtual bool Marshalling(Parcel& parcel) const override 466 { 467 if (!parcel.WriteBool(isSystemDecorEnable_) || !parcel.WriteBool(isStretchable_) || 468 !parcel.WriteUint32(decorWindowModeSupportType_)) { 469 return false; 470 } 471 472 if (!parcel.WriteUint32(static_cast<uint32_t>(defaultWindowMode_)) || 473 !parcel.WriteParcelable(&animationIn_) || !parcel.WriteParcelable(&animationOut_) || 474 !parcel.WriteUint32(maxFloatingWindowSize_)) { 475 return false; 476 } 477 478 if (!parcel.WriteUint32(miniWidthOfMainWindow_) || !parcel.WriteUint32(miniHeightOfMainWindow_) || 479 !parcel.WriteUint32(miniWidthOfSubWindow_) || !parcel.WriteUint32(miniHeightOfSubWindow_)) { 480 return false; 481 } 482 483 if (!parcel.WriteBool(backgroundswitch)) { 484 return false; 485 } 486 487 if (!parcel.WriteBool(freeMultiWindowEnable_)) { 488 return false; 489 } 490 491 if (!parcel.WriteBool(freeMultiWindowSupport_)) { 492 return false; 493 } 494 if (!parcel.WriteParcelable(&freeMultiWindowConfig_)) { 495 return false; 496 } 497 if (!parcel.WriteString(uiType_)) { 498 return false; 499 } 500 if (!parcel.WriteBool(supportTypeFloatWindow_)) { 501 return false; 502 } 503 if (!parcel.WriteBool(maxMidSceneNum_)) { 504 return false; 505 } 506 return true; 507 } 508 UnmarshallingSystemSessionConfig509 static SystemSessionConfig* Unmarshalling(Parcel& parcel) 510 { 511 SystemSessionConfig* config = new (std::nothrow) SystemSessionConfig(); 512 if (config == nullptr) { 513 return nullptr; 514 } 515 config->isSystemDecorEnable_ = parcel.ReadBool(); 516 config->isStretchable_ = parcel.ReadBool(); 517 config->decorWindowModeSupportType_ = parcel.ReadUint32(); 518 config->defaultWindowMode_ = static_cast<WindowMode>(parcel.ReadUint32()); 519 sptr<KeyboardAnimationCurve> animationIn = parcel.ReadParcelable<KeyboardAnimationCurve>(); 520 if (animationIn == nullptr) { 521 delete config; 522 return nullptr; 523 } 524 config->animationIn_ = *animationIn; 525 sptr<KeyboardAnimationCurve> animationOut = parcel.ReadParcelable<KeyboardAnimationCurve>(); 526 if (animationOut == nullptr) { 527 delete config; 528 return nullptr; 529 } 530 config->animationOut_ = *animationOut; 531 config->maxFloatingWindowSize_ = parcel.ReadUint32(); 532 config->miniWidthOfMainWindow_ = parcel.ReadUint32(); 533 config->miniHeightOfMainWindow_ = parcel.ReadUint32(); 534 config->miniWidthOfSubWindow_ = parcel.ReadUint32(); 535 config->miniHeightOfSubWindow_ = parcel.ReadUint32(); 536 config->backgroundswitch = parcel.ReadBool(); 537 config->freeMultiWindowEnable_ = parcel.ReadBool(); 538 config->freeMultiWindowSupport_ = parcel.ReadBool(); 539 sptr<FreeMultiWindowConfig> freeMultiWindowConfig = parcel.ReadParcelable<FreeMultiWindowConfig>(); 540 if (freeMultiWindowConfig == nullptr) { 541 delete config; 542 return nullptr; 543 } 544 config->freeMultiWindowConfig_ = *freeMultiWindowConfig; 545 config->uiType_ = parcel.ReadString(); 546 config->supportTypeFloatWindow_ = parcel.ReadBool(); 547 config->maxMidSceneNum_ = parcel.ReadUint32(); 548 return config; 549 } 550 IsFreeMultiWindowModeSystemSessionConfig551 bool IsFreeMultiWindowMode() const 552 { 553 return freeMultiWindowEnable_ && freeMultiWindowSupport_; 554 } 555 }; 556 } // namespace Rosen 557 } // namespace OHOS 558 #endif // OHOS_ROSEN_WINDOW_PROPERTY_H 559