Skip to content

Commit

Permalink
feat: hw机型判断适配dconfig
Browse files Browse the repository at this point in the history
Description: hw机型判断适配dconfig

Log: hw机型判断适配dconfig

Task: https://pms.uniontech.com/task-view-276433.html
  • Loading branch information
hundundadi committed Jul 6, 2023
1 parent b041de7 commit f0dc74a
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 41 deletions.
26 changes: 26 additions & 0 deletions assets/org.deepin.music.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"magic": "dsg.config.meta",
"version": "1.0",
"contents": {
"specialMuteRecovery": {
"value": 0,
"serial": 0,
"flags": ["global"],
"name": "Special Mute Recovery",
"name[zh_CN]": "特殊静音恢复",
"description": "Silent recovery on some special models, like Huawei",
"permissions": "readwrite",
"visibility": "private"
},
"specialBlockLockScreen": {
"value": 0,
"serial": 0,
"flags": ["global"],
"name": "Special Block Lock Screen",
"name[zh_CN]": "特殊阻止锁屏",
"description": "Block the lock screen on some special models, like m900",
"permissions": "readwrite",
"visibility": "private"
}
}
}
9 changes: 9 additions & 0 deletions src/music-player/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ aux_source_directory(./listView/musicSearchList allSource)
aux_source_directory(./listView/lyricLineList allSource)

find_package(PkgConfig REQUIRED)
find_package(DtkWidget REQUIRED)

pkg_check_modules(Dtk REQUIRED IMPORTED_TARGET dtkwidget)
pkg_check_modules(Dtk REQUIRED IMPORTED_TARGET dtkcore)
Expand Down Expand Up @@ -184,3 +185,11 @@ install(FILES ${PROJECT_SOURCE_DIR}/src/music-player/data/deepin-music.desktop
install(FILES ${PROJECT_SOURCE_DIR}/src/music-player/icons/icons/deepin-music.svg
DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/scalable/apps)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/assets/deepin-music DESTINATION ${CMAKE_INSTALL_DATADIR}/deepin-manual/manual-assets/application/)

#hw机型增加DConfig配置
set(APPID org.deepin.music)
set(configFile ${PROJECT_SOURCE_DIR}/assets/org.deepin.music.json)
if (DEFINED DSG_DATA_DIR)
message("-- DConfig is supported by DTK")
dconfig_meta_files(APPID ${APPID} FILES ${configFile})
endif()
112 changes: 71 additions & 41 deletions src/music-player/core/util/global.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
#include <QLibraryInfo>
#include <QDBusInterface>
#include <QDebug>

#ifdef DTKCORE_CLASS_DConfigFile
#include <DConfig>
#endif
DCORE_USE_NAMESPACE;

static QString appName;
Expand Down Expand Up @@ -100,29 +102,43 @@ bool Global::checkBoardVendorType()
// boardVendorFlag = result.contains("HUAWEI");
// file.close();
// }
QProcess process;
process.start("dmidecode", QStringList() << "-s" << "system-product-name");
process.waitForStarted();
process.waitForFinished();
QString result(process.readAll());
boardVendorFlag = result.contains("KLVV", Qt::CaseInsensitive)
|| result.contains("KLVU", Qt::CaseInsensitive)
|| result.contains("PGUV", Qt::CaseInsensitive)
|| result.contains("PGUW", Qt::CaseInsensitive)
|| result.contains("L540", Qt::CaseInsensitive)
|| result.contains("W585", Qt::CaseInsensitive);
process.close();

process.start("bash", QStringList() << "-c" << "dmidecode | grep -i \"String 4\"");
process.waitForStarted();
process.waitForFinished();
result = process.readAll();
//qDebug() << __func__ << result;
boardVendorFlag = boardVendorFlag
|| result.contains("PWC30", Qt::CaseInsensitive); //w525
process.close();

int specialMuteRecovery = -1;

Check warning on line 105 in src/music-player/core/util/global.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Finding the same expression on both sides of an operator is suspicious and might indicate a cut and paste or logic error. Please examine this code carefully to determine if it is correct.
#ifdef DTKCORE_CLASS_DConfigFile
//wayland下需要查询是否支持特殊录屏模式,例如hw机型
DConfig *dconfig = DConfig::create("org.deepin.music","org.deepin.music");
//需要判断Dconfig文件是否合法
if(dconfig && dconfig->isValid()){
specialMuteRecovery = dconfig->value("specialMuteRecovery").toInt();
}
#endif
qInfo() << "specialMuteRecovery value is:" << specialMuteRecovery;
if(specialMuteRecovery != -1){
boardVendorFlag = specialMuteRecovery? true:false;
}else{
QProcess process;
process.start("dmidecode", QStringList() << "-s" << "system-product-name");
process.waitForStarted();
process.waitForFinished();
QString result(process.readAll());
boardVendorFlag = result.contains("KLVV", Qt::CaseInsensitive)
|| result.contains("KLVU", Qt::CaseInsensitive)
|| result.contains("PGUV", Qt::CaseInsensitive)
|| result.contains("PGUW", Qt::CaseInsensitive)
|| result.contains("L540", Qt::CaseInsensitive)
|| result.contains("W585", Qt::CaseInsensitive);
process.close();

process.start("bash", QStringList() << "-c" << "dmidecode | grep -i \"String 4\"");
process.waitForStarted();
process.waitForFinished();
result = process.readAll();
//qDebug() << __func__ << result;
boardVendorFlag = boardVendorFlag
|| result.contains("PWC30", Qt::CaseInsensitive); //w525
process.close();
}
initBoardVendorFlag = true;
qInfo() << "Whether special mute recovery mode is supported?" << boardVendorFlag;
return boardVendorFlag;
}

Expand All @@ -141,27 +157,41 @@ bool Global::boardVendorType()

bool Global::isPangu()
{
if (!initPanguFlag) {
QDBusInterface systemInfoInterface("com.deepin.daemon.SystemInfo",
"/com/deepin/daemon/SystemInfo",
"org.freedesktop.DBus.Properties",
QDBusConnection::sessionBus());

int specialBlockLockScreen = -1;

Check warning on line 160 in src/music-player/core/util/global.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Finding the same expression on both sides of an operator is suspicious and might indicate a cut and paste or logic error. Please examine this code carefully to determine if it is correct.
#ifdef DTKCORE_CLASS_DConfigFile
//wayland下需要查询是否支持特殊录屏模式,例如m900机型
DConfig *dconfig = DConfig::create("org.deepin.music","org.deepin.music");
if(dconfig && dconfig->isValid()){
specialBlockLockScreen = dconfig->value("specialBlockLockScreen").toInt();
}
#endif
qInfo() << "specialBlockLockScreen value is:" << specialBlockLockScreen;
if(specialBlockLockScreen != -1){
initPanguFlag = true;
if (!systemInfoInterface.isValid())
return false;

QDBusMessage replyCpu = systemInfoInterface.call("Get", "com.deepin.daemon.SystemInfo", "CPUHardware");
QList<QVariant> outArgsCPU = replyCpu.arguments();
if (outArgsCPU.count()) {
QString CPUHardware = outArgsCPU.at(0).value<QDBusVariant>().variant().toString();
qInfo() << __FUNCTION__ << __LINE__ << "Current CPUHardware: " << CPUHardware;

if (CPUHardware.contains("PANGU")) {
panguFlag = true;
panguFlag = specialBlockLockScreen? true:false;
}else{
if (!initPanguFlag) {
QDBusInterface systemInfoInterface("com.deepin.daemon.SystemInfo",
"/com/deepin/daemon/SystemInfo",
"org.freedesktop.DBus.Properties",
QDBusConnection::sessionBus());

initPanguFlag = true;
if (!systemInfoInterface.isValid())
return false;

QDBusMessage replyCpu = systemInfoInterface.call("Get", "com.deepin.daemon.SystemInfo", "CPUHardware");
QList<QVariant> outArgsCPU = replyCpu.arguments();
if (outArgsCPU.count()) {
QString CPUHardware = outArgsCPU.at(0).value<QDBusVariant>().variant().toString();
qInfo() << __FUNCTION__ << __LINE__ << "Current CPUHardware: " << CPUHardware;

if (CPUHardware.contains("PANGU")) {
panguFlag = true;
}
}
}
}

qInfo() << "Whether Block the lock screen on some special models is supported, like m900?" << panguFlag;
return panguFlag;
}

0 comments on commit f0dc74a

Please sign in to comment.