• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 namespace OHOS {
19 namespace Security {
20 namespace AccessToken {
Marshalling(Parcel & parcel) const21 bool ProcessData::Marshalling(Parcel &parcel) const
22 {
23     return (parcel.WriteString(bundleName) && parcel.WriteInt32(pid) &&
24         parcel.WriteInt32(uid) && parcel.WriteInt32(hostPid) && parcel.WriteInt32(gpuPid) &&
25         parcel.WriteInt32(static_cast<int32_t>(state)) && parcel.WriteBool(isContinuousTask) &&
26         parcel.WriteBool(isKeepAlive) && parcel.WriteBool(isFocused) && parcel.WriteInt32(requestProcCode) &&
27         parcel.WriteInt32(processChangeReason) && parcel.WriteString(processName) &&
28         parcel.WriteInt32(static_cast<int32_t>(processType)) && parcel.WriteInt32(extensionType)
29         && parcel.WriteInt32(renderUid) && parcel.WriteUint32(accessTokenId) &&
30         parcel.WriteBool(isTestMode) && parcel.WriteInt32(exitReason) && parcel.WriteString(exitMsg));
31 }
32 
ReadFromParcel(Parcel & parcel)33 bool ProcessData::ReadFromParcel(Parcel &parcel)
34 {
35     bundleName = parcel.ReadString();
36     pid = parcel.ReadInt32();
37     uid = parcel.ReadInt32();
38     hostPid = parcel.ReadInt32();
39     gpuPid = parcel.ReadInt32();
40     state = static_cast<AppProcessState>(parcel.ReadInt32());
41     isContinuousTask = parcel.ReadBool();
42     isKeepAlive = parcel.ReadBool();
43     isFocused = parcel.ReadBool();
44     requestProcCode = parcel.ReadInt32();
45     processChangeReason = parcel.ReadInt32();
46     processName = parcel.ReadString();
47     processType = static_cast<ProcessType>(parcel.ReadInt32());
48     extensionType = parcel.ReadInt32();
49     renderUid = parcel.ReadInt32();
50     accessTokenId = parcel.ReadUint32();
51     isTestMode = parcel.ReadBool();
52     exitReason = parcel.ReadInt32();
53     exitMsg = parcel.ReadString();
54     return true;
55 }
56 
Unmarshalling(Parcel & parcel)57 ProcessData *ProcessData::Unmarshalling(Parcel &parcel)
58 {
59     ProcessData *processData = new (std::nothrow) ProcessData();
60     if (processData && !processData->ReadFromParcel(parcel)) {
61         delete processData;
62         processData = nullptr;
63     }
64     return processData;
65 }
66 }  // namespace AccessToken
67 }  // namespace Security
68 }  // namespace OHOS
69