From ddcd97db9cdc5455550ebc20bc64b068c610b32b Mon Sep 17 00:00:00 2001 From: "Ira Lytvynenko (GitHub)" Date: Fri, 3 Apr 2020 18:24:01 +0300 Subject: Remove redundant GetSystemInfo sending (#3305) --- .../application_manager/policies/policy_handler.h | 6 ------ .../src/policies/policy_event_observer.cc | 5 ----- .../application_manager/src/policies/policy_handler.cc | 15 --------------- .../test/policy_event_observer_test.cc | 11 ----------- .../application_manager/test/policy_handler_test.cc | 18 ------------------ .../policies/policy_handler_interface.h | 6 ------ .../policy/policy_external/policy/policy_listener.h | 1 - .../policy/policy_external/policy/policy_manager.h | 7 ------- .../policy/policy_regular/policy/policy_listener.h | 1 - .../policy/policy_regular/policy/policy_manager.h | 7 ------- .../policies/mock_policy_handler_interface.h | 2 -- .../policy_external/policy/mock_policy_listener.h | 1 - .../policy_external/policy/mock_policy_manager.h | 1 - .../policy_regular/policy/mock_policy_listener.h | 1 - .../policy/policy_regular/policy/mock_policy_manager.h | 1 - .../include/policy/policy_manager_impl.h | 7 ------- .../policy/policy_external/src/policy_manager_impl.cc | 7 ------- .../policy_external/test/policy_manager_impl_test.cc | 8 -------- .../include/policy/policy_manager_impl.h | 7 ------- .../policy/policy_regular/src/policy_manager_impl.cc | 8 -------- .../policy_regular/test/policy_manager_impl_test.cc | 8 -------- 21 files changed, 128 deletions(-) diff --git a/src/components/application_manager/include/application_manager/policies/policy_handler.h b/src/components/application_manager/include/application_manager/policies/policy_handler.h index daf87f3c36..4525433b8b 100644 --- a/src/components/application_manager/include/application_manager/policies/policy_handler.h +++ b/src/components/application_manager/include/application_manager/policies/policy_handler.h @@ -222,7 +222,6 @@ class PolicyHandler : public PolicyHandlerInterface, */ uint32_t TimeoutExchangeMSec() const OVERRIDE; void OnExceededTimeout() OVERRIDE; - void OnSystemReady() OVERRIDE; const boost::optional LockScreenDismissalEnabledState() const OVERRIDE; const boost::optional LockScreenDismissalWarningMessage( const std::string& language) const OVERRIDE; @@ -382,11 +381,6 @@ class PolicyHandler : public PolicyHandlerInterface, const std::string& wers_country_code, const std::string& language) OVERRIDE; - /** - * @brief Send request to HMI to get update on system parameters - */ - virtual void OnSystemInfoUpdateRequired() OVERRIDE; - /** * @brief Sends GetVehicleData request in case when Vechicle info is ready. */ diff --git a/src/components/application_manager/src/policies/policy_event_observer.cc b/src/components/application_manager/src/policies/policy_event_observer.cc index afe909fee4..7ca4d7b5b8 100644 --- a/src/components/application_manager/src/policies/policy_event_observer.cc +++ b/src/components/application_manager/src/policies/policy_event_observer.cc @@ -70,11 +70,6 @@ void PolicyEventObserver::on_event(const event_engine::Event& event) { unsubscribe_from_event(hmi_apis::FunctionID::VehicleInfo_GetVehicleData); break; } - case hmi_apis::FunctionID::BasicCommunication_OnReady: { - policy_handler_->OnSystemReady(); - unsubscribe_from_event(hmi_apis::FunctionID::BasicCommunication_OnReady); - break; - } default: { break; } } } diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index 9c0f5da73c..f41bb45dbf 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -376,10 +376,6 @@ const PolicySettings& PolicyHandler::get_settings() const { bool PolicyHandler::InitPolicyTable() { LOG4CXX_AUTO_TRACE(logger_); POLICY_LIB_CHECK_OR_RETURN(false); - // Subscribing to notification for system readiness to be able to get system - // info necessary for policy table - event_observer_->subscribe_on_event( - hmi_apis::FunctionID::BasicCommunication_OnReady); std::string preloaded_file = get_settings().preloaded_pt_file(); if (file_system::FileExists(preloaded_file)) { const bool pt_inited = @@ -987,12 +983,6 @@ void PolicyHandler::OnGetSystemInfo(const std::string& ccpu_version, policy_manager_->SetSystemInfo(ccpu_version, wers_country_code, language); } -void PolicyHandler::OnSystemInfoUpdateRequired() { - LOG4CXX_AUTO_TRACE(logger_); - POLICY_LIB_CHECK_VOID(); - MessageHelper::SendGetSystemInfoRequest(application_manager_); -} - void PolicyHandler::OnVIIsReady() { LOG4CXX_AUTO_TRACE(logger_); const uint32_t correlation_id = @@ -1765,11 +1755,6 @@ void PolicyHandler::OnExceededTimeout() { policy_manager_->OnExceededTimeout(); } -void PolicyHandler::OnSystemReady() { - POLICY_LIB_CHECK_VOID(); - policy_manager_->OnSystemReady(); -} - const boost::optional PolicyHandler::LockScreenDismissalEnabledState() const { POLICY_LIB_CHECK_OR_RETURN(boost::optional()); diff --git a/src/components/application_manager/test/policy_event_observer_test.cc b/src/components/application_manager/test/policy_event_observer_test.cc index a74b12071c..22d7a8cfa0 100644 --- a/src/components/application_manager/test/policy_event_observer_test.cc +++ b/src/components/application_manager/test/policy_event_observer_test.cc @@ -89,8 +89,6 @@ class PolicyEventObserverTest : public ::testing::Test { EXPECT_CALL(policy_handler_mock_, PTUpdatedAt(Counters::KILOMETERS, field_value)) .Times(pt_updated_calls_number); - EXPECT_CALL(policy_handler_mock_, OnSystemReady()) - .Times(on_system_ready_calls_number); policy_event_observer_->on_event(*event_); } @@ -125,15 +123,6 @@ TEST_F(PolicyEventObserverTest, CheckResultsOnEvent(1u, 0u); } -TEST_F(PolicyEventObserverTest, - OnEvent_EventBasicCommunication_OnReady_ExpectOnSystemReady) { - // Arrange - CreateEvent(Event::EventID::BasicCommunication_OnReady); - CookSmartObject(hmi_apis::Common_Result::SUCCESS, field_name, field_value); - // Check - CheckResultsOnEvent(0u, 1u); -} - } // namespace policy_test } // namespace components } // namespace test diff --git a/src/components/application_manager/test/policy_handler_test.cc b/src/components/application_manager/test/policy_handler_test.cc index 2b1fc6de1d..7a49431440 100644 --- a/src/components/application_manager/test/policy_handler_test.cc +++ b/src/components/application_manager/test/policy_handler_test.cc @@ -811,15 +811,6 @@ TEST_F(PolicyHandlerTest, OnExceededTimeout) { policy_handler_.OnExceededTimeout(); } -TEST_F(PolicyHandlerTest, OnSystemReady) { - // Arrange - EnablePolicyAndPolicyManagerMock(); - // Check expectations - EXPECT_CALL(*mock_policy_manager_, OnSystemReady()); - // Act - policy_handler_.OnSystemReady(); -} - TEST_F(PolicyHandlerTest, PTUpdatedAt_method_UseCounter_KILOMETERS) { // Arrange EnablePolicyAndPolicyManagerMock(); @@ -1366,15 +1357,6 @@ TEST_F(PolicyHandlerTest, IsApplicationRevoked) { policy_handler_.IsApplicationRevoked(kPolicyAppId_); } -TEST_F(PolicyHandlerTest, OnSystemInfoUpdateRequired) { - // Arrange - ChangePolicyManagerToMock(); - // Check expectations - EXPECT_CALL(mock_message_helper_, SendGetSystemInfoRequest(_)); - // Act - policy_handler_.OnSystemInfoUpdateRequired(); -} - TEST_F(PolicyHandlerTest, GetAppRequestTypes) { // Arrange EnablePolicy(); diff --git a/src/components/include/application_manager/policies/policy_handler_interface.h b/src/components/include/application_manager/policies/policy_handler_interface.h index 46bc835036..3210d05ae8 100644 --- a/src/components/include/application_manager/policies/policy_handler_interface.h +++ b/src/components/include/application_manager/policies/policy_handler_interface.h @@ -149,7 +149,6 @@ class PolicyHandlerInterface : public VehicleDataItemProvider { */ virtual uint32_t TimeoutExchangeMSec() const = 0; virtual void OnExceededTimeout() = 0; - virtual void OnSystemReady() = 0; virtual const boost::optional LockScreenDismissalEnabledState() const = 0; virtual const boost::optional LockScreenDismissalWarningMessage( @@ -313,11 +312,6 @@ class PolicyHandlerInterface : public VehicleDataItemProvider { const std::string& wers_country_code, const std::string& language) = 0; - /** - * @brief Send request to HMI to get update on system parameters - */ - virtual void OnSystemInfoUpdateRequired() = 0; - /** * @brief Sends GetVehicleData request in case when Vechicle info is ready. */ diff --git a/src/components/include/policy/policy_external/policy/policy_listener.h b/src/components/include/policy/policy_external/policy/policy_listener.h index c613fdd091..0ad695f2c0 100644 --- a/src/components/include/policy/policy_external/policy/policy_listener.h +++ b/src/components/include/policy/policy_external/policy/policy_listener.h @@ -60,7 +60,6 @@ class PolicyListener { virtual std::string OnCurrentDeviceIdUpdateRequired( const transport_manager::DeviceHandle& device_handle, const std::string& policy_app_id) = 0; - virtual void OnSystemInfoUpdateRequired() = 0; virtual custom_str::CustomString GetAppName( const std::string& policy_app_id) = 0; virtual void OnUpdateHMIAppType( diff --git a/src/components/include/policy/policy_external/policy/policy_manager.h b/src/components/include/policy/policy_external/policy/policy_manager.h index 9ba5de4973..4a96fdf3b8 100644 --- a/src/components/include/policy/policy_external/policy/policy_manager.h +++ b/src/components/include/policy/policy_external/policy/policy_manager.h @@ -473,13 +473,6 @@ class PolicyManager : public usage_statistics::StatisticsManager, */ virtual bool CanAppStealFocus(const std::string& app_id) const = 0; - /** - * @brief Runs necessary operations, which is depends on external system - * state, e.g. getting system-specific parameters which are need to be - * filled into policy table - */ - virtual void OnSystemReady() = 0; - /** * @brief Get number of notification by priority * @param priority Specified priority diff --git a/src/components/include/policy/policy_regular/policy/policy_listener.h b/src/components/include/policy/policy_regular/policy/policy_listener.h index 192244bb09..729eda0a95 100644 --- a/src/components/include/policy/policy_regular/policy/policy_listener.h +++ b/src/components/include/policy/policy_regular/policy/policy_listener.h @@ -58,7 +58,6 @@ class PolicyListener { virtual std::string OnCurrentDeviceIdUpdateRequired( const transport_manager::DeviceHandle& device_handle, const std::string& policy_app_id) = 0; - virtual void OnSystemInfoUpdateRequired() = 0; virtual custom_str::CustomString GetAppName( const std::string& policy_app_id) = 0; virtual void OnUpdateHMIAppType( diff --git a/src/components/include/policy/policy_regular/policy/policy_manager.h b/src/components/include/policy/policy_regular/policy/policy_manager.h index 7ba9a77a6c..0689a5b768 100644 --- a/src/components/include/policy/policy_regular/policy/policy_manager.h +++ b/src/components/include/policy/policy_regular/policy/policy_manager.h @@ -464,13 +464,6 @@ class PolicyManager : public usage_statistics::StatisticsManager, */ virtual bool CanAppStealFocus(const std::string& app_id) const = 0; - /** - * @brief Runs necessary operations, which is depends on external system - * state, e.g. getting system-specific parameters which are need to be - * filled into policy table - */ - virtual void OnSystemReady() = 0; - /** * @brief Get number of notification by priority * @param priority Specified priority diff --git a/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h b/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h index cd99157319..4eaae1d53a 100644 --- a/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h +++ b/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h @@ -125,7 +125,6 @@ class MockPolicyHandlerInterface : public policy::PolicyHandlerInterface { MOCK_CONST_METHOD0(TimeoutExchangeSec, uint32_t()); MOCK_CONST_METHOD0(TimeoutExchangeMSec, uint32_t()); MOCK_METHOD0(OnExceededTimeout, void()); - MOCK_METHOD0(OnSystemReady, void()); MOCK_CONST_METHOD0(LockScreenDismissalEnabledState, const boost::optional()); MOCK_CONST_METHOD1(LockScreenDismissalWarningMessage, @@ -182,7 +181,6 @@ class MockPolicyHandlerInterface : public policy::PolicyHandlerInterface { void(const std::string& ccpu_version, const std::string& wers_country_code, const std::string& language)); - MOCK_METHOD0(OnSystemInfoUpdateRequired, void()); MOCK_METHOD0(OnVIIsReady, void()); MOCK_METHOD1(OnVehicleDataUpdated, void(const smart_objects::SmartObject& message)); diff --git a/src/components/include/test/policy/policy_external/policy/mock_policy_listener.h b/src/components/include/test/policy/policy_external/policy/mock_policy_listener.h index 0060d2299f..62dfdf4058 100644 --- a/src/components/include/test/policy/policy_external/policy/mock_policy_listener.h +++ b/src/components/include/test/policy/policy_external/policy/mock_policy_listener.h @@ -71,7 +71,6 @@ class MockPolicyListener : public ::policy::PolicyListener { MOCK_METHOD2(OnCurrentDeviceIdUpdateRequired, std::string(const transport_manager::DeviceHandle& device_handle, const std::string& policy_app_id)); - MOCK_METHOD0(OnSystemInfoUpdateRequired, void()); MOCK_METHOD1(GetAppName, custom_str::CustomString(const std::string& policy_app_id)); MOCK_METHOD0(OnUserRequestedUpdateCheckRequired, void()); diff --git a/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h b/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h index da3f130077..bf092d38e8 100644 --- a/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h +++ b/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h @@ -206,7 +206,6 @@ class MockPolicyManager : public PolicyManager { MOCK_METHOD0(CleanupUnpairedDevices, bool()); MOCK_CONST_METHOD1(CanAppKeepContext, bool(const std::string& app_id)); MOCK_CONST_METHOD1(CanAppStealFocus, bool(const std::string& app_id)); - MOCK_METHOD0(OnSystemReady, void()); MOCK_CONST_METHOD1(GetNotificationsNumber, uint32_t(const std::string& priority)); MOCK_METHOD1(SetVINValue, void(const std::string& value)); diff --git a/src/components/include/test/policy/policy_regular/policy/mock_policy_listener.h b/src/components/include/test/policy/policy_regular/policy/mock_policy_listener.h index e5f2321217..f12358396b 100644 --- a/src/components/include/test/policy/policy_regular/policy/mock_policy_listener.h +++ b/src/components/include/test/policy/policy_regular/policy/mock_policy_listener.h @@ -68,7 +68,6 @@ class MockPolicyListener : public ::policy::PolicyListener { MOCK_METHOD2(OnCurrentDeviceIdUpdateRequired, std::string(const transport_manager::DeviceHandle& device_handle, const std::string& policy_app_id)); - MOCK_METHOD0(OnSystemInfoUpdateRequired, void()); MOCK_METHOD1(GetAppName, custom_str::CustomString(const std::string& policy_app_id)); MOCK_METHOD0(OnUserRequestedUpdateCheckRequired, void()); diff --git a/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h b/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h index b328306134..c803f63c9d 100644 --- a/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h +++ b/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h @@ -204,7 +204,6 @@ class MockPolicyManager : public PolicyManager { MOCK_METHOD0(CleanupUnpairedDevices, bool()); MOCK_CONST_METHOD1(CanAppKeepContext, bool(const std::string& app_id)); MOCK_CONST_METHOD1(CanAppStealFocus, bool(const std::string& app_id)); - MOCK_METHOD0(OnSystemReady, void()); MOCK_CONST_METHOD1(GetNotificationsNumber, uint32_t(const std::string& priority)); MOCK_METHOD1(SetVINValue, void(const std::string& value)); diff --git a/src/components/policy/policy_external/include/policy/policy_manager_impl.h b/src/components/policy/policy_external/include/policy/policy_manager_impl.h index 2fd58d3a07..e9fd2e0256 100644 --- a/src/components/policy/policy_external/include/policy/policy_manager_impl.h +++ b/src/components/policy/policy_external/include/policy/policy_manager_impl.h @@ -435,13 +435,6 @@ class PolicyManagerImpl : public PolicyManager { const std::string& wers_country_code, const std::string& language) OVERRIDE; - /** - * @brief Runs necessary operations, which is depends on external system - * state, e.g. getting system-specific parameters which are need to be - * filled into policy table - */ - void OnSystemReady() OVERRIDE; - /** * @brief Get number of notification by priority * @param priority Specified priority diff --git a/src/components/policy/policy_external/src/policy_manager_impl.cc b/src/components/policy/policy_external/src/policy_manager_impl.cc index 35dcd2a272..082d4a37ba 100644 --- a/src/components/policy/policy_external/src/policy_manager_impl.cc +++ b/src/components/policy/policy_external/src/policy_manager_impl.cc @@ -1630,13 +1630,6 @@ void PolicyManagerImpl::SetSystemInfo(const std::string& ccpu_version, cache_->SetMetaInfo(ccpu_version, wers_country_code, language); } -void PolicyManagerImpl::OnSystemReady() { - // Update policy table for the first time with system information - if (!cache_->IsMetaInfoPresent()) { - listener()->OnSystemInfoUpdateRequired(); - } -} - uint32_t PolicyManagerImpl::GetNotificationsNumber( const std::string& priority) const { LOG4CXX_AUTO_TRACE(logger_); diff --git a/src/components/policy/policy_external/test/policy_manager_impl_test.cc b/src/components/policy/policy_external/test/policy_manager_impl_test.cc index 388630a68f..9e0b61c2dd 100644 --- a/src/components/policy/policy_external/test/policy_manager_impl_test.cc +++ b/src/components/policy/policy_external/test/policy_manager_impl_test.cc @@ -174,14 +174,6 @@ TEST_F(PolicyManagerImplTest2, ForcePTExchange_ExpectUpdateNeeded) { EXPECT_EQ("UPDATE_NEEDED", policy_manager_->GetPolicyTableStatus()); } -TEST_F(PolicyManagerImplTest2, OnSystemReady) { - // Arrange - CreateLocalPT(preloaded_pt_filename_); - // Check - EXPECT_CALL(listener_, OnSystemInfoUpdateRequired()); - policy_manager_->OnSystemReady(); -} - TEST_F(PolicyManagerImplTest2, ResetRetrySequence) { // Arrange CreateLocalPT(preloaded_pt_filename_); diff --git a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h index d29852b279..b608c6f7ec 100644 --- a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h +++ b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h @@ -451,13 +451,6 @@ class PolicyManagerImpl : public PolicyManager { const std::string& wers_country_code, const std::string& language) OVERRIDE; - /** - * @brief Runs necessary operations, which is depends on external system - * state, e.g. getting system-specific parameters which are need to be - * filled into policy table - */ - void OnSystemReady() OVERRIDE; - /** * @brief Get number of notification by priority * @param priority Specified priority diff --git a/src/components/policy/policy_regular/src/policy_manager_impl.cc b/src/components/policy/policy_regular/src/policy_manager_impl.cc index 29da676ec5..81b49bb71e 100644 --- a/src/components/policy/policy_regular/src/policy_manager_impl.cc +++ b/src/components/policy/policy_regular/src/policy_manager_impl.cc @@ -1212,14 +1212,6 @@ void PolicyManagerImpl::SetSystemInfo(const std::string& ccpu_version, LOG4CXX_AUTO_TRACE(logger_); } -void PolicyManagerImpl::OnSystemReady() { - // Update policy table for the first time with system information - if (cache_->IsPTPreloaded()) { - listener()->OnSystemInfoUpdateRequired(); - return; - } -} - uint32_t PolicyManagerImpl::GetNotificationsNumber( const std::string& priority) const { LOG4CXX_AUTO_TRACE(logger_); diff --git a/src/components/policy/policy_regular/test/policy_manager_impl_test.cc b/src/components/policy/policy_regular/test/policy_manager_impl_test.cc index abf9a2ec14..37ef1afc0c 100644 --- a/src/components/policy/policy_regular/test/policy_manager_impl_test.cc +++ b/src/components/policy/policy_regular/test/policy_manager_impl_test.cc @@ -1428,14 +1428,6 @@ TEST_F(PolicyManagerImplTest2, ForcePTExchange_ExpectUpdateNeeded) { EXPECT_EQ("UPDATE_NEEDED", manager->GetPolicyTableStatus()); } -TEST_F(PolicyManagerImplTest2, OnSystemReady) { - // Arrange - CreateLocalPT("sdl_preloaded_pt.json"); - // Check - EXPECT_CALL(listener, OnSystemInfoUpdateRequired()); - manager->OnSystemReady(); -} - TEST_F(PolicyManagerImplTest2, ResetRetrySequence) { // Arrange CreateLocalPT("sdl_preloaded_pt.json"); -- cgit v1.2.1