diff options
author | Shobhit Adlakha <ShobhitAd@users.noreply.github.com> | 2022-08-04 16:41:19 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-04 16:41:19 -0400 |
commit | f8b1dd0e85b023e5b9eb027b3f4c1c7be2194e0f (patch) | |
tree | 5022f65a6879bbaf53cdb8ef6421a68ce4d852b8 | |
parent | adb38b9bb5c34f2d7fc5d8f39db70a6b1e96be92 (diff) | |
download | sdl_core-f8b1dd0e85b023e5b9eb027b3f4c1c7be2194e0f.tar.gz |
Fix/Invalid VR.AddCommand sent during CreateInteractionChoiceSet resumption (#3938)
* Apply changes from luxoft PR
* Apply suggested changes
* Revert "Apply changes from luxoft PR"
This reverts commit 2f6b188b899184058254ac138eec441510265b04.
* Apply suggested changes and fix unit test
* Update src/components/application_manager/src/message_helper/message_helper.cc
Co-authored-by: Jacob Keeler <jacob.keeler@livioradio.com>
Co-authored-by: Jacob Keeler <jacob.keeler@livioradio.com>
3 files changed, 19 insertions, 6 deletions
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_interaction_choice_set_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_interaction_choice_set_request.cc index dccf2e9fdd..9caf7e4c7a 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_interaction_choice_set_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_interaction_choice_set_request.cc @@ -89,7 +89,13 @@ void DeleteInteractionChoiceSetRequest::Run() { SendResponse(false, mobile_apis::Result::IN_USE); return; } - SendVrDeleteCommand(app); + if (choice_set.keyExists(strings::grammar_id) && + choice_set[strings::grammar_id].asInt() != -1) { + SendVrDeleteCommand(app); + } else { + response_result_codes_.push_back(hmi_apis::Common_Result::SUCCESS); + SendDeleteInteractionChoiceSetResponse(); + } } bool DeleteInteractionChoiceSetRequest::Init() { diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_interaction_choice_set_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_interaction_choice_set_test.cc index bd4c5c1ec6..aded581faf 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_interaction_choice_set_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/delete_interaction_choice_set_test.cc @@ -205,10 +205,6 @@ TEST_F(DeleteInteractionChoiceSetRequestTest, .WillOnce(Return(choice_set_id)); EXPECT_CALL(*app_, is_perform_interaction_active()).WillOnce(Return(false)); EXPECT_CALL(*app_, performinteraction_choice_set_map()).Times(0); - - EXPECT_CALL(*app_, FindChoiceSet(kChoiceSetId)) - .WillOnce(Return(invalid_choice_set_id)); - EXPECT_CALL(*app_, app_id()).Times(0); } 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 8588d02319..d5d87a6a2f 100644 --- a/src/components/application_manager/src/message_helper/message_helper.cc +++ b/src/components/application_manager/src/message_helper/message_helper.cc @@ -737,11 +737,16 @@ void MessageHelper::SendDeleteChoiceSetRequest(smart_objects::SmartObject* cmd, DCHECK_OR_RETURN_VOID(cmd); using namespace smart_objects; - SmartObject msg_params = SmartObject(smart_objects::SmartType_Map); + if (!cmd->keyExists(strings::grammar_id) || + (*cmd)[strings::grammar_id].asInt() == -1) { + return; + } + SmartObject msg_params = SmartObject(smart_objects::SmartType_Map); msg_params[strings::app_id] = application->app_id(); msg_params[strings::type] = hmi_apis::Common_VRCommandType::Choice; msg_params[strings::grammar_id] = (*cmd)[strings::grammar_id]; + cmd = &((*cmd)[strings::choice_set]); for (uint32_t i = 0; i < (*cmd).length(); ++i) { msg_params[strings::cmd_id] = (*cmd)[i][strings::choice_id]; @@ -1527,6 +1532,7 @@ smart_objects::SmartObjectList MessageHelper::CreateAddCommandRequestToHMI( smart_objects::SmartObjectList MessageHelper::CreateAddVRCommandRequestFromChoiceToHMI( ApplicationConstSharedPtr app, ApplicationManager& app_mngr) { + SDL_LOG_AUTO_TRACE(); smart_objects::SmartObjectList requests; if (!app) { SDL_LOG_ERROR("Invalid application"); @@ -1541,6 +1547,11 @@ MessageHelper::CreateAddVRCommandRequestFromChoiceToHMI( (*(it->second))[strings::grammar_id].asUInt(); const size_t size = (*(it->second))[strings::choice_set].length(); for (size_t j = 0; j < size; ++j) { + if (!(*(it->second))[strings::choice_set][j].keyExists( + strings::vr_commands)) { + continue; + } + smart_objects::SmartObjectSPtr vr_command = CreateMessageForHMI( hmi_apis::messageType::request, app_mngr.GetNextHMICorrelationID()); if (!vr_command) { |