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

Commit db32cbbe authored by Jakub Pawlowski's avatar Jakub Pawlowski Committed by android-build-merger
Browse files

Get rid of no longer necessary bt_bdaddr_t helpers

am: a5eefaed

Change-Id: Iecdea5cdaad1422b37cd0ab6304ad72591f2a2cb
parents 5843d337 a5eefaed
Loading
Loading
Loading
Loading
+1 −8
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@
#include <hardware/bluetooth.h>
#include <stdbool.h>
#include <stddef.h>
#include "stack/include/bt_types.h"

// Note: the string representation of a bdaddr is expected to have the format
// xx:xx:xx:xx:xx:xx
@@ -34,14 +35,6 @@ typedef char bdstr_t[sizeof("xx:xx:xx:xx:xx:xx")];
// |addr| may not be NULL.
bool bdaddr_is_empty(const bt_bdaddr_t* addr);

// Returns true if |first| and |second| refer to the same address. Neither
// may be NULL.
bool bdaddr_equals(const bt_bdaddr_t* first, const bt_bdaddr_t* second);

// Returns destination bdaddr |dest| after copying |src| to |dest|.
// |dest| and |src| must not be NULL.
bt_bdaddr_t* bdaddr_copy(bt_bdaddr_t* dest, const bt_bdaddr_t* src);

// Makes a string representation of |addr| and places it into |string|. |size|
// refers to the size of |string|'s buffer and must be >= 18. On success, this
// function returns |string|, otherwise it returns NULL. Neither |addr| nor
+0 −14
Original line number Diff line number Diff line
@@ -30,20 +30,6 @@ bool bdaddr_is_empty(const bt_bdaddr_t* addr) {
  return memcmp(addr, &zero, sizeof(bt_bdaddr_t)) == 0;
}

bool bdaddr_equals(const bt_bdaddr_t* first, const bt_bdaddr_t* second) {
  CHECK(first != NULL);
  CHECK(second != NULL);

  return memcmp(first, second, sizeof(bt_bdaddr_t)) == 0;
}

bt_bdaddr_t* bdaddr_copy(bt_bdaddr_t* dest, const bt_bdaddr_t* src) {
  CHECK(dest != NULL);
  CHECK(src != NULL);

  return (bt_bdaddr_t*)memcpy(dest, src, sizeof(bt_bdaddr_t));
}

const char* bdaddr_to_string(const bt_bdaddr_t* addr, char* string,
                             size_t size) {
  CHECK(addr != NULL);
+4 −4
Original line number Diff line number Diff line
@@ -56,17 +56,17 @@ TEST(BdaddrTest, test_equals) {
  bt_bdaddr_t bdaddr3;
  string_to_bdaddr(test_addr, &bdaddr1);
  string_to_bdaddr(test_addr, &bdaddr2);
  EXPECT_TRUE(bdaddr_equals(&bdaddr1, &bdaddr2));
  EXPECT_TRUE(bdaddr1 == bdaddr2);

  string_to_bdaddr(test_addr2, &bdaddr3);
  EXPECT_FALSE(bdaddr_equals(&bdaddr2, &bdaddr3));
  EXPECT_FALSE(bdaddr2 == bdaddr3);
}

TEST(BdaddrTest, test_copy) {
  bt_bdaddr_t bdaddr1;
  bt_bdaddr_t bdaddr2;
  string_to_bdaddr(test_addr, &bdaddr1);
  bdaddr_copy(&bdaddr2, &bdaddr1);
  bdaddr2 = bdaddr1;

  EXPECT_TRUE(bdaddr_equals(&bdaddr1, &bdaddr2));
  EXPECT_TRUE(bdaddr1 == bdaddr2);
}
+1 −3
Original line number Diff line number Diff line
@@ -381,9 +381,7 @@ void btif_enable_bluetooth_evt(tBTA_STATUS status) {
  BTIF_TRACE_DEBUG("%s: status %d", __func__, status);

  /* Fetch the local BD ADDR */
  bt_bdaddr_t local_bd_addr;
  const controller_t* controller = controller_get_interface();
  bdaddr_copy(&local_bd_addr, controller->get_address());
  bt_bdaddr_t local_bd_addr = *controller_get_interface()->get_address();

  bdstr_t bdstr;
  bdaddr_to_string(&local_bd_addr, bdstr, sizeof(bdstr));
+1 −8
Original line number Diff line number Diff line
@@ -66,14 +66,7 @@ struct BgConnHash {
  }
};

struct BgConnKeyEqual {
  bool operator()(const bt_bdaddr_t& x, const bt_bdaddr_t& y) const {
    return bdaddr_equals(&x, &y);
  }
};

static std::unordered_map<bt_bdaddr_t, background_connection_t, BgConnHash,
                          BgConnKeyEqual>
static std::unordered_map<bt_bdaddr_t, background_connection_t, BgConnHash>
    background_connections;

static void background_connection_add(uint8_t addr_type,
Loading