Loading include/gui/Sensor.h +2 −1 Original line number Diff line number Diff line Loading @@ -71,6 +71,7 @@ public: int32_t getFifoMaxEventCount() const; const String8& getStringType() const; const String8& getRequiredPermission() const; int32_t getMaxDelay() const; bool isWakeUpSensor() const; // LightFlattenable protocol Loading @@ -94,7 +95,7 @@ private: int32_t mFifoMaxEventCount; String8 mStringType; String8 mRequiredPermission; // Todo: Surface this in java SDK. int32_t mMaxDelay; bool mWakeUpSensor; static void flattenString8(void*& buffer, size_t& size, const String8& string8); static bool unflattenString8(void const*& buffer, size_t& size, String8& outputString8); Loading libs/gui/Sensor.cpp +29 −3 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ #include <stdint.h> #include <sys/types.h> #include <sys/limits.h> #include <utils/Errors.h> #include <utils/String8.h> Loading @@ -24,6 +25,7 @@ #include <hardware/sensors.h> #include <gui/Sensor.h> #include <log/log.h> // ---------------------------------------------------------------------------- namespace android { Loading @@ -33,7 +35,7 @@ Sensor::Sensor() : mHandle(0), mType(0), mMinValue(0), mMaxValue(0), mResolution(0), mPower(0), mMinDelay(0), mFifoReservedEventCount(0), mFifoMaxEventCount(0), mWakeUpSensor(false) mMaxDelay(0), mWakeUpSensor(false) { } Loading Loading @@ -61,6 +63,20 @@ Sensor::Sensor(struct sensor_t const* hwSensor, int halVersion) mFifoMaxEventCount = 0; } if (halVersion >= SENSORS_DEVICE_API_VERSION_1_3) { if (hwSensor->maxDelay > INT_MAX) { // Max delay is declared as a 64 bit integer for 64 bit architectures. But it should // always fit in a 32 bit integer, log error and cap it to INT_MAX. ALOGE("Sensor maxDelay overflow error %s %lld", mName.string(), hwSensor->maxDelay); mMaxDelay = INT_MAX; } else { mMaxDelay = (int32_t) hwSensor->maxDelay; } } else { // For older hals set maxDelay to 0. mMaxDelay = 0; } // Ensure existing sensors have correct string type and required // permissions. switch (mType) { Loading Loading @@ -289,6 +305,10 @@ const String8& Sensor::getRequiredPermission() const { return mRequiredPermission; } int32_t Sensor::getMaxDelay() const { return mMaxDelay; } bool Sensor::isWakeUpSensor() const { return mWakeUpSensor; } Loading @@ -298,7 +318,8 @@ size_t Sensor::getFlattenedSize() const size_t fixedSize = sizeof(int32_t) * 3 + sizeof(float) * 4 + sizeof(int32_t) * 3; sizeof(int32_t) * 4 + sizeof(bool) * 1; size_t variableSize = sizeof(uint32_t) + FlattenableUtils::align<4>(mName.length()) + Loading Loading @@ -328,6 +349,8 @@ status_t Sensor::flatten(void* buffer, size_t size) const { FlattenableUtils::write(buffer, size, mFifoMaxEventCount); flattenString8(buffer, size, mStringType); flattenString8(buffer, size, mRequiredPermission); FlattenableUtils::write(buffer, size, mMaxDelay); FlattenableUtils::write(buffer, size, mWakeUpSensor); return NO_ERROR; } Loading @@ -342,7 +365,8 @@ status_t Sensor::unflatten(void const* buffer, size_t size) { size_t fixedSize = sizeof(int32_t) * 3 + sizeof(float) * 4 + sizeof(int32_t) * 3; sizeof(int32_t) * 4 + sizeof(bool) * 1; if (size < fixedSize) { return NO_MEMORY; } Loading @@ -364,6 +388,8 @@ status_t Sensor::unflatten(void const* buffer, size_t size) { if (!unflattenString8(buffer, size, mRequiredPermission)) { return NO_MEMORY; } FlattenableUtils::read(buffer, size, mMaxDelay); FlattenableUtils::read(buffer, size, mWakeUpSensor); return NO_ERROR; } Loading services/sensorservice/SensorInterface.cpp +0 −3 Original line number Diff line number Diff line Loading @@ -17,8 +17,6 @@ #include <stdint.h> #include <sys/types.h> #include <cutils/log.h> #include "SensorInterface.h" namespace android { Loading @@ -34,7 +32,6 @@ HardwareSensor::HardwareSensor(const sensor_t& sensor) : mSensorDevice(SensorDevice::getInstance()), mSensor(&sensor, mSensorDevice.getHalDeviceVersion()) { ALOGI("%s", sensor.name); } HardwareSensor::~HardwareSensor() { Loading services/sensorservice/SensorService.cpp +0 −1 Original line number Diff line number Diff line Loading @@ -159,7 +159,6 @@ void SensorService::onFirstRef() mSocketBufferSize = MAX_SOCKET_BUFFER_SIZE_BATCHED; } } ALOGD("Max socket buffer size %u", mSocketBufferSize); if (fp) { fclose(fp); } Loading Loading
include/gui/Sensor.h +2 −1 Original line number Diff line number Diff line Loading @@ -71,6 +71,7 @@ public: int32_t getFifoMaxEventCount() const; const String8& getStringType() const; const String8& getRequiredPermission() const; int32_t getMaxDelay() const; bool isWakeUpSensor() const; // LightFlattenable protocol Loading @@ -94,7 +95,7 @@ private: int32_t mFifoMaxEventCount; String8 mStringType; String8 mRequiredPermission; // Todo: Surface this in java SDK. int32_t mMaxDelay; bool mWakeUpSensor; static void flattenString8(void*& buffer, size_t& size, const String8& string8); static bool unflattenString8(void const*& buffer, size_t& size, String8& outputString8); Loading
libs/gui/Sensor.cpp +29 −3 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ #include <stdint.h> #include <sys/types.h> #include <sys/limits.h> #include <utils/Errors.h> #include <utils/String8.h> Loading @@ -24,6 +25,7 @@ #include <hardware/sensors.h> #include <gui/Sensor.h> #include <log/log.h> // ---------------------------------------------------------------------------- namespace android { Loading @@ -33,7 +35,7 @@ Sensor::Sensor() : mHandle(0), mType(0), mMinValue(0), mMaxValue(0), mResolution(0), mPower(0), mMinDelay(0), mFifoReservedEventCount(0), mFifoMaxEventCount(0), mWakeUpSensor(false) mMaxDelay(0), mWakeUpSensor(false) { } Loading Loading @@ -61,6 +63,20 @@ Sensor::Sensor(struct sensor_t const* hwSensor, int halVersion) mFifoMaxEventCount = 0; } if (halVersion >= SENSORS_DEVICE_API_VERSION_1_3) { if (hwSensor->maxDelay > INT_MAX) { // Max delay is declared as a 64 bit integer for 64 bit architectures. But it should // always fit in a 32 bit integer, log error and cap it to INT_MAX. ALOGE("Sensor maxDelay overflow error %s %lld", mName.string(), hwSensor->maxDelay); mMaxDelay = INT_MAX; } else { mMaxDelay = (int32_t) hwSensor->maxDelay; } } else { // For older hals set maxDelay to 0. mMaxDelay = 0; } // Ensure existing sensors have correct string type and required // permissions. switch (mType) { Loading Loading @@ -289,6 +305,10 @@ const String8& Sensor::getRequiredPermission() const { return mRequiredPermission; } int32_t Sensor::getMaxDelay() const { return mMaxDelay; } bool Sensor::isWakeUpSensor() const { return mWakeUpSensor; } Loading @@ -298,7 +318,8 @@ size_t Sensor::getFlattenedSize() const size_t fixedSize = sizeof(int32_t) * 3 + sizeof(float) * 4 + sizeof(int32_t) * 3; sizeof(int32_t) * 4 + sizeof(bool) * 1; size_t variableSize = sizeof(uint32_t) + FlattenableUtils::align<4>(mName.length()) + Loading Loading @@ -328,6 +349,8 @@ status_t Sensor::flatten(void* buffer, size_t size) const { FlattenableUtils::write(buffer, size, mFifoMaxEventCount); flattenString8(buffer, size, mStringType); flattenString8(buffer, size, mRequiredPermission); FlattenableUtils::write(buffer, size, mMaxDelay); FlattenableUtils::write(buffer, size, mWakeUpSensor); return NO_ERROR; } Loading @@ -342,7 +365,8 @@ status_t Sensor::unflatten(void const* buffer, size_t size) { size_t fixedSize = sizeof(int32_t) * 3 + sizeof(float) * 4 + sizeof(int32_t) * 3; sizeof(int32_t) * 4 + sizeof(bool) * 1; if (size < fixedSize) { return NO_MEMORY; } Loading @@ -364,6 +388,8 @@ status_t Sensor::unflatten(void const* buffer, size_t size) { if (!unflattenString8(buffer, size, mRequiredPermission)) { return NO_MEMORY; } FlattenableUtils::read(buffer, size, mMaxDelay); FlattenableUtils::read(buffer, size, mWakeUpSensor); return NO_ERROR; } Loading
services/sensorservice/SensorInterface.cpp +0 −3 Original line number Diff line number Diff line Loading @@ -17,8 +17,6 @@ #include <stdint.h> #include <sys/types.h> #include <cutils/log.h> #include "SensorInterface.h" namespace android { Loading @@ -34,7 +32,6 @@ HardwareSensor::HardwareSensor(const sensor_t& sensor) : mSensorDevice(SensorDevice::getInstance()), mSensor(&sensor, mSensorDevice.getHalDeviceVersion()) { ALOGI("%s", sensor.name); } HardwareSensor::~HardwareSensor() { Loading
services/sensorservice/SensorService.cpp +0 −1 Original line number Diff line number Diff line Loading @@ -159,7 +159,6 @@ void SensorService::onFirstRef() mSocketBufferSize = MAX_SOCKET_BUFFER_SIZE_BATCHED; } } ALOGD("Max socket buffer size %u", mSocketBufferSize); if (fp) { fclose(fp); } Loading