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_phone_state.h" 17 18 namespace OHOS { 19 namespace Bluetooth { Marshalling(Parcel & parcel) const20bool BluetoothPhoneState::Marshalling(Parcel &parcel) const 21 { 22 if (!parcel.WriteInt32(activeNum_)) { 23 return false; 24 } 25 if (!parcel.WriteInt32(heldNum_)) { 26 return false; 27 } 28 if (!parcel.WriteInt32(callState_)) { 29 return false; 30 } 31 if (!parcel.WriteString(number_)) { 32 return false; 33 } 34 if (!parcel.WriteInt32(callType_)) { 35 return false; 36 } 37 if (!parcel.WriteString(name_)) { 38 return false; 39 } 40 return true; 41 } 42 WriteToParcel(Parcel & parcel)43bool BluetoothPhoneState::WriteToParcel(Parcel &parcel) 44 { 45 return Marshalling(parcel); 46 } 47 Unmarshalling(Parcel & parcel)48BluetoothPhoneState *BluetoothPhoneState::Unmarshalling(Parcel &parcel) 49 { 50 BluetoothPhoneState *phoneState = new BluetoothPhoneState(); 51 if (phoneState != nullptr && !phoneState->ReadFromParcel(parcel)) { 52 delete phoneState; 53 phoneState = nullptr; 54 } 55 return phoneState; 56 } 57 ReadFromParcel(Parcel & parcel)58bool BluetoothPhoneState::ReadFromParcel(Parcel &parcel) 59 { 60 if (!parcel.ReadInt32(activeNum_)) { 61 return false; 62 } 63 if (!parcel.ReadInt32(heldNum_)) { 64 return false; 65 } 66 if (!parcel.ReadInt32(callState_)) { 67 return false; 68 } 69 if (!parcel.ReadString(number_)) { 70 return false; 71 } 72 if (!parcel.ReadInt32(callType_)) { 73 return false; 74 } 75 if (!parcel.ReadString(name_)) { 76 return false; 77 } 78 return true; 79 } 80 GetActiveNum()81int BluetoothPhoneState::GetActiveNum() 82 { 83 return activeNum_; 84 } 85 SetActiveNum(int activeNum)86void BluetoothPhoneState::SetActiveNum(int activeNum) 87 { 88 activeNum_ = activeNum; 89 } 90 GetHeldNum()91int BluetoothPhoneState::GetHeldNum() 92 { 93 return heldNum_; 94 } 95 SetHeldNum(int heldNum)96void BluetoothPhoneState::SetHeldNum(int heldNum) 97 { 98 heldNum_ = heldNum; 99 } 100 GetCallState()101int BluetoothPhoneState::GetCallState() 102 { 103 return callState_; 104 } 105 SetCallState(int callState)106void BluetoothPhoneState::SetCallState(int callState) 107 { 108 callState_ = callState; 109 } 110 GetNumber()111std::string BluetoothPhoneState::GetNumber() 112 { 113 return number_; 114 } 115 SetNumber(std::string number)116void BluetoothPhoneState::SetNumber(std::string number) 117 { 118 number_ = number; 119 } 120 GetCallType()121int BluetoothPhoneState::GetCallType() 122 { 123 return callType_; 124 } 125 SetCallType(int callType)126void BluetoothPhoneState::SetCallType(int callType) 127 { 128 callType_ = callType; 129 } 130 GetName()131std::string BluetoothPhoneState::GetName() 132 { 133 return name_; 134 } 135 SetName(std::string name)136void BluetoothPhoneState::SetName(std::string name) 137 { 138 name_ = name; 139 } 140 } // namespace Bluetooth 141 } // namespace OHOS