summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAKalinich-Luxoft <AKalinich@luxoft.com>2017-06-27 12:05:14 +0300
committerAKalinich-Luxoft <AKalinich@luxoft.com>2017-12-12 14:11:47 +0200
commit3baea565f75bfc8cebacccc0bc04045af076e7f8 (patch)
tree95ee77a53ccc56fb45246c29ab006771b1ee95be
parent4fe39afab7101e50f51415a20507821e2775387e (diff)
downloadsdl_core-3baea565f75bfc8cebacccc0bc04045af076e7f8.tar.gz
Removed is_suspended setter.
is_suspended flag was encapsulated inside resumption controller Updated mocks
-rw-r--r--src/components/application_manager/include/application_manager/resumption/resume_ctrl.h13
-rw-r--r--src/components/application_manager/include/application_manager/resumption/resume_ctrl_impl.h19
-rw-r--r--src/components/application_manager/src/commands/hmi/on_exit_all_applications_notification.cc1
-rw-r--r--src/components/application_manager/src/resumption/resume_ctrl_impl.cc19
-rw-r--r--src/components/application_manager/test/commands/hmi/hmi_notifications/hmi_notifications_test.cc1
-rw-r--r--src/components/application_manager/test/include/application_manager/mock_resume_ctrl.h1
6 files changed, 21 insertions, 33 deletions
diff --git a/src/components/application_manager/include/application_manager/resumption/resume_ctrl.h b/src/components/application_manager/include/application_manager/resumption/resume_ctrl.h
index 298992c907..0ec58f2419 100644
--- a/src/components/application_manager/include/application_manager/resumption/resume_ctrl.h
+++ b/src/components/application_manager/include/application_manager/resumption/resume_ctrl.h
@@ -125,7 +125,8 @@ class ResumeCtrl {
virtual void OnAwake() = 0;
/**
- * @brief Retrieves value of is_suspended_
+ * @brief Checks if SDL has already received OnExitAllApplication notification
+ * with "SUSPEND" reason
*
* @return Returns TRUE if SDL has received OnExitAllApplication notification
* with reason "SUSPEND" otherwise returns FALSE
@@ -133,16 +134,6 @@ class ResumeCtrl {
virtual bool is_suspended() const = 0;
/**
- * @brief Sets value of is_suspended_
- *
- * @param contains TRUE if method is called when SDL has received
- * OnExitAllApplication notification with reason "SUSPEND"
- * contains FALSE if method is called when SDL has received
- * OnAwakeSDL notification.
- */
- virtual void set_is_suspended(const bool suspended_flag) = 0;
-
- /**
* @brief Method stops timer "RsmCtrlPercist" when SDL
* receives OnExitAllApplication notification
* with reason "SUSPEND"
diff --git a/src/components/application_manager/include/application_manager/resumption/resume_ctrl_impl.h b/src/components/application_manager/include/application_manager/resumption/resume_ctrl_impl.h
index dd0c5836b8..d7ff621c95 100644
--- a/src/components/application_manager/include/application_manager/resumption/resume_ctrl_impl.h
+++ b/src/components/application_manager/include/application_manager/resumption/resume_ctrl_impl.h
@@ -139,7 +139,8 @@ class ResumeCtrlImpl : public ResumeCtrl,
void OnAwake() OVERRIDE;
/**
- * @brief Retrieves value of is_suspended_
+ * @brief Checks if SDL has already received OnExitAllApplication notification
+ * with "SUSPEND" reason
*
* @return Returns TRUE if SDL has received OnExitAllApplication notification
* with reason "SUSPEND" otherwise returns FALSE
@@ -147,16 +148,6 @@ class ResumeCtrlImpl : public ResumeCtrl,
bool is_suspended() const OVERRIDE;
/**
- * @brief Sets value of is_suspended_
- *
- * @param contains TRUE if method is called when SDL has received
- * OnExitAllApplication notification with reason "SUSPEND"
- * contains FALSE if method is called when SDL has received
- * OnAwakeSDL notification.
- */
- void set_is_suspended(const bool suspended_flag) OVERRIDE;
-
- /**
* @brief Method stops timer "RsmCtrlPercist" when SDL
* receives OnExitAllApplication notification
* with reason "SUSPEND"
@@ -324,6 +315,12 @@ class ResumeCtrlImpl : public ResumeCtrl,
void SaveDataOnTimer();
/**
+ * @brief FinalPersistData persists ResumptionData last time and stops
+ * persistent data timer to avoid further persisting
+ */
+ void FinalPersistData();
+
+ /**
* @brief AddFiles allows to add files for the application
* which should be resumed
* @param application application which will be resumed
diff --git a/src/components/application_manager/src/commands/hmi/on_exit_all_applications_notification.cc b/src/components/application_manager/src/commands/hmi/on_exit_all_applications_notification.cc
index 6d131683d3..cb68b21263 100644
--- a/src/components/application_manager/src/commands/hmi/on_exit_all_applications_notification.cc
+++ b/src/components/application_manager/src/commands/hmi/on_exit_all_applications_notification.cc
@@ -75,7 +75,6 @@ void OnExitAllApplicationsNotification::Run() {
break;
}
case hmi_apis::Common_ApplicationsCloseReason::SUSPEND: {
- application_manager_.resume_controller().set_is_suspended(true);
application_manager_.resume_controller().OnSuspend();
SendOnSDLPersistenceComplete();
return;
diff --git a/src/components/application_manager/src/resumption/resume_ctrl_impl.cc b/src/components/application_manager/src/resumption/resume_ctrl_impl.cc
index bf7a365b9e..435e621169 100644
--- a/src/components/application_manager/src/resumption/resume_ctrl_impl.cc
+++ b/src/components/application_manager/src/resumption/resume_ctrl_impl.cc
@@ -264,19 +264,19 @@ bool ResumeCtrlImpl::RemoveApplicationFromSaved(
void ResumeCtrlImpl::OnSuspend() {
LOG4CXX_AUTO_TRACE(logger_);
- StopSavePersistentDataTimer();
- SaveAllApplications();
- resumption_storage_->Persist();
+ is_suspended_ = true;
+ FinalPersistData();
}
void ResumeCtrlImpl::OnIgnitionOff() {
LOG4CXX_AUTO_TRACE(logger_);
resumption_storage_->IncrementIgnOffCount();
- OnSuspend();
+ FinalPersistData();
}
void ResumeCtrlImpl::OnAwake() {
LOG4CXX_AUTO_TRACE(logger_);
+ is_suspended_ = false;
ResetLaunchTime();
StartSavePersistentDataTimer();
}
@@ -285,10 +285,6 @@ bool ResumeCtrlImpl::is_suspended() const {
return is_suspended_;
}
-void ResumeCtrlImpl::set_is_suspended(const bool suspended_flag) {
- is_suspended_ = suspended_flag;
-}
-
void ResumeCtrlImpl::StartSavePersistentDataTimer() {
LOG4CXX_AUTO_TRACE(logger_);
if (!save_persistent_data_timer_.is_running()) {
@@ -447,6 +443,13 @@ void ResumeCtrlImpl::SaveDataOnTimer() {
}
}
+void ResumeCtrlImpl::FinalPersistData() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ StopSavePersistentDataTimer();
+ SaveAllApplications();
+ resumption_storage_->Persist();
+}
+
bool ResumeCtrlImpl::IsDeviceMacAddressEqual(
ApplicationSharedPtr application, const std::string& saved_device_mac) {
LOG4CXX_AUTO_TRACE(logger_);
diff --git a/src/components/application_manager/test/commands/hmi/hmi_notifications/hmi_notifications_test.cc b/src/components/application_manager/test/commands/hmi/hmi_notifications/hmi_notifications_test.cc
index 2a67aa2390..21ed5a1f41 100644
--- a/src/components/application_manager/test/commands/hmi/hmi_notifications/hmi_notifications_test.cc
+++ b/src/components/application_manager/test/commands/hmi/hmi_notifications/hmi_notifications_test.cc
@@ -1035,7 +1035,6 @@ TEST_F(HMICommandsNotificationsTest,
EXPECT_CALL(app_mngr_, resume_controller())
.Times(2)
.WillRepeatedly(ReturnRef(mock_resume_ctrl));
- EXPECT_CALL(mock_resume_ctrl, set_is_suspended(true));
EXPECT_CALL(mock_resume_ctrl, OnSuspend());
EXPECT_CALL(app_mngr_, GetNextHMICorrelationID())
diff --git a/src/components/application_manager/test/include/application_manager/mock_resume_ctrl.h b/src/components/application_manager/test/include/application_manager/mock_resume_ctrl.h
index d5178f5054..fb264b7d82 100644
--- a/src/components/application_manager/test/include/application_manager/mock_resume_ctrl.h
+++ b/src/components/application_manager/test/include/application_manager/mock_resume_ctrl.h
@@ -51,7 +51,6 @@ class MockResumeCtrl : public resumption::ResumeCtrl {
MOCK_METHOD0(OnIgnitionOff, void());
MOCK_METHOD0(OnAwake, void());
MOCK_CONST_METHOD0(is_suspended, bool());
- MOCK_METHOD1(set_is_suspended, void(const bool));
MOCK_METHOD0(StopSavePersistentDataTimer, void());
MOCK_METHOD2(StartResumption,
bool(app_mngr::ApplicationSharedPtr application,