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

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

bta:: Remove BTA_EIR_CANNED_UUID_LIST

Bug: 331855424
Test: m .
Flag: EXEMPT, Code Removal
Change-Id: I8b328a82fc446d93476988bd74551c15baee5156
parent c6394f6f
Loading
Loading
Loading
Loading
+4 −41
Original line number Diff line number Diff line
@@ -1068,13 +1068,11 @@ static size_t find_utf8_char_boundary(const char* utf8str, size_t offset) {
static void bta_dm_set_eir(char* local_name) {
  uint8_t* p;
  uint8_t* p_length;
#if (BTA_EIR_CANNED_UUID_LIST != TRUE)
  uint8_t* p_type;
  uint8_t max_num_uuid;
#if (BTA_EIR_SERVER_NUM_CUSTOM_UUID > 0)
  uint8_t custom_uuid_idx;
#endif  // BTA_EIR_SERVER_NUM_CUSTOM_UUID
#endif  // BTA_EIR_CANNED_UUID_LIST
  uint8_t free_eir_length = HCI_DM5_PACKET_SIZE;
  uint8_t num_uuid;
  uint8_t data_type;
@@ -1083,14 +1081,12 @@ static void bta_dm_set_eir(char* local_name) {
  /* wait until complete to disable */
  if (alarm_is_scheduled(bta_dm_cb.disable_timer)) return;

#if (BTA_EIR_CANNED_UUID_LIST != TRUE)
  /* if local name is not provided, get it from controller */
  if (local_name == NULL) {
    if (BTM_ReadLocalDeviceName((const char**)&local_name) != BTM_SUCCESS) {
      log::error("Fail to read local device name for EIR");
    }
  }
#endif  // BTA_EIR_CANNED_UUID_LIST

  /* Allocate a buffer to hold HCI command */
  BT_HDR* p_buf = (BT_HDR*)osi_malloc(BTM_CMD_BUF_SIZE);
@@ -1111,14 +1107,10 @@ static void bta_dm_set_eir(char* local_name) {
  /* check whether it needs to be shortened or not */
  if (local_name_len > p_bta_dm_eir_cfg->bta_dm_eir_min_name_len) {
    /* get number of UUID 16-bit list */
#if (BTA_EIR_CANNED_UUID_LIST == TRUE)
    num_uuid = p_bta_dm_eir_cfg->bta_dm_eir_uuid16_len / Uuid::kNumBytes16;
#else   // BTA_EIR_CANNED_UUID_LIST
    max_num_uuid = (free_eir_length - 2) / Uuid::kNumBytes16;
    data_type = get_btm_client_interface().eir.BTM_GetEirSupportedServices(
        bta_dm_cb.eir_uuid, &p, max_num_uuid, &num_uuid);
    p = (uint8_t*)p_buf + BTM_HCI_EIR_OFFSET; /* reset p */
#endif  // BTA_EIR_CANNED_UUID_LIST

    /* if UUID doesn't fit remaing space, shorten local name */
    if (local_name_len > (free_eir_length - 4 - num_uuid * Uuid::kNumBytes16)) {
@@ -1140,31 +1132,6 @@ static void bta_dm_set_eir(char* local_name) {
  }
  free_eir_length -= local_name_len + 2;

#if (BTA_EIR_CANNED_UUID_LIST == TRUE)
  /* if UUID list is provided as static data in configuration */
  if ((p_bta_dm_eir_cfg->bta_dm_eir_uuid16_len > 0) &&
      (p_bta_dm_eir_cfg->bta_dm_eir_uuid16)) {
    if (free_eir_length > Uuid::kNumBytes16 + 2) {
      free_eir_length -= 2;

      if (free_eir_length >= p_bta_dm_eir_cfg->bta_dm_eir_uuid16_len) {
        num_uuid = p_bta_dm_eir_cfg->bta_dm_eir_uuid16_len / Uuid::kNumBytes16;
        data_type = HCI_EIR_COMPLETE_16BITS_UUID_TYPE;
      } else /* not enough room for all UUIDs */
      {
        log::warn("BTA EIR: UUID 16-bit list is truncated");
        num_uuid = free_eir_length / Uuid::kNumBytes16;
        data_type = HCI_EIR_MORE_16BITS_UUID_TYPE;
      }
      UINT8_TO_STREAM(p, num_uuid * Uuid::kNumBytes16 + 1);
      UINT8_TO_STREAM(p, data_type);
      memcpy(p, p_bta_dm_eir_cfg->bta_dm_eir_uuid16,
             num_uuid * Uuid::kNumBytes16);
      p += num_uuid * Uuid::kNumBytes16;
      free_eir_length -= num_uuid * Uuid::kNumBytes16;
    }
  }
#else /* (BTA_EIR_CANNED_UUID_LIST == TRUE) */
  /* if UUID list is dynamic */
  if (free_eir_length >= 2) {
    p_length = p++;
@@ -1202,9 +1169,8 @@ static void bta_dm_set_eir(char* local_name) {
    UINT8_TO_STREAM(p_type, data_type);
    free_eir_length -= num_uuid * Uuid::kNumBytes16 + 2;
  }
#endif /* (BTA_EIR_CANNED_UUID_LIST == TRUE) */

#if (BTA_EIR_CANNED_UUID_LIST != TRUE && BTA_EIR_SERVER_NUM_CUSTOM_UUID > 0)
#if (BTA_EIR_SERVER_NUM_CUSTOM_UUID > 0)
  /* Adding 32-bit UUID list */
  if (free_eir_length >= 2) {
    p_length = p++;
@@ -1262,8 +1228,7 @@ static void bta_dm_set_eir(char* local_name) {
    UINT8_TO_STREAM(p_type, data_type);
    free_eir_length -= num_uuid * Uuid::kNumBytes128 + 2;
  }
#endif /* ( BTA_EIR_CANNED_UUID_LIST != TRUE \
          )&&(BTA_EIR_SERVER_NUM_CUSTOM_UUID > 0) */
#endif /* BTA_EIR_SERVER_NUM_CUSTOM_UUID > 0 */

  /* if Flags are provided in configuration */
  if ((p_bta_dm_eir_cfg->bta_dm_eir_flag_len > 0) &&
@@ -1308,7 +1273,6 @@ static void bta_dm_set_eir(char* local_name) {
  get_btm_client_interface().eir.BTM_WriteEIR(p_buf);
}

#if (BTA_EIR_CANNED_UUID_LIST != TRUE)
/*******************************************************************************
 *
 * Function         bta_dm_get_cust_uuid_index
@@ -1414,7 +1378,6 @@ void bta_dm_eir_update_uuid(uint16_t uuid16, bool adding) {

  bta_dm_set_eir(NULL);
}
#endif  // BTA_EIR_CANNED_UUID_LIST

tBTA_DM_PEER_DEVICE* find_connected_device(
    const RawAddress& bd_addr, UNUSED_ATTR tBT_TRANSPORT transport) {
+1 −15
Original line number Diff line number Diff line
@@ -623,24 +623,11 @@ const tBTM_PM_PWR_MD* p_bta_dm_pm_md = &bta_dm_pm_md[0];
 *                    (same reason of DM5)
 */

#if (BTA_EIR_CANNED_UUID_LIST == TRUE)
/* for example */
const uint8_t bta_dm_eir_uuid16_list[] = {
    0x08, 0x11, /* Headset */
    0x1E, 0x11, /* Handsfree */
    0x0E, 0x11, /* AV Remote Control */
    0x0B, 0x11, /* Audio Sink */
};
#endif  // BTA_EIR_CANNED_UUID_LIST

/* Extended Inquiry Response */
const tBTA_DM_EIR_CONF bta_dm_eir_cfg = {
    50, /* minimum length of local name when it is shortened */
        /* if length of local name is longer than this and EIR has not enough */
        /* room for all UUID list then local name is shortened to this length */
#if (BTA_EIR_CANNED_UUID_LIST == TRUE)
    8,    (uint8_t*)bta_dm_eir_uuid16_list,
#else     // BTA_EIR_CANNED_UUID_LIST
    {
        /* mask of UUID list in EIR */
        0xFFFFFFFF, /* LSB is the first UUID of the first 32 UUIDs in
@@ -649,7 +636,6 @@ const tBTA_DM_EIR_CONF bta_dm_eir_cfg = {
                       BTM_EIR_UUID_LKUP_TBL */
                    /* BTM_EIR_UUID_LKUP_TBL can be overrided */
    },
#endif    // BTA_EIR_CANNED_UUID_LIST
    NULL, /* Inquiry TX power         */
    0,    /* length of flags in bytes */
    NULL, /* flags for EIR */
+0 −4
Original line number Diff line number Diff line
@@ -214,15 +214,11 @@ typedef struct {
  tBTA_PM_TIMER pm_timer[BTA_DM_NUM_PM_TIMER];
  uint8_t cur_av_count;   /* current AV connecions */

#if (BTA_EIR_CANNED_UUID_LIST != TRUE)
  /* store UUID list for EIR */
  uint32_t eir_uuid[BTM_EIR_SERVICE_ARRAY_SIZE];
#if (BTA_EIR_SERVER_NUM_CUSTOM_UUID > 0)
  tBTA_CUSTOM_UUID bta_custom_uuid[BTA_EIR_SERVER_NUM_CUSTOM_UUID];
#endif

#endif

  alarm_t* switch_delay_timer;
} tBTA_DM_CB;

+0 −5
Original line number Diff line number Diff line
@@ -156,12 +156,7 @@ enum {
typedef struct {
  uint8_t bta_dm_eir_min_name_len; /* minimum length of local name when it is
                                      shortened */
#if (BTA_EIR_CANNED_UUID_LIST == TRUE)
  uint8_t bta_dm_eir_uuid16_len; /* length of 16-bit UUIDs */
  uint8_t* bta_dm_eir_uuid16;    /* 16-bit UUIDs */
#else
  uint32_t uuid_mask[BTM_EIR_SERVICE_ARRAY_SIZE]; /* mask of UUID list in EIR */
#endif
  int8_t* bta_dm_eir_inq_tx_power;     /* Inquiry TX power         */
  uint8_t bta_dm_eir_flag_len;         /* length of flags in bytes */
  uint8_t* bta_dm_eir_flags;           /* flags for EIR */
+0 −2
Original line number Diff line number Diff line
@@ -380,11 +380,9 @@ void bta_pan_disable(void) {
  /* close all connections */
  PAN_SetRole(0, std::string(), std::string());

#if (BTA_EIR_CANNED_UUID_LIST != TRUE)
  bta_sys_remove_uuid(UUID_SERVCLASS_NAP);
  bta_sys_remove_uuid(UUID_SERVCLASS_GN);
  bta_sys_remove_uuid(UUID_SERVCLASS_PANU);
#endif  // BTA_EIR_CANNED_UUID_LIST
  /* free all queued up data buffers */
  for (i = 0; i < BTA_PAN_NUM_CONN; i++, p_scb++) {
    if (p_scb->in_use) {
Loading