OSDN Git Service

Use tACL_CB::tACL_CONN::remote_version_info
authorChris Manton <cmanton@google.com>
Wed, 4 Nov 2020 16:27:13 +0000 (08:27 -0800)
committerChris Manton <cmanton@google.com>
Sat, 7 Nov 2020 06:39:01 +0000 (22:39 -0800)
Toward readable code

Bug: 163134718
Tag: #refactor
Test: Paired 2 phones using LE/nRF

Change-Id: I0421cea1528b907e9b479e6b9d6489705cea0b22

stack/acl/acl.h
stack/acl/btm_acl.cc

index c8def9a..1e54481 100644 (file)
@@ -70,8 +70,6 @@ typedef struct {
   uint16_t hci_handle;
   uint16_t link_policy;
   uint16_t link_super_tout;
-  uint16_t lmp_subversion;
-  uint16_t manufacturer;
   uint16_t pkt_types_mask;
   tBLE_ADDR_TYPE active_remote_addr_type;
   tBLE_ADDR_TYPE conn_addr_type;
@@ -102,7 +100,6 @@ typedef struct {
  public:
   bool is_encrypted = false;
   uint8_t link_role;
-  uint8_t lmp_version;
   uint8_t switch_role_failed_attempts;
 
   struct {
index 39a24f9..f0353a9 100644 (file)
@@ -734,10 +734,10 @@ void btm_process_remote_version_complete(uint8_t status, uint16_t handle,
   }
 
   if (status == HCI_SUCCESS) {
-    p_acl_cb->lmp_version = lmp_version;
-    p_acl_cb->manufacturer = manufacturer;
-    p_acl_cb->lmp_subversion = lmp_subversion;
-
+    p_acl_cb->remote_version_info.lmp_version = lmp_version;
+    p_acl_cb->remote_version_info.manufacturer = manufacturer;
+    p_acl_cb->remote_version_info.lmp_subversion = lmp_subversion;
+    p_acl_cb->remote_version_info.valid = true;
     bluetooth::common::LogRemoteVersionInfo(handle, status, lmp_version,
                                             manufacturer, lmp_subversion);
   } else {
@@ -1505,11 +1505,17 @@ bool BTM_ReadRemoteVersion(const RawAddress& addr, uint8_t* lmp_version,
     }
   }
 
-  if (lmp_version) *lmp_version = p_acl->lmp_version;
+  if (!p_acl->remote_version_info.valid) {
+    LOG_WARN("Remote version information is invalid");
+    return false;
+  }
+
+  if (lmp_version) *lmp_version = p_acl->remote_version_info.lmp_version;
 
-  if (manufacturer) *manufacturer = p_acl->manufacturer;
+  if (manufacturer) *manufacturer = p_acl->remote_version_info.manufacturer;
 
-  if (lmp_sub_version) *lmp_sub_version = p_acl->lmp_subversion;
+  if (lmp_sub_version)
+    *lmp_sub_version = p_acl->remote_version_info.lmp_subversion;
 
   return true;
 }