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

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

Locally link and remove unused funcs stack/btm/btm_ble_adv_filter

Towards readable code

Bug: 163134718
Tag: #refactor
Test: act.py -tc BleCocTest
Change-Id: I3d9da417cd70567e0f985c34500098827c4e842d
parent 00ab0dc0
Loading
Loading
Loading
Loading
+42 −79
Original line number Diff line number Diff line
@@ -78,51 +78,10 @@ static uint8_t btm_ble_cs_update_pf_counter(tBTM_BLE_SCAN_COND_OP action,
#define BTM_BLE_ADV_FILT_CB_EVT_MASK 0xF0
#define BTM_BLE_ADV_FILT_SUBCODE_MASK 0x0F

bool is_filtering_supported() {
static bool is_filtering_supported() {
  return cmn_ble_vsc_cb.filter_support != 0 && cmn_ble_vsc_cb.max_filter != 0;
}

/*******************************************************************************
 *
 * Function         btm_ble_condtype_to_ocf
 *
 * Description      Convert cond_type to OCF
 *
 * Returns          Returns ocf value
 *
 ******************************************************************************/
uint8_t btm_ble_condtype_to_ocf(uint8_t cond_type) {
  uint8_t ocf = 0;

  switch (cond_type) {
    case BTM_BLE_PF_ADDR_FILTER:
      ocf = BTM_BLE_META_PF_ADDR;
      break;
    case BTM_BLE_PF_SRVC_UUID:
      ocf = BTM_BLE_META_PF_UUID;
      break;
    case BTM_BLE_PF_SRVC_SOL_UUID:
      ocf = BTM_BLE_META_PF_SOL_UUID;
      break;
    case BTM_BLE_PF_LOCAL_NAME:
      ocf = BTM_BLE_META_PF_LOCAL_NAME;
      break;
    case BTM_BLE_PF_MANU_DATA:
      ocf = BTM_BLE_META_PF_MANU_DATA;
      break;
    case BTM_BLE_PF_SRVC_DATA_PATTERN:
      ocf = BTM_BLE_META_PF_SRVC_DATA;
      break;
    case BTM_BLE_PF_TYPE_ALL:
      ocf = BTM_BLE_META_PF_ALL;
      break;
    default:
      ocf = BTM_BLE_PF_TYPE_MAX;
      break;
  }
  return ocf;
}

/*******************************************************************************
 *
 * Function         btm_ble_ocf_to_condtype
@@ -132,7 +91,7 @@ uint8_t btm_ble_condtype_to_ocf(uint8_t cond_type) {
 * Returns          Returns condtype value
 *
 ******************************************************************************/
uint8_t btm_ble_ocf_to_condtype(uint8_t ocf) {
static uint8_t btm_ble_ocf_to_condtype(uint8_t ocf) {
  uint8_t cond_type = 0;

  switch (ocf) {
@@ -167,7 +126,7 @@ uint8_t btm_ble_ocf_to_condtype(uint8_t ocf) {
  return cond_type;
}

void btm_flt_update_cb(uint8_t expected_ocf, tBTM_BLE_PF_CFG_CBACK cb,
static void btm_flt_update_cb(uint8_t expected_ocf, tBTM_BLE_PF_CFG_CBACK cb,
                              uint8_t* p, uint16_t evt_len) {
  if (evt_len != 4) {
    BTM_TRACE_ERROR("%s: bad length: %d", __func__, evt_len);
@@ -218,7 +177,8 @@ void btm_flt_update_cb(uint8_t expected_ocf, tBTM_BLE_PF_CFG_CBACK cb,
 * Returns          pointer to the counter if found; NULL otherwise.
 *
 ******************************************************************************/
tBTM_BLE_PF_COUNT* btm_ble_find_addr_filter_counter(tBLE_BD_ADDR* p_le_bda) {
static tBTM_BLE_PF_COUNT* btm_ble_find_addr_filter_counter(
    tBLE_BD_ADDR* p_le_bda) {
  uint8_t i;
  tBTM_BLE_PF_COUNT* p_addr_filter =
      &btm_ble_adv_filt_cb.p_addr_filter_count[1];
@@ -243,7 +203,7 @@ tBTM_BLE_PF_COUNT* btm_ble_find_addr_filter_counter(tBLE_BD_ADDR* p_le_bda) {
 *                  otherwise.
 *
 ******************************************************************************/
tBTM_BLE_PF_COUNT* btm_ble_alloc_addr_filter_counter(
static tBTM_BLE_PF_COUNT* btm_ble_alloc_addr_filter_counter(
    const RawAddress& bd_addr) {
  uint8_t i;
  tBTM_BLE_PF_COUNT* p_addr_filter =
@@ -267,7 +227,7 @@ tBTM_BLE_PF_COUNT* btm_ble_alloc_addr_filter_counter(
 * Returns          true if deallocation succeed; false otherwise.
 *
 ******************************************************************************/
bool btm_ble_dealloc_addr_filter_counter(tBLE_BD_ADDR* p_bd_addr,
static bool btm_ble_dealloc_addr_filter_counter(tBLE_BD_ADDR* p_bd_addr,
                                                uint8_t filter_type) {
  uint8_t i;
  tBTM_BLE_PF_COUNT* p_addr_filter =
@@ -294,9 +254,10 @@ bool btm_ble_dealloc_addr_filter_counter(tBLE_BD_ADDR* p_bd_addr,
 * This function update(add,delete or clear) the adv local name filtering
 * condition.
 */
void BTM_LE_PF_local_name(tBTM_BLE_SCAN_COND_OP action,
static void BTM_LE_PF_local_name(tBTM_BLE_SCAN_COND_OP action,
                                 tBTM_BLE_PF_FILT_INDEX filt_index,
                          std::vector<uint8_t> name, tBTM_BLE_PF_CFG_CBACK cb) {
                                 std::vector<uint8_t> name,
                                 tBTM_BLE_PF_CFG_CBACK cb) {
  uint8_t len = BTM_BLE_ADV_FILT_META_HDR_LENGTH;

  uint8_t len_max = len + BTM_BLE_PF_STR_LEN_MAX;
@@ -325,7 +286,7 @@ void BTM_LE_PF_local_name(tBTM_BLE_SCAN_COND_OP action,
/**
 * this function update(add/remove) service data change filter.
 */
void BTM_LE_PF_srvc_data(tBTM_BLE_SCAN_COND_OP action,
static void BTM_LE_PF_srvc_data(tBTM_BLE_SCAN_COND_OP action,
                                tBTM_BLE_PF_FILT_INDEX filt_index) {
  uint8_t num_avail = (action == BTM_BLE_SCAN_COND_ADD) ? 0 : 1;

@@ -337,9 +298,10 @@ void BTM_LE_PF_srvc_data(tBTM_BLE_SCAN_COND_OP action,
 * This function update(add,delete or clear) the adv manufacturer data filtering
 * condition.
 */
void BTM_LE_PF_manu_data(tBTM_BLE_SCAN_COND_OP action,
                         tBTM_BLE_PF_FILT_INDEX filt_index, uint16_t company_id,
                         uint16_t company_id_mask, std::vector<uint8_t> data,
static void BTM_LE_PF_manu_data(tBTM_BLE_SCAN_COND_OP action,
                                tBTM_BLE_PF_FILT_INDEX filt_index,
                                uint16_t company_id, uint16_t company_id_mask,
                                std::vector<uint8_t> data,
                                std::vector<uint8_t> data_mask,
                                tBTM_BLE_PF_CFG_CBACK cb) {
  uint8_t len = BTM_BLE_ADV_FILT_META_HDR_LENGTH;
@@ -389,7 +351,7 @@ void BTM_LE_PF_manu_data(tBTM_BLE_SCAN_COND_OP action,
 * This function update(add,delete or clear) the service data filtering
 * condition.
 **/
void BTM_LE_PF_srvc_data_pattern(tBTM_BLE_SCAN_COND_OP action,
static void BTM_LE_PF_srvc_data_pattern(tBTM_BLE_SCAN_COND_OP action,
                                        tBTM_BLE_PF_FILT_INDEX filt_index,
                                        std::vector<uint8_t> data,
                                        std::vector<uint8_t> data_mask,
@@ -434,8 +396,9 @@ void BTM_LE_PF_srvc_data_pattern(tBTM_BLE_SCAN_COND_OP action,
 *                  counter update failed.
 *
 ******************************************************************************/
uint8_t btm_ble_cs_update_pf_counter(tBTM_BLE_SCAN_COND_OP action,
                                     uint8_t cond_type, tBLE_BD_ADDR* p_bd_addr,
static uint8_t btm_ble_cs_update_pf_counter(tBTM_BLE_SCAN_COND_OP action,
                                            uint8_t cond_type,
                                            tBLE_BD_ADDR* p_bd_addr,
                                            uint8_t num_available) {
  tBTM_BLE_PF_COUNT* p_addr_filter = NULL;
  uint8_t* p_counter = NULL;
@@ -487,9 +450,9 @@ uint8_t btm_ble_cs_update_pf_counter(tBTM_BLE_SCAN_COND_OP action,
/**
 * This function updates the address filter of adv.
 */
void BTM_LE_PF_addr_filter(tBTM_BLE_SCAN_COND_OP action,
                           tBTM_BLE_PF_FILT_INDEX filt_index, tBLE_BD_ADDR addr,
                           tBTM_BLE_PF_CFG_CBACK cb) {
static void BTM_LE_PF_addr_filter(tBTM_BLE_SCAN_COND_OP action,
                                  tBTM_BLE_PF_FILT_INDEX filt_index,
                                  tBLE_BD_ADDR addr, tBTM_BLE_PF_CFG_CBACK cb) {
  const uint8_t len = BTM_BLE_ADV_FILT_META_HDR_LENGTH + BTM_BLE_META_ADDR_LEN;

  uint8_t param[len];
@@ -527,7 +490,7 @@ void BTM_LE_PF_addr_filter(tBTM_BLE_SCAN_COND_OP action,
/**
 * This function updates(adds, deletes or clears) the service UUID filter.
 */
void BTM_LE_PF_uuid_filter(tBTM_BLE_SCAN_COND_OP action,
static void BTM_LE_PF_uuid_filter(tBTM_BLE_SCAN_COND_OP action,
                                  tBTM_BLE_PF_FILT_INDEX filt_index,
                                  tBTM_BLE_PF_COND_TYPE filter_type,
                                  const bluetooth::Uuid& uuid,
@@ -827,7 +790,7 @@ void BTM_BleAdvFilterParamSetup(
  }
}

void enable_cmpl_cback(tBTM_BLE_PF_STATUS_CBACK p_stat_cback, uint8_t* p,
static void enable_cmpl_cback(tBTM_BLE_PF_STATUS_CBACK p_stat_cback, uint8_t* p,
                              uint16_t evt_len) {
  uint8_t status, op_subcode, action;