diff options
author | Alex Kutsan <akutsan@luxoft.com> | 2017-01-18 09:43:01 +0200 |
---|---|---|
committer | Alex Kutsan <akutsan@luxoft.com> | 2017-01-18 09:43:01 +0200 |
commit | 44263b5e41770bd1f7d156dff71112e02fe68c18 (patch) | |
tree | 94df1f4c0264d9b69dc002661290f37d9c5accca /src/components/application_manager/src/commands/hmi | |
parent | 0d9c2776edbb0b50bbf878c563cb80df398986ed (diff) | |
parent | e325c8bc87099c5743ac54e22ac0c649991b6b45 (diff) | |
download | sdl_core-44263b5e41770bd1f7d156dff71112e02fe68c18.tar.gz |
Change policies path and fix params method usage
Diffstat (limited to 'src/components/application_manager/src/commands/hmi')
9 files changed, 258 insertions, 96 deletions
diff --git a/src/components/application_manager/src/commands/hmi/decrypt_certificate_request.cc b/src/components/application_manager/src/commands/hmi/decrypt_certificate_request.cc new file mode 100644 index 0000000000..a09fe71bf2 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/decrypt_certificate_request.cc @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2016, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "application_manager/commands/hmi/decrypt_certificate_request.h" + +namespace application_manager { + +namespace commands { + +DecryptCertificateRequest::DecryptCertificateRequest( + const MessageSharedPtr& message, ApplicationManager& application_manager) + : RequestToHMI(message, application_manager) {} + +void DecryptCertificateRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + const uint32_t correlation_id = RequestToHMI::correlation_id(); + const uint32_t app_id = RequestToHMI::application_id(); + application_manager_.set_application_id(correlation_id, app_id); + SendRequest(); +} + +} // namespace commands + +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/decrypt_certificate_response.cc b/src/components/application_manager/src/commands/hmi/decrypt_certificate_response.cc new file mode 100644 index 0000000000..cea9290f7d --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/decrypt_certificate_response.cc @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2016, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +#include "application_manager/commands/hmi/decrypt_certificate_response.h" + +#include "application_manager/policies/policy_handler.h" +#ifdef EXTERNAL_PROPRIETARY_MODE +namespace application_manager { + +namespace commands { + +DecryptCertificateResponse::DecryptCertificateResponse( + const MessageSharedPtr& message, ApplicationManager& application_manager) + : ResponseFromHMI(message, application_manager) {} + +DecryptCertificateResponse::~DecryptCertificateResponse() {} + +void DecryptCertificateResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + const hmi_apis::Common_Result::eType code = + static_cast<hmi_apis::Common_Result::eType>( + (*message_)[strings::params][hmi_response::code].asInt()); + + const bool is_succeeded = hmi_apis::Common_Result::SUCCESS == code; + + application_manager_.GetPolicyHandler().OnCertificateDecrypted(is_succeeded); +} + +} // namespace commands +} // namespace application_manager +#endif // EXTERNAL_PROPRIETARY_MODE diff --git a/src/components/application_manager/src/commands/hmi/get_urls.cc b/src/components/application_manager/src/commands/hmi/get_urls.cc index af220051d4..e7c5244ddc 100644 --- a/src/components/application_manager/src/commands/hmi/get_urls.cc +++ b/src/components/application_manager/src/commands/hmi/get_urls.cc @@ -35,18 +35,6 @@ #include "application_manager/application_manager.h" #include "application_manager/policies/policy_handler.h" -namespace { -struct PolicyAppIdComparator { - PolicyAppIdComparator(const std::string& policy_app_id) - : policy_app_id_(policy_app_id) {} - - bool operator()(const policy::EndpointData& data) { - return data.app_id == policy_app_id_; - } - std::string policy_app_id_; -}; -} - namespace application_manager { namespace commands { @@ -58,41 +46,110 @@ GetUrls::~GetUrls() {} void GetUrls::Run() { LOG4CXX_AUTO_TRACE(logger_); - using namespace smart_objects; - using namespace application_manager; - using namespace strings; - using namespace hmi_apis; + namespace Common_Result = hmi_apis::Common_Result; + using policy::EndpointUrls; if (!application_manager_.GetPolicyHandler().PolicyEnabled()) { SendResponseToHMI(Common_Result::DATA_NOT_AVAILABLE); return; } - SmartObject& object = *message_; - const std::string service_to_check = - object[msg_params][hmi_request::service].asString(); + const uint32_t service_to_check = + (*message_)[strings::msg_params][hmi_request::service].asUInt(); + + EndpointUrls endpoints; + application_manager_.GetPolicyHandler().GetUpdateUrls(service_to_check, + endpoints); - policy::EndpointUrls endpoints; - application_manager_.GetPolicyHandler().GetServiceUrls( - object[strings::msg_params][hmi_request::service].asString(), endpoints); if (endpoints.empty()) { LOG4CXX_ERROR(logger_, "No URLs for service " << service_to_check); SendResponseToHMI(Common_Result::DATA_NOT_AVAILABLE); return; } -#ifdef EXTENDED_POLICY - const std::string policy_service = "7"; +#if defined(PROPRIETARY_MODE) || defined(EXTERNAL_PROPRIETARY_MODE) + const uint32_t policy_service = 7u; if (policy_service == service_to_check) { ProcessPolicyServiceURLs(endpoints); return; } -#endif +#endif // PROPRIETARY_MODE || EXTERNAL_PROPRIETARY_MODE + ProcessServiceURLs(endpoints); } -#ifdef EXTENDED_POLICY +void GetUrls::ProcessServiceURLs(const policy::EndpointUrls& endpoints) { + namespace Common_Result = hmi_apis::Common_Result; + using smart_objects::SmartObject; + + (*message_)[strings::msg_params].erase(hmi_request::service); + SmartObject& urls = (*message_)[strings::msg_params][hmi_response::urls]; + + size_t index = 0; + for (size_t e = 0; e < endpoints.size(); ++e) { + for (size_t u = 0; u < endpoints[e].url.size(); ++u, ++index) { + const std::string app_url = endpoints[e].url[u]; + + SmartObject& service_info = urls[index]; + + service_info[strings::url] = app_url; + if (policy::kDefaultId != endpoints[e].app_id) { +#ifndef EXTERNAL_PROPRIETARY_MODE + service_info[hmi_response::policy_app_id] = endpoints[e].app_id; +#else // EXTERNAL_PROPRIETARY_MODE + ApplicationSharedPtr app = + application_manager_.application_by_policy_id(endpoints[e].app_id); + + if (!app) { + LOG4CXX_ERROR(logger_, + "Can't find application with policy id " + << endpoints[e].app_id + << " URLs adding for this appliation is skipped."); + continue; + } + + service_info[strings::app_id] = app->hmi_app_id(); +#endif // EXTERNAL_PROPRIETARY_MODE + } + } + } + SendResponseToHMI(Common_Result::SUCCESS); +} + +void GetUrls::SendResponseToHMI(hmi_apis::Common_Result::eType result) { + (*message_)[strings::params][strings::message_type] = MessageType::kResponse; + (*message_)[strings::params][hmi_response::code] = result; + application_manager_.ManageHMICommand(message_); +} + +#if defined(PROPRIETARY_MODE) || defined(EXTERNAL_PROPRIETARY_MODE) +struct PolicyAppIdComparator { + PolicyAppIdComparator(const std::string& policy_app_id) + : policy_app_id_(policy_app_id) {} + + bool operator()(const policy::EndpointData& data) { + return data.app_id == policy_app_id_; + } + std::string policy_app_id_; +}; + +void FillSODefaultUrls(smart_objects::SmartObject& urls, + const policy::EndpointUrls& endpoints) { + using smart_objects::SmartObject; + PolicyAppIdComparator comparator(policy::kDefaultId); + policy::EndpointUrls::const_iterator it = + std::find_if(endpoints.begin(), endpoints.end(), comparator); + if (it == endpoints.end()) { + return; + } + SmartObject service_info = SmartObject(smart_objects::SmartType_Map); + for (size_t i = 0; i < (*it).url.size(); ++i) { + service_info[strings::url] = (*it).url[i]; + urls[i] = service_info; + } +} + void GetUrls::ProcessPolicyServiceURLs(const policy::EndpointUrls& endpoints) { LOG4CXX_AUTO_TRACE(logger_); using namespace smart_objects; @@ -162,58 +219,7 @@ void GetUrls::ProcessPolicyServiceURLs(const policy::EndpointUrls& endpoints) { SendResponseToHMI(Common_Result::SUCCESS); return; } -#endif - -void GetUrls::ProcessServiceURLs(const policy::EndpointUrls& endpoints) { - using namespace smart_objects; - using namespace strings; - using namespace hmi_apis; - - SmartObject& object = *message_; - object[msg_params].erase(hmi_request::service); - object[msg_params][hmi_response::urls] = SmartObject(SmartType_Array); - - SmartObject& urls = object[msg_params][hmi_response::urls]; - - size_t index = 0; - for (size_t e = 0; e < endpoints.size(); ++e) { - for (size_t u = 0; u < endpoints[e].url.size(); ++u, ++index) { - const std::string app_url = endpoints[e].url[u]; - - urls[index] = SmartObject(SmartType_Map); - SmartObject& service_info = urls[index]; - - service_info[url] = app_url; - if (policy::kDefaultId != endpoints[e].app_id) { - service_info[hmi_response::policy_app_id] = endpoints[e].app_id; - } - } - } - SendResponseToHMI(Common_Result::SUCCESS); -} - -void GetUrls::FillSODefaultUrls(smart_objects::SmartObject& urls, - const policy::EndpointUrls& endpoints) { - using namespace smart_objects; - LOG4CXX_AUTO_TRACE(logger_); - PolicyAppIdComparator comparator(policy::kDefaultId); - policy::EndpointUrls::const_iterator it = - std::find_if(endpoints.begin(), endpoints.end(), comparator); - if (it == endpoints.end()) { - return; - } - SmartObject service_info = SmartObject(SmartType_Map); - for (size_t i = 0; i < (*it).url.size(); ++i) { - service_info[strings::url] = (*it).url[i]; - urls[i] = service_info; - } -} - -void GetUrls::SendResponseToHMI(hmi_apis::Common_Result::eType result) { - (*message_)[strings::params][strings::message_type] = MessageType::kResponse; - (*message_)[strings::params][hmi_response::code] = result; - application_manager_.ManageHMICommand(message_); -} +#endif // PROPRIETARY_MODE || EXTERNAL_PROPRIETARY } // namespace commands } // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/on_received_policy_update.cc b/src/components/application_manager/src/commands/hmi/on_received_policy_update.cc index 03c0bc7378..8724a072ed 100644 --- a/src/components/application_manager/src/commands/hmi/on_received_policy_update.cc +++ b/src/components/application_manager/src/commands/hmi/on_received_policy_update.cc @@ -47,7 +47,7 @@ OnReceivedPolicyUpdate::~OnReceivedPolicyUpdate() {} void OnReceivedPolicyUpdate::Run() { LOG4CXX_AUTO_TRACE(logger_); -#ifdef EXTENDED_POLICY +#if defined(PROPRIETARY_MODE) || defined(EXTERNAL_PROPRIETARY_MODE) const std::string& file_path = (*message_)[strings::msg_params][hmi_notification::policyfile].asString(); policy::BinaryMessage file_content; diff --git a/src/components/application_manager/src/commands/hmi/on_system_request_notification.cc b/src/components/application_manager/src/commands/hmi/on_system_request_notification.cc index b74f1b6799..ea91dca5f1 100644 --- a/src/components/application_manager/src/commands/hmi/on_system_request_notification.cc +++ b/src/components/application_manager/src/commands/hmi/on_system_request_notification.cc @@ -89,6 +89,22 @@ void OnSystemRequestNotification::Run() { return; } + std::string device_mac; + application_manager_.connection_handler() + .get_session_observer() + .GetDataOnDeviceID(app->device(), NULL, NULL, &device_mac, NULL); + + if (policy::kDeviceAllowed != + application_manager_.GetPolicyHandler().GetUserConsentForDevice( + device_mac)) { + LOG4CXX_WARN(logger_, + "Application " + << app->policy_app_id() + << " is registered from non-consented device." + "Can't forward notification to application."); + return; + } + LOG4CXX_DEBUG(logger_, "Sending request with application id " << app->policy_app_id()); diff --git a/src/components/application_manager/src/commands/hmi/on_vi_vehicle_data_notification.cc b/src/components/application_manager/src/commands/hmi/on_vi_vehicle_data_notification.cc index 5f8109ccab..5383876714 100644 --- a/src/components/application_manager/src/commands/hmi/on_vi_vehicle_data_notification.cc +++ b/src/components/application_manager/src/commands/hmi/on_vi_vehicle_data_notification.cc @@ -50,6 +50,13 @@ void OnVIVehicleDataNotification::Run() { (*message_)[strings::params][strings::function_id] = static_cast<int32_t>(mobile_apis::FunctionID::eType::OnVehicleDataID); + const smart_objects::SmartObject& msg_params = + (*message_)[strings::msg_params]; + if (msg_params.keyExists(strings::odometer)) { + application_manager_.IviInfoUpdated(ODOMETER, + msg_params[strings::odometer].asInt()); + } + SendNotificationToMobile(message_); } diff --git a/src/components/application_manager/src/commands/hmi/request_from_hmi.cc b/src/components/application_manager/src/commands/hmi/request_from_hmi.cc index 3734f73e0d..1119e7c4fd 100644 --- a/src/components/application_manager/src/commands/hmi/request_from_hmi.cc +++ b/src/components/application_manager/src/commands/hmi/request_from_hmi.cc @@ -1,5 +1,5 @@ /* - Copyright (c) 2013, Ford Motor Company + Copyright (c) 2016, Ford Motor Company All rights reserved. Redistribution and use in source and binary forms, with or without @@ -89,7 +89,6 @@ void RequestFromHMI::SendErrorResponse( (*message)[strings::params][strings::message_type] = MessageType::kErrorResponse; (*message)[strings::params][hmi_response::code] = result_code; - (*message)[strings::params][strings::error_msg] = error_message; application_manager_.ManageHMICommand(message); diff --git a/src/components/application_manager/src/commands/hmi/sdl_activate_app_request.cc b/src/components/application_manager/src/commands/hmi/sdl_activate_app_request.cc index 4a501b5449..8a62ccd10a 100644 --- a/src/components/application_manager/src/commands/hmi/sdl_activate_app_request.cc +++ b/src/components/application_manager/src/commands/hmi/sdl_activate_app_request.cc @@ -84,6 +84,41 @@ SDLActivateAppRequest::SDLActivateAppRequest( SDLActivateAppRequest::~SDLActivateAppRequest() {} +uint32_t SDLActivateAppRequest::app_id() const { + using namespace strings; + if (!(*message_).keyExists(msg_params)) { + LOG4CXX_DEBUG(logger_, msg_params << " section is absent in the message."); + return 0; + } + if (!(*message_)[msg_params].keyExists(strings::app_id)) { + LOG4CXX_DEBUG(logger_, + strings::app_id << " section is absent in the message."); + return 0; + } + return (*message_)[msg_params][strings::app_id].asUInt(); +} + +#ifdef EXTERNAL_PROPRIETARY_MODE +void SDLActivateAppRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + using namespace hmi_apis::FunctionID; + + if (application_manager_.state_controller().IsStateActive( + HmiState::STATE_ID_DEACTIVATE_HMI)) { + LOG4CXX_DEBUG(logger_, + "DeactivateHmi state is active. " + "Sends response with result code REJECTED"); + SendErrorResponse(correlation_id(), + static_cast<eType>(function_id()), + hmi_apis::Common_Result::REJECTED); + } else { + const uint32_t application_id = app_id(); + application_manager_.GetPolicyHandler().OnActivateApp(application_id, + correlation_id()); + } +} + +#else // EXTERNAL_PROPRIETARY_MODE void SDLActivateAppRequest::Run() { LOG4CXX_AUTO_TRACE(logger_); using namespace hmi_apis::FunctionID; @@ -173,6 +208,7 @@ void SDLActivateAppRequest::Run() { subscribe_on_event(BasicCommunication_OnAppRegistered); } +#endif // EXTERNAL_PROPRIETARY_MODE void SDLActivateAppRequest::onTimeOut() { using namespace hmi_apis::FunctionID; using namespace hmi_apis::Common_Result; @@ -205,20 +241,6 @@ void SDLActivateAppRequest::on_event(const event_engine::Event& event) { correlation_id()); } -uint32_t SDLActivateAppRequest::app_id() const { - using namespace strings; - if (!(*message_).keyExists(msg_params)) { - LOG4CXX_DEBUG(logger_, msg_params << " section is absent in the message."); - return 0; - } - if (!(*message_)[msg_params].keyExists(strings::app_id)) { - LOG4CXX_DEBUG(logger_, - strings::app_id << " section is absent in the message."); - return 0; - } - return (*message_)[msg_params][strings::app_id].asUInt(); -} - uint32_t SDLActivateAppRequest::hmi_app_id( const smart_objects::SmartObject& so) const { using namespace strings; diff --git a/src/components/application_manager/src/commands/hmi/sdl_policy_update.cc b/src/components/application_manager/src/commands/hmi/sdl_policy_update.cc index e79bca14de..f1fb9ccead 100644 --- a/src/components/application_manager/src/commands/hmi/sdl_policy_update.cc +++ b/src/components/application_manager/src/commands/hmi/sdl_policy_update.cc @@ -44,7 +44,7 @@ SDLPolicyUpdate::~SDLPolicyUpdate() {} void SDLPolicyUpdate::Run() { LOG4CXX_AUTO_TRACE(logger_); -#ifdef EXTENDED_POLICY +#if defined(PROPRIETARY_MODE) || defined(EXTERNAL_PROPRIETARY_MODE) SendRequest(); #else LOG4CXX_WARN(logger_, |