From d68458f1b25c0607a90ee2b8faa9f700ee29640a Mon Sep 17 00:00:00 2001 From: Mateusz Grzegorzek Date: Mon, 23 Aug 2021 12:56:11 +0200 Subject: [PATCH] [BH-740] Split ApplicationManager - move `LowBattery` handling to Pure `ApplicationManager`, - cleanup `ApplicationManagerCommon` --- module-services/service-appmgr/CMakeLists.txt | 1 - .../service-appmgr/model/ActionsRegistry.hpp | 3 +- .../model/ApplicationManagerCommon.hpp | 17 +----- .../service-appmgr/model/ActionsRegistry.cpp | 2 - .../model/ApplicationManagerCommon.cpp | 56 +------------------ .../services/appmgr/ApplicationManager.cpp | 38 +++++++++---- .../PurePhone/services/appmgr/CMakeLists.txt | 1 + .../include/appmgr/ApplicationManager.hpp | 5 ++ 8 files changed, 39 insertions(+), 84 deletions(-) diff --git a/module-services/service-appmgr/CMakeLists.txt b/module-services/service-appmgr/CMakeLists.txt index 545e65ff10381292d9795875574ad7c464af9179..c112ddbe8681de38c937aaa639089118b2670b8b 100644 --- a/module-services/service-appmgr/CMakeLists.txt +++ b/module-services/service-appmgr/CMakeLists.txt @@ -70,7 +70,6 @@ target_sources(service-appmgr target_link_libraries(service-appmgr PRIVATE - application-desktop application-special-input json::json module-audio diff --git a/module-services/service-appmgr/include/service-appmgr/model/ActionsRegistry.hpp b/module-services/service-appmgr/include/service-appmgr/model/ActionsRegistry.hpp index 84cbc9239ef46e085f0b85faa0e8e8cd9846144c..ca8662e9359555eb6a693620973eef1730127116 100644 --- a/module-services/service-appmgr/include/service-appmgr/model/ActionsRegistry.hpp +++ b/module-services/service-appmgr/include/service-appmgr/model/ActionsRegistry.hpp @@ -42,8 +42,7 @@ namespace app::manager { Accepted, Skipped, - Dropped, - NotHandled + Dropped }; class ActionsRegistry 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 314ce54c5f0468c3f6f85fd39621c0c383baac16..bb8b6aa67f69758ba31ae2b80c3f15b9eb513724 100644 --- a/module-services/service-appmgr/include/service-appmgr/model/ApplicationManagerCommon.hpp +++ b/module-services/service-appmgr/include/service-appmgr/model/ApplicationManagerCommon.hpp @@ -13,13 +13,10 @@ #include #include -#include #include #include #include #include -#include -#include #include #include @@ -33,8 +30,6 @@ #include #include -#include -#include #include #include @@ -43,13 +38,6 @@ namespace app class ApplicationLauncher; namespace manager { - class APMAction; - class APMChangeLanguage; - class APMConfirmClose; - class APMConfirmSwitch; - class APMRegister; - class APMSwitch; - class APMSwitchPrevApp; class GetAutoLockTimeoutRequest; class SetAutoLockTimeoutRequest; } // namespace manager @@ -120,6 +108,8 @@ namespace app::manager } auto checkOnBoarding() -> bool; virtual void registerMessageHandlers(); + auto handleSwitchApplication(SwitchRequest *msg, bool closeCurrentlyFocusedApp = true) -> bool; + virtual void handleStart(StartAllowedMessage *msg); ApplicationName rootApplicationName; ActionsRegistry actionsRegistry; @@ -130,7 +120,6 @@ namespace app::manager void suspendSystemServices(); void closeNoLongerNeededApplications(); auto closeApplications() -> bool; - auto closeApplicationsOnUpdate() -> bool; void closeApplication(ApplicationHandle *application); // Message handlers @@ -141,7 +130,6 @@ namespace app::manager auto handleActionOnFocusedApp(ActionEntry &action) -> ActionProcessStatus; auto handleCustomAction(ActionEntry &action) -> ActionProcessStatus; auto handleCustomActionOnBackgroundApp(ApplicationHandle *app, ActionEntry &action) -> ActionProcessStatus; - auto handleSwitchApplication(SwitchRequest *msg, bool closeCurrentlyFocusedApp = true) -> bool; auto handleCloseConfirmation(CloseConfirmation *msg) -> bool; auto handleSwitchConfirmation(SwitchConfirmation *msg) -> bool; auto handleSwitchBack(SwitchBackRequest *msg) -> bool; @@ -152,7 +140,6 @@ namespace app::manager virtual auto handleDeveloperModeRequest(sys::Message *request) -> sys::MessagePointer; /// handles dom request by passing this request to application which should provide the dom auto handleDOMRequest(sys::Message *request) -> std::shared_ptr; - void handleStart(StartAllowedMessage *msg); void requestApplicationClose(ApplicationHandle &app, bool isCloseable); void onApplicationSwitch(ApplicationHandle &nextApp, diff --git a/module-services/service-appmgr/model/ActionsRegistry.cpp b/module-services/service-appmgr/model/ActionsRegistry.cpp index 55757d1c018427dc684973fa0668ec4f3d591169..3e237e216964bd17da822eefa53cd2f65fd9e57a 100644 --- a/module-services/service-appmgr/model/ActionsRegistry.cpp +++ b/module-services/service-appmgr/model/ActionsRegistry.cpp @@ -84,8 +84,6 @@ namespace app::manager it = actions.erase(it); break; } - case ActionProcessStatus::NotHandled: - [[fallthrough]]; case ActionProcessStatus::Skipped: // Skip the action and check the next one. ++it; diff --git a/module-services/service-appmgr/model/ApplicationManagerCommon.cpp b/module-services/service-appmgr/model/ApplicationManagerCommon.cpp index 963fbb893e016cb7a91760e89314a7faf35adca0..c0c637db6974c60a10790c1903fc44f255a8ca73 100644 --- a/module-services/service-appmgr/model/ApplicationManagerCommon.cpp +++ b/module-services/service-appmgr/model/ApplicationManagerCommon.cpp @@ -3,43 +3,25 @@ #include "ApplicationManagerCommon.hpp" #include "ApplicationStatus.hpp" -#include "AutoLockRequests.hpp" #include "Controller.hpp" #include "DOMRequest.hpp" #include "FinishRequest.hpp" -#include "GetAllNotificationsRequest.hpp" #include "Message.hpp" -#include #include #include #include -#include -#include -#include -#include #include -#include #include -#include -#include -#include #include #include -#include #include #include -#include #include #include -#include -#include -#include -#include #include #include #include -#include #include #include @@ -151,23 +133,8 @@ namespace app::manager void ApplicationManagerCommon::handleStart(StartAllowedMessage *msg) { - switch (msg->getStartupType()) { - case StartupType::Regular: - if (auto app = getApplication(rootApplicationName); app != nullptr) { - Controller::sendAction(this, actions::Home); - } - break; - case StartupType::LowBattery: - handleSwitchApplication(std::make_unique( - service::name::appmgr, app::name_desktop, window::name::dead_battery, nullptr) - .get()); - break; - case StartupType::LowBatteryCharging: - handleSwitchApplication( - std::make_unique( - service::name::appmgr, app::name_desktop, window::name::charging_battery, nullptr) - .get()); - break; + if (auto app = getApplication(rootApplicationName); app != nullptr) { + Controller::sendAction(this, actions::Home); } } @@ -353,23 +320,6 @@ namespace app::manager } } - auto ApplicationManagerCommon::closeApplicationsOnUpdate() -> bool - { - for (const auto &app : getApplications()) { - if (app->started()) { - auto appName = app->name(); - if (appName == app::name_desktop) { - LOG_DEBUG("Delay closing %s", app::name_desktop); - continue; - } - LOG_INFO("Closing application on Update %s", appName.c_str()); - closeApplication(app.get()); - app->setState(ApplicationHandle::State::DEACTIVATED); - } - } - return true; - } - void ApplicationManagerCommon::closeApplication(ApplicationHandle *application) { if (application == nullptr) { @@ -468,8 +418,6 @@ namespace app::manager return handleHomeAction(action); case actions::Launch: return handleLaunchAction(action); - case actions::PhoneModeChanged: - return ActionProcessStatus::NotHandled; case actions::ShowPopup: [[fallthrough]]; case actions::AbortPopup: diff --git a/products/PurePhone/services/appmgr/ApplicationManager.cpp b/products/PurePhone/services/appmgr/ApplicationManager.cpp index 852a7d4cec7c54b771159ff33b05891dfa68503a..1f5eb6d484b0003641af803f87542c2f118e6a26 100644 --- a/products/PurePhone/services/appmgr/ApplicationManager.cpp +++ b/products/PurePhone/services/appmgr/ApplicationManager.cpp @@ -3,6 +3,7 @@ #include +#include #include #include #include @@ -12,17 +13,18 @@ #include #include #include -#include +#include +#include #include -#include -#include +#include #include +#include #include #include #include #include -#include -#include +#include +#include namespace app::manager { @@ -464,15 +466,31 @@ namespace app::manager auto ApplicationManager::handleAction(ActionEntry &action) -> ActionProcessStatus { - const auto status = ApplicationManagerCommon::handleAction(action); - if (status != ActionProcessStatus::NotHandled) { - return status; - } switch (action.actionId) { case actions::PhoneModeChanged: return handlePhoneModeChangedAction(action); default: - return ActionProcessStatus::NotHandled; + return ApplicationManagerCommon::handleAction(action); + } + } + + void ApplicationManager::handleStart(StartAllowedMessage *msg) + { + switch (msg->getStartupType()) { + case StartupType::Regular: + ApplicationManagerCommon::handleStart(msg); + break; + case StartupType::LowBattery: + handleSwitchApplication(std::make_unique( + service::name::appmgr, app::name_desktop, window::name::dead_battery, nullptr) + .get()); + break; + case StartupType::LowBatteryCharging: + handleSwitchApplication( + std::make_unique( + service::name::appmgr, app::name_desktop, window::name::charging_battery, nullptr) + .get()); + break; } } } // namespace app::manager diff --git a/products/PurePhone/services/appmgr/CMakeLists.txt b/products/PurePhone/services/appmgr/CMakeLists.txt index 4228d662dde8d2466e2b60691b90058a5c3a897f..3f29503326d621f13aee9fc483ac893fb6d3276c 100644 --- a/products/PurePhone/services/appmgr/CMakeLists.txt +++ b/products/PurePhone/services/appmgr/CMakeLists.txt @@ -14,6 +14,7 @@ target_include_directories(appmgr target_link_libraries(appmgr PRIVATE + application-desktop application-special-input apps-common module-apps diff --git a/products/PurePhone/services/appmgr/include/appmgr/ApplicationManager.hpp b/products/PurePhone/services/appmgr/include/appmgr/ApplicationManager.hpp index 77f6f67e27e0dc3c01236633b0cbcca6e81df497..3af6e3160237c481f29bb849f6281c921a197142 100644 --- a/products/PurePhone/services/appmgr/include/appmgr/ApplicationManager.hpp +++ b/products/PurePhone/services/appmgr/include/appmgr/ApplicationManager.hpp @@ -5,6 +5,10 @@ #include +#include +#include +#include + namespace app::manager { class ApplicationManager : public ApplicationManagerCommon @@ -38,6 +42,7 @@ namespace app::manager auto handleDBResponse(db::QueryResponse *msg) -> bool; auto handlePhoneModeChangedAction(ActionEntry &action) -> ActionProcessStatus; auto handleAction(ActionEntry &action) -> ActionProcessStatus override; + void handleStart(StartAllowedMessage *msg) override; std::shared_ptr phoneModeObserver; locks::PhoneLockHandler phoneLockHandler;