1 /* 2 * Copyright (C) 2023 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_socket_coc.h" 17 18 namespace OHOS { 19 namespace Bluetooth { Marshalling(Parcel & parcel) const20bool BluetoothSocketCocInfo::Marshalling(Parcel &parcel) const 21 { 22 if (!parcel.WriteString(addr)) { 23 return false; 24 } 25 if (!parcel.WriteInt32(minInterval)) { 26 return false; 27 } 28 if (!parcel.WriteInt32(maxInterval)) { 29 return false; 30 } 31 if (!parcel.WriteInt32(peripheralLatency)) { 32 return false; 33 } 34 if (!parcel.WriteInt32(supervisionTimeout)) { 35 return false; 36 } 37 if (!parcel.WriteInt32(minConnEventLen)) { 38 return false; 39 } 40 if (!parcel.WriteInt32(maxConnEventLen)) { 41 return false; 42 } 43 return true; 44 } 45 WriteToParcel(Parcel & parcel)46bool BluetoothSocketCocInfo::WriteToParcel(Parcel &parcel) 47 { 48 return Marshalling(parcel); 49 } 50 Unmarshalling(Parcel & parcel)51BluetoothSocketCocInfo *BluetoothSocketCocInfo::Unmarshalling(Parcel &parcel) 52 { 53 BluetoothSocketCocInfo *codecData = new BluetoothSocketCocInfo(); 54 if (codecData != nullptr && !codecData->ReadFromParcel(parcel)) { 55 delete codecData; 56 codecData = nullptr; 57 } 58 return codecData; 59 } 60 ReadFromParcel(Parcel & parcel)61bool BluetoothSocketCocInfo::ReadFromParcel(Parcel &parcel) 62 { 63 if (!parcel.ReadString(addr)) { 64 return false; 65 } 66 if (!parcel.ReadInt32(minInterval)) { 67 return false; 68 } 69 if (!parcel.ReadInt32(maxInterval)) { 70 return false; 71 } 72 if (!parcel.ReadInt32(peripheralLatency)) { 73 return false; 74 } 75 if (!parcel.ReadInt32(supervisionTimeout)) { 76 return false; 77 } 78 if (!parcel.ReadInt32(minConnEventLen)) { 79 return false; 80 } 81 if (!parcel.ReadInt32(maxConnEventLen)) { 82 return false; 83 } 84 return true; 85 } 86 } // namespace Bluetooth 87 } // namespace OHOS