1 /* 2 * Copyright (C) 2021-2022 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_ble_scan_settings.h" 17 18 namespace OHOS { 19 namespace Bluetooth { Marshalling(Parcel & parcel) const20bool BluetoothBleScanSettings::Marshalling(Parcel &parcel) const 21 { 22 if (!parcel.WriteInt64(reportDelayMillis_)) { 23 return false; 24 } 25 if (!parcel.WriteInt32(scanMode_)) { 26 return false; 27 } 28 if (!parcel.WriteInt32(reportMode_)) { 29 return false; 30 } 31 if (!parcel.WriteBool(legacy_)) { 32 return false; 33 } 34 if (!parcel.WriteInt32(phy_)) { 35 return false; 36 } 37 if (!parcel.WriteUint8(callbackType_)) { 38 return false; 39 } 40 if (!parcel.WriteUint8(sensitivityMode_)) { 41 return false; 42 } 43 if (!parcel.WriteUint8(matchTrackAdvType_)) { 44 return false; 45 } 46 return true; 47 } 48 Unmarshalling(Parcel & parcel)49BluetoothBleScanSettings *BluetoothBleScanSettings::Unmarshalling(Parcel &parcel) 50 { 51 BluetoothBleScanSettings *settings = new BluetoothBleScanSettings(); 52 if (settings != nullptr && !settings->ReadFromParcel(parcel)) { 53 delete settings; 54 settings = nullptr; 55 } 56 return settings; 57 } 58 WriteToParcel(Parcel & parcel)59bool BluetoothBleScanSettings::WriteToParcel(Parcel &parcel) 60 { 61 return Marshalling(parcel); 62 } 63 ReadFromParcel(Parcel & parcel)64bool BluetoothBleScanSettings::ReadFromParcel(Parcel &parcel) 65 { 66 int64_t reportDelayMillis = 0; 67 if (parcel.ReadInt64(reportDelayMillis)) { 68 BluetoothBleScanSettings::SetReportDelay(reportDelayMillis); 69 } else { 70 return false; 71 } 72 if (!parcel.ReadInt32(scanMode_)) { 73 return false; 74 } 75 if (!parcel.ReadInt32(reportMode_)) { 76 return false; 77 } 78 if (!parcel.ReadBool(legacy_)) { 79 return false; 80 } 81 if (!parcel.ReadInt32(phy_)) { 82 return false; 83 } 84 if (!parcel.ReadUint8(callbackType_)) { 85 return false; 86 } 87 if (!parcel.ReadUint8(sensitivityMode_)) { 88 return false; 89 } 90 if (!parcel.ReadUint8(matchTrackAdvType_)) { 91 return false; 92 } 93 return true; 94 } 95 } // namespace Bluetooth 96 } // namespace OHOS 97