Files
MuditaOS/module-sys/SystemManager/messages/SystemManagerMessage.hpp
Przemyslaw Brudny 3408fafa8f [EGD-6066] Removed Message default constructor
Forced each message to have declared type as parts of Bus logic
depends on it and previously we encountered undefined
behaviours. Added tests and messages validators.
2021-03-29 22:37:09 +02:00

43 lines
1.3 KiB
C++

// 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 <MessageType.hpp>
#include <Service/Message.hpp>
#include "SystemManager/Constants.hpp"
#include "SystemManager/data/SystemManagerActionsParams.hpp"
#include <service-appmgr/service-appmgr/Actions.hpp>
namespace sys
{
class SystemManagerMessage : public sys::DataMessage
{
public:
SystemManagerMessage() : sys::DataMessage(MessageType::PMChangePowerMode){};
};
class CriticalBatteryLevelNotification : public sys::DataMessage, public app::manager::actions::ConvertibleToAction
{
public:
explicit CriticalBatteryLevelNotification(bool isActive, bool isCharging = false)
: isActive(isActive), isCharging(isCharging)
{}
[[nodiscard]] auto toAction() const -> std::unique_ptr<app::manager::ActionRequest>
{
return std::make_unique<app::manager::ActionRequest>(
service::name::system_manager,
app::manager::actions::DisplayLowBatteryScreen,
std::make_unique<app::manager::actions::LowBatteryNotificationParams>(isActive, isCharging));
}
private:
bool isActive;
bool isCharging;
};
} // namespace sys