From de69dfe73aea68dece35d978994b6bbdf1ffae88 Mon Sep 17 00:00:00 2001 From: PVasilev Date: Mon, 29 May 2017 10:38:57 +0300 Subject: [PATCH 1/3] Fix UnregisterAppInterface for not found app If an app is not found in SDL but the mobile side sends UnregisterAppInterface, SDL creates the mobile request but never runs it because the app is not found. Then the request times out and the response to the mobile side is `GENERIC_ERROR`. Now command will be ran and the proper response of `APPLICATION_NOT_REGISTERED` will be sent. --- .../src/commands/command_request_impl.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/components/application_manager/src/commands/command_request_impl.cc b/src/components/application_manager/src/commands/command_request_impl.cc index bafad525638..c5da8720af8 100644 --- a/src/components/application_manager/src/commands/command_request_impl.cc +++ b/src/components/application_manager/src/commands/command_request_impl.cc @@ -487,9 +487,11 @@ mobile_apis::Result::eType CommandRequestImpl::GetMobileResultCode( bool CommandRequestImpl::CheckAllowedParameters() { LOG4CXX_AUTO_TRACE(logger_); - // RegisterAppInterface should always be allowed - if (mobile_apis::FunctionID::RegisterAppInterfaceID == - static_cast(function_id())) { + // RegisterAppInterface and UnregisterAppInterface should always be allowed + const mobile_apis::FunctionID::eType func_id = + static_cast(function_id()); + if (mobile_apis::FunctionID::RegisterAppInterfaceID == func_id || + mobile_apis::FunctionID::UnregisterAppInterfaceID == func_id) { return true; } From 0e2707b89a01badfe15129a78fd3927804c9d094 Mon Sep 17 00:00:00 2001 From: PVasilev Date: Mon, 29 May 2017 11:23:28 +0300 Subject: [PATCH 2/3] Add Unit Test --- .../commands/command_request_impl_test.cc | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/components/application_manager/test/commands/command_request_impl_test.cc b/src/components/application_manager/test/commands/command_request_impl_test.cc index 2471ec1165e..67d2b3d5581 100644 --- a/src/components/application_manager/test/commands/command_request_impl_test.cc +++ b/src/components/application_manager/test/commands/command_request_impl_test.cc @@ -515,6 +515,26 @@ TEST_F(CommandRequestImplTest, (*result)[strings::msg_params][strings::info].asString().empty()); } +TEST_F(CommandRequestImplTest, CheckPermissions_UnregisterAppInterface_True) { + MessageSharedPtr msg = CreateMessage(); + (*msg)[strings::params][strings::function_id] = + mobile_apis::FunctionID::UnregisterAppInterfaceID; + + CommandPtr command = CreateCommand(msg); + + EXPECT_TRUE(command->CheckPermissions()); +} + +TEST_F(CommandRequestImplTest, CheckPermissions_RegisterAppInterface_True) { + MessageSharedPtr msg = CreateMessage(); + (*msg)[strings::params][strings::function_id] = + mobile_apis::FunctionID::RegisterAppInterfaceID; + + CommandPtr command = CreateCommand(msg); + + EXPECT_TRUE(command->CheckPermissions()); +} + } // namespace command_request_impl } // namespace commands_test } // namespace components From cb7f7b9ca7e2820e53b03ce516ded6e376f281e8 Mon Sep 17 00:00:00 2001 From: PVasilev Date: Mon, 29 May 2017 13:21:09 +0300 Subject: [PATCH 3/3] Change comparison --- .../src/commands/command_request_impl.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/components/application_manager/src/commands/command_request_impl.cc b/src/components/application_manager/src/commands/command_request_impl.cc index c5da8720af8..83cf6b52fce 100644 --- a/src/components/application_manager/src/commands/command_request_impl.cc +++ b/src/components/application_manager/src/commands/command_request_impl.cc @@ -488,10 +488,11 @@ bool CommandRequestImpl::CheckAllowedParameters() { LOG4CXX_AUTO_TRACE(logger_); // RegisterAppInterface and UnregisterAppInterface should always be allowed - const mobile_apis::FunctionID::eType func_id = - static_cast(function_id()); - if (mobile_apis::FunctionID::RegisterAppInterfaceID == func_id || - mobile_apis::FunctionID::UnregisterAppInterfaceID == func_id) { + using namespace helpers; + if (Compare( + static_cast(function_id()), + mobile_apis::FunctionID::RegisterAppInterfaceID, + mobile_apis::FunctionID::UnregisterAppInterfaceID)) { return true; }