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 "asset/asset_obj.h" 17 #include "utils_log.h" 18 19 namespace OHOS { 20 namespace Storage { 21 namespace DistributedFile { ReadFromParcel(Parcel & parcel)22bool AssetObj::ReadFromParcel(Parcel &parcel) 23 { 24 parcel.ReadString(sessionId_); 25 parcel.ReadString(dstNetworkId_); 26 parcel.ReadString(srcBundleName_); 27 parcel.ReadString(dstBundleName_); 28 if (!parcel.ReadStringVector(&uris_)) { 29 LOGE("failed to read uris_."); 30 return false; 31 } 32 return true; 33 } 34 Marshalling(Parcel & parcel) const35bool AssetObj::Marshalling(Parcel &parcel) const 36 { 37 parcel.WriteString(sessionId_); 38 parcel.WriteString(dstNetworkId_); 39 parcel.WriteString(srcBundleName_); 40 parcel.WriteString(dstBundleName_); 41 if (!parcel.WriteStringVector(uris_)) { 42 LOGE("failed to write uris_."); 43 return false; 44 } 45 return true; 46 } Unmarshalling(Parcel & parcel)47AssetObj *AssetObj::Unmarshalling(Parcel &parcel) 48 { 49 AssetObj *info = new (std::nothrow) AssetObj(); 50 if ((info != nullptr) && (!info->ReadFromParcel(parcel))) { 51 LOGW("read from parcel failed"); 52 delete info; 53 info = nullptr; 54 } 55 return info; 56 } 57 } // namespace DistributedFile 58 } // namespace Storage 59 } // namespace OHOS