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)
This commit is contained in:
Arne Coucheron 2014-11-05 05:17:05 +01:00 committed by Steve Kondik
parent c77679141d
commit 4cf9742078
1 changed files with 8 additions and 3 deletions

View File

@ -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