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

Commit ba2fa7d7 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "If a wake key is disabled by the user, do not wake from doze."

parents 36ee36ae 7019688a
Loading
Loading
Loading
Loading
+17 −1
Original line number Diff line number Diff line
@@ -5002,8 +5002,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            // If we're currently dozing with the screen on and the keyguard showing, pass the key
            // to the application but preserve its wake key status to make sure we still move
            // from dozing to fully interactive if we would normally go from off to fully
            // interactive.
            // interactive, unless the user has explicitly disabled this wake key.
            result = ACTION_PASS_TO_USER;
            isWakeKey = isWakeKey && isWakeKeyEnabled(keyCode);
        } 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.
@@ -5301,6 +5302,21 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        }
    }

    /**
     * Check if the given keyCode represents a key that is considered a wake key
     * and is currently enabled by the user in Settings or for another reason.
     */
    private boolean isWakeKeyEnabled(int keyCode) {
        switch (keyCode) {
            case KeyEvent.KEYCODE_VOLUME_UP:
            case KeyEvent.KEYCODE_VOLUME_DOWN:
            case KeyEvent.KEYCODE_VOLUME_MUTE:
                // Volume keys are still wake keys if the device is docked.
                return mVolumeWakeScreen || mDockMode != Intent.EXTRA_DOCK_STATE_UNDOCKED;
        }
        return true;
    }

    /**
     * When the screen is off we ignore some keys that might otherwise typically
     * be considered wake keys.  We filter them out here.