mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-10 12:26:16 -04:00
清理高通骁龙 SoC 名称 (#3935)
This commit is contained in:
parent
58a4700a46
commit
ad312a61fe
@ -20,6 +20,9 @@ package org.jackhuang.hmcl.util.platform.hardware;
|
|||||||
import org.jackhuang.hmcl.util.StringUtils;
|
import org.jackhuang.hmcl.util.StringUtils;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Glavo
|
* @author Glavo
|
||||||
*/
|
*/
|
||||||
@ -35,14 +38,13 @@ public final class CentralProcessor {
|
|||||||
|
|
||||||
name = name.replaceFirst(" (\\d+|Dual|Quad|Six|Eight|Ten)-[Cc]ores?", "");
|
name = name.replaceFirst(" (\\d+|Dual|Quad|Six|Eight|Ten)-[Cc]ores?", "");
|
||||||
name = name.replaceAll(" (CPU|FPU|APU|Processor)", "");
|
name = name.replaceAll(" (CPU|FPU|APU|Processor)", "");
|
||||||
|
name = name.replaceAll("\\((TM|R)\\)(?=\\s|$)", "");
|
||||||
|
|
||||||
if (name.contains("Intel")) {
|
if (name.contains("Intel")) {
|
||||||
name = name.replaceFirst("^(\\d+th Gen )?Intel(\\(R\\)|®)? ", "Intel ");
|
name = name.replaceFirst("^(\\d+th Gen )?Intel\\s+", "Intel ");
|
||||||
name = name.replaceAll(" ([a-zA-Z]+)\\((?:TM|R|™|®)\\) ", " $1 ");
|
|
||||||
name = name.replace("Core(TM)2", "Core 2");
|
name = name.replace("Core(TM)2", "Core 2");
|
||||||
} else if (name.contains("AMD")) {
|
} else if (name.contains("AMD")) {
|
||||||
name = name.replace("(tm)", "");
|
name = name.replace("(tm)", "");
|
||||||
|
|
||||||
idx = name.indexOf(" w/ Radeon "); // Radeon 780M Graphics
|
idx = name.indexOf(" w/ Radeon "); // Radeon 780M Graphics
|
||||||
if (idx < 0)
|
if (idx < 0)
|
||||||
idx = name.indexOf(" with Radeon ");
|
idx = name.indexOf(" with Radeon ");
|
||||||
@ -52,6 +54,17 @@ public final class CentralProcessor {
|
|||||||
name = name.substring(0, idx);
|
name = name.substring(0, idx);
|
||||||
} else if (name.contains("Loongson")) {
|
} else if (name.contains("Loongson")) {
|
||||||
name = name.replaceFirst("^Loongson-3A R\\d \\((Loongson-[^)]+)\\)", "$1");
|
name = name.replaceFirst("^Loongson-3A R\\d \\((Loongson-[^)]+)\\)", "$1");
|
||||||
|
} else if (name.contains("Snapdragon")) {
|
||||||
|
name = StringUtils.normalizeWhitespaces(name);
|
||||||
|
|
||||||
|
if (name.startsWith("Snapdragon ")) {
|
||||||
|
Matcher matcher = Pattern.compile("Snapdragon X Elite - (?<id>X1E\\S+) - Qualcomm Oryon").matcher(name);
|
||||||
|
if (matcher.matches()) {
|
||||||
|
name = "Qualcomm Snapdragon X Elite " + matcher.group("id");
|
||||||
|
} else if (!name.contains("Qualcomm")) {
|
||||||
|
name = "Qualcomm " + name;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return StringUtils.normalizeWhitespaces(name);
|
return StringUtils.normalizeWhitespaces(name);
|
||||||
|
@ -17,15 +17,38 @@
|
|||||||
*/
|
*/
|
||||||
package org.jackhuang.hmcl.util.platform.hardware;
|
package org.jackhuang.hmcl.util.platform.hardware;
|
||||||
|
|
||||||
|
import org.jackhuang.hmcl.util.StringUtils;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Glavo
|
* @author Glavo
|
||||||
*/
|
*/
|
||||||
public final class GraphicsCard {
|
public final class GraphicsCard {
|
||||||
|
|
||||||
|
public static String cleanName(String name) {
|
||||||
|
if (name == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
name = name.replaceAll("\\((TM|R)\\)(?=\\s|$)", "");
|
||||||
|
name = name.replace(" GPU", "");
|
||||||
|
|
||||||
|
if (name.contains("Snapdragon")) {
|
||||||
|
name = StringUtils.normalizeWhitespaces(name);
|
||||||
|
if (name.startsWith("Snapdragon ")) {
|
||||||
|
Matcher matcher = Pattern.compile("Snapdragon X Elite - (?<id>X1E\\S+) - Qualcomm Adreno").matcher(name);
|
||||||
|
if (matcher.matches()) {
|
||||||
|
name = "Qualcomm Adreno Graphics";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return StringUtils.normalizeWhitespaces(name);
|
||||||
|
}
|
||||||
|
|
||||||
public static Builder builder() {
|
public static Builder builder() {
|
||||||
return new Builder();
|
return new Builder();
|
||||||
}
|
}
|
||||||
|
@ -193,7 +193,7 @@ final class LinuxGPUDetector {
|
|||||||
if (device != null) {
|
if (device != null) {
|
||||||
matcher = Pattern.compile(".*\\[(?<name>.*)]").matcher(device.getName());
|
matcher = Pattern.compile(".*\\[(?<name>.*)]").matcher(device.getName());
|
||||||
if (matcher.matches())
|
if (matcher.matches())
|
||||||
builder.setName(builder.getVendor() + " " + matcher.group("name"));
|
builder.setName(GraphicsCard.cleanName(builder.getVendor() + " " + matcher.group("name")));
|
||||||
else
|
else
|
||||||
builder.setName(builder.getVendor() + " " + device.getName());
|
builder.setName(builder.getVendor() + " " + device.getName());
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ public final class WindowsHardwareDetector extends HardwareDetector {
|
|||||||
String adapterDACType = videoController.get("AdapterDACType");
|
String adapterDACType = videoController.get("AdapterDACType");
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(name)) {
|
if (StringUtils.isNotBlank(name)) {
|
||||||
cards.add(GraphicsCard.builder().setName(name)
|
cards.add(GraphicsCard.builder().setName(GraphicsCard.cleanName(name))
|
||||||
.setVendor(HardwareVendor.of(adapterCompatibility))
|
.setVendor(HardwareVendor.of(adapterCompatibility))
|
||||||
.setDriverVersion(driverVersion)
|
.setDriverVersion(driverVersion)
|
||||||
.setType(StringUtils.isBlank(adapterDACType)
|
.setType(StringUtils.isBlank(adapterDACType)
|
||||||
|
@ -54,6 +54,9 @@ public final class CentralProcessorTest {
|
|||||||
assertEquals("AMD Phenom II X6 1055T", cleanName("AMD Phenom(tm) II X6 1055T Processor"));
|
assertEquals("AMD Phenom II X6 1055T", cleanName("AMD Phenom(tm) II X6 1055T Processor"));
|
||||||
assertEquals("AMD Athlon 5350", cleanName("AMD Athlon(tm) 5350 APU with Radeon(tm) R3"));
|
assertEquals("AMD Athlon 5350", cleanName("AMD Athlon(tm) 5350 APU with Radeon(tm) R3"));
|
||||||
|
|
||||||
|
assertEquals("Qualcomm Snapdragon X Elite X1E78100", cleanName("Snapdragon(R) X Elite - X1E78100 - Qualcomm(R) Oryon(TM) CPU"));
|
||||||
|
assertEquals("Qualcomm Snapdragon 850", cleanName("Snapdragon (TM) 850 @ 2.96 GHz"));
|
||||||
|
|
||||||
assertEquals("Hygon C86 7285", cleanName("Hygon C86 7285 32-core Processor"));
|
assertEquals("Hygon C86 7285", cleanName("Hygon C86 7285 32-core Processor"));
|
||||||
assertEquals("Hygon C86 3250", cleanName("Hygon C86 3250 8-core Processor"));
|
assertEquals("Hygon C86 3250", cleanName("Hygon C86 3250 8-core Processor"));
|
||||||
|
|
||||||
@ -64,5 +67,6 @@ public final class CentralProcessorTest {
|
|||||||
|
|
||||||
assertEquals("Loongson-3A3000", cleanName("Loongson-3A R3 (Loongson-3A3000) @ 1400MHz"));
|
assertEquals("Loongson-3A3000", cleanName("Loongson-3A R3 (Loongson-3A3000) @ 1400MHz"));
|
||||||
assertEquals("Loongson-3B4000", cleanName("Loongson-3A R4 (Loongson-3B4000) @ 1800MHz"));
|
assertEquals("Loongson-3B4000", cleanName("Loongson-3A R4 (Loongson-3B4000) @ 1800MHz"));
|
||||||
|
assertEquals("Loongson-3A6000", cleanName("Loongson-3A6000"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* Hello Minecraft! Launcher
|
||||||
|
* Copyright (C) 2025 huangyuhui <huanghongxun2008@126.com> and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.jackhuang.hmcl.util.platform.hardware;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.jackhuang.hmcl.util.platform.hardware.GraphicsCard.cleanName;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Glavo
|
||||||
|
*/
|
||||||
|
public final class GraphicsCardTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCleanName() {
|
||||||
|
assertEquals("Intel UHD Graphics 770", cleanName("Intel(R) UHD Graphics 770"));
|
||||||
|
|
||||||
|
assertEquals("Qualcomm Adreno 630", cleanName("Qualcomm(R) Adreno(TM) 630 GPU"));
|
||||||
|
assertEquals("Qualcomm Adreno Graphics", cleanName("Snapdragon X Elite - X1E78100 - Qualcomm Adreno"));
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user