Android-x86
Fork
Donation

  • R/O
  • HTTP
  • SSH
  • HTTPS

device-generic-goldfish: Commit

device/generic/goldfish


Commit MetaInfo

Revisionedbafe794f9638de61500ea2c299e8bc62a7562f (tree)
Time2017-05-14 16:20:51
Authorandroid-build-team Robot <android-build-team-robot@goog...>
Commiterandroid-build-team Robot

Log Message

release-request-951b3a8b-6c0c-4d2e-8af4-1c3f7e209f66-for-git_oc-release-4006899 snap-temp-L39600000063784275

Change-Id: I64be9a1a12c29beea62b1b9dec96dbc4a9fae4f0

Change Summary

Incremental Difference

--- a/sensors/sensors_qemu.c
+++ b/sensors/sensors_qemu.c
@@ -216,9 +216,20 @@ static int sensor_device_pick_pending_event_locked(SensorDevice* d,
216216 if (mask) {
217217 uint32_t i = 31 - __builtin_clz(mask);
218218 d->pendingSensors &= ~(1U << i);
219+ // Copy the structure
219220 *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+ }
222233
223234 D("%s: %d [%f, %f, %f]", __FUNCTION__,
224235 i,
@@ -290,10 +301,15 @@ static int sensor_device_poll_event_locked(SensorDevice* dev)
290301
291302 float params[3];
292303
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+
293308 /* "acceleration:<x>:<y>:<z>" corresponds to an acceleration event */
294309 if (sscanf(buff, "acceleration:%g:%g:%g", params+0, params+1, params+2)
295310 == 3) {
296311 new_sensors |= SENSORS_ACCELERATION;
312+ if (events[ID_ACCELERATION].type == SENSOR_TYPE_META_DATA) continue;
297313 events[ID_ACCELERATION].acceleration.x = params[0];
298314 events[ID_ACCELERATION].acceleration.y = params[1];
299315 events[ID_ACCELERATION].acceleration.z = params[2];
@@ -306,6 +322,7 @@ static int sensor_device_poll_event_locked(SensorDevice* dev)
306322 if (sscanf(buff, "orientation:%g:%g:%g", params+0, params+1, params+2)
307323 == 3) {
308324 new_sensors |= SENSORS_ORIENTATION;
325+ if (events[ID_ORIENTATION].type == SENSOR_TYPE_META_DATA) continue;
309326 events[ID_ORIENTATION].orientation.azimuth = params[0];
310327 events[ID_ORIENTATION].orientation.pitch = params[1];
311328 events[ID_ORIENTATION].orientation.roll = params[2];
@@ -320,6 +337,7 @@ static int sensor_device_poll_event_locked(SensorDevice* dev)
320337 if (sscanf(buff, "magnetic:%g:%g:%g", params+0, params+1, params+2)
321338 == 3) {
322339 new_sensors |= SENSORS_MAGNETIC_FIELD;
340+ if (events[ID_MAGNETIC_FIELD].type == SENSOR_TYPE_META_DATA) continue;
323341 events[ID_MAGNETIC_FIELD].magnetic.x = params[0];
324342 events[ID_MAGNETIC_FIELD].magnetic.y = params[1];
325343 events[ID_MAGNETIC_FIELD].magnetic.z = params[2];
@@ -332,6 +350,7 @@ static int sensor_device_poll_event_locked(SensorDevice* dev)
332350 /* "temperature:<celsius>" */
333351 if (sscanf(buff, "temperature:%g", params+0) == 1) {
334352 new_sensors |= SENSORS_TEMPERATURE;
353+ if (events[ID_TEMPERATURE].type == SENSOR_TYPE_META_DATA) continue;
335354 events[ID_TEMPERATURE].temperature = params[0];
336355 events[ID_TEMPERATURE].type = SENSOR_TYPE_AMBIENT_TEMPERATURE;
337356 continue;
@@ -340,6 +359,7 @@ static int sensor_device_poll_event_locked(SensorDevice* dev)
340359 /* "proximity:<value>" */
341360 if (sscanf(buff, "proximity:%g", params+0) == 1) {
342361 new_sensors |= SENSORS_PROXIMITY;
362+ if (events[ID_PROXIMITY].type == SENSOR_TYPE_META_DATA) continue;
343363 events[ID_PROXIMITY].distance = params[0];
344364 events[ID_PROXIMITY].type = SENSOR_TYPE_PROXIMITY;
345365 continue;
@@ -347,6 +367,7 @@ static int sensor_device_poll_event_locked(SensorDevice* dev)
347367 /* "light:<lux>" */
348368 if (sscanf(buff, "light:%g", params+0) == 1) {
349369 new_sensors |= SENSORS_LIGHT;
370+ if (events[ID_LIGHT].type == SENSOR_TYPE_META_DATA) continue;
350371 events[ID_LIGHT].light = params[0];
351372 events[ID_LIGHT].type = SENSOR_TYPE_LIGHT;
352373 continue;
@@ -355,6 +376,7 @@ static int sensor_device_poll_event_locked(SensorDevice* dev)
355376 /* "pressure:<hpa>" */
356377 if (sscanf(buff, "pressure:%g", params+0) == 1) {
357378 new_sensors |= SENSORS_PRESSURE;
379+ if (events[ID_PRESSURE].type == SENSOR_TYPE_META_DATA) continue;
358380 events[ID_PRESSURE].pressure = params[0];
359381 events[ID_PRESSURE].type = SENSOR_TYPE_PRESSURE;
360382 continue;
@@ -363,6 +385,7 @@ static int sensor_device_poll_event_locked(SensorDevice* dev)
363385 /* "humidity:<percent>" */
364386 if (sscanf(buff, "humidity:%g", params+0) == 1) {
365387 new_sensors |= SENSORS_HUMIDITY;
388+ if (events[ID_HUMIDITY].type == SENSOR_TYPE_META_DATA) continue;
366389 events[ID_HUMIDITY].relative_humidity = params[0];
367390 events[ID_HUMIDITY].type = SENSOR_TYPE_RELATIVE_HUMIDITY;
368391 continue;
@@ -560,6 +583,7 @@ static int sensor_device_default_flush(
560583 dev->sensors[handle].type = SENSOR_TYPE_META_DATA;
561584 dev->sensors[handle].sensor = 0;
562585 dev->sensors[handle].timestamp = 0;
586+ dev->sensors[handle].meta_data.sensor = handle;
563587 dev->sensors[handle].meta_data.what = META_DATA_FLUSH_COMPLETE;
564588 dev->pendingSensors |= (1U << handle);
565589 pthread_mutex_unlock(&dev->lock);
@@ -829,6 +853,12 @@ open_sensors(const struct hw_module_t* module,
829853 dev->device.activate = sensor_device_activate;
830854 dev->device.setDelay = sensor_device_set_delay;
831855
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+
832862 // Version 1.3-specific functions
833863 dev->device.batch = sensor_device_default_batch;
834864 dev->device.flush = sensor_device_default_flush;
Show on old repository browser