diff options
author | Arne Coucheron <arco68@gmail.com> | 2014-11-05 05:17:05 +0100 |
---|---|---|
committer | Steve Kondik <shade@chemlab.org> | 2015-11-07 13:49:06 -0800 |
commit | 4cf9742078c4b48c3b9c301044f64314a8f07a9f (patch) | |
tree | 2e27bc545d308b3c5b70386bdc00fd85924ab68c /services | |
parent | c77679141d48c6fb593a1b23f5a985f2330f5820 (diff) | |
download | frameworks_native-4cf9742078c4b48c3b9c301044f64314a8f07a9f.zip frameworks_native-4cf9742078c4b48c3b9c301044f64314a8f07a9f.tar.gz frameworks_native-4cf9742078c4b48c3b9c301044f64314a8f07a9f.tar.bz2 |
sensorservice: Register orientation sensor if HAL doesn't provide it
* In KitKat and on most Samsung devices, the orientation sensor is
not getting registered, and makes the compass non-working in a lot
of apps. This patch enables the sensor for such devices.
Change-Id: I0ebba72ec4aa2cfa02c21a6daff0c356c6793fd0
(cherry picked from commit 98fa6f1152da759ef3eaf36cb16e0aaf2013376a)
Diffstat (limited to 'services')
-rw-r--r-- | services/sensorservice/SensorService.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/services/sensorservice/SensorService.cpp b/services/sensorservice/SensorService.cpp index 313011a..2d35fe9 100644 --- a/services/sensorservice/SensorService.cpp +++ b/services/sensorservice/SensorService.cpp @@ -146,9 +146,14 @@ void SensorService::onFirstRef() aSensor = registerVirtualSensor( new OrientationSensor() ); if (virtualSensorsNeeds & (1<<SENSOR_TYPE_ROTATION_VECTOR)) { - // if we are doing our own rotation-vector, also add - // the orientation sensor and remove the HAL provided one. - mUserSensorList.replaceAt(aSensor, orientationIndex); + if (orientationIndex == -1) { + // some sensor HALs don't provide an orientation sensor. + mUserSensorList.add(aSensor); + } else { + // if we are doing our own rotation-vector, also add + // the orientation sensor and remove the HAL provided one. + mUserSensorList.replaceAt(aSensor, orientationIndex); + } } // virtual debugging sensors are not added to mUserSensorList |