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

Commit 2aeb6c5b authored by Michael Sun's avatar Michael Sun
Browse files

floss: handle hid host callbacks

Implement the skeleton handles for the hid host callbacks.

Bug: 240781725
Test: emerge-${BOARD} floss
Change-Id: I5ba9367613c28026e9f4d0ff11a0ddb1287dd603
parent 5701afd8
Loading
Loading
Loading
Loading
+60 −1
Original line number Diff line number Diff line
@@ -8,7 +8,10 @@ use bt_topshim::btif::{
};
use bt_topshim::{
    metrics,
    profiles::hid_host::{HHCallbacksDispatcher, HidHost},
    profiles::hid_host::{
        BthhConnectionState, BthhHidInfo, BthhProtocolMode, BthhStatus, HHCallbacks,
        HHCallbacksDispatcher, HidHost,
    },
    profiles::sdp::{BtSdpRecord, Sdp, SdpCallbacks, SdpCallbacksDispatcher},
    topstack,
};
@@ -626,6 +629,27 @@ pub(crate) trait BtifBluetoothCallbacks {
    fn le_rand_cb(&mut self, random: u64);
}

#[btif_callbacks_dispatcher(Bluetooth, dispatch_hid_host_callbacks, HHCallbacks)]
pub(crate) trait BtifHHCallbacks {
    #[btif_callback(ConnectionState)]
    fn connection_state(&mut self, address: RawAddress, state: BthhConnectionState);

    #[btif_callback(HidInfo)]
    fn hid_info(&mut self, address: RawAddress, info: BthhHidInfo);

    #[btif_callback(ProtocolMode)]
    fn protocol_mode(&mut self, address: RawAddress, status: BthhStatus, mode: BthhProtocolMode);

    #[btif_callback(IdleTime)]
    fn idle_time(&mut self, address: RawAddress, status: BthhStatus, idle_rate: i32);

    #[btif_callback(GetReport)]
    fn get_report(&mut self, address: RawAddress, status: BthhStatus, data: Vec<u8>, size: i32);

    #[btif_callback(Handshake)]
    fn handshake(&mut self, address: RawAddress, status: BthhStatus);
}

#[btif_callbacks_dispatcher(Bluetooth, dispatch_sdp_callbacks, SdpCallbacks)]
pub(crate) trait BtifSdpCallbacks {
    #[btif_callback(SdpSearch)]
@@ -1576,6 +1600,41 @@ impl BtifSdpCallbacks for Bluetooth {
    }
}

impl BtifHHCallbacks for Bluetooth {
    fn connection_state(&mut self, address: RawAddress, state: BthhConnectionState) {
        debug!("Hid host connection state updated: Address({:?}) State({:?})", address, state);
    }

    fn hid_info(&mut self, address: RawAddress, info: BthhHidInfo) {
        debug!("Hid host info updated: Address({:?}) Info({:?})", address, info);
    }

    fn protocol_mode(&mut self, address: RawAddress, status: BthhStatus, mode: BthhProtocolMode) {
        debug!(
            "Hid host protocol mode updated: Address({:?}) Status({:?}) Mode({:?})",
            address, status, mode
        );
    }

    fn idle_time(&mut self, address: RawAddress, status: BthhStatus, idle_rate: i32) {
        debug!(
            "Hid host idle time updated: Address({:?}) Status({:?}) Idle Rate({:?})",
            address, status, idle_rate
        );
    }

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

    fn handshake(&mut self, address: RawAddress, status: BthhStatus) {
        debug!("Hid host handshake: Address({:?}) Status({:?})", address, status);
    }
}

impl IBluetoothQA for Bluetooth {
    fn get_connectable(&self) -> bool {
        match self.properties.get(&BtPropertyType::AdapterScanMode) {
+2 −3
Original line number Diff line number Diff line
@@ -140,9 +140,8 @@ impl Stack {
                    bluetooth_media.lock().unwrap().dispatch_hfp_callbacks(hf);
                }

                Message::HidHost(_h) => {
                    // TODO(abps) - Handle hid host callbacks
                    debug!("Received HH callback");
                Message::HidHost(h) => {
                    bluetooth.lock().unwrap().dispatch_hid_host_callbacks(h);
                }

                Message::Sdp(s) => {
+1 −0
Original line number Diff line number Diff line
@@ -97,6 +97,7 @@ fn convert_report(count: i32, raw: *mut u8) -> Vec<u8> {
    return v;
}

#[derive(Debug)]
pub enum HHCallbacks {
    ConnectionState(RawAddress, BthhConnectionState),
    VirtualUnplug(RawAddress, BthhStatus),