diff options
author | Aleksandr Galiuzov <AGaliuzov@luxoft.com> | 2015-06-12 17:24:07 +0300 |
---|---|---|
committer | Aleksandr Galiuzov <AGaliuzov@luxoft.com> | 2015-06-12 17:24:07 +0300 |
commit | 080fcbcb351d87e88475c83152ddf356e79b7787 (patch) | |
tree | bd5c1c5cf6abe4f96099ed7f19430fec06a29f61 | |
parent | 668b92afd344427765fbec350b90ac42f1ed95af (diff) | |
parent | 1f6b6a18677e7717ee4d5490d5b45c7194b5203f (diff) | |
download | smartdevicelink-080fcbcb351d87e88475c83152ddf356e79b7787.tar.gz |
Merge branch 'hotfix/Subscribe_buttons_after_resumption' into release/4.0.0
3 files changed, 74 insertions, 4 deletions
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 12705c619..9b8093dc5 100644 --- a/src/components/application_manager/include/application_manager/message_helper.h +++ b/src/components/application_manager/include/application_manager/message_helper.h @@ -178,15 +178,28 @@ class MessageHelper { const std::string& path_to_icon, uint32_t app_id); /** - * @brief Sends IVI subscriptions + * @brief Sends IVI subscription requests */ static bool SendIVISubscribtions(const uint32_t app_id); /** - * @brief Sends IVI subscriptions + * @brief Returns IVI subscription requests */ static smart_objects::SmartObjectList GetIVISubscriptionRequests(ApplicationSharedPtr app); + /** + * @brief Sends button subscription notification + */ + static void SendOnButtonSubscriptionNotification( + uint32_t app_id, hmi_apis::Common_ButtonName::eType button, bool is_subscribed); + + /** + * @brief Sends button subscription notifications for all buttons + * that application is subscribed on + */ + static void SendAllOnButtonSubscriptionNotificationsForApp( + ApplicationConstSharedPtr app); + static void SendAppDataToHMI(ApplicationConstSharedPtr app); static void SendGlobalPropertiesToHMI(ApplicationConstSharedPtr app); static smart_objects::SmartObjectList CreateGlobalPropertiesRequestsToHMI(ApplicationConstSharedPtr app); diff --git a/src/components/application_manager/src/message_helper.cc b/src/components/application_manager/src/message_helper.cc index 461c2d169..926330ea9 100644 --- a/src/components/application_manager/src/message_helper.cc +++ b/src/components/application_manager/src/message_helper.cc @@ -53,6 +53,7 @@ #include "utils/file_system.h" #include "utils/macro.h" #include "utils/logger.h" +#include "utils/make_shared.h" #include "formatters/formatter_json_rpc.h" #include "formatters/CFormatterJsonSDLRPCv2.hpp" @@ -726,6 +727,59 @@ smart_objects::SmartObjectList MessageHelper::GetIVISubscriptionRequests( return hmi_requests; } +void MessageHelper::SendOnButtonSubscriptionNotification( + uint32_t app_id, hmi_apis::Common_ButtonName::eType button, bool is_subscribed) { + using namespace smart_objects; + using namespace hmi_apis; + LOG4CXX_AUTO_TRACE(logger_); + + SmartObjectSPtr notification_ptr = utils::MakeShared<SmartObject>(SmartType_Map); + if (!notification_ptr) { + LOG4CXX_ERROR(logger_, "Memory allocation failed."); + return; + } + SmartObject& notification = *notification_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; + + 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; + + if (!ApplicationManagerImpl::instance()->ManageHMICommand(notification_ptr)) { + LOG4CXX_ERROR(logger_, "Unable to send HMI notification"); + } +} + +void MessageHelper::SendAllOnButtonSubscriptionNotificationsForApp( + ApplicationConstSharedPtr app) { + using namespace smart_objects; + using namespace hmi_apis; + using namespace mobile_apis; + LOG4CXX_AUTO_TRACE(logger_); + + if (!app.valid()) { + LOG4CXX_ERROR(logger_, "Invalid application pointer "); + return; + } + + std::set<ButtonName::eType> subscriptions = app->SubscribedButtons(); + std::set<ButtonName::eType>::iterator it = subscriptions.begin(); + for (; subscriptions.end() != it; ++it) { + SendOnButtonSubscriptionNotification( + app->hmi_app_id(), static_cast<Common_ButtonName::eType>(*it), true); + } +} + void MessageHelper::SendSetAppIcon(uint32_t app_id, const std::string& icon_path) { using namespace smart_objects; diff --git a/src/components/application_manager/src/resume_ctrl.cpp b/src/components/application_manager/src/resume_ctrl.cpp index bf07a6e2a..7dcbca642 100644 --- a/src/components/application_manager/src/resume_ctrl.cpp +++ b/src/components/application_manager/src/resume_ctrl.cpp @@ -959,7 +959,8 @@ void ResumeCtrl::AddCommands(ApplicationSharedPtr application, const Json::Value } void ResumeCtrl::AddChoicesets(ApplicationSharedPtr application, const Json::Value& saved_app) { - if(saved_app.isMember(strings::application_choise_sets)) { + LOG4CXX_AUTO_TRACE(logger_); + if (saved_app.isMember(strings::application_choise_sets)) { const Json::Value& app_choise_sets = saved_app[strings::application_choise_sets]; for (Json::Value::iterator json_it = app_choise_sets.begin(); json_it != app_choise_sets.end(); ++json_it) { @@ -993,6 +994,7 @@ void ResumeCtrl::AddChoicesets(ApplicationSharedPtr application, const Json::Val } void ResumeCtrl::SetGlobalProperties(ApplicationSharedPtr application, const Json::Value& saved_app) { + LOG4CXX_AUTO_TRACE(logger_); const Json::Value& global_properties = saved_app[strings::application_global_properties]; if (!global_properties.isNull()) { smart_objects::SmartObject properties_so(smart_objects::SmartType::SmartType_Map); @@ -1003,6 +1005,7 @@ void ResumeCtrl::SetGlobalProperties(ApplicationSharedPtr application, const Jso } void ResumeCtrl::AddSubscriptions(ApplicationSharedPtr application, const Json::Value& saved_app) { + LOG4CXX_AUTO_TRACE(logger_); if (saved_app.isMember(strings::application_subscribtions)) { const Json::Value& subscribtions = saved_app[strings::application_subscribtions]; @@ -1024,8 +1027,8 @@ void ResumeCtrl::AddSubscriptions(ApplicationSharedPtr application, const Json:: application->SubscribeToIVI(ivi); } } - ProcessHMIRequests(MessageHelper::GetIVISubscriptionRequests(application)); + MessageHelper::SendAllOnButtonSubscriptionNotificationsForApp(application); } } |