1 /* 2 * Copyright (c) 2021-2024 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 #include "start_options.h" 17 18 #include "hilog_tag_wrapper.h" 19 #include "process_options.h" 20 21 namespace OHOS { 22 namespace AAFwk { StartOptions(const StartOptions & other)23StartOptions::StartOptions(const StartOptions &other) 24 { 25 windowMode_ = other.windowMode_; 26 displayId_ = other.displayId_; 27 withAnimation_ = other.withAnimation_; 28 windowLeft_ = other.windowLeft_; 29 windowTop_ = other.windowTop_; 30 windowWidth_ = other.windowWidth_; 31 windowHeight_ = other.windowHeight_; 32 windowLeftUsed_ = other.windowLeftUsed_; 33 windowTopUsed_ = other.windowTopUsed_; 34 windowWidthUsed_ = other.windowWidthUsed_; 35 windowHeightUsed_ = other.windowHeightUsed_; 36 processOptions = other.processOptions; 37 windowFocused_ = other.windowFocused_; 38 } 39 operator =(const StartOptions & other)40StartOptions &StartOptions::operator=(const StartOptions &other) 41 { 42 if (this != &other) { 43 windowMode_ = other.windowMode_; 44 displayId_ = other.displayId_; 45 withAnimation_ = other.withAnimation_; 46 windowLeft_ = other.windowLeft_; 47 windowTop_ = other.windowTop_; 48 windowWidth_ = other.windowWidth_; 49 windowHeight_ = other.windowHeight_; 50 windowLeftUsed_ = other.windowLeftUsed_; 51 windowTopUsed_ = other.windowTopUsed_; 52 windowWidthUsed_ = other.windowWidthUsed_; 53 windowHeightUsed_ = other.windowHeightUsed_; 54 processOptions = other.processOptions; 55 windowFocused_ = other.windowFocused_; 56 } 57 return *this; 58 } 59 ReadFromParcel(Parcel & parcel)60bool StartOptions::ReadFromParcel(Parcel &parcel) 61 { 62 SetWindowMode(parcel.ReadInt32()); 63 SetDisplayID(parcel.ReadInt32()); 64 SetWithAnimation(parcel.ReadBool()); 65 SetWindowLeft(parcel.ReadInt32()); 66 SetWindowTop(parcel.ReadInt32()); 67 SetWindowWidth(parcel.ReadInt32()); 68 SetWindowHeight(parcel.ReadInt32()); 69 SetWindowFocused(parcel.ReadBool()); 70 windowLeftUsed_ = parcel.ReadBool(); 71 windowTopUsed_ = parcel.ReadBool(); 72 windowWidthUsed_ = parcel.ReadBool(); 73 windowHeightUsed_ = parcel.ReadBool(); 74 processOptions.reset(parcel.ReadParcelable<ProcessOptions>()); 75 return true; 76 } 77 Unmarshalling(Parcel & parcel)78StartOptions *StartOptions::Unmarshalling(Parcel &parcel) 79 { 80 StartOptions *option = new (std::nothrow) StartOptions(); 81 if (option == nullptr) { 82 return nullptr; 83 } 84 85 if (!option->ReadFromParcel(parcel)) { 86 delete option; 87 option = nullptr; 88 } 89 90 return option; 91 } 92 Marshalling(Parcel & parcel) const93bool StartOptions::Marshalling(Parcel &parcel) const 94 { 95 parcel.WriteInt32(GetWindowMode()); 96 parcel.WriteInt32(GetDisplayID()); 97 parcel.WriteBool(GetWithAnimation()); 98 parcel.WriteInt32(GetWindowLeft()); 99 parcel.WriteInt32(GetWindowTop()); 100 parcel.WriteInt32(GetWindowWidth()); 101 parcel.WriteInt32(GetWindowHeight()); 102 parcel.WriteBool(GetWindowFocused()); 103 parcel.WriteBool(windowLeftUsed_); 104 parcel.WriteBool(windowTopUsed_); 105 parcel.WriteBool(windowWidthUsed_); 106 parcel.WriteBool(windowHeightUsed_); 107 if (!parcel.WriteParcelable(processOptions.get())) { 108 TAG_LOGE(AAFwkTag::ABILITYMGR, "Write processOptions failed."); 109 return false; 110 } 111 return true; 112 } 113 SetWindowMode(int32_t windowMode)114void StartOptions::SetWindowMode(int32_t windowMode) 115 { 116 windowMode_ = windowMode; 117 } 118 GetWindowMode() const119int32_t StartOptions::GetWindowMode() const 120 { 121 return windowMode_; 122 } 123 SetDisplayID(int32_t id)124void StartOptions::SetDisplayID(int32_t id) 125 { 126 displayId_ = id; 127 } 128 GetDisplayID() const129int32_t StartOptions::GetDisplayID() const 130 { 131 return displayId_; 132 } 133 SetWithAnimation(bool withAnimation)134void StartOptions::SetWithAnimation(bool withAnimation) 135 { 136 withAnimation_ = withAnimation; 137 } 138 GetWithAnimation() const139bool StartOptions::GetWithAnimation() const 140 { 141 return withAnimation_; 142 } 143 SetWindowLeft(int32_t windowLeft)144void StartOptions::SetWindowLeft(int32_t windowLeft) 145 { 146 windowLeft_ = windowLeft; 147 } 148 GetWindowLeft() const149int32_t StartOptions::GetWindowLeft() const 150 { 151 return windowLeft_; 152 } 153 SetWindowTop(int32_t windowTop)154void StartOptions::SetWindowTop(int32_t windowTop) 155 { 156 windowTop_ = windowTop; 157 } 158 GetWindowTop() const159int32_t StartOptions::GetWindowTop() const 160 { 161 return windowTop_; 162 } 163 SetWindowWidth(int32_t windowWidth)164void StartOptions::SetWindowWidth(int32_t windowWidth) 165 { 166 windowWidth_ = windowWidth; 167 } 168 GetWindowWidth() const169int32_t StartOptions::GetWindowWidth() const 170 { 171 return windowWidth_; 172 } 173 SetWindowHeight(int32_t windowHeight)174void StartOptions::SetWindowHeight(int32_t windowHeight) 175 { 176 windowHeight_ = windowHeight; 177 } 178 GetWindowHeight() const179int32_t StartOptions::GetWindowHeight() const 180 { 181 return windowHeight_; 182 } 183 SetWindowFocused(bool windowFocused)184void StartOptions::SetWindowFocused(bool windowFocused) 185 { 186 windowFocused_ = windowFocused; 187 } 188 GetWindowFocused() const189int32_t StartOptions::GetWindowFocused() const 190 { 191 return windowFocused_; 192 } 193 } // namespace AAFwk 194 } // namespace OHOS 195