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

Commit 82075007 authored by Chris Manton's avatar Chris Manton
Browse files

Streamline stack/btm/btm_ble_addr::btm_ble_addr_resolvable

Toward readable code

Bug: 163134718
Tag: #refactor
Test: compile & verify basic functions working

Change-Id: I6600ac7d3fdc1a9ff099b0ffa8c9b1826c6db456
parent ca2af5f8
Loading
Loading
Loading
Loading
+4 −9
Original line number Diff line number Diff line
@@ -179,25 +179,20 @@ bool btm_ble_addr_resolvable(const RawAddress& rpa,
 * starting from calculating IRK. If the record index exceeds the maximum record
 * number, matching failed and send a callback. */
static bool btm_ble_match_random_bda(void* data, void* context) {
  BTM_TRACE_EVENT("%s next iteration", __func__);
  RawAddress* random_bda = (RawAddress*)context;

  tBTM_SEC_DEV_REC* p_dev_rec = static_cast<tBTM_SEC_DEV_REC*>(data);

  BTM_TRACE_DEBUG("sec_flags = %02x device_type = %d", p_dev_rec->sec_flags,
                  p_dev_rec->device_type);
  RawAddress* random_bda = static_cast<RawAddress*>(context);

  if (!(p_dev_rec->device_type & BT_DEVICE_TYPE_BLE) ||
      !(p_dev_rec->ble.key_type & BTM_LE_KEY_PID))
    // Match fails preconditions
    return true;

  if (rpa_matches_irk(*random_bda, p_dev_rec->ble.keys.irk)) {
    BTM_TRACE_EVENT("match is found");
    // if it was match, finish iteration, otherwise continue
    // Matched
    return false;
  }

  // not a match, continue iteration
  // This item not a match, continue iteration
  return true;
}