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

Skip to content
Commit ed4e0aa7 authored by Charles Wang's avatar Charles Wang
Browse files

Allow focused privileged windows to capture the power button event.

When this feature enabled, focused windows with the
OVERRIDE_SYSTEM_KEY_BEHAVIOR_IN_FOCUSED_WINDOW permission and the window
flag INPUT_FEATURE_RECEIVE_POWER_KEY_DOUBLE_PRESS set will receive KEYCODE_POWER KeyEvents.

The window can override the double-tap gesture default behavior (launching
camera) by handling the second onKeyDown event of a double tap. If the
app does not handle this event, or if the windw does not have the
permissions to receive KEYCODE_POWER, the default behavior of launching
camera is performed.

A double tap is defined as two consecutive KEYCODE_POWER key down events
within a 300 ms threshold.

Single, long-press and non double-press gestures behaviors will all be
default behavior, regardless of app handling the events or not.

Turning display on and off is unaffected, with the following exception:
In a privileged, focused window that doesn't handle the KEYCODE_POWER
event, there will be a 300 ms delay in turning off the screen.

More details at go/power-button-dd.

Bug: 357144512
Test: atest WmTests:PowerKeyGestureTests
Test: manual testing (single, long-press, double-press, 5x press of
power button on non-privileged windows and privileged windows that
handle and don't handle the KEYCODE_POWER KeyEvent.)
Flag: com.android.hardware.input.override_power_key_behavior_in_focused_window

Change-Id: Ia21ebbda4a93ade5f4d5f73fe0f3bf659e36647a
parent 8da65957
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment