From 4f63943a4cf586e168fbb996f11adb7db40ff3e6 Mon Sep 17 00:00:00 2001 From: rrandomsky Date: Mon, 8 Jan 2024 15:53:22 +0100 Subject: [PATCH] [BH-1792] Updated button handling during pre wake up Button action behavior has been updated for pre-wake. Now, if pre-wake is in progress, the first press, in addition to pressing the front light, disables the pre-wake function. --- harmony_changelog.md | 1 + module-db/Interface/EventRecord.hpp | 6 ++- .../service-time/AlarmMessageHandler.cpp | 11 +++- .../service-time/AlarmMessageHandler.hpp | 4 +- .../service-time/AlarmOperations.cpp | 5 +- .../service-time/AlarmOperations.hpp | 5 +- .../service-time/AlarmServiceAPI.cpp | 8 ++- module-services/service-time/ServiceTime.cpp | 7 ++- .../include/service-time/AlarmMessage.hpp | 30 ++++++++++- .../include/service-time/AlarmServiceAPI.hpp | 3 +- .../include/service-time/AlarmStatus.hpp | 4 +- products/BellHybrid/apps/Application.cpp | 43 +++++++++++++++- .../presenters/StateController.cpp | 1 + .../presenter/RelaxationPausedPresenter.cpp | 2 +- .../presenter/RelaxationPausedPresenter.hpp | 2 +- .../windows/RelaxationPausedWindow.cpp | 2 +- .../RelaxationRunningProgressWindow.cpp | 2 +- .../BellHybrid/apps/common/CMakeLists.txt | 2 + .../layouts/BaseHomeScreenLayoutProvider.hpp | 3 +- .../common/models/AbstractAlarmModel.hpp | 3 +- .../include/common/models/AlarmModel.hpp | 4 +- .../include/common/models/PreWakeUpModel.hpp | 36 +++++++++++++ .../BellHybrid/apps/common/src/AlarmModel.cpp | 5 ++ .../src/layouts/HomeScreenLayoutClassic.cpp | 5 ++ .../src/layouts/HomeScreenLayoutVertical.cpp | 2 + .../apps/common/src/models/PreWakeUpModel.cpp | 27 ++++++++++ .../apps/common/src/widgets/BellBattery.cpp | 2 +- .../BellHybrid/apps/include/Application.hpp | 4 ++ .../services/audio/ServiceAudio.cpp | 39 ++++++++------- .../services/time/AlarmOperations.cpp | 50 +++++++++++++++---- .../time/include/time/AlarmOperations.hpp | 11 ++-- .../time/tests/test-BellAlarmOperations.cpp | 35 +++++++++---- 32 files changed, 302 insertions(+), 62 deletions(-) create mode 100644 products/BellHybrid/apps/common/include/common/models/PreWakeUpModel.hpp create mode 100644 products/BellHybrid/apps/common/src/models/PreWakeUpModel.cpp diff --git a/harmony_changelog.md b/harmony_changelog.md index fed6ba7e7159cbb70ba871e22b56ccba434f84ca..c5776c97b1ebb4af482ff403e6cf904c458c4501 100644 --- a/harmony_changelog.md +++ b/harmony_changelog.md @@ -11,6 +11,7 @@ ### Changed / Improved * Updated FSL drivers from NXP * Increased speed of update process +* Updated button handling during pre wake up ## [2.6.0 2024-03-07] diff --git a/module-db/Interface/EventRecord.hpp b/module-db/Interface/EventRecord.hpp index 123179787c67c3b4097a801272eed2e858cc6cbb..072195b496a957a2b1d10820c8c4d92a543c5734 100644 --- a/module-db/Interface/EventRecord.hpp +++ b/module-db/Interface/EventRecord.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #pragma once @@ -60,9 +60,11 @@ struct SingleEventRecord : public Record, public EventInfo TimePoint startDate, TimePoint endDate, bool wasHandledDuringCall = false) - : EventInfo{startDate, endDate}, parent{parent}, wasHandledDuringPhoneCall(wasHandledDuringCall){}; + : EventInfo{startDate, endDate}, parent{parent}, wasHandledDuringPhoneCall(wasHandledDuringCall), + isPreWakeUpAlreadyHandledByUser(false){}; auto isValid() const -> bool; bool wasHandledDuringPhoneCall; + bool isPreWakeUpAlreadyHandledByUser; }; diff --git a/module-services/service-time/AlarmMessageHandler.cpp b/module-services/service-time/AlarmMessageHandler.cpp index 277286ed98ba848df940735849bd302fe94f9be9..64d31b4ff3c1d67b0e30876f373f5b097c57caee 100644 --- a/module-services/service-time/AlarmMessageHandler.cpp +++ b/module-services/service-time/AlarmMessageHandler.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #include "AlarmMessageHandler.hpp" @@ -186,6 +186,15 @@ namespace alarms } } + auto AlarmMessageHandler::handleTurnOffPreWakeUp(TurnOffPreWakeUpRequestMessage *request) + -> std::shared_ptr + { + return handleWithCallback( + request, [&](TurnOffPreWakeUpRequestMessage *request, IAlarmOperations::OnTurnOffPreWakeUp callback) { + alarmOperations->turnOffPreWakeUp(callback); + }); + } + template auto AlarmMessageHandler::handleWithCallback( RequestType *request, diff --git a/module-services/service-time/AlarmMessageHandler.hpp b/module-services/service-time/AlarmMessageHandler.hpp index 6c905f9bd740eee98f5bc5d74c03e98ff782799a..8a4fc73118053af1f0dff86c425ac8d6eaf0419a 100644 --- a/module-services/service-time/AlarmMessageHandler.hpp +++ b/module-services/service-time/AlarmMessageHandler.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #pragma once @@ -48,6 +48,8 @@ namespace alarms auto handleGetSnoozedAlarms(GetSnoozedAlarmsRequestMessage *request) -> std::shared_ptr; auto handleBatteryStateChange(sevm::BatteryStateChangeMessage *request) -> void; + auto handleTurnOffPreWakeUp(TurnOffPreWakeUpRequestMessage *request) + -> std::shared_ptr; private: stm::ServiceTime *service = nullptr; diff --git a/module-services/service-time/AlarmOperations.cpp b/module-services/service-time/AlarmOperations.cpp index 832fb4e8c8f64d000730743e5625598d9a7a7abe..a5db6afe349d941e69471610092a1889b0e215ea 100644 --- a/module-services/service-time/AlarmOperations.cpp +++ b/module-services/service-time/AlarmOperations.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #include "AlarmOperations.hpp" @@ -510,4 +510,7 @@ namespace alarms { onAlarmDuringPhoneCallCallback = callback; } + + void AlarmOperationsCommon::turnOffPreWakeUp(OnTurnOffPreWakeUp callback) + {} } // namespace alarms diff --git a/module-services/service-time/AlarmOperations.hpp b/module-services/service-time/AlarmOperations.hpp index bc0a406a8d7a150c11e62b91f9ca29b7db688b32..7de035c0f2d18499bf9e1c42c19621fac063c08c 100644 --- a/module-services/service-time/AlarmOperations.hpp +++ b/module-services/service-time/AlarmOperations.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #pragma once @@ -34,6 +34,7 @@ namespace alarms using OnToggleAllProcessed = std::function; using CheckIfPhoneCallIsOngoing = std::function; using OnAlarmDuringPhoneCall = std::function; + using OnTurnOffPreWakeUp = std::function; virtual ~IAlarmOperations() noexcept = default; @@ -70,6 +71,7 @@ namespace alarms virtual void handleNormalBatteryLevel() = 0; virtual void addCheckIfPhoneCallIsOngoingCallback(CheckIfPhoneCallIsOngoing) = 0; virtual void addAlarmDuringPhoneCallCallback(OnAlarmDuringPhoneCall) = 0; + virtual void turnOffPreWakeUp(OnTurnOffPreWakeUp) = 0; }; class IAlarmOperationsFactory @@ -118,6 +120,7 @@ namespace alarms void handleNormalBatteryLevel() override; void addCheckIfPhoneCallIsOngoingCallback(CheckIfPhoneCallIsOngoing callback) override; void addAlarmDuringPhoneCallCallback(OnAlarmDuringPhoneCall callback) override; + void turnOffPreWakeUp(OnTurnOffPreWakeUp callback) override; protected: std::unique_ptr alarmEventsRepo; diff --git a/module-services/service-time/AlarmServiceAPI.cpp b/module-services/service-time/AlarmServiceAPI.cpp index 4aeb13f31816cc296b3caba517f37813421be742..bd8f252297a8b55eeb03cf168c990132f9a5619b 100644 --- a/module-services/service-time/AlarmServiceAPI.cpp +++ b/module-services/service-time/AlarmServiceAPI.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #include "ServiceTimeName.hpp" @@ -10,7 +10,6 @@ namespace alarms { - namespace AlarmServiceAPI { template @@ -74,6 +73,11 @@ namespace alarms { return sendRequest(serv); } + + bool requestTurnOffPreWakeUp(sys::Service *serv) + { + return sendRequest(serv); + } }; // namespace AlarmServiceAPI } // namespace alarms diff --git a/module-services/service-time/ServiceTime.cpp b/module-services/service-time/ServiceTime.cpp index 72668ba42d599b93b88581725ae89f8295fca608..8a60a273bfe800b987ceb098148cf48578e81913 100644 --- a/module-services/service-time/ServiceTime.cpp +++ b/module-services/service-time/ServiceTime.cpp @@ -35,8 +35,7 @@ namespace stm } ServiceTime::~ServiceTime() - { - } + {} sys::ReturnCodes ServiceTime::InitHandler() { @@ -215,6 +214,10 @@ namespace stm alarmMessageHandler->handleBatteryStateChange(message); return std::make_shared(); }); + connect(typeid(alarms::TurnOffPreWakeUpRequestMessage), [&](sys::Message *request) -> sys::MessagePointer { + return alarmMessageHandler->handleTurnOffPreWakeUp( + static_cast(request)); + }); } auto ServiceTime::handleSetAutomaticDateAndTimeRequest(sys::Message *request) diff --git a/module-services/service-time/include/service-time/AlarmMessage.hpp b/module-services/service-time/include/service-time/AlarmMessage.hpp index f3b1aaaaeb2313c2c13616e166cb8454e7e947f3..efcfa72329b482b47d223c7aa9aea8231a698a44 100644 --- a/module-services/service-time/include/service-time/AlarmMessage.hpp +++ b/module-services/service-time/include/service-time/AlarmMessage.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #pragma once @@ -272,4 +272,32 @@ namespace alarms : snoozedAlarms(std::move(snoozedAlarms)){}; const std::vector snoozedAlarms; }; + + class TurnOffPreWakeUpResponseMessage : public AlarmResponse + { + public: + explicit TurnOffPreWakeUpResponseMessage(const bool success = false) : success(success){}; + const bool success{}; + }; + + class PreWakeUpChangeState : public AlarmMessage + { + public: + explicit PreWakeUpChangeState(bool isActive) : activity(isActive) + {} + + bool isActive() const + { + return activity; + }; + + private: + bool activity; + }; + + class TurnOffPreWakeUpRequestMessage : public AlarmMessage + { + public: + TurnOffPreWakeUpRequestMessage(){}; + }; } // namespace alarms diff --git a/module-services/service-time/include/service-time/AlarmServiceAPI.hpp b/module-services/service-time/include/service-time/AlarmServiceAPI.hpp index 1133d23bac305306e535e95e50653b5807d4feec..25c4aca1cb76b8ce27646ceea41f5ac69412842a 100644 --- a/module-services/service-time/include/service-time/AlarmServiceAPI.hpp +++ b/module-services/service-time/include/service-time/AlarmServiceAPI.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #pragma once @@ -31,6 +31,7 @@ namespace alarms bool requestStopAllSnoozedAlarms(sys::Service *serv); bool requestRegisterSnoozedAlarmsCountChangeCallback(sys::Service *serv); bool requestRegisterActiveAlarmsIndicatorHandler(sys::Service *serv); + bool requestTurnOffPreWakeUp(sys::Service *serv); }; // namespace AlarmServiceAPI } // namespace alarms diff --git a/module-services/service-time/include/service-time/AlarmStatus.hpp b/module-services/service-time/include/service-time/AlarmStatus.hpp index 65de993b0e0a2c269e3de5eebcabb2dfc79fc14a..4d413c8b1d2bbfe4ad9a83ffda1cb302b22c0cd4 100644 --- a/module-services/service-time/include/service-time/AlarmStatus.hpp +++ b/module-services/service-time/include/service-time/AlarmStatus.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #pragma once @@ -14,4 +14,4 @@ namespace alarms Ringing, Queued }; -} +} // namespace alarms diff --git a/products/BellHybrid/apps/Application.cpp b/products/BellHybrid/apps/Application.cpp index b5d20b6dbdda8576d5f0766a5d4784d98522839a..cd5c08252a8152c4d16cf84c1dff0f32570fcfd6 100644 --- a/products/BellHybrid/apps/Application.cpp +++ b/products/BellHybrid/apps/Application.cpp @@ -17,6 +17,9 @@ #include #include #include +#include +#include +#include namespace app { @@ -33,10 +36,15 @@ namespace app (isCurrentWindow(gui::popup::resolveWindowName(gui::popup::ID::PowerOff))) || (isCurrentWindow(gui::BellTurnOffWindow::name))); if (val == true) { - LOG_ERROR("Block popup - as curent window is in higher order popup"); + LOG_ERROR("Block popup - as current window is in higher order popup"); } return val ? gui::popup::FilterType::Ignore : gui::popup::FilterType::Show; }); + + preWakeUpModel = std::make_unique(this); + bus.channels.push_back(sys::BusChannel::AlarmNotifications); + connect(typeid(alarms::PreWakeUpChangeState), + [&](sys::Message *msg) { return handlePreWakeUpChangeState(msg); }); } sys::ReturnCodes Application::InitHandler() @@ -134,6 +142,18 @@ namespace app sys::MessagePointer Application::handleKBDKeyEvent(sys::Message *msgl) { onKeyPressed(); + if (preWakeUpModel && preWakeUpModel->isActive()) { + if (this->getState() != app::ApplicationCommon::State::ACTIVE_FORGROUND) { + LOG_FATAL("Terrible terrible damage! Application with no focus grabbed key!"); + return sys::msgNotHandled(); + } + const auto msg = static_cast(msgl); + const auto inputEvent = keyTranslator->translate(msg->key); + if (!inputEvent.is(gui::KeyCode::KEY_UNDEFINED) && isInputEventToHandlePreWakeUp(inputEvent)) { + preWakeUpModel->turnOffPreWakeUp(); + return sys::msgHandled(); + } + } return ApplicationCommon::handleKBDKeyEvent(msgl); } @@ -155,6 +175,16 @@ namespace app return ApplicationCommon::handleAppFocusLost(msgl); } + sys::MessagePointer Application::handlePreWakeUpChangeState(sys::Message *msg) + { + auto *message = dynamic_cast(msg); + if (message == nullptr) { + return sys::msgNotHandled(); + } + preWakeUpModel->setActive(message->isActive()); + return sys::msgHandled(); + } + void Application::onKeyPressed() { restartIdleTimer(); @@ -201,9 +231,20 @@ namespace app startIdleTimer(); idleTimerActiveFlag = true; } + void Application::suspendIdleTimer() { stopIdleTimer(); idleTimerActiveFlag = false; } + + bool Application::isInputEventToHandlePreWakeUp(const gui::InputEvent inputEvent) + { + const auto key = mapKey(inputEvent.getKeyCode()); + if (inputEvent.isShortRelease() && key != KeyMap::Frontlight && key != KeyMap::DeepPressDown && + key != KeyMap::DeepPressUp) { + return true; + } + return false; + } } // namespace app diff --git a/products/BellHybrid/apps/application-bell-main/presenters/StateController.cpp b/products/BellHybrid/apps/application-bell-main/presenters/StateController.cpp index 26dfb544fc59d5f89883faab78761b6f87dde623..063325afee3dc7be906651ec84fa5187adf45c20 100644 --- a/products/BellHybrid/apps/application-bell-main/presenters/StateController.cpp +++ b/products/BellHybrid/apps/application-bell-main/presenters/StateController.cpp @@ -211,6 +211,7 @@ namespace app::home_screen AbstractPresenter &presenter, AbstractAlarmModel &alarmModel, AbstractTimeModel &timeModel) { + alarmModel.turnOffPreWakeUp(); alarmModel.activate(true); presenter.spawnTimer(); view.setTextDescription(utils::time::getBottomDescription( diff --git a/products/BellHybrid/apps/application-bell-relaxation/presenter/RelaxationPausedPresenter.cpp b/products/BellHybrid/apps/application-bell-relaxation/presenter/RelaxationPausedPresenter.cpp index 486c05ec2b973f3daaa91c619db5540c7e931792..443b7b8a01448188407f28cc88c2ad9192de2128 100644 --- a/products/BellHybrid/apps/application-bell-relaxation/presenter/RelaxationPausedPresenter.cpp +++ b/products/BellHybrid/apps/application-bell-relaxation/presenter/RelaxationPausedPresenter.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #include "RelaxationPausedPresenter.hpp" diff --git a/products/BellHybrid/apps/application-bell-relaxation/presenter/RelaxationPausedPresenter.hpp b/products/BellHybrid/apps/application-bell-relaxation/presenter/RelaxationPausedPresenter.hpp index dc473b30a1718a10615da46630af04678773fa2d..d9c299f7aba6f9885a88ee920e4339245f30c65d 100644 --- a/products/BellHybrid/apps/application-bell-relaxation/presenter/RelaxationPausedPresenter.hpp +++ b/products/BellHybrid/apps/application-bell-relaxation/presenter/RelaxationPausedPresenter.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #pragma once diff --git a/products/BellHybrid/apps/application-bell-relaxation/windows/RelaxationPausedWindow.cpp b/products/BellHybrid/apps/application-bell-relaxation/windows/RelaxationPausedWindow.cpp index f68d887edbdfdb372d95e672d270e2a4532e11e4..ddeab2c0ddc76fd9b99ad08ef008890be6cac422 100644 --- a/products/BellHybrid/apps/application-bell-relaxation/windows/RelaxationPausedWindow.cpp +++ b/products/BellHybrid/apps/application-bell-relaxation/windows/RelaxationPausedWindow.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #include "RelaxationPausedWindow.hpp" diff --git a/products/BellHybrid/apps/application-bell-relaxation/windows/RelaxationRunningProgressWindow.cpp b/products/BellHybrid/apps/application-bell-relaxation/windows/RelaxationRunningProgressWindow.cpp index 8a64dea262c02f7c19783c43076b3ac20e6095cd..ae750cdc8ba65862fe80d8e87ec1b0b1efa45ea9 100644 --- a/products/BellHybrid/apps/application-bell-relaxation/windows/RelaxationRunningProgressWindow.cpp +++ b/products/BellHybrid/apps/application-bell-relaxation/windows/RelaxationRunningProgressWindow.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #include "RelaxationRunningProgressWindow.hpp" diff --git a/products/BellHybrid/apps/common/CMakeLists.txt b/products/BellHybrid/apps/common/CMakeLists.txt index 536372c8724597d05156e84b86dc9e6e76430fd3..a2b064ad0b583294376c14e8ea485703352f4125 100644 --- a/products/BellHybrid/apps/common/CMakeLists.txt +++ b/products/BellHybrid/apps/common/CMakeLists.txt @@ -39,6 +39,7 @@ target_sources(application-bell-common src/models/SettingsModel.cpp src/models/BedtimeModel.cpp src/models/LowBatteryInfoModel.cpp + src/models/PreWakeUpModel.cpp src/popups/AlarmActivatedWindow.cpp src/popups/AlarmActivatedWindow.cpp src/popups/BedtimeNotificationWindow.cpp @@ -116,6 +117,7 @@ target_sources(application-bell-common include/common/models/LayoutModel.hpp include/common/models/LowBatteryInfoModel.hpp include/common/models/QuoteModel.hpp + include/common/models/PreWakeUpModel.hpp include/common/popups/presenter/AlarmActivatedPresenter.hpp include/common/popups/AlarmActivatedWindow.hpp include/common/popups/AlarmDeactivatedWindow.hpp diff --git a/products/BellHybrid/apps/common/include/common/layouts/BaseHomeScreenLayoutProvider.hpp b/products/BellHybrid/apps/common/include/common/layouts/BaseHomeScreenLayoutProvider.hpp index 0de803bc5ab2e806482e34bd3b1ac9bfd012a9f7..6dbd1e70b3e10fd9542f75288143c62691f4b02d 100644 --- a/products/BellHybrid/apps/common/include/common/layouts/BaseHomeScreenLayoutProvider.hpp +++ b/products/BellHybrid/apps/common/include/common/layouts/BaseHomeScreenLayoutProvider.hpp @@ -24,7 +24,8 @@ namespace app::home_screen AlarmRinging, AlarmRingingDeactivatedWait, AlarmSnoozedWait, - AlarmSnoozed + AlarmSnoozed, + PreWakeUpActive }; }; diff --git a/products/BellHybrid/apps/common/include/common/models/AbstractAlarmModel.hpp b/products/BellHybrid/apps/common/include/common/models/AbstractAlarmModel.hpp index de8080c17b6a69930521f7124879cfc74924e3c2..5823ede9543c778add9b52e61d6f32f5cf480f89 100644 --- a/products/BellHybrid/apps/common/include/common/models/AbstractAlarmModel.hpp +++ b/products/BellHybrid/apps/common/include/common/models/AbstractAlarmModel.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #pragma once @@ -34,6 +34,7 @@ namespace app virtual TimePoint getTimeOfNextSnooze() = 0; virtual alarms::AlarmStatus getAlarmStatus() = 0; virtual void activateAlarm(bool state) = 0; + virtual bool turnOffPreWakeUp() = 0; /// Command model to update its internal data virtual void update(AlarmModelReadyHandler callback = AlarmModelReadyHandler()) = 0; }; diff --git a/products/BellHybrid/apps/common/include/common/models/AlarmModel.hpp b/products/BellHybrid/apps/common/include/common/models/AlarmModel.hpp index db3d5db85056249553628da6dc0ea55c5f2be6f8..6888e36da54adbdcedcef90c9bd4eff6f1ae1a5c 100644 --- a/products/BellHybrid/apps/common/include/common/models/AlarmModel.hpp +++ b/products/BellHybrid/apps/common/include/common/models/AlarmModel.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #pragma once @@ -36,6 +36,8 @@ namespace app void turnOff() override; void snooze() override; void activateAlarm(bool state) override; + bool turnOffPreWakeUp() override; + std::chrono::seconds getTimeToNextSnooze() override; TimePoint getTimeOfNextSnooze() override; alarms::AlarmStatus getAlarmStatus() override; diff --git a/products/BellHybrid/apps/common/include/common/models/PreWakeUpModel.hpp b/products/BellHybrid/apps/common/include/common/models/PreWakeUpModel.hpp new file mode 100644 index 0000000000000000000000000000000000000000..546be997cccc992cbc02e21e9e3f314c77c0eb81 --- /dev/null +++ b/products/BellHybrid/apps/common/include/common/models/PreWakeUpModel.hpp @@ -0,0 +1,36 @@ +// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved. +// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md + +#pragma once + +namespace app +{ + class ApplicationCommon; +} + +namespace app +{ + class AbstractPreWakeUpModel + { + public: + virtual ~AbstractPreWakeUpModel() noexcept = default; + + virtual bool isActive() const = 0; + virtual void setActive(bool active) = 0; + virtual bool turnOffPreWakeUp() = 0; + }; + + class PreWakeUpModel : public AbstractPreWakeUpModel + { + public: + explicit PreWakeUpModel(ApplicationCommon *app); + + bool isActive() const override; + void setActive(bool active) override; + bool turnOffPreWakeUp() override; + + private: + ApplicationCommon *app{}; + bool activity{false}; + }; +} // namespace app diff --git a/products/BellHybrid/apps/common/src/AlarmModel.cpp b/products/BellHybrid/apps/common/src/AlarmModel.cpp index 286ea0c3622351e0419a434d5bf648b19ca5baae..958deab0739c51ce9ed8b09a359cbf3b87040ca5 100644 --- a/products/BellHybrid/apps/common/src/AlarmModel.cpp +++ b/products/BellHybrid/apps/common/src/AlarmModel.cpp @@ -232,6 +232,11 @@ namespace app update(callback); } + bool AlarmModel::turnOffPreWakeUp() + { + return alarms::AlarmServiceAPI::requestTurnOffPreWakeUp(app); + } + alarms::AlarmStatus AlarmModel::getAlarmStatus() { return alarmStatus; diff --git a/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutClassic.cpp b/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutClassic.cpp index 57da9786edc71b9f3fecfdffe6cad938ec63fade..5e7e705d286a482b1a9206b7fe03a6796a598a2d 100644 --- a/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutClassic.cpp +++ b/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutClassic.cpp @@ -205,6 +205,11 @@ namespace gui alarm->setEditMode(EditMode::Browse); removeTextDescription(); break; + case app::home_screen::ViewState::PreWakeUpActive: + setHeaderViewMode(HeaderViewMode::AlarmIconAndTime); + alarm->setEditMode(EditMode::Browse); + removeTextDescription(); + break; } } diff --git a/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutVertical.cpp b/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutVertical.cpp index e5c05a358dfc971ccb8a51abba5c8e20f4ba77fb..ab4a9af6302389fc5f063289998ff8df9dba4fa9 100644 --- a/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutVertical.cpp +++ b/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutVertical.cpp @@ -106,6 +106,8 @@ namespace gui alarmMainTime->setVisible(false); setScreenMode(ScreenMode::Main); break; + case app::home_screen::ViewState::PreWakeUpActive: + break; } } diff --git a/products/BellHybrid/apps/common/src/models/PreWakeUpModel.cpp b/products/BellHybrid/apps/common/src/models/PreWakeUpModel.cpp new file mode 100644 index 0000000000000000000000000000000000000000..95ba4b67a165c7a64e212563b834cb0632f40d84 --- /dev/null +++ b/products/BellHybrid/apps/common/src/models/PreWakeUpModel.cpp @@ -0,0 +1,27 @@ +// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved. +// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md + +#include "models/PreWakeUpModel.hpp" +#include +#include + +namespace app +{ + PreWakeUpModel::PreWakeUpModel(ApplicationCommon *app) : app{app} + {} + + bool PreWakeUpModel::isActive() const + { + return activity; + } + + void PreWakeUpModel::setActive(bool active) + { + activity = active; + } + + bool PreWakeUpModel::turnOffPreWakeUp() + { + return alarms::AlarmServiceAPI::requestTurnOffPreWakeUp(app); + } +} // namespace app diff --git a/products/BellHybrid/apps/common/src/widgets/BellBattery.cpp b/products/BellHybrid/apps/common/src/widgets/BellBattery.cpp index 5649af3f5a7a1bf48b6b402b7ee71bd6042dc7ac..9ba1eab75497bd5a338d3e41223031c53747fdf4 100644 --- a/products/BellHybrid/apps/common/src/widgets/BellBattery.cpp +++ b/products/BellHybrid/apps/common/src/widgets/BellBattery.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #include diff --git a/products/BellHybrid/apps/include/Application.hpp b/products/BellHybrid/apps/include/Application.hpp index 57d2493fd8c9213be9fcff0a63005d1064f88515..88409f8651aa08113604e3553f7305298d68871c 100644 --- a/products/BellHybrid/apps/include/Application.hpp +++ b/products/BellHybrid/apps/include/Application.hpp @@ -6,6 +6,7 @@ #include #include #include +#include namespace app { @@ -35,6 +36,7 @@ namespace app std::unique_ptr alarmModel; std::unique_ptr batteryModel; + std::unique_ptr preWakeUpModel; private: sys::MessagePointer handleKBDKeyEvent(sys::Message *msgl) override; @@ -42,6 +44,8 @@ namespace app sys::MessagePointer handleAppClose(sys::Message *msgl) override; sys::MessagePointer handleAppFocusLost(sys::Message *msgl) override; void updateStatuses(gui::AppWindow *window) const override; + sys::MessagePointer handlePreWakeUpChangeState(sys::Message *msgl); + bool isInputEventToHandlePreWakeUp(const gui::InputEvent inputEvent); virtual void onKeyPressed(); virtual void onStart(); diff --git a/products/BellHybrid/services/audio/ServiceAudio.cpp b/products/BellHybrid/services/audio/ServiceAudio.cpp index 72604525ece0c9d2b0be652ec9a1c5a8878d8cb9..5ebe697d0e327739c08ac09ccec10bb2d21d371b 100644 --- a/products/BellHybrid/services/audio/ServiceAudio.cpp +++ b/products/BellHybrid/services/audio/ServiceAudio.cpp @@ -13,13 +13,13 @@ namespace // 4kB is too small because internally drflac_open() uses cache which by default has 4kB. // Alternatively smaller DR_FLAC_BUFFER_SIZE could be defined. constexpr auto serviceAudioStackSize = 1024 * 8; - constexpr auto defaultVolume = "11"; - constexpr auto defaultSnoozeVolume = "10"; - constexpr auto defaultBedtimeVolume = "12"; - constexpr auto maxVolumeToSet = 15.f; - constexpr auto minVolumeToSet = 0.f; - constexpr auto profileType = audio::Profile::Type::PlaybackLoudspeaker; - constexpr auto volumeSetting = audio::Setting::Volume; + constexpr auto defaultVolume = "11"; + constexpr auto defaultSnoozeVolume = "10"; + constexpr auto defaultBedtimeVolume = "12"; + constexpr auto maxVolumeToSet = 15.f; + constexpr auto minVolumeToSet = 0.f; + constexpr auto profileType = audio::Profile::Type::PlaybackLoudspeaker; + constexpr auto volumeSetting = audio::Setting::Volume; namespace initializer { @@ -133,8 +133,7 @@ namespace service } Audio::~Audio() - { - } + {} sys::MessagePointer Audio::DataReceivedHandler([[maybe_unused]] sys::DataMessage *msgl, [[maybe_unused]] sys::ResponseMessage *resp) @@ -198,18 +197,24 @@ namespace service return std::make_unique(retCode, retToken); } - auto Audio::handleStop([[maybe_unused]] const std::vector &stopTypes, - const audio::Token &token) -> std::unique_ptr + auto Audio::handleStop(const std::vector &stopTypes, const audio::Token &token) + -> std::unique_ptr { std::vector> retCodes; + // if stopType is not provided then stop all inputs, otherwise stop specific ones from stopType for (auto &input : audioMux.GetAllInputs()) { - auto t = input.token; - if (token.IsValid() && t == token) { - retCodes.emplace_back(t, stopInput(&input)); - } - if (token.IsUninitialized()) { - retCodes.emplace_back(t, stopInput(&input)); + const auto ¤tOperation = input.audio->GetCurrentOperation(); + const auto isOperationInStopTypes = + std::find(stopTypes.begin(), stopTypes.end(), currentOperation.GetPlaybackType()) != stopTypes.end(); + if (stopTypes.empty() || isOperationInStopTypes) { + auto t = input.token; + if (token.IsValid() && t == token) { + retCodes.emplace_back(t, stopInput(&input)); + } + if (token.IsUninitialized()) { + retCodes.emplace_back(t, stopInput(&input)); + } } } diff --git a/products/BellHybrid/services/time/AlarmOperations.cpp b/products/BellHybrid/services/time/AlarmOperations.cpp index 96034701e92dd45aad0f7309cb5245e01cd04ee4..82a82e7340408a660ef12d9e2b05ac1dc7bf4864 100644 --- a/products/BellHybrid/services/time/AlarmOperations.cpp +++ b/products/BellHybrid/services/time/AlarmOperations.cpp @@ -1,8 +1,9 @@ -// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #include +#include #include