M module-services/service-desktop/endpoints/developerMode/DeveloperModeHelper.cpp => module-services/service-desktop/endpoints/developerMode/DeveloperModeHelper.cpp +30 -0
@@ 28,6 28,8 @@
#include <ctime>
#include <locks/data/PhoneLockMessages.hpp>
+
+#include <fstream>
namespace
{
@@ 66,6 68,34 @@ namespace sdesktop::endpoints
code = toCode(owner->bus.sendUnicast(msg, ServiceCellular::serviceName));
return {sent::delayed, std::nullopt};
}
+ else if (body[json::developerMode::EQ].is_string()) {
+ using namespace sdesktop::developerMode;
+ auto cmd = body[json::developerMode::EQ].string_value();
+ auto fileName = body[json::developerMode::fileName].string_value();
+ auto fileData = body[json::developerMode::fileData].string_value();
+ LOG_DEBUG("Received EQ file content: \n %s", fileData.c_str());
+ LOG_INFO("Replacing EQ file: %s", fileName.c_str());
+ auto targetFileName = purefs::dir::getUserDiskPath() / "data/equalizer" / fileName;
+ if (not fileData.empty()) {
+ std::fstream file(targetFileName, std::ios::out | std::ios::trunc);
+ file << fileData;
+ file.close();
+ LOG_INFO("EQ file replaced");
+ }
+
+ std::fstream file(targetFileName, std::ios::in);
+ std::stringstream buffer;
+ buffer << file.rdbuf();
+ if (buffer.str() != fileData) {
+ LOG_ERROR("Files mismatch...");
+ code = toCode(false);
+ }
+ else {
+ LOG_INFO("File verify OK");
+ code = toCode(true);
+ }
+ return {sent::no, ResponseContext{.status = code}};
+ }
else if (body[json::developerMode::focus].bool_value()) {
auto event = std::make_unique<sdesktop::developerMode::AppFocusChangeEvent>();
auto msg = std::make_shared<sdesktop::developerMode::DeveloperModeRequest>(std::move(event));
M module-services/service-desktop/endpoints/include/endpoints/developerMode/DeveloperModeHelper.hpp => module-services/service-desktop/endpoints/include/endpoints/developerMode/DeveloperModeHelper.hpp +3 -0
@@ 38,6 38,9 @@ namespace sdesktop::endpoints
inline constexpr auto state = "state";
inline constexpr auto ATResponse = "ATResponse";
inline constexpr auto AT = "AT";
+ inline constexpr auto EQ = "EQ";
+ inline constexpr auto fileName = "fileName";
+ inline constexpr auto fileData = "fileData";
inline constexpr auto timeout = "timeout";
inline constexpr auto focus = "focus";
inline constexpr auto phoneLocked = "phoneLocked";
A test/eq_setup.py => test/eq_setup.py +25 -0
@@ 0,0 1,25 @@
+#!/usr/bin/env python
+# Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
+# For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+from harness.harness import Harness
+from harness.api.developermode import SetEQ
+
+import sys
+import copy
+
+harness = Harness.from_detect()
+
+# pass EQ json file as an argument of this script. It can be both absolute or relative path.
+
+file_path = sys.argv[1]
+file_data = open(file_path,"r")
+file_text = file_data.read()
+file_data.close()
+
+file_name = file_path.split('/')[-1]
+print("Overriding "+file_name+" ...")
+print("File data: \n"+file_text)
+cmd = SetEQ(file_name,file_text)
+ret = cmd.run(harness)
+print("result: " + "OK" if ret.response.status == 200 else "Error!")
M test/harness => test/harness +1 -1
@@ 1,1 1,1 @@
-Subproject commit 12a9af331fdbabadb0425016c40a6ba0eb349c92
+Subproject commit 9bd08cb65043952885f006d2c2dbcd5be63f50b8