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

Unverified Commit 44c78434 authored by LuK1337's avatar LuK1337 Committed by Michael Bestas
Browse files

SystemUIProxy: Add injectLongPress()

Will be used by Trebuchet.

Change-Id: Ie060333d7166d2dc7406c3994e03f00f7d61aae3
parent 434bb0e6
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -110,6 +110,9 @@ interface ISystemUiProxy {
    /** Sets home rotation enabled. */
    oneway void setHomeRotationEnabled(boolean enabled) = 45;

    /** Injects button long press. */
    oneway void injectLongPress(int keyCode) = 46;

    /** Notifies when taskbar status updated */
    oneway void notifyTaskbarStatus(boolean visible, boolean stashed) = 47;

+16 −3
Original line number Diff line number Diff line
@@ -305,6 +305,15 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
            }
        }

        @Override
        public void injectLongPress(int keyCode) throws RemoteException {
            verifyCallerAndClearCallingIdentityPostMain("longPressInjected", () -> {
                sendEvent(KeyEvent.ACTION_DOWN, keyCode, 0, KeyEvent.FLAG_LONG_PRESS);
                sendEvent(KeyEvent.ACTION_DOWN, keyCode, 1, KeyEvent.FLAG_LONG_PRESS);
                sendEvent(KeyEvent.ACTION_UP, keyCode, 1, KeyEvent.FLAG_LONG_PRESS);
            });
        }

        @Override
        public void onImeSwitcherPressed() {
            // TODO(b/204901476) We're intentionally using the default display for now since
@@ -359,11 +368,11 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
                    onTaskbarAutohideSuspend(suspend));
        }

        private boolean sendEvent(int action, int code) {
        private boolean sendEvent(int action, int code, int repeat, int flags) {
            long when = SystemClock.uptimeMillis();
            final KeyEvent ev = new KeyEvent(when, when, action, code, 0 /* repeat */,
            final KeyEvent ev = new KeyEvent(when, when, action, code, repeat,
                    0 /* metaState */, KeyCharacterMap.VIRTUAL_KEYBOARD, 0 /* scancode */,
                    KeyEvent.FLAG_FROM_SYSTEM | KeyEvent.FLAG_VIRTUAL_HARD_KEY,
                    flags | KeyEvent.FLAG_FROM_SYSTEM | KeyEvent.FLAG_VIRTUAL_HARD_KEY,
                    InputDevice.SOURCE_KEYBOARD);

            ev.setDisplayId(mContext.getDisplay().getDisplayId());
@@ -371,6 +380,10 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
                    .injectInputEvent(ev, InputManager.INJECT_INPUT_EVENT_MODE_ASYNC);
        }

        private boolean sendEvent(int action, int code) {
            return sendEvent(action, code, 0, 0);
        }

        @Override
        public void onOverviewShown(boolean fromHome) {
            verifyCallerAndClearCallingIdentityPostMain("onOverviewShown", () -> {