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

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

floss: rejecting the unbonded HID/HOG profile connections

Rejecting the unbonded HID/HOG connection after we received a connected
notification

BUG: 259745456
Tag: #floss
Test: Classic HID devices still work
Change-Id: I9fcdd9f96fc705aab91945e3a3f1d059d6d47429
parent ff94fb35
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -2038,7 +2038,7 @@ impl BtifSdpCallbacks for Bluetooth {
}

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

        // HID or HOG is not differentiated by the hid host when callback this function. Assume HOG
@@ -2063,6 +2063,14 @@ impl BtifHHCallbacks for Bluetooth {
            BtStatus::Success,
            state as u32,
        );

        if BtBondState::Bonded != self.get_bond_state_by_addr(&address.to_string()) {
            warn!(
                "[{}]: Rejecting a unbonded device's attempt to connect to HID/HOG profiles",
                DisplayAddress(&address)
            );
            self.hh.as_ref().unwrap().disconnect(&mut address);
        }
    }

    fn hid_info(&mut self, address: RawAddress, info: BthhHidInfo) {