Skip to content

Commit c7d28f8

Browse files
committed
untested android support
1 parent d8b1f10 commit c7d28f8

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/enumeration.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -485,17 +485,17 @@ impl UsbControllerType {
485485
/// * Windows: `instance_id`, `parent_instance_id`, `location_paths`, `devinst`, `root_hub_description`
486486
/// * macOS: `registry_id`, `location_id`, `name`, `provider_class_name`, `class_name`
487487
pub struct BusInfo {
488-
#[cfg(target_os = "linux")]
488+
#[cfg(any(target_os = "linux", target_os = "android"))]
489489
pub(crate) path: SysfsPath,
490490

491-
#[cfg(target_os = "linux")]
491+
#[cfg(any(target_os = "linux", target_os = "android"))]
492492
pub(crate) parent_path: SysfsPath,
493493

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

498-
#[cfg(target_os = "linux")]
498+
#[cfg(any(target_os = "linux", target_os = "android"))]
499499
pub(crate) busnum: u8,
500500

501501
#[cfg(target_os = "windows")]
@@ -649,7 +649,7 @@ impl BusInfo {
649649
/// * macOS: The [IONameMatched](https://developer.apple.com/documentation/bundleresources/information_property_list/ionamematch) key of the IOService entry.
650650
/// * Windows: Description field of the root hub device. How the bus will appear in Device Manager.
651651
pub fn system_name(&self) -> Option<&str> {
652-
#[cfg(target_os = "linux")]
652+
#[cfg(any(target_os = "linux", target_os = "android"))]
653653
{
654654
self.root_hub.product_string()
655655
}
@@ -674,6 +674,9 @@ impl std::fmt::Debug for BusInfo {
674674
{
675675
s.field("sysfs_path", &self.path);
676676
s.field("parent_sysfs_path", &self.parent_path);
677+
}
678+
#[cfg(any(target_os = "linux", target_os = "android"))]
679+
{
677680
s.field("busnum", &self.busnum);
678681
}
679682

src/platform/linux_usbfs/enumeration.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@ pub fn list_buses() -> Result<impl Iterator<Item = BusInfo>, Error> {
162162
Ok(list_root_hubs()?.filter_map(|rh| {
163163
// get the parent by following the absolute symlink; root hub in /bus/usb is a symlink to a dir in parent bus
164164
let parent_path = rh
165-
.sysfs_path()
165+
.path
166+
.0
166167
.canonicalize()
167168
.ok()
168169
.and_then(|p| p.parent().map(|p| SysfsPath(p.to_owned())))?;

0 commit comments

Comments
 (0)