diff options
author | Kozoriz <kozorizandriy@gmail.com> | 2016-04-11 16:25:05 +0300 |
---|---|---|
committer | Kozoriz <kozorizandriy@gmail.com> | 2016-04-25 12:05:00 +0300 |
commit | 313ed4ba92a5eb75befe9ede65eef5c15dac068c (patch) | |
tree | 797aabe5c8bae6bfd106a7724ed47655e22b14c0 /src/components/application_manager/include/application_manager/resumption | |
parent | 65350ac57da63f3c267d3a27dce05a3752ddbba7 (diff) | |
download | sdl_core-313ed4ba92a5eb75befe9ede65eef5c15dac068c.tar.gz |
Policies and Resumption correctives after removing all singletons
Diffstat (limited to 'src/components/application_manager/include/application_manager/resumption')
4 files changed, 61 insertions, 21 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 a2896a43e8..50cf784485 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 @@ -49,6 +49,7 @@ #include "utils/timer.h" namespace application_manager { +class ApplicationManager; class Application; } @@ -67,7 +68,7 @@ class ResumeCtrl: public app_mngr::event_engine::EventObserver { /** * @brief allows to create ResumeCtrl object */ - ResumeCtrl(); + ResumeCtrl(application_manager::ApplicationManager& application_manager); /** * @brief allows to destroy ResumeCtrl object @@ -159,6 +160,11 @@ class ResumeCtrl: public app_mngr::event_engine::EventObserver { void StopSavePersistentDataTimer(); /** + * @brief Method stops restore_hmi_level_timer_ "RsmCtrlRstore" in OnSuspend() + */ + void StopRestoreHmiLevelTimer(); + + /** * @brief Start timer for resumption applications * Restore D1-D5 data * @param application that is need to be restored @@ -173,8 +179,7 @@ class ResumeCtrl: public app_mngr::event_engine::EventObserver { * @param application that is need to be restored * @return true if it was saved, otherwise return false */ - bool StartResumptionOnlyHMILevel( - app_mngr::ApplicationSharedPtr application); + bool StartResumptionOnlyHMILevel(app_mngr::ApplicationSharedPtr application); /** * @brief Check if there are all files need for resumption @@ -217,7 +222,7 @@ class ResumeCtrl: public app_mngr::event_engine::EventObserver { * @return HMI app ID */ uint32_t GetHMIApplicationID(const std::string& policy_app_id, - const std::string& device_mac) const; + const std::string& device_id) const; /** * @brief SaveDataOnTimer : * Timer callback for persisting ResumptionData each N seconds @@ -277,15 +282,17 @@ class ResumeCtrl: public app_mngr::event_engine::EventObserver { * @param device_id - id of device where application is run */ void OnAppRegistrationStart(const std::string& policy_app_id, - const std::string& device_id); + const std::string& device_id); /** * @brief Notify resume controller about delete new application */ void OnAppRegistrationEnd(); +#ifdef BUILD_TESTS + void set_resumption_storage(utils::SharedPtr<ResumptionData> mock_storage); +#endif // BUILD_TESTS private: - /** * @brief restores saved data of application * @param application contains application for which restores data @@ -356,7 +363,8 @@ class ResumeCtrl: public app_mngr::event_engine::EventObserver { bool CheckIgnCycleRestrictions(const smart_objects::SmartObject& saved_app); - bool DisconnectedJustBeforeIgnOff(const smart_objects::SmartObject& saved_app); + bool DisconnectedJustBeforeIgnOff( + const smart_objects::SmartObject& saved_app); bool CheckAppRestrictions(app_mngr::ApplicationConstSharedPtr application, const smart_objects::SmartObject& saved_app); @@ -379,20 +387,20 @@ class ResumeCtrl: public app_mngr::event_engine::EventObserver { typedef std::pair<uint32_t, uint32_t> application_timestamp; - // std::set<ApplicationSharedPtr> retrieve_application(); + std::set<app_mngr::ApplicationSharedPtr> retrieve_application(); /** * @brief This struct need to map * timestamp and application from correlationID */ struct ResumingApp { - uint32_t old_session_key; // session key is the same as app_id + uint32_t old_session_key; // session key is the same as app_id app_mngr::ApplicationSharedPtr app; }; struct TimeStampComparator { - bool operator() (const application_timestamp& lhs, - const application_timestamp& rhs) const{ + bool operator()(const application_timestamp& lhs, + const application_timestamp& rhs) const { return lhs.second < rhs.second; } }; @@ -442,7 +450,7 @@ class ResumeCtrl: public app_mngr::event_engine::EventObserver { void InsertToTimerQueue(uint32_t app_id, uint32_t time_stamp); - void AddToResumptionTimerQueue(uint32_t app_id); + void AddToResumptionTimerQueue(const uint32_t app_id); void LoadResumeData(); @@ -453,6 +461,21 @@ class ResumeCtrl: public app_mngr::event_engine::EventObserver { */ bool IsAppDataResumptionExpired( const smart_objects::SmartObject& application) const; + /** + * @brief Checks from resume data, if application has been disconnected + * unexpectedly + * @param app Application section from resume data + * @return true, if it has been unexpectedly disconnected, otherwise - false + */ + bool IsUnexpectedlyDisconnected(const smart_objects::SmartObject& app) const; + + /** + * @brief Checks, if application can be resumed + * @param application Application + * @return true, if no restrictions currently, otherwise - false + */ + bool IsResumeAllowed( + const application_manager::ApplicationSharedPtr application) const; /** *@brief Mapping applications to time_stamps @@ -468,6 +491,7 @@ class ResumeCtrl: public app_mngr::event_engine::EventObserver { bool is_data_saved_; time_t launch_time_; utils::SharedPtr<ResumptionData> resumption_storage_; + application_manager::ApplicationManager& application_manager_; }; } // namespace resumption 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 5c4e5ff256..f75e2c443a 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 @@ -35,6 +35,11 @@ #include "smart_objects/smart_object.h" #include "application_manager/application.h" +#include "application_manager/application_manager.h" + +namespace application_manager { + class ApplicationManagerSettings; +} namespace resumption { @@ -52,7 +57,8 @@ class ResumptionData { /** * @brief Constructor of ResumptionData */ - ResumptionData(); + ResumptionData( + const application_manager::ApplicationManager& application_manager); /** * @brief Destructor of ResumptionData @@ -63,7 +69,8 @@ class ResumptionData { * @brief Save application persistent info for future resuming * @param application is application witch need to be saved */ - virtual void SaveApplication(app_mngr::ApplicationSharedPtr application) = 0; + virtual void SaveApplication( + app_mngr::ApplicationSharedPtr application) = 0; /** * @brief Returns HMI level of application from saved data @@ -202,6 +209,7 @@ class ResumptionData { */ virtual void Persist() = 0; protected: + /** * @brief Retrieves of commands from application * @param application contains application of which selection commands @@ -279,8 +287,8 @@ class ResumptionData { ++first; } } - - mutable sync_primitives::Lock resumption_lock_; + mutable sync_primitives::Lock resumption_lock_; + const application_manager::ApplicationManager& application_manager_; }; } // namespace resumption 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 18c9369f2e..962b164134 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 @@ -42,7 +42,10 @@ namespace resumption { /** * @brief Points what structure contains vr commands */ -enum AccessoryVRCommand { kVRCommandFromChoice = 0, kVRCommandFromCommand }; +enum AccessoryVRCommand { + kVRCommandFromChoice = 0, + kVRCommandFromCommand +}; struct ApplicationParams { ApplicationParams(const smart_objects::SmartObject& application); @@ -65,8 +68,10 @@ class ResumptionDataDB : public ResumptionData { public: /** * @brief Constructor of ResumptionDataDB + * @param db_storage show database should be saved in a disk file or in memory */ - ResumptionDataDB(); + ResumptionDataDB( + const application_manager::ApplicationManager& application_manager); /** * @brief allows to destroy ResumptionDataDB object @@ -84,7 +89,8 @@ class ResumptionDataDB : public ResumptionData { * @brief Save application persistent info for future resuming to db * @param application is application which need to be saved */ - virtual void SaveApplication(app_mngr::ApplicationSharedPtr application); + void SaveApplication( + app_mngr::ApplicationSharedPtr application) OVERRIDE; /** * @brief Returns HMI level of application from saved data * @param policy_app_id contains policy id of application 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 3d6d2a16e2..092ac25ea3 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 @@ -48,7 +48,8 @@ class ResumptionDataJson : public ResumptionData { /** * @brief Constructor of ResumptionDataJson */ - ResumptionDataJson(LastState& last_state); + ResumptionDataJson(LastState& last_state, + const application_manager::ApplicationManager& application_manager); /** * @brief allows to destroy ResumptionDataJson object @@ -59,7 +60,8 @@ class ResumptionDataJson : public ResumptionData { * @brief Save application persistent info for future resuming on json format * @param application is application witch need to be saved */ - virtual void SaveApplication(app_mngr::ApplicationSharedPtr application); + virtual void SaveApplication( + app_mngr::ApplicationSharedPtr application) OVERRIDE; /** * @brief Returns HMI level of application from saved data |