Change auto-rotation sensor policy 09/280009/2
authorTaeminYeom <taemin.yeom@samsung.com>
Mon, 22 Aug 2022 08:02:06 +0000 (17:02 +0900)
committerTaemin Yeom <taemin.yeom@samsung.com>
Tue, 23 Aug 2022 06:25:05 +0000 (06:25 +0000)
-Clients can read the last value of rotation many times
-Default rotation degree is 0

Change-Id: I36d1f9e0ecf1106862be1421bb52f9936816dff7
Signed-off-by: TaeminYeom <taemin.yeom@samsung.com>
src/fusion-sensor/auto_rotation/auto_rotation_alg_emul.cpp
src/server/sensor_handler.cpp

index 0136b757f81bbd50366cec61d768fbb57d758170..601f817c1a2770000e9001952f863e22c20c936f 100644 (file)
@@ -106,13 +106,20 @@ bool auto_rotation_alg_emul::get_rotation(float acc[3],
        realg = (double)sqrt((x * x) + (y * y) + (z * z));
        acc_pitch = ROTATION_90 - abs((int) (asin(z / realg) * RADIAN));
 
-       cur_rotation = convert_rotation(prev_rotation, acc_pitch, acc_theta);
+       int new_rotation = convert_rotation(prev_rotation, acc_pitch, acc_theta);
 
-       if (cur_rotation == AUTO_ROTATION_DEGREE_UNKNOWN)
+       if (new_rotation == AUTO_ROTATION_DEGREE_UNKNOWN) {
+               if (prev_rotation == AUTO_ROTATION_DEGREE_UNKNOWN) {
+                       cur_rotation = AUTO_ROTATION_DEGREE_0; /* default degree is 0 */
+                       return true;
+               }
                return false;
+       }
 
-       if (cur_rotation != prev_rotation)
+       if (new_rotation != prev_rotation) {
+               cur_rotation = new_rotation;
                return true;
+       }
 
        return false;
 }
index dee6b974e1822b5f869ca186b307cdc0fcf22bf0..dab4570f144a544ef0ccd3529875113a97fc5f37 100644 (file)
@@ -26,6 +26,8 @@
 #include <command_types.h>
 #include <sensor_listener_proxy.h>
 
+#define AUTO_ROTATION "http://tizen.org/sensor/general/auto_rotation/tizen_default"
+
 using namespace sensor;
 
 sensor_handler::sensor_handler(const sensor_info &info)
@@ -125,7 +127,9 @@ int sensor_handler::get_cache(sensor_data_t **data, int *len)
        *len = size;
        *data = (sensor_data_t *)temp;
 
-       m_sensor_data_cache.clear();
+       if (m_info.get_uri() != AUTO_ROTATION)
+               m_sensor_data_cache.clear();
+
        return 0;
 }