Loading include/gui/Sensor.h +2 −0 Original line number Diff line number Diff line Loading @@ -63,6 +63,7 @@ public: float getMaxValue() const; float getResolution() const; float getPowerUsage() const; int32_t getMinDelay() const; // Flattenable interface virtual size_t getFlattenedSize() const; Loading @@ -81,6 +82,7 @@ private: float mMaxValue; float mResolution; float mPower; int32_t mMinDelay; }; // ---------------------------------------------------------------------------- Loading include/gui/SensorEventQueue.h +1 −1 Original line number Diff line number Diff line Loading @@ -65,7 +65,7 @@ public: status_t setEventRate(Sensor const* sensor, nsecs_t ns) const; // these are here only to support SensorManager.java status_t enableSensor(int32_t handle, int32_t ms) const; status_t enableSensor(int32_t handle, int32_t us) const; status_t disableSensor(int32_t handle) const; private: Loading libs/gui/Sensor.cpp +10 −2 Original line number Diff line number Diff line Loading @@ -32,7 +32,7 @@ namespace android { Sensor::Sensor() : mHandle(0), mType(0), mMinValue(0), mMaxValue(0), mResolution(0), mPower(0) mPower(0), mMinDelay(0) { } Loading @@ -46,6 +46,7 @@ Sensor::Sensor(struct sensor_t const* hwSensor) mMaxValue = hwSensor->maxRange; // FIXME: maxValue mResolution = hwSensor->resolution; mPower = hwSensor->power; mMinDelay = hwSensor->minDelay; } Sensor::~Sensor() Loading Loading @@ -84,12 +85,17 @@ float Sensor::getPowerUsage() const { return mPower; } int32_t Sensor::getMinDelay() const { return mMinDelay; } size_t Sensor::getFlattenedSize() const { return sizeof(int32_t) + ((mName.length() + 3) & ~3) + sizeof(int32_t) + ((mVendor.length() + 3) & ~3) + sizeof(int32_t) * 2 + sizeof(float) * 4; sizeof(float) * 4 + sizeof(int32_t); } size_t Sensor::getFdCount() const Loading Loading @@ -132,6 +138,7 @@ status_t Sensor::flatten(void* buffer, size_t size, offset += write(buffer, offset, mMaxValue); offset += write(buffer, offset, mResolution); offset += write(buffer, offset, mPower); offset += write(buffer, offset, mMinDelay); return NO_ERROR; } Loading Loading @@ -169,6 +176,7 @@ status_t Sensor::unflatten(void const* buffer, size_t size, offset += read(buffer, offset, &mMaxValue); offset += read(buffer, offset, &mResolution); offset += read(buffer, offset, &mPower); offset += read(buffer, offset, &mMinDelay); return NO_ERROR; } Loading libs/gui/SensorEventQueue.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -114,10 +114,10 @@ status_t SensorEventQueue::disableSensor(Sensor const* sensor) const { return mSensorEventConnection->enableDisable(sensor->getHandle(), false); } status_t SensorEventQueue::enableSensor(int32_t handle, int32_t ms) const { status_t SensorEventQueue::enableSensor(int32_t handle, int32_t us) const { status_t err = mSensorEventConnection->enableDisable(handle, true); if (err == NO_ERROR) { mSensorEventConnection->setEventRate(handle, ms2ns(ms)); mSensorEventConnection->setEventRate(handle, us2ns(us)); } return err; } Loading Loading
include/gui/Sensor.h +2 −0 Original line number Diff line number Diff line Loading @@ -63,6 +63,7 @@ public: float getMaxValue() const; float getResolution() const; float getPowerUsage() const; int32_t getMinDelay() const; // Flattenable interface virtual size_t getFlattenedSize() const; Loading @@ -81,6 +82,7 @@ private: float mMaxValue; float mResolution; float mPower; int32_t mMinDelay; }; // ---------------------------------------------------------------------------- Loading
include/gui/SensorEventQueue.h +1 −1 Original line number Diff line number Diff line Loading @@ -65,7 +65,7 @@ public: status_t setEventRate(Sensor const* sensor, nsecs_t ns) const; // these are here only to support SensorManager.java status_t enableSensor(int32_t handle, int32_t ms) const; status_t enableSensor(int32_t handle, int32_t us) const; status_t disableSensor(int32_t handle) const; private: Loading
libs/gui/Sensor.cpp +10 −2 Original line number Diff line number Diff line Loading @@ -32,7 +32,7 @@ namespace android { Sensor::Sensor() : mHandle(0), mType(0), mMinValue(0), mMaxValue(0), mResolution(0), mPower(0) mPower(0), mMinDelay(0) { } Loading @@ -46,6 +46,7 @@ Sensor::Sensor(struct sensor_t const* hwSensor) mMaxValue = hwSensor->maxRange; // FIXME: maxValue mResolution = hwSensor->resolution; mPower = hwSensor->power; mMinDelay = hwSensor->minDelay; } Sensor::~Sensor() Loading Loading @@ -84,12 +85,17 @@ float Sensor::getPowerUsage() const { return mPower; } int32_t Sensor::getMinDelay() const { return mMinDelay; } size_t Sensor::getFlattenedSize() const { return sizeof(int32_t) + ((mName.length() + 3) & ~3) + sizeof(int32_t) + ((mVendor.length() + 3) & ~3) + sizeof(int32_t) * 2 + sizeof(float) * 4; sizeof(float) * 4 + sizeof(int32_t); } size_t Sensor::getFdCount() const Loading Loading @@ -132,6 +138,7 @@ status_t Sensor::flatten(void* buffer, size_t size, offset += write(buffer, offset, mMaxValue); offset += write(buffer, offset, mResolution); offset += write(buffer, offset, mPower); offset += write(buffer, offset, mMinDelay); return NO_ERROR; } Loading Loading @@ -169,6 +176,7 @@ status_t Sensor::unflatten(void const* buffer, size_t size, offset += read(buffer, offset, &mMaxValue); offset += read(buffer, offset, &mResolution); offset += read(buffer, offset, &mPower); offset += read(buffer, offset, &mMinDelay); return NO_ERROR; } Loading
libs/gui/SensorEventQueue.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -114,10 +114,10 @@ status_t SensorEventQueue::disableSensor(Sensor const* sensor) const { return mSensorEventConnection->enableDisable(sensor->getHandle(), false); } status_t SensorEventQueue::enableSensor(int32_t handle, int32_t ms) const { status_t SensorEventQueue::enableSensor(int32_t handle, int32_t us) const { status_t err = mSensorEventConnection->enableDisable(handle, true); if (err == NO_ERROR) { mSensorEventConnection->setEventRate(handle, ms2ns(ms)); mSensorEventConnection->setEventRate(handle, us2ns(us)); } return err; } Loading