mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 11:39:11 +03:00
Кеширование HardwareAbstractionLayer
This commit is contained in:
parent
22763f3439
commit
49c53d4b35
1 changed files with 14 additions and 8 deletions
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
public class OshiHWIDProvider implements LauncherHWIDInterface {
|
public class OshiHWIDProvider implements LauncherHWIDInterface {
|
||||||
public SystemInfo systemInfo;
|
public SystemInfo systemInfo;
|
||||||
|
public HardwareAbstractionLayer hardware;
|
||||||
public boolean noHWID;
|
public boolean noHWID;
|
||||||
public OshiHWIDProvider()
|
public OshiHWIDProvider()
|
||||||
{
|
{
|
||||||
|
@ -24,7 +25,8 @@ public OshiHWIDProvider()
|
||||||
|
|
||||||
public String getSerial() {
|
public String getSerial() {
|
||||||
try {
|
try {
|
||||||
return systemInfo.getHardware().getComputerSystem().getSerialNumber();
|
if(hardware == null) hardware = systemInfo.getHardware();
|
||||||
|
return hardware.getComputerSystem().getSerialNumber();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LogHelper.error(e);
|
LogHelper.error(e);
|
||||||
return "";
|
return "";
|
||||||
|
@ -34,7 +36,8 @@ public String getSerial() {
|
||||||
|
|
||||||
public String getProcessorID() {
|
public String getProcessorID() {
|
||||||
try {
|
try {
|
||||||
return systemInfo.getHardware().getProcessor().getProcessorID();
|
if(hardware == null) hardware = systemInfo.getHardware();
|
||||||
|
return hardware.getProcessor().getProcessorID();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LogHelper.error(e);
|
LogHelper.error(e);
|
||||||
return "";
|
return "";
|
||||||
|
@ -44,9 +47,10 @@ public String getProcessorID() {
|
||||||
|
|
||||||
public String getHWDisk() {
|
public String getHWDisk() {
|
||||||
try {
|
try {
|
||||||
|
if(hardware == null) hardware = systemInfo.getHardware();
|
||||||
HWDiskStore store = null;
|
HWDiskStore store = null;
|
||||||
long size = 0;
|
long size = 0;
|
||||||
for (HWDiskStore s : systemInfo.getHardware().getDiskStores()) {
|
for (HWDiskStore s : hardware.getDiskStores()) {
|
||||||
if (size < s.getSize()) {
|
if (size < s.getSize()) {
|
||||||
store = s;
|
store = s;
|
||||||
size = s.getSize();
|
size = s.getSize();
|
||||||
|
@ -61,24 +65,26 @@ public String getHWDisk() {
|
||||||
|
|
||||||
public long getTotalMemory() {
|
public long getTotalMemory() {
|
||||||
if(noHWID) return -1;
|
if(noHWID) return -1;
|
||||||
return systemInfo.getHardware().getMemory().getTotal();
|
if(hardware == null) hardware = systemInfo.getHardware();
|
||||||
|
return hardware.getMemory().getTotal();
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getAvailableMemory() {
|
public long getAvailableMemory() {
|
||||||
if(noHWID) return -1;
|
if(noHWID) return -1;
|
||||||
return systemInfo.getHardware().getMemory().getAvailable();
|
if(hardware == null) hardware = systemInfo.getHardware();
|
||||||
|
return hardware.getMemory().getAvailable();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void printHardwareInformation() {
|
public void printHardwareInformation() {
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
HardwareAbstractionLayer hardware = systemInfo.getHardware();
|
if(hardware == null) hardware = systemInfo.getHardware();
|
||||||
ComputerSystem computerSystem = hardware.getComputerSystem();
|
ComputerSystem computerSystem = hardware.getComputerSystem();
|
||||||
LogHelper.debug("ComputerSystem Model: %s Serial: %s", computerSystem.getModel(), computerSystem.getSerialNumber());
|
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());
|
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());
|
LogHelper.debug("USBDevice Serial: %s Name: %s", s.getSerialNumber(), s.getName());
|
||||||
}
|
}
|
||||||
CentralProcessor processor = hardware.getProcessor();
|
CentralProcessor processor = hardware.getProcessor();
|
||||||
|
|
Loading…
Reference in a new issue