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

Commit 1184db2d authored by Vaibhav Devmurari's avatar Vaibhav Devmurari Committed by Automerger Merge Worker
Browse files

Merge "Add Home shortcut Meta+Enter" into udc-dev am: f83766ec am: cfa107bb

parents 278ed845 cfa107bb
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -2987,6 +2987,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                }
                }
                break;
                break;
            case KeyEvent.KEYCODE_H:
            case KeyEvent.KEYCODE_H:
            case KeyEvent.KEYCODE_ENTER:
                if (event.isMetaPressed()) {
                if (event.isMetaPressed()) {
                    return handleHomeShortcuts(displayId, focusedToken, event);
                    return handleHomeShortcuts(displayId, focusedToken, event);
                }
                }
+22 −0
Original line number Original line Diff line number Diff line
@@ -21,6 +21,8 @@ import static android.view.KeyEvent.KEYCODE_B;
import static android.view.KeyEvent.KEYCODE_C;
import static android.view.KeyEvent.KEYCODE_C;
import static android.view.KeyEvent.KEYCODE_CTRL_LEFT;
import static android.view.KeyEvent.KEYCODE_CTRL_LEFT;
import static android.view.KeyEvent.KEYCODE_E;
import static android.view.KeyEvent.KEYCODE_E;
import static android.view.KeyEvent.KEYCODE_ENTER;
import static android.view.KeyEvent.KEYCODE_H;
import static android.view.KeyEvent.KEYCODE_K;
import static android.view.KeyEvent.KEYCODE_K;
import static android.view.KeyEvent.KEYCODE_M;
import static android.view.KeyEvent.KEYCODE_M;
import static android.view.KeyEvent.KEYCODE_META_LEFT;
import static android.view.KeyEvent.KEYCODE_META_LEFT;
@@ -164,4 +166,24 @@ public class ModifierShortcutTests extends ShortcutKeyTestBase {
        sendKeyCombination(new int[]{KEYCODE_META_LEFT, KEYCODE_ALT_LEFT}, 0);
        sendKeyCombination(new int[]{KEYCODE_META_LEFT, KEYCODE_ALT_LEFT}, 0);
        mPhoneWindowManager.assertToggleCapsLock();
        mPhoneWindowManager.assertToggleCapsLock();
    }
    }

    /**
     * META + H to go to homescreen
     */
    @Test
    public void testMetaH() {
        mPhoneWindowManager.overrideLaunchHome();
        sendKeyCombination(new int[]{KEYCODE_META_LEFT, KEYCODE_H}, 0);
        mPhoneWindowManager.assertGoToHomescreen();
    }

    /**
     * META + ENTER to go to homescreen
     */
    @Test
    public void testMetaEnter() {
        mPhoneWindowManager.overrideLaunchHome();
        sendKeyCombination(new int[]{KEYCODE_META_LEFT, KEYCODE_ENTER}, 0);
        mPhoneWindowManager.assertGoToHomescreen();
    }
}
}
+2 −2
Original line number Original line Diff line number Diff line
@@ -117,9 +117,9 @@ class ShortcutKeyTestBase {
            throw new RuntimeException(e);
            throw new RuntimeException(e);
        }
        }


        for (KeyEvent event: events) {
        for (int i = count - 1; i >= 0; i--) {
            final long eventTime = SystemClock.uptimeMillis();
            final long eventTime = SystemClock.uptimeMillis();
            final int keyCode = event.getKeyCode();
            final int keyCode = keyCodes[i];
            final KeyEvent upEvent = new KeyEvent(downTime, eventTime, KeyEvent.ACTION_UP, keyCode,
            final KeyEvent upEvent = new KeyEvent(downTime, eventTime, KeyEvent.ACTION_UP, keyCode,
                    0, metaState, KeyCharacterMap.VIRTUAL_KEYBOARD, 0 /*scancode*/, 0 /*flags*/,
                    0, metaState, KeyCharacterMap.VIRTUAL_KEYBOARD, 0 /*scancode*/, 0 /*flags*/,
                    InputDevice.SOURCE_KEYBOARD);
                    InputDevice.SOURCE_KEYBOARD);
+9 −0
Original line number Original line Diff line number Diff line
@@ -353,6 +353,10 @@ class TestPhoneWindowManager {
                () -> LocalServices.getService(eq(StatusBarManagerInternal.class)));
                () -> LocalServices.getService(eq(StatusBarManagerInternal.class)));
    }
    }


    void overrideLaunchHome() {
        doNothing().when(mPhoneWindowManager).launchHomeFromHotKey(anyInt());
    }

    /**
    /**
     * Below functions will check the policy behavior could be invoked.
     * Below functions will check the policy behavior could be invoked.
     */
     */
@@ -480,4 +484,9 @@ class TestPhoneWindowManager {
        transitionCaptor.getValue().onAppTransitionFinishedLocked(any());
        transitionCaptor.getValue().onAppTransitionFinishedLocked(any());
        verify(mPhoneWindowManager).lockNow(null);
        verify(mPhoneWindowManager).lockNow(null);
    }
    }

    void assertGoToHomescreen() {
        waitForIdle();
        verify(mPhoneWindowManager).launchHomeFromHotKey(anyInt());
    }
}
}