• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 "running_form_info.h"
17 #include "fms_log_wrapper.h"
18 #include "message_parcel.h"
19 #include "string_ex.h"
20 
21 namespace OHOS {
22 namespace AppExecFwk {
ReadFromParcel(Parcel & parcel)23 bool RunningFormInfo::ReadFromParcel(Parcel &parcel)
24 {
25     formId = parcel.ReadInt64();
26     formName = Str16ToStr8(parcel.ReadString16());
27     bundleName = Str16ToStr8(parcel.ReadString16());
28     moduleName = Str16ToStr8(parcel.ReadString16());
29     abilityName = Str16ToStr8(parcel.ReadString16());
30     description = parcel.ReadString();
31     dimension = parcel.ReadInt32();
32     hostBundleName = Str16ToStr8(parcel.ReadString16());
33     int32_t formVisiblityInt = parcel.ReadInt32();
34     formVisiblity = (FormVisibilityType)formVisiblityInt;
35     formUsageState = static_cast<FormUsageState>(parcel.ReadInt32());
36     formLocation = static_cast<Constants::FormLocation>(parcel.ReadInt32());
37     appIndex = parcel.ReadInt32();
38     userId = parcel.ReadInt32();
39     return true;
40 }
41 
Marshalling(Parcel & parcel) const42 bool RunningFormInfo::Marshalling(Parcel &parcel) const
43 {
44     // write formId
45     if (!parcel.WriteInt64(formId)) {
46         return false;
47     }
48 
49     // write formName
50     if (!parcel.WriteString16(Str8ToStr16(formName))) {
51         return false;
52     }
53 
54     // write bundleName
55     if (!parcel.WriteString16(Str8ToStr16(bundleName))) {
56         return false;
57     }
58 
59     // write moduleName
60     if (!parcel.WriteString16(Str8ToStr16(moduleName))) {
61         return false;
62     }
63 
64     // write abilityName
65     if (!parcel.WriteString16(Str8ToStr16(abilityName))) {
66         return false;
67     }
68 
69     // write description
70     if (!parcel.WriteString(description)) {
71         return false;
72     }
73 
74     // write dimension
75     if (!parcel.WriteInt32(dimension)) {
76         return false;
77     }
78 
79     // write hostBundleName
80     if (!parcel.WriteString16(Str8ToStr16(hostBundleName))) {
81         return false;
82     }
83 
84     // write formVisiblity
85     if (!parcel.WriteInt32((int32_t)formVisiblity)) {
86         return false;
87     }
88 
89     // write formUsageState
90     if (!parcel.WriteInt32(static_cast<int32_t>(formUsageState))) {
91         return false;
92     }
93 
94     // write formLocation
95     if (!parcel.WriteInt32(static_cast<int32_t>(formLocation))) {
96         return false;
97     }
98 
99     // write appIndex
100     if (!parcel.WriteInt32(appIndex)) {
101         return false;
102     }
103 
104     // write userId
105     if (!parcel.WriteInt32(userId)) {
106         return false;
107     }
108     return true;
109 }
110 
Unmarshalling(Parcel & parcel)111 RunningFormInfo* RunningFormInfo::Unmarshalling(Parcel &parcel)
112 {
113     std::unique_ptr<RunningFormInfo> object = std::make_unique<RunningFormInfo>();
114     if (object && !object->ReadFromParcel(parcel)) {
115         object = nullptr;
116         return nullptr;
117     }
118     return object.release();
119 }
120 } // namespace AppExecFwk
121 } // namespace OHOS
122