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

Commit 7f6c079e authored by Himanshu Rawat's avatar Himanshu Rawat Committed by Gerrit Code Review
Browse files

Merge "Reset the HID host state only if L2CAP registration is successful"

parents d80fe9a3 f7b34bc0
Loading
Loading
Loading
Loading
+18 −15
Original line number Diff line number Diff line
@@ -76,20 +76,20 @@ static const char* bta_hh_hid_event_name(uint16_t event);
 *
 ******************************************************************************/
void bta_hh_api_enable(const tBTA_HH_DATA* p_data) {
  tBTA_HH_STATUS status = BTA_HH_ERR;
  /* Register with L2CAP */
  tHID_STATUS status = HID_HostRegister(bta_hh_cback);

  if (status == HID_SUCCESS) {
    uint8_t xx;

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

    /* initialize BTE HID */
    HID_HostInit();

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

  /* Register with L2CAP */
  if (HID_HostRegister(bta_hh_cback) == HID_SUCCESS) {
    /* store parameters */
    bta_hh_cb.p_cback = p_data->api_enable.p_cback;

    status = BTA_HH_OK;
    /* initialize device CB */
    for (xx = 0; xx < BTA_HH_MAX_DEVICE; xx++) {
      bta_hh_cb.kdev[xx].state = BTA_HH_IDLE_ST;
@@ -98,20 +98,23 @@ void bta_hh_api_enable(const tBTA_HH_DATA* p_data) {
    }

    /* initialize control block map */
    for (xx = 0; xx < BTA_HH_MAX_KNOWN; xx++)
    for (xx = 0; xx < BTA_HH_MAX_KNOWN; xx++) {
      bta_hh_cb.cb_index[xx] = BTA_HH_IDX_INVALID;
    }

  if (status == BTA_HH_OK) {
    bta_hh_le_enable();
  } else
  {
  } else if (status == HID_ERR_ALREADY_REGISTERED) {
    LOG_WARN("Already registered");
  } else {
    /* signal BTA call back event */
    tBTA_HH bta_hh;
    bta_hh.status = status;
    bta_hh.status = BTA_HH_ERR;
    LOG_ERROR("Failed to register, status: %d", status);
    if (bta_hh_cb.p_cback) {
      (*bta_hh_cb.p_cback)(BTA_HH_ENABLE_EVT, &bta_hh);
    }
  }
}
/*******************************************************************************
 *
 * Function         bta_hh_api_disable