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

Commit 86d8a51d authored by Chris Manton's avatar Chris Manton
Browse files

Use tHCI_STATUS in btm_sec_disconnect

Bug: 163134718
Tag: #refactor
Test: act.py -tc BleCocTest
Test: ble paired 2 phones
Test: classic paired Bose SoundLink

Change-Id: Idc93062d96aa45c0e4ed385a3fa09e6cbdabf915
parent da601eaf
Loading
Loading
Loading
Loading
+7 −26
Original line number Diff line number Diff line
@@ -86,7 +86,7 @@ static void btm_send_link_key_notif(tBTM_SEC_DEV_REC* p_dev_rec);
static bool btm_sec_check_prefetch_pin(tBTM_SEC_DEV_REC* p_dev_rec);

static tBTM_STATUS btm_sec_send_hci_disconnect(tBTM_SEC_DEV_REC* p_dev_rec,
                                               uint8_t reason,
                                               tHCI_STATUS reason,
                                               uint16_t conn_handle);
tBTM_SEC_DEV_REC* btm_sec_find_dev_by_sec_state(uint8_t state);

@@ -1125,7 +1125,7 @@ bool BTM_SecIsSecurityPending(const RawAddress& bd_addr) {
 * disconnect the ACL link, if it's not done yet.
 ******************************************************************************/
static tBTM_STATUS btm_sec_send_hci_disconnect(tBTM_SEC_DEV_REC* p_dev_rec,
                                               uint8_t reason,
                                               tHCI_STATUS reason,
                                               uint16_t conn_handle) {
  uint8_t old_state = p_dev_rec->sec_state;
  tBTM_STATUS status = BTM_CMD_STARTED;
@@ -3004,17 +3004,7 @@ static bool btm_sec_auth_retry(uint16_t handle, uint8_t status) {
  return false;
}

/*******************************************************************************
 *
 * Function         btm_sec_auth_complete
 *
 * Description      This function is when authentication of the connection is
 *                  completed by the LM
 *
 * Returns          void
 *
 ******************************************************************************/
void btm_sec_auth_complete(uint16_t handle, uint8_t status) {
void btm_sec_auth_complete(uint16_t handle, tHCI_STATUS status) {
  tBTM_PAIRING_STATE old_state = btm_cb.pairing_state;
  tBTM_SEC_DEV_REC* p_dev_rec = btm_find_dev_by_handle(handle);
  bool are_bonding = false;
@@ -3161,12 +3151,12 @@ void btm_sec_auth_complete(uint16_t handle, uint8_t status) {
  }

  /* Authentication succeeded, execute the next security procedure, if any */
  status = btm_sec_execute_procedure(p_dev_rec);
  uint8_t btm_status = btm_sec_execute_procedure(p_dev_rec);

  /* If there is no next procedure, or procedure failed to start, notify the
   * caller */
  if (status != BTM_CMD_STARTED)
    btm_sec_dev_rec_cback_event(p_dev_rec, status, false);
  if (btm_status != BTM_CMD_STARTED)
    btm_sec_dev_rec_cback_event(p_dev_rec, btm_status, false);
}

/*******************************************************************************
@@ -3640,16 +3630,7 @@ void btm_sec_connected(const RawAddress& bda, uint16_t handle, uint8_t status,
  return;
}

/*******************************************************************************
 *
 * Function         btm_sec_disconnect
 *
 * Description      This function is called to disconnect HCI link
 *
 * Returns          btm status
 *
 ******************************************************************************/
tBTM_STATUS btm_sec_disconnect(uint16_t handle, uint8_t reason) {
tBTM_STATUS btm_sec_disconnect(uint16_t handle, tHCI_STATUS reason) {
  tBTM_SEC_DEV_REC* p_dev_rec = btm_find_dev_by_handle(handle);

  /* In some weird race condition we may not have a record */
+2 −2
Original line number Diff line number Diff line
@@ -597,7 +597,7 @@ void btm_read_local_oob_complete(uint8_t* p);
 * Returns          void
 *
 ******************************************************************************/
void btm_sec_auth_complete(uint16_t handle, uint8_t status);
void btm_sec_auth_complete(uint16_t handle, tHCI_STATUS status);

/*******************************************************************************
 *
@@ -634,7 +634,7 @@ void btm_sec_connected(const RawAddress& bda, uint16_t handle, uint8_t status,
 * Returns          btm status
 *
 ******************************************************************************/
tBTM_STATUS btm_sec_disconnect(uint16_t handle, uint8_t reason);
tBTM_STATUS btm_sec_disconnect(uint16_t handle, tHCI_STATUS reason);

/*******************************************************************************
 *
+1 −1
Original line number Diff line number Diff line
@@ -178,7 +178,7 @@ typedef struct {
                               uint8_t pin_length);
  friend void BTM_PINCodeReply(const RawAddress& bd_addr, uint8_t res,
                               uint8_t pin_len, uint8_t* p_pin);
  friend void btm_sec_auth_complete(uint16_t handle, uint8_t status);
  friend void btm_sec_auth_complete(uint16_t handle, tHCI_STATUS status);
  friend void btm_sec_connected(const RawAddress& bda, uint16_t handle,
                                uint8_t status, uint8_t enc_mode);
  friend void btm_sec_encrypt_change(uint16_t handle, uint8_t status,
+3 −2
Original line number Diff line number Diff line
@@ -1041,7 +1041,7 @@ static void btu_hcif_authentication_comp_evt(uint8_t* p) {
  STREAM_TO_UINT8(status, p);
  STREAM_TO_UINT16(handle, p);

  btm_sec_auth_complete(handle, status);
  btm_sec_auth_complete(handle, static_cast<tHCI_STATUS>(status));
}

/*******************************************************************************
@@ -1408,7 +1408,8 @@ static void btu_hcif_hdl_command_status(uint16_t opcode, uint8_t status,
      if (status != HCI_SUCCESS) {
        // Device refused to start authentication
        // This is treated as an authentication failure
        btm_sec_auth_complete(HCI_INVALID_HANDLE, status);
        btm_sec_auth_complete(HCI_INVALID_HANDLE,
                              static_cast<tHCI_STATUS>(status));
      }
      break;
    case HCI_SET_CONN_ENCRYPTION:
+1 −1
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@ void btm_proc_sp_req_evt(tBTM_SP_EVT event, uint8_t* p);
void btm_read_inq_tx_power_complete(uint8_t* p);
void btm_read_local_oob_complete(uint8_t* p);
void btm_rem_oob_req(uint8_t* p);
void btm_sec_auth_complete(uint16_t handle, uint8_t status);
void btm_sec_auth_complete(uint16_t handle, tHCI_STATUS status);
void btm_sec_disconnected(uint16_t handle, tHCI_STATUS reason);
void btm_sec_encrypt_change(uint16_t handle, uint8_t status,
                            uint8_t encr_enable);