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

Commit 6aadcedf authored by Hansong Zhang's avatar Hansong Zhang
Browse files

Clean up HIDH code

Bug: 159815595
Tag: #refactor
Test: compile & verify basic functions working
Change-Id: I4ed8662703f7b78bb5bcabf677f7f7eac6b35124
parent cc9ae7e4
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -75,7 +75,7 @@ void bta_hh_api_enable(tBTA_HH_DATA* p_data) {

  memset(&bta_hh_cb, 0, sizeof(tBTA_HH_CB));

  HID_HostSetSecurityLevel("");
  HID_HostSetSecurityLevel();

  /* Register with L2CAP */
  if (HID_HostRegister(bta_hh_cback) == HID_SUCCESS) {
@@ -414,7 +414,7 @@ void bta_hh_sdp_cmpl(tBTA_HH_DEV_CB* p_cb, tBTA_HH_DATA* p_data) {
    if (!p_cb->incoming_conn) {
      tHID_STATUS ret;
      /* set security level */
      HID_HostSetSecurityLevel("");
      HID_HostSetSecurityLevel();

      /* open HID connection */
      ret = HID_HostOpenDev(p_cb->hid_handle);
+0 −41
Original line number Diff line number Diff line
@@ -371,45 +371,4 @@ void BTA_HhRemoveDev(uint8_t dev_handle) {
/*                          Utility Function */
/******************************************************************************/

/*******************************************************************************
 *
 * Function         BTA_HhParseBootRpt
 *
 * Description      This utility function parse a boot mode report.
 *                  For keyboard report, report data will carry the keycode max
 *                  up to 6 key press in one report. Application need to convert
 *                  the keycode into keypress character according to keyboard
 *                  language.
 *
 * Returns          void
 *
 ******************************************************************************/
void BTA_HhParseBootRpt(tBTA_HH_BOOT_RPT* p_data, uint8_t* p_report,
                        uint16_t report_len) {
  p_data->dev_type = BTA_HH_DEVT_UNKNOWN;

  if (p_report) {
    /* first byte is report ID */
    switch (p_report[0]) {
      case BTA_HH_KEYBD_RPT_ID: /* key board report ID */
        p_data->dev_type = p_report[0];
        bta_hh_parse_keybd_rpt(p_data, p_report + 1,
                               (uint16_t)(report_len - 1));
        break;

      case BTA_HH_MOUSE_RPT_ID: /* mouse report ID */
        p_data->dev_type = p_report[0];
        bta_hh_parse_mice_rpt(p_data, p_report + 1, (uint16_t)(report_len - 1));
        break;

      default:
        APPL_TRACE_DEBUG("Unknown boot report: %d", p_report[0]);
        ;
        break;
    }
  }

  return;
}

#endif /* BTA_HH_INCLUDED */
+1 −3
Original line number Diff line number Diff line
@@ -367,13 +367,11 @@ extern void bta_hh_le_open_fail(tBTA_HH_DEV_CB* p_cb, tBTA_HH_DATA* p_data);
extern void bta_hh_gatt_open(tBTA_HH_DEV_CB* p_cb, tBTA_HH_DATA* p_data);
extern void bta_hh_gatt_close(tBTA_HH_DEV_CB* p_cb, tBTA_HH_DATA* p_data);
extern void bta_hh_start_security(tBTA_HH_DEV_CB* p_cb, tBTA_HH_DATA* p_buf);
extern void bta_hh_start_srvc_discovery(tBTA_HH_DEV_CB* p_cb,
                                        tBTA_HH_DATA* p_buf);

extern void bta_hh_start_security(tBTA_HH_DEV_CB* p_cb, tBTA_HH_DATA* p_buf);
extern void bta_hh_security_cmpl(tBTA_HH_DEV_CB* p_cb, tBTA_HH_DATA* p_buf);
extern void bta_hh_le_notify_enc_cmpl(tBTA_HH_DEV_CB* p_cb,
                                      tBTA_HH_DATA* p_data);
extern void bta_hh_ci_load_rpt(tBTA_HH_DEV_CB* p_cb, tBTA_HH_DATA* p_buf);

#if (BTA_HH_DEBUG == TRUE)
extern void bta_hh_trace_dev_db(void);
+0 −48
Original line number Diff line number Diff line
@@ -2083,54 +2083,6 @@ static void bta_hh_gattc_callback(tBTA_GATTC_EVT event, tBTA_GATTC* p_data) {
  }
}

static void read_report_descriptor_ccc_cb(uint16_t conn_id, tGATT_STATUS status,
                                          uint16_t handle, uint16_t len,
                                          uint8_t* value, void* data) {
  tBTA_HH_LE_RPT* p_rpt = (tBTA_HH_LE_RPT*)data;
  uint8_t* pp = value;
  STREAM_TO_UINT16(p_rpt->client_cfg_value, pp);

  APPL_TRACE_DEBUG("Read Client Configuration: 0x%04x",
                   p_rpt->client_cfg_value);
}

/*******************************************************************************
 *
 * Function         bta_hh_le_hid_read_rpt_clt_cfg
 *
 * Description      a test command to read report descriptor client
 *                  configuration
 *
 * Returns          void
 *
 ******************************************************************************/
void bta_hh_le_hid_read_rpt_clt_cfg(const RawAddress& bd_addr, uint8_t rpt_id) {
  tBTA_HH_DEV_CB* p_cb = NULL;
  tBTA_HH_LE_RPT* p_rpt;
  uint8_t index = BTA_HH_IDX_INVALID;

  index = bta_hh_find_cb(bd_addr);
  if (index == BTA_HH_IDX_INVALID) {
    APPL_TRACE_ERROR("%s: unknown device", __func__);
    return;
  }

  p_cb = &bta_hh_cb.kdev[index];

  p_rpt = bta_hh_le_find_rpt_by_idtype(p_cb->hid_srvc.report, p_cb->mode,
                                       BTA_HH_RPTT_INPUT, rpt_id);

  if (p_rpt == NULL) {
    APPL_TRACE_ERROR("%s: no matching report", __func__);
    return;
  }

  bta_hh_le_read_char_descriptor(p_cb, p_rpt->char_inst_id,
                                 GATT_UUID_CHAR_CLIENT_CONFIG,
                                 read_report_descriptor_ccc_cb, p_rpt);
  return;
}

/*******************************************************************************
 *
 * Function         bta_hh_process_cache_rpt
+0 −21
Original line number Diff line number Diff line
@@ -488,25 +488,4 @@ extern void BTA_HhAddDev(const RawAddress& bda, tBTA_HH_ATTR_MASK attr_mask,
 ******************************************************************************/
extern void BTA_HhRemoveDev(uint8_t dev_handle);

/*******************************************************************************
 *
 *              Parsing Utility Functions
 *
 ******************************************************************************/
/*******************************************************************************
 *
 * Function         BTA_HhParseBootRpt
 *
 * Description      This utility function parse a boot mode report.
 *
 * Returns          void
 *
 ******************************************************************************/
extern void BTA_HhParseBootRpt(tBTA_HH_BOOT_RPT* p_data, uint8_t* p_report,
                               uint16_t report_len);

/* test commands */
extern void bta_hh_le_hid_read_rpt_clt_cfg(const RawAddress& bd_addr,
                                           uint8_t rpt_id);

#endif /* BTA_HH_API_H */
Loading