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