Skip to content

Commit

Permalink
[compilation] Workaround missing u64 union in sensors_event_t. MER#1749
Browse files Browse the repository at this point in the history
If android sensors.h available at build time does have u64 union field
in sensors_event_t structure, compilation will fail.

Workaround the issue, by copying step count data from the address where
it would be located would the u64 union be defined.

Signed-off-by: Simo Piiroinen <simo.piiroinen@jollamobile.com>
  • Loading branch information
spiiroin committed Feb 8, 2017
1 parent fcfd74c commit 6fe1253
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions adaptors/hybrisstepcounteradaptor/hybrisstepcounteradaptor.cpp
Expand Up @@ -28,6 +28,10 @@

#ifndef SENSOR_TYPE_STEP_COUNTER
#define SENSOR_TYPE_STEP_COUNTER (19)
/* If hardware/sensors.h does not define SENSOR_TYPE_STEP_COUNTER, assume
* a) the event structure is missing u64 union too, and b) u64.step_counter
* would be located at the same address as non-u64 data array. */
#define NO_SENSORS_EVENT_U64
#endif

HybrisStepCounterAdaptor::HybrisStepCounterAdaptor(const QString& id) :
Expand Down Expand Up @@ -67,7 +71,13 @@ void HybrisStepCounterAdaptor::processSample(const sensors_event_t& data)
{
TimedUnsigned *d = buffer->nextSlot();
d->timestamp_ = quint64(data.timestamp * .001);
#ifdef NO_SENSORS_EVENT_U64
uint64_t value = 0;
memcpy(&value, data.data, sizeof value);
d->value_ = value;
#else
d->value_ = data.u64.step_counter;
#endif
buffer->commit();
buffer->wakeUpReaders();
}
Expand Down

0 comments on commit 6fe1253

Please sign in to comment.