summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaksym Ked (GitHub) <41471947+mked-luxoft@users.noreply.github.com>2020-02-20 21:12:32 +0200
committerGitHub <noreply@github.com>2020-02-20 14:12:32 -0500
commit14873b942d5e876ea119cc19846a454d06007f1f (patch)
treec40e93389629a7a05b8342178e9f39fdd2470c6f
parentb281c67f167f385aabbb232333ddc8cef65172d7 (diff)
downloadsdl_core-14873b942d5e876ea119cc19846a454d06007f1f.tar.gz
Adapt fix #3203 for PROPRIETARY flow (#3242)
* Adapt fix #3203 for PROPRIETARY flow * fixup! Adapt fix #3203 for PROPRIETARY flow Co-authored-by: Ira Lytvynenko (GitHub) <ILytvynenko@luxoft.com>
-rw-r--r--src/components/policy/policy_external/include/policy/policy_types.h3
-rw-r--r--src/components/policy/policy_external/src/status.cc3
-rw-r--r--src/components/policy/policy_external/src/update_status_manager.cc3
-rw-r--r--src/components/policy/policy_regular/include/policy/policy_types.h3
-rw-r--r--src/components/policy/policy_regular/include/policy/status.h34
-rw-r--r--src/components/policy/policy_regular/include/policy/update_status_manager.h6
-rw-r--r--src/components/policy/policy_regular/src/policy_manager_impl.cc1
-rw-r--r--src/components/policy/policy_regular/src/status.cc33
-rw-r--r--src/components/policy/policy_regular/src/update_status_manager.cc10
9 files changed, 90 insertions, 6 deletions
diff --git a/src/components/policy/policy_external/include/policy/policy_types.h b/src/components/policy/policy_external/include/policy/policy_types.h
index ee2d806ba5..879eb0aa9b 100644
--- a/src/components/policy/policy_external/include/policy/policy_types.h
+++ b/src/components/policy/policy_external/include/policy/policy_types.h
@@ -75,7 +75,8 @@ enum PolicyTableStatus {
StatusUpToDate = 0,
StatusUpdatePending,
StatusUpdateRequired,
- StatusUnknown
+ StatusUnknown,
+ StatusProcessingSnapshot
};
// Code generator uses String class name, so this typedef was renamed to PTSring
diff --git a/src/components/policy/policy_external/src/status.cc b/src/components/policy/policy_external/src/status.cc
index 687bea1c3f..f605a51a98 100644
--- a/src/components/policy/policy_external/src/status.cc
+++ b/src/components/policy/policy_external/src/status.cc
@@ -83,7 +83,8 @@ bool policy::UpdateNeededStatus::IsUpdateRequired() const {
}
policy::UpdatePendingStatus::UpdatePendingStatus()
- : Status(kUpdateNeeded, policy::PolicyTableStatus::StatusUpdatePending) {}
+ : Status(kUpdateNeeded,
+ policy::PolicyTableStatus::StatusProcessingSnapshot) {}
void policy::UpdatePendingStatus::ProcessEvent(
policy::UpdateStatusManager* manager, policy::UpdateEvent event) {
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 3653983c8f..cfbd2fe32b 100644
--- a/src/components/policy/policy_external/src/update_status_manager.cc
+++ b/src/components/policy/policy_external/src/update_status_manager.cc
@@ -217,8 +217,7 @@ void UpdateStatusManager::DoTransition() {
next_status_.reset();
const bool is_update_pending =
- (policy::kUpdateNeeded == current_status_->get_status_string() &&
- policy::StatusUpdatePending == current_status_->get_status());
+ policy::StatusProcessingSnapshot == current_status_->get_status();
if (last_processed_event_ != kScheduleManualUpdate && !is_update_pending) {
listener_->OnUpdateStatusChanged(current_status_->get_status_string());
diff --git a/src/components/policy/policy_regular/include/policy/policy_types.h b/src/components/policy/policy_regular/include/policy/policy_types.h
index 9fddb9761b..f8d71ecb13 100644
--- a/src/components/policy/policy_regular/include/policy/policy_types.h
+++ b/src/components/policy/policy_regular/include/policy/policy_types.h
@@ -75,7 +75,8 @@ enum PolicyTableStatus {
StatusUpToDate = 0,
StatusUpdatePending,
StatusUpdateRequired,
- StatusUnknown
+ StatusUnknown,
+ StatusProcessingSnapshot
};
enum class PTUIterationType { DefaultIteration = 0, RetryIteration };
diff --git a/src/components/policy/policy_regular/include/policy/status.h b/src/components/policy/policy_regular/include/policy/status.h
index 8fd3ff559e..4d8bc47dae 100644
--- a/src/components/policy/policy_regular/include/policy/status.h
+++ b/src/components/policy/policy_regular/include/policy/status.h
@@ -52,6 +52,7 @@ enum UpdateEvent {
kOnResetPolicyTableRequireUpdate,
kOnResetPolicyTableNoUpdate,
kScheduleUpdate,
+ kPendingUpdate,
kScheduleManualUpdate,
kOnResetRetrySequence,
kNoEvent
@@ -118,6 +119,39 @@ class Status {
};
/**
+ * @brief The UpdatePendingStatus class represents cases when SDL knows that an
+ * update is required but before the snapshot is sent to the HMI
+ */
+class UpdatePendingStatus : public Status {
+ public:
+ /**
+ * @brief Constructor
+ */
+ UpdatePendingStatus();
+
+ /**
+ * @brief Process event by setting next status in case event can affect
+ * current status or ignores the event
+ * @param manager Status manager pointer
+ * @param event Event which needs to be processed
+ */
+ void ProcessEvent(UpdateStatusManagerInterface* manager,
+ UpdateEvent event) OVERRIDE;
+
+ /**
+ * @brief Check whether update is required in terms of status
+ * @return True if update is required, otherwise - false
+ */
+ bool IsUpdateRequired() const OVERRIDE;
+
+ /**
+ * @brief Check whether update is pending in terms of status
+ * @return True if update is pending, otherwise - false
+ */
+ bool IsUpdatePending() const OVERRIDE;
+};
+
+/**
* @brief The UpToDateStatus class represents 'up-to-date' status
*/
class UpToDateStatus : public Status {
diff --git a/src/components/policy/policy_regular/include/policy/update_status_manager.h b/src/components/policy/policy_regular/include/policy/update_status_manager.h
index 0c79bf0ba4..fb679ac10b 100644
--- a/src/components/policy/policy_regular/include/policy/update_status_manager.h
+++ b/src/components/policy/policy_regular/include/policy/update_status_manager.h
@@ -149,6 +149,12 @@ class UpdateStatusManager : public UpdateStatusManagerInterface {
void ScheduleUpdate();
/**
+ * @brief PendingUpdate will change state from Update_Needed
+ * to Update_Pending
+ */
+ void PendingUpdate();
+
+ /**
* @brief ScheduleUpdate allows to schedule next update.
* It will change state to Update_Needed, that's is
* and will not send any notifications about updating to HMI
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..b93850f579 100644
--- a/src/components/policy/policy_regular/src/policy_manager_impl.cc
+++ b/src/components/policy/policy_regular/src/policy_manager_impl.cc
@@ -650,6 +650,7 @@ void PolicyManagerImpl::StartPTExchange() {
}
if (update_status_manager_.IsUpdateRequired()) {
+ update_status_manager_.PendingUpdate();
if (RequestPTUpdate(PTUIterationType::DefaultIteration) &&
!timer_retry_sequence_.is_running()) {
// Start retry sequency
diff --git a/src/components/policy/policy_regular/src/status.cc b/src/components/policy/policy_regular/src/status.cc
index 114ecb9f97..29d1bbf6b7 100644
--- a/src/components/policy/policy_regular/src/status.cc
+++ b/src/components/policy/policy_regular/src/status.cc
@@ -67,6 +67,9 @@ void policy::UpdateNeededStatus::ProcessEvent(
case kOnResetPolicyTableNoUpdate:
manager->SetNextStatus(std::make_shared<UpToDateStatus>());
break;
+ case kPendingUpdate:
+ manager->SetNextStatus(std::make_shared<UpdatePendingStatus>());
+ break;
case kOnNewAppRegistered:
manager->SetNextStatus(std::make_shared<UpdateNeededStatus>());
break;
@@ -79,6 +82,36 @@ bool policy::UpdateNeededStatus::IsUpdateRequired() const {
return true;
}
+policy::UpdatePendingStatus::UpdatePendingStatus()
+ : Status(kUpdateNeeded,
+ policy::PolicyTableStatus::StatusProcessingSnapshot) {}
+
+void policy::UpdatePendingStatus::ProcessEvent(
+ policy::UpdateStatusManagerInterface* manager, policy::UpdateEvent event) {
+ switch (event) {
+ case kOnUpdateSentOut:
+ manager->SetNextStatus(std::make_shared<UpdatingStatus>());
+ break;
+ case kOnResetPolicyTableRequireUpdate:
+ manager->SetNextStatus(std::make_shared<UpToDateStatus>());
+ manager->SetPostponedStatus(std::make_shared<UpdateNeededStatus>());
+ break;
+ case kOnResetPolicyTableNoUpdate:
+ manager->SetNextStatus(std::make_shared<UpToDateStatus>());
+ break;
+ default:
+ break;
+ }
+}
+
+bool policy::UpdatePendingStatus::IsUpdatePending() const {
+ return true;
+}
+
+bool policy::UpdatePendingStatus::IsUpdateRequired() const {
+ return true;
+}
+
policy::UpdatingStatus::UpdatingStatus()
: Status("UPDATING", policy::PolicyTableStatus::StatusUpdatePending) {}
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..aa8d8cb3a2 100644
--- a/src/components/policy/policy_regular/src/update_status_manager.cc
+++ b/src/components/policy/policy_regular/src/update_status_manager.cc
@@ -54,6 +54,11 @@ void UpdateStatusManager::ProcessEvent(UpdateEvent event) {
DoTransition();
}
+void UpdateStatusManager::PendingUpdate() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ ProcessEvent(kPendingUpdate);
+}
+
void UpdateStatusManager::SetNextStatus(std::shared_ptr<Status> status) {
next_status_ = status;
}
@@ -173,7 +178,10 @@ void UpdateStatusManager::DoTransition() {
current_status_ = next_status_;
next_status_.reset();
LOG4CXX_DEBUG(logger_, "last_processed_event_ = " << last_processed_event_);
- if (last_processed_event_ != kScheduleManualUpdate) {
+ const bool is_update_pending =
+ policy::StatusProcessingSnapshot == current_status_->get_status();
+
+ if (last_processed_event_ != kScheduleManualUpdate && !is_update_pending) {
listener_->OnUpdateStatusChanged(current_status_->get_status_string());
}
if (!postponed_status_) {