From 8118c04117ede6bf0cd7ae9ace3cf0849de0b86a Mon Sep 17 00:00:00 2001 From: Ankur Date: Tue, 24 Feb 2015 19:02:25 +0530 Subject: [PATCH] Removing redundant Light sensor events LIGHT_LUX_DATA_SET and LIGHT_EVENT_LUX_DATA_REPORT_ON_TIME were the same LIGHT_LUX_DATA_SET has been removed. LIGHT_LUX_DATA_SET was used for polling events and LIGHT_EVENT_LUX_DATA_REPORT_ON_TIME was used for event driven Since both these represent the same light sensor event, DATA_SET type has been removed. And LIGHT_EVENT_LUX_DATA_REPORT_ON_TIME has been renamed to LIGHT_LUX_DATA_EVENT to make it simpler. The change has been tested on rd-pq device for all sensord API and all API were found to be working. Change-Id: I44a761251a6fc9e78333f022b131c2562d65ccb9 --- src/libsensord/client_common.cpp | 14 ++++++-------- src/libsensord/sensor_deprecated.h | 6 ++++++ src/libsensord/sensor_light.h | 11 +++-------- src/light/light_sensor.cpp | 22 +++++++++++----------- test/src/auto_test.c | 2 +- test/src/tc-common.c | 4 ++-- 6 files changed, 29 insertions(+), 30 deletions(-) diff --git a/src/libsensord/client_common.cpp b/src/libsensord/client_common.cpp index 6e5bfe7..1b0cc59 100755 --- a/src/libsensord/client_common.cpp +++ b/src/libsensord/client_common.cpp @@ -46,7 +46,7 @@ log_element g_log_elements[] = { FILL_LOG_ELEMENT(LOG_ID_EVENT, GEOMAGNETIC_CALIBRATION_NEEDED_EVENT, 0, 1), FILL_LOG_ELEMENT(LOG_ID_EVENT, PROXIMITY_CHANGE_STATE_EVENT, 0,1), - FILL_LOG_ELEMENT(LOG_ID_EVENT, LIGHT_EVENT_CHANGE_LEVEL, 0, 1), + FILL_LOG_ELEMENT(LOG_ID_EVENT, LIGHT_CHANGE_LEVEL_EVENT, 0, 1), FILL_LOG_ELEMENT(LOG_ID_EVENT, PROXIMITY_STATE_EVENT, 0, 10), FILL_LOG_ELEMENT(LOG_ID_EVENT, PROXIMITY_DISTANCE_DATA_EVENT, 0, 10), FILL_LOG_ELEMENT(LOG_ID_EVENT, CONTEXT_EVENT_REPORT, 0, 1), @@ -55,8 +55,8 @@ log_element g_log_elements[] = { FILL_LOG_ELEMENT(LOG_ID_EVENT, GYROSCOPE_RAW_DATA_EVENT, 0, 10), FILL_LOG_ELEMENT(LOG_ID_EVENT, GEOMAGNETIC_RAW_DATA_EVENT, 0, 10), FILL_LOG_ELEMENT(LOG_ID_EVENT, PRESSURE_RAW_DATA_EVENT, 0, 10), - FILL_LOG_ELEMENT(LOG_ID_EVENT, LIGHT_EVENT_LEVEL_DATA_REPORT_ON_TIME, 0, 10), - FILL_LOG_ELEMENT(LOG_ID_EVENT, LIGHT_EVENT_LUX_DATA_REPORT_ON_TIME, 0, 10), + FILL_LOG_ELEMENT(LOG_ID_EVENT, LIGHT_LEVEL_DATA_EVENT, 0, 10), + FILL_LOG_ELEMENT(LOG_ID_EVENT, LIGHT_LUX_DATA_EVENT, 0, 10), FILL_LOG_ELEMENT(LOG_ID_EVENT, GRAVITY_EVENT_RAW_DATA_REPORT_ON_TIME, 0, 10), FILL_LOG_ELEMENT(LOG_ID_EVENT, LINEAR_ACCEL_EVENT_RAW_DATA_REPORT_ON_TIME, 0, 10), FILL_LOG_ELEMENT(LOG_ID_EVENT, ORIENTATION_EVENT_RAW_DATA_REPORT_ON_TIME, 0, 10), @@ -66,8 +66,6 @@ log_element g_log_elements[] = { FILL_LOG_ELEMENT(LOG_ID_EVENT, GEOMAGNETIC_RV_RAW_DATA_EVENT, 0, 10), FILL_LOG_ELEMENT(LOG_ID_EVENT, GAMING_RV_RAW_DATA_EVENT, 0, 10), - FILL_LOG_ELEMENT(LOG_ID_DATA, LIGHT_BASE_DATA_SET, 0, 25), - FILL_LOG_ELEMENT(LOG_ID_DATA, LIGHT_LUX_DATA_SET, 0, 25), FILL_LOG_ELEMENT(LOG_ID_DATA, CONTEXT_BASE_DATA_SET, 0, 25), FILL_LOG_ELEMENT(LOG_ID_DATA, GRAVITY_BASE_DATA_SET, 0, 25), FILL_LOG_ELEMENT(LOG_ID_DATA, LINEAR_ACCEL_BASE_DATA_SET, 0, 25), @@ -149,9 +147,9 @@ bool is_ontime_event(unsigned int event_type) case ACCELEROMETER_RAW_DATA_EVENT: case PROXIMITY_STATE_EVENT: case GYROSCOPE_RAW_DATA_EVENT: - case LIGHT_EVENT_LEVEL_DATA_REPORT_ON_TIME: + case LIGHT_LEVEL_DATA_EVENT: case GEOMAGNETIC_RAW_DATA_EVENT: - case LIGHT_EVENT_LUX_DATA_REPORT_ON_TIME: + case LIGHT_LUX_DATA_EVENT: case PROXIMITY_DISTANCE_DATA_EVENT: case GRAVITY_EVENT_RAW_DATA_REPORT_ON_TIME: case LINEAR_ACCEL_EVENT_RAW_DATA_REPORT_ON_TIME: @@ -173,7 +171,7 @@ bool is_single_state_event(unsigned int event_type) { switch (event_type) { case GEOMAGNETIC_CALIBRATION_NEEDED_EVENT: - case LIGHT_EVENT_CHANGE_LEVEL: + case LIGHT_CHANGE_LEVEL_EVENT: case PROXIMITY_CHANGE_STATE_EVENT: case AUTO_ROTATION_CHANGE_STATE_EVENT: return true; diff --git a/src/libsensord/sensor_deprecated.h b/src/libsensord/sensor_deprecated.h index da7fd94..5ebedfe 100644 --- a/src/libsensord/sensor_deprecated.h +++ b/src/libsensord/sensor_deprecated.h @@ -67,6 +67,12 @@ extern "C" #define AUTO_ROTATION_BASE_DATA_SET AUTO_ROTATION_CHANGE_STATE_EVENT #define AUTO_ROTATION_EVENT_CHANGE_STATE AUTO_ROTATION_CHANGE_STATE_EVENT +#define LIGHT_LUX_DATA_SET LIGHT_LUX_DATA_EVENT +#define LIGHT_BASE_DATA_SET LIGHT_LEVEL_DATA_EVENT +#define LIGHT_EVENT_LUX_DATA_REPORT_ON_TIME LIGHT_LUX_DATA_EVENT +#define LIGHT_EVENT_LEVEL_DATA_REPORT_ON_TIME LIGHT_LEVEL_DATA_EVENT +#define LIGHT_EVENT_CHANGE_LEVEL LIGHT_CHANGE_LEVEL_EVENT + enum accelerometer_rotate_state { ROTATION_UNKNOWN = 0, ROTATION_LANDSCAPE_LEFT = 1, diff --git a/src/libsensord/sensor_light.h b/src/libsensord/sensor_light.h index bd35fb3..1f476b6 100755 --- a/src/libsensord/sensor_light.h +++ b/src/libsensord/sensor_light.h @@ -36,15 +36,10 @@ extern "C" * @{ */ -enum light_data_id { - LIGHT_LUX_DATA_SET = (LIGHT_SENSOR << 16) | 0x0001, - LIGHT_BASE_DATA_SET = (LIGHT_SENSOR << 16) | 0x0002, -}; - enum light_event_type { - LIGHT_EVENT_LUX_DATA_REPORT_ON_TIME = (LIGHT_SENSOR << 16) | 0x0001, - LIGHT_EVENT_LEVEL_DATA_REPORT_ON_TIME = (LIGHT_SENSOR << 16) | 0x0002, - LIGHT_EVENT_CHANGE_LEVEL = (LIGHT_SENSOR << 16) | 0x0004, + LIGHT_LUX_DATA_EVENT = (LIGHT_SENSOR << 16) | 0x0001, + LIGHT_LEVEL_DATA_EVENT = (LIGHT_SENSOR << 16) | 0x0002, + LIGHT_CHANGE_LEVEL_EVENT = (LIGHT_SENSOR << 16) | 0x0004, }; enum light_property_id { diff --git a/src/light/light_sensor.cpp b/src/light/light_sensor.cpp index fbffb23..73e45cc 100755 --- a/src/light/light_sensor.cpp +++ b/src/light/light_sensor.cpp @@ -38,9 +38,9 @@ light_sensor::light_sensor() m_name = string(SENSOR_NAME); vector supported_events = { - LIGHT_EVENT_CHANGE_LEVEL, - LIGHT_EVENT_LEVEL_DATA_REPORT_ON_TIME, - LIGHT_EVENT_LUX_DATA_REPORT_ON_TIME, + LIGHT_CHANGE_LEVEL_EVENT, + LIGHT_LEVEL_DATA_EVENT, + LIGHT_LUX_DATA_EVENT, }; for_each(supported_events.begin(), supported_events.end(), @@ -92,13 +92,13 @@ bool light_sensor::process_event(void) AUTOLOCK(m_client_info_mutex); event.sensor_id = get_id(); - if (get_client_cnt(LIGHT_EVENT_LUX_DATA_REPORT_ON_TIME)) { - event.event_type = LIGHT_EVENT_LUX_DATA_REPORT_ON_TIME; + if (get_client_cnt(LIGHT_LUX_DATA_EVENT)) { + event.event_type = LIGHT_LUX_DATA_EVENT; push(event); } - if (get_client_cnt(LIGHT_EVENT_LEVEL_DATA_REPORT_ON_TIME)) { - event.event_type = LIGHT_EVENT_LEVEL_DATA_REPORT_ON_TIME; + if (get_client_cnt(LIGHT_LEVEL_DATA_EVENT)) { + event.event_type = LIGHT_LEVEL_DATA_EVENT; raw_to_level(event.data); push(event); } @@ -106,8 +106,8 @@ bool light_sensor::process_event(void) if (m_level != level) { m_level = level; - if (get_client_cnt(LIGHT_EVENT_CHANGE_LEVEL)) { - event.event_type = LIGHT_EVENT_CHANGE_LEVEL; + if (get_client_cnt(LIGHT_CHANGE_LEVEL_EVENT)) { + event.event_type = LIGHT_CHANGE_LEVEL_EVENT; raw_to_level(event.data); push(event); } @@ -162,10 +162,10 @@ int light_sensor::get_sensor_data(unsigned int type, sensor_data_t &data) if (ret < 0) return -1; - if (type == LIGHT_LUX_DATA_SET) + if (type == LIGHT_LUX_DATA_EVENT) return 0; - if (type == LIGHT_BASE_DATA_SET) { + if (type == LIGHT_LEVEL_DATA_EVENT) { raw_to_level(data); return 0; } diff --git a/test/src/auto_test.c b/test/src/auto_test.c index 971b171..64857db 100644 --- a/test/src/auto_test.c +++ b/test/src/auto_test.c @@ -211,7 +211,7 @@ int main(int argc, char **argv) result = check_sensor_api(GYROSCOPE_RAW_DATA_EVENT, interval); fprintf(fp, "Gyroscope - RAW_DATA_REPORT_ON_TIME - %d\n", result); - result = check_sensor_api(LIGHT_EVENT_LUX_DATA_REPORT_ON_TIME, interval); + result = check_sensor_api(LIGHT_LUX_DATA_EVENT, interval); fprintf(fp, "Light - RAW_DATA_REPORT_ON_TIME - %d\n", result); result = check_sensor_api(LINEAR_ACCEL_EVENT_RAW_DATA_REPORT_ON_TIME, interval); diff --git a/test/src/tc-common.c b/test/src/tc-common.c index 2d1f263..defded2 100644 --- a/test/src/tc-common.c +++ b/test/src/tc-common.c @@ -80,7 +80,7 @@ unsigned int get_event_driven(sensor_type_t sensor_type, char str[]) break; case LIGHT_SENSOR: if (strcmp(str, "RAW_DATA_REPORT_ON_TIME") == 0) - return LIGHT_EVENT_LUX_DATA_REPORT_ON_TIME; + return LIGHT_LUX_DATA_EVENT; break; case TEMPERATURE_SENSOR: if (strcmp(str, "RAW_DATA_REPORT_ON_TIME") == 0) @@ -229,7 +229,7 @@ int main(int argc, char **argv) } else if (strcmp(argv[1], "light") == 0) { sensor_type = LIGHT_SENSOR; - event = LIGHT_EVENT_LUX_DATA_REPORT_ON_TIME; + event = LIGHT_LUX_DATA_EVENT; } else if (strcmp(argv[1], "proximity") == 0) { sensor_type = PROXIMITY_SENSOR; -- 2.7.4