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

Commit 90bdf67c authored by Michael Sun's avatar Michael Sun
Browse files

btif: hh: Add btif: hh: Add new API to help application send reply for get_report

Linux UHID driver requires an ack when a previous get_report request is
fulfilled. Android relies on the HID (independent from Bluetooth HID)
to deliver the ack, whereas other platforms may not have such an
implementation. This patch adds the API to help other
platforms/applications send the GET_REPORT_REPLY to the driver if
needed.

Bug: 243087440
Test: gd/cert/run
Tag: #floss
Change-Id: Iee28f1e7c57fd6e805cd1a8c181cbc753ba3ce2b
parent b8578f9e
Loading
Loading
Loading
Loading
+33 −1
Original line number Original line Diff line number Diff line
@@ -1634,6 +1634,38 @@ static bt_status_t get_report(RawAddress* bd_addr,
  return BT_STATUS_SUCCESS;
  return BT_STATUS_SUCCESS;
}
}


/*******************************************************************************
 *
 * Function         get_report_reply
 *
 * Description      Send a REPORT_REPLY/FEATURE_ANSWER to HID driver.
 *
 * Returns         bt_status_t
 *
 ******************************************************************************/
static bt_status_t get_report_reply(RawAddress* bd_addr, bthh_status_t status,
                                    char* report, uint16_t size) {
  CHECK_BTHH_INIT();
  btif_hh_device_t* p_dev;

  VLOG(1) << __func__ << " BTHH: addr=" << *bd_addr;

  if (btif_hh_cb.status == BTIF_HH_DISABLED) {
    BTIF_TRACE_ERROR("%s: Error, HH status = %d", __func__, btif_hh_cb.status);
    return BT_STATUS_FAIL;
  }

  p_dev = btif_hh_find_connected_dev_by_bda(*bd_addr);
  if (p_dev == NULL) {
    LOG(ERROR) << " Error, device" << *bd_addr << " not opened";
    return BT_STATUS_FAIL;
  }

  bta_hh_co_get_rpt_rsp(p_dev->dev_handle, (tBTA_HH_STATUS)status,
                        (uint8_t*)report, size);
  return BT_STATUS_SUCCESS;
}

/*******************************************************************************
/*******************************************************************************
 *
 *
 * Function         set_report
 * Function         set_report
@@ -1782,7 +1814,6 @@ static void cleanup(void) {
      p_dev->hh_poll_thread_id = -1;
      p_dev->hh_poll_thread_id = -1;
    }
    }
  }
  }

}
}


static const bthh_interface_t bthhInterface = {
static const bthh_interface_t bthhInterface = {
@@ -1797,6 +1828,7 @@ static const bthh_interface_t bthhInterface = {
    get_idle_time,
    get_idle_time,
    set_idle_time,
    set_idle_time,
    get_report,
    get_report,
    get_report_reply,
    set_report,
    set_report,
    send_data,
    send_data,
    cleanup,
    cleanup,
+4 −0
Original line number Original line Diff line number Diff line
@@ -199,6 +199,10 @@ typedef struct {
  bt_status_t (*get_report)(RawAddress* bd_addr, bthh_report_type_t reportType,
  bt_status_t (*get_report)(RawAddress* bd_addr, bthh_report_type_t reportType,
                            uint8_t reportId, int bufferSize);
                            uint8_t reportId, int bufferSize);


  /** Send a GET_REPORT_REPLY to HID driver. */
  bt_status_t (*get_report_reply)(RawAddress* bd_addr, bthh_status_t status,
                                  char* report, uint16_t size);

  /** Send a SET_REPORT to HID device. */
  /** Send a SET_REPORT to HID device. */
  bt_status_t (*set_report)(RawAddress* bd_addr, bthh_report_type_t reportType,
  bt_status_t (*set_report)(RawAddress* bd_addr, bthh_report_type_t reportType,
                            char* report);
                            char* report);