diff options
Diffstat (limited to 'src/components/application_manager/src/commands/mobile/get_way_points_request.cc')
-rw-r--r-- | src/components/application_manager/src/commands/mobile/get_way_points_request.cc | 51 |
1 files changed, 46 insertions, 5 deletions
diff --git a/src/components/application_manager/src/commands/mobile/get_way_points_request.cc b/src/components/application_manager/src/commands/mobile/get_way_points_request.cc index da4ce38646..66f9602f40 100644 --- a/src/components/application_manager/src/commands/mobile/get_way_points_request.cc +++ b/src/components/application_manager/src/commands/mobile/get_way_points_request.cc @@ -26,6 +26,24 @@ void GetWayPointsRequest::Run() { SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); return; } + + if (!CheckHMIInterfaceAvailability(HmiInterfaces::HMI_INTERFACE_Navigation)) { + LOG4CXX_ERROR(logger_, "Navi interface is not available"); + SendResponse(false, + mobile_apis::Result::UNSUPPORTED_RESOURCE, + "Navi is not supported by system"); + return; + } + + if (!CheckHMINaviCapabilities()) { + LOG4CXX_ERROR(logger_, + "GetWayPoints request is disallowed by hmi capabilities"); + SendResponse(false, + mobile_apis::Result::UNSUPPORTED_RESOURCE, + "Request is disallowed by HMI capabilities"); + return; + } + smart_objects::SmartObject msg_params = smart_objects::SmartObject(smart_objects::SmartType_Map); @@ -37,6 +55,21 @@ void GetWayPointsRequest::Run() { true); } +bool GetWayPointsRequest::CheckHMINaviCapabilities() { + const HMICapabilities& hmi_capabilities = + application_manager_.hmi_capabilities(); + + const smart_objects::SmartObject* navi_capabilities = + hmi_capabilities.navigation_capability(); + if (navi_capabilities) { + if (navi_capabilities->keyExists("getWayPointsEnabled")) { + return (*navi_capabilities)["getWayPointsEnabled"].asBool(); + } + } + + return true; +} + void GetWayPointsRequest::on_event(const event_engine::Event& event) { LOG4CXX_AUTO_TRACE(logger_); const smart_objects::SmartObject& message = event.smart_object(); @@ -49,7 +82,8 @@ void GetWayPointsRequest::on_event(const event_engine::Event& event) { } case hmi_apis::FunctionID::Navigation_GetWayPoints: { LOG4CXX_INFO(logger_, "Received Navigation_GetWayPoints event"); - EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Navigation); + const bool is_waypoints_valid = ValidateSmartObjectStrings( + message[strings::msg_params][strings::way_points]); const hmi_apis::Common_Result::eType result_code = static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); @@ -57,10 +91,17 @@ void GetWayPointsRequest::on_event(const event_engine::Event& event) { GetInfo(message, response_info); const bool result = PrepareResultForMobileResponse( result_code, HmiInterfaces::HMI_INTERFACE_Navigation); - SendResponse(result, - MessageHelper::HMIToMobileResult(result_code), - response_info.empty() ? NULL : response_info.c_str(), - &(message[strings::msg_params])); + + if (is_waypoints_valid) { + SendResponse(result, + MessageHelper::HMIToMobileResult(result_code), + response_info.empty() ? NULL : response_info.c_str(), + &(message[strings::msg_params])); + } else { + SendResponse(false, + mobile_apis::Result::GENERIC_ERROR, + "Invalid message received from vehicle"); + } break; } default: { |