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 "ui_extension_host_info.h" 17 #include "hilog_tag_wrapper.h" 18 19 namespace OHOS { 20 namespace AbilityRuntime { ReadFromParcel(Parcel & parcel)21bool UIExtensionHostInfo::ReadFromParcel(Parcel &parcel) 22 { 23 std::unique_ptr<AppExecFwk::ElementName> abilityInfo(parcel.ReadParcelable<AppExecFwk::ElementName>()); 24 if (abilityInfo == nullptr) { 25 TAG_LOGE(AAFwkTag::ABILITYMGR, "Read host info failed."); 26 return false; 27 } 28 29 elementName_ = *abilityInfo; 30 return true; 31 } 32 Unmarshalling(Parcel & parcel)33UIExtensionHostInfo *UIExtensionHostInfo::Unmarshalling(Parcel &parcel) 34 { 35 UIExtensionHostInfo *hostInfo = new (std::nothrow) UIExtensionHostInfo(); 36 if (hostInfo == nullptr) { 37 TAG_LOGE(AAFwkTag::ABILITYMGR, "Create host info failed."); 38 return nullptr; 39 } 40 41 if (!hostInfo->ReadFromParcel(parcel)) { 42 delete hostInfo; 43 hostInfo = nullptr; 44 } 45 46 return hostInfo; 47 } 48 Marshalling(Parcel & parcel) const49bool UIExtensionHostInfo::Marshalling(Parcel &parcel) const 50 { 51 if (!parcel.WriteParcelable(&elementName_)) { 52 TAG_LOGE(AAFwkTag::ABILITYMGR, "Write element name failed."); 53 return false; 54 } 55 56 return true; 57 } 58 } // namespace AbilityRuntime 59 } // namespace OHOS 60