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

Commit b9ba2b67 authored by John Spurlock's avatar John Spurlock
Browse files

Fix screen timeout determination for starting dream.

It turns out OFF_BECAUSE_OF_TIMEOUT is not the best indicator
of actual screen timeout.

For example, it is the reason passed down when acquiring a wake lock.
This was causing us to launch Dreams in the wrong situations, and
deadlocking on calls to WindowManager.

This fix simply adds an additional check ensuring the intention is to
turn the screen off.

Change-Id: If8adff446b5b1fcb19424b45878b75bfd0552b90
parent 7c46e438
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -1830,8 +1830,8 @@ public class PowerManagerService extends IPowerManager.Stub

            final boolean stateChanged = mPowerState != newState;

            if (stateChanged && reason == WindowManagerPolicy.OFF_BECAUSE_OF_TIMEOUT) {
                if (mPolicy != null && mPolicy.isScreenSaverEnabled() && mIsPowered) {
            if (stateChanged && !newScreenOn && reason == WindowManagerPolicy.OFF_BECAUSE_OF_TIMEOUT) {
                if (mPolicy != null && mIsPowered && mPolicy.isScreenSaverEnabled()) {
                    if (DEBUG) {
                        Slog.d(TAG, "setPowerState: running screen saver instead of turning off screen");
                    }