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

Commit f25f363d authored by Danny Baumann's avatar Danny Baumann Committed by Gerrit Code Review
Browse files

Merge "Fix virtual key press detection." into cm-10.2

parents 716ca809 3b611047
Loading
Loading
Loading
Loading
+12 −21
Original line number Original line Diff line number Diff line
@@ -476,10 +476,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    private int mPressOnAppSwitchBehavior = -1;
    private int mPressOnAppSwitchBehavior = -1;
    private int mLongPressOnAppSwitchBehavior = -1;
    private int mLongPressOnAppSwitchBehavior = -1;


    // To identify simulated keypresses, so we can perform
    // the default action for that key
    private boolean mIsVirtualKeypress;

    // Tracks preloading of the recent apps screen
    // Tracks preloading of the recent apps screen
    private boolean mRecentAppsPreloaded;
    private boolean mRecentAppsPreloaded;


@@ -937,8 +933,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    }
    }


    private void triggerVirtualKeypress(final int keyCode) {
    private void triggerVirtualKeypress(final int keyCode) {
        new Thread(new Runnable() {
            public void run() {
        InputManager im = InputManager.getInstance();
        InputManager im = InputManager.getInstance();
        long now = SystemClock.uptimeMillis();
        long now = SystemClock.uptimeMillis();


@@ -947,12 +941,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                KeyEvent.FLAG_FROM_SYSTEM, InputDevice.SOURCE_KEYBOARD);
                KeyEvent.FLAG_FROM_SYSTEM, InputDevice.SOURCE_KEYBOARD);
        final KeyEvent upEvent = KeyEvent.changeAction(downEvent, KeyEvent.ACTION_UP);
        final KeyEvent upEvent = KeyEvent.changeAction(downEvent, KeyEvent.ACTION_UP);


                mIsVirtualKeypress = true;
        im.injectInputEvent(downEvent, InputManager.INJECT_INPUT_EVENT_MODE_ASYNC);
                im.injectInputEvent(downEvent, InputManager.INJECT_INPUT_EVENT_MODE_WAIT_FOR_RESULT);
        im.injectInputEvent(upEvent, InputManager.INJECT_INPUT_EVENT_MODE_ASYNC);
                im.injectInputEvent(upEvent, InputManager.INJECT_INPUT_EVENT_MODE_WAIT_FOR_RESULT);
                mIsVirtualKeypress = false;
            }
        }).start();
    }
    }


    private void performKeyAction(int behavior) {
    private void performKeyAction(int behavior) {
@@ -2252,6 +2242,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        final boolean down = event.getAction() == KeyEvent.ACTION_DOWN;
        final boolean down = event.getAction() == KeyEvent.ACTION_DOWN;
        final boolean canceled = event.isCanceled();
        final boolean canceled = event.isCanceled();
        final boolean longPress = (flags & KeyEvent.FLAG_LONG_PRESS) != 0;
        final boolean longPress = (flags & KeyEvent.FLAG_LONG_PRESS) != 0;
        final boolean virtualKey = event.getDeviceId() == KeyCharacterMap.VIRTUAL_KEYBOARD;


        if (DEBUG_INPUT) {
        if (DEBUG_INPUT) {
            Log.d(TAG, "interceptKeyTi keyCode=" + keyCode + " down=" + down + " repeatCount="
            Log.d(TAG, "interceptKeyTi keyCode=" + keyCode + " down=" + down + " repeatCount="
@@ -2435,7 +2426,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                        Settings.System.putInt(
                        Settings.System.putInt(
                                res, Settings.System.SHOW_PROCESSES, shown ? 0 : 1);
                                res, Settings.System.SHOW_PROCESSES, shown ? 0 : 1);
                        return -1;
                        return -1;
                    } else if (mPressOnMenuBehavior != KEY_ACTION_MENU && !mIsVirtualKeypress) {
                    } else if (mPressOnMenuBehavior != KEY_ACTION_MENU && !virtualKey) {
                        mMenuDoCustomAction = true;
                        mMenuDoCustomAction = true;
                        return -1;
                        return -1;
                    }
                    }