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

Commit 7648e3d3 authored by Zach Johnson's avatar Zach Johnson Committed by Chris Manton
Browse files

Remove BLE_DELAY_REQUEST_ENC

If it is enabled, the logic makes no sense.

The security flags are stored in 2 bytes.
The upper byte is LE security flags, and the lower byte is classic flags.
It is checking the classic flags to determine whether to start
BLE encryption.

It was false by default.

Bug: 159815595
Tag: #refactor
Test: compile & verify basic functions working
Change-Id: Ifabf514e20c2bc95d2f81a94158b8b63c5e2db6d
parent 40013ba0
Loading
Loading
Loading
Loading
+0 −7
Original line number Diff line number Diff line
@@ -59,7 +59,6 @@ void btif_to_bta_response(tGATTS_RSP* p_dest, btgatt_response_t* p_src) {
 * Encrypted link map handling
 ******************************************************************************/

#if (BLE_DELAY_REQUEST_ENC == FALSE)
static bool btif_gatt_is_link_encrypted(const RawAddress& bd_addr) {
  return BTM_IsEncrypted(bd_addr, BT_TRANSPORT_BR_EDR) ||
         BTM_IsEncrypted(bd_addr, BT_TRANSPORT_LE);
@@ -72,9 +71,7 @@ static void btif_gatt_set_encryption_cb(UNUSED_ATTR const RawAddress& bd_addr,
    BTIF_TRACE_WARNING("%s() - Encryption failed (%d)", __func__, result);
  }
}
#endif

#if (BLE_DELAY_REQUEST_ENC == FALSE)
void btif_gatt_check_encrypted_link(RawAddress bd_addr,
                                    tBT_TRANSPORT transport_link) {
  tBTM_LE_PENC_KEYS key;
@@ -89,10 +86,6 @@ void btif_gatt_check_encrypted_link(RawAddress bd_addr,
                        BTM_BLE_SEC_ENCRYPT);
  }
}
#else
void btif_gatt_check_encrypted_link(UNUSED_ATTR RawAddress bd_addr,
                                    UNUSED_ATTR tBT_TRANSPORT transport_link) {}
#endif

void btif_gatt_move_track_adv_data(btgatt_track_adv_info_t* p_dest,
                                   btgatt_track_adv_info_t* p_src) {
+0 −6
Original line number Diff line number Diff line
@@ -571,12 +571,6 @@
 * ATT/GATT Protocol/Profile Settings
 *
 *****************************************************************************/
#ifndef BLE_DELAY_REQUEST_ENC
/* This flag is to work around IPHONE problem, We need to wait for iPhone ready
   before send encryption request to iPhone */
#define BLE_DELAY_REQUEST_ENC FALSE
#endif

#ifndef GATT_MAX_SR_PROFILES
#define GATT_MAX_SR_PROFILES 32 /* max is 32 */
#endif
+0 −17
Original line number Diff line number Diff line
@@ -311,23 +311,6 @@ tGATT_STATUS gatts_db_read_attr_value_by_type(
    }
  }

#if (BLE_DELAY_REQUEST_ENC == TRUE)
  uint8_t flag = 0;
  if (BTM_GetSecurityFlags(tcb.peer_bda, &flag)) {
    if ((tcb.att_lcid == L2CAP_ATT_CID) && (status == GATT_PENDING) &&
        (type.As16Bit() == GATT_UUID_GAP_DEVICE_NAME)) {
      if ((flag & (BTM_SEC_LINK_KEY_KNOWN | BTM_SEC_FLAG_ENCRYPTED)) ==
          BTM_SEC_LINK_KEY_KNOWN) {
        tHCI_ROLE role = HCI_ROLE_UNKNOWN;
        BTM_GetRole(tcb.peer_bda, &role);
        if (role == HCI_ROLE_CENTRAL) {
          btm_ble_set_encryption(tcb.peer_bda, BTM_BLE_SEC_ENCRYPT,
                                 HCI_ROLE_CENTRAL);
        }
      }
    }
  }
#endif
  return status;
}