• 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         parcel.WriteInt32(childUid) && parcel.WriteBool(isPreload) && parcel.WriteBool(isPreloadModule) &&
32         parcel.WriteBool(isFromWindowFocusChanged));
33 }
34 
ReadFromParcel(Parcel & parcel)35 bool ProcessData::ReadFromParcel(Parcel &parcel)
36 {
37     bundleName = parcel.ReadString();
38     pid = parcel.ReadInt32();
39     uid = parcel.ReadInt32();
40     hostPid = parcel.ReadInt32();
41     gpuPid = parcel.ReadInt32();
42     state = static_cast<AppProcessState>(parcel.ReadInt32());
43     isContinuousTask = parcel.ReadBool();
44     isKeepAlive = parcel.ReadBool();
45     isFocused = parcel.ReadBool();
46     requestProcCode = parcel.ReadInt32();
47     processChangeReason = parcel.ReadInt32();
48     processName = parcel.ReadString();
49     processType = static_cast<ProcessType>(parcel.ReadInt32());
50     extensionType = parcel.ReadInt32();
51     renderUid = parcel.ReadInt32();
52     accessTokenId = parcel.ReadUint32();
53     isTestMode = parcel.ReadBool();
54     exitReason = parcel.ReadInt32();
55     exitMsg = parcel.ReadString();
56     childUid = parcel.ReadInt32();
57     isPreload = parcel.ReadBool();
58     isPreloadModule = parcel.ReadBool();
59     isFromWindowFocusChanged = parcel.ReadBool();
60     return true;
61 }
62 
Unmarshalling(Parcel & parcel)63 ProcessData *ProcessData::Unmarshalling(Parcel &parcel)
64 {
65     ProcessData *processData = new (std::nothrow) ProcessData();
66     if (processData && !processData->ReadFromParcel(parcel)) {
67         delete processData;
68         processData = nullptr;
69     }
70     return processData;
71 }
72 }  // namespace AccessToken
73 }  // namespace Security
74 }  // namespace OHOS
75