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

Commit 8cc7529a authored by Bryce Lee's avatar Bryce Lee
Browse files

Add lock or sleep power button behavior.

This changelist defines a new short-press button behavior,
which will lock the device or put the device to sleep if
already locked. This enables use-cases where the power button
should first return to the lock screen.

Bug: 194002900
Test: manual
Change-Id: I3098e6244563cb62facb7b0b35300e656b744c7c
parent 12989af9
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -261,6 +261,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    static final int SHORT_PRESS_POWER_REALLY_GO_TO_SLEEP_AND_GO_HOME = 3;
    static final int SHORT_PRESS_POWER_GO_HOME = 4;
    static final int SHORT_PRESS_POWER_CLOSE_IME_OR_GO_HOME = 5;
    static final int SHORT_PRESS_POWER_LOCK_OR_SLEEP = 6;

    // must match: config_LongPressOnPowerBehavior in config.xml
    static final int LONG_PRESS_POWER_NOTHING = 0;
@@ -976,6 +977,14 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                    }
                    break;
                }
                case SHORT_PRESS_POWER_LOCK_OR_SLEEP: {
                    if (keyguardOn()) {
                        sleepDefaultDisplayFromPowerButton(eventTime, 0);
                    } else {
                        lockNow(null /*options*/);
                    }
                    break;
                }
            }
        }
    }