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

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

Remove def BLE_PRIVACY_SPT

Always TRUE; untested and unsupported when false

Towards readable code

Bug: 163134718
Tag: #refactor
Test: compile & verify basic functions working
Change-Id: I88e5466db12dfafbe9ed4ef66459b0c9da7f4fc1
parent 413e8381
Loading
Loading
Loading
Loading
+0 −21
Original line number Diff line number Diff line
@@ -232,7 +232,6 @@ tACL_CONN* StackAclBtmAcl::acl_get_connection_from_handle(uint16_t hci_handle) {
  return &btm_cb.acl_cb_.acl_db[index];
}

#if (BLE_PRIVACY_SPT == TRUE)
/*******************************************************************************
 *
 * Function         btm_ble_get_acl_remote_addr
@@ -278,7 +277,6 @@ bool btm_ble_get_acl_remote_addr(tBTM_SEC_DEV_REC* p_dev_rec,

  return st;
}
#endif

void btm_acl_process_sca_cmpl_pkt(uint8_t len, uint8_t* data) {
  uint16_t handle;
@@ -357,15 +355,9 @@ void btm_acl_created(const RawAddress& bda, uint16_t hci_handle,
      btm_set_link_policy(p, btm_cb.acl_cb_.btm_def_link_policy);

      p->transport = transport;
#if (BLE_PRIVACY_SPT == TRUE)
      if (transport == BT_TRANSPORT_LE)
        btm_ble_refresh_local_resolvable_private_addr(
            bda, btm_cb.ble_ctr_cb.addr_mgnt_cb.private_addr);
#else
      p->conn_addr_type = BLE_ADDR_PUBLIC;
      p->conn_addr = *controller_get_interface()->get_address();

#endif
      p->switch_role_failed_attempts = 0;
      p->switch_role_state = BTM_ACL_SWKEY_STATE_IDLE;

@@ -422,10 +414,8 @@ void btm_acl_created(const RawAddress& bda, uint16_t hci_handle,

      /* If here, features are not known yet */
      if (p_dev_rec && transport == BT_TRANSPORT_LE) {
#if (BLE_PRIVACY_SPT == TRUE)
        btm_ble_get_acl_remote_addr(p_dev_rec, p->active_remote_addr,
                                    &p->active_remote_addr_type);
#endif

        if (controller_get_interface()
                ->supports_ble_peripheral_initiated_feature_exchange() ||
@@ -2605,7 +2595,6 @@ int btm_pm_find_acl_ind(const RawAddress& remote_bda) {
 ******************************************************************************/
void btm_ble_refresh_local_resolvable_private_addr(
    const RawAddress& pseudo_addr, const RawAddress& local_rpa) {
#if (BLE_PRIVACY_SPT == TRUE)
  tACL_CONN* p = internal_.btm_bda_to_acl(pseudo_addr, BT_TRANSPORT_LE);

  if (p != NULL) {
@@ -2620,7 +2609,6 @@ void btm_ble_refresh_local_resolvable_private_addr(
      p->conn_addr = *controller_get_interface()->get_address();
    }
  }
#endif
}

/*******************************************************************************
@@ -2706,7 +2694,6 @@ bool BTM_ReadRemoteConnectionAddr(const RawAddress& pseudo_addr,
                                                         p_addr_type);
  }
  bool st = true;
#if (BLE_PRIVACY_SPT == TRUE)
  tACL_CONN* p_acl = internal_.btm_bda_to_acl(pseudo_addr, BT_TRANSPORT_LE);

  if (p_acl == NULL) {
@@ -2718,14 +2705,6 @@ bool BTM_ReadRemoteConnectionAddr(const RawAddress& pseudo_addr,

  conn_addr = p_acl->active_remote_addr;
  *p_addr_type = p_acl->active_remote_addr_type;
#else
  tBTM_SEC_DEV_REC* p_dev_rec = btm_find_dev(pseudo_addr);

  conn_addr = pseudo_addr;
  if (p_dev_rec != NULL) {
    *p_addr_type = p_dev_rec->ble.ble_addr_type;
  }
#endif
  return st;
}

+0 −8
Original line number Diff line number Diff line
@@ -161,10 +161,8 @@ bool BTM_SecAddBleKey(const RawAddress& bd_addr, tBTM_LE_KEY_VALUE* p_le_key,

  btm_sec_save_le_key(bd_addr, key_type, p_le_key, false);

#if (BLE_PRIVACY_SPT == TRUE)
  if (key_type == BTM_LE_KEY_PID || key_type == BTM_LE_KEY_LID)
    btm_ble_resolving_list_load_dev(p_dev_rec);
#endif

  return (true);
}
@@ -1767,12 +1765,10 @@ void btm_ble_connected(const RawAddress& bda, uint16_t handle, uint8_t enc_mode,
  p_dev_rec->role_master = false;
  if (role == HCI_ROLE_MASTER) p_dev_rec->role_master = true;

#if (BLE_PRIVACY_SPT == TRUE)
  if (!addr_matched) p_dev_rec->ble.active_addr_type = BTM_BLE_ADDR_PSEUDO;

  if (p_dev_rec->ble.ble_addr_type == BLE_ADDR_RANDOM && !addr_matched)
    p_dev_rec->ble.cur_rand_addr = bda;
#endif

  p_cb->inq_var.directed_conn = BTM_BLE_CONNECT_EVT;

@@ -1888,10 +1884,8 @@ uint8_t btm_proc_smp_cback(tSMP_EVT event, const RawAddress& bd_addr,

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

          btm_sec_dev_rec_cback_event(p_dev_rec, res, true);
@@ -2065,12 +2059,10 @@ static void btm_ble_reset_id_impl(const Octet16& rand1, const Octet16& rand2) {

  btm_notify_new_key(BTM_BLE_KEY_TYPE_ID);

#if (BLE_PRIVACY_SPT == TRUE)
  /* if privacy is enabled, new RPA should be calculated */
  if (btm_cb.ble_ctr_cb.privacy_mode != BTM_PRIVACY_NONE) {
    btm_gen_resolvable_private_addr(base::Bind(&btm_gen_resolve_paddr_low));
  }
#endif

  /* proceed generate ER */
  btm_cb.devcb.ble_encryption_key_value = rand2;
+0 −8
Original line number Diff line number Diff line
@@ -222,7 +222,6 @@ tBTM_SEC_DEV_REC* btm_ble_resolve_random_addr(const RawAddress& random_bda) {
/** Find the security record whose LE identity address is matching */
tBTM_SEC_DEV_REC* btm_find_dev_by_identity_addr(const RawAddress& bd_addr,
                                                uint8_t addr_type) {
#if (BLE_PRIVACY_SPT == TRUE)
  list_node_t* end = list_end(btm_cb.sec_dev_rec);
  for (list_node_t* node = list_begin(btm_cb.sec_dev_rec); node != end;
       node = list_next(node)) {
@@ -239,7 +238,6 @@ tBTM_SEC_DEV_REC* btm_find_dev_by_identity_addr(const RawAddress& bd_addr,
      return p_dev_rec;
    }
  }
#endif

  return NULL;
}
@@ -254,7 +252,6 @@ tBTM_SEC_DEV_REC* btm_find_dev_by_identity_addr(const RawAddress& bd_addr,
 ******************************************************************************/
bool btm_identity_addr_to_random_pseudo(RawAddress* bd_addr,
                                        uint8_t* p_addr_type, bool refresh) {
#if (BLE_PRIVACY_SPT == TRUE)
  tBTM_SEC_DEV_REC* p_dev_rec =
      btm_find_dev_by_identity_addr(*bd_addr, *p_addr_type);

@@ -273,7 +270,6 @@ bool btm_identity_addr_to_random_pseudo(RawAddress* bd_addr,
    *p_addr_type = p_dev_rec->ble.ble_addr_type;
    return true;
  }
#endif
  return false;
}

@@ -287,7 +283,6 @@ bool btm_identity_addr_to_random_pseudo(RawAddress* bd_addr,
 ******************************************************************************/
bool btm_random_pseudo_to_identity_addr(RawAddress* random_pseudo,
                                        uint8_t* p_identity_addr_type) {
#if (BLE_PRIVACY_SPT == TRUE)
  tBTM_SEC_DEV_REC* p_dev_rec = btm_find_dev(*random_pseudo);

  if (p_dev_rec != NULL) {
@@ -299,7 +294,6 @@ bool btm_random_pseudo_to_identity_addr(RawAddress* random_pseudo,
      return true;
    }
  }
#endif
  return false;
}

@@ -315,7 +309,6 @@ bool btm_random_pseudo_to_identity_addr(RawAddress* random_pseudo,
void btm_ble_refresh_peer_resolvable_private_addr(const RawAddress& pseudo_bda,
                                                  const RawAddress& rpa,
                                                  uint8_t rra_type) {
#if (BLE_PRIVACY_SPT == TRUE)
  /* update security record here, in adv event or connection complete process */
  tBTM_SEC_DEV_REC* p_sec_rec = btm_find_dev(pseudo_bda);
  if (p_sec_rec != NULL) {
@@ -344,6 +337,5 @@ void btm_ble_refresh_peer_resolvable_private_addr(const RawAddress& pseudo_bda,
      BTM_TRACE_ERROR("%s Unknown device to refresh remote device", __func__);
    }
  }
#endif
}
+0 −2
Original line number Diff line number Diff line
@@ -501,7 +501,6 @@ void BTM_LE_PF_addr_filter(tBTM_BLE_SCAN_COND_OP action,
  UINT8_TO_STREAM(p, filt_index);

  if (action != BTM_BLE_SCAN_COND_CLEAR) {
#if (BLE_PRIVACY_SPT == TRUE)
    if (addr.type == BLE_ADDR_PUBLIC_ID) {
      LOG(INFO) << __func__ << " Filter address " << addr.bda
                << " has type PUBLIC_ID, try to get identity address";
@@ -509,7 +508,6 @@ void BTM_LE_PF_addr_filter(tBTM_BLE_SCAN_COND_OP action,
       * this call will have no effect. */
      btm_random_pseudo_to_identity_addr(&addr.bda, &addr.type);
    }
#endif

    LOG(INFO) << __func__
              << " Adding scan filter with peer address: " << addr.bda;
+0 −2
Original line number Diff line number Diff line
@@ -379,14 +379,12 @@ bool btm_ble_start_auto_conn() {

  btm_execute_wl_dev_operation();

#if (BLE_PRIVACY_SPT == TRUE)
  btm_ble_enable_resolving_list_for_platform(BTM_BLE_RL_INIT);
  if (btm_cb.ble_ctr_cb.rl_state != BTM_BLE_RL_IDLE &&
      controller_get_interface()->supports_ble_privacy()) {
    own_addr_type |= BLE_ADDR_TYPE_ID_BIT;
    peer_addr_type |= BLE_ADDR_TYPE_ID_BIT;
  }
#endif

  btm_send_hci_create_connection(
      scan_int,                       /* uint16_t scan_int      */
Loading