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

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

Fix: Open notes shortcut is not customizable

In the new KeyGestureEvent design shortcut handlers should not
depend on keycode and modifeir state to handle an event, so that
the shortcut can be customized in shortcut helepr UI.

Bug: 381241291
Test: atest NoteTaskInitializerTest
Flag: EXEMPT bugfix
Change-Id: I6135c5720901ffeefe70082f8d23d4589b52acec
parent dd413e96
Loading
Loading
Loading
Loading
+2 −9
Original line number Diff line number Diff line
@@ -216,20 +216,13 @@ constructor(
            "handleKeyGestureEvent: Received OPEN_NOTES gesture event from keycodes: " +
                event.keycodes.contentToString()
        }
        if (
            event.keycodes.contains(KEYCODE_N) &&
                event.hasModifiers(KeyEvent.META_CTRL_ON or KeyEvent.META_META_ON)
        ) {
            debugLog { "Note task triggered by keyboard shortcut" }
            backgroundExecutor.execute { controller.showNoteTask(KEYBOARD_SHORTCUT) }
            return true
        }
        if (event.keycodes.size == 1 && event.keycodes[0] == KEYCODE_STYLUS_BUTTON_TAIL) {
            debugLog { "Note task triggered by stylus tail button" }
            backgroundExecutor.execute { controller.showNoteTask(TAIL_BUTTON) }
            return true
        }
        return false
        backgroundExecutor.execute { controller.showNoteTask(KEYBOARD_SHORTCUT) }
        return true
    }

    private fun isKeyGestureSupported(gestureType: Int): Boolean {
+1 −3
Original line number Diff line number Diff line
@@ -181,11 +181,9 @@ internal class NoteTaskInitializerTest : SysuiTestCase() {

    @Test
    @EnableFlags(com.android.hardware.input.Flags.FLAG_USE_KEY_GESTURE_EVENT_HANDLER)
    fun handlesShortcut_metaCtrlN() {
    fun handlesShortcut_keyGestureTypeOpenNotes() {
        val gestureEvent =
            KeyGestureEvent.Builder()
                .setKeycodes(intArrayOf(KeyEvent.KEYCODE_N))
                .setModifierState(KeyEvent.META_META_ON or KeyEvent.META_CTRL_ON)
                .setKeyGestureType(KeyGestureEvent.KEY_GESTURE_TYPE_OPEN_NOTES)
                .setAction(KeyGestureEvent.ACTION_GESTURE_COMPLETE)
                .build()