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

Commit c52e0a37 authored by Łukasz Rymanowski's avatar Łukasz Rymanowski
Browse files

gatt_utils: Add tcb state to dumpsys

Allows to debug legacy code.

TCB (GATT_MAX_PHY_CHANNEL: 7) in_use: 2
  id: 0  address: xx:xx:xx:xx:13:0d  transport: BT_TRANSPORT_LE  ch_state: GATT_CH_OPEN
  id: 1  address: xx:xx:xx:xx:13:1e  transport: BT_TRANSPORT_LE  ch_state: GATT_CH_OPEN

Bug: 325438660
Test: mmm packages/modules/Bluetooth
Test: sanity Bluetooth operations
Flag: Exempt, debug code only
Change-Id: I4c929990e2c037eaa2d0091644753a221cda4887
parent c77ceb7f
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -178,6 +178,8 @@ bt_status_t btif_sdp_execute_service(bool b_enable);
bt_status_t btif_hh_connect(const tAclLinkSpec* link_spec);
bt_status_t btif_hd_execute_service(bool b_enable);

extern void gatt_tcb_dump(int fd);

/*******************************************************************************
 *  Callbacks from bluetooth::core (see go/invisalign-bt)
 ******************************************************************************/
@@ -810,6 +812,7 @@ static void dump(int fd, const char** arguments) {
  btif_sock_dump(fd);
  bluetooth::avrcp::AvrcpService::DebugDump(fd);
  btif_debug_config_dump(fd);
  gatt_tcb_dump(fd);
  device_debug_iot_config_dump(fd);
  BTA_HfClientDumpStatistics(fd);
  wakelock_debug_dump(fd);
+30 −0
Original line number Diff line number Diff line
@@ -436,6 +436,36 @@ tGATT_TCB* gatt_find_tcb_by_addr(const RawAddress& bda,
  return p_tcb;
}

/*******************************************************************************
 *
 * Function     gatt_tcb_dump
 *
 * Description  Print gatt_cb.tcb[] into dumpsys
 *
 * Returns      void
 *
 ******************************************************************************/
void gatt_tcb_dump(int fd) {
  std::stringstream stream;
  int in_use_cnt = 0;

  for (int i = 0; i < GATT_MAX_PHY_CHANNEL; i++) {
    tGATT_TCB* p_tcb = &gatt_cb.tcb[i];

    if (p_tcb->in_use) {
      in_use_cnt++;
      stream << "  id: " << +p_tcb->tcb_idx
             << "  address: " << ADDRESS_TO_LOGGABLE_STR(p_tcb->peer_bda)
             << "  transport: " << bt_transport_text(p_tcb->transport)
             << "  ch_state: " << gatt_channel_state_text(p_tcb->ch_state);
      stream << "\n";
    }
  }

  dprintf(fd, "TCB (GATT_MAX_PHY_CHANNEL: %d) in_use: %d\n%s\n",
          GATT_MAX_PHY_CHANNEL, in_use_cnt, stream.str().c_str());
}

/*******************************************************************************
 *
 * Function         gatt_allocate_tcb_by_bdaddr
+4 −0
Original line number Diff line number Diff line
@@ -108,3 +108,7 @@ void gatt_update_app_use_link_flag(tGATT_IF /* gatt_if */,
                                   bool /* check_acl_link */) {
  inc_func_call_count(__func__);
}

void gatt_tcb_dump(int fd) {
  inc_func_call_count(__func__);
}