From adb726139fb5a9d46400877bf26dad5482e3c36e Mon Sep 17 00:00:00 2001 From: zhanghongyuan Date: Fri, 10 Oct 2025 10:16:37 +0800 Subject: [PATCH] fix: Simplify UFS interface version detection Replaced detailed UFS version parsing (3.0/3.1/4.0) with generic "UFS" identifier when output is non-empty, streamlining interface detection logic. Log: Streamline UFS interface detection Task: https://pms.uniontech.com/task-view-382541.html Change-Id: Ia1a80391d0291e3de69723630ae17029fadd2eb1 --- .../src/DeviceManager/DeviceStorage.cpp | 8 ++------ .../src/GenerateDevice/HWGenerator.cpp | 10 +++++----- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/deepin-devicemanager/src/DeviceManager/DeviceStorage.cpp b/deepin-devicemanager/src/DeviceManager/DeviceStorage.cpp index dfd91d3f..c35579c5 100644 --- a/deepin-devicemanager/src/DeviceManager/DeviceStorage.cpp +++ b/deepin-devicemanager/src/DeviceManager/DeviceStorage.cpp @@ -213,12 +213,8 @@ bool DeviceStorage::setHwinfoInfo(const QMap &mapInfo) QFile file(Path); if (file.open(QIODevice::ReadOnly)) { QString output = file.readAll(); - if (output.contains("310", Qt::CaseInsensitive)) { - m_Interface = "UFS 3.1"; - } else if (output.contains("300", Qt::CaseInsensitive)) { - m_Interface = "UFS 3.0"; - } else if (output.contains("400", Qt::CaseInsensitive)) { - m_Interface = "UFS 4.0"; + if (!output.isEmpty()) { + m_Interface = "UFS"; } file.close(); } diff --git a/deepin-devicemanager/src/GenerateDevice/HWGenerator.cpp b/deepin-devicemanager/src/GenerateDevice/HWGenerator.cpp index 79267176..d03cda59 100644 --- a/deepin-devicemanager/src/GenerateDevice/HWGenerator.cpp +++ b/deepin-devicemanager/src/GenerateDevice/HWGenerator.cpp @@ -281,7 +281,7 @@ void HWGenerator::generatorDiskDevice() tempMap["Name"] = "nouse"; if (Common::specialComType == 2) { - tempMap["Interface"] = "UFS 3.1"; + tempMap["Interface"] = "UFS"; } // 读取interface版本 @@ -297,10 +297,10 @@ void HWGenerator::generatorDiskDevice() exitCode = process.exitCode(); if (exitCode != 127 && exitCode != 126) { deviceInfo = process.readAllStandardOutput(); - if (deviceInfo.trimmed() == "310") { - tempMap["interface"] = "UFS 3.1"; - } else if (deviceInfo.trimmed() == "300") - tempMap["interface"] = "UFS 3.0"; + + if (!deviceInfo.trimmed().isEmpty()) { + tempMap["interface"] = "UFS"; + } } } }