OSDN Git Service

Clean up BTM_SetBleDataLength
authorHansong Zhang <hsz@google.com>
Wed, 13 Jan 2021 00:14:13 +0000 (16:14 -0800)
committerHansong Zhang <hsz@google.com>
Wed, 13 Jan 2021 09:13:30 +0000 (01:13 -0800)
Test: cert/run
Tag: #gd-refactor
Bug: 141555841
Change-Id: I217fd560afbda434e8bab7effc3716cfcd18a7c2

stack/btm/btm_ble.cc

index 07e6b97..4be41ed 100644 (file)
@@ -649,10 +649,25 @@ bool BTM_UseLeLink(const RawAddress& bd_addr) {
 
 tBTM_STATUS BTM_SetBleDataLength(const RawAddress& bd_addr,
                                  uint16_t tx_pdu_length) {
+  if (!controller_get_interface()->supports_ble_packet_extension()) {
+    LOG_INFO("Local controller unable to support le packet extension");
+    return BTM_ILLEGAL_VALUE;
+  }
+
+  if (tx_pdu_length > BTM_BLE_DATA_SIZE_MAX)
+    tx_pdu_length = BTM_BLE_DATA_SIZE_MAX;
+  else if (tx_pdu_length < BTM_BLE_DATA_SIZE_MIN)
+    tx_pdu_length = BTM_BLE_DATA_SIZE_MIN;
+
+  uint16_t tx_time = BTM_BLE_DATA_TX_TIME_MAX_LEGACY;
+
+  if (controller_get_interface()->get_bt_version()->hci_version >=
+      HCI_PROTO_VERSION_5_0)
+    tx_time = BTM_BLE_DATA_TX_TIME_MAX;
+
   if (bluetooth::shim::is_gd_shim_enabled()) {
     return bluetooth::shim::BTM_SetBleDataLength(bd_addr, tx_pdu_length);
   }
-  uint16_t tx_time = BTM_BLE_DATA_TX_TIME_MAX_LEGACY;
 
   if (!BTM_IsAclConnectionUp(bd_addr, BT_TRANSPORT_LE)) {
     LOG_INFO(
@@ -660,11 +675,6 @@ tBTM_STATUS BTM_SetBleDataLength(const RawAddress& bd_addr,
     return BTM_WRONG_MODE;
   }
 
-  if (!controller_get_interface()->supports_ble_packet_extension()) {
-    LOG_INFO("Local controller unable to support le packet extension");
-    return BTM_ILLEGAL_VALUE;
-  }
-
   uint16_t hci_handle = acl_get_hci_handle_for_hcif(bd_addr, BT_TRANSPORT_LE);
 
   if (!acl_peer_supports_ble_packet_extension(hci_handle)) {
@@ -672,14 +682,6 @@ tBTM_STATUS BTM_SetBleDataLength(const RawAddress& bd_addr,
     return BTM_ILLEGAL_VALUE;
   }
 
-  if (tx_pdu_length > BTM_BLE_DATA_SIZE_MAX)
-    tx_pdu_length = BTM_BLE_DATA_SIZE_MAX;
-  else if (tx_pdu_length < BTM_BLE_DATA_SIZE_MIN)
-    tx_pdu_length = BTM_BLE_DATA_SIZE_MIN;
-
-  if (controller_get_interface()->get_bt_version()->hci_version >= HCI_PROTO_VERSION_5_0)
-    tx_time = BTM_BLE_DATA_TX_TIME_MAX;
-
   btsnd_hcic_ble_set_data_length(hci_handle, tx_pdu_length, tx_time);
 
   return BTM_SUCCESS;