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

Commit fe7fbb04 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Move filter param setup to btm layer from btif layer"

parents 97baed46 f6012a8a
Loading
Loading
Loading
Loading
+1 −41
Original line number Original line Diff line number Diff line
@@ -231,10 +231,6 @@ static void btif_dm_ble_key_nc_req_evt(tBTA_DM_SP_KEY_NOTIF* p_notif_req);
static void btif_dm_ble_oob_req_evt(tBTA_DM_SP_RMT_OOB* req_oob_type);
static void btif_dm_ble_oob_req_evt(tBTA_DM_SP_RMT_OOB* req_oob_type);
static void btif_dm_ble_sc_oob_req_evt(tBTA_DM_SP_RMT_OOB* req_oob_type);
static void btif_dm_ble_sc_oob_req_evt(tBTA_DM_SP_RMT_OOB* req_oob_type);


static void bte_scan_filt_param_cfg_evt(uint8_t avbl_space,
                                        tBTM_BLE_SCAN_COND_OP action_type,
                                        tBTM_STATUS btm_status);

static char* btif_get_default_local_name();
static char* btif_get_default_local_name();


static void btif_stats_add_bond_event(const RawAddress& bd_addr,
static void btif_stats_add_bond_event(const RawAddress& bd_addr,
@@ -1299,9 +1295,7 @@ static void btif_dm_search_devices_evt(tBTA_DM_SEARCH_EVT event,
    } break;
    } break;


    case BTA_DM_INQ_CMPL_EVT: {
    case BTA_DM_INQ_CMPL_EVT: {
      BTM_BleAdvFilterParamSetup(
      /* do nothing */
          BTM_BLE_SCAN_COND_DELETE, static_cast<tBTM_BLE_PF_FILT_INDEX>(0),
          nullptr, base::Bind(&bte_scan_filt_param_cfg_evt));
    } break;
    } break;
    case BTA_DM_DISC_CMPL_EVT: {
    case BTA_DM_DISC_CMPL_EVT: {
      invoke_discovery_state_changed_cb(BT_DISCOVERY_STOPPED);
      invoke_discovery_state_changed_cb(BT_DISCOVERY_STOPPED);
@@ -1317,10 +1311,6 @@ static void btif_dm_search_devices_evt(tBTA_DM_SEARCH_EVT event,
       *
       *
       */
       */
      if (!btif_dm_inquiry_in_progress) {
      if (!btif_dm_inquiry_in_progress) {
        btgatt_filt_param_setup_t adv_filt_param;
        memset(&adv_filt_param, 0, sizeof(btgatt_filt_param_setup_t));
        BTM_BleAdvFilterParamSetup(BTM_BLE_SCAN_COND_DELETE, 0, nullptr,
                                   base::Bind(&bte_scan_filt_param_cfg_evt));
        invoke_discovery_state_changed_cb(BT_DISCOVERY_STOPPED);
        invoke_discovery_state_changed_cb(BT_DISCOVERY_STOPPED);
      }
      }
    } break;
    } break;
@@ -1838,19 +1828,6 @@ static void bta_energy_info_cb(tBTM_BLE_TX_TIME_MS tx_time,
  invoke_energy_info_cb(energy_info, data);
  invoke_energy_info_cb(energy_info, data);
}
}


/* Scan filter param config event */
static void bte_scan_filt_param_cfg_evt(uint8_t avbl_space, uint8_t action_type,
                                        tBTM_STATUS btm_status) {
  /* This event occurs on calling BTA_DmBleCfgFilterCondition internally,
  ** and that is why there is no HAL callback
  */
  if (btm_status != btm_status_value(BTM_SUCCESS)) {
    BTIF_TRACE_ERROR("%s, %d", __func__, btm_status);
  } else {
    BTIF_TRACE_DEBUG("%s", __func__);
  }
}

/*****************************************************************************
/*****************************************************************************
 *
 *
 *   btif api functions (no context switch)
 *   btif api functions (no context switch)
@@ -1873,23 +1850,6 @@ void btif_dm_start_discovery(void) {
    return;
    return;
  }
  }


  /* Cleanup anything remaining on index 0 */
  BTM_BleAdvFilterParamSetup(BTM_BLE_SCAN_COND_DELETE,
                             static_cast<tBTM_BLE_PF_FILT_INDEX>(0), nullptr,
                             base::Bind(&bte_scan_filt_param_cfg_evt));

  auto adv_filt_param = std::make_unique<btgatt_filt_param_setup_t>();
  /* Add an allow-all filter on index 0*/
  adv_filt_param->dely_mode = IMMEDIATE_DELY_MODE;
  adv_filt_param->feat_seln = ALLOW_ALL_FILTER;
  adv_filt_param->filt_logic_type = BTA_DM_BLE_PF_FILT_LOGIC_OR;
  adv_filt_param->list_logic_type = BTA_DM_BLE_PF_LIST_LOGIC_OR;
  adv_filt_param->rssi_low_thres = LOWEST_RSSI_VALUE;
  adv_filt_param->rssi_high_thres = LOWEST_RSSI_VALUE;
  BTM_BleAdvFilterParamSetup(
      BTM_BLE_SCAN_COND_ADD, static_cast<tBTM_BLE_PF_FILT_INDEX>(0),
      std::move(adv_filt_param), base::Bind(&bte_scan_filt_param_cfg_evt));

  /* Will be enabled to true once inquiry busy level has been received */
  /* Will be enabled to true once inquiry busy level has been received */
  btif_dm_inquiry_in_progress = false;
  btif_dm_inquiry_in_progress = false;
  /* find nearby devices */
  /* find nearby devices */
+33 −0
Original line number Original line Diff line number Diff line
@@ -33,6 +33,7 @@
#include <memory>
#include <memory>
#include <vector>
#include <vector>


#include "bta/include/bta_api.h"
#include "common/time_util.h"
#include "common/time_util.h"
#include "device/include/controller.h"
#include "device/include/controller.h"
#include "main/shim/acl_api.h"
#include "main/shim/acl_api.h"
@@ -1245,6 +1246,17 @@ void btm_send_hci_set_scan_params(uint8_t scan_type, uint16_t scan_int,
  }
  }
}
}


/* Scan filter param config event */
static void btm_ble_scan_filt_param_cfg_evt(uint8_t avbl_space,
                                            tBTM_BLE_SCAN_COND_OP action_type,
                                            tBTM_STATUS btm_status) {
  if (btm_status != btm_status_value(BTM_SUCCESS)) {
    BTM_TRACE_ERROR("%s, %d", __func__, btm_status);
  } else {
    BTM_TRACE_DEBUG("%s", __func__);
  }
}

/*******************************************************************************
/*******************************************************************************
 *
 *
 * Function         btm_ble_start_inquiry
 * Function         btm_ble_start_inquiry
@@ -1281,6 +1293,22 @@ tBTM_STATUS btm_ble_start_inquiry(uint8_t duration) {
    return (BTM_BUSY);
    return (BTM_BUSY);
  }
  }


  /* Cleanup anything remaining on index 0 */
  BTM_BleAdvFilterParamSetup(BTM_BLE_SCAN_COND_DELETE,
                             static_cast<tBTM_BLE_PF_FILT_INDEX>(0), nullptr,
                             base::Bind(btm_ble_scan_filt_param_cfg_evt));

  auto adv_filt_param = std::make_unique<btgatt_filt_param_setup_t>();
  /* Add an allow-all filter on index 0*/
  adv_filt_param->dely_mode = IMMEDIATE_DELY_MODE;
  adv_filt_param->feat_seln = ALLOW_ALL_FILTER;
  adv_filt_param->filt_logic_type = BTA_DM_BLE_PF_FILT_LOGIC_OR;
  adv_filt_param->list_logic_type = BTA_DM_BLE_PF_LIST_LOGIC_OR;
  adv_filt_param->rssi_low_thres = LOWEST_RSSI_VALUE;
  adv_filt_param->rssi_high_thres = LOWEST_RSSI_VALUE;
  BTM_BleAdvFilterParamSetup(BTM_BLE_SCAN_COND_ADD, static_cast<tBTM_BLE_PF_FILT_INDEX>(0),
                 std::move(adv_filt_param), base::Bind(btm_ble_scan_filt_param_cfg_evt));

  if (!p_ble_cb->is_ble_scan_active()) {
  if (!p_ble_cb->is_ble_scan_active()) {
    cache.ClearAll();
    cache.ClearAll();
    btm_send_hci_set_scan_params(
    btm_send_hci_set_scan_params(
@@ -2213,6 +2241,11 @@ void btm_ble_stop_inquiry(void) {


  p_ble_cb->reset_ble_inquiry();
  p_ble_cb->reset_ble_inquiry();


  /* Cleanup anything remaining on index 0 */
  BTM_BleAdvFilterParamSetup(BTM_BLE_SCAN_COND_DELETE,
                             static_cast<tBTM_BLE_PF_FILT_INDEX>(0), nullptr,
                             base::Bind(btm_ble_scan_filt_param_cfg_evt));

  /* If no more scan activity, stop LE scan now */
  /* If no more scan activity, stop LE scan now */
  if (!p_ble_cb->is_ble_scan_active()) {
  if (!p_ble_cb->is_ble_scan_active()) {
    btm_ble_stop_scan();
    btm_ble_stop_scan();