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

Commit fee1bfaa authored by Chris Manton's avatar Chris Manton Committed by Automerger Merge Worker
Browse files

Provide more suitable API to set packet types am: 6110cf25

Original change: https://android-review.googlesource.com/c/platform/system/bt/+/1393943

Change-Id: Iaa6bac547b563882aa46c37cfa04f1caa65471b8
parents 66e71a81 6110cf25
Loading
Loading
Loading
Loading
+15 −1
Original line number Diff line number Diff line
@@ -55,7 +55,6 @@ tBTM_SEC_DEV_REC* btm_find_dev(const RawAddress& bd_addr);
tBTM_SEC_DEV_REC* btm_find_dev_by_handle(uint16_t handle);
tBTM_SEC_DEV_REC* btm_find_or_alloc_dev(const RawAddress& bd_addr);
tBTM_STATUS btm_sec_execute_procedure(tBTM_SEC_DEV_REC* p_dev_rec);
tBTM_STATUS btm_set_packet_types(tACL_CONN* p, uint16_t pkt_types);
void btm_ble_refresh_local_resolvable_private_addr(
    const RawAddress& pseudo_addr, const RawAddress& local_rpa);
void btm_establish_continue(tACL_CONN* p_acl_cb);
@@ -75,6 +74,7 @@ static void btm_read_rssi_timeout(void* data);
static void btm_read_tx_power_timeout(void* data);
static void btm_process_remote_ext_features(tACL_CONN* p_acl_cb,
                                            uint8_t num_read_pages);
static tBTM_STATUS btm_set_packet_types(tACL_CONN* p, uint16_t pkt_types);

void BTIF_dm_report_inquiry_status_change(uint8_t busy_level_flags);
void BTA_dm_acl_up(const RawAddress bd_addr, tBT_TRANSPORT transport,
@@ -1559,6 +1559,20 @@ tBTM_STATUS btm_set_packet_types(tACL_CONN* p, uint16_t pkt_types) {
  return (BTM_CMD_STARTED);
}

void btm_set_packet_types_from_address(const RawAddress& bd_addr,
                                       tBT_TRANSPORT transport,
                                       uint16_t pkt_types) {
  tACL_CONN* p_acl_cb = btm_bda_to_acl(bd_addr, transport);
  if (p_acl_cb == nullptr) {
    BTM_TRACE_ERROR("%s Unable to find acl for address", __func__);
    return;
  }
  tBTM_STATUS status = btm_set_packet_types(p_acl_cb, pkt_types);
  if (status != BTM_CMD_STARTED) {
    BTM_TRACE_ERROR("%s unable to set packet types from address", __func__);
  }
}

/*******************************************************************************
 *
 * Function         BTM_GetMaxPacketSize
+5 −8
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@
#include "l2c_api.h"
#include "l2cdefs.h"
#include "osi/include/osi.h"
#include "stack/include/acl_api.h"

/* callback function declarations */
void avdt_l2c_connect_ind_cback(const RawAddress& bd_addr, uint16_t lcid,
@@ -195,14 +196,12 @@ void avdt_l2c_connect_ind_cback(const RawAddress& bd_addr, uint16_t lcid,

      if (interop_match_addr(INTEROP_2MBPS_LINK_ONLY, &bd_addr)) {
        // Disable 3DH packets for AVDT ACL to improve sensitivity on HS
        tACL_CONN* p_acl_cb = btm_bda_to_acl(bd_addr, BT_TRANSPORT_BR_EDR);
        btm_set_packet_types(
            p_acl_cb,
        btm_set_packet_types_from_address(
            bd_addr, BT_TRANSPORT_BR_EDR,
            (btm_cb.acl_cb_.btm_acl_pkt_types_supported |
             HCI_PKT_TYPES_MASK_NO_3_DH1 | HCI_PKT_TYPES_MASK_NO_3_DH3 |
             HCI_PKT_TYPES_MASK_NO_3_DH5));
      }

      /* Check the security */
      rc = btm_sec_mx_access_request(bd_addr, AVDT_PSM, false,
                                     BTM_SEC_PROTO_AVDT, AVDT_CHAN_SIG,
@@ -314,10 +313,8 @@ void avdt_l2c_connect_cfm_cback(uint16_t lcid, uint16_t result) {
            if (interop_match_addr(INTEROP_2MBPS_LINK_ONLY,
                                   (const RawAddress*)&p_ccb->peer_addr)) {
              // Disable 3DH packets for AVDT ACL to improve sensitivity on HS
              tACL_CONN* p_acl_cb =
                  btm_bda_to_acl(p_ccb->peer_addr, BT_TRANSPORT_BR_EDR);
              btm_set_packet_types(
                  p_acl_cb,
              btm_set_packet_types_from_address(
                  p_ccb->peer_addr, BT_TRANSPORT_BR_EDR,
                  (btm_cb.acl_cb_.btm_acl_pkt_types_supported |
                   HCI_PKT_TYPES_MASK_NO_3_DH1 | HCI_PKT_TYPES_MASK_NO_3_DH3 |
                   HCI_PKT_TYPES_MASK_NO_3_DH5));
+0 −1
Original line number Diff line number Diff line
@@ -102,7 +102,6 @@ extern void btm_read_tx_power_complete(uint8_t* p, bool is_ble);

extern void btm_read_link_quality_complete(uint8_t* p);

extern tBTM_STATUS btm_set_packet_types(tACL_CONN* p, uint16_t pkt_types);
extern void btm_process_clk_off_comp_evt(uint16_t hci_handle,
                                         uint16_t clock_offset);
extern void btm_blacklist_role_change_device(const RawAddress& bd_addr,
+4 −7
Original line number Diff line number Diff line
@@ -3810,7 +3810,6 @@ void btm_sec_connected(const RawAddress& bda, uint16_t handle, uint8_t status,
  uint8_t res;
  bool is_pairing_device = false;
  bool addr_matched;
  tACL_CONN* p_acl_cb;
  uint8_t bit_shift = 0;

  btm_acl_resubmit_page();
@@ -4057,21 +4056,19 @@ void btm_sec_connected(const RawAddress& bda, uint16_t handle, uint8_t status,
   */
  /* notify btm_acl that link is up, so starting of rmt name request will not */
  /* set paging flag up */
  p_acl_cb = btm_bda_to_acl(bda, BT_TRANSPORT_BR_EDR);
  if (p_acl_cb) {
/* whatever is in btm_establish_continue() without reporting the BTM_BL_CONN_EVT
 * event */
#if (BTM_BYPASS_EXTRA_ACL_SETUP == FALSE)
    /* For now there are a some devices that do not like sending */
    /* commands events and data at the same time. */
    /* Set the packet types to the default allowed by the device */
    btm_set_packet_types(p_acl_cb, btm_cb.acl_cb_.btm_acl_pkt_types_supported);
    btm_set_packet_types_from_address(
        bda, BT_TRANSPORT_BR_EDR, btm_cb.acl_cb_.btm_acl_pkt_types_supported);

    if (btm_cb.acl_cb_.btm_def_link_policy)
      BTM_SetLinkPolicy(p_acl_cb->remote_addr,
                        &btm_cb.acl_cb_.btm_def_link_policy);
      BTM_SetLinkPolicy(bda, &btm_cb.acl_cb_.btm_def_link_policy);
#endif
  }

  btm_acl_created(bda, p_dev_rec->dev_class, p_dev_rec->sec_bd_name, handle,
                  HCI_ROLE_SLAVE, BT_TRANSPORT_BR_EDR);

+4 −0
Original line number Diff line number Diff line
@@ -241,3 +241,7 @@ uint16_t BTM_GetNumAclLinks(void);
 ******************************************************************************/
void btm_acl_role_changed(uint8_t hci_status, const RawAddress* bd_addr,
                          uint8_t new_role);

void btm_set_packet_types_from_address(const RawAddress& bda,
                                       tBT_TRANSPORT transport,
                                       uint16_t pkt_types);