summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlex Kutsan <akutsan@luxoft.com>2017-05-10 13:08:55 +0300
committerAlex Kutsan <akutsan@luxoft.com>2017-05-15 11:33:20 +0300
commitdd4854501bdca7db6fa2076e2f041aaf6bdb03b6 (patch)
tree7075697c1d0ca5fb97ccd767f532b45bf02a1917 /src
parented8f06230da34b3bc88355575371617bb61bb136 (diff)
downloadsdl_core-dd4854501bdca7db6fa2076e2f041aaf6bdb03b6.tar.gz
Fix UPDATE_NEEDED is sent if user requested PTU from HMI
Extended interface of policies: Added new state in update_status manager. In case if updated was trigered by HMI - no notifications should come to HMI during update fixup! Fix UPDATE_NEEDED is sent if user requested PTU from HMI
Diffstat (limited to 'src')
-rw-r--r--src/components/application_manager/src/policies/policy_handler.cc2
-rw-r--r--src/components/application_manager/test/policy_handler_test.cc2
-rw-r--r--src/components/include/policy/policy_external/policy/policy_manager.h7
-rw-r--r--src/components/include/policy/policy_regular/policy/policy_manager.h8
-rw-r--r--src/components/include/test/policy/policy_external/policy/mock_policy_manager.h1
-rw-r--r--src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h1
-rw-r--r--src/components/policy/policy_external/include/policy/policy_manager_impl.h1
-rw-r--r--src/components/policy/policy_external/include/policy/status.h1
-rw-r--r--src/components/policy/policy_external/include/policy/update_status_manager.h8
-rw-r--r--src/components/policy/policy_external/src/policy_manager_impl.cc7
-rw-r--r--src/components/policy/policy_external/src/status.cc2
-rw-r--r--src/components/policy/policy_external/src/update_status_manager.cc14
-rw-r--r--src/components/policy/policy_regular/include/policy/policy_manager_impl.h1
-rw-r--r--src/components/policy/policy_regular/include/policy/status.h1
-rw-r--r--src/components/policy/policy_regular/include/policy/update_status_manager.h8
-rw-r--r--src/components/policy/policy_regular/src/policy_manager_impl.cc6
-rw-r--r--src/components/policy/policy_regular/src/update_status_manager.cc15
17 files changed, 75 insertions, 10 deletions
diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc
index ab09bbc23c..de26c23a70 100644
--- a/src/components/application_manager/src/policies/policy_handler.cc
+++ b/src/components/application_manager/src/policies/policy_handler.cc
@@ -1232,7 +1232,7 @@ void PolicyHandler::KmsChanged(int kilometers) {
void PolicyHandler::PTExchangeAtUserRequest(uint32_t correlation_id) {
LOG4CXX_TRACE(logger_, "PT exchange at user request");
POLICY_LIB_CHECK_VOID();
- std::string update_status = policy_manager_->ForcePTExchange();
+ std::string update_status = policy_manager_->ForcePTExchangeAtUserRequest();
MessageHelper::SendUpdateSDLResponse(
update_status, correlation_id, application_manager_);
}
diff --git a/src/components/application_manager/test/policy_handler_test.cc b/src/components/application_manager/test/policy_handler_test.cc
index 36e7343442..0106ddd556 100644
--- a/src/components/application_manager/test/policy_handler_test.cc
+++ b/src/components/application_manager/test/policy_handler_test.cc
@@ -867,7 +867,7 @@ TEST_F(PolicyHandlerTest, PTExchangeAtUserRequest) {
// Arrange
ChangePolicyManagerToMock();
// Check expectations
- EXPECT_CALL(*mock_policy_manager_, ForcePTExchange());
+ EXPECT_CALL(*mock_policy_manager_, ForcePTExchangeAtUserRequest());
EXPECT_CALL(mock_message_helper_, SendUpdateSDLResponse(_, _, _));
// Act
const uint32_t correlation_id = 2;
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 6028a1674e..74a3d36c4f 100644
--- a/src/components/include/policy/policy_external/policy/policy_manager.h
+++ b/src/components/include/policy/policy_external/policy/policy_manager.h
@@ -142,11 +142,16 @@ class PolicyManager : public usage_statistics::StatisticsManager {
virtual void IncrementIgnitionCycles() = 0;
/**
- * @brief ExchangeByUserRequest
+ * @brief Exchange by hmi or mobile request
*/
virtual std::string ForcePTExchange() = 0;
/**
+ * @brief ExchangeByUserRequest
+ */
+ virtual std::string ForcePTExchangeAtUserRequest() = 0;
+
+ /**
* Resets retry sequence
*/
virtual void ResetRetrySequence() = 0;
diff --git a/src/components/include/policy/policy_regular/policy/policy_manager.h b/src/components/include/policy/policy_regular/policy/policy_manager.h
index fcdf48e8cf..e98a58a6d9 100644
--- a/src/components/include/policy/policy_regular/policy/policy_manager.h
+++ b/src/components/include/policy/policy_regular/policy/policy_manager.h
@@ -141,15 +141,19 @@ class PolicyManager : public usage_statistics::StatisticsManager {
virtual void IncrementIgnitionCycles() = 0;
/**
- * @brief ExchangeByUserRequest
+ * @brief Exchange by hmi or mobile request
*/
virtual std::string ForcePTExchange() = 0;
/**
+ * @brief ExchangeByUserRequest
+ */
+ virtual std::string ForcePTExchangeAtUserRequest() = 0;
+
+ /**
* Resets retry sequence
*/
virtual void ResetRetrySequence() = 0;
-
/**
* Gets timeout to wait before next retry updating PT
* If timeout is equal to zero then the retry sequence is not need.
diff --git a/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h b/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h
index 30c1496495..ac51c47a75 100644
--- a/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h
+++ b/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h
@@ -78,6 +78,7 @@ class MockPolicyManager : public PolicyManager {
MOCK_METHOD1(KmsChanged, void(int kilometers));
MOCK_METHOD0(IncrementIgnitionCycles, void());
MOCK_METHOD0(ForcePTExchange, std::string());
+ MOCK_METHOD0(ForcePTExchangeAtUserRequest, std::string());
MOCK_METHOD0(ResetRetrySequence, void());
MOCK_METHOD0(NextRetryTimeout, int());
MOCK_METHOD0(TimeoutExchangeMSec, uint32_t());
diff --git a/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h b/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h
index 16e647dfba..9d940191fd 100644
--- a/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h
+++ b/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h
@@ -80,6 +80,7 @@ class MockPolicyManager : public PolicyManager {
MOCK_METHOD1(KmsChanged, void(int kilometers));
MOCK_METHOD0(IncrementIgnitionCycles, void());
MOCK_METHOD0(ForcePTExchange, std::string());
+ MOCK_METHOD0(ForcePTExchangeAtUserRequest, std::string());
MOCK_METHOD0(ResetRetrySequence, void());
MOCK_METHOD0(NextRetryTimeout, uint32_t());
MOCK_METHOD0(TimeoutExchangeMSec, uint32_t());
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 2d64a5a4e1..7f8322ee05 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
@@ -74,6 +74,7 @@ class PolicyManagerImpl : public PolicyManager {
virtual void KmsChanged(int kilometers);
virtual void IncrementIgnitionCycles();
virtual std::string ForcePTExchange();
+ virtual std::string ForcePTExchangeAtUserRequest();
virtual std::string GetPolicyTableStatus() const;
virtual void ResetRetrySequence();
virtual int NextRetryTimeout();
diff --git a/src/components/policy/policy_external/include/policy/status.h b/src/components/policy/policy_external/include/policy/status.h
index f578db0311..6318c5fade 100644
--- a/src/components/policy/policy_external/include/policy/status.h
+++ b/src/components/policy/policy_external/include/policy/status.h
@@ -52,6 +52,7 @@ enum UpdateEvent {
kOnResetPolicyTableRequireUpdate,
kOnResetPolicyTableNoUpdate,
kScheduleUpdate,
+ kScheduleManualUpdate,
kOnResetRetrySequence
};
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 c04c513479..b663610a5b 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
@@ -151,6 +151,13 @@ class UpdateStatusManager {
void ScheduleUpdate();
/**
+ * @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
+ */
+ void ScheduleManualUpdate();
+
+ /**
* @brief StringifiedUpdateStatus allows to obtain update status as a string.
*
* @return stringified update status.
@@ -205,6 +212,7 @@ class UpdateStatusManager {
utils::SharedPtr<Status> postponed_status_;
sync_primitives::Lock status_lock_;
+ UpdateEvent last_processed_event_;
bool apps_search_in_progress_;
bool app_registered_from_non_consented_device_;
sync_primitives::Lock apps_search_in_progress_lock_;
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 423691796c..419cb2e4ef 100644
--- a/src/components/policy/policy_external/src/policy_manager_impl.cc
+++ b/src/components/policy/policy_external/src/policy_manager_impl.cc
@@ -1033,6 +1033,13 @@ std::string PolicyManagerImpl::ForcePTExchange() {
return update_status_manager_.StringifiedUpdateStatus();
}
+std::string PolicyManagerImpl::ForcePTExchangeAtUserRequest() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ update_status_manager_.ScheduleManualUpdate();
+ StartPTExchange();
+ return update_status_manager_.StringifiedUpdateStatus();
+}
+
std::string PolicyManagerImpl::GetPolicyTableStatus() const {
return update_status_manager_.StringifiedUpdateStatus();
}
diff --git a/src/components/policy/policy_external/src/status.cc b/src/components/policy/policy_external/src/status.cc
index cfb76fea63..31fc7f110b 100644
--- a/src/components/policy/policy_external/src/status.cc
+++ b/src/components/policy/policy_external/src/status.cc
@@ -43,6 +43,7 @@ void policy::UpToDateStatus::ProcessEvent(UpdateStatusManager* manager,
case kOnNewAppRegistered:
case kOnResetPolicyTableRequireUpdate:
case kScheduleUpdate:
+ case kScheduleManualUpdate:
case kOnResetRetrySequence:
manager->SetNextStatus(utils::MakeShared<UpdateNeededStatus>());
break;
@@ -98,6 +99,7 @@ void policy::UpdatingStatus::ProcessEvent(policy::UpdateStatusManager* manager,
manager->SetPostponedStatus(utils::MakeShared<UpdateNeededStatus>());
break;
case kScheduleUpdate:
+ case kScheduleManualUpdate:
case kOnResetRetrySequence:
manager->SetPostponedStatus(utils::MakeShared<UpdateNeededStatus>());
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 a1f177c4bc..78cafa044c 100644
--- a/src/components/policy/policy_external/src/update_status_manager.cc
+++ b/src/components/policy/policy_external/src/update_status_manager.cc
@@ -62,6 +62,7 @@ UpdateStatusManager::~UpdateStatusManager() {
void UpdateStatusManager::ProcessEvent(UpdateEvent event) {
sync_primitives::AutoLock lock(status_lock_);
current_status_->ProcessEvent(this, event);
+ last_processed_event_ = event;
DoTransition();
}
@@ -154,6 +155,10 @@ void UpdateStatusManager::ScheduleUpdate() {
ProcessEvent(kScheduleUpdate);
}
+void UpdateStatusManager::ScheduleManualUpdate() {
+ ProcessEvent(kScheduleManualUpdate);
+}
+
std::string UpdateStatusManager::StringifiedUpdateStatus() const {
return current_status_->get_status_string();
}
@@ -184,14 +189,19 @@ void UpdateStatusManager::DoTransition() {
current_status_ = next_status_;
next_status_.reset();
- listener_->OnUpdateStatusChanged(current_status_->get_status_string());
+
+ if (last_processed_event_ != kScheduleManualUpdate) {
+ listener_->OnUpdateStatusChanged(current_status_->get_status_string());
+ }
if (!postponed_status_) {
return;
}
current_status_ = postponed_status_;
- listener_->OnUpdateStatusChanged(current_status_->get_status_string());
+ if (last_processed_event_ != kScheduleManualUpdate) {
+ listener_->OnUpdateStatusChanged(current_status_->get_status_string());
+ }
postponed_status_.reset();
}
diff --git a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h
index fec05e0724..667ea2cb71 100644
--- a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h
+++ b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h
@@ -81,6 +81,7 @@ class PolicyManagerImpl : public PolicyManager {
virtual void KmsChanged(int kilometers);
virtual void IncrementIgnitionCycles();
virtual std::string ForcePTExchange();
+ virtual std::string ForcePTExchangeAtUserRequest();
virtual std::string GetPolicyTableStatus() const;
virtual void ResetRetrySequence();
virtual uint32_t NextRetryTimeout();
diff --git a/src/components/policy/policy_regular/include/policy/status.h b/src/components/policy/policy_regular/include/policy/status.h
index 1d9ae97f8e..ee127d3236 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,
+ kScheduleManualUpdate,
kOnResetRetrySequence
};
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 ccd55e040a..89c6b7e7bb 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
@@ -151,6 +151,13 @@ class UpdateStatusManager : public UpdateStatusManagerInterface {
void ScheduleUpdate();
/**
+ * @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
+ */
+ void ScheduleManualUpdate();
+
+ /**
* @brief StringifiedUpdateStatus allows to obtain update status as a string.
*
* @return stringified update status.
@@ -205,6 +212,7 @@ class UpdateStatusManager : public UpdateStatusManagerInterface {
utils::SharedPtr<Status> postponed_status_;
sync_primitives::Lock status_lock_;
+ UpdateEvent last_processed_event_;
bool apps_search_in_progress_;
bool app_registered_from_non_consented_device_;
sync_primitives::Lock apps_search_in_progress_lock_;
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 8236762961..e818fb0e3f 100644
--- a/src/components/policy/policy_regular/src/policy_manager_impl.cc
+++ b/src/components/policy/policy_regular/src/policy_manager_impl.cc
@@ -764,6 +764,12 @@ std::string PolicyManagerImpl::ForcePTExchange() {
return update_status_manager_.StringifiedUpdateStatus();
}
+std::string PolicyManagerImpl::ForcePTExchangeAtUserRequest() {
+ update_status_manager_.ScheduleManualUpdate();
+ StartPTExchange();
+ return update_status_manager_.StringifiedUpdateStatus();
+}
+
std::string PolicyManagerImpl::GetPolicyTableStatus() const {
return update_status_manager_.StringifiedUpdateStatus();
}
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 a1f177c4bc..d683249718 100644
--- a/src/components/policy/policy_regular/src/update_status_manager.cc
+++ b/src/components/policy/policy_regular/src/update_status_manager.cc
@@ -62,6 +62,7 @@ UpdateStatusManager::~UpdateStatusManager() {
void UpdateStatusManager::ProcessEvent(UpdateEvent event) {
sync_primitives::AutoLock lock(status_lock_);
current_status_->ProcessEvent(this, event);
+ last_processed_event_ = event;
DoTransition();
}
@@ -154,6 +155,10 @@ void UpdateStatusManager::ScheduleUpdate() {
ProcessEvent(kScheduleUpdate);
}
+void UpdateStatusManager::ScheduleManualUpdate() {
+ ProcessEvent(kScheduleManualUpdate);
+}
+
std::string UpdateStatusManager::StringifiedUpdateStatus() const {
return current_status_->get_status_string();
}
@@ -184,14 +189,18 @@ void UpdateStatusManager::DoTransition() {
current_status_ = next_status_;
next_status_.reset();
- listener_->OnUpdateStatusChanged(current_status_->get_status_string());
-
+ LOG4CXX_DEBUG(logger_, "last_processed_event_ = " << last_processed_event_);
+ if (last_processed_event_ != kScheduleManualUpdate) {
+ listener_->OnUpdateStatusChanged(current_status_->get_status_string());
+ }
if (!postponed_status_) {
return;
}
current_status_ = postponed_status_;
- listener_->OnUpdateStatusChanged(current_status_->get_status_string());
+ if (last_processed_event_ != kScheduleManualUpdate) {
+ listener_->OnUpdateStatusChanged(current_status_->get_status_string());
+ }
postponed_status_.reset();
}