A => +0 -0
A image/assets/images/dead_battery_W_G.vpi => image/assets/images/dead_battery_W_G.vpi +0 -0
M module-apps/application-desktop/ApplicationDesktop.cpp => module-apps/application-desktop/ApplicationDesktop.cpp +9 -0
@@ 8,6 8,7 @@
#include "windows/MenuWindow.hpp"
#include "windows/PinLockWindow.hpp"
#include "windows/PowerOffWindow.hpp"
+#include "windows/DeadBatteryWindow.hpp"
#include "windows/LockedInfoWindow.hpp"
#include "windows/Reboot.hpp"
#include "windows/Update.hpp"
@@ 94,6 95,11 @@ namespace app
handleLowBatteryNotification(std::move(data));
return msgHandled();
});
+
+ addActionReceiver(app::manager::actions::SystemBrownout, [this](auto &&data) {
+ switchWindow(app::window::name::dead_battery, std::move(data));
+ return msgHandled();
+ });
}
ApplicationDesktop::~ApplicationDesktop()
@@ 358,6 364,9 @@ namespace app
windowsFactory.attach(desktop_poweroff, [](Application *app, const std::string newname) {
return std::make_unique<gui::PowerOffWindow>(app);
});
+ windowsFactory.attach(dead_battery, [](Application *app, const std::string newname) {
+ return std::make_unique<gui::DeadBatteryWindow>(app);
+ });
windowsFactory.attach(desktop_locked, [](Application *app, const std::string newname) {
return std::make_unique<gui::LockedInfoWindow>(app);
});
M module-apps/application-desktop/ApplicationDesktop.hpp => module-apps/application-desktop/ApplicationDesktop.hpp +2 -1
@@ 107,7 107,8 @@ namespace app
manager::actions::ShowMMIPush,
manager::actions::ShowMMIResult,
manager::actions::DisplayCMEError,
- manager::actions::DisplayLowBatteryNotification}};
+ manager::actions::DisplayLowBatteryNotification,
+ manager::actions::SystemBrownout}};
}
};
M module-apps/application-desktop/CMakeLists.txt => module-apps/application-desktop/CMakeLists.txt +1 -0
@@ 27,6 27,7 @@ target_sources( ${PROJECT_NAME}
"${CMAKE_CURRENT_LIST_DIR}/windows/PinLockWindow.cpp"
"${CMAKE_CURRENT_LIST_DIR}/windows/MenuWindow.cpp"
"${CMAKE_CURRENT_LIST_DIR}/windows/PowerOffWindow.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/windows/DeadBatteryWindow.cpp"
"${CMAKE_CURRENT_LIST_DIR}/windows/LockedInfoWindow.cpp"
"${CMAKE_CURRENT_LIST_DIR}/windows/Reboot.cpp"
"${CMAKE_CURRENT_LIST_DIR}/windows/Update.cpp"
A module-apps/application-desktop/windows/DeadBatteryWindow.cpp => module-apps/application-desktop/windows/DeadBatteryWindow.cpp +53 -0
@@ 0,0 1,53 @@
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#include "DeadBatteryWindow.hpp"
+#include "InputEvent.hpp"
+#include "gui/widgets/Image.hpp"
+#include "gui/widgets/BottomBar.hpp"
+#include "gui/widgets/TopBar.hpp"
+#include "log/log.hpp"
+#include <application-desktop/windows/Names.hpp>
+#include <service-appmgr/model/ApplicationManager.hpp>
+#include <service-appmgr/Controller.hpp>
+
+namespace gui
+{
+ namespace
+ {
+ constexpr inline auto SHUTDOWN_TIMER_MS = 500;
+ constexpr inline auto IMG_POS_X = 176;
+ constexpr inline auto IMG_POS_Y = 250;
+ } // namespace
+
+ DeadBatteryWindow::DeadBatteryWindow(app::Application *app) : AppWindow(app, app::window::name::dead_battery)
+ {
+ buildInterface();
+ }
+
+ void DeadBatteryWindow::rebuild()
+ {
+ destroyInterface();
+ buildInterface();
+ }
+
+ void DeadBatteryWindow::buildInterface()
+ {
+ AppWindow::buildInterface();
+ bottomBar->setVisible(false);
+ topBar->setVisible(false);
+
+ image = new gui::Image(this, IMG_POS_X, IMG_POS_Y, 0, 0, "dead_battery_W_G");
+ }
+
+ void DeadBatteryWindow::onBeforeShow(ShowMode mode, SwitchData *data)
+ {
+ app::manager::Controller::sendAction(application, app::manager::actions::CloseSystem);
+ }
+
+ void DeadBatteryWindow::destroyInterface()
+ {
+ erase();
+ image = nullptr;
+ }
+} /* namespace gui */
A module-apps/application-desktop/windows/DeadBatteryWindow.hpp => module-apps/application-desktop/windows/DeadBatteryWindow.hpp +24 -0
@@ 0,0 1,24 @@
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#pragma once
+
+#include <vector>
+#include "AppWindow.hpp"
+
+namespace gui
+{
+ class DeadBatteryWindow : public AppWindow
+ {
+ public:
+ explicit DeadBatteryWindow(app::Application *app);
+ void rebuild() override;
+ void buildInterface() override;
+ void destroyInterface() override;
+ void onBeforeShow(ShowMode mode, SwitchData *data) override;
+
+ private:
+ gui::Image *image = nullptr;
+ };
+
+} /* namespace gui */
M module-apps/application-desktop/windows/Names.hpp => module-apps/application-desktop/windows/Names.hpp +9 -8
@@ 7,13 7,14 @@
namespace app::window::name
{
inline constexpr auto desktop_main_window = gui::name::window::main_window;
- inline constexpr auto desktop_menu = "MenuWindow";
- inline constexpr auto desktop_reboot = "Reboot";
- inline constexpr auto desktop_poweroff = "PowerOffWindow";
- inline constexpr auto desktop_pin_lock = "PinLockWindow";
- inline constexpr auto desktop_locked = "LockedInfoWindow";
- inline constexpr auto desktop_update = "Update";
- inline constexpr auto desktop_mmi_pull = "MmiPullWindow";
- inline constexpr auto desktop_mmi_push = "MmiPushWindow";
+ inline constexpr auto desktop_menu = "MenuWindow";
+ inline constexpr auto desktop_reboot = "Reboot";
+ inline constexpr auto desktop_poweroff = "PowerOffWindow";
+ inline constexpr auto dead_battery = "DeadBatteryWindow";
+ inline constexpr auto desktop_pin_lock = "PinLockWindow";
+ inline constexpr auto desktop_locked = "LockedInfoWindow";
+ inline constexpr auto desktop_update = "Update";
+ inline constexpr auto desktop_mmi_pull = "MmiPullWindow";
+ inline constexpr auto desktop_mmi_push = "MmiPushWindow";
inline constexpr auto desktop_mmi_internal = "MmiInternalMsgWindow";
}; // namespace app::window::name
M module-apps/application-desktop/windows/PowerOffWindow.cpp => module-apps/application-desktop/windows/PowerOffWindow.cpp +2 -19
@@ 4,7 4,6 @@
#include "InputEvent.hpp"
#include "gui/widgets/BottomBar.hpp"
#include "gui/widgets/TopBar.hpp"
-#include "GuiTimer.hpp"
#include "log/log.hpp"
// module-utils
@@ 15,6 14,7 @@
// services
#include <service-appmgr/model/ApplicationManager.hpp>
+#include <service-appmgr/Controller.hpp>
#include "service-cellular/ServiceCellular.hpp"
#include <Style.hpp>
@@ 142,7 142,7 @@ namespace gui
infoLabel->setVisible(false);
application->refreshWindow(RefreshModes::GUI_REFRESH_DEEP);
- scheduleSystemShutdown();
+ app::manager::Controller::sendAction(application, app::manager::actions::CloseSystem);
return true;
};
@@ 160,23 160,6 @@ namespace gui
};
}
- // Temporary solution for shutting down the system.
- // The former solution removed from service-gui during its refactor.
- // To be reimplemented in SystemManager in upcoming commits.
- void PowerOffWindow::scheduleSystemShutdown()
- {
- constexpr auto SystemShutdownDelayInMs = 500;
- auto powerOffTimer = std::make_unique<app::GuiTimer>("PowerOffTimer", application);
- powerOffTimer->setInterval(SystemShutdownDelayInMs);
- timerCallback = [this](Item &, Timer &timer) {
- detachTimer(timer);
- sys::SystemManager::CloseSystem(application);
- return true;
- };
- powerOffTimer->start();
- application->connect(std::move(powerOffTimer), this);
- }
-
void PowerOffWindow::destroyInterface()
{
erase();
M module-apps/application-desktop/windows/PowerOffWindow.hpp => module-apps/application-desktop/windows/PowerOffWindow.hpp +0 -3
@@ 27,9 27,6 @@ namespace gui
gui::Image *powerImage = nullptr;
gui::Image *powerDownImage = nullptr;
State state = State::Return;
-
- void scheduleSystemShutdown();
-
public:
PowerOffWindow(app::Application *app);
void onBeforeShow(ShowMode mode, SwitchData *data) override;
M module-services/service-appmgr/model/ApplicationManager.cpp => module-services/service-appmgr/model/ApplicationManager.cpp +14 -1
@@ 34,7 34,8 @@ namespace app::manager
{
namespace
{
- constexpr auto default_application_locktime_ms = 30000;
+ static constexpr auto default_application_locktime_ms = 30000;
+ static constexpr auto shutdown_delay_ms = 500;
}; // namespace
ApplicationManagerBase::ApplicationManagerBase(std::vector<std::unique_ptr<app::ApplicationLauncher>> &&launchers)
@@ 102,6 103,7 @@ namespace app::manager
: Service{serviceName}, ApplicationManagerBase(std::move(launchers)), rootApplicationName{_rootApplicationName},
blockingTimer{std::make_unique<sys::Timer>(
"BlockTimer", this, std::numeric_limits<sys::ms>::max(), sys::Timer::Type::SingleShot)},
+ shutdownDelay{std::make_unique<sys::Timer>("ShutdownDelay", this, shutdown_delay_ms)},
settings(std::make_unique<settings::Settings>(this))
{
registerMessageHandlers();
@@ 255,6 257,7 @@ namespace app::manager
connect(typeid(CellularMMIResponseMessage), convertibleToActionHandler);
connect(typeid(CellularMMIPushMessage), convertibleToActionHandler);
connect(typeid(sys::CriticalBatteryLevelNotification), convertibleToActionHandler);
+ connect(typeid(sys::SystemBrownoutMesssage), convertibleToActionHandler);
}
sys::ReturnCodes ApplicationManager::SwitchPowerModeHandler(const sys::ServicePowerMode mode)
@@ 398,6 401,8 @@ namespace app::manager
auto params = static_cast<ApplicationLaunchData *>(actionMsg->getData().get());
return handleLaunchAction(params);
}
+ case actions::CloseSystem:
+ return handleCloseSystem();
default: {
auto &actionParams = actionMsg->getData();
return handleCustomAction(action, std::move(actionParams));
@@ 422,6 427,14 @@ namespace app::manager
return handleSwitchApplication(&switchRequest);
}
+ auto ApplicationManager::handleCloseSystem() -> bool
+ {
+ shutdownDelay->connect([&](sys::Timer &) { sys::SystemManager::CloseSystem(this); });
+ shutdownDelay->start();
+
+ return true;
+ }
+
auto ApplicationManager::handleCustomAction(actions::ActionId action, actions::ActionParamsPtr &&actionParams)
-> bool
{
M module-services/service-appmgr/service-appmgr/Actions.hpp => module-services/service-appmgr/service-appmgr/Actions.hpp +2 -0
@@ 24,6 24,7 @@ namespace app::manager
{
Home,
Launch,
+ CloseSystem,
Call,
Dial,
ShowCallLog,
@@ 48,6 49,7 @@ namespace app::manager
ShowMMIPush,
DisplayCMEError,
DisplayLowBatteryNotification,
+ SystemBrownout,
UserAction // The last enumerator in the Action enum.
// All user-defined actions shall have values greater than UserAction.
// All system-wide actions shall have values lesser than UserAction.
M module-services/service-appmgr/service-appmgr/model/ApplicationManager.hpp => module-services/service-appmgr/service-appmgr/model/ApplicationManager.hpp +2 -0
@@ 114,6 114,7 @@ namespace app::manager
auto handleAction(ActionRequest *actionMsg) -> bool;
auto handleHomeAction() -> bool;
auto handleLaunchAction(ApplicationLaunchData *launchParams) -> bool;
+ auto handleCloseSystem() -> bool;
auto handleCustomAction(actions::ActionId action, actions::ActionParamsPtr &&actionParams) -> bool;
auto handleSwitchApplication(SwitchRequest *msg, bool closeCurrentlyFocusedApp = true) -> bool;
auto handleCloseConfirmation(CloseConfirmation *msg) -> bool;
@@ 141,6 142,7 @@ namespace app::manager
// defined in settings database application
// manager is sending signal to power manager and changing window to
// the desktop window in the blocked state.
+ std::unique_ptr<sys::Timer> shutdownDelay;
// Temporary solution - to be replaced with ActionsMiddleware.
std::tuple<ApplicationName, actions::ActionId, actions::ActionParamsPtr> pendingAction;
M module-sys/SystemManager/SystemManager.cpp => module-sys/SystemManager/SystemManager.cpp +5 -1
@@ 261,6 261,10 @@ namespace sys
connect(sevm::BatteryBrownoutMessage(), [&](Message *) {
LOG_INFO("Battery Brownout voltage level reached!");
+
+ auto msg = std::make_shared<SystemBrownoutMesssage>();
+ Bus::SendUnicast(msg, app::manager::ApplicationManager::ServiceName, this);
+
return MessageNone{};
});
@@ 284,7 288,7 @@ namespace sys
CellularServiceAPI::ChangeModulePowerState(this, cellular::State::PowerState::On);
auto msg = std::make_shared<CriticalBatteryLevelNotification>(false);
- Bus::SendUnicast(msg, app::manager::ApplicationManager::ServiceName, this);
+ Bus::SendUnicast(std::move(msg), app::manager::ApplicationManager::ServiceName, this);
return MessageNone{};
});
M module-sys/SystemManager/messages/SystemManagerMessage.hpp => module-sys/SystemManager/messages/SystemManagerMessage.hpp +10 -0
@@ 37,4 37,14 @@ namespace sys
bool isActive;
};
+ class SystemBrownoutMesssage : public sys::Message, public app::manager::actions::ConvertibleToAction
+ {
+ public:
+ [[nodiscard]] auto toAction() const -> std::unique_ptr<app::manager::ActionRequest>
+ {
+ return std::make_unique<app::manager::ActionRequest>(
+ service::name::system_manager, app::manager::actions::SystemBrownout, nullptr);
+ }
+ };
+
} // namespace sys