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

Commit 70da03ad authored by Adrian Roos's avatar Adrian Roos
Browse files

AOD: Skip prox check if cached prox value available

On AOD, we run the proximity sensor, so when a pulse comes in,
there is no need to wait for a new result. Instead, we can use
the existing value if available.

Change-Id: Ibded081e5011a3053e6990012f97f63865e20298
Fixes: 63538693
Test: receive notification, verify that pulsing starts immediately and does not wait for the proximity check.
parent 29119b6f
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -184,6 +184,13 @@ public class DozeSensors {
        pw.print("ProxSensor: "); pw.println(mProxSensor.toString());
    }

    /**
     * @return true if prox is currently far, false if near or null if unknown.
     */
    public Boolean isProximityCurrentlyFar() {
        return mProxSensor.mCurrentlyFar;
    }

    private class ProxSensor implements SensorEventListener {

        static final long COOLDOWN_TRIGGER = 2 * 1000;
+3 −0
Original line number Diff line number Diff line
@@ -103,8 +103,11 @@ public class DozeTriggers implements DozeMachine.Part {
    private void proximityCheckThenCall(IntConsumer callback,
            boolean alreadyPerformedProxCheck,
            int pulseReason) {
        Boolean cachedProxFar = mDozeSensors.isProximityCurrentlyFar();
        if (alreadyPerformedProxCheck) {
            callback.accept(ProximityCheck.RESULT_NOT_CHECKED);
        } else if (cachedProxFar != null) {
            callback.accept(cachedProxFar ? ProximityCheck.RESULT_FAR : ProximityCheck.RESULT_NEAR);
        } else {
            final long start = SystemClock.uptimeMillis();
            new ProximityCheck() {