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

Commit 8ea70529 authored by Daniel Norman's avatar Daniel Norman Committed by Yeabkal Wubshit
Browse files

Allow TOUCHSCREEN event observing while TouchExploration is enabled.

Bug: 344604959
Flag: com.android.server.accessibility.always_allow_observing_touch_events
Test: atest AccessibilityEndToEndTest
Test: Verified by MotionEvent-observing service on the watch
Change-Id: I309846bfd22f0a84e4d985c4831bf5b147c11b26
parent bb7f4f03
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) {