1 /* 2 * Copyright (c) 2023 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 #include "auto_startup_info.h" 16 17 #include "string_ex.h" 18 19 namespace OHOS { 20 namespace AbilityRuntime { ReadFromParcel(Parcel & parcel)21bool AutoStartupInfo::ReadFromParcel(Parcel &parcel) 22 { 23 bundleName = Str16ToStr8(parcel.ReadString16()); 24 abilityName = Str16ToStr8(parcel.ReadString16()); 25 moduleName = Str16ToStr8(parcel.ReadString16()); 26 abilityTypeName = Str16ToStr8(parcel.ReadString16()); 27 appCloneIndex = parcel.ReadInt32(); 28 return true; 29 } 30 Unmarshalling(Parcel & parcel)31AutoStartupInfo *AutoStartupInfo::Unmarshalling(Parcel &parcel) 32 { 33 AutoStartupInfo *info = new (std::nothrow) AutoStartupInfo(); 34 if (info == nullptr) { 35 return nullptr; 36 } 37 38 if (!info->ReadFromParcel(parcel)) { 39 delete info; 40 info = nullptr; 41 } 42 return info; 43 } 44 Marshalling(Parcel & parcel) const45bool AutoStartupInfo::Marshalling(Parcel &parcel) const 46 { 47 if (!parcel.WriteString16(Str8ToStr16(bundleName))) { 48 return false; 49 } 50 if (!parcel.WriteString16(Str8ToStr16(abilityName))) { 51 return false; 52 } 53 if (!parcel.WriteString16(Str8ToStr16(moduleName))) { 54 return false; 55 } 56 if (!parcel.WriteString16(Str8ToStr16(abilityTypeName))) { 57 return false; 58 } 59 if (!parcel.WriteInt32(appCloneIndex)) { 60 return false; 61 } 62 return true; 63 } 64 } // namespace AbilityRuntime 65 } // namespace OHOS 66