1 /*
2  * Copyright (C) 2024 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 "bluetooth_log.h"
17 #include "bluetooth_sensing_info.h"
18 
19 namespace OHOS {
20 namespace Bluetooth {
Marshalling(Parcel & parcel) const21 bool BluetoothSensingInfo::Marshalling(Parcel &parcel) const
22 {
23     if (!parcel.WriteString(addr_)) {
24         return false;
25     }
26     if (!parcel.WriteString(uuid_)) {
27         return false;
28     }
29     if (!parcel.WriteUint32(resourceId_)) {
30         return false;
31     }
32     if (!parcel.WriteString(pkgName_)) {
33         return false;
34     }
35     if (!parcel.WriteBool(isServer_)) {
36         return false;
37     }
38     if (!parcel.WriteUint16(interval_)) {
39         return false;
40     }
41     return true;
42 }
43 
Unmarshalling(Parcel & parcel)44 BluetoothSensingInfo *BluetoothSensingInfo::Unmarshalling(Parcel &parcel)
45 {
46     BluetoothSensingInfo *sensingInfo = new BluetoothSensingInfo();
47     if (sensingInfo != nullptr && !sensingInfo->ReadFromParcel(parcel)) {
48         delete sensingInfo;
49         sensingInfo = nullptr;
50     }
51     return sensingInfo;
52 }
53 
WriteToParcel(Parcel & parcel)54 bool BluetoothSensingInfo::WriteToParcel(Parcel &parcel)
55 {
56     return Marshalling(parcel);
57 }
58 
ReadFromParcel(Parcel & parcel)59 bool BluetoothSensingInfo::ReadFromParcel(Parcel &parcel)
60 {
61     if (!parcel.ReadString(addr_)) {
62         return false;
63     }
64     if (!parcel.ReadString(uuid_)) {
65         return false;
66     }
67     if (!parcel.ReadUint32(resourceId_)) {
68         return false;
69     }
70     if (!parcel.ReadString(pkgName_)) {
71         return false;
72     }
73     if (!parcel.ReadBool(isServer_)) {
74         return false;
75     }
76     if (!parcel.ReadUint16(interval_)) {
77         return false;
78     }
79     return true;
80 }
81 }  // namespace Bluetooth
82 }  // namespace OHOS