Skip to content

Commit

Permalink
PAN: Fix disconnect stuck issue during multi device use case.
Browse files Browse the repository at this point in the history
Precondition:
Enable BT Tethering on peer devices

Use case:
1) DUT has been paired with 3 phones
2) After pair go to first device details
3) Enable Internet access to initiate PANU connection
4) After successful connection with first peer
5) Go to second devices details enable internet access
6) Repeat above steps multiple times

Observed result:
Received disconnected call back on the wrong(Connected) device.
So, in UI for disconnecting device, showing status as
Disconnecting until BT reset.

Fix:
During back to back calls of connect and disconnection
sometimes there is a chance of duplicate handles inside btpan_conn_t
So, retrieve btpan connection instance using bt address which is unique
instead of close handle, so that DUT always can send proper device during
connection state callback and to initiate proper cleanup during close connection.

CRs-Fixed: 2685265
Change-Id: If424e02ae67e6252fca8f5ad742543a6bb632114
  • Loading branch information
Sravan voleti authored and nshrivas committed Jun 10, 2020
1 parent 2a3136f commit 021b7b6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions bta/include/bta_pan_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ typedef struct {

/* Event associated with BTA_PAN_CLOSE_EVT */
typedef struct {
RawAddress bd_addr; /* BD address of peer device. */
uint16_t handle; /* Handle associated with the connection. */
} tBTA_PAN_CLOSE;

Expand Down
1 change: 1 addition & 0 deletions bta/pan/bta_pan_act.cc
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,7 @@ void bta_pan_conn_close(tBTA_PAN_SCB* p_scb, tBTA_PAN_DATA* p_data) {
BT_HDR* p_buf;

bta_pan.close.handle = p_data->hdr.layer_specific;
bta_pan.close.bd_addr = p_scb->bd_addr;

bta_sys_conn_close(BTA_ID_PAN, p_scb->app_id, p_scb->bd_addr);

Expand Down
6 changes: 4 additions & 2 deletions btif/src/btif_pan.cc
Original file line number Diff line number Diff line change
Expand Up @@ -621,17 +621,19 @@ static void bta_pan_callback_transfer(uint16_t event, char* p_param) {
case BTA_PAN_OPEN_EVT: {
btpan_connection_state_t state;
bt_status_t status;
btpan_conn_t* conn = btpan_find_conn_handle(p_data->open.handle);
btpan_conn_t* conn;

LOG_VERBOSE(LOG_TAG, "%s pan connection open status: %d", __func__,
p_data->open.status);
if (p_data->open.status == BTA_PAN_SUCCESS) {
state = BTPAN_STATE_CONNECTED;
status = BT_STATUS_SUCCESS;
conn = btpan_find_conn_handle(p_data->open.handle);
btpan_open_conn(conn, p_data);
} else {
state = BTPAN_STATE_DISCONNECTED;
status = BT_STATUS_FAIL;
conn = btpan_find_conn_addr(p_data->open.bd_addr);
btpan_cleanup_conn(conn);
}
/* debug("BTA_PAN_OPEN_EVT handle:%d, conn:%p", p_data->open.handle,
Expand All @@ -647,7 +649,7 @@ static void bta_pan_callback_transfer(uint16_t event, char* p_param) {
case BTA_PAN_CLOSE_EVT: {
LOG_INFO(LOG_TAG, "%s event = BTA_PAN_CLOSE_EVT handle %d", __func__,
p_data->close.handle);
btpan_conn_t* conn = btpan_find_conn_handle(p_data->close.handle);
btpan_conn_t* conn = btpan_find_conn_addr(p_data->close.bd_addr);

if (conn && conn->handle >= 0) {
int btpan_conn_local_role = bta_role_to_btpan(conn->local_role);
Expand Down

0 comments on commit 021b7b6

Please sign in to comment.