OSDN Git Service

Re-align read remote version information on legacy
authorChris Manton <cmanton@google.com>
Sat, 3 Oct 2020 17:01:53 +0000 (10:01 -0700)
committerChris Manton <cmanton@google.com>
Sat, 3 Oct 2020 20:42:35 +0000 (13:42 -0700)
Bug: 166280067
Tag: #refactor
Test: act.py -tc BleCocTest
Test: ble paired 2 phones
Test: classic paired Bose SoundLink

Change-Id: I7be1ecba73234431194ad9702ec3ea06b09c60bc

stack/acl/btm_acl.cc

index d1cd589..fb6c714 100644 (file)
@@ -810,34 +810,46 @@ void BTM_default_block_role_switch() {
  * Returns          void
  *
  ******************************************************************************/
-static void btm_process_remote_version_complete(uint8_t status, uint16_t handle,
-                                                uint8_t lmp_version,
-                                                uint16_t manufacturer,
-                                                uint16_t lmp_subversion) {
+static void maybe_chain_more_commands_after_read_remote_version_complete(
+    uint8_t status, uint16_t handle) {
   tACL_CONN* p_acl_cb = internal_.acl_get_connection_from_handle(handle);
   if (p_acl_cb == nullptr) {
     LOG_WARN("Received remote version complete for unknown device");
     return;
   }
 
+  switch (p_acl_cb->transport) {
+    case BT_TRANSPORT_LE:
+      l2cble_notify_le_connection(p_acl_cb->remote_addr);
+      l2cble_use_preferred_conn_params(p_acl_cb->remote_addr);
+      break;
+    case BT_TRANSPORT_BR_EDR:
+      if (status == HCI_SUCCESS) {
+        internal_.btm_read_remote_features(p_acl_cb->hci_handle);
+      }
+  }
+}
+
+void btm_process_remote_version_complete(uint8_t status, uint16_t handle,
+                                         uint8_t lmp_version,
+                                         uint16_t manufacturer,
+                                         uint16_t lmp_subversion) {
+  tACL_CONN* p_acl_cb = internal_.acl_get_connection_from_handle(handle);
+  if (p_acl_cb == nullptr) {
+    LOG_WARN("Received remote version complete for unknown acl");
+    return;
+  }
+
   if (status == HCI_SUCCESS) {
     p_acl_cb->lmp_version = lmp_version;
     p_acl_cb->manufacturer = manufacturer;
     p_acl_cb->lmp_subversion = lmp_subversion;
 
-    if (p_acl_cb->transport == BT_TRANSPORT_BR_EDR) {
-      internal_.btm_read_remote_features(p_acl_cb->hci_handle);
-    }
     bluetooth::common::LogRemoteVersionInfo(handle, status, lmp_version,
                                             manufacturer, lmp_subversion);
   } else {
     bluetooth::common::LogRemoteVersionInfo(handle, status, 0, 0, 0);
   }
-
-  if (p_acl_cb->transport == BT_TRANSPORT_LE) {
-    l2cble_notify_le_connection(p_acl_cb->remote_addr);
-    l2cble_use_preferred_conn_params(p_acl_cb->remote_addr);
-  }
 }
 
 void btm_read_remote_version_complete(uint8_t* p) {
@@ -855,6 +867,7 @@ void btm_read_remote_version_complete(uint8_t* p) {
 
   btm_process_remote_version_complete(status, handle, lmp_version, manufacturer,
                                       lmp_subversion);
+  maybe_chain_more_commands_after_read_remote_version_complete(status, handle);
 }
 
 /*******************************************************************************