• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_hfp_ag_stub.h"
17 
18 #include "bluetooth_errorcode.h"
19 #include "bluetooth_log.h"
20 
21 namespace OHOS {
22 namespace Bluetooth {
BluetoothHfpAgStub()23 BluetoothHfpAgStub::BluetoothHfpAgStub() {
24     HILOGI("%{public}s start.", __func__);
25     memberFuncMap_[static_cast<uint32_t>(BluetoothHfpAgInterfaceCode::BT_HFP_AG_GET_CONNECT_DEVICES)] =
26         &BluetoothHfpAgStub::GetConnectDevicesInner;
27     memberFuncMap_[static_cast<uint32_t>(BluetoothHfpAgInterfaceCode::BT_HFP_AG_GET_DEVICES_BY_STATES)] =
28         &BluetoothHfpAgStub::GetDevicesByStatesInner;
29     memberFuncMap_[static_cast<uint32_t>(BluetoothHfpAgInterfaceCode::BT_HFP_AG_GET_DEVICE_STATE)] =
30         &BluetoothHfpAgStub::GetDeviceStateInner;
31     memberFuncMap_[static_cast<uint32_t>(BluetoothHfpAgInterfaceCode::BT_HFP_AG_CONNECT)] =
32         &BluetoothHfpAgStub::ConnectInner;
33     memberFuncMap_[static_cast<uint32_t>(BluetoothHfpAgInterfaceCode::BT_HFP_AG_DISCONNECT)] =
34         &BluetoothHfpAgStub::DisconnectInner;
35     memberFuncMap_[static_cast<uint32_t>(BluetoothHfpAgInterfaceCode::BT_HFP_AG_GET_SCO_STATE)] =
36         &BluetoothHfpAgStub::GetScoStateInner;
37     memberFuncMap_[static_cast<uint32_t>(BluetoothHfpAgInterfaceCode::BT_HFP_AG_CONNECT_SCO)] =
38         &BluetoothHfpAgStub::ConnectScoInner;
39     memberFuncMap_[static_cast<uint32_t>(BluetoothHfpAgInterfaceCode::BT_HFP_AG_DISCONNECT_SCO)] =
40         &BluetoothHfpAgStub::DisconnectScoInner;
41     memberFuncMap_[static_cast<uint32_t>(BluetoothHfpAgInterfaceCode::BT_HFP_AG_PHONE_STATE_CHANGED)] =
42         &BluetoothHfpAgStub::PhoneStateChangedInner;
43     memberFuncMap_[static_cast<uint32_t>(BluetoothHfpAgInterfaceCode::BT_HFP_AG_CLCC_RESPONSE)] =
44         &BluetoothHfpAgStub::ClccResponseInner;
45     memberFuncMap_[static_cast<uint32_t>(BluetoothHfpAgInterfaceCode::BT_HFP_AG_OPEN_VOICE_RECOGNITION)] =
46         &BluetoothHfpAgStub::OpenVoiceRecognitionInner;
47     memberFuncMap_[static_cast<uint32_t>(BluetoothHfpAgInterfaceCode::BT_HFP_AG_CLOSE_VOICE_RECOGNITION)] =
48         &BluetoothHfpAgStub::CloseVoiceRecognitionInner;
49     memberFuncMap_[static_cast<uint32_t>(BluetoothHfpAgInterfaceCode::BT_HFP_AG_SET_ACTIVE_DEVICE)] =
50         &BluetoothHfpAgStub::SetActiveDeviceInner;
51     memberFuncMap_[static_cast<uint32_t>(BluetoothHfpAgInterfaceCode::BT_HFP_AG_GET_ACTIVE_DEVICE)] =
52         &BluetoothHfpAgStub::GetActiveDeviceInner;
53     memberFuncMap_[static_cast<uint32_t>(BluetoothHfpAgInterfaceCode::BT_HFP_AG_INTO_MOCK)] =
54         &BluetoothHfpAgStub::IntoMockInner;
55     memberFuncMap_[static_cast<uint32_t>(BluetoothHfpAgInterfaceCode::BT_HFP_AG_SEND_NO_CARRIER)] =
56         &BluetoothHfpAgStub::SendNoCarrierInner;
57     memberFuncMap_[static_cast<uint32_t>(BluetoothHfpAgInterfaceCode::BT_HFP_AG_REGISTER_OBSERVER)] =
58         &BluetoothHfpAgStub::RegisterObserverInner;
59     memberFuncMap_[static_cast<uint32_t>(BluetoothHfpAgInterfaceCode::BT_HFP_AG_DEREGISTER_OBSERVER)] =
60         &BluetoothHfpAgStub::DeregisterObserverInner;
61     memberFuncMap_[static_cast<uint32_t>(BluetoothHfpAgInterfaceCode::BT_HFP_AG_SET_CONNECT_STRATEGY)] =
62         &BluetoothHfpAgStub::SetConnectStrategyInner;
63     memberFuncMap_[static_cast<uint32_t>(BluetoothHfpAgInterfaceCode::BT_HFP_AG_GET_CONNECT_STRATEGY)] =
64         &BluetoothHfpAgStub::GetConnectStrategyInner;
65     memberFuncMap_[static_cast<uint32_t>(BluetoothHfpAgInterfaceCode::BT_HFP_AG_IS_IN_BAND_RINGING_ENABLE)] =
66         &BluetoothHfpAgStub::IsInbandRingingEnabledInner;
67     memberFuncMap_[static_cast<uint32_t>(BluetoothHfpAgInterfaceCode::BT_HFP_AG_CONNECT_SCO_EX)] =
68         &BluetoothHfpAgStub::ConnectScoInnerEx;
69     memberFuncMap_[static_cast<uint32_t>(BluetoothHfpAgInterfaceCode::BT_HFP_AG_DISCONNECT_SCO_EX)] =
70         &BluetoothHfpAgStub::DisconnectScoInnerEx;
71     memberFuncMap_[static_cast<uint32_t>(BluetoothHfpAgInterfaceCode::BT_HFP_AG_CALL_DETAILS_CHANGED)] =
72         &BluetoothHfpAgStub::CallDetailsChangedInner;
73     memberFuncMap_[static_cast<uint32_t>(BluetoothHfpAgInterfaceCode::BT_HFP_AG_IS_HFP_FEATURE_SUPPORTED)] =
74         &BluetoothHfpAgStub::IsHfpFeatureSupportedInner;
75     memberFuncMap_[static_cast<uint32_t>(BluetoothHfpAgInterfaceCode::BT_HFP_AG_CALL_LOG)] =
76         &BluetoothHfpAgStub::EnableBtCallLogInner;
77     memberFuncMap_[static_cast<uint32_t>(BluetoothHfpAgInterfaceCode::BT_HFP_AG_GET_VIRTUALDEVICE_LIST)] =
78         &BluetoothHfpAgStub::GetVirtualDeviceListInner;
79     memberFuncMap_[static_cast<uint32_t>(BluetoothHfpAgInterfaceCode::BT_HFP_AG_UPDATE_VIRTUALDEVICE)] =
80         &BluetoothHfpAgStub::UpdateVirtualDeviceInner;
81     memberFuncMap_[static_cast<uint32_t>(BluetoothHfpAgInterfaceCode::BT_HFP_AG_GET_CALLTYPE)] =
82         &BluetoothHfpAgStub::GetCurrentCallTypeInner;
83     HILOGI("%{public}s ends.", __func__);
84 }
85 
~BluetoothHfpAgStub()86 BluetoothHfpAgStub::~BluetoothHfpAgStub()
87 {
88     HILOGI("%{public}s start.", __func__);
89     memberFuncMap_.clear();
90 }
91 
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)92 int BluetoothHfpAgStub::OnRemoteRequest(
93     uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
94 {
95     HILOGI("BluetoothHfpAgStub::OnRemoteRequest, cmd = %{public}d, flags= %{public}d", code, option.GetFlags());
96     if (BluetoothHfpAgStub::GetDescriptor() != data.ReadInterfaceToken()) {
97         HILOGI("local descriptor is not equal to remote");
98         return ERR_INVALID_STATE;
99     }
100 
101     auto itFunc = memberFuncMap_.find(code);
102     if (itFunc != memberFuncMap_.end()) {
103         auto memberFunc = itFunc->second;
104         if (memberFunc != nullptr) {
105             return (this->*memberFunc)(data, reply);
106         }
107     }
108     HILOGW("BluetoothHfpAgStub::OnRemoteRequest, default case, need check.");
109     return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
110 }
111 
GetConnectDevicesInner(MessageParcel & data,MessageParcel & reply)112 int32_t BluetoothHfpAgStub::GetConnectDevicesInner(MessageParcel &data, MessageParcel &reply)
113 {
114     std::vector<BluetoothRawAddress> devices;
115     GetConnectDevices(devices);
116     uint32_t DevNum = devices.size();
117     if (!reply.WriteUint32(DevNum)) {
118         HILOGE("BluetoothHfpAgStub:WriteInt32 failed in: %{public}s.", __func__);
119         return BT_ERR_IPC_TRANS_FAILED;
120     }
121     for (uint32_t i = 0; i < DevNum; i++) {
122         if (!reply.WriteParcelable(&devices[i])) {
123             HILOGE("BluetoothHfpAgStub:WriteParcelable failed in: %{public}s.", __func__);
124             return BT_ERR_IPC_TRANS_FAILED;
125         }
126     }
127     return NO_ERROR;
128 }
129 
GetDevicesByStatesInner(MessageParcel & data,MessageParcel & reply)130 ErrCode BluetoothHfpAgStub::GetDevicesByStatesInner(MessageParcel &data, MessageParcel &reply)
131 {
132     std::vector<BluetoothRawAddress> devices;
133     std::vector<int> states;
134     data.ReadInt32Vector(&states);
135     GetDevicesByStates(states, devices);
136     uint32_t DevNum = devices.size();
137     if (!reply.WriteUint32(DevNum)) {
138         HILOGE("BluetoothHfpAgStub:WriteInt32 failed in: %{public}s.", __func__);
139         return ERR_INVALID_VALUE;
140     }
141     for (uint32_t i = 0; i < DevNum; i++) {
142         if (!reply.WriteParcelable(&devices[i])) {
143             HILOGE("BluetoothHfpAgStub:WriteParcelable failed in: %{public}s.", __func__);
144             return ERR_INVALID_VALUE;
145         }
146     }
147     return NO_ERROR;
148 }
149 
GetDeviceStateInner(MessageParcel & data,MessageParcel & reply)150 ErrCode BluetoothHfpAgStub::GetDeviceStateInner(MessageParcel &data, MessageParcel &reply)
151 {
152     std::shared_ptr<BluetoothRawAddress> device(data.ReadParcelable<BluetoothRawAddress>());
153     if (!device) {
154         return BT_ERR_IPC_TRANS_FAILED;
155     }
156     int32_t state;
157     int32_t errCode = GetDeviceState(*device, state);
158     if (!reply.WriteInt32(errCode)) {
159         HILOGE("BluetoothHfpAgStub: reply writing failed in: %{public}s.", __func__);
160         return BT_ERR_IPC_TRANS_FAILED;
161     }
162     if (errCode != NO_ERROR) {
163         HILOGE("internal error.");
164         return BT_ERR_INTERNAL_ERROR;
165     }
166     // write state
167     if (!reply.WriteInt32(state)) {
168         HILOGE("reply write failed.");
169         return BT_ERR_IPC_TRANS_FAILED;
170     }
171     return NO_ERROR;
172 }
173 
ConnectInner(MessageParcel & data,MessageParcel & reply)174 int32_t BluetoothHfpAgStub::ConnectInner(MessageParcel &data, MessageParcel &reply)
175 {
176     std::shared_ptr<BluetoothRawAddress> device(data.ReadParcelable<BluetoothRawAddress>());
177     if (!device) {
178         return BT_ERR_IPC_TRANS_FAILED;
179     }
180     int32_t errCode = Connect(*device);
181     if (!reply.WriteInt32(errCode)) {
182         HILOGE("BluetoothHfpAgStub: reply writing failed in: %{public}s.", __func__);
183         return BT_ERR_IPC_TRANS_FAILED;
184     }
185     return NO_ERROR;
186 }
187 
DisconnectInner(MessageParcel & data,MessageParcel & reply)188 int32_t BluetoothHfpAgStub::DisconnectInner(MessageParcel &data, MessageParcel &reply)
189 {
190     std::shared_ptr<BluetoothRawAddress> device(data.ReadParcelable<BluetoothRawAddress>());
191     if (!device) {
192         return BT_ERR_IPC_TRANS_FAILED;
193     }
194     int32_t errCode = Disconnect(*device);
195     if (!reply.WriteInt32(errCode)) {
196         HILOGE("BluetoothHfpAgStub: reply writing failed in: %{public}s.", __func__);
197         return BT_ERR_IPC_TRANS_FAILED;
198     }
199     return NO_ERROR;
200 }
201 
GetScoStateInner(MessageParcel & data,MessageParcel & reply)202 ErrCode BluetoothHfpAgStub::GetScoStateInner(MessageParcel &data, MessageParcel &reply)
203 {
204     std::shared_ptr<BluetoothRawAddress> device(data.ReadParcelable<BluetoothRawAddress>());
205     if (!device) {
206         return TRANSACTION_ERR;
207     }
208     int result = GetScoState(*device);
209     if (!reply.WriteInt32(result)) {
210         HILOGE("BluetoothHfpAgStub: reply writing failed in: %{public}s.", __func__);
211         return ERR_INVALID_VALUE;
212     }
213     return NO_ERROR;
214 }
215 
ConnectScoInner(MessageParcel & data,MessageParcel & reply)216 ErrCode BluetoothHfpAgStub::ConnectScoInner(MessageParcel &data, MessageParcel &reply)
217 {
218     bool result = ConnectSco();
219     if (!reply.WriteBool(result)) {
220         HILOGE("BluetoothHfpAgStub: reply writing failed in: %{public}s.", __func__);
221         return ERR_INVALID_VALUE;
222     }
223     return NO_ERROR;
224 }
225 
DisconnectScoInner(MessageParcel & data,MessageParcel & reply)226 ErrCode BluetoothHfpAgStub::DisconnectScoInner(MessageParcel &data, MessageParcel &reply)
227 {
228     bool result = DisconnectSco();
229     if (!reply.WriteBool(result)) {
230         HILOGE("BluetoothHfpAgStub: reply writing failed in: %{public}s.", __func__);
231         return ERR_INVALID_VALUE;
232     }
233     return NO_ERROR;
234 }
235 
PhoneStateChangedInner(MessageParcel & data,MessageParcel & reply)236 ErrCode BluetoothHfpAgStub::PhoneStateChangedInner(MessageParcel &data, MessageParcel &reply)
237 {
238     std::shared_ptr<BluetoothPhoneState> phoneState(data.ReadParcelable<BluetoothPhoneState>());
239     CHECK_AND_RETURN_LOG_RET(phoneState, BT_ERR_IPC_TRANS_FAILED,
240         "BluetoothHfpAgStub: read phone state failed");
241     PhoneStateChanged(*phoneState);
242     return NO_ERROR;
243 }
244 
ClccResponseInner(MessageParcel & data,MessageParcel & reply)245 ErrCode BluetoothHfpAgStub::ClccResponseInner(MessageParcel &data, MessageParcel &reply)
246 {
247     int index = data.ReadInt32();
248     int direction = data.ReadInt32();
249     int status = data.ReadInt32();
250     int mode = data.ReadInt32();
251     bool mpty = data.ReadBool();
252     std::string number = data.ReadString();
253     int type = data.ReadInt32();
254     ClccResponse(index, direction, status, mode, mpty, number, type);
255     return NO_ERROR;
256 }
257 
OpenVoiceRecognitionInner(MessageParcel & data,MessageParcel & reply)258 ErrCode BluetoothHfpAgStub::OpenVoiceRecognitionInner(MessageParcel &data, MessageParcel &reply)
259 {
260     std::shared_ptr<BluetoothRawAddress> device(data.ReadParcelable<BluetoothRawAddress>());
261     if (!device) {
262         return TRANSACTION_ERR;
263     }
264     int result = OpenVoiceRecognition(*device);
265     if (!reply.WriteInt32(result)) {
266         HILOGE("BluetoothHfpAgStub: reply writing failed in: %{public}s.", __func__);
267         return ERR_INVALID_VALUE;
268     }
269     return NO_ERROR;
270 }
271 
CloseVoiceRecognitionInner(MessageParcel & data,MessageParcel & reply)272 ErrCode BluetoothHfpAgStub::CloseVoiceRecognitionInner(MessageParcel &data, MessageParcel &reply)
273 {
274     std::shared_ptr<BluetoothRawAddress> device(data.ReadParcelable<BluetoothRawAddress>());
275     if (!device) {
276         return TRANSACTION_ERR;
277     }
278     int result = CloseVoiceRecognition(*device);
279     if (!reply.WriteInt32(result)) {
280         HILOGE("BluetoothHfpAgStub: reply writing failed in: %{public}s.", __func__);
281         return ERR_INVALID_VALUE;
282     }
283     return NO_ERROR;
284 }
285 
SetActiveDeviceInner(MessageParcel & data,MessageParcel & reply)286 ErrCode BluetoothHfpAgStub::SetActiveDeviceInner(MessageParcel &data, MessageParcel &reply)
287 {
288     std::shared_ptr<BluetoothRawAddress> device(data.ReadParcelable<BluetoothRawAddress>());
289     if (!device) {
290         return TRANSACTION_ERR;
291     }
292     int result = SetActiveDevice(*device);
293     if (!reply.WriteInt32(result)) {
294         HILOGE("BluetoothHfpAgStub: reply writing failed in: %{public}s.", __func__);
295         return ERR_INVALID_VALUE;
296     }
297     return NO_ERROR;
298 }
299 
IntoMockInner(MessageParcel & data,MessageParcel & reply)300 ErrCode BluetoothHfpAgStub::IntoMockInner(MessageParcel &data, MessageParcel &reply)
301 {
302     std::shared_ptr<BluetoothRawAddress> device(data.ReadParcelable<BluetoothRawAddress>());
303     if (!device) {
304         return TRANSACTION_ERR;
305     }
306     int state = data.ReadInt32();
307     int result = IntoMock(*device, state);
308     if (!reply.WriteInt32(result)) {
309         HILOGE("BluetoothHfpAgStub: reply writing failed in: %{public}s.", __func__);
310         return ERR_INVALID_VALUE;
311     }
312     return NO_ERROR;
313 }
314 
SendNoCarrierInner(MessageParcel & data,MessageParcel & reply)315 ErrCode BluetoothHfpAgStub::SendNoCarrierInner(MessageParcel &data, MessageParcel &reply)
316 {
317     std::shared_ptr<BluetoothRawAddress> device(data.ReadParcelable<BluetoothRawAddress>());
318     if (!device) {
319         return TRANSACTION_ERR;
320     }
321     int result = SendNoCarrier(*device);
322     if (!reply.WriteInt32(result)) {
323         HILOGE("BluetoothHfpAgStub: reply writing failed in: %{public}s.", __func__);
324         return ERR_INVALID_VALUE;
325     }
326     return NO_ERROR;
327 }
328 
GetActiveDeviceInner(MessageParcel & data,MessageParcel & reply)329 ErrCode BluetoothHfpAgStub::GetActiveDeviceInner(MessageParcel &data, MessageParcel &reply)
330 {
331     std::string result = GetActiveDevice();
332     if (!reply.WriteString(result)) {
333         HILOGE("BluetoothHfpAgStub: reply writing failed in: %{public}s.", __func__);
334         return ERR_INVALID_VALUE;
335     }
336     return NO_ERROR;
337 }
338 
RegisterObserverInner(MessageParcel & data,MessageParcel & reply)339 ErrCode BluetoothHfpAgStub::RegisterObserverInner(MessageParcel &data, MessageParcel &reply)
340 {
341     sptr<IRemoteObject> tempObject = data.ReadRemoteObject();
342     sptr<IBluetoothHfpAgObserver> observer = iface_cast<IBluetoothHfpAgObserver>(tempObject);
343     RegisterObserver(observer);
344     return NO_ERROR;
345 }
346 
DeregisterObserverInner(MessageParcel & data,MessageParcel & reply)347 ErrCode BluetoothHfpAgStub::DeregisterObserverInner(MessageParcel &data, MessageParcel &reply)
348 {
349     sptr<IRemoteObject> tempObject = data.ReadRemoteObject();
350     sptr<IBluetoothHfpAgObserver> observer = iface_cast<IBluetoothHfpAgObserver>(tempObject);
351     DeregisterObserver(observer);
352     return NO_ERROR;
353 }
354 
SetConnectStrategyInner(MessageParcel & data,MessageParcel & reply)355 ErrCode BluetoothHfpAgStub::SetConnectStrategyInner(MessageParcel &data, MessageParcel &reply)
356 {
357     int result = BT_ERR_SYSTEM_PERMISSION_FAILED;
358     if (!reply.WriteInt32(result)) {
359         HILOGE("BluetoothHfpAgStub: reply writing failed in: %{public}s.", __func__);
360         return ERR_INVALID_VALUE;
361     }
362     return NO_ERROR;
363 }
364 
GetConnectStrategyInner(MessageParcel & data,MessageParcel & reply)365 ErrCode BluetoothHfpAgStub::GetConnectStrategyInner(MessageParcel &data, MessageParcel &reply)
366 {
367     return NO_ERROR;
368 }
369 
IsInbandRingingEnabledInner(MessageParcel & data,MessageParcel & reply)370 ErrCode BluetoothHfpAgStub::IsInbandRingingEnabledInner(MessageParcel &data, MessageParcel &reply)
371 {
372     bool isEnabled = true;
373     int result = IsInbandRingingEnabled(isEnabled);
374     if (!reply.WriteInt32(result)) {
375         HILOGE("BluetoothHfpAgStub: reply writing failed in: %{public}s.", __func__);
376         return ERR_INVALID_VALUE;
377     }
378     if (!reply.WriteBool(isEnabled)) {
379         HILOGE("BluetoothHfpAgStub: reply writing failed in: %{public}s.", __func__);
380         return ERR_INVALID_VALUE;
381     }
382     return NO_ERROR;
383 }
384 
ConnectScoInnerEx(MessageParcel & data,MessageParcel & reply)385 ErrCode BluetoothHfpAgStub::ConnectScoInnerEx(MessageParcel &data, MessageParcel &reply)
386 {
387     bool result = ConnectSco();
388     if (!reply.WriteBool(result)) {
389         HILOGE("BluetoothHfpAgStub: reply writing failed in: %{public}s.", __func__);
390         return ERR_INVALID_VALUE;
391     }
392     return NO_ERROR;
393 }
394 
DisconnectScoInnerEx(MessageParcel & data,MessageParcel & reply)395 ErrCode BluetoothHfpAgStub::DisconnectScoInnerEx(MessageParcel &data, MessageParcel &reply)
396 {
397     bool result = DisconnectSco();
398     if (!reply.WriteBool(result)) {
399         HILOGE("BluetoothHfpAgStub: reply writing failed in: %{public}s.", __func__);
400         return ERR_INVALID_VALUE;
401     }
402     return NO_ERROR;
403 }
404 
CallDetailsChangedInner(MessageParcel & data,MessageParcel & reply)405 ErrCode BluetoothHfpAgStub::CallDetailsChangedInner(MessageParcel &data, MessageParcel &reply)
406 {
407     return NO_ERROR;
408 }
409 
EnableBtCallLogInner(MessageParcel & data,MessageParcel & reply)410 ErrCode BluetoothHfpAgStub::EnableBtCallLogInner(MessageParcel &data, MessageParcel &reply)
411 {
412     return NO_ERROR;
413 }
414 
IsHfpFeatureSupportedInner(MessageParcel & data,MessageParcel & reply)415 int32_t BluetoothHfpAgStub::IsHfpFeatureSupportedInner(MessageParcel &data, MessageParcel &reply)
416 {
417     std::shared_ptr<BluetoothRawAddress> device(data.ReadParcelable<BluetoothRawAddress>());
418     CHECK_AND_RETURN_LOG_RET(device, BT_ERR_IPC_TRANS_FAILED, "Read device address failed.");
419     int type = data.ReadInt32();
420     bool isSupported = false;
421     int32_t result = IsHfpFeatureSupported(*device, isSupported, type);
422     CHECK_AND_RETURN_LOG_RET(reply.WriteInt32(result), BT_ERR_INTERNAL_ERROR, "reply WriteInt32 failed");
423     CHECK_AND_RETURN_LOG_RET(reply.WriteBool(isSupported), BT_ERR_INTERNAL_ERROR, "reply WriteBool failed");
424     return NO_ERROR;
425 }
426 
UpdateVirtualDeviceInner(MessageParcel & data,MessageParcel & reply)427 int32_t BluetoothHfpAgStub::UpdateVirtualDeviceInner(MessageParcel &data, MessageParcel &reply)
428 {
429     return BT_ERR_API_NOT_SUPPORT;
430 }
431 
GetVirtualDeviceListInner(MessageParcel & data,MessageParcel & reply)432 int32_t BluetoothHfpAgStub::GetVirtualDeviceListInner(MessageParcel &data, MessageParcel &reply)
433 {
434     return BT_ERR_API_NOT_SUPPORT;
435 }
436 
GetCurrentCallTypeInner(MessageParcel & data,MessageParcel & reply)437 int32_t BluetoothHfpAgStub::GetCurrentCallTypeInner(MessageParcel &data, MessageParcel &reply)
438 {
439     return BT_ERR_API_NOT_SUPPORT;
440 }
441 }  // namespace Bluetooth
442 }  // namespace OHOS
443