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 "process_bind_data.h" 17 18 #include "hilog_tag_wrapper.h" 19 #include "parcel_macro_base.h" 20 #include "string_ex.h" 21 22 namespace OHOS { 23 namespace AppExecFwk { Marshalling(Parcel & parcel) const24bool ProcessBindData::Marshalling(Parcel &parcel) const 25 { 26 return (parcel.WriteString(bundleName) && parcel.WriteInt32(pid) && parcel.WriteInt32(uid) && 27 parcel.WriteBool(isKeepAlive) && parcel.WriteInt32(static_cast<int32_t>(processType)) && 28 parcel.WriteInt32(static_cast<int32_t>(extensionType)) && parcel.WriteInt32(callerPid) && 29 parcel.WriteInt32(callerUid) && parcel.WriteString(callerBundleName) && parcel.WriteInt32(bindingRelation)); 30 } 31 ReadFromParcel(Parcel & parcel)32bool ProcessBindData::ReadFromParcel(Parcel &parcel) 33 { 34 bundleName = parcel.ReadString(); 35 pid = parcel.ReadInt32(); 36 uid = parcel.ReadInt32(); 37 isKeepAlive = parcel.ReadBool(); 38 processType = static_cast<ProcessType>(parcel.ReadInt32()); 39 extensionType = static_cast<ExtensionAbilityType>(parcel.ReadInt32()); 40 callerPid = parcel.ReadInt32(); 41 callerUid = parcel.ReadInt32(); 42 callerBundleName = parcel.ReadString(); 43 bindingRelation = parcel.ReadInt32(); 44 return true; 45 } 46 Unmarshalling(Parcel & parcel)47ProcessBindData *ProcessBindData::Unmarshalling(Parcel &parcel) 48 { 49 ProcessBindData *processBindData = new (std::nothrow) ProcessBindData(); 50 if (processBindData && !processBindData->ReadFromParcel(parcel)) { 51 TAG_LOGW(AAFwkTag::APPMGR, "processBindData failed, because ReadFromParcel failed"); 52 delete processBindData; 53 processBindData = nullptr; 54 } 55 return processBindData; 56 } 57 } // namespace AppExecFwk 58 } // namespace OHOS 59