summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcollin <collin+i@collinmcqueen.com>2021-02-11 13:06:40 -0500
committercollin <collin+i@collinmcqueen.com>2021-02-11 13:06:40 -0500
commita54c2685219d126fc302dcbec1f3eea76c1a0be0 (patch)
treefaf7bbadf8578e6c8010ebb12d3c09d6ec5d0043
parent2a0e2a27fc7beaad4af90ddc59e0ced47091fb83 (diff)
parentf8c35107709ba19eda35664b90d3c7e9aada8c56 (diff)
downloadsdl_core-a54c2685219d126fc302dcbec1f3eea76c1a0be0.tar.gz
Merge branch 'feature/sdl_0293_enable_oem_exclusive_apps_support_base_impl' of https://github.com/LuxoftSDL/sdl_core into LuxoftSDL-feature/sdl_0293_enable_oem_exclusive_apps_support_base_impl
-rw-r--r--src/components/application_manager/include/application_manager/application_manager_impl.h13
-rw-r--r--src/components/application_manager/include/application_manager/hmi_capabilities_impl.h5
-rw-r--r--src/components/application_manager/include/application_manager/policies/policy_handler.h4
-rw-r--r--src/components/application_manager/include/application_manager/smart_object_keys.h1
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/get_system_info_response.h1
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_device_list_request.h19
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_request.h6
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/button_get_capabilities_response.cc8
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_system_info_response.cc13
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/rc_get_capabilities_response.cc8
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_capabilities_response.cc8
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_language_response.cc8
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_supported_languages_response.cc8
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_capabilities_response.cc8
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_language_response.cc8
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_supported_languages_response.cc8
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_device_list_request.cc40
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_capabilities_response.cc8
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_language_response.cc8
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_supported_languages_response.cc26
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc18
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/get_system_info_response_test.cc53
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/update_device_list_request_test.cc41
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/register_app_interface_request_test.cc21
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_vehicle_type_response.cc8
-rw-r--r--src/components/application_manager/src/application_manager_impl.cc68
-rw-r--r--src/components/application_manager/src/hmi_capabilities_impl.cc9
-rw-r--r--src/components/application_manager/src/policies/policy_handler.cc15
-rw-r--r--src/components/application_manager/src/rpc_service_impl.cc5
-rw-r--r--src/components/application_manager/src/smart_object_keys.cc1
-rw-r--r--src/components/application_manager/test/include/application_manager/mock_hmi_capabilities.h2
-rw-r--r--src/components/application_manager/test/policy_handler_test.cc13
-rw-r--r--src/components/connection_handler/include/connection_handler/connection_handler_impl.h2
-rw-r--r--src/components/connection_handler/src/connection_handler_impl.cc9
-rw-r--r--src/components/include/application_manager/application_manager.h6
-rw-r--r--src/components/include/application_manager/hmi_capabilities.h17
-rw-r--r--src/components/include/application_manager/policies/policy_handler_interface.h14
-rw-r--r--src/components/include/connection_handler/connection_handler.h20
-rw-r--r--src/components/include/connection_handler/connection_handler_observer.h8
-rw-r--r--src/components/include/policy/policy_external/policy/policy_manager.h13
-rw-r--r--src/components/include/policy/policy_regular/policy/policy_manager.h13
-rw-r--r--src/components/include/protocol/bson_object_keys.h6
-rw-r--r--src/components/include/test/application_manager/mock_application_manager.h1
-rw-r--r--src/components/include/test/application_manager/policies/mock_policy_handler_interface.h3
-rw-r--r--src/components/include/test/connection_handler/mock_connection_handler.h2
-rw-r--r--src/components/include/test/connection_handler/mock_connection_handler_observer.h2
-rw-r--r--src/components/include/test/policy/policy_external/policy/mock_cache_manager.h2
-rw-r--r--src/components/include/test/policy/policy_external/policy/mock_policy_manager.h2
-rw-r--r--src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h2
-rw-r--r--src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h2
-rw-r--r--src/components/interfaces/HMI_API.xml3
-rw-r--r--src/components/policy/policy_external/include/policy/cache_manager.h10
-rw-r--r--src/components/policy/policy_external/include/policy/cache_manager_interface.h14
-rw-r--r--src/components/policy/policy_external/include/policy/policy_manager_impl.h4
-rw-r--r--src/components/policy/policy_external/include/policy/policy_table/types.h1
-rw-r--r--src/components/policy/policy_external/include/policy/policy_table_interface_ext.xml1
-rw-r--r--src/components/policy/policy_external/include/policy/pt_ext_representation.h8
-rw-r--r--src/components/policy/policy_external/include/policy/sql_pt_ext_queries.h1
-rw-r--r--src/components/policy/policy_external/include/policy/sql_pt_ext_representation.h4
-rw-r--r--src/components/policy/policy_external/src/cache_manager.cc25
-rw-r--r--src/components/policy/policy_external/src/policy_manager_impl.cc11
-rw-r--r--src/components/policy/policy_external/src/policy_table/types.cc18
-rw-r--r--src/components/policy/policy_external/src/sql_pt_ext_queries.cc15
-rw-r--r--src/components/policy/policy_external/src/sql_pt_ext_representation.cc34
-rw-r--r--src/components/policy/policy_external/src/sql_pt_queries.cc1
-rw-r--r--src/components/policy/policy_external/test/CMakeLists.txt2
-rw-r--r--src/components/policy/policy_external/test/cache_manager_test.cc12
-rw-r--r--src/components/policy/policy_external/test/include/policy/mock_pt_ext_representation.h1
-rw-r--r--src/components/policy/policy_external/test/sql_pt_ext_representation_storage_test.cc2
-rw-r--r--src/components/policy/policy_external/test/sql_pt_ext_representation_test.cc334
-rw-r--r--src/components/policy/policy_external/test/sql_pt_representation_test.cc442
-rw-r--r--src/components/policy/policy_regular/include/policy/cache_manager.h10
-rw-r--r--src/components/policy/policy_regular/include/policy/cache_manager_interface.h14
-rw-r--r--src/components/policy/policy_regular/include/policy/policy_manager_impl.h4
-rw-r--r--src/components/policy/policy_regular/include/policy/policy_table/types.h1
-rw-r--r--src/components/policy/policy_regular/include/policy/pt_representation.h8
-rw-r--r--src/components/policy/policy_regular/include/policy/sql_pt_queries.h1
-rw-r--r--src/components/policy/policy_regular/include/policy/sql_pt_representation.h3
-rw-r--r--src/components/policy/policy_regular/src/cache_manager.cc24
-rw-r--r--src/components/policy/policy_regular/src/policy_manager_impl.cc11
-rw-r--r--src/components/policy/policy_regular/src/policy_table/types.cc13
-rw-r--r--src/components/policy/policy_regular/src/sql_pt_queries.cc11
-rw-r--r--src/components/policy/policy_regular/src/sql_pt_representation.cc25
-rw-r--r--src/components/policy/policy_regular/test/CMakeLists.txt1
-rw-r--r--src/components/policy/policy_regular/test/cache_manager_test.cc12
-rw-r--r--src/components/policy/policy_regular/test/policy_manager_impl_test.cc14
-rw-r--r--src/components/policy/policy_regular/test/sql_pt_representation_test.cc498
-rw-r--r--src/components/protocol/src/bson_object_keys.cc6
-rw-r--r--src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h8
-rw-r--r--src/components/protocol_handler/src/protocol_handler_impl.cc43
-rw-r--r--src/components/protocol_handler/test/protocol_handler_tm_test.cc134
-rw-r--r--src/components/utils/test/policy.sql1
m---------tools/rpc_spec0
93 files changed, 1130 insertions, 1241 deletions
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 bedf63b954..f4728eefef 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
@@ -700,6 +700,9 @@ class ApplicationManagerImpl
void RemoveDevice(
const connection_handler::DeviceHandle& device_handle) OVERRIDE;
+ bool GetProtocolVehicleData(
+ connection_handler::ProtocolVehicleData& data) OVERRIDE;
+
/**
* @brief OnDeviceSwitchingStart is invoked on device transport switching
* start (e.g. from Bluetooth to USB) and creates waiting list of applications
@@ -1144,6 +1147,8 @@ class ApplicationManagerImpl
return is_stopping_;
}
+ bool WaitForHmiIsReady() OVERRIDE;
+
/**
* @brief ProcessReconnection handles reconnection flow for application on
* transport switch
@@ -1189,6 +1194,11 @@ class ApplicationManagerImpl
private:
/**
+ * @brief Sets is_stopping flag to true
+ */
+ void InitiateStopping();
+
+ /**
* @brief Adds application to registered applications list and marks it as
* registered
* @param application Application that should be added to registered
@@ -1645,6 +1655,9 @@ class ApplicationManagerImpl
sync_primitives::Lock close_app_timer_pool_lock_;
sync_primitives::Lock end_stream_timer_pool_lock_;
+ mutable sync_primitives::Lock wait_for_hmi_lock_;
+ sync_primitives::ConditionalVariable wait_for_hmi_condvar_;
+
StateControllerImpl state_ctrl_;
std::unique_ptr<app_launch::AppLaunchData> app_launch_dto_;
std::unique_ptr<app_launch::AppLaunchCtrl> app_launch_ctrl_;
diff --git a/src/components/application_manager/include/application_manager/hmi_capabilities_impl.h b/src/components/application_manager/include/application_manager/hmi_capabilities_impl.h
index 0bc98827c8..f646c66ca1 100644
--- a/src/components/application_manager/include/application_manager/hmi_capabilities_impl.h
+++ b/src/components/application_manager/include/application_manager/hmi_capabilities_impl.h
@@ -81,6 +81,10 @@ class HMICapabilitiesImpl : public HMICapabilities {
const std::string& ccpu_version() const OVERRIDE;
+ void set_hardware_version(const std::string& hardware_version) OVERRIDE;
+
+ const std::string& hardware_version() const OVERRIDE;
+
bool attenuated_supported() const OVERRIDE;
void set_attenuated_supported(const bool state) OVERRIDE;
@@ -476,6 +480,7 @@ class HMICapabilitiesImpl : public HMICapabilities {
bool is_rc_supported_;
bool is_driver_distraction_supported_;
std::string ccpu_version_;
+ std::string hardware_version_;
smart_objects::SmartObjectSPtr navigation_capability_;
smart_objects::SmartObjectSPtr phone_capability_;
smart_objects::SmartObjectSPtr video_streaming_capability_;
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 61b228d4f8..0a815b4c5b 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
@@ -386,10 +386,14 @@ class PolicyHandler : public PolicyHandlerInterface,
const std::string& wers_country_code,
const std::string& language) OVERRIDE;
+ void OnHardwareVersionReceived(const std::string& hardware_version) OVERRIDE;
+
void SetPreloadedPtFlag(const bool is_preloaded) OVERRIDE;
std::string GetCCPUVersionFromPT() const OVERRIDE;
+ std::string GetHardwareVersionFromPT() const OVERRIDE;
+
/**
* @brief Sends GetVehicleData request in case when Vechicle info is ready.
*/
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 07cc81c7aa..932c65ae2d 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
@@ -340,6 +340,7 @@ extern const char* video_streaming;
extern const char* remote_control;
extern const char* sdl_version;
extern const char* system_software_version;
+extern const char* system_hardware_version;
extern const char* priority;
extern const char* engine_oil_life;
extern const char* oem_custom_data_type;
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/get_system_info_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/get_system_info_response.h
index 2d3c40c3f3..5254d641de 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/get_system_info_response.h
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/get_system_info_response.h
@@ -45,6 +45,7 @@ struct SystemInfo {
std::string ccpu_version;
std::string wers_country_code;
std::string language;
+ std::string hardware_version;
};
/**
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_device_list_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_device_list_request.h
index db4f265a9f..ed89bc73ec 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_device_list_request.h
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/update_device_list_request.h
@@ -46,8 +46,7 @@ namespace commands {
/**
* @brief UpdateDeviceListRequest command class
**/
-class UpdateDeviceListRequest : public app_mngr::commands::RequestToHMI,
- public app_mngr::event_engine::EventObserver {
+class UpdateDeviceListRequest : public app_mngr::commands::RequestToHMI {
public:
/**
* @brief UpdateDeviceListRequest class constructor
@@ -70,23 +69,7 @@ class UpdateDeviceListRequest : public app_mngr::commands::RequestToHMI,
**/
virtual void Run();
- /**
- * @brief Interface method that is called whenever new event received
- * Need to observe OnHMIReady event, to send UpdateDeviceListRequest
- * when HMI will be ready
- * @param event The received event
- */
- virtual void on_event(const app_mngr::event_engine::Event& event);
-
- /**
- * @brief Need to stop execution StopMethod if HMI did not started
- */
- virtual bool CleanUp();
-
private:
- sync_primitives::Lock wait_hmi_lock;
- sync_primitives::ConditionalVariable termination_condition_;
-
DISALLOW_COPY_AND_ASSIGN(UpdateDeviceListRequest);
};
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_request.h
index fae8f5eeb7..ae52caf0f7 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_request.h
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_request.h
@@ -261,12 +261,6 @@ class RegisterAppInterfaceRequest
const smart_objects::SmartObject& message);
/**
- * @brief WaitForHMIIsReady blocking function. Waits for HMI be ready for
- * requests processing
- */
- void WaitForHMIIsReady();
-
- /**
* @brief FillApplicationParams set app application attributes from the RAI
* request
* @param application applicaiton to fill params
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/button_get_capabilities_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/button_get_capabilities_response.cc
index 20250af222..722bfc5097 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/button_get_capabilities_response.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/button_get_capabilities_response.cc
@@ -60,11 +60,10 @@ void ButtonGetCapabilitiesResponse::Run() {
static_cast<hmi_apis::Common_Result::eType>(
(*message_)[strings::params][hmi_response::code].asInt());
- hmi_capabilities_.UpdateRequestsRequiredForCapabilities(
- hmi_apis::FunctionID::Buttons_GetCapabilities);
-
if (hmi_apis::Common_Result::SUCCESS != code) {
SDL_LOG_ERROR("Error is returned. Capabilities won't be updated.");
+ hmi_capabilities_.UpdateRequestsRequiredForCapabilities(
+ hmi_apis::FunctionID::Buttons_GetCapabilities);
return;
}
@@ -81,6 +80,9 @@ void ButtonGetCapabilitiesResponse::Run() {
[hmi_response::preset_bank_capabilities]);
}
+ hmi_capabilities_.UpdateRequestsRequiredForCapabilities(
+ hmi_apis::FunctionID::Buttons_GetCapabilities);
+
if (!hmi_capabilities_.SaveCachedCapabilitiesToFile(
hmi_interface::buttons, sections_to_update, message_->getSchema())) {
SDL_LOG_ERROR("Failed to save Buttons.GetCapabilities response to cache");
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_system_info_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_system_info_response.cc
index 8229e1978c..50fb41a551 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_system_info_response.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/get_system_info_response.cc
@@ -59,6 +59,8 @@ void GetSystemInfoResponse::Run() {
(*message_)[strings::params][hmi_response::code].asInt());
hmi_capabilities_.set_ccpu_version(policy_handler_.GetCCPUVersionFromPT());
+ hmi_capabilities_.set_hardware_version(
+ policy_handler_.GetHardwareVersionFromPT());
if (hmi_apis::Common_Result::SUCCESS != code) {
SDL_LOG_WARN("GetSystemError returns an error code " << code);
@@ -72,6 +74,11 @@ void GetSystemInfoResponse::Run() {
policy_handler_.OnGetSystemInfo(
info.ccpu_version, info.wers_country_code, info.language);
+ if (!info.hardware_version.empty()) {
+ policy_handler_.OnHardwareVersionReceived(info.hardware_version);
+ hmi_capabilities_.set_hardware_version(info.hardware_version);
+ }
+
hmi_capabilities_.OnSoftwareVersionReceived(info.ccpu_version);
}
@@ -89,6 +96,12 @@ const SystemInfo GetSystemInfoResponse::GetSystemInfo() const {
info.language = application_manager::EnumToString(
static_cast<hmi_apis::Common_Language::eType>(lang_code));
+ if ((*message_)[strings::msg_params].keyExists(
+ strings::system_hardware_version)) {
+ info.hardware_version =
+ (*message_)[strings::msg_params][strings::system_hardware_version]
+ .asString();
+ }
return info;
}
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/rc_get_capabilities_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/rc_get_capabilities_response.cc
index 10507a516f..bd5da04cb3 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/rc_get_capabilities_response.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/rc_get_capabilities_response.cc
@@ -58,11 +58,10 @@ void RCGetCapabilitiesResponse::Run() {
const auto result_code = static_cast<hmi_apis::Common_Result::eType>(
(*message_)[strings::params][hmi_response::code].asInt());
- hmi_capabilities_.UpdateRequestsRequiredForCapabilities(
- hmi_apis::FunctionID::RC_GetCapabilities);
-
if (hmi_apis::Common_Result::SUCCESS != result_code) {
SDL_LOG_DEBUG("Request was not successful. Don't change HMI capabilities");
+ hmi_capabilities_.UpdateRequestsRequiredForCapabilities(
+ hmi_apis::FunctionID::RC_GetCapabilities);
return;
}
@@ -88,6 +87,9 @@ void RCGetCapabilitiesResponse::Run() {
hmi_capabilities_.set_rc_supported(rc_capability_exists);
+ hmi_capabilities_.UpdateRequestsRequiredForCapabilities(
+ hmi_apis::FunctionID::RC_GetCapabilities);
+
if (!hmi_capabilities_.SaveCachedCapabilitiesToFile(
hmi_interface::rc, sections_to_update, message_->getSchema())) {
SDL_LOG_ERROR("Failed to save RC.GetCapabilities response to cache");
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_capabilities_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_capabilities_response.cc
index 167966e55b..10709bf94d 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_capabilities_response.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_capabilities_response.cc
@@ -57,11 +57,10 @@ void TTSGetCapabilitiesResponse::Run() {
const auto result_code = static_cast<hmi_apis::Common_Result::eType>(
(*message_)[strings::params][hmi_response::code].asInt());
- hmi_capabilities_.UpdateRequestsRequiredForCapabilities(
- hmi_apis::FunctionID::TTS_GetCapabilities);
-
if (hmi_apis::Common_Result::SUCCESS != result_code) {
SDL_LOG_DEBUG("Request was not successful. Don't change HMI capabilities");
+ hmi_capabilities_.UpdateRequestsRequiredForCapabilities(
+ hmi_apis::FunctionID::TTS_GetCapabilities);
return;
}
@@ -80,6 +79,9 @@ void TTSGetCapabilitiesResponse::Run() {
[hmi_response::prerecorded_speech_capabilities]);
}
+ hmi_capabilities_.UpdateRequestsRequiredForCapabilities(
+ hmi_apis::FunctionID::TTS_GetCapabilities);
+
if (!hmi_capabilities_.SaveCachedCapabilitiesToFile(
hmi_interface::tts, sections_to_update, message_->getSchema())) {
SDL_LOG_ERROR("Failed to save TTS.GetCapabilities response to cache");
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_language_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_language_response.cc
index 2b14bea681..8b708dda01 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_language_response.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_language_response.cc
@@ -61,11 +61,10 @@ void TTSGetLanguageResponse::Run() {
const Common_Result::eType result_code = static_cast<Common_Result::eType>(
(*message_)[strings::params][hmi_response::code].asInt());
- hmi_capabilities_.UpdateRequestsRequiredForCapabilities(
- hmi_apis::FunctionID::TTS_GetLanguage);
-
if (Common_Result::SUCCESS != result_code) {
SDL_LOG_DEBUG("Request was not successful. Don't change HMI capabilities");
+ hmi_capabilities_.UpdateRequestsRequiredForCapabilities(
+ hmi_apis::FunctionID::TTS_GetLanguage);
return;
}
@@ -79,6 +78,9 @@ void TTSGetLanguageResponse::Run() {
hmi_capabilities_.set_active_tts_language(language);
+ hmi_capabilities_.UpdateRequestsRequiredForCapabilities(
+ hmi_apis::FunctionID::TTS_GetLanguage);
+
std::vector<std::string> sections_to_update{hmi_response::language};
if (!hmi_capabilities_.SaveCachedCapabilitiesToFile(
hmi_interface::tts, sections_to_update, message_->getSchema())) {
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_supported_languages_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_supported_languages_response.cc
index 6b074005b2..71ecd9d4da 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_supported_languages_response.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/tts_get_supported_languages_response.cc
@@ -61,17 +61,19 @@ void TTSGetSupportedLanguagesResponse::Run() {
static_cast<hmi_apis::Common_Result::eType>(
(*message_)[strings::params][hmi_response::code].asInt());
- hmi_capabilities_.UpdateRequestsRequiredForCapabilities(
- hmi_apis::FunctionID::TTS_GetSupportedLanguages);
-
if (hmi_apis::Common_Result::SUCCESS != code) {
SDL_LOG_DEBUG("Request was not successful. Don't change HMI capabilities");
+ hmi_capabilities_.UpdateRequestsRequiredForCapabilities(
+ hmi_apis::FunctionID::TTS_GetSupportedLanguages);
return;
}
hmi_capabilities_.set_tts_supported_languages(
(*message_)[strings::msg_params][hmi_response::languages]);
+ hmi_capabilities_.UpdateRequestsRequiredForCapabilities(
+ hmi_apis::FunctionID::TTS_GetSupportedLanguages);
+
std::vector<std::string> sections_to_update{hmi_response::languages};
if (!hmi_capabilities_.SaveCachedCapabilitiesToFile(
hmi_interface::tts, sections_to_update, message_->getSchema())) {
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_capabilities_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_capabilities_response.cc
index 31dda22709..45c5f59326 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_capabilities_response.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_capabilities_response.cc
@@ -58,11 +58,10 @@ void UIGetCapabilitiesResponse::Run() {
const auto result_code = static_cast<hmi_apis::Common_Result::eType>(
(*message_)[strings::params][hmi_response::code].asInt());
- hmi_capabilities_.UpdateRequestsRequiredForCapabilities(
- hmi_apis::FunctionID::UI_GetCapabilities);
-
if (hmi_apis::Common_Result::SUCCESS != result_code) {
SDL_LOG_DEBUG("Request was not successful. Don't change HMI capabilities");
+ hmi_capabilities_.UpdateRequestsRequiredForCapabilities(
+ hmi_apis::FunctionID::UI_GetCapabilities);
return;
}
@@ -165,6 +164,9 @@ void UIGetCapabilitiesResponse::Run() {
msg_params[strings::pcm_stream_capabilities]);
}
+ hmi_capabilities_.UpdateRequestsRequiredForCapabilities(
+ hmi_apis::FunctionID::UI_GetCapabilities);
+
if (!hmi_capabilities_.SaveCachedCapabilitiesToFile(
hmi_interface::ui, sections_to_update, message_->getSchema())) {
SDL_LOG_ERROR("Failed to save UI.GetCapabilities response to cache");
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_language_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_language_response.cc
index ffeec025be..9bae80f48e 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_language_response.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_language_response.cc
@@ -61,11 +61,10 @@ void UIGetLanguageResponse::Run() {
const Common_Result::eType result_code = static_cast<Common_Result::eType>(
(*message_)[strings::params][hmi_response::code].asInt());
- hmi_capabilities_.UpdateRequestsRequiredForCapabilities(
- hmi_apis::FunctionID::UI_GetLanguage);
-
if (Common_Result::SUCCESS != result_code) {
SDL_LOG_DEBUG("Request was not successful. Don't change HMI capabilities");
+ hmi_capabilities_.UpdateRequestsRequiredForCapabilities(
+ hmi_apis::FunctionID::UI_GetLanguage);
return;
}
@@ -79,6 +78,9 @@ void UIGetLanguageResponse::Run() {
hmi_capabilities_.set_active_ui_language(language);
+ hmi_capabilities_.UpdateRequestsRequiredForCapabilities(
+ hmi_apis::FunctionID::UI_GetLanguage);
+
std::vector<std::string> sections_to_update{hmi_response::language};
if (!hmi_capabilities_.SaveCachedCapabilitiesToFile(
hmi_interface::ui, sections_to_update, message_->getSchema())) {
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_supported_languages_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_supported_languages_response.cc
index 20606294ae..e3d6a979ba 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_supported_languages_response.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_get_supported_languages_response.cc
@@ -61,17 +61,19 @@ void UIGetSupportedLanguagesResponse::Run() {
static_cast<hmi_apis::Common_Result::eType>(
(*message_)[strings::params][hmi_response::code].asInt());
- hmi_capabilities_.UpdateRequestsRequiredForCapabilities(
- hmi_apis::FunctionID::UI_GetSupportedLanguages);
-
if (hmi_apis::Common_Result::SUCCESS != code) {
SDL_LOG_DEBUG("Request was not successful. Don't change HMI capabilities");
+ hmi_capabilities_.UpdateRequestsRequiredForCapabilities(
+ hmi_apis::FunctionID::UI_GetSupportedLanguages);
return;
}
hmi_capabilities_.set_ui_supported_languages(
(*message_)[strings::msg_params][hmi_response::languages]);
+ hmi_capabilities_.UpdateRequestsRequiredForCapabilities(
+ hmi_apis::FunctionID::UI_GetSupportedLanguages);
+
std::vector<std::string> sections_to_update{hmi_response::languages};
if (!hmi_capabilities_.SaveCachedCapabilitiesToFile(
hmi_interface::ui, sections_to_update, message_->getSchema())) {
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_device_list_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_device_list_request.cc
index c8aa295645..4d055564de 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_device_list_request.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/update_device_list_request.cc
@@ -53,51 +53,27 @@ UpdateDeviceListRequest::UpdateDeviceListRequest(
application_manager,
rpc_service,
hmi_capabilities,
- policy_handle)
- , EventObserver(application_manager_.event_dispatcher()) {}
+ policy_handle) {}
UpdateDeviceListRequest::~UpdateDeviceListRequest() {}
void UpdateDeviceListRequest::Run() {
SDL_LOG_AUTO_TRACE();
- sync_primitives::AutoLock auto_lock(wait_hmi_lock);
// Fix problem with SDL and HMI HTML. This problem is not actual for HMI PASA.
// Flag conditional compilation for specific customer is used in order to
// exclude
// hit code to RTC
- if (true == application_manager_.get_settings().launch_hmi()) {
- if (!application_manager_.IsHMICooperating()) {
- SDL_LOG_INFO("Wait for HMI Cooperation");
- subscribe_on_event(hmi_apis::FunctionID::BasicCommunication_OnReady);
- termination_condition_.Wait(auto_lock);
- SDL_LOG_DEBUG("HMI Cooperation OK");
+ if (application_manager_.get_settings().launch_hmi()) {
+ SDL_LOG_INFO("Wait for HMI Cooperation");
+ if (!application_manager_.WaitForHmiIsReady()) {
+ SDL_LOG_ERROR("HMI is not ready");
+ return;
}
- }
-
- SendRequest();
-}
-void UpdateDeviceListRequest::on_event(const event_engine::Event& event) {
- SDL_LOG_AUTO_TRACE();
- sync_primitives::AutoLock auto_lock(wait_hmi_lock);
- switch (event.id()) {
- case hmi_apis::FunctionID::BasicCommunication_OnReady: {
- SDL_LOG_INFO("received OnReady");
- unsubscribe_from_event(hmi_apis::FunctionID::BasicCommunication_OnReady);
- termination_condition_.Broadcast();
- break;
- };
- default: {
- SDL_LOG_ERROR("Unknown event " << event.id());
- break;
- };
+ SDL_LOG_DEBUG("HMI Cooperation is OK");
}
-}
-bool UpdateDeviceListRequest::CleanUp() {
- sync_primitives::AutoLock auto_lock(wait_hmi_lock);
- termination_condition_.Broadcast();
- return true;
+ SendRequest();
}
} // namespace commands
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_capabilities_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_capabilities_response.cc
index 315107d94a..60cb39f987 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_capabilities_response.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_capabilities_response.cc
@@ -57,11 +57,10 @@ void VRGetCapabilitiesResponse::Run() {
const auto result_code = static_cast<hmi_apis::Common_Result::eType>(
(*message_)[strings::params][hmi_response::code].asInt());
- hmi_capabilities_.UpdateRequestsRequiredForCapabilities(
- hmi_apis::FunctionID::VR_GetCapabilities);
-
if (hmi_apis::Common_Result::SUCCESS != result_code) {
SDL_LOG_DEBUG("Request was not successful. Don't change HMI capabilities");
+ hmi_capabilities_.UpdateRequestsRequiredForCapabilities(
+ hmi_apis::FunctionID::VR_GetCapabilities);
return;
}
@@ -74,6 +73,9 @@ void VRGetCapabilitiesResponse::Run() {
hmi_capabilities_.set_vr_capabilities(msg_params[strings::vr_capabilities]);
}
+ hmi_capabilities_.UpdateRequestsRequiredForCapabilities(
+ hmi_apis::FunctionID::VR_GetCapabilities);
+
if (!hmi_capabilities_.SaveCachedCapabilitiesToFile(
hmi_interface::vr, sections_to_update, message_->getSchema())) {
SDL_LOG_ERROR("Failed to save VR.GetCapabilities response to cache");
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_language_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_language_response.cc
index e8c881f6f8..3529d9fcde 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_language_response.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_language_response.cc
@@ -61,11 +61,10 @@ void VRGetLanguageResponse::Run() {
const Common_Result::eType result_code = static_cast<Common_Result::eType>(
(*message_)[strings::params][hmi_response::code].asInt());
- hmi_capabilities_.UpdateRequestsRequiredForCapabilities(
- hmi_apis::FunctionID::VR_GetLanguage);
-
if (Common_Result::SUCCESS != result_code) {
SDL_LOG_DEBUG("Request was not successful. Don't change HMI capabilities");
+ hmi_capabilities_.UpdateRequestsRequiredForCapabilities(
+ hmi_apis::FunctionID::VR_GetLanguage);
return;
}
@@ -79,6 +78,9 @@ void VRGetLanguageResponse::Run() {
hmi_capabilities_.set_active_vr_language(language);
+ hmi_capabilities_.UpdateRequestsRequiredForCapabilities(
+ hmi_apis::FunctionID::VR_GetLanguage);
+
std::vector<std::string> sections_to_update{hmi_response::language};
if (!hmi_capabilities_.SaveCachedCapabilitiesToFile(
hmi_interface::vr, sections_to_update, message_->getSchema())) {
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_supported_languages_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_supported_languages_response.cc
index 72278fcddd..7b234befbe 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_supported_languages_response.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/vr_get_supported_languages_response.cc
@@ -62,20 +62,24 @@ void VRGetSupportedLanguagesResponse::Run() {
static_cast<hmi_apis::Common_Result::eType>(
(*message_)[strings::params][hmi_response::code].asInt());
+ if (hmi_apis::Common_Result::SUCCESS != code) {
+ SDL_LOG_DEBUG("Request was not successful. Don't change HMI capabilities");
+ hmi_capabilities_.UpdateRequestsRequiredForCapabilities(
+ hmi_apis::FunctionID::VR_GetSupportedLanguages);
+ return;
+ }
+
+ HMICapabilities& hmi_capabilities = hmi_capabilities_;
+ hmi_capabilities.set_vr_supported_languages(
+ (*message_)[strings::msg_params][hmi_response::languages]);
+
hmi_capabilities_.UpdateRequestsRequiredForCapabilities(
hmi_apis::FunctionID::VR_GetSupportedLanguages);
- if (hmi_apis::Common_Result::SUCCESS == code) {
- HMICapabilities& hmi_capabilities = hmi_capabilities_;
- hmi_capabilities.set_vr_supported_languages(
- (*message_)[strings::msg_params][hmi_response::languages]);
-
- std::vector<std::string> sections_to_update{hmi_response::languages};
- if (!hmi_capabilities_.SaveCachedCapabilitiesToFile(
- hmi_interface::vr, sections_to_update, message_->getSchema())) {
- SDL_LOG_ERROR(
- "Failed to save VR.GetSupportedLanguages response to cache");
- }
+ std::vector<std::string> sections_to_update{hmi_response::languages};
+ if (!hmi_capabilities_.SaveCachedCapabilitiesToFile(
+ hmi_interface::vr, sections_to_update, message_->getSchema())) {
+ SDL_LOG_ERROR("Failed to save VR.GetSupportedLanguages response to cache");
}
}
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc
index 6ac830c378..920805be7c 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc
@@ -159,18 +159,6 @@ uint32_t RegisterAppInterfaceRequest::default_timeout() const {
return 0;
}
-void RegisterAppInterfaceRequest::WaitForHMIIsReady() {
- while (!application_manager_.IsStopping() &&
- !application_manager_.IsHMICooperating()) {
- SDL_LOG_DEBUG("Waiting for the HMI... conn_key="
- << connection_key() << ", correlation_id=" << correlation_id()
- << ", default_timeout=" << default_timeout()
- << ", thread=" << pthread_self());
- sleep(1);
- // TODO(DK): timer_->StartWait(1);
- }
-}
-
void RegisterAppInterfaceRequest::FillApplicationParams(
ApplicationSharedPtr application) {
SDL_LOG_AUTO_TRACE();
@@ -488,10 +476,8 @@ void RegisterAppInterfaceRequest::Run() {
SDL_LOG_AUTO_TRACE();
SDL_LOG_DEBUG("Connection key is " << connection_key());
- WaitForHMIIsReady();
-
- if (application_manager_.IsStopping()) {
- SDL_LOG_WARN("The ApplicationManager is stopping!");
+ if (!application_manager_.WaitForHmiIsReady()) {
+ SDL_LOG_WARN("Failed to wait for HMI readiness");
return;
}
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/get_system_info_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/get_system_info_response_test.cc
index 8cdce4fa74..3e01849807 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/get_system_info_response_test.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/get_system_info_response_test.cc
@@ -68,6 +68,7 @@ typedef NiceMock<
namespace {
const uint32_t kConnectionKey = 2u;
const std::string ccpu_version("4.1.3.B_EB355B");
+const std::string kHardwareVersion("1.1.1.1");
const std::string wers_country_code("WAEGB");
const std::string lang_code("EN-US");
} // namespace
@@ -82,14 +83,36 @@ class GetSystemInfoResponseTest
(*command_msg)[strings::msg_params]["ccpu_version"] = ccpu_version;
(*command_msg)[strings::msg_params]["wersCountryCode"] = wers_country_code;
(*command_msg)[strings::msg_params]["language"] = lang_code;
-
return command_msg;
}
+ void SetHardwareVersionFromPT() {
+ const std::string hardware_version_from_pt = "1.1.1.0";
+ ON_CALL(mock_policy_handler_, GetHardwareVersionFromPT())
+ .WillByDefault(Return(hardware_version_from_pt));
+ EXPECT_CALL(mock_hmi_capabilities_,
+ set_hardware_version(hardware_version_from_pt));
+ }
+
SmartObject capabilities_;
};
-TEST_F(GetSystemInfoResponseTest, GetSystemInfo_SUCCESS) {
+TEST_F(GetSystemInfoResponseTest, GetSystemInfo_UNSUCCESS) {
+ MessageSharedPtr command_msg = CreateCommandMsg();
+ (*command_msg)[strings::params][hmi_response::code] =
+ hmi_apis::Common_Result::WRONG_LANGUAGE;
+ (*command_msg)[strings::msg_params][hmi_response::capabilities] =
+ (capabilities_);
+
+ ResponseFromHMIPtr command(CreateCommand<GetSystemInfoResponse>(command_msg));
+
+ EXPECT_CALL(mock_hmi_capabilities_, UpdateCachedCapabilities());
+ EXPECT_CALL(mock_policy_handler_, SetPreloadedPtFlag(false));
+
+ command->Run();
+}
+
+TEST_F(GetSystemInfoResponseTest, GetSystemInfo_UpdateCapabilities_Called) {
MessageSharedPtr command_msg = CreateCommandMsg();
(*command_msg)[strings::params][hmi_response::code] =
hmi_apis::Common_Result::SUCCESS;
@@ -98,28 +121,35 @@ TEST_F(GetSystemInfoResponseTest, GetSystemInfo_SUCCESS) {
ResponseFromHMIPtr command(CreateCommand<GetSystemInfoResponse>(command_msg));
- EXPECT_CALL(mock_policy_handler_,
- OnGetSystemInfo(ccpu_version, wers_country_code, lang_code));
+ EXPECT_CALL(mock_hmi_capabilities_, OnSoftwareVersionReceived(ccpu_version));
+ ASSERT_TRUE(command->Init());
command->Run();
}
-TEST_F(GetSystemInfoResponseTest, GetSystemInfo_UNSUCCESS) {
+TEST_F(GetSystemInfoResponseTest,
+ GetSystemInfo_SaveHardwareVersionToHMICapabilitiesIfPresentInResponse) {
MessageSharedPtr command_msg = CreateCommandMsg();
(*command_msg)[strings::params][hmi_response::code] =
- hmi_apis::Common_Result::WRONG_LANGUAGE;
+ hmi_apis::Common_Result::SUCCESS;
(*command_msg)[strings::msg_params][hmi_response::capabilities] =
(capabilities_);
+ (*command_msg)[strings::msg_params][strings::system_hardware_version] =
+ kHardwareVersion;
ResponseFromHMIPtr command(CreateCommand<GetSystemInfoResponse>(command_msg));
- EXPECT_CALL(mock_hmi_capabilities_, UpdateCachedCapabilities());
- EXPECT_CALL(mock_policy_handler_, SetPreloadedPtFlag(false));
+ SetHardwareVersionFromPT();
+ EXPECT_CALL(mock_policy_handler_, OnHardwareVersionReceived(_));
+ EXPECT_CALL(mock_hmi_capabilities_, set_hardware_version(kHardwareVersion));
+ ASSERT_TRUE(command->Init());
command->Run();
}
-TEST_F(GetSystemInfoResponseTest, GetSystemInfo_UpdateCapabilities_Called) {
+TEST_F(
+ GetSystemInfoResponseTest,
+ GetSystemInfo_DontSaveHardwareVersionToHMICapabilitiesIfAbsentInResponse) {
MessageSharedPtr command_msg = CreateCommandMsg();
(*command_msg)[strings::params][hmi_response::code] =
hmi_apis::Common_Result::SUCCESS;
@@ -128,7 +158,10 @@ TEST_F(GetSystemInfoResponseTest, GetSystemInfo_UpdateCapabilities_Called) {
ResponseFromHMIPtr command(CreateCommand<GetSystemInfoResponse>(command_msg));
- EXPECT_CALL(mock_hmi_capabilities_, OnSoftwareVersionReceived(ccpu_version));
+ SetHardwareVersionFromPT();
+ EXPECT_CALL(mock_policy_handler_, OnHardwareVersionReceived(_)).Times(0);
+ EXPECT_CALL(mock_hmi_capabilities_, set_hardware_version(kHardwareVersion))
+ .Times(0);
ASSERT_TRUE(command->Init());
command->Run();
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/update_device_list_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/update_device_list_request_test.cc
index 31c03a7ed5..9760462d05 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/update_device_list_request_test.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/update_device_list_request_test.cc
@@ -92,10 +92,6 @@ class UpdateDeviceListRequestTest
TEST_F(UpdateDeviceListRequestTest, RUN_LaunchHMIReturnsFalse) {
MessageSharedPtr command_msg = CreateCommandMsg();
- EXPECT_CALL(app_mngr_, event_dispatcher())
- .WillOnce(ReturnRef(mock_event_dispatcher_));
- EXPECT_CALL(mock_event_dispatcher_, remove_observer(_));
-
UpdateDeviceListRequestPtr command(
CreateCommand<UpdateDeviceListRequest>(command_msg));
@@ -103,7 +99,7 @@ TEST_F(UpdateDeviceListRequestTest, RUN_LaunchHMIReturnsFalse) {
EXPECT_CALL(settings_, launch_hmi()).WillOnce(Return(false));
- EXPECT_CALL(app_mngr_, IsHMICooperating()).Times(0);
+ EXPECT_CALL(app_mngr_, WaitForHmiIsReady()).Times(0);
EXPECT_CALL(mock_rpc_service_, SendMessageToHMI(command_msg));
command->Run();
@@ -114,13 +110,9 @@ TEST_F(UpdateDeviceListRequestTest, RUN_LaunchHMIReturnsFalse) {
CommandImpl::protocol_version_);
}
-TEST_F(UpdateDeviceListRequestTest, RUN_HMICooperatingReturnsTrue_SUCCESSS) {
+TEST_F(UpdateDeviceListRequestTest, RUN_HMICooperatingReturnsTrue_SUCCESS) {
MessageSharedPtr command_msg = CreateCommandMsg();
- EXPECT_CALL(app_mngr_, event_dispatcher())
- .WillOnce(ReturnRef(mock_event_dispatcher_));
- EXPECT_CALL(mock_event_dispatcher_, remove_observer(_));
-
UpdateDeviceListRequestPtr command(
CreateCommand<UpdateDeviceListRequest>(command_msg));
@@ -128,7 +120,7 @@ TEST_F(UpdateDeviceListRequestTest, RUN_HMICooperatingReturnsTrue_SUCCESSS) {
EXPECT_CALL(settings_, launch_hmi()).WillOnce(Return(true));
- EXPECT_CALL(app_mngr_, IsHMICooperating()).WillOnce(Return(true));
+ EXPECT_CALL(app_mngr_, WaitForHmiIsReady()).WillOnce(Return(true));
EXPECT_CALL(mock_rpc_service_, SendMessageToHMI(command_msg));
command->Run();
@@ -139,29 +131,20 @@ TEST_F(UpdateDeviceListRequestTest, RUN_HMICooperatingReturnsTrue_SUCCESSS) {
CommandImpl::protocol_version_);
}
-TEST_F(UpdateDeviceListRequestTest, OnEvent_WrongEventId_UNSUCCESS) {
- Event event(Event::EventID::INVALID_ENUM);
-
- EXPECT_CALL(app_mngr_, event_dispatcher())
- .WillOnce(ReturnRef(mock_event_dispatcher_));
- EXPECT_CALL(mock_event_dispatcher_, remove_observer(_));
-
- UpdateDeviceListRequestPtr command(CreateCommand<UpdateDeviceListRequest>());
+TEST_F(UpdateDeviceListRequestTest, RUN_HMICooperatingReturnsFalse_UNSUCCESS) {
+ MessageSharedPtr command_msg = CreateCommandMsg();
- command->on_event(event);
-}
+ UpdateDeviceListRequestPtr command(
+ CreateCommand<UpdateDeviceListRequest>(command_msg));
-TEST_F(UpdateDeviceListRequestTest, OnEvent_SUCCESS) {
- Event event(Event::EventID::BasicCommunication_OnReady);
+ EXPECT_CALL(app_mngr_, get_settings()).WillOnce(ReturnRef(settings_));
- EXPECT_CALL(app_mngr_, event_dispatcher())
- .WillOnce(ReturnRef(mock_event_dispatcher_));
- EXPECT_CALL(mock_event_dispatcher_, remove_observer(_, _));
- EXPECT_CALL(mock_event_dispatcher_, remove_observer(_));
+ EXPECT_CALL(settings_, launch_hmi()).WillOnce(Return(true));
- UpdateDeviceListRequestPtr command(CreateCommand<UpdateDeviceListRequest>());
+ EXPECT_CALL(app_mngr_, WaitForHmiIsReady()).WillOnce(Return(false));
+ EXPECT_CALL(mock_rpc_service_, SendMessageToHMI(_)).Times(0);
- command->on_event(event);
+ command->Run();
}
} // namespace update_device_list_request
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/register_app_interface_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/register_app_interface_request_test.cc
index fab648fc95..4572a6d907 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/register_app_interface_request_test.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/register_app_interface_request_test.cc
@@ -198,7 +198,7 @@ class RegisterAppInterfaceRequestTest
void InitGetters() {
ON_CALL(app_mngr_, GetCorrectMobileIDFromMessage(msg_))
.WillByDefault(Return(kAppId1));
- ON_CALL(app_mngr_, IsHMICooperating()).WillByDefault(Return(true));
+ ON_CALL(app_mngr_, WaitForHmiIsReady()).WillByDefault(Return(true));
ON_CALL(app_mngr_, resume_controller())
.WillByDefault(ReturnRef(mock_resume_crt_));
ON_CALL(app_mngr_, connection_handler())
@@ -416,11 +416,7 @@ TEST_F(RegisterAppInterfaceRequestTest, DefaultTimeout_CheckIfZero_SUCCESS) {
TEST_F(RegisterAppInterfaceRequestTest, Run_MinimalData_SUCCESS) {
InitBasicMessage();
(*msg_)[am::strings::msg_params][am::strings::hash_id] = kAppId1;
- EXPECT_CALL(app_mngr_, IsStopping())
- .WillOnce(Return(false))
- .WillOnce(Return(true))
- .WillOnce(Return(false));
- ON_CALL(app_mngr_, IsHMICooperating()).WillByDefault(Return(false));
+ EXPECT_CALL(app_mngr_, WaitForHmiIsReady()).WillOnce(Return(true));
EXPECT_CALL(app_mngr_, IsApplicationForbidden(_, _)).WillOnce(Return(false));
ON_CALL(mock_connection_handler_,
@@ -504,11 +500,7 @@ TEST_F(RegisterAppInterfaceRequestTest,
Run_HmiInterfacesStateAvailable_SUCCESS) {
InitBasicMessage();
- EXPECT_CALL(app_mngr_, IsStopping())
- .WillOnce(Return(false))
- .WillOnce(Return(true))
- .WillOnce(Return(false));
- ON_CALL(app_mngr_, IsHMICooperating()).WillByDefault(Return(false));
+ ON_CALL(app_mngr_, WaitForHmiIsReady()).WillByDefault(Return(true));
EXPECT_CALL(app_mngr_, IsApplicationForbidden(_, _)).WillOnce(Return(false));
ON_CALL(mock_connection_handler_,
@@ -808,11 +800,8 @@ TEST_F(RegisterAppInterfaceRequestTest,
InitBasicMessage();
(*msg_)[am::strings::params][am::strings::connection_key] = kConnectionKey2;
- EXPECT_CALL(app_mngr_, IsStopping())
- .WillOnce(Return(false))
- .WillOnce(Return(true))
- .WillOnce(Return(false));
- ON_CALL(app_mngr_, IsHMICooperating()).WillByDefault(Return(false));
+
+ ON_CALL(app_mngr_, WaitForHmiIsReady()).WillByDefault(Return(true));
EXPECT_CALL(app_mngr_, IsApplicationForbidden(kConnectionKey2, kAppId1))
.WillOnce(Return(false));
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_vehicle_type_response.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_vehicle_type_response.cc
index dbd1b48033..19c1113cc6 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_vehicle_type_response.cc
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_get_vehicle_type_response.cc
@@ -55,11 +55,10 @@ void VIGetVehicleTypeResponse::Run() {
const auto result_code = static_cast<hmi_apis::Common_Result::eType>(
(*message_)[strings::params][hmi_response::code].asInt());
- hmi_capabilities_.UpdateRequestsRequiredForCapabilities(
- hmi_apis::FunctionID::VehicleInfo_GetVehicleType);
-
if (hmi_apis::Common_Result::SUCCESS != result_code) {
SDL_LOG_DEBUG("Request was not successful. Don't change HMI capabilities");
+ hmi_capabilities_.UpdateRequestsRequiredForCapabilities(
+ hmi_apis::FunctionID::VehicleInfo_GetVehicleType);
return;
}
@@ -67,6 +66,9 @@ void VIGetVehicleTypeResponse::Run() {
hmi_capabilities_.set_vehicle_type(
(*message_)[strings::msg_params][hmi_response::vehicle_type]);
+ hmi_capabilities_.UpdateRequestsRequiredForCapabilities(
+ hmi_apis::FunctionID::VehicleInfo_GetVehicleType);
+
if (!hmi_capabilities_.SaveCachedCapabilitiesToFile(
hmi_interface::vehicle_info,
sections_to_update,
diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc
index 8308a843b8..3b1dc1afc6 100644
--- a/src/components/application_manager/src/application_manager_impl.cc
+++ b/src/components/application_manager/src/application_manager_impl.cc
@@ -227,7 +227,7 @@ ApplicationManagerImpl::ApplicationManagerImpl(
ApplicationManagerImpl::~ApplicationManagerImpl() {
SDL_LOG_AUTO_TRACE();
- is_stopping_.store(true);
+ InitiateStopping();
SendOnSDLClose();
media_manager_ = NULL;
hmi_handler_ = NULL;
@@ -1597,6 +1597,58 @@ void ApplicationManagerImpl::OnDeviceListUpdated(
RefreshCloudAppInformation();
}
+bool ApplicationManagerImpl::WaitForHmiIsReady() {
+ sync_primitives::AutoLock lock(wait_for_hmi_lock_);
+ if (!IsStopping() && !IsHMICooperating()) {
+ SDL_LOG_DEBUG("Waiting for the HMI cooperation...");
+ wait_for_hmi_condvar_.Wait(lock);
+ }
+
+ if (IsStopping()) {
+ SDL_LOG_WARN("System is terminating...");
+ return false;
+ }
+
+ return IsHMICooperating();
+}
+
+bool ApplicationManagerImpl::GetProtocolVehicleData(
+ connection_handler::ProtocolVehicleData& data) {
+ SDL_LOG_AUTO_TRACE();
+ using namespace protocol_handler::strings;
+
+ if (!WaitForHmiIsReady()) {
+ SDL_LOG_ERROR("Failed to wait for HMI readiness");
+ return false;
+ }
+
+ const auto vehicle_type_ptr = hmi_capabilities_->vehicle_type();
+ if (vehicle_type_ptr) {
+ if (vehicle_type_ptr->keyExists(vehicle_make)) {
+ data.vehicle_make = vehicle_type_ptr->getElement(vehicle_make).asString();
+ }
+
+ if (vehicle_type_ptr->keyExists(vehicle_model)) {
+ data.vehicle_model =
+ vehicle_type_ptr->getElement(vehicle_model).asString();
+ }
+
+ if (vehicle_type_ptr->keyExists(vehicle_model_year)) {
+ data.vehicle_year =
+ vehicle_type_ptr->getElement(vehicle_model_year).asString();
+ }
+
+ if (vehicle_type_ptr->keyExists(vehicle_trim)) {
+ data.vehicle_trim = vehicle_type_ptr->getElement(vehicle_trim).asString();
+ }
+ }
+
+ data.vehicle_system_software_version = hmi_capabilities_->ccpu_version();
+ data.vehicle_system_hardware_version = hmi_capabilities_->hardware_version();
+
+ return true;
+}
+
void ApplicationManagerImpl::OnFindNewApplicationsRequest() {
connection_handler().ConnectToAllDevices();
SDL_LOG_DEBUG("Starting application list update timer");
@@ -2536,7 +2588,7 @@ bool ApplicationManagerImpl::Init(
bool ApplicationManagerImpl::Stop() {
SDL_LOG_AUTO_TRACE();
- is_stopping_.store(true);
+ InitiateStopping();
application_list_update_timer_.Stop();
try {
if (unregister_reason_ ==
@@ -2951,7 +3003,7 @@ void ApplicationManagerImpl::SetUnregisterAllApplicationsReason(
void ApplicationManagerImpl::HeadUnitReset(
mobile_api::AppInterfaceUnregisteredReason::eType reason) {
SDL_LOG_AUTO_TRACE();
- is_stopping_.store(true);
+ InitiateStopping();
switch (reason) {
case mobile_api::AppInterfaceUnregisteredReason::MASTER_RESET: {
SDL_LOG_TRACE("Performing MASTER_RESET");
@@ -4106,7 +4158,17 @@ bool ApplicationManagerImpl::IsHMICooperating() const {
}
void ApplicationManagerImpl::SetHMICooperating(const bool hmi_cooperating) {
+ SDL_LOG_AUTO_TRACE();
+ sync_primitives::AutoLock lock(wait_for_hmi_lock_);
hmi_cooperating_ = hmi_cooperating;
+ wait_for_hmi_condvar_.Broadcast();
+}
+
+void ApplicationManagerImpl::InitiateStopping() {
+ SDL_LOG_AUTO_TRACE();
+ sync_primitives::AutoLock lock(wait_for_hmi_lock_);
+ is_stopping_.store(true);
+ wait_for_hmi_condvar_.Broadcast();
}
void ApplicationManagerImpl::OnApplicationListUpdateTimer() {
diff --git a/src/components/application_manager/src/hmi_capabilities_impl.cc b/src/components/application_manager/src/hmi_capabilities_impl.cc
index 1390a3ae2c..b4dc9a6b1e 100644
--- a/src/components/application_manager/src/hmi_capabilities_impl.cc
+++ b/src/components/application_manager/src/hmi_capabilities_impl.cc
@@ -1860,6 +1860,15 @@ const std::string& HMICapabilitiesImpl::ccpu_version() const {
return ccpu_version_;
}
+void HMICapabilitiesImpl::set_hardware_version(
+ const std::string& hardware_version) {
+ hardware_version_ = hardware_version;
+}
+
+const std::string& HMICapabilitiesImpl::hardware_version() const {
+ return hardware_version_;
+}
+
void HMICapabilitiesImpl::convert_json_languages_to_obj(
const Json::Value& json_languages,
smart_objects::SmartObject& languages) const {
diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc
index 890dd5b57a..7dae4fc0b3 100644
--- a/src/components/application_manager/src/policies/policy_handler.cc
+++ b/src/components/application_manager/src/policies/policy_handler.cc
@@ -1097,6 +1097,14 @@ void PolicyHandler::OnGetSystemInfo(const std::string& ccpu_version,
policy_manager->SetSystemInfo(ccpu_version, wers_country_code, language);
}
+void PolicyHandler::OnHardwareVersionReceived(
+ const std::string& hardware_version) {
+ SDL_LOG_AUTO_TRACE();
+ const auto policy_manager = LoadPolicyManager();
+ POLICY_LIB_CHECK_VOID(policy_manager);
+ policy_manager->SetHardwareVersion(hardware_version);
+}
+
std::string PolicyHandler::GetCCPUVersionFromPT() const {
SDL_LOG_AUTO_TRACE();
const auto policy_manager = LoadPolicyManager();
@@ -1104,6 +1112,13 @@ std::string PolicyHandler::GetCCPUVersionFromPT() const {
return policy_manager->GetCCPUVersionFromPT();
}
+std::string PolicyHandler::GetHardwareVersionFromPT() const {
+ SDL_LOG_AUTO_TRACE();
+ const auto policy_manager = LoadPolicyManager();
+ POLICY_LIB_CHECK_OR_RETURN(policy_manager, std::string());
+ return policy_manager->GetHardwareVersionFromPT();
+}
+
void PolicyHandler::OnVIIsReady() {
SDL_LOG_AUTO_TRACE();
const uint32_t correlation_id =
diff --git a/src/components/application_manager/src/rpc_service_impl.cc b/src/components/application_manager/src/rpc_service_impl.cc
index 34a0bed7af..f0cd720e30 100644
--- a/src/components/application_manager/src/rpc_service_impl.cc
+++ b/src/components/application_manager/src/rpc_service_impl.cc
@@ -390,7 +390,10 @@ bool RPCServiceImpl::ManageHMICommand(const commands::MessageSharedPtr message,
if (command->Init()) {
command->Run();
- if (kResponse == message_type) {
+ if (helpers::Compare<int32_t, helpers::EQ, helpers::ONE>(
+ message_type, kResponse, kErrorResponse) &&
+ message->getElement(strings::params)
+ .keyExists(strings::correlation_id)) {
const uint32_t correlation_id =
(*(message.get()))[strings::params][strings::correlation_id].asUInt();
const int32_t function_id =
diff --git a/src/components/application_manager/src/smart_object_keys.cc b/src/components/application_manager/src/smart_object_keys.cc
index 20426355c1..8d3aaf5b1a 100644
--- a/src/components/application_manager/src/smart_object_keys.cc
+++ b/src/components/application_manager/src/smart_object_keys.cc
@@ -307,6 +307,7 @@ const char* video_streaming = "videoStreaming";
const char* remote_control = "remoteControl";
const char* sdl_version = "sdlVersion";
const char* system_software_version = "systemSoftwareVersion";
+const char* system_hardware_version = "systemHardwareVersion";
const char* priority = "priority";
const char* engine_oil_life = "engineOilLife";
const char* oem_custom_data_type = "oemCustomDataType";
diff --git a/src/components/application_manager/test/include/application_manager/mock_hmi_capabilities.h b/src/components/application_manager/test/include/application_manager/mock_hmi_capabilities.h
index 2f9f40ad2a..e40197cc13 100644
--- a/src/components/application_manager/test/include/application_manager/mock_hmi_capabilities.h
+++ b/src/components/application_manager/test/include/application_manager/mock_hmi_capabilities.h
@@ -212,6 +212,8 @@ class MockHMICapabilities : public ::application_manager::HMICapabilities {
MOCK_CONST_METHOD0(ccpu_version, const std::string&());
MOCK_METHOD1(set_ccpu_version, void(const std::string& ccpu_version));
+ MOCK_CONST_METHOD0(hardware_version, const std::string&());
+ MOCK_METHOD1(set_hardware_version, void(const std::string& hardware_version));
MOCK_METHOD1(OnSoftwareVersionReceived,
void(const std::string& ccpu_version));
MOCK_METHOD0(UpdateCachedCapabilities, void());
diff --git a/src/components/application_manager/test/policy_handler_test.cc b/src/components/application_manager/test/policy_handler_test.cc
index b9a74f14ba..1d764526b9 100644
--- a/src/components/application_manager/test/policy_handler_test.cc
+++ b/src/components/application_manager/test/policy_handler_test.cc
@@ -1290,19 +1290,6 @@ TEST_F(PolicyHandlerTest, OnSystemInfoChanged) {
policy_handler_.OnSystemInfoChanged(language);
}
-TEST_F(PolicyHandlerTest, OnGetSystemInfo) {
- // Arrange
- ChangePolicyManagerToMock();
- // Check expectations
- const std::string ccpu_version("4.1.3.B_EB355B");
- const std::string wers_country_code("WAEGB");
- const std::string language("ru-ru");
- EXPECT_CALL(*mock_policy_manager_,
- SetSystemInfo(ccpu_version, wers_country_code, language));
- // Act
- policy_handler_.OnGetSystemInfo(ccpu_version, wers_country_code, language);
-}
-
TEST_F(PolicyHandlerTest, IsApplicationRevoked) {
// Arrange
EnablePolicy();
diff --git a/src/components/connection_handler/include/connection_handler/connection_handler_impl.h b/src/components/connection_handler/include/connection_handler/connection_handler_impl.h
index a7dfd29b31..25a89ea4b3 100644
--- a/src/components/connection_handler/include/connection_handler/connection_handler_impl.h
+++ b/src/components/connection_handler/include/connection_handler/connection_handler_impl.h
@@ -648,6 +648,8 @@ class ConnectionHandlerImpl
void CreateWebEngineDevice() OVERRIDE;
+ bool GetProtocolVehicleData(ProtocolVehicleData& data) OVERRIDE;
+
private:
/**
* \brief Disconnect application.
diff --git a/src/components/connection_handler/src/connection_handler_impl.cc b/src/components/connection_handler/src/connection_handler_impl.cc
index a771f0a104..da269721eb 100644
--- a/src/components/connection_handler/src/connection_handler_impl.cc
+++ b/src/components/connection_handler/src/connection_handler_impl.cc
@@ -919,6 +919,15 @@ void ConnectionHandlerImpl::CreateWebEngineDevice() {
transport_manager_.CreateWebEngineDevice();
}
+bool ConnectionHandlerImpl::GetProtocolVehicleData(ProtocolVehicleData& data) {
+ sync_primitives::AutoReadLock read_lock(connection_handler_observer_lock_);
+ if (connection_handler_observer_) {
+ return connection_handler_observer_->GetProtocolVehicleData(data);
+ }
+
+ return false;
+}
+
const std::string
ConnectionHandlerImpl::TransportTypeProfileStringFromConnHandle(
transport_manager::ConnectionUID connection_handle) const {
diff --git a/src/components/include/application_manager/application_manager.h b/src/components/include/application_manager/application_manager.h
index 2bb202c62d..ae9344634c 100644
--- a/src/components/include/application_manager/application_manager.h
+++ b/src/components/include/application_manager/application_manager.h
@@ -623,6 +623,12 @@ class ApplicationManager {
virtual bool IsStopping() const = 0;
+ /**
+ * @brief Waits for HMI readiness and blocks thread if it's not ready yet
+ * @return true if HMI is ready and cooperating, otherwise returns false
+ */
+ virtual bool WaitForHmiIsReady() = 0;
+
virtual void RemoveAppFromTTSGlobalPropertiesList(const uint32_t app_id) = 0;
/**
diff --git a/src/components/include/application_manager/hmi_capabilities.h b/src/components/include/application_manager/hmi_capabilities.h
index 56ac807d63..e7d7aa485b 100644
--- a/src/components/include/application_manager/hmi_capabilities.h
+++ b/src/components/include/application_manager/hmi_capabilities.h
@@ -97,11 +97,26 @@ class HMICapabilities {
/**
* @brief Returns software version of the target
- * @return TRUE if it supported, otherwise FALSE
+ * @return string representation of software version if supported, otherwise
+ * empty string
*/
virtual const std::string& ccpu_version() const = 0;
/**
+ * @brief Interface used to store information about hardware version of the
+ * target
+ * @param hardware_version Received system/hmi hardware version
+ */
+ virtual void set_hardware_version(const std::string& hardware_version) = 0;
+
+ /**
+ * @brief Returns hardware version of the target
+ * @return string representation of hardware version if supported, otherwise
+ * empty string
+ */
+ virtual const std::string& hardware_version() const = 0;
+
+ /**
* @brief Retrieves if mixing audio is supported by HMI
* (ie recording TTS command and playing audio)
* @return Current state of the mixing audio flag
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 d8aef7cc1a..7ada7884bf 100644
--- a/src/components/include/application_manager/policies/policy_handler_interface.h
+++ b/src/components/include/application_manager/policies/policy_handler_interface.h
@@ -332,12 +332,26 @@ class PolicyHandlerInterface : public VehicleDataItemProvider {
const std::string& language) = 0;
/**
+ * @brief Save hardware version from GetSystemInfo request to policy table, if
+ * present
+ * @param hardware_version Hardware version
+ */
+ virtual void OnHardwareVersionReceived(
+ const std::string& hardware_version) = 0;
+
+ /**
* @brief Get information about last ccpu_version from PT
* @return ccpu_version from PT
*/
virtual std::string GetCCPUVersionFromPT() const = 0;
/**
+ * @brief Get information about last hardware version from PT
+ * @return hardware version from PT
+ */
+ virtual std::string GetHardwareVersionFromPT() const = 0;
+
+ /**
* @brief Sends GetVehicleData request in case when Vechicle info is ready.
*/
virtual void OnVIIsReady() = 0;
diff --git a/src/components/include/connection_handler/connection_handler.h b/src/components/include/connection_handler/connection_handler.h
index cb83bec564..7cb1448a37 100644
--- a/src/components/include/connection_handler/connection_handler.h
+++ b/src/components/include/connection_handler/connection_handler.h
@@ -58,6 +58,18 @@ enum CloseSessionReason {
class ConnectionHandlerObserver;
+/**
+ * @brief Helper structure to collect all required vehicle data
+ */
+struct ProtocolVehicleData {
+ std::string vehicle_make;
+ std::string vehicle_model;
+ std::string vehicle_year;
+ std::string vehicle_trim;
+ std::string vehicle_system_software_version;
+ std::string vehicle_system_hardware_version;
+};
+
// The SessionConnectionMap keeps track of the primary and secondary transports
// associated with a session ID
typedef struct {
@@ -345,6 +357,14 @@ class ConnectionHandler {
const = 0;
/**
+ * @brief Collects all vehicle data required by a protocol layer
+ * @param data output structure to store received vehicle data
+ * @return true if data has been received successfully, otherwise returns
+ * false
+ */
+ virtual bool GetProtocolVehicleData(ProtocolVehicleData& data) = 0;
+
+ /**
* @brief Called when HMI cooperation is started,
* creates WebSocketDevice for WebEngine
*/
diff --git a/src/components/include/connection_handler/connection_handler_observer.h b/src/components/include/connection_handler/connection_handler_observer.h
index 7d6664a009..cfbbefefd4 100644
--- a/src/components/include/connection_handler/connection_handler_observer.h
+++ b/src/components/include/connection_handler/connection_handler_observer.h
@@ -177,6 +177,14 @@ class ConnectionHandlerObserver {
*/
virtual void OnWebEngineDeviceCreated() = 0;
+ /**
+ * @brief Collects all vehicle data required by a protocol layer
+ * @param data output structure to store received vehicle data
+ * @return true if data has been received successfully, otherwise returns
+ * false
+ */
+ virtual bool GetProtocolVehicleData(ProtocolVehicleData& data) = 0;
+
protected:
/**
* \brief Destructor
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 9d4ad5ea57..3f17e50702 100644
--- a/src/components/include/policy/policy_external/policy/policy_manager.h
+++ b/src/components/include/policy/policy_external/policy/policy_manager.h
@@ -433,12 +433,25 @@ class PolicyManager : public usage_statistics::StatisticsManager,
const std::string& language) = 0;
/**
+ * @brief Set hardware version from GetSystemInfo response to policy table, if
+ * present
+ * @param hardware_version Hardware version
+ */
+ virtual void SetHardwareVersion(const std::string& hardware_version) = 0;
+
+ /**
* @brief Get information about last ccpu_version from PT
* @return ccpu_version from PT
*/
virtual std::string GetCCPUVersionFromPT() const = 0;
/**
+ * @brief Get information about last hardware version from PT
+ * @return hardware version from PT
+ */
+ virtual std::string GetHardwareVersionFromPT() const = 0;
+
+ /**
* @brief Send OnPermissionsUpdated for choosen application
* @param device_id device identifier
* @param application_id Unique application id
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 c90006928a..b4043067ab 100644
--- a/src/components/include/policy/policy_regular/policy/policy_manager.h
+++ b/src/components/include/policy/policy_regular/policy/policy_manager.h
@@ -424,12 +424,25 @@ class PolicyManager : public usage_statistics::StatisticsManager,
const std::string& language) = 0;
/**
+ * @brief Set hardware version from GetSystemInfo response to policy table, if
+ * present
+ * @param hardware_version Hardware version
+ */
+ virtual void SetHardwareVersion(const std::string& hardware_version) = 0;
+
+ /**
* @brief Get information about last ccpu_version from PT
* @return ccpu_version from PT
*/
virtual std::string GetCCPUVersionFromPT() const = 0;
/**
+ * @brief Get information about last hardware version from PT
+ * @return hardware version from PT
+ */
+ virtual std::string GetHardwareVersionFromPT() const = 0;
+
+ /**
* @brief Send OnPermissionsUpdated for choosen application
* @param device_id device identifier
* @param application_id Unique application id
diff --git a/src/components/include/protocol/bson_object_keys.h b/src/components/include/protocol/bson_object_keys.h
index f81de4cc81..830c33b3eb 100644
--- a/src/components/include/protocol/bson_object_keys.h
+++ b/src/components/include/protocol/bson_object_keys.h
@@ -49,6 +49,12 @@ extern const char* tcp_ip_address;
extern const char* tcp_port;
extern const char* reason;
extern const char* auth_token;
+extern const char* vehicle_make;
+extern const char* vehicle_model;
+extern const char* vehicle_model_year;
+extern const char* vehicle_trim;
+extern const char* vehicle_system_software_version;
+extern const char* vehicle_system_hardware_version;
} // namespace strings
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 3b827b1a0d..6a035a01d1 100644
--- a/src/components/include/test/application_manager/mock_application_manager.h
+++ b/src/components/include/test/application_manager/mock_application_manager.h
@@ -232,6 +232,7 @@ class MockApplicationManager : public application_manager::ApplicationManager {
MOCK_CONST_METHOD1(IsAppsQueriedFrom,
bool(const connection_handler::DeviceHandle handle));
MOCK_CONST_METHOD0(IsStopping, bool());
+ MOCK_METHOD0(WaitForHmiIsReady, bool());
MOCK_METHOD1(RemoveAppFromTTSGlobalPropertiesList,
void(const uint32_t app_id));
MOCK_METHOD2(ResetGlobalProperties,
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 7b6da68c51..af4019ce21 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
@@ -186,7 +186,10 @@ class MockPolicyHandlerInterface : public policy::PolicyHandlerInterface {
void(const std::string& ccpu_version,
const std::string& wers_country_code,
const std::string& language));
+ MOCK_METHOD1(OnHardwareVersionReceived,
+ void(const std::string& hardware_version));
MOCK_CONST_METHOD0(GetCCPUVersionFromPT, std::string());
+ MOCK_CONST_METHOD0(GetHardwareVersionFromPT, std::string());
MOCK_METHOD0(OnVIIsReady, void());
MOCK_METHOD1(OnVehicleDataUpdated,
void(const smart_objects::SmartObject& message));
diff --git a/src/components/include/test/connection_handler/mock_connection_handler.h b/src/components/include/test/connection_handler/mock_connection_handler.h
index 78083b0abf..bdfcf55e34 100644
--- a/src/components/include/test/connection_handler/mock_connection_handler.h
+++ b/src/components/include/test/connection_handler/mock_connection_handler.h
@@ -139,6 +139,8 @@ class MockConnectionHandler : public connection_handler::ConnectionHandler {
OnSecondaryTransportEnded,
void(const transport_manager::ConnectionUID primary_connection_handle,
const transport_manager::ConnectionUID secondary_connection_handle));
+ MOCK_METHOD1(GetProtocolVehicleData,
+ bool(connection_handler::ProtocolVehicleData& data));
MOCK_METHOD0(CreateWebEngineDevice, void());
MOCK_CONST_METHOD0(GetWebEngineDeviceInfo, transport_manager::DeviceInfo&());
};
diff --git a/src/components/include/test/connection_handler/mock_connection_handler_observer.h b/src/components/include/test/connection_handler/mock_connection_handler_observer.h
index 61877daa23..90174017c3 100644
--- a/src/components/include/test/connection_handler/mock_connection_handler_observer.h
+++ b/src/components/include/test/connection_handler/mock_connection_handler_observer.h
@@ -83,6 +83,8 @@ class MockConnectionHandlerObserver
MOCK_METHOD2(SetPendingApplicationState,
void(const transport_manager::ConnectionUID connection_id,
const transport_manager::DeviceInfo& device_info));
+ MOCK_METHOD1(GetProtocolVehicleData,
+ bool(connection_handler::ProtocolVehicleData& data));
};
} // namespace connection_handler_test
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 d93bdff7f7..a79918cc39 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
@@ -207,7 +207,9 @@ class MockCacheManagerInterface : public ::policy::CacheManagerInterface {
bool(const std::string& ccpu_version,
const std::string& wers_country_code,
const std::string& language));
+ MOCK_METHOD1(SetHardwareVersion, void(const std::string& hardware_version));
MOCK_CONST_METHOD0(GetCCPUVersionFromPT, std::string());
+ MOCK_CONST_METHOD0(GetHardwareVersionFromPT, std::string());
MOCK_CONST_METHOD0(IsMetaInfoPresent, bool());
MOCK_METHOD1(SetSystemLanguage, bool(const std::string& language));
MOCK_METHOD1(Increment, void(usage_statistics::GlobalCounterId type));
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 0123c6c912..84a8b3ecce 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
@@ -173,6 +173,7 @@ class MockPolicyManager : public PolicyManager {
void(const std::string& ccpu_version,
const std::string& wers_country_code,
const std::string& language));
+ MOCK_METHOD1(SetHardwareVersion, void(const std::string& hardware_version));
MOCK_METHOD1(SetPreloadedPtFlag, void(const bool is_preloaded));
MOCK_METHOD2(SendNotificationOnPermissionsUpdated,
void(const std::string& device_id,
@@ -308,6 +309,7 @@ class MockPolicyManager : public PolicyManager {
MOCK_METHOD0(RetrySequenceFailed, void());
MOCK_METHOD0(ResetTimeout, void());
MOCK_CONST_METHOD0(GetCCPUVersionFromPT, std::string());
+ MOCK_CONST_METHOD0(GetHardwareVersionFromPT, std::string());
};
} // 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 19de301dc3..716f66f994 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
@@ -181,7 +181,9 @@ class MockCacheManagerInterface : public CacheManagerInterface {
bool(const std::string& ccpu_version,
const std::string& wers_country_code,
const std::string& language));
+ MOCK_METHOD1(SetHardwareVersion, void(const std::string& hardware_version));
MOCK_CONST_METHOD0(GetCCPUVersionFromPT, std::string());
+ MOCK_CONST_METHOD0(GetHardwareVersionFromPT, std::string());
MOCK_CONST_METHOD0(IsMetaInfoPresent, bool());
MOCK_METHOD1(SetSystemLanguage, bool(const std::string& language));
MOCK_METHOD1(Increment, void(usage_statistics::GlobalCounterId type));
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 4cb6455db6..076f0423ef 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
@@ -172,6 +172,7 @@ class MockPolicyManager : public PolicyManager {
void(const std::string& ccpu_version,
const std::string& wers_country_code,
const std::string& language));
+ MOCK_METHOD1(SetHardwareVersion, void(const std::string& hardware_version));
MOCK_METHOD1(SetPreloadedPtFlag, void(const bool is_preloaded));
MOCK_METHOD2(SendNotificationOnPermissionsUpdated,
void(const std::string& device_id,
@@ -311,6 +312,7 @@ class MockPolicyManager : public PolicyManager {
RequestSubType::State(const std::string& policy_app_id));
MOCK_METHOD0(ResetTimeout, void());
MOCK_CONST_METHOD0(GetCCPUVersionFromPT, std::string());
+ MOCK_CONST_METHOD0(GetHardwareVersionFromPT, std::string());
};
} // namespace policy_manager_test
diff --git a/src/components/interfaces/HMI_API.xml b/src/components/interfaces/HMI_API.xml
index 68046005f6..6256cd747b 100644
--- a/src/components/interfaces/HMI_API.xml
+++ b/src/components/interfaces/HMI_API.xml
@@ -4872,6 +4872,9 @@
<param name="wersCountryCode" type="String" maxlength="500" mandatory="true">
<description>Country code from the Ford system WERS (i.e.WAEGB).</description>
</param>
+ <param name="systemHardwareVersion" type="String" maxlength="500" mandatory="false">
+ <description>The hardware version of the system</description>
+ </param>
</function>
<function name="OnSystemInfoChanged" messagetype="notification">
<description>Issued by system to SDL to notify that some system param has changed. Currently applied for Sync Language.</description>
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 12fe8f10cd..8384f56f77 100644
--- a/src/components/policy/policy_external/include/policy/cache_manager.h
+++ b/src/components/policy/policy_external/include/policy/cache_manager.h
@@ -597,13 +597,11 @@ class CacheManager : public CacheManagerInterface {
*/
void SetPreloadedPtFlag(const bool is_preloaded) OVERRIDE;
- /**
- * @brief Records information about head unit system to PT
- * @return bool Success of operation
- */
bool SetMetaInfo(const std::string& ccpu_version,
const std::string& wers_country_code,
- const std::string& language);
+ const std::string& language) OVERRIDE;
+
+ void SetHardwareVersion(const std::string& hardware_version) OVERRIDE;
/**
* @brief Get information about last ccpu_version from PT
@@ -611,6 +609,8 @@ class CacheManager : public CacheManagerInterface {
*/
std::string GetCCPUVersionFromPT() const;
+ std::string GetHardwareVersionFromPT() const OVERRIDE;
+
/**
* @brief Checks, if specific head unit is present in PT
* @return boot Suceess, if present, otherwise - false
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 8ed46e0c72..f33dabd025 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
@@ -645,7 +645,7 @@ class CacheManagerInterface {
virtual void SetPreloadedPtFlag(const bool is_preloaded) = 0;
/**
- * @brief Records information about head unit system to PT
+ * @brief Records mandatory information about head unit system to PT
* @return bool Success of operation
*/
virtual bool SetMetaInfo(const std::string& ccpu_version,
@@ -653,12 +653,24 @@ class CacheManagerInterface {
const std::string& language) = 0;
/**
+ * @brief Records information about hardware version to PT
+ * @param hardware_version Hardware version
+ */
+ virtual void SetHardwareVersion(const std::string& hardware_version) = 0;
+
+ /**
* @brief Get information about last ccpu_version from PT
* @return ccpu_version from PT
*/
virtual std::string GetCCPUVersionFromPT() const = 0;
/**
+ * @brief Get information about last hardware version from PT
+ * @return hardware version from PT
+ */
+ virtual std::string GetHardwareVersionFromPT() const = 0;
+
+ /**
* @brief Checks, if specific head unit is present in PT
* @return boot Suceess, if present, otherwise - false
*/
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 27ce30bb3d..cd4d6f40d5 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
@@ -435,10 +435,14 @@ class PolicyManagerImpl : public PolicyManager {
const std::string& wers_country_code,
const std::string& language) OVERRIDE;
+ void SetHardwareVersion(const std::string& hardware_version) OVERRIDE;
+
void SetPreloadedPtFlag(const bool is_preloaded) OVERRIDE;
std::string GetCCPUVersionFromPT() const OVERRIDE;
+ std::string GetHardwareVersionFromPT() const OVERRIDE;
+
/**
* @brief Get number of notification by priority
* @param priority Specified priority
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 6b2f05d336..25439f835b 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
@@ -490,6 +490,7 @@ struct ModuleMeta : CompositeType {
Optional<String<0, 500> > ccpu_version;
Optional<String<0, 250> > language;
Optional<String<0, 250> > wers_country_code;
+ Optional<String<0, 500> > hardware_version;
Optional<Integer<uint32_t, 0, ODO_MAX> > pt_exchanged_at_odometer_x;
Optional<Integer<uint16_t, 0, 65535> > pt_exchanged_x_days_after_epoch;
Optional<Integer<uint16_t, 0, 65535> > ignition_cycles_since_last_exchange;
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 0e643acd84..a3b91abbc5 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
@@ -223,6 +223,7 @@
<param name="ccpu_version" type="String" maxlength="250" mandatory="false"/>
<param name="language" type="String" maxlength="250" mandatory="false"/>
<param name="wers_country_code" type="String" maxlength="250" mandatory="false"/>
+ <param name="hardware_version" type="String" maxlength="500" mandatory="false"/>
<param name="pt_exchanged_at_odometer_x" type="Integer" minvalue="0" maxvalue="65535" mandatory="false"/>
<param name="pt_exchanged_x_days_after_epoch" type="Integer" minvalue="0" maxvalue="65535" mandatory="false"/>
<param name="ignition_cycles_since_last_exchange" type="Integer" minvalue="0" maxvalue="65535" mandatory="false"/>
diff --git a/src/components/policy/policy_external/include/policy/pt_ext_representation.h b/src/components/policy/policy_external/include/policy/pt_ext_representation.h
index f03947268a..867033bc20 100644
--- a/src/components/policy/policy_external/include/policy/pt_ext_representation.h
+++ b/src/components/policy/policy_external/include/policy/pt_ext_representation.h
@@ -198,7 +198,7 @@ class PTExtRepresentation : public virtual PTRepresentation {
const std::string& language) = 0;
/**
- * @brief Records information about head unit system to PT
+ * @brief Records mandatory information about head unit system to PT
* @return bool Success of operation
*/
virtual bool SetMetaInfo(const std::string& ccpu_version,
@@ -206,6 +206,12 @@ class PTExtRepresentation : public virtual PTRepresentation {
const std::string& language) = 0;
/**
+ * @brief Records information about hardware version to PT
+ * @param hardware_version Hardware version
+ */
+ virtual void SetHardwareVersion(const std::string& hardware_version) = 0;
+
+ /**
* @brief Checks, if specific head unit is present in PT
* @return boot Suceess, if present, otherwise - false
*/
diff --git a/src/components/policy/policy_external/include/policy/sql_pt_ext_queries.h b/src/components/policy/policy_external/include/policy/sql_pt_ext_queries.h
index b8f85ec7b1..abb18d51e4 100644
--- a/src/components/policy/policy_external/include/policy/sql_pt_ext_queries.h
+++ b/src/components/policy/policy_external/include/policy/sql_pt_ext_queries.h
@@ -65,6 +65,7 @@ extern const std::string kInsertExternalConsentStatusGroups;
extern const std::string kCountUnconsentedGroups;
extern const std::string kSelectModuleMeta;
extern const std::string kUpdateMetaParams;
+extern const std::string kUpdateMetaHardwareVersion;
extern const std::string kUpdateModuleMetaVinParam;
extern const std::string kSaveModuleMeta;
extern const std::string kSelectMetaParams;
diff --git a/src/components/policy/policy_external/include/policy/sql_pt_ext_representation.h b/src/components/policy/policy_external/include/policy/sql_pt_ext_representation.h
index 889ede9d20..de2d0c1536 100644
--- a/src/components/policy/policy_external/include/policy/sql_pt_ext_representation.h
+++ b/src/components/policy/policy_external/include/policy/sql_pt_ext_representation.h
@@ -94,7 +94,9 @@ class SQLPTExtRepresentation : public SQLPTRepresentation,
bool SetMetaInfo(const std::string& ccpu_version,
const std::string& wers_country_code,
- const std::string& language);
+ const std::string& language) OVERRIDE;
+
+ void SetHardwareVersion(const std::string& hardware_version) OVERRIDE;
bool IsMetaInfoPresent();
diff --git a/src/components/policy/policy_external/src/cache_manager.cc b/src/components/policy/policy_external/src/cache_manager.cc
index 783a622b2e..07f2df1991 100644
--- a/src/components/policy/policy_external/src/cache_manager.cc
+++ b/src/components/policy/policy_external/src/cache_manager.cc
@@ -2047,7 +2047,8 @@ void CacheManager::PersistData() {
*(*copy_pt.policy_table.module_meta).wers_country_code,
*(*copy_pt.policy_table.module_meta).language);
ex_backup_->SetVINValue(*(*copy_pt.policy_table.module_meta).vin);
-
+ ex_backup_->SetHardwareVersion(
+ *(*copy_pt.policy_table.module_meta).hardware_version);
// Save unpaired flag for devices
policy_table::DeviceData::const_iterator it_device =
copy_pt.policy_table.device_data->begin();
@@ -2300,13 +2301,35 @@ bool CacheManager::SetMetaInfo(const std::string& ccpu_version,
return true;
}
+void CacheManager::SetHardwareVersion(const std::string& hardware_version) {
+ SDL_LOG_AUTO_TRACE();
+ CACHE_MANAGER_CHECK_VOID();
+ sync_primitives::AutoLock auto_lock(cache_lock_);
+
+ *pt_->policy_table.module_meta->hardware_version = hardware_version;
+ Backup();
+}
+
std::string CacheManager::GetCCPUVersionFromPT() const {
SDL_LOG_AUTO_TRACE();
+ CACHE_MANAGER_CHECK(std::string(""));
+ sync_primitives::AutoLock auto_lock(cache_lock_);
+
rpc::Optional<policy_table::ModuleMeta>& module_meta =
pt_->policy_table.module_meta;
return *(module_meta->ccpu_version);
}
+std::string CacheManager::GetHardwareVersionFromPT() const {
+ SDL_LOG_AUTO_TRACE();
+ CACHE_MANAGER_CHECK(std::string(""));
+ sync_primitives::AutoLock auto_lock(cache_lock_);
+
+ rpc::Optional<policy_table::ModuleMeta>& module_meta =
+ pt_->policy_table.module_meta;
+ return *(module_meta->hardware_version);
+}
+
bool CacheManager::IsMetaInfoPresent() const {
CACHE_MANAGER_CHECK(false);
sync_primitives::AutoLock lock(cache_lock_);
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 9bcea70803..d4348957f7 100644
--- a/src/components/policy/policy_external/src/policy_manager_impl.cc
+++ b/src/components/policy/policy_external/src/policy_manager_impl.cc
@@ -1617,11 +1617,22 @@ void PolicyManagerImpl::SetSystemInfo(const std::string& ccpu_version,
cache_->SetMetaInfo(ccpu_version, wers_country_code, language);
}
+void PolicyManagerImpl::SetHardwareVersion(
+ const std::string& hardware_version) {
+ SDL_LOG_AUTO_TRACE();
+ cache_->SetHardwareVersion(hardware_version);
+}
+
std::string PolicyManagerImpl::GetCCPUVersionFromPT() const {
SDL_LOG_AUTO_TRACE();
return cache_->GetCCPUVersionFromPT();
}
+std::string PolicyManagerImpl::GetHardwareVersionFromPT() const {
+ SDL_LOG_AUTO_TRACE();
+ return cache_->GetHardwareVersionFromPT();
+}
+
uint32_t PolicyManagerImpl::GetNotificationsNumber(const std::string& priority,
const bool is_subtle) const {
SDL_LOG_AUTO_TRACE();
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 cb7f2bdd9d..47c4202de0 100644
--- a/src/components/policy/policy_external/src/policy_table/types.cc
+++ b/src/components/policy/policy_external/src/policy_table/types.cc
@@ -1424,6 +1424,7 @@ ModuleMeta::ModuleMeta(const Json::Value* value__)
, ccpu_version(impl::ValueMember(value__, "ccpu_version"))
, language(impl::ValueMember(value__, "language"))
, wers_country_code(impl::ValueMember(value__, "wers_country_code"))
+ , hardware_version(impl::ValueMember(value__, "hardware_version"))
, pt_exchanged_at_odometer_x(
impl::ValueMember(value__, "pt_exchanged_at_odometer_x"))
, pt_exchanged_x_days_after_epoch(
@@ -1437,6 +1438,7 @@ Json::Value ModuleMeta::ToJsonValue() const {
impl::WriteJsonField("ccpu_version", ccpu_version, &result__);
impl::WriteJsonField("language", language, &result__);
impl::WriteJsonField("wers_country_code", wers_country_code, &result__);
+ impl::WriteJsonField("hardware_version", hardware_version, &result__);
impl::WriteJsonField(
"pt_exchanged_at_odometer_x", pt_exchanged_at_odometer_x, &result__);
impl::WriteJsonField("pt_exchanged_x_days_after_epoch",
@@ -1462,6 +1464,11 @@ bool ModuleMeta::is_valid() const {
if (!wers_country_code.is_valid()) {
return false;
}
+
+ if (!hardware_version.is_valid()) {
+ return false;
+ }
+
if (!pt_exchanged_at_odometer_x.is_valid()) {
return false;
}
@@ -1492,6 +1499,11 @@ bool ModuleMeta::struct_empty() const {
if (wers_country_code.is_initialized()) {
return false;
}
+
+ if (hardware_version.is_initialized()) {
+ return false;
+ }
+
if (pt_exchanged_at_odometer_x.is_initialized()) {
return false;
}
@@ -1506,6 +1518,7 @@ bool ModuleMeta::struct_empty() const {
if (vin.is_initialized()) {
return false;
}
+
return true;
}
@@ -1523,6 +1536,10 @@ void ModuleMeta::ReportErrors(rpc::ValidationReport* report__) const {
wers_country_code.ReportErrors(
&report__->ReportSubobject("wers_country_code"));
}
+ if (!hardware_version.is_valid()) {
+ hardware_version.ReportErrors(
+ &report__->ReportSubobject("hardware_version"));
+ }
if (!pt_exchanged_at_odometer_x.is_valid()) {
pt_exchanged_at_odometer_x.ReportErrors(
&report__->ReportSubobject("pt_exchanged_at_odometer_x"));
@@ -1551,6 +1568,7 @@ void ModuleMeta::SetPolicyTableType(PolicyTableType pt_type) {
ccpu_version.SetPolicyTableType(pt_type);
language.SetPolicyTableType(pt_type);
wers_country_code.SetPolicyTableType(pt_type);
+ hardware_version.SetPolicyTableType(pt_type);
pt_exchanged_at_odometer_x.SetPolicyTableType(pt_type);
pt_exchanged_x_days_after_epoch.SetPolicyTableType(pt_type);
ignition_cycles_since_last_exchange.SetPolicyTableType(pt_type);
diff --git a/src/components/policy/policy_external/src/sql_pt_ext_queries.cc b/src/components/policy/policy_external/src/sql_pt_ext_queries.cc
index ea323908c0..26d2124d07 100644
--- a/src/components/policy/policy_external/src/sql_pt_ext_queries.cc
+++ b/src/components/policy/policy_external/src/sql_pt_ext_queries.cc
@@ -170,18 +170,27 @@ const std::string kCountUnconsentedGroups =
" WHERE (`a`.`functional_group_id` = `f`.`id`"
" AND`f`.`user_consent_prompt` IS NULL))";
-const std::string kSelectModuleMeta = "SELECT* FROM `module_meta`";
+const std::string kSelectModuleMeta =
+ "SELECT `ccpu_version`, `language`, "
+ "`wers_country_code`, `hardware_version`, `pt_exchanged_at_odometer_x`, "
+ "`pt_exchanged_x_days_after_epoch`, "
+ "`ignition_cycles_since_last_exchange`, `vin` "
+ "FROM `module_meta`";
const std::string kUpdateMetaParams =
"UPDATE `module_meta` SET "
- "`ccpu_version` = ?, `wers_country_code` = ?, `language` = ? ";
+ "`ccpu_version` = ?, `wers_country_code` = ?, `language` = ?";
+
+const std::string kUpdateMetaHardwareVersion =
+ "UPDATE `module_meta` SET `hardware_version` = ? ";
const std::string kUpdateModuleMetaVinParam =
"UPDATE `module_meta` SET `vin` = ? ";
const std::string kSaveModuleMeta =
"UPDATE `module_meta` SET `ccpu_version` = ?, `language` = ?,"
- "`wers_country_code` = ?, `pt_exchanged_at_odometer_x` = ?,"
+ "`wers_country_code` = ?, `hardware_version` = ?, "
+ "`pt_exchanged_at_odometer_x` = ?,"
"`pt_exchanged_x_days_after_epoch` = ?,"
"`ignition_cycles_since_last_exchange` = ?, `vin` = ?";
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 7147e0949d..fc35551808 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
@@ -600,6 +600,22 @@ bool SQLPTExtRepresentation::SetMetaInfo(const std::string& ccpu_version,
return true;
}
+void SQLPTExtRepresentation::SetHardwareVersion(
+ const std::string& hardware_version) {
+ SDL_LOG_AUTO_TRACE();
+ utils::dbms::SQLQuery query(db());
+ if (!query.Prepare(sql_pt_ext::kUpdateMetaHardwareVersion)) {
+ SDL_LOG_WARN("Incorrect statement for insert to module meta.");
+ return;
+ }
+
+ query.Bind(0, hardware_version);
+
+ if (!query.Exec()) {
+ SDL_LOG_WARN("Incorrect insert to module meta.");
+ }
+}
+
bool SQLPTExtRepresentation::IsMetaInfoPresent() {
SDL_LOG_AUTO_TRACE();
utils::dbms::SQLQuery query(db());
@@ -1320,10 +1336,11 @@ void SQLPTExtRepresentation::GatherModuleMeta(
*meta->ccpu_version = query.GetString(0);
*meta->language = query.GetString(1);
*meta->wers_country_code = query.GetString(2);
- *meta->pt_exchanged_at_odometer_x = query.GetInteger(3);
- *meta->pt_exchanged_x_days_after_epoch = query.GetInteger(4);
- *meta->ignition_cycles_since_last_exchange = query.GetInteger(5);
- *meta->vin = query.GetString(6);
+ *meta->hardware_version = query.GetString(3);
+ *meta->pt_exchanged_at_odometer_x = query.GetInteger(4);
+ *meta->pt_exchanged_x_days_after_epoch = query.GetInteger(5);
+ *meta->ignition_cycles_since_last_exchange = query.GetInteger(6);
+ *meta->vin = query.GetString(7);
}
}
@@ -1652,10 +1669,11 @@ bool SQLPTExtRepresentation::SaveModuleMeta(
query.Bind(0, *(meta.ccpu_version));
query.Bind(1, *(meta.language));
query.Bind(2, *(meta.wers_country_code));
- query.Bind(3, odometer);
- query.Bind(4, *(meta.pt_exchanged_x_days_after_epoch));
- query.Bind(5, *(meta.ignition_cycles_since_last_exchange));
- query.Bind(6, *(meta.vin));
+ query.Bind(3, *(meta.hardware_version));
+ query.Bind(4, odometer);
+ query.Bind(5, *(meta.pt_exchanged_x_days_after_epoch));
+ query.Bind(6, *(meta.ignition_cycles_since_last_exchange));
+ query.Bind(7, *(meta.vin));
if (!query.Exec()) {
SDL_LOG_WARN("Incorrect update for module_meta.");
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 9e69d2cef8..519e51dde5 100644
--- a/src/components/policy/policy_external/src/sql_pt_queries.cc
+++ b/src/components/policy/policy_external/src/sql_pt_queries.cc
@@ -59,6 +59,7 @@ const std::string kCreateSchema =
" `ccpu_version` VARCHAR(45), "
" `language` VARCHAR(45), "
" `wers_country_code` VARCHAR(45), "
+ " `hardware_version` VARCHAR(45), "
" `pt_exchanged_at_odometer_x` INTEGER NOT NULL DEFAULT 0, "
" `pt_exchanged_x_days_after_epoch` INTEGER NOT NULL DEFAULT 0, "
" `ignition_cycles_since_last_exchange` INTEGER NOT NULL DEFAULT 0, "
diff --git a/src/components/policy/policy_external/test/CMakeLists.txt b/src/components/policy/policy_external/test/CMakeLists.txt
index 8f1b8b2539..7a28b2d3c2 100644
--- a/src/components/policy/policy_external/test/CMakeLists.txt
+++ b/src/components/policy/policy_external/test/CMakeLists.txt
@@ -52,6 +52,8 @@ file (GLOB POLICY_TEST_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/policy_manager_impl_test.cc
${CMAKE_CURRENT_SOURCE_DIR}/sql_pt_ext_representation_test.cc
${CMAKE_CURRENT_SOURCE_DIR}/sql_pt_representation_test.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/sql_pt_representation_storage_test.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/sql_pt_ext_representation_storage_test.cc
${CMAKE_CURRENT_SOURCE_DIR}/update_status_manager_test.cc
${CMAKE_CURRENT_SOURCE_DIR}/shared_library_test.cc)
diff --git a/src/components/policy/policy_external/test/cache_manager_test.cc b/src/components/policy/policy_external/test/cache_manager_test.cc
index 746d0c7221..9819811803 100644
--- a/src/components/policy/policy_external/test/cache_manager_test.cc
+++ b/src/components/policy/policy_external/test/cache_manager_test.cc
@@ -2169,6 +2169,18 @@ TEST_F(CacheManagerTest, RemoveAppConsentForGroup_GroupIsRemoved) {
EXPECT_FALSE(unconsented_groups_after_removal.empty());
}
+TEST_F(CacheManagerTest, GetHardwareVersion_ValueWasSetBefore_ReturnValue) {
+ std::string hardware_version = "1.1.1.1";
+ cache_manager_->SetHardwareVersion(hardware_version);
+ EXPECT_EQ(hardware_version, cache_manager_->GetHardwareVersionFromPT());
+}
+
+TEST_F(CacheManagerTest,
+ GetHardwareVersion_ValueNotSettedBefore_ReturnEmptyString) {
+ std::string empty_string = "";
+ EXPECT_EQ(empty_string, cache_manager_->GetHardwareVersionFromPT());
+}
+
} // namespace policy_test
} // namespace components
} // namespace test
diff --git a/src/components/policy/policy_external/test/include/policy/mock_pt_ext_representation.h b/src/components/policy/policy_external/test/include/policy/mock_pt_ext_representation.h
index b307270b10..f43fedcfab 100644
--- a/src/components/policy/policy_external/test/include/policy/mock_pt_ext_representation.h
+++ b/src/components/policy/policy_external/test/include/policy/mock_pt_ext_representation.h
@@ -105,6 +105,7 @@ class MockPTExtRepresentation : public MockPTRepresentation,
bool(const std::string& ccpu_version,
const std::string& wers_country_code,
const std::string& vin));
+ MOCK_METHOD1(SetHardwareVersion, void(const std::string& hardware_version));
MOCK_METHOD0(IsMetaInfoPresent, bool());
MOCK_METHOD1(SetSystemLanguage, bool(const std::string& language));
MOCK_METHOD0(GetKmFromSuccessfulExchange, int());
diff --git a/src/components/policy/policy_external/test/sql_pt_ext_representation_storage_test.cc b/src/components/policy/policy_external/test/sql_pt_ext_representation_storage_test.cc
index 1ceb5ea1ef..09df17beb2 100644
--- a/src/components/policy/policy_external/test/sql_pt_ext_representation_storage_test.cc
+++ b/src/components/policy/policy_external/test/sql_pt_ext_representation_storage_test.cc
@@ -38,8 +38,6 @@
#include "policy/mock_policy_settings.h"
#include "sqlite_wrapper/sql_query.h"
#include "utils/file_system.h"
-#include "utils/make_shared.h"
-#include "utils/shared_ptr.h"
using namespace ::policy;
diff --git a/src/components/policy/policy_external/test/sql_pt_ext_representation_test.cc b/src/components/policy/policy_external/test/sql_pt_ext_representation_test.cc
index 97613550f2..58f526d7d3 100644
--- a/src/components/policy/policy_external/test/sql_pt_ext_representation_test.cc
+++ b/src/components/policy/policy_external/test/sql_pt_ext_representation_test.cc
@@ -38,12 +38,14 @@
#include <utility>
#include <vector>
#include "gtest/gtest.h"
+#include "json/reader.h"
#include "policy/mock_policy_settings.h"
#include "policy/policy_table/types.h"
#include "rpc_base/rpc_base.h"
#include "sqlite_wrapper/sql_query.h"
#include "utils/file_system.h"
#include "utils/gen_hash.h"
+#include "utils/jsoncpp_reader_wrapper.h"
using namespace ::policy;
namespace policy_table = rpc::policy_table_interface_base;
@@ -57,6 +59,44 @@ namespace test {
namespace components {
namespace policy_test {
+namespace {
+const std::string kSdlPreloadedPtJson = "json/sdl_preloaded_pt.json";
+const std::string kHardwareVersion = "1.1.1.0";
+const std::string kSoftwareVersion = "4.1.3.B_EB355B";
+const std::string kWersCountryCode = "WAEGB";
+const std::string kLanguage = "EN-US";
+const std::string kFunctionalGroupWithParams = "Location-1";
+const std::string kUserConsentForGroupWithParams = "Location";
+const std::string kRpcForGroupWithParams = "GetVehicleData";
+} // namespace
+
+policy_table::Table LoadPreloadedPT(const std::string& filename) {
+ std::ifstream ifile(filename);
+ EXPECT_TRUE(ifile.good());
+ Json::CharReaderBuilder reader_builder;
+ Json::Value root(Json::objectValue);
+ Json::parseFromStream(reader_builder, ifile, &root, nullptr);
+ root["policy_table"]["module_config"].removeMember("preloaded_pt");
+ ifile.close();
+ policy_table::Table table(&root);
+ return table;
+}
+
+Json::Value GetDefaultSnapshotModuleMeta(policy_table::Table& policy_table) {
+ auto json_table = policy_table.ToJsonValue();
+
+ Json::Value default_module_meta = json_table["policy_table"]["module_meta"];
+ default_module_meta["ccpu_version"] = Json::Value("");
+ default_module_meta["hardware_version"] = Json::Value("");
+ default_module_meta["language"] = Json::Value("");
+ default_module_meta["wers_country_code"] = Json::Value("");
+ default_module_meta["pt_exchanged_at_odometer_x"] = Json::Value(0);
+ default_module_meta["pt_exchanged_x_days_after_epoch"] = Json::Value(0);
+ default_module_meta["ignition_cycles_since_last_exchange"] = Json::Value(0);
+ default_module_meta["vin"] = Json::Value("");
+ return default_module_meta;
+}
+
class SQLPTExtRepresentationTest : public ::testing::Test {
public:
// Collection of pairs of group alias and corresponding group name
@@ -264,163 +304,147 @@ SQLPTExtRepresentationTest::GetDataInternal(
}
TEST_F(SQLPTExtRepresentationTest,
- DISABLED_GenerateSnapshot_SetPolicyTable_SnapshotIsPresent) {
- // TODO(AKutsan): APPLINK-31526 Test requires initial preloaded pt for
- // preloaded date reading
- // Arrange
- Json::Value table(Json::objectValue);
- table["policy_table"] = Json::Value(Json::objectValue);
+ GenerateSnapshot_DefaultContentOfModuleMeta_MetaInfoPresentInSnapshot) {
+ policy_table::Table update = LoadPreloadedPT(kSdlPreloadedPtJson);
- Json::Value& policy_table = table["policy_table"];
- policy_table["module_config"] = Json::Value(Json::objectValue);
- policy_table["functional_groupings"] = Json::Value(Json::objectValue);
- policy_table["consumer_friendly_messages"] = Json::Value(Json::objectValue);
- policy_table["app_policies"] = Json::Value(Json::objectValue);
-
- Json::Value& module_config = policy_table["module_config"];
- module_config["preloaded_date"] = Json::Value("");
- module_config["exchange_after_x_ignition_cycles"] = Json::Value(10);
- module_config["exchange_after_x_kilometers"] = Json::Value(100);
- module_config["exchange_after_x_days"] = Json::Value(5);
- module_config["timeout_after_x_seconds"] = Json::Value(500);
- module_config["seconds_between_retries"] = Json::Value(Json::arrayValue);
- module_config["seconds_between_retries"][0] = Json::Value(10);
- module_config["seconds_between_retries"][1] = Json::Value(20);
- module_config["seconds_between_retries"][2] = Json::Value(30);
- module_config["endpoints"] = Json::Value(Json::objectValue);
- module_config["endpoints"]["0x00"] = Json::Value(Json::objectValue);
- module_config["endpoints"]["0x00"]["default"] = Json::Value(Json::arrayValue);
- module_config["endpoints"]["0x00"]["default"][0] =
- Json::Value("http://ford.com/cloud/default");
- module_config["notifications_per_minute_by_priority"] =
- Json::Value(Json::objectValue);
- module_config["notifications_per_minute_by_priority"]["emergency"] =
- Json::Value(1);
- module_config["notifications_per_minute_by_priority"]["navigation"] =
- Json::Value(2);
- module_config["notifications_per_minute_by_priority"]["VOICECOMM"] =
- Json::Value(3);
- module_config["notifications_per_minute_by_priority"]["communication"] =
- Json::Value(4);
- module_config["notifications_per_minute_by_priority"]["normal"] =
- Json::Value(5);
- module_config["notifications_per_minute_by_priority"]["none"] =
- Json::Value(6);
- module_config["subtle_notifications_per_minute_by_priority"] =
- Json::Value(Json::objectValue);
- module_config["subtle_notifications_per_minute_by_priority"]["emergency"] =
- Json::Value(7);
- module_config["subtle_notifications_per_minute_by_priority"]["navigation"] =
- Json::Value(8);
- module_config["subtle_notifications_per_minute_by_priority"]["VOICECOMM"] =
- Json::Value(9);
- module_config["subtle_notifications_per_minute_by_priority"]
- ["communication"] = Json::Value(10);
- module_config["subtle_notifications_per_minute_by_priority"]["normal"] =
- Json::Value(11);
- module_config["subtle_notifications_per_minute_by_priority"]["none"] =
- Json::Value(12);
- module_config["vehicle_make"] = Json::Value("MakeT");
- module_config["vehicle_model"] = Json::Value("ModelT");
- module_config["vehicle_year"] = Json::Value("2014");
- module_config["certificate"] = Json::Value("my_cert");
+ ASSERT_TRUE(IsValid(update));
+ EXPECT_TRUE(reps_->Save(update));
- Json::Value& functional_groupings = policy_table["functional_groupings"];
- functional_groupings["default"] = Json::Value(Json::objectValue);
- Json::Value& default_group = functional_groupings["default"];
- default_group["rpcs"] = Json::Value(Json::objectValue);
- default_group["rpcs"]["Update"] = Json::Value(Json::objectValue);
- default_group["rpcs"]["Update"]["hmi_levels"] = Json::Value(Json::arrayValue);
- default_group["rpcs"]["Update"]["hmi_levels"][0] = Json::Value("FULL");
- default_group["rpcs"]["Update"]["parameters"] = Json::Value(Json::arrayValue);
- default_group["rpcs"]["Update"]["parameters"][0] = Json::Value("speed");
-
- Json::Value& consumer_friendly_messages =
- policy_table["consumer_friendly_messages"];
- consumer_friendly_messages["version"] = Json::Value("1.2");
- consumer_friendly_messages["messages"] = Json::Value(Json::objectValue);
- consumer_friendly_messages["messages"]["MSG1"] =
- Json::Value(Json::objectValue);
- Json::Value& msg1 = consumer_friendly_messages["messages"]["MSG1"];
- msg1["languages"] = Json::Value(Json::objectValue);
- msg1["languages"]["en-us"] = Json::Value(Json::objectValue);
- msg1["languages"]["en-us"]["tts"] = Json::Value("TTS message");
- msg1["languages"]["en-us"]["label"] = Json::Value("LABEL message");
- msg1["languages"]["en-us"]["line1"] = Json::Value("LINE1 message");
- msg1["languages"]["en-us"]["line2"] = Json::Value("LINE2 message");
- msg1["languages"]["en-us"]["textBody"] = Json::Value("TEXTBODY message");
-
- Json::Value& app_policies = policy_table["app_policies"];
- app_policies["default"] = Json::Value(Json::objectValue);
- app_policies["default"]["memory_kb"] = Json::Value(50);
- app_policies["default"]["heart_beat_timeout_ms"] = Json::Value(100);
- app_policies["default"]["groups"] = Json::Value(Json::arrayValue);
- app_policies["default"]["groups"][0] = Json::Value("default");
- app_policies["default"]["priority"] = Json::Value("EMERGENCY");
- 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["pre_DataConsent"] = Json::Value(Json::objectValue);
- app_policies["pre_DataConsent"]["memory_kb"] = Json::Value(50);
- app_policies["pre_DataConsent"]["heart_beat_timeout_ms"] = Json::Value(100);
- app_policies["pre_DataConsent"]["groups"] = Json::Value(Json::arrayValue);
- app_policies["pre_DataConsent"]["groups"][0] = Json::Value("default");
- app_policies["pre_DataConsent"]["priority"] = Json::Value("EMERGENCY");
- app_policies["pre_DataConsent"]["default_hmi"] = Json::Value("FULL");
- app_policies["pre_DataConsent"]["keep_context"] = Json::Value(true);
- app_policies["pre_DataConsent"]["steal_focus"] = Json::Value(true);
- app_policies["1234"] = Json::Value(Json::objectValue);
- app_policies["1234"]["memory_kb"] = Json::Value(50);
- app_policies["1234"]["heart_beat_timeout_ms"] = Json::Value(100);
- app_policies["1234"]["groups"] = Json::Value(Json::arrayValue);
- app_policies["1234"]["groups"][0] = Json::Value("default");
- app_policies["1234"]["priority"] = Json::Value("EMERGENCY");
- app_policies["1234"]["default_hmi"] = Json::Value("FULL");
- app_policies["1234"]["keep_context"] = Json::Value(true);
- app_policies["1234"]["steal_focus"] = Json::Value(true);
- app_policies["device"] = Json::Value(Json::objectValue);
- app_policies["device"]["groups"] = Json::Value(Json::arrayValue);
- app_policies["device"]["groups"][0] = Json::Value("default");
- app_policies["device"]["priority"] = Json::Value("EMERGENCY");
- app_policies["device"]["default_hmi"] = Json::Value("FULL");
- app_policies["device"]["keep_context"] = Json::Value(true);
- app_policies["device"]["steal_focus"] = Json::Value(true);
-
- policy_table::Table update(&table);
- update.SetPolicyTableType(rpc::policy_table_interface_base::PT_UPDATE);
+ std::shared_ptr<policy_table::Table> snapshot = reps_->GenerateSnapshot();
+
+ auto expected_module_meta = GetDefaultSnapshotModuleMeta(update);
+ auto& snapshot_module_meta = snapshot->policy_table.module_meta;
+ EXPECT_EQ(expected_module_meta.toStyledString(),
+ snapshot_module_meta.ToJsonValue().toStyledString());
+}
+
+TEST_F(
+ SQLPTExtRepresentationTest,
+ GenerateSnapshot_SetMandatoryMetaInfo_MandatoryMetaInfoIsPresentInSnapshot) {
+ policy_table::Table update = LoadPreloadedPT(kSdlPreloadedPtJson);
- // Assert
ASSERT_TRUE(IsValid(update));
ASSERT_TRUE(reps_->Save(update));
- // Act
+ EXPECT_TRUE(
+ reps_->SetMetaInfo(kSoftwareVersion, kWersCountryCode, kLanguage));
+
std::shared_ptr<policy_table::Table> snapshot = reps_->GenerateSnapshot();
- snapshot->SetPolicyTableType(rpc::policy_table_interface_base::PT_SNAPSHOT);
- policy_table["module_meta"] = Json::Value(Json::objectValue);
- policy_table["usage_and_error_counts"] = Json::Value(Json::objectValue);
- policy_table["device_data"] = Json::Value(Json::objectValue);
- policy_table["module_config"]["preloaded_pt"] = Json::Value(false);
+ auto expected_module_meta = GetDefaultSnapshotModuleMeta(update);
+ expected_module_meta["ccpu_version"] = Json::Value(kSoftwareVersion);
+ expected_module_meta["language"] = Json::Value(kLanguage);
+ expected_module_meta["wers_country_code"] = Json::Value(kWersCountryCode);
- Json::Value& module_meta = policy_table["module_meta"];
- module_meta["ccpu_version"] = Json::Value("");
- module_meta["language"] = Json::Value("");
- module_meta["wers_country_code"] = Json::Value("");
- module_meta["pt_exchanged_at_odometer_x"] = Json::Value(0);
- module_meta["pt_exchanged_x_days_after_epoch"] = Json::Value(0);
- module_meta["ignition_cycles_since_last_exchange"] = Json::Value(0);
- module_meta["vin"] = Json::Value("");
+ auto& snapshot_module_meta = snapshot->policy_table.module_meta;
+ EXPECT_EQ(expected_module_meta.toStyledString(),
+ snapshot_module_meta.ToJsonValue().toStyledString());
+}
- Json::Value& usage_and_error_counts = policy_table["usage_and_error_counts"];
- usage_and_error_counts["count_of_iap_buffer_full"] = Json::Value(0);
- usage_and_error_counts["count_sync_out_of_memory"] = Json::Value(0);
- usage_and_error_counts["count_of_sync_reboots"] = Json::Value(0);
+TEST_F(SQLPTExtRepresentationTest,
+ GenerateSnapshot_SetHardwareVersion_HardwareVersionIsPresentInSnapshot) {
+ policy_table::Table update = LoadPreloadedPT(kSdlPreloadedPtJson);
- policy_table::Table expected(&table);
+ ASSERT_TRUE(IsValid(update));
+ EXPECT_TRUE(reps_->Save(update));
- // Assert
- EXPECT_EQ(expected.ToJsonValue().toStyledString(),
- snapshot->ToJsonValue().toStyledString());
+ reps_->SetHardwareVersion(kHardwareVersion);
+ std::shared_ptr<policy_table::Table> snapshot = reps_->GenerateSnapshot();
+
+ auto expected_module_meta = GetDefaultSnapshotModuleMeta(update);
+ expected_module_meta["hardware_version"] = Json::Value(kHardwareVersion);
+
+ auto& snapshot_module_meta = snapshot->policy_table.module_meta;
+ EXPECT_EQ(expected_module_meta.toStyledString(),
+ snapshot_module_meta.ToJsonValue().toStyledString());
+}
+
+TEST_F(SQLPTExtRepresentationTest, Save_ParametersPresent_ParametersSaved) {
+ policy_table::Table update = LoadPreloadedPT(kSdlPreloadedPtJson);
+ ASSERT_TRUE(IsValid(update));
+
+ policy_table::FunctionalGroupings func_groups;
+ ASSERT_TRUE(reps_->GetFunctionalGroupings(func_groups));
+ EXPECT_TRUE(func_groups.empty());
+
+ EXPECT_TRUE(reps_->Save(update));
+ ASSERT_TRUE(reps_->GetFunctionalGroupings(func_groups));
+
+ policy_table::FunctionalGroupings::iterator func_groups_iter =
+ func_groups.find(kFunctionalGroupWithParams);
+ ASSERT_TRUE(func_groups.end() != func_groups_iter);
+ policy_table::Rpcs& rpcs = func_groups_iter->second;
+ EXPECT_EQ(kUserConsentForGroupWithParams,
+ static_cast<std::string>(*rpcs.user_consent_prompt));
+ policy_table::Rpc& rpc = rpcs.rpcs;
+ policy_table::Rpc::const_iterator rpc_iter = rpc.find(kRpcForGroupWithParams);
+ EXPECT_TRUE(rpc.end() != rpc_iter);
+ const ::policy_table::Parameters& parameters = *(rpc_iter->second.parameters);
+ EXPECT_TRUE(!parameters.empty());
+}
+
+TEST_F(SQLPTExtRepresentationTest, Save_NoParameters_NoParametersSaved) {
+ policy_table::Table update = LoadPreloadedPT(kSdlPreloadedPtJson);
+ ASSERT_TRUE(IsValid(update));
+
+ policy_table::FunctionalGroupings func_groups;
+ ASSERT_TRUE(reps_->GetFunctionalGroupings(func_groups));
+ EXPECT_TRUE(func_groups.empty());
+
+ EXPECT_TRUE(reps_->Save(update));
+ ASSERT_TRUE(reps_->GetFunctionalGroupings(func_groups));
+
+ const std::string func_group_without_params = "Notifications";
+ const std::string user_consent = "Notifications";
+ const std::string rpc_without_params = "Alert";
+
+ policy_table::FunctionalGroupings::iterator func_groups_iter =
+ func_groups.find(func_group_without_params);
+ ASSERT_TRUE(func_groups.end() != func_groups_iter);
+ policy_table::Rpcs& rpcs = func_groups_iter->second;
+ EXPECT_EQ(user_consent, static_cast<std::string>(*rpcs.user_consent_prompt));
+ policy_table::Rpc& rpc = rpcs.rpcs;
+ EXPECT_EQ(1u, rpc.size());
+ policy_table::Rpc::const_iterator rpc_iter = rpc.find(rpc_without_params);
+ EXPECT_TRUE(rpc.end() != rpc_iter);
+ // Check parameters
+ const ::policy_table::Parameters& parameters = *(rpc_iter->second.parameters);
+ EXPECT_FALSE(parameters.is_initialized());
+ EXPECT_TRUE(parameters.empty());
+}
+
+TEST_F(SQLPTExtRepresentationTest, Save_EmptyParameters_ParametersEmpty) {
+ policy_table::Table update = LoadPreloadedPT(kSdlPreloadedPtJson);
+ ASSERT_TRUE(IsValid(update));
+
+ policy_table::FunctionalGroupings func_groups;
+ EXPECT_TRUE(reps_->GetFunctionalGroupings(func_groups));
+ EXPECT_TRUE(func_groups.empty());
+
+ auto json_update = update.ToJsonValue();
+ json_update["policy_table"]["functional_groupings"]
+ [kFunctionalGroupWithParams]["rpcs"][kRpcForGroupWithParams]
+ ["parameters"] = Json::Value(Json::arrayValue);
+ policy_table::Table update_with_empty_param(&json_update);
+
+ EXPECT_TRUE(reps_->Save(update_with_empty_param));
+ EXPECT_TRUE(reps_->GetFunctionalGroupings(func_groups));
+
+ policy_table::FunctionalGroupings::iterator func_groups_iter =
+ func_groups.find(kFunctionalGroupWithParams);
+ ASSERT_TRUE(func_groups.end() != func_groups_iter);
+ policy_table::Rpcs& rpcs = func_groups_iter->second;
+ EXPECT_EQ(kUserConsentForGroupWithParams,
+ static_cast<std::string>(*rpcs.user_consent_prompt));
+ policy_table::Rpc& rpc = rpcs.rpcs;
+ policy_table::Rpc::const_iterator rpc_iter = rpc.find(kRpcForGroupWithParams);
+ EXPECT_TRUE(rpc.end() != rpc_iter);
+ // Check parameters
+ const ::policy_table::Parameters& parameters = *(rpc_iter->second.parameters);
+ // 'parameters' : [] - represented as initialized, but empty
+ // missing 'parameters' - represented as non-initialized and empty
+ EXPECT_TRUE(parameters.is_initialized());
+ EXPECT_TRUE(parameters.empty());
}
TEST_F(
@@ -1159,7 +1183,8 @@ TEST_F(
TEST_F(SQLPTExtRepresentationTest,
SetMetaInfo_SetMetaInfo_ExpectValuesSetInParams) {
// Arrange
- ASSERT_TRUE(reps_->SetMetaInfo("4.1.3.B_EB355B", "WAEGB", "ru-ru"));
+ ASSERT_TRUE(
+ reps_->SetMetaInfo(kSoftwareVersion, kWersCountryCode, kLanguage));
utils::dbms::SQLQuery query(reps_->db());
const std::string query_select_ccpu =
"SELECT `ccpu_version` FROM `module_meta`";
@@ -1171,13 +1196,13 @@ TEST_F(SQLPTExtRepresentationTest,
// Assert
query.Prepare(query_select_ccpu);
query.Next();
- EXPECT_EQ("4.1.3.B_EB355B", query.GetString(0));
+ EXPECT_EQ(kSoftwareVersion, query.GetString(0));
query.Prepare(query_select_wers_country_code);
query.Next();
- EXPECT_EQ("WAEGB", query.GetString(0));
+ EXPECT_EQ(kWersCountryCode, query.GetString(0));
query.Prepare(query_select_language);
query.Next();
- EXPECT_EQ("ru-ru", query.GetString(0));
+ EXPECT_EQ(kLanguage, query.GetString(0));
}
TEST_F(SQLPTExtRepresentationTest,
@@ -1203,6 +1228,17 @@ TEST_F(SQLPTExtRepresentationTest,
EXPECT_EQ("ru-ru", query.GetString(0));
}
+TEST_F(SQLPTExtRepresentationTest, SetHardwareVersion_ValueIsSetInModuleMeta) {
+ utils::dbms::SQLQuery query(reps_->db());
+ reps_->SetHardwareVersion(kHardwareVersion);
+ const std::string query_select_hardware_version =
+ "SELECT `hardware_version` FROM `module_meta`";
+
+ query.Prepare(query_select_hardware_version);
+ query.Next();
+ EXPECT_EQ(kHardwareVersion, query.GetString(0));
+}
+
TEST_F(
SQLPTExtRepresentationTest,
GetFunctionalGroupNames_SetGroupsManuallyThenGetGroupNames_ExpectAllGroupsReceived) {
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 224c663c52..1adf9ae7c6 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
@@ -188,150 +188,6 @@ class SQLPTRepresentationTest : public SQLPTRepresentation,
StringsCompare(groups, app_groups);
}
- void PolicyTableUpdatePrepare(Json::Value& table) {
- PolicyTableUpdatePrepareNoParameters(table);
-
- table["policy_table"]["functional_groupings"]["default"]["rpcs"]["Update"]
- ["parameters"] = Json::Value(Json::arrayValue);
- table["policy_table"]["functional_groupings"]["default"]["rpcs"]["Update"]
- ["parameters"][0] = Json::Value("speed");
- }
-
- void PolicyTableUpdatePrepareEmptyParameters(Json::Value& table) {
- PolicyTableUpdatePrepareNoParameters(table);
-
- // Parameters are empty
- table["policy_table"]["functional_groupings"]["default"]["rpcs"]["Update"]
- ["parameters"] = Json::Value(Json::arrayValue);
- }
-
- void PolicyTableUpdatePrepareNoParameters(Json::Value& table) {
- table["policy_table"] = Json::Value(Json::objectValue);
- Json::Value& policy_table = table["policy_table"];
- policy_table["module_config"] = Json::Value(Json::objectValue);
- policy_table["functional_groupings"] = Json::Value(Json::objectValue);
- policy_table["consumer_friendly_messages"] = Json::Value(Json::objectValue);
- policy_table["app_policies"] = Json::Value(Json::objectValue);
-
- Json::Value& module_config = policy_table["module_config"];
- module_config["preloaded_date"] = Json::Value("25-04-2015");
- module_config["exchange_after_x_ignition_cycles"] = Json::Value(10);
- module_config["exchange_after_x_kilometers"] = Json::Value(100);
- module_config["exchange_after_x_days"] = Json::Value(5);
- module_config["timeout_after_x_seconds"] = Json::Value(500);
- module_config["seconds_between_retries"] = Json::Value(Json::arrayValue);
- Json::Value& seconds_between_retries =
- module_config["seconds_between_retries"];
- seconds_between_retries[0] = Json::Value(10);
- seconds_between_retries[1] = Json::Value(20);
- seconds_between_retries[2] = Json::Value(30);
- module_config["endpoints"] = Json::Value(Json::objectValue);
- Json::Value& endpoins = module_config["endpoints"];
- endpoins["0x00"] = Json::Value(Json::objectValue);
- endpoins["0x00"]["default"] = Json::Value(Json::arrayValue);
- endpoins["0x00"]["default"][0] =
- Json::Value("http://ford.com/cloud/default");
- module_config["notifications_per_minute_by_priority"] =
- Json::Value(Json::objectValue);
- module_config["notifications_per_minute_by_priority"]["emergency"] =
- Json::Value(1);
- module_config["notifications_per_minute_by_priority"]["navigation"] =
- Json::Value(2);
- module_config["notifications_per_minute_by_priority"]["VOICECOMM"] =
- Json::Value(3);
- module_config["notifications_per_minute_by_priority"]["communication"] =
- Json::Value(4);
- module_config["notifications_per_minute_by_priority"]["normal"] =
- Json::Value(5);
- module_config["notifications_per_minute_by_priority"]["none"] =
- Json::Value(6);
- module_config["subtle_notifications_per_minute_by_priority"] =
- Json::Value(Json::objectValue);
- module_config["subtle_notifications_per_minute_by_priority"]["emergency"] =
- Json::Value(7);
- module_config["subtle_notifications_per_minute_by_priority"]["navigation"] =
- Json::Value(8);
- module_config["subtle_notifications_per_minute_by_priority"]["VOICECOMM"] =
- Json::Value(9);
- module_config["subtle_notifications_per_minute_by_priority"]
- ["communication"] = Json::Value(10);
- module_config["subtle_notifications_per_minute_by_priority"]["normal"] =
- Json::Value(11);
- module_config["subtle_notifications_per_minute_by_priority"]["none"] =
- Json::Value(12);
- module_config["vehicle_make"] = Json::Value("MakeT");
- module_config["vehicle_model"] = Json::Value("ModelT");
- module_config["vehicle_year"] = Json::Value("2014");
- module_config["certificate"] = Json::Value("my_cert");
-
- Json::Value& functional_groupings = policy_table["functional_groupings"];
- functional_groupings["default"] = Json::Value(Json::objectValue);
- Json::Value& default_group = functional_groupings["default"];
- default_group["rpcs"] = Json::Value(Json::objectValue);
- default_group["rpcs"]["Update"] = Json::Value(Json::objectValue);
- default_group["rpcs"]["Update"]["hmi_levels"] =
- Json::Value(Json::arrayValue);
- default_group["rpcs"]["Update"]["hmi_levels"][0] = Json::Value("FULL");
- // No parameters
-
- Json::Value& consumer_friendly_messages =
- policy_table["consumer_friendly_messages"];
- consumer_friendly_messages["version"] = Json::Value("1.2");
- consumer_friendly_messages["messages"] = Json::Value(Json::objectValue);
- consumer_friendly_messages["messages"]["MSG1"] =
- Json::Value(Json::objectValue);
- Json::Value& msg1 = consumer_friendly_messages["messages"]["MSG1"];
- msg1["languages"] = Json::Value(Json::objectValue);
- msg1["languages"]["en-us"] = Json::Value(Json::objectValue);
- msg1["languages"]["en-us"]["tts"] = Json::Value("TTS message");
- msg1["languages"]["en-us"]["label"] = Json::Value("LABEL message");
- msg1["languages"]["en-us"]["line1"] = Json::Value("LINE1 message");
- msg1["languages"]["en-us"]["line2"] = Json::Value("LINE2 message");
- msg1["languages"]["en-us"]["textBody"] = Json::Value("TEXTBODY message");
-
- Json::Value& app_policies = policy_table["app_policies"];
- app_policies["default"] = Json::Value(Json::objectValue);
- app_policies["default"]["priority"] = Json::Value("EMERGENCY");
- app_policies["default"]["memory_kb"] = Json::Value(50);
- app_policies["default"]["heart_beat_timeout_ms"] = Json::Value(100);
- app_policies["default"]["groups"] = Json::Value(Json::arrayValue);
- app_policies["default"]["groups"][0] = Json::Value("default");
- app_policies["default"]["priority"] = Json::Value("EMERGENCY");
- app_policies["default"]["is_revoked"] = Json::Value(true);
- 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["pre_DataConsent"] = Json::Value(Json::objectValue);
- app_policies["pre_DataConsent"]["memory_kb"] = Json::Value(40);
- app_policies["pre_DataConsent"]["heart_beat_timeout_ms"] = Json::Value(90);
- app_policies["pre_DataConsent"]["groups"] = Json::Value(Json::arrayValue);
- app_policies["pre_DataConsent"]["groups"][0] = Json::Value("default");
- app_policies["pre_DataConsent"]["priority"] = Json::Value("EMERGENCY");
- app_policies["pre_DataConsent"]["default_hmi"] = Json::Value("FULL");
- 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["1234"] = Json::Value(Json::objectValue);
- app_policies["1234"]["memory_kb"] = Json::Value(150);
- app_policies["1234"]["heart_beat_timeout_ms"] = Json::Value(200);
- app_policies["1234"]["groups"] = Json::Value(Json::arrayValue);
- app_policies["1234"]["groups"][0] = Json::Value("default");
- app_policies["1234"]["priority"] = Json::Value("EMERGENCY");
- app_policies["1234"]["default_hmi"] = Json::Value("FULL");
- 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["device"] = Json::Value(Json::objectValue);
- app_policies["device"]["groups"] = Json::Value(Json::arrayValue);
- app_policies["device"]["groups"][0] = Json::Value("default");
- app_policies["device"]["priority"] = Json::Value("EMERGENCY");
- app_policies["device"]["is_revoked"] = Json::Value(true);
- app_policies["device"]["default_hmi"] = Json::Value("FULL");
- app_policies["device"]["keep_context"] = Json::Value(true);
- app_policies["device"]["steal_focus"] = Json::Value(true);
- }
-
::testing::AssertionResult IsValid(const policy_table::Table& table) {
if (table.is_valid()) {
return ::testing::AssertionSuccess();
@@ -1633,304 +1489,6 @@ TEST(SQLPTRepresentationTest3, RemoveDB_RemoveDB_ExpectFileDeleted) {
EXPECT_FALSE(file_system::FileExists(path));
}
-TEST_F(SQLPTRepresentationTest,
- DISABLED_GenerateSnapshot_SetPolicyTable_SnapshotIsPresent) {
- // TODO(AKutsan):APPLINK-31526 Test requires initial preloaded pt for
- // preloaded date reading
- // Arrange
- Json::Value table(Json::objectValue);
- PolicyTableUpdatePrepare(table);
-
- policy_table::Table update(&table);
- update.SetPolicyTableType(rpc::policy_table_interface_base::PT_UPDATE);
-
- // Assert
- ASSERT_TRUE(IsValid(update));
- ASSERT_TRUE(reps->Save(update));
-
- // Act
- std::shared_ptr<policy_table::Table> snapshot = reps->GenerateSnapshot();
- snapshot->SetPolicyTableType(rpc::policy_table_interface_base::PT_SNAPSHOT);
- // Remove fields which must be absent in snapshot
- table["policy_table"]["consumer_friendly_messages"].removeMember("messages");
- table["policy_table"]["app_policies"]["1234"].removeMember("default_hmi");
- table["policy_table"]["app_policies"]["1234"].removeMember("keep_context");
- table["policy_table"]["app_policies"]["1234"].removeMember("steal_focus");
- table["policy_table"]["app_policies"]["default"].removeMember("default_hmi");
- table["policy_table"]["app_policies"]["default"].removeMember("keep_context");
- table["policy_table"]["app_policies"]["default"].removeMember("steal_focus");
- table["policy_table"]["app_policies"]["pre_DataConsent"].removeMember(
- "default_hmi");
- table["policy_table"]["app_policies"]["pre_DataConsent"].removeMember(
- "keep_context");
- table["policy_table"]["app_policies"]["pre_DataConsent"].removeMember(
- "steal_focus");
- table["policy_table"]["app_policies"]["device"].removeMember("default_hmi");
- table["policy_table"]["app_policies"]["device"].removeMember("keep_context");
- table["policy_table"]["app_policies"]["device"].removeMember("steal_focus");
- table["policy_table"]["app_policies"]["device"].removeMember("groups");
- table["policy_table"]["device_data"] = Json::Value(Json::objectValue);
- table["policy_table"]["module_meta"] = Json::Value(Json::objectValue);
- table["policy_table"]["module_config"]["preloaded_pt"] = Json::Value(false);
- policy_table::Table expected(&table);
- Json::StreamWriterBuilder writer_builder;
- // Checks
- Json::Value snapshot_json_value = snapshot->ToJsonValue();
- EXPECT_EQ(Json::writeString(writer_builder, expected.ToJsonValue()),
- Json::writeString(writer_builder, snapshot_json_value));
- std::cout << Json::writeString(writer_builder, snapshot_json_value)
- << std::endl;
- EXPECT_EQ(expected.ToJsonValue().toStyledString(),
- snapshot_json_value.toStyledString());
-}
-
-TEST_F(SQLPTRepresentationTest,
- DISABLED_Save_SetPolicyTableThenSave_ExpectSavedToPT) {
- // TODO(AKutsan): APPLINK-31526 Test requires initial preloaded pt for
- // preloaded date reading
- // Arrange
- Json::Value table(Json::objectValue);
- PolicyTableUpdatePrepare(table);
-
- policy_table::Table update(&table);
- update.SetPolicyTableType(rpc::policy_table_interface_base::PT_UPDATE);
- // Checks PT before Save
- policy_table::FunctionalGroupings func_groups;
- ASSERT_TRUE(reps->GetFunctionalGroupings(func_groups));
- // Check functional groupings section
- EXPECT_EQ(0u, func_groups.size());
-
- policy_table::ApplicationPoliciesSection policies;
- GatherApplicationPoliciesSection(&policies);
- // Check ApplicationPoliciesSection
- EXPECT_EQ(0u, policies.apps.size());
- EXPECT_EQ(0u, (policies.device.preconsented_groups)->size());
- EXPECT_EQ(0u, policies.device.groups.size());
- EXPECT_EQ(policy_table::Priority::P_EMERGENCY, policies.device.priority);
- EXPECT_EQ(policy_table::HmiLevel::HL_BACKGROUND, policies.device.default_hmi);
- EXPECT_FALSE(policies.device.keep_context);
- EXPECT_FALSE(policies.device.steal_focus);
-
- policy_table::ModuleConfig config;
- GatherModuleConfig(&config);
- // Check Module config section
- EXPECT_TRUE(*config.preloaded_pt);
- EXPECT_EQ(0, config.exchange_after_x_ignition_cycles);
- EXPECT_EQ(0, config.exchange_after_x_kilometers);
- EXPECT_EQ(0, config.exchange_after_x_days);
- EXPECT_EQ(0, config.timeout_after_x_seconds);
- EXPECT_EQ("", static_cast<std::string>(*config.vehicle_make));
- EXPECT_EQ("", static_cast<std::string>(*config.vehicle_model));
- EXPECT_EQ("", static_cast<std::string>(*config.vehicle_year));
- EXPECT_EQ("", static_cast<std::string>(*config.preloaded_date));
- EXPECT_EQ("", static_cast<std::string>(*config.certificate));
- EXPECT_EQ(0u, config.seconds_between_retries.size());
- EXPECT_EQ(0u, config.endpoints.size());
- EXPECT_EQ(0u, config.notifications_per_minute_by_priority.size());
- EXPECT_EQ(0u, (*config.subtle_notifications_per_minute_by_priority).size());
-
- policy_table::ConsumerFriendlyMessages messages;
- GatherConsumerFriendlyMessages(&messages);
- EXPECT_EQ("0", static_cast<std::string>(messages.version));
- policy_table::DeviceData devices;
- GatherDeviceData(&devices);
- EXPECT_EQ(0u, devices.size());
- policy_table::UsageAndErrorCounts counts;
- GatherUsageAndErrorCounts(&counts);
- EXPECT_EQ(0u, counts.app_level->size());
- ASSERT_TRUE(IsValid(update));
- // Act
- ASSERT_TRUE(reps->Save(update));
-
- // Check Functional Groupings
- ASSERT_TRUE(reps->GetFunctionalGroupings(func_groups));
- // Checks
- EXPECT_EQ(1u, func_groups.size());
- policy_table::FunctionalGroupings::iterator func_groups_iter =
- func_groups.find("default");
- ASSERT_TRUE(func_groups.end() != func_groups_iter);
- policy_table::Rpcs& rpcs = func_groups_iter->second;
- EXPECT_EQ("", static_cast<std::string>(*rpcs.user_consent_prompt));
- policy_table::Rpc& rpc = rpcs.rpcs;
- EXPECT_EQ(1u, rpc.size());
- policy_table::Rpc::const_iterator rpc_iter = rpc.find("Update");
- EXPECT_TRUE(rpc.end() != rpc_iter);
- const policy_table::HmiLevels& hmi_levels = rpc_iter->second.hmi_levels;
- EXPECT_EQ(1u, hmi_levels.size());
- EXPECT_TRUE(hmi_levels.end() != std::find(hmi_levels.begin(),
- hmi_levels.end(),
- policy_table::HmiLevel::HL_FULL));
-
- const ::policy_table::Parameters& parameters = *(rpc_iter->second.parameters);
- EXPECT_EQ(1u, parameters.size());
- EXPECT_TRUE(parameters.end() !=
- std::find(parameters.begin(), parameters.end(), "P_SPEED"));
- // Check Application Policies Section
- GatherApplicationPoliciesSection(&policies);
- const uint32_t apps_size = 3u;
-
- rpc::String<1ul, 255ul> str("default");
- policy_table::Strings groups;
- groups.push_back(str);
- CheckAppPoliciesSection(policies,
- apps_size,
- policy_table::Priority::P_EMERGENCY,
- "1234",
- 150u,
- 200u,
- groups);
- CheckAppPoliciesSection(policies,
- apps_size,
- policy_table::Priority::P_EMERGENCY,
- "default",
- 50u,
- 100u,
- groups);
- CheckAppPoliciesSection(policies,
- apps_size,
- policy_table::Priority::P_EMERGENCY,
- "pre_DataConsent",
- 40u,
- 90u,
- groups);
- CheckAppPoliciesSection(policies,
- apps_size,
- policy_table::Priority::P_EMERGENCY,
- "device",
- 0u,
- 0u,
- groups);
- EXPECT_EQ(0u, (policies.device.preconsented_groups)->size());
- EXPECT_EQ(0u, policies.device.groups.size());
- EXPECT_EQ(policy_table::HmiLevel::HL_BACKGROUND, policies.device.default_hmi);
- EXPECT_FALSE(policies.device.keep_context);
- EXPECT_FALSE(policies.device.steal_focus);
-
- CheckAppGroups("1234", groups);
- CheckAppGroups("default", groups);
- CheckAppGroups("pre_DataConsent", groups);
- CheckAppGroups("device", groups);
-
- GatherModuleConfig(&config);
- // Check Module Config section
- ASSERT_FALSE(*config.preloaded_pt);
- ASSERT_EQ("my_cert", static_cast<std::string>(*config.certificate));
- ASSERT_EQ("25-04-2015", static_cast<std::string>(*config.preloaded_date));
- ASSERT_EQ("2014", static_cast<std::string>(*config.vehicle_year));
- ASSERT_EQ("ModelT", static_cast<std::string>(*config.vehicle_model));
- ASSERT_EQ("MakeT", static_cast<std::string>(*config.vehicle_make));
- ASSERT_EQ(10, config.exchange_after_x_ignition_cycles);
- ASSERT_EQ(100, config.exchange_after_x_kilometers);
- ASSERT_EQ(5, config.exchange_after_x_days);
- ASSERT_EQ(500, config.timeout_after_x_seconds);
- ASSERT_EQ(3u, config.seconds_between_retries.size());
- ASSERT_EQ(10, config.seconds_between_retries[0]);
- ASSERT_EQ(20, config.seconds_between_retries[1]);
- ASSERT_EQ(30, config.seconds_between_retries[2]);
- ASSERT_EQ(6u, config.notifications_per_minute_by_priority.size());
- ASSERT_EQ(1, config.notifications_per_minute_by_priority["emergency"]);
- ASSERT_EQ(2, config.notifications_per_minute_by_priority["navigation"]);
- ASSERT_EQ(3, config.notifications_per_minute_by_priority["VOICECOMM"]);
- ASSERT_EQ(4, config.notifications_per_minute_by_priority["communication"]);
- ASSERT_EQ(5, config.notifications_per_minute_by_priority["normal"]);
- ASSERT_EQ(6, config.notifications_per_minute_by_priority["none"]);
- ASSERT_EQ(6u, (*config.subtle_notifications_per_minute_by_priority).size());
- ASSERT_EQ(7,
- (*config.subtle_notifications_per_minute_by_priority)["emergency"]);
- ASSERT_EQ(
- 8, (*config.subtle_notifications_per_minute_by_priority)["navigation"]);
- ASSERT_EQ(9,
- (*config.subtle_notifications_per_minute_by_priority)["VOICECOMM"]);
- ASSERT_EQ(
- 10,
- (*config.subtle_notifications_per_minute_by_priority)["communication"]);
- ASSERT_EQ(11,
- (*config.subtle_notifications_per_minute_by_priority)["normal"]);
- ASSERT_EQ(12, (*config.subtle_notifications_per_minute_by_priority)["none"]);
- EXPECT_EQ(1u, config.endpoints.size());
- policy_table::ServiceEndpoints& service_endpoints = config.endpoints;
- EXPECT_EQ("0x00", service_endpoints.begin()->first);
- policy_table::URLList& url_list = service_endpoints.begin()->second;
- EXPECT_EQ("default", url_list.begin()->first);
- policy_table::URL& url = url_list.begin()->second;
- EXPECT_EQ("http://ford.com/cloud/default", static_cast<std::string>(url[0]));
- GatherConsumerFriendlyMessages(&messages);
- EXPECT_EQ("1.2", static_cast<std::string>(messages.version));
-}
-
-TEST_F(SQLPTRepresentationTest,
- Save_SavePolicyTable_EmptyParameters_ParametersEMPTY) {
- // Arrange
- Json::Value table(Json::objectValue);
- PolicyTableUpdatePrepareEmptyParameters(table);
-
- policy_table::Table update(&table);
- update.SetPolicyTableType(rpc::policy_table_interface_base::PT_UPDATE);
- // Checks PT before Save
- policy_table::FunctionalGroupings func_groups;
- ASSERT_TRUE(reps->GetFunctionalGroupings(func_groups));
- // Check functional groupings section
- EXPECT_EQ(0u, func_groups.size());
-
- // Act
- ASSERT_TRUE(reps->Save(update));
-
- // Check Functional Groupings
- ASSERT_TRUE(reps->GetFunctionalGroupings(func_groups));
- // Checks
- EXPECT_EQ(1u, func_groups.size());
- policy_table::FunctionalGroupings::iterator func_groups_iter =
- func_groups.find("default");
- ASSERT_TRUE(func_groups.end() != func_groups_iter);
- policy_table::Rpcs& rpcs = func_groups_iter->second;
- EXPECT_EQ("", static_cast<std::string>(*rpcs.user_consent_prompt));
- policy_table::Rpc& rpc = rpcs.rpcs;
- EXPECT_EQ(1u, rpc.size());
- policy_table::Rpc::const_iterator rpc_iter = rpc.find("Update");
- EXPECT_TRUE(rpc.end() != rpc_iter);
- // Check parameters
- const ::policy_table::Parameters& parameters = *(rpc_iter->second.parameters);
- // 'parameters' : [] - represented as initialized, but empty
- // missing 'parameters' - represented as non-initialized and empty
- EXPECT_TRUE(parameters.is_initialized());
- EXPECT_TRUE(parameters.empty());
-}
-
-TEST_F(SQLPTRepresentationTest,
- Save_SavePolicyTable_NoParameters_NoParametersSaved) {
- // Arrange
- Json::Value table(Json::objectValue);
- PolicyTableUpdatePrepareNoParameters(table);
-
- policy_table::Table update(&table);
- update.SetPolicyTableType(rpc::policy_table_interface_base::PT_UPDATE);
- // Checks PT before Save
- policy_table::FunctionalGroupings func_groups;
- ASSERT_TRUE(reps->GetFunctionalGroupings(func_groups));
- // Check functional groupings section
- EXPECT_EQ(0u, func_groups.size());
-
- // Act
- ASSERT_TRUE(reps->Save(update));
-
- // Check Functional Groupings
- ASSERT_TRUE(reps->GetFunctionalGroupings(func_groups));
- // Checks
- EXPECT_EQ(1u, func_groups.size());
- policy_table::FunctionalGroupings::iterator func_groups_iter =
- func_groups.find("default");
- ASSERT_TRUE(func_groups.end() != func_groups_iter);
- policy_table::Rpcs& rpcs = func_groups_iter->second;
- EXPECT_EQ("", static_cast<std::string>(*rpcs.user_consent_prompt));
- policy_table::Rpc& rpc = rpcs.rpcs;
- EXPECT_EQ(1u, rpc.size());
- policy_table::Rpc::const_iterator rpc_iter = rpc.find("Update");
- EXPECT_TRUE(rpc.end() != rpc_iter);
- // Check parameters
- const ::policy_table::Parameters& parameters = *(rpc_iter->second.parameters);
- EXPECT_EQ(0u, parameters.size());
-}
-
} // namespace policy_test
} // namespace components
} // namespace test
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 25b4a8bc18..473caef145 100644
--- a/src/components/policy/policy_regular/include/policy/cache_manager.h
+++ b/src/components/policy/policy_regular/include/policy/cache_manager.h
@@ -544,13 +544,11 @@ class CacheManager : public CacheManagerInterface {
*/
void SetPreloadedPtFlag(const bool is_preloaded) OVERRIDE;
- /**
- * @brief Records information about head unit system to PT
- * @return bool Success of operation
- */
bool SetMetaInfo(const std::string& ccpu_version,
const std::string& wers_country_code,
- const std::string& language);
+ const std::string& language) OVERRIDE;
+
+ void SetHardwareVersion(const std::string& hardware_version) OVERRIDE;
/**
* @brief Get information about last ccpu_version from PT
@@ -558,6 +556,8 @@ class CacheManager : public CacheManagerInterface {
*/
std::string GetCCPUVersionFromPT() const;
+ std::string GetHardwareVersionFromPT() const OVERRIDE;
+
/**
* @brief Checks, if specific head unit is present in PT
* @return boot Suceess, if present, otherwise - false
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 14130c0316..5e536ef315 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
@@ -586,7 +586,7 @@ class CacheManagerInterface {
virtual void SetPreloadedPtFlag(const bool is_preloaded) = 0;
/**
- * @brief Records information about head unit system to PT
+ * @brief Records mandatory information about head unit system to PT
* @return bool Success of operation
*/
virtual bool SetMetaInfo(const std::string& ccpu_version,
@@ -594,12 +594,24 @@ class CacheManagerInterface {
const std::string& language) = 0;
/**
+ * @brief Records information about hardware version to PT
+ * @param hardware_version Hardware version
+ */
+ virtual void SetHardwareVersion(const std::string& hardware_version) = 0;
+
+ /**
* @brief Get information about last ccpu_version from PT
* @return ccpu_version from PT
*/
virtual std::string GetCCPUVersionFromPT() const = 0;
/**
+ * @brief Get information about last hardware version from PT
+ * @return string representation of hardware version from PT, empty if absent
+ */
+ virtual std::string GetHardwareVersionFromPT() const = 0;
+
+ /**
* @brief Checks, if specific head unit is present in PT
* @return boot Suceess, if present, otherwise - false
*/
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 dff4802d82..32c546df62 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
@@ -451,10 +451,14 @@ class PolicyManagerImpl : public PolicyManager {
const std::string& wers_country_code,
const std::string& language) OVERRIDE;
+ void SetHardwareVersion(const std::string& hardware_version) OVERRIDE;
+
void SetPreloadedPtFlag(const bool is_preloaded) OVERRIDE;
std::string GetCCPUVersionFromPT() const OVERRIDE;
+ std::string GetHardwareVersionFromPT() const OVERRIDE;
+
/**
* @brief Get number of notification by priority
* @param priority Specified priority
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 673f17e32b..7eeb41f064 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
@@ -430,6 +430,7 @@ struct ModuleMeta : CompositeType {
Optional<Integer<uint16_t, 0, 65535> > pt_exchanged_x_days_after_epoch;
Optional<Integer<uint16_t, 0, 65535> > ignition_cycles_since_last_exchange;
Optional<String<0, 500> > ccpu_version;
+ Optional<String<0, 500> > hardware_version;
public:
ModuleMeta();
diff --git a/src/components/policy/policy_regular/include/policy/pt_representation.h b/src/components/policy/policy_regular/include/policy/pt_representation.h
index 895b4ea6b5..9a57ed21ad 100644
--- a/src/components/policy/policy_regular/include/policy/pt_representation.h
+++ b/src/components/policy/policy_regular/include/policy/pt_representation.h
@@ -152,12 +152,18 @@ class PTRepresentation {
virtual EndpointUrls GetUpdateUrls(int service_type) = 0;
/**
- * @brief Records information about head unit system to PT
+ * @brief Records mandatory information about head unit system to PT
* @return bool Success of operation
*/
virtual bool SetMetaInfo(const std::string& ccpu_version) = 0;
/**
+ * @brief Records information about hardware version to PT
+ * @param hardware_version Hardware version
+ */
+ virtual void SetHardwareVersion(const std::string& hardware_version) = 0;
+
+ /**
* @brief Get allowed number of notifications
* depending on application priority.
* @param priority Priority of application
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 5bf85a4bb5..fd7f879abf 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
@@ -145,6 +145,7 @@ extern const std::string kUpdateDBVersion;
extern const std::string kSaveModuleMeta;
extern const std::string kSelectModuleMeta;
extern const std::string kUpdateMetaParams;
+extern const std::string kUpdateMetaHardwareVersion;
extern const std::string kInsertVehicleDataItem;
extern const std::string kSelectVehicleDataItem;
extern const std::string kDeleteVehicleDataItems;
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 512bfd6326..18147c43f0 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
@@ -90,7 +90,8 @@ class SQLPTRepresentation : public virtual PTRepresentation {
StringArray* nicknames = NULL,
StringArray* app_hmi_types = NULL);
bool GetFunctionalGroupings(policy_table::FunctionalGroupings& groups);
- bool SetMetaInfo(const std::string& ccpu_version);
+ bool SetMetaInfo(const std::string& ccpu_version) OVERRIDE;
+ void SetHardwareVersion(const std::string& hardware_version) OVERRIDE;
#ifdef BUILD_TESTS
uint32_t open_counter() {
return open_counter_;
diff --git a/src/components/policy/policy_regular/src/cache_manager.cc b/src/components/policy/policy_regular/src/cache_manager.cc
index d53ec4d18a..cf4164d133 100644
--- a/src/components/policy/policy_regular/src/cache_manager.cc
+++ b/src/components/policy/policy_regular/src/cache_manager.cc
@@ -1337,6 +1337,8 @@ void CacheManager::PersistData() {
}
backup_->SetMetaInfo(*(*copy_pt.policy_table.module_meta).ccpu_version);
+ backup_->SetHardwareVersion(
+ *(*copy_pt.policy_table.module_meta).hardware_version);
// In case of extended policy the meta info should be backuped as well.
backup_->WriteDb();
@@ -1490,13 +1492,35 @@ bool CacheManager::SetMetaInfo(const std::string& ccpu_version,
return true;
}
+void CacheManager::SetHardwareVersion(const std::string& hardware_version) {
+ SDL_LOG_AUTO_TRACE();
+ CACHE_MANAGER_CHECK_VOID();
+ sync_primitives::AutoLock auto_lock(cache_lock_);
+
+ *pt_->policy_table.module_meta->hardware_version = hardware_version;
+ Backup();
+}
+
std::string CacheManager::GetCCPUVersionFromPT() const {
SDL_LOG_AUTO_TRACE();
+ CACHE_MANAGER_CHECK(std::string(""));
+ sync_primitives::AutoLock auto_lock(cache_lock_);
+
rpc::Optional<policy_table::ModuleMeta>& module_meta =
pt_->policy_table.module_meta;
return *(module_meta->ccpu_version);
}
+std::string CacheManager::GetHardwareVersionFromPT() const {
+ SDL_LOG_AUTO_TRACE();
+ CACHE_MANAGER_CHECK(std::string(""));
+ sync_primitives::AutoLock auto_lock(cache_lock_);
+
+ rpc::Optional<policy_table::ModuleMeta>& module_meta =
+ pt_->policy_table.module_meta;
+ return *(module_meta->hardware_version);
+}
+
bool CacheManager::IsMetaInfoPresent() const {
CACHE_MANAGER_CHECK(false);
bool result = true;
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 059375322a..b6101eb960 100644
--- a/src/components/policy/policy_regular/src/policy_manager_impl.cc
+++ b/src/components/policy/policy_regular/src/policy_manager_impl.cc
@@ -1217,11 +1217,22 @@ void PolicyManagerImpl::SetSystemInfo(const std::string& ccpu_version,
cache_->SetMetaInfo(ccpu_version, wers_country_code, language);
}
+void PolicyManagerImpl::SetHardwareVersion(
+ const std::string& hardware_version) {
+ SDL_LOG_AUTO_TRACE();
+ cache_->SetHardwareVersion(hardware_version);
+}
+
std::string PolicyManagerImpl::GetCCPUVersionFromPT() const {
SDL_LOG_AUTO_TRACE();
return cache_->GetCCPUVersionFromPT();
}
+std::string PolicyManagerImpl::GetHardwareVersionFromPT() const {
+ SDL_LOG_AUTO_TRACE();
+ return cache_->GetHardwareVersionFromPT();
+}
+
uint32_t PolicyManagerImpl::GetNotificationsNumber(const std::string& priority,
const bool is_subtle) const {
SDL_LOG_AUTO_TRACE();
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 d3473bb2a7..d2a70baafe 100644
--- a/src/components/policy/policy_regular/src/policy_table/types.cc
+++ b/src/components/policy/policy_regular/src/policy_table/types.cc
@@ -1297,7 +1297,8 @@ ModuleMeta::ModuleMeta(const Json::Value* value__)
impl::ValueMember(value__, "pt_exchanged_x_days_after_epoch"))
, ignition_cycles_since_last_exchange(
impl::ValueMember(value__, "ignition_cycles_since_last_exchange"))
- , ccpu_version(impl::ValueMember(value__, "ccpu_version")) {}
+ , ccpu_version(impl::ValueMember(value__, "ccpu_version"))
+ , hardware_version(impl::ValueMember(value__, "hardware_version")) {}
Json::Value ModuleMeta::ToJsonValue() const {
Json::Value result__(Json::objectValue);
@@ -1319,6 +1320,9 @@ bool ModuleMeta::is_valid() const {
if (!ccpu_version.is_valid()) {
return false;
}
+ if (!hardware_version.is_valid()) {
+ return false;
+ }
if (!pt_exchanged_at_odometer_x.is_valid()) {
return false;
}
@@ -1339,6 +1343,9 @@ bool ModuleMeta::struct_empty() const {
if (ccpu_version.is_initialized()) {
return false;
}
+ if (hardware_version.is_initialized()) {
+ return false;
+ }
if (pt_exchanged_at_odometer_x.is_initialized()) {
return false;
}
@@ -1359,6 +1366,10 @@ void ModuleMeta::ReportErrors(rpc::ValidationReport* report__) const {
if (!ccpu_version.is_valid()) {
ccpu_version.ReportErrors(&report__->ReportSubobject("ccpu_version"));
}
+ if (!hardware_version.is_valid()) {
+ hardware_version.ReportErrors(
+ &report__->ReportSubobject("hardware_version"));
+ }
if (!pt_exchanged_at_odometer_x.is_valid()) {
pt_exchanged_at_odometer_x.ReportErrors(
&report__->ReportSubobject("pt_exchanged_at_odometer_x"));
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 cf9167406f..ea0b7fe997 100644
--- a/src/components/policy/policy_regular/src/sql_pt_queries.cc
+++ b/src/components/policy/policy_regular/src/sql_pt_queries.cc
@@ -60,7 +60,8 @@ const std::string kCreateSchema =
" `pt_exchanged_x_days_after_epoch` INTEGER NOT NULL DEFAULT 0, "
" `ignition_cycles_since_last_exchange` INTEGER NOT NULL DEFAULT 0, "
" `flag_update_required` BOOL NOT NULL, "
- " `ccpu_version` VARCHAR(45) "
+ " `ccpu_version` VARCHAR(45), "
+ " `hardware_version` VARCHAR(45) "
"); "
"CREATE TABLE IF NOT EXISTS `module_config`( "
" `preloaded_pt` BOOL NOT NULL, "
@@ -1076,10 +1077,16 @@ const std::string kSaveModuleMeta =
"`pt_exchanged_x_days_after_epoch` = ?, "
"`ignition_cycles_since_last_exchange` = ? ";
-const std::string kSelectModuleMeta = "SELECT* FROM `module_meta`";
+const std::string kSelectModuleMeta =
+ "SELECT `ccpu_version`, `hardware_version`, `pt_exchanged_at_odometer_x`, "
+ "`pt_exchanged_x_days_after_epoch`, `ignition_cycles_since_last_exchange` "
+ "FROM `module_meta`";
const std::string kUpdateMetaParams =
"UPDATE `module_meta` SET "
"`ccpu_version` = ? ";
+
+const std::string kUpdateMetaHardwareVersion =
+ "UPDATE `module_meta` SET `hardware_version` = ? ";
} // namespace sql_pt
} // namespace policy
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 7193a06bdb..57781ae16f 100644
--- a/src/components/policy/policy_regular/src/sql_pt_representation.cc
+++ b/src/components/policy/policy_regular/src/sql_pt_representation.cc
@@ -472,10 +472,11 @@ void SQLPTRepresentation::GatherModuleMeta(
SDL_LOG_INFO("Gather Module Meta Info");
utils::dbms::SQLQuery query(db());
if (query.Prepare(sql_pt::kSelectModuleMeta) && query.Next()) {
- *meta->pt_exchanged_at_odometer_x = query.GetInteger(0);
- *meta->pt_exchanged_x_days_after_epoch = query.GetInteger(1);
- *meta->ignition_cycles_since_last_exchange = query.GetInteger(2);
- *meta->ccpu_version = query.GetString(4);
+ *meta->ccpu_version = query.GetString(0);
+ *meta->hardware_version = query.GetString(1);
+ *meta->pt_exchanged_at_odometer_x = query.GetInteger(2);
+ *meta->pt_exchanged_x_days_after_epoch = query.GetInteger(3);
+ *meta->ignition_cycles_since_last_exchange = query.GetInteger(4);
}
}
@@ -716,6 +717,22 @@ bool SQLPTRepresentation::SetMetaInfo(const std::string& ccpu_version) {
return true;
}
+void SQLPTRepresentation::SetHardwareVersion(
+ const std::string& hardware_version) {
+ SDL_LOG_AUTO_TRACE();
+ utils::dbms::SQLQuery query(db());
+ if (!query.Prepare(sql_pt::kUpdateMetaHardwareVersion)) {
+ SDL_LOG_WARN("Incorrect statement for insert to module meta.");
+ return;
+ }
+
+ query.Bind(0, hardware_version);
+
+ if (!query.Exec()) {
+ SDL_LOG_WARN("Incorrect insert to module meta.");
+ }
+}
+
bool SQLPTRepresentation::GatherApplicationPoliciesSection(
policy_table::ApplicationPoliciesSection* policies) const {
SDL_LOG_INFO("Gather applications policies");
diff --git a/src/components/policy/policy_regular/test/CMakeLists.txt b/src/components/policy/policy_regular/test/CMakeLists.txt
index d2cd7be224..cdd6cc98da 100644
--- a/src/components/policy/policy_regular/test/CMakeLists.txt
+++ b/src/components/policy/policy_regular/test/CMakeLists.txt
@@ -49,6 +49,7 @@ file (GLOB POLICY_TEST_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/policy_manager_impl_test.cc
${CMAKE_CURRENT_SOURCE_DIR}/access_remote_impl_test.cc
${CMAKE_CURRENT_SOURCE_DIR}/sql_pt_representation_test.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/sql_pt_representation_storage_test.cc
${CMAKE_CURRENT_SOURCE_DIR}/update_status_manager_test.cc
${CMAKE_CURRENT_SOURCE_DIR}/vehicle_data_item_type_test.cc
${CMAKE_CURRENT_SOURCE_DIR}/shared_library_test.cc
diff --git a/src/components/policy/policy_regular/test/cache_manager_test.cc b/src/components/policy/policy_regular/test/cache_manager_test.cc
index 31166b8f43..00b632ac17 100644
--- a/src/components/policy/policy_regular/test/cache_manager_test.cc
+++ b/src/components/policy/policy_regular/test/cache_manager_test.cc
@@ -1235,6 +1235,18 @@ TEST_F(CacheManagerTest, IsApplicationRepresented_DeviceApp_ReturnTrue) {
EXPECT_TRUE(cache_manager_->IsApplicationRepresented(kDeviceId));
}
+TEST_F(CacheManagerTest, GetHardwareVersion_ValueWasSetBefore_ReturnValue) {
+ std::string hardware_version = "1.1.1.1";
+ cache_manager_->SetHardwareVersion(hardware_version);
+ EXPECT_EQ(hardware_version, cache_manager_->GetHardwareVersionFromPT());
+}
+
+TEST_F(CacheManagerTest,
+ GetHardwareVersion_ValueNotSettedBefore_ReturnEmptyString) {
+ std::string empty_string = "";
+ EXPECT_EQ(empty_string, cache_manager_->GetHardwareVersionFromPT());
+}
+
} // namespace policy_test
} // namespace components
} // namespace test
diff --git a/src/components/policy/policy_regular/test/policy_manager_impl_test.cc b/src/components/policy/policy_regular/test/policy_manager_impl_test.cc
index d5a66f4388..c456561328 100644
--- a/src/components/policy/policy_regular/test/policy_manager_impl_test.cc
+++ b/src/components/policy/policy_regular/test/policy_manager_impl_test.cc
@@ -599,20 +599,6 @@ TEST_F(PolicyManagerImplTest, GetHMITypes_ValidHmiTypes_ReturnTrue) {
EXPECT_TRUE(policy_manager_->GetHMITypes(kValidAppId, &app_types));
}
-TEST_F(PolicyManagerImplTest, SetMetaInfo_SetCCPUVersion_SUCCESS) {
- const std::string ccpu_version = "ccpu_version";
- const std::string wers_country_code = "wersCountryCode";
- const std::string language = "language";
-
- EXPECT_CALL(*mock_cache_manager_,
- SetMetaInfo(ccpu_version, wers_country_code, language));
- policy_manager_->SetSystemInfo(ccpu_version, wers_country_code, language);
-
- EXPECT_CALL(*mock_cache_manager_, GetCCPUVersionFromPT())
- .WillOnce(Return(ccpu_version));
- EXPECT_EQ(ccpu_version, policy_manager_->GetCCPUVersionFromPT());
-}
-
} // namespace policy_test
} // namespace components
} // namespace test
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 f4efa811b6..fb64dfe7d0 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
@@ -72,6 +72,35 @@ namespace policy_test {
using policy_handler_test::MockPolicySettings;
+namespace {
+const std::string kSdlPreloadedPtJson = "json/sdl_preloaded_pt.json";
+const std::string kSoftwareVersion = "4.1.3.B_EB355B";
+const std::string kHardwareVersion = "1.1.1.0";
+} // namespace
+
+policy_table::Table LoadPreloadedPT(const std::string& filename) {
+ std::ifstream ifile(filename);
+ EXPECT_TRUE(ifile.good());
+ Json::CharReaderBuilder reader_builder;
+ Json::Value root(Json::objectValue);
+ Json::parseFromStream(reader_builder, ifile, &root, nullptr);
+ root["policy_table"]["module_config"].removeMember("preloaded_pt");
+ ifile.close();
+ policy_table::Table table(&root);
+ return table;
+}
+
+Json::Value GetDefaultSnapshotModuleMeta(policy_table::Table& policy_table) {
+ auto json_table = policy_table.ToJsonValue();
+
+ Json::Value default_module_meta = json_table["policy_table"]["module_meta"];
+ default_module_meta["pt_exchanged_at_odometer_x"] = Json::Value(0);
+ default_module_meta["pt_exchanged_x_days_after_epoch"] = Json::Value(0);
+ default_module_meta["ignition_cycles_since_last_exchange"] = Json::Value(0);
+
+ return default_module_meta;
+}
+
class SQLPTRepresentationTest : protected SQLPTRepresentation,
public ::testing::Test {
protected:
@@ -201,180 +230,6 @@ class SQLPTRepresentationTest : protected SQLPTRepresentation,
StringsCompare(groups, app_groups);
}
- void PolicyTableUpdatePrepare(Json::Value& table) {
- // Root
- table["policy_table"] = Json::Value(Json::objectValue);
-
- // 1st level
- Json::Value& policy_table = table["policy_table"];
- policy_table["module_config"] = Json::Value(Json::objectValue);
- policy_table["functional_groupings"] = Json::Value(Json::objectValue);
- policy_table["consumer_friendly_messages"] = Json::Value(Json::objectValue);
- policy_table["app_policies"] = Json::Value(Json::objectValue);
- policy_table["usage_and_error_counts"] = Json::Value(Json::objectValue);
- policy_table["device_data"] = Json::Value(Json::objectValue);
-
- // 'module_config' section start
- Json::Value& module_config = policy_table["module_config"];
- module_config["preloaded_pt"] = Json::Value(false);
- module_config["preloaded_date"] = Json::Value("");
- module_config["exchange_after_x_ignition_cycles"] = Json::Value(10);
- module_config["exchange_after_x_kilometers"] = Json::Value(100);
- module_config["exchange_after_x_days"] = Json::Value(5);
- module_config["timeout_after_x_seconds"] = Json::Value(500);
- module_config["seconds_between_retries"] = Json::Value(Json::arrayValue);
-
- Json::Value& seconds_between_retries =
- module_config["seconds_between_retries"];
- seconds_between_retries[0] = Json::Value(10);
- seconds_between_retries[1] = Json::Value(20);
- seconds_between_retries[2] = Json::Value(30);
- module_config["endpoints"] = Json::Value(Json::objectValue);
-
- Json::Value& endpoins = module_config["endpoints"];
- endpoins["0x00"] = Json::Value(Json::objectValue);
- endpoins["0x00"]["default"] = Json::Value(Json::arrayValue);
- endpoins["0x00"]["default"][0] =
- Json::Value("http://ford.com/cloud/default");
- module_config["notifications_per_minute_by_priority"] =
- Json::Value(Json::objectValue);
- module_config["notifications_per_minute_by_priority"]["emergency"] =
- Json::Value(1);
- module_config["notifications_per_minute_by_priority"]["navigation"] =
- Json::Value(2);
- module_config["notifications_per_minute_by_priority"]["VOICECOMM"] =
- Json::Value(3);
- module_config["notifications_per_minute_by_priority"]["communication"] =
- Json::Value(4);
- module_config["notifications_per_minute_by_priority"]["normal"] =
- Json::Value(5);
- module_config["notifications_per_minute_by_priority"]["none"] =
- Json::Value(6);
- module_config["subtle_notifications_per_minute_by_priority"] =
- Json::Value(Json::objectValue);
- module_config["subtle_notifications_per_minute_by_priority"]["emergency"] =
- Json::Value(7);
- module_config["subtle_notifications_per_minute_by_priority"]["navigation"] =
- Json::Value(8);
- module_config["subtle_notifications_per_minute_by_priority"]["VOICECOMM"] =
- Json::Value(9);
- module_config["subtle_notifications_per_minute_by_priority"]
- ["communication"] = Json::Value(10);
- module_config["subtle_notifications_per_minute_by_priority"]["normal"] =
- Json::Value(11);
- module_config["subtle_notifications_per_minute_by_priority"]["none"] =
- Json::Value(12);
- module_config["vehicle_make"] = Json::Value("");
- module_config["vehicle_model"] = Json::Value("");
- module_config["vehicle_year"] = Json::Value("");
- module_config["certificate"] = Json::Value("encrypted_certificate_content");
- // 'module_config' section end
-
- // 'functional_groupings' section start
- Json::Value& functional_groupings = policy_table["functional_groupings"];
- functional_groupings["default"] = Json::Value(Json::objectValue);
- Json::Value& default_group = functional_groupings["default"];
- default_group["rpcs"] = Json::Value(Json::objectValue);
- default_group["rpcs"]["Update"] = Json::Value(Json::objectValue);
- default_group["rpcs"]["Update"]["hmi_levels"] =
- Json::Value(Json::arrayValue);
- default_group["rpcs"]["Update"]["hmi_levels"][0] = Json::Value("FULL");
- default_group["rpcs"]["Update"]["parameters"] =
- Json::Value(Json::arrayValue);
- default_group["rpcs"]["Update"]["parameters"][0] = Json::Value("speed");
-
- Json::Value& consumer_friendly_messages =
- policy_table["consumer_friendly_messages"];
- consumer_friendly_messages["version"] = Json::Value("some_msg_version");
- consumer_friendly_messages["messages"] = Json::Value(Json::objectValue);
- consumer_friendly_messages["messages"]["MSG_CODE"] =
- Json::Value(Json::objectValue);
- Json::Value& msg1 = consumer_friendly_messages["messages"]["MSG_CODE"];
- msg1["languages"] = Json::Value(Json::objectValue);
- msg1["languages"]["en-us"] = Json::Value(Json::objectValue);
- // 'functional_groupings' section end
-
- // 'app_policies' section start
- Json::Value& app_policies = policy_table["app_policies"];
- app_policies["default"] = Json::Value(Json::objectValue);
- app_policies["default"]["priority"] = Json::Value("EMERGENCY");
- app_policies["default"]["memory_kb"] = Json::Value(50);
- app_policies["default"]["heart_beat_timeout_ms"] = Json::Value(100);
- app_policies["default"]["groups"] = Json::Value(Json::arrayValue);
- app_policies["default"]["groups"][0] = Json::Value("default");
- app_policies["default"]["priority"] = Json::Value("EMERGENCY");
- app_policies["default"]["is_revoked"] = Json::Value(true);
- 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);
- app_policies["pre_DataConsent"]["heart_beat_timeout_ms"] = Json::Value(90);
- app_policies["pre_DataConsent"]["groups"] = Json::Value(Json::arrayValue);
- app_policies["pre_DataConsent"]["groups"][0] = Json::Value("default");
- app_policies["pre_DataConsent"]["priority"] = Json::Value("EMERGENCY");
- app_policies["pre_DataConsent"]["default_hmi"] = Json::Value("FULL");
- 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);
- app_policies["1234"]["groups"] = Json::Value(Json::arrayValue);
- app_policies["1234"]["groups"][0] = Json::Value("default");
- app_policies["1234"]["priority"] = Json::Value("EMERGENCY");
- app_policies["1234"]["default_hmi"] = Json::Value("FULL");
- 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["1234"]["app_services"] = Json::Value(Json::objectValue);
- app_policies["1234"]["icon_url"] =
- Json::Value("http:://www.sdl.com/image.png");
- app_policies["1234"]["app_services"]["MEDIA"] =
- Json::Value(Json::objectValue);
- app_policies["1234"]["app_services"]["MEDIA"]["service_names"] =
- Json::Value(Json::arrayValue);
- app_policies["1234"]["app_services"]["MEDIA"]["service_names"][0] =
- Json::Value("SDL App");
- app_policies["1234"]["app_services"]["MEDIA"]["service_names"][1] =
- Json::Value("SDL Music");
- app_policies["1234"]["app_services"]["MEDIA"]["handled_rpcs"] =
- Json::Value(Json::arrayValue);
- app_policies["1234"]["app_services"]["MEDIA"]["handled_rpcs"][0] =
- Json::Value(Json::objectValue);
- app_policies["1234"]["app_services"]["MEDIA"]["handled_rpcs"][0]
- ["function_id"] = Json::Value(41);
-
- app_policies["device"] = Json::Value(Json::objectValue);
- app_policies["device"]["groups"] = Json::Value(Json::arrayValue);
- app_policies["device"]["groups"][0] = Json::Value("default");
- app_policies["device"]["priority"] = Json::Value("EMERGENCY");
- app_policies["device"]["is_revoked"] = Json::Value(true);
- app_policies["device"]["default_hmi"] = Json::Value("FULL");
- app_policies["device"]["keep_context"] = Json::Value(true);
- app_policies["device"]["steal_focus"] = Json::Value(true);
- // 'app_policies' section end
-
- Json::Value& usage_and_error_counts =
- policy_table["usage_and_error_counts"];
- usage_and_error_counts["app_level"] = Json::Value(Json::objectValue);
- usage_and_error_counts["app_level"]["some_app_id"] =
- Json::Value(Json::objectValue);
- usage_and_error_counts["app_level"]["some_app_id"]["count_of_tls_errors"] =
- Json::Value(5);
-
- Json::Value& device_data = policy_table["device_data"];
- device_data["device_id_hash_1"] = Json::Value(Json::objectValue);
- device_data["device_id_hash_2"] = Json::Value(Json::objectValue);
- device_data["device_id_hash_3"] = Json::Value(Json::objectValue);
- }
-
::testing::AssertionResult IsValid(const policy_table::Table& table) {
if (table.is_valid()) {
return ::testing::AssertionSuccess();
@@ -1812,252 +1667,77 @@ TEST_F(SQLPTRepresentationTest3, RemoveDB_RemoveDB_ExpectFileDeleted) {
EXPECT_FALSE(file_system::FileExists(path));
}
-// TODO {AKozoriz} : Snapshot must have module meta section, but test
-// generates snapshot without it.
TEST_F(SQLPTRepresentationTest,
- DISABLED_GenerateSnapshot_SetPolicyTable_SnapshotIsPresent) {
- // Arrange
- Json::Value table(Json::objectValue);
- PolicyTableUpdatePrepare(table);
+ GenerateSnapshot_DefaultContentOfModuleMeta_MetaInfoPresentInSnapshot) {
+ policy_table::Table update = LoadPreloadedPT(kSdlPreloadedPtJson);
- policy_table::Table update(&table);
- update.SetPolicyTableType(rpc::policy_table_interface_base::PT_UPDATE);
+ ASSERT_TRUE(IsValid(update));
+ EXPECT_TRUE(reps->Save(update));
- // Assert
- // ASSERT_TRUE(IsValid(update));
- ASSERT_TRUE(reps->Save(update));
+ std::shared_ptr<policy_table::Table> snapshot = reps->GenerateSnapshot();
+
+ auto expected_module_meta = GetDefaultSnapshotModuleMeta(update);
+ auto& snapshot_module_meta = snapshot->policy_table.module_meta;
+ EXPECT_EQ(expected_module_meta.toStyledString(),
+ snapshot_module_meta.ToJsonValue().toStyledString());
+}
+
+TEST_F(SQLPTRepresentationTest,
+ GenerateSnapshot_SetMetaInfo_NoSoftwareVersionInSnapshot) {
+ policy_table::Table update = LoadPreloadedPT(kSdlPreloadedPtJson);
+
+ ASSERT_TRUE(IsValid(update));
+ EXPECT_TRUE(reps->Save(update));
+ EXPECT_TRUE(reps->SetMetaInfo(kSoftwareVersion));
- // Act
std::shared_ptr<policy_table::Table> snapshot = reps->GenerateSnapshot();
- snapshot->SetPolicyTableType(rpc::policy_table_interface_base::PT_SNAPSHOT);
- // Remove fields which must be absent in snapshot
- table["policy_table"]["consumer_friendly_messages"].removeMember("messages");
- table["policy_table"]["app_policies"]["1234"].removeMember("default_hmi");
- table["policy_table"]["app_policies"]["1234"].removeMember("keep_context");
- table["policy_table"]["app_policies"]["1234"].removeMember("steal_focus");
- table["policy_table"]["app_policies"]["default"].removeMember("default_hmi");
- table["policy_table"]["app_policies"]["default"].removeMember("keep_context");
- table["policy_table"]["app_policies"]["default"].removeMember("steal_focus");
- table["policy_table"]["app_policies"]["pre_DataConsent"].removeMember(
- "default_hmi");
- table["policy_table"]["app_policies"]["pre_DataConsent"].removeMember(
- "keep_context");
- table["policy_table"]["app_policies"]["pre_DataConsent"].removeMember(
- "steal_focus");
- table["policy_table"]["app_policies"]["device"].removeMember("default_hmi");
- table["policy_table"]["app_policies"]["device"].removeMember("keep_context");
- table["policy_table"]["app_policies"]["device"].removeMember("steal_focus");
- table["policy_table"]["app_policies"]["device"].removeMember("groups");
- table["policy_table"]["device_data"] = Json::Value(Json::objectValue);
- table["policy_table"]["module_meta"] = Json::Value(Json::objectValue);
- policy_table::Table expected(&table);
- Json::StreamWriterBuilder writer_builder;
- // Checks
- EXPECT_EQ(Json::writeString(writer_builder, expected.ToJsonValue()),
- Json::writeString(writer_builder, snapshot->ToJsonValue()));
- EXPECT_EQ(expected.ToJsonValue().toStyledString(),
- snapshot->ToJsonValue().toStyledString());
+
+ auto expected_module_meta = GetDefaultSnapshotModuleMeta(update);
+ auto& snapshot_module_meta = snapshot->policy_table.module_meta;
+ EXPECT_EQ(expected_module_meta.toStyledString(),
+ snapshot_module_meta.ToJsonValue().toStyledString());
}
-TEST_F(SQLPTRepresentationTest, Save_SetPolicyTableThenSave_ExpectSavedToPT) {
- // Arrange
- Json::Value table(Json::objectValue);
- PolicyTableUpdatePrepare(table);
+TEST_F(SQLPTRepresentationTest,
+ GenerateSnapshot_SetHardwareVersion_NoHardwareVersionInSnapshot) {
+ policy_table::Table update = LoadPreloadedPT(kSdlPreloadedPtJson);
- policy_table::Table update(&table);
- update.SetPolicyTableType(rpc::policy_table_interface_base::PT_UPDATE);
- // Checks PT before Save
- policy_table::FunctionalGroupings func_groups;
- ASSERT_TRUE(reps->GetFunctionalGroupings(func_groups));
- // Check functional groupings section
- EXPECT_EQ(0u, func_groups.size());
-
- policy_table::ApplicationPoliciesSection policies;
- GatherApplicationPoliciesSection(&policies);
- // Check ApplicationPoliciesSection
- EXPECT_EQ(0u, policies.apps.size());
- EXPECT_EQ(policy_table::Priority::P_EMERGENCY, policies.device.priority);
-
- policy_table::ModuleConfig config;
- GatherModuleConfig(&config);
- // Check Module config section
- EXPECT_TRUE(*config.preloaded_pt);
- EXPECT_EQ(0, config.exchange_after_x_ignition_cycles);
- EXPECT_EQ(0, config.exchange_after_x_kilometers);
- EXPECT_EQ(0, config.exchange_after_x_days);
- EXPECT_EQ(0, config.timeout_after_x_seconds);
- EXPECT_EQ("", static_cast<std::string>(*config.vehicle_make));
- EXPECT_EQ("", static_cast<std::string>(*config.vehicle_model));
- EXPECT_EQ("", static_cast<std::string>(*config.vehicle_year));
- EXPECT_EQ("", static_cast<std::string>(*config.preloaded_date));
- EXPECT_EQ("", static_cast<std::string>(*config.certificate));
- EXPECT_EQ(0u, config.seconds_between_retries.size());
- EXPECT_EQ(0u, config.endpoints.size());
- EXPECT_EQ(0u, config.notifications_per_minute_by_priority.size());
- EXPECT_EQ(0u, (*config.subtle_notifications_per_minute_by_priority).size());
-
- policy_table::ConsumerFriendlyMessages messages;
- GatherConsumerFriendlyMessages(&messages);
- EXPECT_EQ("0", static_cast<std::string>(messages.version));
-
- policy_table::DeviceData devices;
- GatherDeviceData(&devices);
- EXPECT_EQ(0u, devices.size());
-
- policy_table::UsageAndErrorCounts counts;
- GatherUsageAndErrorCounts(&counts);
- EXPECT_TRUE(0u == counts.app_level->size());
-
- // ASSERT_TRUE(IsValid(update));
- // Act
- ASSERT_TRUE(reps->Save(update));
+ ASSERT_TRUE(IsValid(update));
+ EXPECT_TRUE(reps->Save(update));
+ reps->SetHardwareVersion(kHardwareVersion);
- // Check Functional Groupings
- ASSERT_TRUE(reps->GetFunctionalGroupings(func_groups));
- // Checks
- EXPECT_EQ(1u, func_groups.size());
- policy_table::FunctionalGroupings::iterator func_groups_iter =
- func_groups.find("default");
- ASSERT_TRUE(func_groups.end() != func_groups_iter);
- policy_table::Rpcs& rpcs = func_groups_iter->second;
- EXPECT_EQ("", static_cast<std::string>(*rpcs.user_consent_prompt));
- policy_table::Rpc& rpc = rpcs.rpcs;
- EXPECT_EQ(1u, rpc.size());
- policy_table::Rpc::const_iterator rpc_iter = rpc.find("Update");
- EXPECT_TRUE(rpc.end() != rpc_iter);
- const policy_table::HmiLevels& hmi_levels = rpc_iter->second.hmi_levels;
- EXPECT_EQ(1u, hmi_levels.size());
- EXPECT_TRUE(hmi_levels.end() != std::find(hmi_levels.begin(),
- hmi_levels.end(),
- policy_table::HmiLevel::HL_FULL));
-
- const ::policy_table::Parameters& parameters = *(rpc_iter->second.parameters);
- EXPECT_EQ(1u, parameters.size());
- EXPECT_TRUE(parameters.end() !=
- std::find(parameters.begin(),
- parameters.end(),
- policy_table::EnumToJsonString(
- policy_table::Parameter::P_SPEED)));
- // Check Application Policies Section
- GatherApplicationPoliciesSection(&policies);
- const uint32_t apps_size = 3u;
-
- rpc::String<1ul, 255ul> str("default");
- policy_table::Strings groups;
- groups.push_back(str);
- CheckAppPoliciesSection(policies,
- apps_size,
- policy_table::Priority::P_EMERGENCY,
- "1234",
- 150u,
- 200u,
- groups);
- CheckAppPoliciesSection(policies,
- apps_size,
- policy_table::Priority::P_EMERGENCY,
- "default",
- 50u,
- 100u,
- groups);
- CheckAppPoliciesSection(policies,
- apps_size,
- policy_table::Priority::P_EMERGENCY,
- "pre_DataConsent",
- 40u,
- 90u,
- groups);
- CheckAppPoliciesSection(policies,
- apps_size,
- policy_table::Priority::P_EMERGENCY,
- "device",
- 0u,
- 0u,
- groups);
-
- CheckAppGroups("1234", groups);
- CheckAppGroups("default", groups);
- CheckAppGroups("pre_DataConsent", groups);
-
- GatherModuleConfig(&config);
- // Check Module Config section
- ASSERT_FALSE(*config.preloaded_pt);
- ASSERT_EQ("encrypted_certificate_content",
- static_cast<std::string>(*config.certificate));
- ASSERT_EQ("", static_cast<std::string>(*config.preloaded_date));
- ASSERT_EQ("", static_cast<std::string>(*config.vehicle_year));
- ASSERT_EQ("", static_cast<std::string>(*config.vehicle_model));
- ASSERT_EQ("", static_cast<std::string>(*config.vehicle_make));
- ASSERT_EQ(10, config.exchange_after_x_ignition_cycles);
- ASSERT_EQ(100, config.exchange_after_x_kilometers);
- ASSERT_EQ(5, config.exchange_after_x_days);
- ASSERT_EQ(500, config.timeout_after_x_seconds);
- ASSERT_EQ(3u, config.seconds_between_retries.size());
- ASSERT_EQ(10, config.seconds_between_retries[0]);
- ASSERT_EQ(20, config.seconds_between_retries[1]);
- ASSERT_EQ(30, config.seconds_between_retries[2]);
- ASSERT_EQ(6u, config.notifications_per_minute_by_priority.size());
- ASSERT_EQ(1, config.notifications_per_minute_by_priority["emergency"]);
- ASSERT_EQ(2, config.notifications_per_minute_by_priority["navigation"]);
- ASSERT_EQ(3, config.notifications_per_minute_by_priority["VOICECOMM"]);
- ASSERT_EQ(4, config.notifications_per_minute_by_priority["communication"]);
- ASSERT_EQ(5, config.notifications_per_minute_by_priority["normal"]);
- ASSERT_EQ(6, config.notifications_per_minute_by_priority["none"]);
- ASSERT_EQ(6u, (*config.subtle_notifications_per_minute_by_priority).size());
- ASSERT_EQ(7,
- (*config.subtle_notifications_per_minute_by_priority)["emergency"]);
- ASSERT_EQ(
- 8, (*config.subtle_notifications_per_minute_by_priority)["navigation"]);
- ASSERT_EQ(9,
- (*config.subtle_notifications_per_minute_by_priority)["VOICECOMM"]);
- ASSERT_EQ(
- 10,
- (*config.subtle_notifications_per_minute_by_priority)["communication"]);
- ASSERT_EQ(11,
- (*config.subtle_notifications_per_minute_by_priority)["normal"]);
- ASSERT_EQ(12, (*config.subtle_notifications_per_minute_by_priority)["none"]);
- EXPECT_EQ(1u, config.endpoints.size());
- policy_table::ServiceEndpoints& service_endpoints = config.endpoints;
- EXPECT_EQ("0x00", service_endpoints.begin()->first);
- policy_table::URLList& url_list = service_endpoints.begin()->second;
- EXPECT_EQ("default", url_list.begin()->first);
- policy_table::URL& url = url_list.begin()->second;
- EXPECT_EQ("http://ford.com/cloud/default", static_cast<std::string>(url[0]));
-
- GatherConsumerFriendlyMessages(&messages);
- EXPECT_EQ("some_msg_version", static_cast<std::string>(messages.version));
- EXPECT_TRUE(0u != messages.messages->size());
- EXPECT_TRUE(0u != (*messages.messages)["MSG_CODE"].languages.size());
-
- GatherUsageAndErrorCounts(&counts);
- EXPECT_FALSE(0u == counts.app_level->size());
- EXPECT_EQ(5u, (*counts.app_level)["some_app_id"].count_of_tls_errors);
-
- GatherDeviceData(&devices);
- EXPECT_EQ(3u, devices.size());
-
- const std::string kAppId = "1234";
- const std::string kServiceType = "MEDIA";
- policy_table::AppServiceParameters app_service_parameters;
- GatherAppServiceParameters(kAppId, &app_service_parameters);
- ASSERT_FALSE(app_service_parameters.find(kServiceType) ==
- app_service_parameters.end());
- auto service_names = *(app_service_parameters[kServiceType].service_names);
- EXPECT_TRUE(service_names.is_initialized());
- ASSERT_EQ(service_names.size(), 2u);
- EXPECT_EQ(static_cast<std::string>(service_names[0]), "SDL App");
- EXPECT_EQ(static_cast<std::string>(service_names[1]), "SDL Music");
-
- auto handled_rpcs = app_service_parameters[kServiceType].handled_rpcs;
-
- EXPECT_TRUE(handled_rpcs.is_initialized());
- EXPECT_EQ(handled_rpcs[0].function_id, 41);
-
- policy_table::ApplicationPolicies& apps = policies.apps;
- auto icon_url = *(apps[kAppId].icon_url);
-
- EXPECT_EQ(std::string(icon_url), "http:://www.sdl.com/image.png");
+ std::shared_ptr<policy_table::Table> snapshot = reps->GenerateSnapshot();
+
+ auto expected_module_meta = GetDefaultSnapshotModuleMeta(update);
+ auto& snapshot_module_meta = snapshot->policy_table.module_meta;
+ EXPECT_EQ(expected_module_meta.toStyledString(),
+ snapshot_module_meta.ToJsonValue().toStyledString());
}
+TEST_F(SQLPTRepresentationTest,
+ SetMetaInfo_SetSoftwareVersion_ValueIsSetInModuleMeta) {
+ EXPECT_TRUE(reps->SetMetaInfo(kSoftwareVersion));
+
+ utils::dbms::SQLQuery query(reps->db());
+ const std::string query_select_ccpu =
+ "SELECT `ccpu_version` FROM `module_meta`";
+
+ query.Prepare(query_select_ccpu);
+ query.Next();
+ EXPECT_EQ(kSoftwareVersion, query.GetString(0));
+}
+
+TEST_F(SQLPTRepresentationTest, SetHardwareVersion_ValueIsSetInModuleMeta) {
+ reps->SetHardwareVersion(kHardwareVersion);
+
+ utils::dbms::SQLQuery query(reps->db());
+ const std::string query_select_hardware_version =
+ "SELECT `hardware_version` FROM `module_meta`";
+
+ query.Prepare(query_select_hardware_version);
+ query.Next();
+ EXPECT_EQ(kHardwareVersion, query.GetString(0));
+}
} // namespace policy_test
} // namespace components
} // namespace test
diff --git a/src/components/protocol/src/bson_object_keys.cc b/src/components/protocol/src/bson_object_keys.cc
index acafd3dbd2..7e1656955f 100644
--- a/src/components/protocol/src/bson_object_keys.cc
+++ b/src/components/protocol/src/bson_object_keys.cc
@@ -19,6 +19,12 @@ const char* tcp_ip_address = "tcpIpAddress";
const char* tcp_port = "tcpPort";
const char* reason = "reason";
const char* auth_token = "authToken";
+const char* vehicle_make = "make";
+const char* vehicle_model = "model";
+const char* vehicle_model_year = "modelYear";
+const char* vehicle_trim = "trim";
+const char* vehicle_system_software_version = "systemSoftwareVersion";
+const char* vehicle_system_hardware_version = "systemHardwareVersion";
} // namespace strings
diff --git a/src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h b/src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h
index e54608bb9e..c75b1f272c 100644
--- a/src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h
+++ b/src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h
@@ -733,6 +733,14 @@ class ProtocolHandlerImpl
const uint8_t session_id,
const bool protection) const;
+ /**
+ * @brief Writes available protocol vehicle data into structured bson
+ * @param params bson params to write into
+ * @param data data to write
+ */
+ void WriteProtocolVehicleData(
+ BsonObject& params, const connection_handler::ProtocolVehicleData& data);
+
const ProtocolHandlerSettings& settings_;
/**
diff --git a/src/components/protocol_handler/src/protocol_handler_impl.cc b/src/components/protocol_handler/src/protocol_handler_impl.cc
index f3bb3d1e91..ca15e9481a 100644
--- a/src/components/protocol_handler/src/protocol_handler_impl.cc
+++ b/src/components/protocol_handler/src/protocol_handler_impl.cc
@@ -54,10 +54,11 @@ SDL_CREATE_LOG_VARIABLE("ProtocolHandler")
const size_t kStackSize = 131072;
-const utils::SemanticVersion default_protocol_version(5, 3, 0);
+const utils::SemanticVersion default_protocol_version(5, 4, 0);
const utils::SemanticVersion min_multiple_transports_version(5, 1, 0);
const utils::SemanticVersion min_cloud_app_version(5, 2, 0);
const utils::SemanticVersion min_reason_param_version(5, 3, 0);
+const utils::SemanticVersion min_vehicle_data_version(5, 4, 0);
ProtocolHandlerImpl::ProtocolHandlerImpl(
const ProtocolHandlerSettings& settings,
@@ -226,6 +227,39 @@ void ProtocolHandlerImpl::SendStartSessionAck(
bson_object_deinitialize(&empty_param);
}
+void ProtocolHandlerImpl::WriteProtocolVehicleData(
+ BsonObject& params, const connection_handler::ProtocolVehicleData& data) {
+ auto write_string_to_bson = [&params](const std::string& param_name,
+ const std::string& param_value) {
+ if (param_value.empty()) {
+ return;
+ }
+
+ const uint16_t max_string_length = 500;
+ char value_buffer[max_string_length + 1]; // extra byte for NULL symbol
+ strncpy(value_buffer, param_value.c_str(), sizeof(value_buffer));
+ value_buffer[max_string_length] = 0;
+
+ if (bson_object_put_string(&params, param_name.c_str(), value_buffer)) {
+ SDL_LOG_DEBUG("Parameter "
+ << param_name << " has been written to bson with value: "
+ << bson_object_get_string(&params, param_name.c_str()));
+ } else {
+ SDL_LOG_DEBUG("Failed to write parameter " << param_name
+ << " into bson structure");
+ }
+ };
+
+ write_string_to_bson(strings::vehicle_make, data.vehicle_make);
+ write_string_to_bson(strings::vehicle_model, data.vehicle_model);
+ write_string_to_bson(strings::vehicle_model_year, data.vehicle_year);
+ write_string_to_bson(strings::vehicle_trim, data.vehicle_trim);
+ write_string_to_bson(strings::vehicle_system_software_version,
+ data.vehicle_system_software_version);
+ write_string_to_bson(strings::vehicle_system_hardware_version,
+ data.vehicle_system_hardware_version);
+}
+
void ProtocolHandlerImpl::SendStartSessionAck(
ConnectionID connection_id,
uint8_t session_id,
@@ -289,6 +323,13 @@ void ProtocolHandlerImpl::SendStartSessionAck(
<< static_cast<int32_t>(bson_object_get_int64(&params, strings::mtu)));
if (serviceTypeValue == kRpc) {
+ SDL_LOG_DEBUG("Collecting protocol vehicle data");
+ connection_handler::ProtocolVehicleData data;
+ if (full_version >= min_vehicle_data_version &&
+ connection_handler_.GetProtocolVehicleData(data)) {
+ WriteProtocolVehicleData(params, data);
+ }
+
// Hash ID is only used in RPC case
const bool hash_written = bson_object_put_int32(
&params, strings::hash_id, static_cast<int32_t>(hash_id));
diff --git a/src/components/protocol_handler/test/protocol_handler_tm_test.cc b/src/components/protocol_handler/test/protocol_handler_tm_test.cc
index 86c39e3551..7cf1878c5f 100644
--- a/src/components/protocol_handler/test/protocol_handler_tm_test.cc
+++ b/src/components/protocol_handler/test/protocol_handler_tm_test.cc
@@ -5413,6 +5413,140 @@ TEST_F(ProtocolHandlerImplTest,
EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout));
}
+TEST_F(ProtocolHandlerImplTest,
+ StartSessionAck_ProtocolVehicleData_VehicleDataParamsForV5) {
+ TestAsyncWaiter waiter;
+
+ const size_t maximum_rpc_payload_size = 1500;
+ EXPECT_CALL(protocol_handler_settings_mock, maximum_rpc_payload_size())
+ .WillOnce(Return(maximum_rpc_payload_size));
+ InitProtocolHandlerImpl(0u, 0u);
+
+ EXPECT_CALL(protocol_handler_settings_mock, max_supported_protocol_version())
+ .WillOnce(Return(PROTOCOL_VERSION_5));
+
+ std::map<std::string, std::string> vehicle_mapping = {
+ {protocol_handler::strings::vehicle_make, "TestMake"},
+ {protocol_handler::strings::vehicle_model, "TestModel"},
+ {protocol_handler::strings::vehicle_model_year, "2021"},
+ {protocol_handler::strings::vehicle_trim, "TestTrim"},
+ {protocol_handler::strings::vehicle_system_hardware_version, "TestHW"},
+ {protocol_handler::strings::vehicle_system_software_version, "TestSW"}};
+
+ connection_handler::ProtocolVehicleData data{
+ vehicle_mapping[protocol_handler::strings::vehicle_make],
+ vehicle_mapping[protocol_handler::strings::vehicle_model],
+ vehicle_mapping[protocol_handler::strings::vehicle_model_year],
+ vehicle_mapping[protocol_handler::strings::vehicle_trim],
+ vehicle_mapping
+ [protocol_handler::strings::vehicle_system_software_version],
+ vehicle_mapping
+ [protocol_handler::strings::vehicle_system_hardware_version]};
+
+ EXPECT_CALL(connection_handler_mock, GetProtocolVehicleData(_))
+ .WillOnce(DoAll(SetArgReferee<0>(data), Return(true)));
+
+ const uint32_t hash_id = 123456;
+ char full_version_string[] = "5.4.0";
+
+ BsonObject expected_obj;
+ bson_object_initialize_default(&expected_obj);
+ // mtu
+ bson_object_put_int64(&expected_obj,
+ protocol_handler::strings::mtu,
+ static_cast<int64_t>(maximum_rpc_payload_size));
+ // hashId
+ bson_object_put_int32(&expected_obj,
+ protocol_handler::strings::hash_id,
+ static_cast<int32_t>(hash_id));
+ // protocolVersion
+ bson_object_put_string(&expected_obj,
+ protocol_handler::strings::protocol_version,
+ full_version_string);
+
+ // vehicle data
+ const uint16_t max_string_length = 500;
+ for (auto& data_pair : vehicle_mapping) {
+ char value_buffer[max_string_length + 1]; // extra byte for NULL symbol
+ strncpy(value_buffer, data_pair.second.c_str(), sizeof(value_buffer));
+ value_buffer[max_string_length] = 0;
+
+ bson_object_put_string(
+ &expected_obj, data_pair.first.c_str(), value_buffer);
+ }
+
+ // secondaryTransports
+ BsonArray secondary_transports;
+ bson_array_initialize(&secondary_transports, 0);
+ bson_object_put_array(&expected_obj,
+ protocol_handler::strings::secondary_transports,
+ &secondary_transports);
+
+ BsonArray audio_service_transports;
+ bson_array_initialize(&audio_service_transports, 1);
+ bson_array_add_int32(&audio_service_transports, 1);
+ bson_object_put_array(&expected_obj,
+ protocol_handler::strings::audio_service_transports,
+ &audio_service_transports);
+
+ BsonArray video_service_transports;
+ bson_array_initialize(&video_service_transports, 1);
+ bson_array_add_int32(&video_service_transports, 1);
+ bson_object_put_array(&expected_obj,
+ protocol_handler::strings::video_service_transports,
+ &video_service_transports);
+
+ std::vector<uint8_t> expected_param =
+ CreateVectorFromBsonObject(&expected_obj);
+
+ bson_object_deinitialize(&expected_obj);
+
+ EXPECT_CALL(transport_manager_mock,
+ SendMessageToDevice(ControlMessage(FRAME_DATA_START_SERVICE_ACK,
+ PROTECTION_OFF,
+ connection_id,
+ Eq(expected_param))))
+ .WillOnce(DoAll(NotifyTestAsyncWaiter(&waiter), Return(E_SUCCESS)));
+
+ connection_handler::SessionTransports dummy_st = {0, 0};
+ EXPECT_CALL(connection_handler_mock,
+ SetSecondaryTransportID(_, kDisabledSecondary))
+ .WillOnce(Return(dummy_st));
+ EXPECT_CALL(protocol_handler_settings_mock, multiple_transports_enabled())
+ .WillRepeatedly(Return(false));
+ std::vector<std::string> empty_vec;
+ EXPECT_CALL(protocol_handler_settings_mock, audio_service_transports())
+ .WillRepeatedly(ReturnRef(empty_vec));
+ EXPECT_CALL(protocol_handler_settings_mock, video_service_transports())
+ .WillRepeatedly(ReturnRef(empty_vec));
+ EXPECT_CALL(session_observer_mock,
+ TransportTypeProfileStringFromConnHandle(connection_id))
+ .WillRepeatedly(Return("WEBSOCKET"));
+
+#ifdef ENABLE_SECURITY
+ AddSecurityManager();
+
+ EXPECT_CALL(session_observer_mock, KeyFromPair(connection_id, session_id))
+ .WillRepeatedly(Return(connection_key));
+
+ EXPECT_CALL(session_observer_mock, GetSSLContext(connection_key, kRpc))
+ .WillOnce(ReturnNull());
+#endif // ENABLE_SECURITY
+
+ const uint8_t input_protocol_version = 5;
+ utils::SemanticVersion full_version(5, 4, 0);
+
+ protocol_handler_impl->SendStartSessionAck(connection_id,
+ session_id,
+ input_protocol_version,
+ hash_id,
+ kRpc,
+ false /* protection */,
+ full_version);
+
+ EXPECT_TRUE(waiter.WaitFor(1, kAsyncExpectationsTimeout));
+}
+
} // namespace protocol_handler_test
} // namespace components
} // namespace test
diff --git a/src/components/utils/test/policy.sql b/src/components/utils/test/policy.sql
index d588d695a6..ed627b5fdc 100644
--- a/src/components/utils/test/policy.sql
+++ b/src/components/utils/test/policy.sql
@@ -22,6 +22,7 @@ BEGIN TRANSACTION;
`ccpu_version` VARCHAR(45),
`language` VARCHAR(45),
`wers_country_code` VARCHAR(45),
+ `hardware_version` VARCHAR(45),
`pt_exchanged_at_odometer_x` INTEGER NOT NULL DEFAULT 0,
`pt_exchanged_x_days_after_epoch` INTEGER NOT NULL DEFAULT 0,
`ignition_cycles_since_last_exchange` INTEGER NOT NULL DEFAULT 0,
diff --git a/tools/rpc_spec b/tools/rpc_spec
-Subproject f8be1a712f87705ec9580ab607dd0a3c8e63715
+Subproject d1401e31ae3cb183a5a344064046ffa55334620