Skip to content

Commit 07d5b39

Browse files
committed
feat: use GPU info to distinguish Apple ARM devices
1 parent 3a6997b commit 07d5b39

1 file changed

Lines changed: 17 additions & 14 deletions

File tree

src/main/java/org/damon233/performtrackermod/collector/SystemInfoCollector.java

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,9 @@ private static DeviceType classifyDevice() {
198198

199199
boolean isArm = osArch.contains("arm") || osArch.contains("aarch64");
200200
if (osName.contains("linux") && isArm) {
201-
return classifyArmDevice(getCpuName());
201+
String cpuName = getCpuName();
202+
String gpuName = getGpuName();
203+
return classifyArmDevice(cpuName, gpuName);
202204
}
203205

204206
if (osName.contains("windows") ||
@@ -209,24 +211,25 @@ private static DeviceType classifyDevice() {
209211
return DeviceType.PC;
210212
}
211213

212-
private static DeviceType classifyArmDevice(String cpuInfo) {
214+
private static DeviceType classifyArmDevice(String cpuInfo, String gpuInfo) {
213215
loadChipRules();
214216

215217
DeviceType result;
216-
if (cpuInfo == null || cpuInfo.equals("Unknown")) {
218+
String upper = cpuInfo != null ? cpuInfo.toUpperCase() : "";
219+
String gpuUpper = gpuInfo != null ? gpuInfo.toUpperCase() : "";
220+
221+
if (upper.contains("APPLE")) {
222+
result = DeviceType.MAC;
223+
} else if (gpuUpper.contains("APPLE")) {
224+
result = DeviceType.PHONE;
225+
} else if (upper.isEmpty() || cpuInfo == null || cpuInfo.equals("Unknown")) {
217226
result = DeviceType.EMB;
227+
} else if (matchesAnyChip(upper, phoneChips)) {
228+
result = DeviceType.PHONE;
229+
} else if (matchesAnyChip(upper, serverChips)) {
230+
result = DeviceType.PC;
218231
} else {
219-
String upper = cpuInfo.toUpperCase();
220-
221-
if (upper.contains("APPLE")) {
222-
result = DeviceType.MAC;
223-
} else if (matchesAnyChip(upper, phoneChips)) {
224-
result = DeviceType.PHONE;
225-
} else if (matchesAnyChip(upper, serverChips)) {
226-
result = DeviceType.PC;
227-
} else {
228-
result = DeviceType.EMB;
229-
}
232+
result = DeviceType.EMB;
230233
}
231234

232235
releaseChipRules();

0 commit comments

Comments
 (0)