From 8559ae43163c0223fc1923fb4aee317b19c8a6f5 Mon Sep 17 00:00:00 2001 From: Josep del Rio Date: Wed, 19 Apr 2023 11:58:01 +0000 Subject: [PATCH] Close system dialogs as Escape fallback At the moment the Escape key won't do anything most of the time. We considered adding a fallback to the back key, but that could cause unintended side effects. We have a intent, close system dialogs, that was clamped down as "too powerful" for apps, and currently used by the test instrumentation. This seems like the perfect option for Escape. Bug: 278851142 Test: flashed on device Change-Id: I6ebf22be96313f09a94012f12e75a94df57a29c4 --- .../java/com/android/server/policy/PhoneWindowManager.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java index fc6b4e9dcb20d..4094b1a06d94e 100644 --- a/services/core/java/com/android/server/policy/PhoneWindowManager.java +++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java @@ -3484,6 +3484,11 @@ public class PhoneWindowManager implements WindowManagerPolicy { interceptScreenshotChord(SCREENSHOT_KEY_OTHER, 0 /*pressDelay*/); } return true; + case KeyEvent.KEYCODE_ESCAPE: + if (down && repeatCount == 0) { + mContext.closeSystemDialogs(); + } + return true; } return false;