From eab694c090848c77eb80b6178483132a4554f306 Mon Sep 17 00:00:00 2001 From: Marek Niepieklo Date: Thu, 24 Feb 2022 16:24:35 +0100 Subject: [PATCH] [MOS-221] DND - missing notifications Add notifications for missing calls in DnD mode --- .../service-cellular/CMakeLists.txt | 1 + .../service-cellular/call/CallDB.cpp | 18 ++++++++++++++++ .../service-cellular/call/CallDB.hpp | 21 +++++++++++++++++++ .../service-cellular/call/CallRingGuard.cpp | 5 +++++ .../service-cellular/call/CallRingGuard.hpp | 8 +++++++ .../service-cellular/call/CellularCall.cpp | 8 ++++++- .../service-cellular/call/CellularCall.hpp | 2 ++ 7 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 module-services/service-cellular/call/CallDB.cpp create mode 100644 module-services/service-cellular/call/CallDB.hpp diff --git a/module-services/service-cellular/CMakeLists.txt b/module-services/service-cellular/CMakeLists.txt index aa9ec9116c6351a579bb2aa4fc8c1cc40db7b10c..78c97658ae2cc67dd1e423274b130a87da2ade7d 100644 --- a/module-services/service-cellular/CMakeLists.txt +++ b/module-services/service-cellular/CMakeLists.txt @@ -19,6 +19,7 @@ set(SOURCES call/CellularCall.cpp call/CallAudio.cpp call/CallGUI.cpp + call/CallDB.cpp call/CallRingGuard.cpp CellularServiceAPI.cpp CellularUrcHandler.cpp diff --git a/module-services/service-cellular/call/CallDB.cpp b/module-services/service-cellular/call/CallDB.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f3a1e01143f7f4fdd8a6fb5bfe42eb94d995301f --- /dev/null +++ b/module-services/service-cellular/call/CallDB.cpp @@ -0,0 +1,18 @@ +// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved. +// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md + +#include "CallDB.hpp" +#include "service-appmgr/data/CallActionsParams.hpp" +#include +#include + +CallDB::CallDB(sys::Service &s) : owner(s) +{} + +void CallDB::incrementNotAnsweredCallsNotification(const utils::PhoneNumber::View &number) +{ + DBServiceAPI::GetQuery( + &owner, + db::Interface::Name::Notifications, + std::make_unique(NotificationsRecord::Key::Calls, number)); +} diff --git a/module-services/service-cellular/call/CallDB.hpp b/module-services/service-cellular/call/CallDB.hpp new file mode 100644 index 0000000000000000000000000000000000000000..9500bed46f59e90df701c8124f07d266f0c052be --- /dev/null +++ b/module-services/service-cellular/call/CallDB.hpp @@ -0,0 +1,21 @@ +// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved. +// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md + +#pragma once + +#include + +namespace sys +{ + class Service; +} + +class CallDB +{ + sys::Service &owner; + + public: + explicit CallDB(sys::Service &); + + void incrementNotAnsweredCallsNotification(const utils::PhoneNumber::View &number); +}; diff --git a/module-services/service-cellular/call/CallRingGuard.cpp b/module-services/service-cellular/call/CallRingGuard.cpp index 45070116db893c19335a95312adb0e2131b597c9..d4cc257ab77c242f871392f72c25ed5cc0532529 100644 --- a/module-services/service-cellular/call/CallRingGuard.cpp +++ b/module-services/service-cellular/call/CallRingGuard.cpp @@ -14,3 +14,8 @@ bool callClipGuard(CellularCall::Call &call) return call.mode == sys::phone_modes::PhoneMode::DoNotDisturb && call.operations.areCallsFromFavouritesEnabled() && call.operations.isNumberInFavourites(); } + +bool callDNDGuard(CellularCall::Call &call) +{ + return call.mode == sys::phone_modes::PhoneMode::DoNotDisturb; +} diff --git a/module-services/service-cellular/call/CallRingGuard.hpp b/module-services/service-cellular/call/CallRingGuard.hpp index 17f268d1f87d181df6ab21c7743277330e44bd62..0d5c105bb07554625a86466e2742fa5613a26bc5 100644 --- a/module-services/service-cellular/call/CallRingGuard.hpp +++ b/module-services/service-cellular/call/CallRingGuard.hpp @@ -24,3 +24,11 @@ bool callRingGuard(CellularCall::Call &call); /// - we have this somebody phone number via CLIP URC /// It wont be ever called for private numbers bool callClipGuard(CellularCall::Call &call); + +/// Guard to check if we should place missed call notification +/// This flow is when: +/// - We are in do not disturb mode +/// - somebody calls +/// - we have this somebody phone number via CLIP/RING URC +/// It wont be ever called for private numbers +bool callDNDGuard(CellularCall::Call &call); diff --git a/module-services/service-cellular/call/CellularCall.cpp b/module-services/service-cellular/call/CellularCall.cpp index a6ec8691549bd77f7e66e448e3b3230127454696..84227d3a34aa1041e4c81f391799bcf609e6f897 100644 --- a/module-services/service-cellular/call/CellularCall.cpp +++ b/module-services/service-cellular/call/CellularCall.cpp @@ -6,6 +6,7 @@ #include "service-cellular/ServiceCellular.hpp" #include "service-db/agents/settings/SystemSettings.hpp" +#include #include #include #include @@ -21,7 +22,7 @@ namespace CellularCall { - Call::Call(ServiceCellular &owner) : owner(owner), audio(owner), gui(owner) + Call::Call(ServiceCellular &owner) : owner(owner), audio(owner), gui(owner), db(owner) { utils::PhoneNumber::View number = utils::PhoneNumber::View(); const CallType type = CallType::CT_NONE; @@ -60,6 +61,11 @@ namespace CellularCall gui.notifyCLIP(number); return true; } + + if (callDNDGuard(*this)) { + db.incrementNotAnsweredCallsNotification(number); + } + return false; } diff --git a/module-services/service-cellular/service-cellular/call/CellularCall.hpp b/module-services/service-cellular/service-cellular/call/CellularCall.hpp index c2ff2daba4ade70e3224cff11f6f0d5b96c4e960..cd7ae52086237c1dcc316662a9fa7c78b4d5f565 100644 --- a/module-services/service-cellular/service-cellular/call/CellularCall.hpp +++ b/module-services/service-cellular/service-cellular/call/CellularCall.hpp @@ -5,6 +5,7 @@ #include "call/CallAudio.hpp" #include "call/CallGUI.hpp" +#include "call/CallDB.hpp" #include "PhoneModes/PhoneMode.hpp" #include #include @@ -63,6 +64,7 @@ namespace CellularCall ServiceCellular &owner; CallRingAudio audio; CallGUI gui; + CallDB db; public: void setMode(sys::phone_modes::PhoneMode mode)