device/generic/goldfish
Révision | edbafe794f9638de61500ea2c299e8bc62a7562f (tree) |
---|---|
l'heure | 2017-05-14 16:20:51 |
Auteur | android-build-team Robot <android-build-team-robot@goog...> |
Commiter | android-build-team Robot |
release-request-951b3a8b-6c0c-4d2e-8af4-1c3f7e209f66-for-git_oc-release-4006899 snap-temp-L39600000063784275
Change-Id: I64be9a1a12c29beea62b1b9dec96dbc4a9fae4f0
@@ -216,9 +216,20 @@ static int sensor_device_pick_pending_event_locked(SensorDevice* d, | ||
216 | 216 | if (mask) { |
217 | 217 | uint32_t i = 31 - __builtin_clz(mask); |
218 | 218 | d->pendingSensors &= ~(1U << i); |
219 | + // Copy the structure | |
219 | 220 | *event = d->sensors[i]; |
220 | - event->sensor = i; | |
221 | - event->version = sizeof(*event); | |
221 | + | |
222 | + if (d->sensors[i].type == SENSOR_TYPE_META_DATA) { | |
223 | + // sensor_device_poll_event_locked() will leave | |
224 | + // the meta-data in place until we have it. | |
225 | + // Set |type| to something other than META_DATA | |
226 | + // so sensor_device_poll_event_locked() can | |
227 | + // continue. | |
228 | + d->sensors[i].type = SENSOR_TYPE_META_DATA + 1; | |
229 | + } else { | |
230 | + event->sensor = i; | |
231 | + event->version = sizeof(*event); | |
232 | + } | |
222 | 233 | |
223 | 234 | D("%s: %d [%f, %f, %f]", __FUNCTION__, |
224 | 235 | i, |
@@ -290,10 +301,15 @@ static int sensor_device_poll_event_locked(SensorDevice* dev) | ||
290 | 301 | |
291 | 302 | float params[3]; |
292 | 303 | |
304 | + // If the existing entry for this sensor is META_DATA, | |
305 | + // do not overwrite it. We can resume saving sensor | |
306 | + // values after that meta data has been received. | |
307 | + | |
293 | 308 | /* "acceleration:<x>:<y>:<z>" corresponds to an acceleration event */ |
294 | 309 | if (sscanf(buff, "acceleration:%g:%g:%g", params+0, params+1, params+2) |
295 | 310 | == 3) { |
296 | 311 | new_sensors |= SENSORS_ACCELERATION; |
312 | + if (events[ID_ACCELERATION].type == SENSOR_TYPE_META_DATA) continue; | |
297 | 313 | events[ID_ACCELERATION].acceleration.x = params[0]; |
298 | 314 | events[ID_ACCELERATION].acceleration.y = params[1]; |
299 | 315 | events[ID_ACCELERATION].acceleration.z = params[2]; |
@@ -306,6 +322,7 @@ static int sensor_device_poll_event_locked(SensorDevice* dev) | ||
306 | 322 | if (sscanf(buff, "orientation:%g:%g:%g", params+0, params+1, params+2) |
307 | 323 | == 3) { |
308 | 324 | new_sensors |= SENSORS_ORIENTATION; |
325 | + if (events[ID_ORIENTATION].type == SENSOR_TYPE_META_DATA) continue; | |
309 | 326 | events[ID_ORIENTATION].orientation.azimuth = params[0]; |
310 | 327 | events[ID_ORIENTATION].orientation.pitch = params[1]; |
311 | 328 | events[ID_ORIENTATION].orientation.roll = params[2]; |
@@ -320,6 +337,7 @@ static int sensor_device_poll_event_locked(SensorDevice* dev) | ||
320 | 337 | if (sscanf(buff, "magnetic:%g:%g:%g", params+0, params+1, params+2) |
321 | 338 | == 3) { |
322 | 339 | new_sensors |= SENSORS_MAGNETIC_FIELD; |
340 | + if (events[ID_MAGNETIC_FIELD].type == SENSOR_TYPE_META_DATA) continue; | |
323 | 341 | events[ID_MAGNETIC_FIELD].magnetic.x = params[0]; |
324 | 342 | events[ID_MAGNETIC_FIELD].magnetic.y = params[1]; |
325 | 343 | events[ID_MAGNETIC_FIELD].magnetic.z = params[2]; |
@@ -332,6 +350,7 @@ static int sensor_device_poll_event_locked(SensorDevice* dev) | ||
332 | 350 | /* "temperature:<celsius>" */ |
333 | 351 | if (sscanf(buff, "temperature:%g", params+0) == 1) { |
334 | 352 | new_sensors |= SENSORS_TEMPERATURE; |
353 | + if (events[ID_TEMPERATURE].type == SENSOR_TYPE_META_DATA) continue; | |
335 | 354 | events[ID_TEMPERATURE].temperature = params[0]; |
336 | 355 | events[ID_TEMPERATURE].type = SENSOR_TYPE_AMBIENT_TEMPERATURE; |
337 | 356 | continue; |
@@ -340,6 +359,7 @@ static int sensor_device_poll_event_locked(SensorDevice* dev) | ||
340 | 359 | /* "proximity:<value>" */ |
341 | 360 | if (sscanf(buff, "proximity:%g", params+0) == 1) { |
342 | 361 | new_sensors |= SENSORS_PROXIMITY; |
362 | + if (events[ID_PROXIMITY].type == SENSOR_TYPE_META_DATA) continue; | |
343 | 363 | events[ID_PROXIMITY].distance = params[0]; |
344 | 364 | events[ID_PROXIMITY].type = SENSOR_TYPE_PROXIMITY; |
345 | 365 | continue; |
@@ -347,6 +367,7 @@ static int sensor_device_poll_event_locked(SensorDevice* dev) | ||
347 | 367 | /* "light:<lux>" */ |
348 | 368 | if (sscanf(buff, "light:%g", params+0) == 1) { |
349 | 369 | new_sensors |= SENSORS_LIGHT; |
370 | + if (events[ID_LIGHT].type == SENSOR_TYPE_META_DATA) continue; | |
350 | 371 | events[ID_LIGHT].light = params[0]; |
351 | 372 | events[ID_LIGHT].type = SENSOR_TYPE_LIGHT; |
352 | 373 | continue; |
@@ -355,6 +376,7 @@ static int sensor_device_poll_event_locked(SensorDevice* dev) | ||
355 | 376 | /* "pressure:<hpa>" */ |
356 | 377 | if (sscanf(buff, "pressure:%g", params+0) == 1) { |
357 | 378 | new_sensors |= SENSORS_PRESSURE; |
379 | + if (events[ID_PRESSURE].type == SENSOR_TYPE_META_DATA) continue; | |
358 | 380 | events[ID_PRESSURE].pressure = params[0]; |
359 | 381 | events[ID_PRESSURE].type = SENSOR_TYPE_PRESSURE; |
360 | 382 | continue; |
@@ -363,6 +385,7 @@ static int sensor_device_poll_event_locked(SensorDevice* dev) | ||
363 | 385 | /* "humidity:<percent>" */ |
364 | 386 | if (sscanf(buff, "humidity:%g", params+0) == 1) { |
365 | 387 | new_sensors |= SENSORS_HUMIDITY; |
388 | + if (events[ID_HUMIDITY].type == SENSOR_TYPE_META_DATA) continue; | |
366 | 389 | events[ID_HUMIDITY].relative_humidity = params[0]; |
367 | 390 | events[ID_HUMIDITY].type = SENSOR_TYPE_RELATIVE_HUMIDITY; |
368 | 391 | continue; |
@@ -560,6 +583,7 @@ static int sensor_device_default_flush( | ||
560 | 583 | dev->sensors[handle].type = SENSOR_TYPE_META_DATA; |
561 | 584 | dev->sensors[handle].sensor = 0; |
562 | 585 | dev->sensors[handle].timestamp = 0; |
586 | + dev->sensors[handle].meta_data.sensor = handle; | |
563 | 587 | dev->sensors[handle].meta_data.what = META_DATA_FLUSH_COMPLETE; |
564 | 588 | dev->pendingSensors |= (1U << handle); |
565 | 589 | pthread_mutex_unlock(&dev->lock); |
@@ -829,6 +853,12 @@ open_sensors(const struct hw_module_t* module, | ||
829 | 853 | dev->device.activate = sensor_device_activate; |
830 | 854 | dev->device.setDelay = sensor_device_set_delay; |
831 | 855 | |
856 | + // (dev->sensors[i].type == SENSOR_TYPE_META_DATA) is | |
857 | + // sticky. Don't start off with that setting. | |
858 | + for (int idx = 0; idx < MAX_NUM_SENSORS; idx++) { | |
859 | + dev->sensors[idx].type = SENSOR_TYPE_META_DATA + 1; | |
860 | + } | |
861 | + | |
832 | 862 | // Version 1.3-specific functions |
833 | 863 | dev->device.batch = sensor_device_default_batch; |
834 | 864 | dev->device.flush = sensor_device_default_flush; |