1 /*
2 * Copyright (c) 2023-2024 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_debug_info.h"
17
18 #include "hilog_tag_wrapper.h"
19
20 namespace OHOS {
21 namespace AppExecFwk {
ReadFromParcel(Parcel & parcel)22 bool AppDebugInfo::ReadFromParcel(Parcel &parcel)
23 {
24 bundleName = parcel.ReadString();
25 pid = parcel.ReadInt32();
26 uid = parcel.ReadInt32();
27 return true;
28 }
29
Unmarshalling(Parcel & parcel)30 AppDebugInfo *AppDebugInfo::Unmarshalling(Parcel &parcel)
31 {
32 AppDebugInfo *info = new (std::nothrow) AppDebugInfo();
33 if (info == nullptr) {
34 TAG_LOGE(AAFwkTag::APPMGR, "App debug info is nullptr.");
35 return nullptr;
36 }
37
38 if (!info->ReadFromParcel(parcel)) {
39 TAG_LOGE(AAFwkTag::APPMGR, "Read from parcel failed.");
40 delete info;
41 info = nullptr;
42 }
43 return info;
44 }
45
Marshalling(Parcel & parcel) const46 bool AppDebugInfo::Marshalling(Parcel &parcel) const
47 {
48 // write bundleName
49 if (!parcel.WriteString(bundleName)) {
50 TAG_LOGE(AAFwkTag::APPMGR, "Write bundle name failed.");
51 return false;
52 }
53 // write pid
54 if (!parcel.WriteInt32(pid)) {
55 TAG_LOGE(AAFwkTag::APPMGR, "Write pid failed.");
56 return false;
57 }
58 // write uid
59 if (!parcel.WriteInt32(uid)) {
60 TAG_LOGE(AAFwkTag::APPMGR, "Write uid failed.");
61 return false;
62 }
63 return true;
64 }
65 } // namespace AppExecFwk
66 } // namespace OHOS
67