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:
Marco Chen 2013-01-24 10:45:07 +08:00
parent 6a0da62b7a
commit aef1dbd224

View File

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