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

Commit 5b1d473f authored by Rahul Arya's avatar Rahul Arya
Browse files

Fix infinite L2CAP timeout when ATT is used without GATT clients

If we do ATT operations without a GATT client, the channel timeout stays
at the default value (infinite) which prevents the ACL link from
disconnecting.

The timeout is set to zero when the *last* GATT client disconnects, but
of course this doesn't work if there never are *any* GATT clients, yet
ATT operations (such as service discovery) are taking place.

Test: atest pts-bot?
Bug: 251954527
Merged-In: I2990fd8892ab0f442fd7847b34812e29d832baac
Change-Id: I2990fd8892ab0f442fd7847b34812e29d832baac
(cherry picked from commit c24851b3)
parent 323f73de
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@ table InitFlagsData {
    gd_controller_enabled:bool (privacy:"Any");
    btaa_hci_is_enabled:bool (privacy:"Any");
    btm_dm_flush_discovery_queue_on_search_cancel_is_enabled:bool (privacy:"Any");
    finite_att_timeout_is_enabled:bool (privacy:"Any");
    gatt_robust_caching_client_is_enabled:bool (privacy:"Any");
    gatt_robust_caching_server_is_enabled:bool (privacy:"Any");
    gd_core_is_enabled:bool (privacy:"Any");
+1 −0
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ flatbuffers::Offset<bluetooth::common::InitFlagsData> bluetooth::dumpsys::InitFl
  builder.add_btaa_hci_is_enabled(initFlags::btaa_hci_is_enabled());
  builder.add_btm_dm_flush_discovery_queue_on_search_cancel_is_enabled(
      initFlags::btm_dm_flush_discovery_queue_on_search_cancel_is_enabled());
  builder.add_finite_att_timeout_is_enabled(initFlags::finite_att_timeout_is_enabled());
  builder.add_gatt_robust_caching_client_is_enabled(initFlags::gatt_robust_caching_client_is_enabled());
  builder.add_gatt_robust_caching_server_is_enabled(initFlags::gatt_robust_caching_server_is_enabled());
  builder.add_gd_core_is_enabled(initFlags::gd_core_is_enabled());
+1 −0
Original line number Diff line number Diff line
@@ -208,6 +208,7 @@ init_flags!(
        asynchronously_start_l2cap_coc = true,
        btaa_hci = true,
        btm_dm_flush_discovery_queue_on_search_cancel,
        finite_att_timeout = true,
        gatt_robust_caching_client = true,
        gatt_robust_caching_server,
        gd_core,
+1 −0
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@ mod ffi {
        fn asynchronously_start_l2cap_coc_is_enabled() -> bool;
        fn btaa_hci_is_enabled() -> bool;
        fn btm_dm_flush_discovery_queue_on_search_cancel_is_enabled() -> bool;
        fn finite_att_timeout_is_enabled() -> bool;
        fn gatt_robust_caching_client_is_enabled() -> bool;
        fn gatt_robust_caching_server_is_enabled() -> bool;
        fn gd_core_is_enabled() -> bool;
+7 −3
Original line number Diff line number Diff line
@@ -22,11 +22,14 @@
 *
 ******************************************************************************/

#include <base/logging.h>

#include "bt_target.h"
#include "bt_utils.h"
#include "btif/include/btif_storage.h"
#include "connection_manager.h"
#include "device/include/interop.h"
#include "gd/common/init_flags.h"
#include "internal_include/stack_config.h"
#include "l2c_api.h"
#include "osi/include/allocator.h"
@@ -40,8 +43,6 @@
#include "stack/include/l2cap_acl_interface.h"
#include "types/raw_address.h"

#include <base/logging.h>

using base::StringPrintf;
using bluetooth::eatt::EattExtension;

@@ -113,7 +114,10 @@ void gatt_init(void) {
  fixed_reg.pL2CA_FixedConn_Cb = gatt_le_connect_cback;
  fixed_reg.pL2CA_FixedData_Cb = gatt_le_data_ind;
  fixed_reg.pL2CA_FixedCong_Cb = gatt_le_cong_cback; /* congestion callback */
  fixed_reg.default_idle_tout = 0xffff; /* 0xffff default idle timeout */
  fixed_reg.default_idle_tout =
      bluetooth::common::init_flags::finite_att_timeout_is_enabled()
          ? 2 /* We allow 2s for GATT clients to connect once the link is up */
          : L2CAP_NO_IDLE_TIMEOUT;

  L2CA_RegisterFixedChannel(L2CAP_ATT_CID, &fixed_reg);

Loading