Skip to content

Commit 8e0dd7d

Browse files
author
shuaijie
committed
feat: Dconfig适配900机型
Dconfig适配某机型 Log: Dconfig适配某机型 Task: https://pms.uniontech.com/task-view-359661.html
1 parent d5b730e commit 8e0dd7d

14 files changed

Lines changed: 121 additions & 67 deletions

deepin-devicemanager/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ foreach(dir ${dirs})
9797
endforeach()
9898
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/docx)
9999
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/QtXlsxWriter/include/QtXlsx)
100+
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/ediddecode)
100101

101102
#add cups and zmq
102103
include_directories("/usr/include/cups/")

deepin-devicemanager/assets/org.deepin.devicemanager.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"flags": ["global"],
2222
"name": "Special Computer Type",
2323
"name[zh_CN]": "特殊机器类型",
24-
"description": "special computer type:PGUW(value:1),KLVV/L540(value:2),KLVU(value:3),PGUV/W585(value:4),PGUX(value:5)",
24+
"description": "special computer type:PGUW(value:1),KLVV/L540(value:2),KLVU(value:3),PGUV/W585(value:4),PGUX(value:5),M900(value:6)",
2525
"permissions": "readwrite",
2626
"visibility": "private"
2727
}

deepin-devicemanager/src/DeviceManager/DeviceAudio.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ void DeviceAudio::loadBaseDeviceInfo()
327327
// 添加基本信息
328328
addBaseDeviceInfo(tr("Name"), m_Name);
329329
addBaseDeviceInfo(tr("Vendor"), m_Vendor);
330+
addBaseDeviceInfo(tr("Module Alias"), m_Modalias);
330331
addBaseDeviceInfo(tr("SysFS_Path"), m_SysPath);
331332
addBaseDeviceInfo(tr("Description"), m_Description);
332333
addBaseDeviceInfo(tr("Revision"), m_Version);

deepin-devicemanager/src/DeviceManager/DeviceBluetooth.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ void DeviceBluetooth::setInfoFromHciconfig(const QMap<QString, QString> &mapInfo
3333
// 获取设备的基本信息
3434
setAttribute(mapInfo, "Name", m_Name);
3535
setAttribute(mapInfo, "Manufacturer", m_Vendor);
36+
setAttribute(mapInfo, "Modalias", m_Modalias);
3637

3738
// 获取设备其他信息
3839
getOtherMapInfo(mapInfo);

deepin-devicemanager/src/DeviceManager/DeviceMonitor.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ void DeviceMonitor::setInfoFromEdid(const QMap<QString, QString> &mapInfo)
164164
setAttribute(mapInfo, "Date", m_ProductionWeek);
165165
setAttribute(mapInfo, "Display Input", m_DisplayInput);
166166
setAttribute(mapInfo, "Model", m_Model);
167+
if(m_Model.isEmpty()) m_Model = m_Name ;
167168
getOtherMapInfo(mapInfo);
168169
}
169170

deepin-devicemanager/src/DeviceManager/DeviceNetwork.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ void DeviceNetwork::setInfoFromLshw(const QMap<QString, QString> &mapInfo)
4848
{
4949
if (!matchToLshw(mapInfo)
5050
&& Common::boardVendorType() != "KLVV" && Common::boardVendorType() != "KLVU"
51-
&& Common::boardVendorType() != "PGUW" && Common::boardVendorType() != "PGUV") {
51+
&& Common::boardVendorType() != "PGUW" && Common::boardVendorType() != "PGUV"
52+
&& Common::boardVendorType() != "M900") {
5253
return;
5354
}
5455
// 设置由lshw获取的信息

deepin-devicemanager/src/GenerateDevice/DeviceFactory.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "KLUGenerator.h"
1111
#include "PanguGenerator.h"
1212
#include "PanguVGenerator.h"
13+
#include "M900Generator.h"
1314
#include "HWGenerator.h"
1415
#include "KLVGenerator.h"
1516
#include "commonfunction.h"
@@ -42,6 +43,8 @@ DeviceGenerator *DeviceFactory::getDeviceGenerator()
4243
generator = new KLVGenerator();
4344
else if (type == "PGUV" || type == "PGUW")
4445
generator = new PanguVGenerator();
46+
else if (type == "M900")
47+
generator = new M900Generator();
4548
else if (type == "KLVU")
4649
generator = new KLUGenerator();
4750
else if (type == "PGUX")

deepin-devicemanager/src/GenerateDevice/DeviceGenerator.cpp

Lines changed: 2 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "DeviceManager/DevicePrint.h"
2626
#include "DeviceManager/DeviceInput.h"
2727
#include "MacroDefinition.h"
28+
#include "commontools.h"
2829

2930
// Dtk头文件
3031
#include <DSysInfo>
@@ -86,58 +87,6 @@ void DeviceGenerator::generatorComputerDevice()
8687
DeviceManager::instance()->addComputerDevice(device);
8788
}
8889

89-
void mergeSortCpuInfoByLogicalID(QList<QMap<QString, QString> > &lsCpu, QList<QMap<QString, QString> > &tmpLst, int begin, int end)
90-
{
91-
// 合并列表
92-
int left_length = (end - begin + 1) / 2;
93-
int left_index = begin;
94-
int right_index = begin + left_length;
95-
int result_index = begin;
96-
97-
// 合并左右区间 左区间未合并结束且右区间未合并结束时
98-
while (left_index < begin + left_length && right_index < end + 1) {
99-
// 左右区间,哪个小先排哪个,下标加1
100-
if (lsCpu[left_index]["processor"].toInt() <= lsCpu[right_index]["processor"].toInt())
101-
tmpLst[result_index++] = lsCpu[left_index++];
102-
else
103-
tmpLst[result_index++] = lsCpu[right_index++];
104-
}
105-
106-
// 合并左区间剩余数据
107-
while (left_index < begin + left_length)
108-
tmpLst[result_index++] = lsCpu[left_index++];
109-
110-
// 合并右区间剩余数据
111-
while (right_index < end + 1)
112-
tmpLst[result_index++] = lsCpu[right_index++];
113-
}
114-
115-
void sortCpuInfoByLogicalID(QList<QMap<QString, QString> > &lsCpu, QList<QMap<QString, QString> > &tmpLst, int begin, int end)
116-
{
117-
// 列表个数为1,直接返回
118-
if (0 == end - begin)
119-
return;
120-
121-
// bug 后台获取CPU信息是按照物理CPU,核心,逻辑CPU顺序获取的
122-
// 界面上展示顺序混乱实际是按照物理CPU,核心,逻辑CPU顺序展示
123-
// 与产品沟通后,按照用户的使用感修改,CPU信息按照逻辑CPU的id从小到大显示
124-
// 区间个数为2
125-
if (1 == end - begin) {
126-
// 前 processor > 后 processor 时交换位置
127-
if (lsCpu[begin]["processor"].toInt() > lsCpu[end]["processor"].toInt()) {
128-
QMap<QString, QString> tmpMap = lsCpu[begin];
129-
lsCpu[begin] = lsCpu[end];
130-
lsCpu[end] = tmpMap;
131-
}
132-
} else {
133-
// 区间个数 > 2 递归
134-
sortCpuInfoByLogicalID(lsCpu, tmpLst, begin, (end - begin) / 2 + begin);
135-
sortCpuInfoByLogicalID(lsCpu, tmpLst, (end - begin + 1) / 2 + begin, end);
136-
mergeSortCpuInfoByLogicalID(lsCpu, tmpLst, begin, end);
137-
lsCpu = tmpLst;
138-
}
139-
}
140-
14190
void DeviceGenerator::generatorCpuDevice()
14291
{
14392
// 生成CPU
@@ -150,7 +99,7 @@ void DeviceGenerator::generatorCpuDevice()
15099

151100
// 按照processor id 从小到大排序
152101
if (lsCpu.size() > 1)
153-
sortCpuInfoByLogicalID(srcLst, tmpLst, 0, lsCpu.size() - 1);
102+
CommonTools::sortCpuInfoByLogicalID(srcLst, tmpLst, 0, lsCpu.size() - 1);
154103

155104
// get info from lshw
156105
const QList<QMap<QString, QString> > &lshwCpu = DeviceManager::instance()->cmdInfo("lshw_cpu");

deepin-devicemanager/src/GenerateDevice/HWGenerator.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "DeviceManager/DeviceBluetooth.h"
2727
#include "DeviceManager/DeviceNetwork.h"
2828
#include "DeviceManager/DeviceMemory.h"
29+
#include "commonfunction.h"
2930

3031
HWGenerator::HWGenerator()
3132
{
@@ -115,7 +116,9 @@ void HWGenerator::generatorGpuDevice()
115116
QStringList items = deviceInfo.split("\n");
116117

117118
QMap<QString, QString> mapInfo;
118-
for (QString itemStr : items) {
119+
if(Common::boardVendorType() == "M900")
120+
mapInfo.insert("Name", "PANGU M900");
121+
else for (QString itemStr : items) {
119122
if (itemStr.contains(":"))
120123
continue;
121124
QString curItemStr = itemStr.trimmed();
@@ -266,6 +269,17 @@ void HWGenerator::getDiskInfoFromLshw()
266269

267270
DeviceManager::instance()->addLshwinfoIntoStorageDevice(tempMap);
268271
}
272+
// lshw -C storage
273+
if(Common::boardVendorType() != "M900")
274+
return;
275+
const QList<QMap<QString, QString>> &lstStorage = DeviceManager::instance()->cmdInfo("lshw_storage");
276+
QList<QMap<QString, QString> >::const_iterator sIt = lstStorage.begin();
277+
for (; sIt != lstStorage.end(); ++sIt) {
278+
if ((*sIt).size() < 2)
279+
continue;
280+
281+
DeviceManager::instance()->addLshwinfoIntoNVMEStorageDevice(*sIt);
282+
}
269283
}
270284

271285
void HWGenerator::getDiskInfoFromSmartCtl()

deepin-devicemanager/src/GenerateDevice/PanguVGenerator.cpp

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
#include "EDIDParser.h"
1212
#include "DeviceManager/DeviceNetwork.h"
1313
#include <QProcess>
14+
#include <QDir>
15+
#include <QFileInfoList>
1416

1517
PanguVGenerator::PanguVGenerator()
1618
{
@@ -49,6 +51,7 @@ void parseEDID(QStringList allEDIDS,QString input)
4951

5052
QMap<QString, QString> mapInfo;
5153
mapInfo.insert("Vendor",edidParser.vendor());
54+
mapInfo.insert("Model",edidParser.model());
5255
mapInfo.insert("Date",edidParser.releaseDate());
5356
mapInfo.insert("Size",edidParser.screenSize());
5457
mapInfo.insert("Display Input",input);
@@ -62,15 +65,24 @@ void parseEDID(QStringList allEDIDS,QString input)
6265

6366
void PanguVGenerator::generatorMonitorDevice()
6467
{
65-
QStringList allEDIDS1;
66-
allEDIDS1.append("/sys/devices/platform/hisi-drm/drm/card0/card0-HDMI-A-1/edid");
67-
allEDIDS1.append("/sys/devices/platform/hldrm/drm/card0/card0-HDMI-A-1/edid");
68-
parseEDID(allEDIDS1,"HDMI-A-1");
69-
70-
QStringList allEDIDS2;
71-
allEDIDS2.append("/sys/devices/platform/hisi-drm/drm/card0/card0-VGA-1/edid");
72-
allEDIDS2.append("/sys/devices/platform/hldrm/drm/card0/card0-VGA-1/edid");
73-
parseEDID(allEDIDS2,"VGA-1");
68+
QString toDir = "/sys/class/drm";
69+
QDir toDir_(toDir);
70+
71+
if (!toDir_.exists())
72+
return;
73+
74+
QFileInfoList fileInfoList = toDir_.entryInfoList();
75+
foreach(QFileInfo fileInfo, fileInfoList) {
76+
if(fileInfo.fileName() == "." || fileInfo.fileName() == ".." || !fileInfo.fileName().startsWith("card"))
77+
continue;
78+
79+
if(QFile::exists(fileInfo.filePath() + "/" + "edid")) {
80+
QStringList allEDIDS_all;
81+
allEDIDS_all.append(fileInfo.filePath() + "/" + "edid");
82+
QString interface = fileInfo.fileName().remove("card0-").remove("card1-").remove("card2-");
83+
parseEDID(allEDIDS_all,interface);
84+
}
85+
}
7486
}
7587

7688
void PanguVGenerator::generatorNetworkDevice()

0 commit comments

Comments
 (0)