Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2dd95b3f authored by Philip Junker's avatar Philip Junker
Browse files

Make sure adb shell input keyevent --longpress KEYCODE_DPAD_CENTER triggers...

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

KeyEvent#ACTION_UP removes the CheckForLongPress callback
that triggers View#performLongClick(...) after the longpress
timeout. By adding a delay in case of a long press, the
View#CheckForLongPress callback runs as expected and the
long press is triggered.

Bug: 194799728
Test: manual; build ohm_gtv-userdebug and flash it; navigate to movie / app on main view of LauncherX; adb shell input keyevent --longpress KEYCODE_DPAD_CENTER; verify that longpress menu opens; adb shell input keyevent KEYCODE_DPAD_CENTER; verify that entity page opens
Change-Id: Iae08a6c3b2c52888eae63c91a609f4aff06d2297
parent 764792b6
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -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
     */
+6 −1
Original line number Diff line number Diff line
@@ -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));
        }