diff options
author | JackLivio <jack@livio.io> | 2019-11-07 14:09:25 -0500 |
---|---|---|
committer | JackLivio <jack@livio.io> | 2019-11-07 14:09:25 -0500 |
commit | c872d7a5a128b3b8fc70ef6e4d6e179ef0d3f92f (patch) | |
tree | 26f3ab2b6c4754a14ffe0e79437d8bde5b7d915b | |
parent | 043655b8f902b029256d1bab1a2fbd8f375e7e55 (diff) | |
download | sdl_core-fix/resolve_conflicting_app_resumption.tar.gz |
Add check for number of restored widget windowsfix/resolve_conflicting_app_resumption
4 files changed, 12 insertions, 9 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 11b1bcf926..9cbdc5d422 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 @@ -115,7 +115,7 @@ class ResumeCtrl { * @param saved_app application specific section from backup file * @return true if widgets resumed successfully otherwise - false */ - virtual void RestoreAppWidgets( + virtual size_t RestoreAppWidgets( application_manager::ApplicationSharedPtr application, const smart_objects::SmartObject& saved_app) = 0; 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 5e6fb58671..f0d5dc39e4 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 @@ -124,8 +124,9 @@ class ResumeCtrlImpl : public ResumeCtrl, * @param application application which will be resumed * @param saved_app application specific section from backup file */ - void RestoreAppWidgets(application_manager::ApplicationSharedPtr application, - const smart_objects::SmartObject& saved_app) OVERRIDE; + size_t RestoreAppWidgets( + application_manager::ApplicationSharedPtr application, + const smart_objects::SmartObject& saved_app) OVERRIDE; /** * @brief Remove application from list of saved applications 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 c7ca878a2b..98a0542d0c 100644 --- a/src/components/application_manager/src/resumption/resume_ctrl_impl.cc +++ b/src/components/application_manager/src/resumption/resume_ctrl_impl.cc @@ -216,13 +216,14 @@ bool ResumeCtrlImpl::RestoreAppHMIState(ApplicationSharedPtr application) { } const bool app_hmi_state_is_set = SetAppHMIState(application, saved_hmi_level, true); + size_t restored_widgets = 0; if (app_hmi_state_is_set && application->is_app_data_resumption_allowed()) { - RestoreAppWidgets(application, saved_app); + restored_widgets = RestoreAppWidgets(application, saved_app); } const bool does_app_with_same_level_exist = application_manager_.IsAppTypeExistsInFullOrLimited(application); - if (does_app_with_same_level_exist) { + if (does_app_with_same_level_exist && restored_widgets == 0) { LOG4CXX_DEBUG( logger_, "App of same type exists in full or limited. Do no resume"); @@ -406,7 +407,7 @@ bool ResumeCtrlImpl::SetAppHMIState( return true; } -void ResumeCtrlImpl::RestoreAppWidgets( +size_t ResumeCtrlImpl::RestoreAppWidgets( application_manager::ApplicationSharedPtr application, const smart_objects::SmartObject& saved_app) { using namespace mobile_apis; @@ -414,7 +415,7 @@ void ResumeCtrlImpl::RestoreAppWidgets( DCHECK(application); if (!saved_app.keyExists(strings::windows_info)) { LOG4CXX_ERROR(logger_, "windows_info section does not exist"); - return; + return 0; } const auto& windows_info = saved_app[strings::windows_info]; auto request_list = MessageHelper::CreateUICreateWindowRequestsToHMI( @@ -426,6 +427,7 @@ void ResumeCtrlImpl::RestoreAppWidgets( (*request)[strings::params][strings::correlation_id].asInt(), request)); } ProcessHMIRequests(request_list); + return request_list.size(); } bool ResumeCtrlImpl::IsHMIApplicationIdExist(uint32_t hmi_app_id) { diff --git a/src/components/application_manager/test/include/application_manager/mock_resume_ctrl.h b/src/components/application_manager/test/include/application_manager/mock_resume_ctrl.h index 56c2ae3cd4..b657f0e86b 100644 --- a/src/components/application_manager/test/include/application_manager/mock_resume_ctrl.h +++ b/src/components/application_manager/test/include/application_manager/mock_resume_ctrl.h @@ -102,8 +102,8 @@ class MockResumeCtrl : public resumption::ResumeCtrl { MOCK_CONST_METHOD0(LaunchTime, time_t()); MOCK_METHOD2(RestoreAppWidgets, - void(app_mngr::ApplicationSharedPtr application, - const smart_objects::SmartObject& saved_app)); + size_t(app_mngr::ApplicationSharedPtr application, + const smart_objects::SmartObject& saved_app)); MOCK_METHOD1(RestoreWidgetsHMIState, void(const smart_objects::SmartObject& response_message)); |