Add Home shortcut Meta+Enter
Test: atest ModifierShortcutTests Bug: 277081504 Change-Id: I850667c836e32ee8ae6cf9dbac028716115299c0
This commit is contained in:
@@ -2987,6 +2987,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
}
|
||||
break;
|
||||
case KeyEvent.KEYCODE_H:
|
||||
case KeyEvent.KEYCODE_ENTER:
|
||||
if (event.isMetaPressed()) {
|
||||
return handleHomeShortcuts(displayId, focusedToken, event);
|
||||
}
|
||||
|
||||
@@ -21,6 +21,8 @@ import static android.view.KeyEvent.KEYCODE_B;
|
||||
import static android.view.KeyEvent.KEYCODE_C;
|
||||
import static android.view.KeyEvent.KEYCODE_CTRL_LEFT;
|
||||
import static android.view.KeyEvent.KEYCODE_E;
|
||||
import static android.view.KeyEvent.KEYCODE_ENTER;
|
||||
import static android.view.KeyEvent.KEYCODE_H;
|
||||
import static android.view.KeyEvent.KEYCODE_K;
|
||||
import static android.view.KeyEvent.KEYCODE_M;
|
||||
import static android.view.KeyEvent.KEYCODE_META_LEFT;
|
||||
@@ -164,4 +166,24 @@ public class ModifierShortcutTests extends ShortcutKeyTestBase {
|
||||
sendKeyCombination(new int[]{KEYCODE_META_LEFT, KEYCODE_ALT_LEFT}, 0);
|
||||
mPhoneWindowManager.assertToggleCapsLock();
|
||||
}
|
||||
|
||||
/**
|
||||
* META + H to go to homescreen
|
||||
*/
|
||||
@Test
|
||||
public void testMetaH() {
|
||||
mPhoneWindowManager.overrideLaunchHome();
|
||||
sendKeyCombination(new int[]{KEYCODE_META_LEFT, KEYCODE_H}, 0);
|
||||
mPhoneWindowManager.assertGoToHomescreen();
|
||||
}
|
||||
|
||||
/**
|
||||
* META + ENTER to go to homescreen
|
||||
*/
|
||||
@Test
|
||||
public void testMetaEnter() {
|
||||
mPhoneWindowManager.overrideLaunchHome();
|
||||
sendKeyCombination(new int[]{KEYCODE_META_LEFT, KEYCODE_ENTER}, 0);
|
||||
mPhoneWindowManager.assertGoToHomescreen();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,9 +117,9 @@ class ShortcutKeyTestBase {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
for (KeyEvent event: events) {
|
||||
for (int i = count - 1; i >= 0; i--) {
|
||||
final long eventTime = SystemClock.uptimeMillis();
|
||||
final int keyCode = event.getKeyCode();
|
||||
final int keyCode = keyCodes[i];
|
||||
final KeyEvent upEvent = new KeyEvent(downTime, eventTime, KeyEvent.ACTION_UP, keyCode,
|
||||
0, metaState, KeyCharacterMap.VIRTUAL_KEYBOARD, 0 /*scancode*/, 0 /*flags*/,
|
||||
InputDevice.SOURCE_KEYBOARD);
|
||||
|
||||
@@ -353,6 +353,10 @@ class TestPhoneWindowManager {
|
||||
() -> LocalServices.getService(eq(StatusBarManagerInternal.class)));
|
||||
}
|
||||
|
||||
void overrideLaunchHome() {
|
||||
doNothing().when(mPhoneWindowManager).launchHomeFromHotKey(anyInt());
|
||||
}
|
||||
|
||||
/**
|
||||
* Below functions will check the policy behavior could be invoked.
|
||||
*/
|
||||
@@ -480,4 +484,9 @@ class TestPhoneWindowManager {
|
||||
transitionCaptor.getValue().onAppTransitionFinishedLocked(any());
|
||||
verify(mPhoneWindowManager).lockNow(null);
|
||||
}
|
||||
|
||||
void assertGoToHomescreen() {
|
||||
waitForIdle();
|
||||
verify(mPhoneWindowManager).launchHomeFromHotKey(anyInt());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user