From 3c088db87328bdb138ebc93df558e22226597a07 Mon Sep 17 00:00:00 2001 From: Jin Cheng Date: Thu, 16 Nov 2023 20:09:29 +0800 Subject: [PATCH 1/6] fix(bt/bluedroid): Added dynamic memory allocation for HFP control blocks --- .../bluedroid/btc/profile/std/hf_ag/btc_hf_ag.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/components/bt/host/bluedroid/btc/profile/std/hf_ag/btc_hf_ag.c b/components/bt/host/bluedroid/btc/profile/std/hf_ag/btc_hf_ag.c index 8ababa1c6fc..be2866e81c0 100644 --- a/components/bt/host/bluedroid/btc/profile/std/hf_ag/btc_hf_ag.c +++ b/components/bt/host/bluedroid/btc/profile/std/hf_ag/btc_hf_ag.c @@ -66,7 +66,7 @@ static UINT16 btc_max_hf_clients = BTC_HF_NUM_CB; #if HFP_DYNAMIC_MEMORY == FALSE static hf_local_param_t hf_local_param[BTC_HF_NUM_CB]; #else -static hf_local_param_t *hf_local_param; +static hf_local_param_t *hf_local_param = NULL; #endif #if (BTM_WBS_INCLUDED == TRUE) @@ -315,6 +315,19 @@ bt_status_t btc_hf_init(void) int idx = 0; BTC_TRACE_DEBUG("%s - max_hf_clients=%d", __func__, btc_max_hf_clients); + +#if HFP_DYNAMIC_MEMORY == TRUE + if (hf_local_param != NULL) { + return BT_STATUS_FAIL; + } + + if ((hf_local_param = (hf_local_param_t *)osi_malloc(BTC_HF_NUM_CB * sizeof(hf_local_param_t))) == NULL) { + APPL_TRACE_ERROR("%s malloc failed!", __func__); + return BT_STATUS_NOMEM; + } + memset((void *)hf_local_param, 0, BTC_HF_NUM_CB * sizeof(hf_local_param_t)); +#endif + /* Invoke the enable service API to the core to set the appropriate service_id * Internally, the HSP_SERVICE_ID shall also be enabled if HFP is enabled (phone) * othwerwise only HSP is enabled (tablet)*/ From 94faa4a1123eaddafd27512831359ef40395cccf Mon Sep 17 00:00:00 2001 From: Jin Cheng Date: Fri, 17 Nov 2023 09:28:34 +0800 Subject: [PATCH 2/6] fix(bt/bluedroid): Avoided crash of LoadProhibited during HFP AG deinitialization Move the release of the control blocks from the start of deinitialization to the profile disabled event. --- .../host/bluedroid/btc/profile/std/hf_ag/btc_hf_ag.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/components/bt/host/bluedroid/btc/profile/std/hf_ag/btc_hf_ag.c b/components/bt/host/bluedroid/btc/profile/std/hf_ag/btc_hf_ag.c index be2866e81c0..a8b03fae212 100644 --- a/components/bt/host/bluedroid/btc/profile/std/hf_ag/btc_hf_ag.c +++ b/components/bt/host/bluedroid/btc/profile/std/hf_ag/btc_hf_ag.c @@ -354,13 +354,16 @@ void btc_hf_deinit(void) { BTC_TRACE_EVENT("%s", __FUNCTION__); btc_dm_disable_service(BTA_HFP_SERVICE_ID); + hf_local_param[0].btc_hf_cb.initialized = false; +} + +static void btc_hf_cb_release(void) +{ #if HFP_DYNAMIC_MEMORY == TRUE if (hf_local_param) { osi_free(hf_local_param); hf_local_param = NULL; } -#else - hf_local_param[0].btc_hf_cb.initialized = false; #endif } @@ -1260,9 +1263,12 @@ void btc_hf_cb_handler(btc_msg_t *msg) switch (event) { case BTA_AG_ENABLE_EVT: + break; case BTA_AG_DISABLE_EVT: + { + btc_hf_cb_release(); break; - + } case BTA_AG_REGISTER_EVT: { idx = p_data->hdr.handle - 1; From bf7e27d126e58d328eb9aa22879f8b7d1f63b453 Mon Sep 17 00:00:00 2001 From: Jin Cheng Date: Fri, 17 Nov 2023 09:33:32 +0800 Subject: [PATCH 3/6] fix(bt/bluedroid): Corrected the definitions of HF Client callback events --- .../bt/host/bluedroid/bta/hf_client/bta_hf_client_api.c | 3 ++- .../bt/host/bluedroid/bta/include/bta/bta_hf_client_api.h | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/components/bt/host/bluedroid/bta/hf_client/bta_hf_client_api.c b/components/bt/host/bluedroid/bta/hf_client/bta_hf_client_api.c index 104182412a3..6149d8c4189 100644 --- a/components/bt/host/bluedroid/bta/hf_client/bta_hf_client_api.c +++ b/components/bt/host/bluedroid/bta/hf_client/bta_hf_client_api.c @@ -61,7 +61,8 @@ static const uint8_t bta_hf_client_cb_data_size[] = { sizeof(tBTA_HF_CLIENT_VAL), // #define BTA_HF_CLIENT_BSIR_EVT 19 sizeof(tBTA_HF_CLIENT_NUMBER), // #define BTA_HF_CLIENT_BINP_EVT 20 sizeof(tBTA_HF_CLIENT_VAL), // #define BTA_HF_CLIENT_RING_INDICATION 21 - 0, // #define BTA_HF_CLIENT_DISABLE_EVT 30 + 0, // #define BTA_HF_CLIENT_DISABLE_EVT 22 + sizeof(tBTA_SCO_PKT_STAT_NUMS), // #define BTA_HF_CLIENT_PKT_STAT_NUMS_GET_EVT 23 }; /***************************************************************************** ** External Function Declarations diff --git a/components/bt/host/bluedroid/bta/include/bta/bta_hf_client_api.h b/components/bt/host/bluedroid/bta/include/bta/bta_hf_client_api.h index 30ca233b69f..ac834c7b6f7 100644 --- a/components/bt/host/bluedroid/bta/include/bta/bta_hf_client_api.h +++ b/components/bt/host/bluedroid/bta/include/bta/bta_hf_client_api.h @@ -112,8 +112,8 @@ typedef UINT8 tBTA_HF_CLIENT_AT_RESULT_TYPE; #define BTA_HF_CLIENT_BSIR_EVT 19 /* in-band ring tone setting changed event */ #define BTA_HF_CLIENT_BINP_EVT 20 /* binp number event */ #define BTA_HF_CLIENT_RING_INDICATION 21 /* HF Client ring indication */ -#define BTA_HF_CLIENT_DISABLE_EVT 30 /* HF Client disabled */ -#define BTA_HF_CLIENT_PKT_STAT_NUMS_GET_EVT 31 /* HF Client packet status nums */ +#define BTA_HF_CLIENT_DISABLE_EVT 22 /* HF Client disabled */ +#define BTA_HF_CLIENT_PKT_STAT_NUMS_GET_EVT 23 /* HF Client packet status nums */ typedef UINT8 tBTA_HF_CLIENT_EVT; From 5f621c33da25b5a004765a7afe42832f6e215ef5 Mon Sep 17 00:00:00 2001 From: Jin Cheng Date: Fri, 17 Nov 2023 11:50:07 +0800 Subject: [PATCH 4/6] fix(bt/bluedroid): Removed redundant operation of SCO clean up --- components/bt/host/bluedroid/bta/hf_ag/bta_ag_act.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/components/bt/host/bluedroid/bta/hf_ag/bta_ag_act.c b/components/bt/host/bluedroid/bta/hf_ag/bta_ag_act.c index 6bb9de6cc15..c2e2773792c 100644 --- a/components/bt/host/bluedroid/bta/hf_ag/bta_ag_act.c +++ b/components/bt/host/bluedroid/bta/hf_ag/bta_ag_act.c @@ -397,10 +397,6 @@ void bta_ag_rfc_close(tBTA_AG_SCB *p_scb, tBTA_AG_DATA *p_data) bta_sys_conn_close(BTA_ID_AG, p_scb->app_id, p_scb->peer_addr); - /* call close call-out */ -#if (BTM_SCO_HCI_INCLUDED == TRUE) - bta_ag_sco_co_close(); -#endif /* call close cback */ (*bta_ag_cb.p_cback)(BTA_AG_CLOSE_EVT, (tBTA_AG *) &close); From 885c070eb814194b05fa1b6799e5b2509562eca6 Mon Sep 17 00:00:00 2001 From: Jin Cheng Date: Tue, 5 Dec 2023 19:21:59 +0800 Subject: [PATCH 5/6] fix(bt/bluedroid): Changed the default air mode to invalid value --- components/bt/host/bluedroid/btc/profile/std/hf_ag/bta_ag_co.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/bt/host/bluedroid/btc/profile/std/hf_ag/bta_ag_co.c b/components/bt/host/bluedroid/btc/profile/std/hf_ag/bta_ag_co.c index 84d006647a8..6000f8324c2 100644 --- a/components/bt/host/bluedroid/btc/profile/std/hf_ag/bta_ag_co.c +++ b/components/bt/host/bluedroid/btc/profile/std/hf_ag/bta_ag_co.c @@ -82,7 +82,7 @@ static bta_ag_co_cb_t *bta_ag_co_cb_ptr; #define bta_ag_co_cb (*bta_ag_co_cb_ptr) #endif /* HFP_DYNAMIC_MEMORY == FALSE */ -static UINT8 hf_air_mode = BTM_SCO_AIR_MODE_TRANSPNT; +static UINT8 hf_air_mode = BTM_SCO_AIR_MODE_UNKNOWN; static UINT8 hf_inout_pkt_size = 0; /* ========================================================================= From f7cfcebe69760f1537115a0feb19b0cef73fef1f Mon Sep 17 00:00:00 2001 From: Jin Cheng Date: Tue, 5 Dec 2023 19:25:13 +0800 Subject: [PATCH 6/6] fix(bt/bluedroid): Disabled Sniff Subrating temporarily as it did not work well --- components/bt/host/bluedroid/common/include/common/bt_target.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/bt/host/bluedroid/common/include/common/bt_target.h b/components/bt/host/bluedroid/common/include/common/bt_target.h index aaf1a0a8f87..bb47f9a6432 100644 --- a/components/bt/host/bluedroid/common/include/common/bt_target.h +++ b/components/bt/host/bluedroid/common/include/common/bt_target.h @@ -1010,7 +1010,7 @@ /* TRUE to include Sniff Subrating */ #if (BTA_DM_PM_INCLUDED == TRUE) #ifndef BTM_SSR_INCLUDED -#define BTM_SSR_INCLUDED TRUE +#define BTM_SSR_INCLUDED FALSE #endif #endif /* BTA_DM_PM_INCLUDED */