Check for the presence of accel and magnetometer sensors before adding AOSP fusion sensors. DO NOT MERGE
Bug: 22502485
Change-Id: I3d9018649302b98004e4e216b2173e8411a08501
(cherry picked from commit f504789dd3
)
This commit is contained in:
parent
35851e2abb
commit
e6406e3589
@ -82,7 +82,7 @@ void SensorService::onFirstRef()
|
|||||||
ssize_t count = dev.getSensorList(&list);
|
ssize_t count = dev.getSensorList(&list);
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
ssize_t orientationIndex = -1;
|
ssize_t orientationIndex = -1;
|
||||||
bool hasGyro = false;
|
bool hasGyro = false, hasAccel = false, hasMag = false;
|
||||||
uint32_t virtualSensorsNeeds =
|
uint32_t virtualSensorsNeeds =
|
||||||
(1<<SENSOR_TYPE_GRAVITY) |
|
(1<<SENSOR_TYPE_GRAVITY) |
|
||||||
(1<<SENSOR_TYPE_LINEAR_ACCELERATION) |
|
(1<<SENSOR_TYPE_LINEAR_ACCELERATION) |
|
||||||
@ -92,6 +92,12 @@ void SensorService::onFirstRef()
|
|||||||
for (ssize_t i=0 ; i<count ; i++) {
|
for (ssize_t i=0 ; i<count ; i++) {
|
||||||
registerSensor( new HardwareSensor(list[i]) );
|
registerSensor( new HardwareSensor(list[i]) );
|
||||||
switch (list[i].type) {
|
switch (list[i].type) {
|
||||||
|
case SENSOR_TYPE_ACCELEROMETER:
|
||||||
|
hasAccel = true;
|
||||||
|
break;
|
||||||
|
case SENSOR_TYPE_MAGNETIC_FIELD:
|
||||||
|
hasMag = true;
|
||||||
|
break;
|
||||||
case SENSOR_TYPE_ORIENTATION:
|
case SENSOR_TYPE_ORIENTATION:
|
||||||
orientationIndex = i;
|
orientationIndex = i;
|
||||||
break;
|
break;
|
||||||
@ -115,7 +121,7 @@ void SensorService::onFirstRef()
|
|||||||
// build the sensor list returned to users
|
// build the sensor list returned to users
|
||||||
mUserSensorList = mSensorList;
|
mUserSensorList = mSensorList;
|
||||||
|
|
||||||
if (hasGyro) {
|
if (hasGyro && hasAccel && hasMag) {
|
||||||
Sensor aSensor;
|
Sensor aSensor;
|
||||||
|
|
||||||
// Add Android virtual sensors if they're not already
|
// Add Android virtual sensors if they're not already
|
||||||
|
Loading…
Reference in New Issue
Block a user