~aleteoryx/muditaos

aa357fa71b318307b63d73027a1dc7a166499e64 — Paweł Joński 3 years ago a600ef7
[BH-1365] Restore snooze chime processing to alarm operations

Restore snooze chime processing to alarm operations
M products/BellHybrid/services/time/AlarmOperations.cpp => products/BellHybrid/services/time/AlarmOperations.cpp +11 -7
@@ 164,8 164,11 @@ namespace alarms
         * timestamp hence it is safe to process these three in the one go.
         */
        AlarmOperationsCommon::minuteUpdated(now);
        processPreWakeUp(now);
        if (isBedtimeAllowed()) {
        auto prewakeupStarted  = processPreWakeUp(now);
        auto snoozeChimePlayed = processSnoozeChime(now);

        // If we are during snooze or its prewakeup time, we decided to skip bedtime handling at all
        if (!prewakeupStarted && !snoozeChimePlayed && isBedtimeAllowed()) {
            processBedtime(now);
        }
    }


@@ 176,22 179,23 @@ namespace alarms
        AlarmOperationsCommon::stopAllSnoozedAlarms();
    }

    void AlarmOperations::processPreWakeUp(TimePoint now)
    bool AlarmOperations::processPreWakeUp(TimePoint now)
    {
        if (nextSingleEvents.empty()) {
            return;
            return false;
        }

        auto nextEvent = getNextPreWakeUpEvent();
        if (!nextEvent.isValid()) {
            return;
            return false;
        }

        const auto decision = preWakeUp.decide(now, nextEvent);
        if (!decision.timeForChime && !decision.timeForFrontlight) {
            return;
            return false;
        }
        handlePreWakeUp(nextEvent, decision);
        return true;
    }

    void AlarmOperations::processBedtime(TimePoint now)


@@ 281,7 285,7 @@ namespace alarms
    }
    bool AlarmOperations::isBedtimeAllowed() const
    {
        return ongoingSingleEvents.empty() && not preWakeUp.isActive();
        return ongoingSingleEvents.empty() && snoozedSingleEvents.empty() && not preWakeUp.isActive();
    }

    void AlarmOperations::handleAlarmEvent(const std::shared_ptr<AlarmEventRecord> &event,

M products/BellHybrid/services/time/include/time/AlarmOperations.hpp => products/BellHybrid/services/time/include/time/AlarmOperations.hpp +1 -1
@@ 99,7 99,7 @@ namespace alarms
      private:
        void minuteUpdated(TimePoint now) override;
        void stopAllSnoozedAlarms() override;
        void processPreWakeUp(TimePoint now);
        bool processPreWakeUp(TimePoint now);
        bool processSnoozeChime(TimePoint now);
        void stopAllSnoozeChimes();