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.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user