diff options
19 files changed, 86 insertions, 10 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 e4d4cd7fa2..a03288f9a9 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 @@ -321,6 +321,8 @@ class PolicyHandler : public PolicyHandlerInterface, const PermissionConsent& permissions) OVERRIDE; #endif + void OnSystemRequestReceived() const OVERRIDE; + /** * @brief Get appropriate message parameters and send them with response * to HMI diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_request_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_request_notification.cc index 6d95febe71..e11eda165c 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_request_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_system_request_notification.cc @@ -121,16 +121,15 @@ void OnSystemRequestNotification::Run() { params[strings::connection_key] = app->app_id(); -#ifdef EXTERNAL_PROPRIETARY_MODE using namespace rpc::policy_table_interface_base; const auto request_type = static_cast<rpc::policy_table_interface_base::RequestType>( (*message_)[strings::msg_params][strings::request_type].asUInt()); - if (RequestType::RT_PROPRIETARY == request_type) { - policy_handler_.ptu_retry_handler().OnSystemRequestReceived(); + if (helpers::Compare<RequestType, helpers::EQ, helpers::ONE>( + request_type, RequestType::RT_PROPRIETARY, RequestType::RT_HTTP)) { + policy_handler_.OnSystemRequestReceived(); } -#endif SendNotificationToMobile(message_); } diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_policy_update_response.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_policy_update_response.cc index 12cdfb4ad9..bfbf73270e 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_policy_update_response.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_policy_update_response.cc @@ -31,6 +31,7 @@ */ #include "sdl_rpc_plugin/commands/hmi/sdl_policy_update_response.h" +#include "application_manager/policies/policy_handler_interface.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -52,7 +53,20 @@ SDLPolicyUpdateResponse::~SDLPolicyUpdateResponse() {} void SDLPolicyUpdateResponse::Run() { LOG4CXX_AUTO_TRACE(logger_); - // TODO(PV): add some logic here + const hmi_apis::Common_Result::eType code = + static_cast<hmi_apis::Common_Result::eType>( + (*message_)[strings::params][hmi_response::code].asInt()); + + if (helpers::Compare<hmi_apis::Common_Result::eType, + helpers::NEQ, + helpers::ALL>(code, + hmi_apis::Common_Result::SUCCESS, + hmi_apis::Common_Result::WARNINGS)) { + LOG4CXX_ERROR(logger_, "Error is returned. PTU won't be started."); + return; + } + + application_manager_.GetPolicyHandler().OnUpdateRequestSentToMobile(); } } // namespace commands diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index 09dcb2c7ad..64e15d7134 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -719,6 +719,13 @@ void PolicyHandler::OnGetUserFriendlyMessage( result, correlation_id, application_manager_); } +void PolicyHandler::OnSystemRequestReceived() const { +#ifdef EXTERNAL_PROPRIETARY_MODE + ptu_retry_handler().OnSystemRequestReceived(); +#endif + policy_manager_->ResetTimeout(); +} + void PolicyHandler::GetRegisteredLinks( std::map<std::string, std::string>& out_links) const { DataAccessor<ApplicationSet> accessor = application_manager_.applications(); @@ -1576,8 +1583,6 @@ void PolicyHandler::OnSnapshotCreated(const BinaryMessage& pt_string, const std::string& url = urls[app_url.first].url[app_url.second]; SendMessageToSDK(pt_string, url); #endif // PROPRIETARY_MODE - // reset update required false - OnUpdateRequestSentToMobile(); } #endif // EXTERNAL_PROPRIETARY_MODE diff --git a/src/components/application_manager/src/rpc_service_impl.cc b/src/components/application_manager/src/rpc_service_impl.cc index 9a2d5d1118..627c7265bc 100644 --- a/src/components/application_manager/src/rpc_service_impl.cc +++ b/src/components/application_manager/src/rpc_service_impl.cc @@ -587,7 +587,6 @@ void RPCServiceImpl::SendMessageToMobile( return; } -#ifdef EXTERNAL_PROPRIETARY_MODE if (api_function_id == mobile_apis::FunctionID::OnSystemRequestID) { mobile_apis::RequestType::eType request_type = static_cast<mobile_apis::RequestType::eType>( @@ -597,7 +596,6 @@ void RPCServiceImpl::SendMessageToMobile( app_manager_.GetPolicyHandler().OnUpdateRequestSentToMobile(); } } -#endif // EXTERNAL_PROPRIETARY_MODE } if (message_to_send->binary_data()) { 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 190a1f786b..3af3b770aa 100644 --- a/src/components/include/application_manager/policies/policy_handler_interface.h +++ b/src/components/include/application_manager/policies/policy_handler_interface.h @@ -661,6 +661,12 @@ class PolicyHandlerInterface : public VehicleDataItemProvider { virtual bool GetModuleTypes(const std::string& policy_app_id, std::vector<std::string>* modules) const = 0; + /** + * @brief Notifies policy manager about OnSystemRequest + * notification receiving + */ + virtual void OnSystemRequestReceived() const = 0; + private: /** * @brief Processes data received via OnAppPermissionChanged notification 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 248bbfe16c..22721841aa 100644 --- a/src/components/include/policy/policy_external/policy/policy_manager.h +++ b/src/components/include/policy/policy_external/policy/policy_manager.h @@ -830,6 +830,11 @@ class PolicyManager : public usage_statistics::StatisticsManager, */ virtual ExternalConsentStatus GetExternalConsentStatus() = 0; + /** + * @brief Restart PTU timeout if PTU in UPDATING state + */ + virtual void ResetTimeout() = 0; + protected: /** * @brief Checks is PT exceeded IgnitionCycles 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 ee1f5fa98f..c9143d6bbb 100644 --- a/src/components/include/policy/policy_regular/policy/policy_manager.h +++ b/src/components/include/policy/policy_regular/policy/policy_manager.h @@ -785,6 +785,11 @@ class PolicyManager : public usage_statistics::StatisticsManager, virtual AppIdURL RetrySequenceUrl(const struct RetrySequenceURL& rs, const EndpointUrls& urls) const = 0; + /** + * @brief Restart PTU timeout if PTU in UPDATING state + */ + virtual void ResetTimeout() = 0; + protected: /** * @brief Checks is PT exceeded IgnitionCycles 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 f74526148a..f6e0b3cb0f 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 @@ -327,6 +327,8 @@ class MockPolicyHandlerInterface : public policy::PolicyHandlerInterface { void(const std::string& device_id_from, const std::string& device_id_to)); + MOCK_CONST_METHOD0(OnSystemRequestReceived, void()); + private: #ifdef EXTERNAL_PROPRIETARY_MODE MOCK_METHOD3(OnAppPermissionConsentInternal, 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 8e6cc2666d..d2023fd3d4 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 @@ -304,6 +304,7 @@ class MockPolicyManager : public PolicyManager { MOCK_CONST_METHOD0(IsAllowedRetryCountExceeded, bool()); MOCK_METHOD0(OnSystemRequestReceived, void()); MOCK_METHOD0(RetrySequenceFailed, void()); + MOCK_METHOD0(ResetTimeout, void()); }; } // namespace policy_manager_test } // namespace components 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 927f5ba5cc..da9edb9fe5 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 @@ -306,6 +306,7 @@ class MockPolicyManager : public PolicyManager { RequestType::State(const std::string& policy_app_id)); MOCK_CONST_METHOD1(GetAppRequestSubTypesState, RequestSubType::State(const std::string& policy_app_id)); + MOCK_METHOD0(ResetTimeout, void()); }; } // namespace policy_manager_test 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 b1c22ab9e6..ce344d576a 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 @@ -1139,6 +1139,8 @@ class PolicyManagerImpl : public PolicyManager { bool GetModuleTypes(const std::string& policy_app_id, std::vector<std::string>* modules) const OVERRIDE; + void ResetTimeout() OVERRIDE; + /** * @brief Notify application about its permissions changes by preparing and * sending OnPermissionsChanged notification diff --git a/src/components/policy/policy_external/include/policy/update_status_manager.h b/src/components/policy/policy_external/include/policy/update_status_manager.h index c5738b3272..9426a26fb8 100644 --- a/src/components/policy/policy_external/include/policy/update_status_manager.h +++ b/src/components/policy/policy_external/include/policy/update_status_manager.h @@ -185,6 +185,8 @@ class UpdateStatusManager { */ bool IsAppsSearchInProgress(); + void ResetTimeout(uint32_t update_timeout); + #ifdef BUILD_TESTS PolicyTableStatus GetLastUpdateStatus() const { return current_status_->get_status(); 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 8a8af04909..787e65f43a 100644 --- a/src/components/policy/policy_external/src/policy_manager_impl.cc +++ b/src/components/policy/policy_external/src/policy_manager_impl.cc @@ -1384,9 +1384,16 @@ void PolicyManagerImpl::RetrySequenceFailed() { ResetRetrySequence(ResetRetryCountType::kResetWithStatusUpdate); } -void PolicyManagerImpl::OnSystemRequestReceived() { +void PolicyManagerImpl::ResetTimeout() { LOG4CXX_AUTO_TRACE(logger_); + if (update_status_manager_.IsUpdatePending()) { + uint32_t update_timeout = TimeoutExchangeMSec(); + update_status_manager_.ResetTimeout(update_timeout); + } +} +void PolicyManagerImpl::OnSystemRequestReceived() { + LOG4CXX_AUTO_TRACE(logger_); IncrementRetryIndex(); } diff --git a/src/components/policy/policy_external/src/status.cc b/src/components/policy/policy_external/src/status.cc index 7162410731..687bea1c3f 100644 --- a/src/components/policy/policy_external/src/status.cc +++ b/src/components/policy/policy_external/src/status.cc @@ -67,6 +67,9 @@ void policy::UpdateNeededStatus::ProcessEvent( case kOnResetPolicyTableNoUpdate: manager->SetNextStatus(std::make_shared<UpToDateStatus>()); break; + case kOnNewAppRegistered: + manager->SetNextStatus(std::make_shared<UpdateNeededStatus>()); + break; case kPendingUpdate: manager->SetNextStatus(std::make_shared<UpdatePendingStatus>()); break; diff --git a/src/components/policy/policy_external/src/update_status_manager.cc b/src/components/policy/policy_external/src/update_status_manager.cc index bf20f9dd55..3653983c8f 100644 --- a/src/components/policy/policy_external/src/update_status_manager.cc +++ b/src/components/policy/policy_external/src/update_status_manager.cc @@ -108,6 +108,12 @@ void UpdateStatusManager::OnValidUpdateReceived() { ProcessEvent(kOnValidUpdateReceived); } +void UpdateStatusManager::ResetTimeout(uint32_t update_timeout) { + LOG4CXX_AUTO_TRACE(logger_); + update_status_thread_delegate_->updateTimeOut( + update_timeout); // Restart Timer +} + void UpdateStatusManager::OnWrongUpdateReceived() { LOG4CXX_AUTO_TRACE(logger_); update_status_thread_delegate_->updateTimeOut(0); // Stop Timer diff --git a/src/components/policy/policy_external/test/update_status_manager_test.cc b/src/components/policy/policy_external/test/update_status_manager_test.cc index 9f68456750..29952bd18e 100644 --- a/src/components/policy/policy_external/test/update_status_manager_test.cc +++ b/src/components/policy/policy_external/test/update_status_manager_test.cc @@ -340,6 +340,12 @@ TEST_F(UpdateStatusManagerTest, EXPECT_FALSE(manager_->IsAppsSearchInProgress()); } +TEST_F(UpdateStatusManagerTest, OnAppRegistered) { + manager_->ScheduleUpdate(); + ASSERT_EQ(policy::kUpdateNeeded, manager_->StringifiedUpdateStatus()); + manager_->ProcessEvent(policy::UpdateEvent::kOnNewAppRegistered); + EXPECT_EQ(policy::kUpdateNeeded, manager_->StringifiedUpdateStatus()); +} } // namespace policy_test } // namespace components } // namespace test 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 fc6ec369dc..192de6cd34 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 @@ -876,6 +876,8 @@ class PolicyManagerImpl : public PolicyManager { int32_t timespan_seconds) OVERRIDE; // Interface StatisticsManager (end) + void ResetTimeout() OVERRIDE; + protected: #ifdef USE_HMI_PTU_DECRYPTION /** 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 b78e36bc51..22205763a9 100644 --- a/src/components/policy/policy_regular/src/policy_manager_impl.cc +++ b/src/components/policy/policy_regular/src/policy_manager_impl.cc @@ -1607,6 +1607,16 @@ void PolicyManagerImpl::set_cache_manager( cache_ = std::shared_ptr<CacheManagerInterface>(cache_manager); } +void PolicyManagerImpl::ResetTimeout() { + LOG4CXX_AUTO_TRACE(logger_); + if (update_status_manager_.IsUpdatePending()) { + if (timer_retry_sequence_.is_running()) { + timer_retry_sequence_.Stop(); + } + timer_retry_sequence_.Start(cache_->TimeoutResponse(), timer::kSingleShot); + } +} + void PolicyManagerImpl::OnPTUIterationTimeout() { LOG4CXX_DEBUG(logger_, "Start new retry sequence"); |