From 3b24ac9e903b7d75ca9e2a09d6317df4e32efaef Mon Sep 17 00:00:00 2001 From: Lefucjusz Date: Tue, 17 Oct 2023 12:02:04 +0200 Subject: [PATCH] [MOS-1047] Fix calling abort() in EnterNumberWindow * Removed call to abort() method in case EnterNumberWindow's SwitchData handler receives message that can't be handled, what caused the phone to crash. * Unify ApplicationCall window names definitions. * Code cleanup. --- .../application-call/ApplicationCall.cpp | 112 +++++++++--------- .../application-call/data/CallSwitchData.hpp | 10 +- .../application-call/ApplicationCall.hpp | 16 +-- .../application-call/windows/CallWindow.cpp | 12 +- .../application-call/windows/CallWindow.hpp | 1 - .../windows/EmergencyCallWindow.cpp | 4 +- .../windows/EmergencyCallWindow.hpp | 4 +- .../windows/EnterNumberWindow.cpp | 13 +- .../windows/EnterNumberWindow.hpp | 5 +- .../application-call/windows/NumberWindow.hpp | 4 +- .../application-call/windows/WindowNames.hpp | 15 +++ .../ApplicationCallLog.hpp | 9 +- .../windows/DesktopMainWindow.cpp | 19 ++- .../windows/SMSTemplatesWindow.cpp | 4 +- .../ApplicationSpecialInput.hpp | 7 +- .../service-cellular/CellularServiceAPI.cpp | 2 +- products/PurePhone/PurePhoneMain.cpp | 4 +- .../services/appmgr/RunAppsInBackground.cpp | 5 +- pure_changelog.md | 1 + 19 files changed, 124 insertions(+), 123 deletions(-) create mode 100644 module-apps/application-call/windows/WindowNames.hpp diff --git a/module-apps/application-call/ApplicationCall.cpp b/module-apps/application-call/ApplicationCall.cpp index 133edea7ef331a68467549e6e6feb88b1f626fa4..e798399c2a1ab032b3635ef171b5f5e41e3fe46b 100644 --- a/module-apps/application-call/ApplicationCall.cpp +++ b/module-apps/application-call/ApplicationCall.cpp @@ -28,14 +28,18 @@ #include #include -namespace app +namespace { + constexpr auto applicationCallStackSize = 1024 * 8; +} +namespace app +{ ApplicationCall::ApplicationCall(std::string name, std::string parent, StatusIndicators statusIndicators, StartInBackground startInBackground) - : Application(name, parent, statusIndicators, startInBackground, app::call_stack_size) + : Application(std::move(name), std::move(parent), statusIndicators, startInBackground, applicationCallStackSize) { using namespace gui::status_bar; @@ -58,11 +62,11 @@ namespace app return actionNotHandled(); }); addActionReceiver(manager::actions::Dial, [this](auto &&data) { - switchWindow(window::name_enterNumber, std::forward(data)); + switchWindow(gui::window::name::enter_number, std::forward(data)); return actionHandled(); }); addActionReceiver(manager::actions::EmergencyDial, [this](auto &&data) { - switchWindow(app::window::name_emergencyCall, std::forward(data)); + switchWindow(gui::window::name::emergency_call, std::forward(data)); return actionHandled(); }); addActionReceiver(manager::actions::NotAnEmergencyNotification, [this](auto &&data) { @@ -72,49 +76,49 @@ namespace app return actionHandled(); }); - addActionReceiver(manager::actions::NoSimNotification, [this](auto &&data) { + addActionReceiver(manager::actions::NoSimNotification, [this]([[maybe_unused]] auto &&data) { showNotificationAndRestartCallFlow(NotificationType::Info, utils::translate("app_call_no_sim")); return actionHandled(); }); - addActionReceiver(manager::actions::NoNetworkConnectionNotification, [this](auto &&data) { + addActionReceiver(manager::actions::NoNetworkConnectionNotification, [this]([[maybe_unused]] auto &&data) { showNotificationAndRestartCallFlow(NotificationType::Info, utils::translate("app_call_no_network_connection")); return actionHandled(); }); - addActionReceiver(manager::actions::CallRequestGeneralErrorNotification, [this](auto &&data) { + addActionReceiver(manager::actions::CallRequestGeneralErrorNotification, [this]([[maybe_unused]] auto &&data) { showNotificationAndRestartCallFlow(NotificationType::Failure, utils::translate("app_call_call_request_failed")); return actionHandled(); }); - addActionReceiver(manager::actions::CallRejectedByOfflineNotification, [this](auto &&data) { + addActionReceiver(manager::actions::CallRejectedByOfflineNotification, [this]([[maybe_unused]] auto &&data) { showNotificationAndRestartCallFlow(NotificationType::Info, utils::translate("app_call_offline")); return actionHandled(); }); - addActionReceiver(manager::actions::ActivateCall, [this](auto &&data) { - switchWindow(window::name_call); + addActionReceiver(manager::actions::ActivateCall, [this]([[maybe_unused]] auto &&data) { + switchWindow(gui::window::name::call); return actionHandled(); }); - addActionReceiver(manager::actions::HandleOutgoingCall, [this](auto &&data) { - switchWindow(window::name_call); + addActionReceiver(manager::actions::HandleOutgoingCall, [this]([[maybe_unused]] auto &&data) { + switchWindow(gui::window::name::call); return actionHandled(); }); - addActionReceiver(manager::actions::HandleIncomingCall, [this](auto &&data) { + addActionReceiver(manager::actions::HandleIncomingCall, [this]([[maybe_unused]] auto &&data) { callModel->setState(call::CallState::Incoming); - auto window = getCurrentWindow(); - if (window->getName() != app::window::name_call) { + const auto window = getCurrentWindow(); + if (window->getName() != gui::window::name::call) { LOG_INFO("Switch to call window"); - switchWindow(app::window::name_call); + switchWindow(gui::window::name::call); } return actionHandled(); }); addActionReceiver(manager::actions::HandleCallerId, [this](auto &&data) { - auto callParams = static_cast(data.get()); + const auto callParams = static_cast(data.get()); callModel->setPhoneNumber(callParams->getNumber()); callModel->setState(call::CallState::Incoming); - auto window = getCurrentWindow(); - if (window->getName() != app::window::name_call) { - LOG_INFO("Switch to call window"); - switchWindow(app::window::name_call); + const auto window = getCurrentWindow(); + if (window->getName() != gui::window::name::call) { + LOG_INFO("Switching to call window"); + switchWindow(gui::window::name::call); } return actionHandled(); }); @@ -145,7 +149,7 @@ namespace app // Invoked upon receiving data message sys::MessagePointer ApplicationCall::DataReceivedHandler(sys::DataMessage *msgl, sys::ResponseMessage *resp) { - auto retMsg = Application::DataReceivedHandler(msgl); + const auto retMsg = Application::DataReceivedHandler(msgl); // if message was handled by application's template there is no need to process further. auto response = dynamic_cast(retMsg.get()); assert(response); @@ -158,49 +162,48 @@ namespace app // Invoked during initialization sys::ReturnCodes ApplicationCall::InitHandler() { - - auto ret = Application::InitHandler(); + const auto ret = Application::InitHandler(); if (ret != sys::ReturnCodes::Success) { return ret; } connect(typeid(cellular::CallDurationNotification), [&](sys::Message *request) { - auto message = static_cast(request); + const auto message = static_cast(request); callModel->setTime(message->callDuration); return sys::MessageNone{}; }); - connect(typeid(cellular::CallActiveNotification), [&](sys::Message *request) { + connect(typeid(cellular::CallActiveNotification), [&]([[maybe_unused]] sys::Message *request) { callModel->setState(app::call::CallState::Active); return sys::MessageNone{}; }); - connect(typeid(cellular::CallMissedNotification), [&](sys::Message *request) { + connect(typeid(cellular::CallMissedNotification), [&]([[maybe_unused]] sys::Message *request) { callModel->setState(app::call::CallState::Missed); app::manager::Controller::switchBack(this); return sys::MessageNone{}; }); - connect(typeid(cellular::CallEndedNotification), [&](sys::Message *request) { + connect(typeid(cellular::CallEndedNotification), [&]([[maybe_unused]] sys::Message *request) { callModel->setState(app::call::CallState::Ended); - switchWindow(app::window::name_call); + switchWindow(gui::window::name::call); return sys::MessageNone{}; }); - connect(typeid(cellular::IsCallActive), [&](sys::Message *request) { + connect(typeid(cellular::IsCallActive), [&]([[maybe_unused]] sys::Message *request) { return std::make_shared(callModel->getState() != call::CallState::None); }); connect(typeid(cellular::CallStartedNotification), [&](sys::Message *request) { - auto message = static_cast(request); + const auto message = static_cast(request); callModel->setPhoneNumber(message->getNumber()); callModel->setState(app::call::CallState::Outgoing); - switchWindow(app::window::name_call); + switchWindow(gui::window::name::call); return sys::MessageNone{}; }); connect(typeid(AudioRoutingNotification), [this](sys::Message *request) { - auto message = static_cast(request); + const auto message = static_cast(request); return handleRoutingNotification(message); }); @@ -217,18 +220,22 @@ namespace app void ApplicationCall::createUserInterface() { - windowsFactory.attach(app::window::name_enterNumber, [](ApplicationCommon *app, const std::string &name) { - return std::make_unique(app, static_cast(app)); - }); - windowsFactory.attach(app::window::name_call, [this](ApplicationCommon *app, const std::string &name) { - return std::make_unique(app, *callPresenter); - }); - windowsFactory.attach(app::window::name_emergencyCall, [](ApplicationCommon *app, const std::string &name) { - return std::make_unique(app, static_cast(app)); - }); - windowsFactory.attach(app::window::name_dialogConfirm, [](ApplicationCommon *app, const std::string &name) { - return std::make_unique(app, name); - }); + windowsFactory.attach( + gui::window::name::enter_number, [](ApplicationCommon *app, [[maybe_unused]] const std::string &name) { + return std::make_unique(app, static_cast(app)); + }); + windowsFactory.attach(gui::window::name::call, + [this](ApplicationCommon *app, [[maybe_unused]] const std::string &name) { + return std::make_unique(app, *callPresenter); + }); + windowsFactory.attach( + gui::window::name::emergency_call, [](ApplicationCommon *app, [[maybe_unused]] const std::string &name) { + return std::make_unique(app, static_cast(app)); + }); + windowsFactory.attach(gui::window::name::call_dialog_confirm, + [](ApplicationCommon *app, const std::string &name) { + return std::make_unique(app, name); + }); attachPopups({gui::popup::ID::Volume, gui::popup::ID::Tethering, gui::popup::ID::PhoneModes, @@ -242,14 +249,14 @@ namespace app { auto metaData = std::make_unique(gui::DialogMetadata{"", icon, text, "", std::move(action)}); - switchWindow(app::window::name_dialogConfirm, gui::ShowMode::GUI_SHOW_INIT, std::move(metaData)); + switchWindow(gui::window::name::call_dialog_confirm, gui::ShowMode::GUI_SHOW_INIT, std::move(metaData)); return true; } auto ApplicationCall::showNotificationAndRestartCallFlow(NotificationType type, const std::string &text) -> bool { - auto buttonAction = [=]() -> bool { return conditionalReturnToPreviousView(); }; - auto icon = type == NotificationType::Info ? "info_128px_W_G" : "fail_128px_W_G"; + const auto buttonAction = [=]() -> bool { return conditionalReturnToPreviousView(); }; + const auto icon = type == NotificationType::Info ? "info_128px_W_G" : "fail_128px_W_G"; callModel->clear(); return showNotification(buttonAction, icon, text); } @@ -259,7 +266,7 @@ namespace app void ApplicationCall::handleEmergencyCallEvent(const std::string &number) { - auto state = callModel->getState(); + const auto state = callModel->getState(); if (state != call::CallState::None) { LOG_WARN("Cannot call in %s state", c_str(state)); return; @@ -275,7 +282,7 @@ namespace app void ApplicationCall::handleCallEvent(const std::string &number, ExternalRequest isExternalRequest) { - auto state = callModel->getState(); + const auto state = callModel->getState(); if (state != call::CallState::None) { LOG_WARN("Cannot call in %s state", c_str(state)); return; @@ -286,7 +293,7 @@ namespace app void ApplicationCall::handleAddContactEvent(const std::string &number) { - LOG_INFO("add contact information"); + LOG_INFO("Add contact information"); auto numberView = utils::PhoneNumber(number).getView(); auto searchResults = DBServiceAPI::MatchContactByPhoneNumber(this, numberView); @@ -310,11 +317,10 @@ namespace app sys::MessagePointer ApplicationCall::handleRoutingNotification(AudioRoutingNotification *message) { - if (auto window = getCurrentWindow(); window->getName() == app::window::name_call) { + if (const auto window = getCurrentWindow(); window->getName() == gui::window::name::call) { const auto currentRouting = message->profileType; callPresenter->processCurrentRouting(currentRouting); } return sys::MessageNone{}; } - } // namespace app diff --git a/module-apps/application-call/data/CallSwitchData.hpp b/module-apps/application-call/data/CallSwitchData.hpp index c4110381d40feb79906bc979564a3f4ff83acbb6..3af8d8d53df7ff8c8b4849fc55d65fa12da59a56 100644 --- a/module-apps/application-call/data/CallSwitchData.hpp +++ b/module-apps/application-call/data/CallSwitchData.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #pragma once @@ -6,12 +6,10 @@ #include "SwitchData.hpp" #include - #include namespace app { - class CallSwitchData : public gui::SwitchData { public: @@ -28,7 +26,7 @@ namespace app utils::PhoneNumber::View phoneNumber; public: - CallSwitchData(const utils::PhoneNumber::View &phoneNumber, Type type = Type::UNDEFINED) + explicit CallSwitchData(const utils::PhoneNumber::View &phoneNumber, Type type = Type::UNDEFINED) : SwitchData(descriptionStr), type(type), phoneNumber(phoneNumber){}; const Type &getType() const @@ -48,7 +46,7 @@ namespace app public: static constexpr auto descriptionStr = "EnterNumberSwitchData"; - EnterNumberData(const std::string &phoneNumber) : SwitchData(descriptionStr), phoneNumber(phoneNumber) + explicit EnterNumberData(const std::string &phoneNumber) : SwitchData(descriptionStr), phoneNumber(phoneNumber) {} const std::string &getPhoneNumber() const @@ -60,7 +58,7 @@ namespace app class ExecuteCallData : public CallSwitchData { public: - ExecuteCallData(const utils::PhoneNumber::View &phoneNumber) + explicit ExecuteCallData(const utils::PhoneNumber::View &phoneNumber) : CallSwitchData(phoneNumber, app::CallSwitchData::Type::EXECUTE_CALL){}; }; } /* namespace app */ diff --git a/module-apps/application-call/include/application-call/ApplicationCall.hpp b/module-apps/application-call/include/application-call/ApplicationCall.hpp index 214474068396108a4e2f9e0cf4c8e5b3641497c2..c576b0f493aa03e634ff0c45474e9082f53fb031 100644 --- a/module-apps/application-call/include/application-call/ApplicationCall.hpp +++ b/module-apps/application-call/include/application-call/ApplicationCall.hpp @@ -5,6 +5,7 @@ #include #include +#include #include #include #include @@ -17,18 +18,7 @@ namespace app { - inline constexpr auto name_call = "ApplicationCall"; - inline constexpr auto call_stack_size = 8192U; - - namespace window - { - inline constexpr auto name_enterNumber = gui::name::window::main_window; - inline constexpr auto name_call = "CallWindow"; - inline constexpr auto name_emergencyCall = "EmergencyCallWindow"; - inline constexpr auto name_duplicatedContact = "DuplicatedContactWindow"; - inline constexpr auto name_dialogConfirm = "DialogConfirm"; - inline constexpr auto name_number = "NumberWindow"; - } // namespace window + inline constexpr auto name_call = "ApplicationCall"; class EnterNumberWindowInterface { @@ -56,7 +46,7 @@ namespace app sys::ReturnCodes InitHandler() override; sys::MessagePointer handleAppClose(sys::Message *msgl) override; - sys::ReturnCodes SwitchPowerModeHandler(const sys::ServicePowerMode mode) override final + sys::ReturnCodes SwitchPowerModeHandler([[maybe_unused]] const sys::ServicePowerMode mode) override final { return sys::ReturnCodes::Success; } diff --git a/module-apps/application-call/windows/CallWindow.cpp b/module-apps/application-call/windows/CallWindow.cpp index 46ed636a9f2326593f652aa03d0fc1dc955f23bf..52e27bf306ec4bd52234f299faaaa6842b9c3106 100644 --- a/module-apps/application-call/windows/CallWindow.cpp +++ b/module-apps/application-call/windows/CallWindow.cpp @@ -27,7 +27,7 @@ namespace gui using namespace app::call; CallWindow::CallWindow(app::ApplicationCommon *app, app::call::CallWindowContract::Presenter &presenter) - : gui::AppWindow{app, app::window::name_call}, presenter{presenter} + : gui::AppWindow{app, gui::window::name::call}, presenter{presenter} { presenter.attach(this); presenter.attachCallbacks(); @@ -79,7 +79,7 @@ namespace gui iconsBox->setEdges(RectangleEdge::None); microphoneIcon = new MicrophoneIcon(iconsBox); - microphoneIcon->activatedCallback = [=](gui::Item &item) { + microphoneIcon->activatedCallback = [=]([[maybe_unused]] gui::Item &item) { microphoneIcon->setNext(); LOG_INFO("Microphone %s", static_cast(microphoneIcon->get()) ? "activated" : "deactivated"); @@ -89,7 +89,7 @@ namespace gui }; speakerIcon = new SpeakerIcon(iconsBox); - speakerIcon->activatedCallback = [=](gui::Item &item) { + speakerIcon->activatedCallback = [=]([[maybe_unused]] gui::Item &item) { speakerIcon->setNext(); LOG_INFO("Speaker %s", static_cast(speakerIcon->get()) ? "activated" : "deactivated"); @@ -154,11 +154,11 @@ namespace gui } } - void CallWindow::onBeforeShow(ShowMode mode, SwitchData *data) + void CallWindow::onBeforeShow([[maybe_unused]] ShowMode mode, SwitchData *data) { presenter.buildLayout(); - if (auto switchData = dynamic_cast(data); switchData != nullptr) { + if (const auto switchData = dynamic_cast(data); switchData != nullptr) { presenter.hangUpCall(); presenter.sendSms(switchData->getText()); return; @@ -208,7 +208,7 @@ namespace gui void CallWindow::connectTimerOnExit() { - timerCallback = [this](Item &, sys::Timer &timer) { + timerCallback = [this]([[maybe_unused]] Item &item, [[maybe_unused]] sys::Timer &timer) { LOG_DEBUG("Delayed exit timer callback"); presenter.handleDelayedViewClose(); application->popCurrentWindow(); diff --git a/module-apps/application-call/windows/CallWindow.hpp b/module-apps/application-call/windows/CallWindow.hpp index 2a6cb233d61402b0021ab1c166ce7de8d44fabda..f3acb810897b2a0d4de5c275b41ec6403e89807f 100644 --- a/module-apps/application-call/windows/CallWindow.hpp +++ b/module-apps/application-call/windows/CallWindow.hpp @@ -69,5 +69,4 @@ namespace gui gui::SpeakerIconState getSpeakerIconState() override; void setSpeakerIconState(const gui::SpeakerIconState &icon) override; }; - } /* namespace gui */ diff --git a/module-apps/application-call/windows/EmergencyCallWindow.cpp b/module-apps/application-call/windows/EmergencyCallWindow.cpp index 56e7f5fae16e60c3eaa264780afebb6a75c0875f..08726ceff74d7bda689491c6b0722a5709a5d69c 100644 --- a/module-apps/application-call/windows/EmergencyCallWindow.cpp +++ b/module-apps/application-call/windows/EmergencyCallWindow.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #include "CallAppStyle.hpp" @@ -10,7 +10,7 @@ namespace gui { EmergencyCallWindow::EmergencyCallWindow(app::ApplicationCommon *app, app::EnterNumberWindowInterface *interface) - : NumberWindow(app, interface, app::window::name_emergencyCall) + : NumberWindow(app, interface, gui::window::name::emergency_call) { buildInterface(); } diff --git a/module-apps/application-call/windows/EmergencyCallWindow.hpp b/module-apps/application-call/windows/EmergencyCallWindow.hpp index 3ae58e63a3a54e86db9006908d280e8fe64eb0c1..757343ada3d33116af4573609f0b28ad907d31a4 100644 --- a/module-apps/application-call/windows/EmergencyCallWindow.hpp +++ b/module-apps/application-call/windows/EmergencyCallWindow.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #pragma once @@ -7,7 +7,6 @@ namespace gui { - class EmergencyCallWindow : public NumberWindow { public: @@ -19,5 +18,4 @@ namespace gui void buildInterface() override; status_bar::Configuration configureStatusBar(status_bar::Configuration appConfiguration) override; }; - } /* namespace gui */ diff --git a/module-apps/application-call/windows/EnterNumberWindow.cpp b/module-apps/application-call/windows/EnterNumberWindow.cpp index 08702bb570b2f39446d156deda70c75844590cda..7fa1b58d1d7fa443ee7635de107a042c36d7e644 100644 --- a/module-apps/application-call/windows/EnterNumberWindow.cpp +++ b/module-apps/application-call/windows/EnterNumberWindow.cpp @@ -30,13 +30,13 @@ namespace gui navBar->setText(nav_bar::Side::Center, utils::translate("common_add")); navBar->setText(nav_bar::Side::Right, utils::translate("app_call_clear")); - auto iconsBox = new HBox( + const auto iconsBox = new HBox( this, style::window::default_left_margin, iconsBox::y, style::window::default_body_width, iconsBox::h); iconsBox->setAlignment(Alignment(Alignment::Horizontal::Center, Alignment::Vertical::Top)); iconsBox->setEdges(RectangleEdge::None); newContactIcon = new gui::AddContactIcon(iconsBox); - newContactIcon->activatedCallback = [=](gui::Item &item) { return addNewContact(); }; + newContactIcon->activatedCallback = [=]([[maybe_unused]] gui::Item &item) { return addNewContact(); }; setFocusItem(newContactIcon); iconsBox->resizeItems(); @@ -62,7 +62,7 @@ namespace gui } if (data->getDescription() == app::EnterNumberData::descriptionStr) { - auto *callData = dynamic_cast(data); + const auto callData = dynamic_cast(data); assert(callData != nullptr); initFormatterInput(callData->getPhoneNumber()); @@ -70,10 +70,10 @@ namespace gui application->refreshWindow(RefreshModes::GUI_REFRESH_FAST); } else if (data->getDescription() == app::CallSwitchData::descriptionStr) { - auto *callData = dynamic_cast(data); + const auto callData = dynamic_cast(data); assert(callData != nullptr); - auto &phoneNumber = callData->getPhoneNumber(); + const auto &phoneNumber = callData->getPhoneNumber(); initFormatterInput(phoneNumber.getEntered()); setNumberLabel(phoneNumber.getFormatted()); @@ -84,8 +84,7 @@ namespace gui } } else { - LOG_ERROR("Unhandled switch data"); - abort(); + LOG_ERROR("Unhandled switch data: %s", data->getDescription().c_str()); } return true; diff --git a/module-apps/application-call/windows/EnterNumberWindow.hpp b/module-apps/application-call/windows/EnterNumberWindow.hpp index 37b70f31be719b12e1babbf034b9f3382a86b8d9..7982bbae25090a603460697b308ceb0d246d37a5 100644 --- a/module-apps/application-call/windows/EnterNumberWindow.hpp +++ b/module-apps/application-call/windows/EnterNumberWindow.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #pragma once @@ -15,7 +15,7 @@ namespace gui public: EnterNumberWindow(app::ApplicationCommon *app, app::EnterNumberWindowInterface *interface, - std::string windowName = app::window::name_enterNumber); + std::string windowName = gui::window::name::enter_number); ~EnterNumberWindow() override = default; auto handleSwitchData(SwitchData *data) -> bool override; @@ -26,5 +26,4 @@ namespace gui auto addNewContact() -> bool; }; - } /* namespace gui */ diff --git a/module-apps/application-call/windows/NumberWindow.hpp b/module-apps/application-call/windows/NumberWindow.hpp index 677aa2d1d5325e8c18bc583c5825e51d4f52ec1c..1beba03cf6535b1bff8c2dcadec95a81093dea4c 100644 --- a/module-apps/application-call/windows/NumberWindow.hpp +++ b/module-apps/application-call/windows/NumberWindow.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #pragma once @@ -26,7 +26,7 @@ namespace gui NumberWindow(app::ApplicationCommon *app, app::EnterNumberWindowInterface *interface, - std::string windowName = app::window::name_number); + std::string windowName = gui::window::name::number); auto onInput(const InputEvent &inputEvent) -> bool override; [[nodiscard]] auto getEnteredNumber() const noexcept -> const std::string &; diff --git a/module-apps/application-call/windows/WindowNames.hpp b/module-apps/application-call/windows/WindowNames.hpp new file mode 100644 index 0000000000000000000000000000000000000000..8c005deede5a5b3688cd5c750806a3648d83cd1b --- /dev/null +++ b/module-apps/application-call/windows/WindowNames.hpp @@ -0,0 +1,15 @@ +// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved. +// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md + +#pragma once + +#include + +namespace gui::window::name +{ + inline constexpr auto enter_number = gui::name::window::main_window; + inline constexpr auto call = "CallWindow"; + inline constexpr auto emergency_call = "EmergencyCallWindow"; + inline constexpr auto call_dialog_confirm = "DialogConfirm"; + inline constexpr auto number = "NumberWindow"; +} // namespace gui::window::name diff --git a/module-apps/application-calllog/include/application-calllog/ApplicationCallLog.hpp b/module-apps/application-calllog/include/application-calllog/ApplicationCallLog.hpp index d5dbde2d34766d2b18e7cc7fbdab090dd6487a81..41079dd3b884a10ebb2fe19422a399163e784748 100644 --- a/module-apps/application-calllog/include/application-calllog/ApplicationCallLog.hpp +++ b/module-apps/application-calllog/include/application-calllog/ApplicationCallLog.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #pragma once @@ -9,13 +9,12 @@ namespace app { - - inline constexpr auto CallLogAppStr = "ApplicationCallLog"; + inline constexpr auto name_calllog = "ApplicationCallLog"; class ApplicationCallLog : public Application { public: - ApplicationCallLog(std::string name = CallLogAppStr, + ApplicationCallLog(std::string name = name_calllog, std::string parent = {}, StatusIndicators statusIndicators = StatusIndicators{}, StartInBackground startInBackground = {false}); @@ -25,7 +24,7 @@ namespace app sys::ReturnCodes InitHandler() override; sys::ReturnCodes DeinitHandler() override; - sys::ReturnCodes SwitchPowerModeHandler(const sys::ServicePowerMode mode) override final + sys::ReturnCodes SwitchPowerModeHandler([[maybe_unused]] const sys::ServicePowerMode mode) override final { return sys::ReturnCodes::Success; } diff --git a/module-apps/application-desktop/windows/DesktopMainWindow.cpp b/module-apps/application-desktop/windows/DesktopMainWindow.cpp index 65dac19e623d57cdf31be9efba7b984f6d945e63..25dce6b5cbaab327e8c883576d702e558023c63c 100644 --- a/module-apps/application-desktop/windows/DesktopMainWindow.cpp +++ b/module-apps/application-desktop/windows/DesktopMainWindow.cpp @@ -16,6 +16,12 @@ #include +namespace +{ + constexpr auto pageFirstNotificationIdx = 0; + constexpr auto pageLastNotificationIdx = style::notifications::model::maxNotificationsPerPage - 1; +} // namespace + namespace gui { void DesktopMainWindow::buildInterface() @@ -88,7 +94,7 @@ namespace gui void DesktopMainWindow::onBeforeShow(ShowMode mode, SwitchData *data) { - if (auto notificationData = dynamic_cast(data)) { + if (const auto notificationData = dynamic_cast(data)) { notificationsModel->updateData(notificationData); } else { @@ -112,15 +118,9 @@ namespace gui return AppWindow::onInput(inputEvent); } - namespace - { - constexpr auto pageFirstNotificationIdx = 0; - constexpr auto pageLastNotificationIdx = style::notifications::model::maxNotificationsPerPage - 1; - } // namespace - bool DesktopMainWindow::processShortReleaseEvent(const InputEvent &inputEvent) { - auto code = translator.handle(inputEvent.getRawKey(), InputMode({InputMode::phone}).get()); + const auto code = translator.handle(inputEvent.getRawKey(), InputMode({InputMode::phone}).get()); // if numeric key was pressed record that key and send it to call application if (code != 0) { const auto &number = std::string(1, static_cast(code)); @@ -200,7 +200,7 @@ namespace gui app::ApplicationDesktop *DesktopMainWindow::getAppDesktop() const { - auto *app = dynamic_cast(application); + const auto app = dynamic_cast(application); assert(app); return app; } @@ -220,5 +220,4 @@ namespace gui return app::manager::Controller::sendAction( application, app::manager::actions::Dial, std::make_unique(number)); } - } /* namespace gui */ diff --git a/module-apps/application-messages/windows/SMSTemplatesWindow.cpp b/module-apps/application-messages/windows/SMSTemplatesWindow.cpp index 8b7515b7867287d7cadac8b17aaa0dc38de1df98..84fd16f9ae902462c59cc2949bc3a096c69ba213 100644 --- a/module-apps/application-messages/windows/SMSTemplatesWindow.cpp +++ b/module-apps/application-messages/windows/SMSTemplatesWindow.cpp @@ -90,7 +90,7 @@ namespace gui auto requestingWindow = switchData->requestingWindow; app->templatesCallback = [=](std::shared_ptr templ) { - LOG_DEBUG("SMS template id = %" PRIu32 "chosen", templ->ID); + LOG_DEBUG("SMS template id = %" PRIu32 " chosen", templ->ID); auto data = std::make_unique(templ->text, SMSTextData::Concatenate::True); application->switchWindow(requestingWindow, std::move(data)); return true; @@ -105,7 +105,7 @@ namespace gui assert(app != nullptr); app->templatesCallback = [=](std::shared_ptr templ) { - LOG_DEBUG("SMS template id = %" PRIu32 "sent", templ->ID); + LOG_DEBUG("SMS template id = %" PRIu32 " sent", templ->ID); app::manager::Controller::switchBack( app, std::make_unique(application->GetName(), diff --git a/module-apps/application-special-input/include/application-special-input/ApplicationSpecialInput.hpp b/module-apps/application-special-input/include/application-special-input/ApplicationSpecialInput.hpp index 258f28dcc85c3c68fc8118805aa3067494a88bc7..c53e95d538b5746ca9ac28439fb7fd6804628af1 100644 --- a/module-apps/application-special-input/include/application-special-input/ApplicationSpecialInput.hpp +++ b/module-apps/application-special-input/include/application-special-input/ApplicationSpecialInput.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #pragma once @@ -9,8 +9,7 @@ namespace app { - - inline constexpr auto special_input = "ApplicationSpecialInput"; + inline constexpr auto name_special_input = "ApplicationSpecialInput"; inline constexpr auto char_select = gui::name::window::main_window; // app just to provide input selection on UI @@ -19,7 +18,7 @@ namespace app public: std::string requester = ""; - ApplicationSpecialInput(std::string name = special_input, + ApplicationSpecialInput(std::string name = name_special_input, std::string parent = {}, StatusIndicators statusIndicators = StatusIndicators{}, StartInBackground startInBackground = {true}); diff --git a/module-services/service-cellular/CellularServiceAPI.cpp b/module-services/service-cellular/CellularServiceAPI.cpp index df833afffe6b54bdf91ec59652f86fde25c0ed9e..496e709c39c529b5d22bebd60e1024e032dcc27b 100644 --- a/module-services/service-cellular/CellularServiceAPI.cpp +++ b/module-services/service-cellular/CellularServiceAPI.cpp @@ -261,7 +261,7 @@ bool CellularServiceAPI::IsCallStateForCallApplicationActive(sys::Service *serv, { // Ask ApplicationCall (if App even exist) about its internal Call State auto msg = std::make_shared(); - auto ret = serv->bus.sendUnicastSync(msg, app::name_call, 1000); + const auto ret = serv->bus.sendUnicastSync(std::move(msg), app::name_call, 1000); if (ret.first == sys::ReturnCodes::Success) { auto celResponse = std::dynamic_pointer_cast(ret.second); if ((celResponse != nullptr) && (celResponse->retCode == sys::ReturnCodes::Success)) { diff --git a/products/PurePhone/PurePhoneMain.cpp b/products/PurePhone/PurePhoneMain.cpp index bdb2e1016ceb29ca7a7571fc80df753b72a469d0..5b17c9928c83c1d414f6bf25826839ed374a035a 100644 --- a/products/PurePhone/PurePhoneMain.cpp +++ b/products/PurePhone/PurePhoneMain.cpp @@ -220,7 +220,7 @@ int main() applications.push_back(app::CreateLauncher(app::name_notes)); #endif #ifdef ENABLE_APP_CALLLOG - applications.push_back(app::CreateLauncher(app::CallLogAppStr)); + applications.push_back(app::CreateLauncher(app::name_calllog)); #endif #ifdef ENABLE_APP_PHONEBOOK applications.push_back(app::CreateLauncher(app::name_phonebook)); @@ -230,7 +230,7 @@ int main() #endif #ifdef ENABLE_APP_SPECIAL_INPUT applications.push_back( - app::CreateLauncher(app::special_input, app::Closeable::False)); + app::CreateLauncher(app::name_special_input, app::Closeable::False)); #endif #ifdef ENABLE_APP_ANTENNA applications.push_back(app::CreateLauncher(app::name_antenna)); diff --git a/products/PurePhone/services/appmgr/RunAppsInBackground.cpp b/products/PurePhone/services/appmgr/RunAppsInBackground.cpp index 14e4e7604d195b971eafc44594805f2e686eaa93..656b26645787e577a35439eb06592185985a7b0f 100644 --- a/products/PurePhone/services/appmgr/RunAppsInBackground.cpp +++ b/products/PurePhone/services/appmgr/RunAppsInBackground.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #include @@ -6,10 +6,9 @@ namespace app::manager { - void ApplicationManager::runAppsInBackground() { - for (const auto &name : std::vector{app::special_input}) { + for (const auto &name : std::vector{app::name_special_input}) { if (auto app = getApplication(name); app != nullptr) { StatusIndicators statusIndicators; statusIndicators.phoneMode = phoneModeObserver->getCurrentPhoneMode(); diff --git a/pure_changelog.md b/pure_changelog.md index 7d5a95b5f521571aee2b4db1118075f9471b84ef..dd166890b4cc4db8602f15a2cf52420476be9c18 100644 --- a/pure_changelog.md +++ b/pure_changelog.md @@ -27,6 +27,7 @@ * Fixed frequency lock during user activity * Fixed crash on transferring audio file with big metadata * Fixed possibility of OS crash during update package size check +* Fixed possible crash when entering phone number ## [1.8.0 2023-09-27]