Merge "Add Home shortcut Meta+Enter" into udc-dev am: f83766ecce
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/22764147 Change-Id: I57ebed4d9c39f0571a0458b545d1657267fb5c9b Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -2987,6 +2987,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case KeyEvent.KEYCODE_H:
|
case KeyEvent.KEYCODE_H:
|
||||||
|
case KeyEvent.KEYCODE_ENTER:
|
||||||
if (event.isMetaPressed()) {
|
if (event.isMetaPressed()) {
|
||||||
return handleHomeShortcuts(displayId, focusedToken, event);
|
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_C;
|
||||||
import static android.view.KeyEvent.KEYCODE_CTRL_LEFT;
|
import static android.view.KeyEvent.KEYCODE_CTRL_LEFT;
|
||||||
import static android.view.KeyEvent.KEYCODE_E;
|
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_K;
|
||||||
import static android.view.KeyEvent.KEYCODE_M;
|
import static android.view.KeyEvent.KEYCODE_M;
|
||||||
import static android.view.KeyEvent.KEYCODE_META_LEFT;
|
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);
|
sendKeyCombination(new int[]{KEYCODE_META_LEFT, KEYCODE_ALT_LEFT}, 0);
|
||||||
mPhoneWindowManager.assertToggleCapsLock();
|
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);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (KeyEvent event: events) {
|
for (int i = count - 1; i >= 0; i--) {
|
||||||
final long eventTime = SystemClock.uptimeMillis();
|
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,
|
final KeyEvent upEvent = new KeyEvent(downTime, eventTime, KeyEvent.ACTION_UP, keyCode,
|
||||||
0, metaState, KeyCharacterMap.VIRTUAL_KEYBOARD, 0 /*scancode*/, 0 /*flags*/,
|
0, metaState, KeyCharacterMap.VIRTUAL_KEYBOARD, 0 /*scancode*/, 0 /*flags*/,
|
||||||
InputDevice.SOURCE_KEYBOARD);
|
InputDevice.SOURCE_KEYBOARD);
|
||||||
|
|||||||
@@ -353,6 +353,10 @@ class TestPhoneWindowManager {
|
|||||||
() -> LocalServices.getService(eq(StatusBarManagerInternal.class)));
|
() -> LocalServices.getService(eq(StatusBarManagerInternal.class)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void overrideLaunchHome() {
|
||||||
|
doNothing().when(mPhoneWindowManager).launchHomeFromHotKey(anyInt());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Below functions will check the policy behavior could be invoked.
|
* Below functions will check the policy behavior could be invoked.
|
||||||
*/
|
*/
|
||||||
@@ -480,4 +484,9 @@ class TestPhoneWindowManager {
|
|||||||
transitionCaptor.getValue().onAppTransitionFinishedLocked(any());
|
transitionCaptor.getValue().onAppTransitionFinishedLocked(any());
|
||||||
verify(mPhoneWindowManager).lockNow(null);
|
verify(mPhoneWindowManager).lockNow(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void assertGoToHomescreen() {
|
||||||
|
waitForIdle();
|
||||||
|
verify(mPhoneWindowManager).launchHomeFromHotKey(anyInt());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user