sensorservice: Refactor tracking logic for the Proximity sensor.
This simplifies the code that tracks if the proximity sensor is
active by removing all counting of clients and simply checking the
sensor's isSensorActive() method and reporting changes to it.
Bug: b/202328704
Tests: See b/202328704#comment9 for tests done.
Change-Id: Idd72b82ed0fd5ee089e795ab4b233241350979c2
diff --git a/services/sensorservice/SensorInterface.cpp b/services/sensorservice/SensorInterface.cpp
index c285c00..46f00e8 100644
--- a/services/sensorservice/SensorInterface.cpp
+++ b/services/sensorservice/SensorInterface.cpp
@@ -92,31 +92,13 @@
}
status_t ProximitySensor::activate(void* ident, bool enabled) {
- bool lastState = mSensorDevice.isSensorActive(mSensor.getHandle());
-
status_t status = HardwareSensor::activate(ident, enabled);
if (status != NO_ERROR) {
return status;
}
-
- bool currentState = mSensorDevice.isSensorActive(mSensor.getHandle());
- if (currentState != lastState) {
- mSensorService.onProximityActiveLocked(currentState);
- }
+ mSensorService.checkAndReportProxStateChangeLocked();
return NO_ERROR;
}
-void ProximitySensor::willDisableAllSensors() {
- if (mSensorDevice.isSensorActive(mSensor.getHandle())) {
- mSensorService.onProximityActiveLocked(false);
- }
-}
-
-void ProximitySensor::didEnableAllSensors() {
- if (mSensorDevice.isSensorActive(mSensor.getHandle())) {
- mSensorService.onProximityActiveLocked(true);
- }
-}
-
// ---------------------------------------------------------------------------
}; // namespace android