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

Commit 69dd3142 authored by Charlie Boutier's avatar Charlie Boutier Committed by Gerrit Code Review
Browse files

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

parents cfa30e52 7438b00a
Loading
Loading
Loading
Loading
+15 −18
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) {
  /* Register with L2CAP */
  tHID_STATUS status = HID_HostRegister(bta_hh_cback);

  if (status == HID_SUCCESS) {
  tBTA_HH_STATUS status = BTA_HH_ERR;
  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,23 +98,20 @@ 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 if (status == HID_ERR_ALREADY_REGISTERED) {
    LOG_WARN("Already registered");
  } else {
  } else
  {
    /* signal BTA call back event */
    tBTA_HH bta_hh;
    bta_hh.status = BTA_HH_ERR;
    LOG_ERROR("Failed to register, status: %d", status);
    if (bta_hh_cb.p_cback) {
    bta_hh.status = status;
    (*bta_hh_cb.p_cback)(BTA_HH_ENABLE_EVT, &bta_hh);
  }
}
}
/*******************************************************************************
 *
 * Function         bta_hh_api_disable