#include <unordered_map>
#include "device/include/controller.h"
+#include "main/shim/acl_api.h"
#include "main/shim/shim.h"
#include "stack/btm/btm_dev.h"
#include "stack/btm/btm_int_types.h"
return count;
}
+static const tBLE_BD_ADDR convert_to_address_with_type(
+ const RawAddress& bd_addr, const tBTM_SEC_DEV_REC* p_dev_rec) {
+ if (p_dev_rec == nullptr || !p_dev_rec->is_device_type_has_ble()) {
+ return {
+ .type = BLE_ADDR_PUBLIC,
+ .bda = bd_addr,
+ };
+ }
+
+ if (p_dev_rec->ble.identity_address_with_type.bda.IsEmpty()) {
+ return {
+ .type = p_dev_rec->ble.ble_addr_type,
+ .bda = bd_addr,
+ };
+ } else {
+ return p_dev_rec->ble.identity_address_with_type;
+ }
+}
+
/*******************************************************************************
*
* Function btm_add_dev_to_controller
LOG_DEBUG(
"Adding known device record into acceptlist with identity "
"device:%s",
- p_dev_rec->ble.identity_address_with_type.bda.ToString().c_str());
+ PRIVATE_ADDRESS(p_dev_rec->ble.identity_address_with_type));
background_connection_add(
p_dev_rec->ble.identity_address_with_type.type,
p_dev_rec->ble.identity_address_with_type.bda);
LOG_DEBUG(
"Adding known device record into acceptlist without identity "
"device:%s",
- bd_addr.ToString().c_str());
+ PRIVATE_ADDRESS(bd_addr));
background_connection_add(p_dev_rec->ble.ble_addr_type, bd_addr);
if (p_dev_rec->ble.ble_addr_type == BLE_ADDR_RANDOM &&
BTM_BLE_IS_RESOLVE_BDA(bd_addr)) {
- LOG(INFO) << __func__ << " addig RPA into acceptlist";
+ LOG(INFO) << __func__ << " adding RPA into acceptlist";
}
}
LOG_DEBUG(
"Removing known device record into acceptlist with identity "
"device:%s",
- p_dev_rec->ble.identity_address_with_type.bda.ToString().c_str());
+ PRIVATE_ADDRESS(p_dev_rec->ble.identity_address_with_type));
background_connection_remove(
p_dev_rec->ble.identity_address_with_type.bda);
} else {
LOG_DEBUG(
"Removing known device record into acceptlist without identity "
"device:%s",
- bd_addr.ToString().c_str());
+ PRIVATE_ADDRESS(bd_addr));
background_connection_remove(bd_addr);
if (p_dev_rec->ble.ble_addr_type == BLE_ADDR_RANDOM &&
/** This function is to start auto connection procedure */
static bool btm_ble_start_auto_conn() {
tBTM_BLE_CB* p_cb = &btm_cb.ble_ctr_cb;
-
- BTM_TRACE_EVENT("%s", __func__);
-
- uint16_t scan_int = (p_cb->scan_int == BTM_BLE_SCAN_PARAM_UNDEF)
- ? BTM_BLE_SCAN_SLOW_INT_1
- : p_cb->scan_int;
- uint16_t scan_win = (p_cb->scan_win == BTM_BLE_SCAN_PARAM_UNDEF)
- ? BTM_BLE_SCAN_SLOW_WIN_1
- : p_cb->scan_win;
+ ASSERT(p_cb != nullptr);
+
+ const uint16_t scan_int = (p_cb->scan_int == BTM_BLE_SCAN_PARAM_UNDEF)
+ ? BTM_BLE_SCAN_SLOW_INT_1
+ : p_cb->scan_int;
+ const uint16_t scan_win = (p_cb->scan_win == BTM_BLE_SCAN_PARAM_UNDEF)
+ ? BTM_BLE_SCAN_SLOW_WIN_1
+ : p_cb->scan_win;
uint8_t own_addr_type = p_cb->addr_mgnt_cb.own_addr_type;
uint8_t peer_addr_type = BLE_ADDR_PUBLIC;
if (controller_get_interface()->supports_ble_coded_phy()) phy |= PHY_LE_CODED;
if (!btm_ble_topology_check(BTM_BLE_STATE_INIT)) {
- LOG(INFO) << "initate background connection fail, topology limitation";
+ LOG_INFO(
+ "Unable to initiate background connection due to topology limitation");
return false;
}
if (!btm_cb.ble_ctr_cb.is_connection_state_idle() ||
!background_connections_pending()) {
+ LOG_DEBUG(
+ "Connection state not idle or already have background connection "
+ "pending");
return false;
}
*
******************************************************************************/
void btm_ble_bgconn_cancel_if_disconnected(const RawAddress& bd_addr) {
+ if (bluetooth::shim::is_gd_acl_enabled()) {
+ if (!bluetooth::shim::ACL_AcceptLeConnectionFrom(
+ convert_to_address_with_type(bd_addr, btm_find_dev(bd_addr)))) {
+ LOG_ERROR("Unable to add to acceptlist as it is full:%s",
+ PRIVATE_ADDRESS(bd_addr));
+ }
+ return;
+ }
+
if (!btm_cb.ble_ctr_cb.is_connection_state_connecting()) return;
auto map_it = background_connections.find(bd_addr);
*
******************************************************************************/
bool btm_ble_suspend_bg_conn(void) {
- BTM_TRACE_EVENT("%s", __func__);
+ if (bluetooth::shim::is_gd_acl_enabled()) {
+ LOG_DEBUG("Gd acl_manager handles sync of background connections");
+ return true;
+ }
return btm_ble_stop_auto_conn();
}
* Returns none.
*
******************************************************************************/
-bool btm_ble_resume_bg_conn(void) { return btm_ble_start_auto_conn(); }
+bool btm_ble_resume_bg_conn(void) {
+ if (bluetooth::shim::is_gd_acl_enabled()) {
+ LOG_DEBUG("Gd acl_manager handles sync of background connections");
+ return true;
+ }
+ return btm_ble_start_auto_conn();
+}
bool BTM_BackgroundConnectAddressKnown(const RawAddress& address) {
tBTM_SEC_DEV_REC* p_dev_rec = btm_find_dev(address);
/** Adds the device into acceptlist. Returns false if acceptlist is full and
* device can't be added, true otherwise. */
bool BTM_AcceptlistAdd(const RawAddress& address) {
- VLOG(1) << __func__ << ": " << address;
-
if (!controller_get_interface()->supports_ble()) {
- LOG_WARN("Controller does not support ble");
+ LOG_WARN("Controller does not support Le");
return false;
}
if (bluetooth::shim::is_gd_acl_enabled()) {
- LOG_DEBUG("gd_acl running so skipping adding to acceptlist");
- return true;
+ return bluetooth::shim::ACL_AcceptLeConnectionFrom(
+ convert_to_address_with_type(address, btm_find_dev(address)));
}
if (background_connections_count() ==
}
btm_add_dev_to_controller(true, address);
btm_ble_resume_bg_conn();
+ LOG_DEBUG("Added to Le acceptlist device:%s", PRIVATE_ADDRESS(address));
return true;
}
/** Removes the device from acceptlist */
void BTM_AcceptlistRemove(const RawAddress& address) {
- VLOG(1) << __func__ << ": " << address;
if (!controller_get_interface()->supports_ble()) {
- LOG_WARN("Controller does not support ble");
+ LOG_WARN("Controller does not support Le");
return;
}
if (bluetooth::shim::is_gd_acl_enabled()) {
- LOG_DEBUG("gd_acl running so skipping adding to acceptlist");
+ bluetooth::shim::ACL_IgnoreLeConnectionFrom(
+ convert_to_address_with_type(address, btm_find_dev(address)));
return;
}
}
btm_add_dev_to_controller(false, address);
btm_ble_resume_bg_conn();
+ LOG_DEBUG("Removed from Le acceptlist device:%s", PRIVATE_ADDRESS(address));
}
/** Clear the acceptlist, end any pending acceptlist connections */
void BTM_AcceptlistClear() {
- VLOG(1) << __func__;
if (!controller_get_interface()->supports_ble()) {
- LOG_WARN("Controller does not support ble");
+ LOG_WARN("Controller does not support Le");
return;
}
if (bluetooth::shim::is_gd_acl_enabled()) {
- LOG_DEBUG("gd_acl running so skipping adding to acceptlist");
+ bluetooth::shim::ACL_IgnoreAllLeConnections();
return;
}
btsnd_hcic_ble_clear_acceptlist(
base::BindOnce(&acceptlist_clear_command_complete));
background_connections_clear();
+ LOG_DEBUG("Cleared Le acceptlist");
}