Prevents posting multiple pulse requests at the same time

When docked, DozeDockHandler will try to request pulse almost every time
doze machine transits to DOZE or DOZE_AOD state. Guards pulse requests
with flag to prevent requesting multiple pulses at the same time.

Bug: 135226053
Bug: 135396479
Test: Manual test and the symptom gone.
Change-Id: I20d7def12c25b2772ef2c1ebefba4b4ac4d313d6
This commit is contained in:
Jerry Chang
2019-06-21 18:05:41 +08:00
parent 7fca2368af
commit 9fa6d73e75

View File

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