summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsniukalov <sniukaov@luxoft.com>2020-02-26 12:19:07 +0200
committerYevhenii Dementieiev (GitHub) <ydementieiev@luxoft.com>2020-02-26 21:13:48 +0200
commit441c543ce8c2891bbfe526d2880873ecd1702740 (patch)
tree10783ca072d67e0577f89bd5be8404ef3ce32c28
parentff498abb5b0ee30a68d89bb9696a1254eb05102d (diff)
downloadsdl_core-test/ptu_retry_3aps.tar.gz
Fix PTU after a failed retry sequencetest/ptu_retry_3aps
-rw-r--r--src/components/application_manager/src/policies/policy_handler.cc10
-rw-r--r--src/components/include/policy/policy_external/policy/policy_manager.h2
-rw-r--r--src/components/policy/policy_external/include/policy/policy_manager_impl.h5
-rw-r--r--src/components/policy/policy_external/include/policy/status.h3
-rw-r--r--src/components/policy/policy_external/src/policy_manager_impl.cc26
-rw-r--r--src/components/policy/policy_external/src/update_status_manager.cc18
-rw-r--r--src/components/policy/policy_regular/src/policy_manager_impl.cc2
7 files changed, 21 insertions, 45 deletions
diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc
index afad3f1f1c..f837f7547b 100644
--- a/src/components/application_manager/src/policies/policy_handler.cc
+++ b/src/components/application_manager/src/policies/policy_handler.cc
@@ -1142,7 +1142,7 @@ bool PolicyHandler::ReceiveMessageFromSDK(const std::string& file,
const bool is_ptu_successful =
load_pt_result == PolicyManager::PtProcessingResult::kSuccess;
OnPTUFinished(is_ptu_successful);
- PopAppIdFromPTUQueue();
+
if (is_ptu_successful) {
LOG4CXX_INFO(logger_, "PTU was successful.");
policy_manager_->CleanupUnpairedDevices();
@@ -1567,7 +1567,7 @@ void PolicyHandler::OnSnapshotCreated(const BinaryMessage& pt_string,
POLICY_LIB_CHECK_VOID();
#ifdef PROPRIETARY_MODE
std::string policy_snapshot_full_path;
- if (PTUIterationType::RetryIteration != iteration_type) {
+ if (PTUIterationType::RetryIteration != iteration_type) {
if (!SaveSnapshot(pt_string, policy_snapshot_full_path)) {
LOG4CXX_ERROR(logger_, "Snapshot processing skipped.");
return;
@@ -1935,9 +1935,9 @@ void PolicyHandler::OnAuthTokenUpdated(const std::string& policy_app_id,
void PolicyHandler::OnPTUFinished(const bool ptu_result) {
LOG4CXX_AUTO_TRACE(logger_);
sync_primitives::AutoLock lock(listeners_lock_);
- if (!ptu_result) {
- PopAppIdFromPTUQueue();
- }
+
+ PopAppIdFromPTUQueue();
+
std::for_each(
listeners_.begin(),
listeners_.end(),
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 3d7a913991..f63deb7f7f 100644
--- a/src/components/include/policy/policy_external/policy/policy_manager.h
+++ b/src/components/include/policy/policy_external/policy/policy_manager.h
@@ -78,7 +78,7 @@ class PolicyManager : public usage_statistics::StatisticsManager,
* @return true if init is successful
*/
virtual bool InitPT(const std::string& file_name,
- const PolicySettings* settings) = 0;
+ const PolicySettings* settings) = 0;
/**
* @brief Updates Policy Table from binary message received from
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 4cf21c3373..a55cd855e8 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
@@ -1359,11 +1359,6 @@ class PolicyManagerImpl : public PolicyManager {
bool trigger_ptu_;
/**
- * @brief Flag for notifying that PTU was requested
- */
- bool ptu_requested_;
-
- /**
* @brief Flag that indicates whether a PTU sequence (including retries) is in
* progress
*/
diff --git a/src/components/policy/policy_external/include/policy/status.h b/src/components/policy/policy_external/include/policy/status.h
index 6dcc84001b..eb1bf2ec40 100644
--- a/src/components/policy/policy_external/include/policy/status.h
+++ b/src/components/policy/policy_external/include/policy/status.h
@@ -55,8 +55,7 @@ enum UpdateEvent {
kPendingUpdate,
kScheduleManualUpdate,
kOnResetRetrySequence,
- kNoEvent,
- kUpdateForNextInQueue
+ kNoEvent
};
const std::string kUpToDate = "UP_TO_DATE";
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 25a401109f..a0475676e5 100644
--- a/src/components/policy/policy_external/src/policy_manager_impl.cc
+++ b/src/components/policy/policy_external/src/policy_manager_impl.cc
@@ -214,8 +214,7 @@ PolicyManagerImpl::PolicyManagerImpl()
, retry_sequence_index_(0)
, applications_pending_ptu_count_(0)
, ignition_check(true)
- , retry_sequence_url_(0, 0, "")
- , ptu_requested_(false)
+ , retry_sequence_url_(0, 0, "")
, is_ptu_in_progress_(false) {}
PolicyManagerImpl::PolicyManagerImpl(bool in_memory)
@@ -231,7 +230,6 @@ PolicyManagerImpl::PolicyManagerImpl(bool in_memory)
, retry_sequence_url_(0, 0, "")
, send_on_update_sent_out_(false)
, trigger_ptu_(false)
- , ptu_requested_(false)
, is_ptu_in_progress_(false) {}
void PolicyManagerImpl::set_listener(PolicyListener* listener) {
@@ -546,7 +544,6 @@ 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");
@@ -557,7 +554,7 @@ void PolicyManagerImpl::OnPTUFinished(const PtProcessingResult ptu_result) {
update_status_manager_.OnValidUpdateReceived();
if (HasApplicationForPTU()) {
- update_status_manager_.OnUpdateForNextInQueue();
+ update_status_manager_.OnExistedApplicationAdded(true);
}
if (PtProcessingResult::kNewPtRequired == ptu_result) {
@@ -718,7 +715,6 @@ void PolicyManagerImpl::RequestPTUpdate() {
LOG4CXX_DEBUG(logger_, "Snapshot contents is : " << message_string);
BinaryMessage update(message_string.begin(), message_string.end());
- ptu_requested_ = true;
listener_->OnSnapshotCreated(
update, RetrySequenceDelaysSeconds(), TimeoutExchangeMSec());
@@ -743,7 +739,7 @@ void PolicyManagerImpl::StartPTExchange() {
return;
}
- if (update_status_manager_.IsUpdatePending() || is_ptu_in_progress_) {
+ if (update_status_manager_.IsUpdatePending()) {
if (trigger_ptu_) {
update_status_manager_.ScheduleUpdate();
}
@@ -773,7 +769,8 @@ void PolicyManagerImpl::OnAppsSearchCompleted(const bool trigger_ptu) {
update_status_manager_.OnAppsSearchCompleted();
trigger_ptu_ = trigger_ptu;
- if (update_status_manager_.IsUpdateRequired() && !ptu_requested_) {
+
+ if (update_status_manager_.IsUpdateRequired()) {
StartPTExchange();
}
}
@@ -1397,11 +1394,9 @@ void PolicyManagerImpl::RetrySequenceFailed() {
ResetRetrySequence(ResetRetryCountType::kResetWithStatusUpdate);
if (HasApplicationForPTU()) {
- update_status_manager_.OnUpdateForNextInQueue();
+ update_status_manager_.OnExistedApplicationAdded(true);
StartPTExchange();
}
- is_ptu_in_progress_ = false;
- ptu_requested_ = false;
}
void PolicyManagerImpl::ResetTimeout() {
@@ -1935,7 +1930,6 @@ void PolicyManagerImpl::IncrementIgnitionCycles() {
std::string PolicyManagerImpl::ForcePTExchange() {
update_status_manager_.ScheduleUpdate();
- is_ptu_in_progress_ = false;
StartPTExchange();
return update_status_manager_.StringifiedUpdateStatus();
}
@@ -1984,10 +1978,7 @@ void PolicyManagerImpl::ResetRetrySequence(
LOG4CXX_AUTO_TRACE(logger_);
sync_primitives::AutoLock auto_lock(retry_sequence_lock_);
retry_sequence_index_ = 0;
-
- if (listener_->CanUpdate()) {
- is_ptu_in_progress_ = false;
- }
+ is_ptu_in_progress_ = false;
if (ResetRetryCountType::kResetWithStatusUpdate == reset_type) {
update_status_manager_.OnResetRetrySequence();
}
@@ -2219,9 +2210,6 @@ StatusNotifier PolicyManagerImpl::AddApplication(
}
LOG4CXX_DEBUG(logger_, "Promote existed application");
PromoteExistedApplication(device_id, application_id, device_consent);
- if (!ptu_requested_) {
- update_status_manager_.OnExistedApplicationAdded(cache_->UpdateRequired());
- }
return std::make_shared<utils::CallNothing>();
}
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 ccf8b6510c..d9b3d69050 100644
--- a/src/components/policy/policy_external/src/update_status_manager.cc
+++ b/src/components/policy/policy_external/src/update_status_manager.cc
@@ -44,8 +44,7 @@ UpdateStatusManager::UpdateStatusManager()
, current_status_(std::make_shared<UpToDateStatus>())
, last_processed_event_(kNoEvent)
, apps_search_in_progress_(false)
- , app_registered_from_non_consented_device_(true)
- , last_update_was_failed_(false) {
+ , app_registered_from_non_consented_device_(true) {
update_status_thread_delegate_ = new UpdateThreadDelegate(this);
thread_ = threads::CreateThread("UpdateStatusThread",
update_status_thread_delegate_);
@@ -88,11 +87,6 @@ void UpdateStatusManager::OnUpdateSentOut(uint32_t update_timeout) {
ProcessEvent(kOnUpdateSentOut);
}
-void UpdateStatusManager::OnUpdateForNextInQueue() {
- LOG4CXX_AUTO_TRACE(logger_);
- ProcessEvent(kUpdateForNextInQueue);
-}
-
void UpdateStatusManager::OnUpdateTimeoutOccurs() {
LOG4CXX_AUTO_TRACE(logger_);
@@ -137,7 +131,6 @@ void UpdateStatusManager::OnResetDefaultPT(bool is_update_required) {
void UpdateStatusManager::OnResetRetrySequence() {
LOG4CXX_AUTO_TRACE(logger_);
- last_update_was_failed_ = true;
ProcessEvent(kOnResetRetrySequence);
}
@@ -159,11 +152,12 @@ void UpdateStatusManager::OnNewApplicationAdded(const DeviceConsent consent) {
}
LOG4CXX_DEBUG(logger_, "Application registered from consented device");
app_registered_from_non_consented_device_ = false;
- if (last_update_was_failed_) {
- last_update_was_failed_ = false;
- ProcessEvent(kUpdateForNextInQueue);
+ if (kOnResetRetrySequence == last_processed_event_) {
+ current_status_.reset(new UpToDateStatus());
+ ProcessEvent(kScheduleUpdate);
+ } else {
+ ProcessEvent(kOnNewAppRegistered);
}
- ProcessEvent(kOnNewAppRegistered);
}
void UpdateStatusManager::OnDeviceConsented() {
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 d662a3b8b9..c74adc9af2 100644
--- a/src/components/policy/policy_regular/src/policy_manager_impl.cc
+++ b/src/components/policy/policy_regular/src/policy_manager_impl.cc
@@ -1652,7 +1652,7 @@ void PolicyManagerImpl::OnPTUIterationTimeout() {
}
if (HasApplicationForPTU()) {
- RequestPTUpdate(PTUIterationType::DefaultIteration);
+ StartPTExchange();
}
return;
}