summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAKalinich-Luxoft <AKalinich@luxoft.com>2017-09-20 13:38:22 +0300
committerValerii <vmalkov@luxoft.com>2018-01-26 14:15:35 +0200
commit05b7ae032fb4161d15e64af31aaba4f9c9f23598 (patch)
tree7b0f1d2e9222836369c7131f4aba8528a0aba54a
parentbf46df98ffa80179d8d7317f2ce5e4b4f9a52dbc (diff)
downloadsdl_core-05b7ae032fb4161d15e64af31aaba4f9c9f23598.tar.gz
Update GetWayPoints RPC logic according to proposal
-rw-r--r--src/components/application_manager/include/application_manager/commands/mobile/get_way_points_request.h6
-rw-r--r--src/components/application_manager/src/commands/mobile/get_way_points_request.cc51
2 files changed, 52 insertions, 5 deletions
diff --git a/src/components/application_manager/include/application_manager/commands/mobile/get_way_points_request.h b/src/components/application_manager/include/application_manager/commands/mobile/get_way_points_request.h
index bf23121177..974261d78a 100644
--- a/src/components/application_manager/include/application_manager/commands/mobile/get_way_points_request.h
+++ b/src/components/application_manager/include/application_manager/commands/mobile/get_way_points_request.h
@@ -67,6 +67,12 @@ class GetWayPointsRequest : public CommandRequestImpl {
virtual void on_event(const event_engine::Event& event);
private:
+ /**
+ * @brief Checks is request allowed by HMI capabilities
+ * @return true if allowed otherwise false
+ */
+ bool CheckHMINaviCapabilities();
+
DISALLOW_COPY_AND_ASSIGN(GetWayPointsRequest);
};
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: {