Skip to content

Commit

Permalink
Answer review comments. To be appended
Browse files Browse the repository at this point in the history
  • Loading branch information
AByzhynar committed Jul 24, 2018
1 parent 80532ed commit 93ff02d
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 75 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,20 +124,6 @@ class ResumeCtrl {
*/
virtual void OnAwake() = 0;

/**
* @brief Returns Low Voltage signal timestamp
* @return Low Voltage event timestamp if event LOV VOLTAGE event occures
* otherwise 0
*/
virtual time_t LowVoltageTime() const = 0;

/**
* @brief Returns Wake Up signal timestamp
* @return Wake Up timestamp if Wake Up signal occures
* otherwise 0
*/
virtual time_t WakeUpTime() const = 0;

/**
* @brief Saves Low Voltage signal timestamp
*/
Expand All @@ -148,16 +134,6 @@ class ResumeCtrl {
*/
virtual void SaveWakeUpTime() = 0;

/**
* @brief Resets Low Voltage signal timestamp to zero
*/
virtual void ResetLowVoltageTime() = 0;

/**
* @brief Resets Wake Up signal timestamp to zero
*/
virtual void ResetWakeUpTime() = 0;

/**
* @brief Checks if SDL has already received OnExitAllApplication notification
* with "SUSPEND" reason
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,28 +139,8 @@ class ResumeCtrlImpl : public ResumeCtrl,
*/
void OnAwake() OVERRIDE;

/**
* @brief Returns Low Voltage signal timestamp
* @return Low Voltage event timestamp if event LOV VOLTAGE event occures
* otherwise 0
*/
time_t LowVoltageTime() const OVERRIDE;

/**
* @brief Returns Wake Up signal timestamp
* @return Wake Up timestamp if Wake Up signal occures
* otherwise 0
*/
time_t WakeUpTime() const OVERRIDE;

/**
* @brief Saves Low Voltage signal timestamp
*/
void SaveLowVoltageTime() OVERRIDE;

/**
* @brief Saves Wake Up signal timestamp
*/
void SaveWakeUpTime() OVERRIDE;

/**
Expand Down Expand Up @@ -341,15 +321,29 @@ class ResumeCtrlImpl : public ResumeCtrl,
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 Resets Low Voltage signal timestamp to zero
*/
void ResetLowVoltageTime() OVERRIDE;
void ResetLowVoltageTime();

/**
* @brief Resets Wake Up signal timestamp to zero
*/
void ResetWakeUpTime() OVERRIDE;
void ResetWakeUpTime();

/**
* @brief restores saved data of application
Expand Down Expand Up @@ -436,15 +430,15 @@ class ResumeCtrlImpl : public ResumeCtrl,
* @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 is allowed , othrwise - False
* @return True if allowed , otherwise - False
*/
bool CheckIgnCycleRestrictions(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 is allowed , othrwise - False
* @return True if allowed , otherwise - False
*/
bool CheckLowVoltageRestrictions(const smart_objects::SmartObject& saved_app);

Expand All @@ -454,7 +448,7 @@ class ResumeCtrlImpl : public ResumeCtrl,
/**
* @brief Checks if saved HMI level is applicable for resumption
* @param saved_app application specific section from backup file
* @return True is allowed , othrwise - False
* @return True fs allowed , otherwise - False
*/
bool CheckAppRestrictions(app_mngr::ApplicationConstSharedPtr application,
const smart_objects::SmartObject& saved_app);
Expand All @@ -473,7 +467,7 @@ class ResumeCtrlImpl : public ResumeCtrl,
* then 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
Expand All @@ -482,23 +476,25 @@ class ResumeCtrlImpl : public ResumeCtrl,
* Ignition Off,
* otherwise return false
*/
bool CheckDelayBeforeIgnOff(const smart_objects::SmartObject& saved_app);
bool CheckDelayBeforeIgnOff(
const smart_objects::SmartObject& saved_app) const;

/**
* @brief CheckDelayAfterWakeUp should check if app was registered
* during 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();
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);
bool CheckDelayBeforeLowVoltage(
const smart_objects::SmartObject& saved_app) const;

typedef std::pair<uint32_t, uint32_t> application_timestamp;

Expand Down Expand Up @@ -533,7 +529,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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2613,13 +2613,13 @@ void ApplicationManagerImpl::UnregisterApplication(

return;
}
if (!IsLowVoltage()) {
if (is_resuming) {
resume_controller().SaveApplication(app_to_remove);
} else {
resume_controller().RemoveApplicationFromSaved(app_to_remove);
}

if (is_resuming) {
resume_controller().SaveApplication(app_to_remove);
} else {
resume_controller().RemoveApplicationFromSaved(app_to_remove);
}

(hmi_capabilities_->get_hmi_language_handler())
.OnUnregisterApplication(app_id);
AppV4DevicePredicate finder(handle);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,13 @@ void ResumeCtrlImpl::SaveAllApplications() {
void ResumeCtrlImpl::SaveApplication(ApplicationSharedPtr application) {
LOG4CXX_AUTO_TRACE(logger_);
DCHECK_OR_RETURN_VOID(application);
LOG4CXX_INFO(logger_,
"application with appID " << application->app_id()
<< " will be saved");
if (application_manager_.IsLowVoltage()) {
LOG4CXX_DEBUG(logger_, "Low Voltage state is active");
return;
}
LOG4CXX_DEBUG(logger_,
"application with appID " << application->app_id()
<< " will be saved");
resumption_storage_->SaveApplication(application);
}

Expand Down Expand Up @@ -313,6 +317,10 @@ uint32_t ResumeCtrlImpl::GetHMIApplicationID(

bool ResumeCtrlImpl::RemoveApplicationFromSaved(
ApplicationConstSharedPtr application) {
if (application_manager_.IsLowVoltage()) {
LOG4CXX_DEBUG(logger_, "Low Voltage state is active");
return false;
}
const std::string& device_mac = application->mac_address();
return resumption_storage_->RemoveApplicationFromSaved(
application->policy_app_id(), device_mac);
Expand Down Expand Up @@ -767,12 +775,12 @@ bool ResumeCtrlImpl::CheckIgnCycleRestrictions(
LOG4CXX_AUTO_TRACE(logger_);

if (!CheckDelayAfterIgnOn()) {
LOG4CXX_INFO(logger_, "Application was connected long after ign on");
LOG4CXX_DEBUG(logger_, "Application was connected long after ign on");
return false;
}

if (!CheckDelayBeforeIgnOff(saved_app)) {
LOG4CXX_INFO(logger_, "Application was disconnected long before ign off");
LOG4CXX_DEBUG(logger_, "Application was disconnected long before ign off");
return false;
}
return true;
Expand All @@ -783,17 +791,17 @@ bool ResumeCtrlImpl::CheckLowVoltageRestrictions(
LOG4CXX_AUTO_TRACE(logger_);

if (!CheckDelayBeforeLowVoltage(saved_app)) {
LOG4CXX_INFO(logger_,
"Application was disconnected long before low voltage");
LOG4CXX_DEBUG(logger_,
"Application was disconnected long before low voltage");
return false;
}

if (!CheckDelayAfterWakeUp()) {
LOG4CXX_INFO(logger_, "Application was connected long after wake up");
LOG4CXX_DEBUG(logger_, "Application was connected long after wake up");
return false;
}

LOG4CXX_INFO(logger_, "HMI Level resuming in not restricted by Low Voltage");
LOG4CXX_DEBUG(logger_, "HMI Level resuming in not restricted by Low Voltage");
return true;
}

Expand Down Expand Up @@ -821,7 +829,7 @@ DEPRECATED bool ResumeCtrlImpl::DisconnectedJustBeforeIgnOff(
}

bool ResumeCtrlImpl::CheckDelayBeforeIgnOff(
const smart_objects::SmartObject& saved_app) {
const smart_objects::SmartObject& saved_app) const {
using namespace date_time;
LOG4CXX_AUTO_TRACE(logger_);
DCHECK_OR_RETURN(saved_app.keyExists(strings::time_stamp), false);
Expand Down Expand Up @@ -857,7 +865,7 @@ bool ResumeCtrlImpl::CheckDelayBeforeIgnOff(
}

bool ResumeCtrlImpl::CheckDelayBeforeLowVoltage(
const smart_objects::SmartObject& saved_app) {
const smart_objects::SmartObject& saved_app) const {
using namespace date_time;
LOG4CXX_AUTO_TRACE(logger_);
DCHECK_OR_RETURN(saved_app.keyExists(strings::time_stamp), false);
Expand Down Expand Up @@ -896,7 +904,7 @@ bool ResumeCtrlImpl::CheckDelayBeforeLowVoltage(
return secs_between_app_disconnect_and_low_voltage <= wait_time;
}

bool ResumeCtrlImpl::CheckDelayAfterWakeUp() {
bool ResumeCtrlImpl::CheckDelayAfterWakeUp() const {
using namespace date_time;
LOG4CXX_AUTO_TRACE(logger_);

Expand Down Expand Up @@ -965,15 +973,16 @@ bool ResumeCtrlImpl::CheckIgnCyclesData() const {
const uint32_t global_ign_on_count =
resumption_storage_->GetGlobalIgnOnCounter();
const uint32_t diff = global_ign_on_count - global_ign_off_count;
if (diff >= 2) {
const bool is_ign_off_record_missed = diff >= 2;
if (is_ign_off_record_missed) {
LOG4CXX_WARN(logger_,
"Some IGN OFF records missed. Possibly due to Low Voltage");
return false;
}
return true;
}

bool ResumeCtrlImpl::CheckDelayAfterIgnOn() {
bool ResumeCtrlImpl::CheckDelayAfterIgnOn() const {
using namespace date_time;
LOG4CXX_AUTO_TRACE(logger_);
const time_t ign_off_time = GetIgnOffTime();
Expand Down Expand Up @@ -1001,7 +1010,7 @@ time_t ResumeCtrlImpl::LaunchTime() const {
return launch_time_;
}

time_t ResumeCtrlImpl::GetIgnOffTime() {
time_t ResumeCtrlImpl::GetIgnOffTime() const {
return resumption_storage_->GetIgnOffTime();
}

Expand Down

0 comments on commit 93ff02d

Please # to comment.