From: TaeminYeom Date: Mon, 22 Aug 2022 08:02:06 +0000 (+0900) Subject: Change auto-rotation sensor policy X-Git-Tag: accepted/tizen/unified/20220919.021610~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8b99510e5381dd93698dd673175c12bcdcfc8cf7;p=platform%2Fcore%2Fsystem%2Fsensord.git Change auto-rotation sensor policy -Clients can read the last value of rotation many times -Default rotation degree is 0 Change-Id: I36d1f9e0ecf1106862be1421bb52f9936816dff7 Signed-off-by: TaeminYeom --- diff --git a/src/fusion-sensor/auto_rotation/auto_rotation_alg_emul.cpp b/src/fusion-sensor/auto_rotation/auto_rotation_alg_emul.cpp index 0136b757..601f817c 100644 --- a/src/fusion-sensor/auto_rotation/auto_rotation_alg_emul.cpp +++ b/src/fusion-sensor/auto_rotation/auto_rotation_alg_emul.cpp @@ -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; } diff --git a/src/server/sensor_handler.cpp b/src/server/sensor_handler.cpp index dee6b974..dab4570f 100644 --- a/src/server/sensor_handler.cpp +++ b/src/server/sensor_handler.cpp @@ -26,6 +26,8 @@ #include #include +#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; }