summaryrefslogtreecommitdiff
path: root/src/components/policy/policy_external
diff options
context:
space:
mode:
authorIra Lytvynenko (GitHub) <ILytvynenko@luxoft.com>2020-02-05 20:15:14 +0200
committerGitHub <noreply@github.com>2020-02-05 13:15:14 -0500
commit4f17e762334dcc901a1b0cc9dacdeda506e64ad1 (patch)
tree5967d654d60b15eb0d63ddff663498b62b7037cf /src/components/policy/policy_external
parent49f5b211ca995193d68301b0b3c08e3df427568f (diff)
downloadsdl_core-4f17e762334dcc901a1b0cc9dacdeda506e64ad1.tar.gz
Feature/HMI Policy Table Update using vehicle modem (#3201)
* Send UPDATING state after receiving a successful SDL.PolicyUpdate response * Restart the timeout in case SDL received BC.OnSystemRequest with type PROPRIETARY or HTTP from HMI in UPDATING state * Fix UPDATE_NEEDED - UPDATING sequence in case of second app register * Add unit tests * fixup! Send UPDATING state after receiving a successful SDL.PolicyUpdate response * fixup! Restart the timeout in case SDL received BC.OnSystemRequest with type PROPRIETARY or HTTP from HMI in UPDATING state Co-authored-by: Yaroslav Mamykin (GitHub) <33784535+YarikMamykin@users.noreply.github.com>
Diffstat (limited to 'src/components/policy/policy_external')
-rw-r--r--src/components/policy/policy_external/include/policy/policy_manager_impl.h2
-rw-r--r--src/components/policy/policy_external/include/policy/update_status_manager.h2
-rw-r--r--src/components/policy/policy_external/src/policy_manager_impl.cc9
-rw-r--r--src/components/policy/policy_external/src/status.cc3
-rw-r--r--src/components/policy/policy_external/src/update_status_manager.cc6
-rw-r--r--src/components/policy/policy_external/test/update_status_manager_test.cc6
6 files changed, 27 insertions, 1 deletions
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