summaryrefslogtreecommitdiff
path: root/src/components/application_manager/include/application_manager/resumption
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/application_manager/include/application_manager/resumption')
-rw-r--r--src/components/application_manager/include/application_manager/resumption/resume_ctrl.h49
-rw-r--r--src/components/application_manager/include/application_manager/resumption/resume_ctrl_impl.h135
-rw-r--r--src/components/application_manager/include/application_manager/resumption/resumption_data.h34
-rw-r--r--src/components/application_manager/include/application_manager/resumption/resumption_data_db.h26
-rw-r--r--src/components/application_manager/include/application_manager/resumption/resumption_data_json.h14
-rw-r--r--src/components/application_manager/include/application_manager/resumption/resumption_sql_queries.h13
6 files changed, 227 insertions, 44 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..f9a60c862b 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
@@ -34,14 +34,14 @@
#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_RESUMPTION_RESUME_CTRL_H_
#include <stdint.h>
-#include "utils/shared_ptr.h"
+#include <time.h>
#include "application_manager/resumption/resumption_data.h"
namespace application_manager {
class ApplicationManager;
class Application;
-typedef utils::SharedPtr<Application> ApplicationSharedPtr;
-typedef utils::SharedPtr<const Application> ApplicationConstSharedPtr;
+typedef std::shared_ptr<Application> ApplicationSharedPtr;
+typedef std::shared_ptr<const Application> ApplicationConstSharedPtr;
}
namespace app_mngr = application_manager;
@@ -115,18 +115,48 @@ 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 Method stops timer "RsmCtrlPercist" when SDL
+ * @brief Saves Low Voltage signal timestamp
+ */
+ virtual void SaveLowVoltageTime() = 0;
+
+ /**
+ * @brief Saves Wake Up signal timestamp
+ */
+ virtual void SaveWakeUpTime() = 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 "RsmCtrlPersist" when SDL
* receives OnExitAllApplication notification
* with reason "SUSPEND"
*/
virtual void StopSavePersistentDataTimer() = 0;
/**
+ * @brief Method starts timer "RsmCtrlPersist" when
+ * SDL receives onAwakeSDL notification
+ */
+ virtual void StartSavePersistentDataTimer() = 0;
+
+ /**
* @brief Start timer for resumption applications
* Restore D1-D5 data
* @param application that is need to be restored
@@ -144,6 +174,13 @@ class ResumeCtrl {
app_mngr::ApplicationSharedPtr application) = 0;
/**
+ * @brief Retry resumption of an app if it has been disabled or limited
+ * due to absence of high-bandwidth transport.
+ * @param app_id ID of the app to resume
+ */
+ virtual void RetryResumption(const uint32_t app_id) = 0;
+
+ /**
* @brief Check if there are all files need for resumption
* @param application that is need to be restored
* @return true if it all files exist, otherwise return false
@@ -249,7 +286,9 @@ class ResumeCtrl {
#ifdef BUILD_TESTS
virtual void set_resumption_storage(
- utils::SharedPtr<ResumptionData> mock_storage) = 0;
+ std::shared_ptr<ResumptionData> mock_storage) = 0;
+
+ virtual bool get_resumption_active() const = 0;
#endif // BUILD_TESTS
};
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 b7512df28b..e749118140 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
@@ -33,6 +33,8 @@
#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_RESUMPTION_RESUME_CTRL_IMPL_H_
#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_RESUMPTION_RESUME_CTRL_IMPL_H_
+#include "application_manager/resumption/resume_ctrl.h"
+
#include <stdint.h>
#include <vector>
#include <map>
@@ -46,7 +48,6 @@
#include "smart_objects/smart_object.h"
#include "application_manager/application.h"
#include "application_manager/resumption/resumption_data.h"
-#include "application_manager/resumption/resume_ctrl.h"
#include "utils/timer.h"
namespace resumption {
@@ -129,10 +130,28 @@ 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;
+ void SaveLowVoltageTime() OVERRIDE;
+
+ void SaveWakeUpTime() 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
@@ -141,6 +160,13 @@ class ResumeCtrlImpl : public ResumeCtrl,
void StopSavePersistentDataTimer() OVERRIDE;
/**
+ * @brief Check if all IGNITION OFF and IGNITION ON records
+ * saved in resumption data base
+ * @return True if all records saved, otherwise False
+ */
+ bool CheckIgnCyclesData() const;
+
+ /**
* @brief Method stops restore_hmi_level_timer_ "RsmCtrlRstore" in OnSuspend()
*/
void StopRestoreHmiLevelTimer();
@@ -164,6 +190,13 @@ class ResumeCtrlImpl : public ResumeCtrl,
app_mngr::ApplicationSharedPtr application) OVERRIDE;
/**
+ * @brief Retry resumption of an app if it has been disabled or limited
+ * due to absence of high-bandwidth transport.
+ * @param app_id ID of the app to resume
+ */
+ void RetryResumption(const uint32_t app_id) OVERRIDE;
+
+ /**
* @brief Check if there are all files need for resumption
* @param application that is need to be restored
* @return true if it all files exist, otherwise return false
@@ -279,14 +312,30 @@ class ResumeCtrlImpl : public ResumeCtrl,
* @brief Method starts timer "RsmCtrlPercist" when
* SDL receives onAwakeSDL notification
*/
- void StartSavePersistentDataTimer();
+ void StartSavePersistentDataTimer() OVERRIDE;
#ifdef BUILD_TESTS
void set_resumption_storage(
- utils::SharedPtr<ResumptionData> mock_storage) OVERRIDE;
+ std::shared_ptr<ResumptionData> mock_storage) OVERRIDE;
+
+ bool get_resumption_active() const OVERRIDE;
#endif // BUILD_TESTS
private:
/**
+ * @brief Returns Low Voltage signal timestamp
+ * @return Low Voltage event timestamp if event LOW VOLTAGE event occures
+ * otherwise 0
+ */
+ time_t LowVoltageTime() const;
+
+ /**
+ * @brief Returns Wake Up signal timestamp
+ * @return Wake Up timestamp if Wake Up signal occures
+ * otherwise 0
+ */
+ time_t WakeUpTime() const;
+
+ /**
* @brief restores saved data of application
* @param application contains application for which restores data
* @return true if success, otherwise return false
@@ -301,6 +350,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
@@ -361,11 +416,27 @@ class ResumeCtrlImpl : public ResumeCtrl,
void AddWayPointsSubscription(app_mngr::ApplicationSharedPtr application,
const smart_objects::SmartObject& saved_app);
+ /**
+ * @brief Checks if saved HMI level is allowed for resumption
+ * by Ignition Cycle restrictions
+ * @param saved_app application specific section from backup file
+ * @return True if allowed , otherwise - False
+ */
bool CheckIgnCycleRestrictions(const smart_objects::SmartObject& saved_app);
- bool DisconnectedJustBeforeIgnOff(
- const smart_objects::SmartObject& saved_app);
+ /**
+ * @brief Checks if saved HMI level is allowed for resumption
+ * by Low Voltage restrictions
+ * @param saved_app application specific section from backup file
+ * @return True if allowed , otherwise - False
+ */
+ bool CheckLowVoltageRestrictions(const smart_objects::SmartObject& saved_app);
+ /**
+ * @brief Checks if saved HMI level is applicable for resumption
+ * @param saved_app application specific section from backup file
+ * @return True fs allowed , otherwise - False
+ */
bool CheckAppRestrictions(app_mngr::ApplicationConstSharedPtr application,
const smart_objects::SmartObject& saved_app);
@@ -380,10 +451,38 @@ class ResumeCtrlImpl : public ResumeCtrl,
/**
* @brief CheckDelayAfterIgnOn should check if SDL was started less
- * then N secconds ago. N will be readed from profile.
- * @return true if SDL started N secconds ago, otherwise return false
+ * than N seconds ago. N will be read from profile.
+ * @return true if SDL started N seconds ago, otherwise return false
*/
- bool CheckDelayAfterIgnOn();
+ bool CheckDelayAfterIgnOn() const;
+
+ /**
+ * @brief CheckDelayBeforeIgnOff checks if app was unregistered less
+ * than N seconds before Ignition OFF. N will be read from profile.
+ * @return true if app was disconnected within timeframe of N seconds before
+ * Ignition Off,
+ * otherwise return false
+ */
+ bool CheckDelayBeforeIgnOff(
+ const smart_objects::SmartObject& saved_app) const;
+
+ /**
+ * @brief CheckDelayAfterWakeUp should check if app was registered
+ * during the first N seconds after WakeUp signal. N will be read from
+ * profile.
+ * @return true if app registered within N seconds after WakeUp, otherwise
+ * return false
+ */
+ bool CheckDelayAfterWakeUp() const;
+
+ /**
+ * @brief CheckDelayBeforeLowVoltage checks if app was unregistered within
+ * N seconds before Low Voltage signal. N will be read from profile.
+ * @return true if app was disconnected within timeframe of N seconds before
+ * Low Voltage , otherwise return false
+ */
+ bool CheckDelayBeforeLowVoltage(
+ const smart_objects::SmartObject& saved_app) const;
typedef std::pair<uint32_t, uint32_t> application_timestamp;
@@ -418,7 +517,7 @@ class ResumeCtrlImpl : public ResumeCtrl,
* @brief Get the last ignition off time from LastState
* @return the last ignition off time from LastState
*/
- time_t GetIgnOffTime();
+ time_t GetIgnOffTime() const;
/**
* @brief Setup IgnOff time to LastState
@@ -480,6 +579,19 @@ class ResumeCtrlImpl : public ResumeCtrl,
const application_manager::ApplicationSharedPtr application) const;
/**
+ * @brief Retrieve the HMI level of the app when high-bandwidth transport
+ *isn't available
+ *
+ * The value is configured through smartDeviceLink.ini file
+ *
+ * @param application an instance of the app
+ * @return HMI level that the app is allowed when high-bandwidth transport
+ *isn't available
+ */
+ mobile_apis::HMILevel::eType GetHmiLevelOnLowBandwidthTransport(
+ app_mngr::ApplicationConstSharedPtr application) const;
+
+ /**
*@brief Mapping applications to time_stamps
* wait for timer to resume HMI Level
*
@@ -491,8 +603,11 @@ 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_;
+ time_t low_voltage_time_;
+ time_t wake_up_time_;
+ std::shared_ptr<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 469be2c902..c2634173a5 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
@@ -36,6 +36,7 @@
#include "smart_objects/smart_object.h"
#include "application_manager/application.h"
#include "application_manager/application_manager.h"
+#include "utils/macro.h"
namespace application_manager {
class ApplicationManagerSettings;
@@ -43,7 +44,6 @@ class ApplicationManagerSettings;
namespace resumption {
-namespace smart_objects = NsSmartDeviceLink::NsSmartObjects;
namespace app_mngr = application_manager;
/**
@@ -92,7 +92,29 @@ class ResumptionData {
* @brief Increments ignition counter for all registered applications
* and remember ign_off time stamp
*/
- virtual void OnSuspend() = 0;
+ virtual void IncrementIgnOffCount() = 0;
+
+ /**
+ * @brief Decrements ignition counter for all registered applications
+ */
+ virtual void DecrementIgnOffCount() = 0;
+
+ /**
+ * @brief Increments global ignition on counter
+ * by 1
+ */
+ virtual void IncrementGlobalIgnOnCounter() = 0;
+
+ /**
+ * @brief Get the global ignition on counter
+ * @return the global ignition on counter
+ */
+ virtual uint32_t GetGlobalIgnOnCounter() const = 0;
+
+ /**
+ * @brief Resets global ignition on counter
+ */
+ virtual void ResetGlobalIgnOnCount() = 0;
/**
* @brief Retrieves hash ID for the given mobile app ID
@@ -109,12 +131,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
@@ -266,7 +282,7 @@ class ResumptionData {
++first;
}
}
- mutable sync_primitives::Lock resumption_lock_;
+ mutable sync_primitives::RecursiveLock 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 d08ecc2ae1..2b5a1fdcc9 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
@@ -34,8 +34,8 @@
#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_RESUMPTION_RESUMPTION_DATA_DB_H_
#include "application_manager/resumption/resumption_data.h"
-#include "sql_database.h"
-#include "sql_query.h"
+#include "utils/sqlite_wrapper/sql_database.h"
+#include "utils/sqlite_wrapper/sql_query.h"
namespace resumption {
@@ -55,6 +55,7 @@ struct ApplicationParams {
mobile_apis::HMILevel::eType m_hmi_level;
bool m_is_media_application;
bool m_is_valid;
+ app_mngr::ApplicationSharedPtr app_ptr;
};
/**
@@ -109,11 +110,22 @@ class ResumptionDataDB : public ResumptionData {
virtual uint32_t GetHMIApplicationID(const std::string& policy_app_id,
const std::string& device_id) const;
+ void IncrementGlobalIgnOnCounter() OVERRIDE;
+
+ uint32_t GetGlobalIgnOnCounter() const OVERRIDE;
+
+ void ResetGlobalIgnOnCount() OVERRIDE;
+
/**
* @brief Increments ignition counter for all registered applications
* and remember ign_off time stamp
*/
- virtual void OnSuspend();
+ 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 +142,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
@@ -672,7 +678,7 @@ class ResumptionDataDB : public ResumptionData {
smart_objects::SmartObject& saved_app) const;
/**
- * @brief Selects data from applicationSubscribtionsArray table
+ * @brief Selects data from applicationSubscriptionsArray table
* @param policy_app_id contains mobile application id of application
* @param device_id contains id of device on which is running application
* @param saved_app will contain subscriptions
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..e2418fd033 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
@@ -80,18 +80,16 @@ class ResumptionDataJson : public ResumptionData {
*/
virtual uint32_t GetHMIApplicationID(const std::string& policy_app_id,
const std::string& device_id) const;
-
/**
* @brief Increments ignition counter for all registered applications
* and remember ign_off time stamp
*/
- virtual void OnSuspend();
+ void IncrementIgnOffCount() FINAL;
/**
- * @brief Increments ignition counter for all registered applications
- * and remember ign_off time stamp
+ * @brief Decrements ignition counter for all registered applications
*/
- virtual void OnAwake();
+ void DecrementIgnOffCount() FINAL;
/**
* @brief Retrieves hash ID for the given mobile app ID
@@ -135,6 +133,12 @@ class ResumptionDataJson : public ResumptionData {
*/
virtual uint32_t GetIgnOffTime() const;
+ void IncrementGlobalIgnOnCounter() OVERRIDE;
+
+ uint32_t GetGlobalIgnOnCounter() const OVERRIDE;
+
+ void ResetGlobalIgnOnCount() OVERRIDE;
+
/**
* @brief Checks if saved data have application
* @param policy_app_id - mobile application id
diff --git a/src/components/application_manager/include/application_manager/resumption/resumption_sql_queries.h b/src/components/application_manager/include/application_manager/resumption/resumption_sql_queries.h
index 3f8ca3a416..eee7650697 100644
--- a/src/components/application_manager/include/application_manager/resumption/resumption_sql_queries.h
+++ b/src/components/application_manager/include/application_manager/resumption/resumption_sql_queries.h
@@ -30,8 +30,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_RESUMPTION_RESUMPTION_SQL_QUERY_H_
-#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_RESUMPTION_RESUMPTION_SQL_QUERY_H_
+#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_RESUMPTION_RESUMPTION_SQL_QUERIES_H_
+#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_RESUMPTION_RESUMPTION_SQL_QUERIES_H_
#include <string>
@@ -57,12 +57,15 @@ extern const std::string kUpdateIgnOffCount;
extern const std::string kCountApplicationsIgnOff;
extern const std::string kSelectApplicationsIgnOffCount;
extern const std::string kUpdateSuspendData;
-extern const std::string KUpdateLastIgnOffTime;
+extern const std::string kUpdateLastIgnOffTime;
+extern const std::string kUpdateGlobalIgnOnCount;
+extern const std::string kResetGlobalIgnOnCount;
+extern const std::string kSelectGlobalIgnOnCounter;
extern const std::string kDeleteFile;
extern const std::string kDeleteApplicationFilesArray;
extern const std::string kDeleteSubMenu;
extern const std::string kDeleteApplicationSubMenuArray;
-extern const std::string kDeleteApplicationSubscribtionsArray;
+extern const std::string kDeleteApplicationSubscriptionsArray;
extern const std::string kDeleteImageFromCommands;
extern const std::string kDeleteVrCommands;
extern const std::string kDeleteCommands;
@@ -135,4 +138,4 @@ extern const std::string kSelectSubscribedForWayPoints;
extern const std::string kDeleteSubscribedForWayPoints;
} // namespace resumption
-#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_RESUMPTION_RESUMPTION_SQL_QUERY_H_
+#endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_RESUMPTION_RESUMPTION_SQL_QUERIES_H_