diff options
author | agaliuzov <agaliuzov@luxoft.com> | 2016-05-16 00:12:12 -0700 |
---|---|---|
committer | agaliuzov <agaliuzov@luxoft.com> | 2016-05-16 01:45:41 -0700 |
commit | 59c5e55149cfe84367e3e3475eb1b090c3dd6402 (patch) | |
tree | cb0efd4c41bb3db0e4d93af2f3c5914ebc16a793 | |
parent | 793155c8d67254aa92fadb8a972476484c214b22 (diff) | |
parent | 2b17b5546d4d94665a37697d73f10adfb14b6dd3 (diff) | |
download | sdl_core-59c5e55149cfe84367e3e3475eb1b090c3dd6402.tar.gz |
Merge remote-tracking branch 'upstream/master' into develop
18 files changed, 316 insertions, 82 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 3e2aa24166..3d7dde3076 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,6 +48,7 @@ option(ENABLE_GCOV "gcov code coverage feature" OFF) option(ENABLE_SANITIZE "Sanitize tool" OFF) option(ENABLE_SECURITY "Security Ford protocol protection" ON) option(ENABLE_HMI_PTU_DECRYPTION "Policy table update parsed by hmi" ON) +option(ENABLE_EXTENDED_POLICY "Turns extended flow which requires embedded system interaction" OFF) set(OS_TYPE_OPTION "$ENV{OS_TYPE}") set(DEBUG_OPTION "$ENV{DEBUG}") @@ -229,6 +230,10 @@ if (TELEMETRY_MONITOR) add_definitions(-DTELEMETRY_MONITOR) endif() +if (ENABLE_EXTENDED_POLICY) + add_definitions(-DEXTENDED_POLICY) +endif() + # TODO(AK): check current OS here add_definitions(-DOS_POSIX) @@ -124,7 +124,7 @@ Below are instructions for testing app launching and query with a full system se ### SDL Server The app querying specification defines an endpoint within Policies where sdl_core will reach out to receive a list of applications that can be launched. The SDL Server provides the back end functionality for app launching and querying. -You can find the SDL Server on [GitHub](https://github.com/smartdevicelink/sdl_server). The README contains detailed instructions for installing and launching the server. Launch the server on your local machine, and direct your browser to http://localhost:3000. Note that you need `mongod` running on your machine before launching the server. +You can find the SDL Server on [GitHub](https://github.com/smartdevicelink/sdl_server). The README contains detailed instructions for installing and launching the server. Launch the server on your local machine, and direct your browser to http://localhost:3000. The [App Launching Server Specification](https://github.com/smartdevicelink/sdl_server/blob/master/docs/application_launching_v1.0.md) defines an endpoint `/applications/available/:moduleId.json` which return a list of applications available for launching to the handset for filtering. diff --git a/src/components/application_manager/include/application_manager/commands/hmi/get_urls.h b/src/components/application_manager/include/application_manager/commands/hmi/get_urls.h index 3346f6672b..6de11dfbb6 100644 --- a/src/components/application_manager/include/application_manager/commands/hmi/get_urls.h +++ b/src/components/application_manager/include/application_manager/commands/hmi/get_urls.h @@ -34,6 +34,7 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_GET_URLS_H_ #include "application_manager/commands/hmi/request_from_hmi.h" +#include "policy/policy_types.h" namespace application_manager { namespace commands { @@ -59,10 +60,30 @@ class GetUrls : public RequestFromHMI { /** * @brief Execute command **/ - virtual void Run(); + void Run() OVERRIDE; private: - DISALLOW_COPY_AND_ASSIGN(GetUrls); +#ifdef EXTENDED_POLICY + /** + * @brief Processes URLs collecting for policy service + * @param endpoints Endpoints section of policy table + */ + void ProcessPolicyServiceURLs(const policy::EndpointUrls& endpoints); +#endif + + /** + * @brief Process URLs collecting for service + * @param endpoints Endpoints section of policy table + */ + void ProcessServiceURLs(const policy::EndpointUrls& endpoints); + + /** + * @brief Sends response to HMI + * @param result Result code + */ + void SendResponseToHMI(hmi_apis::Common_Result::eType result); + + DISALLOW_COPY_AND_ASSIGN(GetUrls); }; } // namespace commands diff --git a/src/components/application_manager/include/application_manager/commands/hmi/on_received_policy_update.h b/src/components/application_manager/include/application_manager/commands/hmi/on_received_policy_update.h index 0569e818d1..4c2eacdae3 100644 --- a/src/components/application_manager/include/application_manager/commands/hmi/on_received_policy_update.h +++ b/src/components/application_manager/include/application_manager/commands/hmi/on_received_policy_update.h @@ -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 @@ -52,12 +52,12 @@ class OnReceivedPolicyUpdate : public NotificationFromHMI { /** * @brief OnReceivedPolicyUpdate class destructor **/ - virtual ~OnReceivedPolicyUpdate(); + ~OnReceivedPolicyUpdate() OVERRIDE; /** * @brief Execute command **/ - virtual void Run(); + void Run() OVERRIDE; private: DISALLOW_COPY_AND_ASSIGN(OnReceivedPolicyUpdate); diff --git a/src/components/application_manager/include/application_manager/commands/hmi/sdl_policy_update.h b/src/components/application_manager/include/application_manager/commands/hmi/sdl_policy_update.h index 11d0dc41d8..6cf4646163 100644 --- a/src/components/application_manager/include/application_manager/commands/hmi/sdl_policy_update.h +++ b/src/components/application_manager/include/application_manager/commands/hmi/sdl_policy_update.h @@ -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 @@ -48,11 +48,13 @@ class SDLPolicyUpdate : public RequestToHMI { **/ SDLPolicyUpdate(const MessageSharedPtr& message, ApplicationManager& application_manager); - virtual ~SDLPolicyUpdate(); + + ~SDLPolicyUpdate() OVERRIDE; + /** * @brief Execute command **/ - virtual void Run(); + void Run() OVERRIDE; private: DISALLOW_COPY_AND_ASSIGN(SDLPolicyUpdate); diff --git a/src/components/application_manager/include/application_manager/commands/mobile/on_system_request_notification.h b/src/components/application_manager/include/application_manager/commands/mobile/on_system_request_notification.h index 54b23f6ba3..8e7a03bbd6 100644 --- a/src/components/application_manager/include/application_manager/commands/mobile/on_system_request_notification.h +++ b/src/components/application_manager/include/application_manager/commands/mobile/on_system_request_notification.h @@ -1,6 +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 @@ -35,6 +34,7 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_ON_SYSTEM_REQUEST_NOTIFICATION_H_ #include "application_manager/commands/command_notification_impl.h" +#include <vector> namespace application_manager { @@ -47,6 +47,7 @@ namespace mobile { **/ class OnSystemRequestNotification : public CommandNotificationImpl { public: + typedef std::vector<uint8_t> BinaryMessage; /** * @brief OnSystemRequestNotification class constructor * @@ -58,14 +59,22 @@ class OnSystemRequestNotification : public CommandNotificationImpl { /** * @brief OnSystemRequestNotification class destructor **/ - virtual ~OnSystemRequestNotification(); + ~OnSystemRequestNotification() OVERRIDE; /** * @brief Execute command **/ - virtual void Run(); + void Run() OVERRIDE; private: +#ifdef EXTENDED_POLICY + /** + * @brief Adds HTTP header to message + * @param message Message + */ + void AddHeader(BinaryMessage& message) const; +#endif + DISALLOW_COPY_AND_ASSIGN(OnSystemRequestNotification); }; 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 1b11cdb040..9efa7f9d92 100644 --- a/src/components/application_manager/src/commands/hmi/get_urls.cc +++ b/src/components/application_manager/src/commands/hmi/get_urls.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 @@ -46,48 +46,140 @@ GetUrls::~GetUrls() {} void GetUrls::Run() { LOG4CXX_AUTO_TRACE(logger_); - smart_objects::SmartObject& object = *message_; - object[strings::params][strings::message_type] = MessageType::kResponse; - if (application_manager_.GetPolicyHandler().PolicyEnabled()) { - policy::EndpointUrls endpoints; - application_manager_.GetPolicyHandler().GetServiceUrls( - object[strings::msg_params][hmi_request::service].asString(), - endpoints); - if (!endpoints.empty()) { - object[strings::msg_params].erase(hmi_request::service); - - object[strings::msg_params][hmi_response::urls] = - smart_objects::SmartObject(smart_objects::SmartType_Array); - - smart_objects::SmartObject& urls = - object[strings::msg_params][hmi_response::urls]; - - size_t index = 0; - - for (size_t i = 0; i < endpoints.size(); ++i) { - for (size_t k = 0; k < endpoints[i].url.size(); ++k, ++index) { - const std::string url = endpoints[i].url[k]; - - urls[index] = - smart_objects::SmartObject(smart_objects::SmartType_Map); - smart_objects::SmartObject& service_info = urls[index]; - - service_info[strings::url] = url; - if (policy::kDefaultId != endpoints[i].app_id) { - service_info[hmi_response::policy_app_id] = endpoints[i].app_id; - } - } + using namespace smart_objects; + using namespace application_manager; + using namespace strings; + using namespace hmi_apis; + + 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(); + + 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 (policy_service == service_to_check) { + ProcessPolicyServiceURLs(endpoints); + return; + } +#endif + ProcessServiceURLs(endpoints); +} + +#ifdef EXTENDED_POLICY +void GetUrls::ProcessPolicyServiceURLs(const policy::EndpointUrls& endpoints) { + LOG4CXX_AUTO_TRACE(logger_); + using namespace smart_objects; + using namespace application_manager; + using namespace strings; + using namespace hmi_apis; + + const uint32_t app_id_to_send_to = + application_manager_.GetPolicyHandler().GetAppIdForSending(); + + if (!app_id_to_send_to) { + LOG4CXX_ERROR(logger_, + "There are no available applications for processing."); + application_manager_.ManageHMICommand(message_); + return; + } + + ApplicationSharedPtr app = + application_manager_.application(app_id_to_send_to); + + if (!app.valid()) { + LOG4CXX_WARN(logger_, + "There is no registered application with " + "connection key '" << app_id_to_send_to << "'"); + SendResponseToHMI(Common_Result::DATA_NOT_AVAILABLE); + return; + } + + 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]; + + const std::string mobile_app_id = app->mobile_app_id(); + std::string default_url = "URL is not found"; + + // Will use only one URL for particular application if it will be found + // Otherwise URL from default section will used + SmartObject service_info = SmartObject(SmartType_Map); + + for (size_t e = 0; e < endpoints.size(); ++e) { + + if (mobile_app_id == endpoints[e].app_id) { + if (endpoints[e].url.size()) { + service_info[url] = endpoints[e].url[0]; + SendResponseToHMI(Common_Result::SUCCESS); + return; + } + } + if (policy::kDefaultId == endpoints[e].app_id) { + if (endpoints[e].url.size()) { + default_url = endpoints[e].url[0]; } - object[strings::params][hmi_response::code] = - hmi_apis::Common_Result::SUCCESS; - } else { - object[strings::params][hmi_response::code] = - hmi_apis::Common_Result::DATA_NOT_AVAILABLE; } - } else { - object[strings::params][hmi_response::code] = - hmi_apis::Common_Result::DATA_NOT_AVAILABLE; } + + service_info[strings::app_id] = app->app_id(); + service_info[strings::url] = default_url; + urls[0] = service_info; + // TODO(AOleynik): Issue with absent policy_app_id. Need to fix later on. + // Possibly related to smart schema + 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::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_); } 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 ee7da70ede..03c0bc7378 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 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Ford Motor Company + * Copyright (c) 2016, Ford Motor Company * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -47,6 +47,7 @@ OnReceivedPolicyUpdate::~OnReceivedPolicyUpdate() {} void OnReceivedPolicyUpdate::Run() { LOG4CXX_AUTO_TRACE(logger_); +#ifdef EXTENDED_POLICY const std::string& file_path = (*message_)[strings::msg_params][hmi_notification::policyfile].asString(); policy::BinaryMessage file_content; @@ -56,6 +57,11 @@ void OnReceivedPolicyUpdate::Run() { } application_manager_.GetPolicyHandler().ReceiveMessageFromSDK(file_path, file_content); +#else + LOG4CXX_WARN(logger_, + "This RPC is part of extended policy flow." + "Please re-build with extended policy mode enabled."); +#endif } } // namespace commands 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 ce83d28db4..531692b136 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 @@ -58,30 +58,35 @@ void OnSystemRequestNotification::Run() { params[strings::function_id] = static_cast<int32_t>(mobile_apis::FunctionID::eType::OnSystemRequestID); - const std::string app_id = msg_params[strings::app_id].asString(); - LOG4CXX_DEBUG(logger_, "Received OnSystemRequest for " << app_id); - ApplicationSharedPtr app; - if (strings::default_app_id == app_id) { + if (!msg_params.keyExists(strings::app_id)) { + LOG4CXX_DEBUG(logger_, + "No application specified, trying to choose automatically."); const policy::PolicyHandlerInterface& policy_handler = - application_manager_.GetPolicyHandler(); - const uint32_t selected_app_id = policy_handler.GetAppIdForSending(); + application_manager_.GetPolicyHandler(); + uint32_t selected_app_id = policy_handler.GetAppIdForSending(); if (0 == selected_app_id) { - LOG4CXX_WARN( - logger_, - "Can't select application to forward OnSystemRequestNotification"); + LOG4CXX_WARN(logger_, + "Can't select application to forward OnSystemRequest."); return; } app = application_manager_.application(selected_app_id); + } else { + const uint32_t app_id = msg_params[strings::app_id].asUInt(); + LOG4CXX_WARN(logger_, "Looking for application with connection key " + << app_id); + app = application_manager_.application(app_id); } if (!app.valid()) { LOG4CXX_WARN(logger_, - "Application with connection key " << app_id - << "is not registered."); + "No valid application found to forward OnSystemRequest."); return; } + LOG4CXX_DEBUG(logger_, + "Sending request with application id " << app->policy_app_id()); + params[strings::connection_key] = app->app_id(); SendNotificationToMobile(message_); } 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 88b7c3faae..e79bca14de 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 @@ -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 @@ -44,7 +44,13 @@ SDLPolicyUpdate::~SDLPolicyUpdate() {} void SDLPolicyUpdate::Run() { LOG4CXX_AUTO_TRACE(logger_); +#ifdef EXTENDED_POLICY SendRequest(); +#else + LOG4CXX_WARN(logger_, + "This RPC is part of extended policy flow." + "Please re-build with extended policy mode enabled."); +#endif } } // namespace commands diff --git a/src/components/application_manager/src/commands/mobile/on_system_request_notification.cc b/src/components/application_manager/src/commands/mobile/on_system_request_notification.cc index 4f73ad0ffe..510de55761 100644 --- a/src/components/application_manager/src/commands/mobile/on_system_request_notification.cc +++ b/src/components/application_manager/src/commands/mobile/on_system_request_notification.cc @@ -1,6 +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 @@ -31,6 +30,9 @@ POSSIBILITY OF SUCH DAMAGE. */ +#include <cstring> +#include <cstdio> +#include <string> #include "application_manager/commands/mobile/on_system_request_notification.h" #include "interfaces/MOBILE_API.h" #include "utils/file_system.h" @@ -76,11 +78,21 @@ void OnSystemRequestNotification::Run() { } if (RequestType::PROPRIETARY == request_type) { - /* According to requirements: - "If the requestType = PROPRIETARY, add to mobile API fileType = JSON - If the requestType = HTTP, add to mobile API fileType = BINARY" - Also in Genivi SDL we don't save the PT to file - we put it directly in - binary_data */ +/* According to requirements: + "If the requestType = PROPRIETARY, add to mobile API fileType = JSON + If the requestType = HTTP, add to mobile API fileType = BINARY" + Also in Genivi SDL we don't save the PT to file - we put it directly in + binary_data */ + +#ifdef EXTENDED_POLICY + const std::string filename = + (*message_)[strings::msg_params][strings::file_name].asString(); + + BinaryMessage binary_data; + file_system::ReadBinaryFile(filename, binary_data); + AddHeader(binary_data); + (*message_)[strings::params][strings::binary_data] = binary_data; +#endif (*message_)[strings::msg_params][strings::file_type] = FileType::JSON; } else if (RequestType::HTTP == request_type) { (*message_)[strings::msg_params][strings::file_type] = FileType::BINARY; @@ -89,7 +101,51 @@ void OnSystemRequestNotification::Run() { SendNotification(); } -} // namespace mobile +#ifdef EXTENDED_POLICY +void OnSystemRequestNotification::AddHeader(BinaryMessage& message) const { + LOG4CXX_AUTO_TRACE(logger_); + const int timeout = policy::PolicyHandler::instance()->TimeoutExchange(); + + char size_str[24]; + + if (0 > sprintf(size_str, "%zu", static_cast<size_t>(message.size()))) { + memset(size_str, 0, sizeof(size_str)); + } + + char timeout_str[24]; + if (0 > sprintf(timeout_str, "%d", timeout)) { + memset(timeout_str, 0, sizeof(timeout_str)); + } + + const std::string header = + + "{" + " \"HTTPRequest\": {" + "\"headers\": {" + "\"ContentType\": \"application/json\"," + "\"ConnectTimeout\": " + std::string(timeout_str) + "," + "\"DoOutput\": true," + "\"DoInput\": true," + "\"UseCaches\": false," + "\"RequestMethod\": \"POST\"," + "\"ReadTimeout\":" + std::string(timeout_str) + "," + "\"InstanceFollowRedirects\": false," + "\"charset\": \"utf-8\"," + "\"Content_Length\": " + std::string(size_str) + + "}," + "\"body\": \"" + std::string(message.begin(), message.end()) + "\"" + "}" + "}"; + + message.clear(); + message.assign(header.begin(), header.end()); + + LOG4CXX_DEBUG( + logger_, "Header added: " << std::string(message.begin(), message.end())); +} +#endif + +} //namespace mobile } // namespace commands diff --git a/src/components/application_manager/src/commands/mobile/system_request.cc b/src/components/application_manager/src/commands/mobile/system_request.cc index 93eab1ee1e..5b0380c3e2 100644 --- a/src/components/application_manager/src/commands/mobile/system_request.cc +++ b/src/components/application_manager/src/commands/mobile/system_request.cc @@ -51,8 +51,10 @@ namespace application_manager { CREATE_LOGGERPTR_LOCAL(logger_, "ApplicationManager") namespace { +#ifdef ENABLE_LOG const char* kQueryAppsValidationFailedPrefix = ":QUERY_APPS_VALIDATION_FAILED: "; +#endif const unsigned int kVrSynonymLengthMax = 40U; const unsigned int kVrSynonymLengthMin = 1U; diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index c00c51dcfe..5016591605 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -1112,6 +1112,19 @@ bool PolicyHandler::SaveSnapshot(const BinaryMessage& pt_string, } void PolicyHandler::OnSnapshotCreated(const BinaryMessage& pt_string) { + LOG4CXX_AUTO_TRACE(logger_); + POLICY_LIB_CHECK_VOID(); +#ifdef EXTENDED_POLICY + std::string policy_snapshot_full_path; + if (!SaveSnapshot(pt_string, policy_snapshot_full_path)) { + LOG4CXX_ERROR(logger_, "Snapshot processing skipped."); + return; + } + MessageHelper::SendPolicyUpdate( + policy_snapshot_full_path, + policy_manager_->TimeoutExchange(), + policy_manager_->RetrySequenceDelaysSeconds()); +#else EndpointUrls urls; policy_manager_->GetServiceUrls("0x07", urls); @@ -1120,6 +1133,7 @@ void PolicyHandler::OnSnapshotCreated(const BinaryMessage& pt_string) { return; } SendMessageToSDK(pt_string, urls.front().url.front()); +#endif } bool PolicyHandler::GetPriority(const std::string& policy_app_id, diff --git a/src/components/interfaces/HMI_API.xml b/src/components/interfaces/HMI_API.xml index 08763f82a2..fa8be7ec3c 100644 --- a/src/components/interfaces/HMI_API.xml +++ b/src/components/interfaces/HMI_API.xml @@ -1249,8 +1249,8 @@ <param name="url" type="String" mandatory="true"> <description>Get URL based on service type.</description> </param> - <param name="policyAppId" type="String" mandatory="false"> - <description>Used if URL needed are specific for application.</description> + <param name="appID" type="Integer" mandatory="false"> + <description>ID of application that requested this RPC.</description> </param> </struct> <!-- End of Policies --> @@ -2339,7 +2339,7 @@ <param name="fileName" type="String" maxlength="255" minlength="1" mandatory="true"> <description>File reference name.</description> </param> - <param name="appID" type="String" maxlength="50" minlength="1" mandatory="false"> + <param name="appID" type="Integer" mandatory="false"> <description>ID of application that requested this RPC.</description> </param> </function> @@ -2351,7 +2351,7 @@ <param name="fileName" type="String" maxlength="255" minlength="1" mandatory="true"> <description>The path to file.</description> </param> - <param name="appID" type="String" maxlength="50" minlength="1" mandatory="false"> + <param name="appID" type="Integer" mandatory="false"> <description>ID of application that requested this RPC.</description> </param> </function> diff --git a/src/components/policy/src/policy/include/policy/policy_listener.h b/src/components/policy/src/policy/include/policy/policy_listener.h index 197dfd5c8a..9592e6a712 100644 --- a/src/components/policy/src/policy/include/policy/policy_listener.h +++ b/src/components/policy/src/policy/include/policy/policy_listener.h @@ -74,7 +74,6 @@ class PolicyListener { * when snapshot for PTU has been created. * * @param pt_string the snapshot - * */ virtual void OnSnapshotCreated(const BinaryMessage& pt_string) = 0; diff --git a/src/components/policy/src/policy/policy_table/table_struct/validation.cc b/src/components/policy/src/policy/policy_table/table_struct/validation.cc index 061f7f3ff1..9abab48ce5 100644 --- a/src/components/policy/src/policy/policy_table/table_struct/validation.cc +++ b/src/components/policy/src/policy/policy_table/table_struct/validation.cc @@ -153,6 +153,10 @@ bool MessageLanguages::Validate() const { bool ConsumerFriendlyMessages::Validate() const { /* According to requirements consumer_friendly_messages are optional for PTU and required for PTP and PTS. So, they are allowed always */ + if (PT_SNAPSHOT == GetPolicyTableType() && + messages.is_initialized()) { + return false; + } return true; } diff --git a/src/components/policy/src/policy/src/cache_manager.cc b/src/components/policy/src/policy/src/cache_manager.cc index 2147fdb949..cc06bab467 100644 --- a/src/components/policy/src/policy/src/cache_manager.cc +++ b/src/components/policy/src/policy/src/cache_manager.cc @@ -902,8 +902,22 @@ bool policy::CacheManager::IsNumberService(const std::string& input, utils::SharedPtr<policy_table::Table> CacheManager::GenerateSnapshot() { CACHE_MANAGER_CHECK(snapshot_); sync_primitives::AutoLock lock(cache_lock_); + snapshot_ = new policy_table::Table(); - snapshot_->policy_table = pt_->policy_table; + + //Copy all members of policy table except messages in consumer friendly messages + snapshot_->policy_table.app_policies_section = pt_->policy_table.app_policies_section; + snapshot_->policy_table.functional_groupings = pt_->policy_table.functional_groupings; + snapshot_->policy_table.consumer_friendly_messages->version = pt_->policy_table.consumer_friendly_messages->version; + snapshot_->policy_table.consumer_friendly_messages->mark_initialized(); + snapshot_->policy_table.module_config = pt_->policy_table.module_config; + snapshot_->policy_table.module_meta = pt_->policy_table.module_meta; + snapshot_->policy_table.usage_and_error_counts = pt_->policy_table.usage_and_error_counts; + snapshot_->policy_table.device_data = pt_->policy_table.device_data; + + //Set policy table type to Snapshot + snapshot_->SetPolicyTableType(rpc::policy_table_interface_base::PolicyTableType::PT_SNAPSHOT); + CheckSnapshotInitialization(); return snapshot_; } diff --git a/src/components/policy/src/policy/src/policy_manager_impl.cc b/src/components/policy/src/policy/src/policy_manager_impl.cc index ac270d5862..4c5a6d6f84 100644 --- a/src/components/policy/src/policy/src/policy_manager_impl.cc +++ b/src/components/policy/src/policy/src/policy_manager_impl.cc @@ -106,7 +106,6 @@ utils::SharedPtr<policy_table::Table> PolicyManagerImpl::ParseArray( // For PT Update received from SDL Server. if (value["data"].size() != 0) { Json::Value data = value["data"]; - // First Element in return new policy_table::Table(&data[0]); } else { return new policy_table::Table(&value); @@ -147,7 +146,7 @@ bool PolicyManagerImpl::LoadPT(const std::string& file, // of 'data' array. No Parsing was done by HMI. utils::SharedPtr<policy_table::Table> pt_update = ParseArray(pt_content); #endif - if (!pt_update) { + if (!pt_update) { LOG4CXX_WARN(logger_, "Parsed table pointer is 0."); update_status_manager_.OnWrongUpdateReceived(); return false; |