diff --git a/services/core/java/com/android/server/input/KeyboardMetricsCollector.java b/services/core/java/com/android/server/input/KeyboardMetricsCollector.java index ebc784d763eff80a0b7d8f1821081a33bd38a86b..4b9f2cf9d0c03dd86b691fd521fe276cfccfd3e2 100644 --- a/services/core/java/com/android/server/input/KeyboardMetricsCollector.java +++ b/services/core/java/com/android/server/input/KeyboardMetricsCollector.java @@ -227,7 +227,12 @@ public final class KeyboardMetricsCollector { "LAUNCH_DEFAULT_FITNESS"), LAUNCH_APPLICATION_BY_PACKAGE_NAME( FrameworkStatsLog.KEYBOARD_SYSTEMS_EVENT_REPORTED__KEYBOARD_SYSTEM_EVENT__LAUNCH_APPLICATION_BY_PACKAGE_NAME, - "LAUNCH_APPLICATION_BY_PACKAGE_NAME"); + "LAUNCH_APPLICATION_BY_PACKAGE_NAME"), + DESKTOP_MODE( + FrameworkStatsLog + .KEYBOARD_SYSTEMS_EVENT_REPORTED__KEYBOARD_SYSTEM_EVENT__DESKTOP_MODE, + "DESKTOP_MODE"); + private final int mValue; private final String mName; diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java index bc260184e48756e86f7b8040ea5edbf16ff2f221..b5cd943ea60595b49b18fc388983d024b8c12447 100644 --- a/services/core/java/com/android/server/policy/PhoneWindowManager.java +++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java @@ -3509,6 +3509,16 @@ public class PhoneWindowManager implements WindowManagerPolicy { } } break; + case KeyEvent.KEYCODE_DPAD_DOWN: + if (firstDown && event.isMetaPressed() && event.isCtrlPressed()) { + StatusBarManagerInternal statusbar = getStatusBarManagerInternal(); + if (statusbar != null) { + statusbar.enterDesktop(event.getDisplayId()); + logKeyboardSystemsEvent(event, KeyboardLogEvent.DESKTOP_MODE); + return true; + } + } + break; case KeyEvent.KEYCODE_DPAD_LEFT: if (firstDown && event.isMetaPressed()) { if (event.isCtrlPressed()) { diff --git a/services/tests/wmtests/src/com/android/server/policy/ShortcutLoggingTests.java b/services/tests/wmtests/src/com/android/server/policy/ShortcutLoggingTests.java index 6853c4cdea0e110b20cbc8daadad9451219fcd92..e904eae008025ab4c2b5179cfa3ec425f27e427e 100644 --- a/services/tests/wmtests/src/com/android/server/policy/ShortcutLoggingTests.java +++ b/services/tests/wmtests/src/com/android/server/policy/ShortcutLoggingTests.java @@ -223,7 +223,11 @@ public class ShortcutLoggingTests extends ShortcutKeyTestBase { KeyboardLogEvent.LAUNCH_DEFAULT_MAPS, KeyEvent.KEYCODE_M, META_ON}, {"Meta + S -> Launch Default Messaging App", new int[]{META_KEY, KeyEvent.KEYCODE_S}, - KeyboardLogEvent.LAUNCH_DEFAULT_MESSAGING, KeyEvent.KEYCODE_S, META_ON}}; + KeyboardLogEvent.LAUNCH_DEFAULT_MESSAGING, KeyEvent.KEYCODE_S, META_ON}, + {"Meta + Ctrl + DPAD_DOWN -> Enter desktop mode", + new int[]{META_KEY, CTRL_KEY, KeyEvent.KEYCODE_DPAD_DOWN}, + KeyboardLogEvent.DESKTOP_MODE, KeyEvent.KEYCODE_DPAD_DOWN, + META_ON | CTRL_ON}}; } @Keep