return started;
}
+
+/** White list add complete */
+void wl_add_complete(uint8_t* p_data, uint16_t /* evt_len */) {
+ uint8_t status;
+ STREAM_TO_UINT8(status, p_data);
+ VLOG(2) << __func__ << ": status=" << loghex(status);
+}
+
+/** White list element remove complete */
+void wl_remove_complete(uint8_t* p_data, uint16_t /* evt_len */) {
+ uint8_t status;
+ STREAM_TO_UINT8(status, p_data);
+ VLOG(2) << __func__ << ": status=" << loghex(status);
+}
+
/*******************************************************************************
*
* Function btm_execute_wl_dev_operation
map_it != background_connections.end();) {
BackgroundConnection* connection = &map_it->second;
if (connection->pending_removal) {
- btsnd_hcic_ble_remove_from_white_list(connection->addr_type_in_wl,
- connection->address);
+ btsnd_hcic_ble_remove_from_white_list(
+ connection->addr_type_in_wl, connection->address,
+ base::BindOnce(&wl_remove_complete));
map_it = background_connections.erase(map_it);
} else
++map_it;
const bool connected =
BTM_IsAclConnectionUp(connection->address, BT_TRANSPORT_LE);
if (!connection->in_controller_wl && !connected) {
- btsnd_hcic_ble_add_white_list(connection->addr_type, connection->address);
+ btsnd_hcic_ble_add_white_list(connection->addr_type, connection->address,
+ base::BindOnce(&wl_add_complete));
connection->in_controller_wl = true;
connection->addr_type_in_wl = connection->addr_type;
} else if (connection->in_controller_wl && connected) {
connection between two LE addresses. Not all controllers handle this
correctly, therefore we must make sure connected devices are not in
the white list when bg connection attempt is active. */
- btsnd_hcic_ble_remove_from_white_list(connection->addr_type_in_wl,
- connection->address);
+ btsnd_hcic_ble_remove_from_white_list(
+ connection->addr_type_in_wl, connection->address,
+ base::BindOnce(&wl_remove_complete));
connection->in_controller_wl = false;
}
}
/*******************************************************************************
*
- * Function btm_ble_clear_white_list_complete
- *
- * Description Indicates white list cleared.
- *
- ******************************************************************************/
-void btm_ble_clear_white_list_complete(uint8_t* p_data,
- UNUSED_ATTR uint16_t evt_len) {
- uint8_t status;
-
- STREAM_TO_UINT8(status, p_data);
- BTM_TRACE_EVENT("%s status=%d", __func__, status);
-}
-
-/*******************************************************************************
- *
* Function btm_ble_white_list_init
*
* Description Initialize white list size
BTM_TRACE_DEBUG("%s white_list_size = %d", __func__, white_list_size);
}
-/*******************************************************************************
- *
- * Function btm_ble_add_2_white_list_complete
- *
- * Description White list element added
- *
- ******************************************************************************/
-void btm_ble_add_2_white_list_complete(uint8_t status) {
- BTM_TRACE_EVENT("%s status=%d", __func__, status);
-}
-
-/*******************************************************************************
- *
- * Function btm_ble_remove_from_white_list_complete
- *
- * Description White list element removal complete
- *
- ******************************************************************************/
-void btm_ble_remove_from_white_list_complete(uint8_t* p,
- UNUSED_ATTR uint16_t evt_len) {
- BTM_TRACE_EVENT("%s status=%d", __func__, *p);
-}
-
void btm_ble_create_conn_cancel_complete(uint8_t* p) {
uint8_t status;
STREAM_TO_UINT8(status, p);
btm_ble_resume_bg_conn();
}
+/** clear white list complete */
+void wl_clear_complete(uint8_t* p_data, uint16_t /* evt_len */) {
+ uint8_t status;
+ STREAM_TO_UINT8(status, p_data);
+ VLOG(2) << __func__ << ": status=" << loghex(status);
+}
+
/** Clear the whitelist, end any pending whitelist connections */
void BTM_WhiteListClear() {
VLOG(1) << __func__;
if (!controller_get_interface()->supports_ble()) return;
btm_ble_stop_auto_conn();
- btsnd_hcic_ble_clear_white_list();
+ btsnd_hcic_ble_clear_white_list(base::BindOnce(&wl_clear_complete));
background_connections_clear();
}
/* white list function */
extern void btm_update_scanner_filter_policy(tBTM_BLE_SFP scan_policy);
extern void btm_update_adv_filter_policy(tBTM_BLE_AFP adv_policy);
-extern void btm_read_white_list_size_complete(uint8_t* p, uint16_t evt_len);
-extern void btm_ble_add_2_white_list_complete(uint8_t status);
-extern void btm_ble_remove_from_white_list_complete(uint8_t* p,
- uint16_t evt_len);
-extern void btm_ble_clear_white_list_complete(uint8_t* p, uint16_t evt_len);
extern void btm_ble_white_list_init(uint8_t white_list_size);
/* background connection function */
extern void btm_read_local_name_timeout(void* data);
extern void btm_read_local_name_complete(uint8_t* p, uint16_t evt_len);
-extern void btm_ble_add_2_white_list_complete(uint8_t status);
-extern void btm_ble_remove_from_white_list_complete(uint8_t* p,
- uint16_t evt_len);
-extern void btm_ble_clear_white_list_complete(uint8_t* p, uint16_t evt_len);
extern void btm_ble_create_conn_cancel_complete(uint8_t* p);
extern bool btm_ble_addr_resolvable(const RawAddress& rpa,
tBTM_SEC_DEV_REC* p_dev_rec);
break;
/* BLE Commands sComplete*/
- case HCI_BLE_ADD_WHITE_LIST:
- btm_ble_add_2_white_list_complete(*p);
- break;
-
- case HCI_BLE_CLEAR_WHITE_LIST:
- btm_ble_clear_white_list_complete(p, evt_len);
- break;
-
- case HCI_BLE_REMOVE_WHITE_LIST:
- btm_ble_remove_from_white_list_complete(p, evt_len);
- break;
-
case HCI_BLE_RAND:
case HCI_BLE_ENCRYPT:
btm_ble_rand_enc_complete(p, opcode, (tBTM_RAND_ENC_CB*)p_cplt_cback);
btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p);
}
-void btsnd_hcic_ble_clear_white_list(void) {
- BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE);
- uint8_t* pp = (uint8_t*)(p + 1);
-
- p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_CLEAR_WHITE_LIST;
- p->offset = 0;
-
- UINT16_TO_STREAM(pp, HCI_BLE_CLEAR_WHITE_LIST);
- UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_CLEAR_WHITE_LIST);
-
- btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p);
+void btsnd_hcic_ble_clear_white_list(
+ base::OnceCallback<void(uint8_t*, uint16_t)> cb) {
+ btu_hcif_send_cmd_with_cb(FROM_HERE, HCI_BLE_CLEAR_WHITE_LIST, nullptr, 0,
+ std::move(cb));
}
-void btsnd_hcic_ble_add_white_list(uint8_t addr_type, const RawAddress& bda) {
- BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE);
- uint8_t* pp = (uint8_t*)(p + 1);
-
- p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_ADD_WHITE_LIST;
- p->offset = 0;
-
- UINT16_TO_STREAM(pp, HCI_BLE_ADD_WHITE_LIST);
- UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_ADD_WHITE_LIST);
+void btsnd_hcic_ble_add_white_list(
+ uint8_t addr_type, const RawAddress& bda,
+ base::OnceCallback<void(uint8_t*, uint16_t)> cb) {
+ uint8_t param[HCIC_PARAM_SIZE_ADD_WHITE_LIST];
+ uint8_t* pp = param;
UINT8_TO_STREAM(pp, addr_type);
BDADDR_TO_STREAM(pp, bda);
- btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p);
+ btu_hcif_send_cmd_with_cb(FROM_HERE, HCI_BLE_ADD_WHITE_LIST, param,
+ HCIC_PARAM_SIZE_ADD_WHITE_LIST, std::move(cb));
}
-void btsnd_hcic_ble_remove_from_white_list(uint8_t addr_type,
- const RawAddress& bda) {
- BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE);
- uint8_t* pp = (uint8_t*)(p + 1);
-
- p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_REMOVE_WHITE_LIST;
- p->offset = 0;
-
- UINT16_TO_STREAM(pp, HCI_BLE_REMOVE_WHITE_LIST);
- UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_REMOVE_WHITE_LIST);
+void btsnd_hcic_ble_remove_from_white_list(
+ uint8_t addr_type, const RawAddress& bda,
+ base::OnceCallback<void(uint8_t*, uint16_t)> cb) {
+ uint8_t param[HCIC_PARAM_SIZE_REMOVE_WHITE_LIST];
+ uint8_t* pp = param;
UINT8_TO_STREAM(pp, addr_type);
BDADDR_TO_STREAM(pp, bda);
- btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p);
+ btu_hcif_send_cmd_with_cb(FROM_HERE, HCI_BLE_REMOVE_WHITE_LIST, param,
+ HCIC_PARAM_SIZE_REMOVE_WHITE_LIST, std::move(cb));
}
void btsnd_hcic_ble_upd_ll_conn_params(uint16_t handle, uint16_t conn_int_min,
extern void btsnd_hcic_ble_read_white_list_size(void);
-extern void btsnd_hcic_ble_clear_white_list(void);
+extern void btsnd_hcic_ble_clear_white_list(
+ base::OnceCallback<void(uint8_t*, uint16_t)> cb);
-extern void btsnd_hcic_ble_add_white_list(uint8_t addr_type,
- const RawAddress& bda);
+extern void btsnd_hcic_ble_add_white_list(
+ uint8_t addr_type, const RawAddress& bda,
+ base::OnceCallback<void(uint8_t*, uint16_t)> cb);
-extern void btsnd_hcic_ble_remove_from_white_list(uint8_t addr_type,
- const RawAddress& bda);
+extern void btsnd_hcic_ble_remove_from_white_list(
+ uint8_t addr_type, const RawAddress& bda,
+ base::OnceCallback<void(uint8_t*, uint16_t)> cb);
extern void btsnd_hcic_ble_upd_ll_conn_params(
uint16_t handle, uint16_t conn_int_min, uint16_t conn_int_max,