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

Commit 67b3d354 authored by Will Leshner's avatar Will Leshner
Browse files

Avoid lock screen flash when going to dream.

This is specifically when entering a dream from a single power button
tap on devices that are configured with that behavior.

Bug: 261662912
Test: manually by tapping power button to enter a dream and observing
that the device is locks at the same time without flashing the lock
screen.

Merged-In: I89ecce9cc39cb1cb6f7b19068908ba436643223c
Change-Id: I83d41fb0ca12adc11dbcd6047eee3ba4a3118d26
parent a59b096a
Loading
Loading
Loading
Loading
+23 −5
Original line number Diff line number Diff line
@@ -566,6 +566,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    // What we do when the user double-taps on home
    private int mDoubleTapOnHomeBehavior;

    // Whether to lock the device after the next app transition has finished.
    private boolean mLockAfterAppTransitionFinished;

    // Allowed theater mode wake actions
    private boolean mAllowTheaterModeWakeFromKey;
    private boolean mAllowTheaterModeWakeFromPowerKey;
@@ -1055,11 +1058,10 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            return;
        }

        // Make sure the device locks. Unfortunately, this has the side-effect of briefly revealing
        // the lock screen before the dream appears. Note that locking is a side-effect of the no
        // dream action that is executed if we early return above.
        // TODO(b/261662912): Find a better way to lock the device that doesn't result in jank.
        lockNow(null);
        synchronized (mLock) {
            // Lock the device after the dream transition has finished.
            mLockAfterAppTransitionFinished = true;
        }

        dreamManagerInternal.requestDream();
    }
@@ -2139,6 +2141,22 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                handleStartTransitionForKeyguardLw(
                        keyguardGoingAway, false /* keyguardOccludingStarted */,
                        0 /* duration */);

                synchronized (mLock) {
                    mLockAfterAppTransitionFinished = false;
                }
            }

            @Override
            public void onAppTransitionFinishedLocked(IBinder token) {
                synchronized (mLock) {
                    if (!mLockAfterAppTransitionFinished) {
                        return;
                    }
                    mLockAfterAppTransitionFinished = false;
                }

                lockNow(null);
            }
        });