From e3296bb4e8f98980b88be2cb81c03dc1fd3f2d35 Mon Sep 17 00:00:00 2001 From: Alek-Mudita <54846206+Alek-Mudita@users.noreply.github.com> Date: Thu, 12 Mar 2020 10:46:22 +0100 Subject: [PATCH] Egd 2946 add proper rejected call handling (#220) * [EGD-2046] fixed rejected call status. Hangup call as asnychronous call Code clean up. * [EGD-2964] code refactored * [EGD-2946] missing rejexted call type name * [EGD-2946] call app - time duration use RTC fix #ifdef in AudioServiceApi Minor gui fixec in call window --- image/assets/lang/lang_en.json | 2 + .../application-call/ApplicationCall.cpp | 233 +++++++++++------- .../application-call/ApplicationCall.hpp | 34 ++- .../application-call/windows/CallWindow.cpp | 99 +++----- .../application-call/windows/CallWindow.hpp | 2 +- .../windows/CallLogDetailsWindow.cpp | 28 ++- .../service-audio/api/AudioServiceAPI.hpp | 16 +- .../service-cellular/CellularCall.cpp | 14 +- .../service-cellular/CellularCall.hpp | 8 +- .../service-cellular/ServiceCellular.cpp | 13 +- .../api/CellularServiceAPI.cpp | 13 +- .../api/CellularServiceAPI.hpp | 23 +- .../messages/CellularMessage.hpp | 6 +- 13 files changed, 265 insertions(+), 226 deletions(-) diff --git a/image/assets/lang/lang_en.json b/image/assets/lang/lang_en.json index ffface4c2..83b923804 100644 --- a/image/assets/lang/lang_en.json +++ b/image/assets/lang/lang_en.json @@ -62,6 +62,7 @@ "app_calllog_incoming_call": "incoming call", "app_calllog_outgoing_call": "outgoing call", "app_calllog_missed_call": "missed call", + "app_calllog_rejected_call": "rejected call", "app_calllog_date": "Date", "app_calllog_options_title": "Options", "app_calllog_options_contact_details": "Contact details", @@ -106,6 +107,7 @@ "app_call_end_call": "END CALL", "app_call_emergency": "Emergency call", "app_call_is_calling": "is calling", + "app_call_calling": "calling...", "app_call_call_ended": "call ended", "app_call_add": "ADD", "app_call_contact": "CONTACT", diff --git a/module-apps/application-call/ApplicationCall.cpp b/module-apps/application-call/ApplicationCall.cpp index abd29bbf7..31c23f279 100644 --- a/module-apps/application-call/ApplicationCall.cpp +++ b/module-apps/application-call/ApplicationCall.cpp @@ -10,11 +10,13 @@ #include "Application.hpp" #include "MessageType.hpp" -#include "windows/CallMainWindow.hpp" -#include "windows/EnterNumberWindow.hpp" -#include "windows/EmergencyCallWindow.hpp" -#include "windows/CallWindow.hpp" #include "data/CallSwitchData.hpp" +#include "log/log.hpp" +#include "time/time_conversion.hpp" +#include "windows/CallMainWindow.hpp" +#include "windows/CallWindow.hpp" +#include "windows/EmergencyCallWindow.hpp" +#include "windows/EnterNumberWindow.hpp" #include #include "service-cellular/ServiceCellular.hpp" @@ -22,6 +24,7 @@ #include "service-audio/api/AudioServiceAPI.hpp" #include "service-appmgr/ApplicationManager.hpp" +#include namespace app { @@ -30,31 +33,100 @@ namespace app { { } -ApplicationCall::~ApplicationCall() { + // number of seconds after end call to siwtch back to previous application + constexpr auto delayToSwitchToPreviousApp = 3; + + void ApplicationCall::timerCallCallback() + { + callDuration = utils::time::Timestamp().getTime() - callStartTime; + + auto it = windows.find(window::name_call); + if (getCurrentWindow() == it->second) + { + auto callWindow = dynamic_cast(getCurrentWindow()); + + if (callWindow && callWindow->getState() == gui::CallWindow::State::CALL_IN_PROGRESS) + { + callWindow->updateDuration(callDuration); + refreshWindow(gui::RefreshModes::GUI_REFRESH_FAST); + } + } + + // delayed switch to previous application + if (callDuration >= callDelayedDuration) + { + stopCallTimer(); + sapm::ApplicationManager::messageSwitchPreviousApplication(this); + } } -void ApplicationCall::timerCallCallback() +void ApplicationCall::CallAbortHandler() { - // Invoked when timer ticked, 3 seconds after end call event if user didn't press back button earlier. - ++callDuration; + gui::CallWindow *callWindow = dynamic_cast(windows.find(window::name_call)->second); + assert(callWindow != nullptr); - auto it = windows.find(window::name_call); - if (getCurrentWindow() == it->second) + LOG_INFO("---------------------------------CallAborted"); + AudioServiceAPI::Stop(this); + callDelayedDuration = callDuration + delayToSwitchToPreviousApp; + callWindow->setState(gui::CallWindow::State::CALL_ENDED); + refreshWindow(gui::RefreshModes::GUI_REFRESH_DEEP); +} + +void ApplicationCall::CallActiveHandler() +{ + gui::CallWindow *callWindow = dynamic_cast(windows.find(window::name_call)->second); + assert(callWindow != nullptr); + + runCallTimer(); + + LOG_INFO("---------------------------------CallActive"); + callWindow->setState(gui::CallWindow::State::CALL_IN_PROGRESS); + refreshWindow(gui::RefreshModes::GUI_REFRESH_DEEP); +} + +void ApplicationCall::IncomingCallHandler(const CellularNotificationMessage *const msg) +{ + gui::CallWindow *callWindow = dynamic_cast(windows.find(window::name_call)->second); + assert(callWindow != nullptr); + + LOG_INFO("---------------------------------IncomingCall"); + if (callWindow->getState() == gui::CallWindow::State::INCOMING_CALL) { - gui::CallWindow *callWindow = reinterpret_cast(getCurrentWindow()); - - if (callWindow->getState() == gui::CallWindow::State::CALL_IN_PROGRESS) + LOG_INFO("ignoring call incoming"); + } + else + { + AudioServiceAPI::RoutingStart(this); + std::unique_ptr data = std::make_unique(msg->data); + // send to itself message to switch (run) call application + callWindow->setState(gui::CallWindow::State::INCOMING_CALL); + if (getState() == State::ACTIVE_FORGROUND) { - callWindow->updateDuration(callDuration); - refreshWindow(gui::RefreshModes::GUI_REFRESH_FAST); + LOG_INFO("++++++++++++WINDOW SWITCH"); + switchWindow(window::name_call, std::move(data)); + } + else + { + LOG_INFO("++++++++++++APP SWITCH"); + + sapm::ApplicationManager::messageSwitchApplication(this, name_call, window::name_call, std::move(data)); } } +} - if (callDuration >= callEndTime) +void ApplicationCall::RingingHandler(const CellularNotificationMessage *const msg) +{ + gui::CallWindow *callWindow = dynamic_cast(windows.find(window::name_call)->second); + assert(callWindow != nullptr); + + LOG_INFO("---------------------------------Ringing"); + AudioServiceAPI::RoutingStart(this); + + std::unique_ptr data = std::make_unique(msg->data); + callWindow->setState(gui::CallWindow::State::OUTGOING_CALL); + if (getState() == State::ACTIVE_FORGROUND) { - LOG_INFO("callDuration %d, callEndTime id %d", callDuration, callEndTime); - timerCall.stop(); - sapm::ApplicationManager::messageSwitchPreviousApplication(this); + switchWindow(window::name_call, std::move(data)); } } @@ -68,75 +140,55 @@ sys::Message_t ApplicationCall::DataReceivedHandler(sys::DataMessage* msgl,sys:: return retMsg; } - //this variable defines whether message was processed. - bool handled = false; if (msgl->messageType == MessageType::CellularNotification) { + CellularNotificationMessage *msg = dynamic_cast(msgl); + assert(msg != nullptr); - CellularNotificationMessage *msg = reinterpret_cast(msgl); - gui::CallWindow *callWindow = reinterpret_cast(windows.find(window::name_call)->second); - - if (msg->type == CellularNotificationMessage::Type::CallAborted) + switch (msg->type) { - LOG_INFO("---------------------------------CallAborted"); - AudioServiceAPI::Stop(this); - callEndTime = callDuration + 3; - callWindow->setState(gui::CallWindow::State::CALL_ENDED); - refreshWindow(gui::RefreshModes::GUI_REFRESH_DEEP); + case CellularNotificationMessage::Type::CallAborted: { + CallAbortHandler(); } - else if( msg->type == CellularNotificationMessage::Type::CallActive ) { - callDuration = 0; - - LOG_INFO("---------------------------------CallActive"); - callWindow->setState( gui::CallWindow::State::CALL_IN_PROGRESS ); - refreshWindow( gui::RefreshModes::GUI_REFRESH_DEEP ); - } - else if( msg->type == CellularNotificationMessage::Type::IncomingCall ) { - //reset call duration -// callDuration = 0; - LOG_INFO("---------------------------------IncomingCall"); - if( callWindow->getState() == gui::CallWindow::State::INCOMING_CALL ) { - LOG_INFO("ignoring call incoming"); - } - else { - - AudioServiceAPI::RoutingStart(this); - runCallTimer(); - std::unique_ptr data = std::make_unique(msg->data); - //send to itself message to switch (run) call application - callWindow->setState( gui::CallWindow::State::INCOMING_CALL ); - if (getState() == State::ACTIVE_FORGROUND) - { - LOG_INFO("++++++++++++WINDOW SWITCH"); - switchWindow(window::name_call, std::move(data)); - } - else { - LOG_INFO("++++++++++++APP SWITCH"); - - sapm::ApplicationManager::messageSwitchApplication(this, name_call, window::name_call, std::move(data)); - } - } - } - else if( msg->type == CellularNotificationMessage::Type::Ringing ) { - //reset call duration - runCallTimer(); - LOG_INFO("---------------------------------Ringing"); - AudioServiceAPI::RoutingStart(this); - - std::unique_ptr data = std::make_unique(msg->data); - callWindow->setState( gui::CallWindow::State::OUTGOING_CALL ); - if (getState() == State::ACTIVE_FORGROUND) - { - switchWindow(window::name_call, std::move(data)); - } + break; + case CellularNotificationMessage::Type::CallActive: { + CallActiveHandler(); } - handled = true; + break; + case CellularNotificationMessage::Type::IncomingCall: { + IncomingCallHandler(msg); + } + break; + case CellularNotificationMessage::Type::Ringing: { + RingingHandler(msg); + } + break; + default: + break; + } + + return std::make_shared(); } - if( handled ) - return std::make_shared(); - else - return std::make_shared(sys::ReturnCodes::Unresolved); + if (resp != nullptr) + { + switch (resp->responseTo) + { + case MessageType::CellularHangupCall: { + if (resp->retCode == sys::ReturnCodes::Success) + { + CallAbortHandler(); + } + break; + } + default: + break; + } + + return std::make_shared(); + } + + return std::make_shared(sys::ReturnCodes::Unresolved); } // Invoked during initialization @@ -157,12 +209,6 @@ sys::ReturnCodes ApplicationCall::DeinitHandler() { return sys::ReturnCodes::Success; } -void ApplicationCall::stopCallTimer() { - LOG_INFO("switching to prev calldur: %d endTime: %d", callDuration, callEndTime ); - timerCall.stop(); - sapm::ApplicationManager::messageSwitchPreviousApplication( this ); -} - void ApplicationCall::createUserInterface() { @@ -190,9 +236,18 @@ const std::string& ApplicationCall::getDisplayedNumber() { } void ApplicationCall::runCallTimer() { - callDuration = 0; - callEndTime = -1; - timerCall.restart(); + callStartTime = utils::time::Timestamp().getTime(); + callDuration = std::numeric_limits::min(); + callDelayedDuration = std::numeric_limits::max(); + timerCall.restart(); +} + +void ApplicationCall::stopCallTimer() +{ + callStartTime = std::numeric_limits::max(); + callDuration = std::numeric_limits::min(); + callDelayedDuration = std::numeric_limits::max(); + timerCall.stop(); } void ApplicationCall::destroyUserInterface() { diff --git a/module-apps/application-call/ApplicationCall.hpp b/module-apps/application-call/ApplicationCall.hpp index a9461ed35..075312569 100644 --- a/module-apps/application-call/ApplicationCall.hpp +++ b/module-apps/application-call/ApplicationCall.hpp @@ -1,17 +1,9 @@ -/* - * @file ApplicationCall.hpp - * @author Robert Borzecki (robert.borzecki@mudita.com) - * @date 1 lip 2019 - * @brief - * @copyright Copyright (C) 2019 mudita.com - * @details - */ -#ifndef MODULE_APPS_APPLICATION_CALL_APPLICATIONCALL_HPP_ -#define MODULE_APPS_APPLICATION_CALL_APPLICATIONCALL_HPP_ +#pragma once #include "Application.hpp" -#include "SystemManager/SystemManager.hpp" #include "Service/Message.hpp" +#include "SystemManager/SystemManager.hpp" +#include namespace app { @@ -27,16 +19,24 @@ namespace window * */ class ApplicationCall: public Application { -protected: + private: + void CallAbortHandler(); + void CallActiveHandler(); + void IncomingCallHandler(const CellularNotificationMessage *const msg); + void RingingHandler(const CellularNotificationMessage *const msg); + + protected: std::string phoneNumber; AppTimer timerCall; - uint32_t callDuration = 0; - uint32_t callEndTime = -1; + time_t callStartTime = std::numeric_limits::max(); + ; + time_t callDuration = 0; + time_t callDelayedDuration = std::numeric_limits::max(); void timerCallCallback(); public: ApplicationCall( std::string name=name_call, std::string parent = "", bool startBackgound = false ); - virtual ~ApplicationCall(); - sys::Message_t DataReceivedHandler(sys::DataMessage* msgl,sys::ResponseMessage* resp) override; + ~ApplicationCall() override = default; + sys::Message_t DataReceivedHandler(sys::DataMessage* msgl,sys::ResponseMessage* resp) override; sys::ReturnCodes InitHandler() override; sys::ReturnCodes DeinitHandler() override; @@ -52,5 +52,3 @@ public: }; } /* namespace app */ - -#endif /* MODULE_APPS_APPLICATION_CALL_APPLICATIONCALL_HPP_ */ diff --git a/module-apps/application-call/windows/CallWindow.cpp b/module-apps/application-call/windows/CallWindow.cpp index d6507a15f..09c6e6f6f 100644 --- a/module-apps/application-call/windows/CallWindow.cpp +++ b/module-apps/application-call/windows/CallWindow.cpp @@ -209,9 +209,10 @@ void CallWindow::setVisibleState() { bottomBar->setActive(gui::BottomBar::Side::LEFT, false ); bottomBar->setActive(gui::BottomBar::Side::CENTER, false ); bottomBar->setActive(gui::BottomBar::Side::RIGHT, false ); -// bottomBar->setText( gui::BottomBar::Side::RIGHT, utils::localize.get("app_call_return") ); -// durationLabel->setText(utils::localize.get("app_call_call_ended")); - }break; + + durationLabel->setVisible(true); + durationLabel->setText(utils::localize.get("app_call_call_ended")); + }break; case State::CALL_IN_PROGRESS: { // titleLabel->setText("CALL_IN_PROGRESS"); durationLabel->setVisible(true); @@ -235,8 +236,9 @@ void CallWindow::setVisibleState() { bottomBar->setText( gui::BottomBar::Side::RIGHT, utils::localize.get("app_call_end_call") ); showIconsLambda(); - // durationLabel->setText(utils::localize.get("app_call_is_calling")); // TODO: alek: should be printed sthg? - }break; + durationLabel->setText(utils::localize.get("app_call_calling")); + durationLabel->setVisible(true); + }break; }; } @@ -244,8 +246,9 @@ void CallWindow::setCallNumber( std::string ) { } -void CallWindow::updateDuration( uint32_t duration ) { - uint32_t seconds = 0; +void CallWindow::updateDuration(time_t duration) +{ + uint32_t seconds = 0; uint32_t minutes = 0; uint32_t hours = 0; uint32_t days = 0; @@ -263,7 +266,6 @@ void CallWindow::updateDuration( uint32_t duration ) { ss<setText( ss.str()); - } bool CallWindow::handleSwitchData( SwitchData* data ) { @@ -327,67 +329,44 @@ bool CallWindow::handleSwitchData( SwitchData* data ) { void CallWindow::onBeforeShow( ShowMode mode, SwitchData* data ) { } -bool CallWindow::handleLeftButton() { - if( state == State::INCOMING_CALL ) { - auto ret = CellularServiceAPI::AnswerIncomingCall(application); +bool CallWindow::handleLeftButton() +{ + if (state == State::INCOMING_CALL) + { + auto ret = CellularServiceAPI::AnswerIncomingCall(application); - LOG_INFO("AnswerIncomingCall: %s",(ret?"OK":"FAIL")); + LOG_INFO("AnswerIncomingCall: %s", (ret ? "OK" : "FAIL")); return true; } - else if( state == State::OUTGOING_CALL ) { - } - else if( state == State::CALL_ENDED ) { - - } - else if( state == State::CALL_IN_PROGRESS ) { - - } - return false; + return false; } -bool CallWindow::handleCenterButton() { - if( state == State::INCOMING_CALL ) { - auto ret = CellularServiceAPI::HangupCall(application); - LOG_INFO("HangupCall: %s",(ret?"OK":"FAIL")); - //TODO switch to message templates window - return true; - } - else if( state == State::OUTGOING_CALL ) { - - } - else if( state == State::CALL_ENDED ) { - - } - else if( state == State::CALL_IN_PROGRESS ) { - - } - return false; -} -bool CallWindow::handleRightButton() { - if( state == State::INCOMING_CALL ) { - auto ret = CellularServiceAPI::HangupCall(application); - LOG_INFO("HangupCall: %s",(ret?"OK":"FAIL")); - - return true; - } - else if( state == State::OUTGOING_CALL ) { - auto ret = CellularServiceAPI::HangupCall(application); - LOG_INFO("HangupCall: %s",(ret?"OK":"FAIL")); +bool CallWindow::handleCenterButton() +{ + if (state == State::INCOMING_CALL) + { + LOG_ERROR("TODO: Reject call and send message template"); return true; } -// else if( state == State::CALL_ENDED ) { -// //return to previous application -// sapm::ApplicationManager::messageSwitchPreviousApplication( application ); -// return true; -// } - else if( state == State::CALL_IN_PROGRESS ) { - auto ret = CellularServiceAPI::HangupCall(application); - LOG_INFO("HangupCall: %s",(ret?"OK":"FAIL")); + return false; +} - return true; - } - return false; +bool CallWindow::handleRightButton() +{ + switch (state) + { + case State::INCOMING_CALL: + case State::OUTGOING_CALL: + case State::CALL_IN_PROGRESS: + CellularServiceAPI::HangupCall(application); + return true; + break; + default: + break; + } + + return false; } bool CallWindow::onInput( const InputEvent& inputEvent ) { diff --git a/module-apps/application-call/windows/CallWindow.hpp b/module-apps/application-call/windows/CallWindow.hpp index 476b2fbce..bf92fcd63 100644 --- a/module-apps/application-call/windows/CallWindow.hpp +++ b/module-apps/application-call/windows/CallWindow.hpp @@ -71,7 +71,7 @@ public: */ void setState(State state); const State &getState(); - void updateDuration(uint32_t duration); + void updateDuration(time_t duration); void setCallNumber(std::string); bool onInput(const InputEvent &inputEvent) override; diff --git a/module-apps/application-calllog/windows/CallLogDetailsWindow.cpp b/module-apps/application-calllog/windows/CallLogDetailsWindow.cpp index 282be9aa5..8b2e979ad 100644 --- a/module-apps/application-calllog/windows/CallLogDetailsWindow.cpp +++ b/module-apps/application-calllog/windows/CallLogDetailsWindow.cpp @@ -230,14 +230,26 @@ void CallLogDetailsWindow::onBeforeShow( ShowMode mode, SwitchData* data ) { img->setVisible(false); } callTypeImg[callType]->setVisible(true); - - UTF8 callTypeStr; - switch(callType) { - case CallLogCallType::IN: callTypeStr = utils::localize.get("app_calllog_incoming_call"); break; - case CallLogCallType::OUT: callTypeStr = utils::localize.get("app_calllog_outgoing_call"); break; - default: callTypeStr = utils::localize.get("app_calllog_missed_call"); break; - } - typeData->setText(callTypeStr); + + UTF8 callTypeStr; + switch (record.type) + { + case CallType::CT_INCOMING: + callTypeStr = utils::localize.get("app_calllog_incoming_call"); + break; + case CallType::CT_OUTGOING: + callTypeStr = utils::localize.get("app_calllog_outgoing_call"); + break; + case CallType::CT_MISSED: + callTypeStr = utils::localize.get("app_calllog_missed_call"); + break; + case CallType::CT_REJECTED: + callTypeStr = utils::localize.get("app_calllog_rejected_call"); + break; + default: + break; + } + typeData->setText(callTypeStr); durationData->setText(utils::time::Timestamp(record.duration).str("%Mm %Ss")); // TODO: alek: add duration class diff --git a/module-services/service-audio/api/AudioServiceAPI.hpp b/module-services/service-audio/api/AudioServiceAPI.hpp index c11473981..63f9d79cb 100644 --- a/module-services/service-audio/api/AudioServiceAPI.hpp +++ b/module-services/service-audio/api/AudioServiceAPI.hpp @@ -1,16 +1,4 @@ -/* - * @file AudioSerivceAPI.hpp - * @author Mateusz Piesta (mateusz.piesta@mudita.com) - * @date 29.07.19 - * @brief - * @copyright Copyright (C) 2019 mudita.com - * @details - */ - - - -#ifndef PUREPHONE_AUDIOSERIVCEAPI_HPP -#define PUREPHONE_AUDIOSERVICEAPI_HPP +#pragma once #include "../messages/AudioMessage.hpp" #include @@ -33,5 +21,3 @@ public: static audio::RetCode SetOutputVolume(sys::Service* serv,const audio::Volume vol); static audio::RetCode SetInputGain(sys::Service* serv,const audio::Gain gain); }; - -#endif //PUREPHONE_AUDIOSERIVCEAPI_HPP diff --git a/module-services/service-cellular/CellularCall.cpp b/module-services/service-cellular/CellularCall.cpp index 93408fa36..8d7ccb38e 100644 --- a/module-services/service-cellular/CellularCall.cpp +++ b/module-services/service-cellular/CellularCall.cpp @@ -120,9 +120,8 @@ namespace CellularCall return false; } - bool CellularCall::endCall() + bool CellularCall::endCall(Forced forced) { - if (!isValid()) { LOG_ERROR("Trying to update invalid call"); @@ -140,12 +139,19 @@ namespace CellularCall switch (callType) { case CallType::CT_INCOMING: { - setType(CallType::CT_REJECTED); + if (forced == Forced::True) + { + setType(CallType::CT_REJECTED); + } + else + { + setType(CallType::CT_MISSED); + } } break; case CallType::CT_OUTGOING: { - setType(CallType::CT_MISSED); + // do nothing } break; diff --git a/module-services/service-cellular/CellularCall.hpp b/module-services/service-cellular/CellularCall.hpp index 2b8c190f5..9f69fb5a2 100644 --- a/module-services/service-cellular/CellularCall.hpp +++ b/module-services/service-cellular/CellularCall.hpp @@ -59,6 +59,12 @@ namespace ModemCall namespace CellularCall { + enum class Forced : bool + { + False, + True + }; + class CellularCall { CalllogRecord call; @@ -114,7 +120,7 @@ namespace CellularCall bool setActive(); - bool endCall(); + bool endCall(Forced forced = Forced::False); bool isValid() const { diff --git a/module-services/service-cellular/ServiceCellular.cpp b/module-services/service-cellular/ServiceCellular.cpp index 851d35cd6..cb4cbdcc7 100644 --- a/module-services/service-cellular/ServiceCellular.cpp +++ b/module-services/service-cellular/ServiceCellular.cpp @@ -415,20 +415,21 @@ sys::Message_t ServiceCellular::DataReceivedHandler(sys::DataMessage *msgl, sys: { if (channel->cmd(at::AT::ATH)) { - responseMsg = std::make_shared(true); stopTimer(callStateTimerId); - // Propagate "CallAborted" notification into system - sys::Bus::SendMulticast(std::make_shared(CellularNotificationMessage::Type::CallAborted), - sys::BusChannels::ServiceCellularNotifications, this); + if (!ongoingCall.endCall(CellularCall::Forced::True)) + { + LOG_ERROR("Failed to end ongoing call"); + } + responseMsg = std::make_shared(true, msgl->messageType); } else { LOG_ERROR("Call not aborted"); - responseMsg = std::make_shared(false); + responseMsg = std::make_shared(false, msgl->messageType); } break; } - responseMsg = std::make_shared(false); + responseMsg = std::make_shared(false, msgl->messageType); } break; diff --git a/module-services/service-cellular/api/CellularServiceAPI.cpp b/module-services/service-cellular/api/CellularServiceAPI.cpp index 924e124aa..ea6dbe857 100644 --- a/module-services/service-cellular/api/CellularServiceAPI.cpp +++ b/module-services/service-cellular/api/CellularServiceAPI.cpp @@ -44,18 +44,11 @@ bool CellularServiceAPI::AnswerIncomingCall(sys::Service* serv) { } } -bool CellularServiceAPI::HangupCall(sys::Service* serv){ +void CellularServiceAPI::HangupCall(sys::Service *serv) +{ std::shared_ptr msg = std::make_shared(MessageType::CellularHangupCall); - auto ret = sys::Bus::SendUnicast(msg,ServiceCellular::serviceName,serv,5000); - CellularResponseMessage* response = reinterpret_cast(ret.second.get()); - if((ret.first == sys::ReturnCodes::Success) && (response->retCode == true)){ - return true; - } - else{ - LOG_ERROR("Failed"); - return false; - } + sys::Bus::SendUnicast(msg, ServiceCellular::serviceName, serv); } std::string CellularServiceAPI::GetIMSI(sys::Service *serv, bool getFullIMSINumber) diff --git a/module-services/service-cellular/api/CellularServiceAPI.hpp b/module-services/service-cellular/api/CellularServiceAPI.hpp index 6aefa9905..6595c30e0 100644 --- a/module-services/service-cellular/api/CellularServiceAPI.hpp +++ b/module-services/service-cellular/api/CellularServiceAPI.hpp @@ -17,42 +17,41 @@ class Service; -class CellularServiceAPI { -public: - static bool DialNumber(sys::Service* serv,const std::string& number); - static bool AnswerIncomingCall(sys::Service* serv); - static bool HangupCall(sys::Service* serv); +namespace CellularServiceAPI +{ + bool DialNumber(sys::Service *serv, const std::string &number); + bool AnswerIncomingCall(sys::Service *serv); + void HangupCall(sys::Service *serv); /* * @brief Its calls sercive-cellular for selected SIM IMSI number. * @param serv pointer to caller service. * @param getFullIMSINumber returned string format. false returns only country code, true returns whole iMSI number. * #return IMSI number when succeeds, empty string when fails */ - static std::string GetIMSI(sys::Service *serv, bool getFullIMSINumber = false); + std::string GetIMSI(sys::Service *serv, bool getFullIMSINumber = false); /* * @brief Its calls sercive-cellular for selected SIM own phone number. * @param serv pointer to caller service. * #return SIM own number when succeeds, empty string when fails */ - static std::string GetOwnNumber(sys::Service *serv); + std::string GetOwnNumber(sys::Service *serv); /* * @brief It calls service-cellulat fo newtwork info * @param serv pointer to caller service. */ - static void GetNetworkInfo(sys::Service *serv); + void GetNetworkInfo(sys::Service *serv); /* * @brief It calls service-cellulat to perform operators scan * @param serv pointer to caller service. * */ - static void StartOperatorsScan(sys::Service *serv); + void StartOperatorsScan(sys::Service *serv); /* * @brief It calls service-cellulat to switch antenna * @param serv pointer to caller service. * @param antenna selected antenna. 0 to select antenna A, 1 to select antenna B */ - static bool SelectAntenna(sys::Service *serv, uint8_t antenna); -}; - + bool SelectAntenna(sys::Service *serv, uint8_t antenna); +}; // namespace CellularServiceAPI #endif //PUREPHONE_CELLULARSERVICEAPI_HPP diff --git a/module-services/service-cellular/messages/CellularMessage.hpp b/module-services/service-cellular/messages/CellularMessage.hpp index b263649a8..9f9fb887a 100644 --- a/module-services/service-cellular/messages/CellularMessage.hpp +++ b/module-services/service-cellular/messages/CellularMessage.hpp @@ -75,10 +75,12 @@ public: class CellularResponseMessage : public sys::ResponseMessage { public: - CellularResponseMessage(uint32_t retCode, std::string retdata = std::string()) : sys::ResponseMessage(), retCode(retCode), data(retdata){}; + CellularResponseMessage(bool retCode, std::string retdata = std::string(), MessageType responseTo = MessageType::MessageTypeUninitialized) + : sys::ResponseMessage(sys::ReturnCodes::Success, responseTo), retCode(retCode), data(retdata){}; + CellularResponseMessage(bool retCode, MessageType responseTo) : sys::ResponseMessage(sys::ReturnCodes::Success, responseTo), retCode(retCode){}; virtual ~CellularResponseMessage(){}; - uint32_t retCode; + bool retCode; std::string data; };