1 /* 2 * Copyright (c) 2025 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 "preload_process_data.h" 17 18 #include "hilog_tag_wrapper.h" 19 20 namespace OHOS { 21 namespace AppExecFwk { ReadFromParcel(Parcel & parcel)22bool PreloadProcessData::ReadFromParcel(Parcel &parcel) 23 { 24 isPreForeground = parcel.ReadBool(); 25 pid = parcel.ReadInt32(); 26 uid = parcel.ReadInt32(); 27 bundleName = parcel.ReadString(); 28 return true; 29 } 30 Marshalling(Parcel & parcel) const31bool PreloadProcessData::Marshalling(Parcel &parcel) const 32 { 33 if (!parcel.WriteBool(isPreForeground)) { 34 TAG_LOGE(AAFwkTag::APPMGR, "write isPreForeground failed."); 35 return false; 36 } 37 if (!parcel.WriteInt32(pid)) { 38 TAG_LOGE(AAFwkTag::APPMGR, "write pid failed."); 39 return false; 40 } 41 if (!parcel.WriteInt32(uid)) { 42 TAG_LOGE(AAFwkTag::APPMGR, "write uid failed."); 43 return false; 44 } 45 if (!parcel.WriteString(bundleName)) { 46 TAG_LOGE(AAFwkTag::APPMGR, "write bundleName failed."); 47 return false; 48 } 49 return true; 50 } 51 Unmarshalling(Parcel & parcel)52PreloadProcessData *PreloadProcessData::Unmarshalling(Parcel &parcel) 53 { 54 PreloadProcessData *data = new (std::nothrow) PreloadProcessData(); 55 if (data && !data->ReadFromParcel(parcel)) { 56 delete data; 57 data = nullptr; 58 } 59 return data; 60 } 61 } // namespace AppExecFwk 62 } // namespace OHOS