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

Commit 2f7b0a21 authored by Aseda Aboagye's avatar Aseda Aboagye
Browse files

InputGestureManager: Add shortcut for keyboard backlight adjustment

This commit adds the shortcut of meta+brightness_up/brightness_down to
increment and decrement the keyboard backlight brightness accordingly.

Bug: 401626732
Test: Build and flash DUT and verify that pressing meta+brightness
up and down keys adjust the keyboard backlight brightness.
Flag: com.android.hardware.input.keyboard_backlight_shortcuts

Change-Id: I5aed502788cb34d7f554665caedc201c5a225834
parent 4a50a939
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import static com.android.hardware.input.Flags.enableTalkbackKeyGestures;
import static com.android.hardware.input.Flags.enableVoiceAccessKeyGestures;
import static com.android.hardware.input.Flags.keyboardA11yShortcutControl;
import static com.android.hardware.input.Flags.enablePartialScreenshotKeyboardShortcut;
import static com.android.hardware.input.Flags.keyboardBacklightShortcuts;

import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -346,6 +347,22 @@ final class InputGestureManager {
                            /* allowCaptureByFocusedWindow = */true
                    ));
        }
        if (keyboardBacklightShortcuts()) {
            systemShortcuts.add(
                    createKeyGesture(
                            KeyEvent.KEYCODE_BRIGHTNESS_UP,
                            KeyEvent.META_META_ON,
                            KeyGestureEvent.KEY_GESTURE_TYPE_KEYBOARD_BACKLIGHT_UP,
                            /* allowCaptureByFocusedWindow = */false
                    ));
            systemShortcuts.add(
                    createKeyGesture(
                            KeyEvent.KEYCODE_BRIGHTNESS_DOWN,
                            KeyEvent.META_META_ON,
                            KeyGestureEvent.KEY_GESTURE_TYPE_KEYBOARD_BACKLIGHT_DOWN,
                            /* allowCaptureByFocusedWindow = */false
                    ));
        }
        synchronized (mGestureLock) {
            for (InputGestureData systemShortcut : systemShortcuts) {
                mSystemShortcuts.put(systemShortcut.getTrigger(), systemShortcut);
+1 −0
Original line number Diff line number Diff line
@@ -110,6 +110,7 @@ import org.mockito.kotlin.times
    com.android.hardware.input.Flags.FLAG_ENABLE_NEW_25Q2_KEYCODES,
    com.android.hardware.input.Flags.FLAG_ENABLE_QUICK_SETTINGS_PANEL_SHORTCUT,
    com.android.hardware.input.Flags.FLAG_ENABLE_PARTIAL_SCREENSHOT_KEYBOARD_SHORTCUT,
    com.android.hardware.input.Flags.FLAG_KEYBOARD_BACKLIGHT_SHORTCUTS,
)
class KeyGestureControllerTests {

+16 −0
Original line number Diff line number Diff line
@@ -329,6 +329,22 @@ object KeyGestureTestData {
                intArrayOf(KeyGestureEvent.ACTION_GESTURE_COMPLETE),
                isGestureHandlerRegistered = true,
            ),
            KeyGestureData(
                "META + BRIGHTNESS_UP -> Keyboard Backlight Up",
                intArrayOf(KeyEvent.KEYCODE_META_LEFT, KeyEvent.KEYCODE_BRIGHTNESS_UP),
                KeyGestureEvent.KEY_GESTURE_TYPE_KEYBOARD_BACKLIGHT_UP,
                intArrayOf(KeyEvent.KEYCODE_BRIGHTNESS_UP),
                KeyEvent.META_META_ON,
                intArrayOf(KeyGestureEvent.ACTION_GESTURE_COMPLETE),
            ),
            KeyGestureData(
                "META + BRIGHTNESS_DOWN -> Keyboard Backlight Down",
                intArrayOf(KeyEvent.KEYCODE_META_RIGHT, KeyEvent.KEYCODE_BRIGHTNESS_DOWN),
                KeyGestureEvent.KEY_GESTURE_TYPE_KEYBOARD_BACKLIGHT_DOWN,
                intArrayOf(KeyEvent.KEYCODE_BRIGHTNESS_DOWN),
                KeyEvent.META_META_ON,
                intArrayOf(KeyGestureEvent.ACTION_GESTURE_COMPLETE),
            ),
        )

    // All Key gestures that can be captured by the focused window (and should not happen in