[FEATURE] Support GraphicCard info

This commit is contained in:
Gravita 2021-03-19 23:23:21 +07:00
parent b545c099eb
commit bbdfc204e7
2 changed files with 36 additions and 4 deletions

View file

@ -43,6 +43,11 @@ public void invoke(String... args) throws Exception {
String baseboardSerial = provider.getBaseboardSerialNumber(); String baseboardSerial = provider.getBaseboardSerialNumber();
currentTime = System.currentTimeMillis(); currentTime = System.currentTimeMillis();
LogHelper.info("BaseboardSerial %s, TIME: %d ms", baseboardSerial, currentTime - startTime); LogHelper.info("BaseboardSerial %s, TIME: %d ms", baseboardSerial, currentTime - startTime);
startTime = System.currentTimeMillis();
String graphicCardName = provider.getGraphicCardName();
long graphicCardVRam = provider.getGraphicCardMemory();
currentTime = System.currentTimeMillis();
LogHelper.info("GraphicCard %s (%.3f vram), TIME: %d ms", graphicCardName, (double) graphicCardVRam, currentTime - startTime);
LogHelper.info("Hardware ID end"); LogHelper.info("Hardware ID end");
} }
} }

View file

@ -1,10 +1,7 @@
package pro.gravit.launcher.utils; package pro.gravit.launcher.utils;
import oshi.SystemInfo; import oshi.SystemInfo;
import oshi.hardware.Display; import oshi.hardware.*;
import oshi.hardware.HWDiskStore;
import oshi.hardware.HardwareAbstractionLayer;
import oshi.hardware.PowerSource;
import oshi.software.os.OperatingSystem; import oshi.software.os.OperatingSystem;
import pro.gravit.launcher.request.secure.HardwareReportRequest; import pro.gravit.launcher.request.secure.HardwareReportRequest;
@ -64,6 +61,36 @@ public String getHWDiskID() {
return null; return null;
} }
public GraphicsCard getGraphicCard() {
List<GraphicsCard> graphicsCards = hardware.getGraphicsCards();
GraphicsCard result = null;
long size = 0;
for(GraphicsCard card : graphicsCards) {
long vram = card.getVRam();
if(vram > size) {
result = card;
size = vram;
}
}
return result;
}
public String getGraphicCardName() {
GraphicsCard card = getGraphicCard();
if(card == null) {
return null;
}
return card.getName();
}
public long getGraphicCardMemory() {
GraphicsCard card = getGraphicCard();
if(card == null) {
return 0;
}
return card.getVRam();
}
public byte[] getDisplayID() { public byte[] getDisplayID() {
List<Display> displays = hardware.getDisplays(); List<Display> displays = hardware.getDisplays();
if (displays == null || displays.size() == 0) return null; if (displays == null || displays.size() == 0) return null;