diff options
Diffstat (limited to 'src/components/application_manager/rpc_plugins/rc_rpc_plugin/include')
28 files changed, 1810 insertions, 96 deletions
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 7aa1aa3dba..82e0a8c13b 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 @@ -69,6 +69,7 @@ class RCOnRemoteControlSettingsNotification private: ResourceAllocationManager& resource_allocation_manager_; InteriorDataManager& interior_data_manager_; + RCConsentManager& rc_consent_manager_; /** * @brief Disalows RC functionality for all RC apps * All registered apps will be unsubsribed from OnInteriorVehicleData diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_set_global_properties_request.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_set_global_properties_request.h new file mode 100644 index 0000000000..64b11c3d7b --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_set_global_properties_request.h @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2019, 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_HMI_RC_SET_GLOBAL_PROPERTIES_REQUEST_H +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_RC_SET_GLOBAL_PROPERTIES_REQUEST_H + +#include "application_manager/commands/request_to_hmi.h" +#include "rc_rpc_plugin/commands/rc_command_request.h" + +namespace rc_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +class RCSetGlobalPropertiesRequest : public app_mngr::commands::RequestToHMI { + public: + /** + * @brief RCSetGlobalPropertiesRequest class constructor + * + * @param message Command message as smart pointer to SmartObject + * @param params structure that contains references to + * parameters used in remote сontrol commands + */ + RCSetGlobalPropertiesRequest( + const app_mngr::commands::MessageSharedPtr& message, + const RCCommandParams& params); + /** + * @brief Execute command + */ + void Run() OVERRIDE; + + ~RCSetGlobalPropertiesRequest(); +}; +} // namespace commands +} // namespace rc_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_RC_SET_GLOBAL_PROPERTIES_REQUEST_H diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_set_global_properties_response.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_set_global_properties_response.h new file mode 100644 index 0000000000..2e1494364c --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/hmi/rc_set_global_properties_response.h @@ -0,0 +1,68 @@ +/* + Copyright (c) 2019, 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_HMI_RC_SET_GLOBAL_PROPERTIES_RESPONSE_H +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_RC_SET_GLOBAL_PROPERTIES_RESPONSE_H + +#include "application_manager/commands/response_from_hmi.h" +#include "rc_rpc_plugin/commands/rc_command_request.h" + +namespace rc_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { +class RCSetGlobalPropertiesResponse + : public application_manager::commands::ResponseFromHMI { + public: + /** + * @brief RCSetGlobalPropertiesResponse class constructor + * + * @param message Command message as smart pointer to SmartObject + * @param params Structure that contains references to + * parameters used in remote сontrol commands + */ + RCSetGlobalPropertiesResponse( + const application_manager::commands::MessageSharedPtr& message, + const RCCommandParams& params); + + /** + * @brief Execute command + */ + void Run() OVERRIDE; + + ~RCSetGlobalPropertiesResponse(); +}; + +} // namespace commands +} // namespace rc_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_RC_SET_GLOBAL_PROPERTIES_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 d6ecfd0128..3946d80508 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 @@ -64,9 +64,11 @@ class ButtonPressRequest : public RCCommandRequest { /** * @brief IsResourceFree check resource state * @param module_type Resource name + * @param module_id Resource id * @return True if free, otherwise - false */ - bool IsResourceFree(const std::string& module_type) const FINAL; + bool IsResourceFree(const std::string& module_type, + const std::string& module_id) const FINAL; /** * @brief SetResourceState changes state of resource @@ -82,12 +84,18 @@ class ButtonPressRequest : public RCCommandRequest { */ void on_event(const app_mngr::event_engine::Event& event) FINAL; - std::string ModuleType() FINAL; + std::string ModuleType() const FINAL; + + std::string ModuleId() const FINAL; /** * @brief ButtonPressRequest class destructor */ ~ButtonPressRequest(); + + private: + const mobile_apis::ButtonName::eType GetButtonId() const; + std::string GetButtonName() const; }; } // namespace commands diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_consent_request.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_consent_request.h new file mode 100644 index 0000000000..c41169d027 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_consent_request.h @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_RC_GET_INTERIOR_VEHICLE_DATA_CONSENT_REQUEST_H +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_RC_GET_INTERIOR_VEHICLE_DATA_CONSENT_REQUEST_H + +#include <string> + +#include "rc_rpc_plugin/commands/rc_command_params.h" +#include "rc_rpc_plugin/commands/rc_command_request.h" +#include "utils/macro.h" + +namespace rc_rpc_plugin { +namespace commands { + +class GetInteriorVehicleDataConsentRequest + : public rc_rpc_plugin::commands::RCCommandRequest { + public: + /** + * @brief GetInteriorVehicleDataConsentRequest constructor + * @param message smart pointer with SmartObject + * @param params structure that contains references to + * parameters used in remote сontrol commands + */ + GetInteriorVehicleDataConsentRequest( + const application_manager::commands::MessageSharedPtr& message, + const RCCommandParams& params); + + /** + * @brief Execute command + */ + void Execute() FINAL; + + void on_event(const app_mngr::event_engine::Event& event) FINAL; + + std::string ModuleType() const FINAL; + + /** + * @brief For this RPC this method isn't correct, because SDL receives array + * of module_ids instead of only one module_id. This method returns empty + * string. + */ + std::string ModuleId() const FINAL; + + ~GetInteriorVehicleDataConsentRequest(); + + private: + /** + * @brief Saves ModuleId consents (saved before moduleids + received moduleId + * consents + date_of_consent) to file. + * + * @param msg_params Message params from response message as SmartObject. + */ + bool SaveModuleIdConsents(std::string& info_out, + const smart_objects::SmartObject& msg_params); + + /** + * @brief Gets calculated vehicle data consent and puts it into provided smart + * object + * @param out_response output smart object + * @return true in case all required consent information was provided in + * output smart object, otherwise returns false + */ + bool GetCalculatedVehicleDataConsent( + smart_objects::SmartObject& out_response) const; + + /** + * @brief Checks whether the user_location is covered by the module's + * serviceArea + * @param module_uid module key(module_type + module_id) + * @return true if the user_location is covered by the module's serviceArea or + * the user is the driver (or if seatLocationCapabilities don't exists) + * otherwise false + */ + bool IsUserLocationValid(const ModuleUid& module_uid) const; + + /** + * @brief Checks whether user should have access to module using the specific + * accessMode's rules + * @param module_uid module key(moudle_type + module_id) + * @param access_mode current HMI accessMode + * @return consent enum value + */ + rc_rpc_types::ModuleConsent GetModuleConsentByAccessMode( + const ModuleUid& module_uid, + const hmi_apis::Common_RCAccessMode::eType access_mode) const; + + smart_objects::SmartObject hmi_request_consents_; +}; + +} // namespace commands +} // namespace rc_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_RC_GET_INTERIOR_VEHICLE_DATA_CONSENT_REQUEST_H diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_consent_response.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_consent_response.h new file mode 100644 index 0000000000..c163b02a80 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/get_interior_vehicle_data_consent_response.h @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_RC_GET_INTERIOR_VEHICLE_DATA_CONSENT_RESPONSE_H +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_RC_GET_INTERIOR_VEHICLE_DATA_CONSENT_RESPONSE_H + +#include "application_manager/commands/command_response_impl.h" +#include "rc_rpc_plugin/commands/rc_command_params.h" +#include "utils/macro.h" + +namespace rc_rpc_plugin { + +namespace commands { + +class GetInteriorVehicleDataConsentResponse + : public application_manager::commands::CommandResponseImpl { + public: + /** + * @brief GetInteriorVehicleDataConsentResponse constructor + * + * @param message smart pointer with SmartObject + * @param params structure which contains references for next + * entities: ApplicationManager, RPCService, HMICapabilities, + * PolicyHandlerInterface, ResourceAllocationManager, InteriorDataCache, + * InteriorDataManager. + */ + GetInteriorVehicleDataConsentResponse( + const application_manager::commands::MessageSharedPtr& message, + const RCCommandParams& params); + + void Run() OVERRIDE; + + ~GetInteriorVehicleDataConsentResponse(); +}; + +} // namespace commands +} // namespace rc_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_RC_GET_INTERIOR_VEHICLE_DATA_CONSENT_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 cfb5e72c95..7be37f0756 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 @@ -63,8 +63,8 @@ class GetInteriorVehicleDataRequest : public RCCommandRequest { ~GetInteriorVehicleDataRequest(); private: - std::vector<application_manager::ApplicationSharedPtr> - AppsSubscribedToModuleType(const std::string& module_type); + std::vector<application_manager::ApplicationSharedPtr> AppsSubscribedToModule( + const ModuleUid& module); /** * @brief Check if app wants to proceed with already setup subscription @@ -87,7 +87,8 @@ class GetInteriorVehicleDataRequest : public RCCommandRequest { */ void RemoveExcessiveSubscription(); - std::string ModuleType() FINAL; + std::string ModuleType() const FINAL; + std::string ModuleId() const FINAL; bool excessive_subscription_occured_; bool ProcessCapabilities(); void ProcessResponseToMobileFromCache(app_mngr::ApplicationSharedPtr app); 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 2a7362510d..4663b4b371 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 @@ -53,13 +53,16 @@ class OnInteriorVehicleDataNotification void Run() OVERRIDE; - std::string ModuleType(); + std::string ModuleType() const; + + std::string ModuleId() const; ~OnInteriorVehicleDataNotification(); private: InteriorDataCache& interior_data_cache_; - void AddDataToCache(const std::string& module_type); + RCCapabilitiesManager& rc_capabilities_manager_; + void AddDataToCache(const ModuleUid& module); }; } // namespace commands } // namespace rc_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/release_interior_vehicle_data_module_request.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/release_interior_vehicle_data_module_request.h new file mode 100644 index 0000000000..316dc29a1d --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/release_interior_vehicle_data_module_request.h @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_RELEASE_INTERIOR_VEHICLE_DATA_MODULE_REQUEST_H +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_RELEASE_INTERIOR_VEHICLE_DATA_MODULE_REQUEST_H + +#include "rc_rpc_plugin/commands/rc_command_params.h" +#include "rc_rpc_plugin/commands/rc_command_request.h" +#include "utils/macro.h" + +namespace rc_rpc_plugin { +namespace commands { + +class ReleaseInteriorVehicleDataModuleRequest + : public rc_rpc_plugin::commands::RCCommandRequest { + public: + /** + * @brief ReleaseInteriorVehicleDataModule constructor + * @param message smart pointer with SmartObject + * @param params structure that contains references to + * parameters used in remote сontrol commands + */ + ReleaseInteriorVehicleDataModuleRequest( + const application_manager::commands::MessageSharedPtr& message, + const RCCommandParams& params); + + void Execute() FINAL; + + std::string ModuleType() const FINAL; + + std::string ModuleId() const FINAL; + + ~ReleaseInteriorVehicleDataModuleRequest(); + + private: + bool ProcessCapabilities(); +}; + +} // namespace commands +} // namespace rc_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_RELEASE_INTERIOR_VEHICLE_DATA_MODULE_REQUEST_H diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/release_interior_vehicle_data_module_response.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/release_interior_vehicle_data_module_response.h new file mode 100644 index 0000000000..42e0775a83 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/mobile/release_interior_vehicle_data_module_response.h @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2019, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_RELEASE_INTERIOR_VEHICLE_DATA_MODULE_RESPONSE_H +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_RELEASE_INTERIOR_VEHICLE_DATA_MODULE_RESPONSE_H + +#include "application_manager/commands/command_response_impl.h" +#include "rc_rpc_plugin/commands/rc_command_params.h" +#include "utils/macro.h" + +namespace rc_rpc_plugin { +namespace commands { + +class ReleaseInteriorVehicleDataModuleResponse + : public application_manager::commands::CommandResponseImpl { + public: + /** + * @brief ReleaseInteriorVehicleDataModuleResponse constructor + * + * @param message smart pointer with SmartObject + * @param params structure which contains references for next + * entities: ApplicationManager, RPCService, HMICapabilities, + * PolicyHandlerInterface, ResourceAllocationManager, InteriorDataCache, + * InteriorDataManager. + */ + ReleaseInteriorVehicleDataModuleResponse( + const application_manager::commands::MessageSharedPtr& message, + const RCCommandParams& params); + + void Run() OVERRIDE; + + ~ReleaseInteriorVehicleDataModuleResponse(); +}; + +} // namespace commands +} // namespace rc_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_COMMANDS_MOBILE_RELEASE_INTERIOR_VEHICLE_DATA_MODULE_RESPONSE_H 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 128c668ee9..bb152a52f8 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 @@ -40,10 +40,6 @@ 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( @@ -66,9 +62,11 @@ class SetInteriorVehicleDataRequest : public RCCommandRequest { /** * @brief IsResourceFree check resource state * @param module_type Resource name + * @param module_id Resource id * @return True if free, otherwise - false */ - bool IsResourceFree(const std::string& module_type) const FINAL; + bool IsResourceFree(const std::string& module_type, + const std::string& module_id) const FINAL; /** * @brief SetResourceState changes state of resource @@ -85,28 +83,14 @@ class SetInteriorVehicleDataRequest : public RCCommandRequest { void on_event(const app_mngr::event_engine::Event& event) FINAL; /** - * @brief Method that check if READ_ONLY parameters present - * @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, - ModuleCapability& module_data_capabilities); - - /** - * @brief Method that check if all request parameters are READ_ONLY - * @param request_params params from received message - * @return true if all are read only , false - otherwise - */ - bool AreAllParamsReadOnly(const smart_objects::SmartObject& module_data); - - /** * @brief Method that cuts-off READ_ONLY parameters * @param module_data params to handle */ void CutOffReadOnlyParams(smart_objects::SmartObject& module_data); - std::string ModuleType() FINAL; + std::string ModuleType() const FINAL; + + std::string ModuleId() const FINAL; /** * @brief SetInteriorVehicleDataRequest class destructor @@ -115,14 +99,6 @@ class SetInteriorVehicleDataRequest : public RCCommandRequest { private: /** - * @brief ControlData - * @param module_data received params - * @return value of module data depending on module type - */ - 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 diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/rc_command_params.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/rc_command_params.h index 0ca7789791..3b46b7ea30 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/rc_command_params.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/commands/rc_command_params.h @@ -50,6 +50,8 @@ namespace rc_rpc_plugin { class ResourceAllocationManager; class InteriorDataCache; class InteriorDataManager; +class RCCapabilitiesManager; +class RCConsentManager; struct RCCommandParams { application_manager::ApplicationManager& application_manager_; @@ -59,6 +61,8 @@ struct RCCommandParams { rc_rpc_plugin::ResourceAllocationManager& resource_allocation_manager_; rc_rpc_plugin::InteriorDataCache& interior_data_cache_; rc_rpc_plugin::InteriorDataManager& interior_data_manager_; + rc_rpc_plugin::RCCapabilitiesManager& rc_capabilities_manager_; + rc_rpc_plugin::RCConsentManager& rc_consent_manager_; }; } // namespace rc_rpc_plugin #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 b4e34c083e..6bca1017e0 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 @@ -37,6 +37,8 @@ #include "rc_rpc_plugin/commands/rc_command_params.h" #include "rc_rpc_plugin/interior_data_cache.h" #include "rc_rpc_plugin/rc_app_extension.h" +#include "rc_rpc_plugin/rc_capabilities_manager.h" +#include "rc_rpc_plugin/rc_consent_manager.h" #include "rc_rpc_plugin/resource_allocation_manager.h" namespace rc_rpc_plugin { @@ -76,6 +78,8 @@ class RCCommandRequest : public app_mngr::commands::CommandRequestImpl { ResourceAllocationManager& resource_allocation_manager_; InteriorDataCache& interior_data_cache_; InteriorDataManager& interior_data_manager_; + RCCapabilitiesManager& rc_capabilities_manager_; + RCConsentManager& rc_consent_manager_; /** * @brief AcquireResource try to allocate resource for application * In case if allocation of resource is not required, return ALLOWED by @@ -94,10 +98,13 @@ class RCCommandRequest : public app_mngr::commands::CommandRequestImpl { * This is default implementation which has to be redefined for RPCs which * need to manage the resources * @param module_type Resource name + * @param module_id Resource id * @return True if free, otherwise - false */ - virtual bool IsResourceFree(const std::string& module_type) const { + virtual bool IsResourceFree(const std::string& module_type, + const std::string& module_id) const { UNUSED(module_type); + UNUSED(module_id); return true; } /** @@ -136,7 +143,24 @@ class RCCommandRequest : public app_mngr::commands::CommandRequestImpl { disallowed_info_ = info; } - virtual std::string ModuleType() = 0; + virtual std::string ModuleType() const = 0; + + /** + * @brief Extracts ModuleId from command message. Each inherited class should + * implement its own functionality + * + * @return ModuleId as string. + */ + virtual std::string ModuleId() const = 0; + + /** + * @brief IsModuleIdProvided checks if moduleId parameter + * is provided in the hmi response + * @param hmi_response response from hmi + * @return true if provided, otherwise - false + */ + + bool IsModuleIdProvided(const smart_objects::SmartObject& hmi_response) const; private: /** @@ -158,9 +182,38 @@ class RCCommandRequest : public app_mngr::commands::CommandRequestImpl { /** * @brief SendGetUserConsent sends consent request to HMI * @param module_type Resource name + * @param module_ids Array of module IDs of the module type that needed user + * consent for acquiring their resources */ - void SendGetUserConsent(const std::string& module_type); + void SendGetUserConsent(const std::string& module_type, + const smart_objects::SmartObject& module_ids); + void ProcessAccessResponse(const app_mngr::event_engine::Event& event); + + /** + * @brief Precesses consents result which has been received from HMI + * If module resource consented, resource state will be switched to state BUSY + * and called method Execute. Otherwise will be sent response to Mobile with + * result code REJECTED. + * @param is_allowed consent result + * @param module_type Module type + * @param module_id Module ID + * @param app_id Application, which has asked for module resource consent. + */ + void ProcessConsentResult(const bool is_allowed, + const std::string& module_type, + const std::string& module_id, + const uint32_t app_id); + /** + * @brief Processes ASK_DRIVE Mode. Tries to retrieve module consents from + * LastState. If consent is absent in LastState, will send + * GetInteriorVehicleDataConsent to HMI. Otherwise will start to process + * consent result. + * @param module_type Module type + * @param module_id Module ID + */ + void ProcessAskDriverMode(const std::string& module_type, + const std::string& module_id); bool IsInterfaceAvailable( const app_mngr::HmiInterfaces::InterfaceID interface) const; 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 index c7dda761bf..dad37edd1b 100644 --- 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 @@ -37,8 +37,15 @@ namespace rc_rpc_plugin { /** + * @brief ModuleUid uniquely identify a module + * moduleType + moduleID + */ +typedef std::pair<std::string, std::string> ModuleUid; + +/** * @brief The InteriorDataCache interface for caching data class - * Provide ability to cache module data by module type name and clear cache + * Provide ability to cache module data by module type name and module id + * and clear cache */ class InteriorDataCache { public: @@ -49,32 +56,35 @@ class InteriorDataCache { /** * @brief Add module data to cache - * @param module_type module type name + * @param module module type + module id * @param module_data data to be cached */ - virtual void Add(const std::string& module_type, + virtual void Add(const ModuleUid& module, const smart_objects::SmartObject& module_data) = 0; /** * @brief Retrieve Get cached data - * @param module_type data type to get from cache + * @param module data type to get from cache * @return smart object with cached data, or nulll smart object */ virtual smart_objects::SmartObject Retrieve( + const ModuleUid& module) const = 0; + + virtual std::vector<ModuleUid> GetCachedModulesByType( 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 + * @param module module name + module id to check in cache * @return true if cached, false otherwize */ - virtual bool Contains(const std::string& module_type) const = 0; + virtual bool Contains(const ModuleUid& module) const = 0; /** * @brief Remove cached data - * @param module_type data type to remove from cache + * @param module data type to remove from cache */ - virtual void Remove(const std::string& module_type) = 0; + virtual void Remove(const ModuleUid& module) = 0; /** * @brief Clear clear all cached data diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/interior_data_cache_impl.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/interior_data_cache_impl.h index b40ce4eb4b..d21b0e4162 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/interior_data_cache_impl.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/interior_data_cache_impl.h @@ -46,16 +46,19 @@ class InteriorDataCacheImpl : public InteriorDataCache { ~InteriorDataCacheImpl(); - void Add(const std::string& module_type, + void Add(const ModuleUid& module, const smart_objects::SmartObject& module_data) OVERRIDE; - smart_objects::SmartObject Retrieve( + smart_objects::SmartObject Retrieve(const ModuleUid& module) const OVERRIDE; + + std::vector<ModuleUid> GetCachedModulesByType( const std::string& module_type) const OVERRIDE; - bool Contains(const std::string& module_type) const OVERRIDE; - void Remove(const std::string& module_type) OVERRIDE; + + bool Contains(const ModuleUid& module) const OVERRIDE; + void Remove(const ModuleUid& module) OVERRIDE; void Clear() OVERRIDE; private: - std::map<std::string, smart_objects::SmartObject> cached_data_; + std::map<ModuleUid, smart_objects::SmartObject> cached_data_; mutable sync_primitives::Lock cached_data_lock_; }; 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 index 157e031869..c1fe30fa4d 100644 --- 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 @@ -41,8 +41,15 @@ namespace rc_rpc_plugin { namespace app_mngr = application_manager; namespace plugins = application_manager::plugin_manager; +/** + * @brief ModuleUid uniquely identify a module + * moduleType + moduleID + */ +typedef std::pair<std::string, std::string> ModuleUid; + class InteriorDataManager { public: + virtual ~InteriorDataManager() {} /** * @brief OnPolicyEvent Processes policy related events * @param event Policy event @@ -67,18 +74,19 @@ class InteriorDataManager { /** * @brief StoreRequestToHMITime save information and time stamp of * current interior data subscriptions + * @param module Module resource (module_type + module_id) */ - virtual void StoreRequestToHMITime(const std::string& module_type) = 0; + virtual void StoreRequestToHMITime(const ModuleUid& module) = 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 + * module in time frame and checks if it bigger then allowed by ini file + * @param module module 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; + virtual bool CheckRequestsToHMIFrequency(const ModuleUid& module) = 0; }; } // namespace rc_rpc_plugin 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 index b98ba596fb..791016cdcd 100644 --- 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 @@ -61,9 +61,9 @@ class InteriorDataManagerImpl : public InteriorDataManager { void OnDisablingRC() OVERRIDE; - void StoreRequestToHMITime(const std::string& module_type) OVERRIDE; + void StoreRequestToHMITime(const ModuleUid& module) OVERRIDE; - bool CheckRequestsToHMIFrequency(const std::string& module_type) OVERRIDE; + bool CheckRequestsToHMIFrequency(const ModuleUid& module) OVERRIDE; private: /** @@ -83,18 +83,20 @@ class InteriorDataManagerImpl : public InteriorDataManager { application_manager::Application& app); /** - * @brief UnsubscribeFromInteriorVehicleData remove module_type from cache and + * @brief UnsubscribeFromInteriorVehicleData remove module from cache and * send RC.GetInteriorVehicleData(subscribe=false) to HMI - * @param module_type module type that need to be unsubscribed + * @param module module that needs to be unsubscribed */ - void UnsubscribeFromInteriorVehicleData(const std::string& module_type); + void UnsubscribeFromInteriorVehicleData(const ModuleUid& module); + + void UnsubscribeFromInteriorVehicleDataOfType(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> > + std::vector<ModuleUid> > AppsModules; /** @@ -104,11 +106,16 @@ class InteriorDataManagerImpl : public InteriorDataManager { */ AppsModules AppsSubscribedModules(); + typedef std::map<application_manager::ApplicationSharedPtr, + std::vector<std::string> > + AppsModuleTypes; + AppsModuleTypes AppsSubscribedModuleTypes(); + /** * @brief RequestsToHMIHistory mapping from module type to vector of time * stamps */ - typedef std::map<std::string, std::deque<date_time::TimeDuration> > + typedef std::map<ModuleUid, std::deque<date_time::TimeDuration> > RequestsToHMIHistory; RequestsToHMIHistory requests_to_hmi_history_; mutable sync_primitives::Lock requests_to_hmi_history_lock_; 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 36fe9f5bdb..33271e64fd 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 @@ -40,6 +40,103 @@ #include "utils/macro.h" namespace rc_rpc_plugin { + +typedef std::pair<std::string, std::string> ModuleUid; + +struct Grid { + int32_t col_; + int32_t row_; + int32_t level_; + int32_t colspan_; + int32_t rowspan_; + int32_t levelspan_; + + Grid() + : col_(0), row_(0), level_(0), colspan_(0), rowspan_(0), levelspan_(0) {} + + Grid(int32_t col, + int32_t row, + int32_t level, + int32_t colspan, + int32_t rowspan, + int32_t levelspan) + : col_(col) + , row_(row) + , level_(level) + , colspan_(colspan) + , rowspan_(rowspan) + , levelspan_(levelspan) {} + + Grid& operator=(const Grid& grid) { + col_ = grid.col_; + row_ = grid.row_; + level_ = grid.level_; + colspan_ = grid.colspan_; + rowspan_ = grid.rowspan_; + levelspan_ = grid.levelspan_; + + return *this; + } + + bool operator==(const Grid& grid) const { + return col_ == grid.col_ && row_ == grid.row_ && level_ == grid.level_ && + colspan_ == grid.colspan_ && rowspan_ == grid.rowspan_ && + levelspan_ == grid.levelspan_; + } + + /** + * @brief LevelIntersectionExists checks if the grids have an + * intersection by levels. + * @param grid with which to check intersection + * @return true if intersection exists, otherwise - false + */ + bool LevelIntersectionExists(const Grid& grid) const { + const int32_t top_level = (level_ + levelspan_) - 1; + const int32_t grid_top_level = (grid.level_ + grid.levelspan_) - 1; + + const int32_t min_level = std::max(level_, grid.level_); + const int32_t max_level = std::min(top_level, grid_top_level); + if ((max_level - min_level) < 0) { + return false; + } + return true; + } + + /** + * @brief IntersectionExists checks if the grids have an + * intersection. Grid can be represented by its bottom-left + * and top-right coordinates like a rectangle. First, the + * coordinates of the intersection are calculated, then checked + * that the rectangle which is formed by the intersections of two + * grids has non-zero width and height. + * @param grid with which to check intersection + * @return true if intersection exists, otherwise - false + */ + bool IntersectionExists(const Grid& grid) const { + if (!LevelIntersectionExists(grid)) { + return false; + } + + const int32_t right_top_col = (col_ + colspan_) - 1; + const int32_t right_top_row = (row_ + rowspan_) - 1; + const int32_t grid_right_top_col = (grid.col_ + grid.colspan_) - 1; + const int32_t grid_right_top_row = (grid.row_ + grid.rowspan_) - 1; + + const int32_t left = std::max(col_, grid.col_); + const int32_t bottom = std::max(row_, grid.row_); + const int32_t right = std::min(right_top_col, grid_right_top_col); + const int32_t top = std::min(right_top_row, grid_right_top_row); + + const int32_t width = right - left; + const int32_t height = top - bottom; + + if ((width < 0) || (height < 0)) { + return false; + } + return true; + } +}; + class RCAppExtension : public application_manager::AppExtension { public: explicit RCAppExtension(application_manager::AppExtensionUID uid); @@ -49,13 +146,15 @@ class RCAppExtension : public application_manager::AppExtension { * @brief Subscribe to OnInteriorVehicleDataNotification * @param module interior data specification(zone, data type) */ - void SubscribeToInteriorVehicleData(const std::string& module_type); + void SubscribeToInteriorVehicleData(const ModuleUid& module); /** * @brief Unsubscribe from OnInteriorVehicleDataNotification * @param module interior data specification(zone, data type) */ - void UnsubscribeFromInteriorVehicleData(const std::string& module_type); + void UnsubscribeFromInteriorVehicleData(const ModuleUid& module); + + void UnsubscribeFromInteriorVehicleDataOfType(const std::string& module_type); /** * @brief UnsubscribeFromInteriorVehicleData removes all subscriptions for @@ -67,16 +166,40 @@ class RCAppExtension : public application_manager::AppExtension { * @brief Check if application subscribed to OnInteriorVehicleDataNotification * @param module interior data specification(zone, data type) */ - bool IsSubscibedToInteriorVehicleData(const std::string& module_type); + bool IsSubscribedToInteriorVehicleData(const ModuleUid& module); + + bool IsSubscribedToInteriorVehicleDataOfType(const std::string& module_type); /** * @brief get list of subscriptions of application * @return list of subscriptions of application */ - std::set<std::string> InteriorVehicleDataSubscriptions() const; + std::set<ModuleUid> InteriorVehicleDataSubscriptions() const; + + /** + * @brief GetUserLocation + * @return grid of user location + */ + Grid GetUserLocation() const; + + /** + * @brief SetUserLocation sets user location + * from object to the grid + * @param user_location smart object for user_location + */ + void SetUserLocation( + const ns_smart_device_link::ns_smart_objects::SmartObject& user_location); + + /** + * @brief SetUserLocation sets user location from grid + * @param grid grid of user_location + */ + void SetUserLocation(const Grid& grid); private: - std::set<std::string> subscribed_interior_vehicle_data_; + std::set<ModuleUid> subscribed_interior_vehicle_data_; + + Grid user_location_; // AppExtension interface public: diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_capabilities_manager.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_capabilities_manager.h new file mode 100644 index 0000000000..36fd8bbbf9 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_capabilities_manager.h @@ -0,0 +1,184 @@ +/* + Copyright (c) 2019, 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_CAPABILITIES_MANAGER_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_CAPABILITIES_MANAGER_H_ +#include "application_manager/application_manager.h" +#include "rc_rpc_plugin/resource_allocation_manager.h" + +namespace rc_rpc_plugin { + +enum capabilitiesStatus { success, missedLightName, missedParam, readOnly }; +typedef std::pair<std::string, capabilitiesStatus> ModuleTypeCapability; + +class RCCapabilitiesManager { + public: + /** + * @brief CheckIfButtonExistInRCCaps checks if the + * specified button exists in rc_capabilities + * @param button button name + * @return true if present, otherwise - false + */ + virtual bool CheckIfButtonExistInRCCaps( + const mobile_apis::ButtonName::eType button) const = 0; + + /** + * @brief CheckButtonName checks if the button + * corresponds to the module_type + * @param module_type resource name + * @param button_name button name + * @return true if they match, otherwise - false + */ + virtual bool CheckButtonName(const std::string& module_type, + const std::string& button_name) const = 0; + + /** + * @brief CheckIfModuleExistsInCapabilities checks + * if the specified module exists in rc_capabilities + * @param module moduleType + moduleId + * @return true if exists, otherwise - false + */ + virtual bool CheckIfModuleExistsInCapabilities( + const ModuleUid& module) const = 0; + + /** + * @brief GetModuleDataCapabilities checks whether rc module data + * capabilities are presented + * @param module_data smart object of module_data + * @param module_id module id + * @return pair of state and capability status - ModuleCapability + */ + virtual ModuleTypeCapability GetModuleDataCapabilities( + const smart_objects::SmartObject& module_data, + const std::string& module_id) const = 0; + + /** + * @brief ControlData retrieves control data + * for specified module type + * @param module_data smart object of module_data + * @param module_type resource name + * @return smart object of control data + */ + virtual const smart_objects::SmartObject& ControlDataForType( + const smart_objects::SmartObject& module_data, + const std::string& module_type) const = 0; + + /** + * @brief AreReadOnlyParamsPresent checks if there are + * any read only params in the module data + * @param module_data smart object of module_data + * @param module_type resource name + * @param module_data_capabilities smart object of capabilities + * @return true if read only params exist, otherwise - false + */ + virtual bool AreReadOnlyParamsPresent( + const smart_objects::SmartObject& module_data, + const std::string& module_type, + ModuleTypeCapability& module_data_capabilities) const = 0; + + /** + * @brief AreAllParamsReadOnly checks that all params from module + * data are read only + * @param module_data smart object of module_data + * @param module_type resource name + * @return true if all params are read only, otherwise - false + */ + virtual bool AreAllParamsReadOnly( + const smart_objects::SmartObject& module_data, + const std::string& module_type) const = 0; + + /** + * @brief GetDefaultModuleIdFromCapabilities returns the moduleId + * from the first item published by xyz-ControlCapabilities + * @param module_type resource name + * @return default module id from HMI capabilities + */ + virtual const std::string GetDefaultModuleIdFromCapabilities( + const std::string& module_type) const = 0; + + /** + * @brief GetResources get list of ModuleUids(moduleType + moduleId) + * of all known resources + * @return vector contains all known moduleUids + */ + virtual const std::vector<ModuleUid> GetResources() const = 0; + + /** + * @brief GetModuleServiceArea retrieves service area of module, + * if module serviceArea is missed in capabilities, serviceArea is + * assumed to be the same as location, if location + * is missed in capabilities, it is assumed that serviceArea covers + * the whole area of vehicle + * @param module module type + module id + * @return Grid of module service area + */ + virtual Grid GetModuleServiceArea(const ModuleUid& module) const = 0; + + /** + * @brief IsMultipleAccessAllowed checks if multiple access allowed + * for requested module + * @param module module type + module id + * @return true if allowed, otherwise - false + */ + virtual bool IsMultipleAccessAllowed(const ModuleUid& module) const = 0; + + /** + * @brief GetDriverLocationFromSeatLocationCapability retrieves the driver's + * location from seat location capabilities + * @return Grid of driver's location + */ + virtual const Grid GetDriverLocationFromSeatLocationCapability() const = 0; + + /** + * @brief IsSeatLocationCapabilityProvided checks whether all necessary + * parameters are provided in seat location capabilities + * @return true if provided, otherwise - false + */ + virtual bool IsSeatLocationCapabilityProvided() const = 0; + + /** + * @brief GetModuleIdForSeatLocation returns the moduleId if request from + * mobile contains the id parameter and doesn't contain the moduleId + * parameter. If the vehicle support at least one seat control, seat control + * capability includes at least two items. SupportedSeat id shall be converted + * to the moduleId according to capabilities: 1st item from capabilities for + * driver’s seat. 2nd item for front passenger’s seat. + * @param id supported seat id + */ + virtual const std::string GetModuleIdForSeatLocation( + mobile_apis::SupportedSeat::eType id) const = 0; + + virtual ~RCCapabilitiesManager() {} +}; + +} // namespace rc_rpc_plugin +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_CAPABILITIES_MANAGER_H_ diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_capabilities_manager_impl.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_capabilities_manager_impl.h new file mode 100644 index 0000000000..844647940f --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_capabilities_manager_impl.h @@ -0,0 +1,200 @@ +/* + Copyright (c) 2019, 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_CAPABILITIES_MANAGER_IMPL_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_CAPABILITIES_MANAGER_IMPL_H_ +#include "application_manager/application_manager.h" +#include "rc_rpc_plugin/rc_capabilities_manager.h" + +namespace rc_rpc_plugin { +class RCCapabilitiesManagerImpl : public RCCapabilitiesManager { + public: + RCCapabilitiesManagerImpl( + application_manager::HMICapabilities& hmi_capabilities); + + bool CheckIfButtonExistInRCCaps( + const mobile_apis::ButtonName::eType button) const FINAL; + + bool CheckButtonName(const std::string& module_type, + const std::string& button_name) const FINAL; + + bool CheckIfModuleExistsInCapabilities(const ModuleUid& module) const FINAL; + + ModuleTypeCapability GetModuleDataCapabilities( + const smart_objects::SmartObject& module_data, + const std::string& module_id) const FINAL; + + const smart_objects::SmartObject& ControlDataForType( + const smart_objects::SmartObject& module_data, + const std::string& module_type) const FINAL; + + bool AreReadOnlyParamsPresent( + const smart_objects::SmartObject& module_data, + const std::string& module_type, + ModuleTypeCapability& module_data_capabilities) const FINAL; + + bool AreAllParamsReadOnly(const smart_objects::SmartObject& module_data, + const std::string& module_type) const FINAL; + + const std::string GetDefaultModuleIdFromCapabilities( + const std::string& module_type) const FINAL; + + const std::vector<ModuleUid> GetResources() const FINAL; + + Grid GetModuleServiceArea(const ModuleUid& module) const FINAL; + + bool IsMultipleAccessAllowed(const ModuleUid& module) const FINAL; + + const Grid GetDriverLocationFromSeatLocationCapability() const FINAL; + + bool IsSeatLocationCapabilityProvided() const FINAL; + + const std::string GetModuleIdForSeatLocation( + mobile_apis::SupportedSeat::eType id) const FINAL; + + private: + const std::map<std::string, std::string> GetLightCapabilitiesMapping() const; + + const std::map<std::string, std::string> GetModuleDataToCapabilitiesMapping() + const; + + /** + * @brief Check whether the exists light data related to correspondent + * capabilities + * @param capabilities smart object of capabilities + * @param control_data smart object of control_data + * @return pair of state and capability status - ModuleTypeCapability + */ + ModuleTypeCapability GetControlDataCapabilities( + const smart_objects::SmartObject& capabilities, + const smart_objects::SmartObject& control_data) const; + + /** + * @brief Check whether the parameter exist in capabilities + * @param capabilities 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 the parameter exists in capabilities, + * otherwise - missedParam + */ + 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; + + /** + * @brief Check whether the capabilities for light are allowed + * @param capabilities smart object of capabilities + * @param control_data smart object of control_data + * @return pair of state and capability status - ModuleTypeCapability + */ + ModuleTypeCapability GetLightDataCapabilities( + const smart_objects::SmartObject& capabilities, + const smart_objects::SmartObject& control_data) const; + + /** + * @brief Check whether the light name exists in capabilities + * @param capabilities_status smart object of capabilities_status + * @param light_data smart object of light_data + * @return pair of state and capability status - ModuleTypeCapability + */ + ModuleTypeCapability GetLightNameCapabilities( + const smart_objects::SmartObject& capabilities_status, + const smart_objects::SmartObject& light_data) const; + + ModuleTypeCapability GetRadioBandByCapabilities( + const smart_objects::SmartObject& capabilities_status, + const smart_objects::SmartObject& request_parameter) const; + + bool CheckReadOnlyParamsForAudio( + const smart_objects::SmartObject& module_type_params) const; + + bool CheckReadOnlyParamsForLight( + const smart_objects::SmartObject& module_type_params) const; + + smart_objects::SmartObject GetCapabilitiesByModuleIdFromArray( + const smart_objects::SmartObject& module_data_capabilities, + const std::string& module_id) const; + + const bool CheckModuleIdWithCapabilities( + const smart_objects::SmartObject& rc_capabilities, + const ModuleUid& module) const; + + const bool CheckModuleIdWithCapabilitiesArrays( + const smart_objects::SmartObject& control_capabilities, + const std::string& module_id) const; + + const bool CheckModuleIdWithCapabilitiesStructure( + const smart_objects::SmartObject& control_capabilities, + const std::string& module_id) const; + + const std::string GetDefaultModuleIdFromCapabilitiesStructure( + const smart_objects::SmartObject& control_capabilities, + const std::string& module_type) const; + + const std::string GetDefaultModuleIdFromCapabilitiesArray( + const smart_objects::SmartObject& control_capabilities, + const std::string& module_type) const; + + const std::vector<std::string> GetCapabilitiesList() const; + + const std::function<std::string(const std::string& control_cap)> + GetCapabilitiesToModuleTypeMapping() const; + + void GetResourcesFromCapabilitiesStructure( + const smart_objects::SmartObject& control_capabilities, + const std::string& capabitity_key, + std::vector<ModuleUid>& out_resources) const; + + void GetResourcesFromCapabilitiesArray( + const smart_objects::SmartObject& control_capabilities, + const std::string& capability_key, + std::vector<ModuleUid>& out_resources) const; + + Grid GetModuleServiceAreaFromControlCapability( + const smart_objects::SmartObject& control_capabilities) const; + + Grid GetModuleLocationFromControlCapability( + const smart_objects::SmartObject& control_capabilities) const; + + bool IsMultipleAccessAllowedInControlCaps( + const smart_objects::SmartObject& control_capabilities) const; + + Grid GetWholeVehicleArea() const; + + application_manager::HMICapabilities& hmi_capabilities_; +}; + +} // namespace rc_rpc_plugin +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RC_CAPABILITIES_MANAGER_IMPL_H_ diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_consent_manager.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_consent_manager.h new file mode 100644 index 0000000000..c8b99cc724 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_consent_manager.h @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2019, 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_CONSENT_MANAGER_H +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_CONSENT_MANAGER_H + +#include <string> + +#include "rc_rpc_types.h" + +namespace ns_smart_device_link { +namespace ns_smart_objects { +class SmartObject; +} // namespace ns_smart_objects +} // namespace ns_smart_device_link + +namespace rc_rpc_plugin { + +class RCConsentManager { + public: + /** + * @brief Saves consents (is_consented + date_of_consent) for module resources + * (module_type + module_id) for specified application + * @param policy_app_id Application id which module consents should be saved + * @param mac_address Device mac address + * @param module_consents - Module resources consents + */ + virtual void SaveModuleConsents( + const std::string& policy_app_id, + const std::string& mac_address, + const rc_rpc_types::ModuleIdConsentVector& module_consents) = 0; + + /** + * @brief Retrieves saved consent for specified module resource (module_type + * + module_id) + * @param app_id Application which related to specified module resource + * @param mac_address Device mac address + * @param module_id Module resource (module_type + module_id) + * @return Module consent state + */ + virtual rc_rpc_plugin::rc_rpc_types::ModuleConsent GetModuleConsent( + const std::string& app_id, + const std::string& mac_address, + const rc_rpc_types::ModuleUid& module_id) = 0; + + /** + * @brief Remove modules consents from LastState if they exist + */ + virtual void RemoveAllConsents() = 0; + + /** + * @brief Remove all expired module consents from LastState + * if they exist + */ + virtual void RemoveExpiredConsents() = 0; + + virtual ~RCConsentManager() {} +}; + +} // namespace rc_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_CONSENT_MANAGER_H diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_consent_manager_impl.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_consent_manager_impl.h new file mode 100644 index 0000000000..5cbc4b977e --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_consent_manager_impl.h @@ -0,0 +1,178 @@ +/* + * Copyright (c) 2019, 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_CONSENT_MANAGER_IMPL_H +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_CONSENT_MANAGER_IMPL_H + +#include "rc_consent_manager.h" +#include "resumption/last_state_wrapper.h" +#include "utils/lock.h" + +namespace Json { +class Value; +} // namespace Json + +namespace rc_rpc_plugin { + +class RCConsentManagerImpl : public RCConsentManager { + public: + RCConsentManagerImpl( + resumption::LastStateWrapperPtr last_state, + application_manager::ApplicationManager& application_manager, + const uint32_t period_of_consent_expired); + + DEPRECATED + RCConsentManagerImpl( + resumption::LastState& last_state, + application_manager::ApplicationManager& application_manager, + const uint32_t period_of_consent_expired); + + void SaveModuleConsents( + const std::string& policy_app_id, + const std::string& mac_address, + const rc_rpc_types::ModuleIdConsentVector& module_consents) OVERRIDE; + + rc_rpc_types::ModuleConsent GetModuleConsent( + const std::string& app_id, + const std::string& mac_address, + const rc_rpc_types::ModuleUid& module_id) OVERRIDE; + + void RemoveExpiredConsents() OVERRIDE; + + void RemoveAllConsents() OVERRIDE; + + ~RCConsentManagerImpl() OVERRIDE; + + private: + /** + * @brief Saves module consents for specified application + * @param app_module_consents Application consents for which new + * consents should be added or existing ones should be overwritten + * @param consent_to_save module consents which should be saved + */ + void SaveAppModuleConsent( + Json::Value& app_module_consents, + const rc_rpc_types::ModuleIdConsent& consent_to_save); + + /** + * @brief Checks if module consent is expired + * @param module_consent Module consent + * @return ModuleConsentState + */ + rc_rpc_types::ModuleConsentState CheckModuleConsentState( + const Json::Value& module_consent) const; + + /** + * @brief Removes devices expired consents + * @param device Device section in AppConsensts section of LastState in Json + */ + void RemoveDeviceExpiredConsents(Json::Value& device); + + /** + * @brief Remove expired module consents which are related to specified + * application + * @param app_consents Application consents + */ + void RemoveAppExpiredConsents(Json::Value& app_consents); + + /** + * @brief Remove expired module consents which are related to specified + * module type + * @param module_consents Module consents wich should be checked for expired + * consents + */ + void RemoveModuleExpiredConsents(Json::Value& module_consents); + + /** + * @brief Get Remote Control section of LastState. + * In case the section is absent, will be appended a new empty section. + * @return Remote Control section of LastState in Json + */ + Json::Value& GetRemoteControlDataOrAppend(Json::Value& last_state_data); + + /** + * @brief Gets Device applications section for specified device mac adress + * In case the section is absent, will be appended a new empty section. + * @param mac_aress Device MAC adress + * @return Device applications section of LastState in Json + */ + Json::Value& GetDeviceApplicationsOrAppend(const std::string& mac_address, + Json::Value& last_state_data); + + /** + * @brief Get AppConsentsList section of LastState for specified application. + * In case the consent list is absent, will be appended a new empty section. + * @param policy_app_id Application policy ID + * @param mac_address Device MAC address + * @return AppConsentsList of LastState in Json + */ + Json::Value& GetAppConsentsListOrAppend(const std::string& policy_app_id, + const std::string& mac_address, + Json::Value& last_state_data); + + /** + * @brief Get Application consents section of Remote Control section of + * LastState with all consents for all applications. In case if this section + * is absent, will be created a new empty section + * @return AppConsents section of RemoteControl section of LastState in Jason + */ + Json::Value& GetAppsConsentsOrAppend(Json::Value& last_state_data); + + /** + * @brief Get all module resource consents for specified application and + * module type. In case if section with specified module type consents is + * absent, will be created a new empty section + * @param policy_app_id Application id which contains specified module type + * @param mac_adress MAC address of mobile device that needs user consent for + * acquiring resource + * @param module_type Module type with consents + */ + Json::Value& GetModuleTypeConsentsOrAppend(const std::string& policy_app_id, + const std::string& mac_address, + const std::string& module_type, + Json::Value& last_state_data); + + private: + application_manager::ApplicationManager& app_manager_; + resumption::LastStateWrapperPtr last_state_; + const uint32_t period_of_consent_expired_; + mutable sync_primitives::Lock dictionary_control_lock_; + mutable sync_primitives::Lock remote_control_lock_; + mutable sync_primitives::Lock device_applications_lock_; + mutable sync_primitives::Lock applications_lock_; + mutable sync_primitives::Lock app_consents_lock_; + mutable sync_primitives::Lock module_consents_lock_; +}; + +} // namespace rc_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_CONSENT_MANAGER_IMPL_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 index e85ab758ad..eed860fc7f 100644 --- 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 @@ -37,6 +37,7 @@ #include <string> #include "application_manager/application.h" #include "rc_rpc_plugin/rc_app_extension.h" +#include "rc_rpc_plugin/rc_rpc_types.h" namespace rc_rpc_plugin { class RCRPCPlugin; @@ -65,10 +66,10 @@ class RCHelpers { GetModuleTypeToCapabilitiesMapping(); /** - * @brief GetModulesList get list of all known modules - * @return vector contains all known modules + * @brief GetModuleTypesList get list of all known module types + * @return vector contains all known module types */ - static const std::vector<std::string> GetModulesList(); + static const std::vector<std::string> GetModuleTypesList(); /** * @brief GetRCExtension extract RC extension from application @@ -80,7 +81,11 @@ class RCHelpers { application_manager::Application& app); static smart_objects::SmartObjectSPtr CreateUnsubscribeRequestToHMI( - const std::string& module_type, const uint32_t correlation_id); + const ModuleUid& module, const uint32_t correlation_id); + + static std::vector<application_manager::ApplicationSharedPtr> + AppsSubscribedToModule(application_manager::ApplicationManager& app_mngr, + const ModuleUid& module); static std::vector<application_manager::ApplicationSharedPtr> AppsSubscribedToModuleType(application_manager::ApplicationManager& app_mngr, @@ -88,10 +93,51 @@ class RCHelpers { typedef std::map<application_manager::ApplicationSharedPtr, std::vector<std::string> > - AppsModules; - static AppsModules GetApplicationsAllowedModules( + AppsModuleTypes; + + static AppsModuleTypes GetApplicationsAllowedModuleTypes( application_manager::ApplicationManager& app_mngr); + typedef std::map<std::string, mobile_apis::ButtonName::eType> ButtonsMap; + + static const std::vector<std::string> buttons_climate(); + + static const std::vector<std::string> buttons_radio(); + + static const ButtonsMap buttons_map(); + + static std::vector<std::string> GetModuleReadOnlyParams( + const std::string& module_type); + + /** + * @brief Combines module ids and alloweds for these ids and fills vector with + * ModuleConsents + * @param module_type Module type as string + * @param module_ids Modules ids which needed consents from driver + * @param allowed Consents for modules + */ + static rc_rpc_types::ModuleIdConsentVector FillModuleConsents( + const std::string& module_type, + const std::vector<std::string>& module_ids, + const std::vector<bool> allowed); + + /** + * @brief Retrieves module ids from SmartObject. + * @param moduleIds Smartobject which contains collection of module ids + * @return Collection of module ids + */ + static std::vector<std::string> RetrieveModuleIds( + const smart_objects::SmartObject& moduleIds); + + /** + * @brief Retrieves module ids consents from SmartObject. + * @param moduleIds Smartobject which contains collection of module ids + * consents + * @return Collection of module ids consents. + */ + static std::vector<bool> RetrieveModuleConsents( + const smart_objects::SmartObject& consents); + /** * @brief RemoveRedundantGPSDataFromVIDataMsg removes redundant GPS data * params from interior vehicle data response message if one contains radio @@ -100,6 +146,29 @@ class RCHelpers { */ static void RemoveRedundantGPSDataFromIVDataMsg( smart_objects::SmartObject& msg_params); + + /** + * @brief MergeModuleData 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 + */ + static smart_objects::SmartObject MergeModuleData( + const smart_objects::SmartObject& data1, + const smart_objects::SmartObject& data2); + + /** + * @brief MergeArray merge two arrays if their elements contain an `id` + * parameter + * @param data1 - initial data + * @param data2 - updated data + * @return updated data1 with any values in data2 if the arrays can be merged, + * otherwise data2 + */ + static smart_objects::SmartObject MergeArray( + const smart_objects::SmartObject& data1, + const smart_objects::SmartObject& data2); }; } // namespace rc_rpc_plugin 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 b9f922a1be..5ee2e0725c 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 @@ -46,10 +46,43 @@ const char khmiSettingsControlCapabilities[] = "hmiSettingsControlCapabilities"; const char kseatControlCapabilities[] = "seatControlCapabilities"; // RemoteControlCapabilities constants -const char kRadioControlData[] = "radioControlData"; -const char kClimateControlData[] = "climateControlData"; +const char kServiceArea[] = "serviceArea"; +const char kLocation[] = "location"; +const char kCol[] = "col"; +const char kRow[] = "row"; +const char kLevel[] = "level"; +const char kColspan[] = "colspan"; +const char kRowspan[] = "rowspan"; +const char kLevelspan[] = "levelspan"; + +// SeatLocationCapability constants +const char kCols[] = "columns"; +const char kRows[] = "rows"; +const char kLevels[] = "levels"; +const char kSeats[] = "seats"; +const char kGrid[] = "grid"; +// SeatLocationCapability constants + +const char kAllowMultipleAccess[] = "allowMultipleAccess"; + const char kSupportedLights[] = "supportedLights"; +// ClimateControlCapabilities +const char kFanSpeedAvailable[] = "fanSpeedAvailable"; +const char kCurrentTemperatureAvailable[] = "currentTemperatureAvailable"; +const char kDesiredTemperatureAvailable[] = "desiredTemperatureAvailable"; +const char kAcEnableAvailable[] = "acEnableAvailable"; +const char kCirculateAirEnableAvailable[] = "circulateAirEnableAvailable"; +const char kAutoModeEnableAvailable[] = "autoModeEnableAvailable"; +const char kDefrostZoneAvailable[] = "defrostZoneAvailable"; +const char kDualModeEnableAvailable[] = "dualModeEnableAvailable"; +const char kAcMaxEnableAvailable[] = "acMaxEnableAvailable"; +const char kVentilationModeAvailable[] = "ventilationModeAvailable"; +const char kHeatedSteeringWheelAvailable[] = "heatedSteeringWheelAvailable"; +const char kHeatedWindshieldAvailable[] = "heatedWindshieldAvailable"; +const char kHeatedMirrorsAvailable[] = "heatedMirrorsAvailable"; +const char kHeatedRearWindowAvailable[] = "heatedRearWindowAvailable"; + // LightControlCapabilities const char kName[] = "name"; const char kStatusAvailable[] = "statusAvailable"; @@ -57,7 +90,50 @@ const char kDensityAvailable[] = "densityAvailable"; const char kRGBColorSpaceAvailable[] = "rgbColorSpaceAvailable"; // RadioControlCapabilities +const char kRadioBandAvailable[] = "radioBandAvailable"; +const char kRadioFrequencyAvailable[] = "radioFrequencyAvailable"; +const char kRdsDataAvailable[] = "rdsDataAvailable"; +const char kAvailableHDsAvailable[] = "availableHDsAvailable"; +const char kHdRadioEnableAvailable[] = "hdRadioEnableAvailable"; +const char kSignalStrengthAvailable[] = "signalStrengthAvailable"; +const char kSignalChangeThresholdAvailable[] = "signalChangeThresholdAvailable"; +const char kRadioEnableAvailable[] = "radioEnableAvailable"; +const char kStateAvailable[] = "stateAvailable"; +const char kSisDataAvailable[] = "sisDataAvailable"; + const char kSiriusxmRadioAvailable[] = "siriusxmRadioAvailable"; + +// SeatControlCapabilities +const char kHeatingEnabledAvailable[] = "heatingEnabledAvailable"; +const char kCoolingEnabledAvailable[] = "coolingEnabledAvailable"; +const char kHeatingLevelAvailable[] = "heatingLevelAvailable"; +const char kCoolingLevelAvailable[] = "coolingLevelAvailable"; +const char kHorizontalPositionAvailable[] = "horizontalPositionAvailable"; +const char kVerticalPositionAvailable[] = "verticalPositionAvailable"; +const char kFrontVerticalPositionAvailable[] = "frontVerticalPositionAvailable"; +const char kBackVerticalPositionAvailable[] = "backVerticalPositionAvailable"; +const char kBackTiltAngleAvailable[] = "backTiltAngleAvailable"; +const char kHeadSupportHorizontalPositionAvailable[] = + "headSupportHorizontalPositionAvailable"; +const char kHeadSupportVerticalPositionAvailable[] = + "headSupportVerticalPositionAvailable"; +const char kMassageEnabledAvailable[] = "massageEnabledAvailable"; +const char kMassageModeAvailable[] = "massageModeAvailable"; +const char kMassageCushionFirmnessAvailable[] = + "massageCushionFirmnessAvailable"; +const char kMemoryAvailable[] = "memoryAvailable"; + +// AudioControlCapabilities +const char kSourceAvailable[] = "sourceAvailable"; +const char kKeepContextAvailable[] = "keepContextAvailable"; +const char kVolumeAvailable[] = "volumeAvailable"; +const char kEqualizerAvailable[] = "equalizerAvailable"; + +// HmiSettingsCapabilities +const char kDistanceUnitAvailable[] = "distanceUnitAvailable"; +const char kTemperatureUnitAvailable[] = "temperatureUnitAvailable"; +const char kDisplayModeUnitAvailable[] = "displayModeUnitAvailable"; + } // namespace strings namespace result_codes { @@ -106,6 +182,20 @@ namespace message_params { const char kName[] = "name"; const char kId[] = "id"; +// RCConsentManager, ResumptionCtrl, GetInteriorVehicleDataConsent request +const char kModuleId[] = "moduleId"; +const char kModuleInfo[] = "moduleInfo"; +const char kAppConsents[] = "appConsents"; +const char kAppConsentList[] = "appConsentsList"; +const char kConsent[] = "consent"; +const char kConsentDate[] = "consentDate"; +const char kModuleConsents[] = "moduleConsents"; +const char kAppId[] = "appId"; +const char kModuleIds[] = "moduleIds"; +const char kMacAddress[] = "macAddress"; +const char kApplications[] = "applications"; +// RCConsentManager, ResumptionCtrl, GetInteriorVehicleDataConsent request + // SetInteriorVehicleData request const char kModuleData[] = "moduleData"; // SetInteriorVehicleData request @@ -153,6 +243,7 @@ const char kRdsData[] = "rdsData"; const char kHdRadioEnable[] = "hdRadioEnable"; const char kAvailableHDs[] = "availableHDs"; const char kAvailableHdChannels[] = "availableHdChannels"; +const char kAvailableHdChannelsAvailable[] = "availableHdChannelsAvailable"; const char kHdChannel[] = "hdChannel"; const char kSignalStrength[] = "signalStrength"; const char kSignalChangeThreshold[] = "signalChangeThreshold"; @@ -181,6 +272,23 @@ const char kClimateEnable[] = "climateEnable"; const char kClimateEnableAvailable[] = "climateEnableAvailable"; // ClimateControlData struct +// SeatControlData +const char kHeatingEnabled[] = "heatingEnabled"; +const char kCoolingEnabled[] = "coolingEnabled"; +const char kHeatingLevele[] = "heatingLevel"; +const char kCoolingLevel[] = "coolingLevel"; +const char kHorizontalPosition[] = "horizontalPosition"; +const char kVerticalPosition[] = "verticalPosition"; +const char kFrontVerticalPosition[] = "frontVerticalPosition"; +const char kBackVerticalPosition[] = "backVerticalPosition"; +const char kBackTiltAngle[] = "backTiltAngle"; +const char kHeadSupportHorizontalPosition[] = "headSupportHorizontalPosition"; +const char kHeadSupportVerticalPosition[] = "headSupportVerticalPosition"; +const char kMassageEnabled[] = "massageEnabled"; +const char kMassageMode[] = "massageMode"; +const char kMassageCushionFirmness[] = "massageCushionFirmness"; +const char kMemory[] = "memory"; + // LightControlData const char kLightState[] = "lightState"; const char kLightStatus[] = "status"; @@ -189,10 +297,15 @@ const char kLightColor[] = "color"; // AudioControlData const char kSource[] = "source"; +const char kVolume[] = "volume"; const char kKeepContext[] = "keepContext"; const char kEqualizerSettings[] = "equalizerSettings"; const char kChannelName[] = "channelName"; +// HmiSettingsControlData +const char kDistanceUnit[] = "distanceUnit"; +const char kDisplayMode[] = "displayMode"; + // ModuleData struct const char kRadioControlData[] = "radioControlData"; const char kClimateControlData[] = "climateControlData"; @@ -206,6 +319,15 @@ const char kHMIAppID[] = "appID"; const char kHmiLevel[] = "hmiLevel"; const char kSysContext[] = "systemContext"; const char kAudioState[] = "audioStreamingState"; + +// Grid struct +const char kCol[] = "col"; +const char kRow[] = "row"; +const char kLevel[] = "level"; +const char kColspan[] = "colspan"; +const char kRowspan[] = "rowspan"; +const char kLevelspan[] = "levelspan"; + } // namespace message_params namespace enums_value { 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 303b31f857..e12bd88e58 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 @@ -39,6 +39,8 @@ #include "application_manager/plugin_manager/rpc_plugin.h" #include "rc_rpc_plugin/interior_data_cache.h" #include "rc_rpc_plugin/interior_data_manager.h" +#include "rc_rpc_plugin/rc_capabilities_manager.h" +#include "rc_rpc_plugin/rc_consent_manager.h" #include "rc_rpc_plugin/resource_allocation_manager.h" namespace rc_rpc_plugin { @@ -58,7 +60,15 @@ class RCRPCPlugin : public plugins::RPCPlugin { bool Init(app_mngr::ApplicationManager& app_manager, app_mngr::rpc_service::RPCService& rpc_service, app_mngr::HMICapabilities& hmi_capabilities, - policy::PolicyHandlerInterface& policy_handler) OVERRIDE; + policy::PolicyHandlerInterface& policy_handler, + resumption::LastStateWrapperPtr last_state) OVERRIDE; + + DEPRECATED + bool Init(app_mngr::ApplicationManager& app_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler, + resumption::LastState& last_state) OVERRIDE; /** * @param int32_t command id * @param CommandSource source @@ -101,13 +111,16 @@ class RCRPCPlugin : public plugins::RPCPlugin { private: application_manager::rpc_service::RPCService* rpc_service_; application_manager::ApplicationManager* app_mngr_; + std::unique_ptr<rc_rpc_plugin::RCConsentManager> rc_consent_manager_; 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_; + std::unique_ptr<RCCapabilitiesManager> rc_capabilities_manager_; }; } // namespace rc_rpc_plugin extern "C" application_manager::plugin_manager::RPCPlugin* Create(); +extern "C" void Delete(application_manager::plugin_manager::RPCPlugin* data); #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/rc_rpc_types.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_rpc_types.h new file mode 100644 index 0000000000..3698728aa6 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_rpc_types.h @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2019, 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_TYPES_H +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_TYPES_H + +#include <ctime> +#include <string> +#include <utility> +#include <vector> + +namespace resumption { +class LastState; +} // namespace resumption + +namespace application_manager { +class ApplicationManager; +} // namespace application_manager + +namespace rc_rpc_plugin { +namespace rc_rpc_types { +/** + * @brief Module resource (module_type(first) + module_id(second)) + */ +typedef std::pair<std::string, std::string> ModuleUid; + +/** + * @brief Module consent enum. + */ +enum class ModuleConsent { + NOT_EXISTS = 0, /**< Consent is absent for specified module resource */ + CONSENTED, /**< Module resource is consented */ + NOT_CONSENTED /**< Module resource isn't consented */ +}; + +enum class ModuleConsentState { + NOT_EXISTS = 0, /**< Consent is absent for specified module resource */ + EXPIRED, /**< Module resource is expired */ + ACTIVE /**< Module resource isn't expired */ +}; + +/** + * @brief Module consent + * @param module_id - Module resource for consent + * @param consent - Is module resource consented by driver + * @param date_of_consent - Date, when module resource has been consented (in + * seconds [UNIX time]) + */ +struct ModuleIdConsent { + ModuleUid module_id; + ModuleConsent consent; + std::time_t date_of_consent; +}; + +/** + * @brief ModuleIdConsent collection + */ +typedef std::vector<ModuleIdConsent> ModuleIdConsentVector; +} // namespace rc_rpc_types +} // namespace rc_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_TYPES_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 6dfc794648..ee0bd11885 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 @@ -69,55 +69,84 @@ enum eType { APP_REGISTRATION = 0, MODULE_ALLOCATION, RC_STATE_CHANGING }; } // namespace NotificationTrigger /** + * Defines result of releasing specified module type resource. + */ +namespace ResourceReleasedState { +/** + * NOT_ALLOCATED Module's resource is not allocated + * IS_ALLOCATED Module's resource is already allocated by + * different application + * IS_RELEASED Module's resource is released. + */ +enum eType { NOT_ALLOCATED = 0, IS_ALLOCATED, IS_RELEASED }; +} // namespace ResourceReleasedState + +/** + * @brief ModuleUid uniquely identify a module + * moduleType + moduleID + */ +typedef std::pair<std::string, std::string> ModuleUid; + +/** * @brief Resources defines list of resources */ -typedef std::vector<std::string> Resources; +typedef std::vector<ModuleUid> Resources; class ResourceAllocationManager { public: /** * @brief AcquireResource acquires resource by application * @param module_type resource to acquire + * @param module_id uuid of a resource * @param app_id application that acquire resource * @return ALLOWED if resource acquired \ * IN_USE if resource already acquired * ASK_DRIVER if driver confirmation is required */ virtual AcquireResult::eType AcquireResource(const std::string& module_type, + const std::string& module_id, const uint32_t app_id) = 0; /** * @brief SetResourceState changes resource state. Resource must be acquired * beforehand. * @param module_type Resource to change its state + * @param module_id uuid of a resource * @param app_id Application aquired resource before * @param state State to set for resource */ virtual void SetResourceState(const std::string& module_type, + const std::string& module_id, const uint32_t app_id, const ResourceState::eType state) = 0; /** * @brief IsResourceFree check resource state * @param module_type Resource name + * @param module_id uuid of a resource * @return True if free, otherwise - false */ - virtual bool IsResourceFree(const std::string& module_type) const = 0; + virtual bool IsResourceFree(const std::string& module_type, + const std::string& module_id) const = 0; /** * @brief AcquireResource forces acquiring resource by application * @param module_type resource to acquire + * @param module_id uuid of a resource * @param app_id application that acquire resource */ virtual void ForceAcquireResource(const std::string& module_type, + const std::string& module_id, const uint32_t app_id) = 0; /** * @brief OnDriverDisallowed callback for rejecting acquiring resource * @param module_type resource type + * @param module_id uuid of a resource * @param app_id application id */ virtual void OnDriverDisallowed(const std::string& module_type, + const std::string& module_id, const uint32_t app_id) = 0; /** @@ -171,6 +200,42 @@ class ResourceAllocationManager { virtual void set_rc_enabled(const bool value) = 0; + /** + * @brief ReleaseResource Releases resource acquired by application + * @param module_type Module name + * @param module_id uuid of a module + * @param application_id Application id + */ + virtual ResourceReleasedState::eType ReleaseResource( + const std::string& module_type, + const std::string& module_id, + const uint32_t application_id) = 0; + + /** + * @brief SetResourceAquired mark resourse as aquired and process logic of + * changing state of aquired resources + * @param module_type resource name + * @param module_id uuid of a resource + * @param app applicastion that aquire resource + */ + virtual void SetResourceAcquired(const std::string& module_type, + const std::string& module_id, + const uint32_t app_id) = 0; + + /** + * @brief Checks if specific resource is already aquired by specific + * application + * @param moduleUid Module resurce (module type + module ID) + * @param app_id Application ID which try to aquire resource + * @return true In case when resource is already aquired by specific + * application + * @return false In case when isn't aquired by specific + * application + */ + virtual bool IsResourceAlreadyAcquiredByApp( + const rc_rpc_plugin::ModuleUid& moduleUid, + const uint32_t app_id) const = 0; + virtual ~ResourceAllocationManager() {} }; 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 c0ef971235..0fd5449912 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 @@ -34,6 +34,7 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_RC_RPC_PLUGIN_INCLUDE_RC_RPC_PLUGIN_RESOURCE_ALLOCATION_MANAGER_IMPL_H_ #include "application_manager/application_impl.h" #include "rc_rpc_plugin/rc_app_extension.h" +#include "rc_rpc_plugin/rc_capabilities_manager.h" #include "rc_rpc_plugin/resource_allocation_manager.h" #include "utils/lock.h" #include "utils/macro.h" @@ -46,43 +47,52 @@ class ResourceAllocationManagerImpl : public ResourceAllocationManager { public: ResourceAllocationManagerImpl( application_manager::ApplicationManager& app_mngr, - application_manager::rpc_service::RPCService& rpc_service); + application_manager::rpc_service::RPCService& rpc_service, + rc_rpc_plugin::RCCapabilitiesManager& rc_capabilities_manager); ~ResourceAllocationManagerImpl(); /** * @brief AcquireResource forces acquiring resource by application * @param module_type resource to acquire + * @param module_id uuid of a resource * @param app_id application that acquire resourc * @return result of acauiring resources */ AcquireResult::eType AcquireResource(const std::string& module_type, + const std::string& module_id, const uint32_t app_id) OVERRIDE FINAL; /** * @brief ForceAcquireResource forces acquiring resource by application * @param module_type resource to acquire + * @param module_id uuid of a resource * @param app_id application that acquire resource */ void ForceAcquireResource(const std::string& module_type, + const std::string& module_id, const uint32_t app_id) FINAL; /** * @brief SetResourceState changes resource state. Resource must be acquired * beforehand. * @param module_type Resource to change its state + * @param module_id uuid of a resource * @param app_id Application aquired resource before * @param state State to set for resource */ void SetResourceState(const std::string& module_type, + const std::string& module_id, const uint32_t app_id, const ResourceState::eType state) FINAL; /** * @brief IsResourceFree check resource state * @param module_type Resource name + * @param module_id uuid of a resource * @return True if free, otherwise - false */ - bool IsResourceFree(const std::string& module_type) const FINAL; + bool IsResourceFree(const std::string& module_type, + const std::string& module_id) const FINAL; void SetAccessMode( const hmi_apis::Common_RCAccessMode::eType access_mode) FINAL; @@ -90,6 +100,7 @@ class ResourceAllocationManagerImpl : public ResourceAllocationManager { hmi_apis::Common_RCAccessMode::eType GetAccessMode() const FINAL; void OnDriverDisallowed(const std::string& module_type, + const std::string& module_id, const uint32_t app_id) FINAL; /** @@ -118,6 +129,18 @@ class ResourceAllocationManagerImpl : public ResourceAllocationManager { void set_rc_enabled(const bool value) FINAL; + ResourceReleasedState::eType ReleaseResource( + const std::string& module_type, + const std::string& module_id, + const uint32_t application_id) FINAL; + + void SetResourceAcquired(const std::string& module_type, + const std::string& module_id, + const uint32_t app_id) FINAL; + + bool IsResourceAlreadyAcquiredByApp(const rc_rpc_plugin::ModuleUid& moduleUid, + const uint32_t app_id) const FINAL; + private: typedef std::vector<application_manager::ApplicationSharedPtr> Apps; @@ -137,20 +160,23 @@ class ResourceAllocationManagerImpl : public ResourceAllocationManager { * @brief IsModuleTypeRejected check if current resource was rejected by * driver for current application * @param module_type resource to check + * @param module_id uuid of a resource * @param app_id application id * @return true if current resource was rejected by driver for current * application, otherwise - false */ bool IsModuleTypeRejected(const std::string& module_type, + const std::string& module_id, const uint32_t app_id); /** - * @brief ReleaseResource Releases resource acquired by application + * @brief ReleaseModuleType Releases all resources related to + * the corresponding module type acquired by application * @param module_type Module name * @param application_id Application id */ - void ReleaseResource(const std::string& module_type, - const uint32_t application_id); + void ReleaseModuleType(const std::string& module_type, + const uint32_t application_id); /** * @brief GetAcquiredResources Provides resources acquired by particular @@ -161,6 +187,15 @@ class ResourceAllocationManagerImpl : public ResourceAllocationManager { Resources GetAcquiredResources(const uint32_t application_id) const; /** + * @brief GetAcquiredModuleTypes Provides module types acquired by particular + * application currently + * @param application_id Application id + * @return List of acquired module types by specific application + */ + std::set<std::string> GetAcquiredModuleTypes( + const uint32_t application_id) const; + + /** * @brief ProcessApplicationPolicyUpdate Checks if allowed modules list is * changed for registered RC applications and releases in case some modules * now out of the list @@ -175,33 +210,38 @@ class ResourceAllocationManagerImpl : public ResourceAllocationManager { void RemoveAppsSubscriptions(const Apps& apps); /** - * @brief SetResourceAquired mark resourse as aquired and process logic of + * @brief SetResourceFree mark resourse as free and process logic of * changing state of aquired resources * @param module_type resource name + * @param module_id uuid of a resource * @param app applicastion that aquire resource */ - void SetResourceAquired(const std::string& module_type, - const uint32_t app_id); + ResourceReleasedState::eType SetResourceFree(const std::string& module_type, + const std::string& module_id, + const uint32_t app_id); /** - * @brief SetResourceFree mark resourse as free and process logic of - * changing state of aquired resources - * @param module_type resource name - * @param app applicastion that aquire resource + * @brief CheckLocation checks if the user's grid is equal to or is within the + * service area of the module, or user location is driver's seat + * @param module module type + module id + * @return true if the user's grid equals to or is within module service + * area or user location is driver's seat, otherwise - false */ - void SetResourceFree(const std::string& module_type, const uint32_t app_id); + bool IsUserLocationValid(ModuleUid& module, + application_manager::ApplicationSharedPtr app); /** * @brief AllocatedResources contains link between resource and application * owning that resource */ - typedef std::map<std::string, uint32_t> AllocatedResources; + + typedef std::map<ModuleUid, uint32_t> AllocatedResources; AllocatedResources allocated_resources_; mutable sync_primitives::Lock allocated_resources_lock_; /** * @brief ResourcesState contains states of ALLOCATED resources */ - typedef std::map<std::string, ResourceState::eType> ResourcesState; + typedef std::map<ModuleUid, ResourceState::eType> ResourcesState; ResourcesState resources_state_; mutable sync_primitives::Lock resources_state_lock_; @@ -210,13 +250,14 @@ class ResourceAllocationManagerImpl : public ResourceAllocationManager { * driver for application * application_id : [vector of rejected resources] */ - typedef std::map<uint32_t, std::vector<std::string> > RejectedResources; + typedef std::map<uint32_t, std::vector<ModuleUid> > RejectedResources; RejectedResources rejected_resources_for_application_; mutable sync_primitives::Lock rejected_resources_for_application_lock_; hmi_apis::Common_RCAccessMode::eType current_access_mode_; application_manager::ApplicationManager& app_mngr_; application_manager::rpc_service::RPCService& rpc_service_; + rc_rpc_plugin::RCCapabilitiesManager& rc_capabilities_manager_; bool is_rc_enabled_; }; } // namespace rc_rpc_plugin |