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

Commit a44c29ff authored by Chris Manton's avatar Chris Manton
Browse files

gd: Add dumpsys l2cap fixed channel info

Bug: 162655455
Test: atest --host bluetooth_test_gd
Tag: #gd-refactor

Change-Id: I185f70181edd6c912bd8dfba074f11a8c38c132b
parent 74bf2970
Loading
Loading
Loading
Loading
+22 −0
Original line number Original line Diff line number Diff line
@@ -17,6 +17,8 @@
#include <string>
#include <string>


#include "l2cap/classic/internal/dumpsys_helper.h"
#include "l2cap/classic/internal/dumpsys_helper.h"
#include "l2cap/classic/internal/fixed_channel_impl.h"
#include "l2cap/classic/internal/link.h"
#include "l2cap/classic/internal/link_manager.h"
#include "l2cap/classic/internal/link_manager.h"
#include "l2cap/internal/dynamic_channel_impl.h"
#include "l2cap/internal/dynamic_channel_impl.h"
#include "l2cap_classic_module_generated.h"
#include "l2cap_classic_module_generated.h"
@@ -39,6 +41,22 @@ bluetooth::l2cap::classic::internal::DumpsysHelper::DumpActiveDynamicChannels(
  return channel_offsets;
  return channel_offsets;
}
}


std::vector<flatbuffers::Offset<::bluetooth::l2cap::classic::ChannelData>>
bluetooth::l2cap::classic::internal::DumpsysHelper::DumpActiveFixedChannels(
    flatbuffers::FlatBufferBuilder* fb_builder,
    const bluetooth::l2cap::internal::FixedChannelAllocator<
        bluetooth::l2cap::classic::internal::FixedChannelImpl,
        bluetooth::l2cap::classic::internal::Link>& channel_allocator) const {
  std::vector<flatbuffers::Offset<bluetooth::l2cap::classic::ChannelData>> channel_offsets;

  for (auto it = channel_allocator.channels_.cbegin(); it != channel_allocator.channels_.cend(); ++it) {
    ChannelDataBuilder builder(*fb_builder);
    builder.add_cid(it->first);
    channel_offsets.push_back(builder.Finish());
  }
  return channel_offsets;
}

std::vector<flatbuffers::Offset<bluetooth::l2cap::classic::LinkData>>
std::vector<flatbuffers::Offset<bluetooth::l2cap::classic::LinkData>>
bluetooth::l2cap::classic::internal::DumpsysHelper::DumpActiveLinks(flatbuffers::FlatBufferBuilder* fb_builder) const {
bluetooth::l2cap::classic::internal::DumpsysHelper::DumpActiveLinks(flatbuffers::FlatBufferBuilder* fb_builder) const {
  const std::unordered_map<hci::Address, Link>* links = &link_manager_.links_;
  const std::unordered_map<hci::Address, Link>* links = &link_manager_.links_;
@@ -50,9 +68,13 @@ bluetooth::l2cap::classic::internal::DumpsysHelper::DumpActiveLinks(flatbuffers:
    auto dynamic_channel_offsets = DumpActiveDynamicChannels(fb_builder, it->second.dynamic_channel_allocator_);
    auto dynamic_channel_offsets = DumpActiveDynamicChannels(fb_builder, it->second.dynamic_channel_allocator_);
    auto dynamic_channels = fb_builder->CreateVector(dynamic_channel_offsets);
    auto dynamic_channels = fb_builder->CreateVector(dynamic_channel_offsets);


    auto fixed_channel_offsets = DumpActiveFixedChannels(fb_builder, it->second.fixed_channel_allocator_);
    auto fixed_channels = fb_builder->CreateVector(fixed_channel_offsets);

    LinkDataBuilder builder(*fb_builder);
    LinkDataBuilder builder(*fb_builder);
    builder.add_address(link_address);
    builder.add_address(link_address);
    builder.add_dynamic_channels(dynamic_channels);
    builder.add_dynamic_channels(dynamic_channels);
    builder.add_fixed_channels(fixed_channels);
    link_offsets.push_back(builder.Finish());
    link_offsets.push_back(builder.Finish());
  }
  }
  return link_offsets;
  return link_offsets;
+6 −0
Original line number Original line Diff line number Diff line
@@ -16,8 +16,11 @@


#pragma once
#pragma once


#include "l2cap/classic/internal/fixed_channel_impl.h"
#include "l2cap/classic/internal/link.h"
#include "l2cap/classic/internal/link_manager.h"
#include "l2cap/classic/internal/link_manager.h"
#include "l2cap/internal/dynamic_channel_allocator.h"
#include "l2cap/internal/dynamic_channel_allocator.h"
#include "l2cap/internal/fixed_channel_allocator.h"
#include "l2cap_classic_module_generated.h"
#include "l2cap_classic_module_generated.h"


namespace bluetooth {
namespace bluetooth {
@@ -32,6 +35,9 @@ class DumpsysHelper {
  std::vector<flatbuffers::Offset<ChannelData>> DumpActiveDynamicChannels(
  std::vector<flatbuffers::Offset<ChannelData>> DumpActiveDynamicChannels(
      flatbuffers::FlatBufferBuilder* fb_builder,
      flatbuffers::FlatBufferBuilder* fb_builder,
      const l2cap::internal::DynamicChannelAllocator& channel_allocator) const;
      const l2cap::internal::DynamicChannelAllocator& channel_allocator) const;
  std::vector<flatbuffers::Offset<ChannelData>> DumpActiveFixedChannels(
      flatbuffers::FlatBufferBuilder* fb_builder,
      const l2cap::internal::FixedChannelAllocator<FixedChannelImpl, Link>& channel_allocator) const;
  std::vector<flatbuffers::Offset<LinkData>> DumpActiveLinks(flatbuffers::FlatBufferBuilder* fb_builder) const;
  std::vector<flatbuffers::Offset<LinkData>> DumpActiveLinks(flatbuffers::FlatBufferBuilder* fb_builder) const;


 private:
 private:
+1 −0
Original line number Original line Diff line number Diff line
@@ -9,6 +9,7 @@ table ChannelData {
table LinkData {
table LinkData {
  address:string;
  address:string;
  dynamic_channels:[ChannelData];
  dynamic_channels:[ChannelData];
  fixed_channels:[ChannelData];
}
}


table L2capClassicModuleData {
table L2capClassicModuleData {
+8 −0
Original line number Original line Diff line number Diff line
@@ -26,6 +26,13 @@


namespace bluetooth {
namespace bluetooth {
namespace l2cap {
namespace l2cap {

namespace classic {
namespace internal {
class DumpsysHelper;
}  // namespace internal
}  // namespace classic

namespace internal {
namespace internal {


// Helper class for keeping channels in a Link. It allocates and frees Channel object, and supports querying whether a
// Helper class for keeping channels in a Link. It allocates and frees Channel object, and supports querying whether a
@@ -87,6 +94,7 @@ class FixedChannelAllocator {
  }
  }


 private:
 private:
  friend class bluetooth::l2cap::classic::internal::DumpsysHelper;
  LinkType* link_;
  LinkType* link_;
  os::Handler* l2cap_handler_;
  os::Handler* l2cap_handler_;
  std::unordered_map<Cid, std::shared_ptr<FixedChannelImplType>> channels_;
  std::unordered_map<Cid, std::shared_ptr<FixedChannelImplType>> channels_;