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

Commit d25bb177 authored by Chris Manton's avatar Chris Manton
Browse files

Actively check tACL_CONN:: valid prior to feature use

Towards synchronized code

Bug: 163134718
Tag: #refactor
Test: gd/cert/run --host

Change-Id: Ida5002acb90d3cf3290e332191b23dabcc882b58
parent d7e46bae
Loading
Loading
Loading
Loading
+57 −2
Original line number Diff line number Diff line
@@ -778,6 +778,14 @@ void btm_read_remote_version_complete(tHCI_STATUS status, uint16_t handle,
 ******************************************************************************/
void btm_process_remote_ext_features(tACL_CONN* p_acl_cb,
                                     uint8_t num_read_pages) {
  CHECK(p_acl_cb != nullptr);
  if (!p_acl_cb->peer_lmp_feature_valid[0] ||
      !p_acl_cb->peer_lmp_feature_valid[0]) {
    LOG_WARN(
        "Checking remote features but remote feature read is "
        "incomplete");
  }

  bool ssp_supported =
      HCI_SSP_HOST_SUPPORTED(p_acl_cb->peer_lmp_feature_pages[1]);
  bool secure_connections_supported =
@@ -1225,6 +1233,11 @@ bool BTM_IsPhy2mSupported(const RawAddress& remote_bda, tBT_TRANSPORT transport)
    return false;
  }

  if (!p->peer_le_features_valid) {
    LOG_WARN(
        "Checking remote features but remote feature read is "
        "incomplete");
  }
  return HCI_LE_2M_PHY_SUPPORTED(p->peer_le_features);
}

@@ -2250,6 +2263,12 @@ void btm_acl_notif_conn_collision(const RawAddress& bda) {
 *
 ******************************************************************************/
void btm_acl_chk_peer_pkt_type_support(tACL_CONN* p, uint16_t* p_pkt_type) {
  if (!p->peer_lmp_feature_valid[0]) {
    LOG_ERROR("Remote feature reads are incomplete");
    *p_pkt_type = 0;
    return;
  }

  /* 3 and 5 slot packets? */
  if (!HCI_3_SLOT_PACKETS_SUPPORTED(p->peer_lmp_feature_pages[0]))
    *p_pkt_type &= ~(HCI_PKT_TYPES_MASK_DH3 + HCI_PKT_TYPES_MASK_DM3);
@@ -2341,16 +2360,26 @@ bool acl_peer_supports_ble_connection_parameters_request(
    LOG_WARN("Unable to find active acl");
    return false;
  }
  if (!p_acl->peer_le_features_valid) {
    LOG_WARN(
        "Checking remote features but remote feature read is "
        "incomplete");
  }
  return HCI_LE_CONN_PARAM_REQ_SUPPORTED(p_acl->peer_le_features);
}

bool acl_peer_supports_sniff_subrating(const RawAddress& remote_bda) {
  tACL_CONN* p_acl = internal_.btm_bda_to_acl(remote_bda, BT_TRANSPORT_LE);
  tACL_CONN* p_acl = internal_.btm_bda_to_acl(remote_bda, BT_TRANSPORT_BR_EDR);
  if (p_acl == nullptr) {
    LOG_WARN("Unable to find active acl");
    return false;
  }
  return HCI_SNIFF_SUB_RATE_SUPPORTED(p_acl->peer_le_features);
  if (!p_acl->peer_lmp_feature_valid[0]) {
    LOG_WARN(
        "Checking remote features but remote feature read is "
        "incomplete");
  }
  return HCI_SNIFF_SUB_RATE_SUPPORTED(p_acl->peer_lmp_feature_pages[0]);
}

/*******************************************************************************
@@ -2490,6 +2519,11 @@ bool sco_peer_supports_esco_2m_phy(uint16_t hci_handle) {
  if (p_acl == nullptr) {
    return false;
  }
  if (!p_acl->peer_lmp_feature_valid[0]) {
    LOG_WARN(
        "Checking remote features but remote feature read is "
        "incomplete");
  }
  return HCI_EDR_ESCO_2MPS_SUPPORTED(p_acl->peer_lmp_feature_pages[0]);
}

@@ -2498,6 +2532,11 @@ bool sco_peer_supports_esco_3m_phy(uint16_t hci_handle) {
  if (p_acl == nullptr) {
    return false;
  }
  if (!p_acl->peer_lmp_feature_valid[0]) {
    LOG_WARN(
        "Checking remote features but remote feature read is "
        "incomplete");
  }
  return HCI_EDR_ESCO_3MPS_SUPPORTED(p_acl->peer_lmp_feature_pages[0]);
}

@@ -2593,6 +2632,11 @@ bool acl_peer_supports_ble_packet_extension(uint16_t hci_handle) {
  if (p_acl == nullptr) {
    return false;
  }
  if (!p_acl->peer_le_features_valid) {
    LOG_WARN(
        "Checking remote features but remote feature read is "
        "incomplete");
  }
  return HCI_LE_DATA_LEN_EXT_SUPPORTED(p_acl->peer_le_features);
}

@@ -2601,6 +2645,11 @@ bool acl_peer_supports_ble_2m_phy(uint16_t hci_handle) {
  if (p_acl == nullptr) {
    return false;
  }
  if (!p_acl->peer_le_features_valid) {
    LOG_WARN(
        "Checking remote features but remote feature read is "
        "incomplete");
  }
  return HCI_LE_2M_PHY_SUPPORTED(p_acl->peer_le_features);
}

@@ -2609,6 +2658,12 @@ bool acl_peer_supports_ble_coded_phy(uint16_t hci_handle) {
  if (p_acl == nullptr) {
    return false;
  }
  if (!p_acl->peer_le_features_valid) {
    LOG_WARN(
        "Checking remote features but remote feature read is "
        "incomplete");
    return false;
  }
  return HCI_LE_CODED_PHY_SUPPORTED(p_acl->peer_le_features);
}