diff options
author | Scott Mertz <scott@cyngn.com> | 2014-10-31 18:01:55 -0700 |
---|---|---|
committer | Steve Kondik <steve@cyngn.com> | 2015-03-22 02:33:41 -0700 |
commit | 5264f35b5a2a49ef8c68f053a991cc58e23aa1e5 (patch) | |
tree | 7eec77b42aeb9bb3ec1697db72647995b7dff0ec | |
parent | 8812aca1704288becb467fea71ef3b80bed8a8cd (diff) | |
download | android_frameworks_native-5264f35b5a2a49ef8c68f053a991cc58e23aa1e5.tar.gz android_frameworks_native-5264f35b5a2a49ef8c68f053a991cc58e23aa1e5.tar.bz2 android_frameworks_native-5264f35b5a2a49ef8c68f053a991cc58e23aa1e5.zip |
sensorservice: add fusion sensors if all events are supported
- Fusion sensors depend on gyro, mag field, and accelerometer
events in order to emulate these sensors. Don't create
them unless ALL of the real hardware devices required exist.
Change-Id: I1bce167a52c2dfc56a07450f858b01b78c39b7fe
-rw-r--r-- | services/sensorservice/SensorService.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/services/sensorservice/SensorService.cpp b/services/sensorservice/SensorService.cpp index f1ca04b63..cfa6ceed6 100644 --- a/services/sensorservice/SensorService.cpp +++ b/services/sensorservice/SensorService.cpp @@ -83,6 +83,8 @@ void SensorService::onFirstRef() if (count > 0) { ssize_t orientationIndex = -1; bool hasGyro = false; + bool hasMagnetometer = false; + bool hasAccelerometer = false; uint32_t virtualSensorsNeeds = (1<<SENSOR_TYPE_GRAVITY) | (1<<SENSOR_TYPE_LINEAR_ACCELERATION) | @@ -99,6 +101,12 @@ void SensorService::onFirstRef() case SENSOR_TYPE_GYROSCOPE_UNCALIBRATED: hasGyro = true; break; + case SENSOR_TYPE_MAGNETIC_FIELD: + hasMagnetometer = true; + break; + case SENSOR_TYPE_ACCELEROMETER: + hasAccelerometer = true; + break; case SENSOR_TYPE_GRAVITY: case SENSOR_TYPE_LINEAR_ACCELERATION: case SENSOR_TYPE_ROTATION_VECTOR: @@ -115,7 +123,7 @@ void SensorService::onFirstRef() // build the sensor list returned to users mUserSensorList = mSensorList; - if (hasGyro) { + if (hasGyro && hasMagnetometer && hasAccelerometer) { Sensor aSensor; // Add Android virtual sensors if they're not already |