OSDN Git Service

Prevent spurious connect failures callback
authorStanley Tng <stng@google.com>
Thu, 8 Feb 2018 01:59:04 +0000 (17:59 -0800)
committerStanley Tng <stng@google.com>
Thu, 8 Feb 2018 16:24:23 +0000 (08:24 -0800)
Send connection failures only if the event's mac address matches the
currently bonding device.

Test: Run SL4A "BleCocTest:test_coc_secured_connection_throughput"
Bug: 71364658
Change-Id: I64243996ae37dd376ed36363a7d749b4b5ab36b2

stack/btm/btm_sec.cc

index 2caa6f2..c76dad6 100644 (file)
@@ -4087,7 +4087,7 @@ static void btm_sec_connect_after_reject_timeout(UNUSED_ATTR void* data) {
  * Function         btm_sec_connected
  *
  * Description      This function is when a connection to the peer device is
- *                  establsihed
+ *                  established
  *
  * Returns          void
  *
@@ -4283,6 +4283,15 @@ void btm_sec_connected(const RawAddress& bda, uint16_t handle, uint8_t status,
       }
     }
 
+    if (btm_cb.pairing_bda != bda) {
+      /* Don't callback unless this Connection-Complete-failure event has the
+       * same mac address as the bonding device */
+      VLOG(1) << __func__
+              << ": Different mac addresses: pairing_bda=" << btm_cb.pairing_bda
+              << ", bda=" << bda << ", do not callback";
+      return;
+    }
+
     if (status == HCI_ERR_CONNECTION_TOUT ||
         status == HCI_ERR_LMP_RESPONSE_TIMEOUT ||
         status == HCI_ERR_UNSPECIFIED || status == HCI_ERR_PAGE_TIMEOUT)