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

Commit 22e88721 authored by Jakub Pawlowski's avatar Jakub Pawlowski
Browse files

ESR11-E7716: Disable scans while setting local RPA

This change is required to disable any ongoing classic
advertisement or any scan before setting the RPA for the
DUT, and reenable them after the Set RPA command.
If a direct connection is ongoing, the RPA is not set.
A background connection is suspended and resumed for
sending the "Set RPA" HCI command.

This patch is based on CAF patch by niarora@codeaurora.org
690c2db21f650f74c202fd380cca4ca74cbdf83c

Test: manual
Bug: 35935853
Change-Id: Ifbc90d0c52c8f1fa627ac80c20a69149e89cb794
parent fc2060e6
Loading
Loading
Loading
Loading
+28 −0
Original line number Diff line number Diff line
@@ -2363,6 +2363,34 @@ void btm_ble_reset_id(void) {
  }));
}

/* This function set a random address to local controller. It also temporarily
 * disable scans and adv before sending the command to the controller. */
void btm_ble_set_random_address(BD_ADDR random_bda) {
  tBTM_LE_RANDOM_CB* p_cb = &btm_cb.ble_ctr_cb.addr_mgnt_cb;
  tBTM_BLE_CB* p_ble_cb = &btm_cb.ble_ctr_cb;
  bool adv_mode = btm_cb.ble_ctr_cb.inq_var.adv_mode;

  BTM_TRACE_DEBUG("%s", __func__);
  if (btm_ble_get_conn_st() == BLE_DIR_CONN) {
    BTM_TRACE_ERROR("%s: Cannot set random address. Direct conn ongoing",
                    __func__);
    return;
  }

  if (adv_mode == BTM_BLE_ADV_ENABLE)
    btsnd_hcic_ble_set_adv_enable(BTM_BLE_ADV_DISABLE);
  if (BTM_BLE_IS_SCAN_ACTIVE(p_ble_cb->scan_activity)) btm_ble_stop_scan();
  btm_ble_suspend_bg_conn();

  memcpy(p_cb->private_addr, random_bda, BD_ADDR_LEN);
  btsnd_hcic_ble_set_random_addr(p_cb->private_addr);

  if (adv_mode == BTM_BLE_ADV_ENABLE)
    btsnd_hcic_ble_set_adv_enable(BTM_BLE_ADV_ENABLE);
  if (BTM_BLE_IS_SCAN_ACTIVE(p_ble_cb->scan_activity)) btm_ble_start_scan();
  btm_ble_resume_bg_conn();
}

#if BTM_BLE_CONFORMANCE_TESTING == TRUE
/*******************************************************************************
 *
+1 −1
Original line number Diff line number Diff line
@@ -57,7 +57,7 @@ static void btm_gen_resolve_paddr_cmpl(tSMP_ENC* p) {
    p_cb->private_addr[4] = p->param_buf[1];
    p_cb->private_addr[3] = p->param_buf[2];
    /* set it to controller */
    btsnd_hcic_ble_set_random_addr(p_cb->private_addr);
    btm_ble_set_random_address(p_cb->private_addr);

    p_cb->own_addr_type = BLE_ADDR_RANDOM;

+1 −0
Original line number Diff line number Diff line
@@ -190,6 +190,7 @@ extern void btm_ble_adv_filter_cleanup(void);
extern bool btm_ble_topology_check(tBTM_BLE_STATE_MASK request);
extern bool btm_ble_clear_topology_mask(tBTM_BLE_STATE_MASK request_state);
extern bool btm_ble_set_topology_mask(tBTM_BLE_STATE_MASK request_state);
extern void btm_ble_set_random_address(BD_ADDR random_bda);

#if (BTM_BLE_CONFORMANCE_TESTING == TRUE)
extern void btm_ble_set_no_disc_if_pair_fail(bool disble_disc);