From eeafb5f1be091a34446b842dbde1b7d54cc029a7 Mon Sep 17 00:00:00 2001 From: Lefucjusz Date: Wed, 23 Nov 2022 12:38:47 +0100 Subject: [PATCH] [MOS-783] Moved battery config file to '/user/data' Moved battery config file from root directory of user partition to 'data' directory to comply with new directory layout design. --- .../application-onboarding/ApplicationOnBoarding.cpp | 2 +- .../Audio/Profiles/ProfilePlaybackHeadphones.hpp | 2 +- .../Audio/Profiles/ProfilePlaybackLoudspeaker.hpp | 2 +- .../Audio/Profiles/ProfileRoutingEarspeaker.hpp | 2 +- .../Audio/Profiles/ProfileRoutingHeadphones.hpp | 2 +- .../Audio/Profiles/ProfileRoutingLoudspeaker.hpp | 2 +- .../puretx/bsp/battery_charger/battery_charger.cpp | 10 +++++----- module-utils/i18n/i18nImpl.hpp | 4 ++-- module-vfs/paths/filesystem_paths.cpp | 7 ++++++- module-vfs/paths/include/purefs/filesystem_paths.hpp | 3 ++- 10 files changed, 21 insertions(+), 15 deletions(-) diff --git a/module-apps/application-onboarding/ApplicationOnBoarding.cpp b/module-apps/application-onboarding/ApplicationOnBoarding.cpp index caa1ed756404a9fb6a3ca8a9c5ab578e67faadd4..cc1a35813718494ac200d9e64559d5e46c831fae 100644 --- a/module-apps/application-onboarding/ApplicationOnBoarding.cpp +++ b/module-apps/application-onboarding/ApplicationOnBoarding.cpp @@ -143,7 +143,7 @@ namespace app return std::make_unique(app); }); windowsFactory.attach(gui::window::name::onBoarding_eula, [&](ApplicationCommon *app, const std::string &name) { - const auto eulaDirPath = purefs::dir::getDataDirPath() / "licenses"; + const auto eulaDirPath = purefs::dir::getSystemDataDirPath() / "licenses"; const auto eulaFilename = "eula.txt"; auto eulaRepository = std::make_unique(eulaDirPath, eulaFilename); auto presenter = std::make_unique([&]() { acceptEULA(); }, diff --git a/module-audio/Audio/Profiles/ProfilePlaybackHeadphones.hpp b/module-audio/Audio/Profiles/ProfilePlaybackHeadphones.hpp index 12491ffee916656089538bb51b6cd7669954af80..0947c0f2e488325402f1624bbd5e1c371a0d36ee 100644 --- a/module-audio/Audio/Profiles/ProfilePlaybackHeadphones.hpp +++ b/module-audio/Audio/Profiles/ProfilePlaybackHeadphones.hpp @@ -14,7 +14,7 @@ namespace audio : Profile( "Playback Headphones", Type::PlaybackHeadphones, - purefs::dir::getDataDirPath() / "equalizer/headphones_playback.json", + purefs::dir::getSystemDataDirPath() / "equalizer/headphones_playback.json", audio::codec::Configuration{ .sampleRate_Hz = 0, .bitWidth = 16, diff --git a/module-audio/Audio/Profiles/ProfilePlaybackLoudspeaker.hpp b/module-audio/Audio/Profiles/ProfilePlaybackLoudspeaker.hpp index 0feb26912bf6c0c212ddb7750d80a8dbcf904429..d416e8af39391ad0693a78321571edf8b1dcf953 100644 --- a/module-audio/Audio/Profiles/ProfilePlaybackLoudspeaker.hpp +++ b/module-audio/Audio/Profiles/ProfilePlaybackLoudspeaker.hpp @@ -15,7 +15,7 @@ namespace audio : Profile( "Playback Loudspeaker", Type::PlaybackLoudspeaker, - purefs::dir::getDataDirPath() / "equalizer/loudspeaker_playback.json", + purefs::dir::getSystemDataDirPath() / "equalizer/loudspeaker_playback.json", audio::codec::Configuration{ .sampleRate_Hz = 0, .bitWidth = 16, diff --git a/module-audio/Audio/Profiles/ProfileRoutingEarspeaker.hpp b/module-audio/Audio/Profiles/ProfileRoutingEarspeaker.hpp index a2ebe49290103bf556bd408bd93caee9fe07bae1..003271da892797fd0b116802427a51e58b636cd0 100644 --- a/module-audio/Audio/Profiles/ProfileRoutingEarspeaker.hpp +++ b/module-audio/Audio/Profiles/ProfileRoutingEarspeaker.hpp @@ -14,7 +14,7 @@ namespace audio : Profile( "Routing Earspeaker", Type::RoutingEarspeaker, - purefs::dir::getDataDirPath() / "equalizer/earspeaker_routing.json", + purefs::dir::getSystemDataDirPath() / "equalizer/earspeaker_routing.json", audio::codec::Configuration{ .sampleRate_Hz = 16000, .bitWidth = 16, diff --git a/module-audio/Audio/Profiles/ProfileRoutingHeadphones.hpp b/module-audio/Audio/Profiles/ProfileRoutingHeadphones.hpp index b29a41781e524cac0b31cd79ff46d31b106c1f28..b71cd44ce4e79ed3d7212fc406f0a843dcb40e84 100644 --- a/module-audio/Audio/Profiles/ProfileRoutingHeadphones.hpp +++ b/module-audio/Audio/Profiles/ProfileRoutingHeadphones.hpp @@ -14,7 +14,7 @@ namespace audio : Profile( "Routing Headset", Type::RoutingHeadphones, - purefs::dir::getDataDirPath() / "equalizer/headphones_routing.json", + purefs::dir::getSystemDataDirPath() / "equalizer/headphones_routing.json", audio::codec::Configuration{ .sampleRate_Hz = 16000, .bitWidth = 16, diff --git a/module-audio/Audio/Profiles/ProfileRoutingLoudspeaker.hpp b/module-audio/Audio/Profiles/ProfileRoutingLoudspeaker.hpp index 08c729bb2361cc3f21fedde9bc720298e4156023..7c4c630cc20715c9100d9eb665f21e2d8c990072 100644 --- a/module-audio/Audio/Profiles/ProfileRoutingLoudspeaker.hpp +++ b/module-audio/Audio/Profiles/ProfileRoutingLoudspeaker.hpp @@ -15,7 +15,7 @@ namespace audio ProfileRoutingLoudspeaker(Volume volume, Gain gain) : Profile("Routing Speakerphone", Type::RoutingLoudspeaker, - purefs::dir::getDataDirPath() / "equalizer/loudspeaker_routing.json", + purefs::dir::getSystemDataDirPath() / "equalizer/loudspeaker_routing.json", audio::codec::Configuration{ .sampleRate_Hz = sampleRate, .bitWidth = 16, diff --git a/module-bsp/board/rt1051/puretx/bsp/battery_charger/battery_charger.cpp b/module-bsp/board/rt1051/puretx/bsp/battery_charger/battery_charger.cpp index ec8f296b15cd864f256749f6891f8a79c09e15ba..b153c23c84bf8ee43876be18f9ab3946ac38b4a7 100644 --- a/module-bsp/board/rt1051/puretx/bsp/battery_charger/battery_charger.cpp +++ b/module-bsp/board/rt1051/puretx/bsp/battery_charger/battery_charger.cpp @@ -28,7 +28,7 @@ namespace bsp::battery_charger constexpr std::uint32_t i2cSubaddresSize = 1; - const auto cfgFile = purefs::dir::getUserDiskPath() / "batteryFuelGaugeConfig.cfg"; + const auto cfgFile = purefs::dir::getUserDataDirPath() / "batteryFuelGaugeConfig.cfg"; constexpr auto registersToStore = 0xFF + 1; constexpr auto configFileSizeWithoutChecksum = registersToStore * sizeof(Register); @@ -158,7 +158,7 @@ namespace bsp::battery_charger drivers::I2CAddress batteryChargerAddress = {BATTERY_CHARGER_I2C_ADDR, 0, i2cSubaddresSize}; drivers::I2CAddress topControllerAddress = {TOP_CONTROLLER_I2C_ADDR, 0, i2cSubaddresSize}; - void addChecksumToConfigFile(std::filesystem::path cfgFile) + void addChecksumToConfigFile() { std::fstream file(cfgFile.c_str(), std::ios::binary | std::ios::in | std::ios::out); if (!file.is_open()) { @@ -176,7 +176,7 @@ namespace bsp::battery_charger file.close(); } - bool isCorrectChecksumFromConfigFile(std::filesystem::path cfgFile) + bool isCorrectChecksumFromConfigFile() { bool ret = false; std::ifstream file(cfgFile.c_str(), std::ios::binary | std::ios::in); @@ -418,7 +418,7 @@ namespace bsp::battery_charger savedData[i] = regVal.second; } file.close(); - addChecksumToConfigFile(cfgFile.c_str()); + addChecksumToConfigFile(); return fileConfigRetval::OK; } @@ -458,7 +458,7 @@ namespace bsp::battery_charger readData[i] = regVal; } file.close(); - if (!isCorrectChecksumFromConfigFile(cfgFile.c_str())) { + if (!isCorrectChecksumFromConfigFile()) { return fileConfigRetval::FileCrcError; } return fileConfigRetval::OK; diff --git a/module-utils/i18n/i18nImpl.hpp b/module-utils/i18n/i18nImpl.hpp index 026d4585b55098b70736bfce7bb16b6f130e385f..639dd6d925a906ea2fb661f8a97cb5862a795e81 100644 --- a/module-utils/i18n/i18nImpl.hpp +++ b/module-utils/i18n/i18nImpl.hpp @@ -27,8 +27,8 @@ namespace utils Language inputLanguage = fallbackLanguageName; Language inputLanguageFilename; Language currentDisplayLanguage; - std::filesystem::path InputLanguageDirPath = purefs::dir::getDataDirPath() / "profiles"; - std::filesystem::path DisplayLanguageDirPath = purefs::dir::getDataDirPath() / "lang"; + std::filesystem::path InputLanguageDirPath = purefs::dir::getSystemDataDirPath() / "profiles"; + std::filesystem::path DisplayLanguageDirPath = purefs::dir::getSystemDataDirPath() / "lang"; cpp_freertos::MutexStandard mutex; std::vector metadata; diff --git a/module-vfs/paths/filesystem_paths.cpp b/module-vfs/paths/filesystem_paths.cpp index 37559c01e285ff6ceed15030bc635de8995c8530..5071034ccb3709a7a7abc9d31bc8177ee02a5389 100644 --- a/module-vfs/paths/filesystem_paths.cpp +++ b/module-vfs/paths/filesystem_paths.cpp @@ -96,9 +96,14 @@ namespace purefs return getSystemDiskPath() / PATH_ASSETS; } - std::filesystem::path getDataDirPath() noexcept + std::filesystem::path getSystemDataDirPath() noexcept { return getSystemDiskPath() / PATH_DATA; } + + std::filesystem::path getUserDataDirPath() noexcept + { + return getUserDiskPath() / PATH_DATA; + } } // namespace dir } // namespace purefs diff --git a/module-vfs/paths/include/purefs/filesystem_paths.hpp b/module-vfs/paths/include/purefs/filesystem_paths.hpp index 19b826bbac2bb07ba55348a2851d3e057fe5e15d..83feebbfa780b4eb93b17a0233c8690033c5a2dd 100644 --- a/module-vfs/paths/include/purefs/filesystem_paths.hpp +++ b/module-vfs/paths/include/purefs/filesystem_paths.hpp @@ -24,7 +24,8 @@ namespace purefs std::filesystem::path getBackupOSPath() noexcept; std::filesystem::path getBootJSONPath() noexcept; std::filesystem::path getAssetsDirPath() noexcept; - std::filesystem::path getDataDirPath() noexcept; + std::filesystem::path getSystemDataDirPath() noexcept; + std::filesystem::path getUserDataDirPath() noexcept; } // namespace dir namespace file