Loading services/sensorservice/SensorDevice.cpp +9 −0 Original line number Diff line number Diff line Loading @@ -111,6 +111,15 @@ ssize_t SensorDevice::poll(sensors_event_t* buffer, size_t count) { return c; } status_t SensorDevice::resetStateWithoutActuatingHardware(void *ident, int handle) { if (!mSensorDevice) return NO_INIT; Info& info( mActivationCount.editValueFor(handle)); Mutex::Autolock _l(mLock); info.rates.removeItem(ident); return NO_ERROR; } status_t SensorDevice::activate(void* ident, int handle, int enabled) { if (!mSensorDevice) return NO_INIT; Loading services/sensorservice/SensorDevice.h +1 −0 Original line number Diff line number Diff line Loading @@ -56,6 +56,7 @@ public: ssize_t poll(sensors_event_t* buffer, size_t count); status_t activate(void* ident, int handle, int enabled); status_t setDelay(void* ident, int handle, int64_t ns); status_t resetStateWithoutActuatingHardware(void *ident, int handle); void dump(String8& result, char* buffer, size_t SIZE); }; Loading services/sensorservice/SensorInterface.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -54,6 +54,10 @@ status_t HardwareSensor::setDelay(void* ident, int handle, int64_t ns) { return mSensorDevice.setDelay(ident, handle, ns); } status_t HardwareSensor::resetStateWithoutActuatingHardware(void *ident, int handle) { return mSensorDevice.resetStateWithoutActuatingHardware(ident, handle); } Sensor HardwareSensor::getSensor() const { return mSensor; } Loading services/sensorservice/SensorInterface.h +6 −0 Original line number Diff line number Diff line Loading @@ -40,6 +40,11 @@ public: virtual status_t setDelay(void* ident, int handle, int64_t ns) = 0; virtual Sensor getSensor() const = 0; virtual bool isVirtual() const = 0; virtual status_t resetStateWithoutActuatingHardware(void *ident, int handle) { // Override when you want to clean up for sensors which auto disable // after trigger, or when enabling sensors fail. return INVALID_OPERATION; } }; // --------------------------------------------------------------------------- Loading @@ -61,6 +66,7 @@ public: virtual status_t setDelay(void* ident, int handle, int64_t ns); virtual Sensor getSensor() const; virtual bool isVirtual() const { return false; } virtual status_t resetStateWithoutActuatingHardware(void *ident, int handle); }; Loading services/sensorservice/SensorService.cpp +11 −0 Original line number Diff line number Diff line Loading @@ -242,10 +242,18 @@ status_t SensorService::dump(int fd, const Vector<String16>& args) void SensorService::cleanupAutoDisabledSensor(const sp<SensorEventConnection>& connection, sensors_event_t const* buffer, const int count) { SensorInterface* sensor; status_t err = NO_ERROR; for (int i=0 ; i<count ; i++) { int handle = buffer[i].sensor; if (getSensorType(handle) == SENSOR_TYPE_SIGNIFICANT_MOTION) { if (connection->hasSensor(handle)) { sensor = mSensorMap.valueFor(handle); err = sensor ?sensor->resetStateWithoutActuatingHardware(connection.get(), handle) : status_t(BAD_VALUE); if (err != NO_ERROR) { ALOGE("Sensor Inteface: Resetting state failed with err: %d", err); } cleanupWithoutDisable(connection, handle); } } Loading Loading @@ -530,6 +538,9 @@ status_t SensorService::enable(const sp<SensorEventConnection>& connection, status_t err = sensor ? sensor->activate(connection.get(), true) : status_t(BAD_VALUE); if (err != NO_ERROR) { // enable has failed, reset state in SensorDevice. status_t resetErr = sensor ? sensor->resetStateWithoutActuatingHardware(connection.get(), handle) : status_t(BAD_VALUE); // enable has failed, reset our state. cleanupWithoutDisable(connection, handle); } Loading Loading
services/sensorservice/SensorDevice.cpp +9 −0 Original line number Diff line number Diff line Loading @@ -111,6 +111,15 @@ ssize_t SensorDevice::poll(sensors_event_t* buffer, size_t count) { return c; } status_t SensorDevice::resetStateWithoutActuatingHardware(void *ident, int handle) { if (!mSensorDevice) return NO_INIT; Info& info( mActivationCount.editValueFor(handle)); Mutex::Autolock _l(mLock); info.rates.removeItem(ident); return NO_ERROR; } status_t SensorDevice::activate(void* ident, int handle, int enabled) { if (!mSensorDevice) return NO_INIT; Loading
services/sensorservice/SensorDevice.h +1 −0 Original line number Diff line number Diff line Loading @@ -56,6 +56,7 @@ public: ssize_t poll(sensors_event_t* buffer, size_t count); status_t activate(void* ident, int handle, int enabled); status_t setDelay(void* ident, int handle, int64_t ns); status_t resetStateWithoutActuatingHardware(void *ident, int handle); void dump(String8& result, char* buffer, size_t SIZE); }; Loading
services/sensorservice/SensorInterface.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -54,6 +54,10 @@ status_t HardwareSensor::setDelay(void* ident, int handle, int64_t ns) { return mSensorDevice.setDelay(ident, handle, ns); } status_t HardwareSensor::resetStateWithoutActuatingHardware(void *ident, int handle) { return mSensorDevice.resetStateWithoutActuatingHardware(ident, handle); } Sensor HardwareSensor::getSensor() const { return mSensor; } Loading
services/sensorservice/SensorInterface.h +6 −0 Original line number Diff line number Diff line Loading @@ -40,6 +40,11 @@ public: virtual status_t setDelay(void* ident, int handle, int64_t ns) = 0; virtual Sensor getSensor() const = 0; virtual bool isVirtual() const = 0; virtual status_t resetStateWithoutActuatingHardware(void *ident, int handle) { // Override when you want to clean up for sensors which auto disable // after trigger, or when enabling sensors fail. return INVALID_OPERATION; } }; // --------------------------------------------------------------------------- Loading @@ -61,6 +66,7 @@ public: virtual status_t setDelay(void* ident, int handle, int64_t ns); virtual Sensor getSensor() const; virtual bool isVirtual() const { return false; } virtual status_t resetStateWithoutActuatingHardware(void *ident, int handle); }; Loading
services/sensorservice/SensorService.cpp +11 −0 Original line number Diff line number Diff line Loading @@ -242,10 +242,18 @@ status_t SensorService::dump(int fd, const Vector<String16>& args) void SensorService::cleanupAutoDisabledSensor(const sp<SensorEventConnection>& connection, sensors_event_t const* buffer, const int count) { SensorInterface* sensor; status_t err = NO_ERROR; for (int i=0 ; i<count ; i++) { int handle = buffer[i].sensor; if (getSensorType(handle) == SENSOR_TYPE_SIGNIFICANT_MOTION) { if (connection->hasSensor(handle)) { sensor = mSensorMap.valueFor(handle); err = sensor ?sensor->resetStateWithoutActuatingHardware(connection.get(), handle) : status_t(BAD_VALUE); if (err != NO_ERROR) { ALOGE("Sensor Inteface: Resetting state failed with err: %d", err); } cleanupWithoutDisable(connection, handle); } } Loading Loading @@ -530,6 +538,9 @@ status_t SensorService::enable(const sp<SensorEventConnection>& connection, status_t err = sensor ? sensor->activate(connection.get(), true) : status_t(BAD_VALUE); if (err != NO_ERROR) { // enable has failed, reset state in SensorDevice. status_t resetErr = sensor ? sensor->resetStateWithoutActuatingHardware(connection.get(), handle) : status_t(BAD_VALUE); // enable has failed, reset our state. cleanupWithoutDisable(connection, handle); } Loading