diff options
Diffstat (limited to 'src/components/policy/policy_regular/src')
3 files changed, 44 insertions, 9 deletions
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 22205763a9..1dc6b5c32c 100644 --- a/src/components/policy/policy_regular/src/policy_manager_impl.cc +++ b/src/components/policy/policy_regular/src/policy_manager_impl.cc @@ -70,6 +70,7 @@ PolicyManagerImpl::PolicyManagerImpl() new AccessRemoteImpl(std::static_pointer_cast<CacheManager>(cache_))) , retry_sequence_timeout_(kDefaultRetryTimeoutInMSec) , retry_sequence_index_(0) + , count_application_(0) , timer_retry_sequence_( "Retry sequence timer", new timer::TimerTaskImpl<PolicyManagerImpl>( @@ -77,7 +78,9 @@ PolicyManagerImpl::PolicyManagerImpl() , ignition_check(true) , retry_sequence_url_(0, 0, "") , send_on_update_sent_out_(false) - , trigger_ptu_(false) {} + , trigger_ptu_(false) + , ptu_requested_(false) + , last_registered_app_id_("") {} void PolicyManagerImpl::set_listener(PolicyListener* listener) { listener_ = listener; @@ -411,7 +414,7 @@ PolicyManager::PtProcessingResult PolicyManagerImpl::LoadPT( void PolicyManagerImpl::OnPTUFinished(const PtProcessingResult ptu_result) { LOG4CXX_AUTO_TRACE(logger_); - + ptu_requested_ = false; if (PtProcessingResult::kWrongPtReceived == ptu_result) { LOG4CXX_DEBUG(logger_, "Wrong PT was received"); update_status_manager_.OnWrongUpdateReceived(); @@ -430,7 +433,7 @@ void PolicyManagerImpl::OnPTUFinished(const PtProcessingResult ptu_result) { // If there was a user request for policy table update, it should be started // right after current update is finished - if (update_status_manager_.IsUpdateRequired()) { + if (update_status_manager_.IsUpdateRequired() && HasApplicationForPTU()) { LOG4CXX_DEBUG(logger_, "PTU was successful and new PTU iteration was scheduled"); StartPTExchange(); @@ -607,7 +610,7 @@ bool PolicyManagerImpl::RequestPTUpdate(const PTUIterationType iteration_type) { LOG4CXX_DEBUG(logger_, "Snapshot contents is : " << message_string); BinaryMessage update(message_string.begin(), message_string.end()); - + ptu_requested_ = true; listener_->OnSnapshotCreated(update, iteration_type); return true; } @@ -676,14 +679,23 @@ void PolicyManagerImpl::OnAppsSearchCompleted(const bool trigger_ptu) { trigger_ptu_ = trigger_ptu; - if (update_status_manager_.IsUpdateRequired()) { + if (update_status_manager_.IsUpdateRequired() && !ptu_requested_ && + HasApplicationForPTU()) { StartPTExchange(); } } +void PolicyManagerImpl::OnChangeApplicationCount(const uint32_t new_app_count) { + count_application_ = new_app_count; +} + void PolicyManagerImpl::OnAppRegisteredOnMobile( const std::string& device_id, const std::string& application_id) { - StartPTExchange(); + if (last_registered_app_id_ != application_id) { + StartPTExchange(); + last_registered_app_id_ = application_id; + } + SendNotificationOnPermissionsUpdated(device_id, application_id); } @@ -1257,6 +1269,8 @@ void PolicyManagerImpl::IncrementIgnitionCycles() { std::string PolicyManagerImpl::ForcePTExchange() { update_status_manager_.ScheduleUpdate(); + + ptu_requested_ = false; StartPTExchange(); return update_status_manager_.StringifiedUpdateStatus(); } @@ -1322,6 +1336,9 @@ void PolicyManagerImpl::ResetRetrySequence( LOG4CXX_AUTO_TRACE(logger_); sync_primitives::AutoLock auto_lock(retry_sequence_lock_); retry_sequence_index_ = 0; + if (listener_->CanUpdate()) { + ptu_requested_ = false; + } if (ResetRetryCountType::kResetWithStatusUpdate == reset_type) { update_status_manager_.OnResetRetrySequence(); } @@ -1498,7 +1515,9 @@ StatusNotifier PolicyManagerImpl::AddApplication( device_consent); } PromoteExistedApplication(application_id, device_consent); - update_status_manager_.OnExistedApplicationAdded(cache_->UpdateRequired()); + if (!ptu_requested_) { + update_status_manager_.OnExistedApplicationAdded(cache_->UpdateRequired()); + } return std::make_shared<utils::CallNothing>(); } @@ -1630,6 +1649,10 @@ void PolicyManagerImpl::OnPTUIterationTimeout() { if (timer_retry_sequence_.is_running()) { timer_retry_sequence_.Stop(); } + + if (HasApplicationForPTU()) { + RequestPTUpdate(PTUIterationType::DefaultIteration); + } return; } @@ -1648,6 +1671,10 @@ void PolicyManagerImpl::OnPTUIterationTimeout() { timer_retry_sequence_.Start(timeout_msec, timer::kPeriodic); } +bool PolicyManagerImpl::HasApplicationForPTU() { + return count_application_ > 0; +} + void PolicyManagerImpl::SetDefaultHmiTypes( const transport_manager::DeviceHandle& device_handle, const std::string& application_id, diff --git a/src/components/policy/policy_regular/src/status.cc b/src/components/policy/policy_regular/src/status.cc index 114ecb9f97..cad403e249 100644 --- a/src/components/policy/policy_regular/src/status.cc +++ b/src/components/policy/policy_regular/src/status.cc @@ -57,6 +57,9 @@ policy::UpdateNeededStatus::UpdateNeededStatus() void policy::UpdateNeededStatus::ProcessEvent( policy::UpdateStatusManagerInterface* manager, policy::UpdateEvent event) { switch (event) { + case kPostponedUpdate: + manager->SetNextStatus(std::make_shared<UpdateNeededStatus>()); + break; case kOnUpdateSentOut: manager->SetNextStatus(std::make_shared<UpdatingStatus>()); break; @@ -68,7 +71,6 @@ void policy::UpdateNeededStatus::ProcessEvent( manager->SetNextStatus(std::make_shared<UpToDateStatus>()); break; case kOnNewAppRegistered: - manager->SetNextStatus(std::make_shared<UpdateNeededStatus>()); break; default: break; diff --git a/src/components/policy/policy_regular/src/update_status_manager.cc b/src/components/policy/policy_regular/src/update_status_manager.cc index c37f8bbadc..7e5b866dfa 100644 --- a/src/components/policy/policy_regular/src/update_status_manager.cc +++ b/src/components/policy/policy_regular/src/update_status_manager.cc @@ -43,7 +43,8 @@ UpdateStatusManager::UpdateStatusManager() , current_status_(std::make_shared<UpToDateStatus>()) , last_processed_event_(kNoEvent) , apps_search_in_progress_(false) - , app_registered_from_non_consented_device_(true) {} + , app_registered_from_non_consented_device_(true) + , last_update_was_failed_(false) {} UpdateStatusManager::~UpdateStatusManager() {} @@ -97,6 +98,7 @@ void UpdateStatusManager::OnResetDefaultPT(bool is_update_required) { void UpdateStatusManager::OnResetRetrySequence() { LOG4CXX_AUTO_TRACE(logger_); + last_update_was_failed_ = true; ProcessEvent(kOnResetRetrySequence); } @@ -116,6 +118,10 @@ void UpdateStatusManager::OnNewApplicationAdded(const DeviceConsent consent) { return; } app_registered_from_non_consented_device_ = false; + if (last_update_was_failed_) { + last_update_was_failed_ = false; + ProcessEvent(kPostponedUpdate); + } ProcessEvent(kOnNewAppRegistered); } |