1 /* 2 * Copyright (c) 2021-2022 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 "process_data.h" 17 18 #include "hilog_wrapper.h" 19 #include "parcel_macro_base.h" 20 21 namespace OHOS { 22 namespace AppExecFwk { Marshalling(Parcel & parcel) const23bool ProcessData::Marshalling(Parcel &parcel) const 24 { 25 return (parcel.WriteString(bundleName) && parcel.WriteInt32(pid) && parcel.WriteInt32(uid) && 26 parcel.WriteInt32(static_cast<int32_t>(state)) && parcel.WriteBool(isContinuousTask) && 27 parcel.WriteBool(isKeepAlive) && parcel.WriteBool(isFocused) && parcel.WriteInt32(requestProcCode) && 28 parcel.WriteInt32(processChangeReason)); 29 } 30 ReadFromParcel(Parcel & parcel)31bool ProcessData::ReadFromParcel(Parcel &parcel) 32 { 33 bundleName = parcel.ReadString(); 34 pid = parcel.ReadInt32(); 35 uid = parcel.ReadInt32(); 36 state = static_cast<AppProcessState>(parcel.ReadInt32()); 37 isContinuousTask = parcel.ReadBool(); 38 isKeepAlive = parcel.ReadBool(); 39 isFocused = parcel.ReadBool(); 40 requestProcCode = parcel.ReadInt32(); 41 processChangeReason = parcel.ReadInt32(); 42 43 return true; 44 } 45 Unmarshalling(Parcel & parcel)46ProcessData *ProcessData::Unmarshalling(Parcel &parcel) 47 { 48 ProcessData *processData = new (std::nothrow) ProcessData(); 49 if (processData && !processData->ReadFromParcel(parcel)) { 50 HILOG_WARN("processData failed, because ReadFromParcel failed"); 51 delete processData; 52 processData = nullptr; 53 } 54 return processData; 55 } 56 } // namespace AppExecFwk 57 } // namespace OHOS 58