From 93d12eb664afd667379741fabda47d177893bbb9 Mon Sep 17 00:00:00 2001 From: "Yana Chernysheva (GitHub)" <59469418+ychernysheva@users.noreply.github.com> Date: Thu, 22 Oct 2020 21:50:27 +0300 Subject: Fix application activation after resumption (#3550) * Set is_resuming flag to false * Change return value in RestoreAppHMIState and StartAppHmiStateResumption --- .../application_manager/resumption/resume_ctrl.h | 5 ++-- .../resumption/resume_ctrl_impl.h | 6 ++--- .../src/resumption/resume_ctrl_impl.cc | 28 +++++++++------------- .../include/application_manager/mock_resume_ctrl.h | 4 ++-- .../test/resumption/resume_ctrl_test.cc | 3 +-- 5 files changed, 18 insertions(+), 28 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 d945df6154..456eccd29c 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 @@ -84,9 +84,8 @@ class ResumeCtrl { /** * @brief Set application HMI Level and ausio_state as saved * @param application is application witch HMI Level is need to restore - * @return true if success, otherwise return false */ - virtual bool RestoreAppHMIState( + virtual void RestoreAppHMIState( application_manager::ApplicationSharedPtr application) = 0; /** @@ -255,7 +254,7 @@ class ResumeCtrl { * @param application - application to restore hmi level * and audio streaming state */ - virtual bool StartAppHmiStateResumption( + virtual void StartAppHmiStateResumption( application_manager::ApplicationSharedPtr application) = 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 379b25d8d4..9c529b5f9a 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 @@ -83,9 +83,8 @@ class ResumeCtrlImpl : public ResumeCtrl { /** * @brief Set application HMI Level and ausio_state as saved * @param application is application witch HMI Level is need to restore - * @return true if success, otherwise return false */ - bool RestoreAppHMIState(app_mngr::ApplicationSharedPtr application) OVERRIDE; + void RestoreAppHMIState(app_mngr::ApplicationSharedPtr application) OVERRIDE; /** * @brief Set application HMI Level as stored in policy @@ -234,9 +233,8 @@ class ResumeCtrlImpl : public ResumeCtrl { * @brief Resume HMI Level and audio streaming state if needed * @param application - application to restore hmi level * and audio streaming state - * @return true if success otherwise false */ - bool StartAppHmiStateResumption( + void StartAppHmiStateResumption( app_mngr::ApplicationSharedPtr application) OVERRIDE; /** 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 545560c132..6a045fda03 100644 --- a/src/components/application_manager/src/resumption/resume_ctrl_impl.cc +++ b/src/components/application_manager/src/resumption/resume_ctrl_impl.cc @@ -161,10 +161,10 @@ void ResumeCtrlImpl::SaveApplication(ApplicationSharedPtr application) { resumption_storage_->SaveApplication(application); } -bool ResumeCtrlImpl::RestoreAppHMIState(ApplicationSharedPtr application) { +void ResumeCtrlImpl::RestoreAppHMIState(ApplicationSharedPtr application) { using namespace mobile_apis; SDL_LOG_AUTO_TRACE(); - DCHECK_OR_RETURN(application, false); + DCHECK(application); SDL_LOG_DEBUG("app_id : " << application->app_id() << "; policy_app_id : " << application->policy_app_id()); const std::string& device_mac = application->mac_address(); @@ -172,7 +172,6 @@ bool ResumeCtrlImpl::RestoreAppHMIState(ApplicationSharedPtr application) { bool result = resumption_storage_->GetSavedApplication( application->policy_app_id(), device_mac, saved_app); if (result) { - DCHECK_OR_RETURN(application, false); if (saved_app.keyExists(strings::hmi_level)) { HMILevel::eType saved_hmi_level; if (HMILevel::eType::INVALID_ENUM != @@ -209,16 +208,14 @@ bool ResumeCtrlImpl::RestoreAppHMIState(ApplicationSharedPtr application) { SetAppHMIState(application, saved_hmi_level, true); if (app_exists_in_full_or_limited) { SDL_LOG_DEBUG("App exists in full or limited. Do not resume"); - return false; + return; } } else { - result = false; SDL_LOG_ERROR("saved app data corrupted"); } } else { SDL_LOG_ERROR("Application not saved"); } - return result; } void ResumeCtrlImpl::ProcessSystemCapabilityUpdated( @@ -264,9 +261,8 @@ void ResumeCtrlImpl::ApplicationResumptiOnTimer() { SDL_LOG_ERROR("Invalid app_id = " << *it); continue; } - if (!StartAppHmiStateResumption(app)) { - app->set_is_resuming(false); - } + StartAppHmiStateResumption(app); + app->set_is_resuming(false); } is_resumption_active_ = false; waiting_for_timer_.clear(); @@ -494,18 +490,18 @@ void ResumeCtrlImpl::RetryResumption(const uint32_t app_id) { AddToResumptionTimerQueue(app_id); } -bool ResumeCtrlImpl::StartAppHmiStateResumption( +void ResumeCtrlImpl::StartAppHmiStateResumption( ApplicationSharedPtr application) { using namespace date_time; SDL_LOG_AUTO_TRACE(); - DCHECK_OR_RETURN(application, false); + DCHECK(application); smart_objects::SmartObject saved_app; const std::string& device_mac = application->mac_address(); const bool get_saved_app_result = resumption_storage_->GetSavedApplication( application->policy_app_id(), device_mac, saved_app); if (!get_saved_app_result) { SDL_LOG_ERROR("Application was not saved"); - return false; + return; } const bool is_hmi_level_applicable_to_resume = @@ -513,7 +509,7 @@ bool ResumeCtrlImpl::StartAppHmiStateResumption( if (!is_hmi_level_applicable_to_resume) { SDL_LOG_DEBUG("No applicable HMI level found for resuming"); - return false; + return; } const bool is_resume_allowed_by_low_voltage = CheckLowVoltageRestrictions(saved_app); @@ -531,19 +527,17 @@ bool ResumeCtrlImpl::StartAppHmiStateResumption( if (restore_hmi_level_allowed) { SDL_LOG_INFO("Resume application " << application->policy_app_id()); - const bool hmi_state_restore_result = RestoreAppHMIState(application); + RestoreAppHMIState(application); if (mobile_apis::HMILevel::eType::INVALID_ENUM != application->deferred_resumption_hmi_level()) { // the application has not been fully resumed - return false; + return; } RemoveApplicationFromSaved(application); - return hmi_state_restore_result; } else { SDL_LOG_INFO("Do not need to resume application " << application->policy_app_id()); } - return true; } void ResumeCtrlImpl::ResetLaunchTime() { 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 6b2d31f72f..c2c02a1d0c 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 @@ -96,11 +96,11 @@ class MockResumeCtrl : public resumption::ResumeCtrl { MOCK_CONST_METHOD2(GetSavedAppHmiLevel, int32_t(const std::string&, const std::string&)); MOCK_METHOD1(RestoreAppHMIState, - bool(application_manager::ApplicationSharedPtr application)); + void(application_manager::ApplicationSharedPtr application)); MOCK_METHOD1(SetupDefaultHMILevel, bool(application_manager::ApplicationSharedPtr application)); MOCK_METHOD1(StartAppHmiStateResumption, - bool(application_manager::ApplicationSharedPtr application)); + void(application_manager::ApplicationSharedPtr application)); MOCK_METHOD3(SetAppHMIState, bool(application_manager::ApplicationSharedPtr application, const mobile_apis::HMILevel::eType hmi_level, diff --git a/src/components/application_manager/test/resumption/resume_ctrl_test.cc b/src/components/application_manager/test/resumption/resume_ctrl_test.cc index 3953e7e2dc..8d228240d2 100644 --- a/src/components/application_manager/test/resumption/resume_ctrl_test.cc +++ b/src/components/application_manager/test/resumption/resume_ctrl_test.cc @@ -967,8 +967,7 @@ TEST_F(ResumeCtrlTest, RestoreAppHMIState_RestoreHMILevelFull) { ON_CALL(mock_app_mngr_, GetUserConsentForDevice("12345")) .WillByDefault(Return(policy::kDeviceAllowed)); - const bool res = res_ctrl_->RestoreAppHMIState(mock_app_); - EXPECT_TRUE(res); + res_ctrl_->RestoreAppHMIState(mock_app_); } TEST_F(ResumeCtrlTest, SetupDefaultHMILevel) { -- cgit v1.2.1