From 9621904cdccebb5fa8d2388d60538deb22bcbe03 Mon Sep 17 00:00:00 2001 From: wangmengyang Date: Fri, 7 Sep 2018 12:03:33 +0800 Subject: [PATCH] component/bt: stop to initiate AVDTP connection on failure of A2DP service discovery In opening state of AVDTP connection, if SDP client fails to get valid A2DP service record\ from peer SDP server, then do not initiate AVDTP connection request --- components/bt/bluedroid/bta/av/bta_av_aact.c | 30 +++++++++++++++++++ components/bt/bluedroid/bta/av/bta_av_ssm.c | 3 +- .../bt/bluedroid/bta/av/include/bta_av_int.h | 1 + 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/components/bt/bluedroid/bta/av/bta_av_aact.c b/components/bt/bluedroid/bta/av/bta_av_aact.c index 06c5022b2b..badcfce5ad 100644 --- a/components/bt/bluedroid/bta/av/bta_av_aact.c +++ b/components/bt/bluedroid/bta/av/bta_av_aact.c @@ -143,6 +143,7 @@ const tBTA_AV_SACT bta_av_a2d_action[] = { bta_av_role_res, /* BTA_AV_ROLE_RES */ bta_av_delay_co, /* BTA_AV_DELAY_CO */ bta_av_open_at_inc, /* BTA_AV_OPEN_AT_INC */ + bta_av_open_fail_sdp, /* BTA_AV_OPEN_FAIL_SDP */ NULL }; @@ -1060,6 +1061,35 @@ void bta_av_free_sdb(tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data) utl_freebuf((void **) &p_scb->p_disc_db); } +/******************************************************************************* +** +** Function bta_av_open_fail_sdp +** +** Description report BTA_AV_OPEN_EVT with service discovery failed status +** +** Returns void +** +*******************************************************************************/ +void bta_av_open_fail_sdp(tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data) +{ + tBTA_AV_OPEN open; + + bdcpy(open.bd_addr, p_scb->peer_addr); + open.chnl = p_scb->chnl; + open.hndl = p_scb->hndl; + open.status = BTA_AV_FAIL_SDP; + + if (p_scb->seps[p_scb->sep_idx].tsep == AVDT_TSEP_SRC ) { + open.sep = AVDT_TSEP_SNK; + } else if (p_scb->seps[p_scb->sep_idx].tsep == AVDT_TSEP_SNK ) { + open.sep = AVDT_TSEP_SRC; + } + + (*bta_av_cb.p_cback)(BTA_AV_OPEN_EVT, (tBTA_AV *) &open); + + UNUSED(p_data); +} + /******************************************************************************* ** ** Function bta_av_config_ind diff --git a/components/bt/bluedroid/bta/av/bta_av_ssm.c b/components/bt/bluedroid/bta/av/bta_av_ssm.c index 45fa9242be..ad21e8763e 100644 --- a/components/bt/bluedroid/bta/av/bta_av_ssm.c +++ b/components/bt/bluedroid/bta/av/bta_av_ssm.c @@ -94,6 +94,7 @@ enum { BTA_AV_ROLE_RES, BTA_AV_DELAY_CO, BTA_AV_OPEN_AT_INC, + BTA_AV_OPEN_FAIL_SDP, BTA_AV_NUM_SACTIONS }; @@ -199,7 +200,7 @@ static const UINT8 bta_av_sst_opening[][BTA_AV_NUM_COLS] = { /* CI_SETCONFIG_OK_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST }, /* CI_SETCONFIG_FAIL_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST }, /* SDP_DISC_OK_EVT */ {BTA_AV_CONNECT_REQ, BTA_AV_SIGNORE, BTA_AV_OPENING_SST }, - /* SDP_DISC_FAIL_EVT */ {BTA_AV_CONNECT_REQ, BTA_AV_SIGNORE, BTA_AV_OPENING_SST }, + /* SDP_DISC_FAIL_EVT */ {BTA_AV_FREE_SDB, BTA_AV_OPEN_FAIL_SDP, BTA_AV_INIT_SST }, /* STR_DISC_OK_EVT */ {BTA_AV_DISC_RESULTS, BTA_AV_SIGNORE, BTA_AV_OPENING_SST }, /* STR_DISC_FAIL_EVT */ {BTA_AV_OPEN_FAILED, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST }, /* STR_GETCAP_OK_EVT */ {BTA_AV_GETCAP_RESULTS, BTA_AV_SIGNORE, BTA_AV_OPENING_SST }, diff --git a/components/bt/bluedroid/bta/av/include/bta_av_int.h b/components/bt/bluedroid/bta/av/include/bta_av_int.h index 7fc6643f9f..16b3f38dfe 100644 --- a/components/bt/bluedroid/bta/av/include/bta_av_int.h +++ b/components/bt/bluedroid/bta/av/include/bta_av_int.h @@ -661,6 +661,7 @@ extern void bta_av_switch_role (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); extern void bta_av_role_res (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); extern void bta_av_delay_co (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); extern void bta_av_open_at_inc (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); +extern void bta_av_open_fail_sdp (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data); /* ssm action functions - vdp specific */ extern void bta_av_do_disc_vdp (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);