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

Commit 4206e410 authored by Zach Johnson's avatar Zach Johnson
Browse files

call bta_sys_notify_collision directly

it's always registered, so go ahead and remove the bool
return type from btm_acl_notif_conn_collision

Bug: 159815595
Tag: #refactor
Test: compile & verify basic functions working
Change-Id: Ibbb3c10dc6ef87d01156369b880ec7eafa79fb5d
parent df0d30a1
Loading
Loading
Loading
Loading
+0 −7
Original line number Diff line number Diff line
@@ -2837,13 +2837,6 @@ void BTA_dm_acl_down(const RawAddress bd_addr, tBT_TRANSPORT transport) {

/** Callback from btm when acl connection goes up or down */
static void bta_dm_bl_change_cback(tBTM_BL_EVENT_DATA* p_data) {
  switch (p_data->event) {
    case BTM_BL_COLLISION_EVT:
      /* Collision report from Stack: Notify profiles */
      do_in_main_thread(
          FROM_HERE, base::Bind(bta_sys_notify_collision, *p_data->conn.p_bda));
      return;
  }
}

/*******************************************************************************
+3 −17
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@
#define LOG_TAG "btm_acl"

#include <cstdint>
#include "bta/sys/bta_sys.h"
#include "common/metrics.h"
#include "device/include/controller.h"
#include "device/include/interop.h"
@@ -2330,25 +2331,10 @@ void btm_acl_paging(BT_HDR* p, const RawAddress& bda) {
 *
 * Description      Send connection collision event to upper layer if registered
 *
 * Returns          true if sent out to upper layer,
 *                  false if no one needs the notification.
 *
 ******************************************************************************/
bool btm_acl_notif_conn_collision(const RawAddress& bda) {
  /* Report possible collision to the upper layer. */
  if (btm_cb.acl_cb_.p_bl_changed_cb) {
    VLOG(1) << __func__ << " RemBdAddr: " << bda;

    tBTM_BL_EVENT_DATA evt_data;
    evt_data.event = BTM_BL_COLLISION_EVT;
    evt_data.conn.p_bda = &bda;
    evt_data.conn.transport = BT_TRANSPORT_BR_EDR;
    evt_data.conn.handle = BTM_INVALID_HCI_HANDLE;
    (*btm_cb.acl_cb_.p_bl_changed_cb)(&evt_data);
    return true;
  } else {
    return false;
  }
void btm_acl_notif_conn_collision(const RawAddress& bda) {
  do_in_main_thread(FROM_HERE, base::Bind(bta_sys_notify_collision, bda));
}

/*******************************************************************************
+1 −1
Original line number Diff line number Diff line
@@ -120,7 +120,7 @@ extern void btm_establish_continue(tACL_CONN* p_acl_cb);

extern tACL_CONN* btm_bda_to_acl(const RawAddress& bda,
                                 tBT_TRANSPORT transport);
extern bool btm_acl_notif_conn_collision(const RawAddress& bda);
extern void btm_acl_notif_conn_collision(const RawAddress& bda);
extern void btm_acl_update_conn_addr(uint16_t conn_handle,
                                     const RawAddress& address);

+0 −16
Original line number Diff line number Diff line
@@ -128,34 +128,18 @@ typedef struct {
  int8_t tx_power;
} tBTM_INQ_TXPWR_RESULT;

enum {
  BTM_BL_COLLISION_EVT
};
typedef uint8_t tBTM_BL_EVENT;

/* Device features mask definitions */
#define BTM_FEATURE_BYTES_PER_PAGE HCI_FEATURE_BYTES_PER_PAGE
#define BTM_EXT_FEATURES_PAGE_MAX HCI_EXT_FEATURES_PAGE_MAX

/* the data type associated with BTM_BL_CONN_EVT */
typedef struct {
  tBTM_BL_EVENT event;     /* The event reported. */
  const RawAddress* p_bda; /* The address of the newly connected device */
  DEV_CLASS_PTR p_dc;      /* The device class */
  BD_NAME_PTR p_bdn;       /* The device name */
  uint8_t* p_features;     /* pointer to the remote device's features page[0]
                              (supported features page) */
  uint16_t handle;         /* connection handle */
  tBT_TRANSPORT transport; /* link is LE or not */
} tBTM_BL_CONN_DATA;

#define BTM_INQUIRY_STARTED 1
#define BTM_INQUIRY_CANCELLED 2
#define BTM_INQUIRY_COMPLETE 3

typedef union {
  tBTM_BL_EVENT event;        /* The event reported. */
  tBTM_BL_CONN_DATA conn;     /* The data associated with BTM_BL_CONN_EVT */
} tBTM_BL_EVENT_DATA;

/* Callback function for notifications when the BTM busy level
+3 −3
Original line number Diff line number Diff line
@@ -165,9 +165,9 @@ static void l2c_csm_closed(tL2C_CCB* p_ccb, uint16_t event, void* p_data) {
      break;

    case L2CEVT_LP_CONNECT_CFM_NEG: /* Link failed          */
      /* Disconnect unless ACL collision and upper layer wants to handle it */
      if (p_ci->status != HCI_ERR_CONNECTION_EXISTS ||
          !btm_acl_notif_conn_collision(p_ccb->p_lcb->remote_bd_addr)) {
      if (p_ci->status == HCI_ERR_CONNECTION_EXISTS) {
        btm_acl_notif_conn_collision(p_ccb->p_lcb->remote_bd_addr);
      } else {
        L2CAP_TRACE_API(
            "L2CAP - Calling ConnectCfm_Cb(), CID: 0x%04x  Status: %d",
            p_ccb->local_cid, p_ci->status);