From 2d7f9ad5b7f149c4b9015b50e16e447ff051b3de Mon Sep 17 00:00:00 2001 From: Maciej Gibowicz Date: Wed, 1 Jun 2022 09:30:29 +0200 Subject: [PATCH] [MOS-515] Fix freezing on the on-boarding screen The synchronization of the application startup has been improved. --- .../model/ApplicationManagerCommon.hpp | 2 ++ .../model/ApplicationManagerCommon.cpp | 23 ++++++++++++++++--- .../services/appmgr/ApplicationManager.cpp | 5 ++++ 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/module-services/service-appmgr/include/service-appmgr/model/ApplicationManagerCommon.hpp b/module-services/service-appmgr/include/service-appmgr/model/ApplicationManagerCommon.hpp index 9897ed35f05cb82eaef50a8fc1e9933c62ad0e51..51e97453cde795dcafe979ea43b87695a2ebb24f 100644 --- a/module-services/service-appmgr/include/service-appmgr/model/ApplicationManagerCommon.hpp +++ b/module-services/service-appmgr/include/service-appmgr/model/ApplicationManagerCommon.hpp @@ -108,6 +108,7 @@ namespace app::manager virtual auto handleActionOnFocusedApp(ActionEntry &action) -> ActionProcessStatus; virtual auto handleDisplayLanguageChange(DisplayLanguageChangeRequest *msg) -> bool; void rebuildActiveApplications(); + auto isApplicationStarting(ApplicationHandle &app) const noexcept -> bool; ApplicationName rootApplicationName; ActionsRegistry actionsRegistry; @@ -119,6 +120,7 @@ namespace app::manager void closeNoLongerNeededApplications(); auto closeApplications() -> bool; void closeApplication(ApplicationHandle *application); + auto getStartingApplication() const noexcept -> ApplicationHandle *; // Message handlers void handleActionRequest(ActionRequest *actionMsg); diff --git a/module-services/service-appmgr/model/ApplicationManagerCommon.cpp b/module-services/service-appmgr/model/ApplicationManagerCommon.cpp index 126f4dc8e725bcb11a82e30087060a63c475b932..2bbd06e3806859c95c93787264d6465d95f9ddba 100644 --- a/module-services/service-appmgr/model/ApplicationManagerCommon.cpp +++ b/module-services/service-appmgr/model/ApplicationManagerCommon.cpp @@ -381,9 +381,9 @@ namespace app::manager auto currentlyFocusedApp = getFocusedApplication(); if (currentlyFocusedApp == nullptr) { - if (auto appState = app->state(); appState == ApplicationCommon::State::INITIALIZING || - appState == ApplicationCommon::State::ACTIVATING) { - LOG_INFO("No focused application at the moment, but %s is starting already...", app->name().c_str()); + if (auto startingApplication = getStartingApplication(); startingApplication != nullptr) { + LOG_INFO("No focused application at the moment, but %s is starting already...", + startingApplication->name().c_str()); return false; } LOG_INFO("No focused application at the moment. Starting new application..."); @@ -857,4 +857,21 @@ namespace app::manager { return sys::msgNotHandled(); } + + auto ApplicationManagerCommon::isApplicationStarting(ApplicationHandle &app) const noexcept -> bool + { + return (app.state() == app::ApplicationCommon::State::INITIALIZING || + app.state() == app::ApplicationCommon::State::ACTIVATING); + } + + auto ApplicationManagerCommon::getStartingApplication() const noexcept -> ApplicationHandle * + { + for (const auto &item : stack) { + if (auto app = getApplication(item.appName); app != nullptr && isApplicationStarting(*app)) { + return app; + } + } + return nullptr; + } + } // namespace app::manager diff --git a/products/PurePhone/services/appmgr/ApplicationManager.cpp b/products/PurePhone/services/appmgr/ApplicationManager.cpp index a3eb5ffc026bd6d9b2496f7c2e1c4b69b184af02..f9470c57537e73530e5cdf9a70d96d7d193ccd8a 100644 --- a/products/PurePhone/services/appmgr/ApplicationManager.cpp +++ b/products/PurePhone/services/appmgr/ApplicationManager.cpp @@ -521,6 +521,11 @@ namespace app::manager auto ApplicationManager::startApplication(ApplicationHandle &app) -> bool { if (not ApplicationManagerCommon::startApplication(app)) { + if (ApplicationManagerCommon::isApplicationStarting(app)) { + LOG_INFO("%s is starting already...", app.name().c_str()); + return false; + } + LOG_INFO("Starting application %s", app.name().c_str()); StatusIndicators statusIndicators; statusIndicators.phoneMode = phoneModeObserver->getCurrentPhoneMode();