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

Commit d626e66b authored by Matt Garnes's avatar Matt Garnes
Browse files

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

If the device is 'dreaming' in the Doze state, check if the user has
explicitly disabled the wake key (or never enabled the setting in the
first place) before waking the device.

Change-Id: I4d11f30d0931d959e9c729ca36b3ece5b5a2f8c1
parent e66b38c0
Loading
Loading
Loading
Loading
+17 −1
Original line number Diff line number Diff line
@@ -4994,8 +4994,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.
@@ -5293,6 +5294,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.