[EGD-6486] Fix for settings not avaialble at phone startup Fixed the comparison function of EntryPath objects.
9 files changed, 175 insertions(+), 27 deletions(-) M enabled_unittests M module-apps/Application.cpp M module-apps/application-desktop/ApplicationDesktop.cpp M module-services/service-appmgr/model/ApplicationManager.cpp M module-services/service-db/CMakeLists.txt A module-services/service-db/EntryPath.cpp M module-services/service-db/service-db/SettingsMessages.hpp M module-services/service-db/test/CMakeLists.txt A module-services/service-db/test/test-entry-path.cpp
M enabled_unittests => enabled_unittests +7 -0
@@ 155,6 155,13 @@ TESTS_LIST["catch2-dependency-graph-tests"]=" Given Dependency Graph When topological sort on directed cyclic graph then verify order; " #--------- TESTS_LIST["catch2-entry-path"]=" Entry Path - is less comparison - different settings scope; Entry Path - is less comparison - Global scope; Entry Path - is less comparison - AppLocal scope; Entry Path - std::map::find - EGD-6486; " #--------- TESTS_LIST["catch2-gui"]=" Test BoundingBox intersect; Are fonts loaded;
M module-apps/Application.cpp => module-apps/Application.cpp +2 -0
@@ 617,6 617,8 @@ namespace app setState(State::ACTIVE_BACKGROUND); } lockScreenPasscodeIsOn = utils::getNumericValue<bool>( settings->getValue(settings::SystemProperties::lockScreenPasscodeIsOn, settings::SettingsScope::Global)); settings->registerValueChange( settings::SystemProperties::lockScreenPasscodeIsOn, [this](const std::string &value) { lockScreenPasscodeIsOn = utils::getNumericValue<bool>(value); },
M module-apps/application-desktop/ApplicationDesktop.cpp => module-apps/application-desktop/ApplicationDesktop.cpp +3 -0
@@ 386,6 386,9 @@ namespace app return ret; } lockPassHashChanged( settings->getValue(settings::SystemProperties::lockPassHash, settings::SettingsScope::Global)); requestNotSeenNotifications(this); requestUnreadThreadsCount(this); requestUnreadCallsCount(this);
M module-services/service-appmgr/model/ApplicationManager.cpp => module-services/service-appmgr/model/ApplicationManager.cpp +2 -1
@@ 142,7 142,8 @@ namespace app::manager sys::ReturnCodes ApplicationManager::InitHandler() { utils::localize.setDisplayLanguage(settings->getValue(settings::SystemProperties::displayLanguage)); utils::localize.setDisplayLanguage( settings->getValue(settings::SystemProperties::displayLanguage, settings::SettingsScope::Global)); settings->registerValueChange( settings::SystemProperties::displayLanguage,
M module-services/service-db/CMakeLists.txt => module-services/service-db/CMakeLists.txt +1 -0
@@ 7,6 7,7 @@ set(SOURCES DBServiceAPI_GetByQuery.cpp DatabaseAgent.cpp ServiceDB.cpp EntryPath.cpp messages/DBCalllogMessage.cpp messages/DBContactMessage.cpp messages/DBNotificationMessage.cpp
A module-services/service-db/EntryPath.cpp => module-services/service-db/EntryPath.cpp +52 -0
@@ 0,0 1,52 @@ // Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #include "service-db/SettingsMessages.hpp" namespace settings { namespace { bool isLessAppLocal(const EntryPath &lhs, const EntryPath &rhs) noexcept { if (lhs.mode < rhs.mode) { return true; } if (lhs.mode > rhs.mode) { return false; } if (lhs.service < rhs.service) { return true; } if (lhs.service > rhs.service) { return false; } if (lhs.profile < rhs.profile) { return true; } if (lhs.profile > rhs.profile) { return false; } if (lhs.variable < rhs.variable) { return true; } if (lhs.variable > rhs.variable) { return false; } return false; } } // namespace bool operator<(const EntryPath &lhs, const EntryPath &rhs) noexcept { if (lhs.scope != rhs.scope) { return lhs.scope < rhs.scope; } // Scopes are equal - compare other internals. if (lhs.scope == SettingsScope::AppLocal) { return isLessAppLocal(lhs, rhs); } return lhs.variable < rhs.variable; } } // namespace settings
M module-services/service-db/service-db/SettingsMessages.hpp => module-services/service-db/service-db/SettingsMessages.hpp +3 -26
@@ 1,4 1,4 @@ // Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved. // Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #pragma once @@ 47,33 47,10 @@ namespace settings scope = SettingsScope::AppLocal; } } bool operator<(const EntryPath &other) const { if (mode < other.mode) return true; if (mode > other.mode) return false; if (service < other.service) return true; if (service > other.service) return false; if (profile < other.profile) return true; if (profile > other.profile) return false; if (variable < other.variable) return true; if (variable > other.variable) return false; if (scope < other.scope) return true; if (scope > other.scope) return false; return false; } }; bool operator<(const EntryPath &lhs, const EntryPath &rhs) noexcept; namespace Messages { class SettingsMessage : public sys::DataMessage
M module-services/service-db/test/CMakeLists.txt => module-services/service-db/test/CMakeLists.txt +11 -0
@@ 19,4 19,15 @@ add_catch2_executable( disk_image ) add_catch2_executable( NAME entry-path SRCS main.cpp test-entry-path.cpp LIBS service-db module-db ) add_subdirectory(test-settings)
A module-services/service-db/test/test-entry-path.cpp => module-services/service-db/test/test-entry-path.cpp +94 -0
@@ 0,0 1,94 @@ // Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #include <catch2/catch.hpp> #include "service-db/SettingsMessages.hpp" using namespace settings; TEST_CASE("Entry Path - is less comparison - different settings scope") { EntryPath lhs{"mode", "service", "profile", "variable", SettingsScope::Global}; EntryPath rhs{"mode", "service", "profile", "variable", SettingsScope::AppLocal}; REQUIRE(lhs < rhs); } TEST_CASE("Entry Path - is less comparison - Global scope") { SECTION("is lesser") { EntryPath lhs1{"mode", "service", "profile", "variableA", SettingsScope::Global}; EntryPath rhs1{"mode", "service", "profile", "variableB", SettingsScope::Global}; REQUIRE(lhs1 < rhs1); } SECTION("is equal") { EntryPath lhs2{"mode", "service", "profile", "variableA", SettingsScope::Global}; EntryPath rhs2{"mode", "service", "profile", "variableA", SettingsScope::Global}; REQUIRE(!(lhs2 < rhs2)); } SECTION("is greater") { EntryPath lhs3{"mode", "service", "profile", "variableB", SettingsScope::Global}; EntryPath rhs3{"mode", "service", "profile", "variableA", SettingsScope::Global}; REQUIRE(!(lhs3 < rhs3)); } } TEST_CASE("Entry Path - is less comparison - AppLocal scope") { SECTION("All parts are lesser") { EntryPath lhs1{"modeA", "serviceA", "profileA", "variableA", SettingsScope::AppLocal}; EntryPath rhs1{"modeB", "serviceB", "profileB", "variableB", SettingsScope::AppLocal}; REQUIRE(lhs1 < rhs1); } SECTION("All parts are equal") { EntryPath lhs2{"modeA", "serviceA", "profileA", "variableA", SettingsScope::AppLocal}; EntryPath rhs2{"modeA", "serviceA", "profileA", "variableA", SettingsScope::AppLocal}; REQUIRE(!(lhs2 < rhs2)); } SECTION("One part is lesser, others are equal") { EntryPath lhs3{"modeA", "serviceA", "profileA", "variableA", SettingsScope::AppLocal}; EntryPath rhs3{"modeA", "serviceB", "profileA", "variableA", SettingsScope::AppLocal}; REQUIRE(lhs3 < rhs3); } SECTION("Lesser part before greater part") { EntryPath lhs4{"modeA", "serviceA", "profileC", "variableA", SettingsScope::AppLocal}; EntryPath rhs4{"modeB", "serviceA", "profileA", "variableA", SettingsScope::AppLocal}; REQUIRE(lhs4 < rhs4); } } TEST_CASE("Entry Path - std::map::find - EGD-6486") { std::map<EntryPath, std::string> map = { {{"", "", "", "variableA", SettingsScope::Global}, "1"}, {{"", "", "", "variableA", SettingsScope::Global}, "2"}, {{"modeA", "serviceA", "profileC", "variableB", SettingsScope::AppLocal}, "3"}, }; SECTION("Find global variable") { auto it1 = map.find({"", "", "", "variableA", SettingsScope::Global}); REQUIRE(it1 != map.end()); auto it2 = map.find({"Mode", "Service", "Profile", "variableA", SettingsScope::Global}); REQUIRE(it2 != map.end()); } SECTION("Find app local variable") { auto it = map.find({"modeA", "serviceA", "profileC", "variableB", SettingsScope::AppLocal}); REQUIRE(it != map.end()); } }