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

Commit 9af5027b authored by Chao Quan's avatar Chao Quan Committed by Andre Eisenbach
Browse files

Update app use for link of BR/EDR over GATT

Link of GATT over BR/EDR still exists when no app uses it.
To wait for the link down, closing bt takes more time.
This defect brought from change "Merge BT 4.1 features",
whose change-id is Ic6701da4cf6aaa390ff2c8816b43157f36b7fb42.

Give back link control using gatt_update_app_use_link_flag

Change-Id: Iee756f23651a32dcb7db1aed766e2c64dab6f6ea
Test: manual
parent 47b2dd47
Loading
Loading
Loading
Loading
+17 −13
Original line number Diff line number Diff line
@@ -312,27 +312,31 @@ void gatt_update_app_use_link_flag(tGATT_IF gatt_if, tGATT_TCB* p_tcb,
  if (!gatt_update_app_hold_link_status(gatt_if, p_tcb, is_add)) return;

  if (!check_acl_link ||
      p_tcb->att_lcid !=
          L2CAP_ATT_CID || /* only update link idle timer for fixed channel */
      (BTM_GetHCIConnHandle(p_tcb->peer_bda, p_tcb->transport) ==
       GATT_INVALID_ACL_HANDLE)) {
    return;
  }

  if (is_add) {
    if (p_tcb->att_lcid == L2CAP_ATT_CID) {
      VLOG(1) << "disable link idle timer";
      /* acl link is connected disable the idle timeout */
      GATT_SetIdleTimeout(p_tcb->peer_bda, GATT_LINK_NO_IDLE_TIMEOUT,
                          p_tcb->transport);
    }
  } else {
    if (p_tcb->app_hold_link.empty()) {
      /* acl link is connected but no application needs to use the link
         so set the timeout value to GATT_LINK_IDLE_TIMEOUT_WHEN_NO_APP seconds
         */
      // acl link is connected but no application needs to use the link
      if (p_tcb->att_lcid == L2CAP_ATT_CID) {
        /* for fixed channel, set the timeout value to
           GATT_LINK_IDLE_TIMEOUT_WHEN_NO_APP seconds */
        VLOG(1) << " start link idle timer = "
                << GATT_LINK_IDLE_TIMEOUT_WHEN_NO_APP << " sec";
        GATT_SetIdleTimeout(p_tcb->peer_bda, GATT_LINK_IDLE_TIMEOUT_WHEN_NO_APP,
                            p_tcb->transport);
      } else
        // disconnect the dynamic channel
        gatt_disconnect(p_tcb);
    }
  }
}