diff options
author | Kozoriz <kozorizandriy@gmail.com> | 2016-02-16 10:44:16 +0200 |
---|---|---|
committer | Kozoriz <kozorizandriy@gmail.com> | 2016-02-17 10:15:38 +0200 |
commit | 4129bd5de70492eb3f368706674d4443eb356a32 (patch) | |
tree | be6bea3652361706e756e600f12501eb7a0b492b | |
parent | fa432087b470d3f621d4f14da78f629307aac07c (diff) | |
download | sdl_core-4129bd5de70492eb3f368706674d4443eb356a32.tar.gz |
Integration Timer to Application Manager
14 files changed, 141 insertions, 149 deletions
diff --git a/src/components/application_manager/include/application_manager/application_impl.h b/src/components/application_manager/include/application_manager/application_impl.h index d63b429c09..ebb5ccb678 100644 --- a/src/components/application_manager/include/application_manager/application_impl.h +++ b/src/components/application_manager/include/application_manager/application_impl.h @@ -46,10 +46,10 @@ #include "protocol_handler/protocol_handler.h" #include "connection_handler/device.h" -#include "utils/timer_thread.h" #include "utils/lock.h" #include "utils/atomic_object.h" #include "utils/custom_string.h" +#include "utils/timer.h" namespace usage_statistics { @@ -287,7 +287,6 @@ class ApplicationImpl : public virtual InitialApplicationDataImpl, void CleanupFiles(); private: - typedef SharedPtr<TimerThread<ApplicationImpl>> ApplicationTimerPtr; /** * @brief Callback for video streaming suspend timer. @@ -345,8 +344,8 @@ class ApplicationImpl : public virtual InitialApplicationDataImpl, uint32_t audio_stream_retry_number_; uint32_t video_stream_suspend_timeout_; uint32_t audio_stream_suspend_timeout_; - ApplicationTimerPtr video_stream_suspend_timer_; - ApplicationTimerPtr audio_stream_suspend_timer_; + Timer video_stream_suspend_timer_; + Timer audio_stream_suspend_timer_; /** * @brief Defines number per time in seconds limits diff --git a/src/components/application_manager/include/application_manager/application_manager_impl.h b/src/components/application_manager/include/application_manager/application_manager_impl.h index a2acb4a3d3..67bb3adc56 100644 --- a/src/components/application_manager/include/application_manager/application_manager_impl.h +++ b/src/components/application_manager/include/application_manager/application_manager_impl.h @@ -85,6 +85,7 @@ #include "utils/lock.h" #include "utils/singleton.h" #include "utils/data_accessor.h" +#include "utils/timer.h" namespace NsSmartDeviceLink { namespace NsSmartObjects { @@ -186,7 +187,7 @@ typedef struct { typedef std::queue<AudioData> RawAudioDataQueue; typedef threads::MessageLoopThread<RawAudioDataQueue> AudioPassThruQueue; } - +CREATE_LOGGERPTR_GLOBAL(logger_, "ApplicationManager") typedef std::vector<std::string> RPCParams; class ApplicationManagerImpl @@ -1278,9 +1279,7 @@ class ApplicationManagerImpl */ typedef std::map<uint32_t, std::pair<bool, bool>> NaviServiceStatusMap; - typedef SharedPtr<TimerThread<ApplicationManagerImpl>> - ApplicationManagerTimerPtr; - +typedef utils::SharedPtr<timer::Timer> TimerSPtr; /** * @brief GetHashedAppID allows to obtain unique application id as a string. * It concatenates device mac and application id to obtain unique id. @@ -1463,7 +1462,7 @@ class ApplicationManagerImpl uint32_t navi_close_app_timeout_; uint32_t navi_end_stream_timeout_; - std::vector<ApplicationManagerTimerPtr> timer_pool_; + std::vector<TimerSPtr> timer_pool_; sync_primitives::Lock timer_pool_lock_; sync_primitives::Lock stopping_flag_lock_; StateController state_ctrl_; @@ -1472,20 +1471,11 @@ class ApplicationManagerImpl AMMetricObserver* metric_observer_; #endif // TIME_TESTER - class ApplicationListUpdateTimer - : public timer::TimerThread<ApplicationManagerImpl> { - public: - ApplicationListUpdateTimer(ApplicationManagerImpl* callee) - : timer::TimerThread<ApplicationManagerImpl>( - "AM ListUpdater", - callee, - &ApplicationManagerImpl::OnApplicationListUpdateTimer) {} - }; typedef utils::SharedPtr<ApplicationListUpdateTimer> ApplicationListUpdateTimerSptr; - ApplicationListUpdateTimerSptr application_list_update_timer_; + Timer application_list_update_timer_; - timer::TimerThread<ApplicationManagerImpl> tts_global_properties_timer_; + Timer tts_global_properties_timer_; bool is_low_voltage_; volatile bool is_stopping_; diff --git a/src/components/application_manager/include/application_manager/commands/mobile/perform_interaction_request.h b/src/components/application_manager/include/application_manager/commands/mobile/perform_interaction_request.h index ee8527006c..591a28dc01 100644 --- a/src/components/application_manager/include/application_manager/commands/mobile/perform_interaction_request.h +++ b/src/components/application_manager/include/application_manager/commands/mobile/perform_interaction_request.h @@ -36,7 +36,6 @@ #include "application_manager/commands/command_request_impl.h" #include "application_manager/application.h" -#include "utils/timer_thread.h" #include "utils/macro.h" namespace application_manager { diff --git a/src/components/application_manager/include/application_manager/request_controller.h b/src/components/application_manager/include/application_manager/request_controller.h index 82a44fffe4..98022516be 100644 --- a/src/components/application_manager/include/application_manager/request_controller.h +++ b/src/components/application_manager/include/application_manager/request_controller.h @@ -42,12 +42,12 @@ #include "utils/threads/thread.h" #include "utils/conditional_variable.h" #include "utils/threads/thread_delegate.h" +#include "utils/timer.h" #include "interfaces/MOBILE_API.h" #include "interfaces/HMI_API.h" #include "application_manager/request_info.h" -#include "utils/timer_thread.h" namespace application_manager { @@ -281,7 +281,7 @@ class RequestController { /* * timer for checking requests timeout */ - timer::TimerThread<RequestController> timer_; + timer::Timer timer_; static const uint32_t default_sleep_time_ = UINT_MAX; bool is_low_voltage_; 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 092aa3cdec..9263d5b67f 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 @@ -45,8 +45,8 @@ #include "application_manager/event_engine/event_observer.h" #include "smart_objects/smart_object.h" #include "application_manager/application.h" -#include "utils/timer_thread.h" #include "resumption_data.h" +#include "utils/timer.h" namespace application_manager { class Application; @@ -436,8 +436,8 @@ class ResumeCtrl: public app_mngr::event_engine::EventObserver { * */ mutable sync_primitives::Lock queue_lock_; - timer::TimerThread<ResumeCtrl> restore_hmi_level_timer_; - timer::TimerThread<ResumeCtrl> save_persistent_data_timer_; + timer::Timer restore_hmi_level_timer_; + timer::Timer save_persistent_data_timer_; typedef std::list<uint32_t> WaitingForTimerList; WaitingForTimerList waiting_for_timer_; bool is_resumption_active_; diff --git a/src/components/application_manager/src/application_impl.cc b/src/components/application_manager/src/application_impl.cc index c2ad548be1..86c864e866 100644 --- a/src/components/application_manager/src/application_impl.cc +++ b/src/components/application_manager/src/application_impl.cc @@ -41,6 +41,8 @@ #include "utils/file_system.h" #include "utils/logger.h" #include "utils/gen_hash.h" +#include "utils/make_shared.h" +#include "utils/timer_task_impl.h" namespace { @@ -103,13 +105,23 @@ ApplicationImpl::ApplicationImpl( , is_voice_communication_application_(false) , is_resuming_(false) , video_stream_retry_number_(0) - , audio_stream_retry_number_(0) { + , audio_stream_retry_number_(0) + , video_stream_suspend_timer_( + "VideoStreamSuspend", + new ::timer::TimerTaskImpl<ApplicationImpl>( + this, + &ApplicationImpl::OnVideoStreamSuspend)) + , audio_stream_suspend_timer_( + "AudioStreamSuspend", + new ::timer::TimerTaskImpl<ApplicationImpl>( + this, + &ApplicationImpl::OnAudioStreamSuspend)) { cmd_number_to_time_limits_[mobile_apis::FunctionID::ReadDIDID] = { date_time::DateTime::getCurrentTime(), 0}; cmd_number_to_time_limits_[mobile_apis::FunctionID::GetVehicleDataID] = { date_time::DateTime::getCurrentTime(), 0}; - set_mobile_app_id(mobile_app_id); + set_policy_app_id(policy_app_id); set_name(app_name); MarkUnregistered(); @@ -130,19 +142,6 @@ ApplicationImpl::ApplicationImpl( profile::Profile::instance()->video_data_stopped_timeout(); audio_stream_suspend_timeout_ = profile::Profile::instance()->audio_data_stopped_timeout(); - - video_stream_suspend_timer_ = - ApplicationTimerPtr(new timer::TimerThread<ApplicationImpl>( - "VideoStreamSuspend", - this, - &ApplicationImpl::OnVideoStreamSuspend, - true)); - audio_stream_suspend_timer_ = - ApplicationTimerPtr(new timer::TimerThread<ApplicationImpl>( - "AudioStreamSuspend", - this, - &ApplicationImpl::OnAudioStreamSuspend, - true)); } ApplicationImpl::~ApplicationImpl() { @@ -417,13 +416,13 @@ void ApplicationImpl::StopStreaming( if (ServiceType::kMobileNav == service_type) { if (video_streaming_approved()) { - video_stream_suspend_timer_->stop(); + video_stream_suspend_timer_.Stop(); MessageHelper::SendNaviStopStream(app_id()); set_video_streaming_approved(false); } } else if (ServiceType::kAudio == service_type) { if (audio_streaming_approved()) { - audio_stream_suspend_timer_->stop(); + audio_stream_suspend_timer_.Stop(); MessageHelper::SendAudioStopStream(app_id()); set_audio_streaming_approved(false); } @@ -436,13 +435,13 @@ void ApplicationImpl::SuspendStreaming( LOG4CXX_AUTO_TRACE(logger_); if (ServiceType::kMobileNav == service_type) { - video_stream_suspend_timer_->suspend(); + video_stream_suspend_timer_.Stop(); ApplicationManagerImpl::instance()->OnAppStreaming( app_id(), service_type, false); sync_primitives::AutoLock lock(video_streaming_suspended_lock_); video_streaming_suspended_ = true; } else if (ServiceType::kAudio == service_type) { - audio_stream_suspend_timer_->suspend(); + audio_stream_suspend_timer_.Stop(); ApplicationManagerImpl::instance()->OnAppStreaming( app_id(), service_type, false); sync_primitives::AutoLock lock(audio_streaming_suspended_lock_); @@ -464,7 +463,7 @@ void ApplicationImpl::WakeUpStreaming( MessageHelper::SendOnDataStreaming(ServiceType::kMobileNav, true); video_streaming_suspended_ = false; } - video_stream_suspend_timer_->start(video_stream_suspend_timeout_); + video_stream_suspend_timer_.Start(video_stream_suspend_timeout_, true); } else if (ServiceType::kAudio == service_type) { sync_primitives::AutoLock lock(audio_streaming_suspended_lock_); if (audio_streaming_suspended_) { @@ -473,7 +472,7 @@ void ApplicationImpl::WakeUpStreaming( MessageHelper::SendOnDataStreaming(ServiceType::kAudio, true); audio_streaming_suspended_ = false; } - audio_stream_suspend_timer_->start(audio_stream_suspend_timeout_); + audio_stream_suspend_timer_.Start(audio_stream_suspend_timeout_, true); } } diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index aa225565ea..73abcd4b66 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -55,6 +55,7 @@ #include "utils/file_system.h" #include "utils/helpers.h" #include "utils/make_shared.h" +#include "utils/timer_task_impl.h" #include "smart_objects/enum_schema_item.h" #include "interfaces/HMI_API_schema.h" #include "application_manager/application_impl.h" @@ -80,7 +81,6 @@ DeviceTypes devicesType = { std::make_pair(std::string("WIFI"), hmi_apis::Common_TransportType::WIFI)}; } -CREATE_LOGGERPTR_GLOBAL(logger_, "ApplicationManager") uint32_t ApplicationManagerImpl::corelation_id_ = 0; const uint32_t ApplicationManagerImpl::max_corelation_id_ = UINT_MAX; @@ -123,12 +123,16 @@ ApplicationManagerImpl::ApplicationManagerImpl() metric_observer_(NULL) , #endif // TIME_TESTER - application_list_update_timer_(new ApplicationListUpdateTimer(this)) + application_list_update_timer_( + "AM ListUpdater", + new TimerTaskImpl<ApplicationManagerImpl>( + this, + &ApplicationManagerImpl::OnApplicationListUpdateTimer)), , tts_global_properties_timer_( - "TTSGLPRTimer", - this, - &ApplicationManagerImpl::OnTimerSendTTSGlobalProperties, - true) + "AM TTSGLPRTimer", + new TimerTaskImpl<ApplicationManagerImpl>( + this, + &ApplicationManagerImpl::OnTimerSendTTSGlobalProperties)), , is_low_voltage_(false) , is_stopping_(false) { @@ -140,15 +144,14 @@ ApplicationManagerImpl::ApplicationManagerImpl() {TYPE_ICONS, "Icons"}}; sync_primitives::AutoLock lock(timer_pool_lock_); - ApplicationManagerTimerPtr clearTimerPoolTimer( - new TimerThread<ApplicationManagerImpl>( - "ClearTimerPoolTimer", - this, - &ApplicationManagerImpl::ClearTimerPool, - true)); - const uint32_t timeout_ms = 10000; - clearTimerPoolTimer->start(timeout_ms); - timer_pool_.push_back(clearTimerPoolTimer); + TimerSPtr clearing_timer(utils::MakeShared<timer::Timer>( + "ClearTimerPoolTimer", + new TimerTaskImpl<ApplicationManagerImpl>( + this, + &ApplicationManagerImpl::ClearTimerPool))); + const uint32_t timeout_ms = 10000u; + clearing_timer->Start(timeout_ms, true); + timer_pool_.push_back(clearing_timer); } ApplicationManagerImpl::~ApplicationManagerImpl() { @@ -190,7 +193,7 @@ bool ApplicationManagerImpl::Stop() { stopping_flag_lock_.Acquire(); is_stopping_ = true; stopping_flag_lock_.Release(); - application_list_update_timer_->stop(); + application_list_update_timer_.Stop(); try { UnregisterAllApplications(); } catch (...) { @@ -433,7 +436,7 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication( policy::PolicyHandler::instance()->OnAppsSearchStarted(); uint32_t timeout = profile::Profile::instance()->application_list_update_timeout(); - application_list_update_timer_->start(timeout); + application_list_update_timer_.Start(timeout, false); if (!is_all_apps_allowed_) { LOG4CXX_WARN(logger_, @@ -929,7 +932,7 @@ void ApplicationManagerImpl::OnFindNewApplicationsRequest() { LOG4CXX_DEBUG(logger_, "Starting application list update timer"); uint32_t timeout = profile::Profile::instance()->application_list_update_timeout(); - application_list_update_timer_->start(timeout); + application_list_update_timer_.Start(timeout, false); policy::PolicyHandler::instance()->OnAppsSearchStarted(); } @@ -2887,14 +2890,15 @@ void ApplicationManagerImpl::EndNaviServices(uint32_t app_id) { navi_app_to_stop_.push_back(app_id); - ApplicationManagerTimerPtr closeTimer; - closeTimer = utils::MakeShared< TimerThread<ApplicationManagerImpl> >( - "CloseNaviAppTimer", this, &ApplicationManagerImpl::CloseNaviApp); - - closeTimer->start(navi_close_app_timeout_); + TimerSPtr close_timer(utils::MakeShared<timer::Timer>( + "CloseNaviAppTimer", + new TimerTaskImpl<ApplicationManagerImpl>( + this, + &ApplicationManagerImpl::CloseNaviApp))); + close_timer->Start(navi_close_app_timeout_, false); sync_primitives::AutoLock lock(timer_pool_lock_); - timer_pool_.push_back(closeTimer); + timer_pool_.push_back(close_timer); } } @@ -2928,14 +2932,16 @@ void ApplicationManagerImpl::OnHMILevelChanged(uint32_t app_id, LOG4CXX_TRACE(logger_, "HMILevel from FULL or LIMITED"); navi_app_to_end_stream_.push_back(app_id); - ApplicationManagerTimerPtr endStreamTimer; - endStreamTimer = utils::MakeShared< TimerThread<ApplicationManagerImpl> >( - "AppShouldFinishStreaming", this, &ApplicationManagerImpl::EndNaviStreaming); - - endStreamTimer->start(navi_end_stream_timeout_); + TimerSPtr end_stream_timer(utils::MakeShared<timer::Timer>( + "AppShouldFinishStreaming", + new TimerTaskImpl<ApplicationManagerImpl>( + this, + &ApplicationManagerImpl::EndNaviStreaming) + )); + end_stream_timer->Start(navi_end_stream_timeout_, false); sync_primitives::AutoLock lock(timer_pool_lock_); - timer_pool_.push_back(endStreamTimer); + timer_pool_.push_back(end_stream_timer); } } else if (to == HMI_NONE) { LOG4CXX_TRACE(logger_, "HMILevel to NONE"); @@ -2977,13 +2983,13 @@ void ApplicationManagerImpl::SendHMIStatusNotification( void ApplicationManagerImpl::ClearTimerPool() { LOG4CXX_AUTO_TRACE(logger_); - std::vector<ApplicationManagerTimerPtr> new_timer_pool; + std::vector<TimerSPtr> new_timer_pool; sync_primitives::AutoLock lock(timer_pool_lock_); new_timer_pool.push_back(timer_pool_[0]); - for (size_t i = 1; i < timer_pool_.size(); i++) { - if (timer_pool_[i]->isRunning()) { + for (size_t i = 1; i < timer_pool_.size(); ++i) { + if (timer_pool_[i]->IsRunning()) { new_timer_pool.push_back(timer_pool_[i]); } } @@ -3211,7 +3217,7 @@ void ApplicationManagerImpl::AddAppToTTSGlobalPropertiesList( LOG4CXX_INFO(logger_, "Start tts_global_properties_timer_"); tts_global_properties_app_list_lock_.Release(); const uint32_t timeout_ms = 1000; - tts_global_properties_timer_.start(timeout_ms); + tts_global_properties_timer_.Start(timeout_ms, true); return; } tts_global_properties_app_list_lock_.Release(); @@ -3230,7 +3236,7 @@ void ApplicationManagerImpl::RemoveAppFromTTSGlobalPropertiesList( LOG4CXX_INFO(logger_, "Stop tts_global_properties_timer_"); // if container is empty need to stop timer tts_global_properties_app_list_lock_.Release(); - tts_global_properties_timer_.suspend(); + tts_global_properties_timer_.Stop(); return; } } diff --git a/src/components/application_manager/src/hmi_capabilities.cc b/src/components/application_manager/src/hmi_capabilities.cc index 4e02f9e075..20f8102648 100644 --- a/src/components/application_manager/src/hmi_capabilities.cc +++ b/src/components/application_manager/src/hmi_capabilities.cc @@ -45,32 +45,35 @@ #include "application_manager/message_helper.h" #include "formatters/CFormatterJsonBase.h" +CREATE_LOGGERPTR_GLOBAL(logger_, "ApplicationManager") + namespace application_manager { namespace Formatters = NsSmartDeviceLink::NsJSONHandler::Formatters; -CREATE_LOGGERPTR_GLOBAL(logger_, "ApplicationManager") +std::map<std::string, hmi_apis::Common_VrCapabilities::eType> vr_enum_capabilities = +{ + {"TEXT", hmi_apis::Common_VrCapabilities::VR_TEXT} +}; -std::map<std::string, hmi_apis::Common_VrCapabilities::eType> - vr_enum_capabilities = {{"TEXT", hmi_apis::Common_VrCapabilities::VR_TEXT}}; - -std::map<std::string, hmi_apis::Common_ButtonName::eType> button_enum_name = { - {"OK", hmi_apis::Common_ButtonName::OK}, - {"SEEKLEFT", hmi_apis::Common_ButtonName::SEEKLEFT}, - {"SEEKRIGHT", hmi_apis::Common_ButtonName::SEEKRIGHT}, - {"TUNEUP", hmi_apis::Common_ButtonName::TUNEUP}, - {"TUNEDOWN", hmi_apis::Common_ButtonName::TUNEDOWN}, - {"PRESET_0", hmi_apis::Common_ButtonName::PRESET_0}, - {"PRESET_1", hmi_apis::Common_ButtonName::PRESET_1}, - {"PRESET_2", hmi_apis::Common_ButtonName::PRESET_2}, - {"PRESET_3", hmi_apis::Common_ButtonName::PRESET_3}, - {"PRESET_4", hmi_apis::Common_ButtonName::PRESET_4}, - {"PRESET_5", hmi_apis::Common_ButtonName::PRESET_5}, - {"PRESET_6", hmi_apis::Common_ButtonName::PRESET_6}, - {"PRESET_7", hmi_apis::Common_ButtonName::PRESET_7}, - {"PRESET_8", hmi_apis::Common_ButtonName::PRESET_8}, - {"PRESET_9", hmi_apis::Common_ButtonName::PRESET_9}, - {"CUSTOM_BUTTON", hmi_apis::Common_ButtonName::CUSTOM_BUTTON}, - {"SEARCH", hmi_apis::Common_ButtonName::SEARCH}, +std::map<std::string, hmi_apis::Common_ButtonName::eType> button_enum_name = +{ + {"OK" , hmi_apis::Common_ButtonName::OK}, + {"SEEKLEFT" , hmi_apis::Common_ButtonName::SEEKLEFT}, + {"SEEKRIGHT" , hmi_apis::Common_ButtonName::SEEKRIGHT}, + {"TUNEUP" , hmi_apis::Common_ButtonName::TUNEUP}, + {"TUNEDOWN" , hmi_apis::Common_ButtonName::TUNEDOWN}, + {"PRESET_0" , hmi_apis::Common_ButtonName::PRESET_0}, + {"PRESET_1" , hmi_apis::Common_ButtonName::PRESET_1}, + {"PRESET_2" , hmi_apis::Common_ButtonName::PRESET_2}, + {"PRESET_3" , hmi_apis::Common_ButtonName::PRESET_3}, + {"PRESET_4" , hmi_apis::Common_ButtonName::PRESET_4}, + {"PRESET_5" , hmi_apis::Common_ButtonName::PRESET_5}, + {"PRESET_6" , hmi_apis::Common_ButtonName::PRESET_6}, + {"PRESET_7" , hmi_apis::Common_ButtonName::PRESET_7}, + {"PRESET_8" , hmi_apis::Common_ButtonName::PRESET_8}, + {"PRESET_9" , hmi_apis::Common_ButtonName::PRESET_9}, + {"CUSTOM_BUTTON" , hmi_apis::Common_ButtonName::CUSTOM_BUTTON}, + {"SEARCH" , hmi_apis::Common_ButtonName::SEARCH}, }; diff --git a/src/components/application_manager/src/hmi_command_factory.cc b/src/components/application_manager/src/hmi_command_factory.cc index 0a9bdc5bc4..5701c67b4a 100644 --- a/src/components/application_manager/src/hmi_command_factory.cc +++ b/src/components/application_manager/src/hmi_command_factory.cc @@ -265,10 +265,10 @@ #include "application_manager/commands/hmi/dial_number_request.h" #include "application_manager/commands/hmi/dial_number_response.h" -namespace application_manager { - CREATE_LOGGERPTR_GLOBAL(logger_, "ApplicationManager") +namespace application_manager { + CommandSharedPtr HMICommandFactory::CreateCommand( const commands::MessageSharedPtr& message) { const int function_id = (*message)[strings::params][strings::function_id] diff --git a/src/components/application_manager/src/hmi_language_handler.cc b/src/components/application_manager/src/hmi_language_handler.cc index a766f5e623..9d894d29cc 100644 --- a/src/components/application_manager/src/hmi_language_handler.cc +++ b/src/components/application_manager/src/hmi_language_handler.cc @@ -42,10 +42,10 @@ static const std::string UIKey = "UI"; static const std::string VRKey = "VR"; static const std::string TTSKey = "TTS"; -namespace application_manager { - CREATE_LOGGERPTR_GLOBAL(logger_, "ApplicationManager") +namespace application_manager { + HMILanguageHandler::HMILanguageHandler() : capabilities_ui_language_(hmi_apis::Common_Language::INVALID_ENUM), capabilities_vr_language_(hmi_apis::Common_Language::INVALID_ENUM), diff --git a/src/components/application_manager/src/message_helper/message_helper.cc b/src/components/application_manager/src/message_helper/message_helper.cc index 07324d5bca..3767f99c47 100644 --- a/src/components/application_manager/src/message_helper/message_helper.cc +++ b/src/components/application_manager/src/message_helper/message_helper.cc @@ -59,10 +59,9 @@ #include "formatters/CFormatterJsonSDLRPCv2.h" #include "formatters/CFormatterJsonSDLRPCv1.h" -namespace application_manager { - CREATE_LOGGERPTR_GLOBAL(logger_, "ApplicationManager") +namespace application_manager { namespace { typedef std::map<std::string, hmi_apis::Common_AppPriority::eType> diff --git a/src/components/application_manager/src/request_controller.cc b/src/components/application_manager/src/request_controller.cc index 30d246eed0..97f26e24cc 100644 --- a/src/components/application_manager/src/request_controller.cc +++ b/src/components/application_manager/src/request_controller.cc @@ -36,6 +36,7 @@ #include "application_manager/commands/command_request_impl.h" #include "application_manager/commands/hmi/request_to_hmi.h" #include "utils/make_shared.h" +#include "utils/timer_task_impl.h" namespace application_manager { @@ -46,13 +47,16 @@ using namespace sync_primitives; CREATE_LOGGERPTR_GLOBAL(logger_, "RequestController") RequestController::RequestController() - : pool_state_(UNDEFINED), - pool_size_(profile::Profile::instance()->thread_pool_size()), - timer_("RequestCtrlTimer", this, &RequestController::onTimer, true), - is_low_voltage_(false) { + : pool_state_(UNDEFINED), + pool_size_(profile::Profile::instance()->thread_pool_size()), + timer_("AM RequestCtrlTimer", + new timer::TimerTaskImpl<RequestController>( + this, + &RequestController::onTimer)), + is_low_voltage_(false) { LOG4CXX_AUTO_TRACE(logger_); InitializeThreadpool(); - timer_.start(default_sleep_time_); + timer_.Start(default_sleep_time_, true); } RequestController::~RequestController() { @@ -479,8 +483,7 @@ void RequestController::UpdateTimer() { const uint32_t msecs =static_cast<uint32_t>(date_time::DateTime::getmSecs(end_time - current_time) ); LOG4CXX_DEBUG(logger_, "Sleep for " << msecs << " millisecs" ); // Timeout for bigger than 5 minutes is a mistake - - timer_.updateTimeOut(msecs); + timer_.Start(msecs, true); } else { LOG4CXX_WARN(logger_, "Request app_id: " << front->app_id() << " correlation_id: " << front->requestId() @@ -493,12 +496,12 @@ void RequestController::UpdateTimer() { << date_time::DateTime::getmSecs(current_time - end_time) << " Request timeout (sec): " << front->timeout_msec()/date_time::DateTime::MILLISECONDS_IN_SECOND); - timer_.updateTimeOut(0); + timer_.Start(0u, true); } } else { LOG4CXX_DEBUG(logger_, "Sleep for default sleep time " << default_sleep_time_ << " milliseconds."); - timer_.updateTimeOut(default_sleep_time_); + timer_.Start(default_sleep_time_, true); } } diff --git a/src/components/application_manager/src/resumption/resume_ctrl.cc b/src/components/application_manager/src/resumption/resume_ctrl.cc index 86a778873e..926c98808d 100644 --- a/src/components/application_manager/src/resumption/resume_ctrl.cc +++ b/src/components/application_manager/src/resumption/resume_ctrl.cc @@ -48,6 +48,8 @@ #include "utils/helpers.h" #include "application_manager/resumption/resumption_data_db.h" #include "application_manager/resumption/resumption_data_json.h" +#include "utils/make_shared.h" +#include "utils/timer_task_impl.h" namespace resumption { using namespace application_manager; @@ -55,14 +57,16 @@ using namespace application_manager; CREATE_LOGGERPTR_GLOBAL(logger_, "Resumption") ResumeCtrl::ResumeCtrl() - : queue_lock_(false) - , restore_hmi_level_timer_( - "RsmCtrlRstore", this, &ResumeCtrl::ApplicationResumptiOnTimer) - , save_persistent_data_timer_( - "RsmCtrlPercist", this, &ResumeCtrl::SaveDataOnTimer, true) - , is_resumption_active_(false) - , is_data_saved_(false) - , launch_time_(time(NULL)) {} + : queue_lock_(false), + restore_hmi_level_timer_( + "RsmCtrlRstore", new timer::TimerTaskImpl<ResumeCtrl>( + this, &ResumeCtrl::ApplicationResumptiOnTimer)), + save_persistent_data_timer_( + "RsmCtrlPercist", + new timer::TimerTaskImpl<ResumeCtrl>(this, &ResumeCtrl::SaveDataOnTimer)), + is_resumption_active_(false), + is_data_saved_(false), + launch_time_(time(NULL)) {} bool ResumeCtrl::Init() { using namespace profile; @@ -95,9 +99,10 @@ bool ResumeCtrl::Init() { resumption_storage_.reset(new ResumptionDataJson()); } LoadResumeData(); - save_persistent_data_timer_.start( + save_persistent_data_timer_.Start( profile::Profile::instance() - ->app_resumption_save_persistent_data_timeout()); + ->app_resumption_save_persistent_data_timeout(), + true); return true; } @@ -261,17 +266,18 @@ void ResumeCtrl::OnAwake() { void ResumeCtrl::StartSavePersistentDataTimer() { LOG4CXX_AUTO_TRACE(logger_); - if (!save_persistent_data_timer_.isRunning()) { - save_persistent_data_timer_.start( + if (!save_persistent_data_timer_.IsRunning()) { + save_persistent_data_timer_.Start( profile::Profile::instance() - ->app_resumption_save_persistent_data_timeout()); + ->app_resumption_save_persistent_data_timeout(), + true); } } void ResumeCtrl::StopSavePersistentDataTimer() { LOG4CXX_AUTO_TRACE(logger_); - if (save_persistent_data_timer_.isRunning()) { - save_persistent_data_timer_.stop(); + if (save_persistent_data_timer_.IsRunning()) { + save_persistent_data_timer_.Stop(); } } @@ -716,8 +722,8 @@ void ResumeCtrl::AddToResumptionTimerQueue(uint32_t app_id) { queue_lock_.Release(); if (!is_resumption_active_) { is_resumption_active_ = true; - restore_hmi_level_timer_.start( - profile::Profile::instance()->app_resuming_timeout()); + restore_hmi_level_timer_.Start( + profile::Profile::instance()->app_resuming_timeout(), false); } } diff --git a/src/components/application_manager/test/mock/include/application_manager/application_manager_impl.h b/src/components/application_manager/test/mock/include/application_manager/application_manager_impl.h index c1283ebf6b..13f1bd9965 100644 --- a/src/components/application_manager/test/mock/include/application_manager/application_manager_impl.h +++ b/src/components/application_manager/test/mock/include/application_manager/application_manager_impl.h @@ -406,19 +406,7 @@ class ApplicationManagerImpl friend class ApplicationListAccessor; - class ApplicationListUpdateTimer - : public timer::TimerThread<ApplicationManagerImpl> { - public: - ApplicationListUpdateTimer(ApplicationManagerImpl* callee) - : timer::TimerThread<ApplicationManagerImpl>( - "AM ListUpdater", - callee, - &ApplicationManagerImpl::OnApplicationListUpdateTimer) {} - }; - typedef utils::SharedPtr<ApplicationListUpdateTimer> - ApplicationListUpdateTimerSptr; - - private: +private: FRIEND_BASE_SINGLETON_CLASS(ApplicationManagerImpl); }; |