summaryrefslogtreecommitdiffstats
path: root/libsensors/AccelSensor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libsensors/AccelSensor.cpp')
-rw-r--r--libsensors/AccelSensor.cpp23
1 files changed, 14 insertions, 9 deletions
diff --git a/libsensors/AccelSensor.cpp b/libsensors/AccelSensor.cpp
index 72334be..7b6ba67 100644
--- a/libsensors/AccelSensor.cpp
+++ b/libsensors/AccelSensor.cpp
@@ -21,7 +21,8 @@
#include <unistd.h>
#include <dirent.h>
#include <sys/select.h>
-#include <utils/Log.h>
+#include <cutils/log.h>
+#include <cstring>
#include "AccelSensor.h"
@@ -31,6 +32,7 @@
AccelSensor::AccelSensor()
: SensorBase(NULL, "accelerometer_sensor"),
mEnabled(0),
+
mInputReader(4),
mHasPendingEvent(false)
{
@@ -49,7 +51,7 @@ AccelSensor::AccelSensor()
AccelSensor::~AccelSensor() {
- ALOGD("AccelSensor::~AccelSensor()");
+ // ALOGD("AccelSensor::~AccelSensor()");
if (mEnabled) {
enable(0, 0);
}
@@ -61,11 +63,12 @@ int AccelSensor::setInitialState()
}
int AccelSensor::enable(int32_t handle, int en) {
+ int flags = en ? 1 : 0;
int err;
- if (en != mEnabled) {
+ if (flags != mEnabled) {
err = sspEnable(LOGTAG, SSP_ACCEL, en);
if(err >= 0){
- mEnabled = en;
+ mEnabled = flags;
setInitialState();
return 0;
@@ -88,17 +91,19 @@ int AccelSensor::setDelay(int32_t handle, int64_t ns)
{
int fd;
- strcpy(&input_sysfs_path[input_sysfs_path_len], "acc_poll_delay");
+ if (ns < 10000000) {
+ ns = 10000000; // Minimum on stock
+ }
+
+ strcpy(&input_sysfs_path[input_sysfs_path_len], "poll_delay");
fd = open(input_sysfs_path, O_RDWR);
if (fd >= 0) {
char buf[80];
- sprintf(buf, "%lld", ns); // Some flooring to match stock value
+ sprintf(buf, "%lld", ns);
write(fd, buf, strlen(buf)+1);
close(fd);
return 0;
}
-
- ALOGD("AccelSensor: fail to set delay through %s.", input_sysfs_path);
return -1;
}
@@ -146,6 +151,6 @@ int AccelSensor::readEvents(sensors_event_t* data, int count)
mInputReader.next();
}
- return numEventReceived;
+ return numEventReceived++;
}