diff options
author | Mathias Agopian <mathias@google.com> | 2013-07-12 14:19:10 -0700 |
---|---|---|
committer | Mathias Agopian <mathias@google.com> | 2013-07-12 14:19:10 -0700 |
commit | cdd7d8bc145bbbd21a1689ed87a381287aeec229 (patch) | |
tree | 3c1baae72f829e2fa0e0412bcee629deeabc7728 /services | |
parent | 1bd5068a5180ac12dda374e15c7b1f70e8334284 (diff) | |
parent | 00aea5c5ff9e951024c5751fcce2e8f5602a6460 (diff) | |
download | frameworks_native-cdd7d8bc145bbbd21a1689ed87a381287aeec229.zip frameworks_native-cdd7d8bc145bbbd21a1689ed87a381287aeec229.tar.gz frameworks_native-cdd7d8bc145bbbd21a1689ed87a381287aeec229.tar.bz2 |
resolved conflicts for merge of 00aea5c5 to master
Change-Id: Ie1769be863ee2d411eae451907a928db57882e14
Diffstat (limited to 'services')
-rw-r--r-- | services/sensorservice/SensorDevice.cpp | 16 | ||||
-rw-r--r-- | services/sensorservice/SensorDevice.h | 2 | ||||
-rw-r--r-- | services/sensorservice/SensorInterface.cpp | 4 | ||||
-rw-r--r-- | services/sensorservice/SensorInterface.h | 8 | ||||
-rw-r--r-- | services/sensorservice/SensorService.cpp | 33 | ||||
-rw-r--r-- | services/sensorservice/SensorService.h | 6 |
6 files changed, 38 insertions, 31 deletions
diff --git a/services/sensorservice/SensorDevice.cpp b/services/sensorservice/SensorDevice.cpp index 18a1523..2fa5dbd 100644 --- a/services/sensorservice/SensorDevice.cpp +++ b/services/sensorservice/SensorDevice.cpp @@ -107,13 +107,10 @@ 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)); +void SensorDevice::autoDisable(void *ident, int handle) { + 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) @@ -164,6 +161,15 @@ status_t SensorDevice::activate(void* ident, int handle, int enabled) ALOGE_IF(err, "Error %s sensor %d (%s)", enabled ? "activating" : "disabling", handle, strerror(-err)); + + if (err != NO_ERROR) { + // clean-up on failure + if (enabled) { + // failure when enabling the sensor + Mutex::Autolock _l(mLock); + info.rates.removeItem(ident); + } + } } { // scope for the lock diff --git a/services/sensorservice/SensorDevice.h b/services/sensorservice/SensorDevice.h index ca67ce2..b50e205 100644 --- a/services/sensorservice/SensorDevice.h +++ b/services/sensorservice/SensorDevice.h @@ -56,7 +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 autoDisable(void *ident, int handle); void dump(String8& result); }; diff --git a/services/sensorservice/SensorInterface.cpp b/services/sensorservice/SensorInterface.cpp index cf0a11d..b483b75 100644 --- a/services/sensorservice/SensorInterface.cpp +++ b/services/sensorservice/SensorInterface.cpp @@ -54,8 +54,8 @@ 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); +void HardwareSensor::autoDisable(void *ident, int handle) { + mSensorDevice.autoDisable(ident, handle); } Sensor HardwareSensor::getSensor() const { diff --git a/services/sensorservice/SensorInterface.h b/services/sensorservice/SensorInterface.h index 2e709ae..2e14e57 100644 --- a/services/sensorservice/SensorInterface.h +++ b/services/sensorservice/SensorInterface.h @@ -40,11 +40,7 @@ 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; - } + virtual void autoDisable(void *ident, int handle) { } }; // --------------------------------------------------------------------------- @@ -66,7 +62,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); + virtual void autoDisable(void *ident, int handle); }; diff --git a/services/sensorservice/SensorService.cpp b/services/sensorservice/SensorService.cpp index 99993ba..e3d2a60 100644 --- a/services/sensorservice/SensorService.cpp +++ b/services/sensorservice/SensorService.cpp @@ -274,10 +274,8 @@ void SensorService::cleanupAutoDisabledSensor(const sp<SensorEventConnection>& c if (type == 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); + if (sensor != NULL) { + sensor->autoDisable(connection.get(), handle); } cleanupWithoutDisable(connection, handle); } @@ -509,8 +507,12 @@ status_t SensorService::enable(const sp<SensorEventConnection>& connection, if (mInitCheck != NO_ERROR) return mInitCheck; - Mutex::Autolock _l(mLock); SensorInterface* sensor = mSensorMap.valueFor(handle); + if (sensor == NULL) { + return BAD_VALUE; + } + + Mutex::Autolock _l(mLock); SensorRecord* rec = mActiveSensors.valueFor(handle); if (rec == 0) { rec = new SensorRecord(connection); @@ -546,16 +548,11 @@ status_t SensorService::enable(const sp<SensorEventConnection>& connection, handle, connection.get()); } - // we are setup, now enable the sensor. - status_t err = sensor ? sensor->activate(connection.get(), true) : status_t(BAD_VALUE); - + status_t err = sensor->activate(connection.get(), true); 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); + cleanupWithoutDisableLocked(connection, handle); } return err; } @@ -566,7 +563,8 @@ status_t SensorService::disable(const sp<SensorEventConnection>& connection, if (mInitCheck != NO_ERROR) return mInitCheck; - status_t err = cleanupWithoutDisable(connection, handle); + Mutex::Autolock _l(mLock); + status_t err = cleanupWithoutDisableLocked(connection, handle); if (err == NO_ERROR) { SensorInterface* sensor = mSensorMap.valueFor(handle); err = sensor ? sensor->activate(connection.get(), false) : status_t(BAD_VALUE); @@ -574,9 +572,14 @@ status_t SensorService::disable(const sp<SensorEventConnection>& connection, return err; } -status_t SensorService::cleanupWithoutDisable(const sp<SensorEventConnection>& connection, - int handle) { +status_t SensorService::cleanupWithoutDisable( + const sp<SensorEventConnection>& connection, int handle) { Mutex::Autolock _l(mLock); + return cleanupWithoutDisableLocked(connection, handle); +} + +status_t SensorService::cleanupWithoutDisableLocked( + const sp<SensorEventConnection>& connection, int handle) { SensorRecord* rec = mActiveSensors.valueFor(handle); if (rec) { // see if this connection becomes inactive diff --git a/services/sensorservice/SensorService.h b/services/sensorservice/SensorService.h index 56b0a3e..69e5dbb 100644 --- a/services/sensorservice/SensorService.h +++ b/services/sensorservice/SensorService.h @@ -115,8 +115,10 @@ class SensorService : static void sortEventBuffer(sensors_event_t* buffer, size_t count); Sensor registerSensor(SensorInterface* sensor); Sensor registerVirtualSensor(SensorInterface* sensor); - status_t cleanupWithoutDisable(const sp<SensorEventConnection>& connection, - int handle); + status_t cleanupWithoutDisable( + const sp<SensorEventConnection>& connection, int handle); + status_t cleanupWithoutDisableLocked( + const sp<SensorEventConnection>& connection, int handle); void cleanupAutoDisabledSensor(const sp<SensorEventConnection>& connection, sensors_event_t const* buffer, const int count); |