1
2
3
4
5 package oshi.hardware.platform.unix.aix;
6
7 import java.util.ArrayList;
8 import java.util.Arrays;
9 import java.util.Collections;
10 import java.util.List;
11 import java.util.function.Supplier;
12
13 import oshi.annotation.concurrent.Immutable;
14 import oshi.hardware.UsbDevice;
15 import oshi.hardware.common.AbstractUsbDevice;
16 import oshi.util.Constants;
17 import oshi.util.ParseUtil;
18
19
20
21
22 @Immutable
23 public class AixUsbDevice extends AbstractUsbDevice {
24
25 public AixUsbDevice(String name, String vendor, String vendorId, String productId, String serialNumber,
26 String uniqueDeviceId, List<UsbDevice> connectedDevices) {
27 super(name, vendor, vendorId, productId, serialNumber, uniqueDeviceId, connectedDevices);
28 }
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43 public static List<UsbDevice> getUsbDevices(boolean tree, Supplier<List<String>> lscfg) {
44 List<UsbDevice> deviceList = new ArrayList<>();
45 for (String line : lscfg.get()) {
46 String s = line.trim();
47 if (s.startsWith("usb")) {
48 String[] split = ParseUtil.whitespaces.split(s, 3);
49 if (split.length == 3) {
50 deviceList.add(new AixUsbDevice(split[2], Constants.UNKNOWN, Constants.UNKNOWN, Constants.UNKNOWN,
51 Constants.UNKNOWN, split[0], Collections.emptyList()));
52 }
53 }
54 }
55 if (tree) {
56 return Arrays.asList(new AixUsbDevice("USB Controller", "", "0000", "0000", "", "", deviceList));
57 }
58 return deviceList;
59 }
60 }