diff --git a/core/java/android/view/ViewConfiguration.java b/core/java/android/view/ViewConfiguration.java index 0a3d0da6da1e0..495edab57abd3 100644 --- a/core/java/android/view/ViewConfiguration.java +++ b/core/java/android/view/ViewConfiguration.java @@ -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 */ diff --git a/services/core/java/com/android/server/input/InputShellCommand.java b/services/core/java/com/android/server/input/InputShellCommand.java index 720be826fd387..29aa2a873cc90 100644 --- a/services/core/java/com/android/server/input/InputShellCommand.java +++ b/services/core/java/com/android/server/input/InputShellCommand.java @@ -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)); }