MCPcopy
hub / github.com/oshi/oshi / MacFirmware

Class MacFirmware

oshi-core/src/main/java/oshi/hardware/platform/mac/MacFirmware.java:45–154  ·  view source on GitHub ↗

Firmware data obtained from ioreg.

Source from the content-addressed store, hash-verified

43 * Firmware data obtained from ioreg.
44 */
45@Immutable
46final class MacFirmware extends AbstractFirmware {
47
48 private final Supplier<Quintet<String, String, String, String, String>> manufNameDescVersRelease = memoize(
49 MacFirmware::queryEfi);
50
51 @Override
52 public String getManufacturer() {
53 return manufNameDescVersRelease.get().getA();
54 }
55
56 @Override
57 public String getName() {
58 return manufNameDescVersRelease.get().getB();
59 }
60
61 @Override
62 public String getDescription() {
63 return manufNameDescVersRelease.get().getC();
64 }
65
66 @Override
67 public String getVersion() {
68 return manufNameDescVersRelease.get().getD();
69 }
70
71 @Override
72 public String getReleaseDate() {
73 return manufNameDescVersRelease.get().getE();
74 }
75
76 private static Quintet<String, String, String, String, String> queryEfi() {
77 String manufacturer = null;
78 String name = null;
79 String description = null;
80 String version = null;
81 String releaseDate = null;
82
83 IORegistryEntry platformExpert = IOKitUtil.getMatchingService("IOPlatformExpertDevice");
84 byte[] data;
85 if (platformExpert != null) {
86 IOIterator iter = platformExpert.getChildIterator("IODeviceTree");
87 if (iter != null) {
88 IORegistryEntry entry = iter.next();
89 while (entry != null) {
90 switch (entry.getName()) {
91 case "rom":
92 data = entry.getByteArrayProperty("vendor");
93 if (data != null) {
94 manufacturer = Native.toString(data, StandardCharsets.UTF_8);
95 }
96 data = entry.getByteArrayProperty("version");
97 if (data != null) {
98 version = Native.toString(data, StandardCharsets.UTF_8);
99 }
100 data = entry.getByteArrayProperty("release-date");
101 if (data != null) {
102 releaseDate = Native.toString(data, StandardCharsets.UTF_8);

Callers

nothing calls this directly

Calls 1

memoizeMethod · 0.80

Tested by

no test coverage detected