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 return true; 35 } 36 Unmarshalling(Parcel & parcel)37BluetoothBleScanSettings *BluetoothBleScanSettings::Unmarshalling(Parcel &parcel) 38 { 39 BluetoothBleScanSettings *settings = new BluetoothBleScanSettings(); 40 if (settings != nullptr && !settings->ReadFromParcel(parcel)) { 41 delete settings; 42 settings = nullptr; 43 } 44 return settings; 45 } 46 WriteToParcel(Parcel & parcel)47bool BluetoothBleScanSettings::WriteToParcel(Parcel &parcel) 48 { 49 return Marshalling(parcel); 50 } 51 ReadFromParcel(Parcel & parcel)52bool BluetoothBleScanSettings::ReadFromParcel(Parcel &parcel) 53 { 54 int64_t reportDelayMillis = 0; 55 if (parcel.ReadInt64(reportDelayMillis)) { 56 BluetoothBleScanSettings::SetReportDelay(reportDelayMillis); 57 } else { 58 return false; 59 } 60 if (!parcel.ReadInt32(scanMode_)) { 61 return false; 62 } 63 if (!parcel.ReadBool(legacy_)) { 64 return false; 65 } 66 if (!parcel.ReadInt32(phy_)) { 67 return false; 68 } 69 return true; 70 } 71 } // namespace Bluetooth 72 } // namespace OHOS 73