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

Commit a2455364 authored by Ameer Armaly's avatar Ameer Armaly
Browse files

Fix screenshot shortcut when accessibility is enabled.

Previously, pressing the power button would cause the input state to reset in order to pass on the key events relating to the power button.
When pressing the power button in combination with the volume down button, to take a screen shot, this would mean that the system would receive the ACTION_UP for the volume button before the ACTION_DOWN.
In this change we pass on the power buttons but do not reset state, allowing us to process other events normally.

Flag: com.android.server.accessibility.do_not_reset_key_event_state
Fix:331900630
Test: Enable the DEBUG variable in AccessibilityInputFilter.java. Press volume down and power to take a screenshot. Inspect the logs to observe the event stream.
Test: Press volume up and down with one finger on the screen. Observe the volume adjustment works normally.
Test: Press power and volume up to activate the power menu.
Change-Id: Ie986bcb25f738b0163c92ddb22897f781890f5c1
parent 75ee1ea7
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -48,6 +48,16 @@ flag {
    bug: "198018180"
}

flag {
    name: "do_not_reset_key_event_state"
    namespace: "accessibility"
    description: "Don't reset the event stream state when receiving an event without policy flag FLAG_PASS_TO_USER. Just pass it through the pipeline."
    bug: "331900630"
    metadata {
        purpose: PURPOSE_BUGFIX
    }
}

flag {
    name: "enable_a11y_checker_logging"
    namespace: "accessibility"
+13 −2
Original line number Diff line number Diff line
@@ -347,8 +347,13 @@ class AccessibilityInputFilter extends InputFilter implements EventStreamTransfo
        final int eventSource = event.getSource();
        final int displayId = event.getDisplayId();
        if ((policyFlags & WindowManagerPolicy.FLAG_PASS_TO_USER) == 0) {
            if (!Flags.doNotResetKeyEventState()) {
                state.reset();
                clearEventStreamHandler(displayId, eventSource);
            }
            if (DEBUG) {
                Slog.d(TAG, "Not processing event " + event);
            }
            super.onInputEvent(event, policyFlags);
            return;
        }
@@ -503,9 +508,15 @@ class AccessibilityInputFilter extends InputFilter implements EventStreamTransfo

    private void processKeyEvent(EventStreamState state, KeyEvent event, int policyFlags) {
        if (!state.shouldProcessKeyEvent(event)) {
            if (DEBUG) {
                Slog.d(TAG, "processKeyEvent: not processing: " + event);
            }
            super.onInputEvent(event, policyFlags);
            return;
        }
        if (DEBUG) {
            Slog.d(TAG, "processKeyEvent: " + event);
        }
        // Since the display id of KeyEvent always would be -1 and there is only one
        // KeyboardInterceptor for all display, pass KeyEvent to the mEventHandler of
        // DEFAULT_DISPLAY to handle.