summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreehugger Robot <treehugger-gerrit@google.com>2022-03-23 03:47:33 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2022-03-23 03:47:33 +0000
commit11ff2874e1af9034c8d1edd63a5060bcc4cb795f (patch)
tree005af76d9b19d9f178779d39861a7ab8a835b4f2
parent113dab4e87f00947060593d582f15678a8d228cd (diff)
parent35c693b030ac5e7f5e29f849cba49e8768726e01 (diff)
Merge "Do not add connected device to accept list" am: bad9886714 am: 35c693b030
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Bluetooth/+/2036643 Change-Id: Iab0f371e261fd7d0bed740f34caf7df9b557fa74
-rw-r--r--system/gd/hci/acl_manager/le_impl.h30
1 files changed, 26 insertions, 4 deletions
diff --git a/system/gd/hci/acl_manager/le_impl.h b/system/gd/hci/acl_manager/le_impl.h
index c1c5ff732b..a16baf76a6 100644
--- a/system/gd/hci/acl_manager/le_impl.h
+++ b/system/gd/hci/acl_manager/le_impl.h
@@ -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:
@@ -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(
@@ -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);
@@ -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(
@@ -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);