Class MacUsbDevice

java.lang.Object
oshi.hardware.common.AbstractUsbDevice
oshi.hardware.platform.mac.MacUsbDevice
All Implemented Interfaces:
Comparable<UsbDevice>, UsbDevice

@Immutable public class MacUsbDevice extends AbstractUsbDevice
Mac Usb Device
  • Field Details

  • Constructor Details

  • Method Details

    • getUsbDevices

      public static List<UsbDevice> getUsbDevices(boolean tree)
      Instantiates a list of UsbDevice 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 of tree 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 List<UsbDevice> getUsbDevices()
    • addDeviceAndChildrenToMaps

      private static void addDeviceAndChildrenToMaps(com.sun.jna.platform.mac.IOKit.IORegistryEntry device, long parentId, Map<Long,String> nameMap, Map<Long,String> vendorMap, Map<Long,String> vendorIdMap, Map<Long,String> productIdMap, Map<Long,String> serialMap, Map<Long,List<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 added
      parentId - The id of the device's parent.
      nameMap - the map of names
      vendorMap - the map of vendors
      vendorIdMap - the map of vendorIds
      productIdMap - the map of productIds
      serialMap - the map of serial numbers
      hubMap - the map of hubs
    • addDevicesToList

      private static void addDevicesToList(List<UsbDevice> deviceList, 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, Map<Long,String> vendorIdMap, Map<Long,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 maps
      locationId - The locationID of this controller returned from the registry
      locationIDKey - A pointer to the locationID string
      ioPropertyMatchKey - A pointer to the IOPropertyMatch string
      vendorIdMap - the map of vendorIds
      productIdMap - the map of productIds
    • getDeviceAndChildren

      private static MacUsbDevice getDeviceAndChildren(Long registryEntryId, String vid, String pid, Map<Long,String> nameMap, Map<Long,String> vendorMap, Map<Long,String> vendorIdMap, Map<Long,String> productIdMap, Map<Long,String> serialMap, Map<Long,List<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 ID
      pid - The default (parent) product ID
      nameMap - the map of names
      vendorMap - the map of vendors
      vendorIdMap - the map of vendorIds
      productIdMap - the map of productIds
      serialMap - the map of serial numbers
      hubMap - the map of hubs
      Returns:
      A MacUsbDevice corresponding to this device