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.
This commit is contained in:
Jin Cheng 2023-11-17 09:28:34 +08:00
parent 77430f3e2d
commit 659ae0ce9e

View File

@ -358,13 +358,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
}
@ -1264,9 +1267,12 @@ void btc_hf_cb_handler(btc_msg_t *msg)
switch (event) {
case BTA_AG_ENABLE_EVT:
case BTA_AG_DISABLE_EVT:
break;
case BTA_AG_DISABLE_EVT:
{
btc_hf_cb_release();
break;
}
case BTA_AG_REGISTER_EVT:
{
idx = p_data->hdr.handle - 1;