summaryrefslogtreecommitdiff
path: root/src/components/application_manager
diff options
context:
space:
mode:
authorjacobkeeler <jacob.keeler@livioradio.com>2018-08-22 13:07:09 -0400
committerjacobkeeler <jacob.keeler@livioradio.com>2018-08-22 13:07:09 -0400
commit6ada4dc5bd0d9a2b6068745154e715fccd5dc943 (patch)
tree2890f67599792367ca6315867b66be682795dea7 /src/components/application_manager
parenta086a8e23ed7c86f27460ddc61046ca595ab46a9 (diff)
parent6a436addb2811c3fbc6ff155a8a142aa14c8ec45 (diff)
downloadsdl_core-6ada4dc5bd0d9a2b6068745154e715fccd5dc943.tar.gz
Merge remote-tracking branch 'origin/develop' into feature/boost_datetime_implementation
Diffstat (limited to 'src/components/application_manager')
-rw-r--r--src/components/application_manager/include/application_manager/application.h21
-rw-r--r--src/components/application_manager/include/application_manager/application_data_impl.h4
-rw-r--r--src/components/application_manager/include/application_manager/application_impl.h14
-rw-r--r--src/components/application_manager/include/application_manager/application_manager_impl.h129
-rw-r--r--src/components/application_manager/include/application_manager/command_factory.h9
-rw-r--r--src/components/application_manager/include/application_manager/commands/command_impl.h14
-rw-r--r--src/components/application_manager/include/application_manager/commands/command_request_impl.h2
-rw-r--r--src/components/application_manager/include/application_manager/hmi_state.h35
-rw-r--r--src/components/application_manager/include/application_manager/message.h1
-rw-r--r--src/components/application_manager/include/application_manager/message_helper.h16
-rw-r--r--src/components/application_manager/include/application_manager/resumption/resume_ctrl.h20
-rw-r--r--src/components/application_manager/include/application_manager/resumption/resume_ctrl_impl.h86
-rw-r--r--src/components/application_manager/include/application_manager/resumption/resumption_data.h20
-rw-r--r--src/components/application_manager/include/application_manager/resumption/resumption_data_db.h13
-rw-r--r--src/components/application_manager/include/application_manager/resumption/resumption_data_json.h18
-rw-r--r--src/components/application_manager/include/application_manager/resumption/resumption_sql_queries.h5
-rw-r--r--src/components/application_manager/include/application_manager/rpc_handler_impl.h11
-rw-r--r--src/components/application_manager/include/application_manager/smart_object_keys.h2
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_button_press_request.h17
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_button_press_response.h14
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_consent_request.h10
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_consent_response.h10
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_request.h10
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_response.h10
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_on_interior_vehicle_data_notification.h16
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_on_remote_control_settings_notification.h19
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_set_interior_vehicle_data_request.h10
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_set_interior_vehicle_data_response.h16
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/button_press_request.h15
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/button_press_response.h17
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_request.h19
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_response.h16
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/on_interior_vehicle_data_notification.h14
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_request.h23
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_response.h16
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/rc_command_params.h64
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/rc_command_request.h20
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/interior_data_cache.h81
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/interior_data_cache_impl.h64
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/interior_data_manager.h86
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/interior_data_manager_impl.h122
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_app_extension.h12
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_command_factory.h20
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_helpers.h96
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_module_constants.h45
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_rpc_plugin.h17
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager.h9
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager_impl.h16
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_button_press_request.cc20
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_button_press_response.cc21
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_consent_request.cc16
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_consent_response.cc21
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_request.cc16
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_response.cc31
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_interior_vehicle_data_notification.cc31
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_remote_control_settings_notification.cc37
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_set_interior_vehicle_data_request.cc16
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_set_interior_vehicle_data_response.cc19
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/button_press_request.cc13
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/button_press_response.cc19
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_request.cc159
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_response.cc19
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/on_interior_vehicle_data_notification.cc36
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc284
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_response.cc20
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/rc_command_request.cc28
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/interior_data_cache_impl.cc121
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/interior_data_manager_impl.cc159
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_app_extension.cc4
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_command_factory.cc90
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_helpers.cc118
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_rpc_plugin.cc37
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/resource_allocation_manager_impl.cc65
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/CMakeLists.txt3
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/button_press_request_test.cc22
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/get_interior_vehicle_data_request_test.cc470
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/on_interior_vehicle_data_notification_test.cc70
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/on_remote_control_settings_test.cc20
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/rc_get_interior_vehicle_data_consent_test.cc36
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/set_interior_vehicle_data_request_test.cc22
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_interior_data_cache.h54
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_interior_data_manager.h55
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_resource_allocation_manager.h9
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/interior_data_cache_test.cc160
-rw-r--r--src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/resource_allocation_manager_impl_test.cc16
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_audio_pass_thru_request.h9
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_interaction_request.h7
-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/mobile/create_interaction_choice_set_request.cc35
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_audio_pass_thru_request.cc7
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_interaction_request.cc61
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc46
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/CMakeLists.txt1
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/hmi_notifications_test.cc4
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/create_interaction_choice_set_test.cc102
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/register_app_interface_request_test.cc11
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/subscribe_vehicle_data_request.h8
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/subscribe_vehicle_data_request.cc15
-rw-r--r--src/components/application_manager/src/application_data_impl.cc9
-rw-r--r--src/components/application_manager/src/application_impl.cc11
-rw-r--r--src/components/application_manager/src/application_manager_impl.cc256
-rw-r--r--src/components/application_manager/src/commands/command_impl.cc14
-rw-r--r--src/components/application_manager/src/hmi_state.cc52
-rw-r--r--src/components/application_manager/src/message.cc13
-rw-r--r--src/components/application_manager/src/message_helper/message_helper.cc34
-rw-r--r--src/components/application_manager/src/resumption/resume_ctrl_impl.cc226
-rw-r--r--src/components/application_manager/src/resumption/resumption_data_db.cc93
-rw-r--r--src/components/application_manager/src/resumption/resumption_data_json.cc49
-rw-r--r--src/components/application_manager/src/resumption/resumption_sql_queries.cc18
-rw-r--r--src/components/application_manager/src/rpc_handler_impl.cc52
-rw-r--r--src/components/application_manager/src/smart_object_keys.cc1
-rw-r--r--src/components/application_manager/src/state_controller_impl.cc3
-rw-r--r--src/components/application_manager/test/application_manager_impl_test.cc3
-rw-r--r--src/components/application_manager/test/commands/CMakeLists.txt1
-rw-r--r--src/components/application_manager/test/include/application_manager/commands/commands_test.h7
-rw-r--r--src/components/application_manager/test/include/application_manager/mock_application.h7
-rw-r--r--src/components/application_manager/test/include/application_manager/mock_message_helper.h3
-rw-r--r--src/components/application_manager/test/include/application_manager/mock_resume_ctrl.h7
-rw-r--r--src/components/application_manager/test/include/application_manager/mock_resumption_data.h4
-rw-r--r--src/components/application_manager/test/mock_message_helper.cc7
-rw-r--r--src/components/application_manager/test/resumption/resume_ctrl_test.cc218
-rw-r--r--src/components/application_manager/test/resumption/resumption_data_db_test.cc2
-rw-r--r--src/components/application_manager/test/state_controller/state_controller_test.cc73
123 files changed, 3693 insertions, 1443 deletions
diff --git a/src/components/application_manager/include/application_manager/application.h b/src/components/application_manager/include/application_manager/application.h
index 844b08071b..c3a4ecbb30 100644
--- a/src/components/application_manager/include/application_manager/application.h
+++ b/src/components/application_manager/include/application_manager/application.h
@@ -51,6 +51,7 @@
#include "protocol_handler/protocol_handler.h"
#include "smart_objects/smart_object.h"
#include "utils/macro.h"
+#include "utils/semantic_version.h"
namespace application_manager {
@@ -115,6 +116,7 @@ class InitialApplicationData {
virtual const smart_objects::SmartObject* ngn_media_screen_name() const = 0;
virtual const mobile_api::Language::eType& language() const = 0;
virtual const mobile_api::Language::eType& ui_language() const = 0;
+ virtual const utils::SemanticVersion& msg_version() const = 0;
virtual void set_app_types(const smart_objects::SmartObject& app_types) = 0;
virtual void set_vr_synonyms(
const smart_objects::SmartObject& vr_synonyms) = 0;
@@ -125,6 +127,7 @@ class InitialApplicationData {
virtual void set_language(const mobile_api::Language::eType& language) = 0;
virtual void set_ui_language(
const mobile_api::Language::eType& ui_language) = 0;
+ virtual void set_msg_version(const utils::SemanticVersion& version) = 0;
};
/*
@@ -594,8 +597,6 @@ class Application : public virtual InitialApplicationData,
virtual void increment_list_files_in_none_count() = 0;
virtual bool set_app_icon_path(const std::string& file_name) = 0;
virtual void set_app_allowed(const bool allowed) = 0;
- DEPRECATED virtual void set_device(
- connection_handler::DeviceHandle device) = 0;
/**
* @brief Sets the handle of the device on which secondary transport of this
* app is running
@@ -735,6 +736,12 @@ class Application : public virtual InitialApplicationData,
virtual const HmiStatePtr RegularHmiState() const = 0;
/**
+ * @brief Checks if app is allowed to change audio source
+ * @return True - if allowed, otherwise - False
+ */
+ virtual bool IsAllowedToChangeAudioSource() const = 0;
+
+ /**
* @brief PostponedHmiState returns postponed hmi state of application
* if it's present
*
@@ -782,16 +789,6 @@ class Application : public virtual InitialApplicationData,
virtual bool IsVideoApplication() const = 0;
/**
- * DEPRECATED
- * @brief GetDeviceId allows to obtain device id which posseses
- * by this application.
- * @return device the device id.
- */
- std::string GetDeviceId() const {
- return device_id_;
- }
-
- /**
* @brief IsRegistered allows to distinguish if this
* application has been registered.
*
diff --git a/src/components/application_manager/include/application_manager/application_data_impl.h b/src/components/application_manager/include/application_manager/application_data_impl.h
index 3f60040db9..05091dbfbd 100644
--- a/src/components/application_manager/include/application_manager/application_data_impl.h
+++ b/src/components/application_manager/include/application_manager/application_data_impl.h
@@ -35,6 +35,7 @@
#include <string>
#include "utils/lock.h"
+#include "utils/semantic_version.h"
#include "smart_objects/smart_object.h"
#include "application_manager/application.h"
#include "interfaces/MOBILE_API.h"
@@ -55,6 +56,7 @@ class InitialApplicationDataImpl : public virtual Application {
const smart_objects::SmartObject* ngn_media_screen_name() const;
const mobile_api::Language::eType& language() const;
const mobile_api::Language::eType& ui_language() const;
+ const utils::SemanticVersion& msg_version() const;
void set_app_types(const smart_objects::SmartObject& app_types);
void set_vr_synonyms(const smart_objects::SmartObject& vr_synonyms);
@@ -63,6 +65,7 @@ class InitialApplicationDataImpl : public virtual Application {
void set_ngn_media_screen_name(const smart_objects::SmartObject& ngn_name);
void set_language(const mobile_api::Language::eType& language);
void set_ui_language(const mobile_api::Language::eType& ui_language);
+ void set_msg_version(const utils::SemanticVersion& version);
void set_perform_interaction_layout(
mobile_api::LayoutMode::eType layout) OVERRIDE;
@@ -77,6 +80,7 @@ class InitialApplicationDataImpl : public virtual Application {
mobile_api::Language::eType language_;
mobile_api::Language::eType ui_language_;
mobile_apis::LayoutMode::eType perform_interaction_layout_;
+ utils::SemanticVersion msg_version_;
private:
DISALLOW_COPY_AND_ASSIGN(InitialApplicationDataImpl);
diff --git a/src/components/application_manager/include/application_manager/application_impl.h b/src/components/application_manager/include/application_manager/application_impl.h
index 6035a6e80b..f937ebebe1 100644
--- a/src/components/application_manager/include/application_manager/application_impl.h
+++ b/src/components/application_manager/include/application_manager/application_impl.h
@@ -94,14 +94,6 @@ class ApplicationImpl : public virtual Application,
std::shared_ptr<usage_statistics::StatisticsManager> statistics_manager,
ApplicationManager& application_manager);
- DEPRECATED ApplicationImpl(
- uint32_t application_id,
- const std::string& policy_app_id,
- const std::string& mac_address,
- const custom_str::CustomString& app_name,
- std::shared_ptr<usage_statistics::StatisticsManager> statistics_manager,
- ApplicationManager& application_manager);
-
~ApplicationImpl();
/**
@@ -353,6 +345,12 @@ class ApplicationImpl : public virtual Application,
virtual const HmiStatePtr CurrentHmiState() const;
/**
+ * @brief Checks if app is allowed to change audio source
+ * @return True - if allowed, otherwise - False
+ */
+ virtual bool IsAllowedToChangeAudioSource() const;
+
+ /**
* @brief RegularHmiState of application without active events VR, TTS etc ...
* @return HmiState of application
*/
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 4eb0d7826d..9dd5bea3a1 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
@@ -181,6 +181,10 @@ class ApplicationManagerImpl
void set_application_id(const int32_t correlation_id,
const uint32_t app_id) OVERRIDE;
+ uint32_t get_current_audio_source() const OVERRIDE;
+
+ void set_current_audio_source(const uint32_t source) OVERRIDE;
+
void OnHMILevelChanged(uint32_t app_id,
mobile_apis::HMILevel::eType from,
mobile_apis::HMILevel::eType to) OVERRIDE;
@@ -224,29 +228,6 @@ class ApplicationManagerImpl
bool IsAppTypeExistsInFullOrLimited(ApplicationConstSharedPtr app) const;
/**
- * DEPRECATED
- * @brief Checks if Application is subscribed for way points
- * @param Application AppID
- * @return true if Application is subscribed for way points
- * otherwise false
- */
- bool IsAppSubscribedForWayPoints(const uint32_t app_id) const OVERRIDE;
-
- /**
- * DEPRECATED
- * @brief Subscribe Application for way points
- * @param Application AppID
- */
- void SubscribeAppForWayPoints(const uint32_t app_id) OVERRIDE;
-
- /**
- * DEPRECATED
- * @brief Unsubscribe Application for way points
- * @param Application AppID
- */
- void UnsubscribeAppFromWayPoints(const uint32_t app_id) OVERRIDE;
-
- /**
* @brief Checks if Application is subscribed for way points
* @param Application pointer
* @return true if Application is subscribed for way points
@@ -365,10 +346,6 @@ class ApplicationManagerImpl
* @brief Closes all registered applications
*/
void UnregisterAllApplications();
-
- DEPRECATED bool RemoveAppDataFromHMI(ApplicationSharedPtr app);
-
- DEPRECATED bool LoadAppDataToHMI(ApplicationSharedPtr app);
bool ActivateApplication(ApplicationSharedPtr app) OVERRIDE;
/**
@@ -390,13 +367,6 @@ class ApplicationManagerImpl
*/
uint32_t GetNextHMICorrelationID() OVERRIDE;
- /* @brief Starts audio passthru process
- * @deprecated Use BeginAudioPassThru(uint32_t app_id) instead
- *
- * @return true on success, false if passthru is already in process
- */
- bool BeginAudioPassThrough() OVERRIDE;
-
/**
* @brief Starts AudioPassThru process by given application
* @param app_id ID of the application which starts the process
@@ -404,14 +374,6 @@ class ApplicationManagerImpl
*/
bool BeginAudioPassThru(uint32_t app_id) OVERRIDE;
- /*
- * @brief Finishes already started audio passthru process
- * @deprecated Use EndAudioPassThru(uint32_t app_id) instead
- *
- * @return true on success, false if passthru is not active
- */
- bool EndAudioPassThrough() OVERRIDE;
-
/**
* @brief Finishes already started AudioPassThru process by given application
* @param app_id ID of the application which started the process
@@ -437,22 +399,6 @@ class ApplicationManagerImpl
const hmi_apis::Common_DriverDistractionState::eType state) OVERRIDE;
/*
- * DEPRECATED
- * @brief Retrieves if VR session has started
- *
- * @return Current VR session state (started, stopped)
- */
- inline bool vr_session_started() const;
-
- /*
- * DEPRECATED
- * @brief Sets VR session state
- *
- * @param state Current HMI VR session state
- */
- void set_vr_session_started(const bool state);
-
- /*
* @brief Retrieves SDL access to all mobile apps
*
* @return Currently active state of the access
@@ -482,21 +428,6 @@ class ApplicationManagerImpl
mobile_apis::SystemContext::eType system_context) const OVERRIDE;
/**
- * DEPRECATED
- * @brief CreateRegularState create regular HMI state for application
- * @param app_id Application id
- * @param hmi_level of returned state
- * @param audio_state of returned state
- * @param system_context of returned state
- * @return new regular HMI state
- */
- DEPRECATED HmiStatePtr CreateRegularState(
- uint32_t app_id,
- mobile_apis::HMILevel::eType hmi_level,
- mobile_apis::AudioStreamingState::eType audio_state,
- mobile_apis::SystemContext::eType system_context) const OVERRIDE;
-
- /**
* @brief Checks, if given RPC is allowed at current HMI level for specific
* application in policy table
* @param app Application
@@ -660,10 +591,6 @@ class ApplicationManagerImpl
*/
void OnDeviceSwitchingFinish(const std::string& device_uid) FINAL;
- DEPRECATED bool OnServiceStartedCallback(
- const connection_handler::DeviceHandle& device_handle,
- const int32_t& session_key,
- const protocol_handler::ServiceType& type) OVERRIDE;
void OnServiceStartedCallback(
const connection_handler::DeviceHandle& device_handle,
const int32_t& session_key,
@@ -861,20 +788,6 @@ class ApplicationManagerImpl
*/
uint32_t GenerateNewHMIAppID() OVERRIDE;
- /**
- * DERPECATED
- * @brief Parse smartObject and replace mobile app Id by HMI app ID
- * @param message Smartobject to be parsed
- */
- void ReplaceMobileByHMIAppId(smart_objects::SmartObject& message);
-
- /**
- * DEPRECATED
- * @brief Parse smartObject and replace HMI app ID by mobile app Id
- * @param message Smartobject to be parsed
- */
- void ReplaceHMIByMobileAppId(smart_objects::SmartObject& message);
-
/*
* @brief Save binary data to specified directory
*
@@ -926,22 +839,6 @@ class ApplicationManagerImpl
*/
void RemoveAppFromTTSGlobalPropertiesList(const uint32_t app_id) OVERRIDE;
- /**
- * DEPRECATED
- * @brief method adds application in FULL and LIMITED state
- * to on_phone_call_app_list_.
- * Also OnHMIStateNotification with BACKGROUND state sent for these apps
- */
- void CreatePhoneCallAppList();
-
- /**
- * DEPRECATED
- * @brief method removes application from on_phone_call_app_list_.
- *
- * Also OnHMIStateNotification with previous HMI state sent for these apps
- */
- void ResetPhoneCallAppList();
-
// TODO(AOleynik): Temporary added, to fix build. Should be reworked.
connection_handler::ConnectionHandler& connection_handler() const OVERRIDE;
protocol_handler::ProtocolHandler& protocol_handler() const OVERRIDE;
@@ -1234,10 +1131,10 @@ class ApplicationManagerImpl
*/
void SendOnSDLClose();
- /*
+ /**
* @brief returns true if low voltage state is active
*/
- bool IsLowVoltage();
+ bool IsLowVoltage() const OVERRIDE;
/**
* @brief Allows to process postponed commands for application
@@ -1311,15 +1208,6 @@ class ApplicationManagerImpl
* @brief Starts specified navi service for application
* @param app_id Application to proceed
* @param service_type Type of service to start
- * @return True on success, false on fail
- */
- DEPRECATED bool StartNaviService(uint32_t app_id,
- protocol_handler::ServiceType service_type);
-
- /**
- * @brief Starts specified navi service for application
- * @param app_id Application to proceed
- * @param service_type Type of service to start
* @param params configuration parameters specified by mobile
* @return True if service is immediately started or configuration
* parameters are sent to HMI, false on other cases
@@ -1480,6 +1368,7 @@ class ApplicationManagerImpl
bool is_vr_session_strated_;
bool hmi_cooperating_;
bool is_all_apps_allowed_;
+ uint32_t current_audio_source_;
event_engine::EventDispatcherImpl event_dispatcher_;
media_manager::MediaManager* media_manager_;
@@ -1604,10 +1493,6 @@ class ApplicationManagerImpl
DISALLOW_COPY_AND_ASSIGN(ApplicationManagerImpl);
};
-DEPRECATED bool ApplicationManagerImpl::vr_session_started() const {
- return is_vr_session_strated_;
-}
-
inline bool ApplicationManagerImpl::all_apps_allowed() const {
return is_all_apps_allowed_;
}
diff --git a/src/components/application_manager/include/application_manager/command_factory.h b/src/components/application_manager/include/application_manager/command_factory.h
index b8267ed438..f494fd64f8 100644
--- a/src/components/application_manager/include/application_manager/command_factory.h
+++ b/src/components/application_manager/include/application_manager/command_factory.h
@@ -40,7 +40,6 @@
#include "utils/macro.h"
namespace application_manager {
-using rpc_service::RPCService;
using policy::PolicyHandlerInterface;
typedef std::shared_ptr<commands::Command> CommandSharedPtr;
@@ -105,7 +104,7 @@ class DefaultCommandCreator : public CommandCreator {
* @param policy_handler PolicyHandlerInterface.
*/
DefaultCommandCreator(ApplicationManager& application_manager,
- RPCService& rpc_service,
+ rpc_service::RPCService& rpc_service,
HMICapabilities& hmi_capabilities,
PolicyHandlerInterface& policy_handler)
: application_manager_(application_manager)
@@ -137,7 +136,7 @@ class DefaultCommandCreator : public CommandCreator {
}
ApplicationManager& application_manager_;
- RPCService& rpc_service_;
+ rpc_service::RPCService& rpc_service_;
HMICapabilities& hmi_capabilities_;
PolicyHandlerInterface& policy_handler_;
};
@@ -158,7 +157,7 @@ class DefaultCommandCreator<InvalidCommand> : public CommandCreator {
* @param policy_handler PolicyHandlerInterface.
*/
DefaultCommandCreator(ApplicationManager& application_manager,
- RPCService& rpc_service,
+ rpc_service::RPCService& rpc_service,
HMICapabilities& hmi_capabilities,
PolicyHandlerInterface& policy_handler) {
UNUSED(application_manager);
@@ -203,7 +202,7 @@ struct CommandCreatorFactory {
return res;
}
ApplicationManager& application_manager_;
- RPCService& rpc_service_;
+ rpc_service::RPCService& rpc_service_;
HMICapabilities& hmi_capabilities_;
PolicyHandlerInterface& policy_handler_;
};
diff --git a/src/components/application_manager/include/application_manager/commands/command_impl.h b/src/components/application_manager/include/application_manager/commands/command_impl.h
index be79d9e8d1..4859f73a55 100644
--- a/src/components/application_manager/include/application_manager/commands/command_impl.h
+++ b/src/components/application_manager/include/application_manager/commands/command_impl.h
@@ -152,26 +152,12 @@ class CommandImpl : public Command {
bool ReplaceMobileWithHMIAppId(smart_objects::SmartObject& message);
/**
- * DEPRECATED
- * @brief Parses mobile message and replaces mobile app id with HMI app id
- * @param message Message to replace its ids
- */
- void ReplaceMobileByHMIAppId(smart_objects::SmartObject& message);
-
- /**
* @brief Parses message from HMI and replaces HMI app id with mobile app id
* @param message Message to replace its ids
* @return True if replacement succeeded, otherwise - false
*/
bool ReplaceHMIWithMobileAppId(smart_objects::SmartObject& message);
- /**
- * DEPRECATED
- * @brief Parses message from HMI and replaces HMI app id with mobile app id
- * @param message Message to replace its ids
- */
- void ReplaceHMIByMobileAppId(smart_objects::SmartObject& message);
-
MessageSharedPtr message_;
uint32_t default_timeout_;
bool allowed_to_terminate_;
diff --git a/src/components/application_manager/include/application_manager/commands/command_request_impl.h b/src/components/application_manager/include/application_manager/commands/command_request_impl.h
index e790fc9af6..6fdeaea332 100644
--- a/src/components/application_manager/include/application_manager/commands/command_request_impl.h
+++ b/src/components/application_manager/include/application_manager/commands/command_request_impl.h
@@ -43,8 +43,6 @@ namespace application_manager {
namespace commands {
struct ResponseInfo {
- DEPRECATED ResponseInfo(hmi_apis::Common_Result::eType result,
- HmiInterfaces::InterfaceID interface);
ResponseInfo();
ResponseInfo(const hmi_apis::Common_Result::eType result,
const HmiInterfaces::InterfaceID hmi_interface,
diff --git a/src/components/application_manager/include/application_manager/hmi_state.h b/src/components/application_manager/include/application_manager/hmi_state.h
index e333cb9bbc..4b7779e08c 100644
--- a/src/components/application_manager/include/application_manager/hmi_state.h
+++ b/src/components/application_manager/include/application_manager/hmi_state.h
@@ -94,25 +94,6 @@ class HmiState {
const ApplicationManager& app_mngr,
StateID state_id);
- /**
- * DEPRECATED
- * @brief HmiState constructor
- * @param app_id Application id
- * @param app_mngr Application manager
- */
- HmiState(uint32_t app_id, const ApplicationManager& app_mngr);
-
- /**
- * DEPRECATED
- * @brief HmiState constructor
- * @param app_id Application id
- * @param app_mngr Application manager
- * @param state_id HMI state to assign
- */
- HmiState(uint32_t app_id,
- const ApplicationManager& app_mngr,
- StateID state_id);
-
virtual ~HmiState() {}
/**
@@ -274,8 +255,6 @@ class VRHmiState : public HmiState {
const OVERRIDE;
VRHmiState(std::shared_ptr<Application> app,
const ApplicationManager& app_mngr);
-
- DEPRECATED VRHmiState(uint32_t app_id, const ApplicationManager& app_mngr);
};
/**
@@ -286,8 +265,6 @@ class TTSHmiState : public HmiState {
TTSHmiState(std::shared_ptr<Application> app,
const ApplicationManager& app_mngr);
- DEPRECATED TTSHmiState(uint32_t app_id, const ApplicationManager& app_mngr);
-
virtual mobile_apis::AudioStreamingState::eType audio_streaming_state()
const OVERRIDE;
};
@@ -327,9 +304,6 @@ class PhoneCallHmiState : public HmiState {
PhoneCallHmiState(std::shared_ptr<Application> app,
const ApplicationManager& app_mngr);
- DEPRECATED PhoneCallHmiState(uint32_t app_id,
- const ApplicationManager& app_mngr);
-
mobile_apis::HMILevel::eType hmi_level() const OVERRIDE;
mobile_apis::AudioStreamingState::eType audio_streaming_state()
const OVERRIDE {
@@ -346,9 +320,6 @@ class SafetyModeHmiState : public HmiState {
SafetyModeHmiState(std::shared_ptr<Application> app,
const ApplicationManager& app_mngr);
- DEPRECATED SafetyModeHmiState(uint32_t app_id,
- const ApplicationManager& app_mngr);
-
mobile_apis::AudioStreamingState::eType audio_streaming_state()
const OVERRIDE {
return mobile_apis::AudioStreamingState::NOT_AUDIBLE;
@@ -368,8 +339,6 @@ class DeactivateHMI : public HmiState {
DeactivateHMI(std::shared_ptr<Application> app,
const ApplicationManager& app_mngr);
- DEPRECATED DeactivateHMI(uint32_t app_id, const ApplicationManager& app_mngr);
-
mobile_apis::HMILevel::eType hmi_level() const OVERRIDE;
mobile_apis::AudioStreamingState::eType audio_streaming_state()
const OVERRIDE {
@@ -390,8 +359,6 @@ class AudioSource : public HmiState {
AudioSource(std::shared_ptr<Application> app,
const ApplicationManager& app_mngr);
- DEPRECATED AudioSource(uint32_t app_id, const ApplicationManager& app_mngr);
-
mobile_apis::HMILevel::eType hmi_level() const OVERRIDE;
mobile_apis::AudioStreamingState::eType audio_streaming_state()
const OVERRIDE {
@@ -413,8 +380,6 @@ class EmbeddedNavi : public HmiState {
EmbeddedNavi(std::shared_ptr<Application> app,
const ApplicationManager& app_mngr);
- DEPRECATED EmbeddedNavi(uint32_t app_id, const ApplicationManager& app_mngr);
-
mobile_apis::HMILevel::eType hmi_level() const OVERRIDE;
mobile_apis::AudioStreamingState::eType audio_streaming_state()
const OVERRIDE {
diff --git a/src/components/application_manager/include/application_manager/message.h b/src/components/application_manager/include/application_manager/message.h
index 7c3f0a13c9..1c319cf204 100644
--- a/src/components/application_manager/include/application_manager/message.h
+++ b/src/components/application_manager/include/application_manager/message.h
@@ -88,7 +88,6 @@ class Message {
void set_correlation_id(int32_t id);
void set_connection_key(int32_t key);
void set_message_type(MessageType type);
- DEPRECATED void set_binary_data(BinaryData* data);
void set_binary_data(const BinaryData* data);
void set_json_message(const std::string& json_message);
void set_protocol_version(protocol_handler::MajorProtocolVersion version);
diff --git a/src/components/application_manager/include/application_manager/message_helper.h b/src/components/application_manager/include/application_manager/message_helper.h
index 127ff967b4..73f49e3477 100644
--- a/src/components/application_manager/include/application_manager/message_helper.h
+++ b/src/components/application_manager/include/application_manager/message_helper.h
@@ -50,6 +50,7 @@
#include "application_manager/policies/policy_handler_interface.h"
#include "smart_objects/smart_object.h"
#include "transport_manager/common.h"
+#include <application_manager/smart_object_keys.h>
namespace policy {
class PolicyHandlerInterface;
@@ -634,6 +635,21 @@ class MessageHelper {
ApplicationConstSharedPtr app,
ApplicationManager& app_mngr);
+ /**
+ * @brief Stores whether each choice in a set has the vrCommands parameter
+ * MIXED means some choices have vrCommands and others don't
+ * ALL means all do, NONE means none do
+ */
+ enum ChoiceSetVRCommandsStatus { MIXED, ALL, NONE };
+
+ /**
+ * @brief Check whether each choice in the set has the vrCommands parameter
+ * @param choice set to check
+ * @return a ChoiceSetVRCommandsStatus with the state of the choice set
+ */
+ static ChoiceSetVRCommandsStatus CheckChoiceSetVRCommands(
+ const smart_objects::SmartObject& choice_set);
+
/*
* @brief Finds "Image" structure in request and verify image file presence
* in Core.
diff --git a/src/components/application_manager/include/application_manager/resumption/resume_ctrl.h b/src/components/application_manager/include/application_manager/resumption/resume_ctrl.h
index 90c6c5c208..f9a60c862b 100644
--- a/src/components/application_manager/include/application_manager/resumption/resume_ctrl.h
+++ b/src/components/application_manager/include/application_manager/resumption/resume_ctrl.h
@@ -34,7 +34,7 @@
#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_RESUMPTION_RESUME_CTRL_H_
#include <stdint.h>
-
+#include <time.h>
#include "application_manager/resumption/resumption_data.h"
namespace application_manager {
@@ -125,6 +125,16 @@ class ResumeCtrl {
virtual void OnAwake() = 0;
/**
+ * @brief Saves Low Voltage signal timestamp
+ */
+ virtual void SaveLowVoltageTime() = 0;
+
+ /**
+ * @brief Saves Wake Up signal timestamp
+ */
+ virtual void SaveWakeUpTime() = 0;
+
+ /**
* @brief Checks if SDL has already received OnExitAllApplication notification
* with "SUSPEND" reason
*
@@ -134,13 +144,19 @@ class ResumeCtrl {
virtual bool is_suspended() const = 0;
/**
- * @brief Method stops timer "RsmCtrlPercist" when SDL
+ * @brief Method stops timer "RsmCtrlPersist" when SDL
* receives OnExitAllApplication notification
* with reason "SUSPEND"
*/
virtual void StopSavePersistentDataTimer() = 0;
/**
+ * @brief Method starts timer "RsmCtrlPersist" when
+ * SDL receives onAwakeSDL notification
+ */
+ virtual void StartSavePersistentDataTimer() = 0;
+
+ /**
* @brief Start timer for resumption applications
* Restore D1-D5 data
* @param application that is need to be restored
diff --git a/src/components/application_manager/include/application_manager/resumption/resume_ctrl_impl.h b/src/components/application_manager/include/application_manager/resumption/resume_ctrl_impl.h
index 17aabb6d60..e749118140 100644
--- a/src/components/application_manager/include/application_manager/resumption/resume_ctrl_impl.h
+++ b/src/components/application_manager/include/application_manager/resumption/resume_ctrl_impl.h
@@ -33,6 +33,8 @@
#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_RESUMPTION_RESUME_CTRL_IMPL_H_
#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_RESUMPTION_RESUME_CTRL_IMPL_H_
+#include "application_manager/resumption/resume_ctrl.h"
+
#include <stdint.h>
#include <vector>
#include <map>
@@ -46,7 +48,6 @@
#include "smart_objects/smart_object.h"
#include "application_manager/application.h"
#include "application_manager/resumption/resumption_data.h"
-#include "application_manager/resumption/resume_ctrl.h"
#include "utils/timer.h"
namespace resumption {
@@ -138,6 +139,10 @@ class ResumeCtrlImpl : public ResumeCtrl,
*/
void OnAwake() OVERRIDE;
+ void SaveLowVoltageTime() OVERRIDE;
+
+ void SaveWakeUpTime() OVERRIDE;
+
/**
* @brief Checks if SDL has already received OnExitAllApplication notification
* with "SUSPEND" reason
@@ -155,6 +160,13 @@ class ResumeCtrlImpl : public ResumeCtrl,
void StopSavePersistentDataTimer() OVERRIDE;
/**
+ * @brief Check if all IGNITION OFF and IGNITION ON records
+ * saved in resumption data base
+ * @return True if all records saved, otherwise False
+ */
+ bool CheckIgnCyclesData() const;
+
+ /**
* @brief Method stops restore_hmi_level_timer_ "RsmCtrlRstore" in OnSuspend()
*/
void StopRestoreHmiLevelTimer();
@@ -300,7 +312,7 @@ class ResumeCtrlImpl : public ResumeCtrl,
* @brief Method starts timer "RsmCtrlPercist" when
* SDL receives onAwakeSDL notification
*/
- void StartSavePersistentDataTimer();
+ void StartSavePersistentDataTimer() OVERRIDE;
#ifdef BUILD_TESTS
void set_resumption_storage(
@@ -310,6 +322,20 @@ class ResumeCtrlImpl : public ResumeCtrl,
#endif // BUILD_TESTS
private:
/**
+ * @brief Returns Low Voltage signal timestamp
+ * @return Low Voltage event timestamp if event LOW VOLTAGE event occures
+ * otherwise 0
+ */
+ time_t LowVoltageTime() const;
+
+ /**
+ * @brief Returns Wake Up signal timestamp
+ * @return Wake Up timestamp if Wake Up signal occures
+ * otherwise 0
+ */
+ time_t WakeUpTime() const;
+
+ /**
* @brief restores saved data of application
* @param application contains application for which restores data
* @return true if success, otherwise return false
@@ -390,11 +416,27 @@ class ResumeCtrlImpl : public ResumeCtrl,
void AddWayPointsSubscription(app_mngr::ApplicationSharedPtr application,
const smart_objects::SmartObject& saved_app);
+ /**
+ * @brief Checks if saved HMI level is allowed for resumption
+ * by Ignition Cycle restrictions
+ * @param saved_app application specific section from backup file
+ * @return True if allowed , otherwise - False
+ */
bool CheckIgnCycleRestrictions(const smart_objects::SmartObject& saved_app);
- bool DisconnectedJustBeforeIgnOff(
- const smart_objects::SmartObject& saved_app);
+ /**
+ * @brief Checks if saved HMI level is allowed for resumption
+ * by Low Voltage restrictions
+ * @param saved_app application specific section from backup file
+ * @return True if allowed , otherwise - False
+ */
+ bool CheckLowVoltageRestrictions(const smart_objects::SmartObject& saved_app);
+ /**
+ * @brief Checks if saved HMI level is applicable for resumption
+ * @param saved_app application specific section from backup file
+ * @return True fs allowed , otherwise - False
+ */
bool CheckAppRestrictions(app_mngr::ApplicationConstSharedPtr application,
const smart_objects::SmartObject& saved_app);
@@ -409,10 +451,38 @@ class ResumeCtrlImpl : public ResumeCtrl,
/**
* @brief CheckDelayAfterIgnOn should check if SDL was started less
- * then N seconds ago. N will be readed from profile.
+ * than N seconds ago. N will be read from profile.
* @return true if SDL started N seconds ago, otherwise return false
*/
- bool CheckDelayAfterIgnOn();
+ bool CheckDelayAfterIgnOn() const;
+
+ /**
+ * @brief CheckDelayBeforeIgnOff checks if app was unregistered less
+ * than N seconds before Ignition OFF. N will be read from profile.
+ * @return true if app was disconnected within timeframe of N seconds before
+ * Ignition Off,
+ * otherwise return false
+ */
+ bool CheckDelayBeforeIgnOff(
+ const smart_objects::SmartObject& saved_app) const;
+
+ /**
+ * @brief CheckDelayAfterWakeUp should check if app was registered
+ * during the first N seconds after WakeUp signal. N will be read from
+ * profile.
+ * @return true if app registered within N seconds after WakeUp, otherwise
+ * return false
+ */
+ bool CheckDelayAfterWakeUp() const;
+
+ /**
+ * @brief CheckDelayBeforeLowVoltage checks if app was unregistered within
+ * N seconds before Low Voltage signal. N will be read from profile.
+ * @return true if app was disconnected within timeframe of N seconds before
+ * Low Voltage , otherwise return false
+ */
+ bool CheckDelayBeforeLowVoltage(
+ const smart_objects::SmartObject& saved_app) const;
typedef std::pair<uint32_t, uint32_t> application_timestamp;
@@ -447,7 +517,7 @@ class ResumeCtrlImpl : public ResumeCtrl,
* @brief Get the last ignition off time from LastState
* @return the last ignition off time from LastState
*/
- time_t GetIgnOffTime();
+ time_t GetIgnOffTime() const;
/**
* @brief Setup IgnOff time to LastState
@@ -535,6 +605,8 @@ class ResumeCtrlImpl : public ResumeCtrl,
bool is_data_saved_;
bool is_suspended_;
time_t launch_time_;
+ time_t low_voltage_time_;
+ time_t wake_up_time_;
std::shared_ptr<ResumptionData> resumption_storage_;
application_manager::ApplicationManager& application_manager_;
};
diff --git a/src/components/application_manager/include/application_manager/resumption/resumption_data.h b/src/components/application_manager/include/application_manager/resumption/resumption_data.h
index 5ecfaf3c11..c2634173a5 100644
--- a/src/components/application_manager/include/application_manager/resumption/resumption_data.h
+++ b/src/components/application_manager/include/application_manager/resumption/resumption_data.h
@@ -95,20 +95,26 @@ class ResumptionData {
virtual void IncrementIgnOffCount() = 0;
/**
- * @brief Increments ignition counter for all registered applications
- * and remember ign_off time stamp
+ * @brief Decrements ignition counter for all registered applications
*/
- DEPRECATED virtual void OnSuspend() = 0;
+ virtual void DecrementIgnOffCount() = 0;
/**
- * @brief Decrements ignition counter for all registered applications
+ * @brief Increments global ignition on counter
+ * by 1
*/
- virtual void DecrementIgnOffCount() = 0;
+ virtual void IncrementGlobalIgnOnCounter() = 0;
/**
- * @brief Decrements ignition counter for all registered applications
+ * @brief Get the global ignition on counter
+ * @return the global ignition on counter
+ */
+ virtual uint32_t GetGlobalIgnOnCounter() const = 0;
+
+ /**
+ * @brief Resets global ignition on counter
*/
- DEPRECATED virtual void OnAwake() = 0;
+ virtual void ResetGlobalIgnOnCount() = 0;
/**
* @brief Retrieves hash ID for the given mobile app ID
diff --git a/src/components/application_manager/include/application_manager/resumption/resumption_data_db.h b/src/components/application_manager/include/application_manager/resumption/resumption_data_db.h
index 780aac82c1..2b5a1fdcc9 100644
--- a/src/components/application_manager/include/application_manager/resumption/resumption_data_db.h
+++ b/src/components/application_manager/include/application_manager/resumption/resumption_data_db.h
@@ -110,16 +110,11 @@ class ResumptionDataDB : public ResumptionData {
virtual uint32_t GetHMIApplicationID(const std::string& policy_app_id,
const std::string& device_id) const;
- /**
- * @brief Increments ignition counter for all registered applications
- * and remember ign_off time stamp
- */
- DEPRECATED void OnSuspend() FINAL;
+ void IncrementGlobalIgnOnCounter() OVERRIDE;
- /**
- * @brief Decrements ignition counter for all registered applications
- */
- DEPRECATED void OnAwake() FINAL;
+ uint32_t GetGlobalIgnOnCounter() const OVERRIDE;
+
+ void ResetGlobalIgnOnCount() OVERRIDE;
/**
* @brief Increments ignition counter for all registered applications
diff --git a/src/components/application_manager/include/application_manager/resumption/resumption_data_json.h b/src/components/application_manager/include/application_manager/resumption/resumption_data_json.h
index 82ec1d9e5c..e2418fd033 100644
--- a/src/components/application_manager/include/application_manager/resumption/resumption_data_json.h
+++ b/src/components/application_manager/include/application_manager/resumption/resumption_data_json.h
@@ -80,18 +80,6 @@ class ResumptionDataJson : public ResumptionData {
*/
virtual uint32_t GetHMIApplicationID(const std::string& policy_app_id,
const std::string& device_id) const;
-
- /**
- * @brief Increments ignition counter for all registered applications
- * and remember ign_off time stamp
- */
- DEPRECATED void OnSuspend() FINAL;
-
- /**
- * @brief Decrements ignition counter for all registered applications
- */
- DEPRECATED void OnAwake() FINAL;
-
/**
* @brief Increments ignition counter for all registered applications
* and remember ign_off time stamp
@@ -145,6 +133,12 @@ class ResumptionDataJson : public ResumptionData {
*/
virtual uint32_t GetIgnOffTime() const;
+ void IncrementGlobalIgnOnCounter() OVERRIDE;
+
+ uint32_t GetGlobalIgnOnCounter() const OVERRIDE;
+
+ void ResetGlobalIgnOnCount() OVERRIDE;
+
/**
* @brief Checks if saved data have application
* @param policy_app_id - mobile application id
diff --git a/src/components/application_manager/include/application_manager/resumption/resumption_sql_queries.h b/src/components/application_manager/include/application_manager/resumption/resumption_sql_queries.h
index 33d62740f7..eee7650697 100644
--- a/src/components/application_manager/include/application_manager/resumption/resumption_sql_queries.h
+++ b/src/components/application_manager/include/application_manager/resumption/resumption_sql_queries.h
@@ -57,7 +57,10 @@ extern const std::string kUpdateIgnOffCount;
extern const std::string kCountApplicationsIgnOff;
extern const std::string kSelectApplicationsIgnOffCount;
extern const std::string kUpdateSuspendData;
-extern const std::string KUpdateLastIgnOffTime;
+extern const std::string kUpdateLastIgnOffTime;
+extern const std::string kUpdateGlobalIgnOnCount;
+extern const std::string kResetGlobalIgnOnCount;
+extern const std::string kSelectGlobalIgnOnCounter;
extern const std::string kDeleteFile;
extern const std::string kDeleteApplicationFilesArray;
extern const std::string kDeleteSubMenu;
diff --git a/src/components/application_manager/include/application_manager/rpc_handler_impl.h b/src/components/application_manager/include/application_manager/rpc_handler_impl.h
index 44954d41f7..8f1d454c3b 100644
--- a/src/components/application_manager/include/application_manager/rpc_handler_impl.h
+++ b/src/components/application_manager/include/application_manager/rpc_handler_impl.h
@@ -57,6 +57,7 @@
#include "interfaces/v4_protocol_v1_2_no_extra_schema.h"
#include "utils/threads/message_loop_thread.h"
+#include "utils/semantic_version.h"
namespace application_manager {
namespace rpc_handler {
@@ -142,6 +143,16 @@ class RPCHandlerImpl : public RPCHandler,
void SetTelemetryObserver(AMTelemetryObserver* observer) OVERRIDE;
#endif // TELEMETRY_MONITOR
+ /**
+ * @brief Extracts and validates the syncMsgVersion included in
+ * a RegisterAppInterfaceRequest
+ *
+ * @param output - SmartObject Message received from mobile
+ * @param messageVersion - message version to be updated
+ */
+ void GetMessageVersion(NsSmartDeviceLink::NsSmartObjects::SmartObject& output,
+ utils::SemanticVersion& message_version);
+
private:
void ProcessMessageFromMobile(const std::shared_ptr<Message> message);
void ProcessMessageFromHMI(const std::shared_ptr<Message> message);
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 d0a3c1ed96..4646ef5e8f 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
@@ -313,6 +313,8 @@ extern const char* resume_vr_grammars;
extern const char* ign_off_count;
+extern const char* global_ign_on_counter;
+
extern const char* connection_info;
extern const char* is_download_complete;
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_button_press_request.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_button_press_request.h
index fc3721e763..3bc34be8d1 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_button_press_request.h
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_button_press_request.h
@@ -30,19 +30,20 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_HMI_RC_BUTTON_PRESS_REQUEST_H
-#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_HMI_RC_BUTTON_PRESS_REQUEST_H
+#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_HMI_RC_BUTTON_PRESS_REQUEST_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_HMI_RC_BUTTON_PRESS_REQUEST_H_
#include "application_manager/commands/request_to_hmi.h"
+#include "rc_rpc_plugin/commands/rc_command_request.h"
#include "rc_rpc_plugin/resource_allocation_manager.h"
+#include "rc_rpc_plugin/interior_data_cache.h"
#include "utils/macro.h"
namespace rc_rpc_plugin {
namespace app_mngr = application_manager;
namespace commands {
-class RCButtonPressRequest
- : public application_manager::commands::RequestToHMI {
+class RCButtonPressRequest : public app_mngr::commands::RequestToHMI {
public:
/**
* @brief RCButtonPressRequest class constructor
@@ -54,11 +55,7 @@ class RCButtonPressRequest
* @param resource_allocation_manager ResourceAllocationManager
**/
RCButtonPressRequest(const app_mngr::commands::MessageSharedPtr& message,
- app_mngr::ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handle,
- ResourceAllocationManager& resource_allocation_manager);
+ const RCCommandParams& params);
/**
* @brief Execute command
*/
@@ -68,4 +65,4 @@ class RCButtonPressRequest
} // namespace commands
} // namespace rc_rpc_plugin
-#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_HMI_RC_BUTTON_PRESS_REQUEST_H
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_HMI_RC_BUTTON_PRESS_REQUEST_H_
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_button_press_response.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_button_press_response.h
index c16f4de0cc..939d5fa468 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_button_press_response.h
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_button_press_response.h
@@ -30,11 +30,13 @@
POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_HMI_RC_BUTTON_PRESS_RESPONSE_H
-#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_HMI_RC_BUTTON_PRESS_RESPONSE_H
+#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_HMI_RC_BUTTON_PRESS_RESPONSE_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_HMI_RC_BUTTON_PRESS_RESPONSE_H_
#include "application_manager/commands/response_from_hmi.h"
+#include "rc_rpc_plugin/commands/rc_command_request.h"
#include "rc_rpc_plugin/resource_allocation_manager.h"
+#include "rc_rpc_plugin/interior_data_cache.h"
#include "utils/macro.h"
namespace rc_rpc_plugin {
@@ -54,11 +56,7 @@ class RCButtonPressResponse
* @param resource_allocation_manager ResourceAllocationManager
**/
RCButtonPressResponse(const app_mngr::commands::MessageSharedPtr& message,
- app_mngr::ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handle,
- ResourceAllocationManager& resource_allocation_manager);
+ const RCCommandParams& params);
void Run() OVERRIDE;
@@ -67,4 +65,4 @@ class RCButtonPressResponse
} // namespace commands
} // namespace rc_rpc_plugin
-#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_HMI_RC_BUTTON_PRESS_RESPONSE_H
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_HMI_RC_BUTTON_PRESS_RESPONSE_H_
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_consent_request.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_consent_request.h
index fc2e0d6536..97df5e8390 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_consent_request.h
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_consent_request.h
@@ -34,7 +34,9 @@
#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_HMI_RC_GET_INTERIOR_VEHICLE_DATA_CONSENT_REQUEST_H_
#include "application_manager/commands/request_to_hmi.h"
+#include "rc_rpc_plugin/commands/rc_command_request.h"
#include "rc_rpc_plugin/resource_allocation_manager.h"
+#include "rc_rpc_plugin/interior_data_cache.h"
#include "utils/macro.h"
namespace rc_rpc_plugin {
@@ -45,12 +47,8 @@ class RCGetInteriorVehicleDataConsentRequest
: public application_manager::commands::RequestToHMI {
public:
RCGetInteriorVehicleDataConsentRequest(
- const app_mngr::commands::MessageSharedPtr& message,
- app_mngr::ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handle,
- ResourceAllocationManager& resource_allocation_manager);
+ const application_manager::commands::MessageSharedPtr& message,
+ const RCCommandParams& params);
void Run() OVERRIDE;
~RCGetInteriorVehicleDataConsentRequest();
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_consent_response.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_consent_response.h
index a037d33d5a..46232987a5 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_consent_response.h
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_consent_response.h
@@ -34,7 +34,9 @@
#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_HMI_RC_GET_INTERIOR_VEHICLE_DATA_CONSENT_RESPONSE_H_
#include "application_manager/commands/response_from_hmi.h"
+#include "rc_rpc_plugin/commands/rc_command_request.h"
#include "rc_rpc_plugin/resource_allocation_manager.h"
+#include "rc_rpc_plugin/interior_data_cache.h"
#include "utils/macro.h"
namespace rc_rpc_plugin {
@@ -54,12 +56,8 @@ class RCGetInteriorVehicleDataConsentResponse
* @param resource_allocation_manager ResourceAllocationManager
**/
RCGetInteriorVehicleDataConsentResponse(
- const app_mngr::commands::MessageSharedPtr& message,
- app_mngr::ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handle,
- ResourceAllocationManager& resource_allocation_manager);
+ const application_manager::commands::MessageSharedPtr& message,
+ const RCCommandParams& params);
void Run() OVERRIDE;
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_request.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_request.h
index 9f7b1211b7..a88a39aa7a 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_request.h
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_request.h
@@ -34,7 +34,9 @@
#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_HMI_RC_GET_INTERIOR_VEHICLE_DATA_REQUEST_H_
#include "application_manager/commands/request_to_hmi.h"
+#include "rc_rpc_plugin/commands/rc_command_request.h"
#include "rc_rpc_plugin/resource_allocation_manager.h"
+#include "rc_rpc_plugin/interior_data_cache.h"
#include "utils/macro.h"
namespace rc_rpc_plugin {
@@ -45,12 +47,8 @@ class RCGetInteriorVehicleDataRequest
: public application_manager::commands::RequestToHMI {
public:
RCGetInteriorVehicleDataRequest(
- const app_mngr::commands::MessageSharedPtr& message,
- app_mngr::ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handle,
- ResourceAllocationManager& resource_allocation_manager);
+ const application_manager::commands::MessageSharedPtr& message,
+ const RCCommandParams& params);
void Run() OVERRIDE;
~RCGetInteriorVehicleDataRequest();
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_response.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_response.h
index 28f9b4b9c7..c9e5d39d1d 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_response.h
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_response.h
@@ -34,7 +34,9 @@
#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_HMI_RC_GET_INTERIOR_VEHICLE_DATA_RESPONSE_H_
#include "application_manager/commands/response_from_hmi.h"
+#include "rc_rpc_plugin/commands/rc_command_request.h"
#include "rc_rpc_plugin/resource_allocation_manager.h"
+#include "rc_rpc_plugin/interior_data_cache.h"
#include "utils/macro.h"
namespace rc_rpc_plugin {
@@ -45,12 +47,8 @@ class RCGetInteriorVehicleDataResponse
: public application_manager::commands::ResponseFromHMI {
public:
RCGetInteriorVehicleDataResponse(
- const app_mngr::commands::MessageSharedPtr& message,
- app_mngr::ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handle,
- ResourceAllocationManager& resource_allocation_manager);
+ const application_manager::commands::MessageSharedPtr& message,
+ const RCCommandParams& params);
void Run() OVERRIDE;
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_on_interior_vehicle_data_notification.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_on_interior_vehicle_data_notification.h
index 0afa613c7c..aeb0a06d22 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_on_interior_vehicle_data_notification.h
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_on_interior_vehicle_data_notification.h
@@ -30,11 +30,13 @@
POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_HMI_RC_ON_INTERIOR_VEHICLE_DATA_NOTIFICATION_H
-#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_HMI_RC_ON_INTERIOR_VEHICLE_DATA_NOTIFICATION_H
+#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_HMI_RC_ON_INTERIOR_VEHICLE_DATA_NOTIFICATION_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_HMI_RC_ON_INTERIOR_VEHICLE_DATA_NOTIFICATION_H_
#include "application_manager/commands/notification_from_hmi.h"
+#include "rc_rpc_plugin/commands/rc_command_request.h"
#include "rc_rpc_plugin/resource_allocation_manager.h"
+#include "rc_rpc_plugin/interior_data_cache.h"
#include "utils/macro.h"
namespace rc_rpc_plugin {
@@ -54,12 +56,8 @@ class RCOnInteriorVehicleDataNotification
* @param resource_allocation_manager ResourceAllocationManager
**/
RCOnInteriorVehicleDataNotification(
- const app_mngr::commands::MessageSharedPtr& message,
- app_mngr::ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handle,
- ResourceAllocationManager& resource_allocation_manager);
+ const application_manager::commands::MessageSharedPtr& message,
+ const RCCommandParams& params);
~RCOnInteriorVehicleDataNotification();
@@ -71,4 +69,4 @@ class RCOnInteriorVehicleDataNotification
} // namespace commands
} // namespace rc_rpc_plugin
-#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_HMI_RC_ON_INTERIOR_VEHICLE_DATA_NOTIFICATION_H
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_HMI_RC_ON_INTERIOR_VEHICLE_DATA_NOTIFICATION_H_
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_on_remote_control_settings_notification.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_on_remote_control_settings_notification.h
index b9ab821176..7aa1aa3dba 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_on_remote_control_settings_notification.h
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_on_remote_control_settings_notification.h
@@ -30,15 +30,18 @@
POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_HMI_RC_ON_REMOTE_CONTROL_SETTINGS_NOTIFICATION_H
-#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_HMI_RC_ON_REMOTE_CONTROL_SETTINGS_NOTIFICATION_H
+#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_HMI_RC_ON_REMOTE_CONTROL_SETTINGS_NOTIFICATION_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_HMI_RC_ON_REMOTE_CONTROL_SETTINGS_NOTIFICATION_H_
#include "application_manager/commands/notification_from_hmi.h"
+#include "rc_rpc_plugin/commands/rc_command_request.h"
+#include "rc_rpc_plugin/interior_data_cache.h"
#include "rc_rpc_plugin/resource_allocation_manager.h"
#include "utils/macro.h"
namespace rc_rpc_plugin {
namespace app_mngr = application_manager;
+class InteriorDataManager;
namespace commands {
class RCOnRemoteControlSettingsNotification
@@ -54,12 +57,8 @@ class RCOnRemoteControlSettingsNotification
* @param resource_allocation_manager ResourceAllocationManager
**/
RCOnRemoteControlSettingsNotification(
- const app_mngr::commands::MessageSharedPtr& message,
- app_mngr::ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handle,
- rc_rpc_plugin::ResourceAllocationManager& resource_allocation_manager);
+ const application_manager::commands::MessageSharedPtr& message,
+ const RCCommandParams& params);
/**
* @brief Execute command
**/
@@ -69,7 +68,7 @@ class RCOnRemoteControlSettingsNotification
private:
ResourceAllocationManager& resource_allocation_manager_;
-
+ InteriorDataManager& interior_data_manager_;
/**
* @brief Disalows RC functionality for all RC apps
* All registered apps will be unsubsribed from OnInteriorVehicleData
@@ -80,4 +79,4 @@ class RCOnRemoteControlSettingsNotification
} // namespace commands
} // namespace rc_rpc_plugin
-#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_HMI_RC_ON_REMOTE_CONTROL_SETTINGS_NOTIFICATION_H
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_HMI_RC_ON_REMOTE_CONTROL_SETTINGS_NOTIFICATION_H_
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_set_interior_vehicle_data_request.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_set_interior_vehicle_data_request.h
index 194b423b1a..69b48bfecf 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_set_interior_vehicle_data_request.h
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_set_interior_vehicle_data_request.h
@@ -34,7 +34,9 @@
#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_HMI_RC_SET_INTERIOR_VEHICLE_DATA_REQUEST_H_
#include "application_manager/commands/request_to_hmi.h"
+#include "rc_rpc_plugin/commands/rc_command_request.h"
#include "rc_rpc_plugin/resource_allocation_manager.h"
+#include "rc_rpc_plugin/interior_data_cache.h"
#include "utils/macro.h"
namespace rc_rpc_plugin {
@@ -54,12 +56,8 @@ class RCSetInteriorVehicleDataRequest
* @param resource_allocation_manager ResourceAllocationManager
**/
RCSetInteriorVehicleDataRequest(
- const app_mngr::commands::MessageSharedPtr& message,
- app_mngr::ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handle,
- ResourceAllocationManager& resource_allocation_manager);
+ const application_manager::commands::MessageSharedPtr& message,
+ const RCCommandParams& params);
void Run() OVERRIDE;
~RCSetInteriorVehicleDataRequest();
};
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_set_interior_vehicle_data_response.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_set_interior_vehicle_data_response.h
index f23acda4d4..8a63503220 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_set_interior_vehicle_data_response.h
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_set_interior_vehicle_data_response.h
@@ -30,11 +30,13 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_HMI_SET_INTERIOR_VEHICLE_DATA_RESPONSE_H
-#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_HMI_SET_INTERIOR_VEHICLE_DATA_RESPONSE_H
+#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_HMI_RC_SET_INTERIOR_VEHICLE_DATA_RESPONSE_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_HMI_RC_SET_INTERIOR_VEHICLE_DATA_RESPONSE_H_
#include "application_manager/commands/response_from_hmi.h"
+#include "rc_rpc_plugin/commands/rc_command_request.h"
#include "rc_rpc_plugin/resource_allocation_manager.h"
+#include "rc_rpc_plugin/interior_data_cache.h"
#include "utils/macro.h"
namespace rc_rpc_plugin {
@@ -54,12 +56,8 @@ class RCSetInteriorVehicleDataResponse
* @param resource_allocation_manager ResourceAllocationManager
**/
RCSetInteriorVehicleDataResponse(
- const app_mngr::commands::MessageSharedPtr& message,
- app_mngr::ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handle,
- ResourceAllocationManager& resource_allocation_manager);
+ const application_manager::commands::MessageSharedPtr& message,
+ const RCCommandParams& params);
void Run() OVERRIDE;
@@ -68,4 +66,4 @@ class RCSetInteriorVehicleDataResponse
} // namespace commands
} // namespace rc_rpc_plugin
-#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_HMI_SET_INTERIOR_VEHICLE_DATA_RESPONSE_H
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_HMI_RC_SET_INTERIOR_VEHICLE_DATA_RESPONSE_H_
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/button_press_request.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/button_press_request.h
index fa89c10bf9..d6ecfd0128 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/button_press_request.h
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/button_press_request.h
@@ -30,8 +30,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_BUTTON_PRESS_REQUEST_H
-#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_BUTTON_PRESS_REQUEST_H
+#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_BUTTON_PRESS_REQUEST_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_BUTTON_PRESS_REQUEST_H_
#include "rc_rpc_plugin/commands/rc_command_request.h"
@@ -41,12 +41,9 @@ namespace app_mngr = application_manager;
namespace commands {
class ButtonPressRequest : public RCCommandRequest {
public:
- ButtonPressRequest(const app_mngr::commands::MessageSharedPtr& message,
- app_mngr::ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handle,
- ResourceAllocationManager& resource_allocation_manager);
+ ButtonPressRequest(
+ const application_manager::commands::MessageSharedPtr& message,
+ const RCCommandParams& params);
/**
* @brief Execute command
@@ -96,4 +93,4 @@ class ButtonPressRequest : public RCCommandRequest {
} // namespace commands
} // namespace rc_rpc_plugin
-#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_BUTTON_PRESS_REQUEST_H
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_BUTTON_PRESS_REQUEST_H_
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/button_press_response.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/button_press_response.h
index 16d7b0e3fe..0f3964494e 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/button_press_response.h
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/button_press_response.h
@@ -30,11 +30,13 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_BUTTON_PRESS_RESPONSE_H
-#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_BUTTON_PRESS_RESPONSE_H
+#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_BUTTON_PRESS_RESPONSE_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_BUTTON_PRESS_RESPONSE_H_
#include "application_manager/commands/command_response_impl.h"
#include "rc_rpc_plugin/resource_allocation_manager.h"
+#include "rc_rpc_plugin/commands/rc_command_request.h"
+#include "rc_rpc_plugin/interior_data_cache.h"
#include "utils/macro.h"
namespace rc_rpc_plugin {
@@ -44,12 +46,9 @@ namespace commands {
class ButtonPressResponse
: public application_manager::commands::CommandResponseImpl {
public:
- ButtonPressResponse(const app_mngr::commands::MessageSharedPtr& message,
- app_mngr::ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handle,
- ResourceAllocationManager& resource_allocation_manager);
+ ButtonPressResponse(
+ const application_manager::commands::MessageSharedPtr& message,
+ const RCCommandParams& params);
void Run() OVERRIDE;
/**
* @brief ButtonPressResponse class destructor
@@ -59,4 +58,4 @@ class ButtonPressResponse
} // namespace commands
} // namespace rc_rpc_plugin
-#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_BUTTON_PRESS_RESPONSE_H
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_BUTTON_PRESS_RESPONSE_H_
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_request.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_request.h
index c2ae0e887f..4624d79b56 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_request.h
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_request.h
@@ -43,12 +43,8 @@ namespace commands {
class GetInteriorVehicleDataRequest : public RCCommandRequest {
public:
GetInteriorVehicleDataRequest(
- const app_mngr::commands::MessageSharedPtr& message,
- app_mngr::ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handle,
- ResourceAllocationManager& resource_allocation_manager);
+ const application_manager::commands::MessageSharedPtr& message,
+ const RCCommandParams& params);
/**
* @brief Execute command
*/
@@ -67,6 +63,9 @@ class GetInteriorVehicleDataRequest : public RCCommandRequest {
~GetInteriorVehicleDataRequest();
private:
+ std::vector<application_manager::ApplicationSharedPtr>
+ AppsSubscribedToModuleType(const std::string& module_type);
+
/**
* @brief Check if app wants to proceed with already setup subscription
* @param request_params request parameters to check
@@ -80,8 +79,7 @@ class GetInteriorVehicleDataRequest : public RCCommandRequest {
* @brief Handle subscription to vehicle data
* @param hmi_response json message with response from HMI
*/
- void ProccessSubscription(
- const NsSmartDeviceLink::NsSmartObjects::SmartObject& hmi_response);
+ void ProccessSubscription(const smart_objects::SmartObject& hmi_response);
/**
* @brief Cuts off subscribe parameter
@@ -91,6 +89,11 @@ class GetInteriorVehicleDataRequest : public RCCommandRequest {
std::string ModuleType() FINAL;
bool excessive_subscription_occured_;
+ bool ProcessCapabilities();
+ void ProcessResponseToMobileFromCache(app_mngr::ApplicationSharedPtr app);
+ bool CheckRateLimits();
+ bool AppShouldBeUnsubscribed();
+ bool TheLastAppShouldBeUnsubscribed(app_mngr::ApplicationSharedPtr app);
};
} // namespace commands
} // namespace rc_rpc_plugin
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_response.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_response.h
index 78148ab7df..bf8208edc2 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_response.h
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_response.h
@@ -30,11 +30,13 @@
POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_GET_INTERIOR_VEHICLE_DATA_RESPONSE_H
-#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_GET_INTERIOR_VEHICLE_DATA_RESPONSE_H
+#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_GET_INTERIOR_VEHICLE_DATA_RESPONSE_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_GET_INTERIOR_VEHICLE_DATA_RESPONSE_H_
#include "application_manager/commands/command_response_impl.h"
+#include "rc_rpc_plugin/commands/rc_command_request.h"
#include "rc_rpc_plugin/resource_allocation_manager.h"
+#include "rc_rpc_plugin/interior_data_cache.h"
#include "utils/macro.h"
namespace rc_rpc_plugin {
@@ -45,12 +47,8 @@ class GetInteriorVehicleDataResponse
: public application_manager::commands::CommandResponseImpl {
public:
GetInteriorVehicleDataResponse(
- const app_mngr::commands::MessageSharedPtr& message,
- app_mngr::ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handle,
- ResourceAllocationManager& resource_allocation_manager);
+ const application_manager::commands::MessageSharedPtr& message,
+ const RCCommandParams& params);
void Run() OVERRIDE;
@@ -59,4 +57,4 @@ class GetInteriorVehicleDataResponse
} // namespace commands
} // namespace rc_rpc_plugin
-#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_GET_INTERIOR_VEHICLE_DATA_RESPONSE_H
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_GET_INTERIOR_VEHICLE_DATA_RESPONSE_H_
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/on_interior_vehicle_data_notification.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/on_interior_vehicle_data_notification.h
index 20a7e69868..931e79366c 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/on_interior_vehicle_data_notification.h
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/on_interior_vehicle_data_notification.h
@@ -36,6 +36,8 @@
#include <string>
#include "application_manager/commands/command_notification_impl.h"
#include "rc_rpc_plugin/resource_allocation_manager.h"
+#include "rc_rpc_plugin/interior_data_cache.h"
+#include "rc_rpc_plugin/commands/rc_command_request.h"
#include "utils/macro.h"
namespace rc_rpc_plugin {
@@ -46,18 +48,18 @@ class OnInteriorVehicleDataNotification
: public application_manager::commands::CommandNotificationImpl {
public:
OnInteriorVehicleDataNotification(
- const app_mngr::commands::MessageSharedPtr& message,
- app_mngr::ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handler,
- ResourceAllocationManager& resource_allocation_manager);
+ const application_manager::commands::MessageSharedPtr& message,
+ const RCCommandParams& params);
void Run() OVERRIDE;
std::string ModuleType();
~OnInteriorVehicleDataNotification();
+
+ private:
+ InteriorDataCache& interior_data_cache_;
+ void AddDataToCache(const std::string& module_type);
};
} // namespace commands
} // namespace rc_rpc_plugin
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_request.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_request.h
index 83a8dfdd75..d5de4981c6 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_request.h
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_request.h
@@ -30,8 +30,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_SET_INTERIOR_VEHICLE_DATA_REQUEST_H
-#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_SET_INTERIOR_VEHICLE_DATA_REQUEST_H
+#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_SET_INTERIOR_VEHICLE_DATA_REQUEST_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_SET_INTERIOR_VEHICLE_DATA_REQUEST_H_
#include "rc_rpc_plugin/commands/rc_command_request.h"
@@ -42,12 +42,8 @@ namespace commands {
class SetInteriorVehicleDataRequest : public RCCommandRequest {
public:
SetInteriorVehicleDataRequest(
- const app_mngr::commands::MessageSharedPtr& message,
- app_mngr::ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handle,
- rc_rpc_plugin::ResourceAllocationManager& resource_allocation_manager);
+ const application_manager::commands::MessageSharedPtr& message,
+ const RCCommandParams& params);
/**
* @brief Execute command
@@ -118,8 +114,17 @@ class SetInteriorVehicleDataRequest : public RCCommandRequest {
*/
const smart_objects::SmartObject& ControlData(
const smart_objects::SmartObject& module_data);
+
+ /**
+ * @brief CheckAudioSource check that if app wants to change
+ * the audio source from MOBILE_APP to other types of audio
+ * source without keepContext parameter or with keepContext=false
+ * then this app will go to HMI level 'BACKGROUND'
+ * @param module_data received params
+ */
+ void CheckAudioSource(const smart_objects::SmartObject& audio_data);
};
} // namespace commands
} // namespace rc_rpc_plugin
-#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_SET_INTERIOR_VEHICLE_DATA_REQUEST_H
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_SET_INTERIOR_VEHICLE_DATA_REQUEST_H_
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_response.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_response.h
index 5661a57c07..1ab5ccc6bc 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_response.h
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_response.h
@@ -30,11 +30,13 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_SET_INTERIOR_VEHICLE_DATA_RESPONSE_H
-#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_SET_INTERIOR_VEHICLE_DATA_RESPONSE_H
+#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_SET_INTERIOR_VEHICLE_DATA_RESPONSE_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_SET_INTERIOR_VEHICLE_DATA_RESPONSE_H_
#include "application_manager/commands/command_response_impl.h"
#include "rc_rpc_plugin/resource_allocation_manager.h"
+#include "rc_rpc_plugin/interior_data_cache.h"
+#include "rc_rpc_plugin/commands/rc_command_request.h"
#include "utils/macro.h"
namespace rc_rpc_plugin {
@@ -45,12 +47,8 @@ class SetInteriorVehicleDataResponse
: public application_manager::commands::CommandResponseImpl {
public:
SetInteriorVehicleDataResponse(
- const app_mngr::commands::MessageSharedPtr& message,
- app_mngr::ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handle,
- ResourceAllocationManager& resource_allocation_manager);
+ const application_manager::commands::MessageSharedPtr& message,
+ const RCCommandParams& params);
void Run() OVERRIDE;
@@ -59,4 +57,4 @@ class SetInteriorVehicleDataResponse
} // namespace commands
} // namespace rc_rpc_plugin
-#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_SET_INTERIOR_VEHICLE_DATA_RESPONSE_H
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_SET_INTERIOR_VEHICLE_DATA_RESPONSE_H_
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/rc_command_params.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/rc_command_params.h
new file mode 100644
index 0000000000..8e7ed9c667
--- /dev/null
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/rc_command_params.h
@@ -0,0 +1,64 @@
+/*
+ Copyright (c) 2018, Ford Motor Company
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided with the
+ distribution.
+
+ Neither the name of the Ford Motor Company nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_RC_COMMAND_PARAMS_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_RC_COMMAND_PARAMS_H_
+
+namespace application_manager {
+class ApplicationManager;
+namespace rpc_service {
+class RPCService;
+}
+class HMICapabilities;
+}
+
+namespace policy {
+class PolicyHandlerInterface;
+}
+
+namespace rc_rpc_plugin {
+
+class ResourceAllocationManager;
+class InteriorDataCache;
+class InteriorDataManager;
+
+struct RCCommandParams {
+ application_manager::ApplicationManager& application_manager_;
+ application_manager::rpc_service::RPCService& rpc_service_;
+ application_manager::HMICapabilities& hmi_capabilities_;
+ policy::PolicyHandlerInterface& policy_handler_;
+ rc_rpc_plugin::ResourceAllocationManager& resource_allocation_manager_;
+ rc_rpc_plugin::InteriorDataCache& interior_data_cache_;
+ rc_rpc_plugin::InteriorDataManager& interior_data_manager_;
+};
+}
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_RC_COMMAND_PARAMS_H_
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/rc_command_request.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/rc_command_request.h
index 7c5e6f0ebc..ce95617b6c 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/rc_command_request.h
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/rc_command_request.h
@@ -30,12 +30,14 @@
POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_RC_COMMAND_REQUEST_H
-#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_RC_COMMAND_REQUEST_H
+#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_RC_COMMAND_REQUEST_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_RC_COMMAND_REQUEST_H_
#include "rc_rpc_plugin/resource_allocation_manager.h"
#include "rc_rpc_plugin/rc_app_extension.h"
#include "application_manager/commands/command_request_impl.h"
+#include "rc_rpc_plugin/interior_data_cache.h"
+#include "rc_rpc_plugin/commands/rc_command_params.h"
namespace rc_rpc_plugin {
namespace app_mngr = application_manager;
@@ -56,12 +58,8 @@ class RCCommandRequest : public app_mngr::commands::CommandRequestImpl {
* @param resource_allocation_manager ResourceAllocationManager
**/
RCCommandRequest(
- const app_mngr::commands::MessageSharedPtr& message,
- app_mngr::ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handl,
- rc_rpc_plugin::ResourceAllocationManager& resource_allocation_manager);
+ const application_manager::commands::MessageSharedPtr& message,
+ const RCCommandParams& params);
virtual ~RCCommandRequest();
@@ -73,9 +71,11 @@ class RCCommandRequest : public app_mngr::commands::CommandRequestImpl {
protected:
bool is_subscribed;
- ResourceAllocationManager& resource_allocation_manager_;
bool auto_allowed_;
+ ResourceAllocationManager& resource_allocation_manager_;
+ InteriorDataCache& interior_data_cache_;
+ InteriorDataManager& interior_data_manager_;
/**
* @brief AcquireResource try to allocate resource for application
* In case if allocation of resource is not required, return ALLOWED by
@@ -169,4 +169,4 @@ class RCCommandRequest : public app_mngr::commands::CommandRequestImpl {
}
}
-#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_RC_COMMAND_REQUEST_H
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_RC_COMMAND_REQUEST_H_
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/interior_data_cache.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/interior_data_cache.h
new file mode 100644
index 0000000000..f12566d14c
--- /dev/null
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/interior_data_cache.h
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2018, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_INTERIOR_DATA_CACHE_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_INTERIOR_DATA_CACHE_H_
+#include <string>
+#include "smart_objects/smart_object.h"
+
+namespace rc_rpc_plugin {
+
+/**
+ * @brief The InteriorDataCache interface for caching data class
+ * Provide ability to cache module data by module type name and clear cache
+ */
+class InteriorDataCache {
+ public:
+ /**
+ * @brief Add module data to cache
+ * @param module_type module type name
+ * @param module_data data to be cached
+ */
+ virtual void Add(const std::string& module_type,
+ const smart_objects::SmartObject& module_data) = 0;
+
+ /**
+ * @brief Retrieve Get cached data
+ * @param module_type data type to get from cache
+ * @return smart object with cached data, or nulll smart object
+ */
+ virtual smart_objects::SmartObject Retrieve(
+ const std::string& module_type) const = 0;
+
+ /**
+ * @brief Contains check if data exists in cache
+ * @param module_type module type name to check in cache
+ * @return true if cached, false otherwize
+ */
+ virtual bool Contains(const std::string& module_type) const = 0;
+
+ /**
+ * @brief Remove cached data
+ * @param module_type data type to remove from cache
+ */
+ virtual void Remove(const std::string& module_type) = 0;
+
+ /**
+ * @brief Clear clear all cached data
+ */
+ virtual void Clear() = 0;
+};
+} // rc_rpc_plugin
+
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_INTERIOR_DATA_CACHE_H_
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/interior_data_cache_impl.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/interior_data_cache_impl.h
new file mode 100644
index 0000000000..f2971e3d72
--- /dev/null
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/interior_data_cache_impl.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2018, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_INTERIOR_DATA_CACHE_IMPL_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_INTERIOR_DATA_CACHE_IMPL_H_
+
+#include <map>
+
+#include "utils/macro.h"
+#include "utils/lock.h"
+#include "rc_rpc_plugin/interior_data_cache.h"
+
+namespace rc_rpc_plugin {
+class InteriorDataCacheImpl : public InteriorDataCache {
+ public:
+ InteriorDataCacheImpl();
+
+ ~InteriorDataCacheImpl();
+
+ void Add(const std::string& module_type,
+ const smart_objects::SmartObject& module_data) OVERRIDE;
+ smart_objects::SmartObject Retrieve(
+ const std::string& module_type) const OVERRIDE;
+ bool Contains(const std::string& module_type) const OVERRIDE;
+ void Remove(const std::string& module_type) OVERRIDE;
+ void Clear() OVERRIDE;
+
+ private:
+ std::map<std::string, smart_objects::SmartObject> cached_data_;
+ mutable sync_primitives::Lock cached_data_lock_;
+};
+
+} // rc_rpc_plugin
+
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_INTERIOR_DATA_CACHE_IMPL_H_
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/interior_data_manager.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/interior_data_manager.h
new file mode 100644
index 0000000000..f28c388055
--- /dev/null
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/interior_data_manager.h
@@ -0,0 +1,86 @@
+/*
+ Copyright (c) 2018, Ford Motor Company
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided with the
+ distribution.
+
+ Neither the name of the Ford Motor Company nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_INTERIOR_DATA_MANAGER_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_INTERIOR_DATA_MANAGER_H_
+
+#include "application_manager/application.h"
+#include "application_manager/plugin_manager/rpc_plugin.h"
+
+namespace rc_rpc_plugin {
+
+namespace app_mngr = application_manager;
+namespace plugins = application_manager::plugin_manager;
+
+class InteriorDataManager {
+ public:
+ /**
+ * @brief OnPolicyEvent Processes policy related events
+ * @param event Policy event
+ */
+ virtual void OnPolicyEvent(app_mngr::plugin_manager::PolicyEvent event) = 0;
+
+ /**
+ * @brief OnApplicationEvent Notifies modules on certain application events
+ * @param event Event
+ * @param application Pointer to application struct
+ */
+ virtual void OnApplicationEvent(
+ plugins::ApplicationEvent event,
+ app_mngr::ApplicationSharedPtr application) = 0;
+
+ /**
+ * @brief OnDisablingRC process disable RC event. Unsubscribe from all modules
+ * and clear cache
+ */
+ virtual void OnDisablingRC() = 0;
+
+ /**
+ * @brief StoreRequestToHMITime save information and time stamp of
+ * current interior data subscriptions
+ */
+ virtual void StoreRequestToHMITime(const std::string& module_type) = 0;
+
+ /**
+ * @brief CheckRequestsToHMIFrequency check that rate limits are not allowed of
+ * bounce during current time frame.
+ * calculate amount of requests per module type in time frame and checks if it
+ * bigger then allowed by ini file
+ * @param module_type moduletype to calculate frequency on
+ * @return true if amount of requests was not exceeded, otherwise return false.
+ */
+ virtual bool CheckRequestsToHMIFrequency(const std::string& module_type) = 0;
+};
+
+} // namespace rc_rpc_plugin
+
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_INTERIOR_DATA_MANAGER_H_
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/interior_data_manager_impl.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/interior_data_manager_impl.h
new file mode 100644
index 0000000000..b36f47f260
--- /dev/null
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/interior_data_manager_impl.h
@@ -0,0 +1,122 @@
+/*
+ Copyright (c) 2018, Ford Motor Company
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided with the
+ distribution.
+
+ Neither the name of the Ford Motor Company nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_INTERIOR_DATA_MANAGER_IMPL_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_INTERIOR_DATA_MANAGER_IMPL_H_
+#include "rc_rpc_plugin/interior_data_manager.h"
+#include "utils/date_time.h"
+
+namespace application_manager {
+class ApplicationManager;
+namespace rpc_service {
+class RPCService;
+}
+}
+namespace rc_rpc_plugin {
+
+class InteriorDataCache;
+class RCRPCPlugin;
+
+class InteriorDataManagerImpl : public InteriorDataManager {
+ public:
+ InteriorDataManagerImpl(
+ RCRPCPlugin& rc_plugin,
+ InteriorDataCache& cache,
+ application_manager::ApplicationManager& app_mngr,
+ application_manager::rpc_service::RPCService& rpc_service);
+
+ void OnPolicyEvent(app_mngr::plugin_manager::PolicyEvent event) OVERRIDE;
+
+ void OnApplicationEvent(plugins::ApplicationEvent event,
+ app_mngr::ApplicationSharedPtr application) OVERRIDE;
+
+ void OnDisablingRC() OVERRIDE;
+
+ void StoreRequestToHMITime(const std::string& module_type) OVERRIDE;
+
+ bool CheckRequestsToHMIFrequency(const std::string& module_type) OVERRIDE;
+
+ private:
+ /**
+ * @brief UpdateHMISubscriptionsOnPolicyUpdated process policy update event.
+ * If some modules was disabeled by policies and there are no applications
+ * that subscribed to them - send RC.GetInteriorVehicleData(subscribe=false)
+ * and clear cache
+ */
+ void UpdateHMISubscriptionsOnPolicyUpdated();
+
+ /**
+ * @brief UpdateHMISubscriptionsOnAppUnregistered process AppUnregistered
+ * event and unsubscribed from not actual module types
+ * @param app application that was unregistered
+ */
+ void UpdateHMISubscriptionsOnAppUnregistered(
+ application_manager::Application& app);
+
+ /**
+ * @brief UnsubscribeFromInteriorVehicleData remove module_type from cache and
+ * send RC.GetInteriorVehicleData(subscribe=false) to HMI
+ * @param module_type module type that need to be unsubscribed
+ */
+ void UnsubscribeFromInteriorVehicleData(const std::string& module_type);
+
+ void ClearOldRequestsToHMIHistory();
+ /**
+ * @brief AppsModules mapping from applications to list of modules
+ */
+ typedef std::map<application_manager::ApplicationSharedPtr,
+ std::vector<std::string> > AppsModules;
+
+ /**
+ * @brief AppsSubscribedModules get mapping of application to list of
+ * subscribed modules
+ * @return map of applications to list of subscribed modules
+ */
+ AppsModules AppsSubscribedModules();
+
+ /**
+ * @brief RequestsToHMIHistory mapping from module type to vector of time
+ * stamps
+ */
+ typedef std::map<std::string, std::deque<TimevalStruct> >
+ RequestsToHMIHistory;
+ RequestsToHMIHistory requests_to_hmi_history_;
+ mutable sync_primitives::Lock requests_to_hmi_history_lock_;
+
+ RCRPCPlugin& rc_plugin_;
+ InteriorDataCache& cache_;
+ application_manager::ApplicationManager& app_mngr_;
+ application_manager::rpc_service::RPCService& rpc_service_;
+};
+
+} // namespace rc_rpc_plugin
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_INTERIOR_DATA_MANAGER_IMPL_H_
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_app_extension.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_app_extension.h
index 72f29c7de1..14397237c5 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_app_extension.h
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_app_extension.h
@@ -30,8 +30,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_RC_APP_EXTENSION_H_
-#define SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_RC_APP_EXTENSION_H_
+#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_APP_EXTENSION_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_APP_EXTENSION_H_
#include <string>
#include <set>
@@ -69,6 +69,12 @@ class RCAppExtension : public application_manager::AppExtension {
*/
bool IsSubscibedToInteriorVehicleData(const std::string& module_type);
+ /**
+ * @brief get list of subscriptions of application
+ * @return list of subscriptions of application
+ */
+ std::set<std::string> InteriorVehicleDataSubscriptions() const;
+
private:
std::set<std::string> subscribed_interior_vehicle_data_;
@@ -84,4 +90,4 @@ typedef std::shared_ptr<RCAppExtension> RCAppExtensionPtr;
} // namespace rc_rpc_plugin
-#endif // SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_RC_APP_EXTENSION_H_
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_APP_EXTENSION_H_
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_command_factory.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_command_factory.h
index 6f101cefef..56be342b56 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_command_factory.h
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_command_factory.h
@@ -30,8 +30,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_COMMAND_FACTORY_H
-#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_COMMAND_FACTORY_H
+#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_COMMAND_FACTORY_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_COMMAND_FACTORY_H_
#include <memory>
#include "application_manager/command_factory.h"
@@ -41,6 +41,8 @@
#include "application_manager/hmi_capabilities.h"
#include "application_manager/policies/policy_handler_interface.h"
#include "rc_rpc_plugin/resource_allocation_manager.h"
+#include "rc_rpc_plugin/interior_data_cache.h"
+#include "rc_rpc_plugin/commands/rc_command_params.h"
#include "utils/macro.h"
namespace rc_rpc_plugin {
@@ -56,11 +58,7 @@ class RCCommandFactory : public application_manager::CommandFactory {
* @param policy_handler PolicyHandlerInterface
* @param allocation_manager ResourceAllocationManager
**/
- RCCommandFactory(app_mngr::ApplicationManager& app_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handler,
- ResourceAllocationManager& allocation_manager);
+ RCCommandFactory(const RCCommandParams& params);
application_manager::CommandSharedPtr CreateCommand(
const app_mngr::commands::MessageSharedPtr& message,
app_mngr::commands::Command::CommandSource source) OVERRIDE;
@@ -84,11 +82,7 @@ class RCCommandFactory : public application_manager::CommandFactory {
hmi_apis::FunctionID::eType id,
hmi_apis::messageType::eType message_type) const;
- app_mngr::ApplicationManager& app_manager_;
- app_mngr::rpc_service::RPCService& rpc_service_;
- app_mngr::HMICapabilities& hmi_capabilities_;
- PolicyHandlerInterface& policy_handler_;
- ResourceAllocationManager& allocation_manager_;
+ RCCommandParams params_;
};
} // namespace rc_rpc_plugin
-#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_COMMAND_FACTORY_H
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_COMMAND_FACTORY_H_
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_helpers.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_helpers.h
new file mode 100644
index 0000000000..cf3c6cd5e4
--- /dev/null
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_helpers.h
@@ -0,0 +1,96 @@
+/*
+ Copyright (c) 2018, Ford Motor Company
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided with the
+ distribution.
+
+ Neither the name of the Ford Motor Company nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_HELPERS_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_HELPERS_H_
+
+#include <map>
+#include <string>
+#include "application_manager/application.h"
+#include "rc_rpc_plugin/rc_app_extension.h"
+
+namespace rc_rpc_plugin {
+class RCRPCPlugin;
+
+/**
+ * @brief The RCHelpers class contains frequently used static data
+ * structures related strictly to RC
+ * Converters, mapping, factory functions
+ */
+class RCHelpers {
+ public:
+ /**
+ * @brief GetModuleTypeToDataMapping get mapping of module type enum naming to
+ * actual module data filed name
+ * @return module mapping from enum naming to filed name
+ */
+ static const std::function<std::string(const std::string& module_type)>
+ GetModuleTypeToDataMapping();
+
+ /**
+ * @brief GetModuleTypeToDataMapping get mapping of module type enum naming to
+ * actual module capabilities key
+ * @return module mapping from enum naming to capabilities key
+ */
+ static const std::function<std::string(const std::string& module_type)>
+ GetModuleTypeToCapabilitiesMapping();
+
+ /**
+ * @brief GetModulesList get list of all known modules
+ * @return vector contains all known modules
+ */
+ static const std::vector<std::string> GetModulesList();
+
+ /**
+ * @brief GetRCExtension extract RC extension from application
+ * @param app application to extract extension
+ * @return rc extension of app is rc applicaiton, otherwise return emty shared
+ * pointer.
+ */
+ static RCAppExtensionPtr GetRCExtension(
+ application_manager::Application& app);
+
+ static smart_objects::SmartObjectSPtr CreateUnsubscribeRequestToHMI(
+ const std::string& module_type, const uint32_t correlation_id);
+
+ static std::vector<application_manager::ApplicationSharedPtr>
+ AppsSubscribedToModuleType(application_manager::ApplicationManager& app_mngr,
+ const std::string& module_type);
+
+ typedef std::map<application_manager::ApplicationSharedPtr,
+ std::vector<std::string> > AppsModules;
+ static AppsModules GetApplicationsAllowedModules(
+ application_manager::ApplicationManager& app_mngr);
+};
+
+} // rc_rpc_plugin
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_HELPERS_H_
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_module_constants.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_module_constants.h
index f2037aabbb..e80507445b 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_module_constants.h
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_module_constants.h
@@ -30,8 +30,8 @@
POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_RC_MODULE_CONSTANTS_H_
-#define SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_RC_MODULE_CONSTANTS_H_
+#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_MODULE_CONSTANTS_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_MODULE_CONSTANTS_H_
namespace rc_rpc_plugin {
@@ -40,7 +40,23 @@ namespace strings {
const char kclimateControlCapabilities[] = "climateControlCapabilities";
const char kradioControlCapabilities[] = "radioControlCapabilities";
const char kbuttonCapabilities[] = "buttonCapabilities";
+const char kaudioControlCapabilities[] = "audioControlCapabilities";
+const char klightControlCapabilities[] = "lightControlCapabilities";
+const char khmiSettingsControlCapabilities[] = "hmiSettingsControlCapabilities";
const char kseatControlCapabilities[] = "seatControlCapabilities";
+// RemoteControlCapabilities constants
+
+const char kRadioControlData[] = "radioControlData";
+const char kClimateControlData[] = "climateControlData";
+const char kSupportedLights[] = "supportedLights";
+
+// LightControlCapabilities
+const char kName[] = "name";
+const char kDensityAvailable[] = "densityAvailable";
+const char kRGBColorSpaceAvailable[] = "rgbColorSpaceAvailable";
+
+// RadioControlCapabilities
+const char kSiriusxmRadioAvailable[] = "siriusxmRadioAvailable";
} // strings
namespace result_codes {
@@ -139,6 +155,7 @@ const char kSignalStrength[] = "signalStrength";
const char kSignalChangeThreshold[] = "signalChangeThreshold";
const char kRadioEnable[] = "radioEnable";
const char kState[] = "state";
+const char kSisData[] = "sisData";
// RadioControlData struct
// ClimateControlData struct
@@ -153,11 +170,30 @@ const char kDefrostZone[] = "defrostZone";
const char kDualModeEnable[] = "dualModeEnable";
const char kACMaxEnable[] = "acMaxEnable";
const char kVentilationMode[] = "ventilationMode";
+const char kHeatedSteeringWheelEnable[] = "heatedSteeringWheelEnable";
+const char kHeatedWindshieldEnable[] = "heatedWindshieldEnable";
+const char kHeatedRearWindowEnable[] = "heatedRearWindowEnable";
+const char kHeatedMirrorsEnable[] = "heatedMirrorsEnable";
// ClimateControlData struct
+// LightControlData
+const char kLightState[] = "lightState";
+const char kStatus[] = "status";
+const char kDensity[] = "density";
+const char kColor[] = "color";
+
+// AudioControlData
+const char kSource[] = "source";
+const char kKeepContext[] = "keepContext";
+const char kEqualizerSettings[] = "equalizerSettings";
+const char kChannelName[] = "channelName";
+
// ModuleData struct
const char kRadioControlData[] = "radioControlData";
const char kClimateControlData[] = "climateControlData";
+const char kAudioControlData[] = "audioControlData";
+const char kLightControlData[] = "lightControlData";
+const char kHmiSettingsControlData[] = "hmiSettingsControlData";
const char kSeatControlData[] = "seatControlData";
// ModuleData struct
@@ -173,6 +209,9 @@ namespace enums_value {
const char kClimate[] = "CLIMATE";
const char kRadio[] = "RADIO";
const char kSeat[] = "SEAT";
+const char kAudio[] = "AUDIO";
+const char kLight[] = "LIGHT";
+const char kHmiSettings[] = "HMI_SETTINGS";
// ModuleType enum
// RadioBand enum
@@ -235,4 +274,4 @@ const char kAskDriver[] = "ASK_DRIVER";
} // namespace remote_control
-#endif // SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_RC_MODULE_CONSTANTS_H_
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_MODULE_CONSTANTS_H_
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_rpc_plugin.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_rpc_plugin.h
index 910eda6d3c..ae88ed9cc0 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_rpc_plugin.h
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_rpc_plugin.h
@@ -30,15 +30,21 @@
POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_PLUGIN_H
-#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_PLUGIN_H
+#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_RPC_PLUGIN_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_RPC_PLUGIN_H_
+
+#include <memory>
+
#include "application_manager/plugin_manager/rpc_plugin.h"
#include "application_manager/command_factory.h"
#include "rc_rpc_plugin/resource_allocation_manager.h"
+#include "rc_rpc_plugin/interior_data_cache.h"
+#include "rc_rpc_plugin/interior_data_manager.h"
namespace rc_rpc_plugin {
namespace plugins = application_manager::plugin_manager;
namespace app_mngr = application_manager;
+
class RCRPCPlugin : public plugins::RPCPlugin {
public:
/**
@@ -72,6 +78,7 @@ class RCRPCPlugin : public plugins::RPCPlugin {
* @return plugins command factory
*/
app_mngr::CommandFactory& GetCommandFactory() OVERRIDE;
+
/**
* @brief OnPolicyEvent Processes policy related events
* @param event Policy event
@@ -92,11 +99,15 @@ class RCRPCPlugin : public plugins::RPCPlugin {
application_manager::ApplicationManager& app_mngr);
private:
+ application_manager::rpc_service::RPCService* rpc_service_;
+ application_manager::ApplicationManager* app_mngr_;
std::unique_ptr<application_manager::CommandFactory> command_factory_;
std::unique_ptr<ResourceAllocationManager> resource_allocation_manager_;
+ std::unique_ptr<InteriorDataCache> interior_data_cache_;
+ std::unique_ptr<InteriorDataManager> interior_data_manager_;
};
} // namespace rc_rpc_plugin
extern "C" application_manager::plugin_manager::RPCPlugin* Create();
-#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_PLUGIN_H
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_RPC_PLUGIN_H_
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager.h
index 91d1b09fca..67598b667b 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager.h
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager.h
@@ -30,8 +30,8 @@
POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_RESOURCE_ALLOCATION_H
-#define SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_RESOURCE_ALLOCATION_H
+#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RESOURCE_ALLOCATION_MANAGER_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RESOURCE_ALLOCATION_MANAGER_H_
#include <string>
#include "utils/macro.h"
@@ -154,9 +154,6 @@ class ResourceAllocationManager {
*/
virtual void ResetAllAllocations() = 0;
- virtual RCAppExtensionPtr GetApplicationExtention(
- application_manager::ApplicationSharedPtr application) = 0;
-
/**
* @brief Create and send OnRCStatusNotification to mobile and HMI
* @param event trigger for notification sending
@@ -178,4 +175,4 @@ class ResourceAllocationManager {
};
} // namespace rc_rpc_plugin
-#endif // SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_RESOURCE_ALLOCATION_H
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RESOURCE_ALLOCATION_MANAGER_H_
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager_impl.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager_impl.h
index d6124a026b..b359ee4d29 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager_impl.h
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager_impl.h
@@ -30,8 +30,8 @@
POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_RESOURCE_ALLOCATION_IMPL_H
-#define SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_RESOURCE_ALLOCATION_IMPL_H
+#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RESOURCE_ALLOCATION_MANAGER_IMPL_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RESOURCE_ALLOCATION_MANAGER_IMPL_H_
#include "rc_rpc_plugin/resource_allocation_manager.h"
#include "application_manager/application_impl.h"
#include "rc_rpc_plugin/rc_app_extension.h"
@@ -110,14 +110,6 @@ class ResourceAllocationManagerImpl : public ResourceAllocationManager {
void ResetAllAllocations() FINAL;
- /**
- * @brief GetApplicationExtention Provides access to application RC extention
- * @param application Application
- * @return Pointer to RC extention of application or NULL if not available
- */
- RCAppExtensionPtr GetApplicationExtention(
- application_manager::ApplicationSharedPtr application) FINAL;
-
void SendOnRCStatusNotifications(
NotificationTrigger::eType event,
application_manager::ApplicationSharedPtr application) FINAL;
@@ -198,8 +190,6 @@ class ResourceAllocationManagerImpl : public ResourceAllocationManager {
*/
void SetResourceFree(const std::string& module_type, const uint32_t app_id);
- std::vector<std::string> all_supported_modules();
-
/**
* @brief AllocatedResources contains link between resource and application
* owning that resource
@@ -231,4 +221,4 @@ class ResourceAllocationManagerImpl : public ResourceAllocationManager {
};
} // rc_rpc_plugin
-#endif // SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_RESOURCE_ALLOCATION_IMPL_H
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RESOURCE_ALLOCATION_MANAGER_IMPL_H_
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_button_press_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_button_press_request.cc
index d392420238..75faf5db8c 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_button_press_request.cc
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_button_press_request.cc
@@ -31,6 +31,8 @@
*/
#include "rc_rpc_plugin/commands/hmi/rc_button_press_request.h"
+#include "rc_rpc_plugin/resource_allocation_manager_impl.h"
+
#include "utils/macro.h"
namespace rc_rpc_plugin {
@@ -38,18 +40,12 @@ namespace commands {
RCButtonPressRequest::RCButtonPressRequest(
const app_mngr::commands::MessageSharedPtr& message,
- app_mngr::ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handle,
- ResourceAllocationManager& resource_allocation_manager)
- : application_manager::commands::RequestToHMI(message,
- application_manager,
- rpc_service,
- hmi_capabilities,
- policy_handle) {
- UNUSED(resource_allocation_manager);
-}
+ const RCCommandParams& params)
+ : app_mngr::commands::RequestToHMI(message,
+ params.application_manager_,
+ params.rpc_service_,
+ params.hmi_capabilities_,
+ params.policy_handler_) {}
RCButtonPressRequest::~RCButtonPressRequest() {}
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_button_press_response.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_button_press_response.cc
index c7c11354c7..5c1691ed7b 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_button_press_response.cc
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_button_press_response.cc
@@ -37,19 +37,14 @@ namespace rc_rpc_plugin {
namespace commands {
RCButtonPressResponse::RCButtonPressResponse(
- const app_mngr::commands::MessageSharedPtr& message,
- app_mngr::ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handle,
- ResourceAllocationManager& resource_allocation_manager)
- : application_manager::commands::ResponseFromHMI(message,
- application_manager,
- rpc_service,
- hmi_capabilities,
- policy_handle) {
- UNUSED(resource_allocation_manager);
-}
+ const application_manager::commands::MessageSharedPtr& message,
+ const RCCommandParams& params)
+ : application_manager::commands::ResponseFromHMI(
+ message,
+ params.application_manager_,
+ params.rpc_service_,
+ params.hmi_capabilities_,
+ params.policy_handler_) {}
void RCButtonPressResponse::Run() {
LOG4CXX_AUTO_TRACE(logger_);
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_consent_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_consent_request.cc
index 875f1c8fbf..774ee04677 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_consent_request.cc
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_consent_request.cc
@@ -38,18 +38,12 @@ namespace commands {
RCGetInteriorVehicleDataConsentRequest::RCGetInteriorVehicleDataConsentRequest(
const app_mngr::commands::MessageSharedPtr& message,
- app_mngr::ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handle,
- ResourceAllocationManager& resource_allocation_manager)
+ const RCCommandParams& params)
: application_manager::commands::RequestToHMI(message,
- application_manager,
- rpc_service,
- hmi_capabilities,
- policy_handle) {
- UNUSED(resource_allocation_manager);
-}
+ params.application_manager_,
+ params.rpc_service_,
+ params.hmi_capabilities_,
+ params.policy_handler_) {}
RCGetInteriorVehicleDataConsentRequest::
~RCGetInteriorVehicleDataConsentRequest() {}
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_consent_response.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_consent_response.cc
index 3a9bb12df1..3244857656 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_consent_response.cc
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_consent_response.cc
@@ -38,19 +38,14 @@ namespace commands {
RCGetInteriorVehicleDataConsentResponse::
RCGetInteriorVehicleDataConsentResponse(
- const app_mngr::commands::MessageSharedPtr& message,
- app_mngr::ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handle,
- ResourceAllocationManager& resource_allocation_manager)
- : application_manager::commands::ResponseFromHMI(message,
- application_manager,
- rpc_service,
- hmi_capabilities,
- policy_handle) {
- UNUSED(resource_allocation_manager);
-}
+ const application_manager::commands::MessageSharedPtr& message,
+ const RCCommandParams& params)
+ : application_manager::commands::ResponseFromHMI(
+ message,
+ params.application_manager_,
+ params.rpc_service_,
+ params.hmi_capabilities_,
+ params.policy_handler_) {}
void RCGetInteriorVehicleDataConsentResponse::Run() {
LOG4CXX_AUTO_TRACE(logger_);
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_request.cc
index 0bb5f73c1b..c7baf75e27 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_request.cc
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_request.cc
@@ -38,18 +38,12 @@ namespace commands {
RCGetInteriorVehicleDataRequest::RCGetInteriorVehicleDataRequest(
const app_mngr::commands::MessageSharedPtr& message,
- app_mngr::ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handle,
- ResourceAllocationManager& resource_allocation_manager)
+ const RCCommandParams& params)
: application_manager::commands::RequestToHMI(message,
- application_manager,
- rpc_service,
- hmi_capabilities,
- policy_handle) {
- UNUSED(resource_allocation_manager);
-}
+ params.application_manager_,
+ params.rpc_service_,
+ params.hmi_capabilities_,
+ params.policy_handler_) {}
RCGetInteriorVehicleDataRequest::~RCGetInteriorVehicleDataRequest() {}
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_response.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_response.cc
index f12512a38d..e56f9088bc 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_response.cc
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_response.cc
@@ -31,6 +31,7 @@
*/
#include "rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_response.h"
+#include "rc_rpc_plugin/rc_module_constants.h"
#include "application_manager/event_engine/event.h"
namespace rc_rpc_plugin {
@@ -38,24 +39,30 @@ namespace commands {
RCGetInteriorVehicleDataResponse::RCGetInteriorVehicleDataResponse(
const app_mngr::commands::MessageSharedPtr& message,
- app_mngr::ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handle,
- ResourceAllocationManager& resource_allocation_manager)
- : application_manager::commands::ResponseFromHMI(message,
- application_manager,
- rpc_service,
- hmi_capabilities,
- policy_handle) {
- UNUSED(resource_allocation_manager);
-}
+ const RCCommandParams& params)
+ : application_manager::commands::ResponseFromHMI(
+ message,
+ params.application_manager_,
+ params.rpc_service_,
+ params.hmi_capabilities_,
+ params.policy_handler_) {}
void RCGetInteriorVehicleDataResponse::Run() {
LOG4CXX_AUTO_TRACE(logger_);
app_mngr::event_engine::Event event(
hmi_apis::FunctionID::RC_GetInteriorVehicleData);
+
+ smart_objects::SmartObject& module_data = (*message_)
+ [application_manager::strings::msg_params][message_params::kModuleData];
+ if (module_data.keyExists(message_params::kAudioControlData)) {
+ smart_objects::SmartObject& audio_control_data =
+ module_data[message_params::kAudioControlData];
+ if (audio_control_data.keyExists(message_params::kKeepContext)) {
+ audio_control_data.erase(message_params::kKeepContext);
+ }
+ }
+
event.set_smart_object(*message_);
event.raise(application_manager_.event_dispatcher());
}
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_interior_vehicle_data_notification.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_interior_vehicle_data_notification.cc
index 487193bc4d..0117003f11 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_interior_vehicle_data_notification.cc
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_interior_vehicle_data_notification.cc
@@ -30,6 +30,7 @@
POSSIBILITY OF SUCH DAMAGE.
*/
+#include "rc_rpc_plugin/rc_module_constants.h"
#include "rc_rpc_plugin/commands/hmi/rc_on_interior_vehicle_data_notification.h"
#include "utils/macro.h"
@@ -38,18 +39,13 @@ namespace commands {
RCOnInteriorVehicleDataNotification::RCOnInteriorVehicleDataNotification(
const app_mngr::commands::MessageSharedPtr& message,
- app_mngr::ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handle,
- ResourceAllocationManager& resource_allocation_manager)
- : application_manager::commands::NotificationFromHMI(message,
- application_manager,
- rpc_service,
- hmi_capabilities,
- policy_handle) {
- UNUSED(resource_allocation_manager);
-}
+ const RCCommandParams& params)
+ : application_manager::commands::NotificationFromHMI(
+ message,
+ params.application_manager_,
+ params.rpc_service_,
+ params.hmi_capabilities_,
+ params.policy_handler_) {}
RCOnInteriorVehicleDataNotification::~RCOnInteriorVehicleDataNotification() {}
@@ -57,6 +53,17 @@ void RCOnInteriorVehicleDataNotification::Run() {
LOG4CXX_AUTO_TRACE(logger_);
(*message_)[app_mngr::strings::params][app_mngr::strings::function_id] =
static_cast<int>(mobile_apis::FunctionID::eType::OnInteriorVehicleDataID);
+
+ smart_objects::SmartObject& module_data = (*message_)
+ [application_manager::strings::msg_params][message_params::kModuleData];
+ if (module_data.keyExists(rc_rpc_plugin::message_params::kAudioControlData)) {
+ smart_objects::SmartObject& audio_control_data =
+ module_data[message_params::kAudioControlData];
+ if (audio_control_data.keyExists(message_params::kKeepContext)) {
+ audio_control_data.erase(message_params::kKeepContext);
+ }
+ }
+
SendNotificationToMobile(message_);
}
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_remote_control_settings_notification.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_remote_control_settings_notification.cc
index 8bcb6b08ed..b67e3e2553 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_remote_control_settings_notification.cc
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_remote_control_settings_notification.cc
@@ -32,7 +32,9 @@
#include "rc_rpc_plugin/commands/hmi/rc_on_remote_control_settings_notification.h"
#include "rc_rpc_plugin/rc_rpc_plugin.h"
+#include "rc_rpc_plugin/interior_data_manager.h"
#include "rc_rpc_plugin/rc_module_constants.h"
+#include "rc_rpc_plugin/rc_helpers.h"
#include "utils/macro.h"
namespace rc_rpc_plugin {
@@ -49,17 +51,15 @@ CREATE_LOGGERPTR_GLOBAL(logger_, "RemoteControlModule")
RCOnRemoteControlSettingsNotification::RCOnRemoteControlSettingsNotification(
const app_mngr::commands::MessageSharedPtr& message,
- app_mngr::ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handle,
- ResourceAllocationManager& resource_allocation_manager)
- : application_manager::commands::NotificationFromHMI(message,
- application_manager,
- rpc_service,
- hmi_capabilities,
- policy_handle)
- , resource_allocation_manager_(resource_allocation_manager) {}
+ const RCCommandParams& params)
+ : application_manager::commands::NotificationFromHMI(
+ message,
+ params.application_manager_,
+ params.rpc_service_,
+ params.hmi_capabilities_,
+ params.policy_handler_)
+ , resource_allocation_manager_(params.resource_allocation_manager_)
+ , interior_data_manager_(params.interior_data_manager_) {}
RCOnRemoteControlSettingsNotification::
~RCOnRemoteControlSettingsNotification() {}
@@ -87,13 +87,6 @@ std::string AccessModeToString(
return error;
}
-void UnsubscribeFromInteriorVehicleDataForAllModules(
- RCAppExtensionPtr extension) {
- LOG4CXX_AUTO_TRACE(logger_);
- extension->UnsubscribeFromInteriorVehicleData(enums_value::kClimate);
- extension->UnsubscribeFromInteriorVehicleData(enums_value::kRadio);
-}
-
void RCOnRemoteControlSettingsNotification::DisallowRCFunctionality() {
LOG4CXX_AUTO_TRACE(logger_);
typedef std::vector<application_manager::ApplicationSharedPtr> Apps;
@@ -103,14 +96,8 @@ void RCOnRemoteControlSettingsNotification::DisallowRCFunctionality() {
DCHECK(app);
application_manager_.ChangeAppsHMILevel(
app->app_id(), mobile_apis::HMILevel::eType::HMI_NONE);
-
- const RCAppExtensionPtr extension =
- std::static_pointer_cast<RCAppExtension>(
- app->QueryInterface(RCRPCPlugin::kRCPluginID));
- if (extension) {
- UnsubscribeFromInteriorVehicleDataForAllModules(extension);
- }
}
+ interior_data_manager_.OnDisablingRC();
}
void RCOnRemoteControlSettingsNotification::Run() {
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_set_interior_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_set_interior_vehicle_data_request.cc
index 69ceed17e9..f0d5ecc177 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_set_interior_vehicle_data_request.cc
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_set_interior_vehicle_data_request.cc
@@ -38,18 +38,12 @@ namespace commands {
RCSetInteriorVehicleDataRequest::RCSetInteriorVehicleDataRequest(
const app_mngr::commands::MessageSharedPtr& message,
- app_mngr::ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handle,
- ResourceAllocationManager& resource_allocation_manager)
+ const RCCommandParams& params)
: application_manager::commands::RequestToHMI(message,
- application_manager,
- rpc_service,
- hmi_capabilities,
- policy_handle) {
- UNUSED(resource_allocation_manager);
-}
+ params.application_manager_,
+ params.rpc_service_,
+ params.hmi_capabilities_,
+ params.policy_handler_) {}
RCSetInteriorVehicleDataRequest::~RCSetInteriorVehicleDataRequest() {}
void RCSetInteriorVehicleDataRequest::Run() {
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_set_interior_vehicle_data_response.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_set_interior_vehicle_data_response.cc
index 42c2452943..56d924debe 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_set_interior_vehicle_data_response.cc
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_set_interior_vehicle_data_response.cc
@@ -38,18 +38,13 @@ namespace commands {
RCSetInteriorVehicleDataResponse::RCSetInteriorVehicleDataResponse(
const app_mngr::commands::MessageSharedPtr& message,
- app_mngr::ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handle,
- ResourceAllocationManager& resource_allocation_manager)
- : application_manager::commands::ResponseFromHMI(message,
- application_manager,
- rpc_service,
- hmi_capabilities,
- policy_handle) {
- UNUSED(resource_allocation_manager);
-}
+ const RCCommandParams& params)
+ : application_manager::commands::ResponseFromHMI(
+ message,
+ params.application_manager_,
+ params.rpc_service_,
+ params.hmi_capabilities_,
+ params.policy_handler_) {}
void RCSetInteriorVehicleDataResponse::Run() {
LOG4CXX_AUTO_TRACE(logger_);
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/button_press_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/button_press_request.cc
index 88e4ebaa3c..05e44cfb44 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/button_press_request.cc
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/button_press_request.cc
@@ -50,17 +50,8 @@ typedef std::map<std::string, mobile_apis::ButtonName::eType> ButtonsMap;
ButtonPressRequest::ButtonPressRequest(
const app_mngr::commands::MessageSharedPtr& message,
- app_mngr::ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handle,
- ResourceAllocationManager& resource_allocation_manager)
- : RCCommandRequest(message,
- application_manager,
- rpc_service,
- hmi_capabilities,
- policy_handle,
- resource_allocation_manager) {}
+ const RCCommandParams& params)
+ : RCCommandRequest(message, params) {}
ButtonPressRequest::~ButtonPressRequest() {}
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/button_press_response.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/button_press_response.cc
index dfdb128322..491b0363c9 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/button_press_response.cc
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/button_press_response.cc
@@ -38,18 +38,13 @@ namespace commands {
ButtonPressResponse::ButtonPressResponse(
const app_mngr::commands::MessageSharedPtr& message,
- app_mngr::ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handle,
- ResourceAllocationManager& resource_allocation_manager)
- : application_manager::commands::CommandResponseImpl(message,
- application_manager,
- rpc_service,
- hmi_capabilities,
- policy_handle) {
- UNUSED(resource_allocation_manager);
-}
+ const RCCommandParams& params)
+ : application_manager::commands::CommandResponseImpl(
+ message,
+ params.application_manager_,
+ params.rpc_service_,
+ params.hmi_capabilities_,
+ params.policy_handler_) {}
ButtonPressResponse::~ButtonPressResponse() {}
void ButtonPressResponse::Run() {
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_request.cc
index 06c44d2ff3..6178405808 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_request.cc
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_request.cc
@@ -32,6 +32,8 @@
#include "rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_request.h"
#include "rc_rpc_plugin/rc_module_constants.h"
+#include "rc_rpc_plugin/rc_helpers.h"
+#include "rc_rpc_plugin/rc_rpc_plugin.h"
#include "smart_objects/enum_schema_item.h"
#include "utils/macro.h"
#include "interfaces/MOBILE_API.h"
@@ -46,31 +48,21 @@ CREATE_LOGGERPTR_GLOBAL(logger_, "RemoteControlModule")
GetInteriorVehicleDataRequest::GetInteriorVehicleDataRequest(
const app_mngr::commands::MessageSharedPtr& message,
- app_mngr::ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handle,
- ResourceAllocationManager& resource_allocation_manager)
- : RCCommandRequest(message,
- application_manager,
- rpc_service,
- hmi_capabilities,
- policy_handle,
- resource_allocation_manager)
+ const RCCommandParams& params)
+ : RCCommandRequest(message, params)
+
, excessive_subscription_occured_(false) {}
bool CheckIfModuleTypeExistInCapabilities(
const smart_objects::SmartObject& rc_capabilities,
const std::string& module_type) {
LOG4CXX_AUTO_TRACE(logger_);
- const std::map<std::string, std::string> params = {
- {enums_value::kRadio, strings::kradioControlCapabilities},
- {enums_value::kClimate, strings::kclimateControlCapabilities},
- {enums_value::kSeat, strings::kseatControlCapabilities}};
+ const auto& mapping = RCHelpers::GetModuleTypeToCapabilitiesMapping();
+ const auto& module_list = RCHelpers::GetModulesList();
bool is_module_type_valid = false;
- for (const auto& param : params) {
- if (param.first == module_type) {
- if (rc_capabilities.keyExists(param.second)) {
+ for (const auto& module : module_list) {
+ if (module == module_type) {
+ if (rc_capabilities.keyExists(mapping(module))) {
is_module_type_valid = true;
break;
}
@@ -79,9 +71,8 @@ bool CheckIfModuleTypeExistInCapabilities(
return is_module_type_valid;
}
-void GetInteriorVehicleDataRequest::Execute() {
+bool GetInteriorVehicleDataRequest::ProcessCapabilities() {
LOG4CXX_AUTO_TRACE(logger_);
-
const smart_objects::SmartObject* rc_capabilities =
hmi_capabilities_.rc_capability();
@@ -93,26 +84,107 @@ void GetInteriorVehicleDataRequest::Execute() {
SendResponse(false,
mobile_apis::Result::UNSUPPORTED_RESOURCE,
"Accessing not supported module data");
+ return false;
+ }
+ return true;
+}
+
+void GetInteriorVehicleDataRequest::ProcessResponseToMobileFromCache(
+ app_mngr::ApplicationSharedPtr app) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ const auto& data_mapping = RCHelpers::GetModuleTypeToDataMapping();
+ auto data = interior_data_cache_.Retrieve(ModuleType());
+ auto response_msg_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+ response_msg_params[message_params::kModuleData][data_mapping(ModuleType())] =
+ data;
+ response_msg_params[message_params::kModuleData]
+ [message_params::kModuleType] = ModuleType();
+
+ const auto& request_msg_params = (*message_)[app_mngr::strings::msg_params];
+ LOG4CXX_DEBUG(logger_,
+ "kSubscribe exist" << request_msg_params.keyExists(
+ message_params::kSubscribe));
+ if (request_msg_params.keyExists(message_params::kSubscribe)) {
+ response_msg_params[message_params::kIsSubscribed] =
+ request_msg_params[message_params::kSubscribe].asBool();
+ if (request_msg_params[message_params::kSubscribe].asBool()) {
+ auto extension = RCHelpers::GetRCExtension(*app);
+ DCHECK(extension);
+ extension->SubscribeToInteriorVehicleData(ModuleType());
+ }
+ }
+ SendResponse(
+ true, mobile_apis::Result::SUCCESS, nullptr, &response_msg_params);
+ if (AppShouldBeUnsubscribed()) {
+ auto extension = RCHelpers::GetRCExtension(*app);
+ DCHECK(extension);
+ extension->UnsubscribeFromInteriorVehicleData(ModuleType());
+ }
+}
+
+bool GetInteriorVehicleDataRequest::CheckRateLimits() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ return interior_data_manager_.CheckRequestsToHMIFrequency(ModuleType());
+}
+
+bool GetInteriorVehicleDataRequest::AppShouldBeUnsubscribed() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ const auto& msg_params = (*message_)[app_mngr::strings::msg_params];
+ if (msg_params.keyExists(message_params::kSubscribe)) {
+ return !(msg_params[message_params::kSubscribe].asBool());
+ }
+ return false;
+}
+
+bool GetInteriorVehicleDataRequest::TheLastAppShouldBeUnsubscribed(
+ app_mngr::ApplicationSharedPtr app) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ if (AppShouldBeUnsubscribed()) {
+ const auto subscribed_to_module_type =
+ RCHelpers::AppsSubscribedToModuleType(application_manager_,
+ ModuleType());
+ if (subscribed_to_module_type.size() == 1 &&
+ subscribed_to_module_type.front() == app) {
+ LOG4CXX_DEBUG(logger_,
+ "The last application unsubscribes from " << ModuleType());
+ return true;
+ }
+ }
+ return false;
+}
+
+void GetInteriorVehicleDataRequest::Execute() {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ if (!ProcessCapabilities()) {
return;
}
app_mngr::ApplicationSharedPtr app =
application_manager_.application(connection_key());
- if (HasRequestExcessiveSubscription()) {
- excessive_subscription_occured_ = true;
- is_subscribed =
- (*message_)[app_mngr::strings::msg_params][message_params::kSubscribe]
- .asBool();
- RemoveExcessiveSubscription();
+ if (TheLastAppShouldBeUnsubscribed(app) ||
+ !interior_data_cache_.Contains(ModuleType())) {
+ if (HasRequestExcessiveSubscription()) {
+ excessive_subscription_occured_ = true;
+ is_subscribed =
+ (*message_)[app_mngr::strings::msg_params][message_params::kSubscribe]
+ .asBool();
+ RemoveExcessiveSubscription();
+ }
+ if (!CheckRateLimits()) {
+ LOG4CXX_WARN(logger_, "GetInteriorVehicleData frequency is too high.");
+ SendResponse(false, mobile_apis::Result::REJECTED);
+ return;
+ }
+ interior_data_manager_.StoreRequestToHMITime(ModuleType());
+ SendHMIRequest(hmi_apis::FunctionID::RC_GetInteriorVehicleData,
+ &(*message_)[app_mngr::strings::msg_params],
+ true);
+ return;
}
-
- (*message_)[app_mngr::strings::msg_params][app_mngr::strings::app_id] =
- app->app_id();
-
- SendHMIRequest(hmi_apis::FunctionID::RC_GetInteriorVehicleData,
- &(*message_)[app_mngr::strings::msg_params],
- true);
+ ProcessResponseToMobileFromCache(app);
}
void GetInteriorVehicleDataRequest::on_event(
@@ -144,7 +216,21 @@ void GetInteriorVehicleDataRequest::on_event(
}
if (result) {
+ app_mngr::ApplicationSharedPtr app =
+ application_manager_.application(connection_key());
+
+ DCHECK_OR_RETURN_VOID(app);
+ if (TheLastAppShouldBeUnsubscribed(app)) {
+ interior_data_cache_.Remove(ModuleType());
+ }
ProccessSubscription(hmi_response);
+ if (is_subscribed) {
+ const auto& data_mapping = RCHelpers::GetModuleTypeToDataMapping();
+ const auto module_data =
+ hmi_response[app_mngr::strings::msg_params]
+ [message_params::kModuleData][data_mapping(ModuleType())];
+ interior_data_cache_.Add(ModuleType(), module_data);
+ }
} else {
hmi_response[app_mngr::strings::msg_params].erase(
message_params::kIsSubscribed);
@@ -152,6 +238,7 @@ void GetInteriorVehicleDataRequest::on_event(
std::string response_info;
GetInfo(hmi_response, response_info);
SetResourceState(ModuleType(), ResourceState::FREE);
+
SendResponse(result,
result_code,
response_info.c_str(),
@@ -178,8 +265,7 @@ void GetInteriorVehicleDataRequest::ProccessSubscription(
app_mngr::ApplicationSharedPtr app =
application_manager_.application(CommandRequestImpl::connection_key());
- RCAppExtensionPtr extension =
- resource_allocation_manager_.GetApplicationExtention(app);
+ const auto extension = RCHelpers::GetRCExtension(*app);
const char* module_type;
NsSmartDeviceLink::NsSmartObjects::
EnumConversionHelper<mobile_apis::ModuleType::eType>::EnumToCString(
@@ -258,8 +344,7 @@ bool GetInteriorVehicleDataRequest::HasRequestExcessiveSubscription() {
if (is_subscribe_present_in_request) {
app_mngr::ApplicationSharedPtr app =
application_manager_.application(CommandRequestImpl::connection_key());
- RCAppExtensionPtr extension =
- resource_allocation_manager_.GetApplicationExtention(app);
+ const auto extension = RCHelpers::GetRCExtension(*app);
const bool is_app_already_subscribed =
extension->IsSubscibedToInteriorVehicleData(ModuleType());
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_response.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_response.cc
index 18ccc5b497..a7572f1d62 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_response.cc
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_response.cc
@@ -38,18 +38,13 @@ namespace commands {
GetInteriorVehicleDataResponse::GetInteriorVehicleDataResponse(
const app_mngr::commands::MessageSharedPtr& message,
- app_mngr::ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handle,
- ResourceAllocationManager& resource_allocation_manager)
- : application_manager::commands::CommandResponseImpl(message,
- application_manager,
- rpc_service,
- hmi_capabilities,
- policy_handle) {
- UNUSED(resource_allocation_manager);
-}
+ const RCCommandParams& params)
+ : application_manager::commands::CommandResponseImpl(
+ message,
+ params.application_manager_,
+ params.rpc_service_,
+ params.hmi_capabilities_,
+ params.policy_handler_) {}
GetInteriorVehicleDataResponse::~GetInteriorVehicleDataResponse() {}
void GetInteriorVehicleDataResponse::Run() {
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/on_interior_vehicle_data_notification.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/on_interior_vehicle_data_notification.cc
index fca9962fb5..c8d1329c02 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/on_interior_vehicle_data_notification.cc
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/on_interior_vehicle_data_notification.cc
@@ -33,6 +33,7 @@
#include "rc_rpc_plugin/commands/mobile/on_interior_vehicle_data_notification.h"
#include "rc_rpc_plugin/rc_rpc_plugin.h"
#include "rc_rpc_plugin/rc_module_constants.h"
+#include "rc_rpc_plugin/rc_helpers.h"
#include "smart_objects/enum_schema_item.h"
#include "utils/macro.h"
@@ -43,26 +44,34 @@ CREATE_LOGGERPTR_GLOBAL(logger_, "RemoteControlModule")
OnInteriorVehicleDataNotification::OnInteriorVehicleDataNotification(
const app_mngr::commands::MessageSharedPtr& message,
- app_mngr::ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handler,
- ResourceAllocationManager& resource_allocation_manager)
+ const RCCommandParams& params)
: app_mngr::commands::CommandNotificationImpl(message,
- application_manager,
- rpc_service,
- hmi_capabilities,
- policy_handler) {
- UNUSED(resource_allocation_manager);
-}
+ params.application_manager_,
+ params.rpc_service_,
+ params.hmi_capabilities_,
+ params.policy_handler_)
+ , interior_data_cache_(params.interior_data_cache_) {}
OnInteriorVehicleDataNotification::~OnInteriorVehicleDataNotification() {}
+void OnInteriorVehicleDataNotification::AddDataToCache(
+ const std::string& module_type) {
+ const auto& data_mapping = RCHelpers::GetModuleTypeToDataMapping();
+ const auto module_data =
+ (*message_)[app_mngr::strings::msg_params][message_params::kModuleData]
+ [data_mapping(module_type)];
+ interior_data_cache_.Add(module_type, module_data);
+}
+
void OnInteriorVehicleDataNotification::Run() {
LOG4CXX_AUTO_TRACE(logger_);
const std::string module_type = ModuleType();
-
+ auto apps_subscribed =
+ RCHelpers::AppsSubscribedToModuleType(application_manager_, module_type);
+ if (!apps_subscribed.empty()) {
+ AddDataToCache(module_type);
+ }
typedef std::vector<application_manager::ApplicationSharedPtr> AppPtrs;
AppPtrs apps = RCRPCPlugin::GetRCApplications(application_manager_);
@@ -70,8 +79,7 @@ void OnInteriorVehicleDataNotification::Run() {
DCHECK(*it);
application_manager::Application& app = **it;
- RCAppExtensionPtr extension = std::static_pointer_cast<RCAppExtension>(
- app.QueryInterface(RCRPCPlugin::kRCPluginID));
+ const auto extension = RCHelpers::GetRCExtension(app);
DCHECK(extension);
LOG4CXX_TRACE(logger_,
"Check subscription for "
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc
index 83bb526076..17a492b5aa 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc
@@ -33,6 +33,7 @@
#include "rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_request.h"
#include "rc_rpc_plugin/rc_module_constants.h"
#include "rc_rpc_plugin/rc_rpc_plugin.h"
+#include "rc_rpc_plugin/rc_helpers.h"
#include "smart_objects/enum_schema_item.h"
#include "utils/macro.h"
#include "json/json.h"
@@ -57,18 +58,11 @@ std::vector<std::string> GetModuleReadOnlyParams(
module_ro_params.push_back(kSignalStrength);
module_ro_params.push_back(kSignalChangeThreshold);
module_ro_params.push_back(kState);
+ module_ro_params.push_back(kSisData);
}
return module_ro_params;
}
-const std::map<std::string, std::string> GetModuleTypeToDataMapping() {
- std::map<std::string, std::string> mapping = {
- {enums_value::kRadio, message_params::kRadioControlData},
- {enums_value::kClimate, message_params::kClimateControlData},
- {enums_value::kSeat, message_params::kSeatControlData}};
- return mapping;
-}
-
const std::map<std::string, std::string> GetModuleDataToCapabilitiesMapping() {
std::map<std::string, std::string> mapping;
// climate
@@ -82,6 +76,10 @@ const std::map<std::string, std::string> GetModuleDataToCapabilitiesMapping() {
mapping["dualModeEnable"] = "dualModeEnableAvailable";
mapping["acMaxEnable"] = "acMaxEnableAvailable";
mapping["ventilationMode"] = "ventilationModeAvailable";
+ mapping["heatedSteeringWheelEnable"] = "heatedSteeringWheelAvailable";
+ mapping["heatedWindshieldEnable"] = "heatedWindshieldAvailable";
+ mapping["heatedMirrorsEnable"] = "heatedMirrorsAvailable";
+ mapping["heatedRearWindowEnable"] = "heatedRearWindowAvailable";
// radio
mapping["band"] = "radioBandAvailable";
@@ -90,10 +88,12 @@ const std::map<std::string, std::string> GetModuleDataToCapabilitiesMapping() {
mapping["rdsData"] = "rdsDataAvailable";
mapping["availableHDs"] = "availableHDsAvailable";
mapping["hdChannel"] = "availableHDsAvailable";
+ mapping["hdRadioEnable"] = "hdRadioEnableAvailable";
mapping["signalStrength"] = "signalStrengthAvailable";
mapping["signalChangeThreshold"] = "signalChangeThresholdAvailable";
mapping["radioEnable"] = "radioEnableAvailable";
mapping["state"] = "stateAvailable";
+ mapping["sisData"] = "sisDataAvailable";
// seat
mapping["heatingEnabled"] = "heatingEnabledAvailable";
@@ -113,6 +113,16 @@ const std::map<std::string, std::string> GetModuleDataToCapabilitiesMapping() {
mapping["massageMode"] = "massageModeAvailable";
mapping["massageCushionFirmness"] = "massageCushionFirmnessAvailable";
mapping["memory"] = "memoryAvailable";
+ // audio
+ mapping["source"] = "sourceAvailable";
+ mapping["keepContext"] = "keepContextAvailable";
+ mapping["volume"] = "volumeAvailable";
+ mapping["equalizerSettings"] = "equalizerAvailable";
+
+ // hmi settings
+ mapping["distanceUnit"] = "distanceUnitAvailable";
+ mapping["temperatureUnit"] = "temperatureUnitAvailable";
+ mapping["displayMode"] = "displayModeUnitAvailable";
return mapping;
}
@@ -122,37 +132,127 @@ CREATE_LOGGERPTR_GLOBAL(logger_, "RemoteControlModule")
SetInteriorVehicleDataRequest::SetInteriorVehicleDataRequest(
const app_mngr::commands::MessageSharedPtr& message,
- app_mngr::ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handle,
- ResourceAllocationManager& resource_allocation_manager)
- : RCCommandRequest(message,
- application_manager,
- rpc_service,
- hmi_capabilities,
- policy_handle,
- resource_allocation_manager) {}
+ const RCCommandParams& params)
+ : RCCommandRequest(message, params) {}
SetInteriorVehicleDataRequest::~SetInteriorVehicleDataRequest() {}
+const std::string LightName(const smart_objects::SmartObject& light_name) {
+ const char* name;
+ const bool ok = NsSmartDeviceLink::NsSmartObjects::
+ EnumConversionHelper<mobile_apis::LightName::eType>::EnumToCString(
+ static_cast<mobile_apis::LightName::eType>(light_name.asUInt()),
+ &name);
+ return ok ? name : "unknown";
+}
+
+bool CheckLightDataByCapabilities(
+ const smart_objects::SmartObject& capabilities,
+ const smart_objects::SmartObject& light_data) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ std::map<std::string, std::string> lightCapsMapping = {
+ {message_params::kId, strings::kName},
+ {message_params::kDensity, strings::kDensityAvailable},
+ {message_params::kColor, strings::kRGBColorSpaceAvailable}};
+ auto it = light_data.map_begin();
+ for (; it != light_data.map_end(); ++it) {
+ if (message_params::kStatus == it->first ||
+ message_params::kId == it->first) {
+ continue;
+ }
+ const std::string& caps_key = lightCapsMapping[it->first];
+ LOG4CXX_DEBUG(logger_,
+ "Checking request parameter "
+ << it->first << " with capabilities. Appropriate key is "
+ << caps_key);
+
+ if (!capabilities.keyExists(caps_key)) {
+ LOG4CXX_DEBUG(logger_,
+ "Capability "
+ << caps_key
+ << " is missed in RemoteControl capabilities");
+ return false;
+ }
+ if (!capabilities[caps_key].asBool()) {
+ LOG4CXX_DEBUG(logger_,
+ "Capability "
+ << caps_key
+ << " is switched off in RemoteControl capabilities");
+ return false;
+ }
+ }
+ return true;
+}
+
+bool CheckLightNameByCapabilities(
+ const smart_objects::SmartObject& capabilities_status,
+ const smart_objects::SmartObject& light_data) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ auto it = capabilities_status.asArray()->begin();
+ for (; it != capabilities_status.asArray()->end(); ++it) {
+ const smart_objects::SmartObject& so = *it;
+ const int64_t current_id = so[message_params::kName].asInt();
+ if (current_id == light_data[message_params::kId].asInt()) {
+ return CheckLightDataByCapabilities(so, light_data);
+ }
+ }
+ LOG4CXX_DEBUG(logger_, "There is no such light name in capabilities");
+ return false;
+}
+
+bool CheckRadioBandByCapabilities(
+ const smart_objects::SmartObject& capabilities_status,
+ const smart_objects::SmartObject& request_parameter) {
+ mobile_apis::RadioBand::eType radio_band =
+ static_cast<mobile_apis::RadioBand::eType>(request_parameter.asUInt());
+ if (mobile_apis::RadioBand::XM == radio_band) {
+ if (!capabilities_status.keyExists(strings::kSiriusxmRadioAvailable)) {
+ LOG4CXX_DEBUG(logger_,
+ "Capability "
+ << strings::kSiriusxmRadioAvailable
+ << " is missed in RemoteControl capabilities");
+ return false;
+ }
+ if (!capabilities_status[strings::kSiriusxmRadioAvailable].asBool()) {
+ LOG4CXX_DEBUG(logger_,
+ "Capability "
+ << strings::kSiriusxmRadioAvailable
+ << " is switched off in RemoteControl capabilities");
+ return false;
+ }
+ }
+ return true;
+}
+
bool CheckControlDataByCapabilities(
- const smart_objects::SmartObject& module_caps,
+ const smart_objects::SmartObject& capabilities_status,
const smart_objects::SmartObject& control_data) {
+ LOG4CXX_AUTO_TRACE(logger_);
std::map<std::string, std::string> mapping =
GetModuleDataToCapabilitiesMapping();
- const smart_objects::SmartObject& capabilities_status = module_caps[0];
auto it = control_data.map_begin();
for (; it != control_data.map_end(); ++it) {
const std::string& request_parameter = it->first;
if (message_params::kId == request_parameter) {
continue;
}
+ if (message_params::kLightState == request_parameter) {
+ auto light_data = control_data[request_parameter].asArray()->begin();
+ for (; light_data != control_data[request_parameter].asArray()->end();
+ ++light_data) {
+ if (!CheckLightNameByCapabilities(
+ capabilities_status[strings::kSupportedLights], *light_data)) {
+ return false;
+ }
+ }
+ return true;
+ }
const std::string& caps_key = mapping[request_parameter];
LOG4CXX_DEBUG(logger_,
"Checking request parameter "
<< request_parameter
<< " with capabilities. Appropriate key is " << caps_key);
+
if (!capabilities_status.keyExists(caps_key)) {
LOG4CXX_DEBUG(logger_,
"Capability "
@@ -167,6 +267,11 @@ bool CheckControlDataByCapabilities(
<< " is switched off in RemoteControl capabilities");
return false;
}
+ if (message_params::kBand == request_parameter &&
+ !CheckRadioBandByCapabilities(capabilities_status,
+ control_data[request_parameter])) {
+ return false;
+ }
}
return true;
}
@@ -175,21 +280,31 @@ bool CheckIfModuleDataExistInCapabilities(
const smart_objects::SmartObject& rc_capabilities,
const smart_objects::SmartObject& module_data) {
LOG4CXX_AUTO_TRACE(logger_);
- const std::map<std::string, std::string> params = {
- {message_params::kRadioControlData, strings::kradioControlCapabilities},
- {message_params::kClimateControlData,
- strings::kclimateControlCapabilities},
- {message_params::kSeatControlData, strings::kseatControlCapabilities}};
+
+ const auto& all_module_types = RCHelpers::GetModulesList();
+ const auto& get_module_data_key = RCHelpers::GetModuleTypeToDataMapping();
+ const auto& get_capabilities_key =
+ RCHelpers::GetModuleTypeToCapabilitiesMapping();
+
bool is_module_data_valid = false;
- for (const auto& param : params) {
- if (module_data.keyExists(param.first)) {
- if (!rc_capabilities.keyExists(param.second)) {
- LOG4CXX_DEBUG(logger_, param.first << " capabilities not present");
+ for (const auto& module_type : all_module_types) {
+ const auto module_data_key = get_module_data_key(module_type);
+ const auto capabilities_key = get_capabilities_key(module_type);
+ if (module_data.keyExists(module_data_key)) {
+ if (!rc_capabilities.keyExists(capabilities_key)) {
+ LOG4CXX_DEBUG(logger_, module_data_key << " capabilities not present");
return false;
}
- const smart_objects::SmartObject& caps = rc_capabilities[param.second];
- is_module_data_valid =
- CheckControlDataByCapabilities(caps, module_data[param.first]);
+ const smart_objects::SmartObject& caps =
+ rc_capabilities[capabilities_key];
+ if (message_params::kHmiSettingsControlData == module_data_key ||
+ message_params::kLightControlData == module_data_key) {
+ is_module_data_valid =
+ CheckControlDataByCapabilities(caps, module_data[module_data_key]);
+ } else {
+ is_module_data_valid = CheckControlDataByCapabilities(
+ caps[0], module_data[module_data_key]);
+ }
}
}
return is_module_data_valid;
@@ -198,12 +313,12 @@ bool CheckIfModuleDataExistInCapabilities(
bool isModuleTypeAndDataMatch(const std::string& module_type,
const smart_objects::SmartObject& module_data) {
LOG4CXX_AUTO_TRACE(logger_);
- std::map<std::string, std::string> data_mapping =
- GetModuleTypeToDataMapping();
+ const auto& all_module_types = RCHelpers::GetModulesList();
+ const auto& data_mapping = RCHelpers::GetModuleTypeToDataMapping();
bool module_type_and_data_match = false;
- for (const auto& data : data_mapping) {
- if (data.first == module_type) {
- module_type_and_data_match = module_data.keyExists(data.second);
+ for (const auto& type : all_module_types) {
+ if (type == module_type) {
+ module_type_and_data_match = module_data.keyExists(data_mapping(type));
break;
}
}
@@ -249,6 +364,20 @@ void SetInteriorVehicleDataRequest::Execute() {
(*message_)[app_mngr::strings::msg_params][app_mngr::strings::app_id] =
app->app_id();
+ const bool app_wants_to_set_audio_src =
+ module_data.keyExists(message_params::kAudioControlData) &&
+ module_data[message_params::kAudioControlData].keyExists(
+ message_params::kSource);
+
+ if (app_wants_to_set_audio_src && !app->IsAllowedToChangeAudioSource()) {
+ LOG4CXX_WARN(logger_, "App is not allowed to change audio source");
+ SetResourceState(ModuleType(), ResourceState::FREE);
+ SendResponse(false,
+ mobile_apis::Result::REJECTED,
+ "App is not allowed to change audio source");
+ return;
+ }
+
SendHMIRequest(hmi_apis::FunctionID::RC_SetInteriorVehicleData,
&(*message_)[app_mngr::strings::msg_params],
true);
@@ -284,6 +413,11 @@ void SetInteriorVehicleDataRequest::on_event(
smart_objects::SmartObject response_params;
if (result) {
response_params = hmi_response[app_mngr::strings::msg_params];
+ if (enums_value::kAudio == ModuleType()) {
+ CheckAudioSource((
+ *message_)[app_mngr::strings::msg_params][message_params::kModuleData]
+ [message_params::kAudioControlData]);
+ }
}
std::string info;
GetInfo(hmi_response, info);
@@ -294,17 +428,44 @@ void SetInteriorVehicleDataRequest::on_event(
const smart_objects::SmartObject& SetInteriorVehicleDataRequest::ControlData(
const smart_objects::SmartObject& module_data) {
const std::string module_type = ModuleType();
- std::map<std::string, std::string> data_mapping =
- GetModuleTypeToDataMapping();
- for (const auto& data : data_mapping) {
- if (data.first == module_type) {
- return module_data[data.second];
+
+ const auto& all_module_types = RCHelpers::GetModulesList();
+ const auto& data_mapping = RCHelpers::GetModuleTypeToDataMapping();
+ for (const auto& type : all_module_types) {
+ if (type == module_type) {
+ return module_data[data_mapping(type)];
}
}
NOTREACHED();
return module_data[0];
}
+void SetInteriorVehicleDataRequest::CheckAudioSource(
+ const smart_objects::SmartObject& audio_data) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ const bool should_keep_context =
+ audio_data.keyExists(message_params::kKeepContext) &&
+ audio_data[message_params::kKeepContext].asBool();
+ const bool switch_source_from_app =
+ mobile_apis::PrimaryAudioSource::MOBILE_APP ==
+ application_manager_.get_current_audio_source() &&
+ mobile_apis::PrimaryAudioSource::MOBILE_APP !=
+ audio_data[message_params::kSource].asInt();
+ if (!should_keep_context && switch_source_from_app) {
+ app_mngr::ApplicationSharedPtr app =
+ application_manager_.application(connection_key());
+ if (app->mobile_projection_enabled()) {
+ application_manager_.ChangeAppsHMILevel(
+ app->app_id(), mobile_apis::HMILevel::eType::HMI_LIMITED);
+ } else {
+ application_manager_.ChangeAppsHMILevel(
+ app->app_id(), mobile_apis::HMILevel::eType::HMI_BACKGROUND);
+ }
+ }
+ application_manager_.set_current_audio_source(
+ audio_data[message_params::kSource].asUInt());
+}
+
bool SetInteriorVehicleDataRequest::AreAllParamsReadOnly(
const smart_objects::SmartObject& module_data) {
LOG4CXX_AUTO_TRACE(logger_);
@@ -320,13 +481,34 @@ bool SetInteriorVehicleDataRequest::AreAllParamsReadOnly(
return true;
}
+bool CheckReadOnlyParamsForAudio(
+ const smart_objects::SmartObject& module_type_params) {
+ if (module_type_params.keyExists(message_params::kEqualizerSettings)) {
+ const auto& equalizer_settings =
+ module_type_params[message_params::kEqualizerSettings];
+ auto it = equalizer_settings.asArray()->begin();
+ for (; it != equalizer_settings.asArray()->end(); ++it) {
+ if (it->keyExists(message_params::kChannelName)) {
+ LOG4CXX_DEBUG(logger_,
+ " READ ONLY parameter: " << message_params::kChannelName);
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
bool SetInteriorVehicleDataRequest::AreReadOnlyParamsPresent(
const smart_objects::SmartObject& module_data) {
LOG4CXX_AUTO_TRACE(logger_);
const smart_objects::SmartObject& module_type_params =
ControlData(module_data);
auto it = module_type_params.map_begin();
- std::vector<std::string> ro_params = GetModuleReadOnlyParams(ModuleType());
+ const std::string module_type = ModuleType();
+ std::vector<std::string> ro_params = GetModuleReadOnlyParams(module_type);
+ if (enums_value::kAudio == module_type) {
+ return CheckReadOnlyParamsForAudio(module_type_params);
+ }
for (; it != module_type_params.map_end(); ++it) {
if (helpers::in_range(ro_params, it->first)) {
return true;
@@ -354,6 +536,20 @@ void SetInteriorVehicleDataRequest::CutOffReadOnlyParams(
}
}
}
+
+ if (enums_value::kAudio == module_type) {
+ auto& equalizer_settings = module_data[message_params::kAudioControlData]
+ [message_params::kEqualizerSettings];
+ auto it = equalizer_settings.asArray()->begin();
+ for (; it != equalizer_settings.asArray()->end(); ++it) {
+ if (it->keyExists(message_params::kChannelName)) {
+ it->erase(message_params::kChannelName);
+ LOG4CXX_DEBUG(logger_,
+ "Cutting-off READ ONLY parameter: "
+ << message_params::kChannelName);
+ }
+ }
+ }
}
std::string SetInteriorVehicleDataRequest::ModuleType() {
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_response.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_response.cc
index 2d5d0350e1..4dedd4b5a2 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_response.cc
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_response.cc
@@ -1,4 +1,5 @@
#include "rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_response.h"
+#include "rc_rpc_plugin/interior_data_cache.h"
#include "utils/macro.h"
namespace rc_rpc_plugin {
@@ -6,18 +7,13 @@ namespace commands {
SetInteriorVehicleDataResponse::SetInteriorVehicleDataResponse(
const app_mngr::commands::MessageSharedPtr& message,
- app_mngr::ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handle,
- ResourceAllocationManager& resource_allocation_manager)
- : application_manager::commands::CommandResponseImpl(message,
- application_manager,
- rpc_service,
- hmi_capabilities,
- policy_handle) {
- UNUSED(resource_allocation_manager);
-}
+ const RCCommandParams& params)
+ : application_manager::commands::CommandResponseImpl(
+ message,
+ params.application_manager_,
+ params.rpc_service_,
+ params.hmi_capabilities_,
+ params.policy_handler_) {}
SetInteriorVehicleDataResponse::~SetInteriorVehicleDataResponse() {}
void SetInteriorVehicleDataResponse::Run() {
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/rc_command_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/rc_command_request.cc
index 524e4db7fa..40249387a7 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/rc_command_request.cc
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/rc_command_request.cc
@@ -35,6 +35,7 @@
#include "application_manager/message_helper.h"
#include "application_manager/hmi_interfaces.h"
#include "smart_objects/enum_schema_item.h"
+#include "rc_rpc_plugin/interior_data_cache.h"
CREATE_LOGGERPTR_GLOBAL(logger_, "RemoteControlModule")
@@ -43,18 +44,17 @@ namespace commands {
RCCommandRequest::RCCommandRequest(
const app_mngr::commands::MessageSharedPtr& message,
- app_mngr::ApplicationManager& application_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handle,
- rc_rpc_plugin::ResourceAllocationManager& resource_allocation_manager)
- : application_manager::commands::CommandRequestImpl(message,
- application_manager,
- rpc_service,
- hmi_capabilities,
- policy_handle)
+ const RCCommandParams& params)
+ : application_manager::commands::CommandRequestImpl(
+ message,
+ params.application_manager_,
+ params.rpc_service_,
+ params.hmi_capabilities_,
+ params.policy_handler_)
, is_subscribed(false)
- , resource_allocation_manager_(resource_allocation_manager) {}
+ , resource_allocation_manager_(params.resource_allocation_manager_)
+ , interior_data_cache_(params.interior_data_cache_)
+ , interior_data_manager_(params.interior_data_manager_) {}
RCCommandRequest::~RCCommandRequest() {}
@@ -79,12 +79,6 @@ bool RCCommandRequest::CheckDriverConsent() {
LOG4CXX_AUTO_TRACE(logger_);
app_mngr::ApplicationSharedPtr app =
application_manager_.application(CommandRequestImpl::connection_key());
- RCAppExtensionPtr extension =
- resource_allocation_manager_.GetApplicationExtention(app);
- if (!extension) {
- LOG4CXX_ERROR(logger_, "NULL pointer.");
- return false;
- }
const std::string module_type = ModuleType();
rc_rpc_plugin::TypeAccess access = CheckModule(module_type, app);
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/interior_data_cache_impl.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/interior_data_cache_impl.cc
new file mode 100644
index 0000000000..0eb175aa25
--- /dev/null
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/interior_data_cache_impl.cc
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2018, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <iostream>
+#include <thread>
+#include <chrono>
+#include "rc_rpc_plugin/interior_data_cache_impl.h"
+#include "utils/date_time.h"
+#include "utils/logger.h"
+
+namespace rc_rpc_plugin {
+
+CREATE_LOGGERPTR_GLOBAL(logger_, "RemoteControlModule");
+
+InteriorDataCacheImpl::InteriorDataCacheImpl() {}
+
+InteriorDataCacheImpl::~InteriorDataCacheImpl() {}
+
+/**
+ * @brief MergeModuleData key all keys and values from first parameter and
+ * update and append keys and values from the second
+ * @param data1 - initial data
+ * @param data2 - updated data
+ * @return updated data1 with data2 keys and values
+ */
+smart_objects::SmartObject MergeModuleData(
+ const smart_objects::SmartObject& data1,
+ const smart_objects::SmartObject& data2) {
+ smart_objects::SmartObject result = data1;
+ auto it = data2.map_begin();
+ for (; it != data2.map_end(); ++it) {
+ const std::string& key = it->first;
+ const smart_objects::SmartObject& value = it->second;
+ result[key] = value;
+ }
+ return result;
+}
+
+void InteriorDataCacheImpl::Add(const std::string& module_type,
+ const smart_objects::SmartObject& module_data) {
+ LOG4CXX_TRACE(logger_, "module_type : " << module_type);
+ sync_primitives::AutoLock autolock(cached_data_lock_);
+ auto it = cached_data_.find(module_type);
+ if (cached_data_.end() == it) {
+ cached_data_[module_type] = module_data;
+ return;
+ }
+ cached_data_[module_type] = MergeModuleData(it->second, module_data);
+}
+
+smart_objects::SmartObject InteriorDataCacheImpl::Retrieve(
+ const std::string& module_type) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ sync_primitives::AutoLock autolock(cached_data_lock_);
+ auto it = cached_data_.find(module_type);
+ if (it == cached_data_.end()) {
+ LOG4CXX_WARN(logger_,
+ "Module type " << module_type << " was not found in cache");
+ return smart_objects::SmartObject(smart_objects::SmartType_Null);
+ }
+ LOG4CXX_TRACE(logger_, "module_type : " << module_type);
+ return it->second;
+}
+
+bool InteriorDataCacheImpl::Contains(const std::string& module_type) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ sync_primitives::AutoLock autolock(cached_data_lock_);
+ auto it = cached_data_.find(module_type);
+ const bool contains = it != cached_data_.end();
+ LOG4CXX_TRACE(logger_,
+ "module_type : " << module_type << " "
+ << (contains ? "true" : "false"));
+ return contains;
+}
+
+void InteriorDataCacheImpl::Remove(const std::string& module_type) {
+ LOG4CXX_TRACE(logger_, "module_type : " << module_type);
+ sync_primitives::AutoLock autolock(cached_data_lock_);
+ auto it = cached_data_.find(module_type);
+ if (cached_data_.end() == it) {
+ LOG4CXX_TRACE(logger_, "Not existing module_type : " << module_type);
+ return;
+ }
+ cached_data_.erase(it);
+}
+
+void InteriorDataCacheImpl::Clear() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ sync_primitives::AutoLock autolock(cached_data_lock_);
+ cached_data_.clear();
+}
+}
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/interior_data_manager_impl.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/interior_data_manager_impl.cc
new file mode 100644
index 0000000000..28ed2cd941
--- /dev/null
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/interior_data_manager_impl.cc
@@ -0,0 +1,159 @@
+#include "rc_rpc_plugin/interior_data_manager_impl.h"
+#include "rc_rpc_plugin/rc_helpers.h"
+#include "rc_rpc_plugin/rc_rpc_plugin.h"
+#include "application_manager/application_manager.h"
+#include "application_manager/rpc_service.h"
+
+namespace rc_rpc_plugin {
+CREATE_LOGGERPTR_GLOBAL(logger_, "RemoteControlModule");
+
+InteriorDataManagerImpl::InteriorDataManagerImpl(
+ RCRPCPlugin& rc_plugin,
+ InteriorDataCache& cache,
+ application_manager::ApplicationManager& app_mngr,
+ application_manager::rpc_service::RPCService& rpc_service)
+ : rc_plugin_(rc_plugin)
+ , cache_(cache)
+ , app_mngr_(app_mngr)
+ , rpc_service_(rpc_service) {}
+
+void InteriorDataManagerImpl::OnPolicyEvent(plugins::PolicyEvent event) {
+ UpdateHMISubscriptionsOnPolicyUpdated();
+}
+
+void InteriorDataManagerImpl::OnApplicationEvent(
+ plugins::ApplicationEvent event,
+ app_mngr::ApplicationSharedPtr application) {
+ if (plugins::ApplicationEvent::kApplicationUnregistered == event ||
+ plugins::ApplicationEvent::kApplicationExit == event) {
+ UpdateHMISubscriptionsOnAppUnregistered(*application);
+ }
+}
+
+void InteriorDataManagerImpl::OnDisablingRC() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ auto existing_subscription = AppsSubscribedModules();
+ std::set<std::string> subscribed_modules;
+ for (auto& pair : existing_subscription) {
+ auto& app = pair.first;
+ auto rc_extension = RCHelpers::GetRCExtension(*app);
+ for (const auto& module : pair.second) {
+ subscribed_modules.insert(module);
+ rc_extension->UnsubscribeFromInteriorVehicleData(module);
+ }
+ }
+ for (auto& module : subscribed_modules) {
+ LOG4CXX_TRACE(logger_, "unsubscribe " << module);
+ UnsubscribeFromInteriorVehicleData(module);
+ }
+}
+
+void InteriorDataManagerImpl::StoreRequestToHMITime(
+ const std::string& module_type) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ sync_primitives::AutoLock autolock(requests_to_hmi_history_lock_);
+ requests_to_hmi_history_[module_type].push_back(
+ date_time::DateTime::getCurrentTime());
+}
+
+bool InteriorDataManagerImpl::CheckRequestsToHMIFrequency(
+ const std::string& module_type) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ sync_primitives::AutoLock autolock(requests_to_hmi_history_lock_);
+ ClearOldRequestsToHMIHistory();
+ const auto& history = requests_to_hmi_history_[module_type];
+ const auto limit =
+ app_mngr_.get_settings().get_interior_vehicle_data_frequency().first;
+ return history.size() < limit;
+}
+
+void InteriorDataManagerImpl::UpdateHMISubscriptionsOnPolicyUpdated() {
+ auto apps_allowed_modules =
+ RCHelpers::GetApplicationsAllowedModules(app_mngr_);
+ auto apps_subscribed_modules = AppsSubscribedModules();
+ InteriorDataManagerImpl::AppsModules apps_disallowed_modules;
+ for (auto& pair : apps_subscribed_modules) {
+ auto& allowed = apps_allowed_modules[pair.first];
+ auto& subscribed = pair.second;
+ std::vector<std::string> disallowed_modules;
+ std::set_difference(subscribed.begin(),
+ subscribed.end(),
+ allowed.begin(),
+ allowed.end(),
+ std::back_inserter(disallowed_modules));
+ apps_disallowed_modules[pair.first] = disallowed_modules;
+ }
+
+ for (auto& pair : apps_disallowed_modules) {
+ auto& app = pair.first;
+ auto rc_extension = RCHelpers::GetRCExtension(*app);
+ for (const auto& module : pair.second) {
+ rc_extension->UnsubscribeFromInteriorVehicleData(module);
+ auto apps_subscribed =
+ RCHelpers::AppsSubscribedToModuleType(app_mngr_, module);
+ if (apps_subscribed.empty()) {
+ UnsubscribeFromInteriorVehicleData(module);
+ }
+ }
+ }
+}
+
+void InteriorDataManagerImpl::UpdateHMISubscriptionsOnAppUnregistered(
+ application_manager::Application& app) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ auto rc_extension = RCHelpers::GetRCExtension(app);
+ auto subscribed_data = rc_extension->InteriorVehicleDataSubscriptions();
+ rc_extension->UnsubscribeFromInteriorVehicleData();
+ for (auto& data : subscribed_data) {
+ auto apps_subscribed =
+ RCHelpers::AppsSubscribedToModuleType(app_mngr_, data);
+ if (apps_subscribed.empty()) {
+ UnsubscribeFromInteriorVehicleData(data);
+ }
+ if (apps_subscribed.size() == 1 &&
+ apps_subscribed.front()->hmi_app_id() == app.hmi_app_id()) {
+ UnsubscribeFromInteriorVehicleData(data);
+ }
+ }
+}
+
+void InteriorDataManagerImpl::UnsubscribeFromInteriorVehicleData(
+ const std::string& module_type) {
+ cache_.Remove(module_type);
+ auto unsubscribe_request = RCHelpers::CreateUnsubscribeRequestToHMI(
+ module_type, app_mngr_.GetNextHMICorrelationID());
+ LOG4CXX_DEBUG(logger_, "Send Unsubscribe from " << module_type);
+ rpc_service_.ManageHMICommand(unsubscribe_request);
+}
+
+void InteriorDataManagerImpl::ClearOldRequestsToHMIHistory() {
+ auto limit =
+ app_mngr_.get_settings().get_interior_vehicle_data_frequency().second;
+ uint32_t time_frame = limit * date_time::DateTime::MILLISECONDS_IN_SECOND;
+ auto lest_that_time_frame_ago = [time_frame](TimevalStruct time) {
+ auto span = date_time::DateTime::calculateTimeSpan(time);
+ return span < time_frame;
+ };
+ for (auto& it : requests_to_hmi_history_) {
+ auto& history = it.second;
+ auto first_actual =
+ std::find_if(history.begin(), history.end(), lest_that_time_frame_ago);
+ history.erase(history.begin(), first_actual);
+ }
+}
+
+InteriorDataManagerImpl::AppsModules
+InteriorDataManagerImpl::AppsSubscribedModules() {
+ auto apps_list = RCRPCPlugin::GetRCApplications(app_mngr_);
+ InteriorDataManagerImpl::AppsModules result;
+ for (auto& app_ptr : apps_list) {
+ const auto rc_extension = RCHelpers::GetRCExtension(*app_ptr);
+ auto app_subscriptions = rc_extension->InteriorVehicleDataSubscriptions();
+ result[app_ptr] = std::vector<std::string>(app_subscriptions.size());
+ std::copy(app_subscriptions.begin(),
+ app_subscriptions.end(),
+ result[app_ptr].begin());
+ }
+ return result;
+}
+} // namespace rc_rpc_plugin
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_app_extension.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_app_extension.cc
index 5c0a94cccc..17f19e24e8 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_app_extension.cc
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_app_extension.cc
@@ -64,5 +64,9 @@ void RCAppExtension::SaveResumptionData(
void RCAppExtension::ProcessResumption(
const NsSmartDeviceLink::NsSmartObjects::SmartObject& resumption_data) {}
+std::set<std::string> RCAppExtension::InteriorVehicleDataSubscriptions() const {
+ return subscribed_interior_vehicle_data_;
+}
+
RCAppExtension::~RCAppExtension() {}
} // namespace rc_rpc_plugin
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_command_factory.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_command_factory.cc
index 707d35aa0f..ecfc1dcda4 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_command_factory.cc
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_command_factory.cc
@@ -29,6 +29,7 @@
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
+#include <iostream>
#include "rc_rpc_plugin/rc_command_factory.h"
#include "rc_rpc_plugin/commands/mobile/button_press_request.h"
@@ -53,24 +54,18 @@
#include "interfaces/HMI_API.h"
#include "rc_rpc_plugin/resource_allocation_manager.h"
+#include "rc_rpc_plugin/interior_data_cache.h"
CREATE_LOGGERPTR_GLOBAL(logger_, "RemoteControlModule")
namespace application_manager {
using rc_rpc_plugin::ResourceAllocationManager;
+using rc_rpc_plugin::InteriorDataCache;
+using rc_rpc_plugin::RCCommandParams;
template <typename RCCommandType>
class RCCommandCreator : public CommandCreator {
public:
- RCCommandCreator(ApplicationManager& application_manager,
- rpc_service::RPCService& rpc_service,
- HMICapabilities& hmi_capabilities,
- PolicyHandlerInterface& policy_handler,
- ResourceAllocationManager& resource_allocation_manager)
- : application_manager_(application_manager)
- , rpc_service_(rpc_service)
- , hmi_capabilities_(hmi_capabilities)
- , policy_handler_(policy_handler)
- , resource_allocation_manager_(resource_allocation_manager) {}
+ RCCommandCreator(const RCCommandParams& params) : params_(params) {}
private:
bool CanBeCreated() const override {
@@ -79,20 +74,11 @@ class RCCommandCreator : public CommandCreator {
CommandSharedPtr create(
const commands::MessageSharedPtr& message) const override {
- CommandSharedPtr command(new RCCommandType(message,
- application_manager_,
- rpc_service_,
- hmi_capabilities_,
- policy_handler_,
- resource_allocation_manager_));
+ CommandSharedPtr command(new RCCommandType(message, params_));
return command;
}
- ApplicationManager& application_manager_;
- RPCService& rpc_service_;
- HMICapabilities& hmi_capabilities_;
- PolicyHandlerInterface& policy_handler_;
- ResourceAllocationManager& resource_allocation_manager_;
+ RCCommandParams params_;
};
struct RCInvalidCommand {};
@@ -100,16 +86,8 @@ struct RCInvalidCommand {};
template <>
class RCCommandCreator<RCInvalidCommand> : public CommandCreator {
public:
- RCCommandCreator(ApplicationManager& application_manager,
- RPCService& rpc_service,
- HMICapabilities& hmi_capabilities,
- PolicyHandlerInterface& policy_handler,
- ResourceAllocationManager& resource_allocation_manager) {
- UNUSED(application_manager);
- UNUSED(rpc_service);
- UNUSED(hmi_capabilities);
- UNUSED(policy_handler);
- UNUSED(resource_allocation_manager);
+ RCCommandCreator(const RCCommandParams& params) {
+ UNUSED(params);
}
private:
@@ -125,49 +103,23 @@ class RCCommandCreator<RCInvalidCommand> : public CommandCreator {
};
struct RCCommandCreatorFactory {
- RCCommandCreatorFactory(
- ApplicationManager& application_manager,
- rpc_service::RPCService& rpc_service,
- HMICapabilities& hmi_capabilities,
- PolicyHandlerInterface& policy_handler,
- ResourceAllocationManager& resource_allocation_manager)
- : application_manager_(application_manager)
- , rpc_service_(rpc_service)
- , hmi_capabilities_(hmi_capabilities)
- , policy_handler_(policy_handler)
- , resource_allocation_manager_(resource_allocation_manager) {}
+ RCCommandCreatorFactory(const RCCommandParams& params) : params_(params) {}
template <typename RCCommandType>
CommandCreator& GetCreator() {
- static RCCommandCreator<RCCommandType> res(application_manager_,
- rpc_service_,
- hmi_capabilities_,
- policy_handler_,
- resource_allocation_manager_);
+ LOG4CXX_AUTO_TRACE(logger_);
+ static RCCommandCreator<RCCommandType> res(params_);
return res;
}
- ApplicationManager& application_manager_;
- RPCService& rpc_service_;
- HMICapabilities& hmi_capabilities_;
- PolicyHandlerInterface& policy_handler_;
- ResourceAllocationManager& resource_allocation_manager_;
+ const RCCommandParams params_;
};
}
namespace rc_rpc_plugin {
using namespace application_manager;
-RCCommandFactory::RCCommandFactory(
- app_mngr::ApplicationManager& app_manager,
- app_mngr::rpc_service::RPCService& rpc_service,
- app_mngr::HMICapabilities& hmi_capabilities,
- policy::PolicyHandlerInterface& policy_handler,
- ResourceAllocationManager& allocation_manager)
- : app_manager_(app_manager)
- , rpc_service_(rpc_service)
- , hmi_capabilities_(hmi_capabilities)
- , policy_handler_(policy_handler)
- , allocation_manager_(allocation_manager) {}
+RCCommandFactory::RCCommandFactory(const RCCommandParams& params)
+ : params_(params) {}
CommandSharedPtr RCCommandFactory::CreateCommand(
const app_mngr::commands::MessageSharedPtr& message,
@@ -218,11 +170,7 @@ CommandCreator& RCCommandFactory::get_mobile_creator_factory(
LOG4CXX_DEBUG(logger_,
"CreateMobileCommand function_id: " << id << " message_type: "
<< message_type);
- RCCommandCreatorFactory rc_factory(app_manager_,
- rpc_service_,
- hmi_capabilities_,
- policy_handler_,
- allocation_manager_);
+ RCCommandCreatorFactory rc_factory(params_);
switch (id) {
case mobile_apis::FunctionID::ButtonPressID: {
@@ -259,11 +207,7 @@ CommandCreator& RCCommandFactory::get_hmi_creator_factory(
"CreateHMICommand function_id: " << id << " message_type: "
<< message_type);
- RCCommandCreatorFactory rc_factory(app_manager_,
- rpc_service_,
- hmi_capabilities_,
- policy_handler_,
- allocation_manager_);
+ RCCommandCreatorFactory rc_factory(params_);
switch (id) {
case hmi_apis::FunctionID::Buttons_ButtonPress: {
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_helpers.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_helpers.cc
new file mode 100644
index 0000000000..0bdec55733
--- /dev/null
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_helpers.cc
@@ -0,0 +1,118 @@
+#include "rc_rpc_plugin/rc_helpers.h"
+#include "rc_rpc_plugin/rc_module_constants.h"
+#include "rc_rpc_plugin/rc_rpc_plugin.h"
+#include "application_manager/smart_object_keys.h"
+#include "application_manager/commands/command_impl.h"
+#include "application_manager/message.h"
+
+namespace rc_rpc_plugin {
+CREATE_LOGGERPTR_GLOBAL(logger_, "RemoteControlModule");
+
+const std::function<std::string(const std::string& module_type)>
+RCHelpers::GetModuleTypeToDataMapping() {
+ auto mapping_lambda = [](const std::string& module_type) -> std::string {
+ static std::map<std::string, std::string> mapping = {
+ {enums_value::kClimate, message_params::kClimateControlData},
+ {enums_value::kRadio, message_params::kRadioControlData},
+ {enums_value::kSeat, message_params::kSeatControlData},
+ {enums_value::kAudio, message_params::kAudioControlData},
+ {enums_value::kLight, message_params::kLightControlData},
+ {enums_value::kHmiSettings, message_params::kHmiSettingsControlData}};
+ auto it = mapping.find(module_type);
+ if (mapping.end() == it) {
+ LOG4CXX_ERROR(logger_, "Unknown module type" << module_type);
+ return std::string();
+ }
+ return it->second;
+ };
+
+ return mapping_lambda;
+}
+
+const std::function<std::string(const std::string& module_type)>
+RCHelpers::GetModuleTypeToCapabilitiesMapping() {
+ auto mapping_lambda = [](const std::string& module_type) -> std::string {
+ static std::map<std::string, std::string> mapping = {
+ {enums_value::kClimate, strings::kclimateControlCapabilities},
+ {enums_value::kRadio, strings::kradioControlCapabilities},
+ {enums_value::kSeat, strings::kseatControlCapabilities},
+ {enums_value::kAudio, strings::kaudioControlCapabilities},
+ {enums_value::kLight, strings::klightControlCapabilities},
+ {enums_value::kHmiSettings, strings::khmiSettingsControlCapabilities}};
+ auto it = mapping.find(module_type);
+ if (mapping.end() == it) {
+ LOG4CXX_ERROR(logger_, "Unknown module type" << module_type);
+ return std::string();
+ }
+ return it->second;
+ };
+
+ return mapping_lambda;
+}
+
+const std::vector<std::string> RCHelpers::GetModulesList() {
+ using namespace enums_value;
+ return {kClimate, kRadio, kSeat, kAudio, kLight, kHmiSettings};
+}
+
+RCAppExtensionPtr RCHelpers::GetRCExtension(
+ application_manager::Application& app) {
+ auto extension_interface = app.QueryInterface(RCRPCPlugin::kRCPluginID);
+ auto extension =
+ std::static_pointer_cast<RCAppExtension>(extension_interface);
+ return extension;
+}
+
+smart_objects::SmartObjectSPtr RCHelpers::CreateUnsubscribeRequestToHMI(
+ const std::string& module_type, const uint32_t correlation_id) {
+ using namespace smart_objects;
+ namespace commands = application_manager::commands;
+ namespace am_strings = application_manager::strings;
+
+ SmartObjectSPtr message = std::make_shared<SmartObject>(SmartType_Map);
+ SmartObject& params = (*message)[am_strings::params];
+ SmartObject& msg_params = (*message)[am_strings::msg_params];
+
+ params[am_strings::message_type] =
+ static_cast<int>(application_manager::kRequest);
+ params[am_strings::protocol_version] =
+ commands::CommandImpl::protocol_version_;
+ params[am_strings::protocol_type] = commands::CommandImpl::hmi_protocol_type_;
+ params[am_strings::correlation_id] = correlation_id;
+ params[am_strings::function_id] =
+ hmi_apis::FunctionID::RC_GetInteriorVehicleData;
+ msg_params[message_params::kSubscribe] = false;
+ msg_params[message_params::kModuleType] = module_type;
+ return message;
+}
+
+std::vector<application_manager::ApplicationSharedPtr>
+RCHelpers::AppsSubscribedToModuleType(
+ application_manager::ApplicationManager& app_mngr,
+ const std::string& module_type) {
+ std::vector<application_manager::ApplicationSharedPtr> result;
+ auto rc_apps = RCRPCPlugin::GetRCApplications(app_mngr);
+ for (auto& app : rc_apps) {
+ auto rc_ext = RCHelpers::GetRCExtension(*app);
+ DCHECK_OR_RETURN(rc_ext, result);
+ if (rc_ext->IsSubscibedToInteriorVehicleData(module_type)) {
+ result.push_back(app);
+ }
+ }
+ return result;
+}
+
+RCHelpers::AppsModules RCHelpers::GetApplicationsAllowedModules(
+ app_mngr::ApplicationManager& app_mngr) {
+ auto apps_list = RCRPCPlugin::GetRCApplications(app_mngr);
+ RCHelpers::AppsModules result;
+ for (auto& app_ptr : apps_list) {
+ std::vector<std::string> allowed_modules;
+ app_mngr.GetPolicyHandler().GetModuleTypes(app_ptr->policy_app_id(),
+ &allowed_modules);
+ std::sort(allowed_modules.begin(), allowed_modules.end());
+ result[app_ptr] = allowed_modules;
+ }
+ return result;
+}
+}
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_rpc_plugin.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_rpc_plugin.cc
index 984d6ec9a0..fd6b4e86ac 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_rpc_plugin.cc
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_rpc_plugin.cc
@@ -34,10 +34,15 @@
#include "rc_rpc_plugin/rc_command_factory.h"
#include "rc_rpc_plugin/rc_app_extension.h"
#include "rc_rpc_plugin/resource_allocation_manager_impl.h"
+#include "rc_rpc_plugin/interior_data_cache_impl.h"
+#include "rc_rpc_plugin/interior_data_manager_impl.h"
+#include "rc_rpc_plugin/rc_helpers.h"
#include "utils/helpers.h"
#include <memory>
namespace rc_rpc_plugin {
+CREATE_LOGGERPTR_GLOBAL(logger_, "RemoteControlModule");
+
namespace plugins = application_manager::plugin_manager;
bool RCRPCPlugin::Init(
@@ -45,14 +50,22 @@ bool RCRPCPlugin::Init(
application_manager::rpc_service::RPCService& rpc_service,
application_manager::HMICapabilities& hmi_capabilities,
policy::PolicyHandlerInterface& policy_handler) {
+ interior_data_cache_.reset(new InteriorDataCacheImpl());
+ interior_data_manager_.reset(new InteriorDataManagerImpl(
+ *this, *interior_data_cache_, app_manager, rpc_service));
+
resource_allocation_manager_.reset(
new ResourceAllocationManagerImpl(app_manager, rpc_service));
- command_factory_.reset(
- new rc_rpc_plugin::RCCommandFactory(app_manager,
- rpc_service,
- hmi_capabilities,
- policy_handler,
- *resource_allocation_manager_));
+ RCCommandParams params{app_manager,
+ rpc_service,
+ hmi_capabilities,
+ policy_handler,
+ *(resource_allocation_manager_.get()),
+ *(interior_data_cache_.get()),
+ *(interior_data_manager_.get())};
+ command_factory_.reset(new rc_rpc_plugin::RCCommandFactory(params));
+ rpc_service_ = &rpc_service;
+ app_mngr_ = &app_manager;
return true;
}
@@ -73,14 +86,8 @@ application_manager::CommandFactory& RCRPCPlugin::GetCommandFactory() {
void RCRPCPlugin::OnPolicyEvent(
application_manager::plugin_manager::PolicyEvent event) {
- switch (event) {
- case plugins::kApplicationPolicyUpdated: {
- resource_allocation_manager_->OnPolicyEvent(event);
- break;
- }
- default:
- break;
- }
+ resource_allocation_manager_->OnPolicyEvent(event);
+ interior_data_manager_->OnPolicyEvent(event);
}
void RCRPCPlugin::OnApplicationEvent(
@@ -99,10 +106,12 @@ void RCRPCPlugin::OnApplicationEvent(
}
case plugins::kApplicationExit: {
resource_allocation_manager_->OnApplicationEvent(event, application);
+ interior_data_manager_->OnApplicationEvent(event, application);
break;
}
case plugins::kApplicationUnregistered: {
resource_allocation_manager_->OnApplicationEvent(event, application);
+ interior_data_manager_->OnApplicationEvent(event, application);
break;
}
default:
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/resource_allocation_manager_impl.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/resource_allocation_manager_impl.cc
index 011950b35a..ecd263b77a 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/resource_allocation_manager_impl.cc
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/resource_allocation_manager_impl.cc
@@ -36,9 +36,10 @@
#include "interfaces/HMI_API.h"
#include "interfaces/MOBILE_API.h"
#include "smart_objects/enum_schema_item.h"
-#include "rc_rpc_plugin/rc_rpc_plugin.h"
#include "application_manager/message_helper.h"
+#include "rc_rpc_plugin/rc_rpc_plugin.h"
#include "rc_rpc_plugin/rc_module_constants.h"
+#include "rc_rpc_plugin/rc_helpers.h"
#include "json/json.h"
#include "utils/helpers.h"
@@ -166,13 +167,10 @@ void ResourceAllocationManagerImpl::ProcessApplicationPolicyUpdate() {
allowed_modules.end(),
std::back_inserter(disallowed_modules));
- RCAppExtensionPtr rc_extention = GetApplicationExtention(app_ptr);
+ auto rc_extention = RCHelpers::GetRCExtension(**app);
Resources::const_iterator module = disallowed_modules.begin();
for (; disallowed_modules.end() != module; ++module) {
ReleaseResource(*module, application_id);
- if (rc_extention) {
- rc_extention->UnsubscribeFromInteriorVehicleData(*module);
- }
}
if (!disallowed_modules.empty()) {
SendOnRCStatusNotifications(
@@ -182,40 +180,6 @@ void ResourceAllocationManagerImpl::ProcessApplicationPolicyUpdate() {
}
}
-RCAppExtensionPtr ResourceAllocationManagerImpl::GetApplicationExtention(
- application_manager::ApplicationSharedPtr application) {
- LOG4CXX_AUTO_TRACE(logger_);
- RCAppExtensionPtr rc_app_extension;
- if (!application) {
- return rc_app_extension;
- }
-
- application_manager::AppExtensionPtr app_extension =
- application->QueryInterface(RCRPCPlugin::kRCPluginID);
- if (!app_extension) {
- return rc_app_extension;
- }
-
- rc_app_extension = std::static_pointer_cast<RCAppExtension>(app_extension);
-
- return rc_app_extension;
-}
-
-void ResourceAllocationManagerImpl::RemoveAppsSubscriptions(const Apps& apps) {
- LOG4CXX_AUTO_TRACE(logger_);
- Apps::const_iterator app = apps.begin();
- for (; apps.end() != app; ++app) {
- application_manager::ApplicationSharedPtr app_ptr = *app;
- if (!app_ptr) {
- continue;
- }
- RCAppExtensionPtr rc_extention = GetApplicationExtention(app_ptr);
- if (rc_extention) {
- rc_extention->UnsubscribeFromInteriorVehicleData();
- }
- }
-}
-
template <typename EnumType>
EnumType StringToEnum(const std::string& str) {
using smart_objects::EnumConversionHelper;
@@ -235,6 +199,7 @@ void ConstructOnRCStatusNotificationParams(
using smart_objects::SmartType_Map;
using smart_objects::SmartType_Array;
LOG4CXX_AUTO_TRACE(logger_);
+
auto modules_inserter = [](SmartObject& result_modules) {
return [&result_modules](const std::string& module_name) {
smart_objects::SmartObject module_data =
@@ -273,7 +238,7 @@ ResourceAllocationManagerImpl::CreateOnRCStatusNotificationToMobile(
if (is_rc_enabled()) {
ConstructOnRCStatusNotificationParams(msg_params,
allocated_resources_,
- all_supported_modules(),
+ RCHelpers::GetModulesList(),
app->app_id());
} else {
msg_params[message_params::kAllocatedModules] =
@@ -292,8 +257,10 @@ ResourceAllocationManagerImpl::CreateOnRCStatusNotificationToHmi(
auto msg_to_hmi =
MessageHelper::CreateHMINotification(hmi_apis::FunctionID::RC_OnRCStatus);
auto& msg_params = (*msg_to_hmi)[application_manager::strings::msg_params];
- ConstructOnRCStatusNotificationParams(
- msg_params, allocated_resources_, all_supported_modules(), app->app_id());
+ ConstructOnRCStatusNotificationParams(msg_params,
+ allocated_resources_,
+ RCHelpers::GetModulesList(),
+ app->app_id());
msg_params[application_manager::strings::app_id] = app->hmi_app_id();
return msg_to_hmi;
}
@@ -361,15 +328,6 @@ void ResourceAllocationManagerImpl::SetResourceFree(
LOG4CXX_DEBUG(logger_, "Resource " << module_type << " is released.");
}
-std::vector<std::string>
-ResourceAllocationManagerImpl::all_supported_modules() {
- std::vector<std::string> result;
- result.push_back(enums_value::kClimate);
- result.push_back(enums_value::kRadio);
- result.push_back(enums_value::kSeat);
- return result;
-}
-
std::vector<std::string> ResourceAllocationManagerImpl::GetAcquiredResources(
const uint32_t application_id) const {
LOG4CXX_AUTO_TRACE(logger_);
@@ -510,9 +468,6 @@ void ResourceAllocationManagerImpl::OnApplicationEvent(
NotificationTrigger::MODULE_ALLOCATION,
std::shared_ptr<application_manager::Application>());
}
- Apps app_list;
- app_list.push_back(application);
- RemoveAppsSubscriptions(app_list);
}
}
@@ -529,8 +484,6 @@ void ResourceAllocationManagerImpl::OnPolicyEvent(
if (PolicyEvent::kApplicationsDisabled == event) {
ResetAllAllocations();
- Apps app_list = RCRPCPlugin::GetRCApplications(app_mngr_);
- RemoveAppsSubscriptions(app_list);
return;
}
}
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/CMakeLists.txt b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/CMakeLists.txt
index a1f0f5a6ff..c1c59d7e78 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/CMakeLists.txt
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/CMakeLists.txt
@@ -41,6 +41,7 @@ include_directories (
set (RC_TEST_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/resource_allocation_manager_impl_test.cc
+${CMAKE_CURRENT_SOURCE_DIR}/interior_data_cache_test.cc
)
set(RC_COMMANDS_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/commands)
@@ -72,5 +73,5 @@ if(ENABLE_LOG)
endif()
create_test("rc_commands_test" "${SOURCES}" "${LIBRARIES}" )
-create_test("resource_allocation_manager_test" "${RC_TEST_SOURCES}" "${LIBRARIES}")
+create_test("rc_plugin_test" "${RC_TEST_SOURCES}" "${LIBRARIES}")
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/button_press_request_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/button_press_request_test.cc
index 8ddcaa469d..022a3e51c9 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/button_press_request_test.cc
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/button_press_request_test.cc
@@ -37,6 +37,8 @@
#include "rc_rpc_plugin/rc_rpc_plugin.h"
#include "rc_rpc_plugin/rc_module_constants.h"
#include "rc_rpc_plugin/mock/mock_resource_allocation_manager.h"
+#include "rc_rpc_plugin/mock/mock_interior_data_cache.h"
+#include "rc_rpc_plugin/mock/mock_interior_data_manager.h"
#include "application_manager/mock_application.h"
#include "application_manager/mock_application_manager.h"
#include "application_manager/commands/command_request_test.h"
@@ -115,7 +117,7 @@ class ButtonPressRequestTest
}
rc_capabilities_[strings::kbuttonCapabilities] = button_caps;
ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app_));
- ON_CALL(mock_allocation_manager_, GetApplicationExtention(_))
+ ON_CALL(*mock_app_, QueryInterface(RCRPCPlugin::kRCPluginID))
.WillByDefault(Return(rc_app_extention_));
ON_CALL(app_mngr_, GetPolicyHandler())
.WillByDefault(ReturnRef(mock_policy_handler_));
@@ -147,12 +149,14 @@ class ButtonPressRequestTest
template <class Command>
std::shared_ptr<Command> CreateRCCommand(MessageSharedPtr& msg) {
InitCommand(kDefaultTimeout_);
- return std::make_shared<Command>(msg ? msg : msg = CreateMessage(),
- app_mngr_,
- mock_rpc_service_,
- mock_hmi_capabilities_,
- mock_policy_handler_,
- mock_allocation_manager_);
+ RCCommandParams params{app_mngr_,
+ mock_rpc_service_,
+ mock_hmi_capabilities_,
+ mock_policy_handler_,
+ mock_allocation_manager_,
+ mock_interior_data_cache_,
+ mock_interior_data_manager_};
+ return std::make_shared<Command>(msg ? msg : msg = CreateMessage(), params);
}
protected:
@@ -163,6 +167,10 @@ class ButtonPressRequestTest
mock_policy_handler_;
testing::NiceMock<rc_rpc_plugin_test::MockResourceAllocationManager>
mock_allocation_manager_;
+ testing::NiceMock<rc_rpc_plugin_test::MockInteriorDataCache>
+ mock_interior_data_cache_;
+ testing::NiceMock<rc_rpc_plugin_test::MockInteriorDataManager>
+ mock_interior_data_manager_;
};
TEST_F(ButtonPressRequestTest,
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/get_interior_vehicle_data_request_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/get_interior_vehicle_data_request_test.cc
index a6f0ee12ca..0b30bbf654 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/get_interior_vehicle_data_request_test.cc
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/get_interior_vehicle_data_request_test.cc
@@ -35,11 +35,17 @@
#include "application_manager/mock_application.h"
#include "rc_rpc_plugin/rc_app_extension.h"
#include "rc_rpc_plugin/rc_module_constants.h"
+#include "rc_rpc_plugin/rc_rpc_plugin.h"
#include "application_manager/message_helper.h"
#include "rc_rpc_plugin/rc_command_factory.h"
#include "application_manager/event_engine/event_dispatcher.h"
#include "application_manager/commands/command_request_test.h"
#include "rc_rpc_plugin/mock/mock_resource_allocation_manager.h"
+#include "rc_rpc_plugin/mock/mock_interior_data_cache.h"
+#include "rc_rpc_plugin/mock/mock_interior_data_manager.h"
+
+#include <thread>
+#include <chrono>
using ::testing::_;
using ::testing::Mock;
@@ -50,6 +56,7 @@ using ::testing::ReturnRef;
using ::testing::SaveArg;
using ::application_manager::Message;
using ::application_manager::MessageType;
+using application_manager::ApplicationSet;
using application_manager::commands::MessageSharedPtr;
using ::application_manager::ApplicationSharedPtr;
using ::protocol_handler::MessagePriority;
@@ -64,7 +71,11 @@ using test::components::commands_test::MobileResultCodeIs;
namespace {
const int32_t kConnectionKey = 5u;
const uint32_t kAppId = 0u;
+const uint32_t kAppId2 = 1u;
const int kModuleId = 153u;
+const auto module_type = mobile_apis::ModuleType::RADIO;
+const int32_t time_frame_of_allowed_requests = 1;
+const uint32_t max_request_in_time_frame = 5u;
}
namespace rc_rpc_plugin_test {
@@ -75,163 +86,508 @@ class GetInteriorVehicleDataRequestTest
public:
GetInteriorVehicleDataRequestTest()
: mock_app_(std::make_shared<NiceMock<MockApplication> >())
- , rc_app_extention_(std::make_shared<RCAppExtension>(kModuleId)) {
+ , mock_app2_(std::make_shared<NiceMock<MockApplication> >())
+ , rc_app_extention_(std::make_shared<RCAppExtension>(kModuleId))
+ , rc_app_extention2_(std::make_shared<RCAppExtension>(kModuleId))
+ , apps_lock_(std::make_shared<sync_primitives::Lock>())
+ , apps_da_(apps_, apps_lock_) {
ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kAppId));
+ ON_CALL(*mock_app2_, app_id()).WillByDefault(Return(kAppId2));
+ ON_CALL(*mock_app_, is_remote_control_supported())
+ .WillByDefault(Return(true));
+ ON_CALL(*mock_app2_, is_remote_control_supported())
+ .WillByDefault(Return(true));
+ ON_CALL(*mock_app_, QueryInterface(_))
+ .WillByDefault(Return(rc_app_extention_));
+ ON_CALL(*mock_app2_, QueryInterface(_))
+ .WillByDefault(Return(rc_app_extention2_));
+ }
+
+ /**
+ * @brief CreateBasicMessage creates message for
+ * GetInteriorVehicleData request for app1
+ * @return message shared ptr
+ */
+ MessageSharedPtr CreateBasicMessage() {
+ MessageSharedPtr message = CreateMessage();
+ (*message)[application_manager::strings::params]
+ [application_manager::strings::function_id] =
+ mobile_apis::FunctionID::GetInteriorVehicleDataID;
+ (*message)[application_manager::strings::params]
+ [application_manager::strings::connection_key] = kConnectionKey;
+ (*message)[application_manager::strings::params]
+ [application_manager::strings::connection_key] = kAppId;
+ return message;
+ }
+
+ void SetUp() OVERRIDE {
+ std::pair<uint32_t, int32_t> frequency;
+ frequency.first = max_request_in_time_frame;
+ frequency.second = time_frame_of_allowed_requests;
+ ON_CALL(app_mngr_, get_settings())
+ .WillByDefault(ReturnRef(app_mngr_settings_));
+ ON_CALL(app_mngr_settings_, get_interior_vehicle_data_frequency())
+ .WillByDefault(ReturnRef(frequency));
+
ON_CALL(app_mngr_, hmi_interfaces())
.WillByDefault(ReturnRef(mock_hmi_interfaces_));
-
ON_CALL(
mock_hmi_interfaces_,
GetInterfaceState(application_manager::HmiInterfaces::HMI_INTERFACE_RC))
.WillByDefault(Return(application_manager::HmiInterfaces::
InterfaceState::STATE_AVAILABLE));
ON_CALL(app_mngr_, application(kAppId)).WillByDefault(Return(mock_app_));
- ON_CALL(mock_allocation_manager_, GetApplicationExtention(_))
- .WillByDefault(Return(rc_app_extention_));
+ ON_CALL(app_mngr_, application(kAppId2)).WillByDefault(Return(mock_app2_));
ON_CALL(app_mngr_, GetPolicyHandler())
.WillByDefault(ReturnRef(mock_policy_handler_));
ON_CALL(app_mngr_, hmi_capabilities())
.WillByDefault(ReturnRef(mock_hmi_capabilities_));
ON_CALL(mock_hmi_capabilities_, rc_capability())
- .WillByDefault(Return(&rc_capabilities_));
+ .WillByDefault(Return(nullptr));
ON_CALL(mock_policy_handler_,
CheckHMIType(
_, mobile_apis::AppHMIType::eType::REMOTE_CONTROL, nullptr))
.WillByDefault(Return(true));
+ ON_CALL(mock_policy_handler_, CheckModule(_, _))
+ .WillByDefault(Return(true));
ON_CALL(mock_allocation_manager_, is_rc_enabled())
.WillByDefault(Return(true));
}
- MessageSharedPtr CreateBasicMessage() {
- MessageSharedPtr message = CreateMessage();
- (*message)[application_manager::strings::params]
- [application_manager::strings::function_id] =
- mobile_apis::FunctionID::GetInteriorVehicleDataID;
- (*message)[application_manager::strings::params]
- [application_manager::strings::connection_key] = kConnectionKey;
- (*message)[application_manager::strings::params]
- [application_manager::strings::connection_key] = kAppId;
- return message;
- }
template <class Command>
std::shared_ptr<Command> CreateRCCommand(MessageSharedPtr& msg) {
InitCommand(kDefaultTimeout_);
- return std::make_shared<Command>(msg ? msg : msg = CreateMessage(),
- app_mngr_,
- mock_rpc_service_,
- mock_hmi_capabilities_,
- mock_policy_handler_,
- mock_allocation_manager_);
+ RCCommandParams params{app_mngr_,
+ mock_rpc_service_,
+ mock_hmi_capabilities_,
+ mock_policy_handler_,
+ mock_allocation_manager_,
+ mock_interior_data_cache_,
+ mock_interior_data_manager_};
+ return std::make_shared<Command>(msg ? msg : msg = CreateMessage(), params);
}
protected:
- smart_objects::SmartObject rc_capabilities_;
std::shared_ptr<MockApplication> mock_app_;
+ std::shared_ptr<MockApplication> mock_app2_;
std::shared_ptr<RCAppExtension> rc_app_extention_;
+ std::shared_ptr<RCAppExtension> rc_app_extention2_;
testing::NiceMock<rc_rpc_plugin_test::MockResourceAllocationManager>
mock_allocation_manager_;
+ testing::NiceMock<rc_rpc_plugin_test::MockInteriorDataCache>
+ mock_interior_data_cache_;
+ testing::NiceMock<rc_rpc_plugin_test::MockInteriorDataManager>
+ mock_interior_data_manager_;
+ application_manager::ApplicationSet apps_;
+ const std::shared_ptr<sync_primitives::Lock> apps_lock_;
+ DataAccessor<application_manager::ApplicationSet> apps_da_;
};
+
TEST_F(GetInteriorVehicleDataRequestTest,
- Execute_MessageValidationOk_ExpectCorrectMessageSentToHMI) {
+ Execute_ExpectCorrectMessageSentToHMI_NoSubscriptionNoCache) {
// Arrange
- ON_CALL(mock_policy_handler_, CheckModule(_, _)).WillByDefault(Return(true));
- EXPECT_CALL(mock_hmi_capabilities_, rc_capability())
- .WillOnce(Return(nullptr));
+ MessageSharedPtr mobile_message = CreateBasicMessage();
+ (*mobile_message)[application_manager::strings::msg_params]
+ [message_params::kModuleType] = module_type;
+ ON_CALL(mock_interior_data_cache_, Contains(enums_value::kRadio))
+ .WillByDefault(Return(false));
+ ON_CALL(mock_interior_data_manager_, CheckRequestsToHMIFrequency(_))
+ .WillByDefault(Return(true));
+ std::shared_ptr<
+ rc_rpc_plugin::commands::GetInteriorVehicleDataRequest> command =
+ CreateRCCommand<rc_rpc_plugin::commands::GetInteriorVehicleDataRequest>(
+ mobile_message);
+
+ // Expectations
EXPECT_CALL(mock_rpc_service_,
ManageHMICommand(HMIResultCodeIs(
hmi_apis::FunctionID::RC_GetInteriorVehicleData)))
.WillOnce(Return(true));
+ // Act
+ command->Run();
+}
+
+TEST_F(GetInteriorVehicleDataRequestTest,
+ Execute_ExpectCorrectMessageSentToHMI_SupscribeAppNoCache) {
+ // Arrange
MessageSharedPtr mobile_message = CreateBasicMessage();
+ (*mobile_message)[application_manager::strings::msg_params]
+ [message_params::kModuleType] = module_type;
+ (*mobile_message)[application_manager::strings::msg_params]
+ [message_params::kSubscribe] = true;
+ ON_CALL(mock_interior_data_cache_, Contains(enums_value::kRadio))
+ .WillByDefault(Return(false));
+ ON_CALL(mock_interior_data_manager_, CheckRequestsToHMIFrequency(_))
+ .WillByDefault(Return(true));
std::shared_ptr<
rc_rpc_plugin::commands::GetInteriorVehicleDataRequest> command =
CreateRCCommand<rc_rpc_plugin::commands::GetInteriorVehicleDataRequest>(
mobile_message);
+
+ // Expectations
+ EXPECT_CALL(mock_rpc_service_,
+ ManageHMICommand(HMIResultCodeIs(
+ hmi_apis::FunctionID::RC_GetInteriorVehicleData)))
+ .WillOnce(Return(true));
+ // Act
command->Run();
}
TEST_F(
GetInteriorVehicleDataRequestTest,
- Execute_MessageValidationFailed_ExpectMessageNotSentToHMI_AndFalseSentToMobile) {
+ Execute_ExpectMessageNotSentToHMI_SuccessSentToMobile_AppSubscribed_DataFromCache) {
// Arrange
+ rc_app_extention_->SubscribeToInteriorVehicleData(enums_value::kRadio);
MessageSharedPtr mobile_message = CreateBasicMessage();
- NsSmartDeviceLink::NsSmartObjects::SmartObject& msg_params =
- (*mobile_message)[application_manager::strings::msg_params];
- msg_params[message_params::kModuleType] = mobile_apis::ModuleType::RADIO;
- ON_CALL(mock_policy_handler_, CheckModule(_, _)).WillByDefault(Return(true));
- MessageSharedPtr command_result;
- EXPECT_CALL(mock_rpc_service_,
- ManageHMICommand(HMIResultCodeIs(
- hmi_apis::FunctionID::RC_GetInteriorVehicleData))).Times(0);
- EXPECT_CALL(
- mock_rpc_service_,
- ManageMobileCommand(
- MobileResultCodeIs(mobile_apis::Result::UNSUPPORTED_RESOURCE), _))
- .WillOnce(DoAll(SaveArg<0>(&command_result), Return(true)));
+ (*mobile_message)[application_manager::strings::msg_params]
+ [message_params::kModuleType] = module_type;
+ smart_objects::SmartObject radio_data;
+ radio_data[message_params::kBand] = enums_value::kAM;
std::shared_ptr<
rc_rpc_plugin::commands::GetInteriorVehicleDataRequest> command =
CreateRCCommand<rc_rpc_plugin::commands::GetInteriorVehicleDataRequest>(
mobile_message);
+
+ // Expectations
+ EXPECT_CALL(mock_interior_data_cache_, Contains(enums_value::kRadio))
+ .WillOnce(Return(true));
+ EXPECT_CALL(mock_interior_data_cache_, Retrieve(enums_value::kRadio))
+ .WillOnce(Return(radio_data));
+ EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).Times(0);
+ MessageSharedPtr command_result;
+ EXPECT_CALL(
+ mock_rpc_service_,
+ ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::SUCCESS), _))
+ .WillOnce(DoAll(SaveArg<0>(&command_result), Return(true)));
+
+ // Act
command->Run();
+
+ // Assert
+ EXPECT_EQ((*command_result)[application_manager::strings::msg_params]
+ [message_params::kModuleData]
+ [message_params::kRadioControlData],
+ radio_data);
}
-TEST_F(GetInteriorVehicleDataRequestTest,
- OnEvent_ValidHmiResponse_ExpectSuccessfullResponseSentToMobile) {
+TEST_F(
+ GetInteriorVehicleDataRequestTest,
+ Execute_ExpectCorrectMessageSentToHMI_LastAppSubscribedUnsubscibe_ClearCache) {
// Arrange
MessageSharedPtr mobile_message = CreateBasicMessage();
- NsSmartDeviceLink::NsSmartObjects::SmartObject& msg_params =
- (*mobile_message)[application_manager::strings::msg_params];
- msg_params[message_params::kModuleType] = mobile_apis::ModuleType::CLIMATE;
+ (*mobile_message)[application_manager::strings::msg_params]
+ [message_params::kModuleType] = module_type;
+ (*mobile_message)[application_manager::strings::msg_params]
+ [message_params::kSubscribe] = false;
- MessageSharedPtr hmi_message = CreateBasicMessage();
+ MessageSharedPtr hmi_response = CreateBasicMessage();
NsSmartDeviceLink::NsSmartObjects::SmartObject& hmi_msg_params =
- (*hmi_message)[application_manager::strings::msg_params];
+ (*hmi_response)[application_manager::strings::msg_params];
hmi_apis::Common_Result::eType response_code =
hmi_apis::Common_Result::SUCCESS;
hmi_msg_params[application_manager::hmi_response::code] = response_code;
hmi_msg_params[application_manager::strings::connection_key] = kConnectionKey;
+ apps_.insert(mock_app_);
+ rc_app_extention_->SubscribeToInteriorVehicleData(enums_value::kRadio);
+ ON_CALL(app_mngr_, applications()).WillByDefault(Return(apps_da_));
+ ON_CALL(mock_interior_data_manager_, CheckRequestsToHMIFrequency(_))
+ .WillByDefault(Return(true));
+
+ // Expectations
+ EXPECT_CALL(mock_rpc_service_,
+ ManageHMICommand(HMIResultCodeIs(
+ hmi_apis::FunctionID::RC_GetInteriorVehicleData)))
+ .WillOnce(Return(true));
EXPECT_CALL(
mock_rpc_service_,
ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::SUCCESS), _))
.WillOnce(Return(true));
+ EXPECT_CALL(mock_interior_data_cache_, Remove(enums_value::kRadio));
+
+ // Act
+ std::shared_ptr<
+ rc_rpc_plugin::commands::GetInteriorVehicleDataRequest> command =
+ CreateRCCommand<rc_rpc_plugin::commands::GetInteriorVehicleDataRequest>(
+ mobile_message);
+ command->Run();
application_manager::event_engine::Event event(
hmi_apis::FunctionID::RC_GetInteriorVehicleData);
- event.set_smart_object(*hmi_message);
+ event.set_smart_object(*hmi_response);
+ command->on_event(event);
+}
+
+TEST_F(GetInteriorVehicleDataRequestTest,
+ Execute_ExpectMessageNotSentToHMI_TwoApps_OneUnsubscribed) {
+ // Arrange
+ MessageSharedPtr mobile_message = CreateBasicMessage();
+ (*mobile_message)[application_manager::strings::msg_params]
+ [message_params::kModuleType] = module_type;
+ (*mobile_message)[application_manager::strings::msg_params]
+ [message_params::kSubscribe] = false;
+
+ apps_.insert(mock_app_);
+ apps_.insert(mock_app2_);
+ rc_app_extention_->SubscribeToInteriorVehicleData(enums_value::kRadio);
+ rc_app_extention2_->SubscribeToInteriorVehicleData(enums_value::kRadio);
+
+ smart_objects::SmartObject radio_data;
+ radio_data[message_params::kBand] = enums_value::kAM;
+ ON_CALL(app_mngr_, applications()).WillByDefault(Return(apps_da_));
+
std::shared_ptr<
rc_rpc_plugin::commands::GetInteriorVehicleDataRequest> command =
CreateRCCommand<rc_rpc_plugin::commands::GetInteriorVehicleDataRequest>(
mobile_message);
+
+ // Expectations
+ EXPECT_CALL(mock_interior_data_cache_, Contains(enums_value::kRadio))
+ .WillOnce(Return(true));
+ EXPECT_CALL(mock_interior_data_cache_, Retrieve(enums_value::kRadio))
+ .WillOnce(Return(radio_data));
+
+ EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).Times(0);
+ MessageSharedPtr command_result;
+ EXPECT_CALL(
+ mock_rpc_service_,
+ ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::SUCCESS), _))
+ .WillOnce(DoAll(SaveArg<0>(&command_result), Return(true)));
+
+ // Act
+ command->Run();
+
+ // Assert
+ EXPECT_FALSE(
+ rc_app_extention_->IsSubscibedToInteriorVehicleData(enums_value::kRadio));
+ EXPECT_EQ((*command_result)[application_manager::strings::msg_params]
+ [message_params::kModuleData]
+ [message_params::kRadioControlData],
+ radio_data);
+}
+
+TEST_F(
+ GetInteriorVehicleDataRequestTest,
+ Execute_CapabilitiesValidationFailed_ExpectMessageNotSentToHMI_AndFalseSentToMobile) {
+ // Arrange
+ MessageSharedPtr mobile_message = CreateBasicMessage();
+ NsSmartDeviceLink::NsSmartObjects::SmartObject& msg_params =
+ (*mobile_message)[application_manager::strings::msg_params];
+ msg_params[message_params::kModuleType] = mobile_apis::ModuleType::RADIO;
+ std::shared_ptr<
+ rc_rpc_plugin::commands::GetInteriorVehicleDataRequest> command =
+ CreateRCCommand<rc_rpc_plugin::commands::GetInteriorVehicleDataRequest>(
+ mobile_message);
+ smart_objects::SmartObject rc_capabilities;
+ ON_CALL(mock_hmi_capabilities_, rc_capability())
+ .WillByDefault(Return(&rc_capabilities));
+
+ // Expectations
+ EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).Times(0);
+ EXPECT_CALL(mock_rpc_service_,
+ ManageMobileCommand(
+ MobileResultCodeIs(mobile_apis::Result::UNSUPPORTED_RESOURCE),
+ _)).WillOnce((Return(true)));
+ // Act
+ command->Run();
+}
+
+TEST_F(
+ GetInteriorVehicleDataRequestTest,
+ Execute_PolicyValidationFailed_ExpectMessageNotSentToHMI_AndFalseSentToMobile) {
+ // Arrange
+ MessageSharedPtr mobile_message = CreateBasicMessage();
+ NsSmartDeviceLink::NsSmartObjects::SmartObject& msg_params =
+ (*mobile_message)[application_manager::strings::msg_params];
+ msg_params[message_params::kModuleType] = mobile_apis::ModuleType::RADIO;
+ std::shared_ptr<
+ rc_rpc_plugin::commands::GetInteriorVehicleDataRequest> command =
+ CreateRCCommand<rc_rpc_plugin::commands::GetInteriorVehicleDataRequest>(
+ mobile_message);
+ ON_CALL(mock_policy_handler_, CheckModule(_, _)).WillByDefault(Return(false));
+
+ // Expectations
+ EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).Times(0);
+ EXPECT_CALL(mock_rpc_service_,
+ ManageMobileCommand(
+ MobileResultCodeIs(mobile_apis::Result::DISALLOWED), _))
+ .WillOnce((Return(true)));
+
+ // Act
+ command->Run();
+}
+
+TEST_F(GetInteriorVehicleDataRequestTest,
+ OnEvent_ValidHmiResponse_ExpectSuccessfulResponseSentToMobile_NoCache) {
+ using rc_rpc_plugin::commands::GetInteriorVehicleDataRequest;
+ namespace hmi_response = application_manager::hmi_response;
+ namespace strings = application_manager::strings;
+
+ // Arrange
+ MessageSharedPtr mobile_message = CreateBasicMessage();
+ auto& msg_params = (*mobile_message)[strings::msg_params];
+ msg_params[message_params::kModuleType] = module_type;
+
+ MessageSharedPtr hmi_response_message = CreateBasicMessage();
+ auto& hmi_response_params = (*hmi_response_message)[strings::msg_params];
+ hmi_response_params[hmi_response::code] = hmi_apis::Common_Result::SUCCESS;
+ hmi_response_params[strings::connection_key] = kConnectionKey;
+
+ ON_CALL(mock_interior_data_cache_, Contains(_)).WillByDefault(Return(false));
+ ON_CALL(mock_interior_data_manager_, CheckRequestsToHMIFrequency(_))
+ .WillByDefault(Return(true));
+
+ // Expectations
+ EXPECT_CALL(
+ mock_rpc_service_,
+ ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::SUCCESS), _))
+ .WillOnce(Return(true));
+
+ EXPECT_CALL(mock_rpc_service_,
+ ManageHMICommand(HMIResultCodeIs(
+ hmi_apis::FunctionID::RC_GetInteriorVehicleData)))
+ .WillOnce(Return(true));
+
+ // Act
+ auto command = CreateRCCommand<GetInteriorVehicleDataRequest>(mobile_message);
+ application_manager::event_engine::Event event(
+ hmi_apis::FunctionID::RC_GetInteriorVehicleData);
+ event.set_smart_object(*hmi_response_message);
+ command->Run();
command->on_event(event);
}
TEST_F(GetInteriorVehicleDataRequestTest,
OnEvent_InvalidHmiResponse_ExpectGenericErrorResponseSentToMobile) {
+ using rc_rpc_plugin::commands::GetInteriorVehicleDataRequest;
+ namespace hmi_response = application_manager::hmi_response;
+ namespace strings = application_manager::strings;
+
// Arrange
MessageSharedPtr mobile_message = CreateBasicMessage();
- NsSmartDeviceLink::NsSmartObjects::SmartObject& msg_params =
+ auto& msg_params =
(*mobile_message)[application_manager::strings::msg_params];
- msg_params[message_params::kModuleType] = mobile_apis::ModuleType::CLIMATE;
+ msg_params[message_params::kModuleType] = module_type;
MessageSharedPtr hmi_message = CreateBasicMessage();
+ auto& hmi_msg_params = (*hmi_message)[strings::params];
+ hmi_msg_params[hmi_response::code] = hmi_apis::Common_Result::READ_ONLY;
+ hmi_msg_params[strings::connection_key] = kConnectionKey;
+ ON_CALL(mock_interior_data_cache_, Contains(_)).WillByDefault(Return(false));
+ ON_CALL(mock_interior_data_manager_, CheckRequestsToHMIFrequency(_))
+ .WillByDefault(Return(true));
+
+ // Expectations
+ EXPECT_CALL(mock_rpc_service_,
+ ManageHMICommand(HMIResultCodeIs(
+ hmi_apis::FunctionID::RC_GetInteriorVehicleData)))
+ .WillOnce(Return(true));
+ EXPECT_CALL(mock_rpc_service_,
+ ManageMobileCommand(
+ MobileResultCodeIs(mobile_apis::Result::GENERIC_ERROR), _))
+ .WillOnce(Return(true));
+
+ // Act
+ application_manager::event_engine::Event event(
+ hmi_apis::FunctionID::RC_GetInteriorVehicleData);
+ event.set_smart_object(*hmi_message);
+ auto command = CreateRCCommand<GetInteriorVehicleDataRequest>(mobile_message);
+ command->Run();
+ command->on_event(event);
+}
+
+TEST_F(GetInteriorVehicleDataRequestTest,
+ OnEvent_InvalidHmiResponse_DontUnsubscibeLastApp_NoClearCache) {
+ // Arrange
+ MessageSharedPtr mobile_message = CreateBasicMessage();
+ (*mobile_message)[application_manager::strings::msg_params]
+ [message_params::kModuleType] = module_type;
+ (*mobile_message)[application_manager::strings::msg_params]
+ [message_params::kSubscribe] = false;
+
+ MessageSharedPtr hmi_response = CreateBasicMessage();
NsSmartDeviceLink::NsSmartObjects::SmartObject& hmi_msg_params =
- (*hmi_message)[application_manager::strings::params];
- hmi_apis::Common_Result::eType response_code =
+ (*hmi_response)[application_manager::strings::params];
+ hmi_msg_params[application_manager::hmi_response::code] =
hmi_apis::Common_Result::READ_ONLY;
- hmi_msg_params[application_manager::hmi_response::code] = response_code;
hmi_msg_params[application_manager::strings::connection_key] = kConnectionKey;
+
+ apps_.insert(mock_app_);
+ rc_app_extention_->SubscribeToInteriorVehicleData(enums_value::kRadio);
+ ON_CALL(app_mngr_, applications()).WillByDefault(Return(apps_da_));
+ ON_CALL(mock_interior_data_manager_, CheckRequestsToHMIFrequency(_))
+ .WillByDefault(Return(true));
+
+ // Expectations
+ EXPECT_CALL(mock_rpc_service_,
+ ManageHMICommand(HMIResultCodeIs(
+ hmi_apis::FunctionID::RC_GetInteriorVehicleData)))
+ .WillOnce(Return(true));
EXPECT_CALL(mock_rpc_service_,
ManageMobileCommand(
MobileResultCodeIs(mobile_apis::Result::GENERIC_ERROR), _))
- .WillOnce(Return(false));
+ .WillOnce(Return(true));
+ EXPECT_CALL(mock_interior_data_cache_, Clear()).Times(0);
+
+ // Act
+ std::shared_ptr<
+ rc_rpc_plugin::commands::GetInteriorVehicleDataRequest> command =
+ CreateRCCommand<rc_rpc_plugin::commands::GetInteriorVehicleDataRequest>(
+ mobile_message);
+ command->Run();
application_manager::event_engine::Event event(
hmi_apis::FunctionID::RC_GetInteriorVehicleData);
- event.set_smart_object(*hmi_message);
+ event.set_smart_object(*hmi_response);
+ command->on_event(event);
+
+ // Assert
+ EXPECT_TRUE(
+ rc_app_extention_->IsSubscibedToInteriorVehicleData(enums_value::kRadio));
+}
+
+TEST_F(GetInteriorVehicleDataRequestTest,
+ Execute_ExpectRejectDuToRequestLimitation_NoCahce) {
+ // Arrange
+ rc_app_extention_->UnsubscribeFromInteriorVehicleData(enums_value::kRadio);
+ MessageSharedPtr mobile_message = CreateBasicMessage();
+ (*mobile_message)[application_manager::strings::msg_params]
+ [message_params::kModuleType] = module_type;
+ smart_objects::SmartObject radio_data;
+ radio_data[message_params::kBand] = enums_value::kAM;
std::shared_ptr<
rc_rpc_plugin::commands::GetInteriorVehicleDataRequest> command =
CreateRCCommand<rc_rpc_plugin::commands::GetInteriorVehicleDataRequest>(
mobile_message);
- command->on_event(event);
+ size_t i = 0;
+ for (; i <= max_request_in_time_frame; ++i) {
+ // Expectations
+ EXPECT_CALL(mock_interior_data_manager_,
+ CheckRequestsToHMIFrequency(enums_value::kRadio))
+ .WillOnce(Return(true));
+ EXPECT_CALL(mock_interior_data_manager_,
+ StoreRequestToHMITime(enums_value::kRadio));
+ EXPECT_CALL(mock_interior_data_cache_, Contains(enums_value::kRadio))
+ .WillRepeatedly(Return(false));
+ EXPECT_CALL(mock_rpc_service_,
+ ManageHMICommand(HMIResultCodeIs(
+ hmi_apis::FunctionID::RC_GetInteriorVehicleData)))
+ .WillRepeatedly(Return(true));
+ // Act
+ command->Run();
+ }
+
+ // Expectations
+ EXPECT_CALL(mock_interior_data_manager_,
+ CheckRequestsToHMIFrequency(enums_value::kRadio))
+ .WillOnce(Return(false));
+ EXPECT_CALL(
+ mock_rpc_service_,
+ ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::REJECTED), _))
+ .WillOnce(Return(false));
+ EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).Times(0);
+
+ // Act
+ command->Run();
}
} // namespace rc_rpc_plugin_test
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/on_interior_vehicle_data_notification_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/on_interior_vehicle_data_notification_test.cc
index df11bf8c88..b344471254 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/on_interior_vehicle_data_notification_test.cc
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/on_interior_vehicle_data_notification_test.cc
@@ -37,6 +37,8 @@
#include "rc_rpc_plugin/rc_rpc_plugin.h"
#include "rc_rpc_plugin/rc_module_constants.h"
#include "rc_rpc_plugin/mock/mock_resource_allocation_manager.h"
+#include "rc_rpc_plugin/mock/mock_interior_data_cache.h"
+#include "rc_rpc_plugin/mock/mock_interior_data_manager.h"
#include "gtest/gtest.h"
#include "interfaces/MOBILE_API.h"
@@ -56,6 +58,7 @@ namespace {
const uint32_t kAppId = 0u;
const uint32_t kConnectionKey = 1u;
const std::string kPolicyAppId = "Test";
+const int kModuleId = 153u;
}
namespace rc_rpc_plugin_test {
@@ -66,62 +69,72 @@ class OnInteriorVehicleDataNotificationTest
: public CommandsTest<CommandsTestMocks::kIsNice> {
public:
OnInteriorVehicleDataNotificationTest()
- : mock_app_(std::make_shared<NiceMock<MockApplication> >()) {}
+ : mock_app_(std::make_shared<NiceMock<MockApplication> >())
+ , rc_app_extention_(std::make_shared<RCAppExtension>(kModuleId))
+ , apps_lock_(std::make_shared<sync_primitives::Lock>())
+ , apps_da_(apps_, apps_lock_) {
+ ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kAppId));
+ ON_CALL(*mock_app_, is_remote_control_supported())
+ .WillByDefault(Return(true));
+ ON_CALL(*mock_app_, QueryInterface(_))
+ .WillByDefault(Return(rc_app_extention_));
+ }
MessageSharedPtr CreateBasicMessage() {
MessageSharedPtr message = CreateMessage();
(*message)[application_manager::strings::params]
[application_manager::strings::function_id] =
- mobile_apis::FunctionID::SetInteriorVehicleDataID;
+ mobile_apis::FunctionID::OnInteriorVehicleDataID;
(*message)[application_manager::strings::params]
[application_manager::strings::connection_key] = kConnectionKey;
(*message)[application_manager::strings::params]
- [application_manager::strings::connection_key] = kAppId;
+ [application_manager::strings::app_id] = kAppId;
smart_objects::SmartObject& msg_param =
(*message)[application_manager::strings::msg_params];
- msg_param[message_params::kModuleType] = mobile_apis::ModuleType::CLIMATE;
-
+ msg_param[message_params::kModuleData][message_params::kModuleType] =
+ mobile_apis::ModuleType::CLIMATE;
return message;
}
template <class Command>
std::shared_ptr<Command> CreateRCCommand(MessageSharedPtr& msg) {
InitCommand(kDefaultTimeout_);
- return std::make_shared<Command>(msg ? msg : msg = CreateMessage(),
- app_mngr_,
- mock_rpc_service_,
- mock_hmi_capabilities_,
- mock_policy_handler_,
- mock_allocation_manager_);
+ RCCommandParams params{app_mngr_,
+ mock_rpc_service_,
+ mock_hmi_capabilities_,
+ mock_policy_handler_,
+ mock_allocation_manager_,
+ mock_interior_data_cache_,
+ mock_interior_data_manager_};
+ return ::std::make_shared<Command>(msg ? msg : msg = CreateMessage(),
+ params);
}
protected:
std::shared_ptr<MockApplication> mock_app_;
+ std::shared_ptr<RCAppExtension> rc_app_extention_;
testing::NiceMock<rc_rpc_plugin_test::MockResourceAllocationManager>
mock_allocation_manager_;
+ testing::NiceMock<rc_rpc_plugin_test::MockInteriorDataCache>
+ mock_interior_data_cache_;
+ testing::NiceMock<rc_rpc_plugin_test::MockInteriorDataManager>
+ mock_interior_data_manager_;
+ application_manager::ApplicationSet apps_;
+ const std::shared_ptr<sync_primitives::Lock> apps_lock_;
+ DataAccessor<application_manager::ApplicationSet> apps_da_;
};
TEST_F(OnInteriorVehicleDataNotificationTest,
Run_SendMessageToMobile_Notification) {
// Arrange
MessageSharedPtr mobile_message = CreateBasicMessage();
- ApplicationSet app_set = {mock_app_};
- MessageSharedPtr message;
- std::shared_ptr<sync_primitives::Lock> apps_lock =
- std::make_shared<sync_primitives::Lock>();
- DataAccessor<ApplicationSet> accessor(app_set, apps_lock);
- // Expectations
- EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(accessor));
-
- RCAppExtensionPtr rc_extention_ptr =
- std::make_shared<RCAppExtension>(application_manager::AppExtensionUID(
- rc_rpc_plugin::RCRPCPlugin::kRCPluginID));
- rc_extention_ptr->SubscribeToInteriorVehicleData(enums_value::kClimate);
- ON_CALL(*mock_app_, QueryInterface(_))
- .WillByDefault(Return(rc_extention_ptr));
- ON_CALL(*mock_app_, is_remote_control_supported())
- .WillByDefault(Return(true));
+ apps_.insert(mock_app_);
+ rc_app_extention_->SubscribeToInteriorVehicleData(enums_value::kClimate);
+ ON_CALL(app_mngr_, applications()).WillByDefault(Return(apps_da_));
+ // Expectations
+ EXPECT_CALL(mock_interior_data_cache_, Add(enums_value::kClimate, _));
+ MessageSharedPtr message;
EXPECT_CALL(mock_rpc_service_, SendMessageToMobile(_, false))
.WillOnce(SaveArg<0>(&message));
// Act
@@ -130,8 +143,9 @@ TEST_F(OnInteriorVehicleDataNotificationTest,
rc_rpc_plugin::commands::OnInteriorVehicleDataNotification>(
mobile_message);
command->Run();
+
// Assertions
- ASSERT_TRUE((bool)message);
+ ASSERT_TRUE(message.get());
Mock::VerifyAndClearExpectations(&app_mngr_);
}
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/on_remote_control_settings_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/on_remote_control_settings_test.cc
index 9054ce4830..164623d926 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/on_remote_control_settings_test.cc
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/on_remote_control_settings_test.cc
@@ -38,6 +38,8 @@
#include "rc_rpc_plugin/rc_rpc_plugin.h"
#include "rc_rpc_plugin/rc_module_constants.h"
#include "rc_rpc_plugin/mock/mock_resource_allocation_manager.h"
+#include "rc_rpc_plugin/mock/mock_interior_data_cache.h"
+#include "rc_rpc_plugin/mock/mock_interior_data_manager.h"
#include "gtest/gtest.h"
#include "interfaces/MOBILE_API.h"
@@ -87,18 +89,24 @@ class RCOnRemoteControlSettingsNotificationTest
template <class Command>
std::shared_ptr<Command> CreateRCCommand(MessageSharedPtr& msg) {
InitCommand(kDefaultTimeout_);
- return std::make_shared<Command>(msg ? msg : msg = CreateMessage(),
- app_mngr_,
- mock_rpc_service_,
- mock_hmi_capabilities_,
- mock_policy_handler_,
- mock_allocation_manager_);
+ RCCommandParams params{app_mngr_,
+ mock_rpc_service_,
+ mock_hmi_capabilities_,
+ mock_policy_handler_,
+ mock_allocation_manager_,
+ mock_interior_data_cache_,
+ mock_interior_data_manager_};
+ return std::make_shared<Command>(msg ? msg : msg = CreateMessage(), params);
}
protected:
std::shared_ptr<MockApplication> mock_app_;
testing::NiceMock<rc_rpc_plugin_test::MockResourceAllocationManager>
mock_allocation_manager_;
+ testing::NiceMock<rc_rpc_plugin_test::MockInteriorDataCache>
+ mock_interior_data_cache_;
+ testing::NiceMock<rc_rpc_plugin_test::MockInteriorDataManager>
+ mock_interior_data_manager_;
};
TEST_F(RCOnRemoteControlSettingsNotificationTest,
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/rc_get_interior_vehicle_data_consent_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/rc_get_interior_vehicle_data_consent_test.cc
index 7f36d251cc..567d4b1e20 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/rc_get_interior_vehicle_data_consent_test.cc
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/rc_get_interior_vehicle_data_consent_test.cc
@@ -46,6 +46,8 @@
#include "rc_rpc_plugin/rc_rpc_plugin.h"
#include "rc_rpc_plugin/rc_module_constants.h"
#include "rc_rpc_plugin/mock/mock_resource_allocation_manager.h"
+#include "rc_rpc_plugin/mock/mock_interior_data_cache.h"
+#include "rc_rpc_plugin/mock/mock_interior_data_manager.h"
#include "rc_rpc_plugin/commands/mobile/button_press_request.h"
#include "rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_consent_response.h"
#include "rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_consent_request.h"
@@ -100,11 +102,11 @@ class RCGetInteriorVehicleDataConsentTest
: mock_app_(std::make_shared<NiceMock<MockApplication> >())
, command_holder(app_mngr_)
, request_controller(mock_request_controler)
- , rpc_service(app_mngr_,
- request_controller,
- &mock_protocol_handler,
- &mock_hmi_handler,
- command_holder)
+ , rpc_service_(app_mngr_,
+ request_controller,
+ &mock_protocol_handler,
+ &mock_hmi_handler,
+ command_holder)
, rc_app_extention_(std::make_shared<RCAppExtension>(kPluginID))
, mock_rpc_plugin_manager(
std::make_shared<NiceMock<MockRPCPluginManager> >())
@@ -119,8 +121,10 @@ class RCGetInteriorVehicleDataConsentTest
.WillByDefault(Return(application_manager::HmiInterfaces::
InterfaceState::STATE_AVAILABLE));
ON_CALL(app_mngr_, application(kAppId)).WillByDefault(Return(mock_app_));
- ON_CALL(mock_allocation_manager_, GetApplicationExtention(_))
+ ON_CALL(*mock_app_, QueryInterface(RCRPCPlugin::kRCPluginID))
.WillByDefault(Return(rc_app_extention_));
+ testing::NiceMock<rc_rpc_plugin_test::MockInteriorDataCache>
+ mock_interior_data_cache_;
ON_CALL(app_mngr_, GetPolicyHandler())
.WillByDefault(ReturnRef(mock_policy_handler_));
ON_CALL(app_mngr_, hmi_capabilities())
@@ -146,12 +150,14 @@ class RCGetInteriorVehicleDataConsentTest
template <class Command>
std::shared_ptr<Command> CreateRCCommand(MessageSharedPtr& msg) {
InitCommand(kDefaultTimeout_);
- return std::make_shared<Command>(msg ? msg : msg = CreateMessage(),
- app_mngr_,
- rpc_service,
- mock_hmi_capabilities_,
- mock_policy_handler_,
- mock_allocation_manager_);
+ RCCommandParams params{app_mngr_,
+ rpc_service_,
+ mock_hmi_capabilities_,
+ mock_policy_handler_,
+ mock_allocation_manager_,
+ mock_interior_data_cache_,
+ mock_interior_data_manager_};
+ return std::make_shared<Command>(msg ? msg : msg = CreateMessage(), params);
}
MessageSharedPtr CreateBasicMessage() {
@@ -174,11 +180,15 @@ class RCGetInteriorVehicleDataConsentTest
am::CommandHolderImpl command_holder;
testing::NiceMock<rc_rpc_plugin_test::MockResourceAllocationManager>
mock_allocation_manager_;
+ testing::NiceMock<rc_rpc_plugin_test::MockInteriorDataCache>
+ mock_interior_data_cache_;
+ testing::NiceMock<rc_rpc_plugin_test::MockInteriorDataManager>
+ mock_interior_data_manager_;
smart_objects::SmartObject rc_capabilities_;
MockRPCPlugin mock_rpc_plugin;
MockCommandFactory mock_command_factory;
am::request_controller::RequestController request_controller;
- am::rpc_service::RPCServiceImpl rpc_service;
+ am::rpc_service::RPCServiceImpl rpc_service_;
std::shared_ptr<RCAppExtension> rc_app_extention_;
std::shared_ptr<am::plugin_manager::MockRPCPluginManager>
mock_rpc_plugin_manager;
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/set_interior_vehicle_data_request_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/set_interior_vehicle_data_request_test.cc
index 8072783a71..4144beea2a 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/set_interior_vehicle_data_request_test.cc
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/set_interior_vehicle_data_request_test.cc
@@ -37,6 +37,8 @@
#include "rc_rpc_plugin/rc_rpc_plugin.h"
#include "rc_rpc_plugin/rc_module_constants.h"
#include "rc_rpc_plugin/mock/mock_resource_allocation_manager.h"
+#include "rc_rpc_plugin/mock/mock_interior_data_cache.h"
+#include "rc_rpc_plugin/mock/mock_interior_data_manager.h"
#include "gtest/gtest.h"
#include "interfaces/MOBILE_API.h"
@@ -76,7 +78,7 @@ class SetInteriorVehicleDataRequestTest
.WillByDefault(Return(application_manager::HmiInterfaces::
InterfaceState::STATE_AVAILABLE));
ON_CALL(app_mngr_, application(kAppId)).WillByDefault(Return(mock_app_));
- ON_CALL(mock_allocation_manager_, GetApplicationExtention(_))
+ ON_CALL(*mock_app_, QueryInterface(RCRPCPlugin::kRCPluginID))
.WillByDefault(Return(rc_app_extention_));
ON_CALL(*mock_app_, policy_app_id()).WillByDefault(Return(kPolicyAppId));
@@ -108,17 +110,23 @@ class SetInteriorVehicleDataRequestTest
template <class Command>
std::shared_ptr<Command> CreateRCCommand(MessageSharedPtr& msg) {
InitCommand(kDefaultTimeout_);
- return std::make_shared<Command>(msg ? msg : msg = CreateMessage(),
- app_mngr_,
- mock_rpc_service_,
- mock_hmi_capabilities_,
- mock_policy_handler_,
- mock_allocation_manager_);
+ RCCommandParams params{app_mngr_,
+ mock_rpc_service_,
+ mock_hmi_capabilities_,
+ mock_policy_handler_,
+ mock_allocation_manager_,
+ mock_interior_data_cache_,
+ mock_interior_data_manager_};
+ return std::make_shared<Command>(msg ? msg : msg = CreateMessage(), params);
}
protected:
testing::NiceMock<rc_rpc_plugin_test::MockResourceAllocationManager>
mock_allocation_manager_;
+ testing::NiceMock<rc_rpc_plugin_test::MockInteriorDataCache>
+ mock_interior_data_cache_;
+ testing::NiceMock<rc_rpc_plugin_test::MockInteriorDataManager>
+ mock_interior_data_manager_;
std::shared_ptr<MockApplication> mock_app_;
std::shared_ptr<RCAppExtension> rc_app_extention_;
};
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_interior_data_cache.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_interior_data_cache.h
new file mode 100644
index 0000000000..45465f96b0
--- /dev/null
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_interior_data_cache.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2018, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_TEST_INCLUDE_RC_RPC_PLUGIN_MOCK_MOCK_INTERIOR_DATA_CACHE_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_TEST_INCLUDE_RC_RPC_PLUGIN_MOCK_MOCK_INTERIOR_DATA_CACHE_H_
+
+#include <string>
+#include "gmock/gmock.h"
+#include "rc_rpc_plugin/interior_data_cache.h"
+
+namespace rc_rpc_plugin_test {
+
+class MockInteriorDataCache : public rc_rpc_plugin::InteriorDataCache {
+ public:
+ MOCK_METHOD2(Add,
+ void(const std::string&, const smart_objects::SmartObject&));
+ MOCK_CONST_METHOD1(Retrieve, smart_objects::SmartObject(const std::string&));
+ MOCK_CONST_METHOD1(Contains, bool(const std::string&));
+ MOCK_METHOD1(Remove, void(const std::string&));
+ MOCK_METHOD0(Clear, void());
+};
+
+} // namespace rc_rpc_plugin_test
+
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_TEST_INCLUDE_RC_RPC_PLUGIN_MOCK_MOCK_INTERIOR_DATA_CACHE_H_
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_interior_data_manager.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_interior_data_manager.h
new file mode 100644
index 0000000000..fc19c6a889
--- /dev/null
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_interior_data_manager.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2018, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_TEST_INCLUDE_RC_RPC_PLUGIN_MOCK_MOCK_INTERIOR_DATA_MANAGER_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_TEST_INCLUDE_RC_RPC_PLUGIN_MOCK_MOCK_INTERIOR_DATA_MANAGER_H_
+
+#include <string>
+#include "gmock/gmock.h"
+#include "rc_rpc_plugin/interior_data_manager.h"
+namespace rc_rpc_plugin_test {
+
+class MockInteriorDataManager : public rc_rpc_plugin::InteriorDataManager {
+ public:
+ MOCK_METHOD1(OnPolicyEvent,
+ void(application_manager::plugin_manager::PolicyEvent));
+ MOCK_METHOD2(OnApplicationEvent,
+ void(application_manager::plugin_manager::ApplicationEvent,
+ application_manager::ApplicationSharedPtr));
+ MOCK_METHOD0(OnDisablingRC, void());
+ MOCK_METHOD1(StoreRequestToHMITime, void(const std::string&));
+ MOCK_METHOD1(CheckRequestsToHMIFrequency, bool(const std::string&));
+};
+
+} // namespace rc_rpc_plugin_test
+
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_TEST_INCLUDE_RC_RPC_PLUGIN_MOCK_MOCK_INTERIOR_DATA_MANAGER_H_
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_resource_allocation_manager.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_resource_allocation_manager.h
index d74e8fcb65..72ace1432a 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_resource_allocation_manager.h
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_resource_allocation_manager.h
@@ -30,8 +30,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef SRC_COMPONENTS_REMOTE_CONTROL_TEST_INCLUDE_MOCK_RESOURCE_ALLOCATION_MANAGER_H_
-#define SRC_COMPONENTS_REMOTE_CONTROL_TEST_INCLUDE_MOCK_RESOURCE_ALLOCATION_MANAGER_H_
+#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_TEST_INCLUDE_RC_RPC_PLUGIN_MOCK_MOCK_RESOURCE_ALLOCATION_MANAGER_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_TEST_INCLUDE_RC_RPC_PLUGIN_MOCK_MOCK_RESOURCE_ALLOCATION_MANAGER_H_
#include "gmock/gmock.h"
#include "application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager.h"
@@ -61,9 +61,6 @@ class MockResourceAllocationManager
const uint32_t app_id,
const rc_rpc_plugin::ResourceState::eType state));
MOCK_CONST_METHOD1(IsResourceFree, bool(const std::string& module_type));
- MOCK_METHOD1(GetApplicationExtention,
- rc_rpc_plugin::RCAppExtensionPtr(
- application_manager::ApplicationSharedPtr application));
MOCK_METHOD0(ResetAllAllocations, void());
MOCK_METHOD2(SendOnRCStatusNotifications,
void(rc_rpc_plugin::NotificationTrigger::eType,
@@ -74,4 +71,4 @@ class MockResourceAllocationManager
} // namespace rc_rpc_plugin_test
-#endif // SRC_COMPONENTS_REMOTE_CONTROL_TEST_INCLUDE_MOCK_RESOURCE_ALLOCATION_MANAGER_H_
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_TEST_INCLUDE_RC_RPC_PLUGIN_MOCK_MOCK_RESOURCE_ALLOCATION_MANAGER_H_
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/interior_data_cache_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/interior_data_cache_test.cc
new file mode 100644
index 0000000000..e6922a4c83
--- /dev/null
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/interior_data_cache_test.cc
@@ -0,0 +1,160 @@
+/*
+ * Copyright (c) 2018, Ford Motor Company
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Ford Motor Company nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE. */
+
+#include "gtest/gtest.h"
+#include "rc_rpc_plugin/interior_data_cache_impl.h"
+
+namespace rc_rpc_plugin_test {
+
+class InteriorDataCacheTest : public ::testing::Test {};
+
+namespace {
+const uint32_t time_frame_alowed_requests = 1;
+} // namespace
+
+TEST_F(InteriorDataCacheTest,
+ InteriorDataCacheDoesNotContainRandomDataInitialy) {
+ rc_rpc_plugin::InteriorDataCacheImpl cache;
+ std::string module_type_key = "random_module_type";
+ EXPECT_FALSE(cache.Contains(module_type_key));
+ auto retrieved_data = cache.Retrieve(module_type_key);
+ EXPECT_EQ(smart_objects::SmartType_Null, retrieved_data.getType());
+}
+
+TEST_F(InteriorDataCacheTest, CheckThatCacheContansDataAfterAdding) {
+ rc_rpc_plugin::InteriorDataCacheImpl cache;
+ const std::string module_type_key = "random_module_type";
+ smart_objects::SmartObject data;
+ data["key"] = "value";
+
+ cache.Add(module_type_key, data);
+ EXPECT_TRUE(cache.Contains(module_type_key));
+ auto retrieved_data = cache.Retrieve(module_type_key);
+ EXPECT_EQ(data, retrieved_data);
+}
+
+TEST_F(InteriorDataCacheTest, DataDoesNotExistAfterClear) {
+ rc_rpc_plugin::InteriorDataCacheImpl cache;
+ const std::string module_type_key = "random_module_type";
+ smart_objects::SmartObject data;
+ data["key"] = "value";
+
+ cache.Add(module_type_key, data);
+ EXPECT_TRUE(cache.Contains(module_type_key));
+ auto Retrieved_data = cache.Retrieve(module_type_key);
+ EXPECT_EQ(Retrieved_data, data);
+ cache.Clear();
+ auto Retrieved_data_after_clear = cache.Retrieve(module_type_key);
+ EXPECT_EQ(smart_objects::SmartType_Null,
+ Retrieved_data_after_clear.getType());
+}
+
+TEST_F(InteriorDataCacheTest, MultipleDataCached) {
+ rc_rpc_plugin::InteriorDataCacheImpl cache;
+
+ const std::string module_type_key1 = "random_module_type";
+ smart_objects::SmartObject data1;
+ data1["key"] = "value1";
+ cache.Add(module_type_key1, data1);
+ EXPECT_TRUE(cache.Contains(module_type_key1));
+ auto retrieved_data1 = cache.Retrieve(module_type_key1);
+ EXPECT_EQ(data1, retrieved_data1);
+
+ std::string module_type_key2 = "random_module_type2";
+ smart_objects::SmartObject data2;
+ data2["key"] = "value2";
+ cache.Add(module_type_key2, data2);
+ EXPECT_TRUE(cache.Contains(module_type_key2));
+ auto retrieved_data2 = cache.Retrieve(module_type_key2);
+ EXPECT_EQ(retrieved_data2, data2);
+
+ ASSERT_TRUE(data1 != data2);
+ EXPECT_TRUE(data2 != retrieved_data1);
+ EXPECT_TRUE(data1 != retrieved_data2);
+}
+
+TEST_F(InteriorDataCacheTest, RemoveFromChacheSuccessful) {
+ rc_rpc_plugin::InteriorDataCacheImpl cache;
+
+ const std::string module_type = "random_module_type";
+ smart_objects::SmartObject data;
+ data["key"] = "value1";
+ cache.Add(module_type, data);
+ EXPECT_TRUE(cache.Contains(module_type));
+ auto retrieved_data1 = cache.Retrieve(module_type);
+ EXPECT_EQ(data, retrieved_data1);
+
+ cache.Remove(module_type);
+ EXPECT_FALSE(cache.Contains(module_type));
+ auto retreived = cache.Retrieve(module_type);
+ EXPECT_EQ(smart_objects::SmartType_Null, retreived.getType());
+}
+
+TEST_F(InteriorDataCacheTest, RemoveNotExistingNoSideEffects) {
+ rc_rpc_plugin::InteriorDataCacheImpl cache;
+ const std::string module_type_key = "random_module_type";
+ smart_objects::SmartObject data;
+ data["key"] = "value";
+
+ cache.Add(module_type_key, data);
+ cache.Remove("some other module_type");
+
+ EXPECT_TRUE(cache.Contains(module_type_key));
+ auto retrieved_data = cache.Retrieve(module_type_key);
+ EXPECT_EQ(data, retrieved_data);
+}
+
+TEST_F(InteriorDataCacheTest, Exist2ModuleTypesRemoveOneAnotherOneLeft) {
+ rc_rpc_plugin::InteriorDataCacheImpl cache;
+
+ const std::string module_type_key1 = "random_module_type";
+ smart_objects::SmartObject data1;
+ data1["key"] = "value1";
+ cache.Add(module_type_key1, data1);
+
+ std::string module_type_key2 = "random_module_type2";
+ smart_objects::SmartObject data2;
+ data2["key"] = "value2";
+ cache.Add(module_type_key2, data2);
+
+ ASSERT_TRUE(data1 != data2);
+
+ cache.Remove(module_type_key1);
+ EXPECT_FALSE(cache.Contains(module_type_key1));
+ EXPECT_TRUE(cache.Contains(module_type_key2));
+
+ auto retrieved_data1 = cache.Retrieve(module_type_key1);
+ EXPECT_EQ(smart_objects::SmartType_Null, retrieved_data1.getType());
+ auto retrieved_data2 = cache.Retrieve(module_type_key2);
+ EXPECT_EQ(data2, retrieved_data2);
+}
+
+} // rc_rpc_plugin_test
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/resource_allocation_manager_impl_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/resource_allocation_manager_impl_test.cc
index 4e2e4d7895..86c58b9d46 100644
--- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/resource_allocation_manager_impl_test.cc
+++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/resource_allocation_manager_impl_test.cc
@@ -71,7 +71,7 @@ const uint32_t kAppId1 = 11u;
const uint32_t kHMIAppId1 = 1u;
const uint32_t kAppId2 = 22u;
const std::string policy_app_id_1_ = "policy_id_1";
-const uint32_t kSizeOfModules = 3u;
+const uint32_t kSizeOfModules = 6u;
}
namespace rc_rpc_plugin_test {
@@ -298,13 +298,6 @@ TEST_F(RAManagerTest, AnotherAppExit_NoReleaseResource) {
EXPECT_CALL(mock_app_mngr_, application(kAppId2))
.WillRepeatedly(Return(mock_app_2_));
- RCAppExtensionPtr rc_extention_ptr =
- std::make_shared<RCAppExtension>(application_manager::AppExtensionUID(
- rc_rpc_plugin::RCRPCPlugin::kRCPluginID));
-
- EXPECT_CALL(*mock_app_2_, QueryInterface(_))
- .WillOnce(Return(rc_extention_ptr));
-
// Act
application_manager::ApplicationSharedPtr app_ptr(mock_app_2_);
EXPECT_CALL(*mock_app_2_, app_id()).WillRepeatedly(Return(kAppId2));
@@ -358,13 +351,6 @@ TEST_F(RAManagerTest, AnotherAppUnregistered_NoReleaseResource) {
EXPECT_CALL(mock_app_mngr_, application(kAppId1))
.WillRepeatedly(Return(mock_app_2_));
- RCAppExtensionPtr rc_extention_ptr =
- std::make_shared<RCAppExtension>(application_manager::AppExtensionUID(
- rc_rpc_plugin::RCRPCPlugin::kRCPluginID));
-
- EXPECT_CALL(*mock_app_2_, QueryInterface(_))
- .WillOnce(Return(rc_extention_ptr));
-
// Act
application_manager::ApplicationSharedPtr app_ptr(mock_app_2_);
EXPECT_CALL(*mock_app_2_, app_id()).WillRepeatedly(Return(kAppId2));
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_audio_pass_thru_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_audio_pass_thru_request.h
index 6db222a401..1a4c248a02 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_audio_pass_thru_request.h
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_audio_pass_thru_request.h
@@ -109,15 +109,6 @@ class PerformAudioPassThruRequest
ResponseParams response_params_;
/**
- * @brief Prepare result code, result and info for sending to mobile
- * application
- * @param result_code contains result code for sending to mobile application
- * @return result for sending to mobile application.
- * @deprecated
- */
- DEPRECATED bool PrepareResponseParameters(
- mobile_apis::Result::eType& result_code, std::string& info);
- /**
* @brief Prepare result code, 'success' result and info for sending
* to mobile application
* @param result_code contains result code for sending to mobile application
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_interaction_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_interaction_request.h
index 40e706b851..2d4cbc9afc 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_interaction_request.h
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_interaction_request.h
@@ -213,6 +213,13 @@ class PerformInteractionRequest
const smart_objects::SmartObject& choice_set_id_list) const;
/**
+ * @brief Checks each choice in each set for having a VRcommands parameter
+ * @param app contains pointer to application.
+ * @return returns false if request has choice sets with no vrCommands
+ */
+ bool CheckChoiceSetListVRCommands(app_mngr::ApplicationSharedPtr app);
+
+ /**
* @brief Tells if there are sent requests without responses
* @return If there is request without response method returns TRUE
* otherwise returns FALSE
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 9cac2ab34f..542fdac5f8 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
@@ -83,12 +83,6 @@ class RegisterAppInterfaceRequest
**/
virtual void Run();
- /**
- * @brief Prepares and sends RegisterAppInterface response to mobile
- * considering application type
- **/
- void SendRegisterAppInterfaceResponseToMobile();
-
private:
/**
* @brief The AppicationType enum defines whether application is newly
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_interaction_choice_set_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_interaction_choice_set_request.cc
index 9b7653ac52..d50708c4eb 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_interaction_choice_set_request.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_interaction_choice_set_request.cc
@@ -130,10 +130,30 @@ void CreateInteractionChoiceSetRequest::Run() {
SendResponse(false, result);
return;
}
- uint32_t grammar_id = application_manager_.GenerateGrammarID();
- (*message_)[strings::msg_params][strings::grammar_id] = grammar_id;
+ auto vr_status = MessageHelper::CheckChoiceSetVRCommands(
+ (*message_)[strings::msg_params][strings::choice_set]);
+ if (vr_status == MessageHelper::ChoiceSetVRCommandsStatus::MIXED) {
+ // this is an error
+ SendResponse(false,
+ Result::INVALID_DATA,
+ "Some choices don't contain VR commands. Either all or none "
+ "must have voice commands.");
+ return; // exit now, this is a bad set
+ } else if (vr_status == MessageHelper::ChoiceSetVRCommandsStatus::ALL) {
+ // everyone had a vr command, setup the grammar
+ uint32_t grammar_id = application_manager_.GenerateGrammarID();
+ (*message_)[strings::msg_params][strings::grammar_id] = grammar_id;
+ }
+ // continue on as usual
app->AddChoiceSet(choice_set_id_, (*message_)[strings::msg_params]);
- SendVRAddCommandRequests(app);
+
+ if (vr_status == MessageHelper::ChoiceSetVRCommandsStatus::ALL) {
+ // we have VR commands
+ SendVRAddCommandRequests(app);
+ } else {
+ // we have none, just return with success
+ SendResponse(true, Result::SUCCESS);
+ }
}
mobile_apis::Result::eType CreateInteractionChoiceSetRequest::CheckChoiceSet(
@@ -155,7 +175,7 @@ mobile_apis::Result::eType CreateInteractionChoiceSetRequest::CheckChoiceSet(
(*current_choice_set_it)[strings::choice_id].asInt());
if (!ins_res.second) {
LOG4CXX_ERROR(logger_,
- "Choise with ID "
+ "Choice with ID "
<< (*current_choice_set_it)[strings::choice_id].asInt()
<< " already exists");
return mobile_apis::Result::INVALID_ID;
@@ -179,12 +199,15 @@ mobile_apis::Result::eType CreateInteractionChoiceSetRequest::CheckChoiceSet(
bool CreateInteractionChoiceSetRequest::compareSynonyms(
const NsSmartDeviceLink::NsSmartObjects::SmartObject& choice1,
const NsSmartDeviceLink::NsSmartObjects::SmartObject& choice2) {
+ // only compare if they both have vr commands
+ if (!(choice1.keyExists(strings::vr_commands) &&
+ choice2.keyExists(strings::vr_commands))) {
+ return false; // clearly there isn't a duplicate if one of them is null
+ }
smart_objects::SmartArray* vr_cmds_1 =
choice1[strings::vr_commands].asArray();
- DCHECK(vr_cmds_1 != NULL);
smart_objects::SmartArray* vr_cmds_2 =
choice2[strings::vr_commands].asArray();
- DCHECK(vr_cmds_2 != NULL);
smart_objects::SmartArray::iterator it;
it = std::find_first_of(vr_cmds_1->begin(),
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_audio_pass_thru_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_audio_pass_thru_request.cc
index 86a644a778..c90038a8b7 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_audio_pass_thru_request.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_audio_pass_thru_request.cc
@@ -250,13 +250,6 @@ PerformAudioPassThruRequest::PrepareResponseParameters() {
return response_params_;
}
-bool PerformAudioPassThruRequest::PrepareResponseParameters(
- mobile_apis::Result::eType& result_code, std::string& info) {
- LOG4CXX_AUTO_TRACE(logger_);
- NOTREACHED();
- return false;
-}
-
void PerformAudioPassThruRequest::SendSpeakRequest() {
LOG4CXX_AUTO_TRACE(logger_);
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_interaction_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_interaction_request.cc
index ec06f0bb31..42489fd8bd 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_interaction_request.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_interaction_request.cc
@@ -186,7 +186,8 @@ void PerformInteractionRequest::Run() {
case mobile_apis::InteractionMode::BOTH: {
LOG4CXX_DEBUG(logger_, "Interaction Mode: BOTH");
if (!CheckChoiceSetVRSynonyms(app) || !CheckChoiceSetMenuNames(app) ||
- !CheckVrHelpItemPositions(app)) {
+ !CheckVrHelpItemPositions(app) ||
+ !CheckChoiceSetListVRCommands(app)) {
return;
}
break;
@@ -201,7 +202,8 @@ void PerformInteractionRequest::Run() {
}
case mobile_apis::InteractionMode::VR_ONLY: {
LOG4CXX_DEBUG(logger_, "Interaction Mode: VR_ONLY");
- if (!CheckChoiceSetVRSynonyms(app) || !CheckVrHelpItemPositions(app)) {
+ if (!CheckChoiceSetVRSynonyms(app) || !CheckVrHelpItemPositions(app) ||
+ !CheckChoiceSetListVRCommands(app)) {
return;
}
break;
@@ -542,7 +544,7 @@ void PerformInteractionRequest::SendVRPerformInteractionRequest(
smart_objects::SmartObject* choice_set =
app->FindChoiceSet(choice_list[i].asInt());
if (!choice_set) {
- LOG4CXX_WARN(logger_, "Couldn't found choiset");
+ LOG4CXX_WARN(logger_, "Couldn't found choiceset");
continue;
}
msg_params[strings::grammar_id][grammar_id_index++] =
@@ -750,6 +752,15 @@ bool PerformInteractionRequest::CheckChoiceSetVRSynonyms(
size_t jj = 0;
for (; ii < (*i_choice_set)[strings::choice_set].length(); ++ii) {
for (; jj < (*j_choice_set)[strings::choice_set].length(); ++jj) {
+ if (!((*i_choice_set)[strings::choice_set][ii].keyExists(
+ strings::vr_commands) &&
+ (*j_choice_set)[strings::choice_set][jj].keyExists(
+ strings::vr_commands))) {
+ LOG4CXX_DEBUG(logger_,
+ "One or both sets has missing vr commands, skipping "
+ "synonym check");
+ return true;
+ }
// choice_set pointer contains SmartObject msg_params
smart_objects::SmartObject& ii_vr_commands =
(*i_choice_set)[strings::choice_set][ii][strings::vr_commands];
@@ -946,6 +957,45 @@ bool PerformInteractionRequest::CheckChoiceIDFromResponse(
return false;
}
+bool PerformInteractionRequest::CheckChoiceSetListVRCommands(
+ ApplicationSharedPtr app) {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ const smart_objects::SmartObject& choice_set_id_list =
+ (*message_)[strings::msg_params][strings::interaction_choice_set_id_list];
+
+ smart_objects::SmartObject* choice_set = nullptr;
+
+ for (size_t i = 0; i < choice_set_id_list.length(); ++i) {
+ choice_set = app->FindChoiceSet(choice_set_id_list[i].asInt());
+
+ // this should never ever happen since this was already checked
+ if (choice_set == nullptr) {
+ LOG4CXX_ERROR(
+ logger_,
+ "Couldn't find choiceset_id = " << choice_set_id_list[i].asInt());
+ SendResponse(false, mobile_apis::Result::INVALID_ID);
+ return false;
+ }
+
+ const smart_objects::SmartObject& choices_list =
+ (*choice_set)[strings::choice_set];
+ auto vr_status = MessageHelper::CheckChoiceSetVRCommands(choices_list);
+
+ // if not all choices have vr commands
+ if (vr_status != MessageHelper::ChoiceSetVRCommandsStatus::ALL) {
+ LOG4CXX_ERROR(logger_,
+ "PerformInteraction has choice sets with "
+ "missing vrCommands, not in MANUAL_ONLY mode");
+ SendResponse(false,
+ mobile_apis::Result::INVALID_DATA,
+ "Some choices don't contain VR commands.");
+ return false;
+ }
+ }
+ return true;
+}
+
bool PerformInteractionRequest::CheckChoiceIDFromRequest(
ApplicationSharedPtr app,
const size_t choice_set_id_list_length,
@@ -962,9 +1012,10 @@ bool PerformInteractionRequest::CheckChoiceIDFromRequest(
if (!choice_set) {
LOG4CXX_ERROR(
logger_,
- "Couldn't find choiset_id = " << choice_set_id_list[i].asInt());
+ "Couldn't find choiceset_id = " << choice_set_id_list[i].asInt());
return false;
}
+
choice_list_length = (*choice_set)[strings::choice_set].length();
const smart_objects::SmartObject& choices_list =
(*choice_set)[strings::choice_set];
@@ -973,7 +1024,7 @@ bool PerformInteractionRequest::CheckChoiceIDFromRequest(
choice_id_set.insert(choices_list[k][strings::choice_id].asInt());
if (!ins_res.second) {
LOG4CXX_ERROR(logger_,
- "Choise with ID "
+ "choice with ID "
<< choices_list[k][strings::choice_id].asInt()
<< " already exists");
return false;
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 78a92d360a..03dc43e6d0 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
@@ -293,12 +293,45 @@ void RegisterAppInterfaceRequest::Run() {
return;
}
+ uint16_t major =
+ msg_params[strings::sync_msg_version][strings::major_version].asUInt();
+ uint16_t minor =
+ msg_params[strings::sync_msg_version][strings::minor_version].asUInt();
+ uint16_t patch = 0;
+ // Check if patch exists since it is not mandatory.
+ if (msg_params[strings::sync_msg_version].keyExists(strings::patch_version)) {
+ patch =
+ msg_params[strings::sync_msg_version][strings::patch_version].asUInt();
+ }
+
+ utils::SemanticVersion mobile_version(major, minor, patch);
+ utils::SemanticVersion min_module_version(
+ minimum_major_version, minimum_minor_version, minimum_patch_version);
+
+ if (mobile_version < min_module_version) {
+ LOG4CXX_WARN(logger_,
+ "Application RPC Version does not meet minimum requirement");
+ SendResponse(false, mobile_apis::Result::REJECTED);
+ }
+
application = application_manager_.RegisterApplication(message_);
if (!application) {
LOG4CXX_ERROR(logger_, "Application hasn't been registered!");
return;
}
+
+ // Version negotiation
+ utils::SemanticVersion module_version(
+ major_version, minor_version, patch_version);
+ if (mobile_version < module_version) {
+ // Use mobile RPC version as negotiated version
+ application->set_msg_version(mobile_version);
+ } else {
+ // Use module version as negotiated version
+ application->set_msg_version(module_version);
+ }
+
// For resuming application need to restore hmi_app_id from resumeCtrl
resumption::ResumeCtrl& resumer = application_manager_.resume_controller();
const std::string& device_mac = application->mac_address();
@@ -585,12 +618,14 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile(
return;
}
+ utils::SemanticVersion negotiated_version = application->msg_version();
+
response_params[strings::sync_msg_version][strings::major_version] =
- major_version; // From generated file interfaces/generated_msg_version.h
+ negotiated_version.major_version_;
response_params[strings::sync_msg_version][strings::minor_version] =
- minor_version; // From generated file interfaces/generated_msg_version.h
+ negotiated_version.minor_version_;
response_params[strings::sync_msg_version][strings::patch_version] =
- patch_version; // From generated file interfaces/generated_msg_version.h
+ negotiated_version.patch_version_;
const smart_objects::SmartObject& msg_params =
(*message_)[strings::msg_params];
@@ -795,11 +830,6 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile(
SendChangeRegistrationOnHMI(application);
}
-DEPRECATED void
-RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile() {
- SendRegisterAppInterfaceResponseToMobile(ApplicationType::kNewApplication);
-}
-
void RegisterAppInterfaceRequest::SendChangeRegistration(
const hmi_apis::FunctionID::eType function_id,
const int32_t language,
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/CMakeLists.txt b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/CMakeLists.txt
index da51c3e4e4..1a206c2cce 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/CMakeLists.txt
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/CMakeLists.txt
@@ -6,6 +6,7 @@ include_directories(
${COMPONENTS_DIR}/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/
${COMPONENTS_DIR}/application_manager/test/include/
${POLICY_MOCK_INCLUDE_PATH}/
+ ${CMAKE_SOURCE_DIR}/src
)
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/hmi_notifications_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/hmi_notifications_test.cc
index dd51078614..fe82b16f3f 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/hmi_notifications_test.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/hmi_notifications_test.cc
@@ -872,7 +872,7 @@ TEST_F(HMICommandsNotificationsTest,
SubscribeForSignal();
command->Run();
- utils::WaitTerminationSignals(sig_handler);
+ utils::Signals::WaitTerminationSignals(sig_handler);
EXPECT_EQ(am::mobile_api::AppInterfaceUnregisteredReason::IGNITION_OFF,
mob_reason);
@@ -914,7 +914,7 @@ TEST_F(HMICommandsNotificationsTest,
SubscribeForSignal();
command->Run();
- utils::WaitTerminationSignals(sig_handler);
+ utils::Signals::WaitTerminationSignals(sig_handler);
#endif
}
}
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/create_interaction_choice_set_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/create_interaction_choice_set_test.cc
index ed264ff2ab..c42be48e57 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/create_interaction_choice_set_test.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/create_interaction_choice_set_test.cc
@@ -199,6 +199,8 @@ TEST_F(CreateInteractionChoiceSetRequestTest, OnEvent_VR_UNSUPPORTED_RESOURCE) {
10;
(*msg_vr)[strings::msg_params][strings::choice_set][0][strings::menu_name] =
"menu_name";
+ (*msg_vr)[strings::msg_params][strings::choice_set][0][strings::vr_commands]
+ [0] = kVrCommands1;
(*msg_vr)[strings::msg_params][strings::interaction_choice_set_id] = 11;
std::shared_ptr<CreateInteractionChoiceSetRequest> req_vr =
CreateCommand<CreateInteractionChoiceSetRequest>(msg_vr);
@@ -231,7 +233,8 @@ TEST_F(CreateInteractionChoiceSetRequestTest, OnEvent_VR_UNSUPPORTED_RESOURCE) {
Return(am::HmiInterfaces::HMI_INTERFACE_BasicCommunication));
EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).WillOnce(Return(true));
-
+ ON_CALL(mock_message_helper_, CheckChoiceSetVRCommands(_))
+ .WillByDefault(Return(am::MessageHelper::ChoiceSetVRCommandsStatus::ALL));
req_vr->Run();
MessageSharedPtr vr_command_result;
@@ -436,6 +439,9 @@ TEST_F(CreateInteractionChoiceSetRequestTest,
EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId))
.WillOnce(Return(choice_set_id));
+ ON_CALL(mock_message_helper_, CheckChoiceSetVRCommands(_))
+ .WillByDefault(Return(am::MessageHelper::ChoiceSetVRCommandsStatus::ALL));
+
EXPECT_CALL(app_mngr_, GenerateGrammarID()).WillOnce(Return(kGrammarId));
EXPECT_CALL(*mock_app_, AddChoiceSet(kChoiceSetId, _));
EXPECT_CALL(app_mngr_, GetNextHMICorrelationID())
@@ -481,6 +487,79 @@ TEST_F(CreateInteractionChoiceSetRequestTest,
command_->Run();
}
+TEST_F(CreateInteractionChoiceSetRequestTest, Run_WithoutVrCommands_SUCCESS) {
+ (*message_)[am::strings::msg_params][am::strings::choice_set][0]
+ [am::strings::menu_name] = kMenuName;
+ (*message_)[am::strings::msg_params][am::strings::choice_set][0]
+ [am::strings::image][am::strings::value] = kImage;
+ (*message_)[am::strings::msg_params][am::strings::choice_set][0]
+ [am::strings::choice_id] = kChoiceId1;
+ (*message_)[am::strings::msg_params][am::strings::choice_set][0]
+ [am::strings::secondary_image][am::strings::value] = kSecondImage;
+ (*message_)[am::strings::msg_params][am::strings::choice_set][1]
+ [am::strings::choice_id] = kChoiceId2;
+ (*message_)[am::strings::msg_params][am::strings::choice_set][1]
+ [am::strings::menu_name] = kMenuName;
+ (*message_)[am::strings::msg_params][am::strings::interaction_choice_set_id] =
+ kChoiceSetId;
+
+ EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(mock_app_));
+
+ EXPECT_CALL(mock_message_helper_, VerifyImage(_, _, _))
+ .WillRepeatedly(Return(mobile_apis::Result::SUCCESS));
+
+ EXPECT_CALL(mock_message_helper_, CheckChoiceSetVRCommands(_))
+ .WillOnce(Return(am::MessageHelper::ChoiceSetVRCommandsStatus::NONE));
+
+ smart_objects::SmartObject* choice_set_id = NULL;
+ EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId))
+ .WillOnce(Return(choice_set_id));
+
+ // No VR commands
+ EXPECT_CALL(app_mngr_, GenerateGrammarID()).Times(0);
+
+ EXPECT_CALL(*mock_app_, AddChoiceSet(kChoiceSetId, _));
+
+ command_->Run();
+}
+
+TEST_F(CreateInteractionChoiceSetRequestTest,
+ Run_WithMixedVrCommands_UNSUCCESS) {
+ (*message_)[am::strings::msg_params][am::strings::choice_set][0]
+ [am::strings::menu_name] = kMenuName;
+ (*message_)[am::strings::msg_params][am::strings::choice_set][0]
+ [am::strings::image][am::strings::value] = kImage;
+ (*message_)[am::strings::msg_params][am::strings::choice_set][0]
+ [am::strings::choice_id] = kChoiceId1;
+ (*message_)[am::strings::msg_params][am::strings::choice_set][0]
+ [am::strings::secondary_image][am::strings::value] = kSecondImage;
+ (*message_)[am::strings::msg_params][am::strings::choice_set][0]
+ [am::strings::vr_commands][0] = kVrCommands1;
+ (*message_)[am::strings::msg_params][am::strings::choice_set][1]
+ [am::strings::choice_id] = kChoiceId2;
+ (*message_)[am::strings::msg_params][am::strings::choice_set][1]
+ [am::strings::menu_name] = kMenuName;
+ (*message_)[am::strings::msg_params][am::strings::interaction_choice_set_id] =
+ kChoiceSetId;
+ EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(mock_app_));
+
+ EXPECT_CALL(mock_message_helper_, VerifyImage(_, _, _))
+ .WillRepeatedly(Return(mobile_apis::Result::SUCCESS));
+
+ EXPECT_CALL(mock_message_helper_, CheckChoiceSetVRCommands(_))
+ .WillOnce(Return(am::MessageHelper::ChoiceSetVRCommandsStatus::MIXED));
+
+ smart_objects::SmartObject* choice_set_id = NULL;
+ EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId))
+ .WillOnce(Return(choice_set_id));
+
+ EXPECT_CALL(app_mngr_, GenerateGrammarID()).Times(0);
+
+ EXPECT_CALL(*mock_app_, AddChoiceSet(kChoiceSetId, _)).Times(0);
+
+ command_->Run();
+}
+
TEST_F(CreateInteractionChoiceSetRequestTest,
OnEvent_InvalidEventId_UNSUCCESS) {
Event event(hmi_apis::FunctionID::INVALID_ENUM);
@@ -523,6 +602,9 @@ TEST_F(CreateInteractionChoiceSetRequestTest, OnEvent_ValidVrNoError_SUCCESS) {
EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId))
.WillOnce(Return(choice_set_id));
+ ON_CALL(mock_message_helper_, CheckChoiceSetVRCommands(_))
+ .WillByDefault(Return(am::MessageHelper::ChoiceSetVRCommandsStatus::ALL));
+
EXPECT_CALL(app_mngr_, GenerateGrammarID()).WillOnce(Return(kGrammarId));
EXPECT_CALL(*mock_app_, AddChoiceSet(kChoiceSetId, _));
ON_CALL(app_mngr_, GetNextHMICorrelationID())
@@ -557,6 +639,9 @@ TEST_F(CreateInteractionChoiceSetRequestTest,
EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId))
.WillOnce(Return(choice_set_id));
+ ON_CALL(mock_message_helper_, CheckChoiceSetVRCommands(_))
+ .WillByDefault(Return(am::MessageHelper::ChoiceSetVRCommandsStatus::ALL));
+
EXPECT_CALL(app_mngr_, GenerateGrammarID()).WillOnce(Return(kGrammarId));
EXPECT_CALL(*mock_app_, AddChoiceSet(kChoiceSetId, _));
ON_CALL(app_mngr_, GetNextHMICorrelationID())
@@ -592,6 +677,9 @@ TEST_F(CreateInteractionChoiceSetRequestTest,
EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId))
.WillOnce(Return(choice_set_id));
+ ON_CALL(mock_message_helper_, CheckChoiceSetVRCommands(_))
+ .WillByDefault(Return(am::MessageHelper::ChoiceSetVRCommandsStatus::ALL));
+
EXPECT_CALL(app_mngr_, GenerateGrammarID()).WillOnce(Return(kGrammarId));
EXPECT_CALL(*mock_app_, AddChoiceSet(kChoiceSetId, _));
ON_CALL(app_mngr_, GetNextHMICorrelationID())
@@ -640,6 +728,9 @@ TEST_F(CreateInteractionChoiceSetRequestTest,
EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId))
.WillOnce(Return(choice_set_id));
+ ON_CALL(mock_message_helper_, CheckChoiceSetVRCommands(_))
+ .WillByDefault(Return(am::MessageHelper::ChoiceSetVRCommandsStatus::ALL));
+
EXPECT_CALL(app_mngr_, GenerateGrammarID()).WillOnce(Return(kGrammarId));
EXPECT_CALL(*mock_app_, AddChoiceSet(kChoiceSetId, _));
ON_CALL(app_mngr_, GetNextHMICorrelationID())
@@ -682,6 +773,9 @@ TEST_F(CreateInteractionChoiceSetRequestTest, OnTimeOut_InvalidApp_UNSUCCESS) {
EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId))
.WillOnce(Return(choice_set_id));
+ ON_CALL(mock_message_helper_, CheckChoiceSetVRCommands(_))
+ .WillByDefault(Return(am::MessageHelper::ChoiceSetVRCommandsStatus::ALL));
+
EXPECT_CALL(app_mngr_, GenerateGrammarID()).WillOnce(Return(kGrammarId));
EXPECT_CALL(*mock_app_, AddChoiceSet(kChoiceSetId, _));
ON_CALL(app_mngr_, GetNextHMICorrelationID())
@@ -723,6 +817,9 @@ TEST_F(CreateInteractionChoiceSetRequestTest,
EXPECT_CALL(app_mngr_, application(kConnectionKey))
.WillOnce(Return(mock_app_));
+
+ ON_CALL(mock_message_helper_, CheckChoiceSetVRCommands(_))
+ .WillByDefault(Return(am::MessageHelper::ChoiceSetVRCommandsStatus::ALL));
EXPECT_CALL(app_mngr_, GenerateGrammarID()).WillOnce(Return(kGrammarId));
ON_CALL(app_mngr_, GetNextHMICorrelationID())
.WillByDefault(Return(kCorrelationId));
@@ -796,6 +893,9 @@ TEST_F(CreateInteractionChoiceSetRequestTest, Run_ErrorFromHmiFalse_UNSUCCESS) {
EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId))
.WillRepeatedly(Return(choice_set_id));
+ ON_CALL(mock_message_helper_, CheckChoiceSetVRCommands(_))
+ .WillByDefault(Return(am::MessageHelper::ChoiceSetVRCommandsStatus::ALL));
+
EXPECT_CALL(app_mngr_, GenerateGrammarID())
.WillRepeatedly(Return(kGrammarId));
EXPECT_CALL(*mock_app_, AddChoiceSet(kChoiceSetId, _)).Times(2);
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 dbaee6b2ad..2518e9c7fd 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
@@ -55,6 +55,7 @@
#include "utils/custom_string.h"
#include "utils/lock.h"
#include "utils/macro.h"
+#include "utils/semantic_version.h"
namespace test {
namespace components {
@@ -82,6 +83,7 @@ const std::string kMacAddress = "test_mac_address";
const std::string kAppId = "test_app_id";
const std::string kDummyString = "test_string";
const std::vector<uint32_t> kDummyDiagModes;
+const utils::SemanticVersion mock_semantic_version(1, 0, 0);
} // namespace
class RegisterAppInterfaceRequestTest
@@ -115,6 +117,12 @@ class RegisterAppInterfaceRequestTest
kHmiLanguage;
(*msg_)[am::strings::msg_params]
[am::strings::hmi_display_language_desired] = kHmiLanguage;
+ (*msg_)[am::strings::msg_params][am::strings::sync_msg_version]
+ [am::strings::major_version] = 4;
+ (*msg_)[am::strings::msg_params][am::strings::sync_msg_version]
+ [am::strings::minor_version] = 0;
+ (*msg_)[am::strings::msg_params][am::strings::sync_msg_version]
+ [am::strings::patch_version] = 0;
}
MockAppPtr CreateBasicMockedApp() {
@@ -125,6 +133,8 @@ class RegisterAppInterfaceRequestTest
ON_CALL(*mock_app, language()).WillByDefault(ReturnRef(kMobileLanguage));
ON_CALL(*mock_app, ui_language()).WillByDefault(ReturnRef(kMobileLanguage));
ON_CALL(*mock_app, policy_app_id()).WillByDefault(Return(kAppId));
+ ON_CALL(*mock_app, msg_version())
+ .WillByDefault(ReturnRef(mock_semantic_version));
return mock_app;
}
@@ -281,6 +291,7 @@ TEST_F(RegisterAppInterfaceRequestTest, Run_MinimalData_SUCCESS) {
.WillByDefault(Return(notify_upd_manager));
EXPECT_CALL(app_mngr_, RegisterApplication(msg_)).WillOnce(Return(mock_app));
+
EXPECT_CALL(mock_rpc_service_,
ManageHMICommand(HMIResultCodeIs(
hmi_apis::FunctionID::BasicCommunication_OnAppRegistered)))
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/subscribe_vehicle_data_request.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/subscribe_vehicle_data_request.h
index 6e084e0869..7c6e1754da 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/subscribe_vehicle_data_request.h
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/subscribe_vehicle_data_request.h
@@ -113,14 +113,6 @@ class SubscribeVehicleDataRequest
app_mngr::ApplicationSharedPtr app,
const smart_objects::SmartObject& msg_params) const;
- DEPRECATED void CheckVISubscribtions(
- app_mngr::ApplicationSharedPtr app,
- std::string& out_info,
- mobile_apis::Result::eType& out_result_code,
- smart_objects::SmartObject& out_response_params,
- smart_objects::SmartObject& out_request_params,
- bool& out_result);
-
/**
* @brief Checks if current application and other applications
* were subscribed to VI, prepare data that need to send to mobile app
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/subscribe_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/subscribe_vehicle_data_request.cc
index 41fd35b8b5..65f4fde0b2 100644
--- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/subscribe_vehicle_data_request.cc
+++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/subscribe_vehicle_data_request.cc
@@ -234,21 +234,6 @@ bool SubscribeVehicleDataRequest::IsSomeoneSubscribedFor(
return it != accessor.GetData().end();
}
-void SubscribeVehicleDataRequest::CheckVISubscribtions(
- ApplicationSharedPtr app,
- std::string& out_info,
- mobile_apis::Result::eType& out_result_code,
- smart_objects::SmartObject& out_response_params,
- smart_objects::SmartObject& out_request_params,
- bool& out_result) {
- CheckVISubscriptions(app,
- out_info,
- out_result_code,
- out_response_params,
- out_request_params,
- out_result);
-}
-
void SubscribeVehicleDataRequest::CheckVISubscriptions(
ApplicationSharedPtr app,
std::string& out_info,
diff --git a/src/components/application_manager/src/application_data_impl.cc b/src/components/application_manager/src/application_data_impl.cc
index 3cfbeb2602..ea7893ddc5 100644
--- a/src/components/application_manager/src/application_data_impl.cc
+++ b/src/components/application_manager/src/application_data_impl.cc
@@ -103,6 +103,10 @@ const mobile_api::Language::eType& InitialApplicationDataImpl::ui_language()
return ui_language_;
}
+const utils::SemanticVersion& InitialApplicationDataImpl::msg_version() const {
+ return msg_version_;
+}
+
void InitialApplicationDataImpl::set_app_types(
const smart_objects::SmartObject& app_types) {
if (app_types_) {
@@ -153,6 +157,11 @@ void InitialApplicationDataImpl::set_ui_language(
ui_language_ = ui_language;
}
+void InitialApplicationDataImpl::set_msg_version(
+ const utils::SemanticVersion& version) {
+ msg_version_ = version;
+}
+
void InitialApplicationDataImpl::set_perform_interaction_layout(
mobile_apis::LayoutMode::eType layout) {
perform_interaction_layout_ = layout;
diff --git a/src/components/application_manager/src/application_impl.cc b/src/components/application_manager/src/application_impl.cc
index 9de0b7e963..1168d94245 100644
--- a/src/components/application_manager/src/application_impl.cc
+++ b/src/components/application_manager/src/application_impl.cc
@@ -314,6 +314,13 @@ const HmiStatePtr ApplicationImpl::RegularHmiState() const {
return state_.GetState(HmiState::STATE_ID_REGULAR);
}
+bool ApplicationImpl::IsAllowedToChangeAudioSource() const {
+ if (is_remote_control_supported() && is_media_application()) {
+ return true;
+ }
+ return false;
+}
+
const HmiStatePtr ApplicationImpl::PostponedHmiState() const {
return state_.GetState(HmiState::STATE_ID_POSTPONED);
}
@@ -664,10 +671,6 @@ void ApplicationImpl::set_app_allowed(const bool allowed) {
is_app_allowed_ = allowed;
}
-void ApplicationImpl::set_device(connection_handler::DeviceHandle device) {
- device_id_ = device;
-}
-
void ApplicationImpl::set_secondary_device(
connection_handler::DeviceHandle secondary_device) {
secondary_device_id_ = secondary_device;
diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc
index 992494e647..81e18312ef 100644
--- a/src/components/application_manager/src/application_manager_impl.cc
+++ b/src/components/application_manager/src/application_manager_impl.cc
@@ -177,7 +177,7 @@ ApplicationManagerImpl::ApplicationManagerImpl(
, is_low_voltage_(false)
, apps_size_(0)
, is_stopping_(false) {
- std::srand(std::time(0));
+ std::srand(std::time(nullptr));
AddPolicyObserver(this);
dir_type_to_string_map_ = {{TYPE_STORAGE, "Storage"},
@@ -404,6 +404,7 @@ void ApplicationManagerImpl::OnApplicationSwitched(ApplicationSharedPtr app) {
bool ApplicationManagerImpl::IsAppTypeExistsInFullOrLimited(
ApplicationConstSharedPtr app) const {
+ LOG4CXX_AUTO_TRACE(logger_);
bool voice_state = app->is_voice_communication_supported();
bool media_state = app->is_media_application();
bool navi_state = app->is_navi();
@@ -663,16 +664,6 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication(
return application;
}
-DEPRECATED bool ApplicationManagerImpl::RemoveAppDataFromHMI(
- ApplicationSharedPtr app) {
- return true;
-}
-
-DEPRECATED bool ApplicationManagerImpl::LoadAppDataToHMI(
- ApplicationSharedPtr app) {
- return true;
-}
-
bool ApplicationManagerImpl::ActivateApplication(ApplicationSharedPtr app) {
using namespace mobile_api;
LOG4CXX_AUTO_TRACE(logger_);
@@ -799,16 +790,6 @@ uint32_t ApplicationManagerImpl::GetNextHMICorrelationID() {
return corelation_id_;
}
-bool ApplicationManagerImpl::BeginAudioPassThrough() {
- sync_primitives::AutoLock lock(audio_pass_thru_lock_);
- if (audio_pass_thru_active_) {
- return false;
- } else {
- audio_pass_thru_active_ = true;
- return true;
- }
-}
-
bool ApplicationManagerImpl::BeginAudioPassThru(uint32_t app_id) {
sync_primitives::AutoLock lock(audio_pass_thru_lock_);
if (audio_pass_thru_active_) {
@@ -820,16 +801,6 @@ bool ApplicationManagerImpl::BeginAudioPassThru(uint32_t app_id) {
}
}
-bool ApplicationManagerImpl::EndAudioPassThrough() {
- sync_primitives::AutoLock lock(audio_pass_thru_lock_);
- if (audio_pass_thru_active_) {
- audio_pass_thru_active_ = false;
- return true;
- } else {
- return false;
- }
-}
-
bool ApplicationManagerImpl::EndAudioPassThru(uint32_t app_id) {
sync_primitives::AutoLock lock(audio_pass_thru_lock_);
if (audio_pass_thru_active_ && audio_pass_thru_app_id_ == app_id) {
@@ -851,11 +822,6 @@ void ApplicationManagerImpl::set_driver_distraction_state(
driver_distraction_state_ = state;
}
-DEPRECATED void ApplicationManagerImpl::set_vr_session_started(
- const bool state) {
- is_vr_session_strated_ = state;
-}
-
void ApplicationManagerImpl::SetAllAppsAllowed(const bool allowed) {
is_all_apps_allowed_ = allowed;
}
@@ -874,18 +840,6 @@ HmiStatePtr ApplicationManagerImpl::CreateRegularState(
return state;
}
-HmiStatePtr ApplicationManagerImpl::CreateRegularState(
- uint32_t app_id,
- mobile_apis::HMILevel::eType hmi_level,
- mobile_apis::AudioStreamingState::eType audio_state,
- mobile_apis::SystemContext::eType system_context) const {
- HmiStatePtr state(new HmiState(app_id, *this));
- state->set_hmi_level(hmi_level);
- state->set_audio_streaming_state(audio_state);
- state->set_system_context(system_context);
- return state;
-}
-
void ApplicationManagerImpl::StartAudioPassThruThread(int32_t session_key,
int32_t correlation_id,
int32_t max_duration,
@@ -1289,111 +1243,6 @@ uint32_t ApplicationManagerImpl::GenerateNewHMIAppID() {
return hmi_app_id;
}
-void ApplicationManagerImpl::ReplaceMobileByHMIAppId(
- smart_objects::SmartObject& message) {
- MessageHelper::PrintSmartObject(message);
- if (message.keyExists(strings::app_id)) {
- ApplicationSharedPtr application_ptr =
- application(message[strings::app_id].asUInt());
- if (application_ptr.use_count() != 0) {
- LOG4CXX_DEBUG(logger_,
- "ReplaceMobileByHMIAppId from "
- << message[strings::app_id].asInt() << " to "
- << application_ptr->hmi_app_id());
- message[strings::app_id] = application_ptr->hmi_app_id();
- }
- } else {
- switch (message.getType()) {
- case smart_objects::SmartType::SmartType_Array: {
- smart_objects::SmartArray* message_array = message.asArray();
- smart_objects::SmartArray::iterator it = message_array->begin();
- for (; it != message_array->end(); ++it) {
- ReplaceMobileByHMIAppId(*it);
- }
- break;
- }
- case smart_objects::SmartType::SmartType_Map: {
- std::set<std::string> keys = message.enumerate();
- std::set<std::string>::const_iterator key = keys.begin();
- for (; key != keys.end(); ++key) {
- std::string k = *key;
- ReplaceMobileByHMIAppId(message[*key]);
- }
- break;
- }
- default: { break; }
- }
- }
-}
-
-void ApplicationManagerImpl::ReplaceHMIByMobileAppId(
- smart_objects::SmartObject& message) {
- if (message.keyExists(strings::app_id)) {
- ApplicationSharedPtr application =
- application_by_hmi_app(message[strings::app_id].asUInt());
-
- if (application.use_count() != 0) {
- LOG4CXX_DEBUG(logger_,
- "ReplaceHMIByMobileAppId from "
- << message[strings::app_id].asInt() << " to "
- << application->app_id());
- message[strings::app_id] = application->app_id();
- }
- } else {
- switch (message.getType()) {
- case smart_objects::SmartType::SmartType_Array: {
- smart_objects::SmartArray* message_array = message.asArray();
- smart_objects::SmartArray::iterator it = message_array->begin();
- for (; it != message_array->end(); ++it) {
- ReplaceHMIByMobileAppId(*it);
- }
- break;
- }
- case smart_objects::SmartType::SmartType_Map: {
- std::set<std::string> keys = message.enumerate();
- std::set<std::string>::const_iterator key = keys.begin();
- for (; key != keys.end(); ++key) {
- ReplaceHMIByMobileAppId(message[*key]);
- }
- break;
- }
- default: { break; }
- }
- }
-}
-
-bool ApplicationManagerImpl::StartNaviService(
- uint32_t app_id, protocol_handler::ServiceType service_type) {
- using namespace protocol_handler;
- LOG4CXX_AUTO_TRACE(logger_);
-
- if (HMILevelAllowsStreaming(app_id, service_type)) {
- NaviServiceStatusMap::iterator it = navi_service_status_.find(app_id);
- if (navi_service_status_.end() == it) {
- std::pair<NaviServiceStatusMap::iterator, bool> res =
- navi_service_status_.insert(
- std::pair<uint32_t, std::pair<bool, bool> >(
- app_id, std::make_pair(false, false)));
- if (!res.second) {
- LOG4CXX_WARN(logger_, "Navi service refused");
- return false;
- }
- it = res.first;
- }
- // Fill NaviServices map. Set true to first value of pair if
- // we've started video service or to second value if we've
- // started audio service
- service_type == ServiceType::kMobileNav ? it->second.first = true
- : it->second.second = true;
-
- application(app_id)->StartStreaming(service_type);
- return true;
- } else {
- LOG4CXX_WARN(logger_, "Refused navi service by HMI level");
- }
- return false;
-}
-
bool ApplicationManagerImpl::StartNaviService(
uint32_t app_id,
protocol_handler::ServiceType service_type,
@@ -1533,46 +1382,6 @@ void ApplicationManagerImpl::StopNaviService(
app->StopStreaming(service_type);
}
-// Suppress warning for deprecated method used within another deprecated method
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-bool ApplicationManagerImpl::OnServiceStartedCallback(
- const connection_handler::DeviceHandle& device_handle,
- const int32_t& session_key,
- const protocol_handler::ServiceType& type) {
- using namespace helpers;
- using namespace protocol_handler;
- LOG4CXX_AUTO_TRACE(logger_);
- LOG4CXX_DEBUG(logger_,
- "ServiceType = " << type << ". Session = " << std::hex
- << session_key);
-
- if (type == kRpc) {
- LOG4CXX_DEBUG(logger_, "RPC service is about to be started.");
- return true;
- }
- ApplicationSharedPtr app = application(session_key);
- if (!app) {
- LOG4CXX_WARN(logger_,
- "The application with id:" << session_key
- << " doesn't exists.");
- return false;
- }
-
- if (Compare<ServiceType, EQ, ONE>(
- type, ServiceType::kMobileNav, ServiceType::kAudio)) {
- if (app->is_navi()) {
- return StartNaviService(session_key, type);
- } else {
- LOG4CXX_WARN(logger_, "Refuse not navi application");
- }
- } else {
- LOG4CXX_WARN(logger_, "Refuse unknown service");
- }
- return false;
-}
-#pragma GCC diagnostic pop
-
void ApplicationManagerImpl::OnServiceStartedCallback(
const connection_handler::DeviceHandle& device_handle,
const int32_t& session_key,
@@ -1947,6 +1756,8 @@ bool ApplicationManagerImpl::Stop() {
stopping_application_mng_lock_.Release();
application_list_update_timer_.Stop();
try {
+ SetUnregisterAllApplicationsReason(
+ mobile_api::AppInterfaceUnregisteredReason::IGNITION_OFF);
UnregisterAllApplications();
} catch (...) {
LOG4CXX_ERROR(logger_,
@@ -2326,6 +2137,14 @@ void ApplicationManagerImpl::set_application_id(const int32_t correlation_id,
std::pair<const int32_t, const uint32_t>(correlation_id, app_id));
}
+uint32_t ApplicationManagerImpl::get_current_audio_source() const {
+ return current_audio_source_;
+}
+
+void ApplicationManagerImpl::set_current_audio_source(const uint32_t source) {
+ current_audio_source_ = source;
+}
+
void ApplicationManagerImpl::AddPolicyObserver(
policy::PolicyHandlerObserver* listener) {
GetPolicyHandler().add_listener(listener);
@@ -2418,7 +2237,10 @@ void ApplicationManagerImpl::ClearAppsPersistentData() {
void ApplicationManagerImpl::SendOnSDLClose() {
LOG4CXX_AUTO_TRACE(logger_);
-
+ if (IsLowVoltage()) {
+ LOG4CXX_TRACE(logger_, "SDL is in Low Voltage State");
+ return;
+ }
// must be sent to PASA HMI on shutdown synchronously
smart_objects::SmartObjectSPtr msg =
std::make_shared<smart_objects::SmartObject>(
@@ -2608,11 +2430,13 @@ void ApplicationManagerImpl::UnregisterApplication(
return;
}
+
if (is_resuming) {
resume_controller().SaveApplication(app_to_remove);
} else {
resume_controller().RemoveApplicationFromSaved(app_to_remove);
}
+
(hmi_capabilities_->get_hmi_language_handler())
.OnUnregisterApplication(app_id);
AppV4DevicePredicate finder(handle);
@@ -2716,14 +2540,24 @@ bool ApplicationManagerImpl::is_audio_pass_thru_active() const {
void ApplicationManagerImpl::OnLowVoltage() {
LOG4CXX_AUTO_TRACE(logger_);
is_low_voltage_ = true;
+ resume_ctrl_->SaveLowVoltageTime();
+ resume_ctrl_->StopSavePersistentDataTimer();
request_ctrl_.OnLowVoltage();
}
-bool ApplicationManagerImpl::IsLowVoltage() {
- LOG4CXX_TRACE(logger_, "result: " << is_low_voltage_);
+bool ApplicationManagerImpl::IsLowVoltage() const {
+ LOG4CXX_TRACE(logger_, "Result: " << is_low_voltage_);
return is_low_voltage_;
}
+void ApplicationManagerImpl::OnWakeUp() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ is_low_voltage_ = false;
+ resume_ctrl_->SaveWakeUpTime();
+ resume_ctrl_->StartSavePersistentDataTimer();
+ request_ctrl_.OnWakeUp();
+}
+
std::string ApplicationManagerImpl::GetHashedAppID(
uint32_t connection_key, const std::string& mobile_app_id) const {
connection_handler::DeviceHandle device_id = 0;
@@ -3142,12 +2976,6 @@ policy::DeviceConsent ApplicationManagerImpl::GetUserConsentForDevice(
return GetPolicyHandler().GetUserConsentForDevice(device_id);
}
-void ApplicationManagerImpl::OnWakeUp() {
- LOG4CXX_AUTO_TRACE(logger_);
- is_low_voltage_ = false;
- request_ctrl_.OnWakeUp();
-}
-
mobile_apis::Result::eType ApplicationManagerImpl::SaveBinary(
const std::vector<uint8_t>& binary_data,
const std::string& file_path,
@@ -3611,30 +3439,6 @@ void ApplicationManagerImpl::ClearTTSGlobalPropertiesList() {
}
bool ApplicationManagerImpl::IsAppSubscribedForWayPoints(
- const uint32_t app_id) const {
- LOG4CXX_AUTO_TRACE(logger_);
- sync_primitives::AutoLock lock(subscribed_way_points_apps_lock_);
- if (subscribed_way_points_apps_list_.find(app_id) ==
- subscribed_way_points_apps_list_.end()) {
- return false;
- }
- return true;
-}
-
-void ApplicationManagerImpl::SubscribeAppForWayPoints(const uint32_t app_id) {
- LOG4CXX_AUTO_TRACE(logger_);
- sync_primitives::AutoLock lock(subscribed_way_points_apps_lock_);
- subscribed_way_points_apps_list_.insert(app_id);
-}
-
-void ApplicationManagerImpl::UnsubscribeAppFromWayPoints(
- const uint32_t app_id) {
- LOG4CXX_AUTO_TRACE(logger_);
- sync_primitives::AutoLock lock(subscribed_way_points_apps_lock_);
- subscribed_way_points_apps_list_.erase(app_id);
-}
-
-bool ApplicationManagerImpl::IsAppSubscribedForWayPoints(
ApplicationSharedPtr app) const {
LOG4CXX_AUTO_TRACE(logger_);
sync_primitives::AutoLock lock(subscribed_way_points_apps_lock_);
diff --git a/src/components/application_manager/src/commands/command_impl.cc b/src/components/application_manager/src/commands/command_impl.cc
index db78ad15f0..dcc521ae57 100644
--- a/src/components/application_manager/src/commands/command_impl.cc
+++ b/src/components/application_manager/src/commands/command_impl.cc
@@ -155,13 +155,6 @@ bool CommandImpl::ReplaceMobileWithHMIAppId(
return true;
}
-DEPRECATED void CommandImpl::ReplaceMobileByHMIAppId(
- NsSmartDeviceLink::NsSmartObjects::SmartObject& message) {
- if (!ReplaceMobileWithHMIAppId(message)) {
- LOG4CXX_ERROR(logger_, "Substitution mobile --> HMI id is failed.");
- }
-}
-
bool CommandImpl::ReplaceHMIWithMobileAppId(
NsSmartDeviceLink::NsSmartObjects::SmartObject& message) {
if (message.keyExists(strings::app_id)) {
@@ -207,12 +200,5 @@ bool CommandImpl::ReplaceHMIWithMobileAppId(
return true;
}
-DEPRECATED void CommandImpl::ReplaceHMIByMobileAppId(
- NsSmartDeviceLink::NsSmartObjects::SmartObject& message) {
- if (!ReplaceHMIWithMobileAppId(message)) {
- LOG4CXX_ERROR(logger_, "Substitution HMI --> mobile id is failed.");
- }
-}
-
} // namespace commands
} // namespace application_manager
diff --git a/src/components/application_manager/src/hmi_state.cc b/src/components/application_manager/src/hmi_state.cc
index 0033fe4fb6..aa4c979ae7 100644
--- a/src/components/application_manager/src/hmi_state.cc
+++ b/src/components/application_manager/src/hmi_state.cc
@@ -67,27 +67,6 @@ HmiState::HmiState(std::shared_ptr<Application> app,
LOG4CXX_DEBUG(logger_, *this);
}
-DEPRECATED HmiState::HmiState(uint32_t app_id,
- const ApplicationManager& app_mngr,
- StateID state_id)
- : state_id_(state_id)
- , app_mngr_(app_mngr)
- , hmi_level_(mobile_apis::HMILevel::INVALID_ENUM)
- , audio_streaming_state_(mobile_apis::AudioStreamingState::INVALID_ENUM)
- , system_context_(mobile_apis::SystemContext::INVALID_ENUM) {
- app_ = app_mngr_.application(app_id);
-}
-
-DEPRECATED HmiState::HmiState(uint32_t app_id,
- const ApplicationManager& app_mngr)
- : state_id_(STATE_ID_REGULAR)
- , app_mngr_(app_mngr)
- , hmi_level_(mobile_apis::HMILevel::INVALID_ENUM)
- , audio_streaming_state_(mobile_apis::AudioStreamingState::INVALID_ENUM)
- , system_context_(mobile_apis::SystemContext::INVALID_ENUM) {
- app_ = app_mngr_.application(app_id);
-}
-
void HmiState::set_parent(HmiStatePtr parent) {
DCHECK_OR_RETURN_VOID(parent);
parent_ = parent;
@@ -119,18 +98,10 @@ VRHmiState::VRHmiState(std::shared_ptr<Application> app,
const ApplicationManager& app_mngr)
: HmiState(app, app_mngr, STATE_ID_VR_SESSION) {}
-DEPRECATED VRHmiState::VRHmiState(uint32_t app_id,
- const ApplicationManager& app_mngr)
- : HmiState(app_id, app_mngr, STATE_ID_VR_SESSION) {}
-
TTSHmiState::TTSHmiState(std::shared_ptr<Application> app,
const ApplicationManager& app_mngr)
: HmiState(app, app_mngr, STATE_ID_TTS_SESSION) {}
-DEPRECATED TTSHmiState::TTSHmiState(uint32_t app_id,
- const ApplicationManager& app_mngr)
- : HmiState(app_id, app_mngr, STATE_ID_TTS_SESSION) {}
-
mobile_apis::AudioStreamingState::eType TTSHmiState::audio_streaming_state()
const {
using namespace helpers;
@@ -189,10 +160,6 @@ PhoneCallHmiState::PhoneCallHmiState(std::shared_ptr<Application> app,
const ApplicationManager& app_mngr)
: HmiState(app, app_mngr, STATE_ID_PHONE_CALL) {}
-DEPRECATED PhoneCallHmiState::PhoneCallHmiState(
- uint32_t app_id, const ApplicationManager& app_mngr)
- : HmiState(app_id, app_mngr, STATE_ID_PHONE_CALL) {}
-
mobile_apis::HMILevel::eType PhoneCallHmiState::hmi_level() const {
using namespace helpers;
using namespace mobile_apis;
@@ -214,18 +181,10 @@ SafetyModeHmiState::SafetyModeHmiState(std::shared_ptr<Application> app,
const ApplicationManager& app_mngr)
: HmiState(app, app_mngr, STATE_ID_SAFETY_MODE) {}
-DEPRECATED SafetyModeHmiState::SafetyModeHmiState(
- uint32_t app_id, const ApplicationManager& app_mngr)
- : HmiState(app_id, app_mngr, STATE_ID_SAFETY_MODE) {}
-
DeactivateHMI::DeactivateHMI(std::shared_ptr<Application> app,
const ApplicationManager& app_mngr)
: HmiState(app, app_mngr, STATE_ID_DEACTIVATE_HMI) {}
-DEPRECATED DeactivateHMI::DeactivateHMI(uint32_t app_id,
- const ApplicationManager& app_mngr)
- : HmiState(app_id, app_mngr, STATE_ID_DEACTIVATE_HMI) {}
-
mobile_apis::HMILevel::eType DeactivateHMI::hmi_level() const {
using namespace helpers;
using namespace mobile_apis;
@@ -242,16 +201,15 @@ AudioSource::AudioSource(std::shared_ptr<Application> app,
const ApplicationManager& app_mngr)
: HmiState(app, app_mngr, STATE_ID_AUDIO_SOURCE) {}
-DEPRECATED AudioSource::AudioSource(uint32_t app_id,
- const ApplicationManager& app_mngr)
- : HmiState(app_id, app_mngr, STATE_ID_AUDIO_SOURCE) {}
-
mobile_apis::HMILevel::eType AudioSource::hmi_level() const {
// Checking for NONE is necessary to avoid issue during
// calculation of HMI level during setting default HMI level
if (mobile_apis::HMILevel::HMI_NONE == parent()->hmi_level()) {
return mobile_apis::HMILevel::HMI_NONE;
}
+ if (mobile_apis::HMILevel::HMI_FULL == parent()->hmi_level()) {
+ return mobile_apis::HMILevel::HMI_FULL;
+ }
return mobile_apis::HMILevel::HMI_BACKGROUND;
}
@@ -260,10 +218,6 @@ EmbeddedNavi::EmbeddedNavi(std::shared_ptr<Application> app,
const ApplicationManager& app_mngr)
: HmiState(app, app_mngr, STATE_ID_EMBEDDED_NAVI) {}
-DEPRECATED EmbeddedNavi::EmbeddedNavi(uint32_t app_id,
- const ApplicationManager& app_mngr)
- : HmiState(app_id, app_mngr, STATE_ID_EMBEDDED_NAVI) {}
-
mobile_apis::HMILevel::eType EmbeddedNavi::hmi_level() const {
using namespace mobile_apis;
using namespace helpers;
diff --git a/src/components/application_manager/src/message.cc b/src/components/application_manager/src/message.cc
index b005af0fb5..332d68adbf 100644
--- a/src/components/application_manager/src/message.cc
+++ b/src/components/application_manager/src/message.cc
@@ -190,19 +190,6 @@ void Message::set_message_type(MessageType type) {
type_ = type;
}
-void Message::set_binary_data(BinaryData* data) {
- if (NULL == data) {
- NOTREACHED();
- return;
- }
-
- if (binary_data_) {
- delete binary_data_;
- }
-
- binary_data_ = new BinaryData(*data);
-}
-
void Message::set_binary_data(const BinaryData* data) {
if (NULL == data) {
NOTREACHED();
diff --git a/src/components/application_manager/src/message_helper/message_helper.cc b/src/components/application_manager/src/message_helper/message_helper.cc
index 052d619fcc..0ad86b5541 100644
--- a/src/components/application_manager/src/message_helper/message_helper.cc
+++ b/src/components/application_manager/src/message_helper/message_helper.cc
@@ -2690,6 +2690,40 @@ mobile_apis::Result::eType MessageHelper::VerifyImage(
return mobile_apis::Result::WARNINGS;
}
+MessageHelper::ChoiceSetVRCommandsStatus
+MessageHelper::CheckChoiceSetVRCommands(
+ const smart_objects::SmartObject& choice_set) {
+ // if this is false, someone doesn't have vrCommands
+ bool all_have = true;
+ // if this is false, someone has vrCommands
+ bool none_have = true;
+ smart_objects::SmartArray::const_iterator current_choice_set_it =
+ choice_set.asArray()->begin();
+ // Iterate through choices
+ for (; choice_set.asArray()->end() != current_choice_set_it;
+ ++current_choice_set_it) {
+ // if the vrCommands is present
+ if (current_choice_set_it->keyExists(
+ application_manager::strings::vr_commands)) {
+ // this one has the parameter
+ none_have = false;
+ } else {
+ // this one doesn't
+ all_have = false;
+ }
+ }
+ // everyone has it
+ if (all_have) {
+ return MessageHelper::ChoiceSetVRCommandsStatus::ALL;
+ }
+ // No one has it
+ if (none_have) {
+ return MessageHelper::ChoiceSetVRCommandsStatus::NONE;
+ }
+ // mix-and-match
+ return MessageHelper::ChoiceSetVRCommandsStatus::MIXED;
+}
+
mobile_apis::Result::eType MessageHelper::VerifyImageVrHelpItems(
smart_objects::SmartObject& message,
ApplicationConstSharedPtr app,
diff --git a/src/components/application_manager/src/resumption/resume_ctrl_impl.cc b/src/components/application_manager/src/resumption/resume_ctrl_impl.cc
index 42dc335878..3e77078ee5 100644
--- a/src/components/application_manager/src/resumption/resume_ctrl_impl.cc
+++ b/src/components/application_manager/src/resumption/resume_ctrl_impl.cc
@@ -74,7 +74,9 @@ ResumeCtrlImpl::ResumeCtrlImpl(ApplicationManager& application_manager)
, is_resumption_active_(false)
, is_data_saved_(false)
, is_suspended_(false)
- , launch_time_(time(NULL))
+ , launch_time_(time(nullptr))
+ , low_voltage_time_(0)
+ , wake_up_time_(0)
, application_manager_(application_manager) {}
#ifdef BUILD_TESTS
void ResumeCtrlImpl::set_resumption_storage(
@@ -128,6 +130,8 @@ bool ResumeCtrlImpl::Init(resumption::LastState& last_state) {
application_manager_.get_settings()
.app_resumption_save_persistent_data_timeout(),
timer::kPeriodic);
+
+ resumption_storage_->IncrementGlobalIgnOnCounter();
return true;
}
@@ -144,9 +148,13 @@ void ResumeCtrlImpl::SaveAllApplications() {
void ResumeCtrlImpl::SaveApplication(ApplicationSharedPtr application) {
LOG4CXX_AUTO_TRACE(logger_);
DCHECK_OR_RETURN_VOID(application);
- LOG4CXX_INFO(logger_,
- "application with appID " << application->app_id()
- << " will be saved");
+ if (application_manager_.IsLowVoltage()) {
+ LOG4CXX_DEBUG(logger_, "Low Voltage state is active");
+ return;
+ }
+ LOG4CXX_DEBUG(logger_,
+ "application with appID " << application->app_id()
+ << " will be saved");
resumption_storage_->SaveApplication(application);
}
@@ -310,6 +318,10 @@ uint32_t ResumeCtrlImpl::GetHMIApplicationID(
bool ResumeCtrlImpl::RemoveApplicationFromSaved(
ApplicationConstSharedPtr application) {
+ if (application_manager_.IsLowVoltage()) {
+ LOG4CXX_DEBUG(logger_, "Low Voltage state is active");
+ return false;
+ }
const std::string& device_mac = application->mac_address();
return resumption_storage_->RemoveApplicationFromSaved(
application->policy_app_id(), device_mac);
@@ -323,8 +335,11 @@ void ResumeCtrlImpl::OnSuspend() {
void ResumeCtrlImpl::OnIgnitionOff() {
LOG4CXX_AUTO_TRACE(logger_);
- resumption_storage_->IncrementIgnOffCount();
- FinalPersistData();
+ if (!application_manager_.IsLowVoltage()) {
+ resumption_storage_->IncrementIgnOffCount();
+ resumption_storage_->ResetGlobalIgnOnCount();
+ FinalPersistData();
+ }
}
void ResumeCtrlImpl::OnAwake() {
@@ -334,6 +349,25 @@ void ResumeCtrlImpl::OnAwake() {
StartSavePersistentDataTimer();
}
+void ResumeCtrlImpl::SaveLowVoltageTime() {
+ low_voltage_time_ = time(nullptr);
+ LOG4CXX_DEBUG(logger_,
+ "Low Voltage timestamp : " << low_voltage_time_ << " saved");
+}
+
+void ResumeCtrlImpl::SaveWakeUpTime() {
+ wake_up_time_ = std::time(nullptr);
+ LOG4CXX_DEBUG(logger_, "Wake Up timestamp : " << wake_up_time_ << " saved");
+}
+
+time_t ResumeCtrlImpl::LowVoltageTime() const {
+ return low_voltage_time_;
+}
+
+time_t ResumeCtrlImpl::WakeUpTime() const {
+ return wake_up_time_;
+}
+
bool ResumeCtrlImpl::is_suspended() const {
return is_suspended_;
}
@@ -440,12 +474,25 @@ void ResumeCtrlImpl::StartAppHmiStateResumption(
LOG4CXX_ERROR(logger_, "Application was not saved");
return;
}
- const uint32_t ign_off_count = saved_app[strings::ign_off_count].asUInt();
- bool restore_data_allowed = false;
- restore_data_allowed =
- CheckAppRestrictions(application, saved_app) &&
- ((0 == ign_off_count) || CheckIgnCycleRestrictions(saved_app));
- if (restore_data_allowed) {
+
+ const bool is_hmi_level_applicable_to_resume =
+ CheckAppRestrictions(application, saved_app);
+
+ if (!is_hmi_level_applicable_to_resume) {
+ LOG4CXX_DEBUG(logger_, "No applicable HMI level found for resuming");
+ return;
+ }
+
+ const bool is_resume_allowed_by_low_voltage =
+ CheckLowVoltageRestrictions(saved_app);
+
+ const bool is_hmi_level_allowed_by_ign_cycle =
+ CheckIgnCycleRestrictions(saved_app);
+
+ const bool restore_hmi_level_allowed =
+ is_resume_allowed_by_low_voltage && is_hmi_level_allowed_by_ign_cycle;
+
+ if (restore_hmi_level_allowed) {
LOG4CXX_INFO(logger_,
"Resume application " << application->policy_app_id());
RestoreAppHMIState(application);
@@ -716,30 +763,62 @@ void ResumeCtrlImpl::AddSubscriptions(
bool ResumeCtrlImpl::CheckIgnCycleRestrictions(
const smart_objects::SmartObject& saved_app) {
LOG4CXX_AUTO_TRACE(logger_);
- bool result = true;
if (!CheckDelayAfterIgnOn()) {
- LOG4CXX_INFO(logger_, "Application was connected long after ign on");
- result = false;
+ LOG4CXX_DEBUG(logger_, "Application was connected long after ign on");
+ return false;
}
- if (!DisconnectedJustBeforeIgnOff(saved_app)) {
- LOG4CXX_INFO(logger_, "Application was dissconnected long before ign off");
- result = false;
+ if (!CheckDelayBeforeIgnOff(saved_app)) {
+ LOG4CXX_DEBUG(logger_, "Application was disconnected long before ign off");
+ return false;
}
- return result;
+ return true;
}
-bool ResumeCtrlImpl::DisconnectedJustBeforeIgnOff(
+bool ResumeCtrlImpl::CheckLowVoltageRestrictions(
const smart_objects::SmartObject& saved_app) {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ if (!CheckDelayBeforeLowVoltage(saved_app)) {
+ LOG4CXX_DEBUG(logger_,
+ "Application was disconnected long before low voltage");
+ return false;
+ }
+
+ if (!CheckDelayAfterWakeUp()) {
+ LOG4CXX_DEBUG(logger_, "Application was connected long after wake up");
+ return false;
+ }
+
+ LOG4CXX_DEBUG(logger_, "HMI Level resuming in not restricted by Low Voltage");
+ return true;
+}
+
+bool ResumeCtrlImpl::CheckDelayBeforeIgnOff(
+ const smart_objects::SmartObject& saved_app) const {
using namespace date_time;
LOG4CXX_AUTO_TRACE(logger_);
DCHECK_OR_RETURN(saved_app.keyExists(strings::time_stamp), false);
const time_t time_stamp =
static_cast<time_t>(saved_app[strings::time_stamp].asInt());
- time_t ign_off_time =
+ const time_t ign_off_time =
static_cast<time_t>(resumption_storage_->GetIgnOffTime());
+
+ if (CheckIgnCyclesData() && 0 == ign_off_time) {
+ LOG4CXX_DEBUG(
+ logger_, "No IGNITION OFF records found: This is first Ignition cycle");
+ return true;
+ }
+
+ // This means that ignition off timestamp was not saved
+ // Possible reasons: Low Voltage event, core crash etc.
+ if (ign_off_time < time_stamp) {
+ LOG4CXX_DEBUG(logger_, "Last IGNITION OFF record missed");
+ return true;
+ }
+
const uint32_t sec_spent_before_ign = labs(ign_off_time - time_stamp);
LOG4CXX_DEBUG(
logger_,
@@ -752,6 +831,71 @@ bool ResumeCtrlImpl::DisconnectedJustBeforeIgnOff(
application_manager_.get_settings().resumption_delay_before_ign();
}
+bool ResumeCtrlImpl::CheckDelayBeforeLowVoltage(
+ const smart_objects::SmartObject& saved_app) const {
+ using namespace date_time;
+ LOG4CXX_AUTO_TRACE(logger_);
+ DCHECK_OR_RETURN(saved_app.keyExists(strings::time_stamp), false);
+
+ if (0 == LowVoltageTime()) {
+ LOG4CXX_DEBUG(logger_, "No Low Voltage signal timestamp saved");
+ return true;
+ }
+
+ const time_t unregistration_time_stamp =
+ static_cast<time_t>(saved_app[strings::time_stamp].asInt());
+ const time_t low_voltage_timestamp = static_cast<time_t>(LowVoltageTime());
+ const int32_t sec_spent_before_low_voltage =
+ (low_voltage_timestamp - unregistration_time_stamp);
+ if (0 > sec_spent_before_low_voltage) {
+ LOG4CXX_DEBUG(logger_,
+ "Low Voltage time: "
+ << low_voltage_timestamp
+ << "; App disconnect time: " << unregistration_time_stamp
+ << "; Secs between app disconnect and low voltage event "
+ << sec_spent_before_low_voltage);
+ return true;
+ }
+
+ const uint32_t secs_between_app_disconnect_and_low_voltage =
+ static_cast<uint32_t>(sec_spent_before_low_voltage);
+ const uint32_t wait_time =
+ application_manager_.get_settings().resumption_delay_before_ign();
+ LOG4CXX_DEBUG(logger_,
+ "Low Voltage time: "
+ << low_voltage_timestamp
+ << "; App disconnect time: " << unregistration_time_stamp
+ << "; Secs between app disconnect and low voltage event "
+ << secs_between_app_disconnect_and_low_voltage
+ << "; Timeout for HMI level resuming: " << wait_time);
+ return secs_between_app_disconnect_and_low_voltage <= wait_time;
+}
+
+bool ResumeCtrlImpl::CheckDelayAfterWakeUp() const {
+ using namespace date_time;
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ if (0 == WakeUpTime()) {
+ LOG4CXX_DEBUG(logger_, "No WakeUp signal timestamp saved");
+ return true;
+ }
+
+ const time_t current_time = time(nullptr);
+ const time_t wake_up_timestamp = static_cast<time_t>(WakeUpTime());
+
+ const uint32_t seconds_from_wake_up_signal =
+ labs(current_time - wake_up_timestamp);
+ const uint32_t wait_time =
+ application_manager_.get_settings().resumption_delay_after_ign();
+ LOG4CXX_DEBUG(
+ logger_,
+ "Current time: " << current_time << "; WakeUp Signal time: "
+ << wake_up_timestamp << "; Seconds passed from wake up: "
+ << seconds_from_wake_up_signal
+ << "; Timeout for HMI level resuming: " << wait_time);
+ return seconds_from_wake_up_signal <= wait_time;
+}
+
bool ResumeCtrlImpl::CheckAppRestrictions(
ApplicationConstSharedPtr application,
const smart_objects::SmartObject& saved_app) {
@@ -773,9 +917,10 @@ bool ResumeCtrlImpl::CheckAppRestrictions(
? true
: false;
LOG4CXX_DEBUG(logger_,
- "is_media_app " << application->is_media_application()
- << "; hmi_level " << hmi_level << " result "
- << result);
+ "is_media_app: " << application->is_media_application()
+ << "; hmi_level: " << hmi_level << "; result: "
+ << (result ? "Applicable for resume"
+ : "Non-applicable for resume"));
return result;
}
@@ -788,11 +933,36 @@ bool ResumeCtrlImpl::CheckIcons(ApplicationSharedPtr application,
return mobile_apis::Result::INVALID_DATA != verify_images;
}
-bool ResumeCtrlImpl::CheckDelayAfterIgnOn() {
+bool ResumeCtrlImpl::CheckIgnCyclesData() const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ const uint32_t global_ign_on_count =
+ resumption_storage_->GetGlobalIgnOnCounter();
+ const uint32_t the_first_ignition = 1;
+ const bool is_emergency_ign_off_occurred =
+ global_ign_on_count > the_first_ignition;
+ // global_ign_on_count is reseting to 0 at ignition off
+ // global_ign_on_count is incrementing at ignition on
+ // global_ign_on_count > 1 means that correct ignition off was not present.
+ if (is_emergency_ign_off_occurred) {
+ LOG4CXX_WARN(logger_,
+ "Emergency IGN OFF occurred. Possibly after Low Voltage");
+ return false;
+ }
+ return true;
+}
+
+bool ResumeCtrlImpl::CheckDelayAfterIgnOn() const {
using namespace date_time;
LOG4CXX_AUTO_TRACE(logger_);
- const time_t curr_time = time(NULL);
+ const time_t ign_off_time = GetIgnOffTime();
+
+ if (CheckIgnCyclesData() && 0 == ign_off_time) {
+ LOG4CXX_DEBUG(logger_, "This is first Ignition cycle");
+ return true;
+ }
+ const time_t curr_time = time(nullptr);
const time_t sdl_launch_time = LaunchTime();
+
const uint32_t seconds_from_sdl_start = labs(curr_time - sdl_launch_time);
const uint32_t wait_time =
application_manager_.get_settings().resumption_delay_after_ign();
@@ -808,7 +978,7 @@ time_t ResumeCtrlImpl::LaunchTime() const {
return launch_time_;
}
-time_t ResumeCtrlImpl::GetIgnOffTime() {
+time_t ResumeCtrlImpl::GetIgnOffTime() const {
return resumption_storage_->GetIgnOffTime();
}
@@ -856,6 +1026,8 @@ void ResumeCtrlImpl::AddToResumptionTimerQueue(const uint32_t app_id) {
"Application ID " << app_id << " have been added"
" to resumption queue.");
if (run_resumption) {
+ LOG4CXX_DEBUG(logger_,
+ "Application ID " << app_id << " will be restored by timer");
restore_hmi_level_timer_.Start(
application_manager_.get_settings().app_resuming_timeout(),
timer::kSingleShot);
diff --git a/src/components/application_manager/src/resumption/resumption_data_db.cc b/src/components/application_manager/src/resumption/resumption_data_db.cc
index 2fe7330a9c..1591ce566a 100644
--- a/src/components/application_manager/src/resumption/resumption_data_db.cc
+++ b/src/components/application_manager/src/resumption/resumption_data_db.cc
@@ -163,11 +163,10 @@ void ResumptionDataDB::SaveApplication(
}
if (application->is_application_data_changed()) {
- if (application_exist) {
- if (!DeleteSavedApplication(policy_app_id, device_mac)) {
- LOG4CXX_ERROR(logger_, "Deleting of application data is not finished");
- return;
- }
+ if (application_exist &&
+ !DeleteSavedApplication(policy_app_id, device_mac)) {
+ LOG4CXX_ERROR(logger_, "Deleting of application data is not finished");
+ return;
}
if (!SaveApplicationToDB(application, policy_app_id, device_mac)) {
@@ -176,23 +175,15 @@ void ResumptionDataDB::SaveApplication(
}
LOG4CXX_INFO(logger_, "All data from application were saved successfully");
application->set_is_application_data_changed(false);
- } else {
- if (application_exist) {
- if (!UpdateApplicationData(application, policy_app_id, device_mac)) {
- LOG4CXX_ERROR(logger_, "Updating application data is failed");
- return;
- }
- LOG4CXX_INFO(logger_, "Application data were updated successfully");
- } else {
- if (Compare<HMILevel::eType, EQ, ONE>(application->hmi_level(),
- HMILevel::HMI_FULL,
- HMILevel::HMI_LIMITED)) {
- if (!InsertApplicationData(application, policy_app_id, device_mac)) {
- LOG4CXX_ERROR(logger_, "Saving data of application is failed");
- return;
- }
- }
+ } else if (application_exist) {
+ if (!UpdateApplicationData(application, policy_app_id, device_mac)) {
+ LOG4CXX_ERROR(logger_, "Updating application data is failed");
+ return;
}
+ LOG4CXX_INFO(logger_, "Application data were updated successfully");
+ } else if (!InsertApplicationData(application, policy_app_id, device_mac)) {
+ LOG4CXX_ERROR(logger_, "Saving data of application is failed");
+ return;
}
WriteDb();
}
@@ -212,8 +203,6 @@ uint32_t ResumptionDataDB::GetHMIApplicationID(
return hmi_app_id;
}
-DEPRECATED void ResumptionDataDB::OnSuspend() {}
-
void ResumptionDataDB::IncrementIgnOffCount() {
LOG4CXX_AUTO_TRACE(logger_);
@@ -240,7 +229,7 @@ void ResumptionDataDB::IncrementIgnOffCount() {
}
}
- if (query_update_last_ign_off_time.Prepare(KUpdateLastIgnOffTime)) {
+ if (query_update_last_ign_off_time.Prepare(kUpdateLastIgnOffTime)) {
query_update_last_ign_off_time.Bind(0, static_cast<int64_t>(time(NULL)));
if (query_update_last_ign_off_time.Exec()) {
LOG4CXX_INFO(logger_, "Data last_ign_off_time was updated");
@@ -293,8 +282,6 @@ bool ResumptionDataDB::GetHashId(const std::string& policy_app_id,
return SelectHashId(policy_app_id, device_id, hash_id);
}
-DEPRECATED void ResumptionDataDB::OnAwake() {}
-
void ResumptionDataDB::DecrementIgnOffCount() {
LOG4CXX_AUTO_TRACE(logger_);
@@ -376,10 +363,61 @@ bool ResumptionDataDB::RemoveApplicationFromSaved(
uint32_t ResumptionDataDB::GetIgnOffTime() const {
LOG4CXX_AUTO_TRACE(logger_);
-
return SelectIgnOffTime();
}
+uint32_t ResumptionDataDB::GetGlobalIgnOnCounter() const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ sync_primitives::AutoLock autolock(resumption_lock_);
+
+ utils::dbms::SQLQuery query(db());
+ if (!query.Prepare(kSelectGlobalIgnOnCounter)) {
+ LOG4CXX_ERROR(logger_,
+ "Problem with prepare query : " << kSelectGlobalIgnOnCounter);
+ return 1;
+ }
+
+ if (!query.Exec()) {
+ LOG4CXX_ERROR(logger_,
+ "Problem with exec query : " << kSelectGlobalIgnOnCounter);
+ return 1;
+ }
+
+ const auto global_ign_on_counter = query.GetUInteger(0);
+ LOG4CXX_DEBUG(logger_, "Global Ign On Counter = " << global_ign_on_counter);
+ return global_ign_on_counter;
+}
+
+void ResumptionDataDB::IncrementGlobalIgnOnCounter() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ sync_primitives::AutoLock autolock(resumption_lock_);
+
+ db_->BeginTransaction();
+ utils::dbms::SQLQuery query_update_global_ign_on_count(db());
+ if (query_update_global_ign_on_count.Prepare(kUpdateGlobalIgnOnCount)) {
+ if (query_update_global_ign_on_count.Exec()) {
+ LOG4CXX_DEBUG(logger_,
+ "Data query_update_global_ign_on_count was updated");
+ }
+ }
+ db_->CommitTransaction();
+ WriteDb();
+}
+
+void ResumptionDataDB::ResetGlobalIgnOnCount() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ sync_primitives::AutoLock autolock(resumption_lock_);
+
+ LOG4CXX_DEBUG(logger_, "Global IGN ON counter resetting");
+
+ utils::dbms::SQLQuery query_update_global_ign_on_count(db());
+ if (query_update_global_ign_on_count.Prepare(kResetGlobalIgnOnCount)) {
+ if (query_update_global_ign_on_count.Exec()) {
+ LOG4CXX_DEBUG(logger_, "Data was updated");
+ }
+ }
+}
+
ssize_t ResumptionDataDB::IsApplicationSaved(
const std::string& policy_app_id, const std::string& device_id) const {
LOG4CXX_AUTO_TRACE(logger_);
@@ -557,7 +595,6 @@ void ResumptionDataDB::SelectDataForLoadResumeData(
using namespace app_mngr;
using namespace smart_objects;
LOG4CXX_AUTO_TRACE(logger_);
-
utils::dbms::SQLQuery select_data(db());
utils::dbms::SQLQuery count_application(db());
if (!select_data.Prepare(kSelectDataForLoadResumeData) ||
diff --git a/src/components/application_manager/src/resumption/resumption_data_json.cc b/src/components/application_manager/src/resumption/resumption_data_json.cc
index b6a50fd5de..87241c883a 100644
--- a/src/components/application_manager/src/resumption/resumption_data_json.cc
+++ b/src/components/application_manager/src/resumption/resumption_data_json.cc
@@ -143,8 +143,6 @@ uint32_t ResumptionDataJson::GetHMIApplicationID(
return hmi_app_id;
}
-DEPRECATED void ResumptionDataJson::OnSuspend() {}
-
void ResumptionDataJson::IncrementIgnOffCount() {
using namespace app_mngr;
LOG4CXX_AUTO_TRACE(logger_);
@@ -169,8 +167,6 @@ void ResumptionDataJson::IncrementIgnOffCount() {
LOG4CXX_DEBUG(logger_, GetResumptionData().toStyledString());
}
-DEPRECATED void ResumptionDataJson::OnAwake() {}
-
void ResumptionDataJson::DecrementIgnOffCount() {
using namespace app_mngr;
LOG4CXX_AUTO_TRACE(logger_);
@@ -283,6 +279,51 @@ uint32_t ResumptionDataJson::GetIgnOffTime() const {
return resumption[strings::last_ign_off_time].asUInt();
}
+uint32_t ResumptionDataJson::GetGlobalIgnOnCounter() const {
+ using namespace app_mngr;
+ LOG4CXX_AUTO_TRACE(logger_);
+ sync_primitives::AutoLock autolock(resumption_lock_);
+ Json::Value& resumption = GetResumptionData();
+ if (resumption.isMember(strings::global_ign_on_counter)) {
+ const uint32_t global_ign_on_counter =
+ resumption[strings::global_ign_on_counter].asUInt();
+ LOG4CXX_DEBUG(logger_, "Global Ign On Counter = " << global_ign_on_counter);
+ return global_ign_on_counter;
+ }
+ return 1;
+}
+
+void ResumptionDataJson::IncrementGlobalIgnOnCounter() {
+ using namespace app_mngr;
+ LOG4CXX_AUTO_TRACE(logger_);
+ sync_primitives::AutoLock autolock(resumption_lock_);
+ Json::Value& resumption = GetResumptionData();
+ if (resumption.isMember(strings::global_ign_on_counter)) {
+ const uint32_t global_ign_on_counter =
+ resumption[strings::global_ign_on_counter].asUInt();
+ LOG4CXX_DEBUG(
+ logger_,
+ "Global IGN ON counter in resumption data: " << global_ign_on_counter);
+ resumption[strings::global_ign_on_counter] = global_ign_on_counter + 1;
+ LOG4CXX_DEBUG(logger_,
+ "Global IGN ON counter new value: "
+ << resumption[strings::global_ign_on_counter].asUInt());
+ } else {
+ resumption[strings::global_ign_on_counter] = 1;
+ }
+ last_state().SaveStateToFileSystem();
+}
+
+void ResumptionDataJson::ResetGlobalIgnOnCount() {
+ using namespace app_mngr;
+ LOG4CXX_AUTO_TRACE(logger_);
+ sync_primitives::AutoLock autolock(resumption_lock_);
+ Json::Value& resumption = GetResumptionData();
+
+ resumption[strings::global_ign_on_counter] = 0;
+ LOG4CXX_DEBUG(logger_, "Global IGN ON counter resetting");
+}
+
ssize_t ResumptionDataJson::IsApplicationSaved(
const std::string& policy_app_id, const std::string& device_id) const {
LOG4CXX_AUTO_TRACE(logger_);
diff --git a/src/components/application_manager/src/resumption/resumption_sql_queries.cc b/src/components/application_manager/src/resumption/resumption_sql_queries.cc
index 9ca91e859a..4770bafef4 100644
--- a/src/components/application_manager/src/resumption/resumption_sql_queries.cc
+++ b/src/components/application_manager/src/resumption/resumption_sql_queries.cc
@@ -37,6 +37,7 @@ const std::string kCreateSchema =
"BEGIN ; "
"CREATE TABLE IF NOT EXISTS `resumption`( "
" `idresumption` INTEGER PRIMARY KEY, "
+ " `global_ign_on_count` INTEGER, "
" `last_ign_off_time` INTEGER "
" ); "
"CREATE TABLE IF NOT EXISTS `subscribedForWayPoints`( "
@@ -372,7 +373,9 @@ const std::string kDropSchema =
"VACUUM;";
const std::string kInsertInitData =
- "INSERT OR IGNORE INTO `resumption` (`last_ign_off_time`) VALUES (0); "
+ "INSERT OR IGNORE INTO `resumption` "
+ "(`last_ign_off_time`, `global_ign_on_count`) "
+ "VALUES (0, 0); "
"INSERT OR IGNORE INTO `_internal_data` (`db_version_hash`) VALUES(0); ";
const std::string kChecksResumptionData =
@@ -410,6 +413,17 @@ const std::string kSelectHashId =
const std::string kSelectIgnOffTime =
"SELECT `last_ign_off_time` FROM `resumption`";
+const std::string kSelectGlobalIgnOnCounter =
+ "SELECT `global_ign_on_count` FROM `resumption`";
+
+const std::string kResetGlobalIgnOnCount =
+ "UPDATE `resumption` "
+ "SET `global_ign_on_count` = 0";
+
+const std::string kUpdateGlobalIgnOnCount =
+ "UPDATE `resumption` "
+ "SET `global_ign_on_count` = `global_ign_on_count` + 1 ";
+
const std::string kCheckApplication =
"SELECT COUNT (`deviceID`) FROM `application` "
"WHERE `deviceID` = ? AND `appID` = ?";
@@ -445,7 +459,7 @@ const std::string kUpdateSuspendData =
"UPDATE `application` "
"SET `ign_off_count` = `ign_off_count` + 1";
-const std::string KUpdateLastIgnOffTime =
+const std::string kUpdateLastIgnOffTime =
"UPDATE `resumption` "
"SET `last_ign_off_time` = ?";
diff --git a/src/components/application_manager/src/rpc_handler_impl.cc b/src/components/application_manager/src/rpc_handler_impl.cc
index 7ae2b3e0c1..a605795b6e 100644
--- a/src/components/application_manager/src/rpc_handler_impl.cc
+++ b/src/components/application_manager/src/rpc_handler_impl.cc
@@ -194,6 +194,36 @@ void RPCHandlerImpl::SetTelemetryObserver(AMTelemetryObserver* observer) {
#endif // TELEMETRY_MONITOR
+void RPCHandlerImpl::GetMessageVersion(
+ NsSmartDeviceLink::NsSmartObjects::SmartObject& output,
+ utils::SemanticVersion& message_version) {
+ if (output.keyExists(
+ NsSmartDeviceLink::NsJSONHandler::strings::S_MSG_PARAMS) &&
+ output[NsSmartDeviceLink::NsJSONHandler::strings::S_MSG_PARAMS].keyExists(
+ strings::sync_msg_version)) {
+ // SyncMsgVersion exists, check if it is valid.
+ auto sync_msg_version =
+ output[NsSmartDeviceLink::NsJSONHandler::strings::S_MSG_PARAMS]
+ [strings::sync_msg_version];
+ uint16_t major = 0;
+ uint16_t minor = 0;
+ uint16_t patch = 0;
+ if (sync_msg_version.keyExists(strings::major_version)) {
+ major = sync_msg_version[strings::major_version].asUInt();
+ }
+ if (sync_msg_version.keyExists(strings::minor_version)) {
+ minor = sync_msg_version[strings::minor_version].asUInt();
+ }
+ if (sync_msg_version.keyExists(strings::patch_version)) {
+ patch = sync_msg_version[strings::patch_version].asUInt();
+ }
+ utils::SemanticVersion temp_version(major, minor, patch);
+ if (temp_version.isValid()) {
+ message_version = temp_version;
+ }
+ }
+}
+
bool RPCHandlerImpl::ConvertMessageToSO(
const Message& message,
NsSmartDeviceLink::NsSmartObjects::SmartObject& output) {
@@ -218,11 +248,27 @@ bool RPCHandlerImpl::ConvertMessageToSO(
rpc::ValidationReport report("RPC");
+ // Attach RPC version to SmartObject if it does not exist yet.
+ auto app_ptr = app_manager_.application(message.connection_key());
+ utils::SemanticVersion msg_version(0, 0, 0);
+ if (app_ptr &&
+ (output[NsSmartDeviceLink::NsJSONHandler::strings::S_PARAMS]
+ .keyExists(NsSmartDeviceLink::NsJSONHandler::strings::
+ S_RPC_MSG_VERSION) == false)) {
+ msg_version = app_ptr->msg_version();
+ } else if (mobile_apis::FunctionID::RegisterAppInterfaceID ==
+ static_cast<mobile_apis::FunctionID::eType>(
+ output[strings::params][strings::function_id].asInt())) {
+ GetMessageVersion(output, msg_version);
+ }
+
if (!conversion_result ||
- !mobile_so_factory().attachSchema(output, true) ||
- ((output.validate(&report) != smart_objects::Errors::OK))) {
+ !mobile_so_factory().attachSchema(output, true, msg_version) ||
+ ((output.validate(&report, msg_version) !=
+ smart_objects::Errors::OK))) {
LOG4CXX_WARN(logger_,
- "Failed to parse string to smart object :"
+ "Failed to parse string to smart object with API version "
+ << msg_version.toString() << " : "
<< message.json_message());
std::shared_ptr<smart_objects::SmartObject> response(
MessageHelper::CreateNegativeResponse(
diff --git a/src/components/application_manager/src/smart_object_keys.cc b/src/components/application_manager/src/smart_object_keys.cc
index 006b8c9249..7f742fcd9b 100644
--- a/src/components/application_manager/src/smart_object_keys.cc
+++ b/src/components/application_manager/src/smart_object_keys.cc
@@ -276,6 +276,7 @@ const char* last_ign_off_time = "last_ign_off_time";
const char* resume_vr_grammars = "resumeVrGrammars";
const char* ign_off_count = "ign_off_count";
+const char* global_ign_on_counter = "global_ign_on_counter";
const char* suspend_count = "suspend_count";
const char* connection_info = "connection_info";
diff --git a/src/components/application_manager/src/state_controller_impl.cc b/src/components/application_manager/src/state_controller_impl.cc
index f7a147d6df..3d44709657 100644
--- a/src/components/application_manager/src/state_controller_impl.cc
+++ b/src/components/application_manager/src/state_controller_impl.cc
@@ -458,6 +458,8 @@ mobile_apis::HMILevel::eType StateControllerImpl::GetAvailableHmiLevel(
LOG4CXX_AUTO_TRACE(logger_);
mobile_apis::HMILevel::eType result = hmi_level;
+ LOG4CXX_DEBUG(logger_, "HMI Level: " << hmi_level);
+
if (!IsStreamableHMILevel(hmi_level)) {
return result;
}
@@ -465,6 +467,7 @@ mobile_apis::HMILevel::eType StateControllerImpl::GetAvailableHmiLevel(
const bool is_audio_app = app->IsAudioApplication();
const bool does_audio_app_with_same_type_exist =
app_mngr_.IsAppTypeExistsInFullOrLimited(app);
+
if (mobile_apis::HMILevel::HMI_LIMITED == hmi_level) {
if (!is_audio_app || does_audio_app_with_same_type_exist) {
result = app_mngr_.GetDefaultHmiLevel(app);
diff --git a/src/components/application_manager/test/application_manager_impl_test.cc b/src/components/application_manager/test/application_manager_impl_test.cc
index e368163cca..36cf890351 100644
--- a/src/components/application_manager/test/application_manager_impl_test.cc
+++ b/src/components/application_manager/test/application_manager_impl_test.cc
@@ -252,7 +252,8 @@ TEST_F(
ApplicationManagerImplTest,
IsAnyAppSubscribedForWayPoints_SubcribeAppForWayPoints_ExpectCorrectResult) {
EXPECT_FALSE(app_manager_impl_->IsAnyAppSubscribedForWayPoints());
- app_manager_impl_->SubscribeAppForWayPoints(app_id_);
+ auto app_ptr = std::static_pointer_cast<am::Application>(mock_app_ptr_);
+ app_manager_impl_->SubscribeAppForWayPoints(app_ptr);
EXPECT_TRUE(app_manager_impl_->IsAnyAppSubscribedForWayPoints());
}
diff --git a/src/components/application_manager/test/commands/CMakeLists.txt b/src/components/application_manager/test/commands/CMakeLists.txt
index 165b5fc0fb..33258e60db 100644
--- a/src/components/application_manager/test/commands/CMakeLists.txt
+++ b/src/components/application_manager/test/commands/CMakeLists.txt
@@ -35,6 +35,7 @@ include_directories(
${COMPONENTS_DIR}/application_manager/include/
${COMPONENTS_DIR}/application_manager/include/application_manager/
${COMPONENTS_DIR}/application_manager/include/application_manager/commands/
+ ${CMAKE_SOURCE_DIR}/src
)
set(COMMANDS_TEST_DIR ${AM_TEST_DIR}/commands)
diff --git a/src/components/application_manager/test/include/application_manager/commands/commands_test.h b/src/components/application_manager/test/include/application_manager/commands/commands_test.h
index d795557f80..9a961ea1a9 100644
--- a/src/components/application_manager/test/include/application_manager/commands/commands_test.h
+++ b/src/components/application_manager/test/include/application_manager/commands/commands_test.h
@@ -44,6 +44,7 @@
#include "application_manager/test/include/application_manager/mock_hmi_interface.h"
#include "application_manager/test/include/application_manager/mock_application.h"
#include "application_manager/test/include/application_manager/mock_message_helper.h"
+#include "application_manager/mock_application_manager_settings.h"
#include "application_manager/mock_rpc_service.h"
#include "application_manager/mock_hmi_capabilities.h"
#include "application_manager/policies/mock_policy_handler_interface.h"
@@ -149,8 +150,10 @@ class CommandsTest : public ::testing::Test {
MockAppManager app_mngr_;
MockRPCService mock_rpc_service_;
- application_manager_test::MockHMICapabilities mock_hmi_capabilities_;
- policy_test::MockPolicyHandlerInterface mock_policy_handler_;
+ testing::NiceMock<application_manager_test::MockHMICapabilities>
+ mock_hmi_capabilities_;
+ testing::NiceMock<policy_test::MockPolicyHandlerInterface>
+ mock_policy_handler_;
MockAppManagerSettings app_mngr_settings_;
MOCK(am::MockHmiInterfaces) mock_hmi_interfaces_;
am::MockMessageHelper& mock_message_helper_;
diff --git a/src/components/application_manager/test/include/application_manager/mock_application.h b/src/components/application_manager/test/include/application_manager/mock_application.h
index 47a39d742c..d7552060ff 100644
--- a/src/components/application_manager/test/include/application_manager/mock_application.h
+++ b/src/components/application_manager/test/include/application_manager/mock_application.h
@@ -38,6 +38,7 @@
#include "smart_objects/smart_object.h"
#include "utils/custom_string.h"
#include "application_manager/usage_statistics.h"
+#include "utils/semantic_version.h"
namespace test {
namespace components {
@@ -50,9 +51,6 @@ class MockApplication : public ::application_manager::Application {
MOCK_CONST_METHOD0(active_message, const smart_objects::SmartObject*());
MOCK_CONST_METHOD0(curHash, const std::string&());
MOCK_METHOD0(UpdateHash, void());
- DEPRECATED MOCK_CONST_METHOD0(flag_sending_hash_change_after_awake, bool());
- DEPRECATED MOCK_METHOD1(set_flag_sending_hash_change_after_awake,
- void(bool flag));
MOCK_CONST_METHOD0(IsHashChangedDuringSuspend, bool());
MOCK_METHOD1(SetHashChangedDuringSuspend, void(const bool flag));
MOCK_CONST_METHOD0(is_application_data_changed, bool());
@@ -113,6 +111,7 @@ class MockApplication : public ::application_manager::Application {
MOCK_CONST_METHOD0(secondary_device, connection_handler::DeviceHandle());
MOCK_CONST_METHOD0(CurrentHmiState, const application_manager::HmiStatePtr());
MOCK_CONST_METHOD0(RegularHmiState, const application_manager::HmiStatePtr());
+ MOCK_CONST_METHOD0(IsAllowedToChangeAudioSource, bool());
MOCK_CONST_METHOD0(PostponedHmiState,
const application_manager::HmiStatePtr());
MOCK_METHOD1(set_tts_properties_in_none, void(bool active));
@@ -191,6 +190,7 @@ class MockApplication : public ::application_manager::Application {
const smart_objects::SmartObject*());
MOCK_CONST_METHOD0(language, const mobile_apis::Language::eType&());
MOCK_CONST_METHOD0(ui_language, const mobile_apis::Language::eType&());
+ MOCK_CONST_METHOD0(msg_version, const utils::SemanticVersion&());
MOCK_METHOD1(set_app_types,
void(const smart_objects::SmartObject& app_types));
MOCK_METHOD1(set_vr_synonyms,
@@ -203,6 +203,7 @@ class MockApplication : public ::application_manager::Application {
void(const mobile_apis::Language::eType& language));
MOCK_METHOD1(set_ui_language,
void(const mobile_apis::Language::eType& ui_language));
+ MOCK_METHOD1(set_msg_version, void(const utils::SemanticVersion& version));
// DynamicApplicationData methods
MOCK_CONST_METHOD0(help_prompt, const smart_objects::SmartObject*());
MOCK_CONST_METHOD0(timeout_prompt, const smart_objects::SmartObject*());
diff --git a/src/components/application_manager/test/include/application_manager/mock_message_helper.h b/src/components/application_manager/test/include/application_manager/mock_message_helper.h
index 8641a3781e..8a06102e99 100644
--- a/src/components/application_manager/test/include/application_manager/mock_message_helper.h
+++ b/src/components/application_manager/test/include/application_manager/mock_message_helper.h
@@ -195,6 +195,9 @@ class MockMessageHelper {
mobile_apis::Result::eType(smart_objects::SmartObject& message,
ApplicationConstSharedPtr app,
ApplicationManager& app_mngr));
+ MOCK_METHOD1(CheckChoiceSetVRCommands,
+ MessageHelper::ChoiceSetVRCommandsStatus(
+ const smart_objects::SmartObject&));
MOCK_METHOD6(GetBCActivateAppRequestToHMI,
smart_objects::SmartObjectSPtr(
diff --git a/src/components/application_manager/test/include/application_manager/mock_resume_ctrl.h b/src/components/application_manager/test/include/application_manager/mock_resume_ctrl.h
index 3c4a3806d6..0fa7a898be 100644
--- a/src/components/application_manager/test/include/application_manager/mock_resume_ctrl.h
+++ b/src/components/application_manager/test/include/application_manager/mock_resume_ctrl.h
@@ -50,8 +50,15 @@ class MockResumeCtrl : public resumption::ResumeCtrl {
MOCK_METHOD0(OnSuspend, void());
MOCK_METHOD0(OnIgnitionOff, void());
MOCK_METHOD0(OnAwake, void());
+ MOCK_CONST_METHOD0(LowVoltageTime, time_t());
+ MOCK_CONST_METHOD0(WakeUpTime, time_t());
+ MOCK_METHOD0(SaveLowVoltageTime, void());
+ MOCK_METHOD0(SaveWakeUpTime, void());
+ MOCK_METHOD0(ResetLowVoltageTime, void());
+ MOCK_METHOD0(ResetWakeUpTime, void());
MOCK_CONST_METHOD0(is_suspended, bool());
MOCK_METHOD0(StopSavePersistentDataTimer, void());
+ MOCK_METHOD0(StartSavePersistentDataTimer, void());
MOCK_METHOD2(StartResumption,
bool(app_mngr::ApplicationSharedPtr application,
const std::string& hash));
diff --git a/src/components/application_manager/test/include/application_manager/mock_resumption_data.h b/src/components/application_manager/test/include/application_manager/mock_resumption_data.h
index cfec034653..38d1944dba 100644
--- a/src/components/application_manager/test/include/application_manager/mock_resumption_data.h
+++ b/src/components/application_manager/test/include/application_manager/mock_resumption_data.h
@@ -66,6 +66,10 @@ class MockResumptionData : public ::resumption::ResumptionData {
const std::string& device_id,
std::string& hash_id));
MOCK_METHOD0(OnAwake, void());
+ MOCK_METHOD0(IncrementGlobalIgnOnCounter, void());
+ MOCK_CONST_METHOD0(GetGlobalIgnOnCounter, uint32_t());
+ MOCK_METHOD0(ResetGlobalIgnOnCount, void());
+
MOCK_METHOD0(DecrementIgnOffCount, void());
MOCK_CONST_METHOD3(GetSavedApplication,
bool(const std::string& policy_app_id,
diff --git a/src/components/application_manager/test/mock_message_helper.cc b/src/components/application_manager/test/mock_message_helper.cc
index 9e2eb75a55..0850361a20 100644
--- a/src/components/application_manager/test/mock_message_helper.cc
+++ b/src/components/application_manager/test/mock_message_helper.cc
@@ -340,6 +340,13 @@ mobile_apis::Result::eType MessageHelper::VerifyImage(
message, app, app_mngr);
}
+MessageHelper::ChoiceSetVRCommandsStatus
+MessageHelper::CheckChoiceSetVRCommands(
+ const smart_objects::SmartObject& choice_set) {
+ return MockMessageHelper::message_helper_mock()->CheckChoiceSetVRCommands(
+ choice_set);
+}
+
mobile_apis::Result::eType MessageHelper::VerifyImageFiles(
smart_objects::SmartObject& message,
ApplicationConstSharedPtr app,
diff --git a/src/components/application_manager/test/resumption/resume_ctrl_test.cc b/src/components/application_manager/test/resumption/resume_ctrl_test.cc
index 54c76fcf94..1c2339096c 100644
--- a/src/components/application_manager/test/resumption/resume_ctrl_test.cc
+++ b/src/components/application_manager/test/resumption/resume_ctrl_test.cc
@@ -44,6 +44,7 @@
#include "application_manager/application_manager_impl.h"
#include "application_manager/application.h"
#include "utils/data_accessor.h"
+#include "config_profile/profile.h"
#include "application_manager/mock_message_helper.h"
#include "application_manager/mock_application_manager.h"
@@ -89,7 +90,11 @@ class ResumeCtrlTest : public ::testing::Test {
, kDefaultDeferredTestLevel_(eType::INVALID_ENUM)
, kNaviLowbandwidthLevel_("LIMITED")
, kProjectionLowbandwidthLevel_("NONE")
- , kMediaLowbandwidthLevel_("NONE") {}
+ , kMediaLowbandwidthLevel_("NONE") {
+ profile::Profile profile_;
+ profile_.set_config_file_name("smartDeviceLink.ini");
+ resumption_delay_before_ign_ = profile_.resumption_delay_before_ign();
+ }
virtual void SetUp() OVERRIDE {
Mock::VerifyAndClearExpectations(&mock_app_mngr_);
@@ -153,7 +158,7 @@ class ResumeCtrlTest : public ::testing::Test {
NiceMock<event_engine_test::MockEventDispatcher> mock_event_dispatcher_;
application_manager_test::MockApplicationManagerSettings
mock_application_manager_settings_;
- application_manager_test::MockApplicationManager mock_app_mngr_;
+ NiceMock<application_manager_test::MockApplicationManager> mock_app_mngr_;
std::shared_ptr<NiceMock<application_manager_test::MockAppExtension> >
mock_app_extension_;
MockStateController mock_state_controller_;
@@ -172,6 +177,7 @@ class ResumeCtrlTest : public ::testing::Test {
const std::string kHash_;
const uint32_t kAppResumingTimeout_;
const uint32_t kTestTimeStamp_;
+ uint32_t resumption_delay_before_ign_;
std::shared_ptr<sync_primitives::Lock> app_set_lock_ptr_;
sync_primitives::Lock app_set_lock_;
const mobile_apis::HMILevel::eType kDefaultDeferredTestLevel_;
@@ -613,8 +619,12 @@ TEST_F(ResumeCtrlTest, StartAppHmiStateResumption_AppInFull) {
mobile_apis::HMILevel::eType restored_test_type = eType::HMI_FULL;
uint32_t ign_off_count = 0;
smart_objects::SmartObject saved_app;
+ const uint32_t time_offset = 5;
+ const uint32_t time_stamp =
+ time(nullptr) - resumption_delay_before_ign_ + time_offset;
saved_app[application_manager::strings::ign_off_count] = ign_off_count;
saved_app[application_manager::strings::hmi_level] = restored_test_type;
+ saved_app[application_manager::strings::time_stamp] = time_stamp;
application_manager::CommandsMap command;
DataAccessor<application_manager::CommandsMap> data_accessor(
@@ -661,8 +671,12 @@ TEST_F(ResumeCtrlTest, StartAppHmiStateResumption_AppHasDeferredResumption) {
mobile_apis::HMILevel::eType deferred_level = eType::HMI_FULL;
uint32_t ign_off_count = 0;
smart_objects::SmartObject saved_app;
+ const uint32_t time_offset = 5;
+ const uint32_t time_stamp =
+ time(nullptr) - resumption_delay_before_ign_ + time_offset;
saved_app[application_manager::strings::ign_off_count] = ign_off_count;
saved_app[application_manager::strings::hmi_level] = restored_test_type;
+ saved_app[application_manager::strings::time_stamp] = time_stamp;
// resume into deferred level instead of restored level
EXPECT_CALL(mock_state_controller_, SetRegularState(_, deferred_level))
@@ -693,8 +707,12 @@ TEST_F(ResumeCtrlTest,
mobile_apis::HMILevel::eType restored_test_type = eType::HMI_FULL;
uint32_t ign_off_count = 0;
smart_objects::SmartObject saved_app;
+ const uint32_t time_offset = 5;
+ const uint32_t time_stamp =
+ time(nullptr) - resumption_delay_before_ign_ + time_offset;
saved_app[application_manager::strings::ign_off_count] = ign_off_count;
saved_app[application_manager::strings::hmi_level] = restored_test_type;
+ saved_app[application_manager::strings::time_stamp] = time_stamp;
EXPECT_CALL(mock_state_controller_, SetRegularState(_, eType::HMI_LIMITED))
.Times(AtLeast(1));
@@ -731,8 +749,12 @@ TEST_F(
mobile_apis::HMILevel::eType restored_test_type = eType::HMI_LIMITED;
uint32_t ign_off_count = 0;
smart_objects::SmartObject saved_app;
+ const uint32_t time_offset = 5;
+ const uint32_t time_stamp =
+ time(nullptr) - resumption_delay_before_ign_ + time_offset;
saved_app[application_manager::strings::ign_off_count] = ign_off_count;
saved_app[application_manager::strings::hmi_level] = restored_test_type;
+ saved_app[application_manager::strings::time_stamp] = time_stamp;
// in this test, it is expected that the app will resume into LIMITED, which
// is the higher level among NONE and LIMITED
@@ -869,8 +891,12 @@ TEST_F(ResumeCtrlTest, ApplicationResumptiOnTimer_AppInFull) {
mobile_apis::HMILevel::eType restored_test_type = eType::HMI_FULL;
const uint32_t ign_off_count = 0u;
smart_objects::SmartObject saved_app;
+ const uint32_t time_offset = 5;
+ const uint32_t time_stamp =
+ time(nullptr) - resumption_delay_before_ign_ + time_offset;
saved_app[application_manager::strings::ign_off_count] = ign_off_count;
saved_app[application_manager::strings::hmi_level] = restored_test_type;
+ saved_app[application_manager::strings::time_stamp] = time_stamp;
MockStateController state_controller;
EXPECT_CALL(mock_app_mngr_, state_controller())
@@ -1203,6 +1229,194 @@ TEST_F(ResumeCtrlTest, GetSavedAppHmiLevel_AskedAppFound_INVALID_ENUM) {
res_ctrl_->GetSavedAppHmiLevel(kTestPolicyAppId_, kMacAddress_));
}
+TEST_F(
+ ResumeCtrlTest,
+ ResumptionLowVoltage_AppInFullUnregisteredWithinTimeFrame_HMILevelRestored) {
+ const mobile_apis::HMILevel::eType restored_test_type = eType::HMI_FULL;
+ const uint32_t time_offset = 5;
+ const uint32_t time_stamp =
+ time(nullptr) - resumption_delay_before_ign_ + time_offset;
+ smart_objects::SmartObject saved_app;
+ saved_app[application_manager::strings::hmi_level] = restored_test_type;
+ saved_app[application_manager::strings::time_stamp] = time_stamp;
+
+ application_manager::CommandsMap command;
+ DataAccessor<application_manager::CommandsMap> data_accessor(
+ command, app_set_lock_ptr_);
+
+ EXPECT_CALL(mock_state_controller_, SetRegularState(_, restored_test_type))
+ .Times(AtLeast(1));
+ GetInfoFromApp();
+ EXPECT_CALL(mock_app_mngr_, GetDefaultHmiLevel(const_app_))
+ .WillRepeatedly(Return(kDefaultTestLevel_));
+ EXPECT_CALL(*mock_app_, commands_map()).WillRepeatedly(Return(data_accessor));
+ ON_CALL(*mock_storage_,
+ GetSavedApplication(kTestPolicyAppId_, kMacAddress_, _))
+ .WillByDefault(DoAll(SetArgReferee<2>(saved_app), Return(true)));
+
+ EXPECT_CALL(*mock_storage_,
+ RemoveApplicationFromSaved(kTestPolicyAppId_, kMacAddress_))
+ .WillOnce(Return(true));
+
+ ON_CALL(mock_app_mngr_, GetUserConsentForDevice("12345"))
+ .WillByDefault(Return(policy::kDeviceAllowed));
+
+ NiceMock<MockApplicationManagerSettings> app_mngr_settings_;
+ EXPECT_CALL(mock_app_mngr_, get_settings())
+ .WillOnce(ReturnRef(app_mngr_settings_));
+
+ EXPECT_CALL(app_mngr_settings_, resumption_delay_before_ign())
+ .WillOnce(Return(resumption_delay_before_ign_));
+
+ res_ctrl_->SaveLowVoltageTime();
+ res_ctrl_->StartAppHmiStateResumption(mock_app_);
+}
+
+TEST_F(
+ ResumeCtrlTest,
+ ResumptionLowVoltage_AppInFullUnregisteredBeyondTimeFrame_HMILevelNotRestored) {
+ const mobile_apis::HMILevel::eType restored_test_type = eType::HMI_FULL;
+ const uint32_t time_offset = 5;
+ const uint32_t time_stamp =
+ time(nullptr) - resumption_delay_before_ign_ - time_offset;
+ smart_objects::SmartObject saved_app;
+ saved_app[application_manager::strings::hmi_level] = restored_test_type;
+ saved_app[application_manager::strings::time_stamp] = time_stamp;
+
+ application_manager::CommandsMap command;
+ DataAccessor<application_manager::CommandsMap> data_accessor(
+ command, app_set_lock_ptr_);
+
+ EXPECT_CALL(mock_app_mngr_, state_controller()).Times(0);
+ GetInfoFromApp();
+ EXPECT_CALL(mock_app_mngr_, GetDefaultHmiLevel(const_app_))
+ .WillRepeatedly(Return(kDefaultTestLevel_));
+ EXPECT_CALL(*mock_app_, commands_map()).WillRepeatedly(Return(data_accessor));
+ ON_CALL(*mock_storage_,
+ GetSavedApplication(kTestPolicyAppId_, kMacAddress_, _))
+ .WillByDefault(DoAll(SetArgReferee<2>(saved_app), Return(true)));
+
+ ON_CALL(mock_app_mngr_, GetUserConsentForDevice("12345"))
+ .WillByDefault(Return(policy::kDeviceAllowed));
+
+ NiceMock<MockApplicationManagerSettings> app_mngr_settings_;
+ EXPECT_CALL(mock_app_mngr_, get_settings())
+ .WillOnce(ReturnRef(app_mngr_settings_));
+
+ EXPECT_CALL(app_mngr_settings_, resumption_delay_before_ign())
+ .WillOnce(Return(resumption_delay_before_ign_));
+
+ res_ctrl_->SaveLowVoltageTime();
+ res_ctrl_->StartAppHmiStateResumption(mock_app_);
+}
+
+TEST_F(ResumeCtrlTest, ResumptionLowVoltage_AppInBackground_NotRestored) {
+ const mobile_apis::HMILevel::eType restored_test_type = eType::HMI_BACKGROUND;
+ const uint32_t time_offset = 5;
+ const uint32_t time_stamp =
+ time(nullptr) - resumption_delay_before_ign_ - time_offset;
+ smart_objects::SmartObject saved_app;
+ saved_app[application_manager::strings::hmi_level] = restored_test_type;
+ saved_app[application_manager::strings::time_stamp] = time_stamp;
+
+ application_manager::CommandsMap command;
+ DataAccessor<application_manager::CommandsMap> data_accessor(
+ command, app_set_lock_ptr_);
+
+ EXPECT_CALL(mock_app_mngr_, state_controller()).Times(0);
+ GetInfoFromApp();
+ EXPECT_CALL(mock_app_mngr_, GetDefaultHmiLevel(const_app_))
+ .WillRepeatedly(Return(kDefaultTestLevel_));
+ EXPECT_CALL(*mock_app_, commands_map()).WillRepeatedly(Return(data_accessor));
+ ON_CALL(*mock_storage_,
+ GetSavedApplication(kTestPolicyAppId_, kMacAddress_, _))
+ .WillByDefault(DoAll(SetArgReferee<2>(saved_app), Return(true)));
+
+ res_ctrl_->SaveLowVoltageTime();
+ res_ctrl_->StartAppHmiStateResumption(mock_app_);
+}
+
+TEST_F(
+ ResumeCtrlTest,
+ ResumptionLowVoltage_AppInLimitedlUnregisteredWithinTimeFrame_HMILevelRestored) {
+ const mobile_apis::HMILevel::eType restored_test_type = eType::HMI_LIMITED;
+ const uint32_t time_offset = 5;
+ const uint32_t time_stamp =
+ time(nullptr) - resumption_delay_before_ign_ + time_offset;
+ smart_objects::SmartObject saved_app;
+ saved_app[application_manager::strings::hmi_level] = restored_test_type;
+ saved_app[application_manager::strings::time_stamp] = time_stamp;
+
+ application_manager::CommandsMap command;
+ DataAccessor<application_manager::CommandsMap> data_accessor(
+ command, app_set_lock_ptr_);
+
+ EXPECT_CALL(mock_state_controller_, SetRegularState(_, restored_test_type))
+ .Times(AtLeast(1));
+ GetInfoFromApp();
+ EXPECT_CALL(mock_app_mngr_, GetDefaultHmiLevel(const_app_))
+ .WillRepeatedly(Return(kDefaultTestLevel_));
+ EXPECT_CALL(*mock_app_, commands_map()).WillRepeatedly(Return(data_accessor));
+ ON_CALL(*mock_storage_,
+ GetSavedApplication(kTestPolicyAppId_, kMacAddress_, _))
+ .WillByDefault(DoAll(SetArgReferee<2>(saved_app), Return(true)));
+
+ EXPECT_CALL(*mock_storage_,
+ RemoveApplicationFromSaved(kTestPolicyAppId_, kMacAddress_))
+ .WillOnce(Return(true));
+
+ ON_CALL(mock_app_mngr_, GetUserConsentForDevice("12345"))
+ .WillByDefault(Return(policy::kDeviceAllowed));
+
+ NiceMock<MockApplicationManagerSettings> app_mngr_settings_;
+ EXPECT_CALL(mock_app_mngr_, get_settings())
+ .WillOnce(ReturnRef(app_mngr_settings_));
+
+ EXPECT_CALL(app_mngr_settings_, resumption_delay_before_ign())
+ .WillOnce(Return(resumption_delay_before_ign_ + time_offset));
+
+ res_ctrl_->SaveLowVoltageTime();
+ res_ctrl_->StartAppHmiStateResumption(mock_app_);
+}
+
+TEST_F(
+ ResumeCtrlTest,
+ ResumptionLowVoltage_AppInLimitedlUnregisteredBeyondTimeFrame_HMILevelNotRestored) {
+ const mobile_apis::HMILevel::eType restored_test_type = eType::HMI_LIMITED;
+ const uint32_t time_offset = 5;
+ const uint32_t time_stamp =
+ time(nullptr) - resumption_delay_before_ign_ - time_offset;
+ smart_objects::SmartObject saved_app;
+ saved_app[application_manager::strings::hmi_level] = restored_test_type;
+ saved_app[application_manager::strings::time_stamp] = time_stamp;
+
+ application_manager::CommandsMap command;
+ DataAccessor<application_manager::CommandsMap> data_accessor(
+ command, app_set_lock_ptr_);
+
+ EXPECT_CALL(mock_app_mngr_, state_controller()).Times(0);
+ GetInfoFromApp();
+ EXPECT_CALL(mock_app_mngr_, GetDefaultHmiLevel(const_app_))
+ .WillRepeatedly(Return(kDefaultTestLevel_));
+ EXPECT_CALL(*mock_app_, commands_map()).WillRepeatedly(Return(data_accessor));
+ ON_CALL(*mock_storage_,
+ GetSavedApplication(kTestPolicyAppId_, kMacAddress_, _))
+ .WillByDefault(DoAll(SetArgReferee<2>(saved_app), Return(true)));
+
+ ON_CALL(mock_app_mngr_, GetUserConsentForDevice("12345"))
+ .WillByDefault(Return(policy::kDeviceAllowed));
+
+ NiceMock<MockApplicationManagerSettings> app_mngr_settings_;
+ EXPECT_CALL(mock_app_mngr_, get_settings())
+ .WillOnce(ReturnRef(app_mngr_settings_));
+
+ EXPECT_CALL(app_mngr_settings_, resumption_delay_before_ign())
+ .WillOnce(Return(resumption_delay_before_ign_));
+
+ res_ctrl_->SaveLowVoltageTime();
+ res_ctrl_->StartAppHmiStateResumption(mock_app_);
+}
+
} // namespace resumption_test
} // namespace components
} // namespace test
diff --git a/src/components/application_manager/test/resumption/resumption_data_db_test.cc b/src/components/application_manager/test/resumption/resumption_data_db_test.cc
index 953f43e056..8423520b9f 100644
--- a/src/components/application_manager/test/resumption/resumption_data_db_test.cc
+++ b/src/components/application_manager/test/resumption/resumption_data_db_test.cc
@@ -123,7 +123,7 @@ class ResumptionDataDBTest : public ResumptionDataTest {
void SetZeroIgnOffTime() {
utils::dbms::SQLQuery query(test_db());
- EXPECT_TRUE(query.Prepare(KUpdateLastIgnOffTime));
+ EXPECT_TRUE(query.Prepare(kUpdateLastIgnOffTime));
query.Bind(0, 0);
EXPECT_TRUE(query.Exec());
}
diff --git a/src/components/application_manager/test/state_controller/state_controller_test.cc b/src/components/application_manager/test/state_controller/state_controller_test.cc
index fd2503da33..3731848d89 100644
--- a/src/components/application_manager/test/state_controller/state_controller_test.cc
+++ b/src/components/application_manager/test/state_controller/state_controller_test.cc
@@ -64,6 +64,7 @@ using ::testing::_;
using ::testing::Return;
using ::testing::ReturnRef;
using ::testing::ReturnPointee;
+using ::testing::SaveArg;
using ::testing::Mock;
using ::testing::NiceMock;
using ::testing::InSequence;
@@ -2829,6 +2830,78 @@ TEST_F(StateControllerImplTest,
state_ctrl_->SetRegularState(navi_app_, hmi_state, true);
}
+TEST_F(StateControllerImplTest, OnEventChangedAudioSourceAppRemainInFull) {
+ const uint32_t app_id = simple_app_->app_id();
+ InsertApplication(simple_app_);
+ smart_objects::SmartObject msg;
+ msg[am::strings::msg_params][am::strings::app_id] = app_id;
+ msg[am::strings::msg_params][am::hmi_notification::is_active] = true;
+ msg[am::strings::msg_params][am::hmi_notification::event_name] =
+ hmi_apis::Common_EventTypes::AUDIO_SOURCE;
+
+ const hmi_apis::FunctionID::eType event_id =
+ hmi_apis::FunctionID::BasicCommunication_OnEventChanged;
+ am::event_engine::Event event(event_id);
+ event.set_smart_object(msg);
+
+ const HmiStatePtr state =
+ createHmiState(mobile_apis::HMILevel::HMI_FULL,
+ mobile_apis::AudioStreamingState::AUDIBLE,
+ mobile_apis::VideoStreamingState::NOT_STREAMABLE,
+ mobile_apis::SystemContext::SYSCTXT_MAIN);
+ EXPECT_CALL(*simple_app_ptr_, RegularHmiState()).WillOnce(Return(state));
+ EXPECT_CALL(*simple_app_ptr_, IsAudioApplication())
+ .WillRepeatedly(Return(true));
+ EXPECT_CALL(*simple_app_ptr_, CurrentHmiState())
+ .WillOnce(Return(FullAudibleState()));
+
+ HmiStatePtr new_state;
+ EXPECT_CALL(*simple_app_ptr_, AddHMIState(_))
+ .WillOnce(SaveArg<0>(&new_state));
+
+ state_ctrl_->on_event(event);
+
+ EXPECT_EQ(new_state->hmi_level(), mobile_apis::HMILevel::HMI_FULL);
+ EXPECT_EQ(new_state->audio_streaming_state(),
+ mobile_apis::AudioStreamingState::NOT_AUDIBLE);
+}
+
+TEST_F(StateControllerImplTest, OnEventChangedAudioSourceAppToBackground) {
+ const uint32_t app_id = simple_app_->app_id();
+ InsertApplication(simple_app_);
+ smart_objects::SmartObject msg;
+ msg[am::strings::msg_params][am::strings::app_id] = app_id;
+ msg[am::strings::msg_params][am::hmi_notification::is_active] = true;
+ msg[am::strings::msg_params][am::hmi_notification::event_name] =
+ hmi_apis::Common_EventTypes::AUDIO_SOURCE;
+
+ const hmi_apis::FunctionID::eType event_id =
+ hmi_apis::FunctionID::BasicCommunication_OnEventChanged;
+ am::event_engine::Event event(event_id);
+ event.set_smart_object(msg);
+
+ const HmiStatePtr state =
+ createHmiState(mobile_apis::HMILevel::HMI_LIMITED,
+ mobile_apis::AudioStreamingState::AUDIBLE,
+ mobile_apis::VideoStreamingState::NOT_STREAMABLE,
+ mobile_apis::SystemContext::SYSCTXT_MAIN);
+ EXPECT_CALL(*simple_app_ptr_, RegularHmiState()).WillOnce(Return(state));
+ EXPECT_CALL(*simple_app_ptr_, IsAudioApplication())
+ .WillRepeatedly(Return(true));
+ EXPECT_CALL(*simple_app_ptr_, CurrentHmiState())
+ .WillOnce(Return(LimitedState()));
+
+ HmiStatePtr new_state;
+ EXPECT_CALL(*simple_app_ptr_, AddHMIState(_))
+ .WillOnce(SaveArg<0>(&new_state));
+
+ state_ctrl_->on_event(event);
+
+ EXPECT_EQ(new_state->hmi_level(), mobile_apis::HMILevel::HMI_BACKGROUND);
+ EXPECT_EQ(new_state->audio_streaming_state(),
+ mobile_apis::AudioStreamingState::NOT_AUDIBLE);
+}
+
TEST_F(StateControllerImplTest, OnEventOnAppDeactivatedIncorrectHmiLevel) {
smart_objects::SmartObject msg;
const uint32_t app_id = simple_app_->app_id();