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

Commit 9bff2427 authored by Chris Manton's avatar Chris Manton
Browse files

dumpsys: Move l2cap dumpsys to proper file

Bug: 328135211
Test: m .
Flag: EXEMPT, Mechanical Refactor

Change-Id: Ic35ad9c4439946c62a798228f956262a8ff735d1
parent 4ccf635b
Loading
Loading
Loading
Loading
+2 −24
Original line number Diff line number Diff line
@@ -57,8 +57,8 @@
#include "stack/btm/btm_sec_cb.h"
#include "stack/include/bt_hdr.h"
#include "stack/include/btm_log_history.h"
#include "stack/include/l2c_api.h"
#include "stack/include/main_thread.h"
#include "stack/l2cap/l2c_int.h"
#include "types/ble_address_with_type.h"
#include "types/raw_address.h"

@@ -1212,28 +1212,6 @@ struct shim::legacy::Acl::impl {
#undef DUMPSYS_TAG
};

#define DUMPSYS_TAG "shim::legacy::l2cap"
extern tL2C_CB l2cb;
void DumpsysL2cap(int fd) {
  LOG_DUMPSYS_TITLE(fd, DUMPSYS_TAG);
  for (int i = 0; i < MAX_L2CAP_LINKS; i++) {
    const tL2C_LCB& lcb = l2cb.lcb_pool[i];
    if (!lcb.in_use) continue;
    LOG_DUMPSYS(fd, "link_state:%s", link_state_text(lcb.link_state).c_str());
    LOG_DUMPSYS(fd, "handle:0x%04x", lcb.Handle());

    const tL2C_CCB* ccb = lcb.ccb_queue.p_first_ccb;
    while (ccb != nullptr) {
      LOG_DUMPSYS(
          fd, "  active channel lcid:0x%04x rcid:0x%04x is_ecoc:%s in_use:%s",
          ccb->local_cid, ccb->remote_cid, common::ToString(ccb->ecoc).c_str(),
          common::ToString(ccb->in_use).c_str());
      ccb = ccb->p_next_ccb;
    }
  }
}

#undef DUMPSYS_TAG
#define DUMPSYS_TAG "shim::legacy::acl"
void DumpsysAcl(int fd) {
  const tACL_CB& acl_cb = btm_cb.acl_cb_;
@@ -1372,7 +1350,7 @@ void shim::legacy::Acl::Dump(int fd) const {
  DumpsysRecord(fd);
  DumpsysNeighbor(fd);
  DumpsysAcl(fd);
  DumpsysL2cap(fd);
  L2CA_Dumpsys(fd);
  DumpsysBtm(fd);
}

+14 −0
Original line number Diff line number Diff line
@@ -933,4 +933,18 @@ template <>
struct formatter<tL2CAP_PRIORITY> : enum_formatter<tL2CAP_PRIORITY> {};
}  // namespace fmt

/*******************************************************************************
**
** Function         L2CA_Dumpsys
**
** Description      This function provides dumpsys data during the dumpsys
**                  procedure.
**
** Parameters:      fd: Descriptor used to write the L2CAP internals
**
** Returns          void
**
*******************************************************************************/
void L2CA_Dumpsys(int fd);

#endif /* L2C_API_H */
+25 −0
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@
#include "include/check.h"
#include "internal_include/bt_target.h"
#include "internal_include/bt_trace.h"
#include "main/shim/dumpsys.h"
#include "main/shim/entry.h"
#include "os/log.h"
#include "os/system_properties.h"
@@ -1773,3 +1774,27 @@ bool L2CA_isMediaChannel(uint16_t handle, uint16_t channel_id,

  return ret;
}

using namespace bluetooth;

#define DUMPSYS_TAG "shim::legacy::l2cap"

void L2CA_Dumpsys(int fd) {
  LOG_DUMPSYS_TITLE(fd, DUMPSYS_TAG);
  for (int i = 0; i < MAX_L2CAP_LINKS; i++) {
    const tL2C_LCB& lcb = l2cb.lcb_pool[i];
    if (!lcb.in_use) continue;
    LOG_DUMPSYS(fd, "link_state:%s", link_state_text(lcb.link_state).c_str());
    LOG_DUMPSYS(fd, "handle:0x%04x", lcb.Handle());

    const tL2C_CCB* ccb = lcb.ccb_queue.p_first_ccb;
    while (ccb != nullptr) {
      LOG_DUMPSYS(
          fd, "  active channel lcid:0x%04x rcid:0x%04x is_ecoc:%s in_use:%s",
          ccb->local_cid, ccb->remote_cid, logbool(ccb->ecoc).c_str(),
          logbool(ccb->in_use).c_str());
      ccb = ccb->p_next_ccb;
    }
  }
}
#undef DUMPSYS_TAG
+13 −0
Original line number Diff line number Diff line
@@ -14,7 +14,9 @@
 * limitations under the License.
 */

#include <fcntl.h>
#include <gtest/gtest.h>
#include <sys/socket.h>

#include "common/init_flags.h"
#include "device/include/controller.h"
@@ -246,3 +248,14 @@ TEST_F(StackL2capTest, l2cap_result_code_text) {
          static_cast<tL2CAP_CONN>(std::numeric_limits<std::uint16_t>::max()))
          .c_str());
}

TEST_F(StackL2capTest, L2CA_Dumpsys) {
  int sv[2];
  char buf[32];
  ASSERT_EQ(0, socketpair(AF_UNIX, SOCK_STREAM, 0, sv));
  ASSERT_EQ(0, fcntl(sv[1], F_SETFL, fcntl(sv[1], F_GETFL, 0) | O_NONBLOCK));

  L2CA_Dumpsys(sv[0]);
  while (read(sv[1], buf, sizeof(buf)) != -1) {
  }
}
+2 −0
Original line number Diff line number Diff line
@@ -278,3 +278,5 @@ uint16_t L2CA_LeCreditThreshold() {
}

// END mockcify generation

void L2CA_Dumpsys(int /* fd */) { inc_func_call_count(__func__); }