Merge "Avoiding flush on-change sensors at subscription" into mnc-dr-dev am: a78c2e65e1
am: ffb07f645e
* commit 'ffb07f645e12b5c32479bba74b3310353edf691a':
Avoiding flush on-change sensors at subscription
This commit is contained in:
commit
e4db21f4b8
@ -912,10 +912,15 @@ status_t SensorService::enable(const sp<SensorEventConnection>& connection,
|
|||||||
status_t err = sensor->batch(connection.get(), handle, 0, samplingPeriodNs,
|
status_t err = sensor->batch(connection.get(), handle, 0, samplingPeriodNs,
|
||||||
maxBatchReportLatencyNs);
|
maxBatchReportLatencyNs);
|
||||||
|
|
||||||
// Call flush() before calling activate() on the sensor. Wait for a first flush complete
|
// Call flush() before calling activate() on the sensor. Wait for a first
|
||||||
// event before sending events on this connection. Ignore one-shot sensors which don't
|
// flush complete event before sending events on this connection. Ignore
|
||||||
// support flush(). Also if this sensor isn't already active, don't call flush().
|
// one-shot sensors which don't support flush(). Ignore on-change sensors
|
||||||
if (err == NO_ERROR && sensor->getSensor().getReportingMode() != AREPORTING_MODE_ONE_SHOT &&
|
// to maintain the on-change logic (any on-change events except the initial
|
||||||
|
// one should be trigger by a change in value). Also if this sensor isn't
|
||||||
|
// already active, don't call flush().
|
||||||
|
if (err == NO_ERROR &&
|
||||||
|
sensor->getSensor().getReportingMode() != AREPORTING_MODE_ONE_SHOT &&
|
||||||
|
sensor->getSensor().getReportingMode() != AREPORTING_MODE_ON_CHANGE &&
|
||||||
rec->getNumConnections() > 1) {
|
rec->getNumConnections() > 1) {
|
||||||
connection->setFirstFlushPending(handle, true);
|
connection->setFirstFlushPending(handle, true);
|
||||||
status_t err_flush = sensor->flush(connection.get(), handle);
|
status_t err_flush = sensor->flush(connection.get(), handle);
|
||||||
|
Loading…
Reference in New Issue
Block a user