From b6a46e879d1bcd382916c6cb66dcb95e1bb33a2a Mon Sep 17 00:00:00 2001 From: RobertPiet Date: Thu, 21 Jan 2021 11:53:04 +0100 Subject: [PATCH] [EGD-4960] registerVariableChange moved to Init section of apps --- .../ApplicationSettings.cpp | 24 ++++++++++--------- .../ApplicationSettings.cpp | 17 ++++++------- .../model/ApplicationManager.cpp | 16 ++++++------- .../service-cellular/ServiceCellular.cpp | 4 ++-- .../service-db/agents/settings/Settings.cpp | 2 ++ .../agents/settings/SettingsAgent.cpp | 7 ++++++ .../service-desktop/ServiceDesktop.cpp | 5 ++-- 7 files changed, 44 insertions(+), 31 deletions(-) diff --git a/module-apps/application-settings-new/ApplicationSettings.cpp b/module-apps/application-settings-new/ApplicationSettings.cpp index c46f31f23971f33e9ad1df88c2fefcc26dd1b4c6..31c7592e9173368421522189d8152e3f5fb1ab8c 100644 --- a/module-apps/application-settings-new/ApplicationSettings.cpp +++ b/module-apps/application-settings-new/ApplicationSettings.cpp @@ -68,17 +68,10 @@ namespace app Store::GSM::get()->sim == selectedSim) { selectedSimNumber = CellularServiceAPI::GetOwnNumber(this); } - settings->registerValueChange(settings::operators_on, - [this](const std::string &value) { operatorOnChanged(value); }); - - settings->registerValueChange(::settings::Cellular::volte_on, - [this](const std::string &value) { volteChanged(value); }); } ApplicationSettingsNew::~ApplicationSettingsNew() { - settings->unregisterValueChange(settings::operators_on); - settings->unregisterValueChange(::settings::Cellular::volte_on); } // Invoked upon receiving data message @@ -158,9 +151,14 @@ namespace app setActiveWindow(gui::name::window::main_window); - settings->registerValueChange(::settings::SystemProperties::lockPassHash, [this](std::string value) { - lockPassHash = utils::getNumericValue(value); - }); + settings->registerValueChange(settings::operators_on, + [this](const std::string &value) { operatorOnChanged(value); }); + settings->registerValueChange(::settings::Cellular::volte_on, + [this](const std::string &value) { volteChanged(value); }); + settings->registerValueChange( + ::settings::SystemProperties::lockPassHash, + [this](std::string value) { lockPassHash = utils::getNumericValue(value); }, + ::settings::SettingsScope::Global); return ret; } @@ -272,17 +270,20 @@ namespace app void ApplicationSettingsNew::operatorOnChanged(const std::string &value) { + LOG_DEBUG("[ApplicationSettingsNew::operatorOnChanged] value=%s", value.c_str()); if (!value.empty()) { operatorsOn = utils::getNumericValue(value); } } bool ApplicationSettingsNew::getOperatorsOn() const noexcept { + LOG_DEBUG("[ApplicationSettingsNew::getOperatorsOn] %d", operatorsOn); return operatorsOn; } void ApplicationSettingsNew::setOperatorsOn(bool value) { operatorsOn = value; + LOG_DEBUG("[ApplicationSettingsNew::setOperatorsOn] to %d", operatorsOn); settings->setValue(settings::operators_on, std::to_string(value)); } @@ -307,7 +308,8 @@ namespace app void ApplicationSettingsNew::setLockPassHash(unsigned int value) { lockPassHash = value; - settings->setValue(::settings::SystemProperties::lockPassHash, std::to_string(value)); + settings->setValue( + ::settings::SystemProperties::lockPassHash, std::to_string(value), ::settings::SettingsScope::Global); } auto ApplicationSettingsNew::getCurrentValues() -> settingsInterface::ScreenLightSettings::Values diff --git a/module-apps/application-settings/ApplicationSettings.cpp b/module-apps/application-settings/ApplicationSettings.cpp index e0e2c2ae2f4046b050afe867e538f3e1888483f6..ffcd30f79f5bd657afecac0a18c29cf025fbaa2a 100644 --- a/module-apps/application-settings/ApplicationSettings.cpp +++ b/module-apps/application-settings/ApplicationSettings.cpp @@ -47,14 +47,6 @@ namespace app switchWindow(app::sim_select); return msgHandled(); }); - settings->registerValueChange( - settings::SystemProperties::lockPassHash, - [this](std::string value) { lockPassChanged(value); }, - settings::SettingsScope::Global); - settings->registerValueChange( - settings::SystemProperties::timeDateFormat, - [this](std::string value) { timeDateChanged(value); }, - settings::SettingsScope::Global); } ApplicationSettings::~ApplicationSettings() @@ -106,6 +98,15 @@ namespace app if (ret != sys::ReturnCodes::Success) return ret; + settings->registerValueChange( + settings::SystemProperties::lockPassHash, + [this](std::string value) { lockPassChanged(value); }, + settings::SettingsScope::Global); + settings->registerValueChange( + settings::SystemProperties::timeDateFormat, + [this](std::string value) { timeDateChanged(value); }, + settings::SettingsScope::Global); + createUserInterface(); setActiveWindow(gui::name::window::main_window); diff --git a/module-services/service-appmgr/model/ApplicationManager.cpp b/module-services/service-appmgr/model/ApplicationManager.cpp index e6794aa845f2d37e830d16fb9040b00720f50fdc..a18f2e2a150d4bf3ca6a40eda1b7e1e476d2cb33 100644 --- a/module-services/service-appmgr/model/ApplicationManager.cpp +++ b/module-services/service-appmgr/model/ApplicationManager.cpp @@ -106,6 +106,14 @@ namespace app::manager { registerMessageHandlers(); blockingTimer->connect([this](sys::Timer &) { onPhoneLocked(); }); + } + + sys::ReturnCodes ApplicationManager::InitHandler() + { + blockingTimer->setInterval(default_application_locktime_ms); + utils::localize.setFallbackLanguage(utils::localize.DefaultLanguage); + utils::localize.setDisplayLanguage(displayLanguage); + utils::localize.setInputLanguage(inputLanguage); settings->registerValueChange( settings::SystemProperties::displayLanguage, [this](std::string value) { displayLanguageChanged(value); }, @@ -118,14 +126,6 @@ namespace app::manager settings::SystemProperties::lockTime, [this](std::string value) { lockTimeChanged(value); }, settings::SettingsScope::Global); - } - - sys::ReturnCodes ApplicationManager::InitHandler() - { - blockingTimer->setInterval(default_application_locktime_ms); - utils::localize.setFallbackLanguage(utils::localize.DefaultLanguage); - utils::localize.setDisplayLanguage(displayLanguage); - utils::localize.setInputLanguage(inputLanguage); startSystemServices(); startBackgroundApplications(); diff --git a/module-services/service-cellular/ServiceCellular.cpp b/module-services/service-cellular/ServiceCellular.cpp index 44c6b2f2b00dc676f5b728e87a79fc0dc7bb0fc0..27de01c3dafb93c639ff87cf3708a341e225c06d 100644 --- a/module-services/service-cellular/ServiceCellular.cpp +++ b/module-services/service-cellular/ServiceCellular.cpp @@ -204,8 +204,6 @@ ServiceCellular::ServiceCellular() : sys::Service(serviceName, "", cellularStack sys::Bus::SendMulticast(msg.value(), sys::BusChannels::ServiceCellularNotifications, this); }; registerMessageHandlers(); - settings->registerValueChange(settings::Cellular::volte_on, - [this](const std::string &value) { volteChanged(value); }); packetData = std::make_unique(*this); packetData->loadAPNSettings(); } @@ -235,6 +233,8 @@ sys::ReturnCodes ServiceCellular::InitHandler() board = EventManagerServiceAPI::GetBoard(this); state.set(this, State::ST::WaitForStartPermission); + settings->registerValueChange(settings::Cellular::volte_on, + [this](const std::string &value) { volteChanged(value); }); return sys::ReturnCodes::Success; } diff --git a/module-services/service-db/agents/settings/Settings.cpp b/module-services/service-db/agents/settings/Settings.cpp index 29d99582b7063caf2b32f3cd8bfcdb13d05f07a2..7dd7fe933ef72061c762919a686fd01a3207c6d5 100644 --- a/module-services/service-db/agents/settings/Settings.cpp +++ b/module-services/service-db/agents/settings/Settings.cpp @@ -163,6 +163,7 @@ namespace settings LOG_INFO("Callback function on value change (%s) does not exist", path.to_string().c_str()); } else { + LOG_DEBUG("[Settings::unregisterValueChange] %s", path.to_string().c_str()); cbValues.erase(it_cb); } @@ -173,6 +174,7 @@ namespace settings void Settings::unregisterValueChange() { for (auto it_cb : cbValues) { + LOG_DEBUG("[Settings::unregisterValueChange] %s", it_cb.first.to_string().c_str()); auto msg = std::make_shared(it_cb.first); sendMsg(std::move(msg)); } diff --git a/module-services/service-db/agents/settings/SettingsAgent.cpp b/module-services/service-db/agents/settings/SettingsAgent.cpp index e3246d8d1262c6fbefe855043466a595b0d8a85a..7211d4098e970029cfdf16d140315b5b008474c5 100644 --- a/module-services/service-db/agents/settings/SettingsAgent.cpp +++ b/module-services/service-db/agents/settings/SettingsAgent.cpp @@ -211,11 +211,13 @@ auto SettingsAgent::handleSetVariable(sys::Message *req) -> sys::MessagePointer auto oldValue = dbGetValue(path); if (oldValue.has_value() && oldValue.value() != value) { dbSetValue(path, value); + LOG_DEBUG("[SettingsAgent::handleSetVariable] %s=%s", path.to_string().c_str(), value.c_str()); for (auto regPath : variableChangeRecipents[path.to_string()]) { if (regPath.service != path.service) { auto updateMsg = std::make_shared(regPath, value, oldValue.value_or("")); sys::Bus::SendUnicast(std::move(updateMsg), regPath.service, parentService); + LOG_DEBUG("[SettingsAgent::handleSetVariable] notified service: %s", regPath.service.c_str()); } } } @@ -234,6 +236,10 @@ auto SettingsAgent::handleRegisterOnVariableChange(sys::Message *req) -> sys::Me auto currentValue = dbGetValue(path).value_or(""); auto msgValue = std::make_shared<::settings::Messages::VariableChanged>(path, currentValue, ""); sys::Bus::SendUnicast(std::move(msgValue), msg->sender, parentService); + LOG_DEBUG("[SettingsAgent::handleRegisterOnVariableChange] %s=%s to %s", + path.to_string().c_str(), + currentValue.c_str(), + msg->sender.c_str()); } else { it->second.insert(path); @@ -251,6 +257,7 @@ auto SettingsAgent::handleUnregisterOnVariableChange(sys::Message *req) -> sys:: auto it = variableChangeRecipents.find(path.to_string()); if (variableChangeRecipents.end() != it) { it->second.erase(path); + LOG_DEBUG("[SettingsAgent::handleUnregisterOnVariableChange] %s", path.to_string().c_str()); } } } diff --git a/module-services/service-desktop/ServiceDesktop.cpp b/module-services/service-desktop/ServiceDesktop.cpp index 61d54278372982aa5fb1f1c8368774c9bb6f265a..e2aa6c53dc5136c3f4a1487e37aed59cb90e1c1a 100644 --- a/module-services/service-desktop/ServiceDesktop.cpp +++ b/module-services/service-desktop/ServiceDesktop.cpp @@ -29,8 +29,6 @@ ServiceDesktop::ServiceDesktop() : sys::Service(service::name::service_desktop, updateOS = std::make_unique(this); settings = std::make_unique(this); - settings->registerValueChange(updateos::settings::history, - [this](const std::string &value) { updateOS->setInitialHistory(value); }); } ServiceDesktop::~ServiceDesktop() @@ -115,6 +113,9 @@ sys::ReturnCodes ServiceDesktop::InitHandler() return std::make_shared(); }); + settings->registerValueChange(updateos::settings::history, + [this](const std::string &value) { updateOS->setInitialHistory(value); }); + return (sys::ReturnCodes::Success); }