diff options
author | Jacob Keeler <jacob.keeler@livioradio.com> | 2018-07-16 14:36:35 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-16 14:36:35 -0700 |
commit | 4dde9552b3d9ab5fa29502810be48bdf0f793cd7 (patch) | |
tree | 4870b3b1721cd9595a7118f789c610fa1b44f83e /src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src | |
parent | 5cff788119f1e62344b94aebb7ca23cf63dc39f8 (diff) | |
parent | 2f05a630fe5f35bc46f3003d9fc35d3451c130c4 (diff) | |
download | sdl_core-4dde9552b3d9ab5fa29502810be48bdf0f793cd7.tar.gz |
Merge pull request #2199 from smartdevicelink/feature/handling_VR_help_requests
Feature/handling vr help requests
Diffstat (limited to 'src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src')
5 files changed, 39 insertions, 85 deletions
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/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_hmi_status_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_hmi_status_notification.cc index a495423bce..9422bec478 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_hmi_status_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_hmi_status_notification.cc @@ -78,17 +78,8 @@ void OnHMIStatusNotification::Run() { mobile_apis::HMILevel::eType hmi_level = static_cast<mobile_apis::HMILevel::eType>( (*message_)[strings::msg_params][strings::hmi_level].asInt()); - if ((mobile_apis::HMILevel::HMI_BACKGROUND == hmi_level) || - (mobile_apis::HMILevel::HMI_NONE == hmi_level)) { - if (!(app->tts_properties_in_none())) { - app->set_tts_properties_in_none(true); - LOG4CXX_INFO(logger_, - "OnHMIStatusNotification::Send TTS GlobalProperties" - " with empty array to HMI"); - MessageHelper::SendTTSGlobalProperties(app, false, application_manager_); - } - } else if ((mobile_apis::HMILevel::HMI_FULL == hmi_level) || - (mobile_apis::HMILevel::HMI_LIMITED == hmi_level)) { + if ((mobile_apis::HMILevel::HMI_FULL == hmi_level) || + (mobile_apis::HMILevel::HMI_LIMITED == hmi_level)) { if (!(app->tts_properties_in_full())) { app->set_tts_properties_in_full(true); LOG4CXX_INFO(logger_, diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_global_properties_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_global_properties_request.cc index 90ec06025e..92c72d7f66 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_global_properties_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_global_properties_request.cc @@ -162,6 +162,9 @@ void SetGlobalPropertiesRequest::Run() { params[strings::app_id] = app->app_id(); SendUIRequest(params, true); + + auto& help_prompt_manager = app->help_prompt_manager(); + help_prompt_manager.OnSetGlobalPropertiesReceived(params, false); } else { LOG4CXX_DEBUG(logger_, "VRHelp params does not present"); DCHECK_OR_RETURN_VOID(!is_vr_help_title_present && !is_vr_help_present); @@ -169,15 +172,6 @@ void SetGlobalPropertiesRequest::Run() { smart_objects::SmartObject params = smart_objects::SmartObject(smart_objects::SmartType_Map); - if (ValidateVRHelpTitle(app->vr_help_title())) { - LOG4CXX_DEBUG(logger_, "App already contains VRHelp data"); - } else { - if (!PrepareUIRequestDefaultVRHelpData(app, params)) { - LOG4CXX_ERROR(logger_, "default VRHElp data could not be generated"); - SendResponse(false, mobile_apis::Result::INVALID_DATA); - return; - } - } PrepareUIRequestMenuAndKeyboardData(app, msg_params, params); // Preparing data @@ -247,6 +241,9 @@ void SetGlobalPropertiesRequest::Run() { params[strings::app_id] = app->app_id(); SendTTSRequest(params, true); + + auto& help_prompt_manager = app->help_prompt_manager(); + help_prompt_manager.OnSetGlobalPropertiesReceived(params, false); } } @@ -276,6 +273,9 @@ void SetGlobalPropertiesRequest::on_event(const event_engine::Event& event) { using namespace helpers; const smart_objects::SmartObject& message = event.smart_object(); + ApplicationSharedPtr application = + application_manager_.application(connection_key()); + switch (event.id()) { case hmi_apis::FunctionID::UI_SetGlobalProperties: { LOG4CXX_INFO(logger_, "Received UI_SetGlobalProperties event"); @@ -284,6 +284,10 @@ void SetGlobalPropertiesRequest::on_event(const event_engine::Event& event) { ui_result_ = static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); GetInfo(message, ui_response_info_); + if (application.valid()) { + auto& help_prompt_manager = application->help_prompt_manager(); + help_prompt_manager.OnSetGlobalPropertiesReceived(message, true); + } break; } case hmi_apis::FunctionID::TTS_SetGlobalProperties: { @@ -293,6 +297,10 @@ void SetGlobalPropertiesRequest::on_event(const event_engine::Event& event) { tts_result_ = static_cast<hmi_apis::Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); GetInfo(message, tts_response_info_); + if (application.valid()) { + auto& help_prompt_manager = application->help_prompt_manager(); + help_prompt_manager.OnSetGlobalPropertiesReceived(message, true); + } break; } default: { @@ -309,10 +317,6 @@ void SetGlobalPropertiesRequest::on_event(const event_engine::Event& event) { std::string response_info; const bool result = PrepareResponseParameters(result_code, response_info); - // TODO{ALeshin} APPLINK-15858. connection_key removed during SendResponse - ApplicationSharedPtr application = - application_manager_.application(connection_key()); - SendResponse(result, result_code, response_info.empty() ? NULL : response_info.c_str(), @@ -356,17 +360,6 @@ bool SetGlobalPropertiesRequest::PrepareResponseParameters( return result; } -bool SetGlobalPropertiesRequest::ValidateVRHelpTitle( - const smart_objects::SmartObject* const vr_help_so_ptr) { - LOG4CXX_AUTO_TRACE(logger_); - if (vr_help_so_ptr) { - const std::string& vr_help = vr_help_so_ptr->asString(); - LOG4CXX_TRACE(logger_, "App contains vr_help_title: \"" << vr_help << '"'); - return !vr_help.empty(); - } - return false; -} - void SetGlobalPropertiesRequest::PrepareUIRequestVRHelpData( const ApplicationSharedPtr app, const smart_objects::SmartObject& msg_params, @@ -381,41 +374,6 @@ void SetGlobalPropertiesRequest::PrepareUIRequestVRHelpData( out_params[strings::vr_help] = (*app->vr_help()); } -bool SetGlobalPropertiesRequest::PrepareUIRequestDefaultVRHelpData( - const ApplicationSharedPtr app, smart_objects::SmartObject& out_params) { - LOG4CXX_AUTO_TRACE(logger_); - DCHECK_OR_RETURN(app, false); - - LOG4CXX_DEBUG(logger_, "Generate default VRHelp data"); - const DataAccessor<CommandsMap> accessor = app->commands_map(); - const CommandsMap& cmdMap = accessor.GetData(); - - int32_t index = 0; - smart_objects::SmartObject vr_help_items; - for (CommandsMap::const_iterator command_it = cmdMap.begin(); - cmdMap.end() != command_it; - ++command_it) { - const smart_objects::SmartObject& command = *command_it->second; - if (!command.keyExists(strings::vr_commands)) { - LOG4CXX_ERROR(logger_, "VR synonyms are empty"); - return false; - } - // use only first - vr_help_items[index][strings::position] = (index + 1); - vr_help_items[index++][strings::text] = - (*command_it->second)[strings::vr_commands][0]; - } - - app->set_vr_help_title(smart_objects::SmartObject(app->name())); - - out_params[strings::vr_help_title] = (*app->vr_help_title()); - if (vr_help_items.length() > 0) { - app->set_vr_help(vr_help_items); - out_params[strings::vr_help] = (*app->vr_help()); - } - return true; -} - void SetGlobalPropertiesRequest::PrepareUIRequestMenuAndKeyboardData( const ApplicationSharedPtr app, const smart_objects::SmartObject& msg_params, |