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

Commit f2998ba9 authored by Jack He's avatar Jack He Committed by Andre Eisenbach
Browse files

DO NOT MERGE Fix unknown type issue in unit tests

Bug: 63790458
Test: build, unit test
Change-Id: If5e403907292aa25c8d39b17f2f1818d493433e6
Merged-In: I28288c295b7ca0259b2112c11b4e5a81d6f2e33c
parent 2405a42a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -136,7 +136,7 @@ cc_test {
        "libcutils",
    ],
    static_libs: [
        "libbluetooth-types",
        "libbtcore",
        "libosi",
    ],
    cflags: ["-DBUILDCFG"],
+18 −3
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@
#include <string.h>

#include "bt_common.h"
#include "btcore/include/bdaddr.h"
#include "btif_common.h"
#include "osi/include/allocator.h"
#include "osi/include/list.h"
@@ -79,8 +80,14 @@ static void queue_int_add(connect_node_t* p_param) {
  for (const list_node_t* node = list_begin(connect_queue);
       node != list_end(connect_queue); node = list_next(node)) {
    if (((connect_node_t*)list_node(node))->uuid == p_param->uuid) {
      LOG_INFO(LOG_TAG, "%s dropping duplicate connect request for uuid: %04x",
               __func__, p_param->uuid);
      bdstr_t bd_addr_str;
      LOG_ERROR(
          LOG_TAG,
          "%s dropping duplicate connection request UUID=%04X, "
          "bd_addr=%s, busy=%d",
          __func__, p_param->uuid,
          bdaddr_to_string(&p_param->bda, bd_addr_str, sizeof(bd_addr_str)),
          p_param->busy);
      return;
    }
  }
@@ -111,10 +118,12 @@ static void queue_int_cleanup(uint16_t* p_uuid) {
    connection_request = (connect_node_t*)list_node(node);
    node = list_next(node);
    if (connection_request->uuid == uuid) {
      bdstr_t bd_addr_str;
      LOG_INFO(LOG_TAG,
               "%s: removing connection request UUID=%04X, bd_addr=%s, busy=%d",
               __func__, connection_request->uuid,
               connection_request->bda.ToString().c_str(),
               bdaddr_to_string(&connection_request->bda, bd_addr_str,
                                sizeof(bd_addr_str)),
               connection_request->busy);
      list_remove(connect_queue, connection_request);
    }
@@ -198,6 +207,12 @@ bt_status_t btif_queue_connect_next(void) {

  connect_node_t* p_head = (connect_node_t*)list_front(connect_queue);

  bdstr_t bd_addr_str;
  LOG_INFO(LOG_TAG,
           "%s: executing connection request UUID=%04X, bd_addr=%s, busy=%d",
           __func__, p_head->uuid,
           bdaddr_to_string(&p_head->bda, bd_addr_str, sizeof(bd_addr_str)),
           p_head->busy);
  // If the queue is currently busy, we return success anyway,
  // since the connection has been queued...
  if (p_head->busy) return BT_STATUS_SUCCESS;
+8 −8
Original line number Diff line number Diff line
@@ -19,7 +19,6 @@

#include "btif/include/btif_profile_queue.h"
#include "stack_manager.h"
#include "types/raw_address.h"

static bool sStackRunning;

@@ -54,8 +53,8 @@ class BtifProfileQueueTest : public ::testing::Test {
 public:
  static const uint16_t kTestUuid1 = 0x9527;
  static const uint16_t kTestUuid2 = 0x819F;
  static const RawAddress kTestAddr1;
  static const RawAddress kTestAddr2;
  static const bt_bdaddr_t kTestAddr1;
  static const bt_bdaddr_t kTestAddr2;

 protected:
  void SetUp() override {
@@ -65,20 +64,21 @@ class BtifProfileQueueTest : public ::testing::Test {
  void TearDown() override { btif_queue_release(); };
};

const RawAddress BtifProfileQueueTest::kTestAddr1{
const bt_bdaddr_t BtifProfileQueueTest::kTestAddr1{
    {0x11, 0x22, 0x33, 0x44, 0x55, 0x66}};
const RawAddress BtifProfileQueueTest::kTestAddr2{
const bt_bdaddr_t BtifProfileQueueTest::kTestAddr2{
    {0xAB, 0xCD, 0xEF, 0x12, 0x34, 0x56}};

static bt_status_t test_connect_cb(RawAddress* bda, uint16_t uuid) {
static bt_status_t test_connect_cb(bt_bdaddr_t* bda, uint16_t uuid) {
  sResult = UNKNOWN;
  if (*bda == BtifProfileQueueTest::kTestAddr1) {
  if (!memcmp(bda, &BtifProfileQueueTest::kTestAddr1, sizeof(bt_bdaddr_t))) {
    if (uuid == BtifProfileQueueTest::kTestUuid1) {
      sResult = UUID1_ADDR1;
    } else if (uuid == BtifProfileQueueTest::kTestUuid2) {
      sResult = UUID2_ADDR1;
    }
  } else if (*bda == BtifProfileQueueTest::kTestAddr2) {
  } else if (!memcmp(bda, &BtifProfileQueueTest::kTestAddr2,
                     sizeof(bt_bdaddr_t))) {
    if (uuid == BtifProfileQueueTest::kTestUuid1) {
      sResult = UUID1_ADDR2;
    } else if (uuid == BtifProfileQueueTest::kTestUuid2) {