Package oshi.hardware.platform.mac
Class MacUsbDevice
- java.lang.Object
-
- oshi.hardware.common.AbstractUsbDevice
-
- oshi.hardware.platform.mac.MacUsbDevice
-
@Immutable public class MacUsbDevice extends AbstractUsbDevice
Mac Usb Device
-
-
Constructor Summary
Constructors Constructor Description MacUsbDevice(java.lang.String name, java.lang.String vendor, java.lang.String vendorId, java.lang.String productId, java.lang.String serialNumber, java.lang.String uniqueDeviceId, java.util.List<UsbDevice> connectedDevices)
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static void
addDeviceAndChildrenToMaps(com.sun.jna.platform.mac.IOKit.IORegistryEntry device, long parentId, java.util.Map<java.lang.Long,java.lang.String> nameMap, java.util.Map<java.lang.Long,java.lang.String> vendorMap, java.util.Map<java.lang.Long,java.lang.String> vendorIdMap, java.util.Map<java.lang.Long,java.lang.String> productIdMap, java.util.Map<java.lang.Long,java.lang.String> serialMap, java.util.Map<java.lang.Long,java.util.List<java.lang.Long>> hubMap)
Recursively populate maps with information from a USB Device and its childrenprivate static void
addDevicesToList(java.util.List<UsbDevice> deviceList, java.util.List<UsbDevice> list)
private static void
getControllerIdByLocation(long id, com.sun.jna.platform.mac.CoreFoundation.CFTypeRef locationId, com.sun.jna.platform.mac.CoreFoundation.CFStringRef locationIDKey, com.sun.jna.platform.mac.CoreFoundation.CFStringRef ioPropertyMatchKey, java.util.Map<java.lang.Long,java.lang.String> vendorIdMap, java.util.Map<java.lang.Long,java.lang.String> productIdMap)
Looks up vendor and product id information for a USB Host Controller by cross-referencing the locationprivate static MacUsbDevice
getDeviceAndChildren(java.lang.Long registryEntryId, java.lang.String vid, java.lang.String pid, java.util.Map<java.lang.Long,java.lang.String> nameMap, java.util.Map<java.lang.Long,java.lang.String> vendorMap, java.util.Map<java.lang.Long,java.lang.String> vendorIdMap, java.util.Map<java.lang.Long,java.lang.String> productIdMap, java.util.Map<java.lang.Long,java.lang.String> serialMap, java.util.Map<java.lang.Long,java.util.List<java.lang.Long>> hubMap)
Recursively creates MacUsbDevices by fetching information from maps to populate fieldsprivate static java.util.List<UsbDevice>
getUsbDevices()
static java.util.List<UsbDevice>
getUsbDevices(boolean tree)
Instantiates a list ofUsbDevice
objects, representing devices connected via a usb port (including internal devices).-
Methods inherited from class oshi.hardware.common.AbstractUsbDevice
compareTo, getConnectedDevices, getName, getProductId, getSerialNumber, getUniqueDeviceId, getVendor, getVendorId, toString
-
-
-
-
Field Detail
-
CF
private static final com.sun.jna.platform.mac.CoreFoundation CF
-
IOUSB
private static final java.lang.String IOUSB
- See Also:
- Constant Field Values
-
IOSERVICE
private static final java.lang.String IOSERVICE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
MacUsbDevice
public MacUsbDevice(java.lang.String name, java.lang.String vendor, java.lang.String vendorId, java.lang.String productId, java.lang.String serialNumber, java.lang.String uniqueDeviceId, java.util.List<UsbDevice> connectedDevices)
-
-
Method Detail
-
getUsbDevices
public static java.util.List<UsbDevice> getUsbDevices(boolean tree)
Instantiates a list ofUsbDevice
objects, representing devices connected via a usb port (including internal devices).If the value of
tree
is true, the top level devices returned from this method are the USB Controllers; connected hubs and devices in its device tree share that controller's bandwidth. If the value oftree
is false, USB devices (not controllers) are listed in a single flat list.- Parameters:
tree
- If true, returns a list of controllers, which requires recursive iteration of connected devices. If false, returns a flat list of devices excluding controllers.- Returns:
- a list of
UsbDevice
objects.
-
getUsbDevices
private static java.util.List<UsbDevice> getUsbDevices()
-
addDeviceAndChildrenToMaps
private static void addDeviceAndChildrenToMaps(com.sun.jna.platform.mac.IOKit.IORegistryEntry device, long parentId, java.util.Map<java.lang.Long,java.lang.String> nameMap, java.util.Map<java.lang.Long,java.lang.String> vendorMap, java.util.Map<java.lang.Long,java.lang.String> vendorIdMap, java.util.Map<java.lang.Long,java.lang.String> productIdMap, java.util.Map<java.lang.Long,java.lang.String> serialMap, java.util.Map<java.lang.Long,java.util.List<java.lang.Long>> hubMap)
Recursively populate maps with information from a USB Device and its children- Parameters:
device
- The device which, along with its children, should be addedparentId
- The id of the device's parent.nameMap
- the map of namesvendorMap
- the map of vendorsvendorIdMap
- the map of vendorIdsproductIdMap
- the map of productIdsserialMap
- the map of serial numbershubMap
- the map of hubs
-
addDevicesToList
private static void addDevicesToList(java.util.List<UsbDevice> deviceList, java.util.List<UsbDevice> list)
-
getControllerIdByLocation
private static void getControllerIdByLocation(long id, com.sun.jna.platform.mac.CoreFoundation.CFTypeRef locationId, com.sun.jna.platform.mac.CoreFoundation.CFStringRef locationIDKey, com.sun.jna.platform.mac.CoreFoundation.CFStringRef ioPropertyMatchKey, java.util.Map<java.lang.Long,java.lang.String> vendorIdMap, java.util.Map<java.lang.Long,java.lang.String> productIdMap)
Looks up vendor and product id information for a USB Host Controller by cross-referencing the location- Parameters:
id
- The global unique ID for the host controller used as a key for mapslocationId
- The locationID of this controller returned from the registrylocationIDKey
- A pointer to the locationID stringioPropertyMatchKey
- A pointer to the IOPropertyMatch stringproductIdMap
- the map of productIdsvendorIdMap
- the map of vendorIds
-
getDeviceAndChildren
private static MacUsbDevice getDeviceAndChildren(java.lang.Long registryEntryId, java.lang.String vid, java.lang.String pid, java.util.Map<java.lang.Long,java.lang.String> nameMap, java.util.Map<java.lang.Long,java.lang.String> vendorMap, java.util.Map<java.lang.Long,java.lang.String> vendorIdMap, java.util.Map<java.lang.Long,java.lang.String> productIdMap, java.util.Map<java.lang.Long,java.lang.String> serialMap, java.util.Map<java.lang.Long,java.util.List<java.lang.Long>> hubMap)
Recursively creates MacUsbDevices by fetching information from maps to populate fields- Parameters:
registryEntryId
- The device unique registry id.vid
- The default (parent) vendor IDpid
- The default (parent) product IDnameMap
- the map of namesvendorMap
- the map of vendorsvendorIdMap
- the map of vendorIdsproductIdMap
- the map of productIdsserialMap
- the map of serial numbershubMap
- the map of hubs- Returns:
- A MacUsbDevice corresponding to this device
-
-