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

Commit 88448fc8 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge changes Ie3306462,I73bb3476 am: c5860315

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Bluetooth/+/1896713

Change-Id: I3a78e6742074b3f8a41fbf634c1614a454ec8a7a
parents 96085eee c5860315
Loading
Loading
Loading
Loading
+34 −0
Original line number Diff line number Diff line
@@ -57,6 +57,8 @@ class DeviceGroup {
  const Uuid& GetUuid(void) const { return group_uuid_; }

 private:
  friend std::ostream& operator<<(std::ostream& out,
                                  const bluetooth::groups::DeviceGroup& value);
  int group_id_;
  Uuid group_uuid_;
  std::unordered_set<RawAddress> devices_;
@@ -261,6 +263,18 @@ class DeviceGroupsImpl : public DeviceGroups {
    return true;
  }

  void Dump(int fd) {
    std::stringstream stream;

    stream << "  Num. registered clients: " << callbacks_.size() << std::endl;
    stream << "  Groups:\n";
    for (const auto& kv_pair : groups_) {
      stream << kv_pair.second << std::endl;
    }

    dprintf(fd, "%s", stream.str().c_str());
  }

 private:
  DeviceGroup* find_device_group(int group_id) {
    return groups_.count(group_id) ? &groups_.at(group_id) : nullptr;
@@ -350,6 +364,26 @@ void DeviceGroups::CleanUp(DeviceGroupsCallbacks* callbacks) {
    instance = nullptr;
  }
}

std::ostream& operator<<(std::ostream& out,
                         bluetooth::groups::DeviceGroup const& group) {
  out << "    == Group id: " << group.group_id_ << " == \n"
      << "      Uuid: " << group.group_uuid_ << std::endl;
  out << "      Devices:\n";
  for (auto const& addr : group.devices_) {
    out << "        " << addr << std::endl;
  }
  return out;
}

void DeviceGroups::DebugDump(int fd) {
  dprintf(fd, "Device Groups Manager:\n");
  if (instance)
    instance->Dump(fd);
  else
    dprintf(fd, "  Not initialized \n");
}

DeviceGroups* DeviceGroups::Get() { return instance; }

}  // namespace groups
+1 −0
Original line number Diff line number Diff line
@@ -65,6 +65,7 @@ class DeviceGroups {
  static bool GetForStorage(const RawAddress& addr, std::vector<uint8_t>& out);
  static void CleanUp(DeviceGroupsCallbacks* callbacks);
  static DeviceGroups* Get();
  static void DebugDump(int fd);
  /** To add to the existing group, group_id needs to be provided.
   *  Otherwise a new group for the given context uuid will be created.
   */
+2 −0
Original line number Diff line number Diff line
@@ -3030,6 +3030,8 @@ void LeAudioClient::Initialize(
}

void LeAudioClient::DebugDump(int fd) {
  DeviceGroups::DebugDump(fd);

  dprintf(fd, "LeAudio Manager: \n");
  if (instance)
    instance->Dump(fd);
+2 −0
Original line number Diff line number Diff line
@@ -35,6 +35,8 @@ void bluetooth::groups::DeviceGroups::Initialize(
  mock_groups->Initialize(callbacks);
};

void bluetooth::groups::DeviceGroups::DebugDump(int) {}

void bluetooth::groups::DeviceGroups::CleanUp(
    bluetooth::groups::DeviceGroupsCallbacks* callbacks) {
  LOG_ASSERT(mock_groups) << "Mock Device Groups not set!";
+2 −1
Original line number Diff line number Diff line
@@ -119,13 +119,14 @@ class Uuid final {
  // Network-byte-ordered ID (Big Endian).
  UUID128Bit uu;
};
}  // namespace bluetooth

inline std::ostream& operator<<(std::ostream& os, const bluetooth::Uuid& a) {
  os << a.ToString();
  return os;
}

}  // namespace bluetooth

// Custom std::hash specialization so that bluetooth::UUID can be used as a key
// in std::unordered_map.
namespace std {