diff options
author | JackLivio <jack@livio.io> | 2018-01-16 15:42:37 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-16 15:42:37 -0500 |
commit | ac4f7aeabd54a49ecf61dbc12ee19cbeb3522c74 (patch) | |
tree | 1555c50c33e2bd358bda3d8c3f7afd55496771b1 | |
parent | 77ff65fe0a710bd01257d4b0ad6cc14913cbb644 (diff) | |
parent | 8862a94c64534572c1e4e691af440598111cae7c (diff) | |
download | sdl_core-ac4f7aeabd54a49ecf61dbc12ee19cbeb3522c74.tar.gz |
Merge pull request #1604 from AKalinich-Luxoft/fix/fix_data_resumption_flow
Fix SUSPEND -> OnSDLAwake -> SUSPEND -> IGN_OFF sequence for resumption data saving
28 files changed, 342 insertions, 65 deletions
diff --git a/src/components/application_manager/CMakeLists.txt b/src/components/application_manager/CMakeLists.txt index 7a49ce6b81..21f92418fe 100644 --- a/src/components/application_manager/CMakeLists.txt +++ b/src/components/application_manager/CMakeLists.txt @@ -324,6 +324,7 @@ set (HMI_COMMANDS_SOURCES ${COMMANDS_SOURCE_DIR}/hmi/on_system_error_notification.cc ${COMMANDS_SOURCE_DIR}/hmi/basic_communication_system_request.cc ${COMMANDS_SOURCE_DIR}/hmi/basic_communication_system_response.cc + ${COMMANDS_SOURCE_DIR}/hmi/basic_communication_on_awake_sdl.cc ${COMMANDS_SOURCE_DIR}/hmi/sdl_policy_update.cc ${COMMANDS_SOURCE_DIR}/hmi/sdl_policy_update_response.cc ${COMMANDS_SOURCE_DIR}/hmi/on_received_policy_update.cc diff --git a/src/components/application_manager/include/application_manager/application.h b/src/components/application_manager/include/application_manager/application.h index fdb0c15922..b753ba0e7f 100644 --- a/src/components/application_manager/include/application_manager/application.h +++ b/src/components/application_manager/include/application_manager/application.h @@ -409,6 +409,20 @@ class Application : public virtual InitialApplicationData, virtual void UpdateHash() = 0; /** + * @brief checks is hashID was changed during suspended state + * @return Returns TRUE if hashID was changed during suspended state + * otherwise returns FALSE. + */ + virtual bool IsHashChangedDuringSuspend() const = 0; + + /** + * @brief changes state of the flag which tracks is hashID was changed during + * suspended state or not + * @param state new state of the flag + */ + virtual void SetHashChangedDuringSuspend(const bool state) = 0; + + /** * @brief method is called when SDL is saving application data for resumption * @return TRUE if data of application need to save for resumption, otherwise * return FALSE diff --git a/src/components/application_manager/include/application_manager/application_impl.h b/src/components/application_manager/include/application_manager/application_impl.h index 3304200372..01963e24e7 100644 --- a/src/components/application_manager/include/application_manager/application_impl.h +++ b/src/components/application_manager/include/application_manager/application_impl.h @@ -198,17 +198,35 @@ class ApplicationImpl : public virtual Application, virtual DataAccessor<ButtonSubscriptions> SubscribedButtons() const OVERRIDE; virtual const std::string& curHash() const; + #ifdef CUSTOMER_PASA + // DEPRECATED virtual bool flag_sending_hash_change_after_awake() const; + // DEPRECATED virtual void set_flag_sending_hash_change_after_awake(bool flag); #endif // CUSTOMER_PASA - /** - * @brief Change Hash for current application - * and send notification to mobile - * @return updated_hash - */ + + /** + * @brief Change Hash for current application + * and send notification to mobile + * @return updated_hash + */ virtual void UpdateHash(); + /** + * @brief checks is hashID was changed during suspended state + * @return Returns TRUE if hashID was changed during suspended state + * otherwise returns FALSE. + */ + bool IsHashChangedDuringSuspend() const OVERRIDE; + + /** + * @brief changes state of the flag which tracks is hashID was changed during + * suspended state or not + * @param state new state of the flag + */ + void SetHashChangedDuringSuspend(const bool state) OVERRIDE; + UsageStatistics& usage_report(); bool AreCommandLimitsExceeded(mobile_apis::FunctionID::eType cmd_id, @@ -432,6 +450,7 @@ class ApplicationImpl : public virtual Application, protocol_handler::MajorProtocolVersion protocol_version_; bool is_voice_communication_application_; sync_primitives::atomic_bool is_resuming_; + bool is_hash_changed_during_suspend_; uint32_t video_stream_retry_number_; uint32_t audio_stream_retry_number_; diff --git a/src/components/application_manager/include/application_manager/commands/hmi/basic_communication_on_awake_sdl.h b/src/components/application_manager/include/application_manager/commands/hmi/basic_communication_on_awake_sdl.h index f789a14780..daa71e68b5 100644 --- a/src/components/application_manager/include/application_manager/commands/hmi/basic_communication_on_awake_sdl.h +++ b/src/components/application_manager/include/application_manager/commands/hmi/basic_communication_on_awake_sdl.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Ford Motor Company + * Copyright (c) 2017, Ford Motor Company * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -29,3 +29,45 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_BASIC_COMMUNICATION_ON_AWAKE_SDL_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_BASIC_COMMUNICATION_ON_AWAKE_SDL_H_ + +#include "application_manager/commands/hmi/notification_from_hmi.h" + +namespace application_manager { + +namespace commands { + +/** + * @brief OnAwakeSDLNotification command class + **/ +class OnAwakeSDLNotification : public NotificationFromHMI { + public: + /** + * @brief OnAwakeSDLNotification class constructor + * @param message Incoming SmartObject message + * @param application_manager reference to ApplicationManager instance + **/ + OnAwakeSDLNotification(const MessageSharedPtr& message, + ApplicationManager& application_manager); + + /** + * @brief OnAwakeSDLNotification class destructor + **/ + virtual ~OnAwakeSDLNotification(); + + /** + * @brief Execute command + **/ + void Run() FINAL; + + private: + DISALLOW_COPY_AND_ASSIGN(OnAwakeSDLNotification); +}; + +} // namespace commands + +} // namespace application_manager + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_COMMANDS_HMI_BASIC_COMMUNICATION_ON_AWAKE_SDL_H_ diff --git a/src/components/application_manager/include/application_manager/commands/hmi/on_exit_all_applications_notification.h b/src/components/application_manager/include/application_manager/commands/hmi/on_exit_all_applications_notification.h index a752e00801..92ef97a4aa 100644 --- a/src/components/application_manager/include/application_manager/commands/hmi/on_exit_all_applications_notification.h +++ b/src/components/application_manager/include/application_manager/commands/hmi/on_exit_all_applications_notification.h @@ -60,7 +60,7 @@ class OnExitAllApplicationsNotification : public NotificationFromHMI { /** * @brief Execute command **/ - virtual void Run(); + void Run() FINAL; private: /** 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..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 @@ -115,11 +115,25 @@ 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 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 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..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 @@ -129,11 +129,25 @@ 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 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 Method stops timer "RsmCtrlPercist" when SDL * receives OnExitAllApplication notification * with reason "SUSPEND" @@ -301,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 @@ -491,6 +511,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/include/application_manager/resumption/resumption_data.h b/src/components/application_manager/include/application_manager/resumption/resumption_data.h index aeb65b32b9..a9954141af 100644 --- a/src/components/application_manager/include/application_manager/resumption/resumption_data.h +++ b/src/components/application_manager/include/application_manager/resumption/resumption_data.h @@ -91,9 +91,27 @@ class ResumptionData { * @brief Increments ignition counter for all registered applications * and remember ign_off time stamp */ + virtual void IncrementIgnOffCount() = 0; + + /** + * @brief Increments ignition counter for all registered applications + * and remember ign_off time stamp + */ + // DEPRECATED virtual void OnSuspend() = 0; /** + * @brief Decrements ignition counter for all registered applications + */ + virtual void DecrementIgnOffCount() = 0; + + /** + * @brief Decrements ignition counter for all registered applications + */ + // DEPRECATED + virtual void OnAwake() = 0; + + /** * @brief Retrieves hash ID for the given mobile app ID * and device ID from stored information. * @param policy_app_id - mobile application id @@ -108,12 +126,6 @@ class ResumptionData { std::string& hash_id) const = 0; /** - * @brief Increments ignition counter for all registered applications - * and remember ign_off time stamp - */ - virtual void OnAwake() = 0; - - /** * @brief Retrieves data of saved application for the given mobile app ID * and device ID * @param policy_app_id - mobile application id diff --git a/src/components/application_manager/include/application_manager/resumption/resumption_data_db.h b/src/components/application_manager/include/application_manager/resumption/resumption_data_db.h index 862816bf87..8cb70274f3 100644 --- a/src/components/application_manager/include/application_manager/resumption/resumption_data_db.h +++ b/src/components/application_manager/include/application_manager/resumption/resumption_data_db.h @@ -113,7 +113,25 @@ class ResumptionDataDB : public ResumptionData { * @brief Increments ignition counter for all registered applications * and remember ign_off time stamp */ - virtual void OnSuspend(); + // DEPRECATED + void OnSuspend() FINAL; + + /** + * @brief Decrements ignition counter for all registered applications + */ + // DEPRECATED + void OnAwake() FINAL; + + /** + * @brief Increments ignition counter for all registered applications + * and remember ign_off time stamp + */ + void IncrementIgnOffCount() FINAL; + + /** + * @brief Decrements ignition counter for all registered applications + */ + void DecrementIgnOffCount() FINAL; /** * @brief Retrieves hash ID for the given mobile app ID @@ -130,12 +148,6 @@ class ResumptionDataDB : public ResumptionData { std::string& hash_id) const; /** - * @brief Decrements ignition counter for all registered applications - * and remember ign_off time stamp - */ - virtual void OnAwake(); - - /** * @brief Retrieves data of saved application for the given mobile app ID * and device ID * @param policy_app_id - mobile application id diff --git a/src/components/application_manager/include/application_manager/resumption/resumption_data_json.h b/src/components/application_manager/include/application_manager/resumption/resumption_data_json.h index 0be6d64db2..4da3441037 100644 --- a/src/components/application_manager/include/application_manager/resumption/resumption_data_json.h +++ b/src/components/application_manager/include/application_manager/resumption/resumption_data_json.h @@ -85,13 +85,25 @@ class ResumptionDataJson : public ResumptionData { * @brief Increments ignition counter for all registered applications * and remember ign_off time stamp */ - virtual void OnSuspend(); + // DEPRECATED + void OnSuspend() FINAL; + + /** + * @brief Decrements ignition counter for all registered applications + */ + // DEPRECATED + void OnAwake() FINAL; /** * @brief Increments ignition counter for all registered applications * and remember ign_off time stamp */ - virtual void OnAwake(); + void IncrementIgnOffCount() FINAL; + + /** + * @brief Decrements ignition counter for all registered applications + */ + void DecrementIgnOffCount() FINAL; /** * @brief Retrieves hash ID for the given mobile app ID diff --git a/src/components/application_manager/src/application_impl.cc b/src/components/application_manager/src/application_impl.cc index 569880bb56..0ba98d67f5 100644 --- a/src/components/application_manager/src/application_impl.cc +++ b/src/components/application_manager/src/application_impl.cc @@ -44,6 +44,7 @@ #include "utils/make_shared.h" #include "utils/timer_task_impl.h" #include "application_manager/policies/policy_handler_interface.h" +#include "application_manager/resumption/resume_ctrl.h" namespace { @@ -111,6 +112,7 @@ ApplicationImpl::ApplicationImpl( protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_3) , is_voice_communication_application_(false) , is_resuming_(false) + , is_hash_changed_during_suspend_(false) , video_stream_retry_number_(0) , audio_stream_retry_number_(0) , video_stream_suspend_timer_( @@ -872,7 +874,19 @@ void ApplicationImpl::UpdateHash() { utils::gen_hash(application_manager_.get_settings().hash_string_size()); set_is_application_data_changed(true); - MessageHelper::SendHashUpdateNotification(app_id(), application_manager_); + if (!application_manager_.resume_controller().is_suspended()) { + MessageHelper::SendHashUpdateNotification(app_id(), application_manager_); + } else { + is_hash_changed_during_suspend_ = true; + } +} + +bool ApplicationImpl::IsHashChangedDuringSuspend() const { + return is_hash_changed_during_suspend_; +} + +void ApplicationImpl::SetHashChangedDuringSuspend(const bool state) { + is_hash_changed_during_suspend_ = state; } void ApplicationImpl::CleanupFiles() { 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/basic_communication_on_awake_sdl.cc b/src/components/application_manager/src/commands/hmi/basic_communication_on_awake_sdl.cc index 80b1edb5bb..c6c550a474 100644 --- a/src/components/application_manager/src/commands/hmi/basic_communication_on_awake_sdl.cc +++ b/src/components/application_manager/src/commands/hmi/basic_communication_on_awake_sdl.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Ford Motor Company + * Copyright (c) 2017, Ford Motor Company * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -29,3 +29,45 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ + +#include "application_manager/commands/hmi/basic_communication_on_awake_sdl.h" +#include "application_manager/message_helper.h" +#include "application_manager/resumption/resume_ctrl.h" + +namespace application_manager { + +namespace commands { + +OnAwakeSDLNotification::OnAwakeSDLNotification( + const MessageSharedPtr& message, ApplicationManager& application_manager) + : NotificationFromHMI(message, application_manager) {} + +OnAwakeSDLNotification::~OnAwakeSDLNotification() {} + +void OnAwakeSDLNotification::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + if (!application_manager_.resume_controller().is_suspended()) { + return; + } + + { + DataAccessor<ApplicationSet> accessor = application_manager_.applications(); + ApplicationSetIt itBegin = accessor.GetData().begin(); + ApplicationSetIt itEnd = accessor.GetData().end(); + for (; itBegin != itEnd; ++itBegin) { + const ApplicationSharedPtr app = *itBegin; + if (app && app->IsHashChangedDuringSuspend()) { + MessageHelper::SendHashUpdateNotification(app->app_id(), + application_manager_); + app->SetHashChangedDuringSuspend(false); + } + } + } + + application_manager_.resume_controller().OnAwake(); +} + +} // namespace commands + +} // namespace application_manager 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..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,6 +75,7 @@ void OnExitAllApplicationsNotification::Run() { break; } case hmi_apis::Common_ApplicationsCloseReason::SUSPEND: { + application_manager_.resume_controller().OnSuspend(); SendOnSDLPersistenceComplete(); return; } diff --git a/src/components/application_manager/src/hmi_command_factory.cc b/src/components/application_manager/src/hmi_command_factory.cc index ffaa8d9b5f..a7f3ce7e6b 100644 --- a/src/components/application_manager/src/hmi_command_factory.cc +++ b/src/components/application_manager/src/hmi_command_factory.cc @@ -269,6 +269,7 @@ #include "application_manager/commands/hmi/on_system_error_notification.h" #include "application_manager/commands/hmi/basic_communication_system_request.h" #include "application_manager/commands/hmi/basic_communication_system_response.h" +#include "application_manager/commands/hmi/basic_communication_on_awake_sdl.h" #include "application_manager/commands/hmi/sdl_policy_update.h" #include "application_manager/commands/hmi/sdl_policy_update_response.h" #include "application_manager/commands/hmi/on_received_policy_update.h" @@ -781,6 +782,11 @@ CommandSharedPtr HMICommandFactory::CreateCommand( message, application_manager)); break; } + case hmi_apis::FunctionID::BasicCommunication_OnAwakeSDL: { + command.reset( + new commands::OnAwakeSDLNotification(message, application_manager)); + break; + } case hmi_apis::FunctionID::BasicCommunication_OnExitApplication: { command.reset(new commands::OnExitApplicationNotification( message, application_manager)); 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..435e621169 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 @@ -263,16 +264,25 @@ bool ResumeCtrlImpl::RemoveApplicationFromSaved( void ResumeCtrlImpl::OnSuspend() { LOG4CXX_AUTO_TRACE(logger_); - StopSavePersistentDataTimer(); - SaveAllApplications(); - resumption_storage_->OnSuspend(); - resumption_storage_->Persist(); + is_suspended_ = true; + FinalPersistData(); +} + +void ResumeCtrlImpl::OnIgnitionOff() { + LOG4CXX_AUTO_TRACE(logger_); + resumption_storage_->IncrementIgnOffCount(); + FinalPersistData(); } void ResumeCtrlImpl::OnAwake() { + LOG4CXX_AUTO_TRACE(logger_); + is_suspended_ = false; ResetLaunchTime(); StartSavePersistentDataTimer(); - return resumption_storage_->OnAwake(); +} + +bool ResumeCtrlImpl::is_suspended() const { + return is_suspended_; } void ResumeCtrlImpl::StartSavePersistentDataTimer() { @@ -433,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_); @@ -774,7 +791,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/src/resumption/resumption_data_db.cc b/src/components/application_manager/src/resumption/resumption_data_db.cc index 08de6d8190..23fecb7624 100644 --- a/src/components/application_manager/src/resumption/resumption_data_db.cc +++ b/src/components/application_manager/src/resumption/resumption_data_db.cc @@ -212,7 +212,10 @@ uint32_t ResumptionDataDB::GetHMIApplicationID( return hmi_app_id; } -void ResumptionDataDB::OnSuspend() { +// DEPRECATED +void ResumptionDataDB::OnSuspend() {} + +void ResumptionDataDB::IncrementIgnOffCount() { LOG4CXX_AUTO_TRACE(logger_); utils::dbms::SQLQuery query_update_suspend_data(db()); @@ -291,7 +294,10 @@ bool ResumptionDataDB::GetHashId(const std::string& policy_app_id, return SelectHashId(policy_app_id, device_id, hash_id); } -void ResumptionDataDB::OnAwake() { +// DEPRECATED +void ResumptionDataDB::OnAwake() {} + +void ResumptionDataDB::DecrementIgnOffCount() { LOG4CXX_AUTO_TRACE(logger_); UpdateDataOnAwake(); diff --git a/src/components/application_manager/src/resumption/resumption_data_json.cc b/src/components/application_manager/src/resumption/resumption_data_json.cc index 7866fc4de1..203c4889c5 100644 --- a/src/components/application_manager/src/resumption/resumption_data_json.cc +++ b/src/components/application_manager/src/resumption/resumption_data_json.cc @@ -143,11 +143,14 @@ uint32_t ResumptionDataJson::GetHMIApplicationID( return hmi_app_id; } -void ResumptionDataJson::OnSuspend() { +// DEPRECATED +void ResumptionDataJson::OnSuspend() {} + +void ResumptionDataJson::IncrementIgnOffCount() { using namespace app_mngr; LOG4CXX_AUTO_TRACE(logger_); sync_primitives::AutoLock autolock(resumption_lock_); - Json::Value to_save; + Json::Value to_save = Json::arrayValue; for (Json::Value::iterator it = GetSavedApplications().begin(); it != GetSavedApplications().end(); ++it) { @@ -167,7 +170,10 @@ void ResumptionDataJson::OnSuspend() { LOG4CXX_DEBUG(logger_, GetResumptionData().toStyledString()); } -void ResumptionDataJson::OnAwake() { +// DEPRECATED +void ResumptionDataJson::OnAwake() {} + +void ResumptionDataJson::DecrementIgnOffCount() { using namespace app_mngr; LOG4CXX_AUTO_TRACE(logger_); sync_primitives::AutoLock autolock(resumption_lock_); 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..03e1187d35 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,16 @@ TEST_F(HMICommandsNotificationsTest, kCorrelationId_; MessageSharedPtr temp_message = CreateMessage(); + resumprion_test::MockResumeCtrl mock_resume_ctrl; + EXPECT_CALL(app_mngr_, resume_controller()) + .WillOnce(ReturnRef(mock_resume_ctrl)); + 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_application.h b/src/components/application_manager/test/include/application_manager/mock_application.h index 9bdfe65cb7..a8c4f96b35 100644 --- a/src/components/application_manager/test/include/application_manager/mock_application.h +++ b/src/components/application_manager/test/include/application_manager/mock_application.h @@ -50,8 +50,12 @@ class MockApplication : public ::application_manager::Application { MOCK_CONST_METHOD0(active_message, const smart_objects::SmartObject*()); MOCK_CONST_METHOD0(curHash, const std::string&()); MOCK_METHOD0(UpdateHash, void()); + // DEPRECATED MOCK_CONST_METHOD0(flag_sending_hash_change_after_awake, bool()); + // DEPRECATED MOCK_METHOD1(set_flag_sending_hash_change_after_awake, void(bool flag)); + MOCK_CONST_METHOD0(IsHashChangedDuringSuspend, bool()); + MOCK_METHOD1(SetHashChangedDuringSuspend, void(const bool flag)); MOCK_CONST_METHOD0(is_application_data_changed, bool()); MOCK_METHOD1(set_is_application_data_changed, void(bool state_application_data)); 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..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 @@ -48,7 +48,9 @@ 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_METHOD0(StopSavePersistentDataTimer, void()); MOCK_METHOD2(StartResumption, bool(app_mngr::ApplicationSharedPtr application, diff --git a/src/components/application_manager/test/include/application_manager/mock_resumption_data.h b/src/components/application_manager/test/include/application_manager/mock_resumption_data.h index 7b16a3bf00..cfec034653 100644 --- a/src/components/application_manager/test/include/application_manager/mock_resumption_data.h +++ b/src/components/application_manager/test/include/application_manager/mock_resumption_data.h @@ -60,11 +60,13 @@ class MockResumptionData : public ::resumption::ResumptionData { uint32_t(const std::string& policy_app_id, const std::string& device_id)); MOCK_METHOD0(OnSuspend, void()); + MOCK_METHOD0(IncrementIgnOffCount, void()); MOCK_CONST_METHOD3(GetHashId, bool(const std::string& policy_app_id, const std::string& device_id, std::string& hash_id)); MOCK_METHOD0(OnAwake, void()); + MOCK_METHOD0(DecrementIgnOffCount, void()); MOCK_CONST_METHOD3(GetSavedApplication, bool(const std::string& policy_app_id, const std::string& device_id, diff --git a/src/components/application_manager/test/resumption/resume_ctrl_test.cc b/src/components/application_manager/test/resumption/resume_ctrl_test.cc index f2fc18ca58..bbb814fb5b 100644 --- a/src/components/application_manager/test/resumption/resume_ctrl_test.cc +++ b/src/components/application_manager/test/resumption/resume_ctrl_test.cc @@ -880,7 +880,7 @@ TEST_F(ResumeCtrlTest, CheckPersistenceFilesForResumption_WithChoiceSet) { // TODO (VVeremjova) APPLINK-16718 TEST_F(ResumeCtrlTest, DISABLED_OnSuspend) { - EXPECT_CALL(*mock_storage_, OnSuspend()); + EXPECT_CALL(*mock_storage_, IncrementIgnOffCount()); res_ctrl_->OnSuspend(); } @@ -896,7 +896,7 @@ TEST_F(ResumeCtrlTest, OnSuspend_EmptyApplicationlist) { ON_CALL(app_mngr_, applications()).WillByDefault(Return(accessor)); EXPECT_CALL(*mock_storage_, SaveApplication(mock_app)).Times(0); - EXPECT_CALL(*mock_storage_, OnSuspend()); + EXPECT_CALL(*mock_storage_, IncrementIgnOffCount()).Times(0); EXPECT_CALL(*mock_storage_, Persist()); res_ctrl_->OnSuspend(); } @@ -906,7 +906,7 @@ TEST_F(ResumeCtrlTest, OnAwake) { EXPECT_CALL(mock_application_manager_settings_, app_resumption_save_persistent_data_timeout()) .WillOnce(ReturnRef(timeout)); - EXPECT_CALL(*mock_storage_, OnAwake()); + EXPECT_CALL(*mock_storage_, DecrementIgnOffCount()).Times(0); res_ctrl_->OnAwake(); } diff --git a/src/components/application_manager/test/resumption/resumption_data_db_test.cc b/src/components/application_manager/test/resumption/resumption_data_db_test.cc index aa4db59eac..cf0ebb7fd2 100644 --- a/src/components/application_manager/test/resumption/resumption_data_db_test.cc +++ b/src/components/application_manager/test/resumption/resumption_data_db_test.cc @@ -728,7 +728,7 @@ TEST_F(ResumptionDataDBTest, OnSuspend) { res_db()->SaveApplication(app_mock); CheckSavedDB(); - res_db()->OnSuspend(); + res_db()->IncrementIgnOffCount(); ign_off_count_++; CheckSavedDB(); } @@ -740,18 +740,18 @@ TEST_F(ResumptionDataDBTest, OnSuspendFourTimes) { res_db()->SaveApplication(app_mock); CheckSavedDB(); - res_db()->OnSuspend(); + res_db()->IncrementIgnOffCount(); ign_off_count_++; CheckSavedDB(); - res_db()->OnSuspend(); + res_db()->IncrementIgnOffCount(); ign_off_count_++; CheckSavedDB(); - res_db()->OnSuspend(); + res_db()->IncrementIgnOffCount(); ign_off_count_++; CheckSavedDB(); - res_db()->OnSuspend(); + res_db()->IncrementIgnOffCount(); ssize_t result = res_db()->IsApplicationSaved(policy_app_id_, kMacAddress_); EXPECT_EQ(-1, result); @@ -765,11 +765,11 @@ TEST_F(ResumptionDataDBTest, OnSuspendOnAwake) { res_db()->SaveApplication(app_mock); CheckSavedDB(); - res_db()->OnSuspend(); + res_db()->IncrementIgnOffCount(); ign_off_count_++; CheckSavedDB(); - res_db()->OnAwake(); + res_db()->DecrementIgnOffCount(); ign_off_count_ = 0; CheckSavedDB(); } @@ -782,7 +782,7 @@ TEST_F(ResumptionDataDBTest, Awake_AppNotSuspended) { res_db()->SaveApplication(app_mock); CheckSavedDB(); - res_db()->OnAwake(); + res_db()->DecrementIgnOffCount(); ign_off_count_ = 0; CheckSavedDB(); } @@ -795,12 +795,12 @@ TEST_F(ResumptionDataDBTest, TwiceAwake_AppNotSuspended) { res_db()->SaveApplication(app_mock); CheckSavedDB(); - res_db()->OnSuspend(); - res_db()->OnAwake(); + res_db()->IncrementIgnOffCount(); + res_db()->DecrementIgnOffCount(); ign_off_count_ = 0; CheckSavedDB(); - res_db()->OnAwake(); + res_db()->DecrementIgnOffCount(); CheckSavedDB(); } @@ -826,14 +826,14 @@ TEST_F(ResumptionDataDBTest, GetIgnOffTime_AfterSuspendAndAwake) { last_ign_off_time = res_db()->GetIgnOffTime(); EXPECT_EQ(0u, last_ign_off_time); - res_db()->OnSuspend(); + res_db()->IncrementIgnOffCount(); uint32_t after_suspend; after_suspend = res_db()->GetIgnOffTime(); EXPECT_LE(last_ign_off_time, after_suspend); uint32_t after_awake; - res_db()->OnAwake(); + res_db()->DecrementIgnOffCount(); after_awake = res_db()->GetIgnOffTime(); EXPECT_LE(after_suspend, after_awake); diff --git a/src/components/application_manager/test/resumption/resumption_data_json_test.cc b/src/components/application_manager/test/resumption/resumption_data_json_test.cc index 834637fa62..e017c39497 100644 --- a/src/components/application_manager/test/resumption/resumption_data_json_test.cc +++ b/src/components/application_manager/test/resumption/resumption_data_json_test.cc @@ -257,7 +257,7 @@ TEST_F(ResumptionDataJsonTest, OnSuspend) { res_json.SaveApplication(app_mock); CheckSavedJson(); - res_json.OnSuspend(); + res_json.IncrementIgnOffCount(); ign_off_count_++; CheckSavedJson(); } @@ -268,13 +268,13 @@ TEST_F(ResumptionDataJsonTest, OnSuspendFourTimes) { res_json.SaveApplication(app_mock); CheckSavedJson(); - res_json.OnSuspend(); + res_json.IncrementIgnOffCount(); ign_off_count_++; CheckSavedJson(); - res_json.OnSuspend(); - res_json.OnSuspend(); - res_json.OnSuspend(); + res_json.IncrementIgnOffCount(); + res_json.IncrementIgnOffCount(); + res_json.IncrementIgnOffCount(); EXPECT_TRUE(-1 != res_json.IsApplicationSaved(policy_app_id_, kMacAddress_)); } @@ -285,11 +285,11 @@ TEST_F(ResumptionDataJsonTest, OnSuspendOnAwake) { res_json.SaveApplication(app_mock); CheckSavedJson(); - res_json.OnSuspend(); + res_json.IncrementIgnOffCount(); ign_off_count_++; CheckSavedJson(); - res_json.OnAwake(); + res_json.DecrementIgnOffCount(); ign_off_count_ = 0; CheckSavedJson(); } @@ -300,7 +300,7 @@ TEST_F(ResumptionDataJsonTest, Awake_AppNotSuspended) { res_json.SaveApplication(app_mock); CheckSavedJson(); - res_json.OnAwake(); + res_json.DecrementIgnOffCount(); ign_off_count_ = 0; CheckSavedJson(); } @@ -311,12 +311,12 @@ TEST_F(ResumptionDataJsonTest, TwiceAwake_AppNotSuspended) { res_json.SaveApplication(app_mock); CheckSavedJson(); - res_json.OnSuspend(); - res_json.OnAwake(); + res_json.IncrementIgnOffCount(); + res_json.DecrementIgnOffCount(); ign_off_count_ = 0; CheckSavedJson(); - res_json.OnAwake(); + res_json.DecrementIgnOffCount(); CheckSavedJson(); } @@ -339,14 +339,14 @@ TEST_F(ResumptionDataJsonTest, GetIgnOffTime_AfterSuspendAndAwake) { last_ign_off_time = res_json.GetIgnOffTime(); EXPECT_EQ(0u, last_ign_off_time); - res_json.OnSuspend(); + res_json.IncrementIgnOffCount(); uint32_t after_suspend; after_suspend = res_json.GetIgnOffTime(); EXPECT_LE(last_ign_off_time, after_suspend); uint32_t after_awake; - res_json.OnAwake(); + res_json.DecrementIgnOffCount(); after_awake = res_json.GetIgnOffTime(); EXPECT_LE(after_suspend, after_awake); diff --git a/src/components/hmi_message_handler/src/messagebroker_adapter.cc b/src/components/hmi_message_handler/src/messagebroker_adapter.cc index abefbe3e24..ff5a6d687e 100644 --- a/src/components/hmi_message_handler/src/messagebroker_adapter.cc +++ b/src/components/hmi_message_handler/src/messagebroker_adapter.cc @@ -108,6 +108,7 @@ void MessageBrokerAdapter::SubscribeTo() { MessageBrokerController::subscribeTo("BasicCommunication.OnUpdateDeviceList"); MessageBrokerController::subscribeTo("BasicCommunication.OnFindApplications"); MessageBrokerController::subscribeTo("BasicCommunication.OnAppActivated"); + MessageBrokerController::subscribeTo("BasicCommunication.OnAwakeSDL"); MessageBrokerController::subscribeTo("BasicCommunication.OnExitApplication"); MessageBrokerController::subscribeTo( "BasicCommunication.OnExitAllApplications"); diff --git a/src/components/remote_control/test/include/mock_application.h b/src/components/remote_control/test/include/mock_application.h index 28f279cdd3..3dc18e29f7 100644 --- a/src/components/remote_control/test/include/mock_application.h +++ b/src/components/remote_control/test/include/mock_application.h @@ -59,8 +59,12 @@ class MockApplication : public ::application_manager::Application { MOCK_CONST_METHOD0(active_message, const smart_objects::SmartObject*()); MOCK_CONST_METHOD0(curHash, const std::string&()); MOCK_METHOD0(UpdateHash, void()); + // DEPRECATED MOCK_CONST_METHOD0(flag_sending_hash_change_after_awake, bool()); + // DEPRECATED MOCK_METHOD1(set_flag_sending_hash_change_after_awake, void(bool flag)); + MOCK_CONST_METHOD0(IsHashChangedDuringSuspend, bool()); + MOCK_METHOD1(SetHashChangedDuringSuspend, void(const bool state)); MOCK_CONST_METHOD0(is_application_data_changed, bool()); MOCK_METHOD1(set_is_application_data_changed, void(bool state_application_data)); |