#include <dlfcn.h>
#include <sensor_log.h>
+#include <sensor_types.h>
+#include <sensor_common.h>
#include <virtual_sensor.h>
#include <auto_rotation_sensor.h>
#include <sensor_loader.h>
-#include <virtual_sensor_config.h>
#include <auto_rotation_alg.h>
#include <auto_rotation_alg_emul.h>
-using std::bind1st;
-using std::mem_fun;
-using std::string;
-using std::vector;
-
-#define SENSOR_NAME "AUTO_ROTATION_SENSOR"
-#define SENSOR_TYPE_AUTO_ROTATION "AUTO_ROTATION"
-
-#define MS_TO_US 1000
-
-#define ELEMENT_NAME "NAME"
-#define ELEMENT_VENDOR "VENDOR"
-#define ELEMENT_RAW_DATA_UNIT "RAW_DATA_UNIT"
-#define ELEMENT_DEFAULT_SAMPLING_TIME "DEFAULT_SAMPLING_TIME"
-
-#define AUTO_ROTATION_LIB "/usr/lib/sensord/libauto_rotation_sensor.so"
+#define SENSOR_NAME "AUTO_ROTATION_SENSOR"
auto_rotation_sensor::auto_rotation_sensor()
: m_accel_sensor(NULL)
, m_alg(NULL)
, m_rotation(0)
-, m_interval(1)
-, m_rotation_time(1) // rotation state is valid from initial state, so set rotation time to non-zero value
-, m_default_sampling_time(1)
+, m_interval(100)
+, m_rotation_time(0)
{
- virtual_sensor_config &config = virtual_sensor_config::get_instance();
-
- if (!config.get(SENSOR_TYPE_AUTO_ROTATION, ELEMENT_VENDOR, m_vendor)) {
- _E("[VENDOR] is empty\n");
- throw ENXIO;
- }
-
- _I("m_vendor = %s", m_vendor.c_str());
-
- if (!config.get(SENSOR_TYPE_AUTO_ROTATION, ELEMENT_RAW_DATA_UNIT, m_raw_data_unit)) {
- _E("[RAW_DATA_UNIT] is empty\n");
- throw ENXIO;
- }
-
- _I("m_raw_data_unit = %s", m_raw_data_unit.c_str());
-
- if (!config.get(SENSOR_TYPE_AUTO_ROTATION, ELEMENT_DEFAULT_SAMPLING_TIME, &m_default_sampling_time)) {
- _E("[DEFAULT_SAMPLING_TIME] is empty\n");
- throw ENXIO;
- }
-
- _I("m_default_sampling_time = %d", m_default_sampling_time);
-
- m_interval = m_default_sampling_time * MS_TO_US;
}
auto_rotation_sensor::~auto_rotation_sensor()
unsigned int auto_rotation_sensor::get_event_type(void)
{
- return (AUTO_ROTATION_SENSOR << 16) | 0x0001;
+ return AUTO_ROTATION_EVENT_CHANGE_STATE;
}
const char* auto_rotation_sensor::get_name(void)
void auto_rotation_sensor::synthesize(const sensor_event_t& event)
{
- if (event.event_type != ACCELEROMETER_RAW_DATA_EVENT)
+ if (event.event_type != ACCELEROMETER_EVENT_RAW_DATA_REPORT_ON_TIME)
return;
int rotation;
}
rotation_event->sensor_id = get_id();
- rotation_event->event_type = AUTO_ROTATION_CHANGE_STATE_EVENT;
+ rotation_event->event_type = AUTO_ROTATION_EVENT_CHANGE_STATE;
rotation_event->data_length = data_length;
rotation_event->data = rotation_data;
bool auto_rotation_sensor::set_interval(unsigned long interval)
{
+ m_accel_sensor->add_interval((intptr_t)this , m_interval, true);
+
+ m_interval = interval;
return false;
}
m_alg->start();
- m_accel_sensor->add_interval((intptr_t)this , (m_interval/MS_TO_US), true);
+ m_accel_sensor->add_interval((intptr_t)this , m_interval, true);
m_accel_sensor->start();
return activate();
return deactivate();
}
-bool auto_rotation_sensor::check_lib(void)
-{
- if (access(AUTO_ROTATION_LIB, F_OK) < 0)
- return false;
-
- return true;
-}
-
auto_rotation_alg *auto_rotation_sensor::get_alg()
{
auto_rotation_alg *alg = new(std::nothrow) auto_rotation_alg_emul();
return alg;
}
-