From cb8aeef3e3a3462bfcde86bb194b192e311d1e50 Mon Sep 17 00:00:00 2001 From: "yangkuo (A)" <1041733144@qq.com> Date: Sat, 14 Jun 2025 17:32:55 +0800 Subject: [PATCH] get current calltype Signed-off-by: yangkuo (A) <1041733144@qq.com> --- .../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 | 8 ++++++++ interfaces/inner_api/include/bluetooth_hfp_ag.h | 7 +++++++ 6 files changed, 34 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..1827ba93 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; + int GetCurrentCallType() 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..54d3effc 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_GET_CALLTYPE, // 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..b7c5bf99 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 int GetCurrentCallType() = 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..2dfbc436 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); } + +int BluetoothHfpAgProxy::GetCurrentCallType() +{ + MessageParcel data; + CHECK_AND_RETURN_LOG_RET(data.WriteInterfaceToken(BluetoothHfpAgProxy::GetDescriptor()), + BT_ERR_IPC_TRANS_FAILED, "WriteInterfaceToken error"); + + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + + SEND_IPC_REQUEST_RETURN_RESULT(BluetoothHfpAgInterfaceCode::BT_HFP_AG_GET_CALLTYPE, + data, reply, option, BT_ERR_IPC_TRANS_FAILED); + + return reply.ReadInt32(); +} + } // namespace Bluetooth } // namespace OHOS diff --git a/frameworks/inner/src/bluetooth_hfp_ag.cpp b/frameworks/inner/src/bluetooth_hfp_ag.cpp index aafa3a00..298fcdc6 100644 --- a/frameworks/inner/src/bluetooth_hfp_ag.cpp +++ b/frameworks/inner/src/bluetooth_hfp_ag.cpp @@ -378,6 +378,14 @@ struct HandsFreeAudioGateway::impl { HILOGI("end"); } + int GetCurrentCallType() + { + HILOGD("enter"); + sptr proxy = GetRemoteProxy(PROFILE_HFP_AG); + CHECK_AND_RETURN_LOG_RET(proxy != nullptr, BT_ERR_UNAVAILABLE_PROXY, "proxy is null"); + return proxy->GetCurrentCallType(); + } + int32_t profileRegisterId = 0; private: const static int HFP_AG_SLC_STATE_DISCONNECTED = static_cast(BTConnectState::DISCONNECTED); diff --git a/interfaces/inner_api/include/bluetooth_hfp_ag.h b/interfaces/inner_api/include/bluetooth_hfp_ag.h index 81812926..72c86263 100644 --- a/interfaces/inner_api/include/bluetooth_hfp_ag.h +++ b/interfaces/inner_api/include/bluetooth_hfp_ag.h @@ -394,6 +394,13 @@ public: */ void GetVirtualDeviceList(std::vector &devices) const; + /** + * @brief get current call type. + * + * @since 20 + */ + int GetCurrentCallType(); + /** * @brief Static HandsFree AudioGateway observer instance. * -- Gitee