1 /* 2 * Copyright (c) 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_window_option.h" 17 #include "hilog_tag_wrapper.h" 18 19 #ifdef START_WINDOW_OPTIONS_WITH_PIXELMAP 20 #include "pixel_map.h" 21 #endif 22 23 namespace OHOS { 24 namespace AAFwk { ReadFromParcel(Parcel & parcel)25bool StartWindowOption::ReadFromParcel(Parcel &parcel) 26 { 27 hasStartWindow = parcel.ReadBool(); 28 startWindowBackgroundColor = parcel.ReadString(); 29 #ifdef START_WINDOW_OPTIONS_WITH_PIXELMAP 30 std::shared_ptr<Media::PixelMap> pixelMap(parcel.ReadParcelable<Media::PixelMap>()); 31 startWindowIcon = pixelMap; 32 #endif 33 return true; 34 } 35 Unmarshalling(Parcel & parcel)36StartWindowOption *StartWindowOption::Unmarshalling(Parcel &parcel) 37 { 38 StartWindowOption *option = new (std::nothrow) StartWindowOption(); 39 if (option == nullptr) { 40 return nullptr; 41 } 42 43 if (!option->ReadFromParcel(parcel)) { 44 delete option; 45 option = nullptr; 46 } 47 48 return option; 49 } 50 Marshalling(Parcel & parcel) const51bool StartWindowOption::Marshalling(Parcel &parcel) const 52 { 53 if (!parcel.WriteBool(hasStartWindow)) { 54 TAG_LOGE(AAFwkTag::ABILITYMGR, "hasStartWindow write failed"); 55 return false; 56 } 57 if (!parcel.WriteString(startWindowBackgroundColor)) { 58 TAG_LOGE(AAFwkTag::ABILITYMGR, "startWindowBackgroundColor write failed"); 59 return false; 60 } 61 #ifdef START_WINDOW_OPTIONS_WITH_PIXELMAP 62 if (!parcel.WriteParcelable(startWindowIcon.get())) { 63 TAG_LOGE(AAFwkTag::ABILITYMGR, "startWindowIcon write failed"); 64 return false; 65 } 66 #endif 67 return true; 68 } 69 } // namespace AAFwk 70 } // namespace OHOS