1eace7efcSopenharmony_ci/* 2eace7efcSopenharmony_ci * Copyright (c) 2021-2024 Huawei Device Co., Ltd. 3eace7efcSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4eace7efcSopenharmony_ci * you may not use this file except in compliance with the License. 5eace7efcSopenharmony_ci * You may obtain a copy of the License at 6eace7efcSopenharmony_ci * 7eace7efcSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8eace7efcSopenharmony_ci * 9eace7efcSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10eace7efcSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11eace7efcSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12eace7efcSopenharmony_ci * See the License for the specific language governing permissions and 13eace7efcSopenharmony_ci * limitations under the License. 14eace7efcSopenharmony_ci */ 15eace7efcSopenharmony_ci 16eace7efcSopenharmony_ci#include "start_options.h" 17eace7efcSopenharmony_ci 18eace7efcSopenharmony_ci#include "hilog_tag_wrapper.h" 19eace7efcSopenharmony_ci#include "process_options.h" 20eace7efcSopenharmony_ci#include "start_window_option.h" 21eace7efcSopenharmony_ci 22eace7efcSopenharmony_cinamespace OHOS { 23eace7efcSopenharmony_cinamespace AAFwk { 24eace7efcSopenharmony_ciStartOptions::StartOptions(const StartOptions &other) 25eace7efcSopenharmony_ci{ 26eace7efcSopenharmony_ci windowMode_ = other.windowMode_; 27eace7efcSopenharmony_ci displayId_ = other.displayId_; 28eace7efcSopenharmony_ci withAnimation_ = other.withAnimation_; 29eace7efcSopenharmony_ci windowLeft_ = other.windowLeft_; 30eace7efcSopenharmony_ci windowTop_ = other.windowTop_; 31eace7efcSopenharmony_ci windowWidth_ = other.windowWidth_; 32eace7efcSopenharmony_ci windowHeight_ = other.windowHeight_; 33eace7efcSopenharmony_ci windowLeftUsed_ = other.windowLeftUsed_; 34eace7efcSopenharmony_ci windowTopUsed_ = other.windowTopUsed_; 35eace7efcSopenharmony_ci windowWidthUsed_ = other.windowWidthUsed_; 36eace7efcSopenharmony_ci windowHeightUsed_ = other.windowHeightUsed_; 37eace7efcSopenharmony_ci processOptions = other.processOptions; 38eace7efcSopenharmony_ci windowFocused_ = other.windowFocused_; 39eace7efcSopenharmony_ci startWindowOption = other.startWindowOption; 40eace7efcSopenharmony_ci} 41eace7efcSopenharmony_ci 42eace7efcSopenharmony_ciStartOptions &StartOptions::operator=(const StartOptions &other) 43eace7efcSopenharmony_ci{ 44eace7efcSopenharmony_ci if (this != &other) { 45eace7efcSopenharmony_ci windowMode_ = other.windowMode_; 46eace7efcSopenharmony_ci displayId_ = other.displayId_; 47eace7efcSopenharmony_ci withAnimation_ = other.withAnimation_; 48eace7efcSopenharmony_ci windowLeft_ = other.windowLeft_; 49eace7efcSopenharmony_ci windowTop_ = other.windowTop_; 50eace7efcSopenharmony_ci windowWidth_ = other.windowWidth_; 51eace7efcSopenharmony_ci windowHeight_ = other.windowHeight_; 52eace7efcSopenharmony_ci windowLeftUsed_ = other.windowLeftUsed_; 53eace7efcSopenharmony_ci windowTopUsed_ = other.windowTopUsed_; 54eace7efcSopenharmony_ci windowWidthUsed_ = other.windowWidthUsed_; 55eace7efcSopenharmony_ci windowHeightUsed_ = other.windowHeightUsed_; 56eace7efcSopenharmony_ci processOptions = other.processOptions; 57eace7efcSopenharmony_ci windowFocused_ = other.windowFocused_; 58eace7efcSopenharmony_ci startWindowOption = other.startWindowOption; 59eace7efcSopenharmony_ci } 60eace7efcSopenharmony_ci return *this; 61eace7efcSopenharmony_ci} 62eace7efcSopenharmony_ci 63eace7efcSopenharmony_cibool StartOptions::ReadFromParcel(Parcel &parcel) 64eace7efcSopenharmony_ci{ 65eace7efcSopenharmony_ci SetWindowMode(parcel.ReadInt32()); 66eace7efcSopenharmony_ci SetDisplayID(parcel.ReadInt32()); 67eace7efcSopenharmony_ci SetWithAnimation(parcel.ReadBool()); 68eace7efcSopenharmony_ci SetWindowLeft(parcel.ReadInt32()); 69eace7efcSopenharmony_ci SetWindowTop(parcel.ReadInt32()); 70eace7efcSopenharmony_ci SetWindowWidth(parcel.ReadInt32()); 71eace7efcSopenharmony_ci SetWindowHeight(parcel.ReadInt32()); 72eace7efcSopenharmony_ci SetWindowFocused(parcel.ReadBool()); 73eace7efcSopenharmony_ci windowLeftUsed_ = parcel.ReadBool(); 74eace7efcSopenharmony_ci windowTopUsed_ = parcel.ReadBool(); 75eace7efcSopenharmony_ci windowWidthUsed_ = parcel.ReadBool(); 76eace7efcSopenharmony_ci windowHeightUsed_ = parcel.ReadBool(); 77eace7efcSopenharmony_ci processOptions.reset(parcel.ReadParcelable<ProcessOptions>()); 78eace7efcSopenharmony_ci startWindowOption.reset(parcel.ReadParcelable<StartWindowOption>()); 79eace7efcSopenharmony_ci return true; 80eace7efcSopenharmony_ci} 81eace7efcSopenharmony_ci 82eace7efcSopenharmony_ciStartOptions *StartOptions::Unmarshalling(Parcel &parcel) 83eace7efcSopenharmony_ci{ 84eace7efcSopenharmony_ci StartOptions *option = new (std::nothrow) StartOptions(); 85eace7efcSopenharmony_ci if (option == nullptr) { 86eace7efcSopenharmony_ci return nullptr; 87eace7efcSopenharmony_ci } 88eace7efcSopenharmony_ci 89eace7efcSopenharmony_ci if (!option->ReadFromParcel(parcel)) { 90eace7efcSopenharmony_ci delete option; 91eace7efcSopenharmony_ci option = nullptr; 92eace7efcSopenharmony_ci } 93eace7efcSopenharmony_ci 94eace7efcSopenharmony_ci return option; 95eace7efcSopenharmony_ci} 96eace7efcSopenharmony_ci 97eace7efcSopenharmony_cibool StartOptions::Marshalling(Parcel &parcel) const 98eace7efcSopenharmony_ci{ 99eace7efcSopenharmony_ci parcel.WriteInt32(GetWindowMode()); 100eace7efcSopenharmony_ci parcel.WriteInt32(GetDisplayID()); 101eace7efcSopenharmony_ci parcel.WriteBool(GetWithAnimation()); 102eace7efcSopenharmony_ci parcel.WriteInt32(GetWindowLeft()); 103eace7efcSopenharmony_ci parcel.WriteInt32(GetWindowTop()); 104eace7efcSopenharmony_ci parcel.WriteInt32(GetWindowWidth()); 105eace7efcSopenharmony_ci parcel.WriteInt32(GetWindowHeight()); 106eace7efcSopenharmony_ci parcel.WriteBool(GetWindowFocused()); 107eace7efcSopenharmony_ci parcel.WriteBool(windowLeftUsed_); 108eace7efcSopenharmony_ci parcel.WriteBool(windowTopUsed_); 109eace7efcSopenharmony_ci parcel.WriteBool(windowWidthUsed_); 110eace7efcSopenharmony_ci parcel.WriteBool(windowHeightUsed_); 111eace7efcSopenharmony_ci if (!parcel.WriteParcelable(processOptions.get())) { 112eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "write processOptions failed"); 113eace7efcSopenharmony_ci return false; 114eace7efcSopenharmony_ci } 115eace7efcSopenharmony_ci if (!parcel.WriteParcelable(startWindowOption.get())) { 116eace7efcSopenharmony_ci TAG_LOGE(AAFwkTag::ABILITYMGR, "write startWindowOption failed"); 117eace7efcSopenharmony_ci return false; 118eace7efcSopenharmony_ci } 119eace7efcSopenharmony_ci return true; 120eace7efcSopenharmony_ci} 121eace7efcSopenharmony_ci 122eace7efcSopenharmony_civoid StartOptions::SetWindowMode(int32_t windowMode) 123eace7efcSopenharmony_ci{ 124eace7efcSopenharmony_ci windowMode_ = windowMode; 125eace7efcSopenharmony_ci} 126eace7efcSopenharmony_ci 127eace7efcSopenharmony_ciint32_t StartOptions::GetWindowMode() const 128eace7efcSopenharmony_ci{ 129eace7efcSopenharmony_ci return windowMode_; 130eace7efcSopenharmony_ci} 131eace7efcSopenharmony_ci 132eace7efcSopenharmony_civoid StartOptions::SetDisplayID(int32_t id) 133eace7efcSopenharmony_ci{ 134eace7efcSopenharmony_ci displayId_ = id; 135eace7efcSopenharmony_ci} 136eace7efcSopenharmony_ci 137eace7efcSopenharmony_ciint32_t StartOptions::GetDisplayID() const 138eace7efcSopenharmony_ci{ 139eace7efcSopenharmony_ci return displayId_; 140eace7efcSopenharmony_ci} 141eace7efcSopenharmony_ci 142eace7efcSopenharmony_civoid StartOptions::SetWithAnimation(bool withAnimation) 143eace7efcSopenharmony_ci{ 144eace7efcSopenharmony_ci withAnimation_ = withAnimation; 145eace7efcSopenharmony_ci} 146eace7efcSopenharmony_ci 147eace7efcSopenharmony_cibool StartOptions::GetWithAnimation() const 148eace7efcSopenharmony_ci{ 149eace7efcSopenharmony_ci return withAnimation_; 150eace7efcSopenharmony_ci} 151eace7efcSopenharmony_ci 152eace7efcSopenharmony_civoid StartOptions::SetWindowLeft(int32_t windowLeft) 153eace7efcSopenharmony_ci{ 154eace7efcSopenharmony_ci windowLeft_ = windowLeft; 155eace7efcSopenharmony_ci} 156eace7efcSopenharmony_ci 157eace7efcSopenharmony_ciint32_t StartOptions::GetWindowLeft() const 158eace7efcSopenharmony_ci{ 159eace7efcSopenharmony_ci return windowLeft_; 160eace7efcSopenharmony_ci} 161eace7efcSopenharmony_ci 162eace7efcSopenharmony_civoid StartOptions::SetWindowTop(int32_t windowTop) 163eace7efcSopenharmony_ci{ 164eace7efcSopenharmony_ci windowTop_ = windowTop; 165eace7efcSopenharmony_ci} 166eace7efcSopenharmony_ci 167eace7efcSopenharmony_ciint32_t StartOptions::GetWindowTop() const 168eace7efcSopenharmony_ci{ 169eace7efcSopenharmony_ci return windowTop_; 170eace7efcSopenharmony_ci} 171eace7efcSopenharmony_ci 172eace7efcSopenharmony_civoid StartOptions::SetWindowWidth(int32_t windowWidth) 173eace7efcSopenharmony_ci{ 174eace7efcSopenharmony_ci windowWidth_ = windowWidth; 175eace7efcSopenharmony_ci} 176eace7efcSopenharmony_ci 177eace7efcSopenharmony_ciint32_t StartOptions::GetWindowWidth() const 178eace7efcSopenharmony_ci{ 179eace7efcSopenharmony_ci return windowWidth_; 180eace7efcSopenharmony_ci} 181eace7efcSopenharmony_ci 182eace7efcSopenharmony_civoid StartOptions::SetWindowHeight(int32_t windowHeight) 183eace7efcSopenharmony_ci{ 184eace7efcSopenharmony_ci windowHeight_ = windowHeight; 185eace7efcSopenharmony_ci} 186eace7efcSopenharmony_ci 187eace7efcSopenharmony_ciint32_t StartOptions::GetWindowHeight() const 188eace7efcSopenharmony_ci{ 189eace7efcSopenharmony_ci return windowHeight_; 190eace7efcSopenharmony_ci} 191eace7efcSopenharmony_ci 192eace7efcSopenharmony_civoid StartOptions::SetWindowFocused(bool windowFocused) 193eace7efcSopenharmony_ci{ 194eace7efcSopenharmony_ci windowFocused_ = windowFocused; 195eace7efcSopenharmony_ci} 196eace7efcSopenharmony_ci 197eace7efcSopenharmony_ciint32_t StartOptions::GetWindowFocused() const 198eace7efcSopenharmony_ci{ 199eace7efcSopenharmony_ci return windowFocused_; 200eace7efcSopenharmony_ci} 201eace7efcSopenharmony_ci} // namespace AAFwk 202eace7efcSopenharmony_ci} // namespace OHOS 203