From 3baea565f75bfc8cebacccc0bc04045af076e7f8 Mon Sep 17 00:00:00 2001 From: AKalinich-Luxoft Date: Tue, 27 Jun 2017 12:05:14 +0300 Subject: Removed is_suspended setter. is_suspended flag was encapsulated inside resumption controller Updated mocks --- .../application_manager/resumption/resume_ctrl.h | 13 ++----------- .../application_manager/resumption/resume_ctrl_impl.h | 19 ++++++++----------- .../hmi/on_exit_all_applications_notification.cc | 1 - .../src/resumption/resume_ctrl_impl.cc | 19 +++++++++++-------- .../hmi/hmi_notifications/hmi_notifications_test.cc | 1 - .../include/application_manager/mock_resume_ctrl.h | 1 - 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,23 +125,14 @@ 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 */ 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 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,23 +139,14 @@ 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 */ 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 @@ -323,6 +314,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 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, -- cgit v1.2.1