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

Commit 0a68fe9b authored by Ricardo Cerqueira's avatar Ricardo Cerqueira
Browse files

sensors: Allow target to override max range of proximity sensor

If a proximity sensor rarely or never reaches its maxRange, the
device will frequently lock up after the sensor is triggered (by
a call, for example), since it'll get stuck in the "active" state.

Set TARGET_PROXIMITY_SENSOR_LIMIT := <value> with the distance
from which the sensor will turn off to override those cases

Change-Id: I31fa2e5b9bd40ed6d80a1d5b0c147ed265f94c3a
parent c1bc8a9e
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -24,6 +24,10 @@ ifeq ($(TARGET_HAS_FOXCONN_SENSORS),true)
    LOCAL_CFLAGS += -DFOXCONN_SENSORS
endif

ifneq ($(TARGET_PROXIMITY_SENSOR_LIMIT),)
    LOCAL_CFLAGS += -DPROXIMITY_LIES=$(TARGET_PROXIMITY_SENSOR_LIMIT)
endif

ifneq ($(filter p990 p999, $(TARGET_BOOTLOADER_BOARD_NAME)),)
    LOCAL_CFLAGS += -DUSE_LGE_ALS_DUMMY
endif
+5 −0
Original line number Diff line number Diff line
@@ -235,6 +235,7 @@ ssize_t SensorDevice::poll(sensors_event_t* buffer, size_t count) {
            sensors_data_t oldBuffer;
            long result =  mSensorDataDevice->poll(mSensorDataDevice, &oldBuffer);
            int sensorType = -1;
            int maxRange = -1;
 
            if (result == 0x7FFFFFFF) {
                continue;
@@ -244,6 +245,7 @@ ssize_t SensorDevice::poll(sensors_event_t* buffer, size_t count) {
                for (size_t i=0 ; i<size_t(mOldSensorsCount) && sensorType < 0 ; i++) {
                    if (mOldSensorsList[i].handle == result) {
                        sensorType = mOldSensorsList[i].type;
                        maxRange = mOldSensorsList[i].maxRange;
                        LOGV("mapped sensor type to %d",sensorType);
                    }
                }
@@ -276,6 +278,9 @@ ssize_t SensorDevice::poll(sensors_event_t* buffer, size_t count) {
                } else {
                    buffer[pollsDone].distance = 1;
                }
#elif defined(PROXIMITY_LIES)
                if (buffer[pollsDone].distance >= PROXIMITY_LIES)
			buffer[pollsDone].distance = maxRange;
#endif
                return pollsDone+1;
            } else if (sensorType == SENSOR_TYPE_LIGHT) {