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 "app_caller_parcelable.h" 17 18 namespace OHOS::HiviewDFX { Marshalling(Parcel & outParcel) const19bool AppCallerParcelable::Marshalling(Parcel& outParcel) const 20 { 21 if (!outParcel.WriteInt32(appCaller_.actionId)) { 22 return false; 23 } 24 if (!outParcel.WriteString(appCaller_.bundleName)) { 25 return false; 26 } 27 if (!outParcel.WriteString(appCaller_.bundleVersion)) { 28 return false; 29 } 30 if (!outParcel.WriteString(appCaller_.threadName)) { 31 return false; 32 } 33 if (!outParcel.WriteInt32(appCaller_.foreground)) { 34 return false; 35 } 36 if (!outParcel.WriteInt32(appCaller_.uid)) { 37 return false; 38 } 39 if (!outParcel.WriteInt32(appCaller_.pid)) { 40 return false; 41 } 42 if (!outParcel.WriteInt64(appCaller_.happenTime)) { 43 return false; 44 } 45 if (!outParcel.WriteInt64(appCaller_.beginTime)) { 46 return false; 47 } 48 if (!outParcel.WriteInt64(appCaller_.endTime)) { 49 return false; 50 } 51 if (!outParcel.WriteBool(appCaller_.isBusinessJank)) { 52 return false; 53 } 54 return true; 55 } 56 Unmarshalling(Parcel & inParcel)57AppCallerParcelable* AppCallerParcelable::Unmarshalling(Parcel& inParcel) 58 { 59 UCollectClient::AppCaller appCaller; 60 if (!inParcel.ReadInt32(appCaller.actionId)) { 61 return nullptr; 62 } 63 if (!inParcel.ReadString(appCaller.bundleName)) { 64 return nullptr; 65 } 66 if (!inParcel.ReadString(appCaller.bundleVersion)) { 67 return nullptr; 68 } 69 if (!inParcel.ReadString(appCaller.threadName)) { 70 return nullptr; 71 } 72 if (!inParcel.ReadInt32(appCaller.foreground)) { 73 return nullptr; 74 } 75 if (!inParcel.ReadInt32(appCaller.uid)) { 76 return nullptr; 77 } 78 if (!inParcel.ReadInt32(appCaller.pid)) { 79 return nullptr; 80 } 81 if (!inParcel.ReadInt64(appCaller.happenTime)) { 82 return nullptr; 83 } 84 if (!inParcel.ReadInt64(appCaller.beginTime)) { 85 return nullptr; 86 } 87 if (!inParcel.ReadInt64(appCaller.endTime)) { 88 return nullptr; 89 } 90 if (!inParcel.ReadBool(appCaller.isBusinessJank)) { 91 return nullptr; 92 } 93 return new(std::nothrow) AppCallerParcelable(appCaller); 94 } 95 GetAppCaller() const96UCollectClient::AppCaller AppCallerParcelable::GetAppCaller() const 97 { 98 return appCaller_; 99 } 100 } // namespace OHOS::HiviewDFX