Merge "Make sure adb shell input keyevent --longpress KEYCODE_DPAD_CENTER triggers View#performLongClick(...)"

This commit is contained in:
Philip Junker
2021-08-10 08:03:35 +00:00
committed by Android (Google) Code Review
2 changed files with 8 additions and 1 deletions

View File

@@ -600,6 +600,8 @@ public class ViewConfiguration {
}
/**
* Used for both key and motion events.
*
* @return the duration in milliseconds before a press turns into
* a long press
*/

View File

@@ -313,8 +313,13 @@ public class InputShellCommand extends ShellCommand {
injectKeyEvent(event);
if (longpress) {
try {
Thread.sleep(ViewConfiguration.getLongPressTimeout());
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
// Some long press behavior would check the event time, we set a new event time here.
final long nextEventTime = now + ViewConfiguration.getGlobalActionKeyTimeout();
final long nextEventTime = now + ViewConfiguration.getLongPressTimeout();
injectKeyEvent(KeyEvent.changeTimeRepeat(event, nextEventTime, 1 /* repeatCount */,
KeyEvent.FLAG_LONG_PRESS));
}