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.WriteBool(legacy_)) { 29 return false; 30 } 31 if (!parcel.WriteInt32(phy_)) { 32 return false; 33 } 34 if (!parcel.WriteUint8(callbackType_)) { 35 return false; 36 } 37 if (!parcel.WriteUint8(sensitivityMode_)) { 38 return false; 39 } 40 if (!parcel.WriteUint8(matchTrackAdvType_)) { 41 return false; 42 } 43 return true; 44 } 45 Unmarshalling(Parcel & parcel)46BluetoothBleScanSettings *BluetoothBleScanSettings::Unmarshalling(Parcel &parcel) 47 { 48 BluetoothBleScanSettings *settings = new BluetoothBleScanSettings(); 49 if (settings != nullptr && !settings->ReadFromParcel(parcel)) { 50 delete settings; 51 settings = nullptr; 52 } 53 return settings; 54 } 55 WriteToParcel(Parcel & parcel)56bool BluetoothBleScanSettings::WriteToParcel(Parcel &parcel) 57 { 58 return Marshalling(parcel); 59 } 60 ReadFromParcel(Parcel & parcel)61bool BluetoothBleScanSettings::ReadFromParcel(Parcel &parcel) 62 { 63 int64_t reportDelayMillis = 0; 64 if (parcel.ReadInt64(reportDelayMillis)) { 65 BluetoothBleScanSettings::SetReportDelay(reportDelayMillis); 66 } else { 67 return false; 68 } 69 if (!parcel.ReadInt32(scanMode_)) { 70 return false; 71 } 72 if (!parcel.ReadBool(legacy_)) { 73 return false; 74 } 75 if (!parcel.ReadInt32(phy_)) { 76 return false; 77 } 78 if (!parcel.ReadUint8(callbackType_)) { 79 return false; 80 } 81 if (!parcel.ReadUint8(sensitivityMode_)) { 82 return false; 83 } 84 if (!parcel.ReadUint8(matchTrackAdvType_)) { 85 return false; 86 } 87 return true; 88 } 89 } // namespace Bluetooth 90 } // namespace OHOS 91