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

Unverified Commit 142099ce authored by LuK1337's avatar LuK1337
Browse files

fixup! SystemUIProxy: Add injectLongPress()

* Fix KeyEvent flags
* Fix KeyEvent repeat count
* Delay long press/up by long press timeout ms

Fixes: https://gitlab.com/LineageOS/issues/android/-/issues/8683
Change-Id: I328c4dc19f8f831fd5c5623f6565ccf1d458bc3c
parent b898dd08
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -72,6 +72,7 @@ import android.view.KeyCharacterMap;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.Surface;
import android.view.ViewConfiguration;
import android.view.accessibility.AccessibilityManager;
import android.view.inputmethod.Flags;
import android.view.inputmethod.InputMethodManager;
@@ -312,9 +313,11 @@ 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, 0, 0);
                mHandler.postDelayed(() -> {
                    sendEvent(KeyEvent.ACTION_DOWN, keyCode, 1, KeyEvent.FLAG_LONG_PRESS);
                sendEvent(KeyEvent.ACTION_UP, keyCode, 1, KeyEvent.FLAG_LONG_PRESS);
                    sendEvent(KeyEvent.ACTION_UP, keyCode, 0, KeyEvent.FLAG_CANCELED);
                }, ViewConfiguration.getLongPressTimeout());
            });
        }