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

Commit 9308fa44 authored by Hansong Zhang's avatar Hansong Zhang
Browse files

Use some L2cap APIs in btm_sec

When we need to start encryption or handle encryption change, link must
be up and L2cap must be already connected.

Test: cert/run
Tag: #gd-refactor
Bug: 141555841
Change-Id: Ifd787141ac3669c377b54bf58f9b53776764d61f
parent 45ac3f75
Loading
Loading
Loading
Loading
+0 −8
Original line number Diff line number Diff line
@@ -2603,14 +2603,6 @@ uint8_t acl_link_role_from_handle(uint16_t handle) {
  return p_acl->link_role;
}

bool acl_is_transport_le_from_handle(uint16_t handle) {
  tACL_CONN* p_acl = internal_.acl_get_connection_from_handle(handle);
  if (p_acl == nullptr) {
    return false;
  }
  return p_acl->transport == BT_TRANSPORT_LE;
}

tBT_TRANSPORT acl_get_transport_from_handle(uint16_t handle) {
  tACL_CONN* p_acl = internal_.acl_get_connection_from_handle(handle);
  if (p_acl == nullptr) {
+4 −7
Original line number Diff line number Diff line
@@ -1096,7 +1096,7 @@ tBTM_STATUS BTM_SetEncryption(const RawAddress& bd_addr,
  if (transport == BT_TRANSPORT_LE) {
    if (BTM_IsAclConnectionUp(bd_addr, BT_TRANSPORT_LE)) {
      rc = btm_ble_set_encryption(bd_addr, sec_act,
                                  acl_link_role(bd_addr, transport));
                                  L2CA_GetBleConnRole(bd_addr));
    } else {
      rc = BTM_WRONG_MODE;
      BTM_TRACE_WARNING("%s: cannot call btm_ble_set_encryption, p is NULL",
@@ -3204,13 +3204,10 @@ void btm_sec_encrypt_change(uint16_t handle, tHCI_STATUS status,
  BTM_TRACE_DEBUG("after update p_dev_rec->sec_flags=0x%x",
                  p_dev_rec->sec_flags);

  if (BTM_IsAclConnectionUpFromHandle(handle)) {
  btm_sec_check_pending_enc_req(
      p_dev_rec, acl_get_transport_from_handle(handle), encr_enable);
  }

  if (BTM_IsAclConnectionUpFromHandle(handle) &&
      acl_is_transport_le_from_handle(handle)) {
  if (BTM_IsBleConnection(handle)) {
    if (status == HCI_ERR_KEY_MISSING || status == HCI_ERR_AUTH_FAILURE ||
        status == HCI_ERR_ENCRY_MODE_NOT_ACCEPTABLE) {
      p_dev_rec->sec_flags &= ~(BTM_SEC_LE_LINK_KEY_KNOWN);
+0 −2
Original line number Diff line number Diff line
@@ -283,8 +283,6 @@ void btm_cont_rswitch_from_handle(uint16_t hci_handle);
uint8_t acl_link_role(const RawAddress& remote_bda, tBT_TRANSPORT transport);
uint8_t acl_link_role_from_handle(uint16_t handle);

bool acl_is_transport_le_from_handle(uint16_t handle);

tBT_TRANSPORT acl_get_transport_from_handle(uint16_t handle);

uint16_t acl_get_hci_handle_for_hcif(const RawAddress& bd_addr,