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

Commit 7ba80b0a authored by Jean Chen's avatar Jean Chen
Browse files

feat(MultiFingerMultiTap): Send Setting value, SingleFingerTripleTap and...

feat(MultiFingerMultiTap): Send Setting value, SingleFingerTripleTap and TwoFingerTripleTap, to MagnificationGestureHandle for enable feature

Add TwoFingerTripleTap to the constructor for AccessibilityInputFilter, which will enable us to implement the feature on window magnification and fullscreen magnification.

Add the feature flag check when setting the value of mDetectTwoFingerTripleTap in MagnifictionGestureHandler (not client side) to ensure that the feature is enabled and apply on window and fullscreen Mag.

Bug: 297805269
Test: manual
Test: atest MagnificationGestureHandlerTest
Test: atest FullScreenMagnificationGestureHandlerTest
Test: atest WindowMagnificationGestureHandlerTest
Change-Id: I851d1ce055a2348044cb9cf2e92942ffb9255b15
parent e9fc0fb0
Loading
Loading
Loading
Loading
+12 −3
Original line number Diff line number Diff line
@@ -157,6 +157,7 @@ class AccessibilityInputFilter extends InputFilter implements EventStreamTransfo
                    | FLAG_FEATURE_AUTOCLICK
                    | FLAG_FEATURE_TOUCH_EXPLORATION
                    | FLAG_FEATURE_MAGNIFICATION_SINGLE_FINGER_TRIPLE_TAP
                    | FLAG_FEATURE_MAGNIFICATION_TWO_FINGER_TRIPLE_TAP
                    | FLAG_FEATURE_TRIGGERED_SCREEN_MAGNIFIER
                    | FLAG_SERVICE_HANDLES_DOUBLE_TAP
                    | FLAG_REQUEST_MULTI_FINGER_GESTURES
@@ -538,6 +539,7 @@ class AccessibilityInputFilter extends InputFilter implements EventStreamTransfo

        if ((mEnabledFeatures & FLAG_FEATURE_CONTROL_SCREEN_MAGNIFIER) != 0
                || ((mEnabledFeatures & FLAG_FEATURE_MAGNIFICATION_SINGLE_FINGER_TRIPLE_TAP) != 0)
                || ((mEnabledFeatures & FLAG_FEATURE_MAGNIFICATION_TWO_FINGER_TRIPLE_TAP) != 0)
                || ((mEnabledFeatures & FLAG_FEATURE_TRIGGERED_SCREEN_MAGNIFIER) != 0)) {
            final MagnificationGestureHandler magnificationGestureHandler =
                    createMagnificationGestureHandler(displayId,
@@ -656,6 +658,8 @@ class AccessibilityInputFilter extends InputFilter implements EventStreamTransfo
            int displayId, Context displayContext) {
        final boolean detectControlGestures = (mEnabledFeatures
                & FLAG_FEATURE_MAGNIFICATION_SINGLE_FINGER_TRIPLE_TAP) != 0;
        final boolean detectTwoFingerTripleTap = (mEnabledFeatures
                & FLAG_FEATURE_MAGNIFICATION_TWO_FINGER_TRIPLE_TAP) != 0;
        final boolean triggerable = (mEnabledFeatures
                & FLAG_FEATURE_TRIGGERED_SCREEN_MAGNIFIER) != 0;
        MagnificationGestureHandler magnificationGestureHandler;
@@ -665,8 +669,10 @@ class AccessibilityInputFilter extends InputFilter implements EventStreamTransfo
                    TYPE_ACCESSIBILITY_MAGNIFICATION_OVERLAY, null /* options */);
            magnificationGestureHandler = new WindowMagnificationGestureHandler(uiContext,
                    mAms.getWindowMagnificationMgr(), mAms.getTraceManager(),
                    mAms.getMagnificationController(), detectControlGestures, triggerable,
                    displayId);
                    mAms.getMagnificationController(),
                    detectControlGestures,
                    detectTwoFingerTripleTap,
                    triggerable, displayId);
        } else {
            final Context uiContext = displayContext.createWindowContext(
                    TYPE_MAGNIFICATION_OVERLAY, null /* options */);
@@ -675,7 +681,10 @@ class AccessibilityInputFilter extends InputFilter implements EventStreamTransfo
            magnificationGestureHandler = new FullScreenMagnificationGestureHandler(uiContext,
                    mAms.getMagnificationController().getFullScreenMagnificationController(),
                    mAms.getTraceManager(),
                    mAms.getMagnificationController(), detectControlGestures, triggerable,
                    mAms.getMagnificationController(),
                    detectControlGestures,
                    detectTwoFingerTripleTap,
                    triggerable,
                    new WindowMagnificationPromptController(displayContext, mUserId), displayId,
                    fullScreenMagnificationVibrationHelper);
        }
+11 −5
Original line number Diff line number Diff line
@@ -177,12 +177,14 @@ public class FullScreenMagnificationGestureHandler extends MagnificationGestureH
            FullScreenMagnificationController fullScreenMagnificationController,
            AccessibilityTraceManager trace,
            Callback callback,
            boolean detectTripleTap,
            boolean detectSingleFingerTripleTap,
            boolean detectTwoFingerTripleTap,
            boolean detectShortcutTrigger,
            @NonNull WindowMagnificationPromptController promptController,
            int displayId,
            FullScreenMagnificationVibrationHelper fullScreenMagnificationVibrationHelper) {
        this(context, fullScreenMagnificationController, trace, callback, detectTripleTap,
        this(context, fullScreenMagnificationController, trace, callback,
                detectSingleFingerTripleTap, detectTwoFingerTripleTap,
                detectShortcutTrigger, promptController, displayId,
                fullScreenMagnificationVibrationHelper, /* magnificationLogger= */ null);
    }
@@ -193,16 +195,20 @@ public class FullScreenMagnificationGestureHandler extends MagnificationGestureH
            FullScreenMagnificationController fullScreenMagnificationController,
            AccessibilityTraceManager trace,
            Callback callback,
            boolean detectTripleTap,
            boolean detectSingleFingerTripleTap,
            boolean detectTwoFingerTripleTap,
            boolean detectShortcutTrigger,
            @NonNull WindowMagnificationPromptController promptController,
            int displayId,
            FullScreenMagnificationVibrationHelper fullScreenMagnificationVibrationHelper,
            MagnificationLogger magnificationLogger) {
        super(displayId, detectTripleTap, detectShortcutTrigger, trace, callback);
        super(displayId, detectSingleFingerTripleTap, detectTwoFingerTripleTap,
                detectShortcutTrigger, trace, callback);
        if (DEBUG_ALL) {
            Log.i(mLogTag,
                    "FullScreenMagnificationGestureHandler(detectTripleTap = " + detectTripleTap
                    "FullScreenMagnificationGestureHandler(detectSingleFingerTripleTap = "
                            + detectSingleFingerTripleTap
                            + ", detectTwoFingerTripleTap = " + detectTwoFingerTripleTap
                            + ", detectShortcutTrigger = " + detectShortcutTrigger + ")");
        }
        mFullScreenMagnificationController = fullScreenMagnificationController;
+15 −3
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import android.view.MotionEvent;

import com.android.server.accessibility.AccessibilityTraceManager;
import com.android.server.accessibility.BaseEventStreamTransformation;
import com.android.server.accessibility.Flags;

import java.util.ArrayDeque;
import java.util.Queue;
@@ -63,6 +64,13 @@ public abstract class MagnificationGestureHandler extends BaseEventStreamTransfo
     */
    protected final boolean mDetectSingleFingerTripleTap;

    /**
     * {@code true} if this detector should detect and respond to two-finger triple-tap
     * gestures for engaging and disengaging magnification,
     * {@code false} if it should ignore such gestures
     */
    protected final boolean mDetectTwoFingerTripleTap;

    /** Callback interface to report that magnification is interactive with a user. */
    public interface Callback {
        /**
@@ -85,12 +93,16 @@ public abstract class MagnificationGestureHandler extends BaseEventStreamTransfo
    private final AccessibilityTraceManager mTrace;
    protected final Callback mCallback;

    protected MagnificationGestureHandler(int displayId, boolean detectSingleFingerTripleTap,
    protected MagnificationGestureHandler(int displayId,
            boolean detectSingleFingerTripleTap,
            boolean detectTwoFingerTripleTap,
            boolean detectShortcutTrigger,
            AccessibilityTraceManager trace,
            @NonNull Callback callback) {
        mDisplayId = displayId;
        mDetectSingleFingerTripleTap = detectSingleFingerTripleTap;
        mDetectTwoFingerTripleTap = Flags.enableMagnificationMultipleFingerMultipleTapGesture()
                && detectTwoFingerTripleTap;
        mDetectShortcutTrigger = detectShortcutTrigger;
        mTrace = trace;
        mCallback = callback;
@@ -128,8 +140,8 @@ public abstract class MagnificationGestureHandler extends BaseEventStreamTransfo
    }

    private boolean shouldDispatchTransformedEvent(MotionEvent event) {
        if ((!mDetectSingleFingerTripleTap && !mDetectShortcutTrigger) || !event.isFromSource(
                SOURCE_TOUCHSCREEN)) {
        if ((!mDetectSingleFingerTripleTap && !mDetectTwoFingerTripleTap && !mDetectShortcutTrigger)
                || !event.isFromSource(SOURCE_TOUCHSCREEN)) {
            return true;
        }
        return false;
+6 −2
Original line number Diff line number Diff line
@@ -99,8 +99,12 @@ public class WindowMagnificationGestureHandler extends MagnificationGestureHandl
            WindowMagnificationManager windowMagnificationMgr,
            AccessibilityTraceManager trace,
            Callback callback,
            boolean detectTripleTap, boolean detectShortcutTrigger, int displayId) {
        super(displayId, detectTripleTap, detectShortcutTrigger, trace, callback);
            boolean detectSingleFingerTripleTap,
            boolean detectTwoFingerTripleTap,
            boolean detectShortcutTrigger,
            int displayId) {
        super(displayId, detectSingleFingerTripleTap, detectTwoFingerTripleTap,
                detectShortcutTrigger, trace, callback);
        if (DEBUG_ALL) {
            Slog.i(mLogTag,
                    "WindowMagnificationGestureHandler() , displayId = " + displayId + ")");
+9 −6
Original line number Diff line number Diff line
@@ -234,9 +234,11 @@ public class FullScreenMagnificationGestureHandlerTest {
        mFullScreenMagnificationController.setAlwaysOnMagnificationEnabled(true);
        mClock = new OffsettableClock.Stopped();

        boolean detectTripleTap = true;
        boolean detectSingleFingerTripleTap = true;
        boolean detectTwoFingerTripleTap = true;
        boolean detectShortcutTrigger = true;
        mMgh = newInstance(detectTripleTap, detectShortcutTrigger);
        mMgh = newInstance(detectSingleFingerTripleTap, detectTwoFingerTripleTap,
                detectShortcutTrigger);
    }

    @After
@@ -251,11 +253,11 @@ public class FullScreenMagnificationGestureHandlerTest {
    }

    @NonNull
    private FullScreenMagnificationGestureHandler newInstance(boolean detectTripleTap,
            boolean detectShortcutTrigger) {
    private FullScreenMagnificationGestureHandler newInstance(boolean detectSingleFingerTripleTap,
            boolean detectTwoFingerTripleTap, boolean detectShortcutTrigger) {
        FullScreenMagnificationGestureHandler h = new FullScreenMagnificationGestureHandler(
                mContext, mFullScreenMagnificationController, mMockTraceManager, mMockCallback,
                detectTripleTap, detectShortcutTrigger,
                detectSingleFingerTripleTap, detectTwoFingerTripleTap, detectShortcutTrigger,
                mWindowMagnificationPromptController, DISPLAY_0,
                mMockFullScreenMagnificationVibrationHelper, mMockMagnificationLogger);
        if (isWatch()) {
@@ -424,7 +426,8 @@ public class FullScreenMagnificationGestureHandlerTest {

    @Test
    public void testDisablingTripleTap_removesInputLag() {
        mMgh = newInstance(/* detect3tap */ false, /* detectShortcut */ true);
        mMgh = newInstance(/* detectSingleFingerTripleTap */ false,
                /* detectTwoFingerTripleTap */ true, /* detectShortcut */ true);
        goFromStateIdleTo(STATE_IDLE);
        allowEventDelegation();
        tap();
Loading