Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 320fd662 authored by Andrew Dodd's avatar Andrew Dodd Committed by Nebojsa Cvetkovic
Browse files

SensorEventQueue: Allow setRate on sensor enable

4.3 and earlier would set the sensor rate on activation and then set it again
when setRate was called.

Some sensor HALs assume this will happen and ignore the first setRate

Conditionally the first one back in for such broken HALs

Change-Id: If1c259b0fd5517a1272cdad0a1abf1fe0fb5a7d1
parent 38deda9d
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -61,6 +61,10 @@ ifeq ($(TARGET_TOROPLUS_RADIO), true)
	LOCAL_CFLAGS += -DTOROPLUS_RADIO
endif

ifeq ($(SENSORS_NEED_SETRATE_ON_ENABLE), true)
        LOCAL_CFLAGS += -DSENSORS_SETRATE_ON_ENABLE
endif

include $(BUILD_SHARED_LIBRARY)

ifeq (,$(ONE_SHOT_MAKEFILE))
+7 −1
Original line number Diff line number Diff line
@@ -128,8 +128,14 @@ status_t SensorEventQueue::disableSensor(Sensor const* sensor) const {

status_t SensorEventQueue::enableSensor(int32_t handle, int32_t samplingPeriodUs,
                                        int maxBatchReportLatencyUs, int reservedFlags) const {
    return mSensorEventConnection->enableDisable(handle, true, us2ns(samplingPeriodUs),
    status_t err = mSensorEventConnection->enableDisable(handle, true, us2ns(samplingPeriodUs),
                                                 us2ns(maxBatchReportLatencyUs), reservedFlags);
    #ifdef SENSORS_SETRATE_ON_ENABLE
    if (err == NO_ERROR) {
        mSensorEventConnection->setEventRate(handle, us2ns(samplingPeriodUs));
    }
    #endif
    return err;
}

status_t SensorEventQueue::flush() const {