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

Commit be3617dd authored by Zach Johnson's avatar Zach Johnson
Browse files

BTA_HH_LE_INCLUDED is always true

stop corrupting the code formatting

Bug: 159815595
Tag: #refactor
Test: compile & verify basic functions working
Change-Id: I0b5dd0a15c4ab73f2e4a9eb9c01cb3f94b02b2fd
parent 0b7f0d8f
Loading
Loading
Loading
Loading
+0 −8
Original line number Diff line number Diff line
@@ -39,9 +39,7 @@
#include "stack/include/btu.h"
#include "utl.h"

#if (BTA_HH_LE_INCLUDED == TRUE)
#include "bta_hh_int.h"
#endif

using base::StringPrintf;
using bluetooth::Uuid;
@@ -139,13 +137,9 @@ void bta_gattc_disable() {
    bta_gattc_cb.state = BTA_GATTC_STATE_DISABLING;
/* don't deregister HH GATT IF */
/* HH GATT IF will be deregistered by bta_hh_le_deregister when disable HH */
#if (BTA_HH_LE_INCLUDED == TRUE)
    if (!bta_hh_le_is_hh_gatt_if(bta_gattc_cb.cl_rcb[i].client_if)) {
#endif
      bta_gattc_deregister(&bta_gattc_cb.cl_rcb[i]);
#if (BTA_HH_LE_INCLUDED == TRUE)
    }
#endif
  }

  /* no registered apps, indicate disable completed */
@@ -1070,7 +1064,6 @@ static void bta_gattc_enc_cmpl_cback(tGATT_IF gattc_if, const RawAddress& bda) {

  if (p_clcb == NULL) return;

#if (BTA_HH_LE_INCLUDED == TRUE)
  /* filter this event just for BTA HH LE GATT client,
   * In the future, if we want to enable encryption complete event
   * for all GATT clients, we can remove this code
@@ -1078,7 +1071,6 @@ static void bta_gattc_enc_cmpl_cback(tGATT_IF gattc_if, const RawAddress& bda) {
  if (!bta_hh_le_is_hh_gatt_if(gattc_if)) {
    return;
  }
#endif

  VLOG(1) << __func__ << ": cif:" << +gattc_if;

+0 −28
Original line number Diff line number Diff line
@@ -93,11 +93,9 @@ void bta_hh_api_enable(tBTA_HH_DATA* p_data) {
      bta_hh_cb.cb_index[xx] = BTA_HH_IDX_INVALID;
  }

#if (BTA_HH_LE_INCLUDED == TRUE)
  if (status == BTA_HH_OK) {
    bta_hh_le_enable();
  } else
#endif
  {
    /* signal BTA call back event */
    tBTA_HH bta_hh;
@@ -151,10 +149,8 @@ void bta_hh_api_disable(void) {
 *
 ******************************************************************************/
void bta_hh_disc_cmpl(void) {
#if (BTA_HH_LE_INCLUDED == TRUE)
  HID_HostDeregister();
  bta_hh_le_deregister();
#else
  tBTA_HH_STATUS status = BTA_HH_OK;

  /* Deregister with lower layer */
@@ -313,12 +309,10 @@ void bta_hh_start_sdp(tBTA_HH_DEV_CB* p_cb, tBTA_HH_DATA* p_data) {
  p_cb->mode = p_data->api_conn.mode;
  bta_hh_cb.p_cur = p_cb;

#if (BTA_HH_LE_INCLUDED == TRUE)
  if (bta_hh_is_le_device(p_cb, p_data->api_conn.bd_addr)) {
    bta_hh_le_open_conn(p_cb, p_data->api_conn.bd_addr);
    return;
  }
#endif

  /* if previously virtually cabled device, skip SDP */
  if (p_cb->app_id) {
@@ -484,11 +478,9 @@ 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;

#if (BTA_HH_LE_INCLUDED == TRUE)
  if (p_cb->is_le_device)
    bta_hh_le_api_disc_act(p_cb);
  else
#endif
  {
    /* found an active connection */
    disc_dat.handle =
@@ -532,22 +524,18 @@ void bta_hh_open_cmpl_act(tBTA_HH_DEV_CB* p_cb, tBTA_HH_DATA* p_data) {
  bta_hh_co_open(p_cb->hid_handle, p_cb->sub_class, p_cb->attr_mask,
                 p_cb->app_id);

#if (BTA_HH_LE_INCLUDED == TRUE)
  conn.status = p_cb->status;
  conn.le_hid = p_cb->is_le_device;
  conn.scps_supported = p_cb->scps_supported;

  if (!p_cb->is_le_device)
#endif
  {
    /* inform role manager */
    bta_sys_conn_open(BTA_ID_HH, p_cb->app_id, p_cb->addr);
  }
  /* set protocol mode when not default report mode */
  if (p_cb->mode != BTA_HH_PROTO_RPT_MODE
#if (BTA_HH_LE_INCLUDED == TRUE)
      && !p_cb->is_le_device
#endif
      ) {
    if ((HID_HostWriteDev(dev_handle, HID_TRANS_SET_PROTOCOL,
                          HID_PAR_PROTOCOL_BOOT_MODE, 0, 0, NULL)) !=
@@ -909,11 +897,9 @@ void bta_hh_close_act(tBTA_HH_DEV_CB* p_cb, tBTA_HH_DATA* p_data) {
 ******************************************************************************/
void bta_hh_get_dscp_act(tBTA_HH_DEV_CB* p_cb,
                         UNUSED_ATTR tBTA_HH_DATA* p_data) {
#if (BTA_HH_LE_INCLUDED == TRUE)
  if (p_cb->is_le_device) {
    bta_hh_le_get_dscp_act(p_cb);
  } else
#endif
    (*bta_hh_cb.p_cback)(BTA_HH_GET_DSCP_EVT, (tBTA_HH*)&p_cb->dscp_info);
}

@@ -940,31 +926,22 @@ void bta_hh_maint_dev_act(tBTA_HH_DEV_CB* p_cb, tBTA_HH_DATA* p_data) {
      dev_info.bda = p_dev_info->bda;
      /* initialize callback data */
      if (p_cb->hid_handle == BTA_HH_INVALID_HANDLE) {
#if (BTA_HH_LE_INCLUDED == TRUE)
        if (bta_hh_is_le_device(p_cb, p_data->api_conn.bd_addr)) {
          dev_info.handle = bta_hh_le_add_device(p_cb, p_dev_info);
          if (dev_info.handle != BTA_HH_INVALID_HANDLE)
            dev_info.status = BTA_HH_OK;
        } else
#endif

            if (HID_HostAddDev(p_dev_info->bda, p_dev_info->attr_mask,
                               &dev_handle) == HID_SUCCESS) {
          dev_info.handle = dev_handle;
          dev_info.status = BTA_HH_OK;

#if (BTA_HH_LE_INCLUDED == TRUE)
          /* update DI information */
          bta_hh_update_di_info(p_cb, p_dev_info->dscp_info.vendor_id,
                                p_dev_info->dscp_info.product_id,
                                p_dev_info->dscp_info.version,
                                p_dev_info->dscp_info.flag);
#else
          bta_hh_update_di_info(p_cb, p_dev_info->dscp_info.vendor_id,
                                p_dev_info->dscp_info.product_id,
                                p_dev_info->dscp_info.version, 0);

#endif
          /* add to BTA device list */
          bta_hh_add_device_to_list(
              p_cb, dev_handle, p_dev_info->attr_mask,
@@ -988,13 +965,11 @@ void bta_hh_maint_dev_act(tBTA_HH_DEV_CB* p_cb, tBTA_HH_DATA* p_data) {
      dev_info.handle = (uint8_t)p_dev_info->hdr.layer_specific;
      dev_info.bda = p_cb->addr;

#if (BTA_HH_LE_INCLUDED == TRUE)
      if (p_cb->is_le_device) {
        bta_hh_le_remove_dev_bg_conn(p_cb);
        bta_hh_sm_execute(p_cb, BTA_HH_API_CLOSE_EVT, NULL);
        bta_hh_clean_up_kdev(p_cb);
      } else
#endif
      {
        if (HID_HostRemoveDev(dev_info.handle) == HID_SUCCESS) {
          dev_info.status = BTA_HH_OK;
@@ -1026,11 +1001,9 @@ void bta_hh_write_dev_act(tBTA_HH_DEV_CB* p_cb, tBTA_HH_DATA* p_data) {
  uint16_t event = (p_data->api_sndcmd.t_type - BTA_HH_FST_BTE_TRANS_EVT) +
                   BTA_HH_FST_TRANS_CB_EVT;

#if (BTA_HH_LE_INCLUDED == TRUE)
  if (p_cb->is_le_device)
    bta_hh_le_write_dev_act(p_cb, p_data);
  else
#endif
  {

    cbdata.handle = p_cb->hid_handle;
@@ -1247,4 +1220,3 @@ static const char* bta_hh_hid_event_name(uint16_t event) {
  }
}
#endif
#endif /* BTA_HH_INCLUDED */
+0 −2
Original line number Diff line number Diff line
@@ -276,14 +276,12 @@ void BTA_HhSendCtrl(uint8_t dev_handle, tBTA_HH_TRANS_CTRL_TYPE c_type) {
 ******************************************************************************/
void BTA_HhSendData(uint8_t dev_handle, UNUSED_ATTR const RawAddress& dev_bda,
                    BT_HDR* p_data) {
#if (BTA_HH_LE_INCLUDED == TRUE)
  if (p_data->layer_specific != BTA_HH_RPTT_OUTPUT) {
    APPL_TRACE_ERROR(
        "ERROR! Wrong report type! Write Command only valid for output "
        "report!");
    return;
  }
#endif
  bta_hh_snd_write_dev(dev_handle, HID_TRANS_DATA,
                       (uint8_t)p_data->layer_specific, 0, 0, p_data);
}
+4 −23
Original line number Diff line number Diff line
@@ -29,9 +29,7 @@
#include "bta_sys.h"
#include "utl.h"

#if (BTA_HH_LE_INCLUDED == TRUE)
#include "bta_gatt_api.h"
#endif

/* can be moved to bta_api.h */
#define BTA_HH_MAX_RPT_CHARS 8
@@ -50,13 +48,11 @@ enum {
  BTA_HH_API_GET_DSCP_EVT,
  BTA_HH_API_MAINT_DEV_EVT,
  BTA_HH_OPEN_CMPL_EVT,
#if (BTA_HH_LE_INCLUDED == TRUE)
  BTA_HH_GATT_CLOSE_EVT,
  BTA_HH_GATT_OPEN_EVT,
  BTA_HH_START_ENC_EVT,
  BTA_HH_ENC_CMPL_EVT,
  BTA_HH_GATT_ENC_CMPL_EVT,
#endif

  /* not handled by execute state machine */
  BTA_HH_API_ENABLE_EVT,
@@ -80,12 +76,8 @@ enum {
  BTA_HH_NULL_ST,
  BTA_HH_IDLE_ST,
  BTA_HH_W4_CONN_ST,
  BTA_HH_CONN_ST
#if (BTA_HH_LE_INCLUDED == TRUE)
  ,
  BTA_HH_W4_SEC
#endif
  ,
  BTA_HH_CONN_ST,
  BTA_HH_W4_SEC,
  BTA_HH_INVALID_ST /* Used to check invalid states before executing SM function
                     */

@@ -98,9 +90,7 @@ typedef struct {
  uint8_t t_type;
  uint8_t param;
  uint8_t rpt_id;
#if (BTA_HH_LE_INCLUDED == TRUE)
  uint8_t srvc_id;
#endif
  uint16_t data;
  BT_HDR* p_data;
} tBTA_HH_CMD_DATA;
@@ -136,7 +126,6 @@ typedef struct {
  tBTA_HH_DEV_DSCP_INFO dscp_info;
} tBTA_HH_MAINT_DEV;

#if (BTA_HH_LE_INCLUDED == TRUE)
typedef struct {
  BT_HDR hdr;
  uint16_t conn_id;
@@ -150,7 +139,7 @@ typedef struct {
  uint16_t scan_int;
  uint16_t scan_win;
} tBTA_HH_SCPP_UPDATE;
#endif

/* union of all event data types */
typedef union {
  BT_HDR hdr;
@@ -160,15 +149,12 @@ typedef union {
  tBTA_HH_CBACK_DATA hid_cback;
  tBTA_HH_STATUS status;
  tBTA_HH_MAINT_DEV api_maintdev;
#if (BTA_HH_LE_INCLUDED == TRUE)
  tBTA_HH_LE_CLOSE le_close;
  tBTA_GATTC_OPEN le_open;
  tBTA_HH_SCPP_UPDATE le_scpp_update;
  tBTA_GATTC_ENC_CMPL_CB le_enc_cmpl;
#endif
} tBTA_HH_DATA;

#if (BTA_HH_LE_INCLUDED == TRUE)
typedef struct {
  uint8_t index;
  bool in_use;
@@ -210,7 +196,6 @@ typedef struct {
/* check to see if th edevice handle is a LE device handle */
#define BTA_HH_IS_LE_DEV_HDL(x) ((x)&0xf0)
#define BTA_HH_IS_LE_DEV_HDL_VALID(x) (((x) >> 4) <= BTA_HH_LE_MAX_KNOWN)
#endif

/* device control block */
typedef struct {
@@ -233,7 +218,6 @@ typedef struct {
  tBTA_HH_PROTO_MODE mode; /* protocol mode */
  tBTA_HH_STATE state;     /* CB state */

#if (BTA_HH_LE_INCLUDED == TRUE)
#define BTA_HH_LE_DISC_NONE 0x00
#define BTA_HH_LE_DISC_HIDS 0x01
#define BTA_HH_LE_DISC_DIS 0x02
@@ -254,7 +238,6 @@ typedef struct {
#define BTA_HH_LE_SCPS_NOTIFY_SPT 0x01
#define BTA_HH_LE_SCPS_NOTIFY_ENB 0x02
  uint8_t scps_notify; /* scan refresh supported/notification enabled */
#endif

  bool security_pending;
} tBTA_HH_DEV_CB;
@@ -280,11 +263,9 @@ typedef struct {
                                                 block idx, used in sdp */
  uint8_t cb_index[BTA_HH_MAX_KNOWN];     /* maintain a CB index
                                        map to dev handle */
#if (BTA_HH_LE_INCLUDED == TRUE)
  uint8_t le_cb_index[BTA_HH_LE_MAX_KNOWN]; /* maintain a CB index map to LE dev
                                             handle */
  tGATT_IF gatt_if;
#endif
  tBTA_HH_CBACK* p_cback; /* Application callbacks */
  tSDP_DISCOVERY_DB* p_disc_db;
  uint8_t trace_level; /* tracing level */
+0 −4
Original line number Diff line number Diff line
@@ -22,8 +22,6 @@
#include "bta_hh_int.h"
#include "osi/include/osi.h"

#if (BTA_HH_LE_INCLUDED == TRUE)

#include <string.h>

#include <base/bind.h>
@@ -2127,5 +2125,3 @@ static void bta_hh_process_cache_rpt(tBTA_HH_DEV_CB* p_cb,
    }
  }
}

#endif
Loading