am 24c8f4b1: am 177a4166: am 99426810: Merge "Check for the presence of accel and magnetometer sensors before adding AOSP fusion sensors." into mnc-dev

* commit '24c8f4b1569a925e8c421414389f84d0035eaad9':
  Check for the presence of accel and magnetometer sensors before adding AOSP fusion sensors.
This commit is contained in:
Chenjie Luo 2015-07-24 03:41:22 +00:00 committed by Android Git Automerger
commit f369a4fc10

View File

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