1
2
3
4
5 package oshi.hardware.platform.windows;
6
7 import static oshi.util.Memoizer.memoize;
8
9 import java.util.function.Supplier;
10
11 import com.sun.jna.platform.win32.COM.WbemcliUtil.WmiResult;
12
13 import oshi.annotation.concurrent.Immutable;
14 import oshi.driver.windows.wmi.Win32Bios;
15 import oshi.driver.windows.wmi.Win32Bios.BiosProperty;
16 import oshi.hardware.common.AbstractFirmware;
17 import oshi.util.Constants;
18 import oshi.util.Util;
19 import oshi.util.platform.windows.WmiUtil;
20 import oshi.util.tuples.Quintet;
21
22
23
24
25 @Immutable
26 final class WindowsFirmware extends AbstractFirmware {
27
28 private final Supplier<Quintet<String, String, String, String, String>> manufNameDescVersRelease = memoize(
29 WindowsFirmware::queryManufNameDescVersRelease);
30
31 @Override
32 public String getManufacturer() {
33 return manufNameDescVersRelease.get().getA();
34 }
35
36 @Override
37 public String getName() {
38 return manufNameDescVersRelease.get().getB();
39 }
40
41 @Override
42 public String getDescription() {
43 return manufNameDescVersRelease.get().getC();
44 }
45
46 @Override
47 public String getVersion() {
48 return manufNameDescVersRelease.get().getD();
49 }
50
51 @Override
52 public String getReleaseDate() {
53 return manufNameDescVersRelease.get().getE();
54 }
55
56 private static Quintet<String, String, String, String, String> queryManufNameDescVersRelease() {
57 String manufacturer = null;
58 String name = null;
59 String description = null;
60 String version = null;
61 String releaseDate = null;
62 WmiResult<BiosProperty> win32BIOS = Win32Bios.queryBiosInfo();
63 if (win32BIOS.getResultCount() > 0) {
64 manufacturer = WmiUtil.getString(win32BIOS, BiosProperty.MANUFACTURER, 0);
65 name = WmiUtil.getString(win32BIOS, BiosProperty.NAME, 0);
66 description = WmiUtil.getString(win32BIOS, BiosProperty.DESCRIPTION, 0);
67 version = WmiUtil.getString(win32BIOS, BiosProperty.VERSION, 0);
68 releaseDate = WmiUtil.getDateString(win32BIOS, BiosProperty.RELEASEDATE, 0);
69 }
70 return new Quintet<>(Util.isBlank(manufacturer) ? Constants.UNKNOWN : manufacturer,
71 Util.isBlank(name) ? Constants.UNKNOWN : name,
72 Util.isBlank(description) ? Constants.UNKNOWN : description,
73 Util.isBlank(version) ? Constants.UNKNOWN : version,
74 Util.isBlank(releaseDate) ? Constants.UNKNOWN : releaseDate);
75 }
76 }