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

Commit 94d310a0 authored by Hansong Zhang's avatar Hansong Zhang
Browse files

Introduce ACL_CONN is_enceypted

Use it as the source of truth for enceyption state in ACL.

No need to check device record then.

Bug: 159815595
Tag: #refactor
Test: compile & verify basic functions working
Change-Id: If28b8a9779ad958562cf0ec99f982d4910c0c1a1
parent 65b05a9b
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -100,6 +100,7 @@ typedef struct {
  }

 public:
  bool is_encrypted = false;
  uint8_t link_role;
  uint8_t lmp_version;
  uint8_t switch_role_failed_attempts;
+3 −4
Original line number Diff line number Diff line
@@ -576,10 +576,7 @@ tBTM_STATUS BTM_SwitchRole(const RawAddress& remote_bd_addr, uint8_t new_role) {
  }
  /* some devices do not support switch while encryption is on */
  else {
    tBTM_SEC_DEV_REC* p_dev_rec = btm_find_dev(remote_bd_addr);
    if ((p_dev_rec != NULL) &&
        ((p_dev_rec->sec_flags & BTM_SEC_ENCRYPTED) != 0) &&
        !BTM_EPR_AVAILABLE(p_acl)) {
    if (p_acl->is_encrypted && !BTM_EPR_AVAILABLE(p_acl)) {
      /* bypass turning off encryption if change link key is already doing it */
      p_acl->set_encryption_off();
      p_acl->set_switch_role_encryption_off();
@@ -617,6 +614,8 @@ void btm_acl_encrypt_change(uint16_t handle, uint8_t status,
  else
    return;

  p->is_encrypted = encr_enable;

  /* Process Role Switch if active */
  if (p->is_switch_role_encryption_off()) {
    /* if encryption turn off failed we still will try to switch role */