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

Commit b74367aa authored by Hsin-chen Chuang's avatar Hsin-chen Chuang Committed by Gerrit Code Review
Browse files

Merge "floss: create_uhid_for_suspend_wakesource: Log masked address" into main

parents d1813713 1cd17fef
Loading
Loading
Loading
Loading
+4 −5
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@ use bt_topshim::{

use bt_utils::array_utils;
use bt_utils::cod::{is_cod_hid_combo, is_cod_hid_keyboard};
use bt_utils::uhid::{UHid, BD_ADDR_DEFAULT};
use bt_utils::uhid::UHid;
use btif_macros::{btif_callback, btif_callbacks_dispatcher};

use log::{debug, error, warn};
@@ -1296,13 +1296,12 @@ impl Bluetooth {
        if !self.uhid_wakeup_source.is_empty() {
            return;
        }
        let adapter_addr = self.get_address().to_string().to_lowercase();
        match self.uhid_wakeup_source.create(
            "VIRTUAL_SUSPEND_UHID".to_string(),
            adapter_addr,
            String::from(BD_ADDR_DEFAULT),
            self.get_address(),
            RawAddress::empty(),
        ) {
            Err(e) => log::error!("Fail to create uhid {}", e),
            Err(e) => error!("Fail to create uhid {}", e),
            Ok(_) => (),
        }
    }
+16 −8
Original line number Diff line number Diff line
//! This library provides access to Linux uhid.

use bt_topshim::btif::{DisplayAddress, RawAddress};
use log::{debug, error};
use std::fs::File;
use uhid_virt::{Bus, CreateParams, UHIDDevice};
@@ -7,9 +8,6 @@ use uhid_virt::{Bus, CreateParams, UHIDDevice};
const VID_DEFAULT: u32 = 0x0000;
const PID_DEFAULT: u32 = 0x0000;

/// Default address for a virtual uhid device.
pub const BD_ADDR_DEFAULT: &str = "00:00:00:00:00:00";

// Report descriptor for a standard mouse
const RDESC: [u8; 34] = [
    0x05, 0x01, // USAGE_PAGE (Generic Desktop)
@@ -50,13 +48,23 @@ impl UHid {
    }

    /// Initialize a uhid device with kernel.
    pub fn create(&mut self, name: String, phys: String, uniq: String) -> Result<(), String> {
        debug!("Create a UHID {} with phys: {}, uniq: {}", name, phys, uniq);
    pub fn create(
        &mut self,
        name: String,
        phys: RawAddress,
        uniq: RawAddress,
    ) -> Result<(), String> {
        debug!(
            "Create a UHID {} with phys: {}, uniq: {}",
            name,
            DisplayAddress(&phys),
            DisplayAddress(&uniq)
        );
        let rd_data = RDESC.to_vec();
        let create_params = CreateParams {
            name: name,
            phys: phys,
            uniq: uniq,
            name,
            phys: phys.to_string().to_lowercase(),
            uniq: uniq.to_string().to_lowercase(),
            bus: Bus::BLUETOOTH,
            vendor: VID_DEFAULT,
            product: PID_DEFAULT,