diff options
Diffstat (limited to 'src/components')
127 files changed, 2954 insertions, 248 deletions
diff --git a/src/components/application_manager/include/application_manager/application.h b/src/components/application_manager/include/application_manager/application.h index 668c0a1720..cd3b31ce75 100644 --- a/src/components/application_manager/include/application_manager/application.h +++ b/src/components/application_manager/include/application_manager/application.h @@ -189,6 +189,9 @@ class DynamicApplicationData { virtual const smart_objects::SmartObject* keyboard_props() const = 0; virtual const smart_objects::SmartObject* menu_title() const = 0; virtual const smart_objects::SmartObject* menu_icon() const = 0; + virtual const smart_objects::SmartObject* day_color_scheme() const = 0; + virtual const smart_objects::SmartObject* night_color_scheme() const = 0; + virtual const std::string& display_layout() const = 0; virtual void load_global_properties(const smart_objects::SmartObject& so) = 0; virtual void set_help_prompt( @@ -220,6 +223,12 @@ class DynamicApplicationData { virtual void set_video_stream_retry_number( const uint32_t& video_stream_retry_number) = 0; + virtual void set_day_color_scheme( + const smart_objects::SmartObject& color_scheme) = 0; + virtual void set_night_color_scheme( + const smart_objects::SmartObject& color_scheme) = 0; + + virtual void set_display_layout(const std::string& layout) = 0; /** * @brief Checks if application is media, voice communication or navigation * @return true if application is media, voice communication or navigation, diff --git a/src/components/application_manager/include/application_manager/application_data_impl.h b/src/components/application_manager/include/application_manager/application_data_impl.h index 64b5f8780b..dc9be4e1d8 100644 --- a/src/components/application_manager/include/application_manager/application_data_impl.h +++ b/src/components/application_manager/include/application_manager/application_data_impl.h @@ -55,6 +55,7 @@ class InitialApplicationDataImpl : public virtual Application { const smart_objects::SmartObject* ngn_media_screen_name() const; const mobile_api::Language::eType& language() const; const mobile_api::Language::eType& ui_language() const; + void set_app_types(const smart_objects::SmartObject& app_types); void set_vr_synonyms(const smart_objects::SmartObject& vr_synonyms); void set_mobile_app_id(const std::string& policy_app_id); @@ -95,6 +96,9 @@ class DynamicApplicationDataImpl : public virtual Application { const smart_objects::SmartObject* keyboard_props() const; const smart_objects::SmartObject* menu_title() const; const smart_objects::SmartObject* menu_icon() const; + const smart_objects::SmartObject* day_color_scheme() const; + const smart_objects::SmartObject* night_color_scheme() const; + const std::string& display_layout() const; void load_global_properties(const smart_objects::SmartObject& properties_so); void set_help_prompt(const smart_objects::SmartObject& help_prompt); @@ -109,6 +113,9 @@ class DynamicApplicationDataImpl : public virtual Application { void set_keyboard_props(const smart_objects::SmartObject& keyboard_props); void set_menu_title(const smart_objects::SmartObject& menu_title); void set_menu_icon(const smart_objects::SmartObject& menu_icon); + void set_day_color_scheme(const smart_objects::SmartObject& color_scheme); + void set_night_color_scheme(const smart_objects::SmartObject& color_scheme); + void set_display_layout(const std::string& layout); /* * @brief Adds a command to the in application menu */ @@ -263,6 +270,9 @@ class DynamicApplicationDataImpl : public virtual Application { smart_objects::SmartObject* menu_title_; smart_objects::SmartObject* menu_icon_; smart_objects::SmartObject* tbt_show_command_; + smart_objects::SmartObject* day_color_scheme_; + smart_objects::SmartObject* night_color_scheme_; + std::string display_layout_; CommandsMap commands_; mutable sync_primitives::Lock commands_lock_; diff --git a/src/components/application_manager/include/application_manager/application_manager_impl.h b/src/components/application_manager/include/application_manager/application_manager_impl.h index 376027e9fb..30816e0ffa 100644 --- a/src/components/application_manager/include/application_manager/application_manager_impl.h +++ b/src/components/application_manager/include/application_manager/application_manager_impl.h @@ -1214,6 +1214,9 @@ class ApplicationManagerImpl app_launch::AppLaunchCtrl& app_launch_ctrl() OVERRIDE; + bool IsSOStructValid(const hmi_apis::StructIdentifiers::eType struct_id, + const smart_objects::SmartObject& display_capabilities); + private: /** * @brief PullLanguagesInfo allows to pull information about languages. diff --git a/src/components/application_manager/include/application_manager/policies/policy_handler.h b/src/components/application_manager/include/application_manager/policies/policy_handler.h index b4653c6cb2..73a05b370e 100644 --- a/src/components/application_manager/include/application_manager/policies/policy_handler.h +++ b/src/components/application_manager/include/application_manager/policies/policy_handler.h @@ -487,6 +487,32 @@ class PolicyHandler : public PolicyHandlerInterface, mobile_apis::RequestType::eType type) const OVERRIDE; /** + * @brief Checks if certain request subtype is allowed for application + * @param policy_app_id Unique applicaion id + * @param request_subtype Request subtype + * @return true, if allowed, otherwise - false + */ + bool IsRequestSubTypeAllowed( + const std::string& policy_app_id, + const std::string& request_subtype) const OVERRIDE; + + /** + * @brief Gets application request types state + * @param policy_app_id Unique application id + * @return request types state + */ + RequestType::State GetAppRequestTypeState( + const std::string& policy_app_id) const OVERRIDE; + + /** + * @brief Gets application request subtypes state + * @param policy_app_id Unique application id + * @return request subtypes state + */ + RequestSubType::State GetAppRequestSubTypeState( + const std::string& policy_app_id) const OVERRIDE; + + /** * @brief Gets application request types * @param policy_app_id Unique application id * @return request types @@ -495,6 +521,14 @@ class PolicyHandler : public PolicyHandlerInterface, const std::string& policy_app_id) const OVERRIDE; /** + * @brief Gets application request subtypes + * @param policy_app_id Unique application id + * @return app request subtypes + */ + const std::vector<std::string> GetAppRequestSubTypes( + const std::string& policy_app_id) const OVERRIDE; + + /** * @brief Gets vehicle information * @return Structure with vehicle information */ diff --git a/src/components/application_manager/include/application_manager/smart_object_keys.h b/src/components/application_manager/include/application_manager/smart_object_keys.h index 3a54d66906..ce5b68ee3c 100644 --- a/src/components/application_manager/include/application_manager/smart_object_keys.h +++ b/src/components/application_manager/include/application_manager/smart_object_keys.h @@ -179,17 +179,30 @@ extern const char* navigation_capability; extern const char* phone_capability; extern const char* video_streaming_capability; extern const char* rc_capability; +extern const char* day_color_scheme; +extern const char* night_color_scheme; +extern const char* primary_color; +extern const char* secondary_color; +extern const char* background_color; +extern const char* red; +extern const char* green; +extern const char* blue; +extern const char* display_layout; +extern const char* icon_resumed; // PutFile extern const char* sync_file_name; extern const char* file_name; extern const char* file_type; extern const char* file_size; +extern const char* crc32_check_sum; extern const char* request_type; +extern const char* request_subtype; extern const char* persistent_file; extern const char* file_data; extern const char* space_available; extern const char* image_type; +extern const char* is_template; extern const char* image; extern const char* type; extern const char* system_file; @@ -239,6 +252,7 @@ extern const char* rpm; extern const char* fuel_level; extern const char* fuel_level_state; extern const char* instant_fuel_consumption; +extern const char* fuel_range; extern const char* external_temp; extern const char* vin; extern const char* prndl; @@ -275,6 +289,7 @@ extern const char* remote_control; extern const char* sdl_version; extern const char* system_software_version; extern const char* priority; +extern const char* engine_oil_life; // resuming extern const char* application_commands; @@ -469,6 +484,7 @@ extern const char* dtc; extern const char* ecu_header; extern const char* image_capabilities; extern const char* display_type; +extern const char* display_name; extern const char* text_fields; extern const char* media_clock_formats; extern const char* graphic_supported; diff --git a/src/components/application_manager/src/application_data_impl.cc b/src/components/application_manager/src/application_data_impl.cc index a81540708c..226c83dbf6 100644 --- a/src/components/application_manager/src/application_data_impl.cc +++ b/src/components/application_manager/src/application_data_impl.cc @@ -173,6 +173,9 @@ DynamicApplicationDataImpl::DynamicApplicationDataImpl() , menu_title_(NULL) , menu_icon_(NULL) , tbt_show_command_(NULL) + , day_color_scheme_(NULL) + , night_color_scheme_(NULL) + , display_layout_("") , commands_() , commands_lock_(true) , sub_menu_() @@ -214,6 +217,16 @@ DynamicApplicationDataImpl::~DynamicApplicationDataImpl() { tbt_show_command_ = NULL; } + if (day_color_scheme_) { + delete day_color_scheme_; + day_color_scheme_ = NULL; + } + + if (night_color_scheme_) { + delete night_color_scheme_; + night_color_scheme_ = NULL; + } + for (CommandsMap::iterator command_it = commands_.begin(); commands_.end() != command_it; ++command_it) { @@ -290,6 +303,20 @@ const smart_objects::SmartObject* DynamicApplicationDataImpl::menu_icon() return menu_icon_; } +const smart_objects::SmartObject* DynamicApplicationDataImpl::day_color_scheme() + const { + return day_color_scheme_; +} + +const smart_objects::SmartObject* +DynamicApplicationDataImpl::night_color_scheme() const { + return night_color_scheme_; +} + +const std::string& DynamicApplicationDataImpl::display_layout() const { + return display_layout_; +} + void DynamicApplicationDataImpl::load_global_properties( const smart_objects::SmartObject& properties_so) { SetGlobalProperties(properties_so.getElement(strings::vr_help_title), @@ -405,6 +432,28 @@ void DynamicApplicationDataImpl::set_menu_icon( menu_icon_ = new smart_objects::SmartObject(menu_icon); } +void DynamicApplicationDataImpl::set_day_color_scheme( + const smart_objects::SmartObject& color_scheme) { + if (day_color_scheme_) { + delete day_color_scheme_; + } + + day_color_scheme_ = new smart_objects::SmartObject(color_scheme); +} + +void DynamicApplicationDataImpl::set_night_color_scheme( + const smart_objects::SmartObject& color_scheme) { + if (night_color_scheme_) { + delete night_color_scheme_; + } + + night_color_scheme_ = new smart_objects::SmartObject(color_scheme); +} + +void DynamicApplicationDataImpl::set_display_layout(const std::string& layout) { + display_layout_ = layout; +} + void DynamicApplicationDataImpl::SetGlobalProperties( const smart_objects::SmartObject& param, void (DynamicApplicationData::*callback)( diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 408dcbf1da..5edd485343 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -624,6 +624,13 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication( const std::string& bundle_id = app_info[strings::bundle_id].asString(); application->set_bundle_id(bundle_id); } + + const std::string app_icon_dir(settings_.app_icons_folder()); + const std::string full_icon_path(app_icon_dir + "/" + policy_app_id); + if (file_system::FileExists(full_icon_path)) { + application->set_app_icon_path(full_icon_path); + } + PutDriverDistractionMessageToPostponed(application); // Stops timer of saving data to resumption in order to @@ -4462,6 +4469,23 @@ std::vector<std::string> ApplicationManagerImpl::ConvertRejectedParamList( return output; } +bool ApplicationManagerImpl::IsSOStructValid( + const hmi_apis::StructIdentifiers::eType struct_id, + const smart_objects::SmartObject& display_capabilities) { + smart_objects::SmartObject display_capabilities_so = display_capabilities; + if (hmi_so_factory().AttachSchema(struct_id, display_capabilities_so)) { + if (display_capabilities_so.isValid()) { + return true; + } else { + return false; + } + } else { + LOG4CXX_ERROR(logger_, "Could not find struct id: " << struct_id); + return false; + } + return true; +} + #ifdef BUILD_TESTS void ApplicationManagerImpl::AddMockApplication(ApplicationSharedPtr mock_app) { applications_list_lock_.Acquire(); diff --git a/src/components/application_manager/src/commands/command_request_impl.cc b/src/components/application_manager/src/commands/command_request_impl.cc index 515d8a998c..527d640c5c 100644 --- a/src/components/application_manager/src/commands/command_request_impl.cc +++ b/src/components/application_manager/src/commands/command_request_impl.cc @@ -39,6 +39,7 @@ #include "application_manager/application_manager.h" #include "application_manager/message_helper.h" #include "smart_objects/smart_object.h" + namespace application_manager { namespace commands { @@ -605,10 +606,8 @@ bool CommandRequestImpl::CheckAllowedParameters() { smart_objects::SmartMap::const_iterator iter_end = s_map.map_end(); for (; iter != iter_end; ++iter) { - if (iter->second.asBool()) { - LOG4CXX_DEBUG(logger_, "Request's param: " << iter->first); - params.insert(iter->first); - } + LOG4CXX_DEBUG(logger_, "Request's param: " << iter->first); + params.insert(iter->first); } mobile_apis::Result::eType check_result = 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 c29ff3e2d3..f06012893e 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 @@ -36,6 +36,7 @@ #include "application_manager/commands/mobile/on_system_request_notification.h" #include "interfaces/MOBILE_API.h" #include "utils/file_system.h" +#include "policy/policy_table/enums.h" #include "application_manager/application_manager.h" #include "application_manager/policies/policy_handler_interface.h" @@ -65,19 +66,40 @@ void OnSystemRequestNotification::Run() { return; } - RequestType::eType request_type = static_cast<RequestType::eType>( - (*message_)[strings::msg_params][strings::request_type].asInt()); + const mobile_apis::RequestType::eType request_type = + static_cast<mobile_apis::RequestType::eType>( + (*message_)[strings::msg_params][strings::request_type].asInt()); const policy::PolicyHandlerInterface& policy_handler = application_manager_.GetPolicyHandler(); + + const std::string stringified_request_type = + rpc::policy_table_interface_base::EnumToJsonString( + static_cast<rpc::policy_table_interface_base::RequestType>( + request_type)); + if (!policy_handler.IsRequestTypeAllowed(app->policy_app_id(), request_type)) { LOG4CXX_WARN(logger_, - "Request type " << request_type + "Request type " << stringified_request_type << " is not allowed by policies"); return; } - if (RequestType::PROPRIETARY == request_type) { + const bool request_subtype_present = + (*message_)[strings::msg_params].keyExists(strings::request_subtype); + if (request_subtype_present) { + const std::string request_subtype = + (*message_)[strings::msg_params][strings::request_subtype].asString(); + if (!policy_handler.IsRequestSubTypeAllowed(app->policy_app_id(), + request_subtype)) { + LOG4CXX_ERROR(logger_, + "Request subtype: " << request_subtype + << " is DISALLOWED by policies"); + return; + } + } + + if (mobile_apis::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" @@ -97,7 +119,7 @@ void OnSystemRequestNotification::Run() { #endif // PROPRIETARY_MODE (*message_)[strings::msg_params][strings::file_type] = FileType::JSON; - } else if (RequestType::HTTP == request_type) { + } else if (mobile_apis::RequestType::HTTP == request_type) { (*message_)[strings::msg_params][strings::file_type] = FileType::BINARY; if ((*message_)[strings::msg_params].keyExists(strings::url)) { (*message_)[strings::msg_params][strings::timeout] = @@ -183,8 +205,8 @@ size_t OnSystemRequestNotification::ParsePTString( if (pt_string[i] == '\"' || pt_string[i] == '\\') { result += '\\'; } else if (pt_string[i] == '\n') { - result_length--; // contentLength is adjusted when this character is not - // copied to result. + result_length--; // contentLength is adjusted when this character is + // not copied to result. continue; } result += pt_string[i]; diff --git a/src/components/application_manager/src/commands/mobile/put_file_request.cc b/src/components/application_manager/src/commands/mobile/put_file_request.cc index 602b420ba0..269c9c814e 100644 --- a/src/components/application_manager/src/commands/mobile/put_file_request.cc +++ b/src/components/application_manager/src/commands/mobile/put_file_request.cc @@ -38,6 +38,22 @@ #include "application_manager/application_impl.h" #include "utils/file_system.h" +#include <boost/crc.hpp> + +namespace { +/** +* Calculates CRC32 checksum +* @param binary_data - input data for which CRC32 should be calculated +* @return calculated CRC32 checksum +*/ +uint32_t GetCrc32CheckSum(const std::vector<uint8_t>& binary_data) { + const std::size_t file_size = binary_data.size(); + boost::crc_32_type result; + result.process_bytes(&binary_data[0], file_size); + return result.checksum(); +} + +} // namespace namespace application_manager { @@ -137,7 +153,7 @@ void PutFileRequest::Run() { is_persistent_file_ = false; bool is_system_file = false; length_ = binary_data.size(); - bool is_download_compleate = true; + bool is_download_complete = true; bool offset_exist = (*message_)[strings::msg_params].keyExists(strings::offset); @@ -187,11 +203,29 @@ void PutFileRequest::Run() { return; } const std::string full_path = file_path + "/" + sync_file_name_; - UNUSED(full_path); + const size_t bin_data_size = binary_data.size(); + + if ((*message_)[strings::msg_params].keyExists(strings::crc32_check_sum)) { + LOG4CXX_TRACE(logger_, "Binary Data Size: " << bin_data_size); + const uint32_t crc_received = + (*message_)[strings::msg_params][strings::crc32_check_sum].asUInt(); + LOG4CXX_TRACE(logger_, "CRC32 SUM Received: " << crc_received); + const uint32_t crc_calculated = GetCrc32CheckSum(binary_data); + LOG4CXX_TRACE(logger_, "CRC32 SUM Calculated: " << crc_calculated); + if (crc_calculated != crc_received) { + SendResponse(false, + mobile_apis::Result::CORRUPTED_DATA, + "CRC Check on file failed. File upload has been cancelled, " + "please retry.", + &response_params); + return; + } + } + LOG4CXX_DEBUG(logger_, - "Wrtiting " << binary_data.size() << "bytes to " << full_path - << " (current size is" - << file_system::FileSize(full_path) << ")"); + "Writing " << bin_data_size << " bytes to " << full_path + << " (current size is" + << file_system::FileSize(full_path) << ")"); mobile_apis::Result::eType save_result = application_manager_.SaveBinary( binary_data, file_path, sync_file_name_, offset_); @@ -211,7 +245,7 @@ void PutFileRequest::Run() { if (!is_system_file) { AppFile file(sync_file_name_, is_persistent_file_, - is_download_compleate, + is_download_complete, file_type_); if (0 == offset_) { diff --git a/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc b/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc index a3a30ddb20..3a8a2de4ab 100644 --- a/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc +++ b/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc @@ -50,6 +50,7 @@ #include "config_profile/profile.h" #include "interfaces/MOBILE_API.h" #include "interfaces/generated_msg_version.h" +#include "utils/file_system.h" namespace { namespace custom_str = utils::custom_string; @@ -348,6 +349,15 @@ void RegisterAppInterfaceRequest::Run() { } } + if (msg_params.keyExists(strings::day_color_scheme)) { + application->set_day_color_scheme(msg_params[strings::day_color_scheme]); + } + + if (msg_params.keyExists(strings::night_color_scheme)) { + application->set_night_color_scheme( + msg_params[strings::night_color_scheme]); + } + // Add device to policy table and set device info, if any policy::DeviceParams dev_params; if (-1 == @@ -440,50 +450,69 @@ void FillUIRelatedFields(smart_objects::SmartObject& response_params, smart_objects::SmartObject& display_caps = response_params[hmi_response::display_capabilities]; - display_caps[hmi_response::display_type] = - hmi_capabilities.display_capabilities()->getElement( - hmi_response::display_type); - - display_caps[hmi_response::text_fields] = - hmi_capabilities.display_capabilities()->getElement( - hmi_response::text_fields); - - display_caps[hmi_response::image_fields] = - hmi_capabilities.display_capabilities()->getElement( - hmi_response::image_fields); + if (hmi_capabilities.display_capabilities()->keyExists( + hmi_response::display_type)) { + display_caps[hmi_response::display_type] = + hmi_capabilities.display_capabilities()->getElement( + hmi_response::display_type); + } - display_caps[hmi_response::media_clock_formats] = - hmi_capabilities.display_capabilities()->getElement( - hmi_response::media_clock_formats); + if (hmi_capabilities.display_capabilities()->keyExists( + hmi_response::display_name)) { + display_caps[hmi_response::display_name] = + hmi_capabilities.display_capabilities()->getElement( + hmi_response::display_name); + } - display_caps[hmi_response::templates_available] = - hmi_capabilities.display_capabilities()->getElement( - hmi_response::templates_available); + if (hmi_capabilities.display_capabilities()->keyExists( + hmi_response::text_fields)) { + display_caps[hmi_response::text_fields] = + hmi_capabilities.display_capabilities()->getElement( + hmi_response::text_fields); + } - display_caps[hmi_response::screen_params] = - hmi_capabilities.display_capabilities()->getElement( - hmi_response::screen_params); + if (hmi_capabilities.display_capabilities()->keyExists( + hmi_response::image_fields)) { + display_caps[hmi_response::image_fields] = + hmi_capabilities.display_capabilities()->getElement( + hmi_response::image_fields); + } - display_caps[hmi_response::num_custom_presets_available] = - hmi_capabilities.display_capabilities()->getElement( - hmi_response::num_custom_presets_available); + if (hmi_capabilities.display_capabilities()->keyExists( + hmi_response::media_clock_formats)) { + display_caps[hmi_response::media_clock_formats] = + hmi_capabilities.display_capabilities()->getElement( + hmi_response::media_clock_formats); + } - display_caps[hmi_response::graphic_supported] = - (hmi_capabilities.display_capabilities() - ->getElement(hmi_response::image_capabilities) - .length() > 0); + if (hmi_capabilities.display_capabilities()->keyExists( + hmi_response::templates_available)) { + display_caps[hmi_response::templates_available] = + hmi_capabilities.display_capabilities()->getElement( + hmi_response::templates_available); + } - display_caps[hmi_response::templates_available] = - hmi_capabilities.display_capabilities()->getElement( - hmi_response::templates_available); + if (hmi_capabilities.display_capabilities()->keyExists( + hmi_response::screen_params)) { + display_caps[hmi_response::screen_params] = + hmi_capabilities.display_capabilities()->getElement( + hmi_response::screen_params); + } - display_caps[hmi_response::screen_params] = - hmi_capabilities.display_capabilities()->getElement( - hmi_response::screen_params); + if (hmi_capabilities.display_capabilities()->keyExists( + hmi_response::num_custom_presets_available)) { + display_caps[hmi_response::num_custom_presets_available] = + hmi_capabilities.display_capabilities()->getElement( + hmi_response::num_custom_presets_available); + } - display_caps[hmi_response::num_custom_presets_available] = - hmi_capabilities.display_capabilities()->getElement( - hmi_response::num_custom_presets_available); + if (hmi_capabilities.display_capabilities()->keyExists( + hmi_response::image_capabilities)) { + display_caps[hmi_response::graphic_supported] = + (hmi_capabilities.display_capabilities() + ->getElement(hmi_response::image_capabilities) + .length() > 0); + } } if (hmi_capabilities.audio_pass_thru_capabilities()) { @@ -710,6 +739,10 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile( } policy::StatusNotifier notify_upd_manager = GetPolicyHandler().AddApplication( application->policy_app_id(), hmi_types); + + response_params[strings::icon_resumed] = + file_system::FileExists(application->app_icon_path()); + SendResponse(true, result_code, add_info.c_str(), &response_params); SendOnAppRegisteredNotificationToHMI( *(application.get()), resumption, need_restore_vr); @@ -813,8 +846,9 @@ void RegisterAppInterfaceRequest::SendOnAppRegisteredNotificationToHMI( msg_params[strings::tts_name] = *(application_impl.tts_name()); } + const std::string policy_app_id = application_impl.policy_app_id(); std::string priority; - GetPolicyHandler().GetPriority(application_impl.policy_app_id(), &priority); + GetPolicyHandler().GetPriority(policy_app_id, &priority); if (!priority.empty()) { msg_params[strings::priority] = MessageHelper::GetPriorityCode(priority); @@ -824,8 +858,10 @@ void RegisterAppInterfaceRequest::SendOnAppRegisteredNotificationToHMI( smart_objects::SmartObject& application = msg_params[strings::application]; application[strings::app_name] = application_impl.name(); application[strings::app_id] = application_impl.app_id(); - application[hmi_response::policy_app_id] = application_impl.policy_app_id(); - application[strings::icon] = application_impl.app_icon_path(); + application[hmi_response::policy_app_id] = policy_app_id; + if (file_system::FileExists(application_impl.app_icon_path())) { + application[strings::icon] = application_impl.app_icon_path(); + } const smart_objects::SmartObject* ngn_media_screen_name = application_impl.ngn_media_screen_name(); @@ -844,18 +880,41 @@ void RegisterAppInterfaceRequest::SendOnAppRegisteredNotificationToHMI( application[strings::app_type] = *app_type; } - std::vector<std::string> request_types = - GetPolicyHandler().GetAppRequestTypes(application_impl.policy_app_id()); + const policy::RequestType::State app_request_types_state = + GetPolicyHandler().GetAppRequestTypeState(policy_app_id); + if (policy::RequestType::State::AVAILABLE == app_request_types_state) { + const auto request_types = + GetPolicyHandler().GetAppRequestTypes(policy_app_id); + application[strings::request_type] = SmartObject(SmartType_Array); + smart_objects::SmartObject& request_types_array = + application[strings::request_type]; - application[strings::request_type] = SmartObject(SmartType_Array); - smart_objects::SmartObject& request_array = - application[strings::request_type]; - - uint32_t index = 0; - std::vector<std::string>::const_iterator it = request_types.begin(); - for (; request_types.end() != it; ++it) { - request_array[index] = *it; - ++index; + size_t index = 0; + for (auto it : request_types) { + request_types_array[index] = it; + ++index; + } + } else if (policy::RequestType::State::EMPTY == app_request_types_state) { + application[strings::request_type] = SmartObject(SmartType_Array); + } + + const policy::RequestSubType::State app_request_subtypes_state = + GetPolicyHandler().GetAppRequestSubTypeState(policy_app_id); + if (policy::RequestSubType::State::AVAILABLE == app_request_subtypes_state) { + const auto request_subtypes = + GetPolicyHandler().GetAppRequestSubTypes(policy_app_id); + application[strings::request_subtype] = SmartObject(SmartType_Array); + smart_objects::SmartObject& request_subtypes_array = + application[strings::request_subtype]; + + size_t index = 0; + for (auto it : request_subtypes) { + request_subtypes_array[index] = it; + ++index; + } + } else if (policy::RequestSubType::State::EMPTY == + app_request_subtypes_state) { + application[strings::request_subtype] = SmartObject(SmartType_Array); } application[strings::device_info] = SmartObject(SmartType_Map); @@ -884,6 +943,18 @@ void RegisterAppInterfaceRequest::SendOnAppRegisteredNotificationToHMI( device_info[strings::transport_type] = application_manager_.GetDeviceTransportType(transport_type); + const smart_objects::SmartObject* day_color_scheme = + application_impl.day_color_scheme(); + if (day_color_scheme) { + application[strings::day_color_scheme] = *day_color_scheme; + } + + const smart_objects::SmartObject* night_color_scheme = + application_impl.night_color_scheme(); + if (night_color_scheme) { + application[strings::night_color_scheme] = *night_color_scheme; + } + DCHECK(application_manager_.ManageHMICommand(notification)); } diff --git a/src/components/application_manager/src/commands/mobile/set_app_icon_request.cc b/src/components/application_manager/src/commands/mobile/set_app_icon_request.cc index ee544e956a..a100bbb5fb 100644 --- a/src/components/application_manager/src/commands/mobile/set_app_icon_request.cc +++ b/src/components/application_manager/src/commands/mobile/set_app_icon_request.cc @@ -31,9 +31,10 @@ POSSIBILITY OF SUCH DAMAGE. */ -#include <algorithm> #include "application_manager/commands/mobile/set_app_icon_request.h" +#include <algorithm> + #include "application_manager/message_helper.h" #include "application_manager/application_impl.h" #include "interfaces/MOBILE_API.h" @@ -90,10 +91,6 @@ void SetAppIconRequest::Run() { return; } - if (is_icons_saving_enabled_) { - CopyToIconStorage(full_file_path); - } - smart_objects::SmartObject msg_params = smart_objects::SmartObject(smart_objects::SmartType_Map); @@ -262,6 +259,11 @@ void SetAppIconRequest::on_event(const event_engine::Event& event) { const std::string& path = (*message_)[strings::msg_params][strings::sync_file_name] [strings::value].asString(); + + if (is_icons_saving_enabled_) { + CopyToIconStorage(path); + } + app->set_app_icon_path(path); LOG4CXX_INFO(logger_, diff --git a/src/components/application_manager/src/commands/mobile/set_display_layout_request.cc b/src/components/application_manager/src/commands/mobile/set_display_layout_request.cc index 38b62ce731..ed60ca4928 100644 --- a/src/components/application_manager/src/commands/mobile/set_display_layout_request.cc +++ b/src/components/application_manager/src/commands/mobile/set_display_layout_request.cc @@ -48,8 +48,7 @@ SetDisplayLayoutRequest::~SetDisplayLayoutRequest() {} void SetDisplayLayoutRequest::Run() { LOG4CXX_AUTO_TRACE(logger_); - ApplicationConstSharedPtr app = - application_manager_.application(connection_key()); + ApplicationSharedPtr app = application_manager_.application(connection_key()); if (!app) { LOG4CXX_ERROR(logger_, "Application is not registered"); @@ -57,6 +56,58 @@ void SetDisplayLayoutRequest::Run() { return; } + const smart_objects::SmartObject& msg_params = + (*message_)[strings::msg_params]; + + std::string old_layout = app->display_layout(); + std::string new_layout = ""; + + if (msg_params.keyExists(strings::display_layout)) { + new_layout = msg_params[strings::display_layout].asString(); + } + + if (new_layout != old_layout && + !new_layout.empty()) { // Template switched, allow any color change + LOG4CXX_DEBUG(logger_, + "SetDisplayLayoutRequest New Layout: " << new_layout); + app->set_display_layout(new_layout); + } else { + LOG4CXX_DEBUG(logger_, "SetDisplayLayoutRequest No Layout Change"); + // Template layout is the same as previous layout + // Reject message if colors are set + if (msg_params.keyExists(strings::day_color_scheme) && + app->day_color_scheme() != NULL && + !(msg_params[strings::day_color_scheme] == + *(app->day_color_scheme()))) { + // Color scheme param exists and has been previously set, do not allow + // color change + LOG4CXX_DEBUG(logger_, "Reject Day Color Scheme Change"); + SendResponse(false, mobile_apis::Result::REJECTED); + return; + } + + if (msg_params.keyExists(strings::night_color_scheme) && + app->night_color_scheme() != NULL && + !(msg_params[strings::night_color_scheme] == + *(app->night_color_scheme()))) { + // Color scheme param exists and has been previously set, do not allow + // color change + LOG4CXX_DEBUG(logger_, "Reject Night Color Scheme Change"); + SendResponse(false, mobile_apis::Result::REJECTED); + return; + } + } + + if (msg_params.keyExists(strings::day_color_scheme)) { + LOG4CXX_DEBUG(logger_, "Allow Day Color Scheme Change"); + app->set_day_color_scheme(msg_params[strings::day_color_scheme]); + } + + if (msg_params.keyExists(strings::night_color_scheme)) { + LOG4CXX_DEBUG(logger_, "Allow Night Color Scheme Change"); + app->set_night_color_scheme(msg_params[strings::night_color_scheme]); + } + (*message_)[strings::msg_params][strings::app_id] = app->app_id(); StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); SendHMIRequest(hmi_apis::FunctionID::UI_SetDisplayLayout, 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 fe38b93732..f0331d0ced 100644 --- a/src/components/application_manager/src/commands/mobile/system_request.cc +++ b/src/components/application_manager/src/commands/mobile/system_request.cc @@ -41,6 +41,7 @@ Copyright (c) 2013, Ford Motor Company #include "application_manager/policies/policy_handler_interface.h" #include "interfaces/MOBILE_API.h" #include "utils/file_system.h" +#include "policy/policy_table/enums.h" #include "formatters/CFormatterJsonBase.h" #include "json/json.h" #include "utils/helpers.h" @@ -454,17 +455,43 @@ void SystemRequest::Run() { const policy::PolicyHandlerInterface& policy_handler = application_manager_.GetPolicyHandler(); + + const std::string stringified_request_type = + rpc::policy_table_interface_base::EnumToJsonString( + static_cast<rpc::policy_table_interface_base::RequestType>( + request_type)); + if (!policy_handler.IsRequestTypeAllowed(application->policy_app_id(), request_type)) { + LOG4CXX_ERROR(logger_, + "RequestType " << stringified_request_type + << " is DISALLOWED by policies"); SendResponse(false, mobile_apis::Result::DISALLOWED); return; } + LOG4CXX_TRACE(logger_, + "RequestType " << stringified_request_type << " is ALLOWED"); + + const bool request_subtype_present = + (*message_)[strings::msg_params].keyExists(strings::request_subtype); + if (request_subtype_present) { + const std::string request_subtype = + (*message_)[strings::msg_params][strings::request_subtype].asString(); + if (!policy_handler.IsRequestSubTypeAllowed(application->policy_app_id(), + request_subtype)) { + LOG4CXX_ERROR(logger_, + "Request subtype: " << request_subtype + << " is DISALLOWED by policies"); + SendResponse(false, mobile_apis::Result::DISALLOWED); + return; + } + LOG4CXX_TRACE(logger_, + "Request subtype: " << request_subtype << " is ALLOWED"); + } - std::string file_name; + std::string file_name = kSYNC; if ((*message_)[strings::msg_params].keyExists(strings::file_name)) { file_name = (*message_)[strings::msg_params][strings::file_name].asString(); - } else { - file_name = kSYNC; } if (!CheckSyntax(file_name)) { @@ -481,8 +508,8 @@ void SystemRequest::Run() { return; } - bool is_system_file = std::string::npos != file_name.find(kSYNC) || - std::string::npos != file_name.find(kIVSU); + const bool is_system_file = std::string::npos != file_name.find(kSYNC) || + std::string::npos != file_name.find(kIVSU); // to avoid override existing file if (is_system_file) { @@ -587,6 +614,10 @@ void SystemRequest::Run() { msg_params[strings::request_type] = (*message_)[strings::msg_params][strings::request_type]; + if (request_subtype_present) { + msg_params[strings::request_subtype] = + (*message_)[strings::msg_params][strings::request_subtype]; + } StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_BasicCommunication); SendHMIRequest(hmi_apis::FunctionID::BasicCommunication_SystemRequest, &msg_params, diff --git a/src/components/application_manager/src/hmi_capabilities_impl.cc b/src/components/application_manager/src/hmi_capabilities_impl.cc index e39b728155..f64b80a088 100644 --- a/src/components/application_manager/src/hmi_capabilities_impl.cc +++ b/src/components/application_manager/src/hmi_capabilities_impl.cc @@ -282,6 +282,9 @@ void InitCapabilities() { image_field_name_enum.insert(std::make_pair( std::string("graphic"), hmi_apis::Common_ImageFieldName::graphic)); image_field_name_enum.insert( + std::make_pair(std::string("secondaryGraphic"), + hmi_apis::Common_ImageFieldName::secondaryGraphic)); + image_field_name_enum.insert( std::make_pair(std::string("showConstantTBTIcon"), hmi_apis::Common_ImageFieldName::showConstantTBTIcon)); image_field_name_enum.insert(std::make_pair( @@ -548,10 +551,15 @@ void HMICapabilitiesImpl::set_vr_supported_languages( void HMICapabilitiesImpl::set_display_capabilities( const smart_objects::SmartObject& display_capabilities) { - if (display_capabilities_) { - delete display_capabilities_; + if (app_mngr_.IsSOStructValid( + hmi_apis::StructIdentifiers::Common_DisplayCapabilities, + display_capabilities)) { + if (display_capabilities_) { + delete display_capabilities_; + } + display_capabilities_ = + new smart_objects::SmartObject(display_capabilities); } - display_capabilities_ = new smart_objects::SmartObject(display_capabilities); } void HMICapabilitiesImpl::set_hmi_zone_capabilities( diff --git a/src/components/application_manager/src/message_helper/message_helper.cc b/src/components/application_manager/src/message_helper/message_helper.cc index 6a908c4ebc..d3af65effa 100644 --- a/src/components/application_manager/src/message_helper/message_helper.cc +++ b/src/components/application_manager/src/message_helper/message_helper.cc @@ -175,6 +175,8 @@ std::pair<std::string, mobile_apis::VehicleDataType::VEHICLEDATA_FUELLEVEL_STATE), std::make_pair(strings::instant_fuel_consumption, mobile_apis::VehicleDataType::VEHICLEDATA_FUELCONSUMPTION), + std::make_pair(strings::fuel_range, + mobile_apis::VehicleDataType::VEHICLEDATA_FUELRANGE), std::make_pair(strings::external_temp, mobile_apis::VehicleDataType::VEHICLEDATA_EXTERNTEMP), std::make_pair(strings::vin, mobile_apis::VehicleDataType::VEHICLEDATA_VIN), @@ -217,7 +219,8 @@ std::pair<std::string, mobile_apis::VehicleDataType::VEHICLEDATA_ACCPEDAL), std::make_pair(strings::steering_wheel_angle, mobile_apis::VehicleDataType::VEHICLEDATA_STEERINGWHEEL), -}; + std::make_pair(strings::engine_oil_life, + mobile_apis::VehicleDataType::VEHICLEDATA_ENGINEOILLIFE)}; const VehicleData MessageHelper::vehicle_data_( kVehicleDataInitializer, @@ -1677,6 +1680,9 @@ bool MessageHelper::CreateHMIApplicationStruct( const smart_objects::SmartObject* app_types = app->app_types(); const smart_objects::SmartObject* ngn_media_screen_name = app->ngn_media_screen_name(); + const smart_objects::SmartObject* day_color_scheme = app->day_color_scheme(); + const smart_objects::SmartObject* night_color_scheme = + app->night_color_scheme(); std::string device_name; std::string mac_address; std::string transport_type; @@ -1714,6 +1720,14 @@ bool MessageHelper::CreateHMIApplicationStruct( message[strings::app_type] = *app_types; } + if (day_color_scheme) { + message[strings::day_color_scheme] = *day_color_scheme; + } + + if (night_color_scheme) { + message[strings::night_color_scheme] = *night_color_scheme; + } + message[strings::device_info] = smart_objects::SmartObject(smart_objects::SmartType_Map); message[strings::device_info][strings::name] = device_name; @@ -2589,12 +2603,23 @@ void MessageHelper::SendOnAppPermissionsChangedNotification( if (permissions.requestTypeChanged) { smart_objects::SmartObject request_types_array( smart_objects::SmartType_Array); - ; + for (uint16_t index = 0; index < permissions.requestType.size(); ++index) { request_types_array[index] = permissions.requestType[index]; } message[strings::msg_params][strings::request_type] = request_types_array; } + if (permissions.requestSubTypeChanged) { + smart_objects::SmartObject request_subtypes_array( + smart_objects::SmartType_Array); + + for (uint16_t index = 0; index < permissions.requestSubType.size(); + ++index) { + request_subtypes_array[index] = permissions.requestSubType[index]; + } + message[strings::msg_params][strings::request_subtype] = + request_subtypes_array; + } app_mngr.ManageHMICommand( utils::MakeShared<smart_objects::SmartObject>(message)); diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index 77281f5a72..123606a11e 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -54,6 +54,7 @@ #include "utils/file_system.h" #include "utils/scope_guard.h" #include "utils/make_shared.h" +#include "utils/helpers.h" #include "policy/policy_manager.h" #ifdef SDL_REMOTE_CONTROL #include "functional_module/plugin_manager.h" @@ -90,7 +91,8 @@ RequestTypeMap TypeToString = { {mobile_apis::RequestType::VEHICLE_DIAGNOSTICS, "VEHICLE_DIAGNOSTICS"}, {mobile_apis::RequestType::EMERGENCY, "EMERGENCY"}, {mobile_apis::RequestType::MEDIA, "MEDIA"}, - {mobile_apis::RequestType::FOTA, "FOTA"}}; + {mobile_apis::RequestType::FOTA, "FOTA"}, + {mobile_apis::RequestType::OEM_SPECIFIC, "OEM_SPECIFIC"}}; const std::string RequestTypeToString(mobile_apis::RequestType::eType type) { RequestTypeMap::const_iterator it = TypeToString.find(type); @@ -1027,7 +1029,7 @@ void PolicyHandler::OnPendingPermissionChange( policy_manager_->RemovePendingPermissionChanges(policy_app_id); } - if (permissions.requestTypeChanged) { + if (permissions.requestTypeChanged || permissions.requestSubTypeChanged) { MessageHelper::SendOnAppPermissionsChangedNotification( app->app_id(), permissions, application_manager_); policy_manager_->RemovePendingPermissionChanges(policy_app_id); @@ -1882,6 +1884,18 @@ void PolicyHandler::OnAppRegisteredOnMobile(const std::string& application_id) { policy_manager_->OnAppRegisteredOnMobile(application_id); } +RequestType::State PolicyHandler::GetAppRequestTypeState( + const std::string& policy_app_id) const { + POLICY_LIB_CHECK(RequestType::State::UNAVAILABLE); + return policy_manager_->GetAppRequestTypesState(policy_app_id); +} + +RequestSubType::State PolicyHandler::GetAppRequestSubTypeState( + const std::string& policy_app_id) const { + POLICY_LIB_CHECK(RequestSubType::State::UNAVAILABLE); + return policy_manager_->GetAppRequestSubTypesState(policy_app_id); +} + bool PolicyHandler::IsRequestTypeAllowed( const std::string& policy_app_id, mobile_apis::RequestType::eType type) const { @@ -1894,17 +1908,66 @@ bool PolicyHandler::IsRequestTypeAllowed( return false; } - std::vector<std::string> request_types = - policy_manager_->GetAppRequestTypes(policy_app_id); + const RequestType::State request_type_state = + policy_manager_->GetAppRequestTypesState(policy_app_id); - // If no request types are assigned to app - any is allowed - if (request_types.empty()) { - return true; + switch (request_type_state) { + case RequestType::State::EMPTY: { + // If empty array of request types is assigned to app - any is allowed + LOG4CXX_TRACE(logger_, "Any Request Type is allowed by policies."); + return true; + } + case RequestType::State::OMITTED: { + // If RequestType parameter omitted for app - any is disallowed + LOG4CXX_TRACE(logger_, "All Request Types are disallowed by policies."); + return false; + } + case RequestType::State::AVAILABLE: { + // If any of request types is available for current application - get them + const auto request_types = + policy_manager_->GetAppRequestTypes(policy_app_id); + return helpers::in_range(request_types, stringified_type); + } + default: + return false; } +} - std::vector<std::string>::const_iterator it = - std::find(request_types.begin(), request_types.end(), stringified_type); - return request_types.end() != it; +bool PolicyHandler::IsRequestSubTypeAllowed( + const std::string& policy_app_id, + const std::string& request_subtype) const { + POLICY_LIB_CHECK(false); + using namespace mobile_apis; + + if (request_subtype.empty()) { + LOG4CXX_ERROR(logger_, "Request subtype to check is empty."); + return false; + } + + const RequestSubType::State request_subtype_state = + policy_manager_->GetAppRequestSubTypesState(policy_app_id); + switch (request_subtype_state) { + case RequestSubType::State::EMPTY: { + // If empty array of request subtypes is assigned to app - any is allowed + LOG4CXX_TRACE(logger_, "Any Request SubType is allowed by policies."); + return true; + } + case RequestSubType::State::OMITTED: { + // If RequestSubType parameter omitted for app - any is disallowed + LOG4CXX_TRACE(logger_, + "All Request SubTypes are disallowed by policies."); + return false; + } + case RequestSubType::State::AVAILABLE: { + // If any of request subtypes is available for current application + // get them all + const auto request_subtypes = + policy_manager_->GetAppRequestSubTypes(policy_app_id); + return helpers::in_range(request_subtypes, request_subtype); + } + default: + return false; + } } const std::vector<std::string> PolicyHandler::GetAppRequestTypes( @@ -1913,6 +1976,12 @@ const std::vector<std::string> PolicyHandler::GetAppRequestTypes( return policy_manager_->GetAppRequestTypes(policy_app_id); } +const std::vector<std::string> PolicyHandler::GetAppRequestSubTypes( + const std::string& policy_app_id) const { + POLICY_LIB_CHECK(std::vector<std::string>()); + return policy_manager_->GetAppRequestSubTypes(policy_app_id); +} + const VehicleInfo policy::PolicyHandler::GetVehicleInfo() const { POLICY_LIB_CHECK(VehicleInfo()); return policy_manager_->GetVehicleInfo(); diff --git a/src/components/application_manager/src/smart_object_keys.cc b/src/components/application_manager/src/smart_object_keys.cc index f56fd23c84..a55696524c 100644 --- a/src/components/application_manager/src/smart_object_keys.cc +++ b/src/components/application_manager/src/smart_object_keys.cc @@ -143,17 +143,30 @@ const char* navigation_capability = "navigationCapability"; const char* phone_capability = "phoneCapability"; const char* video_streaming_capability = "videoStreamingCapability"; const char* rc_capability = "remoteControlCapability"; +const char* day_color_scheme = "dayColorScheme"; +const char* night_color_scheme = "nightColorScheme"; +const char* primary_color = "primaryColor"; +const char* secondary_color = "secondaryColor"; +const char* background_color = "backgroundColor"; +const char* red = "red"; +const char* green = "green"; +const char* blue = "blue"; +const char* display_layout = "displayLayout"; +const char* icon_resumed = "iconResumed"; // PutFile const char* sync_file_name = "syncFileName"; const char* file_name = "fileName"; const char* file_type = "fileType"; const char* file_size = "fileSize"; +const char* crc32_check_sum = "crc"; const char* request_type = "requestType"; +const char* request_subtype = "requestSubType"; const char* persistent_file = "persistentFile"; const char* file_data = "fileData"; const char* space_available = "spaceAvailable"; const char* image_type = "imageType"; +const char* is_template = "isTemplate"; const char* image = "image"; const char* type = "type"; const char* system_file = "systemFile"; @@ -203,6 +216,7 @@ const char* rpm = "rpm"; const char* fuel_level = "fuelLevel"; const char* fuel_level_state = "fuelLevel_State"; const char* instant_fuel_consumption = "instantFuelConsumption"; +const char* fuel_range = "fuelRange"; const char* external_temp = "externalTemperature"; const char* vin = "vin"; const char* prndl = "prndl"; @@ -239,6 +253,7 @@ const char* remote_control = "remoteControl"; const char* sdl_version = "sdlVersion"; const char* system_software_version = "systemSoftwareVersion"; const char* priority = "priority"; +const char* engine_oil_life = "engineOilLife"; // resuming const char* application_commands = "applicationCommands"; @@ -427,6 +442,7 @@ const char* dtc = "dtc"; const char* ecu_header = "ecuHeader"; const char* image_capabilities = "imageCapabilities"; const char* display_type = "displayType"; +const char* display_name = "displayName"; const char* text_fields = "textFields"; const char* media_clock_formats = "mediaClockFormats"; const char* graphic_supported = "graphicSupported"; diff --git a/src/components/application_manager/test/application_manager_impl_test.cc b/src/components/application_manager/test/application_manager_impl_test.cc index c922c227bb..9cc552f188 100644 --- a/src/components/application_manager/test/application_manager_impl_test.cc +++ b/src/components/application_manager/test/application_manager_impl_test.cc @@ -89,6 +89,9 @@ namespace { const std::string kDirectoryName = "./test_storage"; const uint32_t kTimeout = 10000u; connection_handler::DeviceHandle kDeviceId = 12345u; +const std::string kAppId = "someID"; +const uint32_t kConnectionKey = 1232u; +const std::string kAppName = "appName"; } // namespace class ApplicationManagerImplTest : public ::testing::Test { @@ -136,6 +139,8 @@ class ApplicationManagerImplTest : public ::testing::Test { .WillByDefault(Return(stop_streaming_timeout)); ON_CALL(mock_application_manager_settings_, default_timeout()) .WillByDefault(ReturnRef(kTimeout)); + ON_CALL(mock_application_manager_settings_, + application_list_update_timeout()).WillByDefault(Return(kTimeout)); app_manager_impl_.reset(new am::ApplicationManagerImpl( mock_application_manager_settings_, mock_policy_settings_)); @@ -941,6 +946,49 @@ TEST_F(ApplicationManagerImplTest, UnregisterAnotherAppDuringAudioPassThru) { } } +TEST_F(ApplicationManagerImplTest, + RegisterApplication_PathToTheIconExists_IconWasSet) { + file_system::CreateDirectory(kDirectoryName); + const std::string full_icon_path = kDirectoryName + "/" + kAppId; + ASSERT_TRUE(file_system::CreateFile(full_icon_path)); + + smart_objects::SmartObject request_for_registration( + smart_objects::SmartType_Map); + + smart_objects::SmartObject& params = + request_for_registration[strings::msg_params]; + params[strings::app_id] = kAppId; + params[strings::language_desired] = mobile_api::Language::EN_US; + params[strings::hmi_display_language_desired] = mobile_api::Language::EN_US; + + request_for_registration[strings::params][strings::connection_key] = + kConnectionKey; + request_for_registration[strings::msg_params][strings::app_name] = kAppName; + request_for_registration[strings::msg_params][strings::sync_msg_version] + [strings::minor_version] = APIVersion::kAPIV2; + request_for_registration[strings::msg_params][strings::sync_msg_version] + [strings::major_version] = APIVersion::kAPIV3; + + request_for_registration[strings::params][strings::protocol_version] = + protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_2; + + smart_objects::SmartObjectSPtr request_for_registration_ptr = + MakeShared<smart_objects::SmartObject>(request_for_registration); + + ApplicationSharedPtr application = + app_manager_impl_->RegisterApplication(request_for_registration_ptr); + EXPECT_STREQ(kAppName.c_str(), application->name().c_str()); + EXPECT_STREQ(full_icon_path.c_str(), application->app_icon_path().c_str()); + EXPECT_EQ(protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_2, + application->protocol_version()); + EXPECT_EQ(APIVersion::kAPIV2, + application->version().min_supported_api_version); + EXPECT_EQ(APIVersion::kAPIV3, + application->version().max_supported_api_version); + + EXPECT_TRUE(file_system::RemoveDirectory(kDirectoryName, true)); +} + } // application_manager_test } // namespace components } // namespace test diff --git a/src/components/application_manager/test/commands/CMakeLists.txt b/src/components/application_manager/test/commands/CMakeLists.txt index 8dafc16471..be236fdb49 100644 --- a/src/components/application_manager/test/commands/CMakeLists.txt +++ b/src/components/application_manager/test/commands/CMakeLists.txt @@ -65,6 +65,7 @@ set(LIBRARIES AMMobileCommandsLibrary connectionHandler jsoncpp + Policy ) create_cotired_test("commands_test" "${SOURCES}" "${LIBRARIES}" ) diff --git a/src/components/application_manager/test/commands/hmi/ui_get_capabilities_response_test.cc b/src/components/application_manager/test/commands/hmi/ui_get_capabilities_response_test.cc index b02c9851ee..7dd7a74f4c 100644 --- a/src/components/application_manager/test/commands/hmi/ui_get_capabilities_response_test.cc +++ b/src/components/application_manager/test/commands/hmi/ui_get_capabilities_response_test.cc @@ -95,6 +95,8 @@ TEST_F(UIGetCapabilitiesResponseTest, RUN_SetDisplay_SUCCESSS) { smart_objects::SmartObject(smart_objects::SmartType_Map); (*command_msg)[strings::msg_params][hmi_response::display_capabilities] [hmi_response::display_type] = "GEN2_8_DMA"; + (*command_msg)[strings::msg_params][hmi_response::display_capabilities] + [hmi_response::display_name] = "GENERIC_DISPLAY"; ResponseFromHMIPtr command( CreateCommand<UIGetCapabilitiesResponse>(command_msg)); diff --git a/src/components/application_manager/test/commands/mobile/on_system_request_notification_test.cc b/src/components/application_manager/test/commands/mobile/on_system_request_notification_test.cc index 7840e35cec..60af9381e8 100644 --- a/src/components/application_manager/test/commands/mobile/on_system_request_notification_test.cc +++ b/src/components/application_manager/test/commands/mobile/on_system_request_notification_test.cc @@ -54,6 +54,7 @@ using application_manager::commands::CommandImpl; using application_manager::MockMessageHelper; using test::components::policy_test::MockPolicyHandlerInterface; using namespace mobile_apis; +using testing::SaveArg; using testing::Mock; using testing::Return; using testing::ReturnRef; @@ -61,17 +62,35 @@ using testing::_; namespace { const uint32_t kConnectionKey = 1u; +const std::string kPolicyAppId = "fake-app-id"; } // namespace class OnSystemRequestNotificationTest - : public CommandsTest<CommandsTestMocks::kIsNice> {}; + : public CommandsTest<CommandsTestMocks::kIsNice> { + public: + OnSystemRequestNotificationTest() : mock_app_(CreateMockApp()) {} + + void PreConditions() { + ON_CALL(app_mngr_, application(kConnectionKey)) + .WillByDefault(Return(mock_app_)); + + ON_CALL(app_mngr_, GetPolicyHandler()) + .WillByDefault(ReturnRef(mock_policy_handler_)); + ON_CALL(*mock_app_, policy_app_id()).WillByDefault(Return(kPolicyAppId)); + } + + protected: + MockAppPtr mock_app_; + MockPolicyHandlerInterface mock_policy_handler_; +}; TEST_F(OnSystemRequestNotificationTest, Run_ProprietaryType_SUCCESS) { - const RequestType::eType kRequestType = RequestType::PROPRIETARY; + const mobile_apis::RequestType::eType request_type = + mobile_apis::RequestType::PROPRIETARY; MessageSharedPtr msg = CreateMessage(); (*msg)[strings::params][strings::connection_key] = kConnectionKey; - (*msg)[strings::msg_params][strings::request_type] = kRequestType; + (*msg)[strings::msg_params][strings::request_type] = request_type; SharedPtr<OnSystemRequestNotification> command = CreateCommand<OnSystemRequestNotification>(msg); @@ -111,11 +130,12 @@ TEST_F(OnSystemRequestNotificationTest, Run_ProprietaryType_SUCCESS) { } TEST_F(OnSystemRequestNotificationTest, Run_HTTPType_SUCCESS) { - const RequestType::eType kRequestType = RequestType::HTTP; + const mobile_apis::RequestType::eType request_type = + mobile_apis::RequestType::HTTP; MessageSharedPtr msg = CreateMessage(); (*msg)[strings::params][strings::connection_key] = kConnectionKey; - (*msg)[strings::msg_params][strings::request_type] = kRequestType; + (*msg)[strings::msg_params][strings::request_type] = request_type; SharedPtr<OnSystemRequestNotification> command = CreateCommand<OnSystemRequestNotification>(msg); @@ -148,11 +168,12 @@ TEST_F(OnSystemRequestNotificationTest, Run_HTTPType_SUCCESS) { } TEST_F(OnSystemRequestNotificationTest, Run_InvalidApp_NoNotification) { - const RequestType::eType kRequestType = RequestType::HTTP; + const mobile_apis::RequestType::eType request_type = + mobile_apis::RequestType::HTTP; MessageSharedPtr msg = CreateMessage(); (*msg)[strings::params][strings::connection_key] = kConnectionKey; - (*msg)[strings::msg_params][strings::request_type] = kRequestType; + (*msg)[strings::msg_params][strings::request_type] = request_type; SharedPtr<OnSystemRequestNotification> command = CreateCommand<OnSystemRequestNotification>(msg); @@ -172,11 +193,12 @@ TEST_F(OnSystemRequestNotificationTest, Run_InvalidApp_NoNotification) { } TEST_F(OnSystemRequestNotificationTest, Run_RequestNotAllowed_NoNotification) { - const RequestType::eType kRequestType = RequestType::HTTP; + const mobile_apis::RequestType::eType request_type = + mobile_apis::RequestType::HTTP; MessageSharedPtr msg = CreateMessage(); (*msg)[strings::params][strings::connection_key] = kConnectionKey; - (*msg)[strings::msg_params][strings::request_type] = kRequestType; + (*msg)[strings::msg_params][strings::request_type] = request_type; SharedPtr<OnSystemRequestNotification> command = CreateCommand<OnSystemRequestNotification>(msg); @@ -199,6 +221,71 @@ TEST_F(OnSystemRequestNotificationTest, Run_RequestNotAllowed_NoNotification) { command->Run(); } +TEST_F( + OnSystemRequestNotificationTest, + Run_RequestTypeAllowedAndRequestSubTypeDisallowed_MessageNotSentToMobile) { + MessageSharedPtr msg = CreateMessage(); + (*msg)[strings::params][strings::connection_key] = kConnectionKey; + const auto request_type = mobile_apis::RequestType::HTTP; + (*msg)[strings::msg_params][strings::request_type] = request_type; + const std::string request_subtype = "fakeSubType"; + (*msg)[am::strings::msg_params][am::strings::request_subtype] = + request_subtype; + + PreConditions(); + + EXPECT_CALL(mock_policy_handler_, + IsRequestTypeAllowed(kPolicyAppId, request_type)) + .WillOnce(Return(true)); + EXPECT_CALL(mock_policy_handler_, + IsRequestSubTypeAllowed(kPolicyAppId, request_subtype)) + .WillOnce(Return(false)); + + EXPECT_CALL(app_mngr_, SendMessageToMobile(_, _)).Times(0); + + auto command = CreateCommand<OnSystemRequestNotification>(msg); + + ASSERT_TRUE(command->Init()); + command->Run(); +} + +TEST_F(OnSystemRequestNotificationTest, + Run_RequestTypeAllowedAndRequestSubTypeAllowed_SendMessageToMobile) { + MessageSharedPtr msg = CreateMessage(); + (*msg)[strings::params][strings::connection_key] = kConnectionKey; + const auto request_type = mobile_apis::RequestType::OEM_SPECIFIC; + (*msg)[strings::msg_params][strings::request_type] = request_type; + const std::string request_subtype = "fakeSubType"; + (*msg)[am::strings::msg_params][am::strings::request_subtype] = + request_subtype; + + PreConditions(); + + EXPECT_CALL(mock_policy_handler_, + IsRequestTypeAllowed(kPolicyAppId, request_type)) + .WillOnce(Return(true)); + EXPECT_CALL(mock_policy_handler_, + IsRequestSubTypeAllowed(kPolicyAppId, request_subtype)) + .WillOnce(Return(true)); + + smart_objects::SmartObjectSPtr result; + EXPECT_CALL(app_mngr_, SendMessageToMobile(_, _)) + .WillOnce((SaveArg<0>(&result))); + + auto command = CreateCommand<OnSystemRequestNotification>(msg); + + ASSERT_TRUE(command->Init()); + command->Run(); + + EXPECT_EQ(application_manager::MessageType::kNotification, + (*result)[strings::params][strings::message_type].asInt()); + EXPECT_EQ(request_type, + (*result)[strings::msg_params][strings::request_type].asInt()); + EXPECT_EQ( + request_subtype, + (*result)[strings::msg_params][strings::request_subtype].asString()); +} + } // namespace on_system_request_notification } // namespace mobile_commands_test } // namespace commands_test diff --git a/src/components/application_manager/test/commands/mobile/put_file_test.cc b/src/components/application_manager/test/commands/mobile/put_file_test.cc index b48ac67501..575daa7217 100644 --- a/src/components/application_manager/test/commands/mobile/put_file_test.cc +++ b/src/components/application_manager/test/commands/mobile/put_file_test.cc @@ -77,6 +77,7 @@ const std::string kFileName = "sync_file_name.txt"; const int64_t kOffset = 10u; const int64_t kZeroOffset = 0u; const std::string kStorageFolder = "./storage"; +const std::string kFolder = "folder"; const std::string kAppFolder = "app_folder"; } @@ -344,6 +345,64 @@ TEST_F(PutFileRequestTest, Run_InvalidPutFile_UNSUCCESS) { command->Run(); } +TEST_F(PutFileRequestTest, Run_CrcSumEqual_SendSuccessResponse) { + binary_data_ = {1u}; + (*msg_)[am::strings::params][am::strings::binary_data] = binary_data_; + const uint32_t correct_crc_sum = + 2768625435u; // calculated using the GetCrc32CheckSum method + (*msg_)[am::strings::msg_params][am::strings::crc32_check_sum] = + correct_crc_sum; + + ExpectReceiveMessageFromSDK(); + ON_CALL(app_mngr_, get_settings()) + .WillByDefault(ReturnRef(app_mngr_settings_)); + ON_CALL(app_mngr_settings_, app_storage_folder()) + .WillByDefault(ReturnRef(kStorageFolder)); + ON_CALL(*mock_app_, folder_name()).WillByDefault(Return(kFolder)); + const size_t available_space = binary_data_.size() + 1; + ON_CALL(*mock_app_, GetAvailableDiskSpace()) + .WillByDefault(Return(available_space)); + ON_CALL(*mock_app_, AddFile(_)).WillByDefault(Return(true)); + + const std::string file_path = kStorageFolder + "/" + kFolder; + EXPECT_CALL(app_mngr_, SaveBinary(binary_data_, file_path, kFileName, 0u)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + EXPECT_CALL(*mock_app_, increment_put_file_in_none_count()); + ExpectManageMobileCommandWithResultCode(mobile_apis::Result::SUCCESS); + PutFileRequestPtr command(CreateCommand<PutFileRequest>(msg_)); + ASSERT_TRUE(command->Init()); + command->Run(); + // The folder was created in the "Run" method + EXPECT_TRUE(file_system::RemoveDirectory(kStorageFolder, true)); +} + +TEST_F(PutFileRequestTest, Run_CrcSumUnequal_SendCorruptedDataResponse) { + binary_data_ = {1u}; + (*msg_)[am::strings::params][am::strings::binary_data] = binary_data_; + const uint32_t incorrect_crc_sum = 0u; + (*msg_)[am::strings::msg_params][am::strings::crc32_check_sum] = + incorrect_crc_sum; + + ExpectReceiveMessageFromSDK(); + ON_CALL(app_mngr_, get_settings()) + .WillByDefault(ReturnRef(app_mngr_settings_)); + ON_CALL(app_mngr_settings_, app_storage_folder()) + .WillByDefault(ReturnRef(kStorageFolder)); + ON_CALL(*mock_app_, folder_name()).WillByDefault(Return(kFolder)); + const size_t available_space = binary_data_.size() + 1; + ON_CALL(*mock_app_, GetAvailableDiskSpace()) + .WillByDefault(Return(available_space)); + ON_CALL(*mock_app_, AddFile(_)).WillByDefault(Return(true)); + + ExpectManageMobileCommandWithResultCode(mobile_apis::Result::CORRUPTED_DATA); + EXPECT_CALL(app_mngr_, SaveBinary(_, _, _, _)).Times(0); + PutFileRequestPtr command(CreateCommand<PutFileRequest>(msg_)); + ASSERT_TRUE(command->Init()); + command->Run(); + // The folder was created in the "Run" method + EXPECT_TRUE(file_system::RemoveDirectory(kStorageFolder, true)); +} + } // namespace put_file } // namespace mobile_commands_test } // namespace commands_test diff --git a/src/components/application_manager/test/commands/mobile/register_app_interface_request_test.cc b/src/components/application_manager/test/commands/mobile/register_app_interface_request_test.cc index b7a004f199..3225b4ef4c 100644 --- a/src/components/application_manager/test/commands/mobile/register_app_interface_request_test.cc +++ b/src/components/application_manager/test/commands/mobile/register_app_interface_request_test.cc @@ -161,6 +161,12 @@ class RegisterAppInterfaceRequestTest .WillByDefault(ReturnRef(kDummyDiagModes)); ON_CALL(mock_policy_handler_, GetAppRequestTypes(_)) .WillByDefault(Return(std::vector<std::string>())); + ON_CALL(mock_policy_handler_, GetAppRequestTypeState(_)) + .WillByDefault(Return(policy::RequestType::State::EMPTY)); + ON_CALL(mock_policy_handler_, GetAppRequestSubTypes(_)) + .WillByDefault(Return(std::vector<std::string>())); + ON_CALL(mock_policy_handler_, GetAppRequestSubTypeState(_)) + .WillByDefault(Return(policy::RequestSubType::State::EMPTY)); ON_CALL(mock_policy_handler_, GetUserConsentForDevice(_)) .WillByDefault(Return(policy::DeviceConsent::kDeviceAllowed)); ON_CALL(app_mngr_, GetDeviceTransportType(_)) @@ -344,6 +350,7 @@ TEST_F(RegisterAppInterfaceRequestTest, SmartObject& display_capabilities = (*expected_message)[am::hmi_response::display_capabilities]; display_capabilities[am::hmi_response::display_type] = "test_display_type"; + display_capabilities[am::hmi_response::display_name] = "GENERIC_DISPLAY"; display_capabilities[am::hmi_response::text_fields] = "test_text_fields"; display_capabilities[am::hmi_response::image_fields] = "test_image_fields"; display_capabilities[am::hmi_response::media_clock_formats] = diff --git a/src/components/application_manager/test/commands/mobile/set_app_icon_test.cc b/src/components/application_manager/test/commands/mobile/set_app_icon_test.cc index b278479df8..a5d50502f4 100644 --- a/src/components/application_manager/test/commands/mobile/set_app_icon_test.cc +++ b/src/components/application_manager/test/commands/mobile/set_app_icon_test.cc @@ -40,6 +40,8 @@ #include "application_manager/commands/command_request_test.h" #include "application_manager/mock_application.h" #include "application_manager/mock_application_manager.h" +#include "protocol_handler/mock_protocol_handler.h" +#include "protocol_handler/mock_protocol_handler_settings.h" #include "application_manager/mock_message_helper.h" #include "application_manager/event_engine/event.h" #include "application_manager/mock_hmi_interface.h" @@ -55,6 +57,9 @@ using am::commands::SetAppIconRequest; using am::commands::CommandImpl; using am::commands::MessageSharedPtr; using am::MockMessageHelper; +using am::MockHmiInterfaces; +using test::components::protocol_handler_test::MockProtocolHandler; +using test::components::protocol_handler_test::MockProtocolHandlerSettings; using ::utils::SharedPtr; using ::testing::_; using ::testing::Return; @@ -88,6 +93,10 @@ class SetAppIconRequestTest return msg; } + NiceMock<MockHmiInterfaces> hmi_interfaces_; + protocol_handler_test::MockProtocolHandler mock_protocol_handler_; + protocol_handler_test::MockProtocolHandlerSettings + mock_protocol_handler_settings_; }; TEST_F(SetAppIconRequestTest, OnEvent_UI_UNSUPPORTED_RESOURCE) { @@ -107,6 +116,20 @@ TEST_F(SetAppIconRequestTest, OnEvent_UI_UNSUPPORTED_RESOURCE) { MockAppPtr mock_app = CreateMockApp(); ON_CALL(app_mngr_, application(kConnectionKey)) .WillByDefault(Return(mock_app)); + ON_CALL(app_mngr_, hmi_interfaces()) + .WillByDefault(ReturnRef(hmi_interfaces_)); + ON_CALL(hmi_interfaces_, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) + .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); + + ON_CALL(app_mngr_, protocol_handler()) + .WillByDefault(ReturnRef(mock_protocol_handler_)); + ON_CALL(mock_protocol_handler_, get_settings()) + .WillByDefault(ReturnRef(mock_protocol_handler_settings_)); + + ON_CALL(mock_protocol_handler_settings_, max_supported_protocol_version()) + .WillByDefault( + Return(protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_4)); ON_CALL(*mock_app, app_id()).WillByDefault(Return(kConnectionKey)); ON_CALL(*mock_app, set_app_icon_path(_)).WillByDefault(Return(true)); diff --git a/src/components/application_manager/test/commands/mobile/set_display_layout_test.cc b/src/components/application_manager/test/commands/mobile/set_display_layout_test.cc index 8444b88d63..3e1785a3bd 100644 --- a/src/components/application_manager/test/commands/mobile/set_display_layout_test.cc +++ b/src/components/application_manager/test/commands/mobile/set_display_layout_test.cc @@ -69,6 +69,7 @@ const uint32_t kAppId = 1u; const uint32_t kCmdId = 1u; const uint32_t kConnectionKey = 2u; const uint32_t kCorrelationKey = 2u; +const std::string kLayout = "media"; } // namespace MATCHER_P(CheckMshCorrId, corr_id, "") { @@ -189,6 +190,7 @@ TEST_F(SetDisplayLayoutRequestTest, Run_SUCCESS) { MockAppPtr mock_app(CreateMockApp()); EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(mock_app)); + EXPECT_CALL(*mock_app, display_layout()).WillOnce(ReturnRef(kLayout)); EXPECT_CALL(*mock_app, app_id()).WillOnce(Return(kAppId)); EXPECT_CALL(app_mngr_, GetNextHMICorrelationID()) diff --git a/src/components/application_manager/test/commands/mobile/system_request_test.cc b/src/components/application_manager/test/commands/mobile/system_request_test.cc index 0e07889b4b..219ac54a8e 100644 --- a/src/components/application_manager/test/commands/mobile/system_request_test.cc +++ b/src/components/application_manager/test/commands/mobile/system_request_test.cc @@ -56,11 +56,14 @@ using am::commands::CommandImpl; using am::commands::MessageSharedPtr; using am::MockHmiInterfaces; using am::event_engine::Event; +using am::MessageType; using policy_test::MockPolicyHandlerInterface; using ::utils::SharedPtr; using ::testing::_; +using ::testing::DoAll; using ::testing::Return; using ::testing::ReturnRef; +using ::testing::SaveArg; namespace { const uint32_t kConnectionKey = 2u; @@ -70,6 +73,7 @@ const std::string kAppFolderName = "fake-app-name"; const std::string kAppStorageFolder = "fake-storage"; const std::string kSystemFilesPath = "/fake/system/files"; const std::string kFileName = "Filename"; +const uint32_t kHmiAppId = 3u; } // namespace class SystemRequestTest @@ -96,6 +100,7 @@ class SystemRequestTest ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kConnectionKey)); ON_CALL(*mock_app_, policy_app_id()).WillByDefault(Return(kAppPolicyId)); ON_CALL(*mock_app_, folder_name()).WillByDefault(Return(kAppFolderName)); + ON_CALL(*mock_app_, hmi_app_id()).WillByDefault(Return(kHmiAppId)); ON_CALL(app_mngr_settings_, system_files_path()) .WillByDefault(ReturnRef(kSystemFilesPath)); @@ -128,6 +133,105 @@ TEST_F(SystemRequestTest, Run_HTTP_FileName_no_binary_data_REJECTED) { command->Run(); } +TEST_F(SystemRequestTest, + Run_RequestTypeAllowedAndRequestSubTypeAllowed_SendHMIRequest) { + MessageSharedPtr msg = CreateIVSUMessage(); + + (*msg)[am::strings::msg_params][am::strings::request_type] = + mobile_apis::RequestType::OEM_SPECIFIC; + + const std::string request_subtype = "fakeSubType"; + (*msg)[am::strings::msg_params][am::strings::request_subtype] = + request_subtype; + + const std::vector<uint8_t> binary_data = {1u, 2u}; + (*msg)[am::strings::params][am::strings::binary_data] = binary_data; + + PreConditions(); + + EXPECT_CALL(mock_policy_handler_, + IsRequestTypeAllowed(kAppPolicyId, + mobile_apis::RequestType::OEM_SPECIFIC)) + .WillOnce(Return(true)); + + EXPECT_CALL(mock_policy_handler_, + IsRequestSubTypeAllowed(kAppPolicyId, request_subtype)) + .WillOnce(Return(true)); + + EXPECT_CALL(app_mngr_, + SaveBinary(binary_data, kSystemFilesPath, kFileName, 0u)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + + smart_objects::SmartObjectSPtr result; + EXPECT_CALL(app_mngr_, ManageHMICommand(_)) + .WillOnce(DoAll(SaveArg<0>(&result), Return(true))); + + SharedPtr<SystemRequest> command(CreateCommand<SystemRequest>(msg)); + ASSERT_TRUE(command->Init()); + command->Run(); + + EXPECT_EQ(MessageType::kRequest, + (*result)[am::strings::params][am::strings::message_type].asInt()); + EXPECT_EQ( + mobile_apis::RequestType::OEM_SPECIFIC, + (*result)[am::strings::msg_params][am::strings::request_type].asInt()); + EXPECT_EQ( + request_subtype, + (*msg)[am::strings::msg_params][am::strings::request_subtype].asString()); +} + +TEST_F( + SystemRequestTest, + Run_RequestTypeAllowedAndRequestSubTypeDisallowed_SendDisallowedResponse) { + MessageSharedPtr msg = CreateIVSUMessage(); + + (*msg)[am::strings::msg_params][am::strings::request_type] = + mobile_apis::RequestType::OEM_SPECIFIC; + + const std::string request_subtype = "fakeSubType2"; + (*msg)[am::strings::msg_params][am::strings::request_subtype] = + request_subtype; + + PreConditions(); + + EXPECT_CALL(mock_policy_handler_, + IsRequestTypeAllowed(kAppPolicyId, + mobile_apis::RequestType::OEM_SPECIFIC)) + .WillOnce(Return(true)); + + EXPECT_CALL(mock_policy_handler_, + IsRequestSubTypeAllowed(kAppPolicyId, request_subtype)) + .WillOnce(Return(false)); + + ExpectManageMobileCommandWithResultCode(mobile_apis::Result::DISALLOWED); + EXPECT_CALL(app_mngr_, ManageHMICommand(_)).Times(0); + + SharedPtr<SystemRequest> command(CreateCommand<SystemRequest>(msg)); + ASSERT_TRUE(command->Init()); + command->Run(); +} + +TEST_F(SystemRequestTest, Run_RequestTypeDisallowed_SendDisallowedResponse) { + MessageSharedPtr msg = CreateIVSUMessage(); + + (*msg)[am::strings::msg_params][am::strings::request_type] = + mobile_apis::RequestType::OEM_SPECIFIC; + + PreConditions(); + + EXPECT_CALL(mock_policy_handler_, + IsRequestTypeAllowed(kAppPolicyId, + mobile_apis::RequestType::OEM_SPECIFIC)) + .WillOnce(Return(false)); + + ExpectManageMobileCommandWithResultCode(mobile_apis::Result::DISALLOWED); + EXPECT_CALL(app_mngr_, ManageHMICommand(_)).Times(0); + + SharedPtr<SystemRequest> command(CreateCommand<SystemRequest>(msg)); + ASSERT_TRUE(command->Init()); + command->Run(); +} + } // namespace system_request } // namespace mobile_commands_test } // namespace commands_test diff --git a/src/components/application_manager/test/hmi_capabilities.json b/src/components/application_manager/test/hmi_capabilities.json index 9db6ee78ae..1c024f2669 100644 --- a/src/components/application_manager/test/hmi_capabilities.json +++ b/src/components/application_manager/test/hmi_capabilities.json @@ -42,6 +42,7 @@ ], "displayCapabilities": { "displayType": "GEN2_8_DMA", + "displayName": "GENERIC_DISPLAY", "textFields": [ { "name": "mainField1", @@ -215,7 +216,9 @@ "imageFields": [ { "name": "softButtonImage", - "imageTypeSupported": [], + "imageTypeSupported": [ + "GRAPHIC_PNG" + ], "imageResolution": { "resolutionWidth": 35, "resolutionHeight": 35 @@ -223,7 +226,9 @@ }, { "name": "choiceImage", - "imageTypeSupported": [], + "imageTypeSupported": [ + "GRAPHIC_PNG" + ], "imageResolution": { "resolutionWidth": 35, "resolutionHeight": 35 @@ -231,7 +236,9 @@ }, { "name": "choiceSecondaryImage", - "imageTypeSupported": [], + "imageTypeSupported": [ + "GRAPHIC_PNG" + ], "imageResolution": { "resolutionWidth": 35, "resolutionHeight": 35 @@ -239,7 +246,9 @@ }, { "name": "menuIcon", - "imageTypeSupported": [], + "imageTypeSupported": [ + "GRAPHIC_PNG" + ], "imageResolution": { "resolutionWidth": 35, "resolutionHeight": 35 @@ -247,7 +256,9 @@ }, { "name": "cmdIcon", - "imageTypeSupported": [], + "imageTypeSupported": [ + "GRAPHIC_PNG" + ], "imageResolution": { "resolutionWidth": 35, "resolutionHeight": 35 @@ -255,7 +266,9 @@ }, { "name": "appIcon", - "imageTypeSupported": [], + "imageTypeSupported": [ + "GRAPHIC_PNG" + ], "imageResolution": { "resolutionWidth": 35, "resolutionHeight": 35 @@ -263,7 +276,19 @@ }, { "name": "graphic", - "imageTypeSupported": [], + "imageTypeSupported": [ + "GRAPHIC_PNG" + ], + "imageResolution": { + "resolutionWidth": 35, + "resolutionHeight": 35 + } + }, + { + "name": "secondaryGraphic", + "imageTypeSupported": [ + "GRAPHIC_PNG" + ], "imageResolution": { "resolutionWidth": 35, "resolutionHeight": 35 diff --git a/src/components/application_manager/test/hmi_capabilities_test.cc b/src/components/application_manager/test/hmi_capabilities_test.cc index b8369528aa..d4f2b954cc 100644 --- a/src/components/application_manager/test/hmi_capabilities_test.cc +++ b/src/components/application_manager/test/hmi_capabilities_test.cc @@ -186,6 +186,8 @@ TEST_F(HMICapabilitiesTest, LoadCapabilitiesFromFile) { if (file_system::FileExists("./app_info_data")) { EXPECT_TRUE(::file_system::DeleteFile("./app_info_data")); } + EXPECT_CALL(app_mngr_, IsSOStructValid(_, _)).WillOnce(Return(true)); + EXPECT_TRUE(hmi_capabilities_test->LoadCapabilitiesFromFile()); // Check active languages @@ -269,6 +271,9 @@ TEST_F(HMICapabilitiesTest, LoadCapabilitiesFromFile) { static_cast<hmi_apis::Common_DisplayType::eType>( display_capabilities_so[hmi_response::display_type].asInt())); + EXPECT_EQ("GENERIC_DISPLAY", + display_capabilities_so[hmi_response::display_name].asString()); + EXPECT_TRUE(display_capabilities_so["graphicSupported"].asBool()); // Check text fields @@ -562,6 +567,7 @@ TEST_F(HMICapabilitiesTest, TEST_F(HMICapabilitiesTest, VerifyImageType) { const int32_t image_type = 1; smart_objects::SmartObject sm_obj; + EXPECT_CALL(app_mngr_, IsSOStructValid(_, _)).WillOnce(Return(true)); sm_obj[hmi_response::image_capabilities][0] = image_type; hmi_capabilities_test->set_display_capabilities(sm_obj); diff --git a/src/components/application_manager/test/include/application_manager/mock_application.h b/src/components/application_manager/test/include/application_manager/mock_application.h index d0c34b3392..5bc4ef6a42 100644 --- a/src/components/application_manager/test/include/application_manager/mock_application.h +++ b/src/components/application_manager/test/include/application_manager/mock_application.h @@ -212,6 +212,9 @@ class MockApplication : public ::application_manager::Application { MOCK_CONST_METHOD0(keyboard_props, const smart_objects::SmartObject*()); MOCK_CONST_METHOD0(menu_title, const smart_objects::SmartObject*()); MOCK_CONST_METHOD0(menu_icon, const smart_objects::SmartObject*()); + MOCK_CONST_METHOD0(day_color_scheme, const smart_objects::SmartObject*()); + MOCK_CONST_METHOD0(night_color_scheme, const smart_objects::SmartObject*()); + MOCK_CONST_METHOD0(display_layout, const std::string&()); MOCK_METHOD1(load_global_properties, void(const smart_objects::SmartObject& so)); MOCK_METHOD1(set_help_prompt, @@ -235,6 +238,11 @@ class MockApplication : public ::application_manager::Application { void(const smart_objects::SmartObject& menu_title)); MOCK_METHOD1(set_menu_icon, void(const smart_objects::SmartObject& menu_icon)); + MOCK_METHOD1(set_day_color_scheme, + void(const smart_objects::SmartObject& color_scheme)); + MOCK_METHOD1(set_night_color_scheme, + void(const smart_objects::SmartObject& color_scheme)); + MOCK_METHOD1(set_display_layout, void(const std::string& layout)); MOCK_CONST_METHOD0(audio_stream_retry_number, uint32_t()); MOCK_METHOD1(set_audio_stream_retry_number, void(const uint32_t& audio_stream_retry_number)); diff --git a/src/components/application_manager/test/policy_handler_test.cc b/src/components/application_manager/test/policy_handler_test.cc index 6425f7a255..3b6d0a16be 100644 --- a/src/components/application_manager/test/policy_handler_test.cc +++ b/src/components/application_manager/test/policy_handler_test.cc @@ -1378,10 +1378,30 @@ TEST_F(PolicyHandlerTest, IsRequestTypeAllowed) { mobile_apis::RequestType::eType type = mobile_apis::RequestType::eType::EMERGENCY; + + EXPECT_CALL(*mock_policy_manager_, GetAppRequestTypesState(kPolicyAppId_)) + .WillOnce(Return(policy::RequestType::State::AVAILABLE)); + EXPECT_CALL(*mock_policy_manager_, GetAppRequestTypes(kPolicyAppId_)) - .WillOnce(Return(std::vector<std::string>())); + .WillOnce(Return(std::vector<std::string>({"HTTP"}))); + // Act + EXPECT_FALSE(policy_handler_.IsRequestTypeAllowed(kPolicyAppId_, type)); +} + +TEST_F(PolicyHandlerTest, IsRequestSubTypeAllowed) { + // Arrange + EnablePolicyAndPolicyManagerMock(); + + // Check expectations + EXPECT_CALL(*mock_policy_manager_, GetAppRequestSubTypesState(kPolicyAppId_)) + .WillOnce(Return(policy::RequestSubType::State::AVAILABLE)); + EXPECT_CALL(*mock_policy_manager_, GetAppRequestSubTypes(kPolicyAppId_)) + .WillOnce( + Return(std::vector<std::string>({"fakeSubType", "fakeSubType2"}))); + // Act - policy_handler_.IsRequestTypeAllowed(kPolicyAppId_, type); + const std::string subtype = "fakeSubType"; + EXPECT_TRUE(policy_handler_.IsRequestSubTypeAllowed(kPolicyAppId_, subtype)); } TEST_F(PolicyHandlerTest, GetVehicleInfo) { diff --git a/src/components/application_manager/test/resumption/resumption_data_db_test.cc b/src/components/application_manager/test/resumption/resumption_data_db_test.cc index 001e06ca58..3b2c0d7b13 100644 --- a/src/components/application_manager/test/resumption/resumption_data_db_test.cc +++ b/src/components/application_manager/test/resumption/resumption_data_db_test.cc @@ -271,6 +271,10 @@ void ResumptionDataDBTest::CheckGlobalProportiesData() { select_image.GetInteger(0)); EXPECT_EQ((*menu_icon_)[am::strings::value].asString(), select_image.GetString(1)); + if ((*menu_icon_).keyExists(am::strings::is_template)) { + EXPECT_EQ((*menu_icon_)[am::strings::is_template].asBool(), + select_image.GetBoolean(2)); + } } if (!select_globalproperties.IsNull(8)) { utils::dbms::SQLQuery select_tts_chunk(test_db()); diff --git a/src/components/application_manager/test/resumption/resumption_data_test.cc b/src/components/application_manager/test/resumption/resumption_data_test.cc index 65e01b6119..0f90fe978f 100644 --- a/src/components/application_manager/test/resumption/resumption_data_test.cc +++ b/src/components/application_manager/test/resumption/resumption_data_test.cc @@ -381,6 +381,7 @@ void ResumptionDataTest::SetMenuTitleAndIcon() { sm::SmartObject sm_icon; sm_icon[am::strings::value] = "test icon"; sm_icon[am::strings::image_type] = ImageType::STATIC; + sm_icon[am::strings::is_template] = false; sm::SmartObject sm_title; sm_title = "test title"; diff --git a/src/components/application_manager/test/resumption_sql_queries_test.cc b/src/components/application_manager/test/resumption_sql_queries_test.cc index 28a3383086..0ec902085f 100644 --- a/src/components/application_manager/test/resumption_sql_queries_test.cc +++ b/src/components/application_manager/test/resumption_sql_queries_test.cc @@ -197,8 +197,9 @@ class ResumptionSqlQueriesTest : public ::testing::Test { const int64_t glob_prop_key); SQLQuery& FillImageTable(SQLQuery& query, - const int imageType, - const string& value); + const int image_type, + const string& value, + const bool is_template); SQLQuery& FillTableLimitedCharacterListTable( SQLQuery& query, const string& limitedCharacterList); @@ -456,11 +457,13 @@ void ResumptionSqlQueriesTest::CheckSelectQuery(const string& query_to_check, } SQLQuery& ResumptionSqlQueriesTest::FillImageTable(SQLQuery& query, - const int imageType, - const string& value) { + const int image_type, + const string& value, + const bool is_template) { EXPECT_TRUE(query.Prepare(kInsertImage)); - query.Bind(0, imageType); + query.Bind(0, image_type); query.Bind(1, value); + query.Bind(2, is_template); EXPECT_TRUE(query.Exec()); return query; } @@ -802,7 +805,10 @@ TEST_F(ResumptionSqlQueriesTest, kChecksResumptionData_ExpectDataCorrect) { TEST_F(ResumptionSqlQueriesTest, kSelectCountHMILevel_ExpectDataCorrect) { // Arrange SQLQuery temp_query(db()); - int64_t key = FillImageTable(temp_query, 1, test_image).LastInsertId(); + int64_t key = FillImageTable(temp_query, + /*image_type=*/1, + test_image, + /*is_template=*/true).LastInsertId(); key = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key) .LastInsertId(); @@ -829,7 +835,10 @@ TEST_F(ResumptionSqlQueriesTest, kSelectCountHMILevel_ExpectDataCorrect) { TEST_F(ResumptionSqlQueriesTest, kSelectHMILevel_ExpectDataCorrect) { // Arrange SQLQuery temp_query(db()); - int64_t key = FillImageTable(temp_query, 1, test_image).LastInsertId(); + int64_t key = FillImageTable(temp_query, + /*image_type=*/1, + test_image, + /*is_template=*/true).LastInsertId(); key = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key) .LastInsertId(); @@ -854,7 +863,10 @@ TEST_F(ResumptionSqlQueriesTest, kSelectHMILevel_ExpectDataCorrect) { TEST_F(ResumptionSqlQueriesTest, kCheckHMIId_ExpectDataCorrect) { // Arrange SQLQuery temp_query(db()); - int64_t key = FillImageTable(temp_query, 1, test_image).LastInsertId(); + int64_t key = FillImageTable(temp_query, + /*image_type=*/1, + test_image, + /*is_template=*/true).LastInsertId(); key = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key) .LastInsertId(); @@ -879,7 +891,10 @@ TEST_F(ResumptionSqlQueriesTest, kCheckHMIId_ExpectDataCorrect) { TEST_F(ResumptionSqlQueriesTest, kSelectHMIId_ExpectDataCorrect) { // Arrange SQLQuery temp_query(db()); - int64_t key = FillImageTable(temp_query, 1, test_image).LastInsertId(); + int64_t key = FillImageTable(temp_query, + /*image_type=*/1, + test_image, + /*is_template=*/true).LastInsertId(); key = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key) .LastInsertId(); @@ -904,7 +919,10 @@ TEST_F(ResumptionSqlQueriesTest, kSelectHMIId_ExpectDataCorrect) { TEST_F(ResumptionSqlQueriesTest, kSelectCountHMIId_ExpectDataCorrect) { // Arrange SQLQuery temp_query(db()); - int64_t key = FillImageTable(temp_query, 1, test_image).LastInsertId(); + int64_t key = FillImageTable(temp_query, + /*image_type=*/1, + test_image, + /*is_template=*/true).LastInsertId(); key = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key) .LastInsertId(); @@ -930,7 +948,10 @@ TEST_F(ResumptionSqlQueriesTest, kSelectCountHMIId_ExpectDataCorrect) { TEST_F(ResumptionSqlQueriesTest, kCountHashId_ExpectDataCorrect) { // Arrange SQLQuery temp_query(db()); - int64_t key = FillImageTable(temp_query, 1, test_image).LastInsertId(); + int64_t key = FillImageTable(temp_query, + /*image_type=*/1, + test_image, + /*is_template=*/true).LastInsertId(); key = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key) .LastInsertId(); @@ -956,7 +977,10 @@ TEST_F(ResumptionSqlQueriesTest, kCountHashId_ExpectDataCorrect) { TEST_F(ResumptionSqlQueriesTest, kSelectHashId_ExpectDataCorrect) { // Arrange SQLQuery temp_query(db()); - int64_t key = FillImageTable(temp_query, 1, test_image).LastInsertId(); + int64_t key = FillImageTable(temp_query, + /*image_type=*/1, + test_image, + /*is_template=*/true).LastInsertId(); key = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key) .LastInsertId(); @@ -990,7 +1014,10 @@ TEST_F(ResumptionSqlQueriesTest, kSelectIgnOffTime_ExpectDataCorrect) { TEST_F(ResumptionSqlQueriesTest, kCheckApplication_ExpectDataCorrect) { // Arrange SQLQuery temp_query(db()); - int64_t key = FillImageTable(temp_query, 1, test_image).LastInsertId(); + int64_t key = FillImageTable(temp_query, + /*image_type=*/1, + test_image, + /*is_template=*/true).LastInsertId(); key = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key) .LastInsertId(); @@ -1015,7 +1042,10 @@ TEST_F(ResumptionSqlQueriesTest, kCheckApplication_ExpectDataCorrect) { TEST_F(ResumptionSqlQueriesTest, kCountApplications_ExpectDataCorrect) { // Arrange SQLQuery temp_query(db()); - int64_t key = FillImageTable(temp_query, 1, test_image).LastInsertId(); + int64_t key = FillImageTable(temp_query, + /*image_type=*/1, + test_image, + /*is_template=*/true).LastInsertId(); key = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key) .LastInsertId(); @@ -1032,7 +1062,9 @@ TEST_F(ResumptionSqlQueriesTest, kCountApplications_ExpectDataCorrect) { device_id, key); - key = FillImageTable(temp_query, 1, "tst_img2").LastInsertId(); + key = FillImageTable( + temp_query, 1 /* image_type */, "tst_img2", true /* is_template */) + .LastInsertId(); key = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key) .LastInsertId(); @@ -1056,7 +1088,10 @@ TEST_F(ResumptionSqlQueriesTest, kSelectDataForLoadResumeData_ExpectDataCorrect) { // Arrange SQLQuery temp_query(db()); - int64_t key = FillImageTable(temp_query, 1, test_image).LastInsertId(); + int64_t key = FillImageTable(temp_query, + /*image_type=*/1, + test_image, + /*is_template=*/true).LastInsertId(); key = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key) .LastInsertId(); @@ -1084,7 +1119,10 @@ TEST_F(ResumptionSqlQueriesTest, TEST_F(ResumptionSqlQueriesTest, kUpdateHMILevel_ExpectDataUpdated) { // Arrange SQLQuery temp_query(db()); - int64_t key = FillImageTable(temp_query, 1, test_image).LastInsertId(); + int64_t key = FillImageTable(temp_query, + /*image_type=*/1, + test_image, + /*is_template=*/true).LastInsertId(); key = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key) .LastInsertId(); @@ -1117,7 +1155,10 @@ TEST_F(ResumptionSqlQueriesTest, kUpdateHMILevel_ExpectDataUpdated) { TEST_F(ResumptionSqlQueriesTest, kUpdateIgnOffCount_ExpectDataUpdated) { // Arrange SQLQuery temp_query(db()); - int64_t key = FillImageTable(temp_query, 1, test_image).LastInsertId(); + int64_t key = FillImageTable(temp_query, + /*image_type=*/1, + test_image, + /*is_template=*/true).LastInsertId(); key = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key) .LastInsertId(); @@ -1148,7 +1189,10 @@ TEST_F(ResumptionSqlQueriesTest, kUpdateIgnOffCount_ExpectDataUpdated) { TEST_F(ResumptionSqlQueriesTest, kCountApplicationsIgnOff_ExpectDataCorrect) { // Arrange SQLQuery temp_query(db()); - int64_t key = FillImageTable(temp_query, 1, test_image).LastInsertId(); + int64_t key = FillImageTable(temp_query, + /*image_type=*/1, + test_image, + /*is_template=*/true).LastInsertId(); key = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key) .LastInsertId(); @@ -1189,7 +1233,10 @@ TEST_F(ResumptionSqlQueriesTest, kSelectApplicationsIgnOffCount_ExpectDataCorrect) { // Arrange SQLQuery temp_query(db()); - int64_t key = FillImageTable(temp_query, 1, test_image).LastInsertId(); + int64_t key = FillImageTable(temp_query, + /*image_type=*/1, + test_image, + /*is_template=*/true).LastInsertId(); key = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key) .LastInsertId(); @@ -1229,7 +1276,10 @@ TEST_F(ResumptionSqlQueriesTest, TEST_F(ResumptionSqlQueriesTest, kUpdateSuspendData_ExpectDataUpdated) { // Arrange SQLQuery temp_query(db()); - int64_t key = FillImageTable(temp_query, 1, test_image).LastInsertId(); + int64_t key = FillImageTable(temp_query, + /*image_type=*/1, + test_image, + /*is_template=*/true).LastInsertId(); key = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key) .LastInsertId(); @@ -1258,7 +1308,10 @@ TEST_F(ResumptionSqlQueriesTest, kUpdateSuspendData_ExpectDataUpdated) { TEST_F(ResumptionSqlQueriesTest, kDeleteFile_ExpectDataDeleted) { // Arrange SQLQuery temp_query(db()); - int64_t key1 = FillImageTable(temp_query, 1, test_image).LastInsertId(); + int64_t key1 = FillImageTable(temp_query, + /*image_type=*/1, + test_image, + /*is_template=*/true).LastInsertId(); key1 = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key1) .LastInsertId(); @@ -1288,7 +1341,10 @@ TEST_F(ResumptionSqlQueriesTest, kDeleteApplicationFilesArray_ExpectDataDeleted) { // Arrange SQLQuery temp_query(db()); - int64_t key1 = FillImageTable(temp_query, 1, test_image).LastInsertId(); + int64_t key1 = FillImageTable(temp_query, + /*image_type=*/1, + test_image, + /*is_template=*/true).LastInsertId(); key1 = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key1) .LastInsertId(); @@ -1324,7 +1380,10 @@ TEST_F(ResumptionSqlQueriesTest, TEST_F(ResumptionSqlQueriesTest, kDeleteSubMenu_ExpectDataDeleted) { // Arrange SQLQuery temp_query(db()); - int64_t key = FillImageTable(temp_query, 1, test_image).LastInsertId(); + int64_t key = FillImageTable(temp_query, + /*image_type=*/1, + test_image, + /*is_template=*/true).LastInsertId(); key = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key) .LastInsertId(); @@ -1355,7 +1414,10 @@ TEST_F(ResumptionSqlQueriesTest, kDeleteApplicationSubMenuArray_ExpectDataDeleted) { // Arrange SQLQuery temp_query(db()); - int64_t key = FillImageTable(temp_query, 1, test_image).LastInsertId(); + int64_t key = FillImageTable(temp_query, + /*image_type=*/1, + test_image, + /*is_template=*/true).LastInsertId(); key = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key) .LastInsertId(); @@ -1389,7 +1451,10 @@ TEST_F(ResumptionSqlQueriesTest, kDeleteApplicationSubscriptionsArray_ExpectDataDeleted) { // Arrange SQLQuery temp_query(db()); - int64_t key1 = FillImageTable(temp_query, 1, test_image).LastInsertId(); + int64_t key1 = FillImageTable(temp_query, + /*image_type=*/1, + test_image, + /*is_template=*/true).LastInsertId(); key1 = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key1) .LastInsertId(); @@ -1426,7 +1491,10 @@ TEST_F(ResumptionSqlQueriesTest, TEST_F(ResumptionSqlQueriesTest, kDeleteImageFromCommands_ExpectDataDeleted) { // Arrange SQLQuery temp_query(db()); - int64_t key1 = FillImageTable(temp_query, 1, test_image).LastInsertId(); + int64_t key1 = FillImageTable(temp_query, + /*image_type=*/1, + test_image, + /*is_template=*/true).LastInsertId(); int64_t key2 = FillCommandTable(temp_query, 1, "tst_menu_name", 1, 2, key1) .LastInsertId(); key1 = FillGlobalPropertiesTable( @@ -1456,7 +1524,10 @@ TEST_F(ResumptionSqlQueriesTest, kDeleteImageFromCommands_ExpectDataDeleted) { TEST_F(ResumptionSqlQueriesTest, kDeleteVrCommands_ExpectDataDeleted) { // Arrange SQLQuery temp_query(db()); - int64_t key1 = FillImageTable(temp_query, 1, test_image).LastInsertId(); + int64_t key1 = FillImageTable(temp_query, + /*image_type=*/1, + test_image, + /*is_template=*/true).LastInsertId(); int64_t key2 = FillCommandTable(temp_query, 1, "tst_menu_name", 1, 2, key1) .LastInsertId(); key1 = FillGlobalPropertiesTable( @@ -1490,7 +1561,10 @@ TEST_F(ResumptionSqlQueriesTest, kDeleteVrCommands_ExpectDataDeleted) { TEST_F(ResumptionSqlQueriesTest, kDeleteCommands_ExpectDataDeleted) { // Arrange SQLQuery temp_query(db()); - int64_t key1 = FillImageTable(temp_query, 1, test_image).LastInsertId(); + int64_t key1 = FillImageTable(temp_query, + /*image_type=*/1, + test_image, + /*is_template=*/true).LastInsertId(); int64_t key2 = FillCommandTable(temp_query, 1, "tst_menu_name", 1, 2, key1) .LastInsertId(); @@ -1522,7 +1596,10 @@ TEST_F(ResumptionSqlQueriesTest, kDeleteApplicationCommandsArray_ExpectDataDeleted) { // Arrange SQLQuery temp_query(db()); - int64_t key1 = FillImageTable(temp_query, 1, test_image).LastInsertId(); + int64_t key1 = FillImageTable(temp_query, + /*image_type=*/1, + test_image, + /*is_template=*/true).LastInsertId(); int64_t key2 = FillCommandTable(temp_query, 1, "tst_menu_name", 1, 2, key1) .LastInsertId(); @@ -1560,7 +1637,10 @@ TEST_F(ResumptionSqlQueriesTest, TEST_F(ResumptionSqlQueriesTest, kDeleteImageFromChoiceSet_ExpectDataDeleted) { // Arrange SQLQuery temp_query(db()); - int64_t key1 = FillImageTable(temp_query, 1, test_image).LastInsertId(); + int64_t key1 = FillImageTable(temp_query, + /*image_type=*/1, + test_image, + /*is_template=*/true).LastInsertId(); int64_t key2 = FillChoiceTable(temp_query, 2, "tst_menu_name", @@ -1595,7 +1675,10 @@ TEST_F(ResumptionSqlQueriesTest, kDeleteVrCommandsFromChoiceSet_ExpectDataDeleted) { // Arrange SQLQuery temp_query(db()); - int64_t key1 = FillImageTable(temp_query, 1, test_image).LastInsertId(); + int64_t key1 = FillImageTable(temp_query, + /*image_type=*/1, + test_image, + /*is_template=*/true).LastInsertId(); int64_t key2 = FillChoiceTable( temp_query, 1, "tst_menu_name", "second_text", "tert_txt", key1) @@ -1638,7 +1721,10 @@ TEST_F(ResumptionSqlQueriesTest, TEST_F(ResumptionSqlQueriesTest, kDeleteChoice_ExpectDataDeleted) { // Arrange SQLQuery temp_query(db()); - int64_t key1 = FillImageTable(temp_query, 1, test_image).LastInsertId(); + int64_t key1 = FillImageTable(temp_query, + /*image_type=*/1, + test_image, + /*is_template=*/true).LastInsertId(); int64_t key2 = FillChoiceTable( temp_query, 1, "tst_menu_name", "second_text", "tert_txt", key1) @@ -1775,7 +1861,10 @@ TEST_F(ResumptionSqlQueriesTest, kDeleteImageFromGlobalProperties_ExpectDataDeleted) { // Arrange SQLQuery temp_query(db()); - int64_t key1 = FillImageTable(temp_query, 1, test_image).LastInsertId(); + int64_t key1 = FillImageTable(temp_query, + /*image_type=*/1, + test_image, + /*is_template=*/true).LastInsertId(); int64_t key2 = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key1) .LastInsertId(); @@ -1804,7 +1893,10 @@ TEST_F(ResumptionSqlQueriesTest, TEST_F(ResumptionSqlQueriesTest, kDeletevrHelpItem_ExpectDataDeleted) { // Arrange SQLQuery temp_query(db()); - int64_t key1 = FillImageTable(temp_query, 1, test_image).LastInsertId(); + int64_t key1 = FillImageTable(temp_query, + /*image_type=*/1, + test_image, + /*is_template=*/true).LastInsertId(); int64_t key2 = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key1) .LastInsertId(); @@ -1834,7 +1926,10 @@ TEST_F(ResumptionSqlQueriesTest, kDeletevrHelpItem_ExpectDataDeleted) { TEST_F(ResumptionSqlQueriesTest, kDeletevrHelpItemArray_ExpectDataDeleted) { // Arrange SQLQuery temp_query(db()); - int64_t key1 = FillImageTable(temp_query, 1, test_image).LastInsertId(); + int64_t key1 = FillImageTable(temp_query, + /*image_type=*/1, + test_image, + /*is_template=*/true).LastInsertId(); int64_t key2 = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key1) .LastInsertId(); @@ -2051,7 +2146,8 @@ TEST_F(ResumptionSqlQueriesTest, kDeleteGlobalProperties_ExpectDataDeleted) { TEST_F(ResumptionSqlQueriesTest, kSelectCountImage_ExpectDataCorrect) { // Arrange SQLQuery temp_query(db()); - FillImageTable(temp_query, 2, "tst_image"); + FillImageTable( + temp_query, /*image_type=*/2, "tst_image", /*is_template=*/true); ValToPosPair p1(0, "tst_image"); ValToPosPair p2(1, ""); // Check @@ -2061,7 +2157,10 @@ TEST_F(ResumptionSqlQueriesTest, kSelectCountImage_ExpectDataCorrect) { TEST_F(ResumptionSqlQueriesTest, kSelectPrimaryKeyImage_ExpectDataCorrect) { // Arrange SQLQuery temp_query(db()); - int64_t image_key = FillImageTable(temp_query, 2, "tst_image").LastInsertId(); + int64_t image_key = FillImageTable(temp_query, + /*image_type=*/2, + "tst_image", + /*is_template=*/true).LastInsertId(); ValToPosPair p1(0, "tst_image"); ValToPosPair p2(1, ""); // Check @@ -2071,7 +2170,8 @@ TEST_F(ResumptionSqlQueriesTest, kSelectPrimaryKeyImage_ExpectDataCorrect) { TEST_F(ResumptionSqlQueriesTest, kInsertImage_ExpectDataInserted) { // Arrange SQLQuery temp_query(db()); - FillImageTable(temp_query, 2, "tst_image"); + FillImageTable( + temp_query, /*image_type=*/2, "tst_image", /*is_template=*/true); const std::string select_count_image = "SELECT COUNT(*) FROM image;"; // Check CheckSelectQuery(select_count_image, 1, 0); @@ -2616,7 +2716,10 @@ TEST_F(ResumptionSqlQueriesTest, kSelectCommandsFromCommand_ExpectDataCorrect) { app_id1, device_id, 9).LastInsertId(); - int64_t image_key = FillImageTable(temp_query, 2, "tst_image").LastInsertId(); + int64_t image_key = FillImageTable(temp_query, + /*image_type=*/2, + "tst_image", + /*is_template=*/true).LastInsertId(); FillChoiceTable( temp_query, 1, "menu_name", "sec_text", "tert_text", image_key) @@ -2656,7 +2759,10 @@ TEST_F(ResumptionSqlQueriesTest, kSelectCommandsFromChoice_ExpectDataCorrect) { app_id1, device_id, 9).LastInsertId(); - int64_t image_key = FillImageTable(temp_query, 2, "tst_image").LastInsertId(); + int64_t image_key = FillImageTable(temp_query, + /*image_type=*/2, + "tst_image", + /*is_template=*/true).LastInsertId(); int64_t choice_key = FillChoiceTable( @@ -2776,7 +2882,10 @@ TEST_F(ResumptionSqlQueriesTest, kSelectChoiceSets_ExpectDataCorrect) { app_id1, device_id, 9).LastInsertId(); - int64_t image_key = FillImageTable(temp_query, 2, "tst_image").LastInsertId(); + int64_t image_key = FillImageTable(temp_query, + /*image_type=*/2, + "tst_image", + /*is_template=*/true).LastInsertId(); int64_t choice_key = FillChoiceTable( temp_query, 1, "menu_name", "sec_text", "tert_text", image_key) @@ -2808,7 +2917,10 @@ TEST_F(ResumptionSqlQueriesTest, kSelectChoiceSets_ExpectDataCorrect) { TEST_F(ResumptionSqlQueriesTest, kSelectImage_ExpectDataCorrect) { // Arrange SQLQuery temp_query(db()); - int64_t image_key = FillImageTable(temp_query, 2, "tst_image").LastInsertId(); + int64_t image_key = FillImageTable(temp_query, + /*image_type=*/2, + "tst_image", + /*is_template=*/true).LastInsertId(); // Check ValToPosPair p1(0, IntToString(image_key)); ValToPosPair p2(1, ""); @@ -2846,7 +2958,10 @@ TEST_F(ResumptionSqlQueriesTest, TEST_F(ResumptionSqlQueriesTest, kSelectGlobalProperties_ExpectDataCorrect) { // Arrange SQLQuery temp_query(db()); - int64_t image_key = FillImageTable(temp_query, 2, "tst_image").LastInsertId(); + int64_t image_key = FillImageTable(temp_query, + /*image_type=*/2, + test_image, + /*is_template=*/true).LastInsertId(); int64_t glob_prop_key = FillGlobalPropertiesTable( temp_query, "tst_vr_title", "tst_menu", 2, 3, 3, "auto", image_key) @@ -2883,7 +2998,10 @@ TEST_F(ResumptionSqlQueriesTest, kSelectGlobalProperties_ExpectDataCorrect) { TEST_F(ResumptionSqlQueriesTest, kChecksVrHelpItem_ExpectDataCorrect) { // Arrange SQLQuery temp_query(db()); - int64_t image_key = FillImageTable(temp_query, 2, "tst_image").LastInsertId(); + int64_t image_key = FillImageTable(temp_query, + /*image_type=*/2, + "tst_image", + /*is_template=*/true).LastInsertId(); int64_t glob_prop_key = FillGlobalPropertiesTable( temp_query, "tst_vr_title", "tst_menu", 2, 3, 3, "auto", image_key) @@ -2900,7 +3018,10 @@ TEST_F(ResumptionSqlQueriesTest, kChecksVrHelpItem_ExpectDataCorrect) { TEST_F(ResumptionSqlQueriesTest, kSelectVrHelpItem_ExpectDataCorrect) { // Arrange SQLQuery temp_query(db()); - int64_t image_key = FillImageTable(temp_query, 2, "tst_image").LastInsertId(); + int64_t image_key = FillImageTable(temp_query, + /*image_type=*/2, + "tst_image", + /*is_template=*/true).LastInsertId(); int64_t glob_prop_key = FillGlobalPropertiesTable( temp_query, "tst_vr_title", "tst_menu", 2, 3, 3, "auto", image_key) diff --git a/src/components/application_manager/test/sdl_preloaded_pt.json b/src/components/application_manager/test/sdl_preloaded_pt.json index 1f477175be..ced0a9d603 100644 --- a/src/components/application_manager/test/sdl_preloaded_pt.json +++ b/src/components/application_manager/test/sdl_preloaded_pt.json @@ -350,12 +350,14 @@ "LIMITED"], "parameters": ["bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -367,12 +369,14 @@ "LIMITED"], "parameters": ["bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -384,12 +388,14 @@ "LIMITED"], "parameters": ["bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus"] @@ -400,12 +406,14 @@ "LIMITED"], "parameters": ["bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus"] diff --git a/src/components/application_manager/test/sdl_pt_update.json b/src/components/application_manager/test/sdl_pt_update.json index 9ac28a7945..f87ae40eac 100644 --- a/src/components/application_manager/test/sdl_pt_update.json +++ b/src/components/application_manager/test/sdl_pt_update.json @@ -1587,12 +1587,14 @@ "GetVehicleData" : { "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ], "parameters" : [ + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -1602,12 +1604,14 @@ "OnVehicleData" : { "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ], "parameters" : [ + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -1617,12 +1621,14 @@ "SubscribeVehicleData" : { "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ], "parameters" : [ + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus" @@ -1631,12 +1637,14 @@ "UnsubscribeVehicleData" : { "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ], "parameters" : [ + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus" diff --git a/src/components/include/application_manager/application_manager.h b/src/components/include/application_manager/application_manager.h index 9941ff9107..f6f06bd7cd 100644 --- a/src/components/include/application_manager/application_manager.h +++ b/src/components/include/application_manager/application_manager.h @@ -731,6 +731,10 @@ class ApplicationManager { virtual void OnTimerSendTTSGlobalProperties() = 0; virtual void OnLowVoltage() = 0; virtual void OnWakeUp() = 0; + + virtual bool IsSOStructValid( + const hmi_apis::StructIdentifiers::eType struct_id, + const smart_objects::SmartObject& display_capabilities) = 0; }; } // namespace application_manager diff --git a/src/components/include/application_manager/policies/policy_handler_interface.h b/src/components/include/application_manager/policies/policy_handler_interface.h index f0859ece38..d48c7307b9 100644 --- a/src/components/include/application_manager/policies/policy_handler_interface.h +++ b/src/components/include/application_manager/policies/policy_handler_interface.h @@ -49,6 +49,7 @@ #include "smart_objects/smart_object.h" #include "policy/policy_types.h" #include "policy/policy_table/types.h" +#include "policy/cache_manager_interface.h" using namespace ::rpc::policy_table_interface_base; namespace policy { @@ -391,6 +392,32 @@ class PolicyHandlerInterface { mobile_apis::RequestType::eType type) const = 0; /** + * @brief Checks if certain request subtype is allowed for application + * @param policy_app_id Unique applicaion id + * @param request_subtype Request subtype + * @return true, if allowed, otherwise - false + */ + virtual bool IsRequestSubTypeAllowed( + const std::string& policy_app_id, + const std::string& request_subtype) const = 0; + + /** + * @brief Gets application request types state + * @param policy_app_id Unique application id + * @return request types state + */ + virtual RequestType::State GetAppRequestTypeState( + const std::string& policy_app_id) const = 0; + + /** + * @brief Gets application request subtypes state + * @param policy_app_id Unique application id + * @return request subtypes state + */ + virtual RequestSubType::State GetAppRequestSubTypeState( + const std::string& policy_app_id) const = 0; + + /** * @brief Gets application request types * @param policy_app_id Unique application id * @return request types @@ -399,6 +426,14 @@ class PolicyHandlerInterface { const std::string& policy_app_id) const = 0; /** + * @brief Gets application request subtypes + * @param policy_app_id Unique application id + * @return app request subtypes + */ + virtual const std::vector<std::string> GetAppRequestSubTypes( + const std::string& policy_app_id) const = 0; + + /** * @brief Gets vehicle information * @return Structure with vehicle information */ diff --git a/src/components/include/policy/policy_external/policy/policy_manager.h b/src/components/include/policy/policy_external/policy/policy_manager.h index 24905671fa..7970d525c5 100644 --- a/src/components/include/policy/policy_external/policy/policy_manager.h +++ b/src/components/include/policy/policy_external/policy/policy_manager.h @@ -41,6 +41,7 @@ #include "policy/policy_table/types.h" #include "policy/policy_listener.h" #include "policy/usage_statistics/statistics_manager.h" +#include "policy/cache_manager_interface.h" #ifdef SDL_REMOTE_CONTROL #include "policy/access_remote.h" @@ -487,6 +488,22 @@ class PolicyManager : public usage_statistics::StatisticsManager { const std::string& device_id_to) = 0; /** + * @brief Get state of request types for given application + * @param policy_app_id Unique application id + * @return request type state + */ + virtual RequestType::State GetAppRequestTypesState( + const std::string& policy_app_id) const = 0; + + /** + * @brief Get state of request subtypes for given application + * @param policy_app_id Unique application id + * @return request subtype state + */ + virtual RequestSubType::State GetAppRequestSubTypesState( + const std::string& policy_app_id) const = 0; + + /** * @brief Gets request types for application * @param policy_app_id Unique application id * @return request types of application @@ -495,6 +512,14 @@ class PolicyManager : public usage_statistics::StatisticsManager { const std::string policy_app_id) const = 0; /** + * @brief Gets request subtypes for application + * @param policy_app_id Unique application id + * @return request subtypes of application + */ + virtual const std::vector<std::string> GetAppRequestSubTypes( + const std::string& policy_app_id) const = 0; + + /** * @brief Get information about vehicle * @return vehicle information */ diff --git a/src/components/include/policy/policy_regular/policy/policy_manager.h b/src/components/include/policy/policy_regular/policy/policy_manager.h index 3e90cfc094..84d48a691e 100644 --- a/src/components/include/policy/policy_regular/policy/policy_manager.h +++ b/src/components/include/policy/policy_regular/policy/policy_manager.h @@ -41,6 +41,8 @@ #include "policy/policy_table/types.h" #include "policy/policy_listener.h" #include "policy/usage_statistics/statistics_manager.h" +#include "policy/cache_manager_interface.h" + #ifdef SDL_REMOTE_CONTROL #include "policy/access_remote.h" #endif // SDL_REMOTE_CONTROL @@ -466,6 +468,22 @@ class PolicyManager : public usage_statistics::StatisticsManager { virtual void OnAppsSearchCompleted(const bool trigger_ptu) = 0; /** + * @brief Get state of request types for given application + * @param policy_app_id Unique application id + * @return request type state + */ + virtual RequestType::State GetAppRequestTypesState( + const std::string& policy_app_id) const = 0; + + /** + * @brief Get state of request subtypes for given application + * @param policy_app_id Unique application id + * @return request subtype state + */ + virtual RequestSubType::State GetAppRequestSubTypesState( + const std::string& policy_app_id) const = 0; + + /** * @brief Gets request types for application * @param policy_app_id Unique application id * @return request types of application @@ -474,6 +492,14 @@ class PolicyManager : public usage_statistics::StatisticsManager { const std::string policy_app_id) const = 0; /** + * @brief Gets request subtypes for application + * @param policy_app_id Unique application id + * @return request subtypes of application + */ + virtual const std::vector<std::string> GetAppRequestSubTypes( + const std::string& policy_app_id) const = 0; + + /** * @brief Get information about vehicle * @return vehicle information */ diff --git a/src/components/include/test/application_manager/mock_application_manager.h b/src/components/include/test/application_manager/mock_application_manager.h index d1caf344f4..bc1c0d08d2 100644 --- a/src/components/include/test/application_manager/mock_application_manager.h +++ b/src/components/include/test/application_manager/mock_application_manager.h @@ -274,6 +274,10 @@ class MockApplicationManager : public application_manager::ApplicationManager { MOCK_METHOD0(event_dispatcher, application_manager::event_engine::EventDispatcher&()); + MOCK_METHOD2(IsSOStructValid, + bool(const hmi_apis::StructIdentifiers::eType struct_id, + const smart_objects::SmartObject& display_capabilities)); + DEPRECATED MOCK_CONST_METHOD1(IsAppSubscribedForWayPoints, bool(const uint32_t)); DEPRECATED MOCK_METHOD1(SubscribeAppForWayPoints, void(const uint32_t)); diff --git a/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h b/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h index 931fd6cfb4..dfd537c678 100644 --- a/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h +++ b/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h @@ -197,6 +197,18 @@ class MockPolicyHandlerInterface : public policy::PolicyHandlerInterface { MOCK_CONST_METHOD2(IsRequestTypeAllowed, bool(const std::string& policy_app_id, mobile_apis::RequestType::eType type)); + MOCK_CONST_METHOD2(IsRequestSubTypeAllowed, + bool(const std::string& policy_app_id, + const std::string& request_subtype)); + MOCK_CONST_METHOD1( + GetAppRequestTypeState, + policy::RequestType::State(const std::string& policy_app_id)); + MOCK_CONST_METHOD1( + GetAppRequestSubTypeState, + policy::RequestSubType::State(const std::string& policy_app_id)); + MOCK_CONST_METHOD1( + GetAppRequestSubTypes, + const std::vector<std::string>(const std::string& policy_app_id)); MOCK_CONST_METHOD1( GetAppRequestTypes, const std::vector<std::string>(const std::string& policy_app_id)); diff --git a/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h b/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h index 5aa92446b6..02931114f0 100644 --- a/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h +++ b/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h @@ -250,6 +250,13 @@ class MockCacheManagerInterface : public ::policy::CacheManagerInterface { MOCK_METHOD2(OnDeviceSwitching, void(const std::string& device_id_from, const std::string& device_id_to)); + MOCK_CONST_METHOD2(GetAppRequestSubTypes, + void(const std::string& policy_app_id, + std::vector<std::string>& request_subtypes)); + MOCK_CONST_METHOD1(GetAppRequestTypesState, + RequestType::State(const std::string& policy_app_id)); + MOCK_CONST_METHOD1(GetAppRequestSubTypesState, + RequestSubType::State(const std::string& policy_app_id)); }; } // namespace policy_test diff --git a/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h b/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h index 9e487da4ba..96e484acae 100644 --- a/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h +++ b/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h @@ -218,6 +218,13 @@ class MockPolicyManager : public PolicyManager { MOCK_METHOD2(OnDeviceSwitching, void(const std::string& device_id_from, const std::string& device_id_to)); + MOCK_CONST_METHOD1( + GetAppRequestSubTypes, + const std::vector<std::string>(const std::string& policy_app_id)); + MOCK_CONST_METHOD1(GetAppRequestTypesState, + RequestType::State(const std::string& policy_app_id)); + MOCK_CONST_METHOD1(GetAppRequestSubTypesState, + RequestSubType::State(const std::string& policy_app_id)); }; } // namespace policy_manager_test } // namespace components diff --git a/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h b/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h index ed3a5088c1..cf20dcb666 100644 --- a/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h +++ b/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h @@ -214,6 +214,13 @@ class MockCacheManagerInterface : public CacheManagerInterface { MOCK_METHOD2(OnDeviceSwitching, void(const std::string& device_id_from, const std::string& device_id_to)); + MOCK_CONST_METHOD2(GetAppRequestSubTypes, + void(const std::string& policy_app_id, + std::vector<std::string>& request_subtypes)); + MOCK_CONST_METHOD1(GetAppRequestTypesState, + RequestType::State(const std::string& policy_app_id)); + MOCK_CONST_METHOD1(GetAppRequestSubTypesState, + RequestSubType::State(const std::string& policy_app_id)); }; } // namespace policy_test diff --git a/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h b/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h index 82012b83c7..0b8823d307 100644 --- a/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h +++ b/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h @@ -226,6 +226,14 @@ class MockPolicyManager : public PolicyManager { MOCK_METHOD2(OnDeviceSwitching, void(const std::string& device_id_from, const std::string& device_id_to)); + + MOCK_CONST_METHOD1( + GetAppRequestSubTypes, + const std::vector<std::string>(const std::string& policy_app_id)); + MOCK_CONST_METHOD1(GetAppRequestTypesState, + RequestType::State(const std::string& policy_app_id)); + MOCK_CONST_METHOD1(GetAppRequestSubTypesState, + RequestSubType::State(const std::string& policy_app_id)); }; } // namespace policy_manager_test diff --git a/src/components/interfaces/HMI_API.xml b/src/components/interfaces/HMI_API.xml index ab3933fc0f..def5d22933 100644 --- a/src/components/interfaces/HMI_API.xml +++ b/src/components/interfaces/HMI_API.xml @@ -624,7 +624,10 @@ <description>The image field for the app icon (set by setAppIcon)</description> </element> <element name="graphic"> - <description>The image field for Show</description> + <description>The primary image field for Show</description> + </element> + <element name="secondaryGraphic"> + <description>The secondary image field for Show</description> </element> <element name="showConstantTBTIcon"> <description>The primary image field for ShowConstantTBT</description> @@ -726,6 +729,36 @@ </enum> <!--IVI part--> +<enum name="FuelType"> + <element name="GASOLINE" /> + <element name="DIESEL" /> + <element name="CNG"> + <description> + For vehicles using compressed natural gas. + </description> + </element> + <element name="LPG"> + <description> + For vehicles using liquefied petroleum gas. + </description> + </element> + <element name="HYDROGEN"> + <description>For FCEV (fuel cell electric vehicle).</description> + </element> + <element name="BATTERY"> + <description>For BEV (Battery Electric Vehicle), PHEV (Plug-in Hybrid Electric Vehicle), solar vehicles and other vehicles which run on a battery.</description> + </element> +</enum> + +<struct name="FuelRange"> + <param name="type" type="Common.FuelType" mandatory="false"/> + <param name="range" type="Float" minvalue="0" maxvalue="10000" mandatory="false"> + <description> + The estimate range in KM the vehicle can travel based on fuel level and consumption. + </description> + </param> +</struct> + <enum name="ComponentVolumeStatus"> <description>The volume status of a vehicle component.</description> <element name="UNKNOWN" internal_name="CVS_UNKNOWN"> @@ -748,6 +781,33 @@ </element> </enum> +<enum name="TPMS"> + <element name="UNKNOWN"> + <description>If set the status of the tire is not known.</description> + </element> + <element name="SYSTEM_FAULT"> + <description>TPMS does not function.</description> + </element> + <element name="SENSOR_FAULT"> + <description>The sensor of the tire does not function.</description> + </element> + <element name="LOW"> + <description>TPMS is reporting a low tire pressure for the tire.</description> + </element> + <element name="SYSTEM_ACTIVE"> + <description>TPMS is active and the tire pressure is monitored.</description> + </element> + <element name="TRAIN"> + <description>TPMS is reporting that the tire must be trained.</description> + </element> + <element name="TRAINING_COMPLETE"> + <description>TPMS reports the training for the tire is completed.</description> + </element> + <element name="NOT_TRAINED"> + <description>TPMS reports the tire is not trained.</description> + </element> +</enum> + <enum name="PRNDL"> <description>The selected gear.</description> <element name="PARK"> @@ -978,6 +1038,8 @@ <element name="VEHICLEDATA_ENGINETORQUE" /> <element name="VEHICLEDATA_ACCPEDAL" /> <element name="VEHICLEDATA_STEERINGWHEEL" /> + <element name="VEHICLEDATA_FUELRANGE" /> + <element name="VEHICLEDATA_ENGINEOILLIFE" /> </enum> <enum name="WiperStatus"> @@ -1102,13 +1164,13 @@ </enum> <enum name="RequestType"> - <description>Enumeration listing possible asynchronous requests.</description> - <element name="HTTP" /> - <element name="FILE_RESUME" /> - <element name="AUTH_REQUEST" /> - <element name="AUTH_CHALLENGE" /> - <element name="AUTH_ACK" /> - <element name="PROPRIETARY" /> + <description>Enumeration listing possible asynchronous requests.</description> + <element name="HTTP" /> + <element name="FILE_RESUME" /> + <element name="AUTH_REQUEST" /> + <element name="AUTH_CHALLENGE" /> + <element name="AUTH_ACK" /> + <element name="PROPRIETARY" /> <element name="QUERY_APPS" /> <element name="LAUNCH_APP" /> <element name="LOCK_SCREEN_ICON_URL" /> @@ -1123,6 +1185,7 @@ <element name="EMERGENCY" /> <element name="MEDIA" /> <element name="FOTA" /> + <element name="OEM_SPECIFIC"/> </enum> <enum name="ECallConfirmationStatus"> @@ -1821,6 +1884,9 @@ <param name="imageType" type="Common.ImageType" mandatory="true"> <description>Describes, whether it is a static or dynamic image.</description> </param> + <param name="isTemplate" type="Boolean" mandatory="false"> + <description>Optional value to specify whether it's a template image. A template image can be (re)colored by the HMI as needed by using an image pattern</description> + </param> </struct> <struct name="DeviceInfo"> @@ -1870,6 +1936,27 @@ </param> </struct> +<struct name="RGBColor"> + <param name="red" type="Integer" minvalue="0" maxvalue="255" mandatory="true" /> + <param name="green" type="Integer" minvalue="0" maxvalue="255" mandatory="true" /> + <param name="blue" type="Integer" minvalue="0" maxvalue="255" mandatory="true" /> +</struct> + +<struct name="TemplateColorScheme"> + <description> + A color scheme for all display layout templates. + </description> + <param name="primaryColor" type="Common.RGBColor" mandatory="false"> + <description>The primary "accent" color</description> + </param> + <param name="secondaryColor" type="Common.RGBColor" mandatory="false"> + <description>The secondary "accent" color</description> + </param> + <param name="backgroundColor" type="Common.RGBColor" mandatory="false"> + <description>The color of the background</description> + </param> +</struct> + <struct name="HMIApplication"> <description>Data type containing information about application needed by HMI.</description> <param name="appName" type="String" maxlength="100" mandatory="true"> @@ -1927,6 +2014,16 @@ <description>If SDL omits this parameter - none RequestType is allowed for this app</description> <description>(either this is a pre-registered app or such is dictated by policies).</description> </param> + <param name="requestSubType" type="String" maxlength="100" minsize="0" maxsize="100" array="true" mandatory="false"> + <description> + The list of SystemRequest's requestSubTypes allowed by policies for the named application. + If the app sends a requestSubType which is not specified in this list, then that request should be rejected. + An empty array signifies that any value of requestSubType is allowed for this app. + If this parameter is omitted, then a request with any value of requestSubType is now allowed for this app + </description> + </param> + <param name="dayColorScheme" type="Common.TemplateColorScheme" mandatory="false"></param> + <param name="nightColorScheme" type="Common.TemplateColorScheme" mandatory="false"></param> </struct> <struct name="MenuParams"> @@ -2059,6 +2156,9 @@ <param name="displayType" type="Common.DisplayType" mandatory="true"> <description>The type of the display. See DisplayType</description> </param> + <param name="displayName" type="String" mandatory="false"> + <description>The name of the display the app is connected to.</description> + </param> <param name="textFields" type="Common.TextField" minsize="0" maxsize="100" array="true" mandatory="true"> <description>A set of all fields for text displaying supported by HU. See TextFieldName.</description> <description>If there are no textfields supported, the empty array must be returned</description> @@ -2253,7 +2353,13 @@ <struct name="SingleTireStatus"> <param name="status" type="Common.ComponentVolumeStatus" mandatory="true"> <description>The status of component volume. See ComponentVolumeStatus.</description> -</param> + </param> + <param name="tpms" type="TPMS" mandatory="false"> + <description>The status of TPMS according to the particular tire.</description> + </param> + <param name="pressure" type="Float" mandatory="false" minvalue="0" maxvalue="2000"> + <description>The pressure value of the particular tire in kilo pascal.</description> + </param> </struct> <struct name="DIDResult"> @@ -2928,6 +3034,11 @@ <param name="requestType" type="Common.RequestType" mandatory="true"> <description>The type of system request.</description> </param> + <param name="requestSubType" type="String" maxlength="255" mandatory="false"> + <description> + This parameter is filled for supporting OEM proprietary data exchanges. + </description> + </param> <param name="url" type="String" maxlength="1000" minlength="1" mandatory="false"> <description>Optional array of URL(s) for HTTP requests.</description> </param> @@ -2954,6 +3065,11 @@ <param name="requestType" type="Common.RequestType" mandatory="true"> <description>The type of system request.</description> </param> + <param name="requestSubType" type="String" maxlength="255" mandatory="false"> + <description> + This parameter is filled for supporting OEM proprietary data exchanges. + </description> + </param> <param name="fileName" type="String" maxlength="255" minlength="1" mandatory="true"> <description>The path to file.</description> </param> @@ -3670,6 +3786,8 @@ <param name="appID" type="Integer" mandatory="true"> <description>ID of application related to this RPC.</description> </param> + <param name="dayColorScheme" type="Common.TemplateColorScheme" mandatory="false"></param> + <param name="nightColorScheme" type="Common.TemplateColorScheme" mandatory="false"></param> </function> <function name="SetDisplayLayout" messagetype="response"> <param name="displayCapabilities" type="Common.DisplayCapabilities" mandatory="false"> @@ -4195,6 +4313,9 @@ <param name="instantFuelConsumption" type="Boolean" mandatory="false"> <description>The instantaneous fuel consumption in microlitres</description> </param> + <param name="fuelRange" type="Boolean" mandatory="false"> + <description>The estimate range in KM the vehicle can travel based on fuel level and consumption</description> + </param> <param name="externalTemperature" type="Boolean" mandatory="false"> <description>The external temperature in degrees celsius</description> </param> @@ -4234,6 +4355,9 @@ <param name="steeringWheelAngle" type="Boolean" mandatory="false"> <description>Current angle of the steering wheel (in deg)</description> </param> + <param name="engineOilLife" type="Boolean" mandatory="false"> + <description>The estimated percentage of remaining oil life of the engine.</description> + </param> <!-- Ford Specific Data Items --> <param name="eCallInfo" type="Boolean" mandatory="false"> <description>Emergency Call notification and confirmation data</description> @@ -4271,6 +4395,9 @@ <param name="instantFuelConsumption" type="Common.VehicleDataResult" mandatory="false"> <description>The instantaneous fuel consumption in microlitres</description> </param> + <param name="fuelRange" type="Common.VehicleDataResult" mandatory="false"> + <description>The estimate range in KM the vehicle can travel based on fuel level and consumption</description> + </param> <param name="externalTemperature" type="Common.VehicleDataResult" mandatory="false"> <description>The external temperature in degrees celsius.</description> </param> @@ -4310,6 +4437,9 @@ <param name="steeringWheelAngle" type="Common.VehicleDataResult" mandatory="false"> <description>Current angle of the steering wheel (in deg)</description> </param> + <param name="engineOilLife" type="Common.VehicleDataResult" mandatory="false"> + <description>The estimated percentage of remaining oil life of the engine.</description> + </param> <!-- Ford Specific Data Items --> <param name="eCallInfo" type="Common.VehicleDataResult" mandatory="false"> <description>Emergency Call notification and confirmation data</description> @@ -4353,6 +4483,9 @@ <param name="instantFuelConsumption" type="Boolean" mandatory="false"> <description>The instantaneous fuel consumption in microlitres</description> </param> + <param name="fuelRange" type="Boolean" mandatory="false"> + <description>The estimate range in KM the vehicle can travel based on fuel level and consumption</description> + </param> <param name="externalTemperature" type="Boolean" mandatory="false"> <description>The external temperature in degrees celsius.</description> </param> @@ -4392,6 +4525,9 @@ <param name="steeringWheelAngle" type="Boolean" mandatory="false"> <description>Current angle of the steering wheel (in deg)</description> </param> + <param name="engineOilLife" type="Boolean" mandatory="false"> + <description>The estimated percentage of remaining oil life of the engine.</description> + </param> <!-- Ford Specific Data Items --> <param name="eCallInfo" type="Boolean" mandatory="false"> <description>Emergency Call notification and confirmation data</description> @@ -4429,6 +4565,9 @@ <param name="instantFuelConsumption" type="Common.VehicleDataResult" mandatory="false"> <description>The instantaneous fuel consumption in microlitres</description> </param> + <param name="fuelRange" type="Common.VehicleDataResult" mandatory="false"> + <description>The estimate range in KM the vehicle can travel based on fuel level and consumption</description> + </param> <param name="externalTemperature" type="Common.VehicleDataResult" mandatory="false"> <description>The external temperature in degrees celsius</description> </param> @@ -4468,6 +4607,9 @@ <param name="steeringWheelAngle" type="Common.VehicleDataResult" mandatory="false"> <description>Current angle of the steering wheel (in deg)</description> </param> + <param name="engineOilLife" type="Common.VehicleDataResult" mandatory="false"> + <description>The estimated percentage of remaining oil life of the engine.</description> + </param> <!-- Ford Specific Data Items --> <param name="eCallInfo" type="Common.VehicleDataResult" mandatory="false"> <description>Emergency Call notification and confirmation data</description> @@ -4506,6 +4648,9 @@ <param name="instantFuelConsumption" type="Boolean" mandatory="false"> <description>The instantaneous fuel consumption in microlitres</description> </param> + <param name="fuelRange" type="Boolean" mandatory="false"> + <description>The estimate range in KM the vehicle can travel based on fuel level and consumption</description> + </param> <param name="externalTemperature" type="Boolean" mandatory="false"> <description>The external temperature in degrees celsius</description> </param> @@ -4548,6 +4693,9 @@ <param name="steeringWheelAngle" type="Boolean" mandatory="false"> <description>Current angle of the steering wheel (in deg)</description> </param> + <param name="engineOilLife" type="Boolean" mandatory="false"> + <description>The estimated percentage of remaining oil life of the engine.</description> + </param> <param name="eCallInfo" type="Boolean" mandatory="false"> <description>Emergency Call notification and confirmation data</description> </param> @@ -4583,6 +4731,9 @@ <param name="instantFuelConsumption" type="Float" minvalue="0" maxvalue="25575" mandatory="false"> <description>The instantaneous fuel consumption in microlitres</description> </param> + <param name="fuelRange" type="Common.FuelRange" minsize="0" maxsize="100" array="true" mandatory="false"> + <description>The estimate range in KM the vehicle can travel based on fuel level and consumption</description> + </param> <param name="externalTemperature" type="Float" minvalue="-40" maxvalue="100" mandatory="false"> <description>The external temperature in degrees celsius</description> </param> @@ -4625,6 +4776,9 @@ <param name="steeringWheelAngle" type="Float" minvalue="-2000" maxvalue="2000" mandatory="false"> <description>Current angle of the steering wheel (in deg)</description> </param> + <param name="engineOilLife" type="Float" minvalue="0" maxvalue="100" mandatory="false"> + <description>The estimated percentage of remaining oil life of the engine.</description> + </param> <param name="eCallInfo" type="Common.ECallInfo" mandatory="false"> <description>Emergency Call notification and confirmation data</description> </param> @@ -4661,6 +4815,9 @@ <param name="instantFuelConsumption" type="Float" minvalue="0" maxvalue="25575" mandatory="false"> <description>The instantaneous fuel consumption in microlitres</description> </param> + <param name="fuelRange" type="Common.FuelRange" minsize="0" maxsize="100" array="true" mandatory="false"> + <description>The estimate range in KM the vehicle can travel based on fuel level and consumption</description> + </param> <param name="externalTemperature" type="Float" minvalue="-40" maxvalue="100" mandatory="false"> <description>The external temperature in degrees celsius</description> </param> @@ -4838,6 +4995,14 @@ If SDL omits this parameter - nothing is changed for RequestType in the policies </description> </param> + <param name="requestSubType" type="String" maxlength="100" minsize="0" maxsize="100" array="true" mandatory="false"> + <description> + The list of SystemRequest's requestSubTypes allowed by policies for the named application. + If the app sends a requestSubType which is not specified in this list, then that request should be rejected. + An empty array signifies that any value of requestSubType is allowed for this app. + If this parameter is omitted, then a request with any value of requestSubType is now allowed for this app + </description> + </param> </function> <function name="OnSDLConsentNeeded" messagetype="notification"> diff --git a/src/components/interfaces/MOBILE_API.xml b/src/components/interfaces/MOBILE_API.xml index cfc7346db2..a5504916ba 100644 --- a/src/components/interfaces/MOBILE_API.xml +++ b/src/components/interfaces/MOBILE_API.xml @@ -135,6 +135,9 @@ <element name="READ_ONLY"> <description>The value being set is read only</description> </element> + <element name="CORRUPTED_DATA"> + <description>The data sent failed to pass CRC check in receiver end</description> + </element> </enum> <enum name="ButtonPressMode"> @@ -519,6 +522,8 @@ <element name="VEHICLEDATA_ENGINETORQUE" /> <element name="VEHICLEDATA_ACCPEDAL" /> <element name="VEHICLEDATA_STEERINGWHEEL" /> + <element name="VEHICLEDATA_FUELRANGE" /> + <element name="VEHICLEDATA_ENGINEOILLIFE" /> </enum> <enum name="ButtonName"> @@ -787,7 +792,11 @@ </element> <element name="graphic"> - <description>The image field for Show</description> + <description>The primary image field for Show</description> + </element> + + <element name="secondaryGraphic"> + <description>The secondary image field for Show</description> </element> <element name="showConstantTBTIcon"> @@ -905,6 +914,9 @@ <param name="imageType" type="ImageType" mandatory="true"> <description>Describes, whether it is a static or dynamic image.</description> </param> + <param name="isTemplate" type="Boolean" mandatory="false"> + <description>Optional value to specify whether it's a template image. A template image can be (re)colored by the HMI as needed by using an image pattern</description> + </param> </struct> <struct name="SoftButton"> @@ -1088,11 +1100,74 @@ <element name="NOT_SUPPORTED" internal_name="CVS_NOT_SUPPORTED"> </element> </enum> + + <enum name="TPMS"> + <element name="UNKNOWN"> + <description>If set the status of the tire is not known.</description> + </element> + <element name="SYSTEM_FAULT"> + <description>TPMS does not function.</description> + </element> + <element name="SENSOR_FAULT"> + <description>The sensor of the tire does not function.</description> + </element> + <element name="LOW"> + <description>TPMS is reporting a low tire pressure for the tire.</description> + </element> + <element name="SYSTEM_ACTIVE"> + <description>TPMS is active and the tire pressure is monitored.</description> + </element> + <element name="TRAIN"> + <description>TPMS is reporting that the tire must be trained.</description> + </element> + <element name="TRAINING_COMPLETE"> + <description>TPMS reports the training for the tire is completed.</description> + </element> + <element name="NOT_TRAINED"> + <description>TPMS reports the tire is not trained.</description> + </element> + </enum> + <enum name="FuelType"> + <element name="GASOLINE" /> + <element name="DIESEL" /> + <element name="CNG"> + <description> + For vehicles using compressed natural gas. + </description> + </element> + <element name="LPG"> + <description> + For vehicles using liquefied petroleum gas. + </description> + </element> + <element name="HYDROGEN"> + <description>For FCEV (fuel cell electric vehicle).</description> + </element> + <element name="BATTERY"> + <description>For BEV (Battery Electric Vehicle), PHEV (Plug-in Hybrid Electric Vehicle), solar vehicles and other vehicles which run on a battery.</description> + </element> + </enum> + + <struct name="FuelRange"> + <param name="type" type="FuelType" mandatory="false"/> + <param name="range" type="Float" minvalue="0" maxvalue="10000" mandatory="false"> + <description> + The estimate range in KM the vehicle can travel based on fuel level and consumption. + </description> + </param> + </struct> + <struct name="SingleTireStatus"> <param name="status" type="ComponentVolumeStatus" mandatory="true"> <description>See ComponentVolumeStatus.</description> </param> + <param name="tpms" type="TPMS" mandatory="false"> + <description>The status of TPMS according to the particular tire.</description> + </param> + <param name="pressure" type="Float" mandatory="false" minvalue="0" maxvalue="2000"> + <description>The pressure value of the particular tire in kilo pascal.</description> + </param> </struct> <enum name="WarningLightStatus"> @@ -1910,6 +1985,9 @@ <param name="displayType" type="DisplayType" mandatory="true"> <description>The type of the display. See DisplayType</description> </param> + <param name="displayName" type="String" mandatory="false"> + <description>The name of the display the app is connected to.</description> + </param> <param name="textFields" type="TextField" minsize="1" maxsize="100" array="true" mandatory="true"> <description>A set of all fields that support text data. See TextField</description> </param> @@ -2150,6 +2228,7 @@ <element name="EMERGENCY" /> <element name="MEDIA" /> <element name="FOTA" /> + <element name="OEM_SPECIFIC" /> </enum> <enum name="AppHMIType"> <description>Enumeration listing possible app types.</description> @@ -2893,7 +2972,27 @@ <description>The position of the haptic rectangle to be highlighted. The center of this rectangle will be "touched" when a press occurs.</description> </param> </struct> - + + <struct name="RGBColor"> + <param name="red" type="Integer" minvalue="0" maxvalue="255" mandatory="true" /> + <param name="green" type="Integer" minvalue="0" maxvalue="255" mandatory="true" /> + <param name="blue" type="Integer" minvalue="0" maxvalue="255" mandatory="true" /> + </struct> + + <struct name="TemplateColorScheme"> + <description> + A color scheme for all display layout templates. + </description> + <param name="primaryColor" type="RGBColor" mandatory="false"> + <description>The primary "accent" color</description> + </param> + <param name="secondaryColor" type="RGBColor" mandatory="false"> + <description>The secondary "accent" color</description> + </param> + <param name="backgroundColor" type="RGBColor" mandatory="false"> + <description>The color of the background</description> + </param> + </struct> <!-- Requests/Responses --> <function name="RegisterAppInterface" functionID="RegisterAppInterfaceID" messagetype="request"> @@ -2994,6 +3093,10 @@ See AppInfo. </description> </param> + + <param name="dayColorScheme" type="TemplateColorScheme" mandatory="false"/> + + <param name="nightColorScheme" type="TemplateColorScheme" mandatory="false"/> </function> <function name="RegisterAppInterface" functionID="RegisterAppInterfaceID" messagetype="response"> @@ -3096,6 +3199,10 @@ <param name="systemSoftwareVersion" type="String" maxlength="100" mandatory="false" platform="documentation"> <description>The software version of the system that implements the SmartDeviceLink core.</description> </param> + <param name="iconResumed" type="Boolean" mandatory="true"> + <description>Existence of apps icon at system. If true, apps icon + was resumed at system. If false, apps icon is not resumed at system</description> + </param> </function> <function name="UnregisterAppInterface" functionID="UnregisterAppInterfaceID" messagetype="request"> @@ -4062,6 +4169,9 @@ <param name="instantFuelConsumption" type="Boolean" mandatory="false"> <description>The instantaneous fuel consumption in microlitres</description> </param> + <param name="fuelRange" type="Boolean" mandatory="false"> + <description>The estimate range in KM the vehicle can travel based on fuel level and consumption</description> + </param> <param name="externalTemperature" type="Boolean" mandatory="false"> <description>The external temperature in degrees celsius</description> </param> @@ -4101,6 +4211,9 @@ <param name="steeringWheelAngle" type="Boolean" mandatory="false"> <description>Current angle of the steering wheel (in deg)</description> </param> + <param name="engineOilLife" type="Boolean" mandatory="false"> + <description>The estimated percentage of remaining oil life of the engine.</description> + </param> <!-- Ford Specific Data Items --> <param name="eCallInfo" type="Boolean" mandatory="false"> @@ -4165,6 +4278,9 @@ <param name="instantFuelConsumption" type="VehicleDataResult" mandatory="false"> <description>The instantaneous fuel consumption in microlitres</description> </param> + <param name="fuelRange" type="VehicleDataResult" mandatory="false"> + <description>The estimate range in KM the vehicle can travel based on fuel level and consumption</description> + </param> <param name="externalTemperature" type="VehicleDataResult" mandatory="false"> <description>The external temperature in degrees celsius.</description> </param> @@ -4204,6 +4320,9 @@ <param name="steeringWheelAngle" type="VehicleDataResult" mandatory="false"> <description>Current angle of the steering wheel (in deg)</description> </param> + <param name="engineOilLife" type="VehicleDataResult" mandatory="false"> + <description>The estimated percentage of remaining oil life of the engine.</description> + </param> <!-- Ford Specific Data Items --> <param name="eCallInfo" type="VehicleDataResult" mandatory="false"> @@ -4246,6 +4365,9 @@ <param name="instantFuelConsumption" type="Boolean" mandatory="false"> <description>The instantaneous fuel consumption in microlitres</description> </param> + <param name="fuelRange" type="Boolean" mandatory="false"> + <description>The estimate range in KM the vehicle can travel based on fuel level and consumption</description> + </param> <param name="externalTemperature" type="Boolean" mandatory="false"> <description>The external temperature in degrees celsius.</description> </param> @@ -4285,6 +4407,9 @@ <param name="steeringWheelAngle" type="Boolean" mandatory="false"> <description>Current angle of the steering wheel (in deg)</description> </param> + <param name="engineOilLife" type="Boolean" mandatory="false"> + <description>The estimated percentage of remaining oil life of the engine.</description> + </param> <!-- Ford Specific Data Items --> <param name="eCallInfo" type="Boolean" mandatory="false"> @@ -4347,6 +4472,9 @@ <param name="instantFuelConsumption" type="VehicleDataResult" mandatory="false"> <description>The instantaneous fuel consumption in microlitres</description> </param> + <param name="fuelRange" type="VehicleDataResult" mandatory="false"> + <description>The estimate range in KM the vehicle can travel based on fuel level and consumption</description> + </param> <param name="externalTemperature" type="VehicleDataResult" mandatory="false"> <description>The external temperature in degrees celsius</description> </param> @@ -4386,6 +4514,9 @@ <param name="steeringWheelAngle" type="VehicleDataResult" mandatory="false"> <description>Current angle of the steering wheel (in deg)</description> </param> + <param name="engineOilLife" type="VehicleDataResult" mandatory="false"> + <description>The estimated percentage of remaining oil life of the engine.</description> + </param> <!-- Ford Specific Data Items --> <param name="eCallInfo" type="VehicleDataResult" mandatory="false"> @@ -4428,6 +4559,9 @@ <param name="instantFuelConsumption" type="Boolean" mandatory="false"> <description>The instantaneous fuel consumption in microlitres</description> </param> + <param name="fuelRange" type="Boolean" mandatory="false"> + <description>The estimate range in KM the vehicle can travel based on fuel level and consumption</description> + </param> <param name="externalTemperature" type="Boolean" mandatory="false"> <description>The external temperature in degrees celsius</description> </param> @@ -4470,6 +4604,9 @@ <param name="steeringWheelAngle" type="Boolean" mandatory="false"> <description>Current angle of the steering wheel (in deg)</description> </param> + <param name="engineOilLife" type="Boolean" mandatory="false"> + <description>The estimated percentage of remaining oil life of the engine.</description> + </param> <!-- Ford Specific Data Items --> <param name="eCallInfo" type="Boolean" mandatory="false"> @@ -4533,6 +4670,9 @@ <param name="instantFuelConsumption" type="Float" minvalue="0" maxvalue="25575" mandatory="false"> <description>The instantaneous fuel consumption in microlitres</description> </param> + <param name="fuelRange" type="FuelRange" minsize="0" maxsize="100" array="true" mandatory="false"> + <description>The estimate range in KM the vehicle can travel based on fuel level and consumption</description> + </param> <param name="externalTemperature" type="Float" minvalue="-40" maxvalue="100" mandatory="false"> <description>The external temperature in degrees celsius</description> </param> @@ -4575,6 +4715,9 @@ <param name="steeringWheelAngle" type="Float" minvalue="-2000" maxvalue="2000" mandatory="false"> <description>Current angle of the steering wheel (in deg)</description> </param> + <param name="engineOilLife" type="Float" minvalue="0" maxvalue="100" mandatory="false"> + <description>The estimated percentage of remaining oil life of the engine.</description> + </param> <!-- Ford Specific Data Items --> <param name="eCallInfo" type="ECallInfo" mandatory="false"> @@ -5079,6 +5222,9 @@ If offset is set to 0, then length is the total length of the file to be downloaded </description> </param> + <param name="crc" type="Integer" minvalue="0" maxvalue="4294967295" mandatory="false"> + <description> Additional CRC32 checksum to protect data integrity up to 512 Mbits . </description> + </param> </function> <function name="PutFile" functionID="PutFileID" messagetype="response"> @@ -5098,6 +5244,7 @@ <element name="GENERIC_ERROR"/> <element name="REJECTED"/> <element name="UNSUPPORTED_REQUEST"/> + <element name="CORRUPTED_DATA"/> </param> <param name="spaceAvailable" type="Integer" minvalue="0" maxvalue="2000000000" mandatory="true"> @@ -5251,6 +5398,9 @@ </description> </param> + <param name="dayColorScheme" type="TemplateColorScheme" mandatory="false"/> + + <param name="nightColorScheme" type="TemplateColorScheme" mandatory="false"/> </function> <function name="SetDisplayLayout" functionID="SetDisplayLayoutID" messagetype="response"> @@ -5301,6 +5451,11 @@ Note that Proprietary requests should forward the binary data to the known proprietary module on the system. </description> </param> + <param name="requestSubType" type="String" maxlength="255" mandatory="false"> + <description> + This parameter is filled for supporting OEM proprietary data exchanges. + </description> + </param> <param name="fileName" type="String" maxlength="255" mandatory="false"> <description> Filename of HTTP data to store in predefined system staging area. @@ -5754,6 +5909,9 @@ <param name="instantFuelConsumption" type="Float" minvalue="0" maxvalue="25575" mandatory="false"> <description>The instantaneous fuel consumption in microlitres</description> </param> + <param name="fuelRange" type="FuelRange" minsize="0" maxsize="100" array="true" mandatory="false"> + <description>The estimate range in KM the vehicle can travel based on fuel level and consumption</description> + </param> <param name="externalTemperature" type="Float" minvalue="-40" maxvalue="100" mandatory="false"> <description>The external temperature in degrees celsius</description> </param> @@ -5796,6 +5954,9 @@ <param name="steeringWheelAngle" type="Float" minvalue="-2000" maxvalue="2000" mandatory="false"> <description>Current angle of the steering wheel (in deg)</description> </param> + <param name="engineOilLife" type="Float" minvalue="0" maxvalue="100" mandatory="false"> + <description>The estimated percentage of remaining oil life of the engine.</description> + </param> <!-- Ford Specific Vehicle Data --> <param name="eCallInfo" type="ECallInfo" mandatory="false"> @@ -5897,6 +6058,11 @@ <param name="requestType" type="RequestType" mandatory="true"> <description>The type of system request.</description> </param> + <param name="requestSubType" type="String" maxlength="255" mandatory="false"> + <description> + This parameter is filled for supporting OEM proprietary data exchanges. + </description> + </param> <param name="url" type="String" maxlength="1000" mandatory="false"> <description> Optional URL for HTTP requests. diff --git a/src/components/policy/policy_external/include/policy/cache_manager.h b/src/components/policy/policy_external/include/policy/cache_manager.h index bda456c90a..f41ddb14cd 100644 --- a/src/components/policy/policy_external/include/policy/cache_manager.h +++ b/src/components/policy/policy_external/include/policy/cache_manager.h @@ -84,6 +84,22 @@ class CacheManager : public CacheManagerInterface { CheckPermissionResult& result); /** + * @brief Get state of request types for given application + * @param policy_app_id Unique application id + * @return request type state + */ + RequestType::State GetAppRequestTypesState( + const std::string& policy_app_id) const OVERRIDE; + + /** + * @brief Get state of request subtypes for given application + * @param policy_app_id Unique application id + * @return request subtype state + */ + RequestSubType::State GetAppRequestSubTypesState( + const std::string& policy_app_id) const OVERRIDE; + + /** * @brief Returns true if Policy Table was not updated yet * from preloaded pt file. */ @@ -642,8 +658,18 @@ class CacheManager : public CacheManagerInterface { * @param policy_app_id Unique application id * @param request_types Request types of application */ - void GetAppRequestTypes(const std::string& policy_app_id, - std::vector<std::string>& request_types) const; + void GetAppRequestTypes( + const std::string& policy_app_id, + std::vector<std::string>& request_types) const OVERRIDE; + + /** + * @brief Gets request subtypes for application + * @param policy_app_id Unique application id + * @param request_subtypes Request subtypes of application to be filled + */ + void GetAppRequestSubTypes( + const std::string& policy_app_id, + std::vector<std::string>& request_subtypes) const OVERRIDE; virtual const MetaInfo GetMetaInfo() const OVERRIDE; diff --git a/src/components/policy/policy_external/include/policy/cache_manager_interface.h b/src/components/policy/policy_external/include/policy/cache_manager_interface.h index b9e9f73646..1d74780f19 100644 --- a/src/components/policy/policy_external/include/policy/cache_manager_interface.h +++ b/src/components/policy/policy_external/include/policy/cache_manager_interface.h @@ -47,6 +47,16 @@ namespace policy_table = rpc::policy_table_interface_base; namespace policy { +namespace RequestType { +// Describes available RequestType states in policy table +enum class State { UNAVAILABLE = 0, AVAILABLE, EMPTY, OMITTED }; +} // namespace RequestType + +namespace RequestSubType { +// Describes available RequestSubType states in policy table +enum class State { UNAVAILABLE = 0, AVAILABLE, EMPTY, OMITTED }; +} // namespace RequestSubType + class CacheManagerInterface { public: virtual ~CacheManagerInterface() {} @@ -79,6 +89,21 @@ class CacheManagerInterface { const PTString& hmi_level, const PTString& rpc, CheckPermissionResult& result) = 0; + /** + * @brief Get state of request types for given application + * @param policy_app_id Unique application id + * @return request type state + */ + virtual RequestType::State GetAppRequestTypesState( + const std::string& policy_app_id) const = 0; + + /** + * @brief Get state of request subtypes for given application + * @param policy_app_id Unique application id + * @return request subtype state + */ + virtual RequestSubType::State GetAppRequestSubTypesState( + const std::string& policy_app_id) const = 0; /** * @brief Returns true if Policy Table was not updated yet @@ -706,6 +731,15 @@ class CacheManagerInterface { std::vector<std::string>& request_types) const = 0; /** + * @brief Gets request subtypes for application + * @param policy_app_id Unique application id + * @param request_subtypes Request subtypes of application to be filled + */ + virtual void GetAppRequestSubTypes( + const std::string& policy_app_id, + std::vector<std::string>& request_subtypes) const = 0; + + /** * @brief Gets meta information * @return meta information */ diff --git a/src/components/policy/policy_external/include/policy/policy_helper.h b/src/components/policy/policy_external/include/policy/policy_helper.h index 6945f45b45..e399b44719 100644 --- a/src/components/policy/policy_external/include/policy/policy_helper.h +++ b/src/components/policy/policy_external/include/policy/policy_helper.h @@ -192,6 +192,14 @@ struct CheckAppPolicy { */ bool IsRequestTypeChanged(const AppPoliciesValueType& app_policy) const; + /** + * @brief Checks whether App RequestSubTypes have been changed by + * udpated + * @param app_policy Reference to updated application policy + * @return True if changed, otherwise - false + */ + bool IsRequestSubTypeChanged(const AppPoliciesValueType& app_policy) const; + private: PolicyManagerImpl* pm_; const utils::SharedPtr<policy_table::Table> update_; diff --git a/src/components/policy/policy_external/include/policy/policy_manager_impl.h b/src/components/policy/policy_external/include/policy/policy_manager_impl.h index 97a2e60055..fcd9c9f69a 100644 --- a/src/components/policy/policy_external/include/policy/policy_manager_impl.h +++ b/src/components/policy/policy_external/include/policy/policy_manager_impl.h @@ -538,6 +538,22 @@ class PolicyManagerImpl : public PolicyManager { void OnAppsSearchCompleted(const bool trigger_ptu) OVERRIDE; /** + * @brief Get state of request types for given application + * @param policy_app_id Unique application id + * @return request type state + */ + RequestType::State GetAppRequestTypesState( + const std::string& policy_app_id) const OVERRIDE; + + /** + * @brief Get state of request subtypes for given application + * @param policy_app_id Unique application id + * @return request subtype state + */ + RequestSubType::State GetAppRequestSubTypesState( + const std::string& policy_app_id) const OVERRIDE; + + /** * @brief Gets request types for application * @param policy_app_id Unique application id * @return request types of application @@ -546,6 +562,14 @@ class PolicyManagerImpl : public PolicyManager { const std::string policy_app_id) const OVERRIDE; /** + * @brief Gets request subtypes for application + * @param policy_app_id Unique application id + * @return request subtypes of application + */ + const std::vector<std::string> GetAppRequestSubTypes( + const std::string& policy_app_id) const OVERRIDE; + + /** * @brief Get information about vehicle * @return vehicle information */ diff --git a/src/components/policy/policy_external/include/policy/policy_table/enums.h b/src/components/policy/policy_external/include/policy/policy_table/enums.h index 4f8ae5c98d..96a6748436 100644 --- a/src/components/policy/policy_external/include/policy/policy_table/enums.h +++ b/src/components/policy/policy_external/include/policy/policy_table/enums.h @@ -70,6 +70,7 @@ enum Parameter { P_FUELLEVEL_STATE, P_HEADLAMPSTATUS, P_INSTANTFUELCONSUMPTION, + P_FUELRANGE, P_ODOMETER, P_TIREPRESSURE, P_WIPERSTATUS, @@ -80,6 +81,7 @@ enum Parameter { P_PRNDL, P_RPM, P_STEERINGWHEELANGLE, + P_ENGINEOILLIFE, P_MYKEY, P_AIRBAGSTATUS, P_BODYINFORMATION, @@ -147,7 +149,9 @@ enum RequestType { RT_VEHICLE_DIAGNOSTICS, RT_EMERGENCY, RT_MEDIA, - RT_FOTA + RT_FOTA, + RT_OEM_SPECIFIC, + RT_EMPTY // Added to allow empty Request Types handling }; bool IsValidEnum(RequestType val); diff --git a/src/components/policy/policy_external/include/policy/policy_table/types.h b/src/components/policy/policy_external/include/policy/policy_table/types.h index 3002d20b93..1b1419365d 100644 --- a/src/components/policy/policy_external/include/policy/policy_table/types.h +++ b/src/components/policy/policy_external/include/policy/policy_table/types.h @@ -102,6 +102,8 @@ typedef Map<DeviceParams, 0, 255> DeviceData; typedef Array<Enum<RequestType>, 0, 255> RequestsTypeArray; +typedef Strings RequestSubTypes; + #ifdef SDL_REMOTE_CONTROL typedef Map<Strings, 0, 255> RemoteRpcs; typedef Map<RemoteRpcs, 0, 255> AccessModules; @@ -173,6 +175,7 @@ struct ApplicationParams : PolicyBase { Optional<Strings> nicknames; Optional<AppHMITypes> AppHMIType; Optional<RequestTypes> RequestType; + Optional<RequestSubTypes> RequestSubType; Optional<Integer<uint16_t, 0, 65225> > memory_kb; Optional<Integer<uint32_t, 0, UINT_MAX> > heart_beat_timeout_ms; #ifdef SDL_REMOTE_CONTROL diff --git a/src/components/policy/policy_external/include/policy/policy_table_interface_ext.xml b/src/components/policy/policy_external/include/policy/policy_table_interface_ext.xml index 6683d41c7f..577f15c3f5 100644 --- a/src/components/policy/policy_external/include/policy/policy_table_interface_ext.xml +++ b/src/components/policy/policy_external/include/policy/policy_table_interface_ext.xml @@ -30,6 +30,7 @@ <element name="fuelLevel_State" /> <element name="headLampStatus" /> <element name="instantFuelConsumption" /> + <element name="fuelRange" /> <element name="odometer" /> <element name="tirePressure" /> <element name="wiperStatus" /> @@ -40,6 +41,7 @@ <element name="prndl" /> <element name="rpm" /> <element name="steeringWheelAngle" /> + <element name="engineOilLife" /> <element name="myKey" /> <element name="airbagStatus" /> <element name="bodyInformation" /> diff --git a/src/components/policy/policy_external/include/policy/policy_types.h b/src/components/policy/policy_external/include/policy/policy_types.h index 232191cfea..9682b3d58d 100644 --- a/src/components/policy/policy_external/include/policy/policy_types.h +++ b/src/components/policy/policy_external/include/policy/policy_types.h @@ -267,7 +267,8 @@ struct AppPermissions { , appRevoked(false) , appPermissionsConsentNeeded(false) , appUnauthorized(false) - , requestTypeChanged(false) {} + , requestTypeChanged(false) + , requestSubTypeChanged(false) {} std::string application_id; bool isAppPermissionsRevoked; @@ -280,6 +281,8 @@ struct AppPermissions { DeviceParams deviceInfo; bool requestTypeChanged; std::vector<std::string> requestType; + bool requestSubTypeChanged; + std::vector<std::string> requestSubType; }; /** @@ -503,7 +506,8 @@ enum PermissionsCheckResult { RESULT_CONSENT_NEEDED, RESULT_CONSENT_NOT_REQIURED, RESULT_PERMISSIONS_REVOKED_AND_CONSENT_NEEDED, - RESULT_REQUEST_TYPE_CHANGED + RESULT_REQUEST_TYPE_CHANGED, + RESULT_REQUEST_SUBTYPE_CHANGED }; /** diff --git a/src/components/policy/policy_external/include/policy/sql_pt_queries.h b/src/components/policy/policy_external/include/policy/sql_pt_queries.h index a69df20cfc..646cc7663b 100644 --- a/src/components/policy/policy_external/include/policy/sql_pt_queries.h +++ b/src/components/policy/policy_external/include/policy/sql_pt_queries.h @@ -65,6 +65,7 @@ extern const std::string kSelectAppGroups; extern const std::string kSelectNicknames; extern const std::string kSelectAppTypes; extern const std::string kSelectRequestTypes; +extern const std::string kSelectRequestSubTypes; extern const std::string kSelectSecondsBetweenRetries; extern const std::string kSelectIgnitionCycles; extern const std::string kSelectKilometers; @@ -78,6 +79,9 @@ extern const std::string kInsertAppGroup; extern const std::string kInsertNickname; extern const std::string kInsertAppType; extern const std::string kInsertRequestType; +extern const std::string kInsertOmittedRequestType; +extern const std::string kInsertOmittedRequestSubType; +extern const std::string kInsertRequestSubType; extern const std::string kInsertMessageType; extern const std::string kInsertLanguage; extern const std::string kInsertMessageString; @@ -98,6 +102,7 @@ extern const std::string kDeleteExternalConsentEntities; extern const std::string kDeleteAppGroup; extern const std::string kDeleteApplication; extern const std::string kDeleteRequestType; +extern const std::string kDeleteRequestSubType; extern const std::string kDeleteDevice; extern const std::string kIncrementIgnitionCycles; extern const std::string kResetIgnitionCycles; diff --git a/src/components/policy/policy_external/include/policy/sql_pt_representation.h b/src/components/policy/policy_external/include/policy/sql_pt_representation.h index 54dfb9f0b7..c32e3205ef 100644 --- a/src/components/policy/policy_external/include/policy/sql_pt_representation.h +++ b/src/components/policy/policy_external/include/policy/sql_pt_representation.h @@ -133,6 +133,9 @@ class SQLPTRepresentation : public virtual PTRepresentation { policy_table::AppHMITypes* app_types) const; bool GatherRequestType(const std::string& app_id, policy_table::RequestTypes* request_types) const; + bool GatherRequestSubType( + const std::string& app_id, + policy_table::RequestSubTypes* request_subtypes) const; bool GatherNickName(const std::string& app_id, policy_table::Strings* nicknames) const; @@ -168,6 +171,9 @@ class SQLPTRepresentation : public virtual PTRepresentation { const policy_table::AppHMITypes& types); bool SaveRequestType(const std::string& app_id, const policy_table::RequestTypes& types); + bool SaveRequestSubType( + const std::string& app_id, + const policy_table::RequestSubTypes& request_subtypes); public: virtual std::string GetLockScreenIconUrl() const; diff --git a/src/components/policy/policy_external/src/cache_manager.cc b/src/components/policy/policy_external/src/cache_manager.cc index 5aa39cb2f4..00bb1e4a1c 100644 --- a/src/components/policy/policy_external/src/cache_manager.cc +++ b/src/components/policy/policy_external/src/cache_manager.cc @@ -41,6 +41,7 @@ #include <vector> #include "utils/file_system.h" +#include "utils/helpers.h" #include "json/reader.h" #include "json/features.h" #include "json/writer.h" @@ -638,13 +639,11 @@ void CacheManager::RemoveAppConsentForGroup(const std::string& app_id, } } -using rpc::policy_table_interface_base::RequestTypes; -using rpc::policy_table_interface_base::RequestType; - void CacheManager::ProcessUpdate( const policy_table::ApplicationPolicies::const_iterator initial_policy_iter) { using namespace policy; + using rpc::policy_table_interface_base::RequestTypes; const RequestTypes& new_request_types = *(initial_policy_iter->second.RequestType); @@ -2392,6 +2391,32 @@ bool CacheManager::ResetPT(const std::string& file_name) { return result; } +policy::RequestType::State CacheManager::GetAppRequestTypesState( + const std::string& policy_app_id) const { + LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock auto_lock(cache_lock_); + policy_table::ApplicationPolicies::const_iterator app_policies_iter = + pt_->policy_table.app_policies_section.apps.find(policy_app_id); + if (pt_->policy_table.app_policies_section.apps.end() == app_policies_iter) { + LOG4CXX_DEBUG(logger_, + "Can't find request types for app_id " << policy_app_id); + return policy::RequestType::State::UNAVAILABLE; + } + const policy_table::RequestTypes& request_types = + *app_policies_iter->second.RequestType; + if (!request_types.is_initialized()) { + LOG4CXX_TRACE(logger_, + "Request types for " << policy_app_id << " are OMITTED"); + return RequestType::State::OMITTED; + } + if (request_types.empty()) { + LOG4CXX_TRACE(logger_, + "Request types for " << policy_app_id << " are EMPTY"); + return policy::RequestType::State::EMPTY; + } + return policy::RequestType::State::AVAILABLE; +} + void CacheManager::GetAppRequestTypes( const std::string& policy_app_id, std::vector<std::string>& request_types) const { @@ -2411,16 +2436,64 @@ void CacheManager::GetAppRequestTypes( return; } if (policy_iter->second.RequestType.is_initialized()) { - policy_table::RequestTypes::iterator it_request_type = - policy_iter->second.RequestType->begin(); - for (; it_request_type != policy_iter->second.RequestType->end(); - ++it_request_type) { - request_types.push_back(EnumToJsonString(*it_request_type)); + for (const auto& request_type : *policy_iter->second.RequestType) { + request_types.push_back(EnumToJsonString(request_type)); } } return; } +RequestSubType::State CacheManager::GetAppRequestSubTypesState( + const std::string& policy_app_id) const { + LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock auto_lock(cache_lock_); + policy_table::ApplicationPolicies::const_iterator app_policies_iter = + pt_->policy_table.app_policies_section.apps.find(policy_app_id); + if (pt_->policy_table.app_policies_section.apps.end() == app_policies_iter) { + LOG4CXX_DEBUG(logger_, + "Can't find request subtypes for app_id " << policy_app_id); + return RequestSubType::State::UNAVAILABLE; + } + const policy_table::RequestSubTypes& request_subtypes = + *app_policies_iter->second.RequestSubType; + if (!request_subtypes.is_initialized()) { + LOG4CXX_TRACE(logger_, + "Request subtypes for " << policy_app_id << " are OMITTED"); + return RequestSubType::State::OMITTED; + } + if (request_subtypes.empty()) { + LOG4CXX_TRACE(logger_, + "Request subtypes for " << policy_app_id << " are EMPTY"); + return RequestSubType::State::EMPTY; + } + return RequestSubType::State::AVAILABLE; +} + +void CacheManager::GetAppRequestSubTypes( + const std::string& policy_app_id, + std::vector<std::string>& request_subtypes) const { + LOG4CXX_AUTO_TRACE(logger_); + CACHE_MANAGER_CHECK_VOID(); + if (kDeviceId == policy_app_id) { + LOG4CXX_DEBUG(logger_, + "Request subtypes not applicable for app_id " << kDeviceId); + return; + } + sync_primitives::AutoLock auto_lock(cache_lock_); + policy_table::ApplicationPolicies::iterator policy_iter = + pt_->policy_table.app_policies_section.apps.find(policy_app_id); + if (pt_->policy_table.app_policies_section.apps.end() == policy_iter) { + LOG4CXX_DEBUG(logger_, + "Can't find request subtypes for app_id " << policy_app_id); + return; + } + + for (const auto& request_subtype : *policy_iter->second.RequestSubType) { + request_subtypes.push_back(request_subtype); + } + return; +} + const MetaInfo CacheManager::GetMetaInfo() const { LOG4CXX_AUTO_TRACE(logger_); sync_primitives::AutoLock auto_lock(cache_lock_); diff --git a/src/components/policy/policy_external/src/policy_helper.cc b/src/components/policy/policy_external/src/policy_helper.cc index 8be0372c03..39b9399c24 100644 --- a/src/components/policy/policy_external/src/policy_helper.cc +++ b/src/components/policy/policy_external/src/policy_helper.cc @@ -322,9 +322,21 @@ bool CheckAppPolicy::operator()(const AppPoliciesValueType& app_policy) { PermissionsCheckResult result = CheckPermissionsChanges(app_policy); - if (!IsPredefinedApp(app_policy) && IsRequestTypeChanged(app_policy)) { - SetPendingPermissions(app_policy, RESULT_REQUEST_TYPE_CHANGED); - AddResult(app_id, RESULT_REQUEST_TYPE_CHANGED); + if (!IsPredefinedApp(app_policy)) { + const bool is_request_type_changed = IsRequestTypeChanged(app_policy); + const bool is_request_subtype_changed = IsRequestSubTypeChanged(app_policy); + if (is_request_type_changed) { + LOG4CXX_TRACE(logger_, + "Request types were changed for application: " << app_id); + SetPendingPermissions(app_policy, RESULT_REQUEST_TYPE_CHANGED); + AddResult(app_id, RESULT_REQUEST_TYPE_CHANGED); + } + if (is_request_subtype_changed) { + LOG4CXX_TRACE( + logger_, "Request subtypes were changed for application: " << app_id); + SetPendingPermissions(app_policy, RESULT_REQUEST_SUBTYPE_CHANGED); + AddResult(app_id, RESULT_REQUEST_SUBTYPE_CHANGED); + } } if (RESULT_NO_CHANGES == result) { @@ -389,17 +401,18 @@ void policy::CheckAppPolicy::SetPendingPermissions( break; case RESULT_REQUEST_TYPE_CHANGED: permissions_diff.requestTypeChanged = true; - { - // Getting RequestTypes from PTU (not from cache) - policy_table::RequestTypes::const_iterator it_request_type = - app_policy.second.RequestType->begin(); - for (; app_policy.second.RequestType->end() != it_request_type; - ++it_request_type) { - permissions_diff.requestType.push_back( - EnumToJsonString(*it_request_type)); - } - } + // Getting Request Types from PTU (not from cache) + for (const auto& request_type : *app_policy.second.RequestType) { + permissions_diff.requestType.push_back(EnumToJsonString(request_type)); + } + break; + case RESULT_REQUEST_SUBTYPE_CHANGED: + permissions_diff.requestSubTypeChanged = true; + // Getting Request SubTypes from PTU (not from cache) + for (const auto& request_subtype : *app_policy.second.RequestSubType) { + permissions_diff.requestSubType.push_back(request_subtype); + } break; default: return; @@ -484,6 +497,32 @@ bool CheckAppPolicy::IsRequestTypeChanged( return diff.size(); } +bool CheckAppPolicy::IsRequestSubTypeChanged( + const AppPoliciesValueType& app_policy) const { + policy::AppPoliciesConstItr it = + snapshot_->policy_table.app_policies_section.apps.find(app_policy.first); + + if (it == snapshot_->policy_table.app_policies_section.apps.end()) { + if (!app_policy.second.RequestSubType->empty()) { + return true; + } + return false; + } + + if (it->second.RequestSubType->size() != + app_policy.second.RequestSubType->size()) { + return true; + } + + policy_table::RequestSubTypes diff; + std::set_difference(it->second.RequestSubType->begin(), + it->second.RequestSubType->end(), + app_policy.second.RequestSubType->begin(), + app_policy.second.RequestSubType->end(), + std::back_inserter(diff)); + return diff.size(); +} + void FillActionsForAppPolicies::operator()( const policy::CheckAppPolicyResults::value_type& value) { const std::string app_id = value.first; @@ -510,6 +549,7 @@ void FillActionsForAppPolicies::operator()( case RESULT_CONSENT_NOT_REQIURED: case RESULT_PERMISSIONS_REVOKED: case RESULT_REQUEST_TYPE_CHANGED: + case RESULT_REQUEST_SUBTYPE_CHANGED: break; case RESULT_NO_CHANGES: default: diff --git a/src/components/policy/policy_external/src/policy_manager_impl.cc b/src/components/policy/policy_external/src/policy_manager_impl.cc index 433a7a6bca..56de26af64 100644 --- a/src/components/policy/policy_external/src/policy_manager_impl.cc +++ b/src/components/policy/policy_external/src/policy_manager_impl.cc @@ -563,6 +563,25 @@ const std::vector<std::string> PolicyManagerImpl::GetAppRequestTypes( return request_types; } +RequestType::State PolicyManagerImpl::GetAppRequestTypesState( + const std::string& policy_app_id) const { + LOG4CXX_AUTO_TRACE(logger_); + return cache_->GetAppRequestTypesState(policy_app_id); +} + +RequestSubType::State PolicyManagerImpl::GetAppRequestSubTypesState( + const std::string& policy_app_id) const { + LOG4CXX_AUTO_TRACE(logger_); + return cache_->GetAppRequestSubTypesState(policy_app_id); +} + +const std::vector<std::string> PolicyManagerImpl::GetAppRequestSubTypes( + const std::string& policy_app_id) const { + std::vector<std::string> request_subtypes; + cache_->GetAppRequestSubTypes(policy_app_id, request_subtypes); + return request_subtypes; +} + const VehicleInfo PolicyManagerImpl::GetVehicleInfo() const { return cache_->GetVehicleInfo(); } diff --git a/src/components/policy/policy_external/src/policy_table/enums.cc b/src/components/policy/policy_external/src/policy_table/enums.cc index 168ff86b27..881ae8cbf9 100644 --- a/src/components/policy/policy_external/src/policy_table/enums.cc +++ b/src/components/policy/policy_external/src/policy_table/enums.cc @@ -126,6 +126,8 @@ bool IsValidEnum(Parameter val) { return true; case P_INSTANTFUELCONSUMPTION: return true; + case P_FUELRANGE: + return true; case P_ODOMETER: return true; case P_TIREPRESSURE: @@ -146,6 +148,8 @@ bool IsValidEnum(Parameter val) { return true; case P_STEERINGWHEELANGLE: return true; + case P_ENGINEOILLIFE: + return true; case P_MYKEY: return true; case P_AIRBAGSTATUS: @@ -215,6 +219,8 @@ const char* EnumToJsonString(Parameter val) { return "headLampStatus"; case P_INSTANTFUELCONSUMPTION: return "instantFuelConsumption"; + case P_FUELRANGE: + return "fuelRange"; case P_ODOMETER: return "odometer"; case P_TIREPRESSURE: @@ -235,6 +241,8 @@ const char* EnumToJsonString(Parameter val) { return "rpm"; case P_STEERINGWHEELANGLE: return "steeringWheelAngle"; + case P_ENGINEOILLIFE: + return "engineOilLife"; case P_MYKEY: return "myKey"; case P_AIRBAGSTATUS: @@ -311,6 +319,9 @@ bool EnumFromJsonString(const std::string& literal, Parameter* result) { } else if ("instantFuelConsumption" == literal) { *result = P_INSTANTFUELCONSUMPTION; return true; + } else if ("fuelRange" == literal) { + *result = P_FUELRANGE; + return true; } else if ("odometer" == literal) { *result = P_ODOMETER; return true; @@ -341,6 +352,9 @@ bool EnumFromJsonString(const std::string& literal, Parameter* result) { } else if ("steeringWheelAngle" == literal) { *result = P_STEERINGWHEELANGLE; return true; + } else if ("engineOilLife" == literal) { + *result = P_ENGINEOILLIFE; + return true; } else if ("myKey" == literal) { *result = P_MYKEY; return true; @@ -591,6 +605,10 @@ bool IsValidEnum(RequestType val) { return true; case RT_FOTA: return true; + case RT_OEM_SPECIFIC: + return true; + case RT_EMPTY: + return true; default: return false; } @@ -638,6 +656,10 @@ const char* EnumToJsonString(RequestType val) { return "MEDIA"; case RT_FOTA: return "FOTA"; + case RT_OEM_SPECIFIC: + return "OEM_SPECIFIC"; + case RT_EMPTY: + return "EMPTY"; default: return ""; } @@ -723,6 +745,14 @@ bool EnumFromJsonString(const std::string& literal, RequestType* result) { if ("FOTA" == literal) { *result = RT_FOTA; return true; + } + if ("OEM_SPECIFIC" == literal) { + *result = RT_OEM_SPECIFIC; + return true; + } + if ("EMPTY" == literal) { + *result = RT_EMPTY; + return true; } else { return false; } diff --git a/src/components/policy/policy_external/src/policy_table/types.cc b/src/components/policy/policy_external/src/policy_table/types.cc index da83626448..6d0bc9d697 100644 --- a/src/components/policy/policy_external/src/policy_table/types.cc +++ b/src/components/policy/policy_external/src/policy_table/types.cc @@ -238,6 +238,7 @@ ApplicationParams::ApplicationParams(const Json::Value* value__) , nicknames(impl::ValueMember(value__, "nicknames")) , AppHMIType(impl::ValueMember(value__, "AppHMIType")) , RequestType(impl::ValueMember(value__, "RequestType")) + , RequestSubType(impl::ValueMember(value__, "RequestSubType")) , memory_kb(impl::ValueMember(value__, "memory_kb"), 0) , heart_beat_timeout_ms(impl::ValueMember(value__, "heart_beat_timeout_ms")) #ifdef SDL_REMOTE_CONTROL @@ -251,6 +252,7 @@ Json::Value ApplicationParams::ToJsonValue() const { impl::WriteJsonField("nicknames", nicknames, &result__); impl::WriteJsonField("AppHMIType", AppHMIType, &result__); impl::WriteJsonField("RequestType", RequestType, &result__); + impl::WriteJsonField("RequestSubType", RequestSubType, &result__); impl::WriteJsonField("memory_kb", memory_kb, &result__); impl::WriteJsonField( "heart_beat_timeout_ms", heart_beat_timeout_ms, &result__); @@ -303,6 +305,9 @@ bool ApplicationParams::struct_empty() const { if (RequestType.is_initialized()) { return false; } + if (RequestSubType.is_initialized()) { + return false; + } if (memory_kb.is_initialized()) { return false; } @@ -337,6 +342,9 @@ void ApplicationParams::ReportErrors(rpc::ValidationReport* report__) const { if (!RequestType.is_valid()) { RequestType.ReportErrors(&report__->ReportSubobject("RequestType")); } + if (!RequestSubType.is_valid()) { + RequestSubType.ReportErrors(&report__->ReportSubobject("RequestSubType")); + } if (!priority.is_valid()) { priority.ReportErrors(&report__->ReportSubobject("priority")); } @@ -368,6 +376,7 @@ void ApplicationParams::SetPolicyTableType(PolicyTableType pt_type) { PolicyBase::SetPolicyTableType(pt_type); AppHMIType.SetPolicyTableType(pt_type); RequestType.SetPolicyTableType(pt_type); + RequestSubType.SetPolicyTableType(pt_type); memory_kb.SetPolicyTableType(pt_type); heart_beat_timeout_ms.SetPolicyTableType(pt_type); #ifdef SDL_REMOTE_CONTROL diff --git a/src/components/policy/policy_external/src/policy_table/validation.cc b/src/components/policy/policy_external/src/policy_table/validation.cc index 48a8578855..6936948c84 100644 --- a/src/components/policy/policy_external/src/policy_table/validation.cc +++ b/src/components/policy/policy_external/src/policy_table/validation.cc @@ -89,6 +89,7 @@ bool ApplicationPoliciesSection::Validate() const { continue; } + LOG4CXX_TRACE(logger_, "Checking app Request Types..."); RequestTypes& app_request_types = *iter->second.RequestType; if (app_request_types.is_omitted()) { @@ -133,6 +134,33 @@ bool ApplicationPoliciesSection::Validate() const { ++iter; } + LOG4CXX_TRACE(logger_, "Checking app Request SubTypes..."); + iter = apps.begin(); + while (iter != end_iter) { + if (it_default_policy == iter || it_pre_data_policy == iter) { + ++iter; + continue; + } + ApplicationParams& app_params = (*iter).second; + const bool is_request_subtype_omitted = + !app_params.RequestSubType.is_initialized(); + + if (is_request_subtype_omitted) { + LOG4CXX_WARN(logger_, + "App policy RequestSubTypes omitted." + " Will be replaced with default."); + app_params.RequestSubType = apps[kDefaultApp].RequestSubType; + ++iter; + continue; + } + + const bool is_request_subtype_empty = app_params.RequestSubType->empty(); + if (is_request_subtype_empty) { + LOG4CXX_WARN(logger_, "App policy RequestSubTypes empty."); + } + ++iter; + } + return true; } diff --git a/src/components/policy/policy_external/src/sql_pt_ext_representation.cc b/src/components/policy/policy_external/src/sql_pt_ext_representation.cc index f58a7f0b82..5bb602244e 100644 --- a/src/components/policy/policy_external/src/sql_pt_ext_representation.cc +++ b/src/components/policy/policy_external/src/sql_pt_ext_representation.cc @@ -670,6 +670,11 @@ bool SQLPTExtRepresentation::SaveApplicationPoliciesSection( return false; } + if (!query_delete.Exec(sql_pt::kDeleteRequestSubType)) { + LOG4CXX_WARN(logger_, "Incorrect delete from request subtype."); + return false; + } + // First, all predefined apps (e.g. default, pre_DataConsent) should be saved, // otherwise another app with the predefined permissions can get incorrect // permissions @@ -713,18 +718,17 @@ bool SQLPTExtRepresentation::SaveSpecificAppPolicy( if (!SetDefaultPolicy(app.first)) { return false; } - if (!SaveRequestType(app.first, *app.second.RequestType)) { - return false; - } } else if (kPreDataConsentId.compare(app.second.get_string()) == 0) { if (!SetPredataPolicy(app.first)) { return false; } - if (!SaveRequestType(app.first, *app.second.RequestType)) { - return false; - } } - + if (!SaveRequestType(app.first, *app.second.RequestType)) { + return false; + } + if (!SaveRequestSubType(app.first, *app.second.RequestSubType)) { + return false; + } // Stop saving other params, since predefined permissions already set return true; } @@ -771,6 +775,10 @@ bool SQLPTExtRepresentation::SaveSpecificAppPolicy( return false; } + if (!SaveRequestSubType(app.first, *app.second.RequestSubType)) { + return false; + } + return true; } diff --git a/src/components/policy/policy_external/src/sql_pt_queries.cc b/src/components/policy/policy_external/src/sql_pt_queries.cc index 9702c315b0..ee53eb1487 100644 --- a/src/components/policy/policy_external/src/sql_pt_queries.cc +++ b/src/components/policy/policy_external/src/sql_pt_queries.cc @@ -271,13 +271,21 @@ const std::string kCreateSchema = " REFERENCES `application`(`id`) " "); " "CREATE TABLE IF NOT EXISTS `request_type`( " - " `request_type` VARCHAR(50) NOT NULL, " + " `request_type` VARCHAR(50), " " `application_id` VARCHAR(45) NOT NULL COLLATE NOCASE, " " PRIMARY KEY(`request_type`,`application_id`), " " CONSTRAINT `fk_app_type_application1` " " FOREIGN KEY(`application_id`) " " REFERENCES `application`(`id`) " "); " + "CREATE TABLE IF NOT EXISTS `request_subtype`( " + " `request_subtype` VARCHAR(50), " + " `application_id` VARCHAR(45) NOT NULL COLLATE NOCASE, " + " PRIMARY KEY(`request_subtype`,`application_id`), " + " CONSTRAINT `fk_request_subtype_app_id` " + " FOREIGN KEY(`application_id`) " + " REFERENCES `application`(`id`) " + "); " "CREATE INDEX IF NOT EXISTS `app_type.fk_app_type_application1_idx` " " ON `app_type`(`application_id` COLLATE NOCASE); " "CREATE TABLE IF NOT EXISTS `consent_group`( " @@ -482,6 +490,7 @@ const std::string kDropSchema = "DROP INDEX IF EXISTS `app_type.fk_app_type_application1_idx`; " "DROP TABLE IF EXISTS `app_type`; " "DROP TABLE IF EXISTS `request_type`; " + "DROP TABLE IF EXISTS `request_subtype`; " "DROP INDEX IF EXISTS `nickname.fk_nickname_application1_idx`; " "DROP TABLE IF EXISTS `nickname`; " "DROP INDEX IF EXISTS `app_level.fk_app_level_language2_idx`; " @@ -636,6 +645,19 @@ const std::string kInsertRequestType = "INSERT OR IGNORE INTO `request_type` (`application_id`, `request_type`) " "VALUES (?, ?)"; +const std::string kInsertOmittedRequestType = + "INSERT INTO `request_type` (`application_id`) " + "VALUES (?)"; + +const std::string kInsertRequestSubType = + "INSERT INTO `request_subtype` (`application_id`, " + "`request_subtype`) " + "VALUES (?, ?)"; + +const std::string kInsertOmittedRequestSubType = + "INSERT INTO `request_subtype` (`application_id`) " + "VALUES (?)"; + const std::string kUpdateVersion = "UPDATE `version` SET `number`= ?"; const std::string kInsertMessageType = @@ -760,6 +782,11 @@ const std::string kSelectRequestTypes = "SELECT DISTINCT `request_type` FROM `request_type` WHERE `application_id` " "= ?"; +const std::string kSelectRequestSubTypes = + "SELECT DISTINCT `request_subtype` FROM `request_subtype` WHERE " + "`application_id` " + "= ?"; + const std::string kSelectSecondsBetweenRetries = "SELECT `value` FROM `seconds_between_retry` ORDER BY `index`"; @@ -805,6 +832,8 @@ const std::string kDeleteApplication = "DELETE FROM `application`"; const std::string kDeleteRequestType = "DELETE FROM `request_type`"; +const std::string kDeleteRequestSubType = "DELETE FROM `request_subtype`"; + const std::string kSelectApplicationRevoked = "SELECT `is_revoked` FROM `application` WHERE `id` = ?"; diff --git a/src/components/policy/policy_external/src/sql_pt_representation.cc b/src/components/policy/policy_external/src/sql_pt_representation.cc index 4315d99b3a..b05716dc3f 100644 --- a/src/components/policy/policy_external/src/sql_pt_representation.cc +++ b/src/components/policy/policy_external/src/sql_pt_representation.cc @@ -786,6 +786,9 @@ bool SQLPTRepresentation::GatherApplicationPoliciesSection( if (!GatherRequestType(app_id, &*params.RequestType)) { return false; } + if (!GatherRequestSubType(app_id, &*params.RequestSubType)) { + return false; + } (*policies).apps[app_id] = params; } @@ -1175,15 +1178,83 @@ bool SQLPTRepresentation::SaveRequestType( } policy_table::RequestTypes::const_iterator it; - for (it = types.begin(); it != types.end(); ++it) { + if (!types.empty()) { + LOG4CXX_WARN(logger_, "Request types not empty."); + for (it = types.begin(); it != types.end(); ++it) { + query.Bind(0, app_id); + query.Bind(1, std::string(policy_table::EnumToJsonString(*it))); + if (!query.Exec() || !query.Reset()) { + LOG4CXX_WARN(logger_, "Incorrect insert into request types."); + return false; + } + } + } else if (types.is_initialized()) { + LOG4CXX_WARN(logger_, "Request types empty."); query.Bind(0, app_id); - query.Bind(1, std::string(policy_table::EnumToJsonString(*it))); + query.Bind(1, + std::string(policy_table::EnumToJsonString( + policy_table::RequestType::RT_EMPTY))); if (!query.Exec() || !query.Reset()) { LOG4CXX_WARN(logger_, "Incorrect insert into request types."); return false; } + } else { + utils::dbms::SQLQuery query_omitted(db()); + if (!query_omitted.Prepare(sql_pt::kInsertOmittedRequestType)) { + LOG4CXX_WARN(logger_, "Incorrect insert statement for request types."); + return false; + } + LOG4CXX_WARN(logger_, "Request types omitted."); + query_omitted.Bind(0, app_id); + if (!query_omitted.Exec() || !query_omitted.Reset()) { + LOG4CXX_WARN(logger_, "Incorrect insert into request types."); + return false; + } + } + return true; +} + +bool SQLPTRepresentation::SaveRequestSubType( + const std::string& app_id, + const policy_table::RequestSubTypes& request_subtypes) { + utils::dbms::SQLQuery query(db()); + if (!query.Prepare(sql_pt::kInsertRequestSubType)) { + LOG4CXX_WARN(logger_, "Incorrect insert statement for request subtypes."); + return false; } + policy_table::Strings::const_iterator it; + if (!request_subtypes.empty()) { + LOG4CXX_TRACE(logger_, "Request subtypes are not empty."); + for (it = request_subtypes.begin(); it != request_subtypes.end(); ++it) { + query.Bind(0, app_id); + query.Bind(1, *it); + if (!query.Exec() || !query.Reset()) { + LOG4CXX_WARN(logger_, "Incorrect insert into request subtypes."); + return false; + } + } + } else if (request_subtypes.is_initialized()) { + LOG4CXX_WARN(logger_, "Request subtypes empty."); + query.Bind(0, app_id); + query.Bind(1, std::string("EMPTY")); + if (!query.Exec() || !query.Reset()) { + LOG4CXX_WARN(logger_, "Incorrect insert into request subtypes."); + return false; + } + } else { + utils::dbms::SQLQuery query_omitted(db()); + if (!query_omitted.Prepare(sql_pt::kInsertOmittedRequestSubType)) { + LOG4CXX_WARN(logger_, "Incorrect insert statement for request subtypes."); + return false; + } + LOG4CXX_WARN(logger_, "Request subtypes omitted."); + query_omitted.Bind(0, app_id); + if (!query_omitted.Exec() || !query_omitted.Reset()) { + LOG4CXX_WARN(logger_, "Incorrect insert into request subtypes."); + return false; + } + } return true; } @@ -1583,11 +1654,36 @@ bool SQLPTRepresentation::GatherRequestType( if (!policy_table::EnumFromJsonString(query.GetString(0), &type)) { return false; } + if (policy_table::RequestType::RT_EMPTY == type) { + request_types->mark_initialized(); + continue; + } request_types->push_back(type); } return true; } +bool SQLPTRepresentation::GatherRequestSubType( + const std::string& app_id, + policy_table::RequestSubTypes* request_subtypes) const { + utils::dbms::SQLQuery query(db()); + if (!query.Prepare(sql_pt::kSelectRequestSubTypes)) { + LOG4CXX_WARN(logger_, "Incorrect select from request subtypes."); + return false; + } + + query.Bind(0, app_id); + while (query.Next()) { + const std::string request_subtype = query.GetString(0); + if ("EMPTY" == request_subtype) { + request_subtypes->mark_initialized(); + continue; + } + request_subtypes->push_back(request_subtype); + } + return true; +} + bool SQLPTRepresentation::GatherNickName( const std::string& app_id, policy_table::Strings* nicknames) const { utils::dbms::SQLQuery query(db()); @@ -1907,6 +2003,13 @@ bool SQLPTRepresentation::SetDefaultPolicy(const std::string& app_id) { !SaveRequestType(app_id, request_types)) { return false; } + + policy_table::Strings request_subtypes; + if (!GatherRequestSubType(kDefaultId, &request_subtypes) || + !SaveRequestSubType(app_id, request_subtypes)) { + return false; + } + policy_table::AppHMITypes app_types; if (!GatherAppType(kDefaultId, &app_types) || !SaveAppType(app_id, app_types)) { diff --git a/src/components/policy/policy_external/test/json/PTU.json b/src/components/policy/policy_external/test/json/PTU.json index c0f18bb6a9..c231340f44 100644 --- a/src/components/policy/policy_external/test/json/PTU.json +++ b/src/components/policy/policy_external/test/json/PTU.json @@ -472,12 +472,14 @@ "parameters": [ "bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -493,12 +495,14 @@ "parameters": [ "bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -514,12 +518,14 @@ "parameters": [ "bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus" @@ -534,12 +540,14 @@ "parameters": [ "bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus" diff --git a/src/components/policy/policy_external/test/json/PTU2.json b/src/components/policy/policy_external/test/json/PTU2.json index 8ad6aefb83..4970c40e60 100644 --- a/src/components/policy/policy_external/test/json/PTU2.json +++ b/src/components/policy/policy_external/test/json/PTU2.json @@ -472,12 +472,14 @@ "parameters": [ "bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -493,12 +495,14 @@ "parameters": [ "bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -514,12 +518,14 @@ "parameters": [ "bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus" @@ -534,12 +540,14 @@ "parameters": [ "bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus" diff --git a/src/components/policy/policy_external/test/json/PTU3.json b/src/components/policy/policy_external/test/json/PTU3.json index 33f699d068..98037cf594 100644 --- a/src/components/policy/policy_external/test/json/PTU3.json +++ b/src/components/policy/policy_external/test/json/PTU3.json @@ -472,12 +472,14 @@ "parameters": [ "bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -493,12 +495,14 @@ "parameters": [ "bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -514,12 +518,14 @@ "parameters": [ "bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus" @@ -534,12 +540,14 @@ "parameters": [ "bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus" diff --git a/src/components/policy/policy_external/test/json/PTU_with_empty_requestType_array.json b/src/components/policy/policy_external/test/json/PTU_with_empty_requestType_array.json index 45e616c874..f232d8fec7 100644 --- a/src/components/policy/policy_external/test/json/PTU_with_empty_requestType_array.json +++ b/src/components/policy/policy_external/test/json/PTU_with_empty_requestType_array.json @@ -1592,12 +1592,14 @@ "GetVehicleData" : { "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ], "parameters" : [ + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -1607,12 +1609,14 @@ "OnVehicleData" : { "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ], "parameters" : [ + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -1622,12 +1626,14 @@ "SubscribeVehicleData" : { "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ], "parameters" : [ + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus" @@ -1636,12 +1642,14 @@ "UnsubscribeVehicleData" : { "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ], "parameters" : [ + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus" diff --git a/src/components/policy/policy_external/test/json/PTU_with_invalid_requestType_between_correct.json b/src/components/policy/policy_external/test/json/PTU_with_invalid_requestType_between_correct.json index 917d53177f..942c862d4f 100644 --- a/src/components/policy/policy_external/test/json/PTU_with_invalid_requestType_between_correct.json +++ b/src/components/policy/policy_external/test/json/PTU_with_invalid_requestType_between_correct.json @@ -1595,12 +1595,14 @@ "GetVehicleData" : { "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ], "parameters" : [ + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -1610,12 +1612,14 @@ "OnVehicleData" : { "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ], "parameters" : [ + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -1625,12 +1629,14 @@ "SubscribeVehicleData" : { "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ], "parameters" : [ + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus" @@ -1639,12 +1645,14 @@ "UnsubscribeVehicleData" : { "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ], "parameters" : [ + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus" diff --git a/src/components/policy/policy_external/test/json/PTU_with_one_invalid_requestType.json b/src/components/policy/policy_external/test/json/PTU_with_one_invalid_requestType.json index f514f279de..c72fdbe6cb 100644 --- a/src/components/policy/policy_external/test/json/PTU_with_one_invalid_requestType.json +++ b/src/components/policy/policy_external/test/json/PTU_with_one_invalid_requestType.json @@ -1592,12 +1592,14 @@ "GetVehicleData" : { "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ], "parameters" : [ + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -1607,12 +1609,14 @@ "OnVehicleData" : { "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ], "parameters" : [ + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -1622,12 +1626,14 @@ "SubscribeVehicleData" : { "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ], "parameters" : [ + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus" @@ -1636,12 +1642,14 @@ "UnsubscribeVehicleData" : { "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ], "parameters" : [ + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus" diff --git a/src/components/policy/policy_external/test/json/PTU_without_requestType_field.json b/src/components/policy/policy_external/test/json/PTU_without_requestType_field.json index 57c1bce8f1..b783ac0cc2 100644 --- a/src/components/policy/policy_external/test/json/PTU_without_requestType_field.json +++ b/src/components/policy/policy_external/test/json/PTU_without_requestType_field.json @@ -1591,12 +1591,14 @@ "GetVehicleData" : { "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ], "parameters" : [ + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -1606,12 +1608,14 @@ "OnVehicleData" : { "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ], "parameters" : [ + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -1621,12 +1625,14 @@ "SubscribeVehicleData" : { "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ], "parameters" : [ + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus" @@ -1635,12 +1641,14 @@ "UnsubscribeVehicleData" : { "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ], "parameters" : [ + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus" diff --git a/src/components/policy/policy_external/test/json/preloadedPT_with_invalid_default_reqestType_between_valid.json b/src/components/policy/policy_external/test/json/preloadedPT_with_invalid_default_reqestType_between_valid.json index 20023ba8e5..fdf730917f 100644 --- a/src/components/policy/policy_external/test/json/preloadedPT_with_invalid_default_reqestType_between_valid.json +++ b/src/components/policy/policy_external/test/json/preloadedPT_with_invalid_default_reqestType_between_valid.json @@ -349,12 +349,14 @@ "LIMITED"], "parameters": ["bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -366,12 +368,14 @@ "LIMITED"], "parameters": ["bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -383,12 +387,14 @@ "LIMITED"], "parameters": ["bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus"] @@ -399,12 +405,14 @@ "LIMITED"], "parameters": ["bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus"] diff --git a/src/components/policy/policy_external/test/json/preloadedPT_with_invalid_default_requestType.json b/src/components/policy/policy_external/test/json/preloadedPT_with_invalid_default_requestType.json index 5e4dffbc56..82b6f762ca 100644 --- a/src/components/policy/policy_external/test/json/preloadedPT_with_invalid_default_requestType.json +++ b/src/components/policy/policy_external/test/json/preloadedPT_with_invalid_default_requestType.json @@ -349,12 +349,14 @@ "LIMITED"], "parameters": ["bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -366,12 +368,14 @@ "LIMITED"], "parameters": ["bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -383,12 +387,14 @@ "LIMITED"], "parameters": ["bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus"] @@ -399,12 +405,14 @@ "LIMITED"], "parameters": ["bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus"] diff --git a/src/components/policy/policy_external/test/json/preloadedPT_with_several_invalid_default_requestTypes.json b/src/components/policy/policy_external/test/json/preloadedPT_with_several_invalid_default_requestTypes.json index 6b92db7c17..713d057f1a 100644 --- a/src/components/policy/policy_external/test/json/preloadedPT_with_several_invalid_default_requestTypes.json +++ b/src/components/policy/policy_external/test/json/preloadedPT_with_several_invalid_default_requestTypes.json @@ -349,12 +349,14 @@ "LIMITED"], "parameters": ["bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -366,12 +368,14 @@ "LIMITED"], "parameters": ["bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -383,12 +387,14 @@ "LIMITED"], "parameters": ["bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus"] @@ -399,12 +405,14 @@ "LIMITED"], "parameters": ["bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus"] diff --git a/src/components/policy/policy_external/test/json/ptu2_requestType.json b/src/components/policy/policy_external/test/json/ptu2_requestType.json index c12ec773e0..4765da0771 100644 --- a/src/components/policy/policy_external/test/json/ptu2_requestType.json +++ b/src/components/policy/policy_external/test/json/ptu2_requestType.json @@ -484,12 +484,14 @@ "parameters": [ "bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -505,12 +507,14 @@ "parameters": [ "bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -526,12 +530,14 @@ "parameters": [ "bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus" @@ -546,12 +552,14 @@ "parameters": [ "bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus" diff --git a/src/components/policy/policy_external/test/json/ptu_requestType.json b/src/components/policy/policy_external/test/json/ptu_requestType.json index 0b1f0ed469..5e34c00a81 100644 --- a/src/components/policy/policy_external/test/json/ptu_requestType.json +++ b/src/components/policy/policy_external/test/json/ptu_requestType.json @@ -483,12 +483,14 @@ "parameters": [ "bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -504,12 +506,14 @@ "parameters": [ "bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -525,12 +529,14 @@ "parameters": [ "bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus" @@ -545,12 +551,14 @@ "parameters": [ "bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus" diff --git a/src/components/policy/policy_external/test/json/sdl_preloaded_pt.json b/src/components/policy/policy_external/test/json/sdl_preloaded_pt.json index 1f477175be..ced0a9d603 100644 --- a/src/components/policy/policy_external/test/json/sdl_preloaded_pt.json +++ b/src/components/policy/policy_external/test/json/sdl_preloaded_pt.json @@ -350,12 +350,14 @@ "LIMITED"], "parameters": ["bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -367,12 +369,14 @@ "LIMITED"], "parameters": ["bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -384,12 +388,14 @@ "LIMITED"], "parameters": ["bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus"] @@ -400,12 +406,14 @@ "LIMITED"], "parameters": ["bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus"] diff --git a/src/components/policy/policy_external/test/json/sdl_preloaded_pt1.json b/src/components/policy/policy_external/test/json/sdl_preloaded_pt1.json index 79d1b572e6..5974b22b8e 100644 --- a/src/components/policy/policy_external/test/json/sdl_preloaded_pt1.json +++ b/src/components/policy/policy_external/test/json/sdl_preloaded_pt1.json @@ -2308,12 +2308,14 @@ [ "bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -2327,12 +2329,14 @@ [ "bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -2346,12 +2350,14 @@ [ "bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus" @@ -2364,12 +2370,14 @@ [ "bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus" diff --git a/src/components/policy/policy_external/test/json/sdl_preloaded_pt_send_location.json b/src/components/policy/policy_external/test/json/sdl_preloaded_pt_send_location.json index 1401c3b7a1..8da6906e8b 100644 --- a/src/components/policy/policy_external/test/json/sdl_preloaded_pt_send_location.json +++ b/src/components/policy/policy_external/test/json/sdl_preloaded_pt_send_location.json @@ -484,12 +484,14 @@ "parameters": [ "bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -505,12 +507,14 @@ "parameters": [ "bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -526,12 +530,14 @@ "parameters": [ "bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus" @@ -546,12 +552,14 @@ "parameters": [ "bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus" diff --git a/src/components/policy/policy_external/test/json/sdl_pt_first_update.json b/src/components/policy/policy_external/test/json/sdl_pt_first_update.json index ac2b18ab6f..f8be46d2b5 100644 --- a/src/components/policy/policy_external/test/json/sdl_pt_first_update.json +++ b/src/components/policy/policy_external/test/json/sdl_pt_first_update.json @@ -1609,12 +1609,14 @@ "GetVehicleData" : { "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ], "parameters" : [ + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -1624,12 +1626,14 @@ "OnVehicleData" : { "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ], "parameters" : [ + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -1639,12 +1643,14 @@ "SubscribeVehicleData" : { "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ], "parameters" : [ + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus" @@ -1653,12 +1659,14 @@ "UnsubscribeVehicleData" : { "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ], "parameters" : [ + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus" diff --git a/src/components/policy/policy_external/test/json/sdl_pt_second_update.json b/src/components/policy/policy_external/test/json/sdl_pt_second_update.json index 230ad1fa4f..fe7b036f94 100644 --- a/src/components/policy/policy_external/test/json/sdl_pt_second_update.json +++ b/src/components/policy/policy_external/test/json/sdl_pt_second_update.json @@ -1609,12 +1609,14 @@ "GetVehicleData" : { "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ], "parameters" : [ + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -1624,12 +1626,14 @@ "OnVehicleData" : { "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ], "parameters" : [ + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -1639,12 +1643,14 @@ "SubscribeVehicleData" : { "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ], "parameters" : [ + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus" @@ -1653,12 +1659,14 @@ "UnsubscribeVehicleData" : { "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ], "parameters" : [ + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus" diff --git a/src/components/policy/policy_external/test/json/sdl_pt_update.json b/src/components/policy/policy_external/test/json/sdl_pt_update.json index 4e2dd3a85c..c79fd26873 100644 --- a/src/components/policy/policy_external/test/json/sdl_pt_update.json +++ b/src/components/policy/policy_external/test/json/sdl_pt_update.json @@ -1593,12 +1593,14 @@ "GetVehicleData" : { "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ], "parameters" : [ + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -1608,12 +1610,14 @@ "OnVehicleData" : { "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ], "parameters" : [ + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -1623,12 +1627,14 @@ "SubscribeVehicleData" : { "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ], "parameters" : [ + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus" @@ -1637,12 +1643,14 @@ "UnsubscribeVehicleData" : { "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ], "parameters" : [ + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus" diff --git a/src/components/policy/policy_external/test/json/sdl_update_pt_2_groups_have_params.json b/src/components/policy/policy_external/test/json/sdl_update_pt_2_groups_have_params.json index 8a3ef897c5..234f57f2db 100644 --- a/src/components/policy/policy_external/test/json/sdl_update_pt_2_groups_have_params.json +++ b/src/components/policy/policy_external/test/json/sdl_update_pt_2_groups_have_params.json @@ -483,12 +483,14 @@ "parameters": [ "bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -504,12 +506,14 @@ "parameters": [ "bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -525,12 +529,14 @@ "parameters": [ "bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus" @@ -545,12 +551,14 @@ "parameters": [ "bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus" diff --git a/src/components/policy/policy_external/test/json/sdl_update_pt_2_groups_no_params_in1.json b/src/components/policy/policy_external/test/json/sdl_update_pt_2_groups_no_params_in1.json index dcb96f147b..d309d58674 100644 --- a/src/components/policy/policy_external/test/json/sdl_update_pt_2_groups_no_params_in1.json +++ b/src/components/policy/policy_external/test/json/sdl_update_pt_2_groups_no_params_in1.json @@ -483,12 +483,14 @@ "parameters": [ "bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -504,12 +506,14 @@ "parameters": [ "bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -525,12 +529,14 @@ "parameters": [ "bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus" @@ -545,12 +551,14 @@ "parameters": [ "bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus" diff --git a/src/components/policy/policy_external/test/json/sdl_update_pt_2_groups_no_params_in1_omitted_in2.json b/src/components/policy/policy_external/test/json/sdl_update_pt_2_groups_no_params_in1_omitted_in2.json index dd7a529ec8..be38e7d706 100644 --- a/src/components/policy/policy_external/test/json/sdl_update_pt_2_groups_no_params_in1_omitted_in2.json +++ b/src/components/policy/policy_external/test/json/sdl_update_pt_2_groups_no_params_in1_omitted_in2.json @@ -483,12 +483,14 @@ "parameters": [ "bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -504,12 +506,14 @@ "parameters": [ "bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -525,12 +529,14 @@ "parameters": [ "bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus" @@ -545,12 +551,14 @@ "parameters": [ "bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus" diff --git a/src/components/policy/policy_external/test/json/sdl_update_pt_send_location.json b/src/components/policy/policy_external/test/json/sdl_update_pt_send_location.json index 14eb11d195..8686f20f0e 100644 --- a/src/components/policy/policy_external/test/json/sdl_update_pt_send_location.json +++ b/src/components/policy/policy_external/test/json/sdl_update_pt_send_location.json @@ -483,12 +483,14 @@ "parameters": [ "bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -504,12 +506,14 @@ "parameters": [ "bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -525,12 +529,14 @@ "parameters": [ "bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus" @@ -545,12 +551,14 @@ "parameters": [ "bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus" diff --git a/src/components/policy/policy_external/test/json/sdl_update_pt_send_location_all_params.json b/src/components/policy/policy_external/test/json/sdl_update_pt_send_location_all_params.json index f1e460e603..b9b693ed5b 100644 --- a/src/components/policy/policy_external/test/json/sdl_update_pt_send_location_all_params.json +++ b/src/components/policy/policy_external/test/json/sdl_update_pt_send_location_all_params.json @@ -483,12 +483,14 @@ "parameters": [ "bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -504,12 +506,14 @@ "parameters": [ "bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -525,12 +529,14 @@ "parameters": [ "bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus" @@ -545,12 +551,14 @@ "parameters": [ "bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus" diff --git a/src/components/policy/policy_external/test/json/sdl_update_pt_send_location_no_params.json b/src/components/policy/policy_external/test/json/sdl_update_pt_send_location_no_params.json index 0ba24ce484..8bbf7ea421 100644 --- a/src/components/policy/policy_external/test/json/sdl_update_pt_send_location_no_params.json +++ b/src/components/policy/policy_external/test/json/sdl_update_pt_send_location_no_params.json @@ -483,12 +483,14 @@ "parameters": [ "bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -504,12 +506,14 @@ "parameters": [ "bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -525,12 +529,14 @@ "parameters": [ "bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus" @@ -545,12 +551,14 @@ "parameters": [ "bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus" diff --git a/src/components/policy/policy_external/test/json/sdl_update_pt_send_location_some_params.json b/src/components/policy/policy_external/test/json/sdl_update_pt_send_location_some_params.json index 6e8ce0c6a7..146adaf7a7 100644 --- a/src/components/policy/policy_external/test/json/sdl_update_pt_send_location_some_params.json +++ b/src/components/policy/policy_external/test/json/sdl_update_pt_send_location_some_params.json @@ -483,12 +483,14 @@ "parameters": [ "bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -504,12 +506,14 @@ "parameters": [ "bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -525,12 +529,14 @@ "parameters": [ "bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus" @@ -545,12 +551,14 @@ "parameters": [ "bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus" diff --git a/src/components/policy/policy_external/test/json/valid_sdl_pt_update.json b/src/components/policy/policy_external/test/json/valid_sdl_pt_update.json index c384ea73e2..bc8d95302c 100644 --- a/src/components/policy/policy_external/test/json/valid_sdl_pt_update.json +++ b/src/components/policy/policy_external/test/json/valid_sdl_pt_update.json @@ -1585,12 +1585,14 @@ "GetVehicleData" : { "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ], "parameters" : [ + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -1600,12 +1602,14 @@ "OnVehicleData" : { "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ], "parameters" : [ + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -1615,12 +1619,14 @@ "SubscribeVehicleData" : { "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ], "parameters" : [ + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus" @@ -1629,12 +1635,14 @@ "UnsubscribeVehicleData" : { "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ], "parameters" : [ + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus" diff --git a/src/components/policy/policy_external/test/sql_pt_representation_test.cc b/src/components/policy/policy_external/test/sql_pt_representation_test.cc index a657a01145..0b0831eaad 100644 --- a/src/components/policy/policy_external/test/sql_pt_representation_test.cc +++ b/src/components/policy/policy_external/test/sql_pt_representation_test.cc @@ -407,7 +407,8 @@ TEST_F(SQLPTRepresentationTest, query.Prepare(query_select); query.Next(); - const int policy_tables_number = 32; + // 33 - is current total tables number created by schema + const int policy_tables_number = 33; ASSERT_EQ(policy_tables_number, query.GetInteger(0)); const std::string query_select_count_of_iap_buffer_full = diff --git a/src/components/policy/policy_regular/include/policy/cache_manager.h b/src/components/policy/policy_regular/include/policy/cache_manager.h index 8c0acd44d2..4a0a09db83 100644 --- a/src/components/policy/policy_regular/include/policy/cache_manager.h +++ b/src/components/policy/policy_regular/include/policy/cache_manager.h @@ -73,6 +73,22 @@ class CacheManager : public CacheManagerInterface { CheckPermissionResult& result); /** + * @brief Get state of request types for given application + * @param policy_app_id Unique application id + * @return request type state + */ + RequestType::State GetAppRequestTypesState( + const std::string& policy_app_id) const OVERRIDE; + + /** + * @brief Get state of request subtypes for given application + * @param policy_app_id Unique application id + * @return request subtype state + */ + RequestSubType::State GetAppRequestSubTypesState( + const std::string& policy_app_id) const OVERRIDE; + + /** * @brief Returns true if Policy Table was not updated yet * from preloaded pt file. */ @@ -597,8 +613,18 @@ class CacheManager : public CacheManagerInterface { * @param policy_app_id Unique application id * @param request_types Request types of application */ - void GetAppRequestTypes(const std::string& policy_app_id, - std::vector<std::string>& request_types) const; + void GetAppRequestTypes( + const std::string& policy_app_id, + std::vector<std::string>& request_types) const OVERRIDE; + + /** + * @brief Gets request subtypes for application + * @param policy_app_id Unique application id + * @param request_subtypes Request subtypes of application to be filled + */ + void GetAppRequestSubTypes( + const std::string& policy_app_id, + std::vector<std::string>& request_subtypes) const OVERRIDE; /** * @brief GetCertificate allows to obtain certificate in order to diff --git a/src/components/policy/policy_regular/include/policy/cache_manager_interface.h b/src/components/policy/policy_regular/include/policy/cache_manager_interface.h index 9f7c7318db..3dd2953865 100644 --- a/src/components/policy/policy_regular/include/policy/cache_manager_interface.h +++ b/src/components/policy/policy_regular/include/policy/cache_manager_interface.h @@ -46,6 +46,16 @@ namespace policy_table = rpc::policy_table_interface_base; namespace policy { +namespace RequestType { +// Describes available RequestType states in policy table +enum class State { UNAVAILABLE = 0, AVAILABLE, EMPTY, OMITTED }; +} // namespace RequestType + +namespace RequestSubType { +// Describes available RequestSubType states in policy table +enum class State { UNAVAILABLE = 0, AVAILABLE, EMPTY, OMITTED }; +} // namespace RequestSubType + class CacheManagerInterface { public: virtual ~CacheManagerInterface() {} @@ -67,6 +77,22 @@ class CacheManagerInterface { CheckPermissionResult& result) = 0; /** + * @brief Get state of request types for given application + * @param policy_app_id Unique application id + * @return request type state + */ + virtual RequestType::State GetAppRequestTypesState( + const std::string& policy_app_id) const = 0; + + /** + * @brief Get state of request subtypes for given application + * @param policy_app_id Unique application id + * @return request subtype state + */ + virtual RequestSubType::State GetAppRequestSubTypesState( + const std::string& policy_app_id) const = 0; + + /** * @brief Returns true if Policy Table was not updated yet * from preloaded pt file. */ @@ -627,6 +653,15 @@ class CacheManagerInterface { std::vector<std::string>& request_types) const = 0; /** + * @brief Gets request subtypes for application + * @param policy_app_id Unique application id + * @param request_subtypes Request subtypes of application to be filled + */ + virtual void GetAppRequestSubTypes( + const std::string& policy_app_id, + std::vector<std::string>& request_subtypes) const = 0; + + /** * @brief GetCertificate allows to obtain certificate in order to * make secure connection * diff --git a/src/components/policy/policy_regular/include/policy/policy_helper.h b/src/components/policy/policy_regular/include/policy/policy_helper.h index 8a60801dd4..7f27ab2676 100644 --- a/src/components/policy/policy_regular/include/policy/policy_helper.h +++ b/src/components/policy/policy_regular/include/policy/policy_helper.h @@ -95,7 +95,8 @@ struct CheckAppPolicy { RESULT_CONSENT_NEEDED, RESULT_CONSENT_NOT_REQIURED, RESULT_PERMISSIONS_REVOKED_AND_CONSENT_NEEDED, - RESULT_REQUEST_TYPE_CHANGED + RESULT_REQUEST_TYPE_CHANGED, + RESULT_REQUEST_SUBTYPE_CHANGED }; void SetPendingPermissions(const AppPoliciesValueType& app_policy, @@ -126,6 +127,7 @@ struct CheckAppPolicy { bool IsConsentRequired(const std::string& app_id, const std::string& group_name) const; bool IsRequestTypeChanged(const AppPoliciesValueType& app_policy) const; + bool IsRequestSubTypeChanged(const AppPoliciesValueType& app_policy) const; private: PolicyManagerImpl* pm_; diff --git a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h index 941db1a67f..8379cf4d82 100644 --- a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h +++ b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h @@ -532,6 +532,22 @@ class PolicyManagerImpl : public PolicyManager { void OnAppsSearchCompleted(const bool trigger_ptu) OVERRIDE; /** + * @brief Get state of request types for given application + * @param policy_app_id Unique application id + * @return request type state + */ + RequestType::State GetAppRequestTypesState( + const std::string& policy_app_id) const OVERRIDE; + + /** + * @brief Get state of request subtypes for given application + * @param policy_app_id Unique application id + * @return request subtype state + */ + RequestSubType::State GetAppRequestSubTypesState( + const std::string& policy_app_id) const OVERRIDE; + + /** * @brief Gets request types for application * @param policy_app_id Unique application id * @return request types of application @@ -540,6 +556,14 @@ class PolicyManagerImpl : public PolicyManager { const std::string policy_app_id) const OVERRIDE; /** + * @brief Gets request subtypes for application + * @param policy_app_id Unique application id + * @return request subtypes of application + */ + const std::vector<std::string> GetAppRequestSubTypes( + const std::string& policy_app_id) const OVERRIDE; + + /** * @brief Get information about vehicle * @return vehicle information */ diff --git a/src/components/policy/policy_regular/include/policy/policy_table/enums.h b/src/components/policy/policy_regular/include/policy/policy_table/enums.h index 4eb35d2aa4..dbe00d0f9c 100644 --- a/src/components/policy/policy_regular/include/policy/policy_table/enums.h +++ b/src/components/policy/policy_regular/include/policy/policy_table/enums.h @@ -70,6 +70,7 @@ enum Parameter { P_FUELLEVEL_STATE, P_HEADLAMPSTATUS, P_INSTANTFUELCONSUMPTION, + P_FUELRANGE, P_ODOMETER, P_TIREPRESSURE, P_WIPERSTATUS, @@ -80,6 +81,7 @@ enum Parameter { P_PRNDL, P_RPM, P_STEERINGWHEELANGLE, + P_ENGINEOILLIFE, P_MYKEY, P_AIRBAGSTATUS, P_BODYINFORMATION, @@ -132,7 +134,9 @@ enum RequestType { RT_VEHICLE_DIAGNOSTICS, RT_EMERGENCY, RT_MEDIA, - RT_FOTA + RT_FOTA, + RT_OEM_SPECIFIC, + RT_EMPTY // Added to allow empty Request Types handling }; bool IsValidEnum(RequestType val); diff --git a/src/components/policy/policy_regular/include/policy/policy_table/types.h b/src/components/policy/policy_regular/include/policy/policy_table/types.h index 992ec3c752..8197247907 100644 --- a/src/components/policy/policy_regular/include/policy/policy_table/types.h +++ b/src/components/policy/policy_regular/include/policy/policy_table/types.h @@ -96,6 +96,8 @@ typedef Map<DeviceParams, 0, 255> DeviceData; typedef Array<Enum<RequestType>, 0, 255> RequestTypes; +typedef Strings RequestSubTypes; + #ifdef SDL_REMOTE_CONTROL typedef Map<Strings, 0, 255> RemoteRpcs; typedef Map<RemoteRpcs, 0, 255> AccessModules; @@ -139,6 +141,7 @@ struct ApplicationParams : PolicyBase { Optional<Strings> nicknames; Optional<AppHMITypes> AppHMIType; Optional<RequestTypes> RequestType; + Optional<RequestSubTypes> RequestSubType; Optional<Integer<uint16_t, 0, 65225> > memory_kb; Optional<Integer<uint32_t, 0, UINT_MAX> > heart_beat_timeout_ms; Optional<String<0, 255> > certificate; diff --git a/src/components/policy/policy_regular/include/policy/policy_types.h b/src/components/policy/policy_regular/include/policy/policy_types.h index af1d119e7a..e0fc808e2f 100644 --- a/src/components/policy/policy_regular/include/policy/policy_types.h +++ b/src/components/policy/policy_regular/include/policy/policy_types.h @@ -267,7 +267,8 @@ struct AppPermissions { , appRevoked(false) , appPermissionsConsentNeeded(false) , appUnauthorized(false) - , requestTypeChanged(false) {} + , requestTypeChanged(false) + , requestSubTypeChanged(false) {} std::string application_id; bool isAppPermissionsRevoked; @@ -280,6 +281,8 @@ struct AppPermissions { DeviceParams deviceInfo; bool requestTypeChanged; std::vector<std::string> requestType; + bool requestSubTypeChanged; + std::vector<std::string> requestSubType; }; /** @@ -471,7 +474,8 @@ enum PermissionsCheckResult { RESULT_CONSENT_NEEDED, RESULT_CONSENT_NOT_REQIURED, RESULT_PERMISSIONS_REVOKED_AND_CONSENT_NEEDED, - RESULT_REQUEST_TYPE_CHANGED + RESULT_REQUEST_TYPE_CHANGED, + RESULT_REQUEST_SUBTYPE_CHANGED }; /** diff --git a/src/components/policy/policy_regular/include/policy/sql_pt_queries.h b/src/components/policy/policy_regular/include/policy/sql_pt_queries.h index 2ded25e456..5259ffa7e9 100644 --- a/src/components/policy/policy_regular/include/policy/sql_pt_queries.h +++ b/src/components/policy/policy_regular/include/policy/sql_pt_queries.h @@ -65,6 +65,7 @@ extern const std::string kSelectAppGroups; extern const std::string kSelectNicknames; extern const std::string kSelectAppTypes; extern const std::string kSelectRequestTypes; +extern const std::string kSelectRequestSubTypes; extern const std::string kSelectSecondsBetweenRetries; extern const std::string kSelectIgnitionCycles; extern const std::string kSelectKilometers; @@ -78,6 +79,9 @@ extern const std::string kInsertAppGroup; extern const std::string kInsertNickname; extern const std::string kInsertAppType; extern const std::string kInsertRequestType; +extern const std::string kInsertOmittedRequestType; +extern const std::string kInsertOmittedRequestSubType; +extern const std::string kInsertRequestSubType; extern const std::string kInsertMessageType; extern const std::string kInsertLanguage; extern const std::string kInsertMessageString; @@ -97,6 +101,7 @@ extern const std::string kDeleteRpc; extern const std::string kDeleteAppGroup; extern const std::string kDeleteApplication; extern const std::string kDeleteRequestType; +extern const std::string kDeleteRequestSubType; extern const std::string kDeleteDevice; extern const std::string kIncrementIgnitionCycles; extern const std::string kResetIgnitionCycles; diff --git a/src/components/policy/policy_regular/include/policy/sql_pt_representation.h b/src/components/policy/policy_regular/include/policy/sql_pt_representation.h index 6b5d6111f1..e39e0d5873 100644 --- a/src/components/policy/policy_regular/include/policy/sql_pt_representation.h +++ b/src/components/policy/policy_regular/include/policy/sql_pt_representation.h @@ -132,6 +132,9 @@ class SQLPTRepresentation : public virtual PTRepresentation { policy_table::AppHMITypes* app_types) const; bool GatherRequestType(const std::string& app_id, policy_table::RequestTypes* request_types) const; + bool GatherRequestSubType( + const std::string& app_id, + policy_table::RequestSubTypes* request_subtypes) const; bool GatherNickName(const std::string& app_id, policy_table::Strings* nicknames) const; @@ -167,6 +170,9 @@ class SQLPTRepresentation : public virtual PTRepresentation { const policy_table::AppHMITypes& types); bool SaveRequestType(const std::string& app_id, const policy_table::RequestTypes& types); + bool SaveRequestSubType( + const std::string& app_id, + const policy_table::RequestSubTypes& request_subtypes); public: bool UpdateRequired() const; diff --git a/src/components/policy/policy_regular/policy_table_interface_ext.xml b/src/components/policy/policy_regular/policy_table_interface_ext.xml index e82b3ad777..93edce3e3a 100644 --- a/src/components/policy/policy_regular/policy_table_interface_ext.xml +++ b/src/components/policy/policy_regular/policy_table_interface_ext.xml @@ -1,3 +1,4 @@ + <?xml version="1.0" standalone="no"?> <?xml-stylesheet type="text/xml" href="protocol2html.xsl"?> @@ -30,6 +31,7 @@ <element name="fuelLevel_State" /> <element name="headLampStatus" /> <element name="instantFuelConsumption" /> + <element name="fuelRange" /> <element name="odometer" /> <element name="tirePressure" /> <element name="wiperStatus" /> @@ -40,6 +42,7 @@ <element name="prndl" /> <element name="rpm" /> <element name="steeringWheelAngle" /> + <element name="engineOilLife" /> <element name="myKey" /> <element name="airbagStatus" /> <element name="bodyInformation" /> diff --git a/src/components/policy/policy_regular/src/cache_manager.cc b/src/components/policy/policy_regular/src/cache_manager.cc index 6a142374d5..1d51b81af4 100644 --- a/src/components/policy/policy_regular/src/cache_manager.cc +++ b/src/components/policy/policy_regular/src/cache_manager.cc @@ -39,6 +39,7 @@ #include <sstream> #include "utils/file_system.h" +#include "utils/helpers.h" #include "json/reader.h" #include "json/features.h" #include "json/writer.h" @@ -1550,6 +1551,32 @@ int32_t CacheManager::GenerateHash(const std::string& str_to_hash) { return result; } +RequestType::State CacheManager::GetAppRequestTypesState( + const std::string& policy_app_id) const { + LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock auto_lock(cache_lock_); + policy_table::ApplicationPolicies::iterator app_policies_iter = + pt_->policy_table.app_policies_section.apps.find(policy_app_id); + if (pt_->policy_table.app_policies_section.apps.end() == app_policies_iter) { + LOG4CXX_DEBUG(logger_, + "Can't find request types for app_id " << policy_app_id); + return RequestType::State::UNAVAILABLE; + } + const policy_table::RequestTypes& request_types = + *app_policies_iter->second.RequestType; + if (!request_types.is_initialized()) { + LOG4CXX_DEBUG(logger_, + "Request types for " << policy_app_id << " are OMITTED"); + return RequestType::State::OMITTED; + } + if (request_types.empty()) { + LOG4CXX_DEBUG(logger_, + "Request types for " << policy_app_id << " are EMPTY"); + return RequestType::State::EMPTY; + } + return RequestType::State::AVAILABLE; +} + void CacheManager::GetAppRequestTypes( const std::string& policy_app_id, std::vector<std::string>& request_types) const { @@ -1568,11 +1595,60 @@ void CacheManager::GetAppRequestTypes( "Can't find request types for app_id " << policy_app_id); return; } - policy_table::RequestTypes::iterator it_request_type = - policy_iter->second.RequestType->begin(); - for (; it_request_type != policy_iter->second.RequestType->end(); - ++it_request_type) { - request_types.push_back(EnumToJsonString(*it_request_type)); + + for (const auto& request_type : *policy_iter->second.RequestType) { + request_types.push_back(EnumToJsonString(request_type)); + } + return; +} + +RequestSubType::State CacheManager::GetAppRequestSubTypesState( + const std::string& policy_app_id) const { + LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock auto_lock(cache_lock_); + policy_table::ApplicationPolicies::iterator app_policies_iter = + pt_->policy_table.app_policies_section.apps.find(policy_app_id); + if (pt_->policy_table.app_policies_section.apps.end() == app_policies_iter) { + LOG4CXX_DEBUG(logger_, + "Can't find request subtypes for app_id " << policy_app_id); + return RequestSubType::State::UNAVAILABLE; + } + const policy_table::RequestSubTypes& request_subtypes = + *app_policies_iter->second.RequestSubType; + if (!request_subtypes.is_initialized()) { + LOG4CXX_DEBUG(logger_, + "Request subtypes for " << policy_app_id << " are OMITTED"); + return RequestSubType::State::OMITTED; + } + if (request_subtypes.empty()) { + LOG4CXX_DEBUG(logger_, + "Request subtypes for " << policy_app_id << " are EMPTY"); + return RequestSubType::State::EMPTY; + } + return RequestSubType::State::AVAILABLE; +} + +void CacheManager::GetAppRequestSubTypes( + const std::string& policy_app_id, + std::vector<std::string>& request_types) const { + LOG4CXX_AUTO_TRACE(logger_); + CACHE_MANAGER_CHECK_VOID(); + sync_primitives::AutoLock auto_lock(cache_lock_); + if (kDeviceId == policy_app_id) { + LOG4CXX_DEBUG(logger_, + "Request subtypes not applicable for app_id " << kDeviceId); + return; + } + policy_table::ApplicationPolicies::iterator policy_iter = + pt_->policy_table.app_policies_section.apps.find(policy_app_id); + if (pt_->policy_table.app_policies_section.apps.end() == policy_iter) { + LOG4CXX_DEBUG(logger_, + "Can't find request subtypes for app_id " << policy_app_id); + return; + } + + for (const auto& request_subtype : *policy_iter->second.RequestSubType) { + request_types.push_back(request_subtype); } return; } diff --git a/src/components/policy/policy_regular/src/policy_helper.cc b/src/components/policy/policy_regular/src/policy_helper.cc index 95f275769c..796dd25ec4 100644 --- a/src/components/policy/policy_regular/src/policy_helper.cc +++ b/src/components/policy/policy_regular/src/policy_helper.cc @@ -339,9 +339,20 @@ bool CheckAppPolicy::operator()(const AppPoliciesValueType& app_policy) { } PermissionsCheckResult result = CheckPermissionsChanges(app_policy); - if (!IsPredefinedApp(app_policy) && IsRequestTypeChanged(app_policy)) { - SetPendingPermissions(app_policy, RESULT_REQUEST_TYPE_CHANGED); - NotifySystem(app_policy); + if (!IsPredefinedApp(app_policy)) { + const bool is_request_type_changed = IsRequestTypeChanged(app_policy); + const bool is_request_subtype_changed = IsRequestSubTypeChanged(app_policy); + + if (is_request_type_changed) { + SetPendingPermissions(app_policy, RESULT_REQUEST_TYPE_CHANGED); + } + if (is_request_subtype_changed) { + SetPendingPermissions(app_policy, RESULT_REQUEST_SUBTYPE_CHANGED); + } + + if (is_request_type_changed || is_request_subtype_changed) { + NotifySystem(app_policy); + } } if (RESULT_NO_CHANGES == result) { LOG4CXX_INFO(logger_, @@ -412,17 +423,19 @@ void policy::CheckAppPolicy::SetPendingPermissions( case RESULT_REQUEST_TYPE_CHANGED: permissions_diff.priority.clear(); permissions_diff.requestTypeChanged = true; - { - // Getting RequestTypes from PTU (not from cache) - policy_table::RequestTypes::const_iterator it_request_type = - app_policy.second.RequestType->begin(); - for (; app_policy.second.RequestType->end() != it_request_type; - ++it_request_type) { - permissions_diff.requestType.push_back( - EnumToJsonString(*it_request_type)); - } - } + // Getting Request Types from PTU (not from cache) + for (const auto& request_type : *app_policy.second.RequestType) { + permissions_diff.requestType.push_back(EnumToJsonString(request_type)); + } + break; + case RESULT_REQUEST_SUBTYPE_CHANGED: + permissions_diff.priority.clear(); + permissions_diff.requestSubTypeChanged = true; + // Getting Request SubTypes from PTU (not from cache) + for (const auto& request_subtype : *app_policy.second.RequestSubType) { + permissions_diff.requestSubType.push_back(request_subtype); + } break; default: return; @@ -491,6 +504,32 @@ bool CheckAppPolicy::IsRequestTypeChanged( return diff.size(); } +bool CheckAppPolicy::IsRequestSubTypeChanged( + const AppPoliciesValueType& app_policy) const { + policy::AppPoliciesConstItr it = + snapshot_->policy_table.app_policies_section.apps.find(app_policy.first); + + if (it == snapshot_->policy_table.app_policies_section.apps.end()) { + if (!app_policy.second.RequestSubType->empty()) { + return true; + } + return false; + } + + if (it->second.RequestSubType->size() != + app_policy.second.RequestSubType->size()) { + return true; + } + + policy_table::RequestSubTypes diff; + std::set_difference(it->second.RequestSubType->begin(), + it->second.RequestSubType->end(), + app_policy.second.RequestSubType->begin(), + app_policy.second.RequestSubType->end(), + std::back_inserter(diff)); + return diff.size(); +} + FillNotificationData::FillNotificationData(Permissions& data, GroupConsent group_state, GroupConsent undefined_group_consent) diff --git a/src/components/policy/policy_regular/src/policy_manager_impl.cc b/src/components/policy/policy_regular/src/policy_manager_impl.cc index 3e08147a4c..a48a9a1ba0 100644 --- a/src/components/policy/policy_regular/src/policy_manager_impl.cc +++ b/src/components/policy/policy_regular/src/policy_manager_impl.cc @@ -385,6 +385,25 @@ const std::vector<std::string> PolicyManagerImpl::GetAppRequestTypes( return request_types; } +RequestType::State PolicyManagerImpl::GetAppRequestTypesState( + const std::string& policy_app_id) const { + LOG4CXX_AUTO_TRACE(logger_); + return cache_->GetAppRequestTypesState(policy_app_id); +} + +RequestSubType::State PolicyManagerImpl::GetAppRequestSubTypesState( + const std::string& policy_app_id) const { + LOG4CXX_AUTO_TRACE(logger_); + return cache_->GetAppRequestSubTypesState(policy_app_id); +} + +const std::vector<std::string> PolicyManagerImpl::GetAppRequestSubTypes( + const std::string& policy_app_id) const { + std::vector<std::string> request_subtypes; + cache_->GetAppRequestSubTypes(policy_app_id, request_subtypes); + return request_subtypes; +} + const VehicleInfo PolicyManagerImpl::GetVehicleInfo() const { return cache_->GetVehicleInfo(); } diff --git a/src/components/policy/policy_regular/src/policy_table/enums.cc b/src/components/policy/policy_regular/src/policy_table/enums.cc index 34d12420d8..1dae9c5f96 100644 --- a/src/components/policy/policy_regular/src/policy_table/enums.cc +++ b/src/components/policy/policy_regular/src/policy_table/enums.cc @@ -127,6 +127,8 @@ bool IsValidEnum(Parameter val) { return true; case P_INSTANTFUELCONSUMPTION: return true; + case P_FUELRANGE: + return true; case P_ODOMETER: return true; case P_TIREPRESSURE: @@ -147,6 +149,8 @@ bool IsValidEnum(Parameter val) { return true; case P_STEERINGWHEELANGLE: return true; + case P_ENGINEOILLIFE: + return true; case P_MYKEY: return true; case P_AIRBAGSTATUS: @@ -185,6 +189,8 @@ const char* EnumToJsonString(Parameter val) { return "headLampStatus"; case P_INSTANTFUELCONSUMPTION: return "instantFuelConsumption"; + case P_FUELRANGE: + return "fuelRange"; case P_ODOMETER: return "odometer"; case P_TIREPRESSURE: @@ -205,6 +211,8 @@ const char* EnumToJsonString(Parameter val) { return "rpm"; case P_STEERINGWHEELANGLE: return "steeringWheelAngle"; + case P_ENGINEOILLIFE: + return "engineOilLife"; case P_MYKEY: return "myKey"; case P_AIRBAGSTATUS: @@ -251,6 +259,9 @@ bool EnumFromJsonString(const std::string& literal, Parameter* result) { } else if ("instantFuelConsumption" == literal) { *result = P_INSTANTFUELCONSUMPTION; return true; + } else if ("fuelRange" == literal) { + *result = P_FUELRANGE; + return true; } else if ("odometer" == literal) { *result = P_ODOMETER; return true; @@ -281,6 +292,9 @@ bool EnumFromJsonString(const std::string& literal, Parameter* result) { } else if ("steeringWheelAngle" == literal) { *result = P_STEERINGWHEELANGLE; return true; + } else if ("engineOilLife" == literal) { + *result = P_ENGINEOILLIFE; + return true; } else if ("myKey" == literal) { *result = P_MYKEY; return true; @@ -454,6 +468,10 @@ bool IsValidEnum(RequestType val) { return true; case RT_FOTA: return true; + case RT_OEM_SPECIFIC: + return true; + case RT_EMPTY: + return true; default: return false; } @@ -501,6 +519,10 @@ const char* EnumToJsonString(RequestType val) { return "MEDIA"; case RT_FOTA: return "FOTA"; + case RT_OEM_SPECIFIC: + return "OEM_SPECIFIC"; + case RT_EMPTY: + return "EMPTY"; default: return ""; } @@ -586,6 +608,14 @@ bool EnumFromJsonString(const std::string& literal, RequestType* result) { if ("FOTA" == literal) { *result = RT_FOTA; return true; + } + if ("OEM_SPECIFIC" == literal) { + *result = RT_OEM_SPECIFIC; + return true; + } + if ("EMPTY" == literal) { + *result = RT_EMPTY; + return true; } else { return false; } diff --git a/src/components/policy/policy_regular/src/policy_table/types.cc b/src/components/policy/policy_regular/src/policy_table/types.cc index 5f6f85f5dd..c4846c0d40 100644 --- a/src/components/policy/policy_regular/src/policy_table/types.cc +++ b/src/components/policy/policy_regular/src/policy_table/types.cc @@ -164,6 +164,7 @@ ApplicationParams::ApplicationParams(const Json::Value* value__) , nicknames(impl::ValueMember(value__, "nicknames")) , AppHMIType(impl::ValueMember(value__, "AppHMIType")) , RequestType(impl::ValueMember(value__, "RequestType")) + , RequestSubType(impl::ValueMember(value__, "RequestSubType")) , memory_kb(impl::ValueMember(value__, "memory_kb"), 0) , heart_beat_timeout_ms(impl::ValueMember(value__, "heart_beat_timeout_ms")) , certificate(impl::ValueMember(value__, "certificate"), "not_specified") @@ -179,6 +180,7 @@ Json::Value ApplicationParams::ToJsonValue() const { impl::WriteJsonField("nicknames", nicknames, &result__); impl::WriteJsonField("AppHMIType", AppHMIType, &result__); impl::WriteJsonField("RequestType", RequestType, &result__); + impl::WriteJsonField("RequestSubType", RequestSubType, &result__); impl::WriteJsonField("memory_kb", memory_kb, &result__); impl::WriteJsonField( "heart_beat_timeout_ms", heart_beat_timeout_ms, &result__); @@ -189,7 +191,8 @@ Json::Value ApplicationParams::ToJsonValue() const { } bool ApplicationParams::is_valid() const { - // RequestType is not validated since there is high-level validation logic, + // RequestType and RequestSubType are not validated since there is high-level + // validation logic, // which takes into account information not available here. if (!PolicyBase::is_valid()) { return false; @@ -240,6 +243,9 @@ bool ApplicationParams::struct_empty() const { if (RequestType.is_initialized()) { return false; } + if (RequestSubType.is_initialized()) { + return false; + } if (memory_kb.is_initialized()) { return false; } @@ -273,6 +279,9 @@ void ApplicationParams::ReportErrors(rpc::ValidationReport* report__) const { if (!RequestType.is_valid()) { RequestType.ReportErrors(&report__->ReportSubobject("RequestType")); } + if (!RequestSubType.is_valid()) { + RequestSubType.ReportErrors(&report__->ReportSubobject("RequestSubType")); + } if (!priority.is_valid()) { priority.ReportErrors(&report__->ReportSubobject("priority")); } @@ -298,6 +307,7 @@ void ApplicationParams::SetPolicyTableType(PolicyTableType pt_type) { groups.SetPolicyTableType(pt_type); AppHMIType.SetPolicyTableType(pt_type); RequestType.SetPolicyTableType(pt_type); + RequestSubType.SetPolicyTableType(pt_type); memory_kb.SetPolicyTableType(pt_type); heart_beat_timeout_ms.SetPolicyTableType(pt_type); certificate.SetPolicyTableType(pt_type); diff --git a/src/components/policy/policy_regular/src/policy_table/validation.cc b/src/components/policy/policy_regular/src/policy_table/validation.cc index 10b8e4bf7c..e760293ea6 100644 --- a/src/components/policy/policy_regular/src/policy_table/validation.cc +++ b/src/components/policy/policy_regular/src/policy_table/validation.cc @@ -40,11 +40,12 @@ bool ApplicationPoliciesSection::Validate() const { return false; } - PolicyTableType pt_type = GetPolicyTableType(); + const PolicyTableType pt_type = GetPolicyTableType(); if (PT_PRELOADED != pt_type && PT_UPDATE != pt_type) { return true; } + LOG4CXX_TRACE(logger_, "Checking app Request Types..."); if (!it_default_policy->second.RequestType.is_valid()) { LOG4CXX_WARN(logger_, "Default policy RequestTypes are not valid. Will be cleaned."); @@ -65,10 +66,15 @@ bool ApplicationPoliciesSection::Validate() const { ApplicationPolicies::iterator end_iter = apps.end(); while (iter != end_iter) { + if (it_default_policy == iter || it_pre_data_policy == iter) { + ++iter; + continue; + } ApplicationParams& app_params = (*iter).second; - bool is_request_type_omitted = !app_params.RequestType.is_initialized(); - bool is_request_type_valid = app_params.RequestType.is_valid(); - bool is_request_type_empty = app_params.RequestType->empty(); + const bool is_request_type_omitted = + !app_params.RequestType.is_initialized(); + const bool is_request_type_valid = app_params.RequestType.is_valid(); + const bool is_request_type_empty = app_params.RequestType->empty(); if (PT_PRELOADED == pt_type) { if (!is_request_type_valid) { @@ -111,6 +117,33 @@ bool ApplicationPoliciesSection::Validate() const { ++iter; } + LOG4CXX_TRACE(logger_, "Checking app Request SubTypes..."); + iter = apps.begin(); + while (iter != end_iter) { + if (it_default_policy == iter || it_pre_data_policy == iter) { + ++iter; + continue; + } + ApplicationParams& app_params = (*iter).second; + const bool is_request_subtype_omitted = + !app_params.RequestSubType.is_initialized(); + + if (is_request_subtype_omitted) { + LOG4CXX_WARN(logger_, + "App policy RequestSubTypes omitted." + " Will be replaced with default."); + app_params.RequestSubType = apps[kDefaultApp].RequestSubType; + ++iter; + continue; + } + + const bool is_request_subtype_empty = app_params.RequestSubType->empty(); + if (is_request_subtype_empty) { + LOG4CXX_WARN(logger_, "App policy RequestSubTypes empty."); + } + ++iter; + } + return true; } diff --git a/src/components/policy/policy_regular/src/sql_pt_queries.cc b/src/components/policy/policy_regular/src/sql_pt_queries.cc index ef4ef49273..91a5573a04 100644 --- a/src/components/policy/policy_regular/src/sql_pt_queries.cc +++ b/src/components/policy/policy_regular/src/sql_pt_queries.cc @@ -258,13 +258,21 @@ const std::string kCreateSchema = " REFERENCES `application`(`id`) " "); " "CREATE TABLE IF NOT EXISTS `request_type`( " - " `request_type` VARCHAR(50) NOT NULL, " + " `request_type` VARCHAR(50), " " `application_id` VARCHAR(45) NOT NULL COLLATE NOCASE, " " PRIMARY KEY(`request_type`,`application_id`), " " CONSTRAINT `fk_app_type_application1` " " FOREIGN KEY(`application_id`) " " REFERENCES `application`(`id`) " "); " + "CREATE TABLE IF NOT EXISTS `request_subtype`( " + " `request_subtype` VARCHAR(50), " + " `application_id` VARCHAR(45) NOT NULL COLLATE NOCASE, " + " PRIMARY KEY(`request_subtype`,`application_id`), " + " CONSTRAINT `fk_request_subtype_app_id` " + " FOREIGN KEY(`application_id`) " + " REFERENCES `application`(`id`) " + "); " "CREATE INDEX IF NOT EXISTS `app_type.fk_app_type_application1_idx` " " ON `app_type`(`application_id` COLLATE NOCASE); " "CREATE TABLE IF NOT EXISTS `consent_group`( " @@ -440,6 +448,8 @@ const std::string kDropSchema = "DROP TABLE IF EXISTS `consent_group`; " "DROP INDEX IF EXISTS `app_type.fk_app_type_application1_idx`; " "DROP TABLE IF EXISTS `app_type`; " + "DROP TABLE IF EXISTS `request_type`; " + "DROP TABLE IF EXISTS `request_subtype`; " "DROP INDEX IF EXISTS `nickname.fk_nickname_application1_idx`; " "DROP TABLE IF EXISTS `nickname`; " "DROP INDEX IF EXISTS `app_level.fk_app_level_language2_idx`; " @@ -582,9 +592,22 @@ const std::string kInsertAppType = "INSERT OR IGNORE INTO `app_type` (`application_id`, `name`) VALUES (?, ?)"; const std::string kInsertRequestType = - "INSERT OR IGNORE INTO `request_type` (`application_id`, `request_type`) " + "INSERT INTO `request_type` (`application_id`, `request_type`) " "VALUES (?, ?)"; +const std::string kInsertOmittedRequestType = + "INSERT INTO `request_type` (`application_id`) " + "VALUES (?)"; + +const std::string kInsertRequestSubType = + "INSERT INTO `request_subtype` (`application_id`, " + "`request_subtype`) " + "VALUES (?, ?)"; + +const std::string kInsertOmittedRequestSubType = + "INSERT INTO `request_subtype` (`application_id`) " + "VALUES (?)"; + const std::string kUpdateVersion = "UPDATE `version` SET `number`= ?"; const std::string kInsertMessageType = @@ -695,6 +718,11 @@ const std::string kSelectRequestTypes = "SELECT DISTINCT `request_type` FROM `request_type` WHERE `application_id` " "= ?"; +const std::string kSelectRequestSubTypes = + "SELECT DISTINCT `request_subtype` FROM `request_subtype` WHERE " + "`application_id` " + "= ?"; + const std::string kSelectSecondsBetweenRetries = "SELECT `value` FROM `seconds_between_retry` ORDER BY `index`"; @@ -740,6 +768,8 @@ const std::string kDeleteApplication = "DELETE FROM `application`"; const std::string kDeleteRequestType = "DELETE FROM `request_type`"; +const std::string kDeleteRequestSubType = "DELETE FROM `request_subtype`"; + const std::string kSelectApplicationRevoked = "SELECT `is_revoked` FROM `application` WHERE `id` = ?"; diff --git a/src/components/policy/policy_regular/src/sql_pt_representation.cc b/src/components/policy/policy_regular/src/sql_pt_representation.cc index 9840a08b26..a57230aeb1 100644 --- a/src/components/policy/policy_regular/src/sql_pt_representation.cc +++ b/src/components/policy/policy_regular/src/sql_pt_representation.cc @@ -744,6 +744,10 @@ bool SQLPTRepresentation::GatherApplicationPoliciesSection( return false; } + if (!GatherRequestSubType(app_id, &*params.RequestSubType)) { + return false; + } + (*policies).apps[app_id] = params; } return true; @@ -837,6 +841,7 @@ bool SQLPTRepresentation::SaveFunctionalGroupings( bool SQLPTRepresentation::SaveRpcs(int64_t group_id, const policy_table::Rpc& rpcs) { + LOG4CXX_AUTO_TRACE(logger_); utils::dbms::SQLQuery query(db()); utils::dbms::SQLQuery query_parameter(db()); if (!query.Prepare(sql_pt::kInsertRpc) || @@ -916,6 +921,11 @@ bool SQLPTRepresentation::SaveApplicationPoliciesSection( return false; } + if (!query_delete.Exec(sql_pt::kDeleteRequestSubType)) { + LOG4CXX_WARN(logger_, "Incorrect delete from request subtype."); + return false; + } + // All predefined apps (e.g. default, pre_DataConsent) should be saved first, // otherwise another app with the predefined permissions can get incorrect // permissions @@ -1006,6 +1016,10 @@ bool SQLPTRepresentation::SaveSpecificAppPolicy( return false; } + if (!SaveRequestSubType(app.first, *app.second.RequestSubType)) { + return false; + } + return true; } @@ -1109,15 +1123,83 @@ bool SQLPTRepresentation::SaveRequestType( } policy_table::RequestTypes::const_iterator it; - for (it = types.begin(); it != types.end(); ++it) { + if (!types.empty()) { + LOG4CXX_WARN(logger_, "Request types not empty."); + for (it = types.begin(); it != types.end(); ++it) { + query.Bind(0, app_id); + query.Bind(1, std::string(policy_table::EnumToJsonString(*it))); + if (!query.Exec() || !query.Reset()) { + LOG4CXX_WARN(logger_, "Incorrect insert into request types."); + return false; + } + } + } else if (types.is_initialized()) { + LOG4CXX_WARN(logger_, "Request types empty."); query.Bind(0, app_id); - query.Bind(1, std::string(policy_table::EnumToJsonString(*it))); + query.Bind(1, + std::string(policy_table::EnumToJsonString( + policy_table::RequestType::RT_EMPTY))); if (!query.Exec() || !query.Reset()) { LOG4CXX_WARN(logger_, "Incorrect insert into request types."); return false; } + } else { + utils::dbms::SQLQuery query_omitted(db()); + if (!query_omitted.Prepare(sql_pt::kInsertOmittedRequestType)) { + LOG4CXX_WARN(logger_, "Incorrect insert statement for request types."); + return false; + } + LOG4CXX_WARN(logger_, "Request types omitted."); + query_omitted.Bind(0, app_id); + if (!query_omitted.Exec() || !query_omitted.Reset()) { + LOG4CXX_WARN(logger_, "Incorrect insert into request types."); + return false; + } + } + return true; +} + +bool SQLPTRepresentation::SaveRequestSubType( + const std::string& app_id, + const policy_table::RequestSubTypes& request_subtypes) { + utils::dbms::SQLQuery query(db()); + if (!query.Prepare(sql_pt::kInsertRequestSubType)) { + LOG4CXX_WARN(logger_, "Incorrect insert statement for request subtypes."); + return false; } + policy_table::Strings::const_iterator it; + if (!request_subtypes.empty()) { + LOG4CXX_TRACE(logger_, "Request subtypes are not empty."); + for (it = request_subtypes.begin(); it != request_subtypes.end(); ++it) { + query.Bind(0, app_id); + query.Bind(1, *it); + if (!query.Exec() || !query.Reset()) { + LOG4CXX_WARN(logger_, "Incorrect insert into request subtypes."); + return false; + } + } + } else if (request_subtypes.is_initialized()) { + LOG4CXX_WARN(logger_, "Request subtypes empty."); + query.Bind(0, app_id); + query.Bind(1, std::string("EMPTY")); + if (!query.Exec() || !query.Reset()) { + LOG4CXX_WARN(logger_, "Incorrect insert into request subtypes."); + return false; + } + } else { + utils::dbms::SQLQuery query_omitted(db()); + if (!query_omitted.Prepare(sql_pt::kInsertOmittedRequestSubType)) { + LOG4CXX_WARN(logger_, "Incorrect insert statement for request subtypes."); + return false; + } + LOG4CXX_WARN(logger_, "Request subtypes omitted."); + query_omitted.Bind(0, app_id); + if (!query_omitted.Exec() || !query_omitted.Reset()) { + LOG4CXX_WARN(logger_, "Incorrect insert into request subtypes."); + return false; + } + } return true; } @@ -1529,11 +1611,36 @@ bool SQLPTRepresentation::GatherRequestType( if (!policy_table::EnumFromJsonString(query.GetString(0), &type)) { return false; } + if (policy_table::RequestType::RT_EMPTY == type) { + request_types->mark_initialized(); + continue; + } request_types->push_back(type); } return true; } +bool SQLPTRepresentation::GatherRequestSubType( + const std::string& app_id, + policy_table::RequestSubTypes* request_subtypes) const { + utils::dbms::SQLQuery query(db()); + if (!query.Prepare(sql_pt::kSelectRequestSubTypes)) { + LOG4CXX_WARN(logger_, "Incorrect select from request subtypes."); + return false; + } + + query.Bind(0, app_id); + while (query.Next()) { + const std::string request_subtype = query.GetString(0); + if ("EMPTY" == request_subtype) { + request_subtypes->mark_initialized(); + continue; + } + request_subtypes->push_back(request_subtype); + } + return true; +} + bool SQLPTRepresentation::GatherNickName( const std::string& app_id, policy_table::Strings* nicknames) const { utils::dbms::SQLQuery query(db()); @@ -1858,6 +1965,13 @@ bool SQLPTRepresentation::SetDefaultPolicy(const std::string& app_id) { !SaveRequestType(app_id, request_types)) { return false; } + + policy_table::Strings request_subtypes; + if (!GatherRequestSubType(kDefaultId, &request_subtypes) || + !SaveRequestSubType(app_id, request_subtypes)) { + return false; + } + policy_table::AppHMITypes app_types; if (!GatherAppType(kDefaultId, &app_types) || !SaveAppType(app_id, app_types)) { diff --git a/src/components/policy/policy_regular/test/PTU.json b/src/components/policy/policy_regular/test/PTU.json index d9f70426d1..7d6837f94e 100644 --- a/src/components/policy/policy_regular/test/PTU.json +++ b/src/components/policy/policy_regular/test/PTU.json @@ -349,12 +349,14 @@ "LIMITED"], "parameters": ["bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -366,12 +368,14 @@ "LIMITED"], "parameters": ["bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -383,12 +387,14 @@ "LIMITED"], "parameters": ["bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus"] @@ -399,12 +405,14 @@ "LIMITED"], "parameters": ["bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus"] diff --git a/src/components/policy/policy_regular/test/PTU2.json b/src/components/policy/policy_regular/test/PTU2.json index b4c3c0624c..7a5c29410c 100644 --- a/src/components/policy/policy_regular/test/PTU2.json +++ b/src/components/policy/policy_regular/test/PTU2.json @@ -349,12 +349,14 @@ "LIMITED"], "parameters": ["bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -366,12 +368,14 @@ "LIMITED"], "parameters": ["bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -383,12 +387,14 @@ "LIMITED"], "parameters": ["bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus"] @@ -399,12 +405,14 @@ "LIMITED"], "parameters": ["bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus"] diff --git a/src/components/policy/policy_regular/test/PTU3.json b/src/components/policy/policy_regular/test/PTU3.json index 6309bd9cfd..1b3340ec8c 100644 --- a/src/components/policy/policy_regular/test/PTU3.json +++ b/src/components/policy/policy_regular/test/PTU3.json @@ -349,12 +349,14 @@ "LIMITED"], "parameters": ["bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -366,12 +368,14 @@ "LIMITED"], "parameters": ["bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -383,12 +387,14 @@ "LIMITED"], "parameters": ["bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus"] @@ -399,12 +405,14 @@ "LIMITED"], "parameters": ["bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus"] diff --git a/src/components/policy/policy_regular/test/PTU4.json b/src/components/policy/policy_regular/test/PTU4.json index 651a4cb2ef..9aa04dd8ba 100644 --- a/src/components/policy/policy_regular/test/PTU4.json +++ b/src/components/policy/policy_regular/test/PTU4.json @@ -349,12 +349,14 @@ "LIMITED"], "parameters": ["bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -366,12 +368,14 @@ "LIMITED"], "parameters": ["bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -383,12 +387,14 @@ "LIMITED"], "parameters": ["bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus"] @@ -399,12 +405,14 @@ "LIMITED"], "parameters": ["bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus"] diff --git a/src/components/policy/policy_regular/test/ptu2_requestType.json b/src/components/policy/policy_regular/test/ptu2_requestType.json index e25095bb9f..e127b2fad6 100644 --- a/src/components/policy/policy_regular/test/ptu2_requestType.json +++ b/src/components/policy/policy_regular/test/ptu2_requestType.json @@ -485,12 +485,14 @@ "parameters": [ "bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -506,12 +508,14 @@ "parameters": [ "bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -527,12 +531,14 @@ "parameters": [ "bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus" @@ -547,12 +553,14 @@ "parameters": [ "bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus" diff --git a/src/components/policy/policy_regular/test/ptu_requestType.json b/src/components/policy/policy_regular/test/ptu_requestType.json index c5aa6f0a6c..bd6a86dac3 100644 --- a/src/components/policy/policy_regular/test/ptu_requestType.json +++ b/src/components/policy/policy_regular/test/ptu_requestType.json @@ -485,12 +485,14 @@ "parameters": [ "bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -506,12 +508,14 @@ "parameters": [ "bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -527,12 +531,14 @@ "parameters": [ "bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus" @@ -547,12 +553,14 @@ "parameters": [ "bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus" diff --git a/src/components/policy/policy_regular/test/sdl_preloaded_pt.json b/src/components/policy/policy_regular/test/sdl_preloaded_pt.json index 1f477175be..ced0a9d603 100644 --- a/src/components/policy/policy_regular/test/sdl_preloaded_pt.json +++ b/src/components/policy/policy_regular/test/sdl_preloaded_pt.json @@ -350,12 +350,14 @@ "LIMITED"], "parameters": ["bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -367,12 +369,14 @@ "LIMITED"], "parameters": ["bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -384,12 +388,14 @@ "LIMITED"], "parameters": ["bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus"] @@ -400,12 +406,14 @@ "LIMITED"], "parameters": ["bodyInformation", "deviceStatus", + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus"] diff --git a/src/components/policy/policy_regular/test/sdl_pt_first_update.json b/src/components/policy/policy_regular/test/sdl_pt_first_update.json index ac2b18ab6f..f8be46d2b5 100644 --- a/src/components/policy/policy_regular/test/sdl_pt_first_update.json +++ b/src/components/policy/policy_regular/test/sdl_pt_first_update.json @@ -1609,12 +1609,14 @@ "GetVehicleData" : { "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ], "parameters" : [ + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -1624,12 +1626,14 @@ "OnVehicleData" : { "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ], "parameters" : [ + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -1639,12 +1643,14 @@ "SubscribeVehicleData" : { "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ], "parameters" : [ + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus" @@ -1653,12 +1659,14 @@ "UnsubscribeVehicleData" : { "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ], "parameters" : [ + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus" diff --git a/src/components/policy/policy_regular/test/sdl_pt_second_update.json b/src/components/policy/policy_regular/test/sdl_pt_second_update.json index 230ad1fa4f..fe7b036f94 100644 --- a/src/components/policy/policy_regular/test/sdl_pt_second_update.json +++ b/src/components/policy/policy_regular/test/sdl_pt_second_update.json @@ -1609,12 +1609,14 @@ "GetVehicleData" : { "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ], "parameters" : [ + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -1624,12 +1626,14 @@ "OnVehicleData" : { "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ], "parameters" : [ + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -1639,12 +1643,14 @@ "SubscribeVehicleData" : { "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ], "parameters" : [ + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus" @@ -1653,12 +1659,14 @@ "UnsubscribeVehicleData" : { "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ], "parameters" : [ + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus" diff --git a/src/components/policy/policy_regular/test/sdl_pt_update.json b/src/components/policy/policy_regular/test/sdl_pt_update.json index f890e8e5ae..e013243760 100644 --- a/src/components/policy/policy_regular/test/sdl_pt_update.json +++ b/src/components/policy/policy_regular/test/sdl_pt_update.json @@ -1587,12 +1587,14 @@ "GetVehicleData" : { "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ], "parameters" : [ + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -1602,12 +1604,14 @@ "OnVehicleData" : { "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ], "parameters" : [ + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -1617,12 +1621,14 @@ "SubscribeVehicleData" : { "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ], "parameters" : [ + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus" @@ -1631,12 +1637,14 @@ "UnsubscribeVehicleData" : { "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ], "parameters" : [ + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus" diff --git a/src/components/policy/policy_regular/test/sql_pt_representation_test.cc b/src/components/policy/policy_regular/test/sql_pt_representation_test.cc index fd83c82b1a..a5f3741331 100644 --- a/src/components/policy/policy_regular/test/sql_pt_representation_test.cc +++ b/src/components/policy/policy_regular/test/sql_pt_representation_test.cc @@ -289,6 +289,7 @@ class SQLPTRepresentationTest : public SQLPTRepresentation, app_policies["default"]["default_hmi"] = Json::Value("FULL"); app_policies["default"]["keep_context"] = Json::Value(true); app_policies["default"]["steal_focus"] = Json::Value(true); + app_policies["default"]["RequestType"] = Json::Value(Json::arrayValue); app_policies["pre_DataConsent"] = Json::Value(Json::objectValue); app_policies["pre_DataConsent"]["memory_kb"] = Json::Value(40); @@ -300,6 +301,9 @@ class SQLPTRepresentationTest : public SQLPTRepresentation, app_policies["pre_DataConsent"]["is_revoked"] = Json::Value(false); app_policies["pre_DataConsent"]["keep_context"] = Json::Value(true); app_policies["pre_DataConsent"]["steal_focus"] = Json::Value(true); + app_policies["pre_DataConsent"]["RequestType"] = + Json::Value(Json::arrayValue); + app_policies["1234"] = Json::Value(Json::objectValue); app_policies["1234"]["memory_kb"] = Json::Value(150); app_policies["1234"]["heart_beat_timeout_ms"] = Json::Value(200); @@ -310,6 +314,8 @@ class SQLPTRepresentationTest : public SQLPTRepresentation, app_policies["1234"]["is_revoked"] = Json::Value(true); app_policies["1234"]["keep_context"] = Json::Value(false); app_policies["1234"]["steal_focus"] = Json::Value(false); + app_policies["1234"]["RequestType"] = Json::Value(Json::arrayValue); + app_policies["device"] = Json::Value(Json::objectValue); app_policies["device"]["groups"] = Json::Value(Json::arrayValue); app_policies["device"]["groups"][0] = Json::Value("default"); @@ -420,7 +426,9 @@ TEST_F(SQLPTRepresentationTest, ASSERT_EQ(0, dbms->FetchOneInt(query_select)); ASSERT_TRUE(reps->RefreshDB()); // Check PT structure destroyed and tables number is 0 - const int32_t total_tables_number = 28; + + // There are 29 tables in the database, now. + const int32_t total_tables_number = 29; ASSERT_EQ(total_tables_number, dbms->FetchOneInt(query_select)); const char* query_select_count_of_iap_buffer_full = "SELECT `count_of_iap_buffer_full` FROM `usage_and_error_count`"; diff --git a/src/components/policy/policy_regular/test/valid_sdl_pt_update.json b/src/components/policy/policy_regular/test/valid_sdl_pt_update.json index c384ea73e2..bc8d95302c 100644 --- a/src/components/policy/policy_regular/test/valid_sdl_pt_update.json +++ b/src/components/policy/policy_regular/test/valid_sdl_pt_update.json @@ -1585,12 +1585,14 @@ "GetVehicleData" : { "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ], "parameters" : [ + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -1600,12 +1602,14 @@ "OnVehicleData" : { "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ], "parameters" : [ + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "vin", @@ -1615,12 +1619,14 @@ "SubscribeVehicleData" : { "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ], "parameters" : [ + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus" @@ -1629,12 +1635,14 @@ "UnsubscribeVehicleData" : { "hmi_levels" : [ "BACKGROUND", "FULL", "LIMITED" ], "parameters" : [ + "engineOilLife", "engineTorque", "externalTemperature", "fuelLevel", "fuelLevel_State", "headLampStatus", "instantFuelConsumption", + "fuelRange", "odometer", "tirePressure", "wiperStatus" diff --git a/src/components/remote_control/test/include/mock_application.h b/src/components/remote_control/test/include/mock_application.h index 88a10dd0e6..33f596f7d4 100644 --- a/src/components/remote_control/test/include/mock_application.h +++ b/src/components/remote_control/test/include/mock_application.h @@ -219,6 +219,9 @@ class MockApplication : public ::application_manager::Application { MOCK_CONST_METHOD0(keyboard_props, const smart_objects::SmartObject*()); MOCK_CONST_METHOD0(menu_title, const smart_objects::SmartObject*()); MOCK_CONST_METHOD0(menu_icon, const smart_objects::SmartObject*()); + MOCK_CONST_METHOD0(day_color_scheme, const smart_objects::SmartObject*()); + MOCK_CONST_METHOD0(night_color_scheme, const smart_objects::SmartObject*()); + MOCK_CONST_METHOD0(display_layout, const std::string&()); MOCK_METHOD1(load_global_properties, void(const smart_objects::SmartObject& so)); MOCK_METHOD1(set_help_prompt, @@ -242,6 +245,11 @@ class MockApplication : public ::application_manager::Application { void(const smart_objects::SmartObject& menu_title)); MOCK_METHOD1(set_menu_icon, void(const smart_objects::SmartObject& menu_icon)); + MOCK_METHOD1(set_day_color_scheme, + void(const smart_objects::SmartObject& color_scheme)); + MOCK_METHOD1(set_night_color_scheme, + void(const smart_objects::SmartObject& color_scheme)); + MOCK_METHOD1(set_display_layout, void(const std::string& layout)); MOCK_CONST_METHOD0(audio_stream_retry_number, uint32_t()); MOCK_METHOD1(set_audio_stream_retry_number, void(const uint32_t& audio_stream_retry_number)); diff --git a/src/components/smart_objects/include/smart_objects/number_schema_item.h b/src/components/smart_objects/include/smart_objects/number_schema_item.h index d549b9891a..34c5e3a8a6 100644 --- a/src/components/smart_objects/include/smart_objects/number_schema_item.h +++ b/src/components/smart_objects/include/smart_objects/number_schema_item.h @@ -39,6 +39,7 @@ #include "smart_objects/default_shema_item.h" #include "smart_objects/schema_item_parameter.h" #include "utils/convert_utils.h" +#include "utils/helpers.h" namespace NsSmartDeviceLink { namespace NsSmartObjects { @@ -123,15 +124,16 @@ bool TNumberSchemaItem<NumberType>::isValidNumberType(SmartType type) { NumberType value(0); if ((SmartType_Double == type) && (typeid(double) == typeid(value))) { return true; - } else if ((SmartType_Integer == type) && - (typeid(int32_t) == typeid(value) || - typeid(uint32_t) == typeid(value) || - typeid(int64_t) == typeid(value) || - typeid(double) == typeid(value))) { + } else if (((SmartType_Integer == type) || (SmartType_UInteger == type)) && + helpers::Compare<const std::type_info&, helpers::EQ, helpers::ONE>( + typeid(value), + typeid(int32_t), + typeid(uint32_t), + typeid(int64_t), + typeid(double))) { return true; - } else { - return false; } + return false; } template <typename NumberType> diff --git a/src/components/smart_objects/src/number_schema_item.cc b/src/components/smart_objects/src/number_schema_item.cc index 78be9fe85d..9789434523 100644 --- a/src/components/smart_objects/src/number_schema_item.cc +++ b/src/components/smart_objects/src/number_schema_item.cc @@ -41,7 +41,7 @@ SmartType TNumberSchemaItem<int32_t>::getSmartType() const { template <> SmartType TNumberSchemaItem<uint32_t>::getSmartType() const { - return SmartType_Integer; + return SmartType_UInteger; } template <> |