~aleteoryx/muditaos

4012b9705b9d381b50ca8cdebe387cacfd955da0 — Bartosz Szostak 3 years ago dd26b29
[MOS-829] The active alarm timeout has been added

The timeout has been added to prevent the alarm
from playing indefinitely. After timeout
the active alarm will be snoozed.
M module-apps/apps-common/popups/presenter/AlarmPresenter.cpp => module-apps/apps-common/popups/presenter/AlarmPresenter.cpp +14 -1
@@ 7,6 7,11 @@
#include "service-time/AlarmMessage.hpp"
#include "time/dateCommon.hpp"

namespace
{
    constexpr auto ACTIVE_ALARM_TIMEOUT = 30min;
}

namespace app::popup
{
    AlarmPopupContract::AlarmModel::AlarmModel(ApplicationCommon *app) : AsyncCallbackReceiver(app), app(app)


@@ 130,6 135,8 @@ namespace app::popup
        else {
            this->getModel()
                ->snoozeAlarm<alarms::RingingAlarmSnoozeRequestMessage, alarms::RingingAlarmSnoozeResponseMessage>();
            if (timerHandle.isActive())
                timerHandle.stop();
        }
        LOG_DEBUG("Snoozed!");
    }


@@ 142,6 149,8 @@ namespace app::popup
        else {
            this->getModel()
                ->stopAlarm<alarms::RingingAlarmTurnOffRequestMessage, alarms::RingingAlarmTurnOffResponseMessage>();
            if (timerHandle.isActive())
                timerHandle.stop();
        }
        LOG_DEBUG("Stopped!");
    }


@@ 185,5 194,9 @@ namespace app::popup
    }

    AlarmPopupPresenter::AlarmPopupPresenter(ApplicationCommon *app) : AlarmPopupContract::Presenter(app)
    {}
    {
        timerHandle = sys::TimerFactory::createSingleShotTimer(
            app, "AlarmTimer", ACTIVE_ALARM_TIMEOUT, [this](sys::Timer &) { snoozeHit(); });
        timerHandle.start();
    }
} // namespace app::popup

M module-apps/apps-common/popups/presenter/AlarmPresenter.hpp => module-apps/apps-common/popups/presenter/AlarmPresenter.hpp +2 -0
@@ 4,6 4,7 @@
#pragma once

#include "time/dateCommon.hpp"
#include "Timers/TimerFactory.hpp"
#include <AlarmEventRecord.hpp>
#include <ApplicationCommon.hpp>
#include <apps-common/BasePresenter.hpp>


@@ 130,6 131,7 @@ namespace app::popup

      private:
        bool noteChanged = false;
        sys::TimerHandle timerHandle{};
        /// returns how many seconds we can snooze the alarm
        virtual std::uint32_t getSnoozeTime() override;
        /// returns if alarm has snooze time available