From cba95e8c6a0981d952980ea07f2fb4354a9df709 Mon Sep 17 00:00:00 2001 From: "kibak.yoon" Date: Thu, 2 Jun 2016 14:07:47 +0900 Subject: [PATCH] sensord: change to use is_started() instead of using member variable directly - it would be better to use member function Change-Id: I2475768459215731d36bdd3ef00df263688c4431 Signed-off-by: kibak.yoon --- src/client/sensor_client_info.cpp | 28 ++++++++++++---------------- src/client/sensor_event_listener.cpp | 4 ++-- src/client/sensor_handle_info.cpp | 5 +++++ src/client/sensor_handle_info.h | 3 +++ 4 files changed, 22 insertions(+), 18 deletions(-) diff --git a/src/client/sensor_client_info.cpp b/src/client/sensor_client_info.cpp index fcd4e80..62de536 100644 --- a/src/client/sensor_client_info.cpp +++ b/src/client/sensor_client_info.cpp @@ -410,7 +410,6 @@ bool sensor_client_info::get_active_batch(sensor_id_t sensor, unsigned int &inte unsigned int min_interval = POLL_MAX_HZ_MS; unsigned int min_latency = std::numeric_limits::max(); - bool active_sensor_found = false; unsigned int _interval; unsigned int _latency; @@ -420,17 +419,16 @@ bool sensor_client_info::get_active_batch(sensor_id_t sensor, unsigned int &inte while (it_handle != m_sensor_handle_infos.end()) { if ((it_handle->second.m_sensor_id == sensor) && - (it_handle->second.m_sensor_state == SENSOR_STATE_STARTED)) { - active_sensor_found = true; - it_handle->second.get_batch(_interval, _latency); - min_interval = (_interval < min_interval) ? _interval : min_interval; - min_latency = (_latency < min_latency) ? _latency : min_latency; + it_handle->second.is_started()) { + it_handle->second.get_batch(_interval, _latency); + min_interval = (_interval < min_interval) ? _interval : min_interval; + min_latency = (_latency < min_latency) ? _latency : min_latency; } ++it_handle; } - if (!active_sensor_found) { + if (!is_sensor_active(sensor)) { _D("Active sensor[%#llx] is not found for client %s", sensor, get_client_name()); return false; } @@ -444,7 +442,6 @@ bool sensor_client_info::get_active_batch(sensor_id_t sensor, unsigned int &inte unsigned int sensor_client_info::get_active_pause_policy(sensor_id_t sensor) { int active_pause = SENSORD_PAUSE_ALL; - bool active_sensor_found = false; int pause; AUTOLOCK(m_handle_info_lock); @@ -453,16 +450,15 @@ unsigned int sensor_client_info::get_active_pause_policy(sensor_id_t sensor) while (it_handle != m_sensor_handle_infos.end()) { if ((it_handle->second.m_sensor_id == sensor) && - (it_handle->second.m_sensor_state == SENSOR_STATE_STARTED)) { - active_sensor_found = true; - pause = it_handle->second.m_pause_policy; - active_pause = (pause < active_pause) ? pause: active_pause; + it_handle->second.is_started()) { + pause = it_handle->second.m_pause_policy; + active_pause = (pause < active_pause) ? pause: active_pause; } ++it_handle; } - if (!active_sensor_found) + if (!is_sensor_active(sensor)) _D("Active sensor[%#llx] is not found for client %s", sensor, get_client_name()); return active_pause; @@ -510,8 +506,8 @@ void sensor_client_info::get_active_event_types(sensor_id_t sensor, event_type_v while (it_handle != m_sensor_handle_infos.end()) { if ((it_handle->second.m_sensor_id == sensor) && - (it_handle->second.m_sensor_state == SENSOR_STATE_STARTED)) - it_handle->second.get_reg_event_types(event_types); + it_handle->second.is_started()) + it_handle->second.get_reg_event_types(event_types); ++it_handle; } @@ -586,7 +582,7 @@ bool sensor_client_info::is_sensor_active(sensor_id_t sensor) while (it_handle != m_sensor_handle_infos.end()) { if ((it_handle->second.m_sensor_id == sensor) && - (it_handle->second.m_sensor_state == SENSOR_STATE_STARTED)) + it_handle->second.is_started()) return true; ++it_handle; diff --git a/src/client/sensor_event_listener.cpp b/src/client/sensor_event_listener.cpp index ec8da17..80c280b 100644 --- a/src/client/sensor_event_listener.cpp +++ b/src/client/sensor_event_listener.cpp @@ -128,8 +128,8 @@ void sensor_event_listener::handle_events(void* event) event_info = sensor_handle_info.get_reg_event_info(event_type); if ((sensor_handle_info.m_sensor_id != sensor_id) || - (sensor_handle_info.m_sensor_state != SENSOR_STATE_STARTED) || - !event_info) + !sensor_handle_info.is_started() || + !event_info) continue; if (event_info->m_fired) diff --git a/src/client/sensor_handle_info.cpp b/src/client/sensor_handle_info.cpp index 175c567..b394990 100644 --- a/src/client/sensor_handle_info.cpp +++ b/src/client/sensor_handle_info.cpp @@ -160,3 +160,8 @@ unsigned int sensor_handle_info::get_reg_event_count(void) { return m_reg_event_infos.size(); } + +bool sensor_handle_info::is_started(void) +{ + return (m_sensor_state == SENSOR_STATE_STARTED); +} diff --git a/src/client/sensor_handle_info.h b/src/client/sensor_handle_info.h index f64b2a6..28e5a01 100644 --- a/src/client/sensor_handle_info.h +++ b/src/client/sensor_handle_info.h @@ -54,6 +54,9 @@ public: void clear_all_events(void); static unsigned long long renew_event_id(void); + + bool is_started(void); + private: event_info_map m_reg_event_infos; static unsigned long long m_event_id; -- 2.7.4