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

Commit d449c1a6 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Allow TOUCHSCREEN event observing while TouchExploration is enabled." into main

parents b0ff3d00 02b1701e
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -10,6 +10,16 @@ flag {
    bug: "297972548"
}

flag {
    name: "always_allow_observing_touch_events"
    namespace: "accessibility"
    description: "Always allows InputFilter observing SOURCE_TOUCHSCREEN events, even if touch exploration is enabled."
    bug: "344604959"
    metadata {
        purpose: PURPOSE_BUGFIX
    }
}

flag {
    name: "resettable_dynamic_properties"
    namespace: "accessibility"
+31 −7
Original line number Diff line number Diff line
@@ -1087,7 +1087,15 @@ class AccessibilityInputFilter extends InputFilter implements EventStreamTransfo
        }
    }

    private boolean anyServiceWantsToObserveMotionEvent(MotionEvent event) {
    private boolean anyServiceWantsGenericMotionEvent(MotionEvent event) {
        if (Flags.alwaysAllowObservingTouchEvents()) {
            final boolean isTouchEvent = event.isFromSource(InputDevice.SOURCE_TOUCHSCREEN);
            if (isTouchEvent && !canShareGenericTouchEvent()) {
                return false;
            }
            final int eventSourceWithoutClass = event.getSource() & ~InputDevice.SOURCE_CLASS_MASK;
            return (mCombinedGenericMotionEventSources & eventSourceWithoutClass) != 0;
        }
        // Disable SOURCE_TOUCHSCREEN generic event interception if any service is performing
        // touch exploration.
        if (event.isFromSource(InputDevice.SOURCE_TOUCHSCREEN)
@@ -1095,13 +1103,14 @@ class AccessibilityInputFilter extends InputFilter implements EventStreamTransfo
            return false;
        }
        final int eventSourceWithoutClass = event.getSource() & ~InputDevice.SOURCE_CLASS_MASK;
        return (mCombinedGenericMotionEventSources
                        & mCombinedMotionEventObservedSources
                        & eventSourceWithoutClass)
                != 0;
        return (mCombinedGenericMotionEventSources & eventSourceWithoutClass) != 0;
    }

    private boolean anyServiceWantsGenericMotionEvent(MotionEvent event) {
    private boolean anyServiceWantsToObserveMotionEvent(MotionEvent event) {
        if (Flags.alwaysAllowObservingTouchEvents()) {
            final int eventSourceWithoutClass = event.getSource() & ~InputDevice.SOURCE_CLASS_MASK;
            return (mCombinedMotionEventObservedSources & eventSourceWithoutClass) != 0;
        }
        // Disable SOURCE_TOUCHSCREEN generic event interception if any service is performing
        // touch exploration.
        if (event.isFromSource(InputDevice.SOURCE_TOUCHSCREEN)
@@ -1109,7 +1118,22 @@ class AccessibilityInputFilter extends InputFilter implements EventStreamTransfo
            return false;
        }
        final int eventSourceWithoutClass = event.getSource() & ~InputDevice.SOURCE_CLASS_MASK;
        return (mCombinedGenericMotionEventSources & eventSourceWithoutClass) != 0;
        return (mCombinedGenericMotionEventSources
                & mCombinedMotionEventObservedSources
                & eventSourceWithoutClass)
                != 0;
    }

    private boolean canShareGenericTouchEvent() {
        if ((mCombinedMotionEventObservedSources & InputDevice.SOURCE_TOUCHSCREEN) != 0) {
            // Share touch events if a MotionEvent-observing service wants them.
            return true;
        }
        if ((mEnabledFeatures & FLAG_FEATURE_TOUCH_EXPLORATION) == 0) {
            // Share touch events if touch exploration is not enabled.
            return true;
        }
        return false;
    }

    public void setCombinedGenericMotionEventSources(int sources) {