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

Commit 7b1aabbe authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge changes I70e0268e,Iee28f1e7

* changes:
  floss: hid: reply to get_report callback
  btif: hh: Add btif: hh: Add new API to help application send reply for get_report
parents 3899bac3 f764fb3d
Loading
Loading
Loading
Loading
+33 −1
Original line number Diff line number Diff line
@@ -1634,6 +1634,38 @@ static bt_status_t get_report(RawAddress* bd_addr,
  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
@@ -1782,7 +1814,6 @@ static void cleanup(void) {
      p_dev->hh_poll_thread_id = -1;
    }
  }

}

static const bthh_interface_t bthhInterface = {
@@ -1797,6 +1828,7 @@ static const bthh_interface_t bthhInterface = {
    get_idle_time,
    set_idle_time,
    get_report,
    get_report_reply,
    set_report,
    send_data,
    cleanup,
+8 −1
Original line number Diff line number Diff line
@@ -1873,11 +1873,18 @@ impl BtifHHCallbacks for Bluetooth {
        );
    }

    fn get_report(&mut self, address: RawAddress, status: BthhStatus, _data: Vec<u8>, size: i32) {
    fn get_report(
        &mut self,
        mut address: RawAddress,
        status: BthhStatus,
        mut data: Vec<u8>,
        size: i32,
    ) {
        debug!(
            "Hid host got report: Address({:?}) Status({:?}) Report Size({:?})",
            address, status, size
        );
        self.hh.as_ref().unwrap().get_report_reply(&mut address, status, &mut data, size as u16);
    }

    fn handshake(&mut self, address: RawAddress, status: BthhStatus) {
+19 −0
Original line number Diff line number Diff line
@@ -302,6 +302,25 @@ impl HidHost {
        ))
    }

    #[profile_enabled_or(BtStatus::NotReady)]
    pub fn get_report_reply(
        &self,
        addr: &mut RawAddress,
        status: BthhStatus,
        report: &mut [u8],
        size: u16,
    ) -> BtStatus {
        let ffi_addr = cast_to_ffi_address!(addr as *mut RawAddress);
        BtStatus::from(ccall!(
            self,
            get_report_reply,
            ffi_addr,
            status as bindings::bthh_status_t,
            report.as_mut_ptr() as *mut std::os::raw::c_char,
            size
        ))
    }

    #[profile_enabled_or(BtStatus::NotReady)]
    pub fn set_report(
        &self,
+4 −0
Original line number Diff line number Diff line
@@ -199,6 +199,10 @@ typedef struct {
  bt_status_t (*get_report)(RawAddress* bd_addr, bthh_report_type_t reportType,
                            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. */
  bt_status_t (*set_report)(RawAddress* bd_addr, bthh_report_type_t reportType,
                            char* report);