From 4a37aefdabd961f3e651b9705f3ba56d0b605e24 Mon Sep 17 00:00:00 2001 From: hcj <1224667075@qq.com> Date: Fri, 22 Nov 2024 15:00:33 +0800 Subject: [PATCH] =?utf8?q?=E8=93=9D=E7=89=99=E6=8E=A5=E5=8F=A3=E5=A2=9E?= =?utf8?q?=E5=8A=A0=E5=88=9D=E5=A7=8B=E5=8C=96=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../bluetooth/include/BluetoothModelC.h | 1 + .../nativeui/bluetooth/src/BluetoothModel.cpp | 20 +++++++++++++++++++ .../phoneservice/src/PhoneService.cpp | 20 +++++++++++++++---- 3 files changed, 37 insertions(+), 4 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/bluetooth/include/BluetoothModelC.h b/code/sdk/application/wearable/fd230app/nativeui/bluetooth/include/BluetoothModelC.h index ab02f9fcf..8f76d5b50 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bluetooth/include/BluetoothModelC.h +++ b/code/sdk/application/wearable/fd230app/nativeui/bluetooth/include/BluetoothModelC.h @@ -31,6 +31,7 @@ int32_t BtA2dpSnkAudioDestroy(void); int uapi_reconnect_(void); +int get_BT_is_init(void); #ifdef __cplusplus } diff --git a/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothModel.cpp index 38743aaed..0f7384c0c 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothModel.cpp @@ -1809,8 +1809,19 @@ void BleAdvStart(void) WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "BleAdvStart bt gap_ble_start_adv ret = 0x%x", ret); } //////////////////////////////////A2DP sink端 代码/////////////////////////////////////////////// + +int get_BT_is_init() +{ + return g_bluetooth_initialled; +} + int uapi_a2dp_snk_get_device_connect_state() { + if(get_BT_is_init()==0) + { + return 0; + } + int ret = a2dp_snk_get_device_connect_state(&g_bd_addr); WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP,"state(int): %d\n", ret); @@ -1860,6 +1871,11 @@ int uapi_a2dp_snk_connect() int uapi_a2dp_snk_connect_() { + if(get_BT_is_init()==0) + { + return 0; + } + bd_addr_t bdaddr={0}; uapi_get_br_address(&bdaddr); @@ -1881,6 +1897,10 @@ int uapi_a2dp_snk_disconnect() int uapi_a2dp_snk_disconnect_() { + if(get_BT_is_init()==0) + { + return 0; + } bd_addr_t bdaddr={0}; uapi_get_br_address(&bdaddr); diff --git a/code/sdk/application/wearable/fd230app/nativeui/phoneservice/src/PhoneService.cpp b/code/sdk/application/wearable/fd230app/nativeui/phoneservice/src/PhoneService.cpp index 3c800e987..a9ca82338 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phoneservice/src/PhoneService.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/phoneservice/src/PhoneService.cpp @@ -789,6 +789,7 @@ static void ScoStateChanged(const bd_addr_t *bdAddr, hfp_sco_connect_state_t sta case HFP_SCO_STATE_CONNECTED: // 同步音量 SyncVolume(); + if(TransCallToMobilePhone_falg) { TransCallToMobilePhone(); @@ -2253,6 +2254,11 @@ int TransCallToMobilePhone(void) int uapi_hfp_disconnect_(void) { + if( get_BT_is_init()==0) + { + return 0; + } + int ret; bd_addr_t bdaddr={0}; OHOS:: uapi_get_br_address(&bdaddr); @@ -2266,10 +2272,11 @@ int uapi_hfp_disconnect_(void) int uapi_hfp_connect_(void) { - // if(uapi_hfp_connect_state()==1) - // { - // return; - // } + if( get_BT_is_init()==0) + { + return 0; + } + int ret; bd_addr_t bdaddr={0}; OHOS:: uapi_get_br_address(&bdaddr); @@ -2330,6 +2337,11 @@ int uapi_hfp_connect_(void) int uapi_hfp_connect_state(void) { + if( get_BT_is_init()==0) + { + return 0; + } + int ret; bd_addr_t bdaddr={0}; OHOS:: uapi_get_br_address(&bdaddr); -- 2.17.1