[EGD-2931] Fix private number incoming calls

The change adjusts both cellular service as well as
call and call log applications to handle properly
incoming calls from private numbers.
This commit is contained in:
Hubert Chrzaniuk committed 2021-02-12 10:32:15 +01:00
1 parent 3a86d65b1d
commit 3cc558b02a
38 files changed
+500 -189

No files matched your search

@@ -50,40 +50,27 @@ namespace app
switchWindow(app::window::name_emergencyCall, std::forward<decltype(data)>(data));
return msgHandled();
});
auto convertibleToActionHandler = [this](sys::Message *request) { return HandleMessageAsAction(request); };
connect(typeid(CellularActionResponseMessage), convertibleToActionHandler);
}
auto ApplicationCall::HandleMessageAsAction(sys::Message *request) -> std::shared_ptr<sys::ResponseMessage>
{
auto actionMsg = dynamic_cast<manager::actions::ConvertibleToAction *>(request);
if (!actionMsg) {
return std::make_shared<sys::ResponseMessage>(sys::ReturnCodes::Failure);
}
auto buttonAction = [=]() -> bool {
returnToPreviousWindow();
return true;
};
constexpr auto iconNoEmergency = "emergency_W_G";
auto textNoEmergency = utils::localize.get("app_call_wrong_emergency");
constexpr auto iconNoSim = "info_big_circle_W_G";
const auto textNoSim = utils::localize.get("app_call_no_sim");
auto action = actionMsg->toAction();
switch (const auto actionId = action->getAction(); actionId) {
case app::manager::actions::CallRejectNotEmergency:
utils::findAndReplaceAll(textNoEmergency, "$NUMBER", action->getData()->getDescription());
addActionReceiver(manager::actions::NotAnEmergencyNotification, [this](auto &&data) {
auto buttonAction = [=]() -> bool {
returnToPreviousWindow();
return true;
};
constexpr auto iconNoEmergency = "emergency_W_G";
auto textNoEmergency = utils::localize.get("app_call_wrong_emergency");
utils::findAndReplaceAll(textNoEmergency, "$NUMBER", data->getDescription());
showNotification(buttonAction, iconNoEmergency, textNoEmergency);
break;
case app::manager::actions::CallRejectNoSim:
return msgHandled();
});
addActionReceiver(manager::actions::NoSimNotification, [this](auto &&data) {
auto buttonAction = [=]() -> bool {
returnToPreviousWindow();
return true;
};
constexpr auto iconNoSim = "info_big_circle_W_G";
const auto textNoSim = utils::localize.get("app_call_no_sim");
showNotification(buttonAction, iconNoSim, textNoSim);
break;
}
return std::make_shared<sys::ResponseMessage>();
return msgHandled();
});
}
// number of seconds after end call to switch back to previous application
@@ -99,14 +86,34 @@ namespace app
manager::Controller::sendAction(this, manager::actions::Call, std::make_unique<app::CallActiveData>());
}
void ApplicationCall::IncomingCallHandler(const CellularCallMessage *const msg)
void ApplicationCall::CallerIdHandler(const CellularCallMessage *const msg)
{
if (state == call::State::IDLE) {
if (getState() == call::State::IDLE) {
if (callerIdTimer) {
callerIdTimer->stop();
callerIdTimer.reset(nullptr);
}
manager::Controller::sendAction(
this, manager::actions::Call, std::make_unique<app::IncomingCallData>(msg->number));
}
}
void ApplicationCall::IncomingCallHandler(const CellularCallMessage *const msg)
{
if (getState() == call::State::IDLE) {
constexpr sys::ms callerIdTimeout = 1000;
callerIdTimer =
std::make_unique<sys::Timer>("CallerIdTimer", this, callerIdTimeout, sys::Timer::Type::SingleShot);
callerIdTimer->connect([=](sys::Timer &) {
callerIdTimer->stop();
manager::Controller::sendAction(
this,
manager::actions::Call,
std::make_unique<app::IncomingCallData>(utils::PhoneNumber().getView()));
});
}
}
void ApplicationCall::RingingHandler(const CellularCallMessage *const msg)
{
manager::Controller::sendAction(
@@ -153,6 +160,9 @@ namespace app
case CellularCallMessage::Type::IncomingCall: {
IncomingCallHandler(msg);
} break;
case CellularCallMessage::Type::CallerId: {
CallerIdHandler(msg);
} break;
}
}