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 "form_instances_filter.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 FormInstancesFilter::ReadFromParcel(Parcel &parcel)
24 {
25     bundleName = Str16ToStr8(parcel.ReadString16());
26     formName = Str16ToStr8(parcel.ReadString16());
27     moduleName = Str16ToStr8(parcel.ReadString16());
28     abilityName = Str16ToStr8(parcel.ReadString16());
29     isUnusedIncluded = parcel.ReadBool();
30 
31     return true;
32 }
33 
Marshalling(Parcel & parcel) const34 bool FormInstancesFilter::Marshalling(Parcel &parcel) const
35 {
36     // write bundleName
37     if (!parcel.WriteString16(Str8ToStr16(bundleName))) {
38         return false;
39     }
40 
41     // write formName
42     if (!parcel.WriteString16(Str8ToStr16(formName))) {
43         return false;
44     }
45 
46     // write moduleName
47     if (!parcel.WriteString16(Str8ToStr16(moduleName))) {
48         return false;
49     }
50 
51     // write abilityName
52     if (!parcel.WriteString16(Str8ToStr16(abilityName))) {
53         return false;
54     }
55 
56     // write isUnusedIncluded
57     if (!parcel.WriteBool(isUnusedIncluded)) {
58         return false;
59     }
60 
61     return true;
62 }
63 
Unmarshalling(Parcel & parcel)64 FormInstancesFilter* FormInstancesFilter::Unmarshalling(Parcel &parcel)
65 {
66     std::unique_ptr<FormInstancesFilter> object = std::make_unique<FormInstancesFilter>();
67     if (object && !object->ReadFromParcel(parcel)) {
68         object = nullptr;
69         return nullptr;
70     }
71     return object.release();
72 }
73 } // namespace AppExecFwk
74 } // namespace OHOS
75