diff options
author | Alexander Kutsan <AKutsan@luxoft.com> | 2016-08-26 18:48:22 +0300 |
---|---|---|
committer | Alexander Kutsan <AKutsan@luxoft.com> | 2016-08-26 18:48:57 +0300 |
commit | d73e6dc8724c5799fae14efd4dcb214af74e4904 (patch) | |
tree | 9ebed8b422490c4d669e90e70783e4f5b55b65c9 /src/components/application_manager/src/policies/policy_event_observer.cc | |
parent | c201c11a35d360c0b96f36b103a2590bfaeb6026 (diff) | |
parent | 61ef8c42badb879216f53d240e1101b9f83a9bb7 (diff) | |
download | sdl_core-d73e6dc8724c5799fae14efd4dcb214af74e4904.tar.gz |
Merge branch 'release/4.1.0'
Diffstat (limited to 'src/components/application_manager/src/policies/policy_event_observer.cc')
-rw-r--r-- | src/components/application_manager/src/policies/policy_event_observer.cc | 38 |
1 files changed, 16 insertions, 22 deletions
diff --git a/src/components/application_manager/src/policies/policy_event_observer.cc b/src/components/application_manager/src/policies/policy_event_observer.cc index 09f97dd3f1..492abe499a 100644 --- a/src/components/application_manager/src/policies/policy_event_observer.cc +++ b/src/components/application_manager/src/policies/policy_event_observer.cc @@ -43,11 +43,13 @@ class PolicyHandler; CREATE_LOGGERPTR_GLOBAL(logger_, "PolicyHandler") -PolicyEventObserver::PolicyEventObserver(PolicyHandler* const policy_handler) - : policy_handler_(policy_handler) { -} +PolicyEventObserver::PolicyEventObserver( + policy::PolicyHandlerInterface* const policy_handler, + application_manager::event_engine::EventDispatcher& event_dispatcher) + : EventObserver(event_dispatcher), policy_handler_(policy_handler) {} -void PolicyEventObserver::set_policy_handler(policy::PolicyHandler* const policy_handler) { +void PolicyEventObserver::set_policy_handler( + PolicyHandlerInterface* const policy_handler) { LOG4CXX_AUTO_TRACE(logger_); sync_primitives::AutoLock auto_lock(policy_handler_lock_); LOG4CXX_DEBUG(logger_, "Set policy handler " << policy_handler); @@ -67,10 +69,8 @@ void PolicyEventObserver::on_event(const event_engine::Event& event) { ProcessOdometerEvent(message); break; } - default: { - break; - } - unsubscribe_from_event(hmi_apis::FunctionID::VehicleInfo_GetOdometer); + default: { break; } + unsubscribe_from_event(hmi_apis::FunctionID::VehicleInfo_GetOdometer); #else case hmi_apis::FunctionID::VehicleInfo_GetVehicleData: { ProcessOdometerEvent(message); @@ -82,27 +82,21 @@ void PolicyEventObserver::on_event(const event_engine::Event& event) { unsubscribe_from_event(hmi_apis::FunctionID::BasicCommunication_OnReady); break; } - default: { - break; - } + default: { break; } #endif } } -void PolicyEventObserver::ProcessOdometerEvent(const smart_objects::SmartObject& message) { - if (hmi_apis::Common_Result::SUCCESS - == static_cast<hmi_apis::Common_Result::eType>(message[strings::params][hmi_response::code] - .asInt())) { - +void PolicyEventObserver::ProcessOdometerEvent( + const smart_objects::SmartObject& message) { + if (hmi_apis::Common_Result::SUCCESS == + static_cast<hmi_apis::Common_Result::eType>( + message[strings::params][hmi_response::code].asInt())) { if (message[strings::msg_params].keyExists(strings::odometer)) { - TimevalStruct current_time = date_time::DateTime::getCurrentTime(); - const int kSecondsInDay = 60 * 60 * 24; - int days_after_epoch = current_time.tv_sec / kSecondsInDay; - if (policy_handler_) { policy_handler_->PTUpdatedAt( - message[strings::msg_params][strings::odometer].asInt(), - days_after_epoch); + Counters::KILOMETERS, + message[strings::msg_params][strings::odometer].asInt()); } } } |