diff options
author | AKalinich-Luxoft <AKalinich@luxoft.com> | 2018-07-06 19:55:38 +0300 |
---|---|---|
committer | AKalinich-Luxoft <AKalinich@luxoft.com> | 2018-07-11 20:50:08 +0300 |
commit | 1c57695b83f1d680a8ea23513378e6c6248210da (patch) | |
tree | 94f9326fef177b03c6752781b45e50fe21ddf0af | |
parent | 6371b7b64145971fbf31c5f0e20de83f2d5d73bb (diff) | |
download | sdl_core-1c57695b83f1d680a8ea23513378e6c6248210da.tar.gz |
Fix failed ATF tests after timer removing
Fixed triggering SetGlobalProperties after resumption and during resumption
Fixed commands limit after resumption
Fixed requests counter
Removed redundant logic
13 files changed, 192 insertions, 165 deletions
diff --git a/src/components/application_manager/include/application_manager/application.h b/src/components/application_manager/include/application_manager/application.h index ae0466326c..8a681ac29a 100644 --- a/src/components/application_manager/include/application_manager/application.h +++ b/src/components/application_manager/include/application_manager/application.h @@ -639,6 +639,7 @@ class Application : public virtual InitialApplicationData, * @return object for recording statistics */ virtual UsageStatistics& usage_report() = 0; + /** * @brief Access to HelpPromptManager interface * @return object for Handling VR help 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 377a97b2b9..b69a056e03 100644 --- a/src/components/application_manager/include/application_manager/application_impl.h +++ b/src/components/application_manager/include/application_manager/application_impl.h @@ -247,6 +247,7 @@ class ApplicationImpl : public virtual Application, void SetHashChangedDuringSuspend(const bool state) OVERRIDE; UsageStatistics& usage_report(); + /** * @brief Access to HelpPromptManager interface * @return object for Handling VR help diff --git a/src/components/application_manager/include/application_manager/help_prompt_manager.h b/src/components/application_manager/include/application_manager/help_prompt_manager.h index d5e712c1e7..a0c34e77d7 100644 --- a/src/components/application_manager/include/application_manager/help_prompt_manager.h +++ b/src/components/application_manager/include/application_manager/help_prompt_manager.h @@ -46,17 +46,29 @@ class HelpPromptManager { * @brief Class destructor */ virtual ~HelpPromptManager() {} + /** * @brief Adds command to constructed values, and sends SetGlobalProperties if * required + * @param cmd_id command unique ID + * @param command smart object with commands to add + * @param is_resumption flag for identifying if command was added during data + * resumption process */ virtual void OnVrCommandAdded(const uint32_t cmd_id, - const smart_objects::SmartObject& command) = 0; + const smart_objects::SmartObject& command, + const bool is_resumption) = 0; + /** * @brief Removes command from constructed values, and send * SetGlobalProperties if required + * @param cmd_id command unique ID + * @param is_resumption flag for identifying if command was added during data + * resumption process */ - virtual void OnVrCommandDeleted(const uint32_t cmd_id) = 0; + virtual void OnVrCommandDeleted(const uint32_t cmd_id, + const bool is_resumption) = 0; + /** * @brief Stop constructing vrHelp and/or helpPrompt if they are present in * message @@ -66,16 +78,17 @@ class HelpPromptManager { */ virtual void OnSetGlobalPropertiesReceived( const smart_objects::SmartObject& msg, const bool is_response) = 0; + /** - * @brief Starts mechanism for handling "help" requests - * @param is_restore determines the need to restore commands - * after resuming + * @brief Requests sending type behavior */ - virtual void OnAppActivated(const bool is_restore) = 0; + enum class SendingType { kNoneSend, kSendHelpPrompt, kSendVRHelp, kSendBoth }; + /** - * @brief Stop mechanism for handling "help" requests + * @brief Get current sending type + * @return current sending type */ - virtual void OnAppUnregistered() = 0; + virtual SendingType GetSendingType() const = 0; }; } // namespace application_manager diff --git a/src/components/application_manager/include/application_manager/help_prompt_manager_impl.h b/src/components/application_manager/include/application_manager/help_prompt_manager_impl.h index a34f034e3e..4af4f82062 100644 --- a/src/components/application_manager/include/application_manager/help_prompt_manager_impl.h +++ b/src/components/application_manager/include/application_manager/help_prompt_manager_impl.h @@ -54,31 +54,40 @@ class HelpPromptManagerImpl : public HelpPromptManager { * @brief Continer for buffering VR help commands */ typedef std::map<uint32_t, smart_objects::SmartObjectSPtr> VRCommandsMap; + /** * @brief Class constructor * @param app owner for this class */ HelpPromptManagerImpl(Application& app, ApplicationManager& app_manager); + /** * @brief Class destructor */ ~HelpPromptManagerImpl(); - /** - * @brief The type sends info to HMI - */ - enum class SendingType { kNoneSend, kSendHelpPrompt, kSendVRHelp, kSendBoth }; /** - * @brief Adds command to constructed values, and send SetGlobalProperties if + * @brief Adds command to constructed values, and sends SetGlobalProperties if * required + * @param cmd_id command unique ID + * @param command smart object with commands to add + * @param is_resumption flag for identifying if command was added during data + * resumption process */ void OnVrCommandAdded(const uint32_t cmd_id, - const smart_objects::SmartObject& command) OVERRIDE; + const smart_objects::SmartObject& command, + const bool is_resumption) OVERRIDE; + /** * @brief Removes command from constructed values, and send * SetGlobalProperties if required + * @param cmd_id command unique ID + * @param is_resumption flag for identifying if command was added during data + * resumption process */ - void OnVrCommandDeleted(const uint32_t cmd_id) OVERRIDE; + void OnVrCommandDeleted(const uint32_t cmd_id, + const bool is_resumption) OVERRIDE; + /** * @brief Stop constructing vrHelp and/or helpPrompt if they are present in * message @@ -88,25 +97,23 @@ class HelpPromptManagerImpl : public HelpPromptManager { */ void OnSetGlobalPropertiesReceived(const smart_objects::SmartObject& msg, const bool is_response) OVERRIDE; + /** - * @brief Starts mechanism for handling "help" requests - * @param is_restore determines the need to restore commands - * after resuming - */ - void OnAppActivated(const bool is_restore) OVERRIDE; - /** - * @brief Stop mechanism for handling "help" requests - */ - void OnAppUnregistered() OVERRIDE; + * @brief Get current sending type + * @return current sending type + */ + SendingType GetSendingType() const OVERRIDE; private: DISALLOW_COPY_AND_ASSIGN(HelpPromptManagerImpl); + /** * @brief Add new smart object with VR command to the map * @param cmd_id ID of VR command * @param command smart object containing VR command structure + * @return true if command was added successfully otherwise returns false */ - void AddCommand(const uint32_t cmd_id, + bool AddCommand(const uint32_t cmd_id, const smart_objects::SmartObject& command); /** * @brief Delete VR command from map by its cmd_id @@ -114,40 +121,43 @@ class HelpPromptManagerImpl : public HelpPromptManager { * @return true if command was successfully deleted otherwise returns false */ bool DeleteCommand(const uint32_t cmd_id); + /** * @brief Send TTS request to HMI */ void SendTTSRequest(); + /** * @brief Send UI request to HMI */ void SendUIRequest(); + /** * @brief Send TTS and UI requests to HMI */ void SendBothRequests(); + /** * @brief Send TTS or UI or both Requests */ void SendRequests(); + /** * @brief Construct the helpPrompt parameter */ void CreatePromptMsg(smart_objects::SmartObject& out_msg_params); + /** * @brief Construct the vrHelp parameter */ void CreateVRMsg(smart_objects::SmartObject& out_msg_params); + /** - * @brief Getting request type to send HMI + * @brief Setting request type to send HMI * @param msg containing request or response for the * SetGlobalPropertiesRequest - * @param is_response determines is the request or response for the for - * the SetGlobalPropertiesRequest - * @return SendingType */ - SendingType GetSendingType(const smart_objects::SmartObject& msg, - const bool is_response); + void SetSendingType(const smart_objects::SmartObject& msg); Application& app_; ApplicationManager& app_manager_; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_command_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_command_request.cc index d1cb9763d9..1da9fc497f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_command_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_command_request.cc @@ -320,9 +320,10 @@ void AddCommandRequest::on_event(const event_engine::Event& event) { return; } + const uint32_t cmd_id = + (*message_)[strings::msg_params][strings::cmd_id].asUInt(); smart_objects::SmartObject msg_param(smart_objects::SmartType_Map); - msg_param[strings::cmd_id] = - (*message_)[strings::msg_params][strings::cmd_id]; + msg_param[strings::cmd_id] = cmd_id; msg_param[strings::app_id] = application->app_id(); switch (event.id()) { @@ -458,8 +459,7 @@ void AddCommandRequest::on_event(const event_engine::Event& event) { msg_params[strings::type] = hmi_apis::Common_VRCommandType::Command; SendHMIRequest(hmi_apis::FunctionID::VR_DeleteCommand, &msg_params); - application->RemoveCommand( - (*message_)[strings::msg_params][strings::cmd_id].asUInt()); + application->RemoveCommand(cmd_id); result = false; LOG4CXX_DEBUG(logger_, "Result " << result); } @@ -474,8 +474,7 @@ void AddCommandRequest::on_event(const event_engine::Event& event) { SendHMIRequest(hmi_apis::FunctionID::UI_DeleteCommand, &msg_params); - application->RemoveCommand( - (*message_)[strings::msg_params][strings::cmd_id].asUInt()); + application->RemoveCommand(cmd_id); result = false; LOG4CXX_DEBUG(logger_, "Result " << result); } @@ -501,7 +500,10 @@ void AddCommandRequest::on_event(const event_engine::Event& event) { result = false; } - if (!result) { + if (result) { + application->help_prompt_manager().OnVrCommandAdded( + cmd_id, (*message_)[strings::msg_params], false); + } else { RemoveCommand(); } @@ -595,13 +597,13 @@ void AddCommandRequest::RemoveCommand() { return; } + const uint32_t cmd_id = + (*message_)[strings::msg_params][strings::cmd_id].asUInt(); smart_objects::SmartObject msg_params(smart_objects::SmartType_Map); - msg_params[strings::cmd_id] = - (*message_)[strings::msg_params][strings::cmd_id]; + msg_params[strings::cmd_id] = cmd_id; msg_params[strings::app_id] = app->app_id(); - app->RemoveCommand( - (*message_)[strings::msg_params][strings::cmd_id].asUInt()); + app->RemoveCommand(cmd_id); if (BothSend() && !(is_vr_received_ || is_ui_received_)) { // in case we have send bth UI and VR and no one respond diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_command_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_command_request.cc index bbe787a123..38069c341e 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_command_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_command_request.cc @@ -198,7 +198,7 @@ void DeleteCommandRequest::on_event(const event_engine::Event& event) { } smart_objects::SmartObject& msg_params = (*message_)[strings::msg_params]; - const int32_t cmd_id = msg_params[strings::cmd_id].asInt(); + const uint32_t cmd_id = msg_params[strings::cmd_id].asUInt(); smart_objects::SmartObject* command = application->FindCommand(cmd_id); @@ -213,7 +213,8 @@ void DeleteCommandRequest::on_event(const event_engine::Event& event) { std::string info; const bool result = PrepareResponseParameters(result_code, info); if (result) { - application->RemoveCommand(msg_params[strings::cmd_id].asInt()); + application->RemoveCommand(cmd_id); + application->help_prompt_manager().OnVrCommandDeleted(cmd_id, false); } SendResponse( result, result_code, info.empty() ? NULL : info.c_str(), &msg_params); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_sub_menu_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_sub_menu_request.cc index 38113afcc2..9a01163702 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_sub_menu_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_sub_menu_request.cc @@ -134,9 +134,11 @@ void DeleteSubMenuRequest::DeleteSubMenuUICommands( (*it->second)[strings::menu_params][hmi_request::parent_id].asInt()) { smart_objects::SmartObject msg_params = smart_objects::SmartObject(smart_objects::SmartType_Map); + const uint32_t cmd_id = (*it->second)[strings::cmd_id].asUInt(); msg_params[strings::app_id] = app->app_id(); - msg_params[strings::cmd_id] = (*it->second)[strings::cmd_id].asInt(); - app->RemoveCommand((*it->second)[strings::cmd_id].asInt()); + msg_params[strings::cmd_id] = cmd_id; + app->RemoveCommand(cmd_id); + app->help_prompt_manager().OnVrCommandDeleted(cmd_id, false); it = commands.begin(); // Can not relay on // iterators after erase was called diff --git a/src/components/application_manager/src/application_data_impl.cc b/src/components/application_manager/src/application_data_impl.cc index a809112f54..f271b7ff6a 100644 --- a/src/components/application_manager/src/application_data_impl.cc +++ b/src/components/application_manager/src/application_data_impl.cc @@ -479,8 +479,6 @@ void DynamicApplicationDataImpl::AddCommand( if (commands_.end() == it) { commands_[cmd_id] = new smart_objects::SmartObject(command); } - auto& help_prompt_mngr = help_prompt_manager(); - help_prompt_mngr.OnVrCommandAdded(cmd_id, command); } void DynamicApplicationDataImpl::RemoveCommand(uint32_t cmd_id) { @@ -490,8 +488,6 @@ void DynamicApplicationDataImpl::RemoveCommand(uint32_t cmd_id) { delete it->second; commands_.erase(it); } - auto& help_prompt_mngr = help_prompt_manager(); - help_prompt_mngr.OnVrCommandDeleted(cmd_id); } smart_objects::SmartObject* DynamicApplicationDataImpl::FindCommand( diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 3e44a54bf2..35deddfc8d 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -662,10 +662,6 @@ bool ApplicationManagerImpl::ActivateApplication(ApplicationSharedPtr app) { LOG4CXX_AUTO_TRACE(logger_); DCHECK_OR_RETURN(app, false); - auto& help_prompt_manager = app->help_prompt_manager(); - const bool is_restore = false; - help_prompt_manager.OnAppActivated(is_restore); - LOG4CXX_DEBUG(logger_, "Activating application with id:" << app->app_id()); // remove from resumption if app was activated by user @@ -2470,9 +2466,6 @@ void ApplicationManagerImpl::UnregisterApplication( } } - auto& help_prompt_manager = app_to_remove->help_prompt_manager(); - help_prompt_manager.OnAppUnregistered(); - commands_holder_->Clear(app_to_remove); if (EndAudioPassThru(app_id)) { diff --git a/src/components/application_manager/src/help_prompt_manager_impl.cc b/src/components/application_manager/src/help_prompt_manager_impl.cc index d951470104..e0ee481c17 100644 --- a/src/components/application_manager/src/help_prompt_manager_impl.cc +++ b/src/components/application_manager/src/help_prompt_manager_impl.cc @@ -61,59 +61,49 @@ HelpPromptManagerImpl::~HelpPromptManagerImpl() { LOG4CXX_AUTO_TRACE(logger_); } -void HelpPromptManagerImpl::OnVrCommandAdded( - const uint32_t cmd_id, const smart_objects::SmartObject& command) { - LOG4CXX_AUTO_TRACE(logger_); - if (SendingType::kNoneSend == sending_type_) { - LOG4CXX_DEBUG(logger_, - "SendingType::kNoneSend" - << " commands with id:" << cmd_id - << " will not be added"); - return; - } - AddCommand(cmd_id, command); - SendRequests(); -} - -void HelpPromptManagerImpl::AddCommand( +bool HelpPromptManagerImpl::AddCommand( const uint32_t cmd_id, const smart_objects::SmartObject& command) { sync_primitives::AutoLock lock(vr_commands_lock_); auto it = vr_commands_.find(cmd_id); if (vr_commands_.end() != it) { LOG4CXX_DEBUG(logger_, "Commands with id:" << cmd_id << " already exists"); - return; + return false; } if (false == command.keyExists(strings::vr_commands)) { LOG4CXX_DEBUG(logger_, "vr_commands does`t present"); - return; + return false; } const smart_objects::SmartObject& commands = command[strings::vr_commands]; - /** - * The remaining number of commands for adding - */ - std::size_t limit = kLimitCommand - count_requests_commands_; - LOG4CXX_DEBUG(logger_, "Remaining number of commands" << limit); + + const std::size_t limit = kLimitCommand - count_requests_commands_; + const std::size_t count_new_commands = commands.length(); + + LOG4CXX_DEBUG(logger_, + "Remaining number of commands: " + << limit << "; commands to add: " << count_new_commands); if (0 == limit || limit > kLimitCommand) { LOG4CXX_DEBUG(logger_, "Commands limit is exceeded"); - return; + return false; } - std::size_t count_new_commands = commands.length(); - - LOG4CXX_DEBUG(logger_, "Adding " << count_new_commands << " commands"); + const std::size_t count_to_add = + limit > count_new_commands ? count_new_commands : limit; + LOG4CXX_DEBUG(logger_, "Adding " << count_to_add << " commands"); vr_commands_[cmd_id] = utils::MakeShared<smart_objects::SmartObject>( smart_objects::SmartType_Array); smart_objects::SmartArray& ar_vr_cmd = *(vr_commands_[cmd_id]->asArray()); smart_objects::SmartArray& ar_cmd = *(commands.asArray()); - ar_vr_cmd.reserve(count_new_commands); + ar_vr_cmd.reserve(count_requests_commands_ + count_to_add); ar_vr_cmd.insert( - ar_vr_cmd.end(), ar_cmd.begin(), ar_cmd.begin() + count_new_commands); + ar_vr_cmd.end(), ar_cmd.begin(), ar_cmd.begin() + count_to_add); + LOG4CXX_DEBUG(logger_, "VR commands with id: " << cmd_id << " added for appID: " << app_.app_id()); - count_requests_commands_ += count_new_commands; + count_requests_commands_ += count_to_add; + return true; } bool HelpPromptManagerImpl::DeleteCommand(const uint32_t cmd_id) { @@ -126,17 +116,36 @@ bool HelpPromptManagerImpl::DeleteCommand(const uint32_t cmd_id) { return false; } - count_requests_commands_ -= - kLimitCommand == count_requests_commands_ ? 0 : it->second->length(); + count_requests_commands_ -= it->second->length(); vr_commands_.erase(it); - LOG4CXX_DEBUG(logger_, - "VR command with id: " << cmd_id << " deleted for appID: " - << app_.app_id()); + LOG4CXX_DEBUG( + logger_, + "VR command with id: " + << cmd_id << " deleted for appID: " << app_.app_id() + << ". Remaining number of commands: " << count_requests_commands_); return true; } -void HelpPromptManagerImpl::OnVrCommandDeleted(const uint32_t cmd_id) { +void HelpPromptManagerImpl::OnVrCommandAdded( + const uint32_t cmd_id, + const smart_objects::SmartObject& command, + const bool is_resumption) { + LOG4CXX_AUTO_TRACE(logger_); + if (SendingType::kNoneSend == sending_type_) { + LOG4CXX_DEBUG(logger_, + "SendingType::kNoneSend" + << " commands with id:" << cmd_id + << " will not be added"); + return; + } + if (AddCommand(cmd_id, command) && !is_resumption) { + SendRequests(); + } +} + +void HelpPromptManagerImpl::OnVrCommandDeleted(const uint32_t cmd_id, + const bool is_resumption) { LOG4CXX_AUTO_TRACE(logger_); if (SendingType::kNoneSend == sending_type_) { LOG4CXX_DEBUG(logger_, @@ -145,7 +154,7 @@ void HelpPromptManagerImpl::OnVrCommandDeleted(const uint32_t cmd_id) { << " will not be deleted"); return; } - if (DeleteCommand(cmd_id)) { + if (DeleteCommand(cmd_id) && !is_resumption) { SendRequests(); } } @@ -159,46 +168,38 @@ void HelpPromptManagerImpl::OnSetGlobalPropertiesReceived( " do not track SetGlobalProperties"); return; } - sending_type_ = GetSendingType(msg, is_response); - LOG4CXX_DEBUG(logger_, "Set sending type to:" << unsigned(sending_type_)); -} -void HelpPromptManagerImpl::OnAppActivated(const bool is_restore) { - LOG4CXX_AUTO_TRACE(logger_); - LOG4CXX_DEBUG(logger_, "Activated for appID:" << app_.app_id()); + if (!is_response) { + if (msg.keyExists(strings::help_prompt)) { + is_tts_send_ = true; + } + if (msg.keyExists(strings::vr_help)) { + is_ui_send_ = true; + } - if (is_restore) { - LOG4CXX_DEBUG(logger_, "restoring"); - is_tts_send_ = (app_.help_prompt() && app_.help_prompt()->length()); - is_ui_send_ = (app_.vr_help() && app_.vr_help()->length()); LOG4CXX_DEBUG(logger_, "is_tts_send_:" << is_tts_send_); LOG4CXX_DEBUG(logger_, "is_ui_send_:" << is_ui_send_); - if (is_tts_send_ && is_ui_send_) { - sending_type_ = SendingType::kNoneSend; - LOG4CXX_DEBUG(logger_, - "SetGlobalProperties RPC" - " with the vrHelp and helpPrompt" - " has been sent"); - return; - } else { - sending_type_ = is_tts_send_ ? SendingType::kSendVRHelp : sending_type_; - sending_type_ = - is_ui_send_ ? SendingType::kSendHelpPrompt : sending_type_; - is_tts_send_ = false; - is_ui_send_ = false; - const DataAccessor<CommandsMap> accessor = app_.commands_map(); - const CommandsMap& commands = accessor.GetData(); - for (auto& command : commands) { - AddCommand(command.first, *command.second); - } - } + return; } - SendRequests(); + + SetSendingType(msg); } -void HelpPromptManagerImpl::OnAppUnregistered() { - LOG4CXX_AUTO_TRACE(logger_); - LOG4CXX_DEBUG(logger_, "Unregisted for appID:" << app_.app_id()); +HelpPromptManagerImpl::SendingType HelpPromptManagerImpl::GetSendingType() + const { + if (is_tts_send_ && is_ui_send_) { + return sending_type_; + } else if (is_tts_send_) { + return SendingType::kSendHelpPrompt == sending_type_ + ? SendingType::kNoneSend + : SendingType::kSendVRHelp; + } else if (is_ui_send_) { + return SendingType::kSendVRHelp == sending_type_ + ? SendingType::kNoneSend + : SendingType::kSendHelpPrompt; + } + + return sending_type_; } void HelpPromptManagerImpl::SendTTSRequest() { @@ -236,6 +237,7 @@ void HelpPromptManagerImpl::SendTTSRequest() { so_to_send[strings::msg_params] = msg_params; app_manager_.GetRPCService().ManageHMICommand(tts_global_properties); } + is_tts_send_ = false; } void HelpPromptManagerImpl::SendUIRequest() { @@ -273,6 +275,7 @@ void HelpPromptManagerImpl::SendUIRequest() { so_to_send[strings::msg_params] = msg_params; app_manager_.GetRPCService().ManageHMICommand(ui_global_properties); } + is_ui_send_ = false; } void HelpPromptManagerImpl::SendBothRequests() { @@ -304,7 +307,7 @@ void HelpPromptManagerImpl::SendRequests() { break; } LOG4CXX_DEBUG(logger_, - "SendingType:" << (unsigned)sending_type_ + "SendingType:" << static_cast<uint32_t>(sending_type_) << " request not sending"); } @@ -361,20 +364,10 @@ void HelpPromptManagerImpl::CreateVRMsg( app_.set_vr_help(out_msg_params[strings::vr_help]); } -HelpPromptManagerImpl::SendingType HelpPromptManagerImpl::GetSendingType( - const smart_objects::SmartObject& msg, const bool is_response) { +void HelpPromptManagerImpl::SetSendingType( + const smart_objects::SmartObject& msg) { LOG4CXX_AUTO_TRACE(logger_); - if (!is_response) { - if (msg.keyExists(strings::help_prompt)) { - is_tts_send_ = true; - } - if (msg.keyExists(strings::vr_help)) { - is_ui_send_ = true; - } - LOG4CXX_DEBUG(logger_, "is_tts_send_:" << is_tts_send_); - LOG4CXX_DEBUG(logger_, "is_ui_send_:" << is_ui_send_); - return sending_type_; - } + hmi_apis::Common_Result::eType result = static_cast<hmi_apis::Common_Result::eType>( msg[strings::params][hmi_response::code].asInt()); @@ -385,27 +378,30 @@ HelpPromptManagerImpl::SendingType HelpPromptManagerImpl::GetSendingType( msg[strings::params][strings::function_id].asUInt()); LOG4CXX_DEBUG(logger_, "Function id:" << function_id); switch (function_id) { - case hmi_apis::FunctionID::TTS_SetGlobalProperties: + case hmi_apis::FunctionID::TTS_SetGlobalProperties: { if (is_tts_send_) { is_tts_send_ = false; - return (SendingType::kSendHelpPrompt == sending_type_) - ? SendingType::kNoneSend - : SendingType::kSendVRHelp; + sending_type_ = SendingType::kSendHelpPrompt == sending_type_ + ? SendingType::kNoneSend + : SendingType::kSendVRHelp; } break; - case hmi_apis::FunctionID::UI_SetGlobalProperties: + } + case hmi_apis::FunctionID::UI_SetGlobalProperties: { if (is_ui_send_) { is_ui_send_ = false; - return (SendingType::kSendVRHelp == sending_type_) - ? SendingType::kNoneSend - : SendingType::kSendHelpPrompt; + sending_type_ = SendingType::kSendVRHelp == sending_type_ + ? SendingType::kNoneSend + : SendingType::kSendHelpPrompt; } break; - default: - return sending_type_; + } + default: { break; } } + LOG4CXX_DEBUG( + logger_, + "Sending type set to:" << static_cast<uint32_t>(sending_type_)); } - return sending_type_; } } // namespace application_manager diff --git a/src/components/application_manager/src/helpers/application_helper.cc b/src/components/application_manager/src/helpers/application_helper.cc index 66afd6b0b6..59f1c6caf2 100644 --- a/src/components/application_manager/src/helpers/application_helper.cc +++ b/src/components/application_manager/src/helpers/application_helper.cc @@ -21,6 +21,7 @@ void DeleteCommands(ApplicationSharedPtr app, ApplicationManager& app_manager) { for (auto cmd : cmap) { MessageHelper::SendDeleteCommandRequest(cmd.second, app, app_manager); app->RemoveCommand(cmd.first); + app->help_prompt_manager().OnVrCommandDeleted(cmd.first, true); } } 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 1f1ff4ddf0..ae8f5b74ab 100644 --- a/src/components/application_manager/src/message_helper/message_helper.cc +++ b/src/components/application_manager/src/message_helper/message_helper.cc @@ -1171,9 +1171,19 @@ MessageHelper::CreateGlobalPropertiesRequestsToHMI( return requests; } + auto& help_prompt_manager = + const_cast<Application*>(app.get())->help_prompt_manager(); + + const bool can_send_ui = helpers::Compare<HelpPromptManager::SendingType, + helpers::EQ, + helpers::ONE>( + help_prompt_manager.GetSendingType(), + HelpPromptManager::SendingType::kSendVRHelp, + HelpPromptManager::SendingType::kSendBoth); + // UI global properties - if (app->vr_help_title() || app->vr_help()) { + if (can_send_ui && (app->vr_help_title() || app->vr_help())) { smart_objects::SmartObjectSPtr ui_global_properties = CreateMessageForHMI(hmi_apis::messageType::request, correlation_id); if (!ui_global_properties) { @@ -1207,8 +1217,15 @@ MessageHelper::CreateGlobalPropertiesRequestsToHMI( requests.push_back(ui_global_properties); } + const bool can_send_vr = helpers::Compare<HelpPromptManager::SendingType, + helpers::EQ, + helpers::ONE>( + help_prompt_manager.GetSendingType(), + HelpPromptManager::SendingType::kSendHelpPrompt, + HelpPromptManager::SendingType::kSendBoth); + // TTS global properties - if (app->help_prompt() || app->timeout_prompt()) { + if (can_send_vr && (app->help_prompt() || app->timeout_prompt())) { smart_objects::SmartObjectSPtr tts_global_properties = CreateMessageForHMI(hmi_apis::messageType::request, correlation_id); if (!tts_global_properties) { diff --git a/src/components/application_manager/src/resumption/resume_ctrl_impl.cc b/src/components/application_manager/src/resumption/resume_ctrl_impl.cc index d75237e0be..def618f965 100644 --- a/src/components/application_manager/src/resumption/resume_ctrl_impl.cc +++ b/src/components/application_manager/src/resumption/resume_ctrl_impl.cc @@ -162,17 +162,7 @@ bool ResumeCtrlImpl::RestoreAppHMIState(ApplicationSharedPtr application) { static_cast<mobile_apis::HMILevel::eType>( saved_app[strings::hmi_level].asInt()); LOG4CXX_DEBUG(logger_, "Saved HMI Level is : " << saved_hmi_level); - result = SetAppHMIState(application, saved_hmi_level, true); - if (result) { - const HMILevel::eType def_hmi_level = - application_manager_.GetDefaultHmiLevel(application); - if (def_hmi_level != saved_hmi_level) { - auto& help_prompt_manager = application->help_prompt_manager(); - const bool is_restore = true; - help_prompt_manager.OnAppActivated(is_restore); - } - } - return result; + return SetAppHMIState(application, saved_hmi_level, true); } else { result = false; LOG4CXX_ERROR(logger_, "saved app data corrupted"); @@ -555,8 +545,12 @@ void ResumeCtrlImpl::AddCommands(ApplicationSharedPtr application, saved_app[strings::application_commands]; for (size_t i = 0; i < app_commands.length(); ++i) { const smart_objects::SmartObject& command = app_commands[i]; + const uint32_t cmd_id = command[strings::cmd_id].asUInt(); + const bool is_resumption = true; - application->AddCommand(command[strings::cmd_id].asUInt(), command); + application->AddCommand(cmd_id, command); + application->help_prompt_manager().OnVrCommandAdded( + cmd_id, command, is_resumption); } ProcessHMIRequests(MessageHelper::CreateAddCommandRequestToHMI( application, application_manager_)); |