• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 "mission_info.h"
17 
18 namespace OHOS {
19 namespace AAFwk {
ReadFromParcel(Parcel & parcel)20 bool MissionInfo::ReadFromParcel(Parcel &parcel)
21 {
22     id = parcel.ReadInt32();
23     runningState = parcel.ReadInt32();
24     lockedState = parcel.ReadBool();
25     continuable = parcel.ReadBool();
26     time = Str16ToStr8(parcel.ReadString16());
27     label = Str16ToStr8(parcel.ReadString16());
28     iconPath = Str16ToStr8(parcel.ReadString16());
29     std::unique_ptr<Want> parcelWant(parcel.ReadParcelable<Want>());
30     if (parcelWant == nullptr) {
31         return false;
32     }
33     want = *parcelWant;
34     return true;
35 }
36 
Unmarshalling(Parcel & parcel)37 MissionInfo *MissionInfo::Unmarshalling(Parcel &parcel)
38 {
39     MissionInfo *info = new MissionInfo();
40     if (!info->ReadFromParcel(parcel)) {
41         delete info;
42         info = nullptr;
43     }
44     return info;
45 }
46 
Marshalling(Parcel & parcel) const47 bool MissionInfo::Marshalling(Parcel &parcel) const
48 {
49     if (!parcel.WriteInt32(id)) {
50         return false;
51     }
52 
53     if (!parcel.WriteInt32(runningState)) {
54         return false;
55     }
56 
57     if (!parcel.WriteBool(lockedState)) {
58         return false;
59     }
60 
61     if (!parcel.WriteBool(continuable)) {
62         return false;
63     }
64 
65     if (!parcel.WriteString16(Str8ToStr16(time))) {
66         return false;
67     }
68 
69     if (!parcel.WriteString16(Str8ToStr16(label))) {
70         return false;
71     }
72 
73     if (!parcel.WriteString16(Str8ToStr16(iconPath))) {
74         return false;
75     }
76 
77     if (!parcel.WriteParcelable(&want)) {
78         return false;
79     }
80 
81     return true;
82 }
83 }  // namespace AAFwk
84 }  // namespace OHOS
85