Кеширование HardwareAbstractionLayer

This commit is contained in:
Gravit 2018-12-29 17:39:04 +07:00
parent 22763f3439
commit 49c53d4b35
No known key found for this signature in database
GPG key ID: 061981E1E85D3216

View file

@ -9,6 +9,7 @@
public class OshiHWIDProvider implements LauncherHWIDInterface {
public SystemInfo systemInfo;
public HardwareAbstractionLayer hardware;
public boolean noHWID;
public OshiHWIDProvider()
{
@ -24,7 +25,8 @@ public OshiHWIDProvider()
public String getSerial() {
try {
return systemInfo.getHardware().getComputerSystem().getSerialNumber();
if(hardware == null) hardware = systemInfo.getHardware();
return hardware.getComputerSystem().getSerialNumber();
} catch (Exception e) {
LogHelper.error(e);
return "";
@ -34,7 +36,8 @@ public String getSerial() {
public String getProcessorID() {
try {
return systemInfo.getHardware().getProcessor().getProcessorID();
if(hardware == null) hardware = systemInfo.getHardware();
return hardware.getProcessor().getProcessorID();
} catch (Exception e) {
LogHelper.error(e);
return "";
@ -44,9 +47,10 @@ public String getProcessorID() {
public String getHWDisk() {
try {
if(hardware == null) hardware = systemInfo.getHardware();
HWDiskStore store = null;
long size = 0;
for (HWDiskStore s : systemInfo.getHardware().getDiskStores()) {
for (HWDiskStore s : hardware.getDiskStores()) {
if (size < s.getSize()) {
store = s;
size = s.getSize();
@ -61,24 +65,26 @@ public String getHWDisk() {
public long getTotalMemory() {
if(noHWID) return -1;
return systemInfo.getHardware().getMemory().getTotal();
if(hardware == null) hardware = systemInfo.getHardware();
return hardware.getMemory().getTotal();
}
public long getAvailableMemory() {
if(noHWID) return -1;
return systemInfo.getHardware().getMemory().getAvailable();
if(hardware == null) hardware = systemInfo.getHardware();
return hardware.getMemory().getAvailable();
}
public void printHardwareInformation() {
try
{
HardwareAbstractionLayer hardware = systemInfo.getHardware();
if(hardware == null) hardware = systemInfo.getHardware();
ComputerSystem computerSystem = hardware.getComputerSystem();
LogHelper.debug("ComputerSystem Model: %s Serial: %s", computerSystem.getModel(), computerSystem.getSerialNumber());
for (HWDiskStore s : systemInfo.getHardware().getDiskStores()) {
for (HWDiskStore s : hardware.getDiskStores()) {
LogHelper.debug("HWDiskStore Serial: %s Model: %s Size: %d", s.getSerial(), s.getModel(), s.getSize());
}
for (UsbDevice s : systemInfo.getHardware().getUsbDevices(true)) {
for (UsbDevice s : hardware.getUsbDevices(true)) {
LogHelper.debug("USBDevice Serial: %s Name: %s", s.getSerialNumber(), s.getName());
}
CentralProcessor processor = hardware.getProcessor();