sensord: change sensor axis policy by using attribute setting via C-API 03/75603/1
authorkibak.yoon <kibak.yoon@samsung.com>
Mon, 20 Jun 2016 03:46:07 +0000 (12:46 +0900)
committerkibak.yoon <kibak.yoon@samsung.com>
Mon, 20 Jun 2016 13:31:49 +0000 (22:31 +0900)
- SENSORD_AXIS_DEVICE_ORIENTED
- SENSORD_AXIS_DISPLAY_ORIENTED

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

index e26ba85..b900db4 100644 (file)
@@ -1080,6 +1080,7 @@ static int change_pause_policy(int handle, int pause)
 
 static int change_axis_orientation(int handle, int axis_orientation)
 {
+       sensor_event_listener::get_instance().set_sensor_axis(axis_orientation);
        return OP_SUCCESS;
 }
 
index 80c280b..fdc622a 100644 (file)
@@ -45,6 +45,7 @@ sensor_event_listener::sensor_event_listener()
 , m_thread_state(THREAD_STATE_TERMINATE)
 , m_hup_observer(NULL)
 , m_client_info(sensor_client_info::get_instance())
+, m_axis(SENSORD_AXIS_DEVICE_ORIENTED)
 , m_display_rotation(AUTO_ROTATION_DEGREE_UNKNOWN)
 {
 }
@@ -204,11 +205,19 @@ bool sensor_event_listener::is_valid_callback(client_callback_info *cb_info)
        return m_client_info.is_event_active(cb_info->handle, cb_info->event_type, cb_info->event_id);
 }
 
+void sensor_event_listener::set_sensor_axis(int axis)
+{
+       m_axis = axis;
+}
+
 void sensor_event_listener::align_sensor_axis(sensor_t sensor, sensor_data_t *data)
 {
        sensor_type_t type = sensor_to_sensor_info(sensor)->get_type();
 
-       if (type != ACCELEROMETER_SENSOR && type != GYROSCOPE_SENSOR && type != GRAVITY_SENSOR)
+       if (m_axis != SENSORD_AXIS_DISPLAY_ORIENTED)
+               return;
+
+       if (type != ACCELEROMETER_SENSOR && type != GYROSCOPE_SENSOR && type != GRAVITY_SENSOR && type != LINEAR_ACCEL_SENSOR)
                return;
 
        float x, y;
@@ -250,7 +259,8 @@ gboolean sensor_event_listener::callback_dispatcher(gpointer data)
        if (cb_info->accuracy_cb)
                cb_info->accuracy_cb(cb_info->sensor, cb_info->timestamp, cb_info->accuracy, cb_info->accuracy_user_data);
 
-       ((sensor_cb_t) cb_info->cb)(cb_info->sensor, cb_info->event_type, (sensor_data_t *) cb_info->sensor_data.get(), cb_info->user_data);
+       sensor_event_listener::get_instance().align_sensor_axis(cb_info->sensor, (sensor_data_t *)cb_info->sensor_data.get());
+       ((sensor_cb_t) cb_info->cb)(cb_info->sensor, cb_info->event_type, (sensor_data_t *)cb_info->sensor_data.get(), cb_info->user_data);
 
        delete cb_info;
 
index 417d0ad..9631a63 100644 (file)
@@ -74,6 +74,8 @@ public:
        void clear(void);
 
        void set_hup_observer(hup_observer_t observer);
+
+       void set_sensor_axis(int axis);
        void set_display_rotation(int rt);
 
 private:
@@ -97,6 +99,8 @@ private:
        sensor_client_info &m_client_info;
 
        /* WC1's rotation control */
+       /* SENSORD_AXIS_DEVICE_ORIENTED, SENSORD_AXIS_DISPLAY_ORIENTED */
+       int m_axis;
        int m_display_rotation;
 
        sensor_event_listener();