mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 11:39:11 +03:00
try catch на получение HWID
This commit is contained in:
parent
9af4145ab7
commit
22763f3439
1 changed files with 32 additions and 11 deletions
|
@ -8,7 +8,19 @@
|
||||||
import ru.gravit.utils.helper.LogHelper;
|
import ru.gravit.utils.helper.LogHelper;
|
||||||
|
|
||||||
public class OshiHWIDProvider implements LauncherHWIDInterface {
|
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() {
|
public String getSerial() {
|
||||||
try {
|
try {
|
||||||
|
@ -48,25 +60,34 @@ public String getHWDisk() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getTotalMemory() {
|
public long getTotalMemory() {
|
||||||
|
if(noHWID) return -1;
|
||||||
return systemInfo.getHardware().getMemory().getTotal();
|
return systemInfo.getHardware().getMemory().getTotal();
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getAvailableMemory() {
|
public long getAvailableMemory() {
|
||||||
|
if(noHWID) return -1;
|
||||||
return systemInfo.getHardware().getMemory().getAvailable();
|
return systemInfo.getHardware().getMemory().getAvailable();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void printHardwareInformation() {
|
public void printHardwareInformation() {
|
||||||
HardwareAbstractionLayer hardware = systemInfo.getHardware();
|
try
|
||||||
ComputerSystem computerSystem = hardware.getComputerSystem();
|
{
|
||||||
LogHelper.debug("ComputerSystem Model: %s Serial: %s", computerSystem.getModel(), computerSystem.getSerialNumber());
|
HardwareAbstractionLayer hardware = systemInfo.getHardware();
|
||||||
for (HWDiskStore s : systemInfo.getHardware().getDiskStores()) {
|
ComputerSystem computerSystem = hardware.getComputerSystem();
|
||||||
LogHelper.debug("HWDiskStore Serial: %s Model: %s Size: %d", s.getSerial(), s.getModel(), s.getSize());
|
LogHelper.debug("ComputerSystem Model: %s Serial: %s", computerSystem.getModel(), computerSystem.getSerialNumber());
|
||||||
|
for (HWDiskStore s : systemInfo.getHardware().getDiskStores()) {
|
||||||
|
LogHelper.debug("HWDiskStore Serial: %s Model: %s Size: %d", s.getSerial(), s.getModel(), s.getSize());
|
||||||
|
}
|
||||||
|
for (UsbDevice s : systemInfo.getHardware().getUsbDevices(true)) {
|
||||||
|
LogHelper.debug("USBDevice Serial: %s Name: %s", s.getSerialNumber(), s.getName());
|
||||||
|
}
|
||||||
|
CentralProcessor processor = hardware.getProcessor();
|
||||||
|
LogHelper.debug("Processor Model: %s ID: %s", processor.getModel(), processor.getProcessorID());
|
||||||
|
} catch (Throwable e)
|
||||||
|
{
|
||||||
|
LogHelper.error(e);
|
||||||
}
|
}
|
||||||
for (UsbDevice s : systemInfo.getHardware().getUsbDevices(true)) {
|
|
||||||
LogHelper.debug("USBDevice Serial: %s Name: %s", s.getSerialNumber(), s.getName());
|
|
||||||
}
|
|
||||||
CentralProcessor processor = hardware.getProcessor();
|
|
||||||
LogHelper.debug("Processor Model: %s ID: %s", processor.getModel(), processor.getProcessorID());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue