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)
(cherry picked from commit 82c4726054919240972745bbcc85e0e27da40aa3)
diff --git a/services/sensorservice/SensorService.cpp b/services/sensorservice/SensorService.cpp
index c11b88e..2141f69 100644
--- a/services/sensorservice/SensorService.cpp
+++ b/services/sensorservice/SensorService.cpp
@@ -204,9 +204,10 @@
// available in the HAL
bool needRotationVector =
(virtualSensorsNeeds & (1<<SENSOR_TYPE_ROTATION_VECTOR)) != 0;
+ bool needOrientation = orientationIndex == -1;
registerSensor(new RotationVectorSensor(), !needRotationVector, true);
- registerSensor(new OrientationSensor(), !needRotationVector, true);
+ registerSensor(new OrientationSensor(), !needOrientation, true);
bool needLinearAcceleration =
(virtualSensorsNeeds & (1<<SENSOR_TYPE_LINEAR_ACCELERATION)) != 0;