• 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 "app_task_info.h"
17 
18 #include "hilog_wrapper.h"
19 
20 namespace OHOS {
21 namespace AppExecFwk {
GetName() const22 const std::string &AppTaskInfo::GetName() const
23 {
24     return appName_;
25 }
26 
GetProcessName() const27 const std::string &AppTaskInfo::GetProcessName() const
28 {
29     return processName_;
30 }
31 
GetPid() const32 pid_t AppTaskInfo::GetPid() const
33 {
34     return pid_;
35 }
36 
GetRecordId() const37 int32_t AppTaskInfo::GetRecordId() const
38 {
39     return appRecordId_;
40 }
41 
SetName(const std::string & appName)42 void AppTaskInfo::SetName(const std::string &appName)
43 {
44     appName_ = appName;
45 }
46 
SetProcessName(const std::string & processName)47 void AppTaskInfo::SetProcessName(const std::string &processName)
48 {
49     processName_ = processName;
50 }
51 
SetPid(const pid_t pid)52 void AppTaskInfo::SetPid(const pid_t pid)
53 {
54     pid_ = pid;
55 }
56 
SetRecordId(const int32_t appRecordId)57 void AppTaskInfo::SetRecordId(const int32_t appRecordId)
58 {
59     appRecordId_ = appRecordId;
60 }
61 
Marshalling(Parcel & parcel) const62 bool AppTaskInfo::Marshalling(Parcel &parcel) const
63 {
64     return (parcel.WriteString(appName_) && parcel.WriteString(processName_) && parcel.WriteInt32(pid_) &&
65             parcel.WriteInt32(appRecordId_));
66 }
67 
ReadFromParcel(Parcel & parcel)68 bool AppTaskInfo::ReadFromParcel(Parcel &parcel)
69 {
70     return (parcel.ReadString(appName_) && parcel.ReadString(processName_) && parcel.ReadInt32(pid_) &&
71             parcel.ReadInt32(appRecordId_));
72 }
73 
Unmarshalling(Parcel & parcel)74 AppTaskInfo *AppTaskInfo::Unmarshalling(Parcel &parcel)
75 {
76     AppTaskInfo *appTaskInfo = new (std::nothrow) AppTaskInfo();
77     if (appTaskInfo && !appTaskInfo->ReadFromParcel(parcel)) {
78         HILOG_WARN("failed, because ReadFromParcel failed");
79         delete appTaskInfo;
80         appTaskInfo = nullptr;
81     }
82     return appTaskInfo;
83 }
84 }  // namespace AppExecFwk
85 }  // namespace OHOS
86