diff options
author | Chenjie Luo <cjluo@google.com> | 2015-07-22 20:23:43 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2015-07-22 20:23:43 +0000 |
commit | 177a4166252afddbe03a5ed7b2e56b0f9173ef81 (patch) | |
tree | 52bdea8f692c224dfec399458616651eff2d67b5 /services | |
parent | a6364e257d6b0be3c94819cd16fffa2d4d7c8150 (diff) | |
parent | 99426810e4828719be84a0f8c186161578512e93 (diff) | |
download | frameworks_native-177a4166252afddbe03a5ed7b2e56b0f9173ef81.zip frameworks_native-177a4166252afddbe03a5ed7b2e56b0f9173ef81.tar.gz frameworks_native-177a4166252afddbe03a5ed7b2e56b0f9173ef81.tar.bz2 |
am 99426810: Merge "Check for the presence of accel and magnetometer sensors before adding AOSP fusion sensors." into mnc-dev
* commit '99426810e4828719be84a0f8c186161578512e93':
Check for the presence of accel and magnetometer sensors before adding AOSP fusion sensors.
Diffstat (limited to 'services')
-rw-r--r-- | services/sensorservice/SensorService.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/services/sensorservice/SensorService.cpp b/services/sensorservice/SensorService.cpp index bb2d4f3..40b21a9 100644 --- a/services/sensorservice/SensorService.cpp +++ b/services/sensorservice/SensorService.cpp @@ -84,7 +84,7 @@ void SensorService::onFirstRef() ssize_t count = dev.getSensorList(&list); if (count > 0) { ssize_t orientationIndex = -1; - bool hasGyro = false; + bool hasGyro = false, hasAccel = false, hasMag = false; uint32_t virtualSensorsNeeds = (1<<SENSOR_TYPE_GRAVITY) | (1<<SENSOR_TYPE_LINEAR_ACCELERATION) | @@ -94,6 +94,12 @@ void SensorService::onFirstRef() for (ssize_t i=0 ; i<count ; i++) { registerSensor( new HardwareSensor(list[i]) ); switch (list[i].type) { + case SENSOR_TYPE_ACCELEROMETER: + hasAccel = true; + break; + case SENSOR_TYPE_MAGNETIC_FIELD: + hasMag = true; + break; case SENSOR_TYPE_ORIENTATION: orientationIndex = i; break; @@ -117,7 +123,7 @@ void SensorService::onFirstRef() // build the sensor list returned to users mUserSensorList = mSensorList; - if (hasGyro) { + if (hasGyro && hasAccel && hasMag) { Sensor aSensor; // Add Android virtual sensors if they're not already |