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

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

Merge changes Ia032262c,Ic587965e,I6dc0fcec,I51913698,I17a8ef4f, ... am: 1e4d8b7f

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

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I1763a715405459240aa443c8ae39fcffe747e374
parents f42de7de 1e4d8b7f
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -275,12 +275,16 @@ void bta_gattc_process_api_open(tBTA_GATTC_DATA* p_msg) {

/** process connect API request */
void bta_gattc_process_api_open_cancel(tBTA_GATTC_DATA* p_msg) {
  CHECK(p_msg != nullptr);

  uint16_t event = ((BT_HDR*)p_msg)->event;

  if (!p_msg->api_cancel_conn.is_direct) {
    LOG_DEBUG("Cancel GATT client background connection");
    bta_gattc_cancel_bk_conn(&p_msg->api_cancel_conn);
    return;
  }
  LOG_DEBUG("Cancel GATT client direct connection");

  tBTA_GATTC_CLCB* p_clcb = bta_gattc_find_clcb_by_cif(
      p_msg->api_cancel_conn.client_if, p_msg->api_cancel_conn.remote_bda,
+19 −16
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@
#include "bta/include/bta_hh_api.h"
#include "bta/include/bta_hh_co.h"
#include "bta/sys/bta_sys.h"
#include "main/shim/dumpsys.h"
#include "osi/include/log.h"
#include "osi/include/osi.h"  // UNUSED_ATTR
#include "stack/include/hidh_api.h"
@@ -478,29 +479,31 @@ void bta_hh_sdp_cmpl(tBTA_HH_DEV_CB* p_cb, tBTA_HH_DATA* p_data) {
 *
 ******************************************************************************/
void bta_hh_api_disc_act(tBTA_HH_DEV_CB* p_cb, tBTA_HH_DATA* p_data) {
  tBTA_HH_CBDATA disc_dat;
  tHID_STATUS status;
  CHECK(p_cb != nullptr);

  if (p_cb->is_le_device)
  if (p_cb->is_le_device) {
    LOG_DEBUG("Host initiating close to le device:%s",
              PRIVATE_ADDRESS(p_cb->addr));
    bta_hh_le_api_disc_act(p_cb);
  else
  {
  } else {
    /* found an active connection */
    disc_dat.handle =
        p_data ? (uint8_t)p_data->hdr.layer_specific : p_cb->hid_handle;
    disc_dat.status = BTA_HH_ERR;

    status = HID_HostCloseDev(disc_dat.handle);

    if (status) {
      tBTA_HH bta_hh;
      bta_hh.dev_status = disc_dat;
    const uint8_t hid_handle =
        (p_data != nullptr) ? static_cast<uint8_t>(p_data->hdr.layer_specific)
                            : p_cb->hid_handle;
    LOG_DEBUG("Host initiating close to classic device:%s",
              PRIVATE_ADDRESS(p_cb->addr));
    tHID_STATUS status = HID_HostCloseDev(hid_handle);
    if (status != HID_SUCCESS) {
      LOG_WARN("Failed closing classic device:%s status:%s",
               PRIVATE_ADDRESS(p_cb->addr), hid_status_text(status).c_str());
      tBTA_HH bta_hh = {
          .dev_status = {.status = BTA_HH_ERR, .handle = hid_handle},
      };
      (*bta_hh_cb.p_cback)(BTA_HH_CLOSE_EVT, &bta_hh);
    }
  }

  return;
}

/*******************************************************************************
 *
 * Function         bta_hh_open_cmpl_act
+65 −54
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@
#include "bta/include/bta_gatt_queue.h"
#include "bta/include/bta_hh_co.h"
#include "device/include/interop.h"
#include "main/shim/dumpsys.h"
#include "osi/include/log.h"
#include "osi/include/osi.h"
#include "stack/btm/btm_sec.h"
@@ -231,7 +232,7 @@ bool bta_hh_is_le_device(tBTA_HH_DEV_CB* p_cb, const RawAddress& remote_bda) {
 * Parameters:
 *
 ******************************************************************************/
uint8_t bta_hh_le_get_le_dev_hdl(uint8_t cb_index) {
static uint8_t bta_hh_le_get_le_dev_hdl(uint8_t cb_index) {
  uint8_t i;
  for (i = 0; i < ARRAY_SIZE(bta_hh_cb.le_cb_index); i++) {
    if (bta_hh_cb.le_cb_index[i] == cb_index) return BTA_HH_GET_LE_DEV_HDL(i);
@@ -278,7 +279,7 @@ void bta_hh_le_open_conn(tBTA_HH_DEV_CB* p_cb, const RawAddress& remote_bda) {
 *                  ID.
 *
 ******************************************************************************/
tBTA_HH_DEV_CB* bta_hh_le_find_dev_cb_by_conn_id(uint16_t conn_id) {
static tBTA_HH_DEV_CB* bta_hh_le_find_dev_cb_by_conn_id(uint16_t conn_id) {
  uint8_t i;
  tBTA_HH_DEV_CB* p_dev_cb = &bta_hh_cb.kdev[0];

@@ -295,7 +296,7 @@ tBTA_HH_DEV_CB* bta_hh_le_find_dev_cb_by_conn_id(uint16_t conn_id) {
 * Description      Utility function find a device control block by BD address.
 *
 ******************************************************************************/
tBTA_HH_DEV_CB* bta_hh_le_find_dev_cb_by_bda(const RawAddress& bda) {
static tBTA_HH_DEV_CB* bta_hh_le_find_dev_cb_by_bda(const RawAddress& bda) {
  uint8_t i;
  tBTA_HH_DEV_CB* p_dev_cb = &bta_hh_cb.kdev[0];

@@ -312,8 +313,8 @@ tBTA_HH_DEV_CB* bta_hh_le_find_dev_cb_by_bda(const RawAddress& bda) {
 * Description      find HID service instance ID by battery service instance ID
 *
 ******************************************************************************/
uint8_t bta_hh_le_find_service_inst_by_battery_inst_id(tBTA_HH_DEV_CB* p_cb,
                                                       uint8_t ba_inst_id) {
static uint8_t bta_hh_le_find_service_inst_by_battery_inst_id(
    tBTA_HH_DEV_CB* p_cb, uint8_t ba_inst_id) {
  if (p_cb->hid_srvc.in_use && p_cb->hid_srvc.incl_srvc_inst == ba_inst_id) {
    return p_cb->hid_srvc.srvc_inst_id;
  }
@@ -328,7 +329,7 @@ uint8_t bta_hh_le_find_service_inst_by_battery_inst_id(tBTA_HH_DEV_CB* p_cb,
 *                  and instance ID
 *
 ******************************************************************************/
tBTA_HH_LE_RPT* bta_hh_le_find_report_entry(
static tBTA_HH_LE_RPT* bta_hh_le_find_report_entry(
    tBTA_HH_DEV_CB* p_cb, uint8_t srvc_inst_id, /* service instance ID */
    uint16_t rpt_uuid, uint16_t char_inst_id) {
  uint8_t i;
@@ -362,7 +363,7 @@ tBTA_HH_LE_RPT* bta_hh_le_find_report_entry(
 * Returns          void
 *
 ******************************************************************************/
tBTA_HH_LE_RPT* bta_hh_le_find_rpt_by_idtype(tBTA_HH_LE_RPT* p_head,
static tBTA_HH_LE_RPT* bta_hh_le_find_rpt_by_idtype(tBTA_HH_LE_RPT* p_head,
                                                    uint8_t mode,
                                                    tBTA_HH_RPT_TYPE r_type,
                                                    uint8_t rpt_id) {
@@ -399,7 +400,7 @@ tBTA_HH_LE_RPT* bta_hh_le_find_rpt_by_idtype(tBTA_HH_LE_RPT* p_head,
 *                  list.
 *
 ******************************************************************************/
tBTA_HH_LE_RPT* bta_hh_le_find_alloc_report_entry(tBTA_HH_DEV_CB* p_cb,
static tBTA_HH_LE_RPT* bta_hh_le_find_alloc_report_entry(tBTA_HH_DEV_CB* p_cb,
                                                         uint8_t srvc_inst_id,
                                                         uint16_t rpt_uuid,
                                                         uint16_t inst_id) {
@@ -493,7 +494,8 @@ static tBTA_HH_STATUS bta_hh_le_read_char_descriptor(tBTA_HH_DEV_CB* p_cb,
 * Parameters:
 *
 ******************************************************************************/
void bta_hh_le_save_report_ref(tBTA_HH_DEV_CB* p_dev_cb, tBTA_HH_LE_RPT* p_rpt,
static void bta_hh_le_save_report_ref(tBTA_HH_DEV_CB* p_dev_cb,
                                      tBTA_HH_LE_RPT* p_rpt,
                                      tGATT_STATUS status, uint8_t* value,
                                      uint16_t len) {
  if (status == GATT_INSUF_AUTHENTICATION) {
@@ -543,8 +545,9 @@ void bta_hh_le_save_report_ref(tBTA_HH_DEV_CB* p_dev_cb, tBTA_HH_LE_RPT* p_rpt,
 * Parameters:
 *
 ******************************************************************************/
void bta_hh_le_register_input_notif(tBTA_HH_DEV_CB* p_dev_cb,
                                    uint8_t proto_mode, bool register_ba) {
static void bta_hh_le_register_input_notif(tBTA_HH_DEV_CB* p_dev_cb,
                                           uint8_t proto_mode,
                                           bool register_ba) {
  tBTA_HH_LE_RPT* p_rpt = &p_dev_cb->hid_srvc.report[0];

#if (BTA_HH_DEBUG == TRUE)
@@ -604,7 +607,7 @@ void bta_hh_le_register_input_notif(tBTA_HH_DEV_CB* p_dev_cb,
 * Description      Deregister all notifications
 *
 ******************************************************************************/
void bta_hh_le_deregister_input_notif(tBTA_HH_DEV_CB* p_dev_cb) {
static void bta_hh_le_deregister_input_notif(tBTA_HH_DEV_CB* p_dev_cb) {
  tBTA_HH_LE_RPT* p_rpt = &p_dev_cb->hid_srvc.report[0];

  for (uint8_t i = 0; i < BTA_HH_LE_RPT_MAX; i++, p_rpt++) {
@@ -634,7 +637,7 @@ void bta_hh_le_deregister_input_notif(tBTA_HH_DEV_CB* p_dev_cb) {
 * Description      HID over GATT connection sucessfully opened
 *
 ******************************************************************************/
void bta_hh_le_open_cmpl(tBTA_HH_DEV_CB* p_cb) {
static void bta_hh_le_open_cmpl(tBTA_HH_DEV_CB* p_cb) {
  if (p_cb->disc_active == BTA_HH_LE_DISC_NONE) {
#if (BTA_HH_DEBUG == TRUE)
    bta_hh_le_hid_report_dbg(p_cb);
@@ -658,7 +661,7 @@ void bta_hh_le_open_cmpl(tBTA_HH_DEV_CB* p_cb) {
 *                  a characteristic
 *
 ******************************************************************************/
bool bta_hh_le_write_ccc(tBTA_HH_DEV_CB* p_cb, uint16_t char_handle,
static bool bta_hh_le_write_ccc(tBTA_HH_DEV_CB* p_cb, uint16_t char_handle,
                                uint16_t clt_cfg_value, GATT_WRITE_OP_CB cb,
                                void* cb_data) {
  const gatt::Descriptor* p_desc = find_descriptor_by_short_uuid(
@@ -674,7 +677,7 @@ bool bta_hh_le_write_ccc(tBTA_HH_DEV_CB* p_cb, uint16_t char_handle,
  return true;
}

bool bta_hh_le_write_rpt_clt_cfg(tBTA_HH_DEV_CB* p_cb);
static bool bta_hh_le_write_rpt_clt_cfg(tBTA_HH_DEV_CB* p_cb);

static void write_rpt_ctl_cfg_cb(uint16_t conn_id, tGATT_STATUS status,
                                 uint16_t handle, void* data) {
@@ -714,7 +717,7 @@ static void write_rpt_ctl_cfg_cb(uint16_t conn_id, tGATT_STATUS status,
 *                  enable all input notification upon connection open.
 *
 ******************************************************************************/
bool bta_hh_le_write_rpt_clt_cfg(tBTA_HH_DEV_CB* p_cb) {
static bool bta_hh_le_write_rpt_clt_cfg(tBTA_HH_DEV_CB* p_cb) {
  uint8_t i;
  tBTA_HH_LE_RPT* p_rpt = &p_cb->hid_srvc.report[p_cb->clt_cfg_idx];

@@ -776,7 +779,7 @@ static void write_proto_mode_cb(uint16_t conn_id, tGATT_STATUS status,
 * Description      Set remote device protocol mode.
 *
 ******************************************************************************/
bool bta_hh_le_set_protocol_mode(tBTA_HH_DEV_CB* p_cb,
static bool bta_hh_le_set_protocol_mode(tBTA_HH_DEV_CB* p_cb,
                                        tBTA_HH_PROTO_MODE mode) {
  tBTA_HH_CBDATA cback_data;

@@ -865,7 +868,7 @@ static void get_protocol_mode_cb(uint16_t conn_id, tGATT_STATUS status,
 * Description      Get remote device protocol mode.
 *
 ******************************************************************************/
void bta_hh_le_get_protocol_mode(tBTA_HH_DEV_CB* p_cb) {
static void bta_hh_le_get_protocol_mode(tBTA_HH_DEV_CB* p_cb) {
  tBTA_HH_HSDATA hs_data;
  p_cb->w4_evt = BTA_HH_GET_PROTO_EVT;

@@ -893,7 +896,8 @@ void bta_hh_le_get_protocol_mode(tBTA_HH_DEV_CB* p_cb) {
 * Parameters:
 *
 ******************************************************************************/
void bta_hh_le_dis_cback(const RawAddress& addr, tDIS_VALUE* p_dis_value) {
static void bta_hh_le_dis_cback(const RawAddress& addr,
                                tDIS_VALUE* p_dis_value) {
  tBTA_HH_DEV_CB* p_cb = bta_hh_le_find_dev_cb_by_bda(addr);

  if (p_cb == NULL || p_dis_value == NULL) {
@@ -927,7 +931,7 @@ void bta_hh_le_dis_cback(const RawAddress& addr, tDIS_VALUE* p_dis_value) {
 * Parameters:
 *
 ******************************************************************************/
void bta_hh_le_pri_service_discovery(tBTA_HH_DEV_CB* p_cb) {
static void bta_hh_le_pri_service_discovery(tBTA_HH_DEV_CB* p_cb) {
  bta_hh_le_co_reset_rpt_cache(p_cb->addr, p_cb->app_id);

  p_cb->disc_active |= (BTA_HH_LE_DISC_HIDS | BTA_HH_LE_DISC_DIS);
@@ -954,9 +958,10 @@ void bta_hh_le_pri_service_discovery(tBTA_HH_DEV_CB* p_cb) {
 * Returns          None
 *
 ******************************************************************************/
void bta_hh_le_encrypt_cback(const RawAddress* bd_addr,
static void bta_hh_le_encrypt_cback(const RawAddress* bd_addr,
                                    UNUSED_ATTR tBT_TRANSPORT transport,
                             UNUSED_ATTR void* p_ref_data, tBTM_STATUS result) {
                                    UNUSED_ATTR void* p_ref_data,
                                    tBTM_STATUS result) {
  uint8_t idx = bta_hh_find_cb(*bd_addr);
  tBTA_HH_DEV_CB* p_dev_cb;

@@ -1047,7 +1052,7 @@ void bta_hh_le_notify_enc_cmpl(tBTA_HH_DEV_CB* p_cb, tBTA_HH_DATA* p_buf) {
 * Parameters:
 *
 ******************************************************************************/
void bta_hh_clear_service_cache(tBTA_HH_DEV_CB* p_cb) {
static void bta_hh_clear_service_cache(tBTA_HH_DEV_CB* p_cb) {
  tBTA_HH_LE_HID_SRVC* p_hid_srvc = &p_cb->hid_srvc;

  p_cb->app_id = 0;
@@ -1157,7 +1162,7 @@ void bta_hh_gatt_open(tBTA_HH_DEV_CB* p_cb, tBTA_HH_DATA* p_buf) {
 * Parameters:
 *
 ******************************************************************************/
void bta_hh_le_close(tBTA_GATTC_CLOSE* p_data) {
static void bta_hh_le_close(tBTA_GATTC_CLOSE* p_data) {
  tBTA_HH_DEV_CB* p_dev_cb = bta_hh_le_find_dev_cb_by_bda(p_data->remote_bda);
  uint16_t sm_event = BTA_HH_GATT_CLOSE_EVT;

@@ -1184,7 +1189,8 @@ void bta_hh_le_close(tBTA_GATTC_CLOSE* p_data) {
 * Parameters:
 *
 ******************************************************************************/
void bta_hh_le_gatt_disc_cmpl(tBTA_HH_DEV_CB* p_cb, tBTA_HH_STATUS status) {
static void bta_hh_le_gatt_disc_cmpl(tBTA_HH_DEV_CB* p_cb,
                                     tBTA_HH_STATUS status) {
  APPL_TRACE_DEBUG("bta_hh_le_gatt_disc_cmpl ");

  /* if open sucessful or protocol mode not desired, keep the connection open
@@ -1301,9 +1307,9 @@ static void read_report_ref_desc_cb(uint16_t conn_id, tGATT_STATUS status,
  if (p_rpt) bta_hh_le_save_report_ref(p_dev_cb, p_rpt, status, value, len);
}

void read_pref_conn_params_cb(uint16_t conn_id, tGATT_STATUS status,
                              uint16_t handle, uint16_t len, uint8_t* value,
                              void* data) {
static void read_pref_conn_params_cb(uint16_t conn_id, tGATT_STATUS status,
                                     uint16_t handle, uint16_t len,
                                     uint8_t* value, void* data) {
  if (status != GATT_SUCCESS) {
    APPL_TRACE_ERROR("%s: error: %d", __func__, status);
    return;
@@ -1449,7 +1455,7 @@ static void bta_hh_le_search_hid_chars(tBTA_HH_DEV_CB* p_dev_cb,
 * Parameters:
 *
 ******************************************************************************/
void bta_hh_le_srvc_search_cmpl(tBTA_GATTC_SEARCH_CMPL* p_data) {
static void bta_hh_le_srvc_search_cmpl(tBTA_GATTC_SEARCH_CMPL* p_data) {
  tBTA_HH_DEV_CB* p_dev_cb = bta_hh_le_find_dev_cb_by_conn_id(p_data->conn_id);

  /* service search exception or no HID service is supported on remote */
@@ -1523,7 +1529,7 @@ void bta_hh_le_srvc_search_cmpl(tBTA_GATTC_SEARCH_CMPL* p_data) {
 * Parameters:
 *
 ******************************************************************************/
void bta_hh_le_input_rpt_notify(tBTA_GATTC_NOTIFY* p_data) {
static void bta_hh_le_input_rpt_notify(tBTA_GATTC_NOTIFY* p_data) {
  tBTA_HH_DEV_CB* p_dev_cb = bta_hh_le_find_dev_cb_by_conn_id(p_data->conn_id);
  uint8_t app_id;
  uint8_t* p_buf;
@@ -1667,14 +1673,17 @@ void bta_hh_gatt_close(tBTA_HH_DEV_CB* p_cb, tBTA_HH_DATA* p_data) {
 *
 ******************************************************************************/
void bta_hh_le_api_disc_act(tBTA_HH_DEV_CB* p_cb) {
  if (p_cb->conn_id != GATT_INVALID_CONN_ID) {
  if (p_cb->conn_id == GATT_INVALID_CONN_ID) {
    LOG_ERROR("Tried to disconnect HID device with invalid id");
    return;
  }

  BtaGattQueue::Clean(p_cb->conn_id);
  BTA_GATTC_Close(p_cb->conn_id);
  /* remove device from background connection if intended to disconnect,
     do not allow reconnection */
  bta_hh_le_remove_dev_bg_conn(p_cb);
}
}

/*******************************************************************************
 *
@@ -1761,7 +1770,7 @@ static void read_report_cb(uint16_t conn_id, tGATT_STATUS status,
 * Returns          void
 *
 ******************************************************************************/
void bta_hh_le_get_rpt(tBTA_HH_DEV_CB* p_cb, tBTA_HH_RPT_TYPE r_type,
static void bta_hh_le_get_rpt(tBTA_HH_DEV_CB* p_cb, tBTA_HH_RPT_TYPE r_type,
                              uint8_t rpt_id) {
  tBTA_HH_LE_RPT* p_rpt = bta_hh_le_find_rpt_by_idtype(
      p_cb->hid_srvc.report, p_cb->mode, r_type, rpt_id);
@@ -1812,7 +1821,7 @@ static void write_report_cb(uint16_t conn_id, tGATT_STATUS status,
 * Returns          void
 *
 ******************************************************************************/
void bta_hh_le_write_rpt(tBTA_HH_DEV_CB* p_cb, tBTA_HH_RPT_TYPE r_type,
static void bta_hh_le_write_rpt(tBTA_HH_DEV_CB* p_cb, tBTA_HH_RPT_TYPE r_type,
                                BT_HDR* p_buf, uint16_t w4_evt) {
  tBTA_HH_LE_RPT* p_rpt;
  uint8_t rpt_id;
@@ -1858,7 +1867,7 @@ void bta_hh_le_write_rpt(tBTA_HH_DEV_CB* p_cb, tBTA_HH_RPT_TYPE r_type,
 * Returns          void
 *
 ******************************************************************************/
void bta_hh_le_suspend(tBTA_HH_DEV_CB* p_cb,
static void bta_hh_le_suspend(tBTA_HH_DEV_CB* p_cb,
                              tBTA_HH_TRANS_CTRL_TYPE ctrl_type) {
  ctrl_type -= BTA_HH_CTRL_SUSPEND;

@@ -2010,6 +2019,8 @@ uint8_t bta_hh_le_add_device(tBTA_HH_DEV_CB* p_cb,
 ******************************************************************************/
void bta_hh_le_remove_dev_bg_conn(tBTA_HH_DEV_CB* p_dev_cb) {
  if (p_dev_cb->in_bg_conn) {
    LOG_DEBUG("Removing from background connection device:%s",
              PRIVATE_ADDRESS(p_dev_cb->addr));
    p_dev_cb->in_bg_conn = false;

    BTA_GATTC_CancelOpen(bta_hh_cb.gatt_if, p_dev_cb->addr, false);
+0 −13
Original line number Diff line number Diff line
@@ -39,10 +39,8 @@ tBTA_HH_CB bta_hh_cb;
/*****************************************************************************
 * Static functions
 ****************************************************************************/
#if (BTA_HH_DEBUG == TRUE)
static const char* bta_hh_evt_code(tBTA_HH_INT_EVT evt_code);
static const char* bta_hh_state_code(tBTA_HH_STATE state_code);
#endif

static void bta_hh_better_state_machine(tBTA_HH_DEV_CB* p_cb, uint16_t event,
                                        tBTA_HH_DATA* p_data) {
@@ -190,10 +188,8 @@ void bta_hh_sm_execute(tBTA_HH_DEV_CB* p_cb, uint16_t event,
                       tBTA_HH_DATA* p_data) {
  tBTA_HH cback_data;
  tBTA_HH_EVT cback_event = 0;
#if (BTA_HH_DEBUG == TRUE)
  tBTA_HH_STATE in_state;
  uint16_t debug_event = event;
#endif

  memset(&cback_data, 0, sizeof(tBTA_HH));

@@ -271,12 +267,10 @@ void bta_hh_sm_execute(tBTA_HH_DEV_CB* p_cb, uint16_t event,
  }
  /* corresponding CB is found, go to state machine */
  else {
#if (BTA_HH_DEBUG == TRUE)
    in_state = p_cb->state;
    APPL_TRACE_EVENT("bta_hh_sm_execute: State 0x%02x [%s], Event [%s]",
                     in_state, bta_hh_state_code(in_state),
                     bta_hh_evt_code(debug_event));
#endif

    if ((p_cb->state == BTA_HH_NULL_ST) || (p_cb->state >= BTA_HH_INVALID_ST)) {
      APPL_TRACE_ERROR(
@@ -287,14 +281,12 @@ void bta_hh_sm_execute(tBTA_HH_DEV_CB* p_cb, uint16_t event,

    bta_hh_better_state_machine(p_cb, event, p_data);

#if (BTA_HH_DEBUG == TRUE)
    if (in_state != p_cb->state) {
      APPL_TRACE_DEBUG("HH State Change: [%s] -> [%s] after Event [%s]",
                       bta_hh_state_code(in_state),
                       bta_hh_state_code(p_cb->state),
                       bta_hh_evt_code(debug_event));
    }
#endif
  }

  return;
@@ -360,10 +352,8 @@ bool bta_hh_hdl_event(BT_HDR* p_msg) {

      if (index != BTA_HH_IDX_INVALID) p_cb = &bta_hh_cb.kdev[index];

#if (BTA_HH_DEBUG == TRUE)
      APPL_TRACE_DEBUG("bta_hh_hdl_event:: handle = %d dev_cb[%d] ",
                       p_msg->layer_specific, index);
#endif
      bta_hh_sm_execute(p_cb, p_msg->event, (tBTA_HH_DATA*)p_msg);
  }
  return (true);
@@ -372,7 +362,6 @@ bool bta_hh_hdl_event(BT_HDR* p_msg) {
/*****************************************************************************
 *  Debug Functions
 ****************************************************************************/
#if (BTA_HH_DEBUG == TRUE)
/*******************************************************************************
 *
 * Function         bta_hh_evt_code
@@ -453,6 +442,4 @@ static const char* bta_hh_state_code(tBTA_HH_STATE state_code) {
  }
}

#endif /* Debug Functions */

#endif /* BTA_HH_INCLUDED */
+24 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@

#include "bt_target.h"  // Must be first to define build configuration

#include "osi/include/log.h"
#include "stack/include/bt_types.h"
#include "stack/include/btm_api_types.h"
#include "stack/include/btm_ble_api_types.h"
@@ -127,6 +128,29 @@ typedef enum : uint8_t {
  BTA_PERIPHERAL_ROLE_ONLY = 0x03,
} tBTA_PREF_ROLES;

inline tBTA_PREF_ROLES toBTA_PREF_ROLES(uint8_t role) {
  ASSERT_LOG(role <= BTA_PERIPHERAL_ROLE_ONLY,
             "Passing illegal preferred role:0x%02x [0x%02x<=>0x%02x]", role,
             BTA_ANY_ROLE, BTA_PERIPHERAL_ROLE_ONLY);
  return static_cast<tBTA_PREF_ROLES>(role);
}

#define CASE_RETURN_TEXT(code) \
  case code:                   \
    return #code

inline std::string preferred_role_text(const tBTA_PREF_ROLES& role) {
  switch (role) {
    CASE_RETURN_TEXT(BTA_ANY_ROLE);
    CASE_RETURN_TEXT(BTA_CENTRAL_ROLE_PREF);
    CASE_RETURN_TEXT(BTA_CENTRAL_ROLE_ONLY);
    CASE_RETURN_TEXT(BTA_PERIPHERAL_ROLE_ONLY);
    default:
      return std::string("UNKNOWN:%hhu", role);
  }
}
#undef CASE_RETURN_TEXT

enum {

  BTA_DM_NO_SCATTERNET,      /* Device doesn't support scatternet, it might
Loading