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
Loading
Please register or sign in to comment