sensord: change to use is_started() instead of using member variable directly 99/75599/1
authorkibak.yoon <kibak.yoon@samsung.com>
Thu, 2 Jun 2016 05:07:47 +0000 (14:07 +0900)
committerkibak.yoon <kibak.yoon@samsung.com>
Mon, 20 Jun 2016 13:30:24 +0000 (22:30 +0900)
- it would be better to use member function

Change-Id: I2475768459215731d36bdd3ef00df263688c4431
Signed-off-by: kibak.yoon <kibak.yoon@samsung.com>
src/client/sensor_client_info.cpp
src/client/sensor_event_listener.cpp
src/client/sensor_handle_info.cpp
src/client/sensor_handle_info.h

index fcd4e80..62de536 100644 (file)
@@ -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<unsigned int>::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;
index ec8da17..80c280b 100644 (file)
@@ -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)
index 175c567..b394990 100644 (file)
@@ -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);
+}
index f64b2a6..28e5a01 100644 (file)
@@ -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;