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

Commit d0ab2373 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge changes I283667e2,Ibc685b5d,I54537140,Ic11c5809

* changes:
  Move create_classic_conn from l2c to acl
  Add API stack/acl/btm_acl::acl_create_classic_connection
  Simplify stack/l2cap/l2c_utils::l2cu_create_conn_after_switch
  Move stack/l2cap/l2c_link::btm_acl_connected
parents b94233ed ed8e56a9
Loading
Loading
Loading
Loading
+45 −0
Original line number Diff line number Diff line
@@ -2826,3 +2826,48 @@ bool acl_set_peer_le_features_from_handle(uint16_t hci_handle,
  STREAM_TO_ARRAY(p_acl->peer_le_features, p, BD_FEATURES_LEN);
  return true;
}

void btm_acl_connected(const RawAddress& bda, uint16_t handle, uint8_t status,
                       uint8_t enc_mode) {
  btm_sec_connected(bda, handle, status, enc_mode);
  btm_acl_set_paging(false);
  l2c_link_hci_conn_comp(status, handle, bda);
}

constexpr uint16_t kDefaultPacketTypes =
    HCI_PKT_TYPES_MASK_DM1 | HCI_PKT_TYPES_MASK_DH1 | HCI_PKT_TYPES_MASK_DM3 |
    HCI_PKT_TYPES_MASK_DH3 | HCI_PKT_TYPES_MASK_DM5 | HCI_PKT_TYPES_MASK_DH5;

void acl_create_classic_connection(const RawAddress& bd_addr,
                                   bool there_are_high_priority_channels,
                                   bool is_bonding) {
  const bool controller_supports_role_switch =
      controller_get_interface()->supports_role_switch();
  const bool acl_allows_role_switch = acl_is_role_switch_allowed();

  /* FW team says that we can participant in 4 piconets
   * typically 3 piconet + 1 for scanning.
   * We can enhance the code to count the number of piconets later. */
  uint8_t allow_role_switch = HCI_CR_CONN_NOT_ALLOW_SWITCH;
  if (((acl_allows_role_switch && (BTM_GetNumAclLinks() < 3)) ||
       (is_bonding && !there_are_high_priority_channels &&
        controller_supports_role_switch)))
    allow_role_switch = HCI_CR_CONN_ALLOW_SWITCH;

  /* Check with the BT manager if details about remote device are known */
  uint8_t page_scan_rep_mode{HCI_PAGE_SCAN_REP_MODE_R1};
  uint8_t page_scan_mode{HCI_MANDATARY_PAGE_SCAN_MODE};
  uint16_t clock_offset = BTM_GetClockOffset(bd_addr);

  tBTM_INQ_INFO* p_inq_info = BTM_InqDbRead(bd_addr);
  if (p_inq_info != nullptr &&
      (p_inq_info->results.inq_result_type & BTM_INQ_RESULT_BR)) {
    page_scan_rep_mode = p_inq_info->results.page_scan_rep_mode;
    page_scan_mode = p_inq_info->results.page_scan_mode;
    clock_offset = p_inq_info->results.clock_offset;
  }

  btsnd_hcic_create_conn(bd_addr, kDefaultPacketTypes, page_scan_rep_mode,
                         page_scan_mode, clock_offset, allow_role_switch);
  btm_acl_set_paging(true);
}
+4 −0
Original line number Diff line number Diff line
@@ -342,3 +342,7 @@ void btm_acl_update_conn_addr(uint16_t conn_handle, const RawAddress& address);
 *
 ******************************************************************************/
bool BTM_ReadPowerMode(const RawAddress& remote_bda, tBTM_PM_MODE* p_mode);

void acl_create_classic_connection(const RawAddress& bd_addr,
                                   bool there_are_high_priority_channels,
                                   bool is_bonding);
+2 −0
Original line number Diff line number Diff line
@@ -21,6 +21,8 @@

// This header contains functions for HCIF-Acl Management to invoke
//
void btm_acl_connected(const RawAddress& bda, uint16_t handle, uint8_t status,
                       uint8_t enc_mode);
void btm_acl_encrypt_change(uint16_t handle, uint8_t status,
                            uint8_t encr_enable);
void btm_blacklist_role_change_device(const RawAddress& bd_addr,
+0 −4
Original line number Diff line number Diff line
@@ -28,10 +28,6 @@ extern void l2c_link_process_num_completed_pkts(uint8_t* p, uint8_t evt_len);
extern void l2c_link_hci_conn_comp(uint8_t status, uint16_t handle,
                                   const RawAddress& p_bda);

// TODO move
extern void btm_acl_connected(const RawAddress& bda, uint16_t handle,
                              uint8_t status, uint8_t enc_mode);

extern bool l2c_link_hci_disc_comp(uint16_t handle, uint8_t reason);

extern void l2c_link_role_changed(const RawAddress* bd_addr, uint8_t new_role,
+0 −7
Original line number Diff line number Diff line
@@ -123,13 +123,6 @@ void l2c_link_hci_conn_req(const RawAddress& bd_addr) {
  }
}

void btm_acl_connected(const RawAddress& bda, uint16_t handle, uint8_t status,
                       uint8_t enc_mode) {
  btm_sec_connected(bda, handle, status, enc_mode);
  btm_acl_set_paging(false);
  l2c_link_hci_conn_comp(status, handle, bda);
}

void l2c_link_hci_conn_comp(uint8_t status, uint16_t handle,
                            const RawAddress& p_bda) {
  tL2C_CONN_INFO ci;
Loading