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

Commit bc072da9 authored by Jeff Brown's avatar Jeff Brown
Browse files

POWER key is always a wake key.

This change is useful to ensure that injected POWER key events
always wake the device even if the right policy flags were
not set.

Change-Id: I05b8b35f984f5c9f58b0e9d44bcb6f41a9562fc8
parent bf677de4
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -2649,6 +2649,12 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            performHapticFeedbackLw(null, HapticFeedbackConstants.VIRTUAL_KEY, false);
        }

        if (keyCode == KeyEvent.KEYCODE_POWER) {
            policyFlags |= WindowManagerPolicy.FLAG_WAKE;
        }
        final boolean isWakeKey = (policyFlags & (WindowManagerPolicy.FLAG_WAKE
                | WindowManagerPolicy.FLAG_WAKE_DROPPED)) != 0;

        // Basic policy based on screen state and keyguard.
        // FIXME: This policy isn't quite correct.  We shouldn't care whether the screen
        //        is on or off, really.  We should care about whether the device is in an
@@ -2658,16 +2664,13 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        //        the device some other way (which is why we have an exemption here for injected
        //        events).
        int result;
        if (isScreenOn || isInjected) {
        if (isScreenOn || (isInjected && !isWakeKey)) {
            // When the screen is on or if the key is injected pass the key to the application.
            result = ACTION_PASS_TO_USER;
        } else {
            // When the screen is off and the key is not injected, determine whether
            // to wake the device but don't pass the key to the application.
            result = 0;

            final boolean isWakeKey = (policyFlags
                    & (WindowManagerPolicy.FLAG_WAKE | WindowManagerPolicy.FLAG_WAKE_DROPPED)) != 0;
            if (down && isWakeKey) {
                if (keyguardActive) {
                    // If the keyguard is showing, let it decide what to do with the wake key.