summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAKalinich-Luxoft <AKalinich@luxoft.com>2017-06-09 09:39:12 +0300
committerAKalinich-Luxoft <AKalinich@luxoft.com>2017-12-12 14:10:29 +0200
commit2f22052761aed0069b9a7fc99c0ffee1e60822c0 (patch)
tree9f7e50486584cf6d7b0328efa941fcd318d97cbb
parent6153f79de2c362dd51c3e945294b74cd9f965ac5 (diff)
downloadsdl_core-2f22052761aed0069b9a7fc99c0ffee1e60822c0.tar.gz
Added OnIgnitionOff() and new bool flag to ResumeCtrl class
SDL should distinct ignition off and suspend notifications. SDL should not increment ignition off count in case of suspended notification, only in case of ignition off. This logic was separated by appending new function OnIgnitionOff() which will be called from application manager on ignition off instead of OnSuspend(). Also was added is_suspended flag and related getter/setter. This flag is used in: - ApplicationImpl to check should SDL send OnHashChange or not - In OnAwakeSDLNotification to check should SDL do OnAwake actions or not - OnExitAllApplicationsNotification and OnAwakeSDLNotification switches this flag Also was fixed some related UT expectations and mocks.
-rw-r--r--src/components/application_manager/include/application_manager/resumption/resume_ctrl.h23
-rw-r--r--src/components/application_manager/include/application_manager/resumption/resume_ctrl_impl.h24
-rw-r--r--src/components/application_manager/src/application_manager_impl.cc2
-rw-r--r--src/components/application_manager/src/commands/hmi/on_exit_all_applications_notification.cc2
-rw-r--r--src/components/application_manager/src/resumption/resume_ctrl_impl.cc20
-rw-r--r--src/components/application_manager/test/application_impl_test.cc17
-rw-r--r--src/components/application_manager/test/commands/hmi/hmi_notifications/hmi_notifications_test.cc10
-rw-r--r--src/components/application_manager/test/include/application_manager/mock_resume_ctrl.h3
8 files changed, 97 insertions, 4 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 26b1739a38..298992c907 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
@@ -115,11 +115,34 @@ class ResumeCtrl {
virtual void OnSuspend() = 0;
/**
+ * @brief Processes resumption data after receiving signal "Ignition Off"
+ */
+ virtual void OnIgnitionOff() = 0;
+
+ /**
* @brief Processes resumption data after receiving signal "Awake"
*/
virtual void OnAwake() = 0;
/**
+ * @brief Retrieves value of is_suspended_
+ *
+ * @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
* 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 bb886cd5f6..dd0c5836b8 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
@@ -129,11 +129,34 @@ class ResumeCtrlImpl : public ResumeCtrl,
void OnSuspend() OVERRIDE;
/**
+ * @brief Processes resumption data after receiving signal "Ignition Off"
+ */
+ void OnIgnitionOff() OVERRIDE;
+
+ /**
* @brief Processes resumption data after receiving signal "Awake"
*/
void OnAwake() OVERRIDE;
/**
+ * @brief Retrieves value of is_suspended_
+ *
+ * @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
* with reason "SUSPEND"
@@ -491,6 +514,7 @@ class ResumeCtrlImpl : public ResumeCtrl,
WaitingForTimerList waiting_for_timer_;
bool is_resumption_active_;
bool is_data_saved_;
+ bool is_suspended_;
time_t launch_time_;
utils::SharedPtr<ResumptionData> resumption_storage_;
application_manager::ApplicationManager& application_manager_;
diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc
index a2cba5198e..cacaadd996 100644
--- a/src/components/application_manager/src/application_manager_impl.cc
+++ b/src/components/application_manager/src/application_manager_impl.cc
@@ -2883,7 +2883,7 @@ void ApplicationManagerImpl::UnregisterAllApplications() {
}
}
if (is_ignition_off) {
- resume_controller().OnSuspend();
+ resume_controller().OnIgnitionOff();
}
request_ctrl_.terminateAllHMIRequests();
}
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 07a95adcea..6d131683d3 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,6 +75,8 @@ 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 c8740227df..bf7a365b9e 100644
--- a/src/components/application_manager/src/resumption/resume_ctrl_impl.cc
+++ b/src/components/application_manager/src/resumption/resume_ctrl_impl.cc
@@ -67,6 +67,7 @@ ResumeCtrlImpl::ResumeCtrlImpl(ApplicationManager& application_manager)
this, &ResumeCtrlImpl::SaveDataOnTimer))
, is_resumption_active_(false)
, is_data_saved_(false)
+ , is_suspended_(false)
, launch_time_(time(NULL))
, application_manager_(application_manager) {}
#ifdef BUILD_TESTS
@@ -265,14 +266,27 @@ void ResumeCtrlImpl::OnSuspend() {
LOG4CXX_AUTO_TRACE(logger_);
StopSavePersistentDataTimer();
SaveAllApplications();
- resumption_storage_->OnSuspend();
resumption_storage_->Persist();
}
+void ResumeCtrlImpl::OnIgnitionOff() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ resumption_storage_->IncrementIgnOffCount();
+ OnSuspend();
+}
+
void ResumeCtrlImpl::OnAwake() {
+ LOG4CXX_AUTO_TRACE(logger_);
ResetLaunchTime();
StartSavePersistentDataTimer();
- return resumption_storage_->OnAwake();
+}
+
+bool ResumeCtrlImpl::is_suspended() const {
+ return is_suspended_;
+}
+
+void ResumeCtrlImpl::set_is_suspended(const bool suspended_flag) {
+ is_suspended_ = suspended_flag;
}
void ResumeCtrlImpl::StartSavePersistentDataTimer() {
@@ -774,7 +788,7 @@ void ResumeCtrlImpl::LoadResumeData() {
"Resumption data for application "
<< app_id << " and device id " << device_id
<< " will be dropped.");
- resumption_storage_->DropAppDataResumption(device_id, app_id);
+ resumption_storage_->RemoveApplicationFromSaved(app_id, device_id);
continue;
}
}
diff --git a/src/components/application_manager/test/application_impl_test.cc b/src/components/application_manager/test/application_impl_test.cc
index a1e284b40d..02a257e5d9 100644
--- a/src/components/application_manager/test/application_impl_test.cc
+++ b/src/components/application_manager/test/application_impl_test.cc
@@ -50,6 +50,7 @@
#include "resumption/last_state.h"
#include "application_manager/resumption/resume_ctrl.h"
#include "application_manager/policies/mock_policy_handler_interface.h"
+#include "application_manager/mock_resume_ctrl.h"
#include "policy/usage_statistics/mock_statistics_manager.h"
#include "smart_objects/smart_object.h"
@@ -652,6 +653,22 @@ TEST_F(ApplicationImplTest,
TEST_F(ApplicationImplTest, UpdateHash_AppMngrNotSuspended) {
EXPECT_CALL(*MockMessageHelper::message_helper_mock(),
SendHashUpdateNotification(app_id, _)).Times(1);
+ resumprion_test::MockResumeCtrl mock_resume_ctrl;
+ EXPECT_CALL(mock_application_manager_, resume_controller())
+ .WillOnce(ReturnRef(mock_resume_ctrl));
+ EXPECT_CALL(mock_resume_ctrl, is_suspended()).WillOnce(Return(false));
+ app_impl->UpdateHash();
+
+ EXPECT_TRUE(app_impl->is_application_data_changed());
+}
+
+TEST_F(ApplicationImplTest, UpdateHash_AppMngrSuspended) {
+ EXPECT_CALL(*MockMessageHelper::message_helper_mock(),
+ SendHashUpdateNotification(app_id, _)).Times(0);
+ resumprion_test::MockResumeCtrl mock_resume_ctrl;
+ EXPECT_CALL(mock_application_manager_, resume_controller())
+ .WillOnce(ReturnRef(mock_resume_ctrl));
+ EXPECT_CALL(mock_resume_ctrl, is_suspended()).WillOnce(Return(true));
app_impl->UpdateHash();
EXPECT_TRUE(app_impl->is_application_data_changed());
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 fffbfc8445..2a67aa2390 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
@@ -130,6 +130,8 @@
#include "application_manager/policies/mock_policy_handler_interface.h"
#include "application_manager/mock_message_helper.h"
#include "protocol_handler/mock_session_observer.h"
+#include "application_manager/mock_resume_ctrl.h"
+
#ifdef SDL_REMOTE_CONTROL
#include "functional_module/plugin_manager.h"
#endif // SDL_REMOTE_CONTROL
@@ -1029,10 +1031,18 @@ TEST_F(HMICommandsNotificationsTest,
kCorrelationId_;
MessageSharedPtr temp_message = CreateMessage();
+ resumprion_test::MockResumeCtrl mock_resume_ctrl;
+ 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())
.WillOnce(Return(kCorrelationId_));
EXPECT_CALL(app_mngr_, ManageHMICommand(_))
.WillOnce(GetMessage(temp_message));
+
command->Run();
EXPECT_EQ(
static_cast<uint32_t>(
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 b06b207f84..d5178f5054 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
@@ -48,7 +48,10 @@ class MockResumeCtrl : public resumption::ResumeCtrl {
MOCK_METHOD1(RemoveApplicationFromSaved,
bool(app_mngr::ApplicationConstSharedPtr application));
MOCK_METHOD0(OnSuspend, void());
+ 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,