diff options
author | Maksym Ked (GitHub) <mked@luxoft.com> | 2018-11-14 21:10:02 +0200 |
---|---|---|
committer | Maksym Ked (GitHub) <mked@luxoft.com> | 2018-11-30 18:30:26 +0200 |
commit | be3846d29022a6073cbf76c841116e4156d2593c (patch) | |
tree | 6cd1ff816582c7bdb7b5000d323b482ffdaa6c4e | |
parent | 01cefc6b1a2b461264bc55e2cce5e7ca1bc86810 (diff) | |
download | sdl_core-feature/button_subscription_response_from_hmi.tar.gz |
Button Subscription request implementationfeature/button_subscription_response_from_hmi
42 files changed, 1884 insertions, 699 deletions
diff --git a/src/components/application_manager/include/application_manager/application.h b/src/components/application_manager/include/application_manager/application.h index 56c87fcb68..84fd30cd2d 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 "interfaces/HMI_API.h" #include "connection_handler/device.h" #include "application_manager/app_extension.h" #include "application_manager/message.h" @@ -102,6 +103,8 @@ struct AppFile { mobile_apis::FileType::eType file_type; }; typedef std::map<std::string, AppFile> AppFilesMap; +typedef std::map<int32_t, hmi_apis::Common_ButtonName::eType> + ButtonSubscriptionsMap; class InitialApplicationData { public: virtual ~InitialApplicationData() {} @@ -946,6 +949,51 @@ class Application : public virtual InitialApplicationData, */ virtual const std::list<AppExtensionPtr>& Extensions() const = 0; + /** + * @brief Get map of pending button subscription requests correlation ids + * to button names + * @return pending button subscriptions map + */ + virtual const ButtonSubscriptionsMap& PendingButtonSubscriptions() const = 0; + + /** + * @brief Add pending button subscription request + * @param correlation_id - correlation id of subscription request + * @param button_name - enum value indication button name + */ + virtual void AddPendingButtonSubscription( + const int32_t correlation_id, + const hmi_apis::Common_ButtonName::eType button_name) = 0; + /** + * @brief Remove pending button subscription request + * @param correlation_id - correlation id of subscription request + */ + virtual void RemovePendingSubscriptionButton( + const int32_t correlation_id) = 0; + + /** + * @brief Get map of pending button unsubscription requests correlation ids + * to button names + * @return pending button unsubscriptions map + */ + virtual const ButtonSubscriptionsMap& PendingButtonUnsubscriptions() + const = 0; + + /** + * @brief Add pending button unsubscription request + * @param correlation_id - correlation id of unsubscription request + * @param button_name - enum value indication button name + */ + virtual void AddPendingButtonUnsubscription( + const int32_t correlation_id, + const hmi_apis::Common_ButtonName::eType button_name) = 0; + /** + * @brief Remove pending button unsubscription request + * @param correlation_id - correlation id of unsubscription request + */ + virtual void RemovePendingButtonUnsubscription( + const int32_t correlation_id) = 0; + protected: mutable sync_primitives::Lock hmi_states_lock_; 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 8dc3b2da20..162cbad42c 100644 --- a/src/components/application_manager/include/application_manager/application_impl.h +++ b/src/components/application_manager/include/application_manager/application_impl.h @@ -409,6 +409,22 @@ class ApplicationImpl : public virtual Application, void SwapMobileMessageQueue(MobileMessageQueue& mobile_messages) OVERRIDE; + const ButtonSubscriptionsMap& PendingButtonSubscriptions() const OVERRIDE; + + void AddPendingButtonSubscription( + const int32_t correlation_id, + const hmi_apis::Common_ButtonName::eType button_name) OVERRIDE; + + void RemovePendingSubscriptionButton(const int32_t correlation_id) OVERRIDE; + + const ButtonSubscriptionsMap& PendingButtonUnsubscriptions() const OVERRIDE; + + void AddPendingButtonUnsubscription( + const int32_t correlation_id, + const hmi_apis::Common_ButtonName::eType button_name) OVERRIDE; + + void RemovePendingButtonUnsubscription(const int32_t correlation_id) OVERRIDE; + protected: /** * @brief Clean up application folder. Persistent files will stay @@ -478,6 +494,7 @@ class ApplicationImpl : public virtual Application, sync_primitives::Lock video_streaming_suspended_lock_; sync_primitives::Lock audio_streaming_suspended_lock_; sync_primitives::Lock streaming_stop_lock_; + sync_primitives::Lock pending_button_subscription_lock_; bool is_app_allowed_; bool has_been_activated_; @@ -496,6 +513,8 @@ class ApplicationImpl : public virtual Application, std::string bundle_id_; AppFilesMap app_files_; std::set<mobile_apis::ButtonName::eType> subscribed_buttons_; + ButtonSubscriptionsMap pending_button_subscriptions_; + ButtonSubscriptionsMap pending_button_unsubscriptions_; UsageStatistics usage_report_; HelpPromptManagerImpl help_prompt_manager_impl_; protocol_handler::MajorProtocolVersion protocol_version_; diff --git a/src/components/application_manager/include/application_manager/commands/button_notification_to_mobile.h b/src/components/application_manager/include/application_manager/commands/button_notification_to_mobile.h new file mode 100644 index 0000000000..0a05a1c194 --- /dev/null +++ b/src/components/application_manager/include/application_manager/commands/button_notification_to_mobile.h @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2018, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_BUTTON_NOTIFICATION_TO_MOBILE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_BUTTON_NOTIFICATION_TO_MOBILE_H_ + +#include "command_notification_impl.h" +#include "application_manager/application.h" +#include "interfaces/MOBILE_API.h" + +namespace application_manager { +namespace commands { +namespace app_mngr = application_manager; + +/** + * @brief Class is intended to encapsulate shared button notification logic in + * base class. Entities defined in this file do not conform to any version of + * HMI or mobile API, and exist only to remove duplication in OnButtonPress and + * OnButtonEvent notifications. + **/ +class ButtonNotificationToMobile + : public app_mngr::commands::CommandNotificationImpl { + public: + /** + * @brief ButtonNotificationToMobile class constructor + **/ + ButtonNotificationToMobile( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler); + + /** + * @brief ButtonNotificationToMobile class destructor + **/ + virtual ~ButtonNotificationToMobile(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + /** + * @brief HandleCustomButton handle event for custom buttons + **/ + void HandleCustomButton(app_mngr::ApplicationSharedPtr app); + /** + * @brief HandleOKButton handle event for OK button + **/ + void HandleOKButton(app_mngr::ApplicationSharedPtr app); + /** + * @brief HandleMediaButton handle event for media buttons + **/ + void HandleMediaButton(); + + /** + * @brief DoesAppIDExist check whether app id exists in received message + **/ + bool DoesAppIDExist() const; + + /** + * @brief SubscribedApps get subscribed apps for btn id received in message + **/ + const std::vector<ApplicationSharedPtr> SubscribedApps() const; + + protected: + virtual void SendButtonNotification(app_mngr::ApplicationSharedPtr app) = 0; +}; +} // namespace commands +} // namespace application_manager + +#endif 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 3f6f869514..16c2efdb98 100644 --- a/src/components/application_manager/include/application_manager/message_helper.h +++ b/src/components/application_manager/include/application_manager/message_helper.h @@ -37,20 +37,20 @@ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_MESSAGE_HELPER_H_ #include <map> -#include <vector> #include <string> +#include <vector> -#include "interfaces/MOBILE_API.h" -#include "interfaces/HMI_API.h" -#include "utils/macro.h" -#include "connection_handler/device.h" +#include <application_manager/smart_object_keys.h> #include "application_manager/application.h" +#include "application_manager/policies/policy_handler_interface.h" +#include "connection_handler/device.h" +#include "interfaces/HMI_API.h" +#include "interfaces/MOBILE_API.h" #include "policy/policy_types.h" #include "protocol_handler/session_observer.h" -#include "application_manager/policies/policy_handler_interface.h" #include "smart_objects/smart_object.h" #include "transport_manager/common.h" -#include <application_manager/smart_object_keys.h> +#include "utils/macro.h" namespace policy { class PolicyHandlerInterface; @@ -105,18 +105,18 @@ typedef std::map<std::string, mobile_apis::VehicleDataType::eType> VehicleData; class MessageHelper { public: /** - * @brief CreateNotification creates basic mobile notification smart object - * @param function_id Notification function ID - * @param app_id application to send notification - * @return basic mobile notification smart object - */ + * @brief CreateNotification creates basic mobile notification smart object + * @param function_id Notification function ID + * @param app_id application to send notification + * @return basic mobile notification smart object + */ static smart_objects::SmartObjectSPtr CreateNotification( mobile_apis::FunctionID::eType function_id, uint32_t app_id); /** - * @brief CreateHMINotification creates basic hmi notification smart object - * @param function_id Notification function ID - * @return basic hmi notification smart object - */ + * @brief CreateHMINotification creates basic hmi notification smart object + * @param function_id Notification function ID + * @return basic hmi notification smart object + */ static smart_objects::SmartObjectSPtr CreateHMINotification( hmi_apis::FunctionID::eType function_id); @@ -150,18 +150,18 @@ class MessageHelper { static void SendOnLanguageChangeToMobile(uint32_t connection_key); /** - * @brief Sends DecryptCertificate request to HMI - * @param file_name path to file containing encrypted certificate - */ + * @brief Sends DecryptCertificate request to HMI + * @param file_name path to file containing encrypted certificate + */ static void SendDecryptCertificateToHMI(const std::string& file_name, ApplicationManager& app_mngr); /** - * @brief SendGetSystemTimeRequest sends mentioned request to HMI. - * @param correlation_id the message correlation id, required for proper - * response processing. - * @param app_mngr - */ + * @brief SendGetSystemTimeRequest sends mentioned request to HMI. + * @param correlation_id the message correlation id, required for proper + * response processing. + * @param app_mngr + */ static void SendGetSystemTimeRequest(const uint32_t correlation_id, ApplicationManager& app_mngr); @@ -237,17 +237,17 @@ class MessageHelper { const std::string& hmi_level); /* - * @brief Used to obtain string representation of app's - * HMI Level. - * @param hmi_level Desired HMI Level - */ + * @brief Used to obtain string representation of app's + * HMI Level. + * @param hmi_level Desired HMI Level + */ static std::string StringifiedHMILevel( const mobile_apis::HMILevel::eType hmi_level); /* - * @brief Used to obtain function name by its id - * @param function_id Function ID - */ + * @brief Used to obtain function name by its id + * @param function_id Function ID + */ static std::string StringifiedFunctionID( mobile_apis::FunctionID::eType function_id); @@ -276,23 +276,47 @@ class MessageHelper { const std::string& path_to_icon, uint32_t app_id); /** - * @brief Creates button subscription notification + * @brief Creates button subscription request to hmi + * @param app_id - id of application for which request should be created + * @param button - button to be subscribed + * @param app_mngr - application manager + * @return Smart object with fulfilled request */ - static smart_objects::SmartObjectSPtr CreateOnButtonSubscriptionNotification( + static smart_objects::SmartObjectSPtr + CreateButtonSubscriptionHandlingRequestToHmi( const uint32_t app_id, const hmi_apis::Common_ButtonName::eType button, - const bool is_subscribed, + const hmi_apis::FunctionID::eType function, ApplicationManager& app_mngr); + static smart_objects::SmartObjectSPtr CreateButtonNotificationToMobile( + ApplicationManager& app_mngr, + ApplicationSharedPtr app, + const smart_objects::SmartObject& source_message); + /** - * @brief Creates button subscription notifications for buttons - * that application is subscribed on + * @brief Creates buttons subscription requests list + * for all buttons that application is subscribed on + * @param app - application to be subscribed for button + * @param buttons_subscriptions - set of buttons to be subscribed + * @return list of all buttons subscription requests ready to be sent to hmi + * @note for every button - separate request is created in the list */ static smart_objects::SmartObjectList - CreateOnButtonSubscriptionNotificationsForApp( + CreateButtonSubscriptionsHandlingRequestsList( ApplicationConstSharedPtr app, - ApplicationManager& app_mngr, - const ButtonSubscriptions& button_subscriptions); + const ButtonSubscriptions& buttons_subscriptions, + const hmi_apis::FunctionID::eType function, + ApplicationManager& app_mngr); + + /** + * @brief Creates button subscription request parameters + * @param app_id - app which needs button subscription + * @param button - button to subscribe + * @return created params smart object + */ + static smart_objects::SmartObjectSPtr CreateSubscribeButton( + const hmi_apis::Common_ButtonName::eType button, uint32_t app_id); static void SendAppDataToHMI(ApplicationConstSharedPtr app, ApplicationManager& app_man); @@ -397,27 +421,27 @@ class MessageHelper { ApplicationManager& app_mngr); /** - * @brief Send SDL_ActivateApp response to HMI - * @param permissions response parameters - */ + * @brief Send SDL_ActivateApp response to HMI + * @param permissions response parameters + */ static void SendSDLActivateAppResponse(policy::AppPermissions& permissions, uint32_t correlation_id, ApplicationManager& app_mngr); /** - * @brief Send OnSDLConsentNeeded to HMI for device data consent by user - * @param device_info Device info, e.g. mac, handle, name - */ + * @brief Send OnSDLConsentNeeded to HMI for device data consent by user + * @param device_info Device info, e.g. mac, handle, name + */ static void SendOnSDLConsentNeeded(const policy::DeviceParams& device_info, ApplicationManager& app_man); /** - * @brief Send request to SyncP process to read file and send - * Policy Table Snapshot using Retry Strategy - * @param file_path Path to file with PTS - * @param timeout Timeout to wait for PTU in seconds - * @param retries Seconds between retries - */ + * @brief Send request to SyncP process to read file and send + * Policy Table Snapshot using Retry Strategy + * @param file_path Path to file with PTS + * @param timeout Timeout to wait for PTU in seconds + * @param retries Seconds between retries + */ static void SendPolicyUpdate(const std::string& file_path, const uint32_t timeout, const std::vector<int>& retries, @@ -481,13 +505,13 @@ class MessageHelper { static void SendNaviStopStream(int32_t app_id, ApplicationManager& app_mngr); /* - * @brief Send notification for Update of Policy Table - * with PT Snapshot. - * @param connection_key Id of application to send message to - * @param policy_data PT Snapshot - * @param url If empty string, no URL is provided - * @param timeout If -1 no timeout is provdied - */ + * @brief Send notification for Update of Policy Table + * with PT Snapshot. + * @param connection_key Id of application to send message to + * @param policy_data PT Snapshot + * @param url If empty string, no URL is provided + * @param timeout If -1 no timeout is provdied + */ static void SendPolicySnapshotNotification( uint32_t connection_key, const std::vector<uint8_t>& policy_data, @@ -521,20 +545,20 @@ class MessageHelper { ApplicationManager& app_man); /* - * @brief Send notification to mobile on application permissions update - * @param connection_key Id of application to send message to - * @param permissions updated permissions for application - */ + * @brief Send notification to mobile on application permissions update + * @param connection_key Id of application to send message to + * @param permissions updated permissions for application + */ static void SendOnPermissionsChangeNotification( uint32_t connection_key, const policy::Permissions& permissions, ApplicationManager& app_mngr); /* - * @brief Send notification to HMI on application permissions update - * @param connection_key Id of application to send message to - * @param permissions updated permissions for application - */ + * @brief Send notification to HMI on application permissions update + * @param connection_key Id of application to send message to + * @param permissions updated permissions for application + */ static void SendOnAppPermissionsChangedNotification( uint32_t connection_key, const policy::AppPermissions& permissions, @@ -646,12 +670,12 @@ class MessageHelper { ApplicationManager& app_mngr); /** - * @brief Verify image and add image file full path - * and add path, although the image doesn't exist - * @param SmartObject with image - * @param app current application - * @return verification result - */ + * @brief Verify image and add image file full path + * and add path, although the image doesn't exist + * @param SmartObject with image + * @param app current application + * @return verification result + */ static void ApplyImagePath(smart_objects::SmartObject& image, ApplicationConstSharedPtr app, ApplicationManager& app_mngr); @@ -672,10 +696,10 @@ class MessageHelper { ApplicationManager& app_mngr); /** - * @brief Stores whether each choice in a set has the vrCommands parameter - * MIXED means some choices have vrCommands and others don't - * ALL means all do, NONE means none do - */ + * @brief Stores whether each choice in a set has the vrCommands parameter + * MIXED means some choices have vrCommands and others don't + * ALL means all do, NONE means none do + */ enum ChoiceSetVRCommandsStatus { MIXED, ALL, NONE }; /** diff --git a/src/components/application_manager/include/application_manager/request_info.h b/src/components/application_manager/include/application_manager/request_info.h index be28bad63c..8172c212e4 100644 --- a/src/components/application_manager/include/application_manager/request_info.h +++ b/src/components/application_manager/include/application_manager/request_info.h @@ -127,7 +127,7 @@ struct RequestInfo { } uint64_t hash(); static uint64_t GenerateHash(uint32_t var1, uint32_t var2); - static uint32_t HmiConnectoinKey; + static uint32_t HmiConnectionKey; protected: RequestPtr request_; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/subscribe_button_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/subscribe_button_request.h new file mode 100644 index 0000000000..dc1f8e62fe --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/subscribe_button_request.h @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2018, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SUBSCRIBE_BUTTON_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SUBSCRIBE_BUTTON_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" +#include "application_manager/event_engine/event.h" +#include "utils/macro.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { +namespace hmi { +/** + * @brief SubscribeButtonRequest command class + **/ +class SubscribeButtonRequest : public app_mngr::commands::RequestToHMI, + public app_mngr::event_engine::EventObserver { + public: + /** + * @brief SubscribeButtonRequest class constructor + * @param message Incoming SmartObject message + **/ + SubscribeButtonRequest(const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief SubscribeButtonRequest class destructor + **/ + virtual ~SubscribeButtonRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + void onTimeOut() OVERRIDE; + + void on_event(const application_manager::event_engine::Event& event) OVERRIDE; + + private: + DISALLOW_COPY_AND_ASSIGN(SubscribeButtonRequest); + + /** + * @brief Determines whether internal unsubscription must be performed + * and HMI UnsubscribeButton request must not be sent + * @param hmi_result - result code received from HMI + * @param app - reference to application instance + * @return bool - true if app should unsubscribe internally + **/ + bool ShouldUnsubscribeIntertally( + const hmi_apis::Common_Result::eType hmi_result, + const app_mngr::Application& app) const; + + hmi_apis::Common_ButtonName::eType button_name_; +}; + +} // namespace hmi +} // namespace commands +} // namespace sdl_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SUBSCRIBE_BUTTON_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/subscribe_button_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/subscribe_button_response.h new file mode 100644 index 0000000000..f0bd2e35aa --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/subscribe_button_response.h @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2018, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SUBSCRIBE_BUTTON_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SUBSCRIBE_BUTTON_RESPONSE_H_ + +#include "application_manager/application_manager.h" +#include "application_manager/commands/response_from_hmi.h" +#include "utils/macro.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +namespace hmi { +/** + * @brief SubscribeButtonResponse command class + **/ +class SubscribeButtonResponse : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief SubscribeButtonResponse class constructor + * @param message Incoming SmartObject message + **/ + SubscribeButtonResponse(const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief SubscribeButtonResponse class destructor + **/ + virtual ~SubscribeButtonResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(SubscribeButtonResponse); +}; + +} // namespace hmi +} // namespace commands +} // namespace sdl_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_SUBSCRIBE_BUTTON_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/unsubscribe_button_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/unsubscribe_button_request.h new file mode 100644 index 0000000000..c2046d5a10 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/unsubscribe_button_request.h @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2018, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UNSUBSCRIBE_BUTTON_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UNSUBSCRIBE_BUTTON_REQUEST_H_ + +#include "application_manager/commands/request_to_hmi.h" +#include "application_manager/event_engine/event.h" +#include "utils/macro.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +namespace hmi { +/** + * @brief UnsubscribeButtonRequest command class + **/ +class UnsubscribeButtonRequest : public app_mngr::commands::RequestToHMI, + public app_mngr::event_engine::EventObserver { + public: + /** + * @brief UnsubscribeButtonRequest class constructor + * @param message Incoming SmartObject message + **/ + UnsubscribeButtonRequest(const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief UnsubscribeButtonRequest class destructor + **/ + virtual ~UnsubscribeButtonRequest(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + void onTimeOut() OVERRIDE; + + void on_event(const application_manager::event_engine::Event& event) OVERRIDE; + + private: + DISALLOW_COPY_AND_ASSIGN(UnsubscribeButtonRequest); + + hmi_apis::Common_ButtonName::eType button_name_; +}; + +} // namespace hmi +} // namespace commands + +} // namespace sdl_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UNSUBSCRIBE_BUTTON_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/unsubscribe_button_response.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/unsubscribe_button_response.h new file mode 100644 index 0000000000..c43c392bab --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/unsubscribe_button_response.h @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2018, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UNSUBSCRIBE_BUTTON_RESPONSE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UNSUBSCRIBE_BUTTON_RESPONSE_H_ + +#include "application_manager/application_manager.h" +#include "application_manager/commands/response_from_hmi.h" +#include "utils/macro.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +namespace hmi { +/** + * @brief UnsubscribeButtonResponse command class + **/ +class UnsubscribeButtonResponse : public app_mngr::commands::ResponseFromHMI { + public: + /** + * @brief UnsubscribeButtonResponse class constructor + * @param message Incoming SmartObject message + **/ + UnsubscribeButtonResponse(const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle); + + /** + * @brief UnsubscribeButtonResponse class destructor + **/ + virtual ~UnsubscribeButtonResponse(); + + /** + * @brief Execute command + **/ + virtual void Run(); + + private: + DISALLOW_COPY_AND_ASSIGN(UnsubscribeButtonResponse); +}; + +} // namespace hmi + +} // namespace commands + +} // namespace sdl_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_UNSUBSCRIBE_BUTTON_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_button_event_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_button_event_notification.h index 6afdc0e1cf..9c8e635964 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_button_event_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_button_event_notification.h @@ -34,8 +34,9 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_BUTTON_EVENT_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_BUTTON_EVENT_NOTIFICATION_H_ -#include "application_manager/commands/command_notification_impl.h" #include "application_manager/application.h" +#include "application_manager/commands/button_notification_to_mobile.h" +#include "application_manager/commands/command_notification_impl.h" #include "utils/macro.h" namespace sdl_rpc_plugin { @@ -50,7 +51,7 @@ namespace mobile { * to mobile device that some button was pressed on HMI. **/ class OnButtonEventNotification - : public app_mngr::commands::CommandNotificationImpl { + : public app_mngr::commands::ButtonNotificationToMobile { public: /** * @brief OnButtonEventNotification class constructor @@ -68,18 +69,14 @@ class OnButtonEventNotification **/ virtual ~OnButtonEventNotification(); - /** - * @brief Execute command - **/ - virtual void Run(); - private: /* * @brief Sends button event notification to mobile device * * @param app Application to receive notification */ - void SendButtonEvent(app_mngr::ApplicationConstSharedPtr app); + virtual void SendButtonNotification( + app_mngr::ApplicationSharedPtr app) OVERRIDE; DISALLOW_COPY_AND_ASSIGN(OnButtonEventNotification); }; @@ -87,6 +84,6 @@ class OnButtonEventNotification } // namespace mobile } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_BUTTON_EVENT_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_button_press_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_button_press_notification.h index fe9bc449be..7895fd68c8 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_button_press_notification.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_button_press_notification.h @@ -34,8 +34,9 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_BUTTON_PRESS_NOTIFICATION_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_BUTTON_PRESS_NOTIFICATION_H_ -#include "application_manager/commands/command_notification_impl.h" #include "application_manager/application.h" +#include "application_manager/commands/button_notification_to_mobile.h" +#include "application_manager/commands/command_notification_impl.h" #include "utils/macro.h" namespace sdl_rpc_plugin { @@ -50,7 +51,7 @@ namespace mobile { * to mobile device that some button was pressed on HMI. **/ class OnButtonPressNotification - : public app_mngr::commands::CommandNotificationImpl { + : public app_mngr::commands::ButtonNotificationToMobile { public: /** * @brief OnButtonPressNotification class constructor @@ -68,24 +69,20 @@ class OnButtonPressNotification **/ virtual ~OnButtonPressNotification(); - /** - * @brief Execute command - **/ - virtual void Run(); - private: /* * @brief Sends button press notification to mobile device * * @param app Application to receive notification */ - void SendButtonPress(app_mngr::ApplicationConstSharedPtr app); + virtual void SendButtonNotification( + app_mngr::ApplicationSharedPtr app) OVERRIDE; DISALLOW_COPY_AND_ASSIGN(OnButtonPressNotification); }; } // namespace mobile } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_BUTTON_PRESS_NOTIFICATION_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/subscribe_button_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/subscribe_button_request.h index 011c0aa359..25dc0e30d7 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/subscribe_button_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/subscribe_button_request.h @@ -70,6 +70,12 @@ class SubscribeButtonRequest : public app_mngr::commands::CommandRequestImpl { void Run() FINAL; /** + * @brief Interface method that is called whenever new event received + * @param event The received event + */ + void on_event(const app_mngr::event_engine::Event& event) FINAL; + + /** * @brief Init sets hash update mode for request */ bool Init() FINAL; @@ -94,10 +100,18 @@ class SubscribeButtonRequest : public app_mngr::commands::CommandRequestImpl { */ void SendSubscribeButtonNotification(); + /** + * @brief Checks whether given button id is preset button + * @param btn_id button id enum type representing button name + * @return true in case if button is a preset button, + * otherwise false + */ + bool IsPresetButton(const mobile_apis::ButtonName::eType btn_id) const; + DISALLOW_COPY_AND_ASSIGN(SubscribeButtonRequest); }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SUBSCRIBE_BUTTON_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unsubscribe_button_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unsubscribe_button_request.h index 8cbaafbfe1..63ad09f445 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unsubscribe_button_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/unsubscribe_button_request.h @@ -73,17 +73,17 @@ class UnsubscribeButtonRequest : public app_mngr::commands::CommandRequestImpl { */ bool Init() FINAL; - private: /** - * @brief Sends ButtonSubscription notification - * to notify HMI that app unsubscribed from the button. + * @brief Interface method that is called whenever new event received + * @param event The received event */ - void SendUnsubscribeButtonNotification(); + void on_event(const app_mngr::event_engine::Event& event) FINAL; + private: DISALLOW_COPY_AND_ASSIGN(UnsubscribeButtonRequest); }; } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_UNSUBSCRIBE_BUTTON_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/subscribe_button_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/subscribe_button_request.cc new file mode 100644 index 0000000000..1bacddc023 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/subscribe_button_request.cc @@ -0,0 +1,179 @@ +/* + * Copyright (c) 2018, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "sdl_rpc_plugin/commands/hmi/subscribe_button_request.h" +#include "application_manager/resumption/resume_ctrl.h" +#include "application_manager/message_helper.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +namespace hmi { + +SubscribeButtonRequest::SubscribeButtonRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) + , EventObserver(application_manager.event_dispatcher()) { + hmi_apis::Common_ButtonName::eType button_name = static_cast< + hmi_apis::Common_ButtonName::eType>( + (*message_)[app_mngr::strings::msg_params][app_mngr::strings::button_name] + .asInt()); + + button_name_ = button_name; +} + +SubscribeButtonRequest::~SubscribeButtonRequest() {} + +void SubscribeButtonRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + subscribe_on_event(hmi_apis::FunctionID::Buttons_SubscribeButton, + correlation_id()); + + ApplicationSharedPtr app = + application_manager_.application_by_hmi_app(application_id()); + + if (!app) { + LOG4CXX_ERROR(logger_, + "Application for connection key: " << application_id() + << " was not found"); + return; + } + + app->AddPendingButtonSubscription(correlation_id(), button_name_); + + SendRequest(); +} + +void SubscribeButtonRequest::onTimeOut() { + LOG4CXX_AUTO_TRACE(logger_); + application_manager_.updateRequestTimeout( + connection_key(), correlation_id(), 0); + + auto& resume_ctrl = application_manager_.resume_controller(); + + ApplicationSharedPtr app = + application_manager_.application_by_hmi_app(application_id()); + + if (!app) { + LOG4CXX_ERROR(logger_, + "Application for app id: " << application_id() + << " was not found"); + return; + } + + app->RemovePendingSubscriptionButton(correlation_id()); + + resume_ctrl.HandleOnTimeOut( + correlation_id(), + static_cast<hmi_apis::FunctionID::eType>(function_id())); +} + +void SubscribeButtonRequest::on_event(const event_engine::Event& event) { + LOG4CXX_AUTO_TRACE(logger_); + using namespace helpers; + + const smart_objects::SmartObject& message = event.smart_object(); + + if (hmi_apis::FunctionID::Buttons_SubscribeButton != event.id()) { + LOG4CXX_ERROR(logger_, "Received unknown event."); + return; + } + + const uint32_t app_id = + (*message_)[strings::msg_params][strings::app_id].asUInt(); + + ApplicationSharedPtr app = + application_manager_.application_by_hmi_app(app_id); + + if (!app) { + LOG4CXX_ERROR(logger_, "NULL pointer."); + return; + } + + hmi_apis::Common_Result::eType hmi_result = + static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asInt()); + + const auto pending_button_subscriptions = app->PendingButtonSubscriptions(); + + const auto it = + pending_button_subscriptions.find(event.smart_object_correlation_id()); + + const bool is_in_pending = it != pending_button_subscriptions.end(); + + const mobile_apis::ButtonName::eType btn_id = + static_cast<mobile_apis::ButtonName::eType>( + (*message_)[strings::msg_params][strings::button_name].asInt()); + + if ((hmi_apis::Common_Result::SUCCESS == hmi_result || + hmi_apis::Common_Result::WARNINGS == hmi_result) && + is_in_pending) { + app->SubscribeToButton(static_cast<mobile_apis::ButtonName::eType>(btn_id)); + app->RemovePendingSubscriptionButton(correlation_id()); + } else if (ShouldUnsubscribeIntertally(hmi_result, *app)) { + app->UnsubscribeFromButton( + static_cast<mobile_apis::ButtonName::eType>(btn_id)); + app->RemovePendingSubscriptionButton(correlation_id()); + } else if (!is_in_pending) { + smart_objects::SmartObjectSPtr msg = + MessageHelper::CreateButtonSubscriptionHandlingRequestToHmi( + application_id(), + static_cast<hmi_apis::Common_ButtonName::eType>(button_name_), + hmi_apis::FunctionID::Buttons_UnsubscribeButton, + application_manager_); + + rpc_service_.SendMessageToHMI(msg); + } +} + +bool SubscribeButtonRequest::ShouldUnsubscribeIntertally( + const hmi_apis::Common_Result::eType hmi_result, + const app_mngr::Application& app) const { + return (hmi_result != hmi_apis::Common_Result::SUCCESS && + hmi_result != hmi_apis::Common_Result::WARNINGS) && + (app.is_resuming()); +} + +} // namespace hmi +} // namespace commands +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/subscribe_button_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/subscribe_button_response.cc new file mode 100644 index 0000000000..f31904c029 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/subscribe_button_response.cc @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2018, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +#include "sdl_rpc_plugin/commands/hmi/subscribe_button_response.h" +#include "application_manager/event_engine/event.h" +#include "interfaces/MOBILE_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; +namespace commands { + +namespace hmi { + +SubscribeButtonResponse::SubscribeButtonResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +SubscribeButtonResponse::~SubscribeButtonResponse() {} + +void SubscribeButtonResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + event_engine::Event event(hmi_apis::FunctionID::Buttons_SubscribeButton); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace hmi +} // namespace commands +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/unsubscribe_button_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/unsubscribe_button_request.cc new file mode 100644 index 0000000000..e03f3e8b7e --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/unsubscribe_button_request.cc @@ -0,0 +1,159 @@ +/* + * Copyright (c) 2018, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "sdl_rpc_plugin/commands/hmi/unsubscribe_button_request.h" +#include "application_manager/resumption/resume_ctrl.h" +#include "application_manager/event_engine/event_dispatcher_impl.h" +#include "application_manager/message_helper.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; + +namespace commands { + +namespace hmi { + +UnsubscribeButtonRequest::UnsubscribeButtonRequest( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : RequestToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) + , EventObserver(application_manager.event_dispatcher()) { + hmi_apis::Common_ButtonName::eType button_name = static_cast< + hmi_apis::Common_ButtonName::eType>( + (*message_)[app_mngr::strings::msg_params][app_mngr::strings::button_name] + .asInt()); + + button_name_ = button_name; +} + +UnsubscribeButtonRequest::~UnsubscribeButtonRequest() { + unsubscribe_from_event(hmi_apis::FunctionID::Buttons_UnsubscribeButton); +} + +void UnsubscribeButtonRequest::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + subscribe_on_event(hmi_apis::FunctionID::Buttons_UnsubscribeButton, + correlation_id()); + + ApplicationSharedPtr app = + application_manager_.application_by_hmi_app(application_id()); + + if (!app) { + LOG4CXX_ERROR(logger_, + "Application for connection key: " << application_id() + << " was not found"); + return; + } + + app->AddPendingButtonUnsubscription(correlation_id(), button_name_); + + SendRequest(); +} + +void UnsubscribeButtonRequest::onTimeOut() { + LOG4CXX_AUTO_TRACE(logger_); + application_manager_.updateRequestTimeout( + connection_key(), correlation_id(), 0); + auto& resume_ctrl = application_manager_.resume_controller(); + + resume_ctrl.HandleOnTimeOut( + correlation_id(), + static_cast<hmi_apis::FunctionID::eType>(function_id())); + + ApplicationSharedPtr app = + application_manager_.application_by_hmi_app(application_id()); + + if (!app) { + LOG4CXX_ERROR(logger_, + "Application for connection key: " << application_id() + << " was not found"); + return; + } + + app->RemovePendingButtonUnsubscription(correlation_id()); +} + +void UnsubscribeButtonRequest::on_event(const event_engine::Event& event) { + LOG4CXX_AUTO_TRACE(logger_); + + ApplicationSharedPtr app = + application_manager_.application_by_hmi_app(application_id()); + + const smart_objects::SmartObject& message = event.smart_object(); + + if (!app) { + LOG4CXX_ERROR(logger_, "NULL pointer."); + return; + } + + const auto pending_button_unsubscriptions = + app->PendingButtonUnsubscriptions(); + + const auto it = + pending_button_unsubscriptions.find(event.smart_object_correlation_id()); + + const bool is_in_pending = it != pending_button_unsubscriptions.end(); + + hmi_apis::Common_Result::eType hmi_result = + static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asInt()); + + if (hmi_apis::Common_Result::SUCCESS == hmi_result && is_in_pending) { + const mobile_apis::ButtonName::eType btn_id = + static_cast<mobile_apis::ButtonName::eType>( + (*message_)[strings::msg_params][strings::button_name].asInt()); + app->UnsubscribeFromButton( + static_cast<mobile_apis::ButtonName::eType>(btn_id)); + app->RemovePendingButtonUnsubscription(correlation_id()); + } else if (!is_in_pending) { + smart_objects::SmartObjectSPtr msg = + MessageHelper::CreateButtonSubscriptionHandlingRequestToHmi( + application_id(), + static_cast<hmi_apis::Common_ButtonName::eType>(button_name_), + hmi_apis::FunctionID::Buttons_SubscribeButton, + application_manager_); + + rpc_service_.SendMessageToHMI(msg); + } +} + +} // namespace hmi +} // namespace commands +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/unsubscribe_button_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/unsubscribe_button_response.cc new file mode 100644 index 0000000000..098e59f96e --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/unsubscribe_button_response.cc @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2018, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +#include "sdl_rpc_plugin/commands/hmi/unsubscribe_button_response.h" +#include "application_manager/event_engine/event.h" +#include "interfaces/MOBILE_API.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; +namespace commands { + +namespace hmi { + +UnsubscribeButtonResponse::UnsubscribeButtonResponse( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + rpc_service::RPCService& rpc_service, + HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : ResponseFromHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +UnsubscribeButtonResponse::~UnsubscribeButtonResponse() {} + +void UnsubscribeButtonResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + event_engine::Event event(hmi_apis::FunctionID::Buttons_UnsubscribeButton); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace hmi +} // namespace commands +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_button_event_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_button_event_notification.cc index 79fb1f4272..d6f7228756 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_button_event_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_button_event_notification.cc @@ -34,6 +34,7 @@ #include "sdl_rpc_plugin/commands/mobile/on_button_event_notification.h" #include "application_manager/application_impl.h" +#include "application_manager/message_helper.h" #include "interfaces/MOBILE_API.h" namespace sdl_rpc_plugin { @@ -49,138 +50,38 @@ OnButtonEventNotification::OnButtonEventNotification( rpc_service::RPCService& rpc_service, HMICapabilities& hmi_capabilities, policy::PolicyHandlerInterface& policy_handler) - : CommandNotificationImpl(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handler) {} + : ButtonNotificationToMobile(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} OnButtonEventNotification::~OnButtonEventNotification() {} -void OnButtonEventNotification::Run() { +void OnButtonEventNotification::SendButtonNotification( + ApplicationSharedPtr app) { LOG4CXX_AUTO_TRACE(logger_); - const uint32_t btn_id = static_cast<uint32_t>( - (*message_)[strings::msg_params][hmi_response::button_name].asInt()); - - const bool is_app_id_exists = - (*message_)[strings::msg_params].keyExists(strings::app_id); - ApplicationSharedPtr app; - - // CUSTOM_BUTTON notification - if (static_cast<uint32_t>(mobile_apis::ButtonName::CUSTOM_BUTTON) == btn_id) { - // app_id is mandatory for CUSTOM_BUTTON notification - if (!is_app_id_exists) { - LOG4CXX_ERROR(logger_, "CUSTOM_BUTTON OnButtonEvent without app_id."); - return; - } - - app = application_manager_.application( - (*message_)[strings::msg_params][strings::app_id].asUInt()); - - // custom_button_id is mandatory for CUSTOM_BUTTON notification - if (false == - (*message_)[strings::msg_params].keyExists( - hmi_response::custom_button_id)) { - LOG4CXX_ERROR(logger_, - "CUSTOM_BUTTON OnButtonEvent without custom_button_id."); - return; - } - - if (!app) { - LOG4CXX_ERROR(logger_, "Application doesn't exist."); - return; - } - - uint32_t custom_btn_id = 0; - custom_btn_id = - (*message_)[strings::msg_params][hmi_response::custom_button_id] - .asUInt(); - - if (false == app->IsSubscribedToSoftButton(custom_btn_id)) { - LOG4CXX_ERROR(logger_, - "Application doesn't subscribed to this custom_button_id."); - return; - } - - if ((mobile_api::HMILevel::HMI_FULL != app->hmi_level()) && - (mobile_api::HMILevel::HMI_LIMITED != app->hmi_level())) { - LOG4CXX_WARN(logger_, - "CUSTOM_BUTTON OnButtonEvent notification is allowed only " - << "in FULL or LIMITED hmi level"); - return; - } - - SendButtonEvent(app); - return; - } - - const std::vector<ApplicationSharedPtr>& subscribed_apps = - application_manager_.applications_by_button(btn_id); - - std::vector<ApplicationSharedPtr>::const_iterator it = - subscribed_apps.begin(); - for (; subscribed_apps.end() != it; ++it) { - ApplicationSharedPtr subscribed_app = *it; - if (!subscribed_app) { - LOG4CXX_WARN(logger_, "Null pointer to subscribed app."); - continue; - } - - // Send ButtonEvent notification only in HMI_FULL or HMI_LIMITED mode - if ((mobile_api::HMILevel::HMI_FULL != subscribed_app->hmi_level()) && - (mobile_api::HMILevel::HMI_LIMITED != subscribed_app->hmi_level())) { - LOG4CXX_WARN(logger_, - "OnButtonEvent notification is allowed only" - << "in FULL or LIMITED hmi level"); - continue; - } - // if "app_id" absent send notification only in HMI_FULL mode - if (is_app_id_exists || subscribed_app->IsFullscreen()) { - SendButtonEvent(subscribed_app); - } - } -} - -void OnButtonEventNotification::SendButtonEvent(ApplicationConstSharedPtr app) { - if (!app) { - LOG4CXX_ERROR(logger_, "OnButtonEvent NULL pointer"); - return; - } + mobile_apis::ButtonEventMode::eType btn_event_mode; - smart_objects::SmartObjectSPtr on_btn_event = - std::make_shared<smart_objects::SmartObject>(); + if ((*message_)[strings::msg_params].keyExists(hmi_response::button_mode)) { + btn_event_mode = static_cast<mobile_apis::ButtonEventMode::eType>( + (*message_)[strings::msg_params][hmi_response::button_mode].asInt()); - if (!on_btn_event) { - LOG4CXX_ERROR(logger_, "OnButtonEvent NULL pointer"); - return; + } else if ((*message_)[strings::msg_params].keyExists( + strings::button_event_mode)) { + btn_event_mode = static_cast<mobile_apis::ButtonEventMode::eType>( + (*message_)[strings::msg_params][strings::button_event_mode].asInt()); } - (*on_btn_event)[strings::params][strings::connection_key] = app->app_id(); + message_ = MessageHelper::CreateButtonNotificationToMobile( + application_manager_, app, *message_); - (*on_btn_event)[strings::params][strings::function_id] = - static_cast<int32_t>(mobile_apis::FunctionID::eType::OnButtonEventID); + (*message_)[strings::msg_params][strings::button_event_mode] = btn_event_mode; - mobile_apis::ButtonName::eType btn_id = - static_cast<mobile_apis::ButtonName::eType>( - (*message_)[strings::msg_params][hmi_response::button_name].asInt()); - - if (btn_id == mobile_apis::ButtonName::PLAY_PAUSE && - app->msg_version() < utils::rpc_version_5) { - btn_id = mobile_apis::ButtonName::OK; - } - - (*on_btn_event)[strings::msg_params][strings::button_name] = btn_id; - (*on_btn_event)[strings::msg_params][strings::button_event_mode] = - (*message_)[strings::msg_params][hmi_response::button_mode]; - - if ((*message_)[strings::msg_params].keyExists( - hmi_response::custom_button_id)) { - (*on_btn_event)[strings::msg_params][strings::custom_button_id] = - (*message_)[strings::msg_params][strings::custom_button_id]; - } + (*message_)[strings::params][strings::function_id] = + mobile_apis::FunctionID::eType::OnButtonEventID; - message_ = on_btn_event; SendNotification(); } @@ -188,4 +89,4 @@ void OnButtonEventNotification::SendButtonEvent(ApplicationConstSharedPtr app) { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_button_press_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_button_press_notification.cc index c73f2b4b98..8f258e9974 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_button_press_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_button_press_notification.cc @@ -34,6 +34,7 @@ #include "sdl_rpc_plugin/commands/mobile/on_button_press_notification.h" #include "application_manager/application_impl.h" +#include "application_manager/message_helper.h" #include "interfaces/MOBILE_API.h" #include "utils/semantic_version.h" @@ -50,145 +51,38 @@ OnButtonPressNotification::OnButtonPressNotification( rpc_service::RPCService& rpc_service, HMICapabilities& hmi_capabilities, policy::PolicyHandlerInterface& policy_handler) - : CommandNotificationImpl(message, - application_manager, - rpc_service, - hmi_capabilities, - policy_handler) {} + : ButtonNotificationToMobile(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} OnButtonPressNotification::~OnButtonPressNotification() {} -void OnButtonPressNotification::Run() { +void OnButtonPressNotification::SendButtonNotification( + ApplicationSharedPtr app) { LOG4CXX_AUTO_TRACE(logger_); - const uint32_t btn_id = static_cast<uint32_t>( - (*message_)[strings::msg_params][hmi_response::button_name].asInt()); - - const bool is_app_id_exists = - (*message_)[strings::msg_params].keyExists(strings::app_id); - ApplicationSharedPtr app; - - // CUSTOM_BUTTON notification - if (static_cast<uint32_t>(mobile_apis::ButtonName::CUSTOM_BUTTON) == btn_id) { - // app_id is mandatory for CUSTOM_BUTTON notification - if (!is_app_id_exists) { - LOG4CXX_ERROR(logger_, "CUSTOM_BUTTON OnButtonPress without app_id."); - return; - } - - app = application_manager_.application( - (*message_)[strings::msg_params][strings::app_id].asUInt()); - - // custom_button_id is mandatory for CUSTOM_BUTTON notification - if (false == - (*message_)[strings::msg_params].keyExists( - hmi_response::custom_button_id)) { - LOG4CXX_ERROR(logger_, - "CUSTOM_BUTTON OnButtonPress without custom_button_id."); - return; - } - - if (!app) { - LOG4CXX_ERROR(logger_, "Application doesn't exist."); - return; - } - - uint32_t custom_btn_id = 0; - custom_btn_id = - (*message_)[strings::msg_params][hmi_response::custom_button_id] - .asUInt(); - - if (false == app->IsSubscribedToSoftButton(custom_btn_id)) { - LOG4CXX_ERROR(logger_, - "Application doesn't subscribed to this custom_button_id."); - return; - } - - // Send ButtonPress notification only in HMI_FULL or HMI_LIMITED mode - if ((mobile_api::HMILevel::HMI_FULL != app->hmi_level()) && - (mobile_api::HMILevel::HMI_LIMITED != app->hmi_level())) { - LOG4CXX_WARN(logger_, - "CUSTOM_BUTTON OnButtonPress notification is allowed only " - << "in FULL or LIMITED hmi level"); - return; - } - - SendButtonPress(app); - return; - } - - const std::vector<ApplicationSharedPtr>& subscribed_apps = - application_manager_.applications_by_button(btn_id); - - std::vector<ApplicationSharedPtr>::const_iterator it = - subscribed_apps.begin(); - for (; subscribed_apps.end() != it; ++it) { - ApplicationSharedPtr subscribed_app = *it; - if (!subscribed_app) { - LOG4CXX_WARN(logger_, "Null pointer to subscribed app."); - continue; - } - - // Send ButtonPress notification only in HMI_FULL or HMI_LIMITED mode - if ((mobile_api::HMILevel::HMI_FULL != subscribed_app->hmi_level()) && - (mobile_api::HMILevel::HMI_LIMITED != subscribed_app->hmi_level())) { - LOG4CXX_WARN(logger_, - "OnButtonPress notification is allowed only" - << "in FULL or LIMITED hmi level"); - continue; - } - // if "appID" is present, send it to named app only if its FULL or - // LIMITED - if (app.use_count() != 0) { - if (app->app_id() == subscribed_app->app_id()) { - SendButtonPress(subscribed_app); - } - } else if (subscribed_app->IsFullscreen()) { - // if No "appID" - send it FULL apps only. - SendButtonPress(subscribed_app); - } - } -} - -void OnButtonPressNotification::SendButtonPress(ApplicationConstSharedPtr app) { - if (!app) { - LOG4CXX_ERROR(logger_, "OnButtonPress NULL pointer"); - return; - } + mobile_apis::ButtonPressMode::eType btn_press_mode; - smart_objects::SmartObjectSPtr on_btn_press = - std::make_shared<smart_objects::SmartObject>(); + if ((*message_)[strings::msg_params].keyExists(hmi_response::button_mode)) { + btn_press_mode = static_cast<mobile_apis::ButtonPressMode::eType>( + (*message_)[strings::msg_params][hmi_response::button_mode].asInt()); - if (!on_btn_press) { - LOG4CXX_ERROR(logger_, "OnButtonPress NULL pointer"); - return; + } else if ((*message_)[strings::msg_params].keyExists( + strings::button_press_mode)) { + btn_press_mode = static_cast<mobile_apis::ButtonPressMode::eType>( + (*message_)[strings::msg_params][strings::button_press_mode].asInt()); } - (*on_btn_press)[strings::params][strings::connection_key] = app->app_id(); + message_ = MessageHelper::CreateButtonNotificationToMobile( + application_manager_, app, *message_); - (*on_btn_press)[strings::params][strings::function_id] = - static_cast<int32_t>(mobile_apis::FunctionID::eType::OnButtonPressID); + (*message_)[strings::msg_params][strings::button_press_mode] = btn_press_mode; - mobile_apis::ButtonName::eType btn_id = - static_cast<mobile_apis::ButtonName::eType>( - (*message_)[strings::msg_params][hmi_response::button_name].asInt()); - - if (btn_id == mobile_apis::ButtonName::PLAY_PAUSE && - app->msg_version() < utils::rpc_version_5) { - btn_id = mobile_apis::ButtonName::OK; - } - - (*on_btn_press)[strings::msg_params][strings::button_name] = btn_id; - (*on_btn_press)[strings::msg_params][strings::button_press_mode] = - (*message_)[strings::msg_params][hmi_response::button_mode]; - - if ((*message_)[strings::msg_params].keyExists( - hmi_response::custom_button_id)) { - (*on_btn_press)[strings::msg_params][strings::custom_button_id] = - (*message_)[strings::msg_params][strings::custom_button_id]; - } + (*message_)[strings::params][strings::function_id] = + mobile_apis::FunctionID::eType::OnButtonPressID; - message_ = on_btn_press; SendNotification(); } @@ -196,4 +90,4 @@ void OnButtonPressNotification::SendButtonPress(ApplicationConstSharedPtr app) { } // namespace commands -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc index 6ba4219f9e..c352e764e8 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc @@ -1497,12 +1497,15 @@ void RegisterAppInterfaceRequest::CheckResponseVehicleTypeParam( void RegisterAppInterfaceRequest::SendSubscribeCustomButtonNotification() { using namespace smart_objects; using namespace hmi_apis; + LOG4CXX_AUTO_TRACE(logger_); SmartObject msg_params = SmartObject(SmartType_Map); msg_params[strings::app_id] = connection_key(); - msg_params[strings::name] = Common_ButtonName::CUSTOM_BUTTON; + msg_params[strings::button_name] = Common_ButtonName::CUSTOM_BUTTON; msg_params[strings::is_suscribed] = true; - CreateHMINotification(FunctionID::Buttons_OnButtonSubscription, msg_params); + + SendHMIRequest( + hmi_apis::FunctionID::Buttons_SubscribeButton, &msg_params, false); } bool RegisterAppInterfaceRequest::IsApplicationSwitched() { diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_button_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_button_request.cc index 1c7280f5c1..587bf3463e 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_button_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_button_request.cc @@ -34,6 +34,10 @@ #include "sdl_rpc_plugin/commands/mobile/subscribe_button_request.h" #include "utils/semantic_version.h" +#include "application_manager/application_impl.h" +#include "application_manager/message_helper.h" +#include "utils/helpers.h" + namespace sdl_rpc_plugin { using namespace application_manager; @@ -106,11 +110,47 @@ void SubscribeButtonRequest::Run() { return; } - app->SubscribeToButton(static_cast<mobile_apis::ButtonName::eType>(btn_id)); - SendSubscribeButtonNotification(); + (*message_)[str::msg_params][str::app_id] = app->app_id(); + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Buttons); + SendHMIRequest(hmi_apis::FunctionID::Buttons_SubscribeButton, + &(*message_)[app_mngr::strings::msg_params], + true); +} + +void SubscribeButtonRequest::on_event(const event_engine::Event& event) { + LOG4CXX_AUTO_TRACE(logger_); + using namespace helpers; + + const smart_objects::SmartObject& message = event.smart_object(); - const bool is_succedeed = true; - SendResponse(is_succedeed, mobile_apis::Result::SUCCESS); + if (hmi_apis::FunctionID::Buttons_SubscribeButton != event.id()) { + LOG4CXX_ERROR(logger_, "Received unknown event."); + return; + } + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Buttons); + ApplicationSharedPtr app = + application_manager_.application(CommandRequestImpl::connection_key()); + + if (!app) { + LOG4CXX_ERROR(logger_, "NULL pointer."); + return; + } + + hmi_apis::Common_Result::eType hmi_result = + static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asInt()); + std::string response_info; + GetInfo(message, response_info); + const bool result = PrepareResultForMobileResponse( + hmi_result, HmiInterfaces::HMI_INTERFACE_Buttons); + + mobile_apis::Result::eType result_code = + MessageHelper::HMIToMobileResult(hmi_result); + + SendResponse(result, + result_code, + response_info.empty() ? nullptr : response_info.c_str(), + &(message[strings::msg_params])); } bool SubscribeButtonRequest::Init() { @@ -118,6 +158,20 @@ bool SubscribeButtonRequest::Init() { return true; } +bool SubscribeButtonRequest::IsPresetButton( + const mobile_apis::ButtonName::eType btn_id) const { + return (mobile_apis::ButtonName::PRESET_0 == btn_id) || + (mobile_apis::ButtonName::PRESET_1 == btn_id) || + (mobile_apis::ButtonName::PRESET_2 == btn_id) || + (mobile_apis::ButtonName::PRESET_3 == btn_id) || + (mobile_apis::ButtonName::PRESET_4 == btn_id) || + (mobile_apis::ButtonName::PRESET_5 == btn_id) || + (mobile_apis::ButtonName::PRESET_6 == btn_id) || + (mobile_apis::ButtonName::PRESET_7 == btn_id) || + (mobile_apis::ButtonName::PRESET_8 == btn_id) || + (mobile_apis::ButtonName::PRESET_9 == btn_id); +} + bool SubscribeButtonRequest::IsSubscriptionAllowed( ApplicationSharedPtr app, mobile_apis::ButtonName::eType btn_id) { if (!app->is_media_application() && @@ -125,25 +179,12 @@ bool SubscribeButtonRequest::IsSubscriptionAllowed( (mobile_apis::ButtonName::SEEKLEFT == btn_id) || (mobile_apis::ButtonName::SEEKRIGHT == btn_id) || (mobile_apis::ButtonName::TUNEUP == btn_id) || - (mobile_apis::ButtonName::TUNEDOWN == btn_id))) { + (mobile_apis::ButtonName::TUNEDOWN == btn_id) || + IsPresetButton(btn_id))) { return false; } return true; } -void SubscribeButtonRequest::SendSubscribeButtonNotification() { - using namespace smart_objects; - using namespace hmi_apis; - - // send OnButtonSubscription notification - SmartObject msg_params = SmartObject(SmartType_Map); - msg_params[strings::app_id] = connection_key(); - msg_params[strings::name] = static_cast<Common_ButtonName::eType>( - (*message_)[strings::msg_params][strings::button_name].asUInt()); - msg_params[strings::is_suscribed] = true; - CreateHMINotification(FunctionID::Buttons_OnButtonSubscription, msg_params); -} - } // namespace commands - -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_button_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_button_request.cc index 0c30f567b4..cec7b82739 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_button_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_button_request.cc @@ -34,6 +34,8 @@ #include "sdl_rpc_plugin/commands/mobile/unsubscribe_button_request.h" #include "application_manager/application_impl.h" +#include "application_manager/message_helper.h" +#include "utils/helpers.h" #include "utils/semantic_version.h" namespace sdl_rpc_plugin { @@ -92,15 +94,60 @@ void UnsubscribeButtonRequest::Run() { return; } - if (!app->UnsubscribeFromButton( - static_cast<mobile_apis::ButtonName::eType>(btn_id))) { - LOG4CXX_ERROR(logger_, "App doesn't subscibe to button " << btn_id); + if (!app->IsSubscribedToButton(btn_id)) { + LOG4CXX_ERROR(logger_, "App is not subscribed to button " << btn_id); SendResponse(false, mobile_apis::Result::IGNORED); return; } - SendUnsubscribeButtonNotification(); - SendResponse(true, mobile_apis::Result::SUCCESS); + (*message_)[str::msg_params][str::app_id] = app->app_id(); + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Buttons); + SendHMIRequest(hmi_apis::FunctionID::Buttons_UnsubscribeButton, + &(*message_)[app_mngr::strings::msg_params], + true); +} + +void UnsubscribeButtonRequest::on_event(const event_engine::Event& event) { + LOG4CXX_AUTO_TRACE(logger_); + using namespace helpers; + + const smart_objects::SmartObject& message = event.smart_object(); + + if (hmi_apis::FunctionID::Buttons_UnsubscribeButton != event.id()) { + LOG4CXX_ERROR(logger_, "Received unknown event."); + return; + } + EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Buttons); + ApplicationSharedPtr app = + application_manager_.application(CommandRequestImpl::connection_key()); + + if (!app) { + LOG4CXX_ERROR(logger_, "NULL pointer."); + return; + } + + hmi_apis::Common_Result::eType hmi_result = + static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asInt()); + std::string response_info; + GetInfo(message, response_info); + const bool result = PrepareResultForMobileResponse( + hmi_result, HmiInterfaces::HMI_INTERFACE_Buttons); + + if (result) { + const mobile_apis::ButtonName::eType btn_id = + static_cast<mobile_apis::ButtonName::eType>( + (*message_)[str::msg_params][str::button_name].asInt()); + app->UnsubscribeFromButton( + static_cast<mobile_apis::ButtonName::eType>(btn_id)); + } + mobile_apis::Result::eType result_code = + MessageHelper::HMIToMobileResult(hmi_result); + + SendResponse(result, + result_code, + response_info.empty() ? nullptr : response_info.c_str(), + &(message[strings::msg_params])); } bool UnsubscribeButtonRequest::Init() { @@ -108,19 +155,5 @@ bool UnsubscribeButtonRequest::Init() { return true; } -void UnsubscribeButtonRequest::SendUnsubscribeButtonNotification() { - using namespace smart_objects; - using namespace hmi_apis; - - // send OnButtonSubscription notification - SmartObject msg_params = SmartObject(SmartType_Map); - msg_params[strings::app_id] = connection_key(); - msg_params[strings::name] = static_cast<Common_ButtonName::eType>( - (*message_)[strings::msg_params][strings::button_name].asInt()); - msg_params[strings::is_suscribed] = false; - CreateHMINotification(FunctionID::Buttons_OnButtonSubscription, msg_params); -} - } // namespace commands - -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/hmi_command_factory.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/hmi_command_factory.cc index 7065c7cf7d..a2bb7d5ec9 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/hmi_command_factory.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/hmi_command_factory.cc @@ -35,211 +35,214 @@ #include "application_manager/message.h" #include "interfaces/HMI_API.h" -#include "sdl_rpc_plugin/commands/hmi/update_device_list_request.h" -#include "sdl_rpc_plugin/commands/hmi/update_device_list_response.h" -#include "sdl_rpc_plugin/commands/hmi/on_update_device_list.h" -#include "sdl_rpc_plugin/commands/hmi/on_start_device_discovery.h" -#include "sdl_rpc_plugin/commands/hmi/update_app_list_request.h" -#include "sdl_rpc_plugin/commands/hmi/update_app_list_response.h" -#include "sdl_rpc_plugin/commands/hmi/on_find_applications.h" +#include "sdl_rpc_plugin/commands/hmi/activate_app_request.h" +#include "sdl_rpc_plugin/commands/hmi/activate_app_response.h" #include "sdl_rpc_plugin/commands/hmi/allow_all_apps_request.h" #include "sdl_rpc_plugin/commands/hmi/allow_all_apps_response.h" #include "sdl_rpc_plugin/commands/hmi/allow_app_request.h" #include "sdl_rpc_plugin/commands/hmi/allow_app_response.h" -#include "sdl_rpc_plugin/commands/hmi/sdl_get_list_of_permissions_request.h" -#include "sdl_rpc_plugin/commands/hmi/sdl_get_list_of_permissions_response.h" -#include "sdl_rpc_plugin/commands/hmi/sdl_get_user_friendly_message_request.h" -#include "sdl_rpc_plugin/commands/hmi/sdl_get_user_friendly_message_response.h" -#include "sdl_rpc_plugin/commands/hmi/sdl_get_status_update_request.h" -#include "sdl_rpc_plugin/commands/hmi/sdl_get_status_update_response.h" -#include "sdl_rpc_plugin/commands/hmi/on_status_update_notification.h" -#include "sdl_rpc_plugin/commands/hmi/update_sdl_request.h" -#include "sdl_rpc_plugin/commands/hmi/update_sdl_response.h" -#include "sdl_rpc_plugin/commands/hmi/activate_app_request.h" -#include "sdl_rpc_plugin/commands/hmi/activate_app_response.h" +#include "sdl_rpc_plugin/commands/hmi/button_get_capabilities_request.h" +#include "sdl_rpc_plugin/commands/hmi/button_get_capabilities_response.h" +#include "sdl_rpc_plugin/commands/hmi/close_popup_request.h" +#include "sdl_rpc_plugin/commands/hmi/close_popup_response.h" +#include "sdl_rpc_plugin/commands/hmi/get_system_info_request.h" +#include "sdl_rpc_plugin/commands/hmi/get_system_info_response.h" #include "sdl_rpc_plugin/commands/hmi/mixing_audio_supported_request.h" #include "sdl_rpc_plugin/commands/hmi/mixing_audio_supported_response.h" #include "sdl_rpc_plugin/commands/hmi/on_allow_sdl_functionality_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_app_activated_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_app_permission_changed_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_app_permission_consent_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_app_activated_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_audio_data_streaming_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_video_data_streaming_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_sdl_consent_needed_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_event_changed_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_exit_all_applications_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_exit_application_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_find_applications.h" +#include "sdl_rpc_plugin/commands/hmi/on_ignition_cycle_over_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_put_file_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_resume_audio_source_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_ignition_cycle_over_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_sdl_consent_needed_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_start_device_discovery.h" +#include "sdl_rpc_plugin/commands/hmi/on_status_update_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_system_info_changed_notification.h" -#include "sdl_rpc_plugin/commands/hmi/get_system_info_request.h" -#include "sdl_rpc_plugin/commands/hmi/get_system_info_response.h" -#include "sdl_rpc_plugin/commands/hmi/close_popup_request.h" -#include "sdl_rpc_plugin/commands/hmi/close_popup_response.h" -#include "sdl_rpc_plugin/commands/hmi/button_get_capabilities_request.h" -#include "sdl_rpc_plugin/commands/hmi/button_get_capabilities_response.h" +#include "sdl_rpc_plugin/commands/hmi/on_update_device_list.h" +#include "sdl_rpc_plugin/commands/hmi/on_video_data_streaming_notification.h" +#include "sdl_rpc_plugin/commands/hmi/sdl_activate_app_request.h" +#include "sdl_rpc_plugin/commands/hmi/sdl_activate_app_response.h" +#include "sdl_rpc_plugin/commands/hmi/sdl_get_list_of_permissions_request.h" +#include "sdl_rpc_plugin/commands/hmi/sdl_get_list_of_permissions_response.h" +#include "sdl_rpc_plugin/commands/hmi/sdl_get_status_update_request.h" +#include "sdl_rpc_plugin/commands/hmi/sdl_get_status_update_response.h" +#include "sdl_rpc_plugin/commands/hmi/sdl_get_user_friendly_message_request.h" +#include "sdl_rpc_plugin/commands/hmi/sdl_get_user_friendly_message_response.h" +#include "sdl_rpc_plugin/commands/hmi/subscribe_button_request.h" +#include "sdl_rpc_plugin/commands/hmi/subscribe_button_response.h" +#include "sdl_rpc_plugin/commands/hmi/tts_change_registration_request.h" +#include "sdl_rpc_plugin/commands/hmi/tts_change_registration_response.h" +#include "sdl_rpc_plugin/commands/hmi/tts_get_capabilities_request.h" +#include "sdl_rpc_plugin/commands/hmi/tts_get_capabilities_response.h" +#include "sdl_rpc_plugin/commands/hmi/tts_get_language_request.h" +#include "sdl_rpc_plugin/commands/hmi/tts_get_language_response.h" +#include "sdl_rpc_plugin/commands/hmi/tts_get_supported_languages_request.h" +#include "sdl_rpc_plugin/commands/hmi/tts_get_supported_languages_response.h" +#include "sdl_rpc_plugin/commands/hmi/tts_is_ready_request.h" +#include "sdl_rpc_plugin/commands/hmi/tts_is_ready_response.h" +#include "sdl_rpc_plugin/commands/hmi/tts_set_global_properties_request.h" +#include "sdl_rpc_plugin/commands/hmi/tts_set_global_properties_response.h" +#include "sdl_rpc_plugin/commands/hmi/tts_speak_request.h" +#include "sdl_rpc_plugin/commands/hmi/tts_speak_response.h" +#include "sdl_rpc_plugin/commands/hmi/tts_stop_speaking_request.h" +#include "sdl_rpc_plugin/commands/hmi/tts_stop_speaking_response.h" #include "sdl_rpc_plugin/commands/hmi/ui_add_command_request.h" #include "sdl_rpc_plugin/commands/hmi/ui_add_command_response.h" -#include "sdl_rpc_plugin/commands/hmi/ui_delete_command_request.h" -#include "sdl_rpc_plugin/commands/hmi/ui_delete_command_response.h" #include "sdl_rpc_plugin/commands/hmi/ui_add_submenu_request.h" #include "sdl_rpc_plugin/commands/hmi/ui_add_submenu_response.h" +#include "sdl_rpc_plugin/commands/hmi/ui_alert_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_alert_response.h" +#include "sdl_rpc_plugin/commands/hmi/ui_change_registration_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_change_registration_response.h" +#include "sdl_rpc_plugin/commands/hmi/ui_delete_command_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_delete_command_response.h" #include "sdl_rpc_plugin/commands/hmi/ui_delete_submenu_request.h" #include "sdl_rpc_plugin/commands/hmi/ui_delete_submenu_response.h" -#include "sdl_rpc_plugin/commands/hmi/ui_get_supported_languages_request.h" -#include "sdl_rpc_plugin/commands/hmi/ui_get_supported_languages_response.h" -#include "sdl_rpc_plugin/commands/hmi/ui_get_language_request.h" -#include "sdl_rpc_plugin/commands/hmi/ui_get_language_response.h" +#include "sdl_rpc_plugin/commands/hmi/ui_end_audio_pass_thru_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_end_audio_pass_thru_response.h" #include "sdl_rpc_plugin/commands/hmi/ui_get_capabilities_request.h" #include "sdl_rpc_plugin/commands/hmi/ui_get_capabilities_response.h" -#include "sdl_rpc_plugin/commands/hmi/ui_change_registration_request.h" -#include "sdl_rpc_plugin/commands/hmi/ui_change_registration_response.h" -#include "sdl_rpc_plugin/commands/hmi/ui_show_request.h" -#include "sdl_rpc_plugin/commands/hmi/ui_show_response.h" -#include "sdl_rpc_plugin/commands/hmi/ui_alert_request.h" -#include "sdl_rpc_plugin/commands/hmi/ui_alert_response.h" +#include "sdl_rpc_plugin/commands/hmi/ui_get_language_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_get_language_response.h" +#include "sdl_rpc_plugin/commands/hmi/ui_get_supported_languages_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_get_supported_languages_response.h" #include "sdl_rpc_plugin/commands/hmi/ui_is_ready_request.h" #include "sdl_rpc_plugin/commands/hmi/ui_is_ready_response.h" -#include "sdl_rpc_plugin/commands/hmi/ui_slider_request.h" -#include "sdl_rpc_plugin/commands/hmi/ui_slider_response.h" -#include "sdl_rpc_plugin/commands/hmi/ui_set_media_clock_timer_request.h" -#include "sdl_rpc_plugin/commands/hmi/ui_set_media_clock_timer_response.h" -#include "sdl_rpc_plugin/commands/hmi/ui_set_global_properties_request.h" -#include "sdl_rpc_plugin/commands/hmi/ui_set_global_properties_response.h" +#include "sdl_rpc_plugin/commands/hmi/ui_perform_audio_pass_thru_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_perform_audio_pass_thru_response.h" +#include "sdl_rpc_plugin/commands/hmi/ui_perform_interaction_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_perform_interaction_response.h" #include "sdl_rpc_plugin/commands/hmi/ui_scrollable_message_request.h" #include "sdl_rpc_plugin/commands/hmi/ui_scrollable_message_response.h" #include "sdl_rpc_plugin/commands/hmi/ui_set_app_icon_request.h" #include "sdl_rpc_plugin/commands/hmi/ui_set_app_icon_response.h" -#include "sdl_rpc_plugin/commands/hmi/ui_perform_audio_pass_thru_response.h" -#include "sdl_rpc_plugin/commands/hmi/ui_perform_audio_pass_thru_request.h" -#include "sdl_rpc_plugin/commands/hmi/ui_end_audio_pass_thru_response.h" -#include "sdl_rpc_plugin/commands/hmi/ui_end_audio_pass_thru_request.h" -#include "sdl_rpc_plugin/commands/hmi/ui_perform_interaction_request.h" -#include "sdl_rpc_plugin/commands/hmi/ui_perform_interaction_response.h" -#include "sdl_rpc_plugin/commands/hmi/vr_is_ready_request.h" -#include "sdl_rpc_plugin/commands/hmi/vr_is_ready_response.h" +#include "sdl_rpc_plugin/commands/hmi/ui_set_global_properties_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_set_global_properties_response.h" +#include "sdl_rpc_plugin/commands/hmi/ui_set_media_clock_timer_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_set_media_clock_timer_response.h" +#include "sdl_rpc_plugin/commands/hmi/ui_show_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_show_response.h" +#include "sdl_rpc_plugin/commands/hmi/ui_slider_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_slider_response.h" +#include "sdl_rpc_plugin/commands/hmi/unsubscribe_button_request.h" +#include "sdl_rpc_plugin/commands/hmi/unsubscribe_button_response.h" +#include "sdl_rpc_plugin/commands/hmi/update_app_list_request.h" +#include "sdl_rpc_plugin/commands/hmi/update_app_list_response.h" +#include "sdl_rpc_plugin/commands/hmi/update_device_list_request.h" +#include "sdl_rpc_plugin/commands/hmi/update_device_list_response.h" +#include "sdl_rpc_plugin/commands/hmi/update_sdl_request.h" +#include "sdl_rpc_plugin/commands/hmi/update_sdl_response.h" #include "sdl_rpc_plugin/commands/hmi/vr_add_command_request.h" #include "sdl_rpc_plugin/commands/hmi/vr_add_command_response.h" -#include "sdl_rpc_plugin/commands/hmi/vr_delete_command_request.h" -#include "sdl_rpc_plugin/commands/hmi/vr_delete_command_response.h" #include "sdl_rpc_plugin/commands/hmi/vr_change_registration_request.h" #include "sdl_rpc_plugin/commands/hmi/vr_change_registration_response.h" -#include "sdl_rpc_plugin/commands/hmi/vr_get_supported_languages_request.h" -#include "sdl_rpc_plugin/commands/hmi/vr_get_supported_languages_response.h" -#include "sdl_rpc_plugin/commands/hmi/vr_get_language_request.h" -#include "sdl_rpc_plugin/commands/hmi/vr_get_language_response.h" +#include "sdl_rpc_plugin/commands/hmi/vr_delete_command_request.h" +#include "sdl_rpc_plugin/commands/hmi/vr_delete_command_response.h" #include "sdl_rpc_plugin/commands/hmi/vr_get_capabilities_request.h" #include "sdl_rpc_plugin/commands/hmi/vr_get_capabilities_response.h" -#include "sdl_rpc_plugin/commands/hmi/tts_is_ready_request.h" -#include "sdl_rpc_plugin/commands/hmi/tts_is_ready_response.h" -#include "sdl_rpc_plugin/commands/hmi/tts_change_registration_request.h" -#include "sdl_rpc_plugin/commands/hmi/tts_change_registration_response.h" -#include "sdl_rpc_plugin/commands/hmi/tts_get_supported_languages_request.h" -#include "sdl_rpc_plugin/commands/hmi/tts_get_supported_languages_response.h" -#include "sdl_rpc_plugin/commands/hmi/tts_get_language_request.h" -#include "sdl_rpc_plugin/commands/hmi/tts_get_language_response.h" -#include "sdl_rpc_plugin/commands/hmi/tts_stop_speaking_request.h" -#include "sdl_rpc_plugin/commands/hmi/tts_stop_speaking_response.h" -#include "sdl_rpc_plugin/commands/hmi/tts_speak_request.h" -#include "sdl_rpc_plugin/commands/hmi/tts_speak_response.h" -#include "sdl_rpc_plugin/commands/hmi/tts_set_global_properties_request.h" -#include "sdl_rpc_plugin/commands/hmi/tts_set_global_properties_response.h" -#include "sdl_rpc_plugin/commands/hmi/tts_get_capabilities_request.h" -#include "sdl_rpc_plugin/commands/hmi/tts_get_capabilities_response.h" +#include "sdl_rpc_plugin/commands/hmi/vr_get_language_request.h" +#include "sdl_rpc_plugin/commands/hmi/vr_get_language_response.h" +#include "sdl_rpc_plugin/commands/hmi/vr_get_supported_languages_request.h" +#include "sdl_rpc_plugin/commands/hmi/vr_get_supported_languages_response.h" +#include "sdl_rpc_plugin/commands/hmi/vr_is_ready_request.h" +#include "sdl_rpc_plugin/commands/hmi/vr_is_ready_response.h" #include "sdl_rpc_plugin/commands/hmi/vr_perform_interaction_request.h" #include "sdl_rpc_plugin/commands/hmi/vr_perform_interaction_response.h" -#include "sdl_rpc_plugin/commands/hmi/sdl_activate_app_request.h" -#include "sdl_rpc_plugin/commands/hmi/sdl_activate_app_response.h" -#include "sdl_rpc_plugin/commands/hmi/on_app_permission_changed_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_event_changed_notification.h" #ifdef EXTERNAL_PROPRIETARY_MODE #include "sdl_rpc_plugin/commands/hmi/decrypt_certificate_request.h" #include "sdl_rpc_plugin/commands/hmi/decrypt_certificate_response.h" #endif // EXTERNAL_PROPRIETARY_MODE +#include "sdl_rpc_plugin/commands/hmi/add_statistics_info_notification.h" +#include "sdl_rpc_plugin/commands/hmi/basic_communication_get_system_time_request.h" +#include "sdl_rpc_plugin/commands/hmi/basic_communication_get_system_time_response.h" +#include "sdl_rpc_plugin/commands/hmi/basic_communication_on_awake_sdl.h" +#include "sdl_rpc_plugin/commands/hmi/basic_communication_system_request.h" +#include "sdl_rpc_plugin/commands/hmi/basic_communication_system_response.h" +#include "sdl_rpc_plugin/commands/hmi/dial_number_request.h" +#include "sdl_rpc_plugin/commands/hmi/dial_number_response.h" +#include "sdl_rpc_plugin/commands/hmi/get_urls.h" +#include "sdl_rpc_plugin/commands/hmi/get_urls_response.h" +#include "sdl_rpc_plugin/commands/hmi/navi_alert_maneuver_request.h" +#include "sdl_rpc_plugin/commands/hmi/navi_alert_maneuver_response.h" +#include "sdl_rpc_plugin/commands/hmi/navi_audio_start_stream_request.h" +#include "sdl_rpc_plugin/commands/hmi/navi_audio_start_stream_response.h" +#include "sdl_rpc_plugin/commands/hmi/navi_audio_stop_stream_request.h" +#include "sdl_rpc_plugin/commands/hmi/navi_audio_stop_stream_response.h" +#include "sdl_rpc_plugin/commands/hmi/navi_get_way_points_request.h" +#include "sdl_rpc_plugin/commands/hmi/navi_get_way_points_response.h" #include "sdl_rpc_plugin/commands/hmi/navi_is_ready_request.h" +#include "sdl_rpc_plugin/commands/hmi/navi_is_ready_response.h" +#include "sdl_rpc_plugin/commands/hmi/navi_send_location_request.h" +#include "sdl_rpc_plugin/commands/hmi/navi_send_location_response.h" +#include "sdl_rpc_plugin/commands/hmi/navi_set_video_config_request.h" +#include "sdl_rpc_plugin/commands/hmi/navi_set_video_config_response.h" #include "sdl_rpc_plugin/commands/hmi/navi_show_constant_tbt_request.h" #include "sdl_rpc_plugin/commands/hmi/navi_show_constant_tbt_response.h" -#include "sdl_rpc_plugin/commands/hmi/navi_is_ready_response.h" -#include "sdl_rpc_plugin/commands/hmi/navi_alert_maneuver_request.h" -#include "sdl_rpc_plugin/commands/hmi/navi_alert_maneuver_response.h" -#include "sdl_rpc_plugin/commands/hmi/navi_update_turn_list_request.h" -#include "sdl_rpc_plugin/commands/hmi/navi_update_turn_list_response.h" +#include "sdl_rpc_plugin/commands/hmi/navi_start_stream_request.h" +#include "sdl_rpc_plugin/commands/hmi/navi_start_stream_response.h" +#include "sdl_rpc_plugin/commands/hmi/navi_stop_stream_request.h" +#include "sdl_rpc_plugin/commands/hmi/navi_stop_stream_response.h" #include "sdl_rpc_plugin/commands/hmi/navi_subscribe_way_points_request.h" #include "sdl_rpc_plugin/commands/hmi/navi_subscribe_way_points_response.h" #include "sdl_rpc_plugin/commands/hmi/navi_unsubscribe_way_points_request.h" #include "sdl_rpc_plugin/commands/hmi/navi_unsubscribe_way_points_response.h" -#include "sdl_rpc_plugin/commands/hmi/navi_get_way_points_request.h" -#include "sdl_rpc_plugin/commands/hmi/navi_get_way_points_response.h" -#include "sdl_rpc_plugin/commands/hmi/on_ready_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_system_time_ready_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_device_chosen_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_file_removed_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_system_context_notification.h" +#include "sdl_rpc_plugin/commands/hmi/navi_update_turn_list_request.h" +#include "sdl_rpc_plugin/commands/hmi/navi_update_turn_list_response.h" +#include "sdl_rpc_plugin/commands/hmi/on_app_deactivated_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_app_registered_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_app_unregistered_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_driver_distraction_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_tts_started_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_tts_stopped_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_vr_started_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_vr_stopped_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_vr_command_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_ui_command_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_app_deactivated_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_ui_language_change_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_vr_language_change_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_tts_language_change_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_navi_tbt_client_state_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_navi_way_point_change_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_button_event_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_button_press_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_button_subscription_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_ui_keyboard_input_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_ui_touch_event_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_ui_reset_timeout_notification.h" -#include "sdl_rpc_plugin/commands/hmi/navi_set_video_config_request.h" -#include "sdl_rpc_plugin/commands/hmi/navi_set_video_config_response.h" -#include "sdl_rpc_plugin/commands/hmi/navi_start_stream_request.h" -#include "sdl_rpc_plugin/commands/hmi/navi_start_stream_response.h" -#include "sdl_rpc_plugin/commands/hmi/navi_stop_stream_request.h" -#include "sdl_rpc_plugin/commands/hmi/navi_stop_stream_response.h" -#include "sdl_rpc_plugin/commands/hmi/navi_audio_start_stream_request.h" -#include "sdl_rpc_plugin/commands/hmi/navi_audio_start_stream_response.h" -#include "sdl_rpc_plugin/commands/hmi/navi_audio_stop_stream_request.h" -#include "sdl_rpc_plugin/commands/hmi/navi_audio_stop_stream_response.h" -#include "sdl_rpc_plugin/commands/hmi/on_system_request_notification.h" -#include "sdl_rpc_plugin/commands/hmi/ui_set_display_layout_request.h" -#include "sdl_rpc_plugin/commands/hmi/ui_set_display_layout_response.h" +#include "sdl_rpc_plugin/commands/hmi/on_device_chosen_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_device_state_changed_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_driver_distraction_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_file_removed_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_navi_tbt_client_state_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_navi_way_point_change_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_policy_update.h" +#include "sdl_rpc_plugin/commands/hmi/on_ready_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_received_policy_update.h" +#include "sdl_rpc_plugin/commands/hmi/on_record_start_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_sdl_close_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_sdl_persistence_complete_notification.h" -#include "sdl_rpc_plugin/commands/hmi/on_record_start_notification.h" -#include "sdl_rpc_plugin/commands/hmi/add_statistics_info_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_system_context_notification.h" #include "sdl_rpc_plugin/commands/hmi/on_system_error_notification.h" -#include "sdl_rpc_plugin/commands/hmi/basic_communication_system_request.h" -#include "sdl_rpc_plugin/commands/hmi/basic_communication_system_response.h" -#include "sdl_rpc_plugin/commands/hmi/basic_communication_get_system_time_request.h" -#include "sdl_rpc_plugin/commands/hmi/basic_communication_get_system_time_response.h" -#include "sdl_rpc_plugin/commands/hmi/basic_communication_on_awake_sdl.h" +#include "sdl_rpc_plugin/commands/hmi/on_system_request_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_system_time_ready_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_tts_language_change_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_tts_reset_timeout_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_tts_started_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_tts_stopped_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_ui_command_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_ui_keyboard_input_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_ui_language_change_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_ui_reset_timeout_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_ui_touch_event_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_vr_command_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_vr_language_change_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_vr_started_notification.h" +#include "sdl_rpc_plugin/commands/hmi/on_vr_stopped_notification.h" #include "sdl_rpc_plugin/commands/hmi/sdl_policy_update.h" #include "sdl_rpc_plugin/commands/hmi/sdl_policy_update_response.h" -#include "sdl_rpc_plugin/commands/hmi/on_received_policy_update.h" -#include "sdl_rpc_plugin/commands/hmi/on_policy_update.h" -#include "sdl_rpc_plugin/commands/hmi/get_urls.h" -#include "sdl_rpc_plugin/commands/hmi/get_urls_response.h" -#include "sdl_rpc_plugin/commands/hmi/on_device_state_changed_notification.h" -#include "sdl_rpc_plugin/commands/hmi/navi_send_location_request.h" -#include "sdl_rpc_plugin/commands/hmi/navi_send_location_response.h" -#include "sdl_rpc_plugin/commands/hmi/on_tts_reset_timeout_notification.h" -#include "sdl_rpc_plugin/commands/hmi/dial_number_request.h" -#include "sdl_rpc_plugin/commands/hmi/dial_number_response.h" #include "sdl_rpc_plugin/commands/hmi/ui_send_haptic_data_request.h" #include "sdl_rpc_plugin/commands/hmi/ui_send_haptic_data_response.h" +#include "sdl_rpc_plugin/commands/hmi/ui_set_display_layout_request.h" +#include "sdl_rpc_plugin/commands/hmi/ui_set_display_layout_response.h" -#include "sdl_rpc_plugin/commands/hmi/rc_is_ready_request.h" -#include "sdl_rpc_plugin/commands/hmi/rc_is_ready_response.h" #include "sdl_rpc_plugin/commands/hmi/rc_get_capabilities_request.h" #include "sdl_rpc_plugin/commands/hmi/rc_get_capabilities_response.h" +#include "sdl_rpc_plugin/commands/hmi/rc_is_ready_request.h" +#include "sdl_rpc_plugin/commands/hmi/rc_is_ready_response.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -617,6 +620,20 @@ CommandCreator& HMICommandFactory::get_creator_factory( : factory .GetCreator<commands::ButtonGetCapabilitiesResponse>(); } + + case hmi_apis::FunctionID::Buttons_SubscribeButton: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::hmi::SubscribeButtonRequest>() + : factory.GetCreator<commands::hmi::SubscribeButtonResponse>(); + } + + case hmi_apis::FunctionID::Buttons_UnsubscribeButton: { + return hmi_apis::messageType::request == message_type + ? factory.GetCreator<commands::hmi::UnsubscribeButtonRequest>() + : factory + .GetCreator<commands::hmi::UnsubscribeButtonResponse>(); + } + case hmi_apis::FunctionID::SDL_OnAllowSDLFunctionality: { return factory .GetCreator<commands::OnAllowSDLFunctionalityNotification>(); @@ -698,10 +715,6 @@ CommandCreator& HMICommandFactory::get_creator_factory( case hmi_apis::FunctionID::Buttons_OnButtonPress: { return factory.GetCreator<commands::hmi::OnButtonPressNotification>(); } - case hmi_apis::FunctionID::Buttons_OnButtonSubscription: { - return factory - .GetCreator<commands::hmi::OnButtonSubscriptionNotification>(); - } case hmi_apis::FunctionID::Navigation_OnTBTClientState: { return factory.GetCreator<commands::OnNaviTBTClientStateNotification>(); } @@ -844,4 +857,4 @@ CommandCreator& HMICommandFactory::get_creator_factory( } } -} // namespace application_manager +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_button_notification_commands_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_button_notification_commands_test.cc index a0e41cf728..1e1cdaa8ef 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_button_notification_commands_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_button_notification_commands_test.cc @@ -39,6 +39,7 @@ #include "application_manager/mock_application_manager.h" #include "application_manager/mock_application.h" +#include "application_manager/mock_message_helper.h" #include "application_manager/commands/command_impl.h" #include "application_manager/commands/commands_test.h" @@ -222,6 +223,11 @@ TYPED_TEST(OnButtonNotificationCommandsTest, Run_CustomButton_SUCCESS) { EXPECT_CALL(this->app_mngr_, application(kAppId)).WillOnce(Return(mock_app)); EXPECT_CALL(*mock_app, IsSubscribedToSoftButton(kCustomButtonId)) .WillOnce(Return(true)); + auto mock_message_helper = am::MockMessageHelper::message_helper_mock(); + smart_objects::SmartObjectSPtr msg = + std::make_shared<smart_objects::SmartObject>(); + EXPECT_CALL(*mock_message_helper, CreateButtonNotificationToMobile(_, _, _)) + .WillRepeatedly(Return(msg)); EXPECT_CALL(this->mock_rpc_service_, SendMessageToMobile( CheckNotificationMessage(TestFixture::kFunctionId), _)); @@ -323,10 +329,18 @@ TYPED_TEST(OnButtonNotificationCommandsTest, Run_SUCCESS) { EXPECT_CALL(this->app_mngr_, applications_by_button(kButtonName)) .WillOnce(Return(subscribed_apps_list)); + auto mock_message_helper = am::MockMessageHelper::message_helper_mock(); + smart_objects::SmartObjectSPtr msg = + std::make_shared<smart_objects::SmartObject>(); + EXPECT_CALL(*mock_message_helper, CreateButtonNotificationToMobile(_, _, _)) + .WillRepeatedly(Return(msg)); + EXPECT_CALL(this->mock_rpc_service_, SendMessageToMobile( CheckNotificationMessage(TestFixture::kFunctionId), _)); + EXPECT_CALL(this->app_mngr_, application(kAppId)).WillOnce(Return(mock_app)); + command->Run(); } diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/register_app_interface_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/register_app_interface_request_test.cc index b60ade4c62..1b9b1361d0 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/register_app_interface_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/register_app_interface_request_test.cc @@ -224,11 +224,6 @@ class RegisterAppInterfaceRequestTest EXPECT_CALL(mock_rpc_service_, ManageHMICommand(HMIResultCodeIs( - hmi_apis::FunctionID::Buttons_OnButtonSubscription))) - .Times(0); - - EXPECT_CALL(mock_rpc_service_, - ManageHMICommand(HMIResultCodeIs( hmi_apis::FunctionID::UI_ChangeRegistration))).Times(0); EXPECT_CALL(mock_rpc_service_, @@ -312,10 +307,23 @@ TEST_F(RegisterAppInterfaceRequestTest, Run_MinimalData_SUCCESS) { ManageHMICommand(HMIResultCodeIs( hmi_apis::FunctionID::BasicCommunication_OnAppRegistered))) .WillOnce(Return(true)); + + ON_CALL(mock_hmi_interfaces_, + GetInterfaceState( + application_manager::HmiInterfaces::HMI_INTERFACE_Buttons)) + .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); + + ON_CALL( + mock_hmi_interfaces_, + GetInterfaceFromFunction(hmi_apis::FunctionID::Buttons_SubscribeButton)) + .WillByDefault( + Return(application_manager::HmiInterfaces::HMI_INTERFACE_Buttons)); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(HMIResultCodeIs( - hmi_apis::FunctionID::Buttons_OnButtonSubscription))) + hmi_apis::FunctionID::Buttons_SubscribeButton))) .WillOnce(Return(true)); + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, am::commands::Command::SOURCE_SDL)) .Times(2); @@ -416,7 +424,7 @@ TEST_F(RegisterAppInterfaceRequestTest, .WillOnce(Return(true)); EXPECT_CALL(mock_rpc_service_, ManageHMICommand(HMIResultCodeIs( - hmi_apis::FunctionID::Buttons_OnButtonSubscription))) + hmi_apis::FunctionID::Buttons_SubscribeButton))) .WillOnce(Return(true)); EXPECT_CALL(mock_rpc_service_, ManageHMICommand( diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/subscribe_button_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/subscribe_button_request_test.cc index caca56e297..1e0f1d4b93 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/subscribe_button_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/subscribe_button_request_test.cc @@ -157,23 +157,23 @@ TEST_F(SubscribeButtonRequestTest, Run_IsSubscribedToButton_UNSUCCESS) { } TEST_F(SubscribeButtonRequestTest, Run_SUCCESS) { - const mobile_apis::ButtonName::eType kButtonName = + const mobile_apis::ButtonName::eType button_name = mobile_apis::ButtonName::SEEKLEFT; - MessageSharedPtr msg(CreateMessage()); - (*msg)[am::strings::msg_params][am::strings::button_name] = kButtonName; + MessageSharedPtr msg(CreateMessage(smart_objects::SmartType_Map)); + (*msg)[am::strings::msg_params][am::strings::button_name] = button_name; CommandPtr command(CreateCommand<SubscribeButtonRequest>(msg)); MockAppPtr app(CreateMockApp()); ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app)); - ON_CALL(*app, msg_version()).WillByDefault(ReturnRef(mock_semantic_version)); + ON_CALL(*app, msg_version()).WillByDefault(ReturnRef(mock_base_rpc_version)); ON_CALL(*app, is_media_application()).WillByDefault(Return(true)); ON_CALL(mock_hmi_capabilities_, is_ui_cooperating()) .WillByDefault(Return(true)); MessageSharedPtr button_caps_ptr(CreateMessage(smart_objects::SmartType_Map)); - (*button_caps_ptr)[0][am::hmi_response::button_name] = kButtonName; + (*button_caps_ptr)[0][am::hmi_response::button_name] = button_name; ON_CALL(mock_hmi_capabilities_, button_capabilities()) .WillByDefault(Return(button_caps_ptr.get())); @@ -186,28 +186,30 @@ TEST_F(SubscribeButtonRequestTest, Run_SUCCESS) { .WillOnce(DoAll(SaveArg<0>(&hmi_result_msg), Return(true))); MessageSharedPtr mobile_result_msg; - EXPECT_CALL(this->mock_rpc_service_, ManageMobileCommand(_, _)) - .WillOnce(DoAll(SaveArg<0>(&mobile_result_msg), Return(true))); ASSERT_TRUE(command->Init()); command->Run(); - EXPECT_EQ(hmi_apis::FunctionID::Buttons_OnButtonSubscription, + EXPECT_EQ(hmi_apis::FunctionID::Buttons_SubscribeButton, static_cast<hmi_apis::FunctionID::eType>( (*hmi_result_msg)[am::strings::params][am::strings::function_id] .asInt())); - EXPECT_EQ(mobile_apis::Result::SUCCESS, - static_cast<mobile_apis::Result::eType>( - (*mobile_result_msg)[am::strings::msg_params] - [am::strings::result_code].asInt())); + EXPECT_EQ( + hmi_apis::Common_ButtonName::eType::SEEKLEFT, + static_cast<hmi_apis::Common_ButtonName::eType>( + (*hmi_result_msg)[am::strings::msg_params][am::strings::button_name] + .asInt())); } -TEST_F(SubscribeButtonRequestTest, Run_SUCCESS_App_Base_RPC_Version) { - const mobile_apis::ButtonName::eType kButtonName = - mobile_apis::ButtonName::OK; +TEST_F(SubscribeButtonRequestTest, + Run_App_Version_4_5_and_OK_btn_Expect_PlayPause_btn_sent_to_HMI) { + const mobile_apis::ButtonName::eType button_ok = mobile_apis::ButtonName::OK; - MessageSharedPtr msg(CreateMessage()); - (*msg)[am::strings::msg_params][am::strings::button_name] = kButtonName; + const mobile_apis::ButtonName::eType button_play_pause = + mobile_apis::ButtonName::PLAY_PAUSE; + + MessageSharedPtr msg(CreateMessage(smart_objects::SmartType_Map)); + (*msg)[am::strings::msg_params][am::strings::button_name] = button_ok; CommandPtr command(CreateCommand<SubscribeButtonRequest>(msg)); MockAppPtr app(CreateMockApp()); @@ -219,40 +221,33 @@ TEST_F(SubscribeButtonRequestTest, Run_SUCCESS_App_Base_RPC_Version) { .WillByDefault(Return(true)); MessageSharedPtr button_caps_ptr(CreateMessage(smart_objects::SmartType_Map)); - (*button_caps_ptr)[0][am::hmi_response::button_name] = kButtonName; - (*button_caps_ptr)[1][am::hmi_response::button_name] = - mobile_apis::ButtonName::PLAY_PAUSE; + (*button_caps_ptr)[0][am::hmi_response::button_name] = button_ok; + (*button_caps_ptr)[1][am::hmi_response::button_name] = button_play_pause; ON_CALL(mock_hmi_capabilities_, button_capabilities()) .WillByDefault(Return(button_caps_ptr.get())); - ON_CALL(*app, IsSubscribedToButton(_)).WillByDefault(Return(false)); + ON_CALL(*app, IsSubscribedToButton(button_play_pause)) + .WillByDefault(Return(false)); MessageSharedPtr hmi_result_msg; EXPECT_CALL(mock_rpc_service_, ManageHMICommand(_)) .WillOnce(DoAll(SaveArg<0>(&hmi_result_msg), Return(true))); - MessageSharedPtr mobile_result_msg; - EXPECT_CALL(this->mock_rpc_service_, ManageMobileCommand(_, _)) - .WillOnce(DoAll(SaveArg<0>(&mobile_result_msg), Return(true))); ASSERT_TRUE(command->Init()); command->Run(); - EXPECT_EQ(hmi_apis::FunctionID::Buttons_OnButtonSubscription, + EXPECT_EQ(hmi_apis::FunctionID::Buttons_SubscribeButton, static_cast<hmi_apis::FunctionID::eType>( (*hmi_result_msg)[am::strings::params][am::strings::function_id] .asInt())); - EXPECT_EQ(hmi_apis::Common_ButtonName::PLAY_PAUSE, - static_cast<hmi_apis::Common_ButtonName::eType>( - (*hmi_result_msg)[am::strings::msg_params][am::strings::name] - .asInt())); - - EXPECT_EQ(mobile_apis::Result::SUCCESS, - static_cast<mobile_apis::Result::eType>( - (*mobile_result_msg)[am::strings::msg_params] - [am::strings::result_code].asInt())); + EXPECT_EQ( + hmi_apis::Common_ButtonName::PLAY_PAUSE, + static_cast<hmi_apis::Common_ButtonName::eType>( + (*hmi_result_msg)[am::strings::msg_params][am::strings::button_name] + .asInt())); } } // namespace subscribe_button_request diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/unsubscribe_button_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/unsubscribe_button_request_test.cc index a848fff2b2..4712ef983f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/unsubscribe_button_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/unsubscribe_button_request_test.cc @@ -77,8 +77,6 @@ TEST_F(UnsubscribeButtonRequestTest, .WillOnce(Return(mock_app)); ON_CALL(*mock_app, msg_version()) .WillByDefault(ReturnRef(mock_semantic_version)); - EXPECT_CALL(*mock_app, UnsubscribeFromButton(kButtonId)) - .WillOnce(Return(false)); EXPECT_CALL( mock_rpc_service_, @@ -111,7 +109,7 @@ TEST_F(UnsubscribeButtonRequestTest, EXPECT_CALL(mock_rpc_service_, ManageMobileCommand( MobileResultCodeIs(mobile_result::UNSUPPORTED_RESOURCE), _)); - + command->Init(); command->Run(); } @@ -137,16 +135,13 @@ TEST_F(UnsubscribeButtonRequestTest, Run_SUCCESS) { ON_CALL(*mock_app, msg_version()) .WillByDefault(ReturnRef(mock_semantic_version)); - EXPECT_CALL(*mock_app, UnsubscribeFromButton(kButtonId)) + EXPECT_CALL(*mock_app, IsSubscribedToButton(kButtonId)) .WillOnce(Return(true)); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(HMIResultCodeIs( - hmi_apis::FunctionID::Buttons_OnButtonSubscription))); - EXPECT_CALL( - mock_rpc_service_, - ManageMobileCommand(MobileResultCodeIs(mobile_result::SUCCESS), _)); + hmi_apis::FunctionID::Buttons_UnsubscribeButton))); - EXPECT_CALL(*mock_app, UpdateHash()); command->Init(); command->Run(); } @@ -180,16 +175,13 @@ TEST_F(UnsubscribeButtonRequestTest, Run_SUCCESS_Base_RPC_Version) { ON_CALL(*mock_app, is_media_application()).WillByDefault(Return(true)); EXPECT_CALL(*mock_app, - UnsubscribeFromButton(mobile_apis::ButtonName::PLAY_PAUSE)) + IsSubscribedToButton(mobile_apis::ButtonName::PLAY_PAUSE)) .WillOnce(Return(true)); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand(HMIResultCodeIs( - hmi_apis::FunctionID::Buttons_OnButtonSubscription))); - EXPECT_CALL( - mock_rpc_service_, - ManageMobileCommand(MobileResultCodeIs(mobile_result::SUCCESS), _)); + hmi_apis::FunctionID::Buttons_UnsubscribeButton))); - EXPECT_CALL(*mock_app, UpdateHash()); command->Init(); command->Run(); } diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/subscribe_vehicle_data_request.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/subscribe_vehicle_data_request.h index 7c6e1754da..8bfe23349c 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/subscribe_vehicle_data_request.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/subscribe_vehicle_data_request.h @@ -34,11 +34,11 @@ POSSIBILITY OF SUCH DAMAGE. */ -#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SUBSCRIBE_VEHICLE_DATA_REQUEST_H_ -#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SUBSCRIBE_VEHICLE_DATA_REQUEST_H_ +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_VEHICLE_INFO_PLUGIN_INCLUDE_VEHICLE_INFO_PLUGIN_COMMANDS_MOBILE_SUBSCRIBE_VEHICLE_DATA_REQUEST_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_VEHICLE_INFO_PLUGIN_INCLUDE_VEHICLE_INFO_PLUGIN_COMMANDS_MOBILE_SUBSCRIBE_VEHICLE_DATA_REQUEST_H_ -#include "application_manager/commands/command_request_impl.h" #include "application_manager/application.h" +#include "application_manager/commands/command_request_impl.h" #include "utils/macro.h" #include "vehicle_info_plugin/vehicle_info_app_extension.h" @@ -66,7 +66,7 @@ class SubscribeVehicleDataRequest policy::PolicyHandlerInterface& policy_handler); /** - * @brief SubscribeButtonCommandRequest class destructor + * @brief SubscribeVehicleDataRequest class destructor **/ ~SubscribeVehicleDataRequest(); @@ -153,6 +153,6 @@ class SubscribeVehicleDataRequest }; } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin -#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SUBSCRIBE_VEHICLE_DATA_REQUEST_H_ +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_VEHICLE_INFO_PLUGIN_INCLUDE_VEHICLE_INFO_PLUGIN_COMMANDS_MOBILE_SUBSCRIBE_VEHICLE_DATA_REQUEST_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/subscribe_vehicle_data_response.h b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/subscribe_vehicle_data_response.h index 60670afee1..0083613468 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/subscribe_vehicle_data_response.h +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/include/vehicle_info_plugin/commands/mobile/subscribe_vehicle_data_response.h @@ -61,7 +61,7 @@ class SubscribeVehicleDataResponse policy::PolicyHandlerInterface& policy_handler); /** - * @brief UnsubscribeVehicleDataCommandRequest class destructor + * @brief SubscribeVehicleDataResponse class destructor **/ virtual ~SubscribeVehicleDataResponse(); @@ -75,6 +75,6 @@ class SubscribeVehicleDataResponse }; } // namespace commands -} // namespace application_manager +} // namespace vehicle_info_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_SUBSCRIBE_VEHICLE_DATA_RESPONSE_H_ diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_subscribe_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_subscribe_vehicle_data_request.cc index 5b609dad8a..59142d2514 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_subscribe_vehicle_data_request.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/hmi/vi_subscribe_vehicle_data_request.cc @@ -67,5 +67,4 @@ void VISubscribeVehicleDataRequest::onTimeOut() { } } // namespace commands - -} // namespace application_manager +} // namespace vehicle_info_plugin diff --git a/src/components/application_manager/src/application_impl.cc b/src/components/application_manager/src/application_impl.cc index 0d1bdba611..3de057620f 100644 --- a/src/components/application_manager/src/application_impl.cc +++ b/src/components/application_manager/src/application_impl.cc @@ -1172,6 +1172,42 @@ void ApplicationImpl::PushMobileMessage( mobile_message_queue_.push_back(mobile_message); } +const std::map<int32_t, hmi_apis::Common_ButtonName::eType>& +ApplicationImpl::PendingButtonSubscriptions() const { + return pending_button_subscriptions_; +} + +const std::map<int32_t, hmi_apis::Common_ButtonName::eType>& +ApplicationImpl::PendingButtonUnsubscriptions() const { + return pending_button_unsubscriptions_; +} + +void ApplicationImpl::AddPendingButtonSubscription( + const int32_t correlation_id, + const hmi_apis::Common_ButtonName::eType button_name) { + sync_primitives::AutoLock auto_lock(pending_button_subscription_lock_); + pending_button_subscriptions_[correlation_id] = button_name; +} + +void ApplicationImpl::RemovePendingSubscriptionButton( + const int32_t correlation_id) { + sync_primitives::AutoLock auto_lock(pending_button_subscription_lock_); + pending_button_subscriptions_.erase(correlation_id); +} + +void ApplicationImpl::AddPendingButtonUnsubscription( + const int32_t correlation_id, + const hmi_apis::Common_ButtonName::eType button_name) { + sync_primitives::AutoLock auto_lock(pending_button_subscription_lock_); + pending_button_unsubscriptions_[correlation_id] = button_name; +} + +void ApplicationImpl::RemovePendingButtonUnsubscription( + const int32_t correlation_id) { + sync_primitives::AutoLock auto_lock(pending_button_subscription_lock_); + pending_button_unsubscriptions_.erase(correlation_id); +} + void ApplicationImpl::SwapMobileMessageQueue( MobileMessageQueue& mobile_messages) { sync_primitives::AutoLock lock(mobile_message_lock_); diff --git a/src/components/application_manager/src/commands/button_notification_to_mobile.cc b/src/components/application_manager/src/commands/button_notification_to_mobile.cc new file mode 100644 index 0000000000..f3aa0b64e0 --- /dev/null +++ b/src/components/application_manager/src/commands/button_notification_to_mobile.cc @@ -0,0 +1,166 @@ +#include "application_manager/commands/button_notification_to_mobile.h" +namespace application_manager { + +namespace commands { +namespace app_mngr = application_manager; + +CREATE_LOGGERPTR_GLOBAL(logger_, "ButtonNotificationToMobile") + +ButtonNotificationToMobile::ButtonNotificationToMobile( + const app_mngr::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandNotificationImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +ButtonNotificationToMobile::~ButtonNotificationToMobile() {} + +bool ButtonNotificationToMobile::DoesAppIDExist() const { + LOG4CXX_AUTO_TRACE(logger_); + using namespace application_manager::strings; + return (*message_)[msg_params].keyExists(strings::app_id); +} + +void ButtonNotificationToMobile::HandleCustomButton( + app_mngr::ApplicationSharedPtr app) { + LOG4CXX_AUTO_TRACE(logger_); + using namespace application_manager::strings; + // app_id is mandatory for CUSTOM_BUTTON notification + if (!DoesAppIDExist()) { + LOG4CXX_ERROR(logger_, "CUSTOM_BUTTON mobile notification without app_id."); + return; + } + + // custom_button_id is mandatory for CUSTOM_BUTTON notification + if (!(*message_)[msg_params].keyExists(hmi_response::custom_button_id)) { + LOG4CXX_ERROR( + logger_, "CUSTOM_BUTTON mobile notification without custom_button_id."); + return; + } + + if (!app) { + LOG4CXX_ERROR(logger_, "Application doesn't exist."); + return; + } + + const uint32_t custom_btn_id = + (*message_)[msg_params][hmi_response::custom_button_id].asUInt(); + + if (!app->IsSubscribedToSoftButton(custom_btn_id)) { + LOG4CXX_ERROR(logger_, + "Application doesn't subscribed to this custom_button_id."); + return; + } + + if ((mobile_api::HMILevel::HMI_NONE == app->hmi_level())) { + LOG4CXX_WARN(logger_, + "CUSTOM_BUTTON mobile notification is allowed only " + << "in FULL, LIMITED or BACKGROUND hmi level"); + return; + } + + SendButtonNotification(app); + return; +} + +void ButtonNotificationToMobile::HandleOKButton( + app_mngr::ApplicationSharedPtr app) { + LOG4CXX_AUTO_TRACE(logger_); + using namespace application_manager; + LOG4CXX_DEBUG(logger_, "OK button received"); + + const auto subscribed_apps = SubscribedApps(); + auto app_ptr = subscribed_apps.end(); + if (app) { + app_ptr = std::find_if(subscribed_apps.begin(), + subscribed_apps.end(), + [&app](const ApplicationSharedPtr subscribed_app) { + return app->app_id() == subscribed_app->app_id(); + }); + if (app_ptr != subscribed_apps.end()) { + LOG4CXX_DEBUG( + logger_, + "Sending button press for this app id: " << (*app_ptr)->app_id()); + SendButtonNotification(*app_ptr); + return; + } + } + + app_ptr = std::find_if(subscribed_apps.begin(), + subscribed_apps.end(), + [](const ApplicationSharedPtr subscribed_app) { + return subscribed_app->IsFullscreen(); + }); + + if (app_ptr != subscribed_apps.end()) { + LOG4CXX_DEBUG(logger_, + "Sending button press for app in FULL with app id: " + << (*app_ptr)->app_id()); + SendButtonNotification(*app_ptr); + return; + } +} + +const std::vector<ApplicationSharedPtr> +ButtonNotificationToMobile::SubscribedApps() const { + const uint32_t btn_id = static_cast<uint32_t>( + (*message_)[strings::msg_params][hmi_response::button_name].asInt()); + return application_manager_.applications_by_button(btn_id); +} + +void ButtonNotificationToMobile::HandleMediaButton() { + LOG4CXX_AUTO_TRACE(logger_); + using namespace application_manager; + const auto subscribed_apps = SubscribedApps(); + + for (const auto subscribed_app : subscribed_apps) { + if (!subscribed_app) { + LOG4CXX_WARN(logger_, "Null pointer to subscribed app."); + continue; + } + + // Send ButtonEvent notification only in HMI_FULL or HMI_LIMITED mode + if ((mobile_api::HMILevel::HMI_FULL != subscribed_app->hmi_level()) && + (mobile_api::HMILevel::HMI_LIMITED != subscribed_app->hmi_level())) { + LOG4CXX_WARN(logger_, + "Mobile button notification is allowed only" + << "in FULL or LIMITED hmi level"); + continue; + } + SendButtonNotification(subscribed_app); + } +} + +void ButtonNotificationToMobile::Run() { + LOG4CXX_AUTO_TRACE(logger_); + using namespace application_manager::strings; + + const uint32_t btn_id = static_cast<uint32_t>( + (*message_)[msg_params][hmi_response::button_name].asInt()); + + LOG4CXX_DEBUG(logger_, "received button id: " << btn_id); + + ApplicationSharedPtr app; + + if (DoesAppIDExist()) { + app = application_manager_.application( + (*message_)[msg_params][app_id].asUInt()); + } + + // CUSTOM_BUTTON notification + if (static_cast<uint32_t>(mobile_apis::ButtonName::CUSTOM_BUTTON) == btn_id) { + HandleCustomButton(app); + } else if (static_cast<uint32_t>(mobile_apis::ButtonName::OK) == btn_id) { + HandleOKButton(app); + } else { + HandleMediaButton(); + } +} + +} // namespace commands +} // namespace application_manager diff --git a/src/components/application_manager/src/hmi_interfaces_impl.cc b/src/components/application_manager/src/hmi_interfaces_impl.cc index 452b5ab79d..149ee7cbb3 100644 --- a/src/components/application_manager/src/hmi_interfaces_impl.cc +++ b/src/components/application_manager/src/hmi_interfaces_impl.cc @@ -43,8 +43,8 @@ generate_function_to_interface_convert_map() { convert_map[Buttons_GetCapabilities] = HmiInterfaces::HMI_INTERFACE_Buttons; convert_map[Buttons_OnButtonEvent] = HmiInterfaces::HMI_INTERFACE_Buttons; convert_map[Buttons_OnButtonPress] = HmiInterfaces::HMI_INTERFACE_Buttons; - convert_map[Buttons_OnButtonSubscription] = - HmiInterfaces::HMI_INTERFACE_Buttons; + convert_map[Buttons_SubscribeButton] = HmiInterfaces::HMI_INTERFACE_Buttons; + convert_map[Buttons_UnsubscribeButton] = HmiInterfaces::HMI_INTERFACE_Buttons; convert_map[BasicCommunication_OnReady] = HmiInterfaces::HMI_INTERFACE_BasicCommunication; convert_map[BasicCommunication_OnStartDeviceDiscovery] = diff --git a/src/components/application_manager/src/message_helper/message_helper.cc b/src/components/application_manager/src/message_helper/message_helper.cc index 6a1ca6309f..96209fe448 100644 --- a/src/components/application_manager/src/message_helper/message_helper.cc +++ b/src/components/application_manager/src/message_helper/message_helper.cc @@ -634,8 +634,6 @@ void MessageHelper::SendUnsubscribeButtonNotification( DCHECK(message); SmartObject& object = *message; - object[strings::params][strings::function_id] = - hmi_apis::FunctionID::Buttons_OnButtonSubscription; object[strings::msg_params] = msg_params; @@ -1025,46 +1023,81 @@ smart_objects::SmartObjectSPtr MessageHelper::CreateSetAppIcon( } smart_objects::SmartObjectSPtr -MessageHelper::CreateOnButtonSubscriptionNotification( - uint32_t app_id, - hmi_apis::Common_ButtonName::eType button, - bool is_subscribed, - ApplicationManager& app_mngr) { +MessageHelper::CreateButtonSubscriptionHandlingRequestToHmi( + const uint32_t app_id, + const hmi_apis::Common_ButtonName::eType button, + const hmi_apis::FunctionID::eType function, + application_manager::ApplicationManager& app_mngr) { using namespace smart_objects; using namespace hmi_apis; LOG4CXX_AUTO_TRACE(logger_); - SmartObjectSPtr notification_ptr = - std::make_shared<SmartObject>(SmartType_Map); - if (!notification_ptr) { - LOG4CXX_ERROR(logger_, "Memory allocation failed."); - return SmartObjectSPtr(nullptr); - } - SmartObject& notification = *notification_ptr; + SmartObjectSPtr request_ptr = CreateMessageForHMI( + hmi_apis::messageType::request, app_mngr.GetNextHMICorrelationID()); + SmartObject& request = *request_ptr; SmartObject msg_params = SmartObject(SmartType_Map); msg_params[strings::app_id] = app_id; - msg_params[strings::name] = button; - msg_params[strings::is_suscribed] = is_subscribed; + msg_params[strings::button_name] = button; + request[strings::params][strings::function_id] = function; + request[strings::msg_params] = msg_params; + return request_ptr; +} - notification[strings::params][strings::message_type] = - static_cast<int32_t>(application_manager::MessageType::kNotification); - notification[strings::params][strings::protocol_version] = - commands::CommandImpl::protocol_version_; - notification[strings::params][strings::protocol_type] = - commands::CommandImpl::hmi_protocol_type_; - notification[strings::params][strings::function_id] = - hmi_apis::FunctionID::Buttons_OnButtonSubscription; - notification[strings::msg_params] = msg_params; +smart_objects::SmartObjectSPtr MessageHelper::CreateButtonNotificationToMobile( + ApplicationManager& app_mngr, + ApplicationSharedPtr app, + const smart_objects::SmartObject& source_message) { + LOG4CXX_AUTO_TRACE(logger_); - return notification_ptr; + if (!app) { + LOG4CXX_ERROR(logger_, "application NULL pointer"); + return std::make_shared<smart_objects::SmartObject>( + smart_objects::SmartType_Null); + } + + smart_objects::SmartObjectSPtr msg = + std::make_shared<smart_objects::SmartObject>( + smart_objects::SmartType_Map); + + smart_objects::SmartObject& ref = *msg; + ref[strings::params][strings::connection_key] = app->app_id(); + + mobile_apis::ButtonName::eType btn_id = mobile_apis::ButtonName::INVALID_ENUM; + + if (source_message[strings::msg_params].keyExists( + hmi_response::button_name)) { + btn_id = static_cast<mobile_apis::ButtonName::eType>( + source_message[strings::msg_params][hmi_response::button_name].asInt()); + + } else if (source_message[strings::msg_params].keyExists( + strings::button_name)) { + btn_id = static_cast<mobile_apis::ButtonName::eType>( + source_message[strings::msg_params][strings::button_name].asInt()); + } + + if (btn_id == mobile_apis::ButtonName::PLAY_PAUSE && + app->msg_version() <= utils::base_rpc_version) { + btn_id = mobile_apis::ButtonName::OK; + } + + ref[strings::msg_params][strings::button_name] = btn_id; + + if (source_message[strings::msg_params].keyExists( + hmi_response::custom_button_id)) { + ref[strings::msg_params][strings::custom_button_id] = + source_message[strings::msg_params][strings::custom_button_id]; + } + + return msg; } smart_objects::SmartObjectList -MessageHelper::CreateOnButtonSubscriptionNotificationsForApp( +MessageHelper::CreateButtonSubscriptionsHandlingRequestsList( ApplicationConstSharedPtr app, - ApplicationManager& app_mngr, - const ButtonSubscriptions& button_subscriptions) { + const ButtonSubscriptions& button_subscriptions, + const hmi_apis::FunctionID::eType function, + ApplicationManager& app_mngr) { using namespace smart_objects; using namespace hmi_apis; using namespace mobile_apis; @@ -1082,8 +1115,8 @@ MessageHelper::CreateOnButtonSubscriptionNotificationsForApp( static_cast<Common_ButtonName::eType>(it); button_subscription_requests.push_back( - CreateOnButtonSubscriptionNotification( - app->hmi_app_id(), btn, true, app_mngr)); + CreateButtonSubscriptionHandlingRequestToHmi( + app->app_id(), btn, function, app_mngr)); } return button_subscription_requests; diff --git a/src/components/application_manager/src/request_controller.cc b/src/components/application_manager/src/request_controller.cc index 315cf6fdf8..c2383253c9 100644 --- a/src/components/application_manager/src/request_controller.cc +++ b/src/components/application_manager/src/request_controller.cc @@ -274,7 +274,7 @@ void RequestController::OnMobileResponse(const uint32_t mobile_correlation_id, void RequestController::OnHMIResponse(const uint32_t correlation_id, const int32_t function_id) { LOG4CXX_AUTO_TRACE(logger_); - TerminateRequest(correlation_id, RequestInfo::HmiConnectoinKey, function_id); + TerminateRequest(correlation_id, RequestInfo::HmiConnectionKey, function_id); } void RequestController::terminateWaitingForExecutionAppRequests( @@ -321,7 +321,7 @@ void RequestController::terminateAppRequests(const uint32_t& app_id) { void RequestController::terminateAllHMIRequests() { LOG4CXX_AUTO_TRACE(logger_); - terminateWaitingForResponseAppRequests(RequestInfo::HmiConnectoinKey); + terminateWaitingForResponseAppRequests(RequestInfo::HmiConnectionKey); } void RequestController::terminateAllMobileRequests() { @@ -343,9 +343,11 @@ void RequestController::updateRequestTimeout(const uint32_t& app_id, "app_id : " << app_id << " mobile_correlation_id : " << correlation_id << " new_timeout : " << new_timeout); - LOG4CXX_DEBUG(logger_, - "New_timeout is NULL. RequestCtrl will " - "not manage this request any more"); + if (0 == new_timeout) { + LOG4CXX_DEBUG(logger_, + "New_timeout is ZERO. RequestCtrl will " + "not manage this request any more"); + } RequestInfoPtr request_info = waiting_for_response_.Find(app_id, correlation_id); @@ -426,19 +428,20 @@ void RequestController::TimeoutThread() { << " request id: " << probably_expired->requestId() << " connection_key: " << probably_expired->app_id() << " is expired"); - const uint32_t experied_request_id = probably_expired->requestId(); - const uint32_t experied_app_id = probably_expired->app_id(); + const uint32_t expired_request_id = probably_expired->requestId(); + const uint32_t expired_app_id = probably_expired->app_id(); probably_expired->request()->onTimeOut(); - if (RequestInfo::HmiConnectoinKey == probably_expired->app_id()) { + if (RequestInfo::HmiConnectionKey == probably_expired->app_id() && + probably_expired->timeout_msec() != 0) { LOG4CXX_DEBUG(logger_, "Erase HMI request: " << probably_expired->requestId()); waiting_for_response_.RemoveRequest(probably_expired); } probably_expired = waiting_for_response_.FrontWithNotNullTimeout(); if (probably_expired) { - if (experied_request_id == probably_expired->requestId() && - experied_app_id == probably_expired->app_id()) { + if (expired_request_id == probably_expired->requestId() && + expired_app_id == probably_expired->app_id()) { LOG4CXX_DEBUG(logger_, "Expired request wasn't removed"); break; } diff --git a/src/components/application_manager/src/request_info.cc b/src/components/application_manager/src/request_info.cc index bbcda06b43..4f1e0a8f07 100644 --- a/src/components/application_manager/src/request_info.cc +++ b/src/components/application_manager/src/request_info.cc @@ -42,12 +42,12 @@ namespace request_controller { CREATE_LOGGERPTR_GLOBAL(logger_, "RequestController") -uint32_t RequestInfo::HmiConnectoinKey = 0; +uint32_t RequestInfo::HmiConnectionKey = 0; HMIRequestInfo::HMIRequestInfo(RequestPtr request, const uint64_t timeout_msec) : RequestInfo(request, HMIRequest, timeout_msec) { correlation_id_ = request_->correlation_id(); - app_id_ = RequestInfo::HmiConnectoinKey; + app_id_ = RequestInfo::HmiConnectionKey; } HMIRequestInfo::HMIRequestInfo(RequestPtr request, @@ -55,7 +55,7 @@ HMIRequestInfo::HMIRequestInfo(RequestPtr request, const uint64_t timeout_msec) : RequestInfo(request, HMIRequest, start_time, timeout_msec) { correlation_id_ = request_->correlation_id(); - app_id_ = RequestInfo::HmiConnectoinKey; + app_id_ = RequestInfo::HmiConnectionKey; } MobileRequestInfo::MobileRequestInfo(RequestPtr request, @@ -252,7 +252,7 @@ uint32_t RequestInfoSet::RemoveByConnectionKey(uint32_t connection_key) { uint32_t RequestInfoSet::RemoveMobileRequests() { LOG4CXX_AUTO_TRACE(logger_); return RemoveRequests(AppIdCompararator(AppIdCompararator::NotEqual, - RequestInfo::HmiConnectoinKey)); + RequestInfo::HmiConnectionKey)); } const size_t RequestInfoSet::Size() { diff --git a/src/components/application_manager/src/resumption/resumption_data_processor.cc b/src/components/application_manager/src/resumption/resumption_data_processor.cc index 65ac9b8947..6aeba08798 100644 --- a/src/components/application_manager/src/resumption/resumption_data_processor.cc +++ b/src/components/application_manager/src/resumption/resumption_data_processor.cc @@ -753,8 +753,11 @@ void ResumptionDataProcessor::AddButtonsSubscriptions( GetButtonSubscriptionsToResume(application); ProcessHMIRequests( - MessageHelper::CreateOnButtonSubscriptionNotificationsForApp( - application, application_manager_, button_subscriptions)); + MessageHelper::CreateButtonSubscriptionsHandlingRequestsList( + application, + button_subscriptions, + hmi_apis::FunctionID::Buttons_SubscribeButton, + application_manager_)); } } @@ -795,18 +798,18 @@ void ResumptionDataProcessor::DeleteButtonsSubscriptions( LOG4CXX_AUTO_TRACE(logger_); const ButtonSubscriptions button_subscriptions = application->SubscribedButtons().GetData(); - smart_objects::SmartObjectSPtr notification; for (auto& btn : button_subscriptions) { const auto hmi_btn = static_cast<hmi_apis::Common_ButtonName::eType>(btn); if (hmi_apis::Common_ButtonName::CUSTOM_BUTTON == hmi_btn) { continue; } - notification = MessageHelper::CreateOnButtonSubscriptionNotification( - application->hmi_app_id(), - hmi_btn, - /*is_subscribed = */ false, - application_manager_); - ProcessHMIRequest(notification, false); + smart_objects::SmartObjectSPtr unsubscribe_request = + MessageHelper::CreateButtonSubscriptionHandlingRequestToHmi( + application->app_id(), + hmi_btn, + hmi_apis::FunctionID::Buttons_UnsubscribeButton, + application_manager_); + ProcessHMIRequest(unsubscribe_request, false); application->UnsubscribeFromButton(btn); } } diff --git a/src/components/application_manager/test/include/application_manager/mock_application.h b/src/components/application_manager/test/include/application_manager/mock_application.h index fe16e8ce6e..ee7a39d12a 100644 --- a/src/components/application_manager/test/include/application_manager/mock_application.h +++ b/src/components/application_manager/test/include/application_manager/mock_application.h @@ -342,6 +342,16 @@ class MockApplication : public ::application_manager::Application { const std::list<application_manager::AppExtensionPtr>&()); MOCK_CONST_METHOD0(is_remote_control_supported, bool()); MOCK_METHOD1(set_remote_control_supported, void(const bool allow)); + MOCK_CONST_METHOD0(PendingButtonSubscriptions, + std::map<int32_t, hmi_apis::Common_ButtonName::eType>&()); + MOCK_CONST_METHOD0(PendingButtonUnsubscriptions, + std::map<int32_t, hmi_apis::Common_ButtonName::eType>&()); + MOCK_METHOD2(AddPendingButtonSubscription, + void(const int32_t, const hmi_apis::Common_ButtonName::eType)); + MOCK_METHOD1(RemovePendingSubscriptionButton, void(const int32_t)); + MOCK_METHOD2(AddPendingButtonUnsubscription, + void(const int32_t, const hmi_apis::Common_ButtonName::eType)); + MOCK_METHOD1(RemovePendingButtonUnsubscription, void(const int32_t)); }; } // namespace application_manager_test diff --git a/src/components/application_manager/test/include/application_manager/mock_message_helper.h b/src/components/application_manager/test/include/application_manager/mock_message_helper.h index 73be350611..1b7b5a5b58 100644 --- a/src/components/application_manager/test/include/application_manager/mock_message_helper.h +++ b/src/components/application_manager/test/include/application_manager/mock_message_helper.h @@ -173,11 +173,21 @@ class MockMessageHelper { MOCK_METHOD2(CreateModuleInfoSO, smart_objects::SmartObjectSPtr(uint32_t function_id, ApplicationManager& app_mngr)); - MOCK_METHOD3(CreateOnButtonSubscriptionNotificationsForApp, + + MOCK_METHOD4(CreateButtonSubscriptionsHandlingRequestsList, smart_objects::SmartObjectList( ApplicationConstSharedPtr app, - ApplicationManager& app_mngr, - const ButtonSubscriptions& button_subscriptions)); + const ButtonSubscriptions& button_subscriptions, + const hmi_apis::FunctionID::eType function, + ApplicationManager& app_mngr)); + + MOCK_METHOD4(CreateButtonSubscriptionHandlingRequestToHmi, + smart_objects::SmartObjectSPtr( + const uint32_t app_id, + const hmi_apis::Common_ButtonName::eType button, + const hmi_apis::FunctionID::eType function, + application_manager::ApplicationManager& app_mngr)); + MOCK_METHOD2(SendOnResumeAudioSourceToHMI, void(uint32_t app_id, ApplicationManager& app_mngr)); MOCK_METHOD2(CreateAddSubMenuRequestsToHMI, @@ -330,13 +340,11 @@ class MockMessageHelper { MOCK_METHOD2(CreateGlobalPropertiesRequestsToHMI, smart_objects::SmartObjectList(ApplicationConstSharedPtr app, ApplicationManager& app_mngr)); - - MOCK_METHOD4( - CreateOnButtonSubscriptionNotification, - smart_objects::SmartObjectSPtr(uint32_t app_id, - hmi_apis::Common_ButtonName::eType button, - bool is_subscribed, - ApplicationManager& app_mngr)); + MOCK_METHOD3(CreateButtonNotificationToMobile, + smart_objects::SmartObjectSPtr( + ApplicationManager& app_mngr, + ApplicationSharedPtr app, + const smart_objects::SmartObject& source_message)); static MockMessageHelper* message_helper_mock(); }; diff --git a/src/components/application_manager/test/mock_message_helper.cc b/src/components/application_manager/test/mock_message_helper.cc index 815ea7565f..6973e4efec 100644 --- a/src/components/application_manager/test/mock_message_helper.cc +++ b/src/components/application_manager/test/mock_message_helper.cc @@ -293,14 +293,27 @@ MockMessageHelper* MockMessageHelper::message_helper_mock() { static ::testing::NiceMock<MockMessageHelper> message_helper_mock; return &message_helper_mock; } + smart_objects::SmartObjectList -MessageHelper::CreateOnButtonSubscriptionNotificationsForApp( +MessageHelper::CreateButtonSubscriptionsHandlingRequestsList( ApplicationConstSharedPtr app, - ApplicationManager& app_mngr, - const ButtonSubscriptions& button_subscriptions) { + const ButtonSubscriptions& button_subscriptions, + const hmi_apis::FunctionID::eType function, + ApplicationManager& app_mngr) { + return MockMessageHelper::message_helper_mock() + ->CreateButtonSubscriptionsHandlingRequestsList( + app, button_subscriptions, function, app_mngr); +} + +smart_objects::SmartObjectSPtr +MessageHelper::CreateButtonSubscriptionHandlingRequestToHmi( + const uint32_t app_id, + const hmi_apis::Common_ButtonName::eType button, + const hmi_apis::FunctionID::eType function, + ApplicationManager& app_mngr) { return MockMessageHelper::message_helper_mock() - ->CreateOnButtonSubscriptionNotificationsForApp( - app, app_mngr, button_subscriptions); + ->CreateButtonSubscriptionHandlingRequestToHmi( + app_id, button, function, app_mngr); } void MessageHelper::SendOnResumeAudioSourceToHMI(const uint32_t app_id, @@ -605,15 +618,12 @@ MessageHelper::CreateGlobalPropertiesRequestsToHMI( ->CreateGlobalPropertiesRequestsToHMI(app, app_mngr); } -smart_objects::SmartObjectSPtr -MessageHelper::CreateOnButtonSubscriptionNotification( - uint32_t app_id, - hmi_apis::Common_ButtonName::eType button, - bool is_subscribed, - ApplicationManager& app_mngr) { +smart_objects::SmartObjectSPtr MessageHelper::CreateButtonNotificationToMobile( + ApplicationManager& app_mngr, + ApplicationSharedPtr app, + const smart_objects::SmartObject& source_message) { return MockMessageHelper::message_helper_mock() - ->CreateOnButtonSubscriptionNotification( - app_id, button, is_subscribed, app_mngr); + ->CreateButtonNotificationToMobile(app_mngr, app, source_message); } } // namespace application_manager diff --git a/src/components/application_manager/test/resumption/resume_ctrl_test.cc b/src/components/application_manager/test/resumption/resume_ctrl_test.cc index 49e1713d75..4e522f282b 100644 --- a/src/components/application_manager/test/resumption/resume_ctrl_test.cc +++ b/src/components/application_manager/test/resumption/resume_ctrl_test.cc @@ -543,10 +543,10 @@ TEST_F(ResumeCtrlTest, StartResumption_AppWithSubscribeOnButtons) { ON_CALL(*mock_app_, SubscribedButtons()) .WillByDefault(Return(button_subscription_accessor)); - smart_objects::SmartObjectList button_subscription_notifications; + smart_objects::SmartObjectList button_subscription_requests_list; ON_CALL(*application_manager::MockMessageHelper::message_helper_mock(), - CreateOnButtonSubscriptionNotificationsForApp(_, _, _)) - .WillByDefault(Return(button_subscription_notifications)); + CreateButtonSubscriptionsHandlingRequestsList(_, _, _, _)) + .WillByDefault(Return(button_subscription_requests_list)); EXPECT_CALL(*mock_app_, set_grammar_id(kTestGrammarId_)); @@ -564,7 +564,7 @@ TEST_F(ResumeCtrlTest, StartResumption_AppWithSubscribeOnButtons) { EXPECT_CALL(*mock_app_extension_, ProcessResumption(saved_app, _)); EXPECT_CALL(*application_manager::MockMessageHelper::message_helper_mock(), - CreateOnButtonSubscriptionNotificationsForApp(_, _, _)); + CreateButtonSubscriptionsHandlingRequestsList(_, _, _, _)); const bool res = res_ctrl_->StartResumption(mock_app_, kHash_, callback_); EXPECT_TRUE(res); diff --git a/src/components/interfaces/HMI_API.xml b/src/components/interfaces/HMI_API.xml index 97df559ef5..15b3223bd3 100644 --- a/src/components/interfaces/HMI_API.xml +++ b/src/components/interfaces/HMI_API.xml @@ -3408,24 +3408,35 @@ </description> </param> </function> - <function name="OnButtonSubscription" messagetype="notification"> - <description> - Sender: SDL->HMI. Purpose: to notify about button subscription state is changed for the named application - </description> - <param name="name" type="Common.ButtonName" mandatory="true" /> - <param name="isSubscribed" type="Boolean" mandatory="true"> + <function name="SubscribeButton" messagetype="request"> <description> - Defines whether the named button has status of 'subscribed' or 'unsubscribed': - If "true" - the named button is subscribed. - If "false" - the named button is unsubscribed. + Subscribes to buttons. </description> - </param> - <param name="appID" type="Integer" mandatory="true"> + <param name="appID" type="Integer" mandatory="true"> + <description>The ID of the application requesting this button subscription. </description> + </param> + + <param name="buttonName" type="Common.ButtonName" mandatory="true"> + <description>Name of the button to subscribe.</description> + </param> + </function> + + <function name="SubscribeButton" messagetype="response"> </function> + + <function name="UnsubscribeButton" messagetype="request"> <description> - The ID of application that relates to this button-subscription status change. + Unsubscribes from buttons. </description> - </param> + <param name="appID" type="Integer" mandatory="true"> + <description>The ID of the application requesting this button unsubscription. </description> + </param> + + <param name="buttonName" type="Common.ButtonName" mandatory="true"> + <description>Name of the button to unsubscribe from.</description> + </param> </function> + + <function name="UnsubscribeButton" messagetype="response"></function> </interface> <interface name="BasicCommunication" version="2.0.0" date="2018-09-05"> |