summaryrefslogtreecommitdiffstats
path: root/services/sensorservice/SensorService.cpp
diff options
context:
space:
mode:
authorMathias Agopian <mathias@google.com>2010-07-21 15:59:50 -0700
committerMathias Agopian <mathias@google.com>2012-06-27 17:07:53 -0700
commit1cd700015318727d6d42236ab6274f1949fb08ba (patch)
treef209f8348eb9e6b7cbd5f6f03c2f8e21a622b548 /services/sensorservice/SensorService.cpp
parent50df2959e58fc7408f98d11d77c8428397dca445 (diff)
downloadframeworks_native-1cd700015318727d6d42236ab6274f1949fb08ba.zip
frameworks_native-1cd700015318727d6d42236ab6274f1949fb08ba.tar.gz
frameworks_native-1cd700015318727d6d42236ab6274f1949fb08ba.tar.bz2
propagate sensor event rate properly
Change-Id: I32e67d30e4295285a6827956cc8161b2025d70bc
Diffstat (limited to 'services/sensorservice/SensorService.cpp')
-rw-r--r--services/sensorservice/SensorService.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/services/sensorservice/SensorService.cpp b/services/sensorservice/SensorService.cpp
index fec9153..a4f6549 100644
--- a/services/sensorservice/SensorService.cpp
+++ b/services/sensorservice/SensorService.cpp
@@ -77,6 +77,9 @@ ANDROID_SINGLETON_STATIC_INSTANCE(BatteryService)
// ---------------------------------------------------------------------------
+// 100 events/s max
+static const nsecs_t MINIMUM_EVENT_PERIOD = ms2ns(10);
+
SensorService::SensorService()
: Thread(false),
mSensorDevice(0),
@@ -284,7 +287,6 @@ status_t SensorService::disable(const sp<SensorEventConnection>& connection,
status_t err = NO_ERROR;
Mutex::Autolock _l(mLock);
SensorRecord* rec = mActiveSensors.valueFor(handle);
- LOGW("sensor (handle=%d) is not enabled", handle);
if (rec) {
// see if this connection becomes inactive
connection->removeSensor(handle);
@@ -310,6 +312,12 @@ status_t SensorService::setRate(const sp<SensorEventConnection>& connection,
if (mInitCheck != NO_ERROR)
return mInitCheck;
+ if (ns < 0)
+ return BAD_VALUE;
+
+ if (ns < MINIMUM_EVENT_PERIOD)
+ ns = MINIMUM_EVENT_PERIOD;
+
status_t err = NO_ERROR;
Mutex::Autolock _l(mLock);