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

Commit 253e11fc authored by Jean Chen's avatar Jean Chen Committed by Android (Google) Code Review
Browse files

Merge "feat(MultiFingerMultiTap): Send Setting value, SingleFingerTripleTap...

Merge "feat(MultiFingerMultiTap): Send Setting value, SingleFingerTripleTap and TwoFingerTripleTap, to MagnificationGestureHandle for enable feature" into main
parents 488eb985 7ba80b0a
Loading
Loading
Loading
Loading
+12 −3
Original line number Original line Diff line number Diff line
@@ -157,6 +157,7 @@ class AccessibilityInputFilter extends InputFilter implements EventStreamTransfo
                    | FLAG_FEATURE_AUTOCLICK
                    | FLAG_FEATURE_AUTOCLICK
                    | FLAG_FEATURE_TOUCH_EXPLORATION
                    | FLAG_FEATURE_TOUCH_EXPLORATION
                    | FLAG_FEATURE_MAGNIFICATION_SINGLE_FINGER_TRIPLE_TAP
                    | FLAG_FEATURE_MAGNIFICATION_SINGLE_FINGER_TRIPLE_TAP
                    | FLAG_FEATURE_MAGNIFICATION_TWO_FINGER_TRIPLE_TAP
                    | FLAG_FEATURE_TRIGGERED_SCREEN_MAGNIFIER
                    | FLAG_FEATURE_TRIGGERED_SCREEN_MAGNIFIER
                    | FLAG_SERVICE_HANDLES_DOUBLE_TAP
                    | FLAG_SERVICE_HANDLES_DOUBLE_TAP
                    | FLAG_REQUEST_MULTI_FINGER_GESTURES
                    | FLAG_REQUEST_MULTI_FINGER_GESTURES
@@ -538,6 +539,7 @@ class AccessibilityInputFilter extends InputFilter implements EventStreamTransfo


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


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


import java.util.ArrayDeque;
import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Queue;
@@ -63,6 +64,13 @@ public abstract class MagnificationGestureHandler extends BaseEventStreamTransfo
     */
     */
    protected final boolean mDetectSingleFingerTripleTap;
    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. */
    /** Callback interface to report that magnification is interactive with a user. */
    public interface Callback {
    public interface Callback {
        /**
        /**
@@ -85,12 +93,16 @@ public abstract class MagnificationGestureHandler extends BaseEventStreamTransfo
    private final AccessibilityTraceManager mTrace;
    private final AccessibilityTraceManager mTrace;
    protected final Callback mCallback;
    protected final Callback mCallback;


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


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


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


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


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


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