Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fb052951 authored by Jakub Pawlowski's avatar Jakub Pawlowski
Browse files

Fix GATT Server disconnecting for no reason

Connections created by GAP profile should be ephemeral, and not
interfere with the connection timeout.

When a device is bonded, listing services through DM would cause a
DM APP to create a connection, and later to disconnect. This causes
connection to timeout. In case a device was already connected, this
should not happen.

Bug: 34951749
Test: manual
Change-Id: Iad04fd9eed4c664f35131442e3f83a704497a067
parent 2af5cc78
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -4647,9 +4647,15 @@ void btm_dm_start_gatt_discovery(BD_ADDR bd_addr) {
    memset(bta_dm_search_cb.pending_close_bda, 0, BD_ADDR_LEN);
    alarm_cancel(bta_dm_search_cb.gatt_close_timer);
    btm_dm_start_disc_gatt_services(bta_dm_search_cb.conn_id);
  } else
  } else {
    if (BTM_IsAclConnectionUp(bd_addr, BT_TRANSPORT_LE)) {
      BTA_GATTC_Open(bta_dm_search_cb.client_if, bd_addr, true,
                     BTA_GATT_TRANSPORT_LE, true);
    } else {
      BTA_GATTC_Open(bta_dm_search_cb.client_if, bd_addr, true,
                   BTA_GATT_TRANSPORT_LE);
                     BTA_GATT_TRANSPORT_LE, false);
    }
  }
}

/*******************************************************************************
+1 −1
Original line number Diff line number Diff line
@@ -432,7 +432,7 @@ void bta_gattc_open(tBTA_GATTC_CLCB* p_clcb, tBTA_GATTC_DATA* p_data) {

  /* open/hold a connection */
  if (!GATT_Connect(p_clcb->p_rcb->client_if, p_data->api_conn.remote_bda, true,
                    p_data->api_conn.transport, false,
                    p_data->api_conn.transport, p_data->api_conn.opportunistic,
                    p_data->api_conn.initiating_phys)) {
    APPL_TRACE_ERROR("Connection open failure");

+8 −3
Original line number Diff line number Diff line
@@ -127,16 +127,20 @@ void BTA_GATTC_AppDeregister(tBTA_GATTC_IF client_if) {
 *                  transport: Transport to be used for GATT connection
 *                             (BREDR/LE)
 *                  initiating_phys: LE PHY to use, optional
 *                  opportunistic: wether the connection shall be opportunistic,
 *                                 and don't impact the disconnection timer
 *
 ******************************************************************************/
void BTA_GATTC_Open(tBTA_GATTC_IF client_if, BD_ADDR remote_bda, bool is_direct,
                    tBTA_GATT_TRANSPORT transport) {
                    tBTA_GATT_TRANSPORT transport, bool opportunistic) {
  uint8_t phy = controller_get_interface()->get_le_all_initiating_phys();
  BTA_GATTC_Open(client_if, remote_bda, is_direct, transport, phy);
  BTA_GATTC_Open(client_if, remote_bda, is_direct, transport, phy,
                 opportunistic);
}

void BTA_GATTC_Open(tBTA_GATTC_IF client_if, BD_ADDR remote_bda, bool is_direct,
                    tBTA_GATT_TRANSPORT transport, uint8_t initiating_phys) {
                    tBTA_GATT_TRANSPORT transport, uint8_t initiating_phys,
                    bool opportunistic) {
  tBTA_GATTC_API_OPEN* p_buf =
      (tBTA_GATTC_API_OPEN*)osi_malloc(sizeof(tBTA_GATTC_API_OPEN));

@@ -145,6 +149,7 @@ void BTA_GATTC_Open(tBTA_GATTC_IF client_if, BD_ADDR remote_bda, bool is_direct,
  p_buf->is_direct = is_direct;
  p_buf->transport = transport;
  p_buf->initiating_phys = initiating_phys;
  p_buf->opportunistic = opportunistic;
  memcpy(p_buf->remote_bda, remote_bda, BD_ADDR_LEN);

  bta_sys_sendmsg(p_buf);
+1 −0
Original line number Diff line number Diff line
@@ -102,6 +102,7 @@ typedef struct {
  bool is_direct;
  tBTA_TRANSPORT transport;
  uint8_t initiating_phys;
  bool opportunistic;
} tBTA_GATTC_API_OPEN;

typedef tBTA_GATTC_API_OPEN tBTA_GATTC_API_CANCEL_OPEN;
+4 −2
Original line number Diff line number Diff line
@@ -400,7 +400,8 @@ void bta_hh_le_open_conn(tBTA_HH_DEV_CB* p_cb, BD_ADDR remote_bda) {
  bta_hh_cb.le_cb_index[BTA_HH_GET_LE_CB_IDX(p_cb->hid_handle)] = p_cb->index;
  p_cb->in_use = true;

  BTA_GATTC_Open(bta_hh_cb.gatt_if, remote_bda, true, BTA_GATT_TRANSPORT_LE);
  BTA_GATTC_Open(bta_hh_cb.gatt_if, remote_bda, true, BTA_GATT_TRANSPORT_LE,
                 false);
}

/*******************************************************************************
@@ -2113,7 +2114,8 @@ static void bta_hh_le_add_dev_bg_conn(tBTA_HH_DEV_CB* p_cb, bool check_bond) {
  if (/*p_cb->dscp_info.flag & BTA_HH_LE_NORMAL_CONN &&*/
      !p_cb->in_bg_conn && to_add) {
    /* add device into BG connection to accept remote initiated connection */
    BTA_GATTC_Open(bta_hh_cb.gatt_if, p_cb->addr, false, BTA_GATT_TRANSPORT_LE);
    BTA_GATTC_Open(bta_hh_cb.gatt_if, p_cb->addr, false, BTA_GATT_TRANSPORT_LE,
                   false);
    p_cb->in_bg_conn = true;

    BTA_DmBleStartAutoConn();
Loading