summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhdanovP <pzhdanov@luxoft.com>2018-09-08 13:35:58 +0300
committerAndriy Byzhynar <abyzhynar@luxoft.com>2018-09-17 16:58:33 +0300
commit76970cd22064a45b80820762e7430b6e58fa614d (patch)
tree4b2c11b841b32fd577609535e8217097ba367c5c
parent4b80f932ffea8b0149214ca8aa9f77765428b21f (diff)
downloadsdl_core-76970cd22064a45b80820762e7430b6e58fa614d.tar.gz
Revert restored data during timeout handling
-rw-r--r--src/components/application_manager/include/application_manager/resumption/resume_ctrl.h7
-rw-r--r--src/components/application_manager/include/application_manager/resumption/resume_ctrl_impl.h2
-rw-r--r--src/components/application_manager/include/application_manager/resumption/resumption_data_processor.h6
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_request.h1
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc34
-rw-r--r--src/components/application_manager/src/resumption/resume_ctrl_impl.cc5
-rw-r--r--src/components/application_manager/src/resumption/resumption_data_processor.cc5
7 files changed, 39 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 fb42b1bd11..370caffc75 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
@@ -173,6 +173,13 @@ class ResumeCtrl {
virtual bool StartResumption(app_mngr::ApplicationSharedPtr application,
const std::string& hash,
ResumptionCallBack callback) = 0;
+
+ /**
+ * @brief Handle restored data when timeout appeared
+ * @param application id - const int32_t
+ */
+ virtual void HandleOnTimeOut(const int32_t app_id) = 0;
+
/**
* @brief Start timer for resumption applications
* Does not restore D1-D5 data
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 7596284435..59a1683755 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
@@ -163,6 +163,8 @@ class ResumeCtrlImpl : public ResumeCtrl {
const std::string& hash,
ResumptionCallBack callback) OVERRIDE;
+ void HandleOnTimeOut(const int32_t app_id) OVERRIDE;
+
/**
* @brief Start timer for resumption applications
* Does not restore D1-D5 data
diff --git a/src/components/application_manager/include/application_manager/resumption/resumption_data_processor.h b/src/components/application_manager/include/application_manager/resumption/resumption_data_processor.h
index 6547bf49f3..0e9a5cb242 100644
--- a/src/components/application_manager/include/application_manager/resumption/resumption_data_processor.h
+++ b/src/components/application_manager/include/application_manager/resumption/resumption_data_processor.h
@@ -96,6 +96,12 @@ class ResumptionDataProcessor : public app_mngr::event_engine::EventObserver {
*/
void on_event(const app_mngr::event_engine::Event& event) OVERRIDE;
+ /**
+ * @brief Handle restored data when timeout appeared
+ * @param application id - const int32_t
+ */
+ void HandleOnTimeOut(const int32_t app_id);
+
private:
/**
* @brief Revert the data to the state before Resumption
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_request.h
index 6e21a0416a..95b7547a54 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_request.h
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_request.h
@@ -297,6 +297,7 @@ class RegisterAppInterfaceRequest
*/
void CheckLanguage();
+ application_manager::ApplicationSharedPtr application_;
bool is_data_resumption_;
std::string response_info_;
mobile_apis::Result::eType result_code_;
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc
index 133ea2c5ea..2a34ee880c 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc
@@ -184,6 +184,7 @@ RegisterAppInterfaceRequest::RegisterAppInterfaceRequest(
rpc_service,
hmi_capabilities,
policy_handler)
+ , application_(nullptr)
, is_data_resumption_(false)
, result_code_(mobile_apis::Result::INVALID_ENUM) {}
@@ -428,6 +429,8 @@ void RegisterAppInterfaceRequest::onTimeOut() {
app_mngr::commands::CommandRequestImpl::onTimeOut();
return;
}
+ auto& resume_ctrl = application_manager_.resume_controller();
+ resume_ctrl.HandleOnTimeOut(application_->app_id());
result_code_ = mobile_api::Result::RESUME_FAILED;
const std::string info = "HMI does not respond during timeout.";
SendRegisterAppInterfaceResponseToMobile(
@@ -526,16 +529,6 @@ void RegisterAppInterfaceRequest::Run() {
return;
}
- uint16_t major =
- msg_params[strings::sync_msg_version][strings::major_version].asUInt();
- uint16_t minor =
- msg_params[strings::sync_msg_version][strings::minor_version].asUInt();
- uint16_t patch = 0;
- // Check if patch exists since it is not mandatory.
- if (msg_params[strings::sync_msg_version].keyExists(strings::patch_version)) {
- patch =
- msg_params[strings::sync_msg_version][strings::patch_version].asUInt();
- }
utils::SemanticVersion mobile_version(major, minor, patch);
utils::SemanticVersion min_module_version(
@@ -547,29 +540,29 @@ void RegisterAppInterfaceRequest::Run() {
SendResponse(false, mobile_apis::Result::REJECTED);
}
- application = application_manager_.RegisterApplication(message_);
+ application_ = application_manager_.RegisterApplication(message_);
- if (!application) {
+ if (!application_) {
LOG4CXX_ERROR(logger_, "Application hasn't been registered!");
return;
}
- FillApplicationParams(application);
+ FillApplicationParams(application_);
- SetupAppDeviceInfo(application);
+ SetupAppDeviceInfo(application_);
const auto resume_data_result = ApplicationDataShouldBeResumed();
SendOnAppRegisteredNotificationToHMI(
- *application, resume_data_result == DataResumeResult::RESUME_DATA);
+ *application_, resume_data_result == DataResumeResult::RESUME_DATA);
// By default app subscribed to CUSTOM_BUTTON
SendSubscribeCustomButtonNotification();
- SendChangeRegistrationOnHMI(application);
+ SendChangeRegistrationOnHMI(application_);
std::function<void(plugin_manager::RPCPlugin&)> on_app_registered =
- [application](plugin_manager::RPCPlugin& plugin) {
+ [this](plugin_manager::RPCPlugin& plugin) {
plugin.OnApplicationEvent(plugin_manager::kApplicationRegistered,
- application);
+ application_);
};
application_manager_.GetPluginManager().ForEachPlugin(on_app_registered);
@@ -595,7 +588,6 @@ void RegisterAppInterfaceRequest::Run() {
if (mobile_apis::Result::INVALID_ENUM == result_code_) {
result_code_ = mobile_apis::Result::SUCCESS;
}
-
if (DataResumeResult::WRONG_HASH == resume_data_result) {
add_info = "Hash from RAI does not match to saved resume data.";
result_code_ = mobile_apis::Result::RESUME_FAILED;
@@ -613,9 +605,9 @@ void RegisterAppInterfaceRequest::Run() {
SendRegisterAppInterfaceResponseToMobile(
ApplicationType::kNewApplication, add_info, need_to_restore_vr);
smart_objects::SmartObjectSPtr so =
- GetLockScreenIconUrlNotification(connection_key(), application);
+ GetLockScreenIconUrlNotification(connection_key(), application_);
rpc_service_.ManageMobileCommand(so, SOURCE_SDL);
- application_manager_.SendDriverDistractionState(application);
+ application_manager_.SendDriverDistractionState(application_);
}
smart_objects::SmartObjectSPtr
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 3d22b8f987..adb8a812d9 100644
--- a/src/components/application_manager/src/resumption/resume_ctrl_impl.cc
+++ b/src/components/application_manager/src/resumption/resume_ctrl_impl.cc
@@ -411,6 +411,11 @@ bool ResumeCtrlImpl::StartResumption(ApplicationSharedPtr application,
return result;
}
+void ResumeCtrlImpl::HandleOnTimeOut(const int32_t app_id) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ resumption_data_processor_.HandleOnTimeOut(app_id);
+}
+
bool ResumeCtrlImpl::StartResumptionOnlyHMILevel(
ApplicationSharedPtr application) {
// sync_primitives::AutoLock lock(resumtion_lock_);
diff --git a/src/components/application_manager/src/resumption/resumption_data_processor.cc b/src/components/application_manager/src/resumption/resumption_data_processor.cc
index 7a882660b2..994354fdae 100644
--- a/src/components/application_manager/src/resumption/resumption_data_processor.cc
+++ b/src/components/application_manager/src/resumption/resumption_data_processor.cc
@@ -76,6 +76,11 @@ bool ResumptionRequestIDs::operator<(const ResumptionRequestIDs& other) const {
function_id < other.function_id;
}
+void ResumptionDataProcessor::HandleOnTimeOut(const int32_t app_id) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ RevertRestoredData(application_manager_.application(app_id));
+}
+
void ResumptionDataProcessor::on_event(const event_engine::Event& event) {
LOG4CXX_AUTO_TRACE(logger_);
const smart_objects::SmartObject& response = event.smart_object();