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

Commit f764fb3d authored by Michael Sun's avatar Michael Sun
Browse files

floss: hid: reply to get_report callback

Linux UHID driver requires an ack when a previous get_report request is
fulfilled; otherwise, it will wait 5 seconds to timeout. This patch
helps Floss send the response when the get_report callback gets
executed.

Bug: 243087440
Test: gd/cert/run
Test: HP910 reconnection time hugely reduced
Tag: #floss
Change-Id: I70e0268e6a03662ccc7f4d694069b4e63259d239
parent 90bdf67c
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -1860,11 +1860,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,