Skip to content

Commit

Permalink
untested android support
Browse files Browse the repository at this point in the history
  • Loading branch information
tuna-f1sh committed Sep 23, 2024
1 parent d8b1f10 commit c7d28f8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
13 changes: 8 additions & 5 deletions src/enumeration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -485,17 +485,17 @@ impl UsbControllerType {
/// * Windows: `instance_id`, `parent_instance_id`, `location_paths`, `devinst`, `root_hub_description`
/// * macOS: `registry_id`, `location_id`, `name`, `provider_class_name`, `class_name`
pub struct BusInfo {
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "android"))]
pub(crate) path: SysfsPath,

#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "android"))]
pub(crate) parent_path: SysfsPath,

/// The phony root hub device
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "android"))]
pub(crate) root_hub: DeviceInfo,

#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "android"))]
pub(crate) busnum: u8,

#[cfg(target_os = "windows")]
Expand Down Expand Up @@ -649,7 +649,7 @@ impl BusInfo {
/// * macOS: The [IONameMatched](https://developer.apple.com/documentation/bundleresources/information_property_list/ionamematch) key of the IOService entry.
/// * Windows: Description field of the root hub device. How the bus will appear in Device Manager.
pub fn system_name(&self) -> Option<&str> {
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "android"))]
{
self.root_hub.product_string()
}
Expand All @@ -674,6 +674,9 @@ impl std::fmt::Debug for BusInfo {
{
s.field("sysfs_path", &self.path);
s.field("parent_sysfs_path", &self.parent_path);
}
#[cfg(any(target_os = "linux", target_os = "android"))]
{
s.field("busnum", &self.busnum);
}

Expand Down
3 changes: 2 additions & 1 deletion src/platform/linux_usbfs/enumeration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ pub fn list_buses() -> Result<impl Iterator<Item = BusInfo>, Error> {
Ok(list_root_hubs()?.filter_map(|rh| {
// get the parent by following the absolute symlink; root hub in /bus/usb is a symlink to a dir in parent bus
let parent_path = rh
.sysfs_path()
.path
.0
.canonicalize()
.ok()
.and_then(|p| p.parent().map(|p| SysfsPath(p.to_owned())))?;
Expand Down

0 comments on commit c7d28f8

Please sign in to comment.