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

Commit fb344c67 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "dumpsys: Add stack::sdp dumpsys procedure" into main

parents 7a5e1b64 13da4a68
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -102,7 +102,6 @@
#include "stack/gatt/connection_manager.h"
#include "stack/include/a2dp_api.h"
#include "stack/include/avdt_api.h"
#include "stack/include/btm_api.h"
#include "stack/include/btm_client_interface.h"
#include "stack/include/hfp_lc3_decoder.h"
#include "stack/include/hfp_lc3_encoder.h"
@@ -111,6 +110,7 @@
#include "stack/include/hidh_api.h"
#include "stack/include/main_thread.h"
#include "stack/include/pan_api.h"
#include "stack/include/sdp_api.h"
#include "storage/config_keys.h"
#include "types/raw_address.h"

@@ -876,6 +876,7 @@ static void dump(int fd, const char** arguments) {
  PAN_Dumpsys(fd);
  DumpsysHid(fd);
  DumpsysBtaDm(fd);
  SDP_Dumpsys(fd);
  bluetooth::shim::Dump(fd, arguments);
  power_telemetry::GetInstance().Dumpsys(fd);
  log::debug("Finished bluetooth dumpsys");
+2 −0
Original line number Diff line number Diff line
@@ -1417,6 +1417,7 @@ cc_test {
        ":LegacyStackSdp",
        ":TestCommonMainHandler",
        ":TestCommonMockFunctions",
        ":TestMockBta",
        ":TestMockBtif",
        ":TestMockDevice",
        ":TestMockRustFfi",
@@ -2241,6 +2242,7 @@ cc_test {
        ":LegacyStackSdp",
        ":TestCommonMockFunctions",
        ":TestFakeOsi",
        ":TestMockBta",
        ":TestMockBtif",
        ":TestMockStackBtm",
        ":TestMockStackL2cap",
+13 −0
Original line number Diff line number Diff line
@@ -577,3 +577,16 @@ struct tLegacyStackSdbCallback {
}  // namespace stack
}  // namespace legacy
}  // namespace bluetooth

/*******************************************************************************
 *
 * Function         SDP_Dumpsys
 *
 * Description      Dumps readable content of the module to the filedescriptor
 *
 * Parameters:      fd        - Valid file descriptor
 *
 * Returns          None
 *
 ******************************************************************************/
void SDP_Dumpsys(int fd);
+49 −1
Original line number Diff line number Diff line
@@ -26,13 +26,14 @@

#include "stack/include/sdp_api.h"

#include <base/strings/stringprintf.h>
#include <bluetooth/log.h>
#include <string.h>

#include <cstdint>

#include "internal_include/bt_target.h"
#include "os/log.h"
#include "main/shim/dumpsys.h"
#include "stack/include/bt_types.h"
#include "stack/include/bt_uuid16.h"
#include "stack/include/sdp_api.h"
@@ -45,6 +46,11 @@
using bluetooth::Uuid;
using namespace bluetooth;

namespace {
constexpr unsigned kMaxSdpConnections = static_cast<unsigned>(SDP_MAX_CONNECTIONS);
constexpr unsigned kMaxSdpRecords = static_cast<unsigned>(SDP_MAX_DISC_SERVER_RECS);
}  // namespace

/*******************************************************************************
 *
 * Function         SDP_InitDiscoveryDb
@@ -1106,3 +1112,45 @@ const bluetooth::legacy::stack::sdp::tSdpApi*
bluetooth::legacy::stack::sdp::get_legacy_stack_sdp_api() {
  return &api_;
}

extern void BTA_SdpDumpsys(int fd);

#define DUMPSYS_TAG "shim::legacy::sdp"

namespace {

void SDP_DumpConnectionControlBlock(int fd, const tCONN_CB& conn_cb) {
  if (conn_cb.device_address == RawAddress::kEmpty) {
    return;
  }
  LOG_DUMPSYS(fd, "peer:%s discovery_state:%s", fmt::format("{}", conn_cb.device_address).c_str(),
              sdp_disc_wait_text(conn_cb.disc_state).c_str());
  LOG_DUMPSYS(fd, "  connection_state:%s connection_flags:0x%02x mtu:%hu l2cap_cid:%hu",
              sdp_state_text(conn_cb.con_state).c_str(), conn_cb.con_flags, conn_cb.rem_mtu_size,
              conn_cb.connection_id);

  const uint64_t remaining_ms = alarm_get_remaining_ms(conn_cb.sdp_conn_timer);
  if (remaining_ms) {
    LOG_DUMPSYS(fd, "  timer_set:%Lu ms", static_cast<long long>(remaining_ms));
  }
  if (conn_cb.num_handles >= kMaxSdpRecords) {
    LOG_DUMPSYS(fd, "  WARNING - Number handles:%hu exceeds max handles:%u", conn_cb.num_handles,
                kMaxSdpRecords);
  } else {
    for (int i = 0; i < conn_cb.num_handles; i++) {
      LOG_DUMPSYS(fd, "  handle:%u", conn_cb.handles[i]);
    }
  }
}

}  // namespace

void SDP_Dumpsys(int fd) {
  LOG_DUMPSYS_TITLE(fd, DUMPSYS_TAG);
  LOG_DUMPSYS(fd, "max_attribute_list_size:%hu max_records_per_search:%hu",
              sdp_cb.max_attr_list_size, sdp_cb.max_recs_per_search);
  for (unsigned i = 0; i < kMaxSdpConnections; i++) {
    SDP_DumpConnectionControlBlock(fd, sdp_cb.ccb[i]);
  }
}
#undef DUMPSYS_TAG
+12 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@
#include "include/macros.h"
#include "osi/include/allocator.h"
#include "stack/include/bt_uuid16.h"
#include "stack/include/sdp_api.h"
#include "stack/include/sdpdefs.h"
#include "stack/sdp/internal/sdp_api.h"
#include "stack/sdp/sdpint.h"
@@ -415,3 +416,14 @@ TEST_F(StackSdpInitTest, sdpu_dump_all_ccb) {

  sdpu_dump_all_ccb();
}

TEST_F(StackSdpInitTest, SDP_Dumpsys) { SDP_Dumpsys(1); }

TEST_F(StackSdpInitTest, SDP_Dumpsys_ccb) {
  ASSERT_NE(nullptr, sdp_conn_originate(addr));
  ASSERT_NE(nullptr, sdp_conn_originate(addr2));
  ASSERT_NE(nullptr, sdp_conn_originate(addr3));
  ASSERT_NE(nullptr, sdp_conn_originate(addr4));
  ASSERT_EQ(nullptr, sdp_conn_originate(addr5));
  SDP_Dumpsys(1);
}
Loading