Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 042fcb3e authored by Hsin-chen Chuang's avatar Hsin-chen Chuang
Browse files

SMP over BR: Clear LE link key info for temporary bond

In case a temporary bond triggered SMP over BR, the link key would be
dropped in btif layer but btm only reset the classic link key info on
disconnected.

The LE link key info can't be reset together with classic because at
that point we can't distinguish a LTK is generated by the current
temporary bond or not (it may be generated by a previous bond).

As a result, this patch clears the LE flags on SMP_COMPLT_EVT when it's
a temporary bond and there is no LE ACL handle.

Bug: 298459880
Test: mmm packages/modules/Bluetooth
Test: bluetooth_AdapterCLHealth.all_floss
Test: bluetooth_AdapterLEHealth.all_floss
Test: Manually tested NearbyShare and CrossDevice on ChromeOS
Change-Id: Ib588fc62dff7aa37ff278ce0657ea14400215760
parent 791d8705
Loading
Loading
Loading
Loading
+14 −2
Original line number Diff line number Diff line
@@ -1870,8 +1870,20 @@ tBTM_STATUS btm_proc_smp_cback(tSMP_EVT event, const RawAddress& bd_addr,

          if (res == BTM_SUCCESS) {
            p_dev_rec->sec_state = BTM_SEC_STATE_IDLE;
            /* add all bonded device into resolving list if IRK is available*/

            if (p_dev_rec->bond_type != tBTM_SEC_DEV_REC::BOND_TYPE_TEMPORARY) {
              // Add all bonded device into resolving list if IRK is available.
              btm_ble_resolving_list_load_dev(*p_dev_rec);
            } else if (p_dev_rec->ble_hci_handle == HCI_INVALID_HANDLE) {
              // At this point LTK should have been dropped by btif.
              // Reset the flags here if LE is not connected (over BR),
              // otherwise they would be reset on disconnected.
              LOG_DEBUG(
                  "SMP over BR triggered by temporary bond has completed,"
                  " resetting the LK flags");
              p_dev_rec->sec_flags &= ~(BTM_SEC_LE_LINK_KEY_KNOWN);
              p_dev_rec->ble.key_type = BTM_LE_KEY_NONE;
            }
          }

          btm_sec_dev_rec_cback_event(p_dev_rec, res, true);