diff options
author | JackLivio <jack@livio.io> | 2017-05-12 09:19:14 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-12 09:19:14 -0400 |
commit | ce755fa605d6eaec86374c42c2272ededef1cf74 (patch) | |
tree | 449778b872b4ea30656f74c2be57f588d696b250 /src/components | |
parent | aaeafb7b96e1bec140e94fe7f31e6f9922402dd7 (diff) | |
parent | 6022233449866cfd8150c198c6ce3bf58e973b0a (diff) | |
download | sdl_core-ce755fa605d6eaec86374c42c2272ededef1cf74.tar.gz |
Merge pull request #1475 from okozlovlux/fix/SDL_uses_url_in_GetURLs_for_NOT_registered_app
Fix issue when SDL uses url in GetURLs for not registered application
Diffstat (limited to 'src/components')
3 files changed, 31 insertions, 24 deletions
diff --git a/src/components/application_manager/include/application_manager/commands/hmi/get_urls.h b/src/components/application_manager/include/application_manager/commands/hmi/get_urls.h index b90266a263..1fcc1e626a 100644 --- a/src/components/application_manager/include/application_manager/commands/hmi/get_urls.h +++ b/src/components/application_manager/include/application_manager/commands/hmi/get_urls.h @@ -63,13 +63,13 @@ class GetUrls : public RequestFromHMI { void Run() OVERRIDE; private: -#if defined(PROPRIETARY_MODE) || defined(EXTERNAL_PROPRIETARY_MODE) +#ifdef PROPRIETARY_MODE /** * @brief Processes URLs collecting for policy service * @param endpoints Endpoints section of policy table */ void ProcessPolicyServiceURLs(const policy::EndpointUrls& endpoints); -#endif // PROPRIETARY_MODE || EXTERNAL_PROPRIETARY_MODE +#endif // PROPRIETARY_MODE /** * @brief Process URLs collecting for service diff --git a/src/components/application_manager/src/commands/hmi/get_urls.cc b/src/components/application_manager/src/commands/hmi/get_urls.cc index e7c5244ddc..a2e1878fac 100644 --- a/src/components/application_manager/src/commands/hmi/get_urls.cc +++ b/src/components/application_manager/src/commands/hmi/get_urls.cc @@ -67,14 +67,14 @@ void GetUrls::Run() { return; } -#if defined(PROPRIETARY_MODE) || defined(EXTERNAL_PROPRIETARY_MODE) +#ifdef PROPRIETARY_MODE const uint32_t policy_service = 7u; if (policy_service == service_to_check) { ProcessPolicyServiceURLs(endpoints); return; } -#endif // PROPRIETARY_MODE || EXTERNAL_PROPRIETARY_MODE +#endif // PROPRIETARY_MODE ProcessServiceURLs(endpoints); } @@ -88,30 +88,34 @@ void GetUrls::ProcessServiceURLs(const policy::EndpointUrls& endpoints) { size_t index = 0; for (size_t e = 0; e < endpoints.size(); ++e) { + ApplicationSharedPtr app = + application_manager_.application_by_policy_id(endpoints[e].app_id); + +#ifndef PROPRIETARY_MODE + bool registered_not_default = false; + if (policy::kDefaultId != endpoints[e].app_id) { + if (!app) { + LOG4CXX_ERROR(logger_, + "Can't find application with policy id " + << endpoints[e].app_id + << " URLs adding for this application is skipped."); + continue; + } + registered_not_default = true; + } +#endif // EXTERNAL_PROPRIETARY_MODE || HTTP for (size_t u = 0; u < endpoints[e].url.size(); ++u, ++index) { - const std::string app_url = endpoints[e].url[u]; - + const std::string& app_url = endpoints[e].url[u]; SmartObject& service_info = urls[index]; service_info[strings::url] = app_url; - if (policy::kDefaultId != endpoints[e].app_id) { -#ifndef EXTERNAL_PROPRIETARY_MODE - service_info[hmi_response::policy_app_id] = endpoints[e].app_id; -#else // EXTERNAL_PROPRIETARY_MODE - ApplicationSharedPtr app = - application_manager_.application_by_policy_id(endpoints[e].app_id); - - if (!app) { - LOG4CXX_ERROR(logger_, - "Can't find application with policy id " - << endpoints[e].app_id - << " URLs adding for this appliation is skipped."); - continue; - } - +#ifndef PROPRIETARY_MODE + if (registered_not_default) { service_info[strings::app_id] = app->hmi_app_id(); -#endif // EXTERNAL_PROPRIETARY_MODE } +#else // EXTERNAL_PROPRIETARY_MODE || HTTP + service_info[hmi_response::policy_app_id] = endpoints[e].app_id; +#endif } } SendResponseToHMI(Common_Result::SUCCESS); @@ -123,7 +127,7 @@ void GetUrls::SendResponseToHMI(hmi_apis::Common_Result::eType result) { application_manager_.ManageHMICommand(message_); } -#if defined(PROPRIETARY_MODE) || defined(EXTERNAL_PROPRIETARY_MODE) +#ifdef PROPRIETARY_MODE struct PolicyAppIdComparator { PolicyAppIdComparator(const std::string& policy_app_id) : policy_app_id_(policy_app_id) {} @@ -219,7 +223,7 @@ void GetUrls::ProcessPolicyServiceURLs(const policy::EndpointUrls& endpoints) { SendResponseToHMI(Common_Result::SUCCESS); return; } -#endif // PROPRIETARY_MODE || EXTERNAL_PROPRIETARY +#endif // PROPRIETARY_MODE } // namespace commands } // namespace application_manager diff --git a/src/components/application_manager/test/commands/hmi/get_urls_test.cc b/src/components/application_manager/test/commands/hmi/get_urls_test.cc index d6ea6d2bc2..9430dc045c 100644 --- a/src/components/application_manager/test/commands/hmi/get_urls_test.cc +++ b/src/components/application_manager/test/commands/hmi/get_urls_test.cc @@ -312,6 +312,9 @@ TEST_F(GetUrlsTest, ProcessServiceURLs_PolicyDefaultId_SUCCESS) { endpoints_.push_back(data); EXPECT_CALL(mock_policy_handler_, GetUpdateUrls(kServiceType, _)) .WillOnce(SetArgReferee<1>(endpoints_)); + MockAppPtr mock_app = CreateMockApp(); + EXPECT_CALL(app_mngr_, application_by_policy_id(_)) + .WillOnce(Return(mock_app)); request_command_->Run(); EXPECT_FALSE((*command_msg_)[am::strings::msg_params].keyExists( |