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

Commit fc569e15 authored by Vaibhav Devmurari's avatar Vaibhav Devmurari
Browse files

Prioritize System shortcuts over shortcut services

Shortcut services is legacy way to define shortcuts in different
components. We should migrate shortcut services to KeyGestureHandler
APIs. But as a stop gap reduce priority of shortcut services so
they don't block system shortcuts.

Currently only 2 shortcuts are registered through shortcut services,
and they apparently do nothing.

Test: manual
Bug: 358569822
Flag: EXEMPT bugfix
Change-Id: I9c0fbcacd1b2a020178f65ad0e39c0f96a1bdd05
parent 09ba9519
Loading
Loading
Loading
Loading
+7 −16
Original line number Diff line number Diff line
@@ -210,16 +210,16 @@ final class AppLaunchShortcutManager {

    /**
     * Handle the shortcut to {@link IShortcutService}
     * @param keyCode The key code of the event.
     * @param metaState The meta key modifier state.
     * @return True if invoked the shortcut, otherwise false.
     * @return true if invoked the shortcut, otherwise false.
     */
    private boolean handleShortcutService(int keyCode, int metaState) {
        final long shortcutCodeMeta = metaState & SHORTCUT_CODE_META_MASK;
    public boolean handleShortcutService(KeyEvent event) {
        // TODO(b/358569822): Ideally shortcut service custom shortcuts should be either
        //  migrated to bookmarks or customizable shortcut APIs.
        final long shortcutCodeMeta = event.getMetaState() & SHORTCUT_CODE_META_MASK;
        if (shortcutCodeMeta == 0) {
            return false;
        }
        long shortcutCode = keyCode | (shortcutCodeMeta << Integer.SIZE);
        long shortcutCode = event.getKeyCode() | (shortcutCodeMeta << Integer.SIZE);
        IShortcutService shortcutService = mShortcutKeyServices.get(shortcutCode);
        if (shortcutService != null) {
            try {
@@ -292,7 +292,6 @@ final class AppLaunchShortcutManager {
            return InterceptKeyResult.DO_NOTHING;
        }

        final int metaState = event.getModifiers();
        final int keyCode = event.getKeyCode();
        if (keyCode == KeyEvent.KEYCODE_SEARCH) {
            if (event.getAction() == KeyEvent.ACTION_DOWN) {
@@ -313,15 +312,7 @@ final class AppLaunchShortcutManager {
        }

        // Intercept shortcuts defined in bookmarks or through application launch keycodes
        AppLaunchData appLaunchData = interceptShortcut(event);

        // TODO(b/358569822): Ideally shortcut service custom shortcuts should be either
        //  migrated to bookmarks or customizable shortcut APIs.
        if (appLaunchData == null && handleShortcutService(keyCode, metaState)) {
            return InterceptKeyResult.CONSUME_KEY;
        }

        return new InterceptKeyResult(/* consumed =*/ false, appLaunchData);
        return new InterceptKeyResult(/* consumed =*/ false, interceptShortcut(event));
    }

    /**
+5 −0
Original line number Diff line number Diff line
@@ -793,6 +793,11 @@ final class KeyGestureController {
                return true;
        }

        // Handle shortcuts through shortcut services
        if (mAppLaunchShortcutManager.handleShortcutService(event)) {
            return true;
        }

        // Handle custom shortcuts
        if (firstDown) {
            InputGestureData customGesture;