OSDN Git Service

ACL: Move some security flag change to Security
authorHansong Zhang <hsz@google.com>
Thu, 29 Oct 2020 23:00:09 +0000 (16:00 -0700)
committerHansong Zhang <hsz@google.com>
Thu, 29 Oct 2020 23:23:45 +0000 (16:23 -0700)
Moving BTM_SEC_LE_LINK_KEY_AUTHED and BTM_SEC_ROLE_SWITCHED.

Bug: 159815595
Tag: #refactor
Test: compile & verify basic functions working
Change-Id: Ib8440b6956d7424d3c9f722d6705deefb619679d

stack/acl/btm_acl.cc
stack/btm/btm_sec.cc

index aed1df0..b90c00e 100644 (file)
@@ -487,18 +487,6 @@ void btm_acl_removed(uint16_t handle) {
     BTA_dm_acl_down(bda, transport);
   }
 
-  tBTM_SEC_DEV_REC* p_dev_rec = btm_find_dev(bda);
-  if (p_dev_rec == nullptr) {
-    LOG_WARN("Device security record not found");
-  } else {
-    if (p_acl->transport == BT_TRANSPORT_LE) {
-      p_dev_rec->sec_flags &= ~(BTM_SEC_LE_ENCRYPTED | BTM_SEC_ROLE_SWITCHED);
-      if ((p_dev_rec->sec_flags & BTM_SEC_LE_LINK_KEY_KNOWN) == 0) {
-        p_dev_rec->sec_flags &=
-            ~(BTM_SEC_LE_LINK_KEY_AUTHED | BTM_SEC_LE_AUTHENTICATED);
-      }
-    }
-  }
   memset(p_acl, 0, sizeof(tACL_CONN));
 }
 
index 7724c7f..c6f1a0f 100644 (file)
@@ -3722,9 +3722,15 @@ void btm_sec_disconnected(uint16_t handle, tHCI_STATUS reason) {
 
   if (transport == BT_TRANSPORT_LE) {
     p_dev_rec->ble_hci_handle = HCI_INVALID_HANDLE;
-    p_dev_rec->sec_flags &= ~(BTM_SEC_LE_AUTHENTICATED | BTM_SEC_LE_ENCRYPTED);
+    p_dev_rec->sec_flags &= ~(BTM_SEC_LE_AUTHENTICATED | BTM_SEC_LE_ENCRYPTED |
+                              BTM_SEC_ROLE_SWITCHED);
     p_dev_rec->enc_key_size = 0;
 
+    if ((p_dev_rec->sec_flags & BTM_SEC_LE_LINK_KEY_KNOWN) == 0) {
+      p_dev_rec->sec_flags &=
+          ~(BTM_SEC_LE_LINK_KEY_AUTHED | BTM_SEC_LE_AUTHENTICATED);
+    }
+
     // This is for chips that don't support being in connected and advertising
     // state at same time.
     if (!p_dev_rec->is_originator) {