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

Commit 603a7093 authored by Chris Manton's avatar Chris Manton
Browse files

Remove #def and use IsEprAvailable

Towards readable code

Bug: 163134718
Tag: #refactor
Test: gd/cert/run --host

Change-Id: I65bac30e7060f0cc156676c1f78d2f3482b16835
parent 03b4fc06
Loading
Loading
Loading
Loading
+2 −8
Original line number Diff line number Diff line
@@ -100,12 +100,6 @@ typedef struct {
   HCI_PKT_TYPES_MASK_NO_2_DH3 | HCI_PKT_TYPES_MASK_NO_3_DH3 | \
   HCI_PKT_TYPES_MASK_NO_2_DH5 | HCI_PKT_TYPES_MASK_NO_3_DH5)

#define BTM_EPR_AVAILABLE(p)                                        \
  ((HCI_ATOMIC_ENCRYPT_SUPPORTED((p)->peer_lmp_feature_pages[0]) && \
    controller_get_interface()->supports_encryption_pause())        \
       ? true                                                       \
       : false)

inline bool IsEprAvailable(const tACL_CONN& p_acl) {
  if (!p_acl.peer_lmp_feature_valid[0]) {
    LOG_WARN("Checking incomplete feature page read");
@@ -532,7 +526,7 @@ tBTM_STATUS BTM_SwitchRoleToCentral(const RawAddress& remote_bd_addr) {
  }
  /* some devices do not support switch while encryption is on */
  else {
    if (p_acl->is_encrypted && !BTM_EPR_AVAILABLE(p_acl)) {
    if (p_acl->is_encrypted && !IsEprAvailable(*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();
@@ -2154,7 +2148,7 @@ void btm_cont_rswitch_from_handle(uint16_t hci_handle) {
    /* Must turn off Encryption first if necessary */
    /* Some devices do not support switch or change of link key while encryption
     * is on */
    if (p->is_encrypted && !BTM_EPR_AVAILABLE(p)) {
    if (p->is_encrypted && !IsEprAvailable(*p)) {
      p->set_encryption_off();
      if (p->is_switch_role_mode_change()) {
        p->set_switch_role_encryption_off();