diff options
74 files changed, 2235 insertions, 782 deletions
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/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 6e7cf05d90..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 @@ -131,4 +127,4 @@ class SetInteriorVehicleDataRequest : public RCCommandRequest { } // 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 a38887572c..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 { @@ -274,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 ab9fe0cc89..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 @@ -39,18 +39,13 @@ 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_); 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 3f757fab2e..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 @@ -39,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() {} 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 f9d65a2635..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,34 +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::kAudio, strings::kaudioControlCapabilities}, - {enums_value::kLight, strings::klightControlCapabilities}, - {enums_value::kSeat, strings::kseatControlCapabilities}, - {enums_value::kHmiSettings, strings::khmiSettingsControlCapabilities}}; + 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; } @@ -82,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(); @@ -96,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( @@ -147,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); @@ -155,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(), @@ -181,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( @@ -261,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 f305f88872..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" @@ -62,17 +63,6 @@ std::vector<std::string> GetModuleReadOnlyParams( 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::kAudio, message_params::kAudioControlData}, - {enums_value::kLight, message_params::kLightControlData}, - {enums_value::kHmiSettings, message_params::kHmiSettingsControlData}, - {enums_value::kSeat, message_params::kSeatControlData}}; - return mapping; -} - const std::map<std::string, std::string> GetModuleDataToCapabilitiesMapping() { std::map<std::string, std::string> mapping; // climate @@ -142,17 +132,8 @@ 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() {} @@ -299,30 +280,30 @@ 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::kAudioControlData, strings::kaudioControlCapabilities}, - {message_params::kLightControlData, strings::klightControlCapabilities}, - {message_params::kSeatControlData, strings::kseatControlCapabilities}, - {message_params::kHmiSettingsControlData, - strings::khmiSettingsControlCapabilities}}; + + 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]; - if (message_params::kHmiSettingsControlData == param.first || - message_params::kLightControlData == 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[param.first]); + CheckControlDataByCapabilities(caps, module_data[module_data_key]); } else { - is_module_data_valid = - CheckControlDataByCapabilities(caps[0], module_data[param.first]); + is_module_data_valid = CheckControlDataByCapabilities( + caps[0], module_data[module_data_key]); } } } @@ -332,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; } } @@ -447,11 +428,12 @@ 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(); 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 59d1919bb5..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,18 +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); - result.push_back(enums_value::kAudio); - result.push_back(enums_value::kLight); - result.push_back(enums_value::kHmiSettings); - return result; -} - std::vector<std::string> ResourceAllocationManagerImpl::GetAcquiredResources( const uint32_t application_id) const { LOG4CXX_AUTO_TRACE(logger_); @@ -513,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); } } @@ -532,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 7eb298f024..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 @@ -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/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/config_profile/include/config_profile/profile.h b/src/components/config_profile/include/config_profile/profile.h index c6fc2017b9..d7b1cbad4a 100644 --- a/src/components/config_profile/include/config_profile/profile.h +++ b/src/components/config_profile/include/config_profile/profile.h @@ -762,6 +762,8 @@ class Profile : public protocol_handler::ProtocolHandlerSettings, const std::pair<uint32_t, int32_t>& get_vehicle_data_frequency() const OVERRIDE; + const std::pair<uint32_t, int32_t>& get_interior_vehicle_data_frequency() + const OVERRIDE; const std::pair<uint32_t, int32_t>& start_stream_retry_amount() const OVERRIDE; @@ -987,6 +989,12 @@ class Profile : public protocol_handler::ProtocolHandlerSettings, */ std::pair<uint32_t, int32_t> get_vehicle_data_frequency_; + /* + * first value is count of request + * second is time scale + */ + std::pair<uint32_t, int32_t> get_interior_vehicle_data_frequency_; + /** * first value is count of retries for start stream * second for timer diff --git a/src/components/config_profile/src/profile.cc b/src/components/config_profile/src/profile.cc index e24e0c4481..931998732e 100644 --- a/src/components/config_profile/src/profile.cc +++ b/src/components/config_profile/src/profile.cc @@ -189,6 +189,8 @@ const char* kAckMQKey = "AckMQ"; const char* kApplicationListUpdateTimeoutKey = "ApplicationListUpdateTimeout"; const char* kReadDIDFrequencykey = "ReadDIDRequest"; const char* kGetVehicleDataFrequencyKey = "GetVehicleDataRequest"; +const char* kGetInteriorVehicleDataFrequencyKey = + "GetInteriorVehicleDataRequest"; const char* kLegacyProtocolMaskKey = "LegacyProtocol"; const char* kHubProtocolMaskKey = "HubProtocol"; const char* kPoolProtocolMaskKey = "PoolProtocol"; @@ -342,6 +344,7 @@ const uint32_t kDefaultTransportManagerDisconnectTimeout = 0; const uint32_t kDefaultApplicationListUpdateTimeout = 1; const std::pair<uint32_t, uint32_t> kReadDIDFrequency = {5, 1}; const std::pair<uint32_t, uint32_t> kGetVehicleDataFrequency = {5, 1}; +const std::pair<uint32_t, uint32_t> kGetInteriorVehicleDataFrequency = {20, 1}; const std::pair<uint32_t, uint32_t> kStartStreamRetryAmount = {3, 1}; const uint32_t kDefaultMaxThreadPoolSize = 2; const int kDefaultIAP2HubConnectAttempts = 0; @@ -807,6 +810,11 @@ const std::pair<uint32_t, int32_t>& Profile::get_vehicle_data_frequency() return get_vehicle_data_frequency_; } +const std::pair<uint32_t, int32_t>& +Profile::get_interior_vehicle_data_frequency() const { + return get_interior_vehicle_data_frequency_; +} + const std::pair<uint32_t, int32_t>& Profile::start_stream_retry_amount() const { return start_stream_retry_amount_; } @@ -1880,6 +1888,11 @@ void Profile::UpdateValues() { kMainSection, kGetVehicleDataFrequencyKey); + ReadUintIntPairValue(&get_interior_vehicle_data_frequency_, + kGetInteriorVehicleDataFrequency, + kMainSection, + kGetInteriorVehicleDataFrequencyKey); + ReadUIntValue(&max_thread_pool_size_, kDefaultMaxThreadPoolSize, kApplicationManagerSection, diff --git a/src/components/include/application_manager/application_manager_settings.h b/src/components/include/application_manager/application_manager_settings.h index 8f9d7496c8..3c9e573c57 100644 --- a/src/components/include/application_manager/application_manager_settings.h +++ b/src/components/include/application_manager/application_manager_settings.h @@ -50,6 +50,8 @@ class ApplicationManagerSettings : public RequestControlerSettings, virtual const std::pair<uint32_t, int32_t>& read_did_frequency() const = 0; virtual const std::pair<uint32_t, int32_t>& get_vehicle_data_frequency() const = 0; + virtual const std::pair<uint32_t, int32_t>& + get_interior_vehicle_data_frequency() const = 0; virtual uint32_t hash_string_size() const = 0; virtual const uint32_t& app_dir_quota() const = 0; virtual uint32_t stop_streaming_timeout() const = 0; diff --git a/src/components/include/test/application_manager/mock_application_manager_settings.h b/src/components/include/test/application_manager/mock_application_manager_settings.h index 735539156a..e0c4a6b9c2 100644 --- a/src/components/include/test/application_manager/mock_application_manager_settings.h +++ b/src/components/include/test/application_manager/mock_application_manager_settings.h @@ -55,6 +55,8 @@ class MockApplicationManagerSettings // typedef for the return type. MOCK_CONST_METHOD0(get_vehicle_data_frequency, const std::pair<uint32_t, int32_t>&()); + MOCK_CONST_METHOD0(get_interior_vehicle_data_frequency, + const std::pair<uint32_t, int32_t>&()); MOCK_CONST_METHOD0(hash_string_size, uint32_t()); MOCK_CONST_METHOD0(app_storage_folder, const std::string&()); MOCK_CONST_METHOD0(app_info_storage, const std::string&()); diff --git a/src/components/interfaces/HMI_API.xml b/src/components/interfaces/HMI_API.xml index 4dc5e7f331..a9854ef730 100644 --- a/src/components/interfaces/HMI_API.xml +++ b/src/components/interfaces/HMI_API.xml @@ -5696,9 +5696,6 @@ <param name="subscribe" type="Boolean" mandatory="false"> <description>If subscribe is true, the head unit will send onInteriorVehicleData notifications for the module type</description> </param> - <param name="appID" type="Integer" mandatory="true"> - <description>Internal SDL-assigned ID of the related application</description> - </param> </function> <function name="GetInteriorVehicleData" messagetype="response"> |