mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 13:51:41 +00:00
Bug 827707 - [GonkSensor] Sensor field in sensors_event_t doesn't mean the index of sensors list from HAL. r=mwu
This commit is contained in:
parent
6a0da62b7a
commit
aef1dbd224
@ -182,16 +182,19 @@ PollSensors()
|
||||
if (buffer[i].type == SENSOR_TYPE_MAGNETIC_FIELD)
|
||||
continue;
|
||||
|
||||
if (buffer[i].sensor >= size) {
|
||||
LOGW("buffer type is hal sensor type SENSOR_UNKNOWN, and buffer sensor is not in a valid range");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (HardwareSensorToHalSensor(buffer[i].type) == SENSOR_UNKNOWN) {
|
||||
// Emulator is broken and gives us events without types set
|
||||
if (HardwareSensorToHalSensor(sensors[buffer[i].sensor].type) != SENSOR_UNKNOWN) {
|
||||
buffer[i].type = sensors[buffer[i].sensor].type;
|
||||
int index;
|
||||
for (index = 0; index < size; index++) {
|
||||
if (sensors[index].handle == buffer[i].sensor) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (index < size &&
|
||||
HardwareSensorToHalSensor(sensors[index].type) != SENSOR_UNKNOWN) {
|
||||
buffer[i].type = sensors[index].type;
|
||||
} else {
|
||||
LOGW("Could not determine sensor type of event");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user