Merge "Prevents posting multiple pulse requests at the same time" into qt-r1-dev

This commit is contained in:
TreeHugger Robot
2019-06-22 11:58:41 +00:00
committed by Android (Google) Code Review

View File

@@ -43,6 +43,7 @@ public class DozeDockHandler implements DozeMachine.Part {
private final DockManager mDockManager; private final DockManager mDockManager;
private int mDockState = DockManager.STATE_NONE; private int mDockState = DockManager.STATE_NONE;
private boolean mPulsePending;
public DozeDockHandler(Context context, DozeMachine machine, DozeHost dozeHost, public DozeDockHandler(Context context, DozeMachine machine, DozeHost dozeHost,
AmbientDisplayConfiguration config, Handler handler, DockManager dockManager) { AmbientDisplayConfiguration config, Handler handler, DockManager dockManager) {
@@ -66,7 +67,8 @@ public class DozeDockHandler implements DozeMachine.Part {
} }
// continue below // continue below
case DOZE: case DOZE:
if (mDockState == DockManager.STATE_DOCKED) { if (mDockState == DockManager.STATE_DOCKED && !mPulsePending) {
mPulsePending = true;
mHandler.post(() -> requestPulse(newState)); mHandler.post(() -> requestPulse(newState));
} }
break; break;
@@ -79,11 +81,10 @@ public class DozeDockHandler implements DozeMachine.Part {
} }
private void requestPulse(State dozeState) { private void requestPulse(State dozeState) {
if (mDozeHost.isPulsingBlocked() || !dozeState.canPulse()) { if (!mDozeHost.isPulsingBlocked() && dozeState.canPulse()) {
return; mMachine.requestPulse(DozeLog.PULSE_REASON_DOCKING);
} }
mPulsePending = false;
mMachine.requestPulse(DozeLog.PULSE_REASON_DOCKING);
} }
private void requestPulseOutNow(State dozeState) { private void requestPulseOutNow(State dozeState) {