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

Commit 9fa6d73e authored by Jerry Chang's avatar Jerry Chang
Browse files

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
parent 7fca2368
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -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,12 +81,11 @@ 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);
        }
        mPulsePending = false;
    }

    private void requestPulseOutNow(State dozeState) {
        if (dozeState == State.DOZE_REQUEST_PULSE || dozeState == State.DOZE_PULSING