• 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_record_info.h"
17 
18 #include "hilog_wrapper.h"
19 #include "nlohmann/json.hpp"
20 #include "string_ex.h"
21 
22 namespace OHOS {
23 namespace AAFwk {
ReadFromParcel(Parcel & parcel)24 bool AbilityRecordInfo::ReadFromParcel(Parcel &parcel)
25 {
26     id = parcel.ReadInt32();
27     elementName = Str16ToStr8(parcel.ReadString16());
28     appName = Str16ToStr8(parcel.ReadString16());
29     mainName = Str16ToStr8(parcel.ReadString16());
30     abilityType = parcel.ReadInt32();
31     previousAppName = Str16ToStr8(parcel.ReadString16());
32     previousMainName = Str16ToStr8(parcel.ReadString16());
33     nextAppName = Str16ToStr8(parcel.ReadString16());
34     nextMainName = Str16ToStr8(parcel.ReadString16());
35     int32_t abilityState = parcel.ReadInt32();
36     state = static_cast<AbilityState>(abilityState);
37     startTime = Str16ToStr8(parcel.ReadString16());
38     ready = parcel.ReadBool();
39     windowAttached = parcel.ReadBool();
40     lanucher = parcel.ReadBool();
41 
42     return true;
43 }
44 
Unmarshalling(Parcel & parcel)45 AbilityRecordInfo *AbilityRecordInfo::Unmarshalling(Parcel &parcel)
46 {
47     AbilityRecordInfo *info = new (std::nothrow) AbilityRecordInfo();
48     if (info == nullptr) {
49         return nullptr;
50     }
51 
52     if (!info->ReadFromParcel(parcel)) {
53         delete info;
54         info = nullptr;
55     }
56     return info;
57 }
58 
Marshalling(Parcel & parcel) const59 bool AbilityRecordInfo::Marshalling(Parcel &parcel) const
60 {
61     parcel.WriteInt32(id);
62     parcel.WriteString16(Str8ToStr16(elementName));
63     parcel.WriteString16(Str8ToStr16(appName));
64     parcel.WriteString16(Str8ToStr16(mainName));
65     parcel.WriteInt32(abilityType);
66     parcel.WriteString16(Str8ToStr16(previousAppName));
67     parcel.WriteString16(Str8ToStr16(previousMainName));
68     parcel.WriteString16(Str8ToStr16(nextAppName));
69     parcel.WriteString16(Str8ToStr16(nextMainName));
70     parcel.WriteInt32(static_cast<int32_t>(state));
71     parcel.WriteString16(Str8ToStr16(startTime));
72     parcel.WriteBool(ready);
73     parcel.WriteBool(windowAttached);
74     parcel.WriteBool(lanucher);
75 
76     return true;
77 }
78 }  // namespace AAFwk
79 }  // namespace OHOS