From f0dc74a95c0b1600135c37b34a9387adf85c8b7d Mon Sep 17 00:00:00 2001 From: Wang Cong Date: Thu, 6 Jul 2023 13:21:00 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20hw=E6=9C=BA=E5=9E=8B=E5=88=A4=E6=96=AD?= =?UTF-8?q?=E9=80=82=E9=85=8Ddconfig?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Description: hw机型判断适配dconfig Log: hw机型判断适配dconfig Task: https://pms.uniontech.com/task-view-276433.html --- assets/org.deepin.music.json | 26 ++++++ src/music-player/CMakeLists.txt | 9 +++ src/music-player/core/util/global.cpp | 112 ++++++++++++++++---------- 3 files changed, 106 insertions(+), 41 deletions(-) create mode 100755 assets/org.deepin.music.json diff --git a/assets/org.deepin.music.json b/assets/org.deepin.music.json new file mode 100755 index 000000000..e22986248 --- /dev/null +++ b/assets/org.deepin.music.json @@ -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" + } + } +} diff --git a/src/music-player/CMakeLists.txt b/src/music-player/CMakeLists.txt index dcd9223f1..40d558f70 100644 --- a/src/music-player/CMakeLists.txt +++ b/src/music-player/CMakeLists.txt @@ -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) @@ -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() diff --git a/src/music-player/core/util/global.cpp b/src/music-player/core/util/global.cpp index 666438084..132c483e0 100644 --- a/src/music-player/core/util/global.cpp +++ b/src/music-player/core/util/global.cpp @@ -13,7 +13,9 @@ #include #include #include - +#ifdef DTKCORE_CLASS_DConfigFile +#include +#endif DCORE_USE_NAMESPACE; static QString appName; @@ -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; +#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; } @@ -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; +#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 outArgsCPU = replyCpu.arguments(); - if (outArgsCPU.count()) { - QString CPUHardware = outArgsCPU.at(0).value().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 outArgsCPU = replyCpu.arguments(); + if (outArgsCPU.count()) { + QString CPUHardware = outArgsCPU.at(0).value().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; }