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

Commit 43d9e248 authored by Jeff Brown's avatar Jeff Brown Committed by Android (Google) Code Review
Browse files

Merge "POWER key is always a wake key."

parents 1fea891f bc072da9
Loading
Loading
Loading
Loading
+7 −4
Original line number Original line Diff line number Diff line
@@ -2649,6 +2649,12 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            performHapticFeedbackLw(null, HapticFeedbackConstants.VIRTUAL_KEY, false);
            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.
        // Basic policy based on screen state and keyguard.
        // FIXME: This policy isn't quite correct.  We shouldn't care whether the screen
        // 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
        //        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
        //        the device some other way (which is why we have an exemption here for injected
        //        events).
        //        events).
        int result;
        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.
            // When the screen is on or if the key is injected pass the key to the application.
            result = ACTION_PASS_TO_USER;
            result = ACTION_PASS_TO_USER;
        } else {
        } else {
            // When the screen is off and the key is not injected, determine whether
            // 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.
            // to wake the device but don't pass the key to the application.
            result = 0;
            result = 0;

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