diff options
author | Alexander Kutsan <akutsan@luxoft.com> | 2017-08-10 14:07:09 +0300 |
---|---|---|
committer | Andrey Oleynik <aoleynik@luxoft.com> | 2017-08-16 22:34:23 +0300 |
commit | 59f437dc8608e1ec54c517416a39860d9a7be3b8 (patch) | |
tree | 2908c276bd5ea066741c034eb2bd144682ba8649 /src/components/application_manager/include | |
parent | 06729e8b744374a4d9694f669101b6c554ce42e0 (diff) | |
download | sdl_core-59f437dc8608e1ec54c517416a39860d9a7be3b8.tar.gz |
Implementation of Remote Control plugin
Stype changes after integration
Fix policy handler remote unit tests
Diffstat (limited to 'src/components/application_manager/include')
6 files changed, 412 insertions, 11 deletions
diff --git a/src/components/application_manager/include/application_manager/application.h b/src/components/application_manager/include/application_manager/application.h index aa0227efda..01b305e876 100644 --- a/src/components/application_manager/include/application_manager/application.h +++ b/src/components/application_manager/include/application_manager/application.h @@ -42,6 +42,7 @@ #include "utils/data_accessor.h" #include "interfaces/MOBILE_API.h" #include "connection_handler/device.h" +#include "application_manager/app_extension.h" #include "application_manager/message.h" #include "application_manager/hmi_state.h" #include "application_manager/application_state.h" @@ -384,7 +385,6 @@ class Application : public virtual InitialApplicationData, public: enum ApplicationRegisterState { kRegistered = 0, kWaitingForRegistration }; - public: Application() : is_greyed_out_(false) {} virtual ~Application() {} @@ -786,6 +786,31 @@ class Application : public virtual InitialApplicationData, */ virtual uint32_t GetAvailableDiskSpace() = 0; +#ifdef SDL_REMOTE_CONTROL + virtual void set_system_context( + const mobile_api::SystemContext::eType& system_context) = 0; + virtual void set_audio_streaming_state( + const mobile_api::AudioStreamingState::eType& state) = 0; + virtual bool IsSubscribedToInteriorVehicleData( + smart_objects::SmartObject module) = 0; + virtual bool SubscribeToInteriorVehicleData( + smart_objects::SmartObject module) = 0; + virtual bool UnsubscribeFromInteriorVehicleData( + smart_objects::SmartObject module) = 0; + virtual void set_hmi_level(const mobile_api::HMILevel::eType& hmi_level) = 0; + + /** + * @brief Return pointer to extension by uid + * @param uid uid of extension + * @return Pointer to extension, if extension was initialized, otherwise NULL + */ + virtual AppExtensionPtr QueryInterface(AppExtensionUID uid) = 0; + virtual bool AddExtension(AppExtensionPtr extention) = 0; + virtual bool RemoveExtension(AppExtensionUID uid) = 0; + virtual void RemoveExtensions() = 0; + virtual const std::set<uint32_t>& SubscribesIVI() const = 0; +#endif // SDL_REMOTE_CONTROL + protected: mutable sync_primitives::Lock hmi_states_lock_; @@ -800,6 +825,7 @@ class Application : public virtual InitialApplicationData, typedef utils::SharedPtr<Application> ApplicationSharedPtr; typedef utils::SharedPtr<const Application> ApplicationConstSharedPtr; +typedef uint32_t ApplicationId; } // namespace application_manager diff --git a/src/components/application_manager/include/application_manager/application_impl.h b/src/components/application_manager/include/application_manager/application_impl.h index 089be323cf..979abe945d 100644 --- a/src/components/application_manager/include/application_manager/application_impl.h +++ b/src/components/application_manager/include/application_manager/application_impl.h @@ -38,6 +38,7 @@ #include <vector> #include <utility> #include <list> +#include <forward_list> #include <stdint.h> #include "utils/date_time.h" @@ -64,7 +65,8 @@ using namespace timer; namespace mobile_api = mobile_apis; namespace custom_str = custom_string; -class ApplicationImpl : public virtual InitialApplicationDataImpl, +class ApplicationImpl : public virtual Application, + public virtual InitialApplicationDataImpl, public virtual DynamicApplicationDataImpl { public: ApplicationImpl( @@ -188,9 +190,18 @@ class ApplicationImpl : public virtual InitialApplicationDataImpl, DataAccessor<VehicleInfoSubscriptions> SubscribedIVI() const OVERRIDE; inline bool IsRegistered() const OVERRIDE; - /** - * @brief ResetDataInNone reset data counters in NONE - */ +#ifdef SDL_REMOTE_CONTROL + bool SubscribeToInteriorVehicleData( + smart_objects::SmartObject module) OVERRIDE; + bool IsSubscribedToInteriorVehicleData( + smart_objects::SmartObject module) OVERRIDE; + bool UnsubscribeFromInteriorVehicleData( + smart_objects::SmartObject module) OVERRIDE; + +#endif // SDL_REMOTE_CONTROL + /** + * @brief ResetDataInNone reset data counters in NONE + */ virtual void ResetDataInNone(); virtual DataAccessor<ButtonSubscriptions> SubscribedButtons() const OVERRIDE; @@ -306,6 +317,39 @@ class ApplicationImpl : public virtual InitialApplicationDataImpl, */ uint32_t GetAvailableDiskSpace() OVERRIDE; +#ifdef SDL_REMOTE_CONTROL + /** + * @brief Sets current system context + * @param system_context new system context + */ + void set_system_context( + const mobile_api::SystemContext::eType& system_context) OVERRIDE; + /** + * @brief Sets current audio streaming state + * @param state new audio streaming state + */ + void set_audio_streaming_state( + const mobile_api::AudioStreamingState::eType& state) OVERRIDE; + /** + * @brief Sets current HMI level + * @param hmi_level new HMI level + */ + void set_hmi_level(const mobile_api::HMILevel::eType& hmi_level) OVERRIDE; + + /** + * @brief Get list of subscriptions to vehicle info notifications + * @return list of subscriptions to vehicle info notifications + */ + const std::set<uint32_t>& SubscribesIVI() const OVERRIDE; + + /** + * @brief Return pointer to extension by uid + * @param uid uid of extension + * @return Pointer to extension, if extension was initialized, otherwise NULL + */ + AppExtensionPtr QueryInterface(AppExtensionUID uid) OVERRIDE; +#endif + protected: /** * @brief Clean up application folder. Persistent files will stay @@ -335,6 +379,27 @@ class ApplicationImpl : public virtual InitialApplicationDataImpl, */ void OnAudioStreamSuspend(); +#ifdef SDL_REMOTE_CONTROL + /** + * @brief Add extension to application + * @param extension pointer to extension + * @return true if success, false if extension already initialized + */ + bool AddExtension(AppExtensionPtr extention) OVERRIDE; + + /** + * @brief Remove extension from application + * @param uid uid of extension + * @return true if success, false if extension is not present + */ + bool RemoveExtension(AppExtensionUID uid) OVERRIDE; + + /** + * @brief Removes all extensions + */ + void RemoveExtensions() OVERRIDE; +#endif // SDL_REMOTE_CONTROL + std::string hash_val_; uint32_t grammar_id_; @@ -384,6 +449,13 @@ class ApplicationImpl : public virtual InitialApplicationDataImpl, Timer video_stream_suspend_timer_; Timer audio_stream_suspend_timer_; +#ifdef SDL_REMOTE_CONTROL + std::list<AppExtensionPtr> extensions_; + + std::forward_list<smart_objects::SmartObject> + subscribed_interior_vehicle_data_; +#endif // SDL_REMOTE_CONTROL + /** * @brief Defines number per time in seconds limits */ diff --git a/src/components/application_manager/include/application_manager/application_manager_impl.h b/src/components/application_manager/include/application_manager/application_manager_impl.h index c0b7b7bd46..f0afbc78b2 100644 --- a/src/components/application_manager/include/application_manager/application_manager_impl.h +++ b/src/components/application_manager/include/application_manager/application_manager_impl.h @@ -59,6 +59,7 @@ #include "protocol_handler/protocol_handler.h" #include "hmi_message_handler/hmi_message_observer.h" #include "hmi_message_handler/hmi_message_sender.h" +#include "application_manager/policies/policy_handler_interface.h" #include "application_manager/policies/policy_handler_observer.h" #include "connection_handler/connection_handler.h" #include "connection_handler/connection_handler_observer.h" @@ -264,6 +265,72 @@ class ApplicationManagerImpl void SendHMIStatusNotification( const utils::SharedPtr<Application> app) OVERRIDE; + +#ifdef SDL_REMOTE_CONTROL + ApplicationSharedPtr application( + const std::string& device_id, + const std::string& policy_app_id) const OVERRIDE; + + uint32_t GetDeviceHandle(uint32_t connection_key) OVERRIDE; + /** + * @brief ChangeAppsHMILevel the function that will change application's + * hmi level. + * + * @param app_id id of the application whose hmi level should be changed. + * + * @param level new hmi level for certain application. + */ + void ChangeAppsHMILevel(uint32_t app_id, mobile_apis::HMILevel::eType level); + /** + * @brief MakeAppNotAudible allows to make certain application not audible. + * + * @param app_id applicatin's id whose audible state should be changed. + */ + void MakeAppNotAudible(uint32_t app_id); + + /** + * @brief MakeAppFullScreen allows ti change application's properties + * in order to make it full screen. + * + * @param app_id the id of application which should be in full screen mode. + * + * @return true if operation was success, false otherwise. + */ + bool MakeAppFullScreen(uint32_t app_id); + + /** + * @brief Subscribes to notification from HMI + * @param hmi_notification string with notification name + */ + void SubscribeToHMINotification(const std::string& hmi_notification) OVERRIDE; + + /** + * @brief Checks HMI level and returns true if audio streaming is allowed + */ + bool IsAudioStreamingAllowed(uint32_t connection_key) const OVERRIDE; + + /** + * @brief Checks HMI level and returns true if video streaming is allowed + */ + bool IsVideoStreamingAllowed(uint32_t connection_key) const OVERRIDE; + + void Erase(ApplicationSharedPtr app_to_remove) { + app_to_remove->RemoveExtensions(); + applications_.erase(app_to_remove); + } + + virtual functional_modules::PluginManager& GetPluginManager() OVERRIDE { + return plugin_manager_; + } + + std::vector<std::string> devices( + const std::string& policy_app_id) const OVERRIDE; + + virtual void SendPostMessageToMobile(const MessagePtr& message) OVERRIDE; + + virtual void SendPostMessageToHMI(const MessagePtr& message) OVERRIDE; +#endif // SDL_REMOTE_CONTROL + /** * @brief Checks if application with the same HMI type * (media, voice communication or navi) exists @@ -763,6 +830,9 @@ class ApplicationManagerImpl void SendMessageToHMI(const commands::MessageSharedPtr message) OVERRIDE; + void RemoveHMIFakeParameters( + application_manager::MessagePtr& message) OVERRIDE; + bool ManageMobileCommand(const commands::MessageSharedPtr message, commands::Command::CommandOrigin origin) OVERRIDE; bool ManageHMICommand(const commands::MessageSharedPtr message) OVERRIDE; @@ -1216,6 +1286,10 @@ class ApplicationManagerImpl smart_objects::SmartObject& output); bool ConvertSOtoMessage(const smart_objects::SmartObject& message, Message& output); + + MessageValidationResult ValidateMessageBySchema( + const Message& message) OVERRIDE; + utils::SharedPtr<Message> ConvertRawMsgToMessage( const ::protocol_handler::RawMessagePtr message); @@ -1499,6 +1573,28 @@ class ApplicationManagerImpl protocol_handler::ProtocolHandler* protocol_handler_; request_controller::RequestController request_ctrl_; +#ifdef SDL_REMOTE_CONTROL + functional_modules::PluginManager plugin_manager_; + + /** + * @brief Map contains apps with HMI state before incoming call + * After incoming call ends previous HMI state must restore + * + */ + struct AppState { + AppState(const mobile_apis::HMILevel::eType& level, + const mobile_apis::AudioStreamingState::eType& streaming_state, + const mobile_apis::SystemContext::eType& context) + : hmi_level(level) + , audio_streaming_state(streaming_state) + , system_context(context) {} + + mobile_apis::HMILevel::eType hmi_level; + mobile_apis::AudioStreamingState::eType audio_streaming_state; + mobile_apis::SystemContext::eType system_context; + }; +#endif // SDL_REMOTE_CONTROL + hmi_apis::HMI_API* hmi_so_factory_; mobile_apis::MOBILE_API* mobile_so_factory_; diff --git a/src/components/application_manager/include/application_manager/message.h b/src/components/application_manager/include/application_manager/message.h index 70d80f44ef..77ef5479ee 100644 --- a/src/components/application_manager/include/application_manager/message.h +++ b/src/components/application_manager/include/application_manager/message.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Ford Motor Company + * Copyright (c) 2017, Ford Motor Company * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -60,14 +60,17 @@ MessageType MessageTypeFromRpcType(protocol_handler::RpcType rpc_type); class Message { public: - Message(protocol_handler::MessagePriority priority); + explicit Message(protocol_handler::MessagePriority priority); Message(const Message& message); Message& operator=(const Message& message); - bool operator==(const Message& message); + bool operator==(const Message& message) const; ~Message(); //! -------------------------------------------------------------------------- int32_t function_id() const; +#ifdef SDL_REMOTE_CONTROL + std::string function_name() const; +#endif // SDL_REMOTE_CONTROL int32_t correlation_id() const; int32_t connection_key() const; @@ -81,8 +84,12 @@ class Message { size_t payload_size() const; const smart_objects::SmartObject& smart_object() const; - //! -------------------------------------------------------------------------- + //! + //--------------------------------------------------------------------------. void set_function_id(int32_t id); +#ifdef SDL_REMOTE_CONTROL + void set_function_name(const std::string& name); +#endif // SDL_REMOTE_CONTROL void set_correlation_id(int32_t id); void set_connection_key(int32_t key); void set_message_type(MessageType type); @@ -105,6 +112,9 @@ class Message { int32_t function_id_; // @remark protocol V2. int32_t correlation_id_; // @remark protocol V2. MessageType type_; // @remark protocol V2. +#ifdef SDL_REMOTE_CONTROL + std::string function_name_; +#endif // SDL_REMOTE_CONTROL // Pre-calculated message priority, higher priority messages are // Processed first @@ -120,6 +130,9 @@ class Message { size_t payload_size_; protocol_handler::MajorProtocolVersion version_; }; + +typedef utils::SharedPtr<application_manager::Message> MobileMessage; +typedef utils::SharedPtr<application_manager::Message> MessagePtr; } // namespace application_manager #endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_MESSAGE_H_ diff --git a/src/components/application_manager/include/application_manager/message_helper.h b/src/components/application_manager/include/application_manager/message_helper.h index 8ec1d4745e..45a1215531 100644 --- a/src/components/application_manager/include/application_manager/message_helper.h +++ b/src/components/application_manager/include/application_manager/message_helper.h @@ -129,6 +129,17 @@ class MessageHelper { static hmi_apis::Common_Result::eType HMIResultFromString( const std::string& hmi_result); +#ifdef SDL_REMOTE_CONTROL + /** + * @brief Converts string to device rank, if possible + * @param device_rank Stringified device rank + * @return Appropriate enum from device rank, or INVALID_ENUM, if conversion + * is not possible + */ + static mobile_api::DeviceRank::eType StringToDeviceRank( + const std::string& device_rank); +#endif // SDL_REMOTE_CONTROL + /** * @brief Converts mobile Result enum value to string * @param mobile_result mobile Result enum value @@ -702,6 +713,24 @@ class MessageHelper { int32_t connection_key, mobile_api::AppInterfaceUnregisteredReason::eType reason); +#ifdef SDL_REMOTE_CONTROL + /** + * @brief Sends HMI status notification to mobile + * + * @param application_impl application with changed HMI status + * + **/ + static void SendHMIStatusNotification( + const Application& application_impl, + ApplicationManager& application_manager); + + static void SendActivateAppToHMI( + uint32_t const app_id, + ApplicationManager& application_manager, + hmi_apis::Common_HMILevel::eType level = hmi_apis::Common_HMILevel::FULL, + bool send_policy_priority = true); +#endif // SDL_REMOTE_CONTROL + private: /** * @brief Creates new request object and fill its header diff --git a/src/components/application_manager/include/application_manager/policies/policy_handler.h b/src/components/application_manager/include/application_manager/policies/policy_handler.h index 0b808b13f5..3dd2bb76e0 100644 --- a/src/components/application_manager/include/application_manager/policies/policy_handler.h +++ b/src/components/application_manager/include/application_manager/policies/policy_handler.h @@ -112,6 +112,159 @@ class PolicyHandler : public PolicyHandlerInterface, uint32_t GetNotificationsNumber(const std::string& priority) const OVERRIDE; virtual DeviceConsent GetUserConsentForDevice( const std::string& device_id) const OVERRIDE; + +#ifdef SDL_REMOTE_CONTROL + /** + * @brief Sets HMI default type for specified application + * @param application_id ID application + * @param app_types list of HMI types + */ + void SetDefaultHmiTypes(const std::string& application_id, + const smart_objects::SmartObject* app_types) OVERRIDE; + + /** + * Checks if application has HMI type + * @param application_id ID application + * @param hmi HMI type to check + * @param app_types additional list of HMI type to search in it + * @return true if hmi is contained in policy or app_types + */ + bool CheckHMIType(const std::string& application_id, + mobile_apis::AppHMIType::eType hmi, + const smart_objects::SmartObject* app_types) OVERRIDE; + + /** + * Notifies about changing HMI level + * @param device_id unique identifier of device + * @param policy_app_id unique identifier of application in policy + * @param hmi_level default HMI level for this application + */ + void OnUpdateHMILevel(const std::string& device_id, + const std::string& policy_app_id, + const std::string& hmi_level) OVERRIDE; + + /** + * Checks access to equipment of vehicle for application by RPC + * @param device_id unique identifier of device + * @param app_id policy id application + * @param module type + * @param rpc name of rpc + * @param params parameters list + */ + application_manager::TypeAccess CheckAccess( + const PTString& device_id, + const PTString& app_id, + const PTString& module, + const std::string& rpc, + const std::vector<PTString>& params) OVERRIDE; + + /** + * Checks access to module for application + * @param app_id policy id application + * @param module + * @return true if module is allowed for application + */ + bool CheckModule(const PTString& app_id, const PTString& module) OVERRIDE; + + /** + * Sets access to equipment of vehicle for application by RPC + * @param device_id unique identifier of device + * @param app_id policy id application + * @param module type + * @param allowed true if access is allowed + */ + void SetAccess(const PTString& device_id, + const PTString& app_id, + const PTString& module, + bool allowed) OVERRIDE; + + /** + * Resets access application to all resources + * @param device_id unique identifier of device + * @param app_id policy id application + */ + void ResetAccess(const PTString& device_id, const PTString& app_id) OVERRIDE; + + /** + * Resets access by group name for all applications + * @param module type + */ + void ResetAccess(const std::string& module) OVERRIDE; + + /** + * Sets device as primary device + * @param dev_id ID device + */ + void SetPrimaryDevice(const PTString& dev_id) OVERRIDE; + + /** + * Resets driver's device + */ + void ResetPrimaryDevice() OVERRIDE; + + /** + * Return id of primary device + */ + uint32_t PrimaryDevice() const OVERRIDE; + + /** + * Sets mode of remote control (on/off) + * @param enabled true if remote control is turned on + */ + void SetRemoteControl(bool enabled) OVERRIDE; + + /** + * @brief If remote control is enabled + * by User and by Policy + */ + bool GetRemoteControl() const OVERRIDE; + + /** + * @brief Notifies passengers' apps about change + * @param new_consent New value of remote permission + */ + void OnRemoteAllowedChanged(bool new_consent) OVERRIDE; + + /** + * @brief Notifies Remote apps about change in permissions + * @param device_id Device on which app is running + * @param application_id ID of app whose permissions are changed + */ + void OnRemoteAppPermissionsChanged( + const std::string& device_id, const std::string& application_id) OVERRIDE; + + /** + * @brief Notifies Remote apps about change in HMI status + * @param device_id Device on which app is running + * @param policy_app_id ID of application + * @param hmi_level new HMI level for this application + */ + void OnUpdateHMIStatus(const std::string& device_id, + const std::string& policy_app_id, + const std::string& hmi_level) OVERRIDE; + + /** + * @brief Notifies Remote apps about change in HMI status + * @param device_id Device on which app is running + * @param policy_app_id ID of application + * @param hmi_level new HMI level for this application + * @param device_rank new device rank + */ + void OnUpdateHMIStatus(const std::string& device_id, + const std::string& policy_app_id, + const std::string& hmi_level, + const std::string& device_rank) OVERRIDE; + + /** + * Gets all allowed module types + * @param app_id unique identifier of application + * @param list of allowed module types + * @return true if application has allowed modules + */ + bool GetModuleTypes(const std::string& policy_app_id, + std::vector<std::string>* modules) const OVERRIDE; +#endif // SDL_REMOTE_CONTROL + bool GetDefaultHmi(const std::string& policy_app_id, std::string* default_hmi) const OVERRIDE; bool GetInitialAppData(const std::string& application_id, @@ -348,7 +501,8 @@ class PolicyHandler : public PolicyHandlerInterface, * @brief Allows to add new or update existed application during * registration process * @param application_id The policy aplication id. - ** @return function that will notify update manager about new application + * @param hmi_types list of hmi types + * @return function that will notify update manager about new application */ StatusNotifier AddApplication( const std::string& application_id, @@ -506,6 +660,18 @@ class PolicyHandler : public PolicyHandlerInterface, PermissionConsent& out_permissions) OVERRIDE; #endif +#ifdef SDL_REMOTE_CONTROL + /** + * @brief Updates HMI level for specified application and send notification + * @param app application where HMI level was changed + * @param level new HMI level + */ + void UpdateHMILevel(application_manager::ApplicationSharedPtr app, + mobile_apis::HMILevel::eType level); + std::vector<std::string> GetDevicesIds( + const std::string& policy_app_id) OVERRIDE; +#endif // SDL_REMOTE_CONTROL + /** * @brief Sets days after epoch on successful policy update */ @@ -644,7 +810,6 @@ class PolicyHandler : public PolicyHandlerInterface, * otherwise FALSE */ bool IsUrlAppIdValid(const uint32_t app_idx, const EndpointUrls& urls) const; - DISALLOW_COPY_AND_ASSIGN(PolicyHandler); }; |