BuildRequires: pkgconfig(glib-2.0)
BuildRequires: pkgconfig(vconf)
BuildRequires: pkgconfig(libsystemd)
+BuildRequires: pkgconfig(libsyscommon)
BuildRequires: pkgconfig(libtzplatform-config)
BuildRequires: pkgconfig(cynara-creds-socket)
BuildRequires: pkgconfig(cynara-client)
install -m 0644 %SOURCE1 %{buildroot}%{_unitdir}
install -m 0644 %SOURCE2 %{buildroot}%{_unitdir}
+mkdir -p %{buildroot}%{_sysconfdir}/sensord
+install -m 644 conf/auto_rotation.conf %{buildroot}/etc/sensord/auto_rotation.conf
+
%install_service multi-user.target.wants sensord.service
%install_service sockets.target.wants sensord.socket
%{_unitdir}/sensord.socket
%{_unitdir}/multi-user.target.wants/sensord.service
%{_unitdir}/sockets.target.wants/sensord.socket
+%config %{_sysconfdir}/sensord/auto_rotation.conf
%license LICENSE.APLv2
#include <math.h>
#include <stdlib.h>
+#include <sensor_log.h>
#include <sensor_types.h>
+#include <libsyscommon/ini-parser.h>
-#define ROTATION_RULE_CNT 4
+#define ROTATION_RULE_CNT 4
+#define AUTO_ROTATION_CONF_PATH "/etc/sensord/auto_rotation.conf"
+
+static struct auto_rotation_config auto_rotation_conf = {
+ .fix = false,
+ .value = 0,
+};
struct rotation_rule {
int tilt;
{90, 60},
};
+int auto_rotation_load_config(struct parse_result *result, void *user_data)
+{
+ struct auto_rotation_config *c = (struct auto_rotation_config*) user_data;
+
+ if (!MATCH(result->section, "AutoRotation"))
+ return 0;
+
+ if (MATCH(result->name, "Fix"))
+ c->fix = (MATCH(result->value, "yes") ? 1 : 0);
+ else if (MATCH(result->name, "DefaultValue"))
+ SET_CONF(c->value, atoi(result->value));
+
+ return 0;
+}
+
auto_rotation_alg_emul::auto_rotation_alg_emul()
{
+ int ret = config_parse(AUTO_ROTATION_CONF_PATH, auto_rotation_load_config, &auto_rotation_conf);
+ if (ret < 0)
+ _D("Failed to load '%s', so use default config", AUTO_ROTATION_CONF_PATH);
}
auto_rotation_alg_emul::~auto_rotation_alg_emul()
bool auto_rotation_alg_emul::get_rotation(float acc[3],
unsigned long long timestamp, int prev_rotation, int &cur_rotation)
{
+ if (auto_rotation_conf.fix) {
+ if (auto_rotation_conf.value == 0) {
+ cur_rotation = AUTO_ROTATION_DEGREE_0;
+ }
+ else if (auto_rotation_conf.value == 90) {
+ cur_rotation = AUTO_ROTATION_DEGREE_90;
+ }
+ else if (auto_rotation_conf.value == 180) {
+ cur_rotation = AUTO_ROTATION_DEGREE_180;
+ }
+ else if (auto_rotation_conf.value == 270) {
+ cur_rotation = AUTO_ROTATION_DEGREE_270;
+ }
+
+ if (prev_rotation == 0)
+ return true;
+ else
+ return false;
+ }
+
const int ROTATION_90 = 90;
const int RADIAN = 57.29747;
if (new_rotation == AUTO_ROTATION_DEGREE_UNKNOWN) {
if (prev_rotation == AUTO_ROTATION_DEGREE_UNKNOWN) {
- cur_rotation = AUTO_ROTATION_DEGREE_0; /* default degree is 0 */
+ if (auto_rotation_conf.value == 0) {
+ cur_rotation = AUTO_ROTATION_DEGREE_0;
+ }
+ else if (auto_rotation_conf.value == 90) {
+ cur_rotation = AUTO_ROTATION_DEGREE_90;
+ }
+ else if (auto_rotation_conf.value == 180) {
+ cur_rotation = AUTO_ROTATION_DEGREE_180;
+ }
+ else if (auto_rotation_conf.value == 270) {
+ cur_rotation = AUTO_ROTATION_DEGREE_270;
+ }
+ else {
+ cur_rotation = AUTO_ROTATION_DEGREE_0; /* if there is no conf, default degree is 0 */
+ }
return true;
}
+
return false;
}