Files
MuditaOS/module-apps/apps-common/notifications/NotificationsConfiguration.cpp
Mateusz Grzegorzek ed68fc92ec [BH-754] Split ServiceDB
- rename ServiceDB to ServiceDBCommon,
- create separate ServiceDB for Pure and Bell,
- move Pure-specific functionality
from `ServiceDBCommon` to Pure `ServiceDB`
2021-08-20 10:47:29 +02:00

49 lines
1.9 KiB
C++

// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#include "NotificationsConfiguration.hpp"
#include <Utils.hpp>
#include <service-db/agents/settings/SystemSettings.hpp>
using namespace notifications;
NotificationsConfiguration::NotificationsConfiguration(std::shared_ptr<sys::phone_modes::Observer> phoneModeObserver,
std::shared_ptr<settings::Settings> settings,
const locks::PhoneLockHandler &phoneLockHandler)
: phoneModeObserver{phoneModeObserver}, settings{settings}, phoneLockHandler{phoneLockHandler}
{}
void NotificationsConfiguration::updateCurrentCall(CallNotificationPolicy &policy)
{
policy.updateCurrentCall(phoneModeObserver->getCurrentPhoneMode());
}
void NotificationsConfiguration::callNumberCheck(CallNotificationPolicy &policy, bool contactInFavourites)
{
policy.numberCheck(getDNDCallsFromFavourites(), contactInFavourites);
}
void NotificationsConfiguration::updateCurrentList(NotificationsListPolicy &policy)
{
policy.updateCurrentList(phoneModeObserver->getCurrentPhoneMode(),
phoneLockHandler.isPhoneLocked(),
getDNDNotificationsOnLockedScreen());
}
void NotificationsConfiguration::updateCurrentSMS(SMSNotificationPolicy &policy)
{
policy.updateCurrentSMS(phoneModeObserver->getCurrentPhoneMode());
}
auto NotificationsConfiguration::getDNDNotificationsOnLockedScreen() const noexcept -> bool
{
return utils::getNumericValue<bool>(
settings->getValue(settings::Offline::notificationsWhenLocked, settings::SettingsScope::Global));
}
auto NotificationsConfiguration::getDNDCallsFromFavourites() const noexcept -> bool
{
return utils::getNumericValue<bool>(
settings->getValue(settings::Offline::callsFromFavorites, settings::SettingsScope::Global));
}