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

Commit fe2d40d7 authored by Jakub Pawlowski's avatar Jakub Pawlowski Committed by Christine Hallstrom
Browse files

Keep the IRK when the scan is finished

Bug: 201255908
Bug: 280811285
Test: manually tested against phone with sample IRK scanning app
Change-Id: I58f8caf2c29bf2b12db2e595d42295b65dc4fa13
Merged-In: I58f8caf2c29bf2b12db2e595d42295b65dc4fa13
parent fec3d3ff
Loading
Loading
Loading
Loading
+1 −27
Original line number Diff line number Diff line
@@ -682,6 +682,7 @@ void BTM_LE_PF_set(tBTM_BLE_PF_FILT_INDEX filt_index,
            return;
          }
          // Allocate a new "temporary" device record

          btm_sec_alloc_dev(cmd.address);
          remove_me_later_map.emplace(filt_index, cmd.address);
          // Set the IRK
@@ -770,15 +771,6 @@ void BTM_LE_PF_clear(tBTM_BLE_PF_FILT_INDEX filt_index,
    /* clear service data filter */
    BTM_LE_PF_srvc_data_pattern(BTM_BLE_SCAN_COND_CLEAR, filt_index, {}, {},
                                fDoNothing);

    // If we have an entry, lets remove the device if it isn't bonded
    auto entry = remove_me_later_map.find(filt_index);
    if (entry != remove_me_later_map.end()) {
      auto entry = remove_me_later_map.find(filt_index);
      if (!btm_sec_is_a_bonded_dev(entry->second)) {
        BTM_SecDeleteDevice(entry->second);
      }
    }
  }

  uint8_t len = BTM_BLE_ADV_FILT_META_HDR_LENGTH + BTM_BLE_PF_FEAT_SEL_LEN;
@@ -896,24 +888,6 @@ void BTM_BleAdvFilterParamSetup(
        (uint8_t)(BTM_BLE_ADV_FILT_META_HDR_LENGTH),
        base::Bind(&btm_flt_update_cb, BTM_BLE_META_PF_FEAT_SEL, cb));

    auto entry = remove_me_later_map.find(filt_index);
    if (entry != remove_me_later_map.end()) {
      LOG_WARN("Replacing existing filter index entry with new address");
      // If device is not bonded, then try removing the device
      // If the device doesn't get removed then it is currently connected
      // (may be pairing?) If we do delete the device we want to erase the
      // filter index so we can replace it If the device is bonded, we
      // want to erase the filter index so we don't delete it in the later
      // BTM_LE_PF_clear call.
      if (!btm_sec_is_a_bonded_dev(entry->second)) {
        if (!BTM_SecDeleteDevice(entry->second)) {
          LOG_WARN("Unable to remove device, still connected.");
          return;
        }
      }
      remove_me_later_map.erase(filt_index);
    }

  } else if (BTM_BLE_SCAN_COND_CLEAR == action) {
    /* Deallocate all filters here */
    btm_ble_dealloc_addr_filter_counter(NULL, BTM_BLE_PF_TYPE_ALL);