summaryrefslogtreecommitdiff
path: root/src/components/application_manager/test/mock/include/application_manager/resume_ctrl.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/application_manager/test/mock/include/application_manager/resume_ctrl.h')
-rw-r--r--src/components/application_manager/test/mock/include/application_manager/resume_ctrl.h277
1 files changed, 256 insertions, 21 deletions
diff --git a/src/components/application_manager/test/mock/include/application_manager/resume_ctrl.h b/src/components/application_manager/test/mock/include/application_manager/resume_ctrl.h
index 463df0b86..c30df0a7b 100644
--- a/src/components/application_manager/test/mock/include/application_manager/resume_ctrl.h
+++ b/src/components/application_manager/test/mock/include/application_manager/resume_ctrl.h
@@ -1,5 +1,5 @@
-/**
- * Copyright (c) 2013, Ford Motor Company
+/*
+ * Copyright (c) 2015, Ford Motor Company
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -88,7 +88,7 @@ class ResumeCtrl: public event_engine::EventObserver {
* @param application is application witch HMI Level is need to restore
* @return true if success, otherwise return false
*/
- bool RestoreApplicationHMILevel(ApplicationSharedPtr application);
+ bool RestoreAppHMIState(ApplicationSharedPtr application);
/**
* @brief Set application HMI Level as stored in policy
@@ -106,9 +106,8 @@ class ResumeCtrl: public event_engine::EventObserver {
* @param check_policy indicate if policy data consent must be verified
* @return true if success, otherwise return false
*/
- bool SetupHMILevel(ApplicationSharedPtr application,
- mobile_apis::HMILevel::eType hmi_level,
- mobile_apis::AudioStreamingState::eType audio_streaming_state,
+ bool SetAppHMIState(ApplicationSharedPtr application,
+ const mobile_apis::HMILevel::eType hmi_level,
bool check_policy = true);
/**
@@ -127,15 +126,33 @@ class ResumeCtrl: public event_engine::EventObserver {
/**
* @brief Remove application from list of saved applications
- * @param application is application witch need to be removed
+ * @param mobile_app_id application witch need to be removed
* @return return true, if success, otherwise return false
*/
- bool RemoveApplicationFromSaved(ApplicationConstSharedPtr application);
+ bool RemoveApplicationFromSaved(const std::string& mobile_app_id);
/**
* @brief Increments ignition counter for all registered applications
+ * and remember ign_off time stamp
*/
- void IgnitionOff();
+ void Suspend();
+
+ /**
+ * @brief Increments ignition counter for all registered applications
+ * and remember ign_off time stamp
+ */
+ void OnAwake();
+
+ /**
+ * @brief Method starts timer "RsmCtrlPercist" when SDL receives onAwakeSDL notification
+ */
+ void StartSavePersistentDataTimer();
+
+ /**
+ * @brief Method stops timer "RsmCtrlPercist" when SDL receives OnExitAllApplication notification
+ * with reason "SUSPEND"
+ */
+ void StopSavePersistentDataTimer();
/**
* @brief Start timer for resumption applications
@@ -143,7 +160,7 @@ class ResumeCtrl: public event_engine::EventObserver {
* @param application that is need to be restored
* @return true if it was saved, otherwise return false
*/
- bool StartResumption(ApplicationSharedPtr application, uint32_t hash);
+ bool StartResumption(ApplicationSharedPtr application, const std::string& hash);
/**
* @brief Start timer for resumption applications
@@ -165,7 +182,7 @@ class ResumeCtrl: public event_engine::EventObserver {
* @param application that is need to be restored
* @return true if it was saved, otherwise return false
*/
- bool CheckApplicationHash(ApplicationSharedPtr application, uint32_t hash);
+ bool CheckApplicationHash(ApplicationSharedPtr application, const std::string& hash);
/**
* @brief Check if Resume controller have saved application with hmi app id
@@ -192,17 +209,36 @@ class ResumeCtrl: public event_engine::EventObserver {
uint32_t GetHMIApplicationID(const std::string& mobile_app_id);
/**
- * @brief Timer callback function
- *
+ * @brief SaveDataOnTimer :
+ * Timer callback for persisting ResumptionData each N seconds
+ * N gets from property
*/
- void onTimer();
+ void SaveDataOnTimer();
void ClearResumptionInfo();
+ void ApplicationsDataUpdated() {
+ is_data_saved = false;
+ }
+
+ /**
+ * @brief Resume HMI Level and audio streaming state if needed
+ * @param application - application to restore hmi level
+ * and audio streaming state
+ */
+ void StartAppHmiStateResumption(ApplicationSharedPtr application);
+ /**
+ * @brief Update launch_time_ to current
+ */
+ void ResetLaunchTime();
+
private:
+
typedef std::pair<uint32_t, uint32_t> application_timestamp;
+ std::set<ApplicationSharedPtr> retrieve_application();
+
/**
* @brief This struct need to map
* timestamp and application from correlationID
@@ -220,6 +256,12 @@ class ResumeCtrl: public event_engine::EventObserver {
};
/**
+ * @brief geter for launch_time_
+ * @return value of launch_time_
+ */
+ time_t launch_time() const;
+
+ /**
* @brief Check device MAC address
*
* @param application that is need to be restored
@@ -229,9 +271,34 @@ class ResumeCtrl: public event_engine::EventObserver {
*/
bool IsDeviceMacAddressEqual(ApplicationSharedPtr application,
const std::string& saved_device_mac);
+ /**
+ * @brief Get Resumption section of LastState
+ * @return Resumption section of LastState in Json
+ */
+ Json::Value& GetResumptionData();
+ /**
+ * @brief Get applications for resumption of LastState
+ * @return applications for resumption of LastState
+ */
Json::Value& GetSavedApplications();
+ /**
+ * @brief Get the last ignition off time from LastState
+ * @return the last ignition off time from LastState
+ */
+ time_t GetIgnOffTime();
+
+ /**
+ * @brief Setup IgnOff time to LastState
+ * @param ign_off_time - igition off time
+ */
+ void SetLastIgnOffTime(time_t ign_off_time);
+
+ /**
+ * @brief Set applications for resumption to LastState
+ * @parems apps_json applications to write in LastState
+ */
void SetSavedApplication(Json::Value& apps_json);
Json::Value GetApplicationCommands(
@@ -249,21 +316,184 @@ class ResumeCtrl: public event_engine::EventObserver {
Json::Value GetApplicationShow(
ApplicationConstSharedPtr application);
- Json::Value JsonFromSO(
- const NsSmartDeviceLink::NsSmartObjects::SmartObject *so);
+ Json::Value JsonFromSO(const smart_objects::SmartObject *so);
void SendHMIRequest(const hmi_apis::FunctionID::eType& function_id,
const smart_objects::SmartObject* msg_params = NULL,
bool use_events = false);
bool ProcessHMIRequest(
- NsSmartDeviceLink::NsSmartObjects::SmartObject* request = NULL,
+ smart_objects::SmartObjectSPtr request = NULL,
bool use_events = false);
+ void InsertToTimerQueue(uint32_t app_id, uint32_t time_stamp);
+
+ /**
+ * @brief AddFiles allows to add files for the application
+ * which should be resumed
+ *
+ * @param application application which will be resumed
+ *
+ * @param saved_app application specific section from backup file
+ */
+ void AddFiles(ApplicationSharedPtr application, const Json::Value& saved_app);
+
/**
- * @brief Time step to check resumption TIME_OUT
+ * @brief AddSubmenues allows to add sub menues for the application
+ * which should be resumed
+ *
+ * @param application application which will be resumed
+ *
+ * @param saved_app application specific section from backup file
+ */
+ void AddSubmenues(ApplicationSharedPtr application, const Json::Value& saved_app);
+
+ /**
+ * @brief AddCommands allows to add commands for the application
+ * which should be resumed
+ *
+ * @param application application which will be resumed
+ *
+ * @param saved_app application specific section from backup file
+ */
+ void AddCommands(ApplicationSharedPtr application, const Json::Value& saved_app);
+
+ /**
+ * @brief AddChoicesets allows to add choice sets for the application
+ * which should be resumed
+ *
+ * @param application application which will be resumed
+ *
+ * @param saved_app application specific section from backup file
+ */
+ void AddChoicesets(ApplicationSharedPtr application, const Json::Value& saved_app);
+
+ /**
+ * @brief SetGlobalProperties allows to restore global properties.
+ *
+ * @param application application which will be resumed
+ *
+ * @param saved_app application specific section from backup file
+ */
+ void SetGlobalProperties(ApplicationSharedPtr application, const Json::Value& saved_app);
+
+ /**
+ * @brief AddSubscriptions allows to restore subscriptions
+ *
+ * @param application application which will be resumed
+ *
+ * @param saved_app application specific section from backup file
+ */
+ void AddSubscriptions(ApplicationSharedPtr application, const Json::Value& saved_app);
+
+ /**
+ * @brief ProcessHMIRequests allows to process obtained requests.
+ *
+ * @param requests request that should be processed.
+ */
+ void ProcessHMIRequests(const smart_objects::SmartObjectList& requests);
+
+ /**
+ * @brief CheckIcons allows to check application icons
+ *
+ * @param application application under resumtion application
+ *
+ * @param json_object
+ *
+ * @return true in case icons exists, false otherwise
+ */
+ bool CheckIcons(ApplicationSharedPtr application, const Json::Value& json_object);
+
+ /**
+ * @brief GetFromSavedOrAppend allows to get existed record about application
+ * or adds the new one.
+ *
+ * @param mobile_app_id application id.
+ *
+ * @return the reference to the record in applications array.
+ */
+ Json::Value& GetFromSavedOrAppend(const std::string& mobile_app_id);
+
+ /**
+ * @brief CheckIgnCycleRestrictions checks if is needed to resume HMI state
+ * by ign cycle restrictions
+ * @param json_app - saved application
+ * @return true if resumptions allowed, otherwise return false
+ */
+ bool CheckIgnCycleRestrictions(const Json::Value& json_app);
+
+ /**
+ * @brief DisconnectedInLastIgnCycle should check if was connected in prev ign cycle
+ * @param json_app - saved applicationa
+ * @return true if app connected in frep ign_cycle otherwise return false
+ */
+ bool DisconnectedInLastIgnCycle(const Json::Value& json_app);
+
+ /**
+ * @brief DisconnectedJustBeforeIgnOff should check if application
+ * was dissconnected in N secconds delay before ign off.
+ * N will be readed from profile
+ * @param json_app - saved applicationa
+ * @return was dissconnected in N secconds delay before ign off
+ * otherwise return false
+ */
+ bool DisconnectedJustBeforeIgnOff(const Json::Value& json_app);
+
+ /**
+ * @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
+ */
+ bool CheckDelayAfterIgnOn();
+
+ /**
+ * @brief CheckAppRestrictions checks if is needed to resume HMI state
+ * by application type and saved app_level
+ * @param json_app - saved application
+ * @return true if resumptions allowed, otherwise return false
+ */
+ bool CheckAppRestrictions(ApplicationSharedPtr application,
+ const Json::Value& json_app);
+ /**
+ * @brief GetObjectIndex allows to obtain specified obbject index from
+ * applications arrays.
+ *
+ * @param mobile_app_id application id that should be found.
+ *
+ * @return application's index of or -1 if it doesn't exists
+ */
+ int GetObjectIndex(const std::string& mobile_app_id);
+
+ /**
+ * @brief Timer callback for restoring HMI Level
+ *
+ */
+ void ApplicationResumptiOnTimer();
+
+ /*
+ * @brief Loads data on start up
+ */
+ void LoadResumeData();
+
+ /*
+ * @brief Return true if application resumption data is valid,
+ * otherwise false
+ *
+ * @param index application index in the resumption list
*/
- static const uint32_t kTimeStep = 3;
+ bool IsResumptionDataValid(uint32_t index);
+
+ template<typename Iterator>
+ Json::Value Append(Iterator first,
+ Iterator last,
+ const std::string& key,
+ Json::Value& result) {
+ while (first != last) {
+ result[key].append(*first);
+ ++first;
+ }
+ return result;
+ }
/**
* @brief times of IGN_OFF that zombie application have to be saved.
@@ -275,10 +505,15 @@ class ResumeCtrl: public event_engine::EventObserver {
* wait for timer to resume HMI Level
*
*/
- std::multiset<application_timestamp, TimeStampComparator> waiting_for_timer_;
mutable sync_primitives::Lock queue_lock_;
+ sync_primitives::Lock resumtion_lock_;
ApplicationManagerImpl* app_mngr_;
- timer::TimerThread<ResumeCtrl> timer_;
+ timer::TimerThread<ResumeCtrl> save_persistent_data_timer_;
+ timer::TimerThread<ResumeCtrl> restore_hmi_level_timer_;
+ std::vector<uint32_t> waiting_for_timer_;
+ bool is_resumption_active_;
+ bool is_data_saved;
+ time_t launch_time_;
};
} // namespace application_manager