Loading system/gd/hci/acl_manager/le_impl.h +26 −4 Original line number Diff line number Diff line Loading @@ -201,6 +201,16 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback { AddressWithType empty(Address::kEmpty, AddressType::RANDOM_DEVICE_ADDRESS); return empty; } bool alreadyConnected(AddressWithType address_with_type) { for (auto it = le_acl_connections_.begin(); it != le_acl_connections_.end(); it++) { if (it->second.remote_address_ == address_with_type) { return true; } } return false; } } connections; public: Loading Loading @@ -370,10 +380,6 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback { static constexpr bool kRemoveConnectionAfterwards = true; void on_le_disconnect(uint16_t handle, ErrorCode reason) { AddressWithType remote_address = connections.getAddressWithType(handle); if (background_connections_.count(remote_address) == 1) { LOG_INFO("re-add device to connect list"); add_device_to_connect_list(remote_address); } bool event_also_routes_to_other_receivers = connections.crash_on_unknown_handle_; connections.crash_on_unknown_handle_ = false; connections.execute( Loading @@ -384,6 +390,12 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback { }, kRemoveConnectionAfterwards); connections.crash_on_unknown_handle_ = event_also_routes_to_other_receivers; if (background_connections_.count(remote_address) == 1) { LOG_INFO("re-add device to connect list"); add_device_to_connect_list(remote_address); } if (!connect_list.empty()) { LOG_INFO("connect_list is not empty, send a new connection request"); AddressWithType empty(Address::kEmpty, AddressType::RANDOM_DEVICE_ADDRESS); Loading Loading @@ -477,6 +489,11 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback { } void add_device_to_connect_list(AddressWithType address_with_type) { if (connections.alreadyConnected(address_with_type)) { LOG_INFO("Device already connected, return"); return; } connect_list.insert(address_with_type); register_with_address_manager(); le_address_manager_->AddDeviceToConnectList( Loading Loading @@ -528,6 +545,11 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback { return; } if (connections.alreadyConnected(address_with_type)) { LOG_INFO("Device already connected, return"); return; } // TODO: Configure default LE connection parameters? if (add_to_connect_list) { add_device_to_connect_list(address_with_type); Loading Loading
system/gd/hci/acl_manager/le_impl.h +26 −4 Original line number Diff line number Diff line Loading @@ -201,6 +201,16 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback { AddressWithType empty(Address::kEmpty, AddressType::RANDOM_DEVICE_ADDRESS); return empty; } bool alreadyConnected(AddressWithType address_with_type) { for (auto it = le_acl_connections_.begin(); it != le_acl_connections_.end(); it++) { if (it->second.remote_address_ == address_with_type) { return true; } } return false; } } connections; public: Loading Loading @@ -370,10 +380,6 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback { static constexpr bool kRemoveConnectionAfterwards = true; void on_le_disconnect(uint16_t handle, ErrorCode reason) { AddressWithType remote_address = connections.getAddressWithType(handle); if (background_connections_.count(remote_address) == 1) { LOG_INFO("re-add device to connect list"); add_device_to_connect_list(remote_address); } bool event_also_routes_to_other_receivers = connections.crash_on_unknown_handle_; connections.crash_on_unknown_handle_ = false; connections.execute( Loading @@ -384,6 +390,12 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback { }, kRemoveConnectionAfterwards); connections.crash_on_unknown_handle_ = event_also_routes_to_other_receivers; if (background_connections_.count(remote_address) == 1) { LOG_INFO("re-add device to connect list"); add_device_to_connect_list(remote_address); } if (!connect_list.empty()) { LOG_INFO("connect_list is not empty, send a new connection request"); AddressWithType empty(Address::kEmpty, AddressType::RANDOM_DEVICE_ADDRESS); Loading Loading @@ -477,6 +489,11 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback { } void add_device_to_connect_list(AddressWithType address_with_type) { if (connections.alreadyConnected(address_with_type)) { LOG_INFO("Device already connected, return"); return; } connect_list.insert(address_with_type); register_with_address_manager(); le_address_manager_->AddDeviceToConnectList( Loading Loading @@ -528,6 +545,11 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback { return; } if (connections.alreadyConnected(address_with_type)) { LOG_INFO("Device already connected, return"); return; } // TODO: Configure default LE connection parameters? if (add_to_connect_list) { add_device_to_connect_list(address_with_type); Loading