summaryrefslogtreecommitdiff
path: root/src/components/policy/policy_regular/src/policy_manager_impl.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/policy/policy_regular/src/policy_manager_impl.cc')
-rw-r--r--src/components/policy/policy_regular/src/policy_manager_impl.cc41
1 files changed, 34 insertions, 7 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,