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

Commit aa6daae7 authored by Zach Johnson's avatar Zach Johnson Committed by Automerger Merge Worker
Browse files

Telescope busy level update events am: 903b7be1

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

Change-Id: Iff7fa40559d13559382f7c0207d4f0a14c7cc66e
parents 6093a09a 903b7be1
Loading
Loading
Loading
Loading
+0 −15
Original line number Diff line number Diff line
@@ -2652,15 +2652,6 @@ static void bta_dm_local_name_cback(UNUSED_ATTR void* p_name) {
    bta_dm_cb.p_sec_cback(BTA_DM_ENABLE_EVT, &sec_event);
}

static void send_busy_level_update(uint8_t busy_level_flags) {
  if (!bta_dm_cb.p_sec_cback) return;

  tBTA_DM_SEC conn;
  memset(&conn, 0, sizeof(tBTA_DM_SEC));
  conn.busy_level.level_flags = busy_level_flags;
  bta_dm_cb.p_sec_cback(BTA_DM_BUSY_LEVEL_EVT, &conn);
}

static void handle_role_change(const RawAddress& bd_addr, uint8_t new_role,
                               uint8_t hci_status) {
  tBTA_DM_SEC conn;
@@ -2854,12 +2845,6 @@ static void bta_dm_bl_change_cback(tBTM_BL_EVENT_DATA* p_data) {
                                p_data->discn.transport, p_data->discn.handle));
      break;

    case BTM_BL_UPDATE_EVT: {
      /* busy level update */
      do_in_main_thread(FROM_HERE, base::Bind(send_busy_level_update,
                                              p_data->update.busy_level_flags));
      return;
    }
    case BTM_BL_ROLE_CHG_EVT: {
      const auto& tmp = p_data->role_chg;
      do_in_main_thread(FROM_HERE, base::Bind(handle_role_change, *tmp.p_bda,
+0 −9
Original line number Diff line number Diff line
@@ -353,7 +353,6 @@ typedef uint8_t tBTA_SIG_STRENGTH_MASK;
#define BTA_DM_SIG_STRENGTH_EVT                                             \
  7                             /* Signal strength for bluetooth connection \
                                   */
#define BTA_DM_BUSY_LEVEL_EVT 8 /* System busy level */
#define BTA_DM_BOND_CANCEL_CMPL_EVT 9 /* Bond cancel complete indication */
#define BTA_DM_SP_CFM_REQ_EVT                     \
  10 /* Simple Pairing User Confirmation request. \
@@ -539,13 +538,6 @@ typedef struct {
  uint8_t new_role; /* the new connection role */
} tBTA_DM_ROLE_CHG;

/* Structure associated with BTA_DM_BUSY_LEVEL_EVT */
typedef struct {
  uint8_t level;       /* when paging or inquiring, level is 10.
                          Otherwise, the number of ACL links */
  uint8_t level_flags; /* indicates individual flags */
} tBTA_DM_BUSY_LEVEL;

#define BTA_IO_CAP_OUT BTM_IO_CAP_OUT       /* 0 DisplayOnly */
#define BTA_IO_CAP_IO BTM_IO_CAP_IO         /* 1 DisplayYesNo */
#define BTA_IO_CAP_IN BTM_IO_CAP_IN         /* 2 KeyboardOnly */
@@ -669,7 +661,6 @@ typedef union {
  tBTA_DM_AUTHORIZE authorize;    /* Authorization request. */
  tBTA_DM_LINK_UP link_up;        /* ACL connection down event */
  tBTA_DM_LINK_DOWN link_down;    /* ACL connection down event */
  tBTA_DM_BUSY_LEVEL busy_level;  /* System busy level */
  tBTA_DM_SP_CFM_REQ cfm_req;     /* user confirm request */
  tBTA_DM_SP_KEY_NOTIF key_notif; /* passkey notification */
  tBTA_DM_SP_RMT_OOB rmt_oob;     /* remote oob */
+16 −16
Original line number Diff line number Diff line
@@ -1641,6 +1641,22 @@ static void btif_dm_remote_service_record_evt(uint16_t event, char* p_param) {
  }
}

static void report_busy_level_change(uint8_t busy_level_flags) {
  if (busy_level_flags == BTM_BL_INQUIRY_STARTED) {
    HAL_CBACK(bt_hal_cbacks, discovery_state_changed_cb, BT_DISCOVERY_STARTED);
    btif_dm_inquiry_in_progress = true;
  } else if (busy_level_flags == BTM_BL_INQUIRY_CANCELLED) {
    HAL_CBACK(bt_hal_cbacks, discovery_state_changed_cb, BT_DISCOVERY_STOPPED);
    btif_dm_inquiry_in_progress = false;
  } else if (busy_level_flags == BTM_BL_INQUIRY_COMPLETE) {
    btif_dm_inquiry_in_progress = false;
  }
}

void BTIF_dm_report_busy_level_change(uint8_t busy_level_flags) {
  do_in_jni_thread(base::Bind(report_busy_level_change, busy_level_flags));
}

/*******************************************************************************
 *
 * Function         btif_dm_upstreams_cback
@@ -1756,22 +1772,6 @@ static void btif_dm_upstreams_evt(uint16_t event, char* p_param) {
      bond_state_changed(BT_STATUS_SUCCESS, bd_addr, BT_BOND_STATE_NONE);
      break;

    case BTA_DM_BUSY_LEVEL_EVT: {
      if (p_data->busy_level.level_flags & BTM_BL_INQUIRY_PAGING_MASK) {
        if (p_data->busy_level.level_flags == BTM_BL_INQUIRY_STARTED) {
          HAL_CBACK(bt_hal_cbacks, discovery_state_changed_cb,
                    BT_DISCOVERY_STARTED);
          btif_dm_inquiry_in_progress = true;
        } else if (p_data->busy_level.level_flags == BTM_BL_INQUIRY_CANCELLED) {
          HAL_CBACK(bt_hal_cbacks, discovery_state_changed_cb,
                    BT_DISCOVERY_STOPPED);
          btif_dm_inquiry_in_progress = false;
        } else if (p_data->busy_level.level_flags == BTM_BL_INQUIRY_COMPLETE) {
          btif_dm_inquiry_in_progress = false;
        }
      }
    } break;

    case BTA_DM_LINK_UP_EVT:
      bd_addr = p_data->link_up.bd_addr;
      BTIF_TRACE_DEBUG("BTA_DM_LINK_UP_EVT. Sending BT_ACL_STATE_CONNECTED");
+0 −1
Original line number Diff line number Diff line
@@ -152,7 +152,6 @@ const char* dump_dm_event(uint16_t event) {
    CASE_RETURN_STR(BTA_DM_LINK_UP_EVT)
    CASE_RETURN_STR(BTA_DM_LINK_DOWN_EVT)
    CASE_RETURN_STR(BTA_DM_SIG_STRENGTH_EVT)
    CASE_RETURN_STR(BTA_DM_BUSY_LEVEL_EVT)
    CASE_RETURN_STR(BTA_DM_BOND_CANCEL_CMPL_EVT)
    CASE_RETURN_STR(BTA_DM_SP_CFM_REQ_EVT)
    CASE_RETURN_STR(BTA_DM_SP_KEY_NOTIF_EVT)
+4 −12
Original line number Diff line number Diff line
@@ -77,6 +77,7 @@ 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);

void BTIF_dm_report_busy_level_change(uint8_t busy_level_flags);
/* 3 seconds timeout waiting for responses */
#define BTM_DEV_REPLY_TIMEOUT_MS (3 * 1000)

@@ -451,32 +452,23 @@ void btm_acl_set_paging(bool value) { btm_cb.is_paging = value; }
 *
 ******************************************************************************/
void btm_acl_update_busy_level(tBTM_BLI_EVENT event) {
  tBTM_BL_UPDATE_DATA evt;
  evt.busy_level_flags = 0;
  switch (event) {
    case BTM_BLI_INQ_EVT:
      BTM_TRACE_DEBUG("BTM_BLI_INQ_EVT");
      btm_cb.is_inquiry = true;
      evt.busy_level_flags = BTM_BL_INQUIRY_STARTED;
      BTIF_dm_report_busy_level_change(BTM_BL_INQUIRY_STARTED);
      break;
    case BTM_BLI_INQ_CANCEL_EVT:
      BTM_TRACE_DEBUG("BTM_BLI_INQ_CANCEL_EVT");
      btm_cb.is_inquiry = false;
      evt.busy_level_flags = BTM_BL_INQUIRY_CANCELLED;
      BTIF_dm_report_busy_level_change(BTM_BL_INQUIRY_CANCELLED);
      break;
    case BTM_BLI_INQ_DONE_EVT:
      BTM_TRACE_DEBUG("BTM_BLI_INQ_DONE_EVT");
      btm_cb.is_inquiry = false;
      evt.busy_level_flags = BTM_BL_INQUIRY_COMPLETE;
      BTIF_dm_report_busy_level_change(BTM_BL_INQUIRY_COMPLETE);
      break;
  }

  evt.event = BTM_BL_UPDATE_EVT;
  if (btm_cb.acl_cb_.p_bl_changed_cb) {
    tBTM_BL_EVENT_DATA btm_bl_event_data;
    btm_bl_event_data.update = evt;
    (*btm_cb.acl_cb_.p_bl_changed_cb)(&btm_bl_event_data);
  }
}

/*******************************************************************************
Loading