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

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

Merge changes I4578a0ee,Ife020abe,I7f8316c2,I6def2d05,I617bdfc3

* changes:
  Add stack/btm/btm_dev header
  Simplify stack/acl/btm_acl::btm_acl_role_changed
  Encapsulate stack/acl/btm_acl::tBTM_ROLE_SWITCH_CMPL
  Clean up stack/acl/acl.h
  Simplify stack/btm/btm_ble::BTM_UseLeLink
parents d6e1036a 1a096f7c
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -72,6 +72,7 @@
#include "osi/include/log.h"
#include "osi/include/log.h"
#include "osi/include/osi.h"
#include "osi/include/osi.h"
#include "osi/include/properties.h"
#include "osi/include/properties.h"
#include "stack/btm/btm_dev.h"
#include "stack/btm/btm_int.h"
#include "stack/btm/btm_int.h"
#include "stack_config.h"
#include "stack_config.h"


+78 −115
Original line number Original line Diff line number Diff line
@@ -16,112 +16,117 @@


#pragma once
#pragma once


#include <stdint.h>
#include <cstdint>
#include "internal_include/bt_target.h"

#include "stack/include/acl_api_types.h"
#include "stack/include/acl_api_types.h"
#include "stack/include/bt_types.h"
#include "stack/include/bt_types.h"
#include "stack/include/hcidefs.h"
#include "types/raw_address.h"
#include "types/raw_address.h"


#define BTM_MAX_SCN_ 31  // PORT_MAX_RFC_PORTS packages/modules/Bluetooth/system/stack/include/rfcdefs.h
#define BTM_MAX_SCN_ 31  // PORT_MAX_RFC_PORTS packages/modules/Bluetooth/system/stack/include/rfcdefs.h


/* Define the ACL Management control structure
/* Structure returned with Role Switch information (in tBTM_CMPL_CB callback
 * function) in response to BTM_SwitchRole call.
 */
 */
typedef struct {
typedef struct {
  uint16_t hci_handle;
  RawAddress remote_bd_addr; /* Remote BD addr involved with the switch */
  uint16_t pkt_types_mask;
  uint8_t hci_status;        /* HCI status returned with the event */
  uint16_t clock_offset;
  uint8_t role;              /* HCI_ROLE_MASTER or HCI_ROLE_SLAVE */
  RawAddress remote_addr;
} tBTM_ROLE_SWITCH_CMPL;
  DEV_CLASS remote_dc;
  BD_NAME remote_name;

  uint16_t manufacturer;
  uint16_t lmp_subversion;
  uint16_t link_super_tout;
  BD_FEATURES
  peer_lmp_feature_pages[HCI_EXT_FEATURES_PAGE_MAX + 1]; /* Peer LMP Extended
                                                            features mask table
                                                            for the device */
  uint8_t num_read_pages;
  uint8_t lmp_version;


typedef struct {
  BD_FEATURES peer_le_features;
  BD_FEATURES peer_lmp_feature_pages[HCI_EXT_FEATURES_PAGE_MAX + 1];
  BD_NAME remote_name;
  DEV_CLASS remote_dc;
  RawAddress active_remote_addr;
  RawAddress conn_addr;
  RawAddress remote_addr;
  bool in_use;
  bool in_use;
  uint8_t link_role;
  bool link_up_issued;
  bool link_up_issued; /* True if busy_level link up has been issued */

#define BTM_ACL_SWKEY_STATE_IDLE 0
#define BTM_ACL_SWKEY_STATE_MODE_CHANGE 1
#define BTM_ACL_SWKEY_STATE_ENCRYPTION_OFF 2
#define BTM_ACL_SWKEY_STATE_SWITCHING 3
#define BTM_ACL_SWKEY_STATE_ENCRYPTION_ON 4
#define BTM_ACL_SWKEY_STATE_IN_PROGRESS 5
  uint8_t switch_role_state;

#define BTM_MAX_SW_ROLE_FAILED_ATTEMPTS 3
  uint8_t switch_role_failed_attempts;

#define BTM_ACL_ENCRYPT_STATE_IDLE 0
#define BTM_ACL_ENCRYPT_STATE_ENCRYPT_OFF 1 /* encryption turning off */
#define BTM_ACL_ENCRYPT_STATE_TEMP_FUNC \
  2 /* temporarily off for change link key or role switch */
#define BTM_ACL_ENCRYPT_STATE_ENCRYPT_ON 3 /* encryption turning on */
  uint8_t encrypt_state;                   /* overall BTM encryption state */

  tBT_TRANSPORT transport;
  tBT_TRANSPORT transport;
  RawAddress conn_addr;   /* local device address used for this connection */
  uint16_t clock_offset;
  uint8_t conn_addr_type; /* local device address type for this connection */
  uint16_t hci_handle;
  RawAddress active_remote_addr;   /* remote address used on this connection */
  uint8_t active_remote_addr_type; /* local device address type for this
                                      connection */
  BD_FEATURES peer_le_features; /* Peer LE Used features mask for the device */

  uint16_t link_policy;
  uint16_t link_policy;

  uint16_t link_super_tout;
  uint16_t lmp_subversion;
  uint16_t manufacturer;
  uint16_t pkt_types_mask;
  uint8_t active_remote_addr_type;
  uint8_t conn_addr_type;
  uint8_t encrypt_state;
  uint8_t link_role;
  uint8_t lmp_version;
  uint8_t num_read_pages;
  uint8_t switch_role_failed_attempts;
  uint8_t switch_role_state;
} tACL_CONN;
} tACL_CONN;


typedef uint8_t tBTM_PM_STATE;
typedef uint8_t tBTM_PM_STATE;
typedef struct {
typedef struct {
  tBTM_PM_PWR_MD req_mode[BTM_MAX_PM_RECORDS + 1]; /* the desired mode and
  bool chg_ind;
                                                      parameters of the
  tBTM_PM_PWR_MD req_mode[BTM_MAX_PM_RECORDS + 1];
                                                      connection*/
  tBTM_PM_PWR_MD set_mode;
  tBTM_PM_PWR_MD
  tBTM_PM_STATE state;
      set_mode; /* the mode and parameters sent down to the host controller. */
  uint16_t interval;
  uint16_t interval; /* the interval from last mode change event. */
  uint16_t max_lat;
#if (BTM_SSR_INCLUDED == TRUE)
  uint16_t min_loc_to;
  uint16_t max_lat;    /* stored SSR maximum latency */
  uint16_t min_rmt_to;
  uint16_t min_rmt_to; /* stored SSR minimum remote timeout */
  uint16_t min_loc_to; /* stored SSR minimum local timeout */
#endif
  tBTM_PM_STATE state; /* contains the current mode of the connection */
  bool chg_ind;        /* a request change indication */
} tBTM_PM_MCB;
} tBTM_PM_MCB;


typedef struct {
/****************************************************
/****************************************************
   **      ACL Management
 **      ACL Management API
 ****************************************************/
 ****************************************************/
typedef struct {
 private:
 private:
  friend bool BTM_FreeSCN(uint8_t scn);
  friend bool BTM_IsBleConnection(uint16_t hci_handle);
  friend bool BTM_IsBleConnection(uint16_t hci_handle);
  friend bool BTM_IsBleConnection(uint16_t hci_handle);
  friend bool BTM_ReadPowerMode(const RawAddress& remote_bda,
                                tBTM_PM_MODE* p_mode);
  friend bool BTM_TryAllocateSCN(uint8_t scn);
  friend bool acl_is_role_switch_allowed();
  friend const RawAddress acl_address_from_handle(uint16_t hci_handle);
  friend const RawAddress acl_address_from_handle(uint16_t hci_handle);
  friend int btm_pm_find_acl_ind(const RawAddress& remote_bda);
  friend int btm_pm_find_acl_ind(const RawAddress& remote_bda);
  friend tACL_CONN* btm_bda_to_acl(const RawAddress& bda,
  friend tACL_CONN* btm_bda_to_acl(const RawAddress& bda,
                                   tBT_TRANSPORT transport);
                                   tBT_TRANSPORT transport);
  friend tBTM_PM_MCB* acl_power_mode_from_handle(uint16_t hci_handle);
  friend tBTM_STATUS BTM_SetPowerMode(uint8_t pm_id,
                                      const RawAddress& remote_bda,
                                      const tBTM_PM_PWR_MD* p_mode);
  friend tBTM_STATUS BTM_SetSsrParams(const RawAddress& remote_bda,
  friend tBTM_STATUS BTM_SetSsrParams(const RawAddress& remote_bda,
                                      uint16_t max_lat, uint16_t min_rmt_to,
                                      uint16_t max_lat, uint16_t min_rmt_to,
                                      uint16_t min_loc_to);
                                      uint16_t min_loc_to);
  friend tBTM_STATUS btm_read_power_mode_state(const RawAddress& remote_bda,
                                               tBTM_PM_STATE* pmState);
  friend uint16_t BTM_GetMaxPacketSize(const RawAddress& addr);
  friend uint16_t BTM_GetNumAclLinks(void);
  friend uint16_t BTM_GetNumAclLinks(void);
  friend uint16_t acl_get_link_supervision_timeout();
  friend uint16_t acl_get_supported_packet_types();
  friend uint16_t btm_get_acl_disc_reason_code(void);
  friend uint8_t BTM_AllocateSCN(void);
  friend uint8_t acl_get_disconnect_reason();
  friend uint8_t btm_handle_to_acl_index(uint16_t hci_handle);
  friend uint8_t btm_handle_to_acl_index(uint16_t hci_handle);
  friend void BTM_SetDefaultLinkSuperTout(uint16_t timeout);
  friend void BTM_acl_after_controller_started();
  friend void BTM_default_block_role_switch();
  friend void BTM_default_unblock_role_switch();
  friend void acl_set_disconnect_reason(uint8_t acl_disc_reason);
  friend void btm_acl_created(const RawAddress& bda, DEV_CLASS dc, BD_NAME bdn,
  friend void btm_acl_created(const RawAddress& bda, DEV_CLASS dc, BD_NAME bdn,
                              uint16_t hci_handle, uint8_t link_role,
                              uint16_t hci_handle, uint8_t link_role,
                              tBT_TRANSPORT transport);
                              tBT_TRANSPORT transport);
  friend void btm_acl_device_down(void);
  friend void btm_acl_device_down(void);
  friend void btm_acl_encrypt_change(uint16_t handle, uint8_t status,
  friend void btm_acl_encrypt_change(uint16_t handle, uint8_t status,
                                     uint8_t encr_enable);
                                     uint8_t encr_enable);
  friend void btm_acl_init(void);
  friend void btm_acl_role_changed(uint8_t hci_status,
                                   const RawAddress& bd_addr, uint8_t new_role);
  friend void btm_acl_update_conn_addr(uint16_t conn_handle,
  friend void btm_acl_update_conn_addr(uint16_t conn_handle,
                                       const RawAddress& address);
                                       const RawAddress& address);
  friend void btm_pm_proc_cmd_status(uint8_t status);
  friend void btm_pm_proc_cmd_status(uint8_t status);
  friend void btm_pm_proc_mode_change(uint8_t hci_status, uint16_t hci_handle,
                                      uint8_t mode, uint16_t interval);
  friend void btm_pm_proc_ssr_evt(uint8_t* p, uint16_t evt_len);
  friend void btm_pm_reset(void);
  friend void btm_pm_reset(void);
  friend void btm_pm_sm_alloc(uint8_t ind);
  friend void btm_process_clk_off_comp_evt(uint16_t hci_handle,
  friend void btm_process_clk_off_comp_evt(uint16_t hci_handle,
                                           uint16_t clock_offset);
                                           uint16_t clock_offset);
  friend void btm_read_automatic_flush_timeout_complete(uint8_t* p);
  friend void btm_read_automatic_flush_timeout_complete(uint8_t* p);
@@ -136,58 +141,16 @@ typedef struct {
  friend void btm_read_rssi_complete(uint8_t* p);
  friend void btm_read_rssi_complete(uint8_t* p);
  friend void btm_read_tx_power_complete(uint8_t* p, bool is_ble);
  friend void btm_read_tx_power_complete(uint8_t* p, bool is_ble);


  friend struct StackAclBtmPm;
  friend struct StackAclBtmAcl;
  friend struct StackAclBtmAcl;
  friend struct StackAclBtmPm;


  tACL_CONN acl_db[MAX_L2CAP_LINKS];
  tACL_CONN acl_db[MAX_L2CAP_LINKS];

  tBTM_PM_MCB pm_mode_db[MAX_L2CAP_LINKS];
  friend uint8_t BTM_AllocateSCN(void);
  tBTM_ROLE_SWITCH_CMPL switch_role_ref_data;
  friend bool BTM_TryAllocateSCN(uint8_t scn);
  uint16_t btm_acl_pkt_types_supported;
  friend bool BTM_FreeSCN(uint8_t scn);
  uint8_t btm_scn[BTM_MAX_SCN_]; /* current SCNs: true if SCN is in use */

  friend bool acl_is_role_switch_allowed();
  friend void BTM_default_block_role_switch();
  friend void BTM_default_unblock_role_switch();
  uint16_t btm_def_link_policy;
  uint16_t btm_def_link_policy;

  friend void btm_acl_init(void);
  friend void BTM_SetDefaultLinkSuperTout(uint16_t timeout);
  friend uint16_t acl_get_link_supervision_timeout();

  uint16_t btm_def_link_super_tout;
  uint16_t btm_def_link_super_tout;

  uint8_t pm_pend_link; /* the index of acl_db, which has a pending PM cmd */

  friend void BTM_acl_after_controller_started();
  friend uint16_t BTM_GetMaxPacketSize(const RawAddress& addr);
  friend uint16_t acl_get_supported_packet_types();
  /* Packet types supported by the local device */
  uint16_t btm_acl_pkt_types_supported;

  friend tBTM_PM_MCB* acl_power_mode_from_handle(uint16_t hci_handle);
  friend uint16_t btm_get_acl_disc_reason_code(void);
  friend uint8_t acl_get_disconnect_reason();
  friend void acl_set_disconnect_reason(uint8_t acl_disc_reason);
  friend void btm_pm_proc_mode_change(uint8_t hci_status, uint16_t hci_handle,
                                      uint8_t mode, uint16_t interval);
  friend void btm_pm_proc_ssr_evt(uint8_t* p, uint16_t evt_len);
  friend void btm_pm_sm_alloc(uint8_t ind);

  uint8_t acl_disc_reason;
  uint8_t acl_disc_reason;

  uint8_t btm_scn[BTM_MAX_SCN_];
 private:
  uint8_t pm_pend_link;
  friend bool BTM_ReadPowerMode(const RawAddress& remote_bda,
} tACL_CB;
                                tBTM_PM_MODE* p_mode);
  friend tBTM_PM_MCB* acl_power_mode_from_handle(uint16_t hci_handle);
  friend tBTM_STATUS BTM_SetPowerMode(uint8_t pm_id,
                                      const RawAddress& remote_bda,
                                      const tBTM_PM_PWR_MD* p_mode);
  friend tBTM_STATUS btm_read_power_mode_state(const RawAddress& remote_bda,
                                               tBTM_PM_STATE* pmState);
  friend void btm_pm_proc_mode_change(uint8_t hci_status, uint16_t hci_handle,
                                      uint8_t mode, uint16_t interval);
  friend void btm_pm_proc_ssr_evt(uint8_t* p, UNUSED_ATTR uint16_t evt_len);

  tBTM_PM_MCB pm_mode_db[MAX_L2CAP_LINKS]; /* per ACL link */
} tACL_CB;  // NEW
+50 −44
Original line number Original line Diff line number Diff line
@@ -42,6 +42,7 @@
#include "main/shim/shim.h"
#include "main/shim/shim.h"
#include "osi/include/log.h"
#include "osi/include/log.h"
#include "stack/acl/acl.h"
#include "stack/acl/acl.h"
#include "stack/btm/btm_dev.h"
#include "stack/btm/btm_int_types.h"
#include "stack/btm/btm_int_types.h"
#include "stack/include/acl_api.h"
#include "stack/include/acl_api.h"
#include "stack/include/btm_api.h"
#include "stack/include/btm_api.h"
@@ -63,6 +64,20 @@ namespace {
StackAclBtmAcl internal_;
StackAclBtmAcl internal_;
}
}


#define BTM_ACL_SWKEY_STATE_IDLE 0
#define BTM_ACL_SWKEY_STATE_MODE_CHANGE 1
#define BTM_ACL_SWKEY_STATE_ENCRYPTION_OFF 2
#define BTM_ACL_SWKEY_STATE_SWITCHING 3
#define BTM_ACL_SWKEY_STATE_ENCRYPTION_ON 4
#define BTM_ACL_SWKEY_STATE_IN_PROGRESS 5

#define BTM_MAX_SW_ROLE_FAILED_ATTEMPTS 3

#define BTM_ACL_ENCRYPT_STATE_IDLE 0
#define BTM_ACL_ENCRYPT_STATE_ENCRYPT_OFF 1
#define BTM_ACL_ENCRYPT_STATE_TEMP_FUNC 2
#define BTM_ACL_ENCRYPT_STATE_ENCRYPT_ON 3

extern tBTM_CB btm_cb;
extern tBTM_CB btm_cb;


tBTM_SEC_DEV_REC* btm_find_dev(const RawAddress& bd_addr);
tBTM_SEC_DEV_REC* btm_find_dev(const RawAddress& bd_addr);
@@ -676,10 +691,11 @@ void btm_acl_encrypt_change(uint16_t handle, uint8_t status,
  else if (p->switch_role_state == BTM_ACL_SWKEY_STATE_ENCRYPTION_ON) {
  else if (p->switch_role_state == BTM_ACL_SWKEY_STATE_ENCRYPTION_ON) {
    p->switch_role_state = BTM_ACL_SWKEY_STATE_IDLE;
    p->switch_role_state = BTM_ACL_SWKEY_STATE_IDLE;
    p->encrypt_state = BTM_ACL_ENCRYPT_STATE_IDLE;
    p->encrypt_state = BTM_ACL_ENCRYPT_STATE_IDLE;
    auto new_role = btm_cb.devcb.switch_role_ref_data.role;
    auto new_role = btm_cb.acl_cb_.switch_role_ref_data.role;
    auto hci_status = btm_cb.devcb.switch_role_ref_data.hci_status;
    auto hci_status = btm_cb.acl_cb_.switch_role_ref_data.hci_status;
    BTA_dm_report_role_change(btm_cb.devcb.switch_role_ref_data.remote_bd_addr,
    BTA_dm_report_role_change(
                              new_role, hci_status);
        btm_cb.acl_cb_.switch_role_ref_data.remote_bd_addr, new_role,
        hci_status);


    BTM_TRACE_DEBUG(
    BTM_TRACE_DEBUG(
        "%s: Role Switch Event: new_role 0x%02x, HCI Status 0x%02x, rs_st:%d",
        "%s: Role Switch Event: new_role 0x%02x, HCI Status 0x%02x, rs_st:%d",
@@ -1424,84 +1440,74 @@ void btm_blacklist_role_change_device(const RawAddress& bd_addr,
 * Returns          void
 * Returns          void
 *
 *
 ******************************************************************************/
 ******************************************************************************/
void btm_acl_role_changed(uint8_t hci_status, const RawAddress* bd_addr,
void btm_acl_role_changed(uint8_t hci_status, const RawAddress& bd_addr,
                          uint8_t new_role) {
                          uint8_t new_role) {
  const RawAddress* p_bda =
  tACL_CONN* p_acl = internal_.btm_bda_to_acl(bd_addr, BT_TRANSPORT_BR_EDR);
      (bd_addr) ? bd_addr : &btm_cb.devcb.switch_role_ref_data.remote_bd_addr;
  if (p_acl == nullptr) {
  tACL_CONN* p = internal_.btm_bda_to_acl(*p_bda, BT_TRANSPORT_BR_EDR);
    BTM_TRACE_WARNING("%s: Unsolicited role change for unknown ACL", __func__);
  tBTM_ROLE_SWITCH_CMPL* p_data = &btm_cb.devcb.switch_role_ref_data;
  tBTM_SEC_DEV_REC* p_dev_rec;

  BTM_TRACE_DEBUG("%s: peer %s hci_status:0x%x new_role:%d", __func__,
                  (p_bda != nullptr) ? bd_addr->ToString().c_str() : "nullptr",
                  hci_status, new_role);
  /* Ignore any stray events */
  if (p == NULL) {
    return;
    return;
  }
  }


  p_data->hci_status = hci_status;
  tBTM_ROLE_SWITCH_CMPL* p_switch_role = &btm_cb.acl_cb_.switch_role_ref_data;
  BTM_TRACE_DEBUG("%s: peer %s hci_status:0x%x new_role:%d", __func__,
                  bd_addr.ToString().c_str(), hci_status, new_role);


  p_switch_role->hci_status = hci_status;
  if (hci_status == HCI_SUCCESS) {
  if (hci_status == HCI_SUCCESS) {
    p_data->role = new_role;
    p_switch_role->role = new_role;
    p_data->remote_bd_addr = *p_bda;
    p_switch_role->remote_bd_addr = bd_addr;


    /* Update cached value */
    /* Update cached value */
    p->link_role = new_role;
    p_acl->link_role = new_role;


    /* Reload LSTO: link supervision timeout is reset in the LM after a role
    /* Reload LSTO: link supervision timeout is reset in the LM after a role
     * switch */
     * switch */
    if (new_role == HCI_ROLE_MASTER) {
    if (new_role == HCI_ROLE_MASTER) {
      BTM_SetLinkSuperTout(p->remote_addr, p->link_super_tout);
      BTM_SetLinkSuperTout(p_acl->remote_addr, p_acl->link_super_tout);
    }
    }
  } else {
  } else {
    new_role = p->link_role;
    new_role = p_acl->link_role;
  }
  }


  /* Check if any SCO req is pending for role change */
  /* Check if any SCO req is pending for role change */
  btm_sco_chk_pend_rolechange(p->hci_handle);
  btm_sco_chk_pend_rolechange(p_acl->hci_handle);


  /* if switching state is switching we need to turn encryption on */
  /* if switching state is switching we need to turn encryption on */
  /* if idle, we did not change encryption */
  /* if idle, we did not change encryption */
  if (p->switch_role_state == BTM_ACL_SWKEY_STATE_SWITCHING) {
  if (p_acl->switch_role_state == BTM_ACL_SWKEY_STATE_SWITCHING) {
    btsnd_hcic_set_conn_encrypt(p->hci_handle, true);
    btsnd_hcic_set_conn_encrypt(p_acl->hci_handle, true);
    p->encrypt_state = BTM_ACL_ENCRYPT_STATE_ENCRYPT_ON;
    p_acl->encrypt_state = BTM_ACL_ENCRYPT_STATE_ENCRYPT_ON;
    p->switch_role_state = BTM_ACL_SWKEY_STATE_ENCRYPTION_ON;
    p_acl->switch_role_state = BTM_ACL_SWKEY_STATE_ENCRYPTION_ON;
    return;
    return;
  }
  }


  /* Set the switch_role_state to IDLE since the reply received from HCI */
  /* Set the switch_role_state to IDLE since the reply received from HCI */
  /* regardless of its result either success or failed. */
  /* regardless of its result either success or failed. */
  if (p->switch_role_state == BTM_ACL_SWKEY_STATE_IN_PROGRESS) {
  if (p_acl->switch_role_state == BTM_ACL_SWKEY_STATE_IN_PROGRESS) {
    p->switch_role_state = BTM_ACL_SWKEY_STATE_IDLE;
    p_acl->switch_role_state = BTM_ACL_SWKEY_STATE_IDLE;
    p->encrypt_state = BTM_ACL_ENCRYPT_STATE_IDLE;
    p_acl->encrypt_state = BTM_ACL_ENCRYPT_STATE_IDLE;
  }
  }


  BTA_dm_report_role_change(*p_bda, new_role, hci_status);
  BTA_dm_report_role_change(bd_addr, new_role, hci_status);

  BTM_TRACE_DEBUG(
  BTM_TRACE_DEBUG(
      "%s: peer %s Role Switch Event: new_role 0x%02x, HCI Status 0x%02x, "
      "%s: peer %s Role Switch Event: new_role 0x%02x, HCI Status 0x%02x, "
      "rs_st:%d",
      "rs_st:%d",
      __func__, (p_bda != nullptr) ? p_bda->ToString().c_str() : "nullptr",
      __func__, bd_addr.ToString().c_str(), p_switch_role->role,
      p_data->role, p_data->hci_status, p->switch_role_state);
      p_switch_role->hci_status, p_acl->switch_role_state);


#if (BTM_DISC_DURING_RS == TRUE)
#if (BTM_DISC_DURING_RS == TRUE)
  /* If a disconnect is pending, issue it now that role switch has completed */
  /* If a disconnect is pending, issue it now that role switch has completed */
  p_dev_rec = btm_find_dev(*p_bda);
  tBTM_SEC_DEV_REC* p_dev_rec = btm_find_dev(bd_addr);
  if (p_dev_rec != NULL) {
  if (p_dev_rec != nullptr) {
    if (p_dev_rec->rs_disc_pending == BTM_SEC_DISC_PENDING) {
    if (p_dev_rec->rs_disc_pending == BTM_SEC_DISC_PENDING) {
      BTM_TRACE_WARNING(
      BTM_TRACE_WARNING("%s peer %s Issuing delayed HCI_Disconnect!!!",
          "%s peer %s Issuing delayed HCI_Disconnect!!!", __func__,
                        __func__, bd_addr.ToString().c_str());
          (p_bda != nullptr) ? p_bda->ToString().c_str() : "nullptr");
      btsnd_hcic_disconnect(p_dev_rec->hci_handle, HCI_ERR_PEER_USER);
      btsnd_hcic_disconnect(p_dev_rec->hci_handle, HCI_ERR_PEER_USER);
    }
    }
    BTM_TRACE_ERROR("%s: peer %s tBTM_SEC_DEV:0x%x rs_disc_pending=%d",
    BTM_TRACE_ERROR("%s: peer %s rs_disc_pending=%d", __func__,
                    __func__,
                    bd_addr.ToString().c_str(), p_dev_rec->rs_disc_pending);
                    (p_bda != nullptr) ? p_bda->ToString().c_str() : "nullptr",
                    PTR_TO_UINT(p_dev_rec), p_dev_rec->rs_disc_pending);
    p_dev_rec->rs_disc_pending = BTM_SEC_RS_NOT_PENDING; /* reset flag */
    p_dev_rec->rs_disc_pending = BTM_SEC_RS_NOT_PENDING; /* reset flag */
  }
  }

#endif
#endif
}
}


+9 −12
Original line number Original line Diff line number Diff line
@@ -44,6 +44,7 @@
#include "main/shim/shim.h"
#include "main/shim/shim.h"
#include "osi/include/log.h"
#include "osi/include/log.h"
#include "osi/include/osi.h"
#include "osi/include/osi.h"
#include "stack/btm/btm_dev.h"
#include "stack/crypto_toolbox/crypto_toolbox.h"
#include "stack/crypto_toolbox/crypto_toolbox.h"
#include "stack/include/acl_api.h"
#include "stack/include/acl_api.h"
#include "stack/include/l2cap_security_interface.h"
#include "stack/include/l2cap_security_interface.h"
@@ -659,21 +660,17 @@ bool BTM_UseLeLink(const RawAddress& bd_addr) {
  if (bluetooth::shim::is_gd_shim_enabled()) {
  if (bluetooth::shim::is_gd_shim_enabled()) {
    return bluetooth::shim::BTM_UseLeLink(bd_addr);
    return bluetooth::shim::BTM_UseLeLink(bd_addr);
  }
  }
  tBT_DEVICE_TYPE dev_type;
  tBLE_ADDR_TYPE addr_type;
  bool use_le = false;


  if (BTM_IsAclConnectionUp(bd_addr, BT_TRANSPORT_BR_EDR)) {
  if (BTM_IsAclConnectionUp(bd_addr, BT_TRANSPORT_BR_EDR)) {
    return use_le;
    return false;
  } else {
  } else if (BTM_IsAclConnectionUp(bd_addr, BT_TRANSPORT_LE)) {
    if (BTM_IsAclConnectionUp(bd_addr, BT_TRANSPORT_LE)) {
    return true;
      use_le = true;
    } else {
      BTM_ReadDevInfo(bd_addr, &dev_type, &addr_type);
      use_le = (dev_type == BT_DEVICE_TYPE_BLE);
    }
  }
  }
  return use_le;

  tBT_DEVICE_TYPE dev_type;
  tBLE_ADDR_TYPE addr_type;
  BTM_ReadDevInfo(bd_addr, &dev_type, &addr_type);
  return (dev_type == BT_DEVICE_TYPE_BLE);
}
}


/*******************************************************************************
/*******************************************************************************
+1 −0
Original line number Original line Diff line number Diff line
@@ -33,6 +33,7 @@
#include "hcimsgs.h"
#include "hcimsgs.h"


#include "btm_ble_int.h"
#include "btm_ble_int.h"
#include "stack/btm/btm_dev.h"
#include "stack/crypto_toolbox/crypto_toolbox.h"
#include "stack/crypto_toolbox/crypto_toolbox.h"
#include "stack/include/acl_api.h"
#include "stack/include/acl_api.h"


Loading