diff options
author | Mathias Agopian <mathias@google.com> | 2010-11-11 17:58:51 -0800 |
---|---|---|
committer | Mathias Agopian <mathias@google.com> | 2010-11-18 15:29:05 -0800 |
commit | 671a6ff4be11b3e2d8eb017e0c7a78e6133fb2b8 (patch) | |
tree | 569c08c41c6c810c99395279283f6e1c812fc51d /services/sensorservice/SensorService.h | |
parent | 80381ab4ed44bd69c3e3464a848ca15851365b03 (diff) | |
download | frameworks_base-671a6ff4be11b3e2d8eb017e0c7a78e6133fb2b8.zip frameworks_base-671a6ff4be11b3e2d8eb017e0c7a78e6133fb2b8.tar.gz frameworks_base-671a6ff4be11b3e2d8eb017e0c7a78e6133fb2b8.tar.bz2 |
Add support for virtual sensors.
Rework sensorservice to allow "virtual sensors", that is
sensors that report a synthetized value based on real sensors.
the main change to sensorservice is around managing which real
sensor need to be activated and which rate to use.
The logic for all this has been moved into SensorDevice, which
essentially wraps the sensor HAL but adds two features to it:
- it keeps track of which sensors need to be activated
- it keeps track of what rate needs to be used
For this purpose an "identity" is associated with each real sensor
activation, so we can track them.
On start-up we check for gravity, linear-acceleration and
rotation-vector sensors, if they're not present in the HAL, we
synthetize them in sensor-service.
Change-Id: I841db2c1b37ef127ed571efa21732ecc5adf1800
Diffstat (limited to 'services/sensorservice/SensorService.h')
-rw-r--r-- | services/sensorservice/SensorService.h | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/services/sensorservice/SensorService.h b/services/sensorservice/SensorService.h index c0922f5..540c7e2 100644 --- a/services/sensorservice/SensorService.h +++ b/services/sensorservice/SensorService.h @@ -34,6 +34,8 @@ #include <gui/ISensorServer.h> #include <gui/ISensorEventConnection.h> +#include "SensorInterface.h" + // --------------------------------------------------------------------------- struct sensors_poll_device_t; @@ -50,7 +52,6 @@ class SensorService : friend class BinderService<SensorService>; static const nsecs_t MINIMUM_EVENTS_PERIOD = 1000000; // 1000 Hz - static const nsecs_t DEFAULT_EVENTS_PERIOD = 200000000; // 5 Hz SensorService(); virtual ~SensorService(); @@ -77,12 +78,8 @@ class SensorService : sp<SensorChannel> const mChannel; mutable Mutex mConnectionLock; - // protected mConnectionLock - struct SensorInfo { - SensorInfo() : ns(DEFAULT_EVENTS_PERIOD) { } - nsecs_t ns; - }; - DefaultKeyedVector<int32_t, SensorInfo> mSensorInfo; + // protected by SensorService::mLock + SortedVector<int> mSensorInfo; public: SensorEventConnection(const sp<SensorService>& service); @@ -93,10 +90,6 @@ class SensorService : bool hasAnySensor() const; bool addSensor(int32_t handle); bool removeSensor(int32_t handle); - status_t setEventRateLocked(int handle, nsecs_t ns); - nsecs_t getEventRateForSensor(int32_t handle) const { - return mSensorInfo.valueFor(handle).ns; - } }; class SensorRecord { @@ -109,21 +102,25 @@ class SensorService : }; SortedVector< wp<SensorEventConnection> > getActiveConnections() const; - String8 getSensorName(int handle) const; - status_t recomputeEventsPeriodLocked(int32_t handle); + DefaultKeyedVector<int, SensorInterface*> getActiveVirtualSensors() const; + String8 getSensorName(int handle) const; void recordLastValue(sensors_event_t const * buffer, size_t count); + static void sortEventBuffer(sensors_event_t* buffer, size_t count); + void registerSensor(SensorInterface* sensor); + void registerVirtualSensor(SensorInterface* sensor); // constants Vector<Sensor> mSensorList; - struct sensors_poll_device_t* mSensorDevice; - struct sensors_module_t* mSensorModule; + DefaultKeyedVector<int, SensorInterface*> mSensorMap; + Vector<SensorInterface *> mVirtualSensorList; Permission mDump; status_t mInitCheck; // protected by mLock mutable Mutex mLock; DefaultKeyedVector<int, SensorRecord*> mActiveSensors; + DefaultKeyedVector<int, SensorInterface*> mActiveVirtualSensors; SortedVector< wp<SensorEventConnection> > mActiveConnections; // The size of this vector is constant, only the items are mutable |