Merge "Ignore prox data when it's obsolete"

This commit is contained in:
Lucas Dupin
2019-03-22 16:11:05 +00:00
committed by Android (Google) Code Review
2 changed files with 9 additions and 1 deletions

View File

@@ -211,7 +211,7 @@ public class DozeMachine {
mDozeService.requestWakeUp();
}
private boolean isExecutingTransition() {
public boolean isExecutingTransition() {
return !mQueuedRequests.isEmpty();
}

View File

@@ -198,6 +198,14 @@ public class DozeTriggers implements DozeMachine.Part {
}
private void onProximityFar(boolean far) {
// Proximity checks are asynchronous and the user might have interacted with the phone
// when a new event is arriving. This means that a state transition might have happened
// and the proximity check is now obsolete.
if (mMachine.isExecutingTransition()) {
Log.w(TAG, "onProximityFar called during transition. Ignoring sensor response.");
return;
}
final boolean near = !far;
final DozeMachine.State state = mMachine.getState();
final boolean paused = (state == DozeMachine.State.DOZE_AOD_PAUSED);