• 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 #include "hilog_wrapper.h"
19 #include "parcel_macro_base.h"
20 
21 namespace OHOS {
22 namespace AppExecFwk {
Marshalling(Parcel & parcel) const23 bool ProcessData::Marshalling(Parcel &parcel) const
24 {
25     return (parcel.WriteString(bundleName) && parcel.WriteInt32(pid) && parcel.WriteInt32(uid) &&
26         parcel.WriteInt32(static_cast<int32_t>(state)) && parcel.WriteBool(isContinuousTask) &&
27         parcel.WriteBool(isKeepAlive) && parcel.WriteBool(isFocused) && parcel.WriteInt32(requestProcCode) &&
28         parcel.WriteInt32(processChangeReason) && parcel.WriteString(processName) &&
29         parcel.WriteInt32(static_cast<int32_t>(processType)) && parcel.WriteInt32(static_cast<int32_t>(extensionType))
30         && parcel.WriteInt32(renderUid));
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     state = static_cast<AppProcessState>(parcel.ReadInt32());
39     isContinuousTask = parcel.ReadBool();
40     isKeepAlive = parcel.ReadBool();
41     isFocused = parcel.ReadBool();
42     requestProcCode = parcel.ReadInt32();
43     processChangeReason = parcel.ReadInt32();
44     processName = parcel.ReadString();
45     processType = static_cast<ProcessType>(parcel.ReadInt32());
46     extensionType = static_cast<ExtensionAbilityType>(parcel.ReadInt32());
47     renderUid = parcel.ReadInt32();
48     return true;
49 }
50 
Unmarshalling(Parcel & parcel)51 ProcessData *ProcessData::Unmarshalling(Parcel &parcel)
52 {
53     ProcessData *processData = new (std::nothrow) ProcessData();
54     if (processData && !processData->ReadFromParcel(parcel)) {
55         HILOG_WARN("processData failed, because ReadFromParcel failed");
56         delete processData;
57         processData = nullptr;
58     }
59     return processData;
60 }
61 }  // namespace AppExecFwk
62 }  // namespace OHOS
63