summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRicardo Cerqueira <ricardo@cyngn.com>2014-09-04 17:54:36 +0100
committerRicardo Cerqueira <ricardo@cyngn.com>2014-09-04 17:54:36 +0100
commit101c55d0b91557fa7a46b611b06fb343b5321936 (patch)
treeb519caaf4eceea68c06bed069c7c685bfe0cc25d
parent03283a4630eace5af6ac3de9f2bff17adc0521c8 (diff)
downloaddevice_samsung_i9100-101c55d0b91557fa7a46b611b06fb343b5321936.zip
device_samsung_i9100-101c55d0b91557fa7a46b611b06fb343b5321936.tar.gz
device_samsung_i9100-101c55d0b91557fa7a46b611b06fb343b5321936.tar.bz2
sensors: Force a minimum interval between gyro state changes
The gyroscope will mess up the entire sensor pile if it gets deactivated less than around 150 msec after it's enabled, which does happen with some overly aggressive apps. Prevent this simply by delaying all gyro disablements by 200 msec. Change-Id: I8212a8aa4beb22a241ed63cc8d1471b4fea3d0b6
-rw-r--r--libsensors/sensors.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/libsensors/sensors.cpp b/libsensors/sensors.cpp
index d57f65a..e393cd5 100644
--- a/libsensors/sensors.cpp
+++ b/libsensors/sensors.cpp
@@ -210,6 +210,9 @@ sensors_poll_context_t::~sensors_poll_context_t() {
int sensors_poll_context_t::activate(int handle, int enabled) {
int index = handleToDriver(handle);
if (index < 0) return index;
+ if (index == gyro && enabled == 0) {
+ usleep(200*1000);
+ }
int err = mSensors[index]->enable(handle, enabled);
if (enabled && !err) {
const char wakeMessage(WAKE_MESSAGE);
@@ -311,7 +314,7 @@ static int open_sensors(const struct hw_module_t* module, const char* id,
memset(&dev->device, 0, sizeof(sensors_poll_device_t));
dev->device.common.tag = HARDWARE_DEVICE_TAG;
- dev->device.common.version = 0;
+ dev->device.common.version = SENSORS_DEVICE_API_VERSION_0_1;
dev->device.common.module = const_cast<hw_module_t*>(module);
dev->device.common.close = poll__close;
dev->device.activate = poll__activate;