diff options
author | JackLivio <jack@livio.io> | 2018-08-29 14:08:41 -0400 |
---|---|---|
committer | JackLivio <jack@livio.io> | 2018-08-29 14:08:41 -0400 |
commit | cee3ba5cec980dcee4cc37af71bd09dc306d3867 (patch) | |
tree | 3f22a7132d77dde142019231bf10ab2e3be1f5dd /src/components/application_manager/rpc_plugins | |
parent | 90db9ca480eabeaf85ec77626b1bf10fa491270d (diff) | |
parent | 09e4e684708ad5ab2544c72745516e9fe481ba0b (diff) | |
download | sdl_core-cee3ba5cec980dcee4cc37af71bd09dc306d3867.tar.gz |
Merge remote-tracking branch 'origin/develop' into feature/boost_filesystem_implementation
# Conflicts:
# src/3rd_party/CMakeLists.txt
# src/components/utils/CMakeLists.txt
Diffstat (limited to 'src/components/application_manager/rpc_plugins')
117 files changed, 3465 insertions, 1453 deletions
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_button_press_request.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_button_press_request.h index fc3721e763..3bc34be8d1 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_button_press_request.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_button_press_request.h @@ -30,19 +30,20 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_HMI_RC_BUTTON_PRESS_REQUEST_H -#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_HMI_RC_BUTTON_PRESS_REQUEST_H +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_HMI_RC_BUTTON_PRESS_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_HMI_RC_BUTTON_PRESS_REQUEST_H_ #include "application_manager/commands/request_to_hmi.h" +#include "rc_rpc_plugin/commands/rc_command_request.h" #include "rc_rpc_plugin/resource_allocation_manager.h" +#include "rc_rpc_plugin/interior_data_cache.h" #include "utils/macro.h" namespace rc_rpc_plugin { namespace app_mngr = application_manager; namespace commands { -class RCButtonPressRequest - : public application_manager::commands::RequestToHMI { +class RCButtonPressRequest : public app_mngr::commands::RequestToHMI { public: /** * @brief RCButtonPressRequest class constructor @@ -54,11 +55,7 @@ class RCButtonPressRequest * @param resource_allocation_manager ResourceAllocationManager **/ RCButtonPressRequest(const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle, - ResourceAllocationManager& resource_allocation_manager); + const RCCommandParams& params); /** * @brief Execute command */ @@ -68,4 +65,4 @@ class RCButtonPressRequest } // namespace commands } // namespace rc_rpc_plugin -#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_HMI_RC_BUTTON_PRESS_REQUEST_H +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_HMI_RC_BUTTON_PRESS_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_button_press_response.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_button_press_response.h index c16f4de0cc..939d5fa468 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_button_press_response.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_button_press_response.h @@ -30,11 +30,13 @@ POSSIBILITY OF SUCH DAMAGE. */ -#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_HMI_RC_BUTTON_PRESS_RESPONSE_H -#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_HMI_RC_BUTTON_PRESS_RESPONSE_H +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_HMI_RC_BUTTON_PRESS_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_HMI_RC_BUTTON_PRESS_RESPONSE_H_ #include "application_manager/commands/response_from_hmi.h" +#include "rc_rpc_plugin/commands/rc_command_request.h" #include "rc_rpc_plugin/resource_allocation_manager.h" +#include "rc_rpc_plugin/interior_data_cache.h" #include "utils/macro.h" namespace rc_rpc_plugin { @@ -54,11 +56,7 @@ class RCButtonPressResponse * @param resource_allocation_manager ResourceAllocationManager **/ RCButtonPressResponse(const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle, - ResourceAllocationManager& resource_allocation_manager); + const RCCommandParams& params); void Run() OVERRIDE; @@ -67,4 +65,4 @@ class RCButtonPressResponse } // namespace commands } // namespace rc_rpc_plugin -#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_HMI_RC_BUTTON_PRESS_RESPONSE_H +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_HMI_RC_BUTTON_PRESS_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_consent_request.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_consent_request.h index fc2e0d6536..97df5e8390 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_consent_request.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_consent_request.h @@ -34,7 +34,9 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_HMI_RC_GET_INTERIOR_VEHICLE_DATA_CONSENT_REQUEST_H_ #include "application_manager/commands/request_to_hmi.h" +#include "rc_rpc_plugin/commands/rc_command_request.h" #include "rc_rpc_plugin/resource_allocation_manager.h" +#include "rc_rpc_plugin/interior_data_cache.h" #include "utils/macro.h" namespace rc_rpc_plugin { @@ -45,12 +47,8 @@ class RCGetInteriorVehicleDataConsentRequest : public application_manager::commands::RequestToHMI { public: RCGetInteriorVehicleDataConsentRequest( - const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle, - ResourceAllocationManager& resource_allocation_manager); + const application_manager::commands::MessageSharedPtr& message, + const RCCommandParams& params); void Run() OVERRIDE; ~RCGetInteriorVehicleDataConsentRequest(); diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_consent_response.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_consent_response.h index a037d33d5a..46232987a5 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_consent_response.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_consent_response.h @@ -34,7 +34,9 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_HMI_RC_GET_INTERIOR_VEHICLE_DATA_CONSENT_RESPONSE_H_ #include "application_manager/commands/response_from_hmi.h" +#include "rc_rpc_plugin/commands/rc_command_request.h" #include "rc_rpc_plugin/resource_allocation_manager.h" +#include "rc_rpc_plugin/interior_data_cache.h" #include "utils/macro.h" namespace rc_rpc_plugin { @@ -54,12 +56,8 @@ class RCGetInteriorVehicleDataConsentResponse * @param resource_allocation_manager ResourceAllocationManager **/ RCGetInteriorVehicleDataConsentResponse( - const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle, - ResourceAllocationManager& resource_allocation_manager); + const application_manager::commands::MessageSharedPtr& message, + const RCCommandParams& params); void Run() OVERRIDE; diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_request.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_request.h index 9f7b1211b7..a88a39aa7a 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_request.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_request.h @@ -34,7 +34,9 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_HMI_RC_GET_INTERIOR_VEHICLE_DATA_REQUEST_H_ #include "application_manager/commands/request_to_hmi.h" +#include "rc_rpc_plugin/commands/rc_command_request.h" #include "rc_rpc_plugin/resource_allocation_manager.h" +#include "rc_rpc_plugin/interior_data_cache.h" #include "utils/macro.h" namespace rc_rpc_plugin { @@ -45,12 +47,8 @@ class RCGetInteriorVehicleDataRequest : public application_manager::commands::RequestToHMI { public: RCGetInteriorVehicleDataRequest( - const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle, - ResourceAllocationManager& resource_allocation_manager); + const application_manager::commands::MessageSharedPtr& message, + const RCCommandParams& params); void Run() OVERRIDE; ~RCGetInteriorVehicleDataRequest(); diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_response.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_response.h index 28f9b4b9c7..c9e5d39d1d 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_response.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_response.h @@ -34,7 +34,9 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_HMI_RC_GET_INTERIOR_VEHICLE_DATA_RESPONSE_H_ #include "application_manager/commands/response_from_hmi.h" +#include "rc_rpc_plugin/commands/rc_command_request.h" #include "rc_rpc_plugin/resource_allocation_manager.h" +#include "rc_rpc_plugin/interior_data_cache.h" #include "utils/macro.h" namespace rc_rpc_plugin { @@ -45,12 +47,8 @@ class RCGetInteriorVehicleDataResponse : public application_manager::commands::ResponseFromHMI { public: RCGetInteriorVehicleDataResponse( - const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle, - ResourceAllocationManager& resource_allocation_manager); + const application_manager::commands::MessageSharedPtr& message, + const RCCommandParams& params); void Run() OVERRIDE; diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_on_interior_vehicle_data_notification.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_on_interior_vehicle_data_notification.h index 0afa613c7c..aeb0a06d22 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_on_interior_vehicle_data_notification.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_on_interior_vehicle_data_notification.h @@ -30,11 +30,13 @@ POSSIBILITY OF SUCH DAMAGE. */ -#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_HMI_RC_ON_INTERIOR_VEHICLE_DATA_NOTIFICATION_H -#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_HMI_RC_ON_INTERIOR_VEHICLE_DATA_NOTIFICATION_H +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_HMI_RC_ON_INTERIOR_VEHICLE_DATA_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_HMI_RC_ON_INTERIOR_VEHICLE_DATA_NOTIFICATION_H_ #include "application_manager/commands/notification_from_hmi.h" +#include "rc_rpc_plugin/commands/rc_command_request.h" #include "rc_rpc_plugin/resource_allocation_manager.h" +#include "rc_rpc_plugin/interior_data_cache.h" #include "utils/macro.h" namespace rc_rpc_plugin { @@ -54,12 +56,8 @@ class RCOnInteriorVehicleDataNotification * @param resource_allocation_manager ResourceAllocationManager **/ RCOnInteriorVehicleDataNotification( - const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle, - ResourceAllocationManager& resource_allocation_manager); + const application_manager::commands::MessageSharedPtr& message, + const RCCommandParams& params); ~RCOnInteriorVehicleDataNotification(); @@ -71,4 +69,4 @@ class RCOnInteriorVehicleDataNotification } // namespace commands } // namespace rc_rpc_plugin -#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_HMI_RC_ON_INTERIOR_VEHICLE_DATA_NOTIFICATION_H +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_HMI_RC_ON_INTERIOR_VEHICLE_DATA_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_on_remote_control_settings_notification.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_on_remote_control_settings_notification.h index b9ab821176..7aa1aa3dba 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_on_remote_control_settings_notification.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_on_remote_control_settings_notification.h @@ -30,15 +30,18 @@ POSSIBILITY OF SUCH DAMAGE. */ -#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_HMI_RC_ON_REMOTE_CONTROL_SETTINGS_NOTIFICATION_H -#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_HMI_RC_ON_REMOTE_CONTROL_SETTINGS_NOTIFICATION_H +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_HMI_RC_ON_REMOTE_CONTROL_SETTINGS_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_HMI_RC_ON_REMOTE_CONTROL_SETTINGS_NOTIFICATION_H_ #include "application_manager/commands/notification_from_hmi.h" +#include "rc_rpc_plugin/commands/rc_command_request.h" +#include "rc_rpc_plugin/interior_data_cache.h" #include "rc_rpc_plugin/resource_allocation_manager.h" #include "utils/macro.h" namespace rc_rpc_plugin { namespace app_mngr = application_manager; +class InteriorDataManager; namespace commands { class RCOnRemoteControlSettingsNotification @@ -54,12 +57,8 @@ class RCOnRemoteControlSettingsNotification * @param resource_allocation_manager ResourceAllocationManager **/ RCOnRemoteControlSettingsNotification( - const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle, - rc_rpc_plugin::ResourceAllocationManager& resource_allocation_manager); + const application_manager::commands::MessageSharedPtr& message, + const RCCommandParams& params); /** * @brief Execute command **/ @@ -69,7 +68,7 @@ class RCOnRemoteControlSettingsNotification private: ResourceAllocationManager& resource_allocation_manager_; - + InteriorDataManager& interior_data_manager_; /** * @brief Disalows RC functionality for all RC apps * All registered apps will be unsubsribed from OnInteriorVehicleData @@ -80,4 +79,4 @@ class RCOnRemoteControlSettingsNotification } // namespace commands } // namespace rc_rpc_plugin -#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_HMI_RC_ON_REMOTE_CONTROL_SETTINGS_NOTIFICATION_H +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_HMI_RC_ON_REMOTE_CONTROL_SETTINGS_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_set_interior_vehicle_data_request.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_set_interior_vehicle_data_request.h index 194b423b1a..69b48bfecf 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_set_interior_vehicle_data_request.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_set_interior_vehicle_data_request.h @@ -34,7 +34,9 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_HMI_RC_SET_INTERIOR_VEHICLE_DATA_REQUEST_H_ #include "application_manager/commands/request_to_hmi.h" +#include "rc_rpc_plugin/commands/rc_command_request.h" #include "rc_rpc_plugin/resource_allocation_manager.h" +#include "rc_rpc_plugin/interior_data_cache.h" #include "utils/macro.h" namespace rc_rpc_plugin { @@ -54,12 +56,8 @@ class RCSetInteriorVehicleDataRequest * @param resource_allocation_manager ResourceAllocationManager **/ RCSetInteriorVehicleDataRequest( - const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle, - ResourceAllocationManager& resource_allocation_manager); + const application_manager::commands::MessageSharedPtr& message, + const RCCommandParams& params); void Run() OVERRIDE; ~RCSetInteriorVehicleDataRequest(); }; diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_set_interior_vehicle_data_response.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_set_interior_vehicle_data_response.h index f23acda4d4..8a63503220 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_set_interior_vehicle_data_response.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_set_interior_vehicle_data_response.h @@ -30,11 +30,13 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_HMI_SET_INTERIOR_VEHICLE_DATA_RESPONSE_H -#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_HMI_SET_INTERIOR_VEHICLE_DATA_RESPONSE_H +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_HMI_RC_SET_INTERIOR_VEHICLE_DATA_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_HMI_RC_SET_INTERIOR_VEHICLE_DATA_RESPONSE_H_ #include "application_manager/commands/response_from_hmi.h" +#include "rc_rpc_plugin/commands/rc_command_request.h" #include "rc_rpc_plugin/resource_allocation_manager.h" +#include "rc_rpc_plugin/interior_data_cache.h" #include "utils/macro.h" namespace rc_rpc_plugin { @@ -54,12 +56,8 @@ class RCSetInteriorVehicleDataResponse * @param resource_allocation_manager ResourceAllocationManager **/ RCSetInteriorVehicleDataResponse( - const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle, - ResourceAllocationManager& resource_allocation_manager); + const application_manager::commands::MessageSharedPtr& message, + const RCCommandParams& params); void Run() OVERRIDE; @@ -68,4 +66,4 @@ class RCSetInteriorVehicleDataResponse } // namespace commands } // namespace rc_rpc_plugin -#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_HMI_SET_INTERIOR_VEHICLE_DATA_RESPONSE_H +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_HMI_RC_SET_INTERIOR_VEHICLE_DATA_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/button_press_request.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/button_press_request.h index fa89c10bf9..d6ecfd0128 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/button_press_request.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/button_press_request.h @@ -30,8 +30,8 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_BUTTON_PRESS_REQUEST_H -#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_BUTTON_PRESS_REQUEST_H +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_BUTTON_PRESS_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_BUTTON_PRESS_REQUEST_H_ #include "rc_rpc_plugin/commands/rc_command_request.h" @@ -41,12 +41,9 @@ namespace app_mngr = application_manager; namespace commands { class ButtonPressRequest : public RCCommandRequest { public: - ButtonPressRequest(const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle, - ResourceAllocationManager& resource_allocation_manager); + ButtonPressRequest( + const application_manager::commands::MessageSharedPtr& message, + const RCCommandParams& params); /** * @brief Execute command @@ -96,4 +93,4 @@ class ButtonPressRequest : public RCCommandRequest { } // namespace commands } // namespace rc_rpc_plugin -#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_BUTTON_PRESS_REQUEST_H +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_BUTTON_PRESS_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/button_press_response.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/button_press_response.h index 16d7b0e3fe..0f3964494e 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/button_press_response.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/button_press_response.h @@ -30,11 +30,13 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_BUTTON_PRESS_RESPONSE_H -#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_BUTTON_PRESS_RESPONSE_H +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_BUTTON_PRESS_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_BUTTON_PRESS_RESPONSE_H_ #include "application_manager/commands/command_response_impl.h" #include "rc_rpc_plugin/resource_allocation_manager.h" +#include "rc_rpc_plugin/commands/rc_command_request.h" +#include "rc_rpc_plugin/interior_data_cache.h" #include "utils/macro.h" namespace rc_rpc_plugin { @@ -44,12 +46,9 @@ namespace commands { class ButtonPressResponse : public application_manager::commands::CommandResponseImpl { public: - ButtonPressResponse(const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle, - ResourceAllocationManager& resource_allocation_manager); + ButtonPressResponse( + const application_manager::commands::MessageSharedPtr& message, + const RCCommandParams& params); void Run() OVERRIDE; /** * @brief ButtonPressResponse class destructor @@ -59,4 +58,4 @@ class ButtonPressResponse } // namespace commands } // namespace rc_rpc_plugin -#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_BUTTON_PRESS_RESPONSE_H +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_BUTTON_PRESS_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_request.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_request.h index c2ae0e887f..4624d79b56 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_request.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_request.h @@ -43,12 +43,8 @@ namespace commands { class GetInteriorVehicleDataRequest : public RCCommandRequest { public: GetInteriorVehicleDataRequest( - const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle, - ResourceAllocationManager& resource_allocation_manager); + const application_manager::commands::MessageSharedPtr& message, + const RCCommandParams& params); /** * @brief Execute command */ @@ -67,6 +63,9 @@ class GetInteriorVehicleDataRequest : public RCCommandRequest { ~GetInteriorVehicleDataRequest(); private: + std::vector<application_manager::ApplicationSharedPtr> + AppsSubscribedToModuleType(const std::string& module_type); + /** * @brief Check if app wants to proceed with already setup subscription * @param request_params request parameters to check @@ -80,8 +79,7 @@ class GetInteriorVehicleDataRequest : public RCCommandRequest { * @brief Handle subscription to vehicle data * @param hmi_response json message with response from HMI */ - void ProccessSubscription( - const NsSmartDeviceLink::NsSmartObjects::SmartObject& hmi_response); + void ProccessSubscription(const smart_objects::SmartObject& hmi_response); /** * @brief Cuts off subscribe parameter @@ -91,6 +89,11 @@ class GetInteriorVehicleDataRequest : public RCCommandRequest { std::string ModuleType() FINAL; bool excessive_subscription_occured_; + bool ProcessCapabilities(); + void ProcessResponseToMobileFromCache(app_mngr::ApplicationSharedPtr app); + bool CheckRateLimits(); + bool AppShouldBeUnsubscribed(); + bool TheLastAppShouldBeUnsubscribed(app_mngr::ApplicationSharedPtr app); }; } // namespace commands } // namespace rc_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_response.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_response.h index 78148ab7df..bf8208edc2 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_response.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_response.h @@ -30,11 +30,13 @@ POSSIBILITY OF SUCH DAMAGE. */ -#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_GET_INTERIOR_VEHICLE_DATA_RESPONSE_H -#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_GET_INTERIOR_VEHICLE_DATA_RESPONSE_H +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_GET_INTERIOR_VEHICLE_DATA_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_GET_INTERIOR_VEHICLE_DATA_RESPONSE_H_ #include "application_manager/commands/command_response_impl.h" +#include "rc_rpc_plugin/commands/rc_command_request.h" #include "rc_rpc_plugin/resource_allocation_manager.h" +#include "rc_rpc_plugin/interior_data_cache.h" #include "utils/macro.h" namespace rc_rpc_plugin { @@ -45,12 +47,8 @@ class GetInteriorVehicleDataResponse : public application_manager::commands::CommandResponseImpl { public: GetInteriorVehicleDataResponse( - const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle, - ResourceAllocationManager& resource_allocation_manager); + const application_manager::commands::MessageSharedPtr& message, + const RCCommandParams& params); void Run() OVERRIDE; @@ -59,4 +57,4 @@ class GetInteriorVehicleDataResponse } // namespace commands } // namespace rc_rpc_plugin -#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_GET_INTERIOR_VEHICLE_DATA_RESPONSE_H +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_GET_INTERIOR_VEHICLE_DATA_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/on_interior_vehicle_data_notification.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/on_interior_vehicle_data_notification.h index 20a7e69868..931e79366c 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/on_interior_vehicle_data_notification.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/on_interior_vehicle_data_notification.h @@ -36,6 +36,8 @@ #include <string> #include "application_manager/commands/command_notification_impl.h" #include "rc_rpc_plugin/resource_allocation_manager.h" +#include "rc_rpc_plugin/interior_data_cache.h" +#include "rc_rpc_plugin/commands/rc_command_request.h" #include "utils/macro.h" namespace rc_rpc_plugin { @@ -46,18 +48,18 @@ class OnInteriorVehicleDataNotification : public application_manager::commands::CommandNotificationImpl { public: OnInteriorVehicleDataNotification( - const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler, - ResourceAllocationManager& resource_allocation_manager); + const application_manager::commands::MessageSharedPtr& message, + const RCCommandParams& params); void Run() OVERRIDE; std::string ModuleType(); ~OnInteriorVehicleDataNotification(); + + private: + InteriorDataCache& interior_data_cache_; + void AddDataToCache(const std::string& module_type); }; } // namespace commands } // namespace rc_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_request.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_request.h index 83a8dfdd75..128c668ee9 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" @@ -39,15 +39,16 @@ namespace rc_rpc_plugin { namespace app_mngr = application_manager; namespace commands { + +enum capabilitiesStatus { success, missedLightName, missedParam, readOnly }; + +typedef std::pair<std::string, capabilitiesStatus> ModuleCapability; + 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 @@ -85,10 +86,12 @@ class SetInteriorVehicleDataRequest : public RCCommandRequest { /** * @brief Method that check if READ_ONLY parameters present - * @param request_params params from received message + * @param request_params params from received message, + * @param module_data_capabilities info for notification to mobile * @return true if present , false - otherwise */ - bool AreReadOnlyParamsPresent(const smart_objects::SmartObject& module_data); + bool AreReadOnlyParamsPresent(const smart_objects::SmartObject& module_data, + ModuleCapability& module_data_capabilities); /** * @brief Method that check if all request parameters are READ_ONLY @@ -99,7 +102,7 @@ class SetInteriorVehicleDataRequest : public RCCommandRequest { /** * @brief Method that cuts-off READ_ONLY parameters - * @param request_params params to handle + * @param module_data params to handle */ void CutOffReadOnlyParams(smart_objects::SmartObject& module_data); @@ -118,8 +121,17 @@ class SetInteriorVehicleDataRequest : public RCCommandRequest { */ const smart_objects::SmartObject& ControlData( const smart_objects::SmartObject& module_data); + + /** + * @brief CheckAudioSource check that if app wants to change + * the audio source from MOBILE_APP to other types of audio + * source without keepContext parameter or with keepContext=false + * then this app will go to HMI level 'BACKGROUND' + * @param module_data received params + */ + void CheckAudioSource(const smart_objects::SmartObject& audio_data); }; } // namespace commands } // namespace rc_rpc_plugin -#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_SET_INTERIOR_VEHICLE_DATA_REQUEST_H +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_SET_INTERIOR_VEHICLE_DATA_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_response.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_response.h index 5661a57c07..1ab5ccc6bc 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_response.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_response.h @@ -30,11 +30,13 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_SET_INTERIOR_VEHICLE_DATA_RESPONSE_H -#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_SET_INTERIOR_VEHICLE_DATA_RESPONSE_H +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_SET_INTERIOR_VEHICLE_DATA_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_SET_INTERIOR_VEHICLE_DATA_RESPONSE_H_ #include "application_manager/commands/command_response_impl.h" #include "rc_rpc_plugin/resource_allocation_manager.h" +#include "rc_rpc_plugin/interior_data_cache.h" +#include "rc_rpc_plugin/commands/rc_command_request.h" #include "utils/macro.h" namespace rc_rpc_plugin { @@ -45,12 +47,8 @@ class SetInteriorVehicleDataResponse : public application_manager::commands::CommandResponseImpl { public: SetInteriorVehicleDataResponse( - const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle, - ResourceAllocationManager& resource_allocation_manager); + const application_manager::commands::MessageSharedPtr& message, + const RCCommandParams& params); void Run() OVERRIDE; @@ -59,4 +57,4 @@ class SetInteriorVehicleDataResponse } // namespace commands } // namespace rc_rpc_plugin -#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_COMMANDS_SET_INTERIOR_VEHICLE_DATA_RESPONSE_H +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_SET_INTERIOR_VEHICLE_DATA_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_icon_response.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/rc_command_params.h index 514c6ad6d4..8e7ed9c667 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_icon_response.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/rc_command_params.h @@ -1,5 +1,4 @@ /* - Copyright (c) 2018, Ford Motor Company All rights reserved. @@ -31,32 +30,35 @@ POSSIBILITY OF SUCH DAMAGE. */ -#include "sdl_rpc_plugin/commands/mobile/set_icon_response.h" -#include "application_manager/application_manager.h" -#include "application_manager/rpc_service.h" - -namespace sdl_rpc_plugin { -using namespace application_manager; +#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 commands { +namespace application_manager { +class ApplicationManager; +namespace rpc_service { +class RPCService; +} +class HMICapabilities; +} -SetIconResponse::SetIconResponse( - const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& app_man, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) - : CommandResponseImpl( - message, app_man, rpc_service, hmi_capabilities, policy_handler) {} +namespace policy { +class PolicyHandlerInterface; +} -SetIconResponse::~SetIconResponse() {} +namespace rc_rpc_plugin { -void SetIconResponse::Run() { - LOG4CXX_AUTO_TRACE(logger_); +class ResourceAllocationManager; +class InteriorDataCache; +class InteriorDataManager; - rpc_service_.SendMessageToMobile(message_); +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_; +}; } - -} // namespace commands - -} // namespace application_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/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_icon_response.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/interior_data_cache_impl.h index 654dff25b5..f2971e3d72 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_icon_response.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/interior_data_cache_impl.h @@ -30,47 +30,35 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SET_ICON_RESPONSE_H_ -#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SET_ICON_RESPONSE_H_ +#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 "application_manager/commands/response_from_hmi.h" +#include <map> -namespace sdl_rpc_plugin { -namespace app_mngr = application_manager; +#include "utils/macro.h" +#include "utils/lock.h" +#include "rc_rpc_plugin/interior_data_cache.h" -namespace commands { - -/** - * @brief UISetIconResponse command class - **/ -class UISetIconResponse : public app_mngr::commands::ResponseFromHMI { +namespace rc_rpc_plugin { +class InteriorDataCacheImpl : public InteriorDataCache { public: - /** - * @brief UISetIconResponse class constructor - * - * @param message Incoming SmartObject message - **/ - UISetIconResponse(const app_mngr::commands::MessageSharedPtr& message, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle); + InteriorDataCacheImpl(); - /** - * @brief UISetIconResponse class destructor - **/ - virtual ~UISetIconResponse(); + ~InteriorDataCacheImpl(); - /** - * @brief Execute command - **/ - virtual void Run(); + 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: - DISALLOW_COPY_AND_ASSIGN(UISetIconResponse); + std::map<std::string, smart_objects::SmartObject> cached_data_; + mutable sync_primitives::Lock cached_data_lock_; }; -} // namespace commands - -} // namespace application_manager +} // rc_rpc_plugin -#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SET_ICON_RESPONSE_H_ +#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..9b16a2c4da --- /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<date_time::TimeDuration> > + RequestsToHMIHistory; + RequestsToHMIHistory requests_to_hmi_history_; + mutable sync_primitives::Lock requests_to_hmi_history_lock_; + + RCRPCPlugin& rc_plugin_; + InteriorDataCache& cache_; + application_manager::ApplicationManager& app_mngr_; + application_manager::rpc_service::RPCService& rpc_service_; +}; + +} // namespace rc_rpc_plugin +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_INTERIOR_DATA_MANAGER_IMPL_H_ diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_app_extension.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_app_extension.h index 72f29c7de1..14397237c5 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_app_extension.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_app_extension.h @@ -30,8 +30,8 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_RC_APP_EXTENSION_H_ -#define SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_RC_APP_EXTENSION_H_ +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_APP_EXTENSION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_APP_EXTENSION_H_ #include <string> #include <set> @@ -69,6 +69,12 @@ class RCAppExtension : public application_manager::AppExtension { */ bool IsSubscibedToInteriorVehicleData(const std::string& module_type); + /** + * @brief get list of subscriptions of application + * @return list of subscriptions of application + */ + std::set<std::string> InteriorVehicleDataSubscriptions() const; + private: std::set<std::string> subscribed_interior_vehicle_data_; @@ -84,4 +90,4 @@ typedef std::shared_ptr<RCAppExtension> RCAppExtensionPtr; } // namespace rc_rpc_plugin -#endif // SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_RC_APP_EXTENSION_H_ +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_APP_EXTENSION_H_ diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_command_factory.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_command_factory.h index 6f101cefef..56be342b56 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_command_factory.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_command_factory.h @@ -30,8 +30,8 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_COMMAND_FACTORY_H -#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_COMMAND_FACTORY_H +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_COMMAND_FACTORY_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_COMMAND_FACTORY_H_ #include <memory> #include "application_manager/command_factory.h" @@ -41,6 +41,8 @@ #include "application_manager/hmi_capabilities.h" #include "application_manager/policies/policy_handler_interface.h" #include "rc_rpc_plugin/resource_allocation_manager.h" +#include "rc_rpc_plugin/interior_data_cache.h" +#include "rc_rpc_plugin/commands/rc_command_params.h" #include "utils/macro.h" namespace rc_rpc_plugin { @@ -56,11 +58,7 @@ class RCCommandFactory : public application_manager::CommandFactory { * @param policy_handler PolicyHandlerInterface * @param allocation_manager ResourceAllocationManager **/ - RCCommandFactory(app_mngr::ApplicationManager& app_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler, - ResourceAllocationManager& allocation_manager); + RCCommandFactory(const RCCommandParams& params); application_manager::CommandSharedPtr CreateCommand( const app_mngr::commands::MessageSharedPtr& message, app_mngr::commands::Command::CommandSource source) OVERRIDE; @@ -84,11 +82,7 @@ class RCCommandFactory : public application_manager::CommandFactory { hmi_apis::FunctionID::eType id, hmi_apis::messageType::eType message_type) const; - app_mngr::ApplicationManager& app_manager_; - app_mngr::rpc_service::RPCService& rpc_service_; - app_mngr::HMICapabilities& hmi_capabilities_; - PolicyHandlerInterface& policy_handler_; - ResourceAllocationManager& allocation_manager_; + RCCommandParams params_; }; } // namespace rc_rpc_plugin -#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_COMMAND_FACTORY_H +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_COMMAND_FACTORY_H_ diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_helpers.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_helpers.h new file mode 100644 index 0000000000..cf3c6cd5e4 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_helpers.h @@ -0,0 +1,96 @@ +/* + Copyright (c) 2018, Ford Motor Company + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the Ford Motor Company nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_HELPERS_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_HELPERS_H_ + +#include <map> +#include <string> +#include "application_manager/application.h" +#include "rc_rpc_plugin/rc_app_extension.h" + +namespace rc_rpc_plugin { +class RCRPCPlugin; + +/** + * @brief The RCHelpers class contains frequently used static data + * structures related strictly to RC + * Converters, mapping, factory functions + */ +class RCHelpers { + public: + /** + * @brief GetModuleTypeToDataMapping get mapping of module type enum naming to + * actual module data filed name + * @return module mapping from enum naming to filed name + */ + static const std::function<std::string(const std::string& module_type)> + GetModuleTypeToDataMapping(); + + /** + * @brief GetModuleTypeToDataMapping get mapping of module type enum naming to + * actual module capabilities key + * @return module mapping from enum naming to capabilities key + */ + static const std::function<std::string(const std::string& module_type)> + GetModuleTypeToCapabilitiesMapping(); + + /** + * @brief GetModulesList get list of all known modules + * @return vector contains all known modules + */ + static const std::vector<std::string> GetModulesList(); + + /** + * @brief GetRCExtension extract RC extension from application + * @param app application to extract extension + * @return rc extension of app is rc applicaiton, otherwise return emty shared + * pointer. + */ + static RCAppExtensionPtr GetRCExtension( + application_manager::Application& app); + + static smart_objects::SmartObjectSPtr CreateUnsubscribeRequestToHMI( + const std::string& module_type, const uint32_t correlation_id); + + static std::vector<application_manager::ApplicationSharedPtr> + AppsSubscribedToModuleType(application_manager::ApplicationManager& app_mngr, + const std::string& module_type); + + typedef std::map<application_manager::ApplicationSharedPtr, + std::vector<std::string> > AppsModules; + static AppsModules GetApplicationsAllowedModules( + application_manager::ApplicationManager& app_mngr); +}; + +} // rc_rpc_plugin +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_HELPERS_H_ diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_module_constants.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_module_constants.h index f2037aabbb..1951af1a24 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_module_constants.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_module_constants.h @@ -30,8 +30,8 @@ POSSIBILITY OF SUCH DAMAGE. */ -#ifndef SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_RC_MODULE_CONSTANTS_H_ -#define SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_RC_MODULE_CONSTANTS_H_ +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_MODULE_CONSTANTS_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_MODULE_CONSTANTS_H_ namespace rc_rpc_plugin { @@ -40,7 +40,24 @@ namespace strings { const char kclimateControlCapabilities[] = "climateControlCapabilities"; const char kradioControlCapabilities[] = "radioControlCapabilities"; const char kbuttonCapabilities[] = "buttonCapabilities"; +const char kaudioControlCapabilities[] = "audioControlCapabilities"; +const char klightControlCapabilities[] = "lightControlCapabilities"; +const char khmiSettingsControlCapabilities[] = "hmiSettingsControlCapabilities"; const char kseatControlCapabilities[] = "seatControlCapabilities"; +// RemoteControlCapabilities constants + +const char kRadioControlData[] = "radioControlData"; +const char kClimateControlData[] = "climateControlData"; +const char kSupportedLights[] = "supportedLights"; + +// LightControlCapabilities +const char kName[] = "name"; +const char kStatusAvailable[] = "statusAvailable"; +const char kDensityAvailable[] = "densityAvailable"; +const char kRGBColorSpaceAvailable[] = "rgbColorSpaceAvailable"; + +// RadioControlCapabilities +const char kSiriusxmRadioAvailable[] = "siriusxmRadioAvailable"; } // strings namespace result_codes { @@ -139,6 +156,7 @@ const char kSignalStrength[] = "signalStrength"; const char kSignalChangeThreshold[] = "signalChangeThreshold"; const char kRadioEnable[] = "radioEnable"; const char kState[] = "state"; +const char kSisData[] = "sisData"; // RadioControlData struct // ClimateControlData struct @@ -153,11 +171,30 @@ const char kDefrostZone[] = "defrostZone"; const char kDualModeEnable[] = "dualModeEnable"; const char kACMaxEnable[] = "acMaxEnable"; const char kVentilationMode[] = "ventilationMode"; +const char kHeatedSteeringWheelEnable[] = "heatedSteeringWheelEnable"; +const char kHeatedWindshieldEnable[] = "heatedWindshieldEnable"; +const char kHeatedRearWindowEnable[] = "heatedRearWindowEnable"; +const char kHeatedMirrorsEnable[] = "heatedMirrorsEnable"; // ClimateControlData struct +// LightControlData +const char kLightState[] = "lightState"; +const char kLightStatus[] = "status"; +const char kLightDensity[] = "density"; +const char kLightColor[] = "color"; + +// AudioControlData +const char kSource[] = "source"; +const char kKeepContext[] = "keepContext"; +const char kEqualizerSettings[] = "equalizerSettings"; +const char kChannelName[] = "channelName"; + // ModuleData struct const char kRadioControlData[] = "radioControlData"; const char kClimateControlData[] = "climateControlData"; +const char kAudioControlData[] = "audioControlData"; +const char kLightControlData[] = "lightControlData"; +const char kHmiSettingsControlData[] = "hmiSettingsControlData"; const char kSeatControlData[] = "seatControlData"; // ModuleData struct @@ -173,6 +210,9 @@ namespace enums_value { const char kClimate[] = "CLIMATE"; const char kRadio[] = "RADIO"; const char kSeat[] = "SEAT"; +const char kAudio[] = "AUDIO"; +const char kLight[] = "LIGHT"; +const char kHmiSettings[] = "HMI_SETTINGS"; // ModuleType enum // RadioBand enum @@ -235,4 +275,4 @@ const char kAskDriver[] = "ASK_DRIVER"; } // namespace remote_control -#endif // SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_RC_MODULE_CONSTANTS_H_ +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_MODULE_CONSTANTS_H_ diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_rpc_plugin.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_rpc_plugin.h index 910eda6d3c..ae88ed9cc0 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_rpc_plugin.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_rpc_plugin.h @@ -30,15 +30,21 @@ POSSIBILITY OF SUCH DAMAGE. */ -#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_PLUGIN_H -#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_PLUGIN_H +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_RPC_PLUGIN_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_RPC_PLUGIN_H_ + +#include <memory> + #include "application_manager/plugin_manager/rpc_plugin.h" #include "application_manager/command_factory.h" #include "rc_rpc_plugin/resource_allocation_manager.h" +#include "rc_rpc_plugin/interior_data_cache.h" +#include "rc_rpc_plugin/interior_data_manager.h" namespace rc_rpc_plugin { namespace plugins = application_manager::plugin_manager; namespace app_mngr = application_manager; + class RCRPCPlugin : public plugins::RPCPlugin { public: /** @@ -72,6 +78,7 @@ class RCRPCPlugin : public plugins::RPCPlugin { * @return plugins command factory */ app_mngr::CommandFactory& GetCommandFactory() OVERRIDE; + /** * @brief OnPolicyEvent Processes policy related events * @param event Policy event @@ -92,11 +99,15 @@ class RCRPCPlugin : public plugins::RPCPlugin { application_manager::ApplicationManager& app_mngr); private: + application_manager::rpc_service::RPCService* rpc_service_; + application_manager::ApplicationManager* app_mngr_; std::unique_ptr<application_manager::CommandFactory> command_factory_; std::unique_ptr<ResourceAllocationManager> resource_allocation_manager_; + std::unique_ptr<InteriorDataCache> interior_data_cache_; + std::unique_ptr<InteriorDataManager> interior_data_manager_; }; } // namespace rc_rpc_plugin extern "C" application_manager::plugin_manager::RPCPlugin* Create(); -#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_PLUGIN_H +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_RPC_PLUGIN_H_ diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager.h index 91d1b09fca..67598b667b 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager.h @@ -30,8 +30,8 @@ POSSIBILITY OF SUCH DAMAGE. */ -#ifndef SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_RESOURCE_ALLOCATION_H -#define SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_RESOURCE_ALLOCATION_H +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RESOURCE_ALLOCATION_MANAGER_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RESOURCE_ALLOCATION_MANAGER_H_ #include <string> #include "utils/macro.h" @@ -154,9 +154,6 @@ class ResourceAllocationManager { */ virtual void ResetAllAllocations() = 0; - virtual RCAppExtensionPtr GetApplicationExtention( - application_manager::ApplicationSharedPtr application) = 0; - /** * @brief Create and send OnRCStatusNotification to mobile and HMI * @param event trigger for notification sending @@ -178,4 +175,4 @@ class ResourceAllocationManager { }; } // namespace rc_rpc_plugin -#endif // SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_RESOURCE_ALLOCATION_H +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RESOURCE_ALLOCATION_MANAGER_H_ diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager_impl.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager_impl.h index d6124a026b..b359ee4d29 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager_impl.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager_impl.h @@ -30,8 +30,8 @@ POSSIBILITY OF SUCH DAMAGE. */ -#ifndef SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_RESOURCE_ALLOCATION_IMPL_H -#define SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_RESOURCE_ALLOCATION_IMPL_H +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RESOURCE_ALLOCATION_MANAGER_IMPL_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RESOURCE_ALLOCATION_MANAGER_IMPL_H_ #include "rc_rpc_plugin/resource_allocation_manager.h" #include "application_manager/application_impl.h" #include "rc_rpc_plugin/rc_app_extension.h" @@ -110,14 +110,6 @@ class ResourceAllocationManagerImpl : public ResourceAllocationManager { void ResetAllAllocations() FINAL; - /** - * @brief GetApplicationExtention Provides access to application RC extention - * @param application Application - * @return Pointer to RC extention of application or NULL if not available - */ - RCAppExtensionPtr GetApplicationExtention( - application_manager::ApplicationSharedPtr application) FINAL; - void SendOnRCStatusNotifications( NotificationTrigger::eType event, application_manager::ApplicationSharedPtr application) FINAL; @@ -198,8 +190,6 @@ class ResourceAllocationManagerImpl : public ResourceAllocationManager { */ void SetResourceFree(const std::string& module_type, const uint32_t app_id); - std::vector<std::string> all_supported_modules(); - /** * @brief AllocatedResources contains link between resource and application * owning that resource @@ -231,4 +221,4 @@ class ResourceAllocationManagerImpl : public ResourceAllocationManager { }; } // rc_rpc_plugin -#endif // SRC_COMPONENTS_REMOTE_CONTROL_INCLUDE_REMOTE_CONTROL_RESOURCE_ALLOCATION_IMPL_H +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RESOURCE_ALLOCATION_MANAGER_IMPL_H_ diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_button_press_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_button_press_request.cc index d392420238..75faf5db8c 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_button_press_request.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_button_press_request.cc @@ -31,6 +31,8 @@ */ #include "rc_rpc_plugin/commands/hmi/rc_button_press_request.h" +#include "rc_rpc_plugin/resource_allocation_manager_impl.h" + #include "utils/macro.h" namespace rc_rpc_plugin { @@ -38,18 +40,12 @@ namespace commands { RCButtonPressRequest::RCButtonPressRequest( const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle, - ResourceAllocationManager& resource_allocation_manager) - : application_manager::commands::RequestToHMI(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handle) { - UNUSED(resource_allocation_manager); -} + const RCCommandParams& params) + : app_mngr::commands::RequestToHMI(message, + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} RCButtonPressRequest::~RCButtonPressRequest() {} diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_button_press_response.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_button_press_response.cc index c7c11354c7..5c1691ed7b 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_button_press_response.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_button_press_response.cc @@ -37,19 +37,14 @@ namespace rc_rpc_plugin { namespace commands { RCButtonPressResponse::RCButtonPressResponse( - const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle, - ResourceAllocationManager& resource_allocation_manager) - : application_manager::commands::ResponseFromHMI(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handle) { - UNUSED(resource_allocation_manager); -} + const application_manager::commands::MessageSharedPtr& message, + const RCCommandParams& params) + : application_manager::commands::ResponseFromHMI( + message, + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} void RCButtonPressResponse::Run() { LOG4CXX_AUTO_TRACE(logger_); diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_consent_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_consent_request.cc index 875f1c8fbf..774ee04677 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_consent_request.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_consent_request.cc @@ -38,18 +38,12 @@ namespace commands { RCGetInteriorVehicleDataConsentRequest::RCGetInteriorVehicleDataConsentRequest( const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle, - ResourceAllocationManager& resource_allocation_manager) + const RCCommandParams& params) : application_manager::commands::RequestToHMI(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handle) { - UNUSED(resource_allocation_manager); -} + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} RCGetInteriorVehicleDataConsentRequest:: ~RCGetInteriorVehicleDataConsentRequest() {} diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_consent_response.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_consent_response.cc index 3a9bb12df1..3244857656 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_consent_response.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_consent_response.cc @@ -38,19 +38,14 @@ namespace commands { RCGetInteriorVehicleDataConsentResponse:: RCGetInteriorVehicleDataConsentResponse( - const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle, - ResourceAllocationManager& resource_allocation_manager) - : application_manager::commands::ResponseFromHMI(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handle) { - UNUSED(resource_allocation_manager); -} + const application_manager::commands::MessageSharedPtr& message, + const RCCommandParams& params) + : application_manager::commands::ResponseFromHMI( + message, + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} void RCGetInteriorVehicleDataConsentResponse::Run() { LOG4CXX_AUTO_TRACE(logger_); diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_request.cc index 0bb5f73c1b..c7baf75e27 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_request.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_request.cc @@ -38,18 +38,12 @@ namespace commands { RCGetInteriorVehicleDataRequest::RCGetInteriorVehicleDataRequest( const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle, - ResourceAllocationManager& resource_allocation_manager) + const RCCommandParams& params) : application_manager::commands::RequestToHMI(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handle) { - UNUSED(resource_allocation_manager); -} + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} RCGetInteriorVehicleDataRequest::~RCGetInteriorVehicleDataRequest() {} diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_response.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_response.cc index f12512a38d..e56f9088bc 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_response.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_get_interior_vehicle_data_response.cc @@ -31,6 +31,7 @@ */ #include "rc_rpc_plugin/commands/hmi/rc_get_interior_vehicle_data_response.h" +#include "rc_rpc_plugin/rc_module_constants.h" #include "application_manager/event_engine/event.h" namespace rc_rpc_plugin { @@ -38,24 +39,30 @@ namespace commands { RCGetInteriorVehicleDataResponse::RCGetInteriorVehicleDataResponse( const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle, - ResourceAllocationManager& resource_allocation_manager) - : application_manager::commands::ResponseFromHMI(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handle) { - UNUSED(resource_allocation_manager); -} + const RCCommandParams& params) + : application_manager::commands::ResponseFromHMI( + message, + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} void RCGetInteriorVehicleDataResponse::Run() { LOG4CXX_AUTO_TRACE(logger_); app_mngr::event_engine::Event event( hmi_apis::FunctionID::RC_GetInteriorVehicleData); + + smart_objects::SmartObject& module_data = (*message_) + [application_manager::strings::msg_params][message_params::kModuleData]; + if (module_data.keyExists(message_params::kAudioControlData)) { + smart_objects::SmartObject& audio_control_data = + module_data[message_params::kAudioControlData]; + if (audio_control_data.keyExists(message_params::kKeepContext)) { + audio_control_data.erase(message_params::kKeepContext); + } + } + event.set_smart_object(*message_); event.raise(application_manager_.event_dispatcher()); } diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_interior_vehicle_data_notification.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_interior_vehicle_data_notification.cc index 487193bc4d..0117003f11 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_interior_vehicle_data_notification.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_interior_vehicle_data_notification.cc @@ -30,6 +30,7 @@ POSSIBILITY OF SUCH DAMAGE. */ +#include "rc_rpc_plugin/rc_module_constants.h" #include "rc_rpc_plugin/commands/hmi/rc_on_interior_vehicle_data_notification.h" #include "utils/macro.h" @@ -38,18 +39,13 @@ namespace commands { RCOnInteriorVehicleDataNotification::RCOnInteriorVehicleDataNotification( const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle, - ResourceAllocationManager& resource_allocation_manager) - : application_manager::commands::NotificationFromHMI(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handle) { - UNUSED(resource_allocation_manager); -} + const RCCommandParams& params) + : application_manager::commands::NotificationFromHMI( + message, + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} RCOnInteriorVehicleDataNotification::~RCOnInteriorVehicleDataNotification() {} @@ -57,6 +53,17 @@ void RCOnInteriorVehicleDataNotification::Run() { LOG4CXX_AUTO_TRACE(logger_); (*message_)[app_mngr::strings::params][app_mngr::strings::function_id] = static_cast<int>(mobile_apis::FunctionID::eType::OnInteriorVehicleDataID); + + smart_objects::SmartObject& module_data = (*message_) + [application_manager::strings::msg_params][message_params::kModuleData]; + if (module_data.keyExists(rc_rpc_plugin::message_params::kAudioControlData)) { + smart_objects::SmartObject& audio_control_data = + module_data[message_params::kAudioControlData]; + if (audio_control_data.keyExists(message_params::kKeepContext)) { + audio_control_data.erase(message_params::kKeepContext); + } + } + SendNotificationToMobile(message_); } diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_remote_control_settings_notification.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_remote_control_settings_notification.cc index 8bcb6b08ed..91cb6cb7ee 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,30 +87,9 @@ 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; - Apps apps = RCRPCPlugin::GetRCApplications(application_manager_); - for (Apps::iterator it = apps.begin(); it != apps.end(); ++it) { - application_manager::ApplicationSharedPtr app = *it; - DCHECK(app); - application_manager_.ChangeAppsHMILevel( - app->app_id(), mobile_apis::HMILevel::eType::HMI_NONE); - - const RCAppExtensionPtr extension = - std::static_pointer_cast<RCAppExtension>( - app->QueryInterface(RCRPCPlugin::kRCPluginID)); - if (extension) { - UnsubscribeFromInteriorVehicleDataForAllModules(extension); - } - } + interior_data_manager_.OnDisablingRC(); } void RCOnRemoteControlSettingsNotification::Run() { diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_set_interior_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_set_interior_vehicle_data_request.cc index 69ceed17e9..f0d5ecc177 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_set_interior_vehicle_data_request.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_set_interior_vehicle_data_request.cc @@ -38,18 +38,12 @@ namespace commands { RCSetInteriorVehicleDataRequest::RCSetInteriorVehicleDataRequest( const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle, - ResourceAllocationManager& resource_allocation_manager) + const RCCommandParams& params) : application_manager::commands::RequestToHMI(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handle) { - UNUSED(resource_allocation_manager); -} + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} RCSetInteriorVehicleDataRequest::~RCSetInteriorVehicleDataRequest() {} void RCSetInteriorVehicleDataRequest::Run() { diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_set_interior_vehicle_data_response.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_set_interior_vehicle_data_response.cc index 42c2452943..56d924debe 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_set_interior_vehicle_data_response.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_set_interior_vehicle_data_response.cc @@ -38,18 +38,13 @@ namespace commands { RCSetInteriorVehicleDataResponse::RCSetInteriorVehicleDataResponse( const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle, - ResourceAllocationManager& resource_allocation_manager) - : application_manager::commands::ResponseFromHMI(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handle) { - UNUSED(resource_allocation_manager); -} + const RCCommandParams& params) + : application_manager::commands::ResponseFromHMI( + message, + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} void RCSetInteriorVehicleDataResponse::Run() { LOG4CXX_AUTO_TRACE(logger_); diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/button_press_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/button_press_request.cc index 88e4ebaa3c..05e44cfb44 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/button_press_request.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/button_press_request.cc @@ -50,17 +50,8 @@ typedef std::map<std::string, mobile_apis::ButtonName::eType> ButtonsMap; ButtonPressRequest::ButtonPressRequest( const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle, - ResourceAllocationManager& resource_allocation_manager) - : RCCommandRequest(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handle, - resource_allocation_manager) {} + const RCCommandParams& params) + : RCCommandRequest(message, params) {} ButtonPressRequest::~ButtonPressRequest() {} diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/button_press_response.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/button_press_response.cc index dfdb128322..491b0363c9 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/button_press_response.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/button_press_response.cc @@ -38,18 +38,13 @@ namespace commands { ButtonPressResponse::ButtonPressResponse( const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle, - ResourceAllocationManager& resource_allocation_manager) - : application_manager::commands::CommandResponseImpl(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handle) { - UNUSED(resource_allocation_manager); -} + const RCCommandParams& params) + : application_manager::commands::CommandResponseImpl( + message, + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} ButtonPressResponse::~ButtonPressResponse() {} void ButtonPressResponse::Run() { diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_request.cc index 06c44d2ff3..6178405808 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_request.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_request.cc @@ -32,6 +32,8 @@ #include "rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_request.h" #include "rc_rpc_plugin/rc_module_constants.h" +#include "rc_rpc_plugin/rc_helpers.h" +#include "rc_rpc_plugin/rc_rpc_plugin.h" #include "smart_objects/enum_schema_item.h" #include "utils/macro.h" #include "interfaces/MOBILE_API.h" @@ -46,31 +48,21 @@ CREATE_LOGGERPTR_GLOBAL(logger_, "RemoteControlModule") GetInteriorVehicleDataRequest::GetInteriorVehicleDataRequest( const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle, - ResourceAllocationManager& resource_allocation_manager) - : RCCommandRequest(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handle, - resource_allocation_manager) + const RCCommandParams& params) + : RCCommandRequest(message, params) + , excessive_subscription_occured_(false) {} bool CheckIfModuleTypeExistInCapabilities( const smart_objects::SmartObject& rc_capabilities, const std::string& module_type) { LOG4CXX_AUTO_TRACE(logger_); - const std::map<std::string, std::string> params = { - {enums_value::kRadio, strings::kradioControlCapabilities}, - {enums_value::kClimate, strings::kclimateControlCapabilities}, - {enums_value::kSeat, strings::kseatControlCapabilities}}; + const auto& mapping = RCHelpers::GetModuleTypeToCapabilitiesMapping(); + const auto& module_list = RCHelpers::GetModulesList(); bool is_module_type_valid = false; - for (const auto& param : params) { - if (param.first == module_type) { - if (rc_capabilities.keyExists(param.second)) { + for (const auto& module : module_list) { + if (module == module_type) { + if (rc_capabilities.keyExists(mapping(module))) { is_module_type_valid = true; break; } @@ -79,9 +71,8 @@ bool CheckIfModuleTypeExistInCapabilities( return is_module_type_valid; } -void GetInteriorVehicleDataRequest::Execute() { +bool GetInteriorVehicleDataRequest::ProcessCapabilities() { LOG4CXX_AUTO_TRACE(logger_); - const smart_objects::SmartObject* rc_capabilities = hmi_capabilities_.rc_capability(); @@ -93,26 +84,107 @@ void GetInteriorVehicleDataRequest::Execute() { SendResponse(false, mobile_apis::Result::UNSUPPORTED_RESOURCE, "Accessing not supported module data"); + return false; + } + return true; +} + +void GetInteriorVehicleDataRequest::ProcessResponseToMobileFromCache( + app_mngr::ApplicationSharedPtr app) { + LOG4CXX_AUTO_TRACE(logger_); + const auto& data_mapping = RCHelpers::GetModuleTypeToDataMapping(); + auto data = interior_data_cache_.Retrieve(ModuleType()); + auto response_msg_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + response_msg_params[message_params::kModuleData][data_mapping(ModuleType())] = + data; + response_msg_params[message_params::kModuleData] + [message_params::kModuleType] = ModuleType(); + + const auto& request_msg_params = (*message_)[app_mngr::strings::msg_params]; + LOG4CXX_DEBUG(logger_, + "kSubscribe exist" << request_msg_params.keyExists( + message_params::kSubscribe)); + if (request_msg_params.keyExists(message_params::kSubscribe)) { + response_msg_params[message_params::kIsSubscribed] = + request_msg_params[message_params::kSubscribe].asBool(); + if (request_msg_params[message_params::kSubscribe].asBool()) { + auto extension = RCHelpers::GetRCExtension(*app); + DCHECK(extension); + extension->SubscribeToInteriorVehicleData(ModuleType()); + } + } + SendResponse( + true, mobile_apis::Result::SUCCESS, nullptr, &response_msg_params); + if (AppShouldBeUnsubscribed()) { + auto extension = RCHelpers::GetRCExtension(*app); + DCHECK(extension); + extension->UnsubscribeFromInteriorVehicleData(ModuleType()); + } +} + +bool GetInteriorVehicleDataRequest::CheckRateLimits() { + LOG4CXX_AUTO_TRACE(logger_); + return interior_data_manager_.CheckRequestsToHMIFrequency(ModuleType()); +} + +bool GetInteriorVehicleDataRequest::AppShouldBeUnsubscribed() { + LOG4CXX_AUTO_TRACE(logger_); + const auto& msg_params = (*message_)[app_mngr::strings::msg_params]; + if (msg_params.keyExists(message_params::kSubscribe)) { + return !(msg_params[message_params::kSubscribe].asBool()); + } + return false; +} + +bool GetInteriorVehicleDataRequest::TheLastAppShouldBeUnsubscribed( + app_mngr::ApplicationSharedPtr app) { + LOG4CXX_AUTO_TRACE(logger_); + if (AppShouldBeUnsubscribed()) { + const auto subscribed_to_module_type = + RCHelpers::AppsSubscribedToModuleType(application_manager_, + ModuleType()); + if (subscribed_to_module_type.size() == 1 && + subscribed_to_module_type.front() == app) { + LOG4CXX_DEBUG(logger_, + "The last application unsubscribes from " << ModuleType()); + return true; + } + } + return false; +} + +void GetInteriorVehicleDataRequest::Execute() { + LOG4CXX_AUTO_TRACE(logger_); + + if (!ProcessCapabilities()) { return; } app_mngr::ApplicationSharedPtr app = application_manager_.application(connection_key()); - if (HasRequestExcessiveSubscription()) { - excessive_subscription_occured_ = true; - is_subscribed = - (*message_)[app_mngr::strings::msg_params][message_params::kSubscribe] - .asBool(); - RemoveExcessiveSubscription(); + if (TheLastAppShouldBeUnsubscribed(app) || + !interior_data_cache_.Contains(ModuleType())) { + if (HasRequestExcessiveSubscription()) { + excessive_subscription_occured_ = true; + is_subscribed = + (*message_)[app_mngr::strings::msg_params][message_params::kSubscribe] + .asBool(); + RemoveExcessiveSubscription(); + } + if (!CheckRateLimits()) { + LOG4CXX_WARN(logger_, "GetInteriorVehicleData frequency is too high."); + SendResponse(false, mobile_apis::Result::REJECTED); + return; + } + interior_data_manager_.StoreRequestToHMITime(ModuleType()); + SendHMIRequest(hmi_apis::FunctionID::RC_GetInteriorVehicleData, + &(*message_)[app_mngr::strings::msg_params], + true); + return; } - - (*message_)[app_mngr::strings::msg_params][app_mngr::strings::app_id] = - app->app_id(); - - SendHMIRequest(hmi_apis::FunctionID::RC_GetInteriorVehicleData, - &(*message_)[app_mngr::strings::msg_params], - true); + ProcessResponseToMobileFromCache(app); } void GetInteriorVehicleDataRequest::on_event( @@ -144,7 +216,21 @@ void GetInteriorVehicleDataRequest::on_event( } if (result) { + app_mngr::ApplicationSharedPtr app = + application_manager_.application(connection_key()); + + DCHECK_OR_RETURN_VOID(app); + if (TheLastAppShouldBeUnsubscribed(app)) { + interior_data_cache_.Remove(ModuleType()); + } ProccessSubscription(hmi_response); + if (is_subscribed) { + const auto& data_mapping = RCHelpers::GetModuleTypeToDataMapping(); + const auto module_data = + hmi_response[app_mngr::strings::msg_params] + [message_params::kModuleData][data_mapping(ModuleType())]; + interior_data_cache_.Add(ModuleType(), module_data); + } } else { hmi_response[app_mngr::strings::msg_params].erase( message_params::kIsSubscribed); @@ -152,6 +238,7 @@ void GetInteriorVehicleDataRequest::on_event( std::string response_info; GetInfo(hmi_response, response_info); SetResourceState(ModuleType(), ResourceState::FREE); + SendResponse(result, result_code, response_info.c_str(), @@ -178,8 +265,7 @@ void GetInteriorVehicleDataRequest::ProccessSubscription( app_mngr::ApplicationSharedPtr app = application_manager_.application(CommandRequestImpl::connection_key()); - RCAppExtensionPtr extension = - resource_allocation_manager_.GetApplicationExtention(app); + const auto extension = RCHelpers::GetRCExtension(*app); const char* module_type; NsSmartDeviceLink::NsSmartObjects:: EnumConversionHelper<mobile_apis::ModuleType::eType>::EnumToCString( @@ -258,8 +344,7 @@ bool GetInteriorVehicleDataRequest::HasRequestExcessiveSubscription() { if (is_subscribe_present_in_request) { app_mngr::ApplicationSharedPtr app = application_manager_.application(CommandRequestImpl::connection_key()); - RCAppExtensionPtr extension = - resource_allocation_manager_.GetApplicationExtention(app); + const auto extension = RCHelpers::GetRCExtension(*app); const bool is_app_already_subscribed = extension->IsSubscibedToInteriorVehicleData(ModuleType()); diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_response.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_response.cc index 18ccc5b497..a7572f1d62 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_response.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_response.cc @@ -38,18 +38,13 @@ namespace commands { GetInteriorVehicleDataResponse::GetInteriorVehicleDataResponse( const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle, - ResourceAllocationManager& resource_allocation_manager) - : application_manager::commands::CommandResponseImpl(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handle) { - UNUSED(resource_allocation_manager); -} + const RCCommandParams& params) + : application_manager::commands::CommandResponseImpl( + message, + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) {} GetInteriorVehicleDataResponse::~GetInteriorVehicleDataResponse() {} void GetInteriorVehicleDataResponse::Run() { diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/on_interior_vehicle_data_notification.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/on_interior_vehicle_data_notification.cc index fca9962fb5..c8d1329c02 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/on_interior_vehicle_data_notification.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/on_interior_vehicle_data_notification.cc @@ -33,6 +33,7 @@ #include "rc_rpc_plugin/commands/mobile/on_interior_vehicle_data_notification.h" #include "rc_rpc_plugin/rc_rpc_plugin.h" #include "rc_rpc_plugin/rc_module_constants.h" +#include "rc_rpc_plugin/rc_helpers.h" #include "smart_objects/enum_schema_item.h" #include "utils/macro.h" @@ -43,26 +44,34 @@ CREATE_LOGGERPTR_GLOBAL(logger_, "RemoteControlModule") OnInteriorVehicleDataNotification::OnInteriorVehicleDataNotification( const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler, - ResourceAllocationManager& resource_allocation_manager) + const RCCommandParams& params) : app_mngr::commands::CommandNotificationImpl(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handler) { - UNUSED(resource_allocation_manager); -} + params.application_manager_, + params.rpc_service_, + params.hmi_capabilities_, + params.policy_handler_) + , interior_data_cache_(params.interior_data_cache_) {} OnInteriorVehicleDataNotification::~OnInteriorVehicleDataNotification() {} +void OnInteriorVehicleDataNotification::AddDataToCache( + const std::string& module_type) { + const auto& data_mapping = RCHelpers::GetModuleTypeToDataMapping(); + const auto module_data = + (*message_)[app_mngr::strings::msg_params][message_params::kModuleData] + [data_mapping(module_type)]; + interior_data_cache_.Add(module_type, module_data); +} + void OnInteriorVehicleDataNotification::Run() { LOG4CXX_AUTO_TRACE(logger_); const std::string module_type = ModuleType(); - + auto apps_subscribed = + RCHelpers::AppsSubscribedToModuleType(application_manager_, module_type); + if (!apps_subscribed.empty()) { + AddDataToCache(module_type); + } typedef std::vector<application_manager::ApplicationSharedPtr> AppPtrs; AppPtrs apps = RCRPCPlugin::GetRCApplications(application_manager_); @@ -70,8 +79,7 @@ void OnInteriorVehicleDataNotification::Run() { DCHECK(*it); application_manager::Application& app = **it; - RCAppExtensionPtr extension = std::static_pointer_cast<RCAppExtension>( - app.QueryInterface(RCRPCPlugin::kRCPluginID)); + const auto extension = RCHelpers::GetRCExtension(app); DCHECK(extension); LOG4CXX_TRACE(logger_, "Check subscription for " diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc index 83bb526076..e6f19a889c 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc @@ -33,6 +33,7 @@ #include "rc_rpc_plugin/commands/mobile/set_interior_vehicle_data_request.h" #include "rc_rpc_plugin/rc_module_constants.h" #include "rc_rpc_plugin/rc_rpc_plugin.h" +#include "rc_rpc_plugin/rc_helpers.h" #include "smart_objects/enum_schema_item.h" #include "utils/macro.h" #include "json/json.h" @@ -57,15 +58,20 @@ std::vector<std::string> GetModuleReadOnlyParams( module_ro_params.push_back(kSignalStrength); module_ro_params.push_back(kSignalChangeThreshold); module_ro_params.push_back(kState); + module_ro_params.push_back(kSisData); + } else if (enums_value::kLight == module_type) { + module_ro_params.push_back(kLightStatus); } + return module_ro_params; } -const std::map<std::string, std::string> GetModuleTypeToDataMapping() { +const std::map<std::string, std::string> GetLightCapabilitiesMapping() { std::map<std::string, std::string> mapping = { - {enums_value::kRadio, message_params::kRadioControlData}, - {enums_value::kClimate, message_params::kClimateControlData}, - {enums_value::kSeat, message_params::kSeatControlData}}; + {message_params::kId, strings::kName}, + {message_params::kLightStatus, strings::kStatusAvailable}, + {message_params::kLightDensity, strings::kDensityAvailable}, + {message_params::kLightColor, strings::kRGBColorSpaceAvailable}}; return mapping; } @@ -82,6 +88,10 @@ const std::map<std::string, std::string> GetModuleDataToCapabilitiesMapping() { mapping["dualModeEnable"] = "dualModeEnableAvailable"; mapping["acMaxEnable"] = "acMaxEnableAvailable"; mapping["ventilationMode"] = "ventilationModeAvailable"; + mapping["heatedSteeringWheelEnable"] = "heatedSteeringWheelAvailable"; + mapping["heatedWindshieldEnable"] = "heatedWindshieldAvailable"; + mapping["heatedMirrorsEnable"] = "heatedMirrorsAvailable"; + mapping["heatedRearWindowEnable"] = "heatedRearWindowAvailable"; // radio mapping["band"] = "radioBandAvailable"; @@ -90,10 +100,12 @@ const std::map<std::string, std::string> GetModuleDataToCapabilitiesMapping() { mapping["rdsData"] = "rdsDataAvailable"; mapping["availableHDs"] = "availableHDsAvailable"; mapping["hdChannel"] = "availableHDsAvailable"; + mapping["hdRadioEnable"] = "hdRadioEnableAvailable"; mapping["signalStrength"] = "signalStrengthAvailable"; mapping["signalChangeThreshold"] = "signalChangeThresholdAvailable"; mapping["radioEnable"] = "radioEnableAvailable"; mapping["state"] = "stateAvailable"; + mapping["sisData"] = "sisDataAvailable"; // seat mapping["heatingEnabled"] = "heatingEnabledAvailable"; @@ -114,6 +126,17 @@ const std::map<std::string, std::string> GetModuleDataToCapabilitiesMapping() { mapping["massageCushionFirmness"] = "massageCushionFirmnessAvailable"; mapping["memory"] = "memoryAvailable"; + // audio + mapping["source"] = "sourceAvailable"; + mapping["keepContext"] = "keepContextAvailable"; + mapping["volume"] = "volumeAvailable"; + mapping["equalizerSettings"] = "equalizerAvailable"; + + // hmi settings + mapping["distanceUnit"] = "distanceUnitAvailable"; + mapping["temperatureUnit"] = "temperatureUnitAvailable"; + mapping["displayMode"] = "displayModeUnitAvailable"; + return mapping; } } // namespace @@ -122,94 +145,294 @@ 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() {} -bool CheckControlDataByCapabilities( - const smart_objects::SmartObject& module_caps, +const std::string LightName(const smart_objects::SmartObject& light_name) { + const char* name; + const bool ok = NsSmartDeviceLink::NsSmartObjects:: + EnumConversionHelper<mobile_apis::LightName::eType>::EnumToCString( + static_cast<mobile_apis::LightName::eType>(light_name.asUInt()), + &name); + return ok ? name : "unknown"; +} + +/** + * @brief Check whether the parameter exist in capabilities + * @param smart object of capabilities + * @param mapping - map of module data and capabilities + * @param request_parameter - string + * @param switched_off_result - ref of mobile_apis::Result + * @return success if parameter exist in capabilities missedParam otherwise + */ +capabilitiesStatus GetItemCapability( + const smart_objects::SmartObject& capabilities, + const std::map<std::string, std::string>& mapping, + const std::string& request_parameter, + const mobile_apis::Result::eType& switched_off_result) { + const auto it = mapping.find(request_parameter); + + if (it == mapping.end()) { + LOG4CXX_DEBUG(logger_, + "Parameter " << request_parameter + << " doesn't exist in capabilities."); + return capabilitiesStatus::missedParam; + } + + const std::string& caps_key = it->second; + + LOG4CXX_DEBUG(logger_, + "Checking request parameter " + << request_parameter + << " with capabilities. Appropriate key is " << caps_key); + + if (!capabilities.keyExists(caps_key)) { + LOG4CXX_DEBUG(logger_, + "Capability " << caps_key + << " is missed in RemoteControl capabilities"); + return capabilitiesStatus::missedParam; + } + + if (!capabilities[caps_key].asBool()) { + LOG4CXX_DEBUG(logger_, + "Capability " + << caps_key + << " is switched off in RemoteControl capabilities"); + capabilitiesStatus status = capabilitiesStatus::missedParam; + if (mobile_apis::Result::READ_ONLY == switched_off_result) { + status = capabilitiesStatus::readOnly; + } + return status; + } + + return capabilitiesStatus::success; +} + +/** + * @brief Check whether the cpabilities for light allowed + * @param smart object of capabilities + * @param smart object of control_data + * @return pair of state and capability status - ModuleCapability + */ +ModuleCapability GetLightDataCapabilities( + const smart_objects::SmartObject& capabilities, const smart_objects::SmartObject& control_data) { + LOG4CXX_AUTO_TRACE(logger_); + std::map<std::string, std::string> mapping = GetLightCapabilitiesMapping(); + + for (auto it = control_data.map_begin(); it != control_data.map_end(); ++it) { + const std::string& request_parameter = it->first; + + if (message_params::kId == request_parameter) { + continue; + } + + const capabilitiesStatus status_item_capability = + GetItemCapability(capabilities, + mapping, + request_parameter, + mobile_apis::Result::READ_ONLY); + + if (capabilitiesStatus::success != status_item_capability) { + return std::make_pair(message_params::kLightState, + status_item_capability); + } + } + + return std::make_pair("", capabilitiesStatus::success); +} + +/** + * @brief Check whether the light name exists in capabilities + * @param smart object of capabilities_status + * @param smart object of light_data + * @return pair of state and capability status - ModuleCapability + */ +ModuleCapability GetLightNameCapabilities( + const smart_objects::SmartObject& capabilities_status, + const smart_objects::SmartObject& light_data) { + LOG4CXX_AUTO_TRACE(logger_); + auto it = capabilities_status.asArray()->begin(); + for (; it != capabilities_status.asArray()->end(); ++it) { + const smart_objects::SmartObject& so = *it; + const int64_t current_id = so[message_params::kName].asInt(); + if (current_id == light_data[message_params::kId].asInt()) { + return GetLightDataCapabilities(so, light_data); + } + } + LOG4CXX_DEBUG(logger_, "There is no such light name in capabilities"); + return std::make_pair(message_params::kLightState, + capabilitiesStatus::missedLightName); +} + +/** + * @brief Check whether the exists light data related to correspondent + * capabilities + * @param smart object of capabilities + * @param smart object of control_data + * @return pair of state and capability status - ModuleCapability + */ +ModuleCapability GetControlDataCapabilities( + const smart_objects::SmartObject& capabilities, + const smart_objects::SmartObject& control_data) { + LOG4CXX_AUTO_TRACE(logger_); std::map<std::string, std::string> mapping = GetModuleDataToCapabilitiesMapping(); - const smart_objects::SmartObject& capabilities_status = module_caps[0]; - auto it = control_data.map_begin(); - for (; it != control_data.map_end(); ++it) { + + for (auto it = control_data.map_begin(); it != control_data.map_end(); ++it) { const std::string& request_parameter = it->first; if (message_params::kId == request_parameter) { continue; } - const std::string& caps_key = mapping[request_parameter]; - LOG4CXX_DEBUG(logger_, - "Checking request parameter " - << request_parameter - << " with capabilities. Appropriate key is " << caps_key); - if (!capabilities_status.keyExists(caps_key)) { - LOG4CXX_DEBUG(logger_, - "Capability " - << caps_key - << " is missed in RemoteControl capabilities"); - return false; + if (message_params::kLightState == request_parameter) { + auto light_data = control_data[request_parameter].asArray()->begin(); + ModuleCapability light_capability = + std::make_pair("", capabilitiesStatus::success); + + for (; light_data != control_data[request_parameter].asArray()->end(); + ++light_data) { + light_capability = GetLightNameCapabilities( + capabilities[strings::kSupportedLights], *light_data); + + if (capabilitiesStatus::success != light_capability.second) { + return light_capability; + } + } + + return light_capability; } - if (!capabilities_status[caps_key].asBool()) { - LOG4CXX_DEBUG(logger_, - "Capability " - << caps_key - << " is switched off in RemoteControl capabilities"); - return false; + + const capabilitiesStatus status_item_capability = + GetItemCapability(capabilities[0], + mapping, + request_parameter, + mobile_apis::Result::UNSUPPORTED_RESOURCE); + + if (capabilitiesStatus::success != status_item_capability) { + return std::make_pair("", status_item_capability); } } - return true; + + return std::make_pair("", capabilitiesStatus::success); } -bool CheckIfModuleDataExistInCapabilities( +/** + * @brief Check whether the exists hmi data related to correspondent + * capabilities + * @param smart object of capabilities + * @param smart object of control_data + * @return pair of state and capability status - ModuleCapability + */ +ModuleCapability GetHmiControlDataCapabilities( + const smart_objects::SmartObject& capabilities, + const smart_objects::SmartObject& control_data) { + LOG4CXX_AUTO_TRACE(logger_); + std::map<std::string, std::string> mapping = + GetModuleDataToCapabilitiesMapping(); + + for (auto it = control_data.map_begin(); it != control_data.map_end(); ++it) { + const capabilitiesStatus status_item_capability = + GetItemCapability(capabilities, + mapping, + it->first, + mobile_apis::Result::UNSUPPORTED_RESOURCE); + + if (capabilitiesStatus::success != status_item_capability) { + return std::make_pair("", status_item_capability); + } + } + + return std::make_pair("", capabilitiesStatus::success); +} + +/** + * @brief Check whether rc module data capabilities are presented + * @param smart object of rc_capabilities + * @param smart object of module_data + * @return pair of state and capability status - ModuleCapability + */ +ModuleCapability GetModuleDataCapabilities( const smart_objects::SmartObject& rc_capabilities, const smart_objects::SmartObject& module_data) { LOG4CXX_AUTO_TRACE(logger_); - const std::map<std::string, std::string> params = { - {message_params::kRadioControlData, strings::kradioControlCapabilities}, - {message_params::kClimateControlData, - strings::kclimateControlCapabilities}, - {message_params::kSeatControlData, strings::kseatControlCapabilities}}; - 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"); - return false; + + const auto& all_module_types = RCHelpers::GetModulesList(); + const auto& get_module_data_key = RCHelpers::GetModuleTypeToDataMapping(); + const auto& get_capabilities_key = + RCHelpers::GetModuleTypeToCapabilitiesMapping(); + ModuleCapability module_data_capabilities = + std::make_pair("", capabilitiesStatus::missedParam); + + 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 module_data_capabilities; + } + const smart_objects::SmartObject& caps = + rc_capabilities[capabilities_key]; + + if (message_params::kHmiSettingsControlData == module_data_key) { + module_data_capabilities = + GetHmiControlDataCapabilities(caps, module_data[module_data_key]); + } else { + module_data_capabilities = + GetControlDataCapabilities(caps, module_data[module_data_key]); } - const smart_objects::SmartObject& caps = rc_capabilities[param.second]; - is_module_data_valid = - CheckControlDataByCapabilities(caps, module_data[param.first]); } } - return is_module_data_valid; + + return module_data_capabilities; } 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; } } return module_type_and_data_match; } +mobile_apis::Result::eType PrepareResultCodeAndInfo( + const ModuleCapability module_data_capabilities, std::string& info) { + mobile_apis::Result::eType result_code = + mobile_apis::Result::UNSUPPORTED_RESOURCE; + if (message_params::kLightState == module_data_capabilities.first) { + switch (module_data_capabilities.second) { + case capabilitiesStatus::missedLightName: + info = "The requested LightName is not supported by the vehicle."; + break; + case capabilitiesStatus::missedParam: + info = + "The requested parameter of the given LightName is not supported " + "by the vehicle."; + break; + case capabilitiesStatus::readOnly: + info = "The requested parameter is read-only."; + result_code = mobile_apis::Result::READ_ONLY; + break; + default: + break; + } + + } else { + info = "Accessing not supported module data."; + } + return result_code; + LOG4CXX_WARN(logger_, info); +} + void SetInteriorVehicleDataRequest::Execute() { LOG4CXX_AUTO_TRACE(logger_); @@ -220,15 +443,22 @@ void SetInteriorVehicleDataRequest::Execute() { if (isModuleTypeAndDataMatch(module_type, module_data)) { const smart_objects::SmartObject* rc_capabilities = hmi_capabilities_.rc_capability(); - if (rc_capabilities && - !CheckIfModuleDataExistInCapabilities(*rc_capabilities, module_data)) { - LOG4CXX_WARN(logger_, "Accessing not supported module data"); - SetResourceState(ModuleType(), ResourceState::FREE); - SendResponse(false, - mobile_apis::Result::UNSUPPORTED_RESOURCE, - "Accessing not supported module data"); - return; + ModuleCapability module_data_capabilities; + + if (rc_capabilities) { + module_data_capabilities = + GetModuleDataCapabilities(*rc_capabilities, module_data); + + if (capabilitiesStatus::success != module_data_capabilities.second) { + SetResourceState(ModuleType(), ResourceState::FREE); + std::string info; + mobile_apis::Result::eType result = + PrepareResultCodeAndInfo(module_data_capabilities, info); + SendResponse(false, result, info.c_str()); + return; + } } + if (AreAllParamsReadOnly(module_data)) { LOG4CXX_WARN(logger_, "All request params in module type are READ ONLY!"); SetResourceState(ModuleType(), ResourceState::FREE); @@ -237,11 +467,27 @@ void SetInteriorVehicleDataRequest::Execute() { "All request params in module type are READ ONLY!"); return; } - if (AreReadOnlyParamsPresent(module_data)) { + + module_data_capabilities = std::make_pair("", capabilitiesStatus::success); + + if (AreReadOnlyParamsPresent(module_data, module_data_capabilities)) { LOG4CXX_DEBUG(logger_, "Request module type has READ ONLY parameters"); + + if (enums_value::kLight == module_data_capabilities.first && + capabilitiesStatus::success != module_data_capabilities.second) { + SetResourceState(ModuleType(), ResourceState::FREE); + SendResponse( + false, + mobile_apis::Result::READ_ONLY, + "The LightStatus enum passed is READ ONLY and cannot be written."); + return; + } + LOG4CXX_DEBUG(logger_, "Cutting-off READ ONLY parameters... "); + CutOffReadOnlyParams(module_data); } + application_manager_.RemoveHMIFakeParameters(message_); app_mngr::ApplicationSharedPtr app = @@ -249,6 +495,20 @@ void SetInteriorVehicleDataRequest::Execute() { (*message_)[app_mngr::strings::msg_params][app_mngr::strings::app_id] = app->app_id(); + const bool app_wants_to_set_audio_src = + module_data.keyExists(message_params::kAudioControlData) && + module_data[message_params::kAudioControlData].keyExists( + message_params::kSource); + + if (app_wants_to_set_audio_src && !app->IsAllowedToChangeAudioSource()) { + LOG4CXX_WARN(logger_, "App is not allowed to change audio source"); + SetResourceState(ModuleType(), ResourceState::FREE); + SendResponse(false, + mobile_apis::Result::REJECTED, + "App is not allowed to change audio source"); + return; + } + SendHMIRequest(hmi_apis::FunctionID::RC_SetInteriorVehicleData, &(*message_)[app_mngr::strings::msg_params], true); @@ -284,6 +544,11 @@ void SetInteriorVehicleDataRequest::on_event( smart_objects::SmartObject response_params; if (result) { response_params = hmi_response[app_mngr::strings::msg_params]; + if (enums_value::kAudio == ModuleType()) { + CheckAudioSource(( + *message_)[app_mngr::strings::msg_params][message_params::kModuleData] + [message_params::kAudioControlData]); + } } std::string info; GetInfo(hmi_response, info); @@ -294,17 +559,44 @@ void SetInteriorVehicleDataRequest::on_event( const smart_objects::SmartObject& SetInteriorVehicleDataRequest::ControlData( const smart_objects::SmartObject& module_data) { const std::string module_type = ModuleType(); - std::map<std::string, std::string> data_mapping = - GetModuleTypeToDataMapping(); - for (const auto& data : data_mapping) { - if (data.first == module_type) { - return module_data[data.second]; + + const auto& all_module_types = RCHelpers::GetModulesList(); + const auto& data_mapping = RCHelpers::GetModuleTypeToDataMapping(); + for (const auto& type : all_module_types) { + if (type == module_type) { + return module_data[data_mapping(type)]; } } NOTREACHED(); return module_data[0]; } +void SetInteriorVehicleDataRequest::CheckAudioSource( + const smart_objects::SmartObject& audio_data) { + LOG4CXX_AUTO_TRACE(logger_); + const bool should_keep_context = + audio_data.keyExists(message_params::kKeepContext) && + audio_data[message_params::kKeepContext].asBool(); + const bool switch_source_from_app = + mobile_apis::PrimaryAudioSource::MOBILE_APP == + application_manager_.get_current_audio_source() && + mobile_apis::PrimaryAudioSource::MOBILE_APP != + audio_data[message_params::kSource].asInt(); + if (!should_keep_context && switch_source_from_app) { + app_mngr::ApplicationSharedPtr app = + application_manager_.application(connection_key()); + if (app->mobile_projection_enabled()) { + application_manager_.ChangeAppsHMILevel( + app->app_id(), mobile_apis::HMILevel::eType::HMI_LIMITED); + } else { + application_manager_.ChangeAppsHMILevel( + app->app_id(), mobile_apis::HMILevel::eType::HMI_BACKGROUND); + } + } + application_manager_.set_current_audio_source( + audio_data[message_params::kSource].asUInt()); +} + bool SetInteriorVehicleDataRequest::AreAllParamsReadOnly( const smart_objects::SmartObject& module_data) { LOG4CXX_AUTO_TRACE(logger_); @@ -317,21 +609,95 @@ bool SetInteriorVehicleDataRequest::AreAllParamsReadOnly( return false; } } + + LOG4CXX_DEBUG(logger_, "All params are ReadOnly"); return true; } +bool CheckReadOnlyParamsForAudio( + const smart_objects::SmartObject& module_type_params) { + if (module_type_params.keyExists(message_params::kEqualizerSettings)) { + const auto& equalizer_settings = + module_type_params[message_params::kEqualizerSettings]; + auto it = equalizer_settings.asArray()->begin(); + + for (; it != equalizer_settings.asArray()->end(); ++it) { + if (it->keyExists(message_params::kChannelName)) { + LOG4CXX_DEBUG(logger_, + "READ ONLY parameter. ChannelName = " + << (*it)[message_params::kChannelName].asString()); + return true; + } + } + } + + return false; +} + +bool CheckReadOnlyParamsForLight( + const smart_objects::SmartObject& module_type_params) { + if (module_type_params.keyExists(message_params::kLightState)) { + const auto& light_state = module_type_params[message_params::kLightState]; + auto it = light_state.asArray()->begin(); + + for (; it != light_state.asArray()->end(); ++it) { + if (it->keyExists(message_params::kLightStatus)) { + const mobile_apis::LightStatus::eType light_status = + static_cast<mobile_apis::LightStatus::eType>( + (*it)[message_params::kLightStatus].asUInt()); + + if (helpers::Compare<mobile_apis::LightStatus::eType, + helpers::EQ, + helpers::ONE>(light_status, + mobile_apis::LightStatus::RAMP_UP, + mobile_apis::LightStatus::RAMP_DOWN, + mobile_apis::LightStatus::UNKNOWN, + mobile_apis::LightStatus::INVALID)) { + LOG4CXX_DEBUG(logger_, + "READ ONLY parameter. Status = " + << (*it)[message_params::kLightStatus].asInt()); + return true; + } + } + } + } + + return false; +} + bool SetInteriorVehicleDataRequest::AreReadOnlyParamsPresent( - const smart_objects::SmartObject& module_data) { + const smart_objects::SmartObject& module_data, + ModuleCapability& module_data_capabilities) { LOG4CXX_AUTO_TRACE(logger_); const smart_objects::SmartObject& module_type_params = ControlData(module_data); + const std::string module_type = ModuleType(); + + if (enums_value::kAudio == module_type) { + return CheckReadOnlyParamsForAudio(module_type_params); + } + + if (enums_value::kLight == module_type) { + const bool result = CheckReadOnlyParamsForLight(module_type_params); + + if (result) { + module_data_capabilities = + std::make_pair(module_type, capabilitiesStatus::readOnly); + } + + return result; + } + + const std::vector<std::string> ro_params = + GetModuleReadOnlyParams(module_type); auto it = module_type_params.map_begin(); - std::vector<std::string> ro_params = GetModuleReadOnlyParams(ModuleType()); + for (; it != module_type_params.map_end(); ++it) { if (helpers::in_range(ro_params, it->first)) { return true; } } + return false; } @@ -347,10 +713,26 @@ void SetInteriorVehicleDataRequest::CutOffReadOnlyParams( if (module_type_params.keyExists(it)) { if (enums_value::kClimate == module_type) { module_data[message_params::kClimateControlData].erase(it); - LOG4CXX_DEBUG(logger_, "Cutting-off READ ONLY parameter: " << it); } else if (enums_value::kRadio == module_type) { module_data[message_params::kRadioControlData].erase(it); - LOG4CXX_DEBUG(logger_, "Cutting-off READ ONLY parameter: " << it); + } else { + continue; + } + + LOG4CXX_DEBUG(logger_, "Cutting-off READ ONLY parameter: " << it); + } + } + + if (enums_value::kAudio == module_type) { + auto& equalizer_settings = module_data[message_params::kAudioControlData] + [message_params::kEqualizerSettings]; + auto it = equalizer_settings.asArray()->begin(); + for (; it != equalizer_settings.asArray()->end(); ++it) { + if (it->keyExists(message_params::kChannelName)) { + it->erase(message_params::kChannelName); + LOG4CXX_DEBUG(logger_, + "Cutting-off READ ONLY parameter: " + << message_params::kChannelName); } } } 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..0c42f6e3de --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/interior_data_manager_impl.cc @@ -0,0 +1,158 @@ +#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::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::MILLISECONDS_IN_SECOND; + auto lest_that_time_frame_ago = [time_frame](date_time::TimeDuration time) { + auto span = date_time::calculateTimeSpan(time); + return span < time_frame; + }; + for (auto& it : requests_to_hmi_history_) { + auto& history = it.second; + auto first_actual = + std::find_if(history.begin(), history.end(), lest_that_time_frame_ago); + history.erase(history.begin(), first_actual); + } +} + +InteriorDataManagerImpl::AppsModules +InteriorDataManagerImpl::AppsSubscribedModules() { + auto apps_list = RCRPCPlugin::GetRCApplications(app_mngr_); + InteriorDataManagerImpl::AppsModules result; + for (auto& app_ptr : apps_list) { + const auto rc_extension = RCHelpers::GetRCExtension(*app_ptr); + auto app_subscriptions = rc_extension->InteriorVehicleDataSubscriptions(); + result[app_ptr] = std::vector<std::string>(app_subscriptions.size()); + std::copy(app_subscriptions.begin(), + app_subscriptions.end(), + result[app_ptr].begin()); + } + return result; +} +} // namespace rc_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_app_extension.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_app_extension.cc index 5c0a94cccc..17f19e24e8 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_app_extension.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_app_extension.cc @@ -64,5 +64,9 @@ void RCAppExtension::SaveResumptionData( void RCAppExtension::ProcessResumption( const NsSmartDeviceLink::NsSmartObjects::SmartObject& resumption_data) {} +std::set<std::string> RCAppExtension::InteriorVehicleDataSubscriptions() const { + return subscribed_interior_vehicle_data_; +} + RCAppExtension::~RCAppExtension() {} } // namespace rc_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_command_factory.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_command_factory.cc index 707d35aa0f..ecfc1dcda4 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_command_factory.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_command_factory.cc @@ -29,6 +29,7 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include <iostream> #include "rc_rpc_plugin/rc_command_factory.h" #include "rc_rpc_plugin/commands/mobile/button_press_request.h" @@ -53,24 +54,18 @@ #include "interfaces/HMI_API.h" #include "rc_rpc_plugin/resource_allocation_manager.h" +#include "rc_rpc_plugin/interior_data_cache.h" CREATE_LOGGERPTR_GLOBAL(logger_, "RemoteControlModule") namespace application_manager { using rc_rpc_plugin::ResourceAllocationManager; +using rc_rpc_plugin::InteriorDataCache; +using rc_rpc_plugin::RCCommandParams; template <typename RCCommandType> class RCCommandCreator : public CommandCreator { public: - RCCommandCreator(ApplicationManager& application_manager, - rpc_service::RPCService& rpc_service, - HMICapabilities& hmi_capabilities, - PolicyHandlerInterface& policy_handler, - ResourceAllocationManager& resource_allocation_manager) - : application_manager_(application_manager) - , rpc_service_(rpc_service) - , hmi_capabilities_(hmi_capabilities) - , policy_handler_(policy_handler) - , resource_allocation_manager_(resource_allocation_manager) {} + RCCommandCreator(const RCCommandParams& params) : params_(params) {} private: bool CanBeCreated() const override { @@ -79,20 +74,11 @@ class RCCommandCreator : public CommandCreator { CommandSharedPtr create( const commands::MessageSharedPtr& message) const override { - CommandSharedPtr command(new RCCommandType(message, - application_manager_, - rpc_service_, - hmi_capabilities_, - policy_handler_, - resource_allocation_manager_)); + CommandSharedPtr command(new RCCommandType(message, params_)); return command; } - ApplicationManager& application_manager_; - RPCService& rpc_service_; - HMICapabilities& hmi_capabilities_; - PolicyHandlerInterface& policy_handler_; - ResourceAllocationManager& resource_allocation_manager_; + RCCommandParams params_; }; struct RCInvalidCommand {}; @@ -100,16 +86,8 @@ struct RCInvalidCommand {}; template <> class RCCommandCreator<RCInvalidCommand> : public CommandCreator { public: - RCCommandCreator(ApplicationManager& application_manager, - RPCService& rpc_service, - HMICapabilities& hmi_capabilities, - PolicyHandlerInterface& policy_handler, - ResourceAllocationManager& resource_allocation_manager) { - UNUSED(application_manager); - UNUSED(rpc_service); - UNUSED(hmi_capabilities); - UNUSED(policy_handler); - UNUSED(resource_allocation_manager); + RCCommandCreator(const RCCommandParams& params) { + UNUSED(params); } private: @@ -125,49 +103,23 @@ class RCCommandCreator<RCInvalidCommand> : public CommandCreator { }; struct RCCommandCreatorFactory { - RCCommandCreatorFactory( - ApplicationManager& application_manager, - rpc_service::RPCService& rpc_service, - HMICapabilities& hmi_capabilities, - PolicyHandlerInterface& policy_handler, - ResourceAllocationManager& resource_allocation_manager) - : application_manager_(application_manager) - , rpc_service_(rpc_service) - , hmi_capabilities_(hmi_capabilities) - , policy_handler_(policy_handler) - , resource_allocation_manager_(resource_allocation_manager) {} + RCCommandCreatorFactory(const RCCommandParams& params) : params_(params) {} template <typename RCCommandType> CommandCreator& GetCreator() { - static RCCommandCreator<RCCommandType> res(application_manager_, - rpc_service_, - hmi_capabilities_, - policy_handler_, - resource_allocation_manager_); + LOG4CXX_AUTO_TRACE(logger_); + static RCCommandCreator<RCCommandType> res(params_); return res; } - ApplicationManager& application_manager_; - RPCService& rpc_service_; - HMICapabilities& hmi_capabilities_; - PolicyHandlerInterface& policy_handler_; - ResourceAllocationManager& resource_allocation_manager_; + const RCCommandParams params_; }; } namespace rc_rpc_plugin { using namespace application_manager; -RCCommandFactory::RCCommandFactory( - app_mngr::ApplicationManager& app_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler, - ResourceAllocationManager& allocation_manager) - : app_manager_(app_manager) - , rpc_service_(rpc_service) - , hmi_capabilities_(hmi_capabilities) - , policy_handler_(policy_handler) - , allocation_manager_(allocation_manager) {} +RCCommandFactory::RCCommandFactory(const RCCommandParams& params) + : params_(params) {} CommandSharedPtr RCCommandFactory::CreateCommand( const app_mngr::commands::MessageSharedPtr& message, @@ -218,11 +170,7 @@ CommandCreator& RCCommandFactory::get_mobile_creator_factory( LOG4CXX_DEBUG(logger_, "CreateMobileCommand function_id: " << id << " message_type: " << message_type); - RCCommandCreatorFactory rc_factory(app_manager_, - rpc_service_, - hmi_capabilities_, - policy_handler_, - allocation_manager_); + RCCommandCreatorFactory rc_factory(params_); switch (id) { case mobile_apis::FunctionID::ButtonPressID: { @@ -259,11 +207,7 @@ CommandCreator& RCCommandFactory::get_hmi_creator_factory( "CreateHMICommand function_id: " << id << " message_type: " << message_type); - RCCommandCreatorFactory rc_factory(app_manager_, - rpc_service_, - hmi_capabilities_, - policy_handler_, - allocation_manager_); + RCCommandCreatorFactory rc_factory(params_); switch (id) { case hmi_apis::FunctionID::Buttons_ButtonPress: { diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_helpers.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_helpers.cc new file mode 100644 index 0000000000..0bdec55733 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_helpers.cc @@ -0,0 +1,118 @@ +#include "rc_rpc_plugin/rc_helpers.h" +#include "rc_rpc_plugin/rc_module_constants.h" +#include "rc_rpc_plugin/rc_rpc_plugin.h" +#include "application_manager/smart_object_keys.h" +#include "application_manager/commands/command_impl.h" +#include "application_manager/message.h" + +namespace rc_rpc_plugin { +CREATE_LOGGERPTR_GLOBAL(logger_, "RemoteControlModule"); + +const std::function<std::string(const std::string& module_type)> +RCHelpers::GetModuleTypeToDataMapping() { + auto mapping_lambda = [](const std::string& module_type) -> std::string { + static std::map<std::string, std::string> mapping = { + {enums_value::kClimate, message_params::kClimateControlData}, + {enums_value::kRadio, message_params::kRadioControlData}, + {enums_value::kSeat, message_params::kSeatControlData}, + {enums_value::kAudio, message_params::kAudioControlData}, + {enums_value::kLight, message_params::kLightControlData}, + {enums_value::kHmiSettings, message_params::kHmiSettingsControlData}}; + auto it = mapping.find(module_type); + if (mapping.end() == it) { + LOG4CXX_ERROR(logger_, "Unknown module type" << module_type); + return std::string(); + } + return it->second; + }; + + return mapping_lambda; +} + +const std::function<std::string(const std::string& module_type)> +RCHelpers::GetModuleTypeToCapabilitiesMapping() { + auto mapping_lambda = [](const std::string& module_type) -> std::string { + static std::map<std::string, std::string> mapping = { + {enums_value::kClimate, strings::kclimateControlCapabilities}, + {enums_value::kRadio, strings::kradioControlCapabilities}, + {enums_value::kSeat, strings::kseatControlCapabilities}, + {enums_value::kAudio, strings::kaudioControlCapabilities}, + {enums_value::kLight, strings::klightControlCapabilities}, + {enums_value::kHmiSettings, strings::khmiSettingsControlCapabilities}}; + auto it = mapping.find(module_type); + if (mapping.end() == it) { + LOG4CXX_ERROR(logger_, "Unknown module type" << module_type); + return std::string(); + } + return it->second; + }; + + return mapping_lambda; +} + +const std::vector<std::string> RCHelpers::GetModulesList() { + using namespace enums_value; + return {kClimate, kRadio, kSeat, kAudio, kLight, kHmiSettings}; +} + +RCAppExtensionPtr RCHelpers::GetRCExtension( + application_manager::Application& app) { + auto extension_interface = app.QueryInterface(RCRPCPlugin::kRCPluginID); + auto extension = + std::static_pointer_cast<RCAppExtension>(extension_interface); + return extension; +} + +smart_objects::SmartObjectSPtr RCHelpers::CreateUnsubscribeRequestToHMI( + const std::string& module_type, const uint32_t correlation_id) { + using namespace smart_objects; + namespace commands = application_manager::commands; + namespace am_strings = application_manager::strings; + + SmartObjectSPtr message = std::make_shared<SmartObject>(SmartType_Map); + SmartObject& params = (*message)[am_strings::params]; + SmartObject& msg_params = (*message)[am_strings::msg_params]; + + params[am_strings::message_type] = + static_cast<int>(application_manager::kRequest); + params[am_strings::protocol_version] = + commands::CommandImpl::protocol_version_; + params[am_strings::protocol_type] = commands::CommandImpl::hmi_protocol_type_; + params[am_strings::correlation_id] = correlation_id; + params[am_strings::function_id] = + hmi_apis::FunctionID::RC_GetInteriorVehicleData; + msg_params[message_params::kSubscribe] = false; + msg_params[message_params::kModuleType] = module_type; + return message; +} + +std::vector<application_manager::ApplicationSharedPtr> +RCHelpers::AppsSubscribedToModuleType( + application_manager::ApplicationManager& app_mngr, + const std::string& module_type) { + std::vector<application_manager::ApplicationSharedPtr> result; + auto rc_apps = RCRPCPlugin::GetRCApplications(app_mngr); + for (auto& app : rc_apps) { + auto rc_ext = RCHelpers::GetRCExtension(*app); + DCHECK_OR_RETURN(rc_ext, result); + if (rc_ext->IsSubscibedToInteriorVehicleData(module_type)) { + result.push_back(app); + } + } + return result; +} + +RCHelpers::AppsModules RCHelpers::GetApplicationsAllowedModules( + app_mngr::ApplicationManager& app_mngr) { + auto apps_list = RCRPCPlugin::GetRCApplications(app_mngr); + RCHelpers::AppsModules result; + for (auto& app_ptr : apps_list) { + std::vector<std::string> allowed_modules; + app_mngr.GetPolicyHandler().GetModuleTypes(app_ptr->policy_app_id(), + &allowed_modules); + std::sort(allowed_modules.begin(), allowed_modules.end()); + result[app_ptr] = allowed_modules; + } + return result; +} +} diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_rpc_plugin.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_rpc_plugin.cc index 984d6ec9a0..fd6b4e86ac 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_rpc_plugin.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_rpc_plugin.cc @@ -34,10 +34,15 @@ #include "rc_rpc_plugin/rc_command_factory.h" #include "rc_rpc_plugin/rc_app_extension.h" #include "rc_rpc_plugin/resource_allocation_manager_impl.h" +#include "rc_rpc_plugin/interior_data_cache_impl.h" +#include "rc_rpc_plugin/interior_data_manager_impl.h" +#include "rc_rpc_plugin/rc_helpers.h" #include "utils/helpers.h" #include <memory> namespace rc_rpc_plugin { +CREATE_LOGGERPTR_GLOBAL(logger_, "RemoteControlModule"); + namespace plugins = application_manager::plugin_manager; bool RCRPCPlugin::Init( @@ -45,14 +50,22 @@ bool RCRPCPlugin::Init( application_manager::rpc_service::RPCService& rpc_service, application_manager::HMICapabilities& hmi_capabilities, policy::PolicyHandlerInterface& policy_handler) { + interior_data_cache_.reset(new InteriorDataCacheImpl()); + interior_data_manager_.reset(new InteriorDataManagerImpl( + *this, *interior_data_cache_, app_manager, rpc_service)); + resource_allocation_manager_.reset( new ResourceAllocationManagerImpl(app_manager, rpc_service)); - command_factory_.reset( - new rc_rpc_plugin::RCCommandFactory(app_manager, - rpc_service, - hmi_capabilities, - policy_handler, - *resource_allocation_manager_)); + RCCommandParams params{app_manager, + rpc_service, + hmi_capabilities, + policy_handler, + *(resource_allocation_manager_.get()), + *(interior_data_cache_.get()), + *(interior_data_manager_.get())}; + command_factory_.reset(new rc_rpc_plugin::RCCommandFactory(params)); + rpc_service_ = &rpc_service; + app_mngr_ = &app_manager; return true; } @@ -73,14 +86,8 @@ application_manager::CommandFactory& RCRPCPlugin::GetCommandFactory() { void RCRPCPlugin::OnPolicyEvent( application_manager::plugin_manager::PolicyEvent event) { - switch (event) { - case plugins::kApplicationPolicyUpdated: { - resource_allocation_manager_->OnPolicyEvent(event); - break; - } - default: - break; - } + resource_allocation_manager_->OnPolicyEvent(event); + interior_data_manager_->OnPolicyEvent(event); } void RCRPCPlugin::OnApplicationEvent( @@ -99,10 +106,12 @@ void RCRPCPlugin::OnApplicationEvent( } case plugins::kApplicationExit: { resource_allocation_manager_->OnApplicationEvent(event, application); + interior_data_manager_->OnApplicationEvent(event, application); break; } case plugins::kApplicationUnregistered: { resource_allocation_manager_->OnApplicationEvent(event, application); + interior_data_manager_->OnApplicationEvent(event, application); break; } default: diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/resource_allocation_manager_impl.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/resource_allocation_manager_impl.cc index 011950b35a..ecd263b77a 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/resource_allocation_manager_impl.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/resource_allocation_manager_impl.cc @@ -36,9 +36,10 @@ #include "interfaces/HMI_API.h" #include "interfaces/MOBILE_API.h" #include "smart_objects/enum_schema_item.h" -#include "rc_rpc_plugin/rc_rpc_plugin.h" #include "application_manager/message_helper.h" +#include "rc_rpc_plugin/rc_rpc_plugin.h" #include "rc_rpc_plugin/rc_module_constants.h" +#include "rc_rpc_plugin/rc_helpers.h" #include "json/json.h" #include "utils/helpers.h" @@ -166,13 +167,10 @@ void ResourceAllocationManagerImpl::ProcessApplicationPolicyUpdate() { allowed_modules.end(), std::back_inserter(disallowed_modules)); - RCAppExtensionPtr rc_extention = GetApplicationExtention(app_ptr); + auto rc_extention = RCHelpers::GetRCExtension(**app); Resources::const_iterator module = disallowed_modules.begin(); for (; disallowed_modules.end() != module; ++module) { ReleaseResource(*module, application_id); - if (rc_extention) { - rc_extention->UnsubscribeFromInteriorVehicleData(*module); - } } if (!disallowed_modules.empty()) { SendOnRCStatusNotifications( @@ -182,40 +180,6 @@ void ResourceAllocationManagerImpl::ProcessApplicationPolicyUpdate() { } } -RCAppExtensionPtr ResourceAllocationManagerImpl::GetApplicationExtention( - application_manager::ApplicationSharedPtr application) { - LOG4CXX_AUTO_TRACE(logger_); - RCAppExtensionPtr rc_app_extension; - if (!application) { - return rc_app_extension; - } - - application_manager::AppExtensionPtr app_extension = - application->QueryInterface(RCRPCPlugin::kRCPluginID); - if (!app_extension) { - return rc_app_extension; - } - - rc_app_extension = std::static_pointer_cast<RCAppExtension>(app_extension); - - return rc_app_extension; -} - -void ResourceAllocationManagerImpl::RemoveAppsSubscriptions(const Apps& apps) { - LOG4CXX_AUTO_TRACE(logger_); - Apps::const_iterator app = apps.begin(); - for (; apps.end() != app; ++app) { - application_manager::ApplicationSharedPtr app_ptr = *app; - if (!app_ptr) { - continue; - } - RCAppExtensionPtr rc_extention = GetApplicationExtention(app_ptr); - if (rc_extention) { - rc_extention->UnsubscribeFromInteriorVehicleData(); - } - } -} - template <typename EnumType> EnumType StringToEnum(const std::string& str) { using smart_objects::EnumConversionHelper; @@ -235,6 +199,7 @@ void ConstructOnRCStatusNotificationParams( using smart_objects::SmartType_Map; using smart_objects::SmartType_Array; LOG4CXX_AUTO_TRACE(logger_); + auto modules_inserter = [](SmartObject& result_modules) { return [&result_modules](const std::string& module_name) { smart_objects::SmartObject module_data = @@ -273,7 +238,7 @@ ResourceAllocationManagerImpl::CreateOnRCStatusNotificationToMobile( if (is_rc_enabled()) { ConstructOnRCStatusNotificationParams(msg_params, allocated_resources_, - all_supported_modules(), + RCHelpers::GetModulesList(), app->app_id()); } else { msg_params[message_params::kAllocatedModules] = @@ -292,8 +257,10 @@ ResourceAllocationManagerImpl::CreateOnRCStatusNotificationToHmi( auto msg_to_hmi = MessageHelper::CreateHMINotification(hmi_apis::FunctionID::RC_OnRCStatus); auto& msg_params = (*msg_to_hmi)[application_manager::strings::msg_params]; - ConstructOnRCStatusNotificationParams( - msg_params, allocated_resources_, all_supported_modules(), app->app_id()); + ConstructOnRCStatusNotificationParams(msg_params, + allocated_resources_, + RCHelpers::GetModulesList(), + app->app_id()); msg_params[application_manager::strings::app_id] = app->hmi_app_id(); return msg_to_hmi; } @@ -361,15 +328,6 @@ void ResourceAllocationManagerImpl::SetResourceFree( LOG4CXX_DEBUG(logger_, "Resource " << module_type << " is released."); } -std::vector<std::string> -ResourceAllocationManagerImpl::all_supported_modules() { - std::vector<std::string> result; - result.push_back(enums_value::kClimate); - result.push_back(enums_value::kRadio); - result.push_back(enums_value::kSeat); - return result; -} - std::vector<std::string> ResourceAllocationManagerImpl::GetAcquiredResources( const uint32_t application_id) const { LOG4CXX_AUTO_TRACE(logger_); @@ -510,9 +468,6 @@ void ResourceAllocationManagerImpl::OnApplicationEvent( NotificationTrigger::MODULE_ALLOCATION, std::shared_ptr<application_manager::Application>()); } - Apps app_list; - app_list.push_back(application); - RemoveAppsSubscriptions(app_list); } } @@ -529,8 +484,6 @@ void ResourceAllocationManagerImpl::OnPolicyEvent( if (PolicyEvent::kApplicationsDisabled == event) { ResetAllAllocations(); - Apps app_list = RCRPCPlugin::GetRCApplications(app_mngr_); - RemoveAppsSubscriptions(app_list); return; } } diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/CMakeLists.txt b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/CMakeLists.txt index a1f0f5a6ff..c1c59d7e78 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/CMakeLists.txt +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/CMakeLists.txt @@ -41,6 +41,7 @@ include_directories ( set (RC_TEST_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/resource_allocation_manager_impl_test.cc +${CMAKE_CURRENT_SOURCE_DIR}/interior_data_cache_test.cc ) set(RC_COMMANDS_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/commands) @@ -72,5 +73,5 @@ if(ENABLE_LOG) endif() create_test("rc_commands_test" "${SOURCES}" "${LIBRARIES}" ) -create_test("resource_allocation_manager_test" "${RC_TEST_SOURCES}" "${LIBRARIES}") +create_test("rc_plugin_test" "${RC_TEST_SOURCES}" "${LIBRARIES}") diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/button_press_request_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/button_press_request_test.cc index 8ddcaa469d..022a3e51c9 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/button_press_request_test.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/button_press_request_test.cc @@ -37,6 +37,8 @@ #include "rc_rpc_plugin/rc_rpc_plugin.h" #include "rc_rpc_plugin/rc_module_constants.h" #include "rc_rpc_plugin/mock/mock_resource_allocation_manager.h" +#include "rc_rpc_plugin/mock/mock_interior_data_cache.h" +#include "rc_rpc_plugin/mock/mock_interior_data_manager.h" #include "application_manager/mock_application.h" #include "application_manager/mock_application_manager.h" #include "application_manager/commands/command_request_test.h" @@ -115,7 +117,7 @@ class ButtonPressRequestTest } rc_capabilities_[strings::kbuttonCapabilities] = button_caps; ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app_)); - ON_CALL(mock_allocation_manager_, GetApplicationExtention(_)) + ON_CALL(*mock_app_, QueryInterface(RCRPCPlugin::kRCPluginID)) .WillByDefault(Return(rc_app_extention_)); ON_CALL(app_mngr_, GetPolicyHandler()) .WillByDefault(ReturnRef(mock_policy_handler_)); @@ -147,12 +149,14 @@ class ButtonPressRequestTest template <class Command> std::shared_ptr<Command> CreateRCCommand(MessageSharedPtr& msg) { InitCommand(kDefaultTimeout_); - return std::make_shared<Command>(msg ? msg : msg = CreateMessage(), - app_mngr_, - mock_rpc_service_, - mock_hmi_capabilities_, - mock_policy_handler_, - mock_allocation_manager_); + RCCommandParams params{app_mngr_, + mock_rpc_service_, + mock_hmi_capabilities_, + mock_policy_handler_, + mock_allocation_manager_, + mock_interior_data_cache_, + mock_interior_data_manager_}; + return std::make_shared<Command>(msg ? msg : msg = CreateMessage(), params); } protected: @@ -163,6 +167,10 @@ class ButtonPressRequestTest mock_policy_handler_; testing::NiceMock<rc_rpc_plugin_test::MockResourceAllocationManager> mock_allocation_manager_; + testing::NiceMock<rc_rpc_plugin_test::MockInteriorDataCache> + mock_interior_data_cache_; + testing::NiceMock<rc_rpc_plugin_test::MockInteriorDataManager> + mock_interior_data_manager_; }; TEST_F(ButtonPressRequestTest, diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/get_interior_vehicle_data_request_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/get_interior_vehicle_data_request_test.cc index a6f0ee12ca..0b30bbf654 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/get_interior_vehicle_data_request_test.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/get_interior_vehicle_data_request_test.cc @@ -35,11 +35,17 @@ #include "application_manager/mock_application.h" #include "rc_rpc_plugin/rc_app_extension.h" #include "rc_rpc_plugin/rc_module_constants.h" +#include "rc_rpc_plugin/rc_rpc_plugin.h" #include "application_manager/message_helper.h" #include "rc_rpc_plugin/rc_command_factory.h" #include "application_manager/event_engine/event_dispatcher.h" #include "application_manager/commands/command_request_test.h" #include "rc_rpc_plugin/mock/mock_resource_allocation_manager.h" +#include "rc_rpc_plugin/mock/mock_interior_data_cache.h" +#include "rc_rpc_plugin/mock/mock_interior_data_manager.h" + +#include <thread> +#include <chrono> using ::testing::_; using ::testing::Mock; @@ -50,6 +56,7 @@ using ::testing::ReturnRef; using ::testing::SaveArg; using ::application_manager::Message; using ::application_manager::MessageType; +using application_manager::ApplicationSet; using application_manager::commands::MessageSharedPtr; using ::application_manager::ApplicationSharedPtr; using ::protocol_handler::MessagePriority; @@ -64,7 +71,11 @@ using test::components::commands_test::MobileResultCodeIs; namespace { const int32_t kConnectionKey = 5u; const uint32_t kAppId = 0u; +const uint32_t kAppId2 = 1u; const int kModuleId = 153u; +const auto module_type = mobile_apis::ModuleType::RADIO; +const int32_t time_frame_of_allowed_requests = 1; +const uint32_t max_request_in_time_frame = 5u; } namespace rc_rpc_plugin_test { @@ -75,163 +86,508 @@ class GetInteriorVehicleDataRequestTest public: GetInteriorVehicleDataRequestTest() : mock_app_(std::make_shared<NiceMock<MockApplication> >()) - , rc_app_extention_(std::make_shared<RCAppExtension>(kModuleId)) { + , mock_app2_(std::make_shared<NiceMock<MockApplication> >()) + , rc_app_extention_(std::make_shared<RCAppExtension>(kModuleId)) + , rc_app_extention2_(std::make_shared<RCAppExtension>(kModuleId)) + , apps_lock_(std::make_shared<sync_primitives::Lock>()) + , apps_da_(apps_, apps_lock_) { ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kAppId)); + ON_CALL(*mock_app2_, app_id()).WillByDefault(Return(kAppId2)); + ON_CALL(*mock_app_, is_remote_control_supported()) + .WillByDefault(Return(true)); + ON_CALL(*mock_app2_, is_remote_control_supported()) + .WillByDefault(Return(true)); + ON_CALL(*mock_app_, QueryInterface(_)) + .WillByDefault(Return(rc_app_extention_)); + ON_CALL(*mock_app2_, QueryInterface(_)) + .WillByDefault(Return(rc_app_extention2_)); + } + + /** + * @brief CreateBasicMessage creates message for + * GetInteriorVehicleData request for app1 + * @return message shared ptr + */ + MessageSharedPtr CreateBasicMessage() { + MessageSharedPtr message = CreateMessage(); + (*message)[application_manager::strings::params] + [application_manager::strings::function_id] = + mobile_apis::FunctionID::GetInteriorVehicleDataID; + (*message)[application_manager::strings::params] + [application_manager::strings::connection_key] = kConnectionKey; + (*message)[application_manager::strings::params] + [application_manager::strings::connection_key] = kAppId; + return message; + } + + void SetUp() OVERRIDE { + std::pair<uint32_t, int32_t> frequency; + frequency.first = max_request_in_time_frame; + frequency.second = time_frame_of_allowed_requests; + ON_CALL(app_mngr_, get_settings()) + .WillByDefault(ReturnRef(app_mngr_settings_)); + ON_CALL(app_mngr_settings_, get_interior_vehicle_data_frequency()) + .WillByDefault(ReturnRef(frequency)); + ON_CALL(app_mngr_, hmi_interfaces()) .WillByDefault(ReturnRef(mock_hmi_interfaces_)); - ON_CALL( mock_hmi_interfaces_, GetInterfaceState(application_manager::HmiInterfaces::HMI_INTERFACE_RC)) .WillByDefault(Return(application_manager::HmiInterfaces:: InterfaceState::STATE_AVAILABLE)); ON_CALL(app_mngr_, application(kAppId)).WillByDefault(Return(mock_app_)); - ON_CALL(mock_allocation_manager_, GetApplicationExtention(_)) - .WillByDefault(Return(rc_app_extention_)); + ON_CALL(app_mngr_, application(kAppId2)).WillByDefault(Return(mock_app2_)); ON_CALL(app_mngr_, GetPolicyHandler()) .WillByDefault(ReturnRef(mock_policy_handler_)); ON_CALL(app_mngr_, hmi_capabilities()) .WillByDefault(ReturnRef(mock_hmi_capabilities_)); ON_CALL(mock_hmi_capabilities_, rc_capability()) - .WillByDefault(Return(&rc_capabilities_)); + .WillByDefault(Return(nullptr)); ON_CALL(mock_policy_handler_, CheckHMIType( _, mobile_apis::AppHMIType::eType::REMOTE_CONTROL, nullptr)) .WillByDefault(Return(true)); + ON_CALL(mock_policy_handler_, CheckModule(_, _)) + .WillByDefault(Return(true)); ON_CALL(mock_allocation_manager_, is_rc_enabled()) .WillByDefault(Return(true)); } - MessageSharedPtr CreateBasicMessage() { - MessageSharedPtr message = CreateMessage(); - (*message)[application_manager::strings::params] - [application_manager::strings::function_id] = - mobile_apis::FunctionID::GetInteriorVehicleDataID; - (*message)[application_manager::strings::params] - [application_manager::strings::connection_key] = kConnectionKey; - (*message)[application_manager::strings::params] - [application_manager::strings::connection_key] = kAppId; - return message; - } template <class Command> std::shared_ptr<Command> CreateRCCommand(MessageSharedPtr& msg) { InitCommand(kDefaultTimeout_); - return std::make_shared<Command>(msg ? msg : msg = CreateMessage(), - app_mngr_, - mock_rpc_service_, - mock_hmi_capabilities_, - mock_policy_handler_, - mock_allocation_manager_); + RCCommandParams params{app_mngr_, + mock_rpc_service_, + mock_hmi_capabilities_, + mock_policy_handler_, + mock_allocation_manager_, + mock_interior_data_cache_, + mock_interior_data_manager_}; + return std::make_shared<Command>(msg ? msg : msg = CreateMessage(), params); } protected: - smart_objects::SmartObject rc_capabilities_; std::shared_ptr<MockApplication> mock_app_; + std::shared_ptr<MockApplication> mock_app2_; std::shared_ptr<RCAppExtension> rc_app_extention_; + std::shared_ptr<RCAppExtension> rc_app_extention2_; testing::NiceMock<rc_rpc_plugin_test::MockResourceAllocationManager> mock_allocation_manager_; + testing::NiceMock<rc_rpc_plugin_test::MockInteriorDataCache> + mock_interior_data_cache_; + testing::NiceMock<rc_rpc_plugin_test::MockInteriorDataManager> + mock_interior_data_manager_; + application_manager::ApplicationSet apps_; + const std::shared_ptr<sync_primitives::Lock> apps_lock_; + DataAccessor<application_manager::ApplicationSet> apps_da_; }; + TEST_F(GetInteriorVehicleDataRequestTest, - Execute_MessageValidationOk_ExpectCorrectMessageSentToHMI) { + Execute_ExpectCorrectMessageSentToHMI_NoSubscriptionNoCache) { // Arrange - ON_CALL(mock_policy_handler_, CheckModule(_, _)).WillByDefault(Return(true)); - EXPECT_CALL(mock_hmi_capabilities_, rc_capability()) - .WillOnce(Return(nullptr)); + MessageSharedPtr mobile_message = CreateBasicMessage(); + (*mobile_message)[application_manager::strings::msg_params] + [message_params::kModuleType] = module_type; + ON_CALL(mock_interior_data_cache_, Contains(enums_value::kRadio)) + .WillByDefault(Return(false)); + ON_CALL(mock_interior_data_manager_, CheckRequestsToHMIFrequency(_)) + .WillByDefault(Return(true)); + std::shared_ptr< + rc_rpc_plugin::commands::GetInteriorVehicleDataRequest> command = + CreateRCCommand<rc_rpc_plugin::commands::GetInteriorVehicleDataRequest>( + mobile_message); + + // Expectations EXPECT_CALL(mock_rpc_service_, ManageHMICommand(HMIResultCodeIs( hmi_apis::FunctionID::RC_GetInteriorVehicleData))) .WillOnce(Return(true)); + // Act + command->Run(); +} + +TEST_F(GetInteriorVehicleDataRequestTest, + Execute_ExpectCorrectMessageSentToHMI_SupscribeAppNoCache) { + // Arrange MessageSharedPtr mobile_message = CreateBasicMessage(); + (*mobile_message)[application_manager::strings::msg_params] + [message_params::kModuleType] = module_type; + (*mobile_message)[application_manager::strings::msg_params] + [message_params::kSubscribe] = true; + ON_CALL(mock_interior_data_cache_, Contains(enums_value::kRadio)) + .WillByDefault(Return(false)); + ON_CALL(mock_interior_data_manager_, CheckRequestsToHMIFrequency(_)) + .WillByDefault(Return(true)); std::shared_ptr< rc_rpc_plugin::commands::GetInteriorVehicleDataRequest> command = CreateRCCommand<rc_rpc_plugin::commands::GetInteriorVehicleDataRequest>( mobile_message); + + // Expectations + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs( + hmi_apis::FunctionID::RC_GetInteriorVehicleData))) + .WillOnce(Return(true)); + // Act command->Run(); } TEST_F( GetInteriorVehicleDataRequestTest, - Execute_MessageValidationFailed_ExpectMessageNotSentToHMI_AndFalseSentToMobile) { + Execute_ExpectMessageNotSentToHMI_SuccessSentToMobile_AppSubscribed_DataFromCache) { // Arrange + rc_app_extention_->SubscribeToInteriorVehicleData(enums_value::kRadio); MessageSharedPtr mobile_message = CreateBasicMessage(); - NsSmartDeviceLink::NsSmartObjects::SmartObject& msg_params = - (*mobile_message)[application_manager::strings::msg_params]; - msg_params[message_params::kModuleType] = mobile_apis::ModuleType::RADIO; - ON_CALL(mock_policy_handler_, CheckModule(_, _)).WillByDefault(Return(true)); - MessageSharedPtr command_result; - EXPECT_CALL(mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs( - hmi_apis::FunctionID::RC_GetInteriorVehicleData))).Times(0); - EXPECT_CALL( - mock_rpc_service_, - ManageMobileCommand( - MobileResultCodeIs(mobile_apis::Result::UNSUPPORTED_RESOURCE), _)) - .WillOnce(DoAll(SaveArg<0>(&command_result), Return(true))); + (*mobile_message)[application_manager::strings::msg_params] + [message_params::kModuleType] = module_type; + smart_objects::SmartObject radio_data; + radio_data[message_params::kBand] = enums_value::kAM; std::shared_ptr< rc_rpc_plugin::commands::GetInteriorVehicleDataRequest> command = CreateRCCommand<rc_rpc_plugin::commands::GetInteriorVehicleDataRequest>( mobile_message); + + // Expectations + EXPECT_CALL(mock_interior_data_cache_, Contains(enums_value::kRadio)) + .WillOnce(Return(true)); + EXPECT_CALL(mock_interior_data_cache_, Retrieve(enums_value::kRadio)) + .WillOnce(Return(radio_data)); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).Times(0); + MessageSharedPtr command_result; + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::SUCCESS), _)) + .WillOnce(DoAll(SaveArg<0>(&command_result), Return(true))); + + // Act command->Run(); + + // Assert + EXPECT_EQ((*command_result)[application_manager::strings::msg_params] + [message_params::kModuleData] + [message_params::kRadioControlData], + radio_data); } -TEST_F(GetInteriorVehicleDataRequestTest, - OnEvent_ValidHmiResponse_ExpectSuccessfullResponseSentToMobile) { +TEST_F( + GetInteriorVehicleDataRequestTest, + Execute_ExpectCorrectMessageSentToHMI_LastAppSubscribedUnsubscibe_ClearCache) { // Arrange MessageSharedPtr mobile_message = CreateBasicMessage(); - NsSmartDeviceLink::NsSmartObjects::SmartObject& msg_params = - (*mobile_message)[application_manager::strings::msg_params]; - msg_params[message_params::kModuleType] = mobile_apis::ModuleType::CLIMATE; + (*mobile_message)[application_manager::strings::msg_params] + [message_params::kModuleType] = module_type; + (*mobile_message)[application_manager::strings::msg_params] + [message_params::kSubscribe] = false; - MessageSharedPtr hmi_message = CreateBasicMessage(); + MessageSharedPtr hmi_response = CreateBasicMessage(); NsSmartDeviceLink::NsSmartObjects::SmartObject& hmi_msg_params = - (*hmi_message)[application_manager::strings::msg_params]; + (*hmi_response)[application_manager::strings::msg_params]; hmi_apis::Common_Result::eType response_code = hmi_apis::Common_Result::SUCCESS; hmi_msg_params[application_manager::hmi_response::code] = response_code; hmi_msg_params[application_manager::strings::connection_key] = kConnectionKey; + apps_.insert(mock_app_); + rc_app_extention_->SubscribeToInteriorVehicleData(enums_value::kRadio); + ON_CALL(app_mngr_, applications()).WillByDefault(Return(apps_da_)); + ON_CALL(mock_interior_data_manager_, CheckRequestsToHMIFrequency(_)) + .WillByDefault(Return(true)); + + // Expectations + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs( + hmi_apis::FunctionID::RC_GetInteriorVehicleData))) + .WillOnce(Return(true)); EXPECT_CALL( mock_rpc_service_, ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::SUCCESS), _)) .WillOnce(Return(true)); + EXPECT_CALL(mock_interior_data_cache_, Remove(enums_value::kRadio)); + + // Act + std::shared_ptr< + rc_rpc_plugin::commands::GetInteriorVehicleDataRequest> command = + CreateRCCommand<rc_rpc_plugin::commands::GetInteriorVehicleDataRequest>( + mobile_message); + command->Run(); application_manager::event_engine::Event event( hmi_apis::FunctionID::RC_GetInteriorVehicleData); - event.set_smart_object(*hmi_message); + event.set_smart_object(*hmi_response); + command->on_event(event); +} + +TEST_F(GetInteriorVehicleDataRequestTest, + Execute_ExpectMessageNotSentToHMI_TwoApps_OneUnsubscribed) { + // Arrange + MessageSharedPtr mobile_message = CreateBasicMessage(); + (*mobile_message)[application_manager::strings::msg_params] + [message_params::kModuleType] = module_type; + (*mobile_message)[application_manager::strings::msg_params] + [message_params::kSubscribe] = false; + + apps_.insert(mock_app_); + apps_.insert(mock_app2_); + rc_app_extention_->SubscribeToInteriorVehicleData(enums_value::kRadio); + rc_app_extention2_->SubscribeToInteriorVehicleData(enums_value::kRadio); + + smart_objects::SmartObject radio_data; + radio_data[message_params::kBand] = enums_value::kAM; + ON_CALL(app_mngr_, applications()).WillByDefault(Return(apps_da_)); + std::shared_ptr< rc_rpc_plugin::commands::GetInteriorVehicleDataRequest> command = CreateRCCommand<rc_rpc_plugin::commands::GetInteriorVehicleDataRequest>( mobile_message); + + // Expectations + EXPECT_CALL(mock_interior_data_cache_, Contains(enums_value::kRadio)) + .WillOnce(Return(true)); + EXPECT_CALL(mock_interior_data_cache_, Retrieve(enums_value::kRadio)) + .WillOnce(Return(radio_data)); + + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).Times(0); + MessageSharedPtr command_result; + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::SUCCESS), _)) + .WillOnce(DoAll(SaveArg<0>(&command_result), Return(true))); + + // Act + command->Run(); + + // Assert + EXPECT_FALSE( + rc_app_extention_->IsSubscibedToInteriorVehicleData(enums_value::kRadio)); + EXPECT_EQ((*command_result)[application_manager::strings::msg_params] + [message_params::kModuleData] + [message_params::kRadioControlData], + radio_data); +} + +TEST_F( + GetInteriorVehicleDataRequestTest, + Execute_CapabilitiesValidationFailed_ExpectMessageNotSentToHMI_AndFalseSentToMobile) { + // Arrange + MessageSharedPtr mobile_message = CreateBasicMessage(); + NsSmartDeviceLink::NsSmartObjects::SmartObject& msg_params = + (*mobile_message)[application_manager::strings::msg_params]; + msg_params[message_params::kModuleType] = mobile_apis::ModuleType::RADIO; + std::shared_ptr< + rc_rpc_plugin::commands::GetInteriorVehicleDataRequest> command = + CreateRCCommand<rc_rpc_plugin::commands::GetInteriorVehicleDataRequest>( + mobile_message); + smart_objects::SmartObject rc_capabilities; + ON_CALL(mock_hmi_capabilities_, rc_capability()) + .WillByDefault(Return(&rc_capabilities)); + + // Expectations + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).Times(0); + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand( + MobileResultCodeIs(mobile_apis::Result::UNSUPPORTED_RESOURCE), + _)).WillOnce((Return(true))); + // Act + command->Run(); +} + +TEST_F( + GetInteriorVehicleDataRequestTest, + Execute_PolicyValidationFailed_ExpectMessageNotSentToHMI_AndFalseSentToMobile) { + // Arrange + MessageSharedPtr mobile_message = CreateBasicMessage(); + NsSmartDeviceLink::NsSmartObjects::SmartObject& msg_params = + (*mobile_message)[application_manager::strings::msg_params]; + msg_params[message_params::kModuleType] = mobile_apis::ModuleType::RADIO; + std::shared_ptr< + rc_rpc_plugin::commands::GetInteriorVehicleDataRequest> command = + CreateRCCommand<rc_rpc_plugin::commands::GetInteriorVehicleDataRequest>( + mobile_message); + ON_CALL(mock_policy_handler_, CheckModule(_, _)).WillByDefault(Return(false)); + + // Expectations + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).Times(0); + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand( + MobileResultCodeIs(mobile_apis::Result::DISALLOWED), _)) + .WillOnce((Return(true))); + + // Act + command->Run(); +} + +TEST_F(GetInteriorVehicleDataRequestTest, + OnEvent_ValidHmiResponse_ExpectSuccessfulResponseSentToMobile_NoCache) { + using rc_rpc_plugin::commands::GetInteriorVehicleDataRequest; + namespace hmi_response = application_manager::hmi_response; + namespace strings = application_manager::strings; + + // Arrange + MessageSharedPtr mobile_message = CreateBasicMessage(); + auto& msg_params = (*mobile_message)[strings::msg_params]; + msg_params[message_params::kModuleType] = module_type; + + MessageSharedPtr hmi_response_message = CreateBasicMessage(); + auto& hmi_response_params = (*hmi_response_message)[strings::msg_params]; + hmi_response_params[hmi_response::code] = hmi_apis::Common_Result::SUCCESS; + hmi_response_params[strings::connection_key] = kConnectionKey; + + ON_CALL(mock_interior_data_cache_, Contains(_)).WillByDefault(Return(false)); + ON_CALL(mock_interior_data_manager_, CheckRequestsToHMIFrequency(_)) + .WillByDefault(Return(true)); + + // Expectations + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::SUCCESS), _)) + .WillOnce(Return(true)); + + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs( + hmi_apis::FunctionID::RC_GetInteriorVehicleData))) + .WillOnce(Return(true)); + + // Act + auto command = CreateRCCommand<GetInteriorVehicleDataRequest>(mobile_message); + application_manager::event_engine::Event event( + hmi_apis::FunctionID::RC_GetInteriorVehicleData); + event.set_smart_object(*hmi_response_message); + command->Run(); command->on_event(event); } TEST_F(GetInteriorVehicleDataRequestTest, OnEvent_InvalidHmiResponse_ExpectGenericErrorResponseSentToMobile) { + using rc_rpc_plugin::commands::GetInteriorVehicleDataRequest; + namespace hmi_response = application_manager::hmi_response; + namespace strings = application_manager::strings; + // Arrange MessageSharedPtr mobile_message = CreateBasicMessage(); - NsSmartDeviceLink::NsSmartObjects::SmartObject& msg_params = + auto& msg_params = (*mobile_message)[application_manager::strings::msg_params]; - msg_params[message_params::kModuleType] = mobile_apis::ModuleType::CLIMATE; + msg_params[message_params::kModuleType] = module_type; MessageSharedPtr hmi_message = CreateBasicMessage(); + auto& hmi_msg_params = (*hmi_message)[strings::params]; + hmi_msg_params[hmi_response::code] = hmi_apis::Common_Result::READ_ONLY; + hmi_msg_params[strings::connection_key] = kConnectionKey; + ON_CALL(mock_interior_data_cache_, Contains(_)).WillByDefault(Return(false)); + ON_CALL(mock_interior_data_manager_, CheckRequestsToHMIFrequency(_)) + .WillByDefault(Return(true)); + + // Expectations + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs( + hmi_apis::FunctionID::RC_GetInteriorVehicleData))) + .WillOnce(Return(true)); + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand( + MobileResultCodeIs(mobile_apis::Result::GENERIC_ERROR), _)) + .WillOnce(Return(true)); + + // Act + application_manager::event_engine::Event event( + hmi_apis::FunctionID::RC_GetInteriorVehicleData); + event.set_smart_object(*hmi_message); + auto command = CreateRCCommand<GetInteriorVehicleDataRequest>(mobile_message); + command->Run(); + command->on_event(event); +} + +TEST_F(GetInteriorVehicleDataRequestTest, + OnEvent_InvalidHmiResponse_DontUnsubscibeLastApp_NoClearCache) { + // Arrange + MessageSharedPtr mobile_message = CreateBasicMessage(); + (*mobile_message)[application_manager::strings::msg_params] + [message_params::kModuleType] = module_type; + (*mobile_message)[application_manager::strings::msg_params] + [message_params::kSubscribe] = false; + + MessageSharedPtr hmi_response = CreateBasicMessage(); NsSmartDeviceLink::NsSmartObjects::SmartObject& hmi_msg_params = - (*hmi_message)[application_manager::strings::params]; - hmi_apis::Common_Result::eType response_code = + (*hmi_response)[application_manager::strings::params]; + hmi_msg_params[application_manager::hmi_response::code] = hmi_apis::Common_Result::READ_ONLY; - hmi_msg_params[application_manager::hmi_response::code] = response_code; hmi_msg_params[application_manager::strings::connection_key] = kConnectionKey; + + apps_.insert(mock_app_); + rc_app_extention_->SubscribeToInteriorVehicleData(enums_value::kRadio); + ON_CALL(app_mngr_, applications()).WillByDefault(Return(apps_da_)); + ON_CALL(mock_interior_data_manager_, CheckRequestsToHMIFrequency(_)) + .WillByDefault(Return(true)); + + // Expectations + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs( + hmi_apis::FunctionID::RC_GetInteriorVehicleData))) + .WillOnce(Return(true)); EXPECT_CALL(mock_rpc_service_, ManageMobileCommand( MobileResultCodeIs(mobile_apis::Result::GENERIC_ERROR), _)) - .WillOnce(Return(false)); + .WillOnce(Return(true)); + EXPECT_CALL(mock_interior_data_cache_, Clear()).Times(0); + + // Act + std::shared_ptr< + rc_rpc_plugin::commands::GetInteriorVehicleDataRequest> command = + CreateRCCommand<rc_rpc_plugin::commands::GetInteriorVehicleDataRequest>( + mobile_message); + command->Run(); application_manager::event_engine::Event event( hmi_apis::FunctionID::RC_GetInteriorVehicleData); - event.set_smart_object(*hmi_message); + event.set_smart_object(*hmi_response); + command->on_event(event); + + // Assert + EXPECT_TRUE( + rc_app_extention_->IsSubscibedToInteriorVehicleData(enums_value::kRadio)); +} + +TEST_F(GetInteriorVehicleDataRequestTest, + Execute_ExpectRejectDuToRequestLimitation_NoCahce) { + // Arrange + rc_app_extention_->UnsubscribeFromInteriorVehicleData(enums_value::kRadio); + MessageSharedPtr mobile_message = CreateBasicMessage(); + (*mobile_message)[application_manager::strings::msg_params] + [message_params::kModuleType] = module_type; + smart_objects::SmartObject radio_data; + radio_data[message_params::kBand] = enums_value::kAM; std::shared_ptr< rc_rpc_plugin::commands::GetInteriorVehicleDataRequest> command = CreateRCCommand<rc_rpc_plugin::commands::GetInteriorVehicleDataRequest>( mobile_message); - command->on_event(event); + size_t i = 0; + for (; i <= max_request_in_time_frame; ++i) { + // Expectations + EXPECT_CALL(mock_interior_data_manager_, + CheckRequestsToHMIFrequency(enums_value::kRadio)) + .WillOnce(Return(true)); + EXPECT_CALL(mock_interior_data_manager_, + StoreRequestToHMITime(enums_value::kRadio)); + EXPECT_CALL(mock_interior_data_cache_, Contains(enums_value::kRadio)) + .WillRepeatedly(Return(false)); + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs( + hmi_apis::FunctionID::RC_GetInteriorVehicleData))) + .WillRepeatedly(Return(true)); + // Act + command->Run(); + } + + // Expectations + EXPECT_CALL(mock_interior_data_manager_, + CheckRequestsToHMIFrequency(enums_value::kRadio)) + .WillOnce(Return(false)); + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(MobileResultCodeIs(mobile_apis::Result::REJECTED), _)) + .WillOnce(Return(false)); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).Times(0); + + // Act + command->Run(); } } // namespace rc_rpc_plugin_test diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/on_interior_vehicle_data_notification_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/on_interior_vehicle_data_notification_test.cc index df11bf8c88..b344471254 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/on_interior_vehicle_data_notification_test.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/on_interior_vehicle_data_notification_test.cc @@ -37,6 +37,8 @@ #include "rc_rpc_plugin/rc_rpc_plugin.h" #include "rc_rpc_plugin/rc_module_constants.h" #include "rc_rpc_plugin/mock/mock_resource_allocation_manager.h" +#include "rc_rpc_plugin/mock/mock_interior_data_cache.h" +#include "rc_rpc_plugin/mock/mock_interior_data_manager.h" #include "gtest/gtest.h" #include "interfaces/MOBILE_API.h" @@ -56,6 +58,7 @@ namespace { const uint32_t kAppId = 0u; const uint32_t kConnectionKey = 1u; const std::string kPolicyAppId = "Test"; +const int kModuleId = 153u; } namespace rc_rpc_plugin_test { @@ -66,62 +69,72 @@ class OnInteriorVehicleDataNotificationTest : public CommandsTest<CommandsTestMocks::kIsNice> { public: OnInteriorVehicleDataNotificationTest() - : mock_app_(std::make_shared<NiceMock<MockApplication> >()) {} + : mock_app_(std::make_shared<NiceMock<MockApplication> >()) + , rc_app_extention_(std::make_shared<RCAppExtension>(kModuleId)) + , apps_lock_(std::make_shared<sync_primitives::Lock>()) + , apps_da_(apps_, apps_lock_) { + ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kAppId)); + ON_CALL(*mock_app_, is_remote_control_supported()) + .WillByDefault(Return(true)); + ON_CALL(*mock_app_, QueryInterface(_)) + .WillByDefault(Return(rc_app_extention_)); + } MessageSharedPtr CreateBasicMessage() { MessageSharedPtr message = CreateMessage(); (*message)[application_manager::strings::params] [application_manager::strings::function_id] = - mobile_apis::FunctionID::SetInteriorVehicleDataID; + mobile_apis::FunctionID::OnInteriorVehicleDataID; (*message)[application_manager::strings::params] [application_manager::strings::connection_key] = kConnectionKey; (*message)[application_manager::strings::params] - [application_manager::strings::connection_key] = kAppId; + [application_manager::strings::app_id] = kAppId; smart_objects::SmartObject& msg_param = (*message)[application_manager::strings::msg_params]; - msg_param[message_params::kModuleType] = mobile_apis::ModuleType::CLIMATE; - + msg_param[message_params::kModuleData][message_params::kModuleType] = + mobile_apis::ModuleType::CLIMATE; return message; } template <class Command> std::shared_ptr<Command> CreateRCCommand(MessageSharedPtr& msg) { InitCommand(kDefaultTimeout_); - return std::make_shared<Command>(msg ? msg : msg = CreateMessage(), - app_mngr_, - mock_rpc_service_, - mock_hmi_capabilities_, - mock_policy_handler_, - mock_allocation_manager_); + RCCommandParams params{app_mngr_, + mock_rpc_service_, + mock_hmi_capabilities_, + mock_policy_handler_, + mock_allocation_manager_, + mock_interior_data_cache_, + mock_interior_data_manager_}; + return ::std::make_shared<Command>(msg ? msg : msg = CreateMessage(), + params); } protected: std::shared_ptr<MockApplication> mock_app_; + std::shared_ptr<RCAppExtension> rc_app_extention_; testing::NiceMock<rc_rpc_plugin_test::MockResourceAllocationManager> mock_allocation_manager_; + testing::NiceMock<rc_rpc_plugin_test::MockInteriorDataCache> + mock_interior_data_cache_; + testing::NiceMock<rc_rpc_plugin_test::MockInteriorDataManager> + mock_interior_data_manager_; + application_manager::ApplicationSet apps_; + const std::shared_ptr<sync_primitives::Lock> apps_lock_; + DataAccessor<application_manager::ApplicationSet> apps_da_; }; TEST_F(OnInteriorVehicleDataNotificationTest, Run_SendMessageToMobile_Notification) { // Arrange MessageSharedPtr mobile_message = CreateBasicMessage(); - ApplicationSet app_set = {mock_app_}; - MessageSharedPtr message; - std::shared_ptr<sync_primitives::Lock> apps_lock = - std::make_shared<sync_primitives::Lock>(); - DataAccessor<ApplicationSet> accessor(app_set, apps_lock); - // Expectations - EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(accessor)); - - RCAppExtensionPtr rc_extention_ptr = - std::make_shared<RCAppExtension>(application_manager::AppExtensionUID( - rc_rpc_plugin::RCRPCPlugin::kRCPluginID)); - rc_extention_ptr->SubscribeToInteriorVehicleData(enums_value::kClimate); - ON_CALL(*mock_app_, QueryInterface(_)) - .WillByDefault(Return(rc_extention_ptr)); - ON_CALL(*mock_app_, is_remote_control_supported()) - .WillByDefault(Return(true)); + apps_.insert(mock_app_); + rc_app_extention_->SubscribeToInteriorVehicleData(enums_value::kClimate); + ON_CALL(app_mngr_, applications()).WillByDefault(Return(apps_da_)); + // Expectations + EXPECT_CALL(mock_interior_data_cache_, Add(enums_value::kClimate, _)); + MessageSharedPtr message; EXPECT_CALL(mock_rpc_service_, SendMessageToMobile(_, false)) .WillOnce(SaveArg<0>(&message)); // Act @@ -130,8 +143,9 @@ TEST_F(OnInteriorVehicleDataNotificationTest, rc_rpc_plugin::commands::OnInteriorVehicleDataNotification>( mobile_message); command->Run(); + // Assertions - ASSERT_TRUE((bool)message); + ASSERT_TRUE(message.get()); Mock::VerifyAndClearExpectations(&app_mngr_); } diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/on_remote_control_settings_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/on_remote_control_settings_test.cc index 9054ce4830..b95725e0b4 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, @@ -131,22 +139,8 @@ TEST_F(RCOnRemoteControlSettingsNotificationTest, (*mobile_message)[application_manager::strings::msg_params] [message_params::kAllowed] = false; - ApplicationSet app_set = {mock_app_}; - - 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)); - EXPECT_CALL(mock_allocation_manager_, ResetAllAllocations()); + EXPECT_CALL(mock_interior_data_manager_, OnDisablingRC()); // Act std::shared_ptr< 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/sdl_rpc_plugin/src/commands/hmi/ui_set_icon_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_interior_data_cache.h index 44049338a8..45465f96b0 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/ui_set_icon_request.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_interior_data_cache.h @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2018, Ford Motor Company * All rights reserved. * @@ -30,33 +30,25 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "sdl_rpc_plugin/commands/hmi/ui_set_icon_request.h" +#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_ -namespace sdl_rpc_plugin { -using namespace application_manager; +#include <string> +#include "gmock/gmock.h" +#include "rc_rpc_plugin/interior_data_cache.h" -namespace commands { +namespace rc_rpc_plugin_test { -UISetIconRequest::UISetIconRequest( - const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - rpc_service::RPCService& rpc_service, - HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handle) - : RequestToHMI(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handle) {} +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()); +}; -UISetIconRequest::~UISetIconRequest() {} +} // namespace rc_rpc_plugin_test -void UISetIconRequest::Run() { - LOG4CXX_AUTO_TRACE(logger_); - - SendRequest(); -} - -} // namespace commands - -} // namespace application_manager +#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/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_icon_request.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_interior_data_manager.h index 84c275ec5a..fc19c6a889 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/ui_set_icon_request.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_interior_data_manager.h @@ -30,48 +30,26 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SET_ICON_REQUEST_H_ -#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SET_ICON_REQUEST_H_ +#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 "application_manager/commands/request_to_hmi.h" +#include <string> +#include "gmock/gmock.h" +#include "rc_rpc_plugin/interior_data_manager.h" +namespace rc_rpc_plugin_test { -namespace sdl_rpc_plugin { -namespace app_mngr = application_manager; - -namespace commands { - -/** - * @brief UISetIconRequest command class - **/ -class UISetIconRequest : public app_mngr::commands::RequestToHMI { +class MockInteriorDataManager : public rc_rpc_plugin::InteriorDataManager { public: - /** - * @brief UISetIconRequest class constructor - * - * @param message Incoming SmartObject message - **/ - UISetIconRequest(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); - - /** - * @brief UISetIconRequest class destructor - **/ - virtual ~UISetIconRequest(); - - /** - * @brief Execute command - **/ - virtual void Run(); - - private: - DISALLOW_COPY_AND_ASSIGN(UISetIconRequest); + 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 commands - -} // namespace application_manager +} // namespace rc_rpc_plugin_test -#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UI_SET_ICON_REQUEST_H_ +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_TEST_INCLUDE_RC_RPC_PLUGIN_MOCK_MOCK_INTERIOR_DATA_MANAGER_H_ diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_resource_allocation_manager.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_resource_allocation_manager.h index d74e8fcb65..72ace1432a 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_resource_allocation_manager.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_resource_allocation_manager.h @@ -30,8 +30,8 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef SRC_COMPONENTS_REMOTE_CONTROL_TEST_INCLUDE_MOCK_RESOURCE_ALLOCATION_MANAGER_H_ -#define SRC_COMPONENTS_REMOTE_CONTROL_TEST_INCLUDE_MOCK_RESOURCE_ALLOCATION_MANAGER_H_ +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_TEST_INCLUDE_RC_RPC_PLUGIN_MOCK_MOCK_RESOURCE_ALLOCATION_MANAGER_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_TEST_INCLUDE_RC_RPC_PLUGIN_MOCK_MOCK_RESOURCE_ALLOCATION_MANAGER_H_ #include "gmock/gmock.h" #include "application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager.h" @@ -61,9 +61,6 @@ class MockResourceAllocationManager const uint32_t app_id, const rc_rpc_plugin::ResourceState::eType state)); MOCK_CONST_METHOD1(IsResourceFree, bool(const std::string& module_type)); - MOCK_METHOD1(GetApplicationExtention, - rc_rpc_plugin::RCAppExtensionPtr( - application_manager::ApplicationSharedPtr application)); MOCK_METHOD0(ResetAllAllocations, void()); MOCK_METHOD2(SendOnRCStatusNotifications, void(rc_rpc_plugin::NotificationTrigger::eType, @@ -74,4 +71,4 @@ class MockResourceAllocationManager } // namespace rc_rpc_plugin_test -#endif // SRC_COMPONENTS_REMOTE_CONTROL_TEST_INCLUDE_MOCK_RESOURCE_ALLOCATION_MANAGER_H_ +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_TEST_INCLUDE_RC_RPC_PLUGIN_MOCK_MOCK_RESOURCE_ALLOCATION_MANAGER_H_ diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/interior_data_cache_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/interior_data_cache_test.cc new file mode 100644 index 0000000000..e6922a4c83 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/interior_data_cache_test.cc @@ -0,0 +1,160 @@ +/* + * Copyright (c) 2018, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. */ + +#include "gtest/gtest.h" +#include "rc_rpc_plugin/interior_data_cache_impl.h" + +namespace rc_rpc_plugin_test { + +class InteriorDataCacheTest : public ::testing::Test {}; + +namespace { +const uint32_t time_frame_alowed_requests = 1; +} // namespace + +TEST_F(InteriorDataCacheTest, + InteriorDataCacheDoesNotContainRandomDataInitialy) { + rc_rpc_plugin::InteriorDataCacheImpl cache; + std::string module_type_key = "random_module_type"; + EXPECT_FALSE(cache.Contains(module_type_key)); + auto retrieved_data = cache.Retrieve(module_type_key); + EXPECT_EQ(smart_objects::SmartType_Null, retrieved_data.getType()); +} + +TEST_F(InteriorDataCacheTest, CheckThatCacheContansDataAfterAdding) { + rc_rpc_plugin::InteriorDataCacheImpl cache; + const std::string module_type_key = "random_module_type"; + smart_objects::SmartObject data; + data["key"] = "value"; + + cache.Add(module_type_key, data); + EXPECT_TRUE(cache.Contains(module_type_key)); + auto retrieved_data = cache.Retrieve(module_type_key); + EXPECT_EQ(data, retrieved_data); +} + +TEST_F(InteriorDataCacheTest, DataDoesNotExistAfterClear) { + rc_rpc_plugin::InteriorDataCacheImpl cache; + const std::string module_type_key = "random_module_type"; + smart_objects::SmartObject data; + data["key"] = "value"; + + cache.Add(module_type_key, data); + EXPECT_TRUE(cache.Contains(module_type_key)); + auto Retrieved_data = cache.Retrieve(module_type_key); + EXPECT_EQ(Retrieved_data, data); + cache.Clear(); + auto Retrieved_data_after_clear = cache.Retrieve(module_type_key); + EXPECT_EQ(smart_objects::SmartType_Null, + Retrieved_data_after_clear.getType()); +} + +TEST_F(InteriorDataCacheTest, MultipleDataCached) { + rc_rpc_plugin::InteriorDataCacheImpl cache; + + const std::string module_type_key1 = "random_module_type"; + smart_objects::SmartObject data1; + data1["key"] = "value1"; + cache.Add(module_type_key1, data1); + EXPECT_TRUE(cache.Contains(module_type_key1)); + auto retrieved_data1 = cache.Retrieve(module_type_key1); + EXPECT_EQ(data1, retrieved_data1); + + std::string module_type_key2 = "random_module_type2"; + smart_objects::SmartObject data2; + data2["key"] = "value2"; + cache.Add(module_type_key2, data2); + EXPECT_TRUE(cache.Contains(module_type_key2)); + auto retrieved_data2 = cache.Retrieve(module_type_key2); + EXPECT_EQ(retrieved_data2, data2); + + ASSERT_TRUE(data1 != data2); + EXPECT_TRUE(data2 != retrieved_data1); + EXPECT_TRUE(data1 != retrieved_data2); +} + +TEST_F(InteriorDataCacheTest, RemoveFromChacheSuccessful) { + rc_rpc_plugin::InteriorDataCacheImpl cache; + + const std::string module_type = "random_module_type"; + smart_objects::SmartObject data; + data["key"] = "value1"; + cache.Add(module_type, data); + EXPECT_TRUE(cache.Contains(module_type)); + auto retrieved_data1 = cache.Retrieve(module_type); + EXPECT_EQ(data, retrieved_data1); + + cache.Remove(module_type); + EXPECT_FALSE(cache.Contains(module_type)); + auto retreived = cache.Retrieve(module_type); + EXPECT_EQ(smart_objects::SmartType_Null, retreived.getType()); +} + +TEST_F(InteriorDataCacheTest, RemoveNotExistingNoSideEffects) { + rc_rpc_plugin::InteriorDataCacheImpl cache; + const std::string module_type_key = "random_module_type"; + smart_objects::SmartObject data; + data["key"] = "value"; + + cache.Add(module_type_key, data); + cache.Remove("some other module_type"); + + EXPECT_TRUE(cache.Contains(module_type_key)); + auto retrieved_data = cache.Retrieve(module_type_key); + EXPECT_EQ(data, retrieved_data); +} + +TEST_F(InteriorDataCacheTest, Exist2ModuleTypesRemoveOneAnotherOneLeft) { + rc_rpc_plugin::InteriorDataCacheImpl cache; + + const std::string module_type_key1 = "random_module_type"; + smart_objects::SmartObject data1; + data1["key"] = "value1"; + cache.Add(module_type_key1, data1); + + std::string module_type_key2 = "random_module_type2"; + smart_objects::SmartObject data2; + data2["key"] = "value2"; + cache.Add(module_type_key2, data2); + + ASSERT_TRUE(data1 != data2); + + cache.Remove(module_type_key1); + EXPECT_FALSE(cache.Contains(module_type_key1)); + EXPECT_TRUE(cache.Contains(module_type_key2)); + + auto retrieved_data1 = cache.Retrieve(module_type_key1); + EXPECT_EQ(smart_objects::SmartType_Null, retrieved_data1.getType()); + auto retrieved_data2 = cache.Retrieve(module_type_key2); + EXPECT_EQ(data2, retrieved_data2); +} + +} // rc_rpc_plugin_test diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/resource_allocation_manager_impl_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/resource_allocation_manager_impl_test.cc index 4e2e4d7895..86c58b9d46 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/resource_allocation_manager_impl_test.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/resource_allocation_manager_impl_test.cc @@ -71,7 +71,7 @@ const uint32_t kAppId1 = 11u; const uint32_t kHMIAppId1 = 1u; const uint32_t kAppId2 = 22u; const std::string policy_app_id_1_ = "policy_id_1"; -const uint32_t kSizeOfModules = 3u; +const uint32_t kSizeOfModules = 6u; } namespace rc_rpc_plugin_test { @@ -298,13 +298,6 @@ TEST_F(RAManagerTest, AnotherAppExit_NoReleaseResource) { EXPECT_CALL(mock_app_mngr_, application(kAppId2)) .WillRepeatedly(Return(mock_app_2_)); - RCAppExtensionPtr rc_extention_ptr = - std::make_shared<RCAppExtension>(application_manager::AppExtensionUID( - rc_rpc_plugin::RCRPCPlugin::kRCPluginID)); - - EXPECT_CALL(*mock_app_2_, QueryInterface(_)) - .WillOnce(Return(rc_extention_ptr)); - // Act application_manager::ApplicationSharedPtr app_ptr(mock_app_2_); EXPECT_CALL(*mock_app_2_, app_id()).WillRepeatedly(Return(kAppId2)); @@ -358,13 +351,6 @@ TEST_F(RAManagerTest, AnotherAppUnregistered_NoReleaseResource) { EXPECT_CALL(mock_app_mngr_, application(kAppId1)) .WillRepeatedly(Return(mock_app_2_)); - RCAppExtensionPtr rc_extention_ptr = - std::make_shared<RCAppExtension>(application_manager::AppExtensionUID( - rc_rpc_plugin::RCRPCPlugin::kRCPluginID)); - - EXPECT_CALL(*mock_app_2_, QueryInterface(_)) - .WillOnce(Return(rc_extention_ptr)); - // Act application_manager::ApplicationSharedPtr app_ptr(mock_app_2_); EXPECT_CALL(*mock_app_2_, app_id()).WillRepeatedly(Return(kAppId2)); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_unsubscribe_way_points_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_unsubscribe_way_points_request.h index 6061858e5c..f20386a246 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_unsubscribe_way_points_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_unsubscribe_way_points_request.h @@ -43,31 +43,31 @@ namespace commands { /** * @brief NaviSubscribeWayPointsRequest command class **/ -class NaviUnSubscribeWayPointsRequest +class NaviUnsubscribeWayPointsRequest : public app_mngr::commands::RequestToHMI { public: /** - * @brief NaviUnSubscribeWayPointsRequest class constructor + * @brief NaviUnsubscribeWayPointsRequest class constructor * * @param message Incoming SmartObject message **/ - NaviUnSubscribeWayPointsRequest( + NaviUnsubscribeWayPointsRequest( 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); /** - * @brief NaviUnSubscribeWayPointsRequest class destructor + * @brief NaviUnsubscribeWayPointsRequest class destructor **/ - virtual ~NaviUnSubscribeWayPointsRequest(); + virtual ~NaviUnsubscribeWayPointsRequest(); /** * @brief Execute command **/ virtual void Run() OVERRIDE; private: - DISALLOW_COPY_AND_ASSIGN(NaviUnSubscribeWayPointsRequest); + DISALLOW_COPY_AND_ASSIGN(NaviUnsubscribeWayPointsRequest); }; } // namespace commands diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_unsubscribe_way_points_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_unsubscribe_way_points_response.h index 3a02228b8b..ec4f4eb963 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_unsubscribe_way_points_response.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_unsubscribe_way_points_response.h @@ -41,13 +41,13 @@ namespace app_mngr = application_manager; namespace commands { /** - * @brief NaviUnSubscribeWaypoints command class + * @brief NaviUnsubscribeWaypoints command class **/ class NaviUnsubscribeWayPointsResponse : public app_mngr::commands::ResponseFromHMI { public: /** - * @brief NaviUnSubscribeWaypoints class constructor + * @brief NaviUnsubscribeWaypoints class constructor * * @param message Incoming SmartObject message **/ @@ -59,7 +59,7 @@ class NaviUnsubscribeWayPointsResponse policy::PolicyHandlerInterface& policy_handle); /** - * @brief NaviUnSubscribeWaypoints class destructor + * @brief NaviUnsubscribeWaypoints class destructor **/ virtual ~NaviUnsubscribeWayPointsResponse(); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/create_interaction_choice_set_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/create_interaction_choice_set_request.h index 950c295072..12b075af7a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/create_interaction_choice_set_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/create_interaction_choice_set_request.h @@ -128,6 +128,7 @@ class CreateInteractionChoiceSetRequest int32_t choice_set_id_; size_t expected_chs_count_; size_t received_chs_count_; + bool should_send_warnings; /** * @brief Flag for stop sending VR commands to HMI, in case one of responses diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_audio_pass_thru_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_audio_pass_thru_request.h index 6db222a401..1a4c248a02 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_audio_pass_thru_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_audio_pass_thru_request.h @@ -109,15 +109,6 @@ class PerformAudioPassThruRequest ResponseParams response_params_; /** - * @brief Prepare result code, result and info for sending to mobile - * application - * @param result_code contains result code for sending to mobile application - * @return result for sending to mobile application. - * @deprecated - */ - DEPRECATED bool PrepareResponseParameters( - mobile_apis::Result::eType& result_code, std::string& info); - /** * @brief Prepare result code, 'success' result and info for sending * to mobile application * @param result_code contains result code for sending to mobile application diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_interaction_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_interaction_request.h index 40e706b851..2d4cbc9afc 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_interaction_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/perform_interaction_request.h @@ -213,6 +213,13 @@ class PerformInteractionRequest const smart_objects::SmartObject& choice_set_id_list) const; /** + * @brief Checks each choice in each set for having a VRcommands parameter + * @param app contains pointer to application. + * @return returns false if request has choice sets with no vrCommands + */ + bool CheckChoiceSetListVRCommands(app_mngr::ApplicationSharedPtr app); + + /** * @brief Tells if there are sent requests without responses * @return If there is request without response method returns TRUE * otherwise returns FALSE diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_request.h index 9cac2ab34f..542fdac5f8 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_request.h @@ -83,12 +83,6 @@ class RegisterAppInterfaceRequest **/ virtual void Run(); - /** - * @brief Prepares and sends RegisterAppInterface response to mobile - * considering application type - **/ - void SendRegisterAppInterfaceResponseToMobile(); - private: /** * @brief The AppicationType enum defines whether application is newly diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_icon_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_icon_request.h deleted file mode 100644 index f994f06ca3..0000000000 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_icon_request.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - - 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_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_ICON_REQUEST_H_ -#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_ICON_REQUEST_H_ - -#include "application_manager/commands/command_request_impl.h" -#include "application_manager/application_manager.h" -#include "utils/macro.h" - -namespace sdl_rpc_plugin { -namespace app_mngr = application_manager; - -namespace commands { - -/** - * @brief SetIconRequest command class - **/ -class SetIconRequest : public app_mngr::commands::CommandRequestImpl { - public: - /** - * @brief Contains information about the type of image - */ - typedef enum { STATIC = 0, DYNAMIC } ImageType; - - /** - * @brief SetIconRequest class constructor - * - * @param message Incoming SmartObject message - **/ - SetIconRequest(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); - - /** - * @brief SetIconRequest class destructor - **/ - virtual ~SetIconRequest(); - - /** - * @brief Interface method that is called whenever new event received - * - * @param event The received event - */ - void on_event(const app_mngr::event_engine::Event& event); - - /** - * @brief Execute command - **/ - virtual void Run(); - - private: - DISALLOW_COPY_AND_ASSIGN(SetIconRequest); -}; - -} // namespace commands -} // namespace application_manager - -#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_ICON_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_icon_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_icon_response.h deleted file mode 100644 index c83ea3607a..0000000000 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/set_icon_response.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - - 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_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_ICON_RESPONSE_H_ -#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_ICON_RESPONSE_H_ - -#include "application_manager/commands/command_response_impl.h" -#include "application_manager/application_manager.h" -#include "utils/macro.h" - -namespace sdl_rpc_plugin { -namespace app_mngr = application_manager; - -namespace commands { - -/** - * @brief SetIconResponse command class - **/ -class SetIconResponse : public app_mngr::commands::CommandResponseImpl { - public: - /** - * @brief SetIconResponse class constructor - * - * @param message Incoming SmartObject message - **/ - SetIconResponse(const app_mngr::commands::MessageSharedPtr& message, - app_mngr::ApplicationManager& app_man, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler); - - /** - * @brief SetIconResponse class destructor - **/ - virtual ~SetIconResponse(); - - /** - * @brief Execute command - **/ - virtual void Run(); - - private: - DISALLOW_COPY_AND_ASSIGN(SetIconResponse); -}; - -} // namespace commands -} // namespace application_manager - -#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SET_ICON_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unsubscribe_way_points_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unsubscribe_way_points_request.h index b7b87f8b51..fe14f5c7eb 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unsubscribe_way_points_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unsubscribe_way_points_request.h @@ -40,13 +40,13 @@ namespace app_mngr = application_manager; namespace commands { -class UnSubscribeWayPointsRequest +class UnsubscribeWayPointsRequest : public app_mngr::commands::CommandRequestImpl { public: /** - * \brief UnSubscribeWayPointsRequest class constructor + * \brief UnsubscribeWayPointsRequest class constructor **/ - UnSubscribeWayPointsRequest( + UnsubscribeWayPointsRequest( const app_mngr::commands::MessageSharedPtr& message, app_mngr::ApplicationManager& application_manager, app_mngr::rpc_service::RPCService& rpc_service, @@ -54,9 +54,9 @@ class UnSubscribeWayPointsRequest policy::PolicyHandlerInterface& policy_handler); /** - * \brief UnSubscribeWayPointsRequest class destructor + * \brief UnsubscribeWayPointsRequest class destructor **/ - ~UnSubscribeWayPointsRequest(); + ~UnsubscribeWayPointsRequest(); /** * @brief Execute command @@ -76,7 +76,7 @@ class UnSubscribeWayPointsRequest bool Init() FINAL; private: - DISALLOW_COPY_AND_ASSIGN(UnSubscribeWayPointsRequest); + DISALLOW_COPY_AND_ASSIGN(UnsubscribeWayPointsRequest); }; } // commands diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_unsubscribe_way_points_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_unsubscribe_way_points_request.cc index e7d416bc61..ec22c93d8f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_unsubscribe_way_points_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_unsubscribe_way_points_request.cc @@ -37,7 +37,7 @@ using namespace application_manager; namespace commands { -NaviUnSubscribeWayPointsRequest::NaviUnSubscribeWayPointsRequest( +NaviUnsubscribeWayPointsRequest::NaviUnsubscribeWayPointsRequest( const application_manager::commands::MessageSharedPtr& message, ApplicationManager& application_manager, rpc_service::RPCService& rpc_service, @@ -49,9 +49,9 @@ NaviUnSubscribeWayPointsRequest::NaviUnSubscribeWayPointsRequest( hmi_capabilities, policy_handle) {} -NaviUnSubscribeWayPointsRequest::~NaviUnSubscribeWayPointsRequest() {} +NaviUnsubscribeWayPointsRequest::~NaviUnsubscribeWayPointsRequest() {} -void NaviUnSubscribeWayPointsRequest::Run() { +void NaviUnsubscribeWayPointsRequest::Run() { LOG4CXX_AUTO_TRACE(logger_); SendRequest(); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_command_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_command_request.cc index fc836aae5f..155f819761 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_command_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_command_request.cc @@ -96,7 +96,7 @@ void AddCommandRequest::Run() { app, application_manager_); - if (mobile_apis::Result::SUCCESS != verification_result) { + if (mobile_apis::Result::INVALID_DATA == verification_result) { LOG4CXX_ERROR( logger_, "MessageHelper::VerifyImage return " << verification_result); SendResponse(false, verification_result); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_sub_menu_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_sub_menu_request.cc index 3dcc414f9e..183b445326 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_sub_menu_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_sub_menu_request.cc @@ -76,7 +76,7 @@ void AddSubMenuRequest::Run() { verification_result = MessageHelper::VerifyImage( received_msg_params[strings::menu_icon], app, application_manager_); - if (mobile_apis::Result::SUCCESS != verification_result) { + if (mobile_apis::Result::INVALID_DATA == verification_result) { LOG4CXX_ERROR( logger_, "MessageHelper::VerifyImage return " << verification_result); SendResponse(false, verification_result); @@ -117,10 +117,7 @@ void AddSubMenuRequest::Run() { msg_params[strings::menu_params][strings::menu_name] = received_msg_params[strings::menu_name]; msg_params[strings::app_id] = app->app_id(); - - if (mobile_apis::Result::SUCCESS == verification_result) { - msg_params[strings::menu_icon] = received_msg_params[strings::menu_icon]; - } + msg_params[strings::menu_icon] = received_msg_params[strings::menu_icon]; StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); SendHMIRequest(hmi_apis::FunctionID::UI_AddSubMenu, &msg_params, true); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_interaction_choice_set_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_interaction_choice_set_request.cc index d2d39dcd77..d50708c4eb 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_interaction_choice_set_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_interaction_choice_set_request.cc @@ -42,11 +42,13 @@ #include "utils/gen_hash.h" #include "utils/helpers.h" -namespace sdl_rpc_plugin { -using namespace application_manager; +const char* kInvalidImageWarningInfo = "Requested image(s) not found."; +namespace sdl_rpc_plugin { namespace commands { +using namespace application_manager; + CreateInteractionChoiceSetRequest::CreateInteractionChoiceSetRequest( const application_manager::commands::MessageSharedPtr& message, ApplicationManager& application_manager, @@ -78,6 +80,7 @@ void CreateInteractionChoiceSetRequest::Run() { SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); return; } + should_send_warnings = false; for (uint32_t i = 0; i < (*message_)[strings::msg_params][strings::choice_set].length(); ++i) { @@ -104,6 +107,10 @@ void CreateInteractionChoiceSetRequest::Run() { LOG4CXX_ERROR(logger_, "Image verification failed."); SendResponse(false, Result::INVALID_DATA); return; + } else if (verification_result_image == Result::WARNINGS || + verification_result_secondary_image == Result::WARNINGS) { + should_send_warnings = true; + break; } } @@ -123,10 +130,30 @@ void CreateInteractionChoiceSetRequest::Run() { SendResponse(false, result); return; } - uint32_t grammar_id = application_manager_.GenerateGrammarID(); - (*message_)[strings::msg_params][strings::grammar_id] = grammar_id; + auto vr_status = MessageHelper::CheckChoiceSetVRCommands( + (*message_)[strings::msg_params][strings::choice_set]); + if (vr_status == MessageHelper::ChoiceSetVRCommandsStatus::MIXED) { + // this is an error + SendResponse(false, + Result::INVALID_DATA, + "Some choices don't contain VR commands. Either all or none " + "must have voice commands."); + return; // exit now, this is a bad set + } else if (vr_status == MessageHelper::ChoiceSetVRCommandsStatus::ALL) { + // everyone had a vr command, setup the grammar + uint32_t grammar_id = application_manager_.GenerateGrammarID(); + (*message_)[strings::msg_params][strings::grammar_id] = grammar_id; + } + // continue on as usual app->AddChoiceSet(choice_set_id_, (*message_)[strings::msg_params]); - SendVRAddCommandRequests(app); + + if (vr_status == MessageHelper::ChoiceSetVRCommandsStatus::ALL) { + // we have VR commands + SendVRAddCommandRequests(app); + } else { + // we have none, just return with success + SendResponse(true, Result::SUCCESS); + } } mobile_apis::Result::eType CreateInteractionChoiceSetRequest::CheckChoiceSet( @@ -148,7 +175,7 @@ mobile_apis::Result::eType CreateInteractionChoiceSetRequest::CheckChoiceSet( (*current_choice_set_it)[strings::choice_id].asInt()); if (!ins_res.second) { LOG4CXX_ERROR(logger_, - "Choise with ID " + "Choice with ID " << (*current_choice_set_it)[strings::choice_id].asInt() << " already exists"); return mobile_apis::Result::INVALID_ID; @@ -172,12 +199,15 @@ mobile_apis::Result::eType CreateInteractionChoiceSetRequest::CheckChoiceSet( bool CreateInteractionChoiceSetRequest::compareSynonyms( const NsSmartDeviceLink::NsSmartObjects::SmartObject& choice1, const NsSmartDeviceLink::NsSmartObjects::SmartObject& choice2) { + // only compare if they both have vr commands + if (!(choice1.keyExists(strings::vr_commands) && + choice2.keyExists(strings::vr_commands))) { + return false; // clearly there isn't a duplicate if one of them is null + } smart_objects::SmartArray* vr_cmds_1 = choice1[strings::vr_commands].asArray(); - DCHECK(vr_cmds_1 != NULL); smart_objects::SmartArray* vr_cmds_2 = choice2[strings::vr_commands].asArray(); - DCHECK(vr_cmds_2 != NULL); smart_objects::SmartArray::iterator it; it = std::find_first_of(vr_cmds_1->begin(), @@ -435,7 +465,9 @@ void CreateInteractionChoiceSetRequest::DeleteChoices() { void CreateInteractionChoiceSetRequest::OnAllHMIResponsesReceived() { LOG4CXX_AUTO_TRACE(logger_); - if (!error_from_hmi_) { + if (!error_from_hmi_ && should_send_warnings) { + SendResponse(true, mobile_apis::Result::WARNINGS, kInvalidImageWarningInfo); + } else if (!error_from_hmi_) { SendResponse(true, mobile_apis::Result::SUCCESS); } else { DeleteChoices(); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_button_event_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_button_event_notification.cc index 40debbcd4d..aeb53a115e 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_button_event_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_button_event_notification.cc @@ -161,8 +161,16 @@ void OnButtonEventNotification::SendButtonEvent(ApplicationConstSharedPtr app) { (*on_btn_event)[strings::params][strings::function_id] = static_cast<int32_t>(mobile_apis::FunctionID::eType::OnButtonEventID); - (*on_btn_event)[strings::msg_params][strings::button_name] = - (*message_)[strings::msg_params][hmi_response::button_name]; + mobile_apis::ButtonName::eType btn_id = + static_cast<mobile_apis::ButtonName::eType>( + (*message_)[strings::msg_params][hmi_response::button_name].asInt()); + + if (btn_id == mobile_apis::ButtonName::PLAY_PAUSE && + app->msg_version() <= utils::version_4_5) { + btn_id = mobile_apis::ButtonName::OK; + } + + (*on_btn_event)[strings::msg_params][strings::button_name] = btn_id; (*on_btn_event)[strings::msg_params][strings::button_event_mode] = (*message_)[strings::msg_params][hmi_response::button_mode]; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_button_press_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_button_press_notification.cc index faf6ffe38b..56a87da305 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_button_press_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_button_press_notification.cc @@ -35,6 +35,7 @@ #include "application_manager/application_impl.h" #include "interfaces/MOBILE_API.h" +#include "utils/semantic_version.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -168,8 +169,16 @@ void OnButtonPressNotification::SendButtonPress(ApplicationConstSharedPtr app) { (*on_btn_press)[strings::params][strings::function_id] = static_cast<int32_t>(mobile_apis::FunctionID::eType::OnButtonPressID); - (*on_btn_press)[strings::msg_params][strings::button_name] = - (*message_)[strings::msg_params][hmi_response::button_name]; + mobile_apis::ButtonName::eType btn_id = + static_cast<mobile_apis::ButtonName::eType>( + (*message_)[strings::msg_params][hmi_response::button_name].asInt()); + + if (btn_id == mobile_apis::ButtonName::PLAY_PAUSE && + app->msg_version() <= utils::version_4_5) { + btn_id = mobile_apis::ButtonName::OK; + } + + (*on_btn_press)[strings::msg_params][strings::button_name] = btn_id; (*on_btn_press)[strings::msg_params][strings::button_press_mode] = (*message_)[strings::msg_params][hmi_response::button_mode]; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_audio_pass_thru_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_audio_pass_thru_request.cc index 86a644a778..c90038a8b7 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_audio_pass_thru_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_audio_pass_thru_request.cc @@ -250,13 +250,6 @@ PerformAudioPassThruRequest::PrepareResponseParameters() { return response_params_; } -bool PerformAudioPassThruRequest::PrepareResponseParameters( - mobile_apis::Result::eType& result_code, std::string& info) { - LOG4CXX_AUTO_TRACE(logger_); - NOTREACHED(); - return false; -} - void PerformAudioPassThruRequest::SendSpeakRequest() { LOG4CXX_AUTO_TRACE(logger_); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_interaction_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_interaction_request.cc index 8710f3c3d6..42489fd8bd 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_interaction_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_interaction_request.cc @@ -165,7 +165,7 @@ void PerformInteractionRequest::Run() { } if (msg_params.keyExists(strings::vr_help)) { - if (mobile_apis::Result::SUCCESS != + if (mobile_apis::Result::INVALID_DATA == MessageHelper::VerifyImageVrHelpItems( msg_params[strings::vr_help], app, application_manager_)) { LOG4CXX_ERROR(logger_, @@ -186,7 +186,8 @@ void PerformInteractionRequest::Run() { case mobile_apis::InteractionMode::BOTH: { LOG4CXX_DEBUG(logger_, "Interaction Mode: BOTH"); if (!CheckChoiceSetVRSynonyms(app) || !CheckChoiceSetMenuNames(app) || - !CheckVrHelpItemPositions(app)) { + !CheckVrHelpItemPositions(app) || + !CheckChoiceSetListVRCommands(app)) { return; } break; @@ -201,7 +202,8 @@ void PerformInteractionRequest::Run() { } case mobile_apis::InteractionMode::VR_ONLY: { LOG4CXX_DEBUG(logger_, "Interaction Mode: VR_ONLY"); - if (!CheckChoiceSetVRSynonyms(app) || !CheckVrHelpItemPositions(app)) { + if (!CheckChoiceSetVRSynonyms(app) || !CheckVrHelpItemPositions(app) || + !CheckChoiceSetListVRCommands(app)) { return; } break; @@ -343,27 +345,31 @@ bool PerformInteractionRequest::ProcessVRResponse( return false; } - if (Common_Result::SUCCESS == vr_result_code_ && - InteractionMode::MANUAL_ONLY == interaction_mode_) { - LOG4CXX_DEBUG(logger_, - "VR response SUCCESS in MANUAL_ONLY mode " - << "Wait for UI response"); - // in case MANUAL_ONLY mode VR.PI SUCCESS just return - return false; - } - const SmartObject& hmi_msg_params = message[strings::msg_params]; if (hmi_msg_params.keyExists(strings::choice_id)) { - const int choise_id = hmi_msg_params[strings::choice_id].asInt(); - if (!CheckChoiceIDFromResponse(app, choise_id)) { + const int choice_id = hmi_msg_params[strings::choice_id].asInt(); + if (!CheckChoiceIDFromResponse(app, choice_id)) { LOG4CXX_ERROR(logger_, "Wrong choiceID was received from HMI"); TerminatePerformInteraction(); SendResponse( false, Result::GENERIC_ERROR, "Wrong choiceID was received from HMI"); return true; } - msg_params[strings::choice_id] = choise_id; + msg_params[strings::choice_id] = choice_id; } + + const bool is_vr_result_success = Compare<Common_Result::eType, EQ, ONE>( + vr_result_code_, Common_Result::SUCCESS, Common_Result::WARNINGS); + + if (is_vr_result_success && + InteractionMode::MANUAL_ONLY == interaction_mode_) { + LOG4CXX_DEBUG(logger_, + "VR response is successfull in MANUAL_ONLY mode " + << "Wait for UI response"); + // in case MANUAL_ONLY mode VR.PI SUCCESS just return + return false; + } + return false; } @@ -401,19 +407,19 @@ void PerformInteractionRequest::ProcessUIResponse( ui_result_code_, hmi_apis::Common_Result::UNSUPPORTED_RESOURCE); if (result) { - if (is_pi_warning) { - ui_result_code_ = hmi_apis::Common_Result::WARNINGS; - ui_info_ = message[strings::msg_params][strings::info].asString(); - if (message.keyExists(strings::params) && - message[strings::params].keyExists(strings::data)) { - msg_params = message[strings::params][strings::data]; - } - } else if (is_pi_unsupported) { + if (is_pi_unsupported) { ui_result_code_ = hmi_apis::Common_Result::UNSUPPORTED_RESOURCE; ui_info_ = message[strings::msg_params][strings::info].asString(); - } else if (message.keyExists(strings::msg_params)) { - msg_params = message[strings::msg_params]; + } else { + if (message.keyExists(strings::msg_params)) { + msg_params = message[strings::msg_params]; + } + if (is_pi_warning) { + ui_result_code_ = hmi_apis::Common_Result::WARNINGS; + ui_info_ = message[strings::msg_params][strings::info].asString(); + } } + // result code must be GENERIC_ERROR in case wrong choice_id if (msg_params.keyExists(strings::choice_id)) { if (!CheckChoiceIDFromResponse(app, @@ -538,7 +544,7 @@ void PerformInteractionRequest::SendVRPerformInteractionRequest( smart_objects::SmartObject* choice_set = app->FindChoiceSet(choice_list[i].asInt()); if (!choice_set) { - LOG4CXX_WARN(logger_, "Couldn't found choiset"); + LOG4CXX_WARN(logger_, "Couldn't found choiceset"); continue; } msg_params[strings::grammar_id][grammar_id_index++] = @@ -746,6 +752,15 @@ bool PerformInteractionRequest::CheckChoiceSetVRSynonyms( size_t jj = 0; for (; ii < (*i_choice_set)[strings::choice_set].length(); ++ii) { for (; jj < (*j_choice_set)[strings::choice_set].length(); ++jj) { + if (!((*i_choice_set)[strings::choice_set][ii].keyExists( + strings::vr_commands) && + (*j_choice_set)[strings::choice_set][jj].keyExists( + strings::vr_commands))) { + LOG4CXX_DEBUG(logger_, + "One or both sets has missing vr commands, skipping " + "synonym check"); + return true; + } // choice_set pointer contains SmartObject msg_params smart_objects::SmartObject& ii_vr_commands = (*i_choice_set)[strings::choice_set][ii][strings::vr_commands]; @@ -942,6 +957,45 @@ bool PerformInteractionRequest::CheckChoiceIDFromResponse( return false; } +bool PerformInteractionRequest::CheckChoiceSetListVRCommands( + ApplicationSharedPtr app) { + LOG4CXX_AUTO_TRACE(logger_); + + const smart_objects::SmartObject& choice_set_id_list = + (*message_)[strings::msg_params][strings::interaction_choice_set_id_list]; + + smart_objects::SmartObject* choice_set = nullptr; + + for (size_t i = 0; i < choice_set_id_list.length(); ++i) { + choice_set = app->FindChoiceSet(choice_set_id_list[i].asInt()); + + // this should never ever happen since this was already checked + if (choice_set == nullptr) { + LOG4CXX_ERROR( + logger_, + "Couldn't find choiceset_id = " << choice_set_id_list[i].asInt()); + SendResponse(false, mobile_apis::Result::INVALID_ID); + return false; + } + + const smart_objects::SmartObject& choices_list = + (*choice_set)[strings::choice_set]; + auto vr_status = MessageHelper::CheckChoiceSetVRCommands(choices_list); + + // if not all choices have vr commands + if (vr_status != MessageHelper::ChoiceSetVRCommandsStatus::ALL) { + LOG4CXX_ERROR(logger_, + "PerformInteraction has choice sets with " + "missing vrCommands, not in MANUAL_ONLY mode"); + SendResponse(false, + mobile_apis::Result::INVALID_DATA, + "Some choices don't contain VR commands."); + return false; + } + } + return true; +} + bool PerformInteractionRequest::CheckChoiceIDFromRequest( ApplicationSharedPtr app, const size_t choice_set_id_list_length, @@ -958,9 +1012,10 @@ bool PerformInteractionRequest::CheckChoiceIDFromRequest( if (!choice_set) { LOG4CXX_ERROR( logger_, - "Couldn't find choiset_id = " << choice_set_id_list[i].asInt()); + "Couldn't find choiceset_id = " << choice_set_id_list[i].asInt()); return false; } + choice_list_length = (*choice_set)[strings::choice_set].length(); const smart_objects::SmartObject& choices_list = (*choice_set)[strings::choice_set]; @@ -969,7 +1024,7 @@ bool PerformInteractionRequest::CheckChoiceIDFromRequest( choice_id_set.insert(choices_list[k][strings::choice_id].asInt()); if (!ins_res.second) { LOG4CXX_ERROR(logger_, - "Choise with ID " + "choice with ID " << choices_list[k][strings::choice_id].asInt() << " already exists"); return false; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/put_file_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/put_file_request.cc index 4d1e4339f5..d5a13c99a0 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/put_file_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/put_file_request.cc @@ -212,10 +212,9 @@ void PutFileRequest::Run() { return; } const std::string full_path = file_path + "/" + sync_file_name_; - const size_t bin_data_size = binary_data.size(); if ((*message_)[strings::msg_params].keyExists(strings::crc32_check_sum)) { - LOG4CXX_TRACE(logger_, "Binary Data Size: " << bin_data_size); + LOG4CXX_TRACE(logger_, "Binary Data Size: " << binary_data.size()); const uint32_t crc_received = (*message_)[strings::msg_params][strings::crc32_check_sum].asUInt(); LOG4CXX_TRACE(logger_, "CRC32 SUM Received: " << crc_received); @@ -232,7 +231,7 @@ void PutFileRequest::Run() { } LOG4CXX_DEBUG(logger_, - "Writing " << bin_data_size << " bytes to " << full_path + "Writing " << binary_data.size() << " bytes to " << full_path << " (current size is" << file_system::FileSize(full_path) << ")"); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc index 78a92d360a..9cfd4f33b5 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc @@ -228,9 +228,6 @@ void RegisterAppInterfaceRequest::Run() { return; } - const std::string mobile_app_id = - (*message_)[strings::msg_params][strings::app_id].asString(); - ApplicationSharedPtr application = application_manager_.application(connection_key()); @@ -238,18 +235,31 @@ void RegisterAppInterfaceRequest::Run() { SendResponse(false, mobile_apis::Result::APPLICATION_REGISTERED_ALREADY); return; } + // cache the original app ID (for legacy behavior) + const std::string policy_app_id = + application_manager_.GetCorrectMobileIDFromMessage(message_); const smart_objects::SmartObject& msg_params = (*message_)[strings::msg_params]; - const std::string policy_app_id = msg_params[strings::app_id].asString(); - std::string new_policy_app_id = policy_app_id; - std::transform(policy_app_id.begin(), - policy_app_id.end(), - new_policy_app_id.begin(), + // transform app IDs to lowercase for usage in policy checks later + const std::string app_id_short = msg_params[strings::app_id].asString(); + std::string new_app_id_short = app_id_short; + std::transform(app_id_short.begin(), + app_id_short.end(), + new_app_id_short.begin(), ::tolower); - (*message_)[strings::msg_params][strings::app_id] = new_policy_app_id; - + (*message_)[strings::msg_params][strings::app_id] = new_app_id_short; + // If full ID is present, shift that to lowercase too + if (msg_params.keyExists(strings::full_app_id)) { + const std::string app_id_full = msg_params[strings::full_app_id].asString(); + std::string new_app_id_full = app_id_full; + std::transform(app_id_full.begin(), + app_id_full.end(), + new_app_id_full.begin(), + ::tolower); + (*message_)[strings::msg_params][strings::full_app_id] = new_app_id_full; + } if (application_manager_.IsApplicationForbidden(connection_key(), policy_app_id)) { SendResponse(false, mobile_apis::Result::TOO_MANY_PENDING_REQUESTS); @@ -293,12 +303,50 @@ void RegisterAppInterfaceRequest::Run() { return; } + uint16_t major = + msg_params[strings::sync_msg_version][strings::major_version].asUInt(); + uint16_t minor = + msg_params[strings::sync_msg_version][strings::minor_version].asUInt(); + uint16_t patch = 0; + // Check if patch exists since it is not mandatory. + if (msg_params[strings::sync_msg_version].keyExists(strings::patch_version)) { + patch = + msg_params[strings::sync_msg_version][strings::patch_version].asUInt(); + } + + utils::SemanticVersion mobile_version(major, minor, patch); + utils::SemanticVersion min_module_version( + minimum_major_version, minimum_minor_version, minimum_patch_version); + + if (mobile_version < min_module_version) { + LOG4CXX_WARN(logger_, + "Application RPC Version does not meet minimum requirement"); + SendResponse(false, mobile_apis::Result::REJECTED); + } + application = application_manager_.RegisterApplication(message_); if (!application) { LOG4CXX_ERROR(logger_, "Application hasn't been registered!"); return; } + + // Version negotiation + utils::SemanticVersion ver_4_5(4, 5, 0); + utils::SemanticVersion module_version( + major_version, minor_version, patch_version); + if (mobile_version <= ver_4_5) { + // Mobile versioning did not exist for + // versions 4.5 and prior. + application->set_msg_version(ver_4_5); + } else if (mobile_version < module_version) { + // Use mobile RPC version as negotiated version + application->set_msg_version(mobile_version); + } else { + // Use module version as negotiated version + application->set_msg_version(module_version); + } + // For resuming application need to restore hmi_app_id from resumeCtrl resumption::ResumeCtrl& resumer = application_manager_.resume_controller(); const std::string& device_mac = application->mac_address(); @@ -585,12 +633,14 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile( return; } + utils::SemanticVersion negotiated_version = application->msg_version(); + response_params[strings::sync_msg_version][strings::major_version] = - major_version; // From generated file interfaces/generated_msg_version.h + negotiated_version.major_version_; response_params[strings::sync_msg_version][strings::minor_version] = - minor_version; // From generated file interfaces/generated_msg_version.h + negotiated_version.minor_version_; response_params[strings::sync_msg_version][strings::patch_version] = - patch_version; // From generated file interfaces/generated_msg_version.h + negotiated_version.patch_version_; const smart_objects::SmartObject& msg_params = (*message_)[strings::msg_params]; @@ -795,11 +845,6 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile( SendChangeRegistrationOnHMI(application); } -DEPRECATED void -RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile() { - SendRegisterAppInterfaceResponseToMobile(ApplicationType::kNewApplication); -} - void RegisterAppInterfaceRequest::SendChangeRegistration( const hmi_apis::FunctionID::eType function_id, const int32_t language, @@ -1037,7 +1082,7 @@ mobile_apis::Result::eType RegisterAppInterfaceRequest::CheckWithPolicyData() { policy::StringArray app_hmi_types; const std::string mobile_app_id = - message[strings::msg_params][strings::app_id].asString(); + application_manager_.GetCorrectMobileIDFromMessage(message_); const bool init_result = GetPolicyHandler().GetInitialAppData( mobile_app_id, &app_nicknames, &app_hmi_types); @@ -1141,8 +1186,8 @@ void RegisterAppInterfaceRequest::FillDeviceInfo( bool RegisterAppInterfaceRequest::IsApplicationWithSameAppIdRegistered() { LOG4CXX_AUTO_TRACE(logger_); - const custom_string::CustomString mobile_app_id = - (*message_)[strings::msg_params][strings::app_id].asCustomString(); + const custom_string::CustomString mobile_app_id( + application_manager_.GetCorrectMobileIDFromMessage(message_)); const ApplicationSet& applications = application_manager_.applications().GetData(); @@ -1284,6 +1329,17 @@ bool RegisterAppInterfaceRequest::IsWhiteSpaceExist() { } } + if (application_manager_.get_settings().use_full_app_id()) { + if ((*message_)[strings::msg_params].keyExists(strings::full_app_id)) { + str = + (*message_)[strings::msg_params][strings::full_app_id].asCharArray(); + if (!CheckSyntax(str)) { + LOG4CXX_ERROR(logger_, "Invalid app_id syntax check failed"); + return true; + } + } + } + return false; } @@ -1316,10 +1372,8 @@ void RegisterAppInterfaceRequest::SendSubscribeCustomButtonNotification() { } bool RegisterAppInterfaceRequest::IsApplicationSwitched() { - const smart_objects::SmartObject& msg_params = - (*message_)[strings::msg_params]; - - const std::string& policy_app_id = msg_params[strings::app_id].asString(); + const std::string& policy_app_id = + application_manager_.GetCorrectMobileIDFromMessage(message_); LOG4CXX_DEBUG(logger_, "Looking for application id " << policy_app_id); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_response.cc index 73b38823d8..31eb738357 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_response.cc @@ -60,6 +60,40 @@ void RegisterAppInterfaceResponse::Run() { } } + application_manager::ApplicationSharedPtr app = + application_manager_.application(connection_key()); + + if (app && app->msg_version() <= utils::version_4_5 && + app->is_media_application() && + (*message_)[strings::msg_params].keyExists( + hmi_response::button_capabilities)) { + const smart_objects::SmartObject& button_caps = + (*message_)[strings::msg_params][hmi_response::button_capabilities]; + auto it = button_caps.asArray()->begin(); + auto ok_btn_it = it; + bool ok_btn_exists = false; + bool play_pause_btn_exists = false; + for (; it != button_caps.asArray()->end(); ++it) { + smart_objects::SmartObject& so = *it; + int64_t current_id = so[strings::name].asInt(); + if (current_id == -1) { + continue; + } + const mobile_apis::ButtonName::eType current_button = + static_cast<mobile_apis::ButtonName::eType>(current_id); + if (current_button == mobile_apis::ButtonName::PLAY_PAUSE) { + play_pause_btn_exists = true; + so[strings::name] = mobile_apis::ButtonName::OK; + } else if (current_button == mobile_apis::ButtonName::OK) { + ok_btn_exists = true; + ok_btn_it = it; + } + } + if (ok_btn_exists && play_pause_btn_exists) { + button_caps.asArray()->erase(ok_btn_it); + } + } + SendResponse(success, result_code, last_message); if (mobile_apis::Result::SUCCESS != result_code) { @@ -68,16 +102,14 @@ void RegisterAppInterfaceResponse::Run() { // Add registered application to the policy db right after response sent to // mobile to be able to check all other API according to app permissions - application_manager::ApplicationSharedPtr application = - application_manager_.application(connection_key()); - if (!application) { + if (!app) { LOG4CXX_ERROR(logger_, "Application with connection key " << connection_key() << " is not registered."); return; } - SetHeartBeatTimeout(connection_key(), application->policy_app_id()); + SetHeartBeatTimeout(connection_key(), app->policy_app_id()); } void RegisterAppInterfaceResponse::SetHeartBeatTimeout( diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/send_location_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/send_location_request.cc index ab8de5923a..2719d0674d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/send_location_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/send_location_request.cc @@ -124,7 +124,7 @@ void SendLocationRequest::Run() { (*message_)[strings::msg_params][strings::location_image], app, application_manager_); - if (mobile_apis::Result::SUCCESS != verification_result) { + if (mobile_apis::Result::INVALID_DATA == verification_result) { LOG4CXX_ERROR(logger_, "VerifyImage INVALID_DATA!"); SendResponse(false, verification_result); return; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_global_properties_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_global_properties_request.cc index b4b4e84f49..0c217b6b4f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_global_properties_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_global_properties_request.cc @@ -95,7 +95,7 @@ void SetGlobalPropertiesRequest::Run() { (*message_)[strings::msg_params][strings::menu_icon], app, application_manager_); - if (mobile_apis::Result::SUCCESS != verification_result) { + if (mobile_apis::Result::INVALID_DATA == verification_result) { LOG4CXX_ERROR( logger_, "MessageHelper::VerifyImage return " << verification_result); SendResponse(false, verification_result); @@ -104,7 +104,7 @@ void SetGlobalPropertiesRequest::Run() { } // Check for image file(s) in vrHelpItem if ((*message_)[strings::msg_params].keyExists(strings::vr_help)) { - if (mobile_apis::Result::SUCCESS != + if (mobile_apis::Result::INVALID_DATA == MessageHelper::VerifyImageVrHelpItems( (*message_)[strings::msg_params][strings::vr_help], app, diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_icon_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_icon_request.cc deleted file mode 100644 index 54c202f7b0..0000000000 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_icon_request.cc +++ /dev/null @@ -1,149 +0,0 @@ -/* - - 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 "sdl_rpc_plugin/commands/mobile/set_icon_request.h" -#include "application_manager/application_manager.h" -#include "application_manager/application_impl.h" -#include "config_profile/profile.h" -#include "interfaces/MOBILE_API.h" -#include "interfaces/HMI_API.h" -#include "utils/file_system.h" - -namespace sdl_rpc_plugin { -using namespace application_manager; - -namespace commands { - -SetIconRequest::SetIconRequest( - const application_manager::commands::MessageSharedPtr& message, - ApplicationManager& application_manager, - app_mngr::rpc_service::RPCService& rpc_service, - app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) - : CommandRequestImpl(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handler) {} - -SetIconRequest::~SetIconRequest() {} - -void SetIconRequest::Run() { - LOG4CXX_AUTO_TRACE(logger_); - - ApplicationSharedPtr app = application_manager_.application(connection_key()); - - if (!app) { - LOG4CXX_ERROR(logger_, "Application is not registered"); - SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); - return; - } - - const std::string& sync_file_name = - (*message_)[strings::msg_params][strings::sync_file_name].asString(); - - std::string full_file_path = - application_manager_.get_settings().app_storage_folder() + "/"; - full_file_path += app->folder_name(); - full_file_path += "/"; - full_file_path += sync_file_name; - - if (!file_system::FileExists(full_file_path)) { - LOG4CXX_ERROR(logger_, "No such file " << full_file_path); - SendResponse(false, mobile_apis::Result::INVALID_DATA); - return; - } - - smart_objects::SmartObject msg_params = - smart_objects::SmartObject(smart_objects::SmartType_Map); - - msg_params[strings::app_id] = app->app_id(); - msg_params[strings::sync_file_name] = - smart_objects::SmartObject(smart_objects::SmartType_Map); - - // Panasonic requres unchanged path value without encoded special characters - const std::string full_file_path_for_hmi = - file_system::ConvertPathForURL(full_file_path); - - msg_params[strings::sync_file_name][strings::value] = full_file_path_for_hmi; - - // TODO(VS): research why is image_type hardcoded - msg_params[strings::sync_file_name][strings::image_type] = - static_cast<int32_t>(SetIconRequest::ImageType::DYNAMIC); - - // for further use in on_event function - (*message_)[strings::msg_params][strings::sync_file_name] = - msg_params[strings::sync_file_name]; - StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); - SendHMIRequest(hmi_apis::FunctionID::UI_SetAppIcon, &msg_params, true); -} - -void SetIconRequest::on_event(const event_engine::Event& event) { - LOG4CXX_AUTO_TRACE(logger_); - const smart_objects::SmartObject& message = event.smart_object(); - - switch (event.id()) { - case hmi_apis::FunctionID::UI_SetAppIcon: { - EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); - mobile_apis::Result::eType result_code = - static_cast<mobile_apis::Result::eType>( - message[strings::params][hmi_response::code].asInt()); - - bool result = mobile_apis::Result::SUCCESS == result_code; - - if (result) { - ApplicationSharedPtr app = - application_manager_.application(connection_key()); - - const std::string path = - (*message_)[strings::msg_params][strings::sync_file_name] - [strings::value].asString(); - app->set_app_icon_path(path); - - LOG4CXX_INFO(logger_, - "Icon path was set to '" << app->app_icon_path() << "'"); - } - - SendResponse(result, result_code, NULL, &(message[strings::msg_params])); - break; - } - default: { - LOG4CXX_ERROR(logger_, "Received unknown event" << event.id()); - return; - } - } -} - -} // namespace commands - -} // namespace application_manager diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_constant_tbt_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_constant_tbt_request.cc index c2eb067e18..3b2936e6cd 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_constant_tbt_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_constant_tbt_request.cc @@ -105,7 +105,7 @@ void ShowConstantTBTRequest::Run() { if (msg_params.keyExists(strings::turn_icon)) { verification_result = MessageHelper::VerifyImage( msg_params[strings::turn_icon], app, application_manager_); - if (mobile_apis::Result::SUCCESS != verification_result) { + if (mobile_apis::Result::INVALID_DATA == verification_result) { LOG4CXX_ERROR(logger_, "VerifyImage INVALID_DATA!"); SendResponse(false, verification_result); return; @@ -115,7 +115,7 @@ void ShowConstantTBTRequest::Run() { if (msg_params.keyExists(strings::next_turn_icon)) { verification_result = MessageHelper::VerifyImage( msg_params[strings::next_turn_icon], app, application_manager_); - if (mobile_apis::Result::SUCCESS != verification_result) { + if (mobile_apis::Result::INVALID_DATA == verification_result) { LOG4CXX_ERROR(logger_, "VerifyImage INVALID_DATA!"); SendResponse(false, verification_result); return; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_request.cc index 0fdf6d83cf..e0c3e1da9a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_request.cc @@ -143,7 +143,7 @@ void ShowRequest::Run() { (*message_)[strings::msg_params][strings::graphic], app, application_manager_); - if (mobile_apis::Result::SUCCESS != verification_result) { + if (mobile_apis::Result::INVALID_DATA == verification_result) { LOG4CXX_ERROR(logger_, "Image verification failed."); SendResponse(false, verification_result); return; @@ -155,7 +155,7 @@ void ShowRequest::Run() { (*message_)[strings::msg_params][strings::secondary_graphic], app, application_manager_); - if (mobile_apis::Result::SUCCESS != verification_result) { + if (mobile_apis::Result::INVALID_DATA == verification_result) { LOG4CXX_ERROR(logger_, "Image verification failed."); SendResponse(false, verification_result); return; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_button_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_button_request.cc index 908a251962..85cb26321b 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_button_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_button_request.cc @@ -32,6 +32,7 @@ */ #include "sdl_rpc_plugin/commands/mobile/subscribe_button_request.h" +#include "utils/semantic_version.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -65,7 +66,7 @@ void SubscribeButtonRequest::Run() { return; } - const mobile_apis::ButtonName::eType btn_id = + mobile_apis::ButtonName::eType btn_id = static_cast<mobile_apis::ButtonName::eType>( (*message_)[str::msg_params][str::button_name].asInt()); @@ -76,7 +77,20 @@ void SubscribeButtonRequest::Run() { return; } - if (!CheckHMICapabilities(btn_id)) { + if (app->msg_version() <= utils::version_4_5 && + btn_id == mobile_apis::ButtonName::OK && app->is_media_application()) { + bool ok_supported = CheckHMICapabilities(mobile_apis::ButtonName::OK); + bool play_pause_supported = + CheckHMICapabilities(mobile_apis::ButtonName::PLAY_PAUSE); + if (play_pause_supported) { + LOG4CXX_DEBUG(logger_, "Converting Legacy OK button to PLAY_PAUSE"); + btn_id = mobile_apis::ButtonName::PLAY_PAUSE; + (*message_)[str::msg_params][str::button_name] = btn_id; + } else if (!ok_supported) { + LOG4CXX_ERROR(logger_, "OK button isn't allowed by HMI capabilities"); + SendResponse(false, mobile_apis::Result::UNSUPPORTED_RESOURCE); + } + } else if (!CheckHMICapabilities(btn_id)) { LOG4CXX_ERROR(logger_, "Subscribe on button " << btn_id << " isn't allowed by HMI capabilities"); @@ -105,7 +119,8 @@ bool SubscribeButtonRequest::Init() { bool SubscribeButtonRequest::IsSubscriptionAllowed( ApplicationSharedPtr app, mobile_apis::ButtonName::eType btn_id) { if (!app->is_media_application() && - ((mobile_apis::ButtonName::SEEKLEFT == btn_id) || + ((mobile_apis::ButtonName::PLAY_PAUSE == btn_id) || + (mobile_apis::ButtonName::SEEKLEFT == btn_id) || (mobile_apis::ButtonName::SEEKRIGHT == btn_id) || (mobile_apis::ButtonName::TUNEUP == btn_id) || (mobile_apis::ButtonName::TUNEDOWN == btn_id))) { diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_button_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_button_request.cc index 6537f0e7b2..ccfaef54cb 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_button_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_button_request.cc @@ -34,6 +34,7 @@ #include "sdl_rpc_plugin/commands/mobile/unsubscribe_button_request.h" #include "application_manager/application_impl.h" +#include "utils/semantic_version.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -67,11 +68,24 @@ void UnsubscribeButtonRequest::Run() { return; } - const mobile_apis::ButtonName::eType btn_id = + mobile_apis::ButtonName::eType btn_id = static_cast<mobile_apis::ButtonName::eType>( (*message_)[str::msg_params][str::button_name].asInt()); - if (!CheckHMICapabilities(btn_id)) { + if (app->msg_version() <= utils::version_4_5 && + btn_id == mobile_apis::ButtonName::OK && app->is_media_application()) { + bool ok_supported = CheckHMICapabilities(mobile_apis::ButtonName::OK); + bool play_pause_supported = + CheckHMICapabilities(mobile_apis::ButtonName::PLAY_PAUSE); + if (play_pause_supported) { + LOG4CXX_DEBUG(logger_, "Converting Legacy OK button to PLAY_PAUSE"); + btn_id = mobile_apis::ButtonName::PLAY_PAUSE; + (*message_)[str::msg_params][str::button_name] = btn_id; + } else if (!ok_supported) { + LOG4CXX_ERROR(logger_, "OK button isn't allowed by HMI capabilities"); + SendResponse(false, mobile_apis::Result::UNSUPPORTED_RESOURCE); + } + } else if (!CheckHMICapabilities(btn_id)) { LOG4CXX_ERROR(logger_, "Button " << btn_id << " isn't allowed by HMI capabilities"); SendResponse(false, mobile_apis::Result::UNSUPPORTED_RESOURCE); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_way_points_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_way_points_request.cc index 0d0836878f..40bb1ddfc9 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_way_points_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_way_points_request.cc @@ -39,7 +39,7 @@ using namespace application_manager; namespace commands { -UnSubscribeWayPointsRequest::UnSubscribeWayPointsRequest( +UnsubscribeWayPointsRequest::UnsubscribeWayPointsRequest( const application_manager::commands::MessageSharedPtr& message, ApplicationManager& application_manager, app_mngr::rpc_service::RPCService& rpc_service, @@ -51,9 +51,9 @@ UnSubscribeWayPointsRequest::UnSubscribeWayPointsRequest( hmi_capabilities, policy_handler) {} -UnSubscribeWayPointsRequest::~UnSubscribeWayPointsRequest() {} +UnsubscribeWayPointsRequest::~UnsubscribeWayPointsRequest() {} -void UnSubscribeWayPointsRequest::Run() { +void UnsubscribeWayPointsRequest::Run() { LOG4CXX_AUTO_TRACE(logger_); ApplicationSharedPtr app = application_manager_.application(connection_key()); @@ -76,13 +76,13 @@ void UnSubscribeWayPointsRequest::Run() { hmi_apis::FunctionID::Navigation_UnsubscribeWayPoints, NULL, true); } -void UnSubscribeWayPointsRequest::on_event(const event_engine::Event& event) { +void UnsubscribeWayPointsRequest::on_event(const event_engine::Event& event) { LOG4CXX_AUTO_TRACE(logger_); ApplicationSharedPtr app = application_manager_.application(connection_key()); const smart_objects::SmartObject& message = event.smart_object(); switch (event.id()) { case hmi_apis::FunctionID::Navigation_UnsubscribeWayPoints: { - LOG4CXX_INFO(logger_, "Received Navigation_UnSubscribeWayPoints event"); + LOG4CXX_INFO(logger_, "Received Navigation_UnsubscribeWayPoints event"); EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Navigation); const hmi_apis::Common_Result::eType result_code = static_cast<hmi_apis::Common_Result::eType>( @@ -107,7 +107,7 @@ void UnSubscribeWayPointsRequest::on_event(const event_engine::Event& event) { } } -bool UnSubscribeWayPointsRequest::Init() { +bool UnsubscribeWayPointsRequest::Init() { hash_update_mode_ = HashUpdateMode::kDoHashUpdate; return true; } diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/update_turn_list_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/update_turn_list_request.cc index 69379135b5..c04ad34f5f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/update_turn_list_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/update_turn_list_request.cc @@ -100,7 +100,7 @@ void UpdateTurnListRequest::Run() { ((*message_)[strings::msg_params][strings::turn_list]); for (uint32_t i = 0; i < turn_list_array.length(); ++i) { if ((turn_list_array[i].keyExists(strings::turn_icon)) && - (mobile_apis::Result::SUCCESS != + (mobile_apis::Result::INVALID_DATA == MessageHelper::VerifyImage(turn_list_array[i][strings::turn_icon], app, application_manager_))) { diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/hmi_command_factory.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/hmi_command_factory.cc index c510315ad8..7065c7cf7d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/hmi_command_factory.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/hmi_command_factory.cc @@ -607,7 +607,7 @@ CommandCreator& HMICommandFactory::get_creator_factory( case hmi_apis::FunctionID::Navigation_UnsubscribeWayPoints: { return hmi_apis::messageType::request == message_type ? factory - .GetCreator<commands::NaviUnSubscribeWayPointsRequest>() + .GetCreator<commands::NaviUnsubscribeWayPointsRequest>() : factory.GetCreator< commands::NaviUnsubscribeWayPointsResponse>(); } diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/mobile_command_factory.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/mobile_command_factory.cc index 3d7e2f6437..5207c7e432 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/mobile_command_factory.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/mobile_command_factory.cc @@ -263,7 +263,7 @@ CommandCreator& MobileCommandFactory::get_creator_factory( } case mobile_apis::FunctionID::GetWayPointsID: { return mobile_api::messageType::request == message_type - ? factory.GetCreator<commands::ShowConstantTBTRequest>() + ? factory.GetCreator<commands::GetWayPointsRequest>() : factory.GetCreator<commands::GetWayPointsResponse>(); } case mobile_apis::FunctionID::SubscribeWayPointsID: { @@ -273,8 +273,8 @@ CommandCreator& MobileCommandFactory::get_creator_factory( } case mobile_apis::FunctionID::UnsubscribeWayPointsID: { return mobile_api::messageType::request == message_type - ? factory.GetCreator<commands::ShowConstantTBTRequest>() - : factory.GetCreator<commands::ShowConstantTBTResponse>(); + ? factory.GetCreator<commands::UnsubscribeWayPointsRequest>() + : factory.GetCreator<commands::UnsubscribeWayPointsResponse>(); } case mobile_apis::FunctionID::GetSystemCapabilityID: { return mobile_api::messageType::request == message_type diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/CMakeLists.txt b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/CMakeLists.txt index da51c3e4e4..1a206c2cce 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/CMakeLists.txt +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/CMakeLists.txt @@ -6,6 +6,7 @@ include_directories( ${COMPONENTS_DIR}/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/ ${COMPONENTS_DIR}/application_manager/test/include/ ${POLICY_MOCK_INCLUDE_PATH}/ + ${CMAKE_SOURCE_DIR}/src ) diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/dummy_hmi_commands_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/dummy_hmi_commands_test.cc index 0f02deded0..a6497ca6e1 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/dummy_hmi_commands_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/dummy_hmi_commands_test.cc @@ -223,7 +223,6 @@ #include "hmi/on_tts_reset_timeout_notification.h" #include "hmi/dial_number_request.h" #include "hmi/dial_number_response.h" -#include "hmi/ui_set_icon_request.h" #include "application_manager/commands/commands_test.h" #include "application_manager/mock_application.h" @@ -423,7 +422,7 @@ typedef Types<commands::NaviIsReadyResponse, commands::NaviSubscribeWayPointsResponse, commands::NaviSubscribeWayPointsRequest, commands::NaviUnsubscribeWayPointsResponse, - commands::NaviUnSubscribeWayPointsRequest, + commands::NaviUnsubscribeWayPointsRequest, commands::ButtonGetCapabilitiesResponse, commands::ButtonGetCapabilitiesRequest, commands::OnAllowSDLFunctionalityNotification, diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/hmi_notifications_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/hmi_notifications_test.cc index dd51078614..fe82b16f3f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/hmi_notifications_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/hmi_notifications_test.cc @@ -872,7 +872,7 @@ TEST_F(HMICommandsNotificationsTest, SubscribeForSignal(); command->Run(); - utils::WaitTerminationSignals(sig_handler); + utils::Signals::WaitTerminationSignals(sig_handler); EXPECT_EQ(am::mobile_api::AppInterfaceUnregisteredReason::IGNITION_OFF, mob_reason); @@ -914,7 +914,7 @@ TEST_F(HMICommandsNotificationsTest, SubscribeForSignal(); command->Run(); - utils::WaitTerminationSignals(sig_handler); + utils::Signals::WaitTerminationSignals(sig_handler); #endif } } diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_requests_to_hmi_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_requests_to_hmi_test.cc index 9fa864d30d..599c7e50f2 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_requests_to_hmi_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_requests_to_hmi_test.cc @@ -103,7 +103,6 @@ #include "sdl_rpc_plugin/commands/hmi/navi_stop_stream_request.h" #include "sdl_rpc_plugin/commands/hmi/navi_subscribe_way_points_request.h" #include "sdl_rpc_plugin/commands/hmi/sdl_policy_update.h" -#include "sdl_rpc_plugin/commands/hmi/ui_set_icon_request.h" #include "sdl_rpc_plugin/commands/hmi/dial_number_request.h" #include "sdl_rpc_plugin/commands/hmi/ui_send_haptic_data_request.h" @@ -190,7 +189,7 @@ typedef Types<sdl_rpc_plugin::commands::hmi::DialNumberRequest, sdl_rpc_plugin::commands::BasicCommunicationSystemRequest, sdl_rpc_plugin::commands::ButtonGetCapabilitiesRequest, sdl_rpc_plugin::commands::NaviSendLocationRequest, - sdl_rpc_plugin::commands::NaviUnSubscribeWayPointsRequest, + sdl_rpc_plugin::commands::NaviUnsubscribeWayPointsRequest, sdl_rpc_plugin::commands::NaviUpdateTurnListRequest, sdl_rpc_plugin::commands::NaviShowConstantTBTRequest, sdl_rpc_plugin::commands::NaviStopStreamRequest, diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/add_command_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/add_command_request_test.cc index ea1a0fafed..dfcceea889 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/add_command_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/add_command_request_test.cc @@ -31,6 +31,7 @@ */ #include <stdint.h> +#include <memory> #include <string> #include <set> @@ -64,7 +65,6 @@ using am::ApplicationManager; using am::commands::MessageSharedPtr; using am::ApplicationSharedPtr; using ::testing::_; - using ::testing::Return; using ::testing::InSequence; using sdl_rpc_plugin::commands::AddCommandRequest; @@ -263,6 +263,26 @@ TEST_F(AddCommandRequestTest, Run_ImageVerificationFailed_EXPECT_INVALID_DATA) { request_ptr->Run(); } +TEST_F(AddCommandRequestTest, Run_ImageVerificationFailed_EXPECT_WARNINGS) { + CreateBasicParamsUIRequest(); + SmartObject& msg_params = (*msg_)[strings::msg_params]; + SmartObject& image = msg_params[cmd_icon]; + EXPECT_CALL(mock_message_helper_, VerifyImage(image, _, _)) + .WillOnce(Return(mobile_apis::Result::WARNINGS)); + + am::CommandsMap commands_map; + EXPECT_CALL(*mock_app_, commands_map()) + .WillRepeatedly(Return(DataAccessor<application_manager::CommandsMap>( + commands_map, lock_ptr_))); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_AddCommand))) + .WillOnce(Return(true)); + std::shared_ptr<AddCommandRequest> request_ptr = + CreateCommand<AddCommandRequest>(msg_); + request_ptr->Run(); +} + TEST_F(AddCommandRequestTest, Run_MenuNameHasSyntaxError_EXPECT_INVALID_DATA) { CreateBasicParamsUIRequest(); SmartObject& msg_params = (*msg_)[strings::msg_params]; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/create_interaction_choice_set_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/create_interaction_choice_set_test.cc index ed264ff2ab..c42be48e57 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/create_interaction_choice_set_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/create_interaction_choice_set_test.cc @@ -199,6 +199,8 @@ TEST_F(CreateInteractionChoiceSetRequestTest, OnEvent_VR_UNSUPPORTED_RESOURCE) { 10; (*msg_vr)[strings::msg_params][strings::choice_set][0][strings::menu_name] = "menu_name"; + (*msg_vr)[strings::msg_params][strings::choice_set][0][strings::vr_commands] + [0] = kVrCommands1; (*msg_vr)[strings::msg_params][strings::interaction_choice_set_id] = 11; std::shared_ptr<CreateInteractionChoiceSetRequest> req_vr = CreateCommand<CreateInteractionChoiceSetRequest>(msg_vr); @@ -231,7 +233,8 @@ TEST_F(CreateInteractionChoiceSetRequestTest, OnEvent_VR_UNSUPPORTED_RESOURCE) { Return(am::HmiInterfaces::HMI_INTERFACE_BasicCommunication)); EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).WillOnce(Return(true)); - + ON_CALL(mock_message_helper_, CheckChoiceSetVRCommands(_)) + .WillByDefault(Return(am::MessageHelper::ChoiceSetVRCommandsStatus::ALL)); req_vr->Run(); MessageSharedPtr vr_command_result; @@ -436,6 +439,9 @@ TEST_F(CreateInteractionChoiceSetRequestTest, EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId)) .WillOnce(Return(choice_set_id)); + ON_CALL(mock_message_helper_, CheckChoiceSetVRCommands(_)) + .WillByDefault(Return(am::MessageHelper::ChoiceSetVRCommandsStatus::ALL)); + EXPECT_CALL(app_mngr_, GenerateGrammarID()).WillOnce(Return(kGrammarId)); EXPECT_CALL(*mock_app_, AddChoiceSet(kChoiceSetId, _)); EXPECT_CALL(app_mngr_, GetNextHMICorrelationID()) @@ -481,6 +487,79 @@ TEST_F(CreateInteractionChoiceSetRequestTest, command_->Run(); } +TEST_F(CreateInteractionChoiceSetRequestTest, Run_WithoutVrCommands_SUCCESS) { + (*message_)[am::strings::msg_params][am::strings::choice_set][0] + [am::strings::menu_name] = kMenuName; + (*message_)[am::strings::msg_params][am::strings::choice_set][0] + [am::strings::image][am::strings::value] = kImage; + (*message_)[am::strings::msg_params][am::strings::choice_set][0] + [am::strings::choice_id] = kChoiceId1; + (*message_)[am::strings::msg_params][am::strings::choice_set][0] + [am::strings::secondary_image][am::strings::value] = kSecondImage; + (*message_)[am::strings::msg_params][am::strings::choice_set][1] + [am::strings::choice_id] = kChoiceId2; + (*message_)[am::strings::msg_params][am::strings::choice_set][1] + [am::strings::menu_name] = kMenuName; + (*message_)[am::strings::msg_params][am::strings::interaction_choice_set_id] = + kChoiceSetId; + + EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(mock_app_)); + + EXPECT_CALL(mock_message_helper_, VerifyImage(_, _, _)) + .WillRepeatedly(Return(mobile_apis::Result::SUCCESS)); + + EXPECT_CALL(mock_message_helper_, CheckChoiceSetVRCommands(_)) + .WillOnce(Return(am::MessageHelper::ChoiceSetVRCommandsStatus::NONE)); + + smart_objects::SmartObject* choice_set_id = NULL; + EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId)) + .WillOnce(Return(choice_set_id)); + + // No VR commands + EXPECT_CALL(app_mngr_, GenerateGrammarID()).Times(0); + + EXPECT_CALL(*mock_app_, AddChoiceSet(kChoiceSetId, _)); + + command_->Run(); +} + +TEST_F(CreateInteractionChoiceSetRequestTest, + Run_WithMixedVrCommands_UNSUCCESS) { + (*message_)[am::strings::msg_params][am::strings::choice_set][0] + [am::strings::menu_name] = kMenuName; + (*message_)[am::strings::msg_params][am::strings::choice_set][0] + [am::strings::image][am::strings::value] = kImage; + (*message_)[am::strings::msg_params][am::strings::choice_set][0] + [am::strings::choice_id] = kChoiceId1; + (*message_)[am::strings::msg_params][am::strings::choice_set][0] + [am::strings::secondary_image][am::strings::value] = kSecondImage; + (*message_)[am::strings::msg_params][am::strings::choice_set][0] + [am::strings::vr_commands][0] = kVrCommands1; + (*message_)[am::strings::msg_params][am::strings::choice_set][1] + [am::strings::choice_id] = kChoiceId2; + (*message_)[am::strings::msg_params][am::strings::choice_set][1] + [am::strings::menu_name] = kMenuName; + (*message_)[am::strings::msg_params][am::strings::interaction_choice_set_id] = + kChoiceSetId; + EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(mock_app_)); + + EXPECT_CALL(mock_message_helper_, VerifyImage(_, _, _)) + .WillRepeatedly(Return(mobile_apis::Result::SUCCESS)); + + EXPECT_CALL(mock_message_helper_, CheckChoiceSetVRCommands(_)) + .WillOnce(Return(am::MessageHelper::ChoiceSetVRCommandsStatus::MIXED)); + + smart_objects::SmartObject* choice_set_id = NULL; + EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId)) + .WillOnce(Return(choice_set_id)); + + EXPECT_CALL(app_mngr_, GenerateGrammarID()).Times(0); + + EXPECT_CALL(*mock_app_, AddChoiceSet(kChoiceSetId, _)).Times(0); + + command_->Run(); +} + TEST_F(CreateInteractionChoiceSetRequestTest, OnEvent_InvalidEventId_UNSUCCESS) { Event event(hmi_apis::FunctionID::INVALID_ENUM); @@ -523,6 +602,9 @@ TEST_F(CreateInteractionChoiceSetRequestTest, OnEvent_ValidVrNoError_SUCCESS) { EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId)) .WillOnce(Return(choice_set_id)); + ON_CALL(mock_message_helper_, CheckChoiceSetVRCommands(_)) + .WillByDefault(Return(am::MessageHelper::ChoiceSetVRCommandsStatus::ALL)); + EXPECT_CALL(app_mngr_, GenerateGrammarID()).WillOnce(Return(kGrammarId)); EXPECT_CALL(*mock_app_, AddChoiceSet(kChoiceSetId, _)); ON_CALL(app_mngr_, GetNextHMICorrelationID()) @@ -557,6 +639,9 @@ TEST_F(CreateInteractionChoiceSetRequestTest, EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId)) .WillOnce(Return(choice_set_id)); + ON_CALL(mock_message_helper_, CheckChoiceSetVRCommands(_)) + .WillByDefault(Return(am::MessageHelper::ChoiceSetVRCommandsStatus::ALL)); + EXPECT_CALL(app_mngr_, GenerateGrammarID()).WillOnce(Return(kGrammarId)); EXPECT_CALL(*mock_app_, AddChoiceSet(kChoiceSetId, _)); ON_CALL(app_mngr_, GetNextHMICorrelationID()) @@ -592,6 +677,9 @@ TEST_F(CreateInteractionChoiceSetRequestTest, EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId)) .WillOnce(Return(choice_set_id)); + ON_CALL(mock_message_helper_, CheckChoiceSetVRCommands(_)) + .WillByDefault(Return(am::MessageHelper::ChoiceSetVRCommandsStatus::ALL)); + EXPECT_CALL(app_mngr_, GenerateGrammarID()).WillOnce(Return(kGrammarId)); EXPECT_CALL(*mock_app_, AddChoiceSet(kChoiceSetId, _)); ON_CALL(app_mngr_, GetNextHMICorrelationID()) @@ -640,6 +728,9 @@ TEST_F(CreateInteractionChoiceSetRequestTest, EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId)) .WillOnce(Return(choice_set_id)); + ON_CALL(mock_message_helper_, CheckChoiceSetVRCommands(_)) + .WillByDefault(Return(am::MessageHelper::ChoiceSetVRCommandsStatus::ALL)); + EXPECT_CALL(app_mngr_, GenerateGrammarID()).WillOnce(Return(kGrammarId)); EXPECT_CALL(*mock_app_, AddChoiceSet(kChoiceSetId, _)); ON_CALL(app_mngr_, GetNextHMICorrelationID()) @@ -682,6 +773,9 @@ TEST_F(CreateInteractionChoiceSetRequestTest, OnTimeOut_InvalidApp_UNSUCCESS) { EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId)) .WillOnce(Return(choice_set_id)); + ON_CALL(mock_message_helper_, CheckChoiceSetVRCommands(_)) + .WillByDefault(Return(am::MessageHelper::ChoiceSetVRCommandsStatus::ALL)); + EXPECT_CALL(app_mngr_, GenerateGrammarID()).WillOnce(Return(kGrammarId)); EXPECT_CALL(*mock_app_, AddChoiceSet(kChoiceSetId, _)); ON_CALL(app_mngr_, GetNextHMICorrelationID()) @@ -723,6 +817,9 @@ TEST_F(CreateInteractionChoiceSetRequestTest, EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(mock_app_)); + + ON_CALL(mock_message_helper_, CheckChoiceSetVRCommands(_)) + .WillByDefault(Return(am::MessageHelper::ChoiceSetVRCommandsStatus::ALL)); EXPECT_CALL(app_mngr_, GenerateGrammarID()).WillOnce(Return(kGrammarId)); ON_CALL(app_mngr_, GetNextHMICorrelationID()) .WillByDefault(Return(kCorrelationId)); @@ -796,6 +893,9 @@ TEST_F(CreateInteractionChoiceSetRequestTest, Run_ErrorFromHmiFalse_UNSUCCESS) { EXPECT_CALL(*mock_app_, FindChoiceSet(kChoiceSetId)) .WillRepeatedly(Return(choice_set_id)); + ON_CALL(mock_message_helper_, CheckChoiceSetVRCommands(_)) + .WillByDefault(Return(am::MessageHelper::ChoiceSetVRCommandsStatus::ALL)); + EXPECT_CALL(app_mngr_, GenerateGrammarID()) .WillRepeatedly(Return(kGrammarId)); EXPECT_CALL(*mock_app_, AddChoiceSet(kChoiceSetId, _)).Times(2); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/dummy_mobile_commands_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/dummy_mobile_commands_test.cc index c6601d6352..8589cbb6be 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/dummy_mobile_commands_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/dummy_mobile_commands_test.cc @@ -282,7 +282,7 @@ typedef Types<commands::OnWayPointChangeNotification, commands::UnsubscribeButtonRequest, commands::UnsubscribeButtonResponse> MobileCommandsListSecond; -typedef Types<commands::UnSubscribeWayPointsRequest, +typedef Types<commands::UnsubscribeWayPointsRequest, commands::UnsubscribeWayPointsResponse, commands::UpdateTurnListRequest, commands::UpdateTurnListResponse> MobileCommandsListThird; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/register_app_interface_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/register_app_interface_request_test.cc index dbaee6b2ad..7dab16fe35 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/register_app_interface_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/register_app_interface_request_test.cc @@ -55,6 +55,7 @@ #include "utils/custom_string.h" #include "utils/lock.h" #include "utils/macro.h" +#include "utils/semantic_version.h" namespace test { namespace components { @@ -80,8 +81,10 @@ const mobile_apis::Language::eType kMobileLanguage = mobile_apis::Language::EN_US; const std::string kMacAddress = "test_mac_address"; const std::string kAppId = "test_app_id"; +const std::string kFullAppId = "test_app_id_long"; const std::string kDummyString = "test_string"; const std::vector<uint32_t> kDummyDiagModes; +const utils::SemanticVersion mock_semantic_version(1, 0, 0); } // namespace class RegisterAppInterfaceRequestTest @@ -110,11 +113,18 @@ class RegisterAppInterfaceRequestTest void InitBasicMessage() { (*msg_)[am::strings::params][am::strings::connection_key] = kConnectionKey; (*msg_)[am::strings::msg_params][am::strings::app_id] = kAppId; + (*msg_)[am::strings::msg_params][am::strings::full_app_id] = kFullAppId; (*msg_)[am::strings::msg_params][am::strings::app_name] = app_name_; (*msg_)[am::strings::msg_params][am::strings::language_desired] = kHmiLanguage; (*msg_)[am::strings::msg_params] [am::strings::hmi_display_language_desired] = kHmiLanguage; + (*msg_)[am::strings::msg_params][am::strings::sync_msg_version] + [am::strings::major_version] = 4; + (*msg_)[am::strings::msg_params][am::strings::sync_msg_version] + [am::strings::minor_version] = 0; + (*msg_)[am::strings::msg_params][am::strings::sync_msg_version] + [am::strings::patch_version] = 0; } MockAppPtr CreateBasicMockedApp() { @@ -125,6 +135,8 @@ class RegisterAppInterfaceRequestTest ON_CALL(*mock_app, language()).WillByDefault(ReturnRef(kMobileLanguage)); ON_CALL(*mock_app, ui_language()).WillByDefault(ReturnRef(kMobileLanguage)); ON_CALL(*mock_app, policy_app_id()).WillByDefault(Return(kAppId)); + ON_CALL(*mock_app, msg_version()) + .WillByDefault(ReturnRef(mock_semantic_version)); return mock_app; } @@ -141,6 +153,8 @@ class RegisterAppInterfaceRequestTest } void InitGetters() { + ON_CALL(app_mngr_, GetCorrectMobileIDFromMessage(msg_)) + .WillByDefault(Return(kAppId)); ON_CALL(app_mngr_, IsHMICooperating()).WillByDefault(Return(true)); ON_CALL(app_mngr_, resume_controller()) .WillByDefault(ReturnRef(mock_resume_crt_)); @@ -281,6 +295,7 @@ TEST_F(RegisterAppInterfaceRequestTest, Run_MinimalData_SUCCESS) { .WillByDefault(Return(notify_upd_manager)); EXPECT_CALL(app_mngr_, RegisterApplication(msg_)).WillOnce(Return(mock_app)); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(HMIResultCodeIs( hmi_apis::FunctionID::BasicCommunication_OnAppRegistered))) diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/send_location_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/send_location_request_test.cc index bf75e651c6..4f44293fc9 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/send_location_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/send_location_request_test.cc @@ -315,6 +315,21 @@ TEST_F(SendLocationRequestTest, Run_LocationImageValid_Success) { command_->Run(); } +TEST_F(SendLocationRequestTest, Run_LocationImageValid_Warnings) { + InitialSetup(message_); + (*message_)[strings::msg_params][strings::location_image] = + SmartObject(smart_objects::SmartType_Map); + (*message_)[strings::msg_params][strings::location_image][strings::value] = + "notavailable"; + EXPECT_CALL( + mock_message_helper_, + VerifyImage( + (*message_)[strings::msg_params][strings::location_image], _, _)) + .WillOnce(Return(mobile_apis::Result::WARNINGS)); + FinishSetup(); + command_->Run(); +} + TEST_F(SendLocationRequestTest, Run_LocationImageInvalid_Cancelled) { InitialSetup(message_); (*message_)[strings::msg_params][strings::location_image] = @@ -325,8 +340,8 @@ TEST_F(SendLocationRequestTest, Run_LocationImageInvalid_Cancelled) { mock_message_helper_, VerifyImage( (*message_)[strings::msg_params][strings::location_image], _, _)) - .WillOnce(Return(mobile_apis::Result::ABORTED)); - FinishSetupCancelled(mobile_apis::Result::ABORTED); + .WillOnce(Return(mobile_apis::Result::INVALID_DATA)); + FinishSetupCancelled(mobile_apis::Result::INVALID_DATA); command_->Run(); } diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_global_properties_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_global_properties_test.cc index ff85180ad6..03aa5d85a1 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_global_properties_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/set_global_properties_test.cc @@ -31,6 +31,7 @@ */ #include <stdint.h> +#include <memory> #include <string> #include <set> @@ -491,12 +492,109 @@ TEST_F(SetGlobalPropertiesRequestTest, Run_VRWithMenuAndKeyboard_SUCCESS) { command->Run(); } +TEST_F(SetGlobalPropertiesRequestTest, + Run_VRWithMenuAndKeyboard_Menu_WARNINGS) { + MessageSharedPtr msg = CreateMsgParams(); + SmartObject vr_help_title("yes"); + SmartObject vr_help_array(smart_objects::SmartType_Array); + VRArraySetupHelper(msg, vr_help_title, vr_help_array); + (*msg)[am::strings::msg_params][am::strings::vr_help] = vr_help_array; + SmartObject menu_title("Menu_Title"); + (*msg)[am::strings::msg_params][am::hmi_request::menu_title] = menu_title; + SmartObject menu_icon(smart_objects::SmartType_Map); + menu_icon[am::strings::value] = "1"; + (*msg)[am::strings::msg_params][am::hmi_request::menu_icon] = menu_icon; + SmartObject keyboard_properties(smart_objects::SmartType_Map); + (*msg)[am::strings::msg_params][am::hmi_request::keyboard_properties] = + keyboard_properties; + + EXPECT_CALL(mock_message_helper_, VerifyImage(menu_icon, _, _)) + .WillOnce((Return(mobile_apis::Result::WARNINGS))); + EXPECT_CALL(mock_message_helper_, VerifyImageVrHelpItems(vr_help_array, _, _)) + .WillOnce((Return(mobile_apis::Result::SUCCESS))); + EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(kConnectionKey)); + EXPECT_CALL(*mock_app_, set_vr_help_title(vr_help_title)); + EXPECT_CALL(*mock_app_, set_vr_help(vr_help_array)); + EXPECT_CALL(*mock_app_, vr_help_title()).WillOnce(Return(&vr_help_title)); + EXPECT_CALL(*mock_app_, vr_help()).WillOnce(Return(&vr_help_array)); + EXPECT_CALL(*mock_app_, set_menu_title(menu_title)); + EXPECT_CALL(*mock_app_, set_menu_icon(menu_icon)); + EXPECT_CALL(*mock_app_, set_keyboard_props(keyboard_properties)); + EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId)); + EXPECT_CALL(*mock_app_, help_prompt_manager()) + .WillOnce(ReturnRef(*mock_help_prompt_manager_.get())); + EXPECT_CALL(*mock_help_prompt_manager_, + OnSetGlobalPropertiesReceived(_, false)); + + EXPECT_CALL( + mock_hmi_interfaces_, + GetInterfaceFromFunction(hmi_apis::FunctionID::UI_SetGlobalProperties)) + .WillOnce(Return(am::HmiInterfaces::HMI_INTERFACE_UI)); + + ON_CALL(mock_hmi_interfaces_, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) + .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); + + std::shared_ptr<SetGlobalPropertiesRequest> command( + CreateCommand<SetGlobalPropertiesRequest>(msg)); + + command->Run(); +} + +TEST_F(SetGlobalPropertiesRequestTest, Run_VRWithMenuAndKeyboard_VR_WARNINGS) { + MessageSharedPtr msg = CreateMsgParams(); + SmartObject vr_help_title("yes"); + SmartObject vr_help_array(smart_objects::SmartType_Array); + VRArraySetupHelper(msg, vr_help_title, vr_help_array); + (*msg)[am::strings::msg_params][am::strings::vr_help] = vr_help_array; + SmartObject menu_title("Menu_Title"); + (*msg)[am::strings::msg_params][am::hmi_request::menu_title] = menu_title; + SmartObject menu_icon(smart_objects::SmartType_Map); + menu_icon[am::strings::value] = "1"; + (*msg)[am::strings::msg_params][am::hmi_request::menu_icon] = menu_icon; + SmartObject keyboard_properties(smart_objects::SmartType_Map); + (*msg)[am::strings::msg_params][am::hmi_request::keyboard_properties] = + keyboard_properties; + + EXPECT_CALL(mock_message_helper_, VerifyImage(menu_icon, _, _)) + .WillOnce((Return(mobile_apis::Result::SUCCESS))); + EXPECT_CALL(mock_message_helper_, VerifyImageVrHelpItems(vr_help_array, _, _)) + .WillOnce((Return(mobile_apis::Result::WARNINGS))); + EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(kConnectionKey)); + EXPECT_CALL(*mock_app_, set_vr_help_title(vr_help_title)); + EXPECT_CALL(*mock_app_, set_vr_help(vr_help_array)); + EXPECT_CALL(*mock_app_, vr_help_title()).WillOnce(Return(&vr_help_title)); + EXPECT_CALL(*mock_app_, vr_help()).WillOnce(Return(&vr_help_array)); + EXPECT_CALL(*mock_app_, set_menu_title(menu_title)); + EXPECT_CALL(*mock_app_, set_menu_icon(menu_icon)); + EXPECT_CALL(*mock_app_, set_keyboard_props(keyboard_properties)); + EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId)); + EXPECT_CALL(*mock_app_, help_prompt_manager()) + .WillOnce(ReturnRef(*mock_help_prompt_manager_.get())); + EXPECT_CALL(*mock_help_prompt_manager_, + OnSetGlobalPropertiesReceived(_, false)); + + EXPECT_CALL( + mock_hmi_interfaces_, + GetInterfaceFromFunction(hmi_apis::FunctionID::UI_SetGlobalProperties)) + .WillOnce(Return(am::HmiInterfaces::HMI_INTERFACE_UI)); + + ON_CALL(mock_hmi_interfaces_, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) + .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); + + std::shared_ptr<SetGlobalPropertiesRequest> command( + CreateCommand<SetGlobalPropertiesRequest>(msg)); + + command->Run(); +} + TEST_F(SetGlobalPropertiesRequestTest, Run_VRBrokenMenuIcon_Canceled) { MessageSharedPtr msg = CreateMsgParams(); SmartObject vr_help_title("yes"); (*msg)[am::strings::msg_params][am::strings::vr_help_title] = vr_help_title; SmartObject menu_icon(smart_objects::SmartType_Map); - menu_icon[am::strings::value] = "1"; + menu_icon[am::strings::value] = " 1"; (*msg)[am::strings::msg_params][am::hmi_request::menu_icon] = menu_icon; EXPECT_CALL(app_mngr_, application(kConnectionKey)) @@ -504,9 +602,7 @@ TEST_F(SetGlobalPropertiesRequestTest, Run_VRBrokenMenuIcon_Canceled) { EXPECT_CALL(mock_message_helper_, VerifyImage(menu_icon, _, _)) .WillOnce((Return(mobile_apis::Result::ABORTED))); EXPECT_CALL(mock_message_helper_, VerifyImageVrHelpItems(_, _, _)).Times(0); - EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(_)).Times(0); EmptyExpectationsSetupHelper(); - std::shared_ptr<SetGlobalPropertiesRequest> command( CreateCommand<SetGlobalPropertiesRequest>(msg)); @@ -521,14 +617,27 @@ TEST_F(SetGlobalPropertiesRequestTest, Run_VRBrokenVRHelp_Canceled) { (*msg)[am::strings::msg_params][am::hmi_request::menu_icon] = menu_icon; SmartObject vr_help_array(smart_objects::SmartType_Array); VRArraySetupHelper(msg, vr_help_title, vr_help_array); + SmartObject menu_title("Menu_Title"); + (*msg)[am::strings::msg_params][am::hmi_request::menu_title] = menu_title; EXPECT_CALL(mock_message_helper_, VerifyImage(menu_icon, _, _)) .WillOnce((Return(mobile_apis::Result::SUCCESS))); EXPECT_CALL(mock_message_helper_, VerifyImageVrHelpItems(vr_help_array, _, _)) .WillOnce((Return(mobile_apis::Result::ABORTED))); - EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(_)).Times(0); EmptyExpectationsSetupHelper(); + EXPECT_CALL(*mock_app_, vr_help_title()).WillOnce(Return(&vr_help_title)); + EXPECT_CALL(*mock_app_, vr_help()).WillOnce(Return(&vr_help_array)); + EXPECT_CALL(*mock_app_, set_vr_help_title(vr_help_title)); + EXPECT_CALL(*mock_app_, set_vr_help(vr_help_array)); + EXPECT_CALL(*mock_app_, set_menu_title(menu_title)); + EXPECT_CALL(*mock_app_, set_menu_icon(menu_icon)); + EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId)); + EXPECT_CALL(*mock_app_, help_prompt_manager()) + .WillOnce(ReturnRef(*mock_help_prompt_manager_.get())); + EXPECT_CALL(*mock_help_prompt_manager_, + OnSetGlobalPropertiesReceived(_, false)); + std::shared_ptr<SetGlobalPropertiesRequest> command( CreateCommand<SetGlobalPropertiesRequest>(msg)); @@ -649,6 +758,25 @@ TEST_F(SetGlobalPropertiesRequestTest, Run_NoVR_SUCCESS) { command->Run(); } +TEST_F(SetGlobalPropertiesRequestTest, Run_VRCouldNotGenerate_INVALID_DATA) { + MessageSharedPtr msg = CreateMsgParams(); + SmartObject keyboard_properties(smart_objects::SmartType_Map); + (*msg)[am::strings::msg_params][am::hmi_request::keyboard_properties] = + keyboard_properties; + SmartObject menu_title("Menu_Title"); + (*msg)[am::strings::msg_params][am::hmi_request::menu_title] = menu_title; + + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(kConnectionKey)); + EXPECT_CALL(*mock_app_, set_menu_title(menu_title)); + + std::shared_ptr<SetGlobalPropertiesRequest> command( + CreateCommand<SetGlobalPropertiesRequest>(msg)); + + command->Run(); +} + TEST_F(SetGlobalPropertiesRequestTest, Run_NoVRNoDataNoDefault_Canceled) { MessageSharedPtr msg = CreateMsgParams(); SmartObject keyboard_properties(smart_objects::SmartType_Map); @@ -706,6 +834,39 @@ TEST_F(SetGlobalPropertiesRequestTest, Run_NoVRNoDataDefaultCreated_SUCCESS) { command->Run(); } +TEST_F(SetGlobalPropertiesRequestTest, Run_NoVRNoDataFromSynonyms_SUCCESS) { + MessageSharedPtr msg = CreateMsgParams(); + SmartObject keyboard_properties(smart_objects::SmartType_Map); + (*msg)[am::strings::msg_params][am::hmi_request::keyboard_properties] = + keyboard_properties; + + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(kConnectionKey)); + + SmartObject vr_help_array(smart_objects::SmartType_Array); + vr_help_array[0] = SmartObject(smart_objects::SmartType_Map); + vr_help_array[0][am::strings::text] = kText; + vr_help_array[0][am::strings::position] = kPosition; + SmartObject vr_synonyms(smart_objects::SmartType_Array); + vr_synonyms[0] = vr_help_array; + EXPECT_CALL(*mock_app_, set_menu_title(_)).Times(0); + EXPECT_CALL(*mock_app_, set_menu_icon(_)).Times(0); + EXPECT_CALL(*mock_app_, set_keyboard_props(keyboard_properties)); + EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId)); + EXPECT_CALL( + mock_hmi_interfaces_, + GetInterfaceFromFunction(hmi_apis::FunctionID::UI_SetGlobalProperties)) + .WillOnce(Return(am::HmiInterfaces::HMI_INTERFACE_UI)); + ON_CALL(mock_hmi_interfaces_, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) + .WillByDefault(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); + std::shared_ptr<SetGlobalPropertiesRequest> command( + CreateCommand<SetGlobalPropertiesRequest>(msg)); + + command->Run(); +} + TEST_F(SetGlobalPropertiesRequestTest, Run_TTSHelpAndTimeout_SUCCESS) { MessageSharedPtr msg = CreateMsgParams(); SmartObject help_prompt(smart_objects::SmartType_Array); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/show_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/show_test.cc index 1ea1300c35..4725af4671 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/show_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/show_test.cc @@ -31,6 +31,7 @@ */ #include <stdint.h> +#include <memory> #include <string> #include <set> @@ -353,6 +354,33 @@ TEST_F(ShowRequestTest, Run_Graphic_SUCCESS) { command->Run(); } +TEST_F(ShowRequestTest, Run_Graphic_WARNINGS) { + MessageSharedPtr msg = CreateMsgParams(); + + SmartObject msg_params(smart_objects::SmartType_Map); + SmartObject graphic(smart_objects::SmartType_Map); + graphic[am::strings::value] = "1"; + msg_params[am::strings::graphic] = graphic; + (*msg)[am::strings::msg_params] = msg_params; + + std::shared_ptr<ShowRequest> command(CreateCommand<ShowRequest>(msg)); + + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + EXPECT_CALL(mock_message_helper_, VerifyImage(graphic, _, _)) + .WillOnce(Return(mobile_apis::Result::WARNINGS)); + EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId)); + + msg_params[am::strings::app_id] = kAppId; + msg_params[am::hmi_request::show_strings] = + smart_objects::SmartObject(smart_objects::SmartType_Array); + + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)); + EXPECT_CALL(*mock_app_, set_show_command(msg_params)); + + command->Run(); +} + TEST_F(ShowRequestTest, Run_Graphic_Canceled) { MessageSharedPtr msg = CreateMsgParams(); @@ -367,7 +395,7 @@ TEST_F(ShowRequestTest, Run_Graphic_Canceled) { EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(mock_app_)); EXPECT_CALL(mock_message_helper_, VerifyImage(graphic, _, _)) - .WillOnce(Return(mobile_apis::Result::ABORTED)); + .WillOnce(Return(mobile_apis::Result::INVALID_DATA)); EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)); EXPECT_CALL(*mock_app_, app_id()).Times(0); EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)).Times(0); @@ -425,6 +453,32 @@ TEST_F(ShowRequestTest, Run_SecondaryGraphic_SUCCESS) { command->Run(); } +TEST_F(ShowRequestTest, Run_SecondaryGraphic_WARNINGS) { + MessageSharedPtr msg = CreateMsgParams(); + + SmartObject msg_params(smart_objects::SmartType_Map); + SmartObject graphic(smart_objects::SmartType_Map); + graphic[am::strings::value] = "1"; + msg_params[am::strings::secondary_graphic] = graphic; + (*msg)[am::strings::msg_params] = msg_params; + + std::shared_ptr<ShowRequest> command(CreateCommand<ShowRequest>(msg)); + + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app_)); + EXPECT_CALL(mock_message_helper_, VerifyImage(graphic, _, _)) + .WillOnce(Return(mobile_apis::Result::WARNINGS)); + EXPECT_CALL(*mock_app_, app_id()).WillOnce(Return(kAppId)); + + msg_params[am::strings::app_id] = kAppId; + msg_params[am::hmi_request::show_strings] = + smart_objects::SmartObject(smart_objects::SmartType_Array); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)); + EXPECT_CALL(*mock_app_, set_show_command(msg_params)); + + command->Run(); +} + TEST_F(ShowRequestTest, Run_SecondaryGraphic_Canceled) { MessageSharedPtr msg = CreateMsgParams(); @@ -439,7 +493,7 @@ TEST_F(ShowRequestTest, Run_SecondaryGraphic_Canceled) { EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(mock_app_)); EXPECT_CALL(mock_message_helper_, VerifyImage(graphic, _, _)) - .WillOnce(Return(mobile_apis::Result::ABORTED)); + .WillOnce(Return(mobile_apis::Result::INVALID_DATA)); EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)); EXPECT_CALL(*mock_app_, app_id()).Times(0); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/subscribe_button_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/subscribe_button_request_test.cc index bbc18504a6..0196b59b79 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/subscribe_button_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/subscribe_button_request_test.cc @@ -73,6 +73,8 @@ class SubscribeButtonRequestTest }; typedef SubscribeButtonRequestTest::MockHMICapabilities MockHMICapabilities; +const utils::SemanticVersion mock_semantic_version(5, 0, 0); +const utils::SemanticVersion mock_semantic_version_4_5(4, 5, 0); TEST_F(SubscribeButtonRequestTest, Run_AppNotRegistered_UNSUCCESS) { CommandPtr command(CreateCommand<SubscribeButtonRequest>()); @@ -110,6 +112,9 @@ TEST_F(SubscribeButtonRequestTest, Run_UiIsNotSupported_UNSUCCESS) { MockAppPtr app(CreateMockApp()); ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app)); + ON_CALL(*app, msg_version()).WillByDefault(ReturnRef(mock_semantic_version)); + ON_CALL(*app, is_media_application()).WillByDefault(Return(false)); + ON_CALL(mock_hmi_capabilities_, is_ui_cooperating()) .WillByDefault(Return(false)); @@ -130,6 +135,7 @@ TEST_F(SubscribeButtonRequestTest, Run_IsSubscribedToButton_UNSUCCESS) { MockAppPtr app(CreateMockApp()); ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app)); + ON_CALL(*app, msg_version()).WillByDefault(ReturnRef(mock_semantic_version)); ON_CALL(*app, is_media_application()).WillByDefault(Return(true)); ON_CALL(mock_hmi_capabilities_, is_ui_cooperating()) @@ -160,6 +166,7 @@ TEST_F(SubscribeButtonRequestTest, Run_SUCCESS) { MockAppPtr app(CreateMockApp()); ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app)); + ON_CALL(*app, msg_version()).WillByDefault(ReturnRef(mock_semantic_version)); ON_CALL(*app, is_media_application()).WillByDefault(Return(true)); ON_CALL(mock_hmi_capabilities_, is_ui_cooperating()) @@ -195,6 +202,60 @@ TEST_F(SubscribeButtonRequestTest, Run_SUCCESS) { [am::strings::result_code].asInt())); } +TEST_F(SubscribeButtonRequestTest, Run_SUCCESS_App_Version_4_5) { + const mobile_apis::ButtonName::eType kButtonName = + mobile_apis::ButtonName::OK; + + MessageSharedPtr msg(CreateMessage()); + (*msg)[am::strings::msg_params][am::strings::button_name] = kButtonName; + CommandPtr command(CreateCommand<SubscribeButtonRequest>(msg)); + + MockAppPtr app(CreateMockApp()); + ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app)); + ON_CALL(*app, msg_version()) + .WillByDefault(ReturnRef(mock_semantic_version_4_5)); + ON_CALL(*app, is_media_application()).WillByDefault(Return(true)); + + ON_CALL(mock_hmi_capabilities_, is_ui_cooperating()) + .WillByDefault(Return(true)); + + MessageSharedPtr button_caps_ptr(CreateMessage(smart_objects::SmartType_Map)); + (*button_caps_ptr)[0][am::hmi_response::button_name] = kButtonName; + (*button_caps_ptr)[1][am::hmi_response::button_name] = + mobile_apis::ButtonName::PLAY_PAUSE; + + ON_CALL(mock_hmi_capabilities_, button_capabilities()) + .WillByDefault(Return(button_caps_ptr.get())); + + ON_CALL(*app, IsSubscribedToButton(_)).WillByDefault(Return(false)); + + MessageSharedPtr hmi_result_msg; + + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)) + .WillOnce(DoAll(SaveArg<0>(&hmi_result_msg), Return(true))); + + MessageSharedPtr mobile_result_msg; + EXPECT_CALL(this->mock_rpc_service_, ManageMobileCommand(_, _)) + .WillOnce(DoAll(SaveArg<0>(&mobile_result_msg), Return(true))); + ASSERT_TRUE(command->Init()); + command->Run(); + + EXPECT_EQ(hmi_apis::FunctionID::Buttons_OnButtonSubscription, + static_cast<hmi_apis::FunctionID::eType>( + (*hmi_result_msg)[am::strings::params][am::strings::function_id] + .asInt())); + + EXPECT_EQ(hmi_apis::Common_ButtonName::PLAY_PAUSE, + static_cast<hmi_apis::Common_ButtonName::eType>( + (*hmi_result_msg)[am::strings::msg_params][am::strings::name] + .asInt())); + + EXPECT_EQ(mobile_apis::Result::SUCCESS, + static_cast<mobile_apis::Result::eType>( + (*mobile_result_msg)[am::strings::msg_params] + [am::strings::result_code].asInt())); +} + } // namespace subscribe_button_request } // namespace mobile_commands_test } // namespace commands_test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/unsubscribe_button_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/unsubscribe_button_request_test.cc index e363567c64..d6bef42794 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/unsubscribe_button_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/unsubscribe_button_request_test.cc @@ -28,6 +28,8 @@ typedef std::shared_ptr<UnsubscribeButtonRequest> CommandPtr; namespace { const uint32_t kConnectionKey = 1u; const mobile_apis::ButtonName::eType kButtonId = mobile_apis::ButtonName::OK; +const utils::SemanticVersion mock_semantic_version(5, 0, 0); +const utils::SemanticVersion mock_semantic_version_4_5(4, 5, 0); } // namespace class UnsubscribeButtonRequestTest @@ -73,6 +75,8 @@ TEST_F(UnsubscribeButtonRequestTest, MockAppPtr mock_app(CreateMockApp()); EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(mock_app)); + ON_CALL(*mock_app, msg_version()) + .WillByDefault(ReturnRef(mock_semantic_version)); EXPECT_CALL(*mock_app, UnsubscribeFromButton(kButtonId)) .WillOnce(Return(false)); @@ -94,6 +98,8 @@ TEST_F(UnsubscribeButtonRequestTest, MockAppPtr mock_app(CreateMockApp()); EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(mock_app)); + ON_CALL(*mock_app, msg_version()) + .WillByDefault(ReturnRef(mock_semantic_version)); EXPECT_CALL(mock_hmi_capabilities_, is_ui_cooperating()) .WillOnce(Return(true)); @@ -128,6 +134,8 @@ TEST_F(UnsubscribeButtonRequestTest, Run_SUCCESS) { MockAppPtr mock_app(CreateMockApp()); EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillRepeatedly(Return(mock_app)); + ON_CALL(*mock_app, msg_version()) + .WillByDefault(ReturnRef(mock_semantic_version)); EXPECT_CALL(*mock_app, UnsubscribeFromButton(kButtonId)) .WillOnce(Return(true)); @@ -143,6 +151,49 @@ TEST_F(UnsubscribeButtonRequestTest, Run_SUCCESS) { command->Run(); } +TEST_F(UnsubscribeButtonRequestTest, Run_SUCCESS_Version_4_5) { + MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); + (*command_msg)[am::strings::params][am::strings::connection_key] = + kConnectionKey; + (*command_msg)[am::strings::msg_params][am::strings::button_name] = + mobile_apis::ButtonName::OK; + + CommandPtr command(CreateCommand<UnsubscribeButtonRequest>(command_msg)); + + EXPECT_CALL(mock_hmi_capabilities_, is_ui_cooperating()) + .WillRepeatedly(Return(true)); + + MessageSharedPtr button_caps_ptr(CreateMessage(smart_objects::SmartType_Map)); + (*button_caps_ptr)[0][am::hmi_response::button_name] = + mobile_apis::ButtonName::OK; + (*button_caps_ptr)[1][am::hmi_response::button_name] = + mobile_apis::ButtonName::PLAY_PAUSE; + + EXPECT_CALL(mock_hmi_capabilities_, button_capabilities()) + .WillRepeatedly(Return(button_caps_ptr.get())); + + MockAppPtr mock_app(CreateMockApp()); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillRepeatedly(Return(mock_app)); + ON_CALL(*mock_app, msg_version()) + .WillByDefault(ReturnRef(mock_semantic_version_4_5)); + ON_CALL(*mock_app, is_media_application()).WillByDefault(Return(true)); + + EXPECT_CALL(*mock_app, + UnsubscribeFromButton(mobile_apis::ButtonName::PLAY_PAUSE)) + .WillOnce(Return(true)); + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs( + hmi_apis::FunctionID::Buttons_OnButtonSubscription))); + EXPECT_CALL( + mock_rpc_service_, + ManageMobileCommand(MobileResultCodeIs(mobile_result::SUCCESS), _)); + + EXPECT_CALL(*mock_app, UpdateHash()); + command->Init(); + command->Run(); +} + } // namespace unsubscribe_button_request } // namespace mobile_commands_test } // namespace commands_test diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/unsubscribe_way_points_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/unsubscribe_way_points_request_test.cc index 042604b672..f345d719c6 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/unsubscribe_way_points_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/unsubscribe_way_points_request_test.cc @@ -59,7 +59,7 @@ namespace mobile_result = mobile_apis::Result; using ::testing::_; using ::testing::Return; -using sdl_rpc_plugin::commands::UnSubscribeWayPointsRequest; +using sdl_rpc_plugin::commands::UnsubscribeWayPointsRequest; using am::commands::MessageSharedPtr; namespace { @@ -67,21 +67,21 @@ const uint32_t kConnectionKey = 3u; const uint32_t kAppId = 5u; } // namespace -class UnSubscribeWayPointsRequestTest +class UnsubscribeWayPointsRequestTest : public CommandRequestTest<CommandsTestMocks::kIsNice> { public: - UnSubscribeWayPointsRequestTest() + UnsubscribeWayPointsRequestTest() : command_msg_(CreateMessage(smart_objects::SmartType_Map)) - , command_(CreateCommand<UnSubscribeWayPointsRequest>(command_msg_)) { + , command_(CreateCommand<UnsubscribeWayPointsRequest>(command_msg_)) { (*command_msg_)[am::strings::params][am::strings::connection_key] = kConnectionKey; } MessageSharedPtr command_msg_; - std::shared_ptr<UnSubscribeWayPointsRequest> command_; + std::shared_ptr<UnsubscribeWayPointsRequest> command_; }; -TEST_F(UnSubscribeWayPointsRequestTest, +TEST_F(UnsubscribeWayPointsRequestTest, Run_ApplicationIsNotRegistered_UNSUCCESS) { EXPECT_CALL(app_mngr_, application(_)) .WillOnce(Return(ApplicationSharedPtr())); @@ -94,7 +94,7 @@ TEST_F(UnSubscribeWayPointsRequestTest, command_->Run(); } -TEST_F(UnSubscribeWayPointsRequestTest, +TEST_F(UnsubscribeWayPointsRequestTest, Run_AppIsNotSubscribedForWayPoints_UNSUCCESS) { MockAppPtr mock_app(CreateMockApp()); EXPECT_CALL(app_mngr_, application(kConnectionKey)) @@ -112,7 +112,7 @@ TEST_F(UnSubscribeWayPointsRequestTest, command_->Run(); } -TEST_F(UnSubscribeWayPointsRequestTest, Run_AppSubscribedForWayPoints_SUCCESS) { +TEST_F(UnsubscribeWayPointsRequestTest, Run_AppSubscribedForWayPoints_SUCCESS) { MockAppPtr mock_app(CreateMockApp()); EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(mock_app)); @@ -129,7 +129,7 @@ TEST_F(UnSubscribeWayPointsRequestTest, Run_AppSubscribedForWayPoints_SUCCESS) { command_->Run(); } -TEST_F(UnSubscribeWayPointsRequestTest, OnEvent_UnknownEvent_UNSUCCESS) { +TEST_F(UnsubscribeWayPointsRequestTest, OnEvent_UnknownEvent_UNSUCCESS) { MockAppPtr mock_app(CreateMockApp()); EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(mock_app)); @@ -140,8 +140,8 @@ TEST_F(UnSubscribeWayPointsRequestTest, OnEvent_UnknownEvent_UNSUCCESS) { command_->on_event(event); } -TEST_F(UnSubscribeWayPointsRequestTest, - OnEvent_ReceivedNavigationUnSubscribeWayPointsEvent_SUCCESS) { +TEST_F(UnsubscribeWayPointsRequestTest, + OnEvent_ReceivedNavigationUnsubscribeWayPointsEvent_SUCCESS) { MockAppPtr mock_app(CreateMockApp()); EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillRepeatedly(Return(mock_app)); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/update_turn_list_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/update_turn_list_request_test.cc index acb421af6b..78fca8681a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/update_turn_list_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/update_turn_list_request_test.cc @@ -241,6 +241,66 @@ TEST_F(UpdateTurnListRequestTest, Run_ValidTurnList_SUCCESS) { .asString()); } +TEST_F(UpdateTurnListRequestTest, Run_ValidTurnList_WARNINGS) { + const std::string kNavigationText = "valid_navigation_text"; + + (*command_msg_)[am::strings::msg_params][am::strings::turn_list][0] + [am::strings::navigation_text] = kNavigationText; + (*command_msg_)[am::strings::msg_params][am::strings::turn_list][0] + [am::strings::turn_icon][am::strings::value] = + "valid_turn_icon"; + (*command_msg_)[am::strings::msg_params][am::strings::soft_buttons] = 0; + + MockAppPtr mock_app(CreateMockApp()); + EXPECT_CALL(app_mngr_, application(kConnectionKey)) + .WillOnce(Return(mock_app)); + + EXPECT_CALL(mock_message_helper_, + ProcessSoftButtons((*command_msg_)[am::strings::msg_params], + Eq(mock_app), + Ref(mock_policy_handler_), + Ref(app_mngr_))) + .WillOnce(Return(mobile_result::SUCCESS)); + + EXPECT_CALL( + mock_message_helper_, + VerifyImage( + (*command_msg_)[am::strings::msg_params][am::strings::turn_list][0] + [am::strings::turn_icon], + Eq(mock_app), + Ref(app_mngr_))).WillOnce(Return(mobile_result::WARNINGS)); + + EXPECT_CALL(mock_message_helper_, + SubscribeApplicationToSoftButton(_, _, kFunctionId)); + + MessageSharedPtr result_msg(CatchHMICommandResult(CallRun(*command_))); + ASSERT_TRUE(result_msg != nullptr); + EXPECT_EQ( + hmi_apis::FunctionID::Navigation_UpdateTurnList, + (*result_msg)[am::strings::params][am::strings::function_id].asInt()); + + ASSERT_TRUE((*result_msg)[am::strings::msg_params][am::strings::turn_list][0] + .keyExists(am::hmi_request::navi_text)); + + EXPECT_TRUE((*result_msg)[am::strings::msg_params][am::strings::turn_list][0] + [am::hmi_request::navi_text].keyExists( + am::hmi_request::field_name)); + EXPECT_EQ( + hmi_apis::Common_TextFieldName::turnText, + (*result_msg)[am::strings::msg_params][am::strings::turn_list][0] + [am::hmi_request::navi_text][am::hmi_request::field_name] + .asInt()); + + EXPECT_TRUE((*result_msg)[am::strings::msg_params][am::strings::turn_list][0] + [am::hmi_request::navi_text].keyExists( + am::hmi_request::field_text)); + EXPECT_EQ( + kNavigationText, + (*result_msg)[am::strings::msg_params][am::strings::turn_list][0] + [am::hmi_request::navi_text][am::hmi_request::field_text] + .asString()); +} + TEST_F(UpdateTurnListRequestTest, OnEvent_UnknownEvent_UNSUCCESS) { Event event(hmi_apis::FunctionID::INVALID_ENUM); EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)).Times(0); diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/subscribe_vehicle_data_request.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/subscribe_vehicle_data_request.h index 6e084e0869..7c6e1754da 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/subscribe_vehicle_data_request.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/subscribe_vehicle_data_request.h @@ -113,14 +113,6 @@ class SubscribeVehicleDataRequest app_mngr::ApplicationSharedPtr app, const smart_objects::SmartObject& msg_params) const; - DEPRECATED void CheckVISubscribtions( - app_mngr::ApplicationSharedPtr app, - std::string& out_info, - mobile_apis::Result::eType& out_result_code, - smart_objects::SmartObject& out_response_params, - smart_objects::SmartObject& out_request_params, - bool& out_result); - /** * @brief Checks if current application and other applications * were subscribed to VI, prepare data that need to send to mobile app diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/subscribe_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/subscribe_vehicle_data_request.cc index 41fd35b8b5..65f4fde0b2 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/subscribe_vehicle_data_request.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/subscribe_vehicle_data_request.cc @@ -234,21 +234,6 @@ bool SubscribeVehicleDataRequest::IsSomeoneSubscribedFor( return it != accessor.GetData().end(); } -void SubscribeVehicleDataRequest::CheckVISubscribtions( - ApplicationSharedPtr app, - std::string& out_info, - mobile_apis::Result::eType& out_result_code, - smart_objects::SmartObject& out_response_params, - smart_objects::SmartObject& out_request_params, - bool& out_result) { - CheckVISubscriptions(app, - out_info, - out_result_code, - out_response_params, - out_request_params, - out_result); -} - void SubscribeVehicleDataRequest::CheckVISubscriptions( ApplicationSharedPtr app, std::string& out_info, diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_hmi_command_factory.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_hmi_command_factory.cc index 3855d6733b..9311cea6d7 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_hmi_command_factory.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_hmi_command_factory.cc @@ -89,6 +89,7 @@ app_mngr::CommandSharedPtr VehicleInfoHmiCommandFactory::CreateCommand( message_type_str = "error response"; } + UNUSED(message_type_str); LOG4CXX_DEBUG(logger_, "HMICommandFactory::CreateCommand function_id: " << function_id << ", message type: " << message_type_str); diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_mobile_command_factory.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_mobile_command_factory.cc index caa832dde4..7600afa091 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_mobile_command_factory.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_mobile_command_factory.cc @@ -86,6 +86,7 @@ app_mngr::CommandSharedPtr VehicleInfoMobileCommandFactory::CreateCommand( message_type_str = "notification"; } + UNUSED(message_type_str); LOG4CXX_DEBUG(logger_, "HMICommandFactory::CreateCommand function_id: " << function_id << ", message type: " << message_type_str); |