From e8020504372716d9738076bf24ec5c78a44a7739 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E9=98=94?= Date: Wed, 4 Jun 2025 16:35:11 +0800 Subject: [PATCH] get whether vr support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 杨阔 --- .../inner/ipc/include/bluetooth_hfp_ag_proxy.h | 1 + .../bluetooth_service_profile_interface_code.h | 1 + .../inner/ipc/interface/i_bluetooth_hfp_ag.h | 1 + .../inner/ipc/src/bluetooth_hfp_ag_proxy.cpp | 16 ++++++++++++++++ frameworks/inner/src/bluetooth_hfp_ag.cpp | 9 +++++++++ interfaces/inner_api/include/bluetooth_hfp_ag.h | 10 ++++++++++ 6 files changed, 38 insertions(+) diff --git a/frameworks/inner/ipc/include/bluetooth_hfp_ag_proxy.h b/frameworks/inner/ipc/include/bluetooth_hfp_ag_proxy.h index 1dc29d99..90851264 100644 --- a/frameworks/inner/ipc/include/bluetooth_hfp_ag_proxy.h +++ b/frameworks/inner/ipc/include/bluetooth_hfp_ag_proxy.h @@ -54,6 +54,7 @@ public: void EnableBtCallLog(bool state) override; void GetVirtualDeviceList(std::vector &devices) override; void UpdateVirtualDevice(int32_t action, const std::string &address) override; + bool IsVoiceRecognitionSupported(const BluetoothRawAddress &device) override; private: static inline BrokerDelegator delegator_; diff --git a/frameworks/inner/ipc/interface/bluetooth_service_profile_interface_code.h b/frameworks/inner/ipc/interface/bluetooth_service_profile_interface_code.h index 39553c50..847d0a89 100644 --- a/frameworks/inner/ipc/interface/bluetooth_service_profile_interface_code.h +++ b/frameworks/inner/ipc/interface/bluetooth_service_profile_interface_code.h @@ -232,6 +232,7 @@ enum BluetoothHfpAgInterfaceCode { BT_HFP_AG_CALL_LOG, BT_HFP_AG_GET_VIRTUALDEVICE_LIST, BT_HFP_AG_UPDATE_VIRTUALDEVICE, + BT_HFP_AG_IS_VOICE_RECOGNITION_SUPPORTED, // The last code, if you want to add a new code, please add it before this BT_HFP_AG_BUTT }; diff --git a/frameworks/inner/ipc/interface/i_bluetooth_hfp_ag.h b/frameworks/inner/ipc/interface/i_bluetooth_hfp_ag.h index 6489c41f..8be78e35 100644 --- a/frameworks/inner/ipc/interface/i_bluetooth_hfp_ag.h +++ b/frameworks/inner/ipc/interface/i_bluetooth_hfp_ag.h @@ -57,6 +57,7 @@ public: virtual void EnableBtCallLog(bool state) = 0; virtual void GetVirtualDeviceList(std::vector &devices) = 0; virtual void UpdateVirtualDevice(int32_t action, const std::string &address) = 0; + virtual bool IsVoiceRecognitionSupported(const BluetoothRawAddress &device) = 0; }; } // namespace Bluetooth diff --git a/frameworks/inner/ipc/src/bluetooth_hfp_ag_proxy.cpp b/frameworks/inner/ipc/src/bluetooth_hfp_ag_proxy.cpp index a8f910f9..e164229a 100644 --- a/frameworks/inner/ipc/src/bluetooth_hfp_ag_proxy.cpp +++ b/frameworks/inner/ipc/src/bluetooth_hfp_ag_proxy.cpp @@ -489,5 +489,21 @@ void BluetoothHfpAgProxy::UpdateVirtualDevice(int32_t action, const std::string SEND_IPC_REQUEST_RETURN(BluetoothHfpAgInterfaceCode::BT_HFP_AG_UPDATE_VIRTUALDEVICE, data, reply, option); } + +bool BluetoothHfpAgProxy::IsVoiceRecognitionSupported(const BluetoothRawAddress &device) +{ + MessageParcel data; + CHECK_AND_RETURN_LOG_RET(data.WriteInterfaceToken(BluetoothHfpAgProxy::GetDescriptor()), + false, "WriteInterfaceToken error"); + CHECK_AND_RETURN_LOG_RET(data.WriteParcelable(&device), false, "write address error"); + + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + + SEND_IPC_REQUEST_RETURN_RESULT(BluetoothHfpAgInterfaceCode::BT_HFP_AG_IS_VOICE_RECOGNITION_SUPPORTED, + data, reply, option, false); + + return reply.ReadBool(); +} } // namespace Bluetooth } // namespace OHOS diff --git a/frameworks/inner/src/bluetooth_hfp_ag.cpp b/frameworks/inner/src/bluetooth_hfp_ag.cpp index aafa3a00..449b2186 100644 --- a/frameworks/inner/src/bluetooth_hfp_ag.cpp +++ b/frameworks/inner/src/bluetooth_hfp_ag.cpp @@ -727,6 +727,15 @@ void HandsFreeAudioGateway::GetVirtualDeviceList(std::vector &devic proxy->GetVirtualDeviceList(devices); } +bool HandsFreeAudioGateway::IsVoiceRecognitionSupported(const BluetoothRemoteDevice &device) const +{ + CHECK_AND_RETURN_LOG_RET(IS_BT_ENABLED(), BT_ERR_INVALID_STATE, "bluetooth is off."); + sptr proxy = GetRemoteProxy(PROFILE_HFP_AG); + CHECK_AND_RETURN_LOG_RET(proxy != nullptr, BT_ERR_INTERNAL_ERROR, "hfpAG proxy is nullptr"); + + return proxy->IsVoiceRecognitionSupported(BluetoothRawAddress(device.GetDeviceAddr())); +} + void HandsFreeAudioGateway::RegisterObserver(std::shared_ptr observer) { HILOGD("enter"); diff --git a/interfaces/inner_api/include/bluetooth_hfp_ag.h b/interfaces/inner_api/include/bluetooth_hfp_ag.h index 81812926..690a1bab 100644 --- a/interfaces/inner_api/include/bluetooth_hfp_ag.h +++ b/interfaces/inner_api/include/bluetooth_hfp_ag.h @@ -393,6 +393,16 @@ public: * @since 12 */ void GetVirtualDeviceList(std::vector &devices) const; + + /** + * Check whether voice recognition is supported. + * + * @param devices remote device object. + * @return Returns true if the voice recognition is supported. + * returns false if the voice recognition is not supported. + * @since 20 + */ + bool IsVoiceRecognitionSupported(const BluetoothRemoteDevice &device) const; /** * @brief Static HandsFree AudioGateway observer instance. -- Gitee