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

Commit 1577dfd3 authored by Hansong Zhang's avatar Hansong Zhang
Browse files

Dev rec: Optimize HCI role switch supported logic

We don't need to copy the entire supported feature pages.

Bug: 159815595
Tag: #refactor
Test: compile & verify basic functions working
Change-Id: Id64acda8d46bc229785eff46a29e15c6b7395f4e
parent 4c08b1a0
Loading
Loading
Loading
Loading
+2 −12
Original line number Diff line number Diff line
@@ -833,7 +833,6 @@ void btm_process_remote_ext_features(tACL_CONN* p_acl_cb,
                                     uint8_t num_read_pages) {
  uint16_t handle = p_acl_cb->hci_handle;
  tBTM_SEC_DEV_REC* p_dev_rec = btm_find_dev_by_handle(handle);
  uint8_t page_idx;

  if (p_dev_rec == nullptr) {
    return;
@@ -841,17 +840,8 @@ void btm_process_remote_ext_features(tACL_CONN* p_acl_cb,

  p_dev_rec->num_read_pages = num_read_pages;

  /* Move the pages to placeholder */
  for (page_idx = 0; page_idx < num_read_pages; page_idx++) {
    if (page_idx > HCI_EXT_FEATURES_PAGE_MAX) {
      LOG_WARN("Received more extended page features than allowed page=%d",
               page_idx);
      break;
    }
    memcpy(p_dev_rec->feature_pages[page_idx],
           p_acl_cb->peer_lmp_feature_pages[page_idx],
           HCI_FEATURE_BYTES_PER_PAGE);
  }
  p_dev_rec->remote_supports_hci_role_switch =
      HCI_SWITCH_SUPPORTED(p_acl_cb->peer_lmp_feature_pages[0]);

  if (!(p_dev_rec->sec_flags & BTM_SEC_NAME_KNOWN) ||
      p_dev_rec->is_originator) {
+1 −2
Original line number Diff line number Diff line
@@ -100,7 +100,6 @@ bool BTM_SecAddDevice(const RawAddress& bd_addr, DEV_CLASS dev_class,
  }

  p_dev_rec->num_read_pages = 0;
  memset(p_dev_rec->feature_pages, 0, sizeof(p_dev_rec->feature_pages));

  if (p_link_key) {
    VLOG(2) << __func__ << ": BDA: " << bd_addr;
@@ -274,7 +273,7 @@ bool btm_dev_support_role_switch(const RawAddress& bd_addr) {
    return false;
  }

  if (HCI_SWITCH_SUPPORTED(p_dev_rec->feature_pages[0])) {
  if (p_dev_rec->remote_supports_hci_role_switch) {
    BTM_TRACE_DEBUG("%s Peer controller supports role switch", __func__);
    return true;
  }
+1 −2
Original line number Diff line number Diff line
@@ -259,8 +259,6 @@ typedef struct {

  tBTM_BD_NAME sec_bd_name; /* User friendly name of the device. (may be
                               truncated to save space in dev_rec table) */
  BD_FEATURES feature_pages[HCI_EXT_FEATURES_PAGE_MAX +
                            1]; /* Features supported by the device */
  uint8_t num_read_pages;

  uint8_t sec_state;          /* Operating state                    */
@@ -323,6 +321,7 @@ typedef struct {
  /* "Secure Connections Only" mode and it receives */
  /* HCI_IO_CAPABILITY_REQUEST_EVT from the peer before */
  /* it knows peer's support for Secure Connections */
  bool remote_supports_hci_role_switch = false;
  bool remote_feature_received = false;

  uint16_t ble_hci_handle; /* use in DUMO connection */