OSDN Git Service

Remove BLE_DELAY_REQUEST_ENC
authorZach Johnson <zachoverflow@google.com>
Fri, 21 Aug 2020 16:51:09 +0000 (09:51 -0700)
committerChris Manton <cmanton@google.com>
Tue, 27 Apr 2021 16:23:44 +0000 (09:23 -0700)
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

btif/src/btif_gatt_util.cc
internal_include/bt_target.h
stack/gatt/gatt_db.cc

index 07c982a..e6bbf38 100644 (file)
@@ -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) {
index b0c06f1..ee365a5 100644 (file)
  * 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
index 477e261..f7d18e4 100644 (file)
@@ -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;
 }