• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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     if (!parcel.WriteBool(connectable_)) {
42         return false;
43     }
44     if (!parcel.WriteInt32(payloadLen_)) {
45         return false;
46     }
47     if (!parcel.WriteString(bussinessType_)) {
48         return false;
49     }
50     if (!parcel.WriteInt32(scanMode_)) {
51         return false;
52     }
53     return true;
54 }
55 
Unmarshalling(Parcel & parcel)56 BluetoothSensingInfo *BluetoothSensingInfo::Unmarshalling(Parcel &parcel)
57 {
58     BluetoothSensingInfo *sensingInfo = new BluetoothSensingInfo();
59     if (sensingInfo != nullptr && !sensingInfo->ReadFromParcel(parcel)) {
60         delete sensingInfo;
61         sensingInfo = nullptr;
62     }
63     return sensingInfo;
64 }
65 
WriteToParcel(Parcel & parcel)66 bool BluetoothSensingInfo::WriteToParcel(Parcel &parcel)
67 {
68     return Marshalling(parcel);
69 }
70 
ReadFromParcel(Parcel & parcel)71 bool BluetoothSensingInfo::ReadFromParcel(Parcel &parcel)
72 {
73     if (!parcel.ReadString(addr_)) {
74         return false;
75     }
76     if (!parcel.ReadString(uuid_)) {
77         return false;
78     }
79     if (!parcel.ReadUint32(resourceId_)) {
80         return false;
81     }
82     if (!parcel.ReadString(pkgName_)) {
83         return false;
84     }
85     if (!parcel.ReadBool(isServer_)) {
86         return false;
87     }
88     if (!parcel.ReadUint16(interval_)) {
89         return false;
90     }
91     if (!parcel.ReadBool(connectable_)) {
92         return false;
93     }
94     if (!parcel.ReadInt32(payloadLen_)) {
95         return false;
96     }
97     if (!parcel.ReadString(bussinessType_)) {
98         return false;
99     }
100     if (!parcel.ReadInt32(scanMode_)) {
101         return false;
102     }
103     return true;
104 }
105 }  // namespace Bluetooth
106 }  // namespace OHOS