try catch на получение HWID

This commit is contained in:
Gravit 2018-12-29 17:33:59 +07:00
parent 9af4145ab7
commit 22763f3439
No known key found for this signature in database
GPG key ID: 061981E1E85D3216

View file

@ -8,7 +8,19 @@
import ru.gravit.utils.helper.LogHelper;
public class OshiHWIDProvider implements LauncherHWIDInterface {
public static SystemInfo systemInfo = new SystemInfo();
public SystemInfo systemInfo;
public boolean noHWID;
public OshiHWIDProvider()
{
try {
systemInfo = new SystemInfo();
noHWID = false;
} catch(Throwable e)
{
LogHelper.error(e);
noHWID = true;
}
}
public String getSerial() {
try {
@ -48,14 +60,18 @@ public String getHWDisk() {
}
public long getTotalMemory() {
if(noHWID) return -1;
return systemInfo.getHardware().getMemory().getTotal();
}
public long getAvailableMemory() {
if(noHWID) return -1;
return systemInfo.getHardware().getMemory().getAvailable();
}
public void printHardwareInformation() {
try
{
HardwareAbstractionLayer hardware = systemInfo.getHardware();
ComputerSystem computerSystem = hardware.getComputerSystem();
LogHelper.debug("ComputerSystem Model: %s Serial: %s", computerSystem.getModel(), computerSystem.getSerialNumber());
@ -67,6 +83,11 @@ public void printHardwareInformation() {
}
CentralProcessor processor = hardware.getProcessor();
LogHelper.debug("Processor Model: %s ID: %s", processor.getModel(), processor.getProcessorID());
} catch (Throwable e)
{
LogHelper.error(e);
}
}
@Override