Loading core/java/android/util/ExceptionUtils.java +8 −0 Original line number Diff line number Diff line Loading @@ -78,4 +78,12 @@ public class ExceptionUtils { propagateIfInstanceOf(t, RuntimeException.class); throw new RuntimeException(t); } /** * Gets the root {@link Throwable#getCause() cause} of {@code t} */ public static @NonNull Throwable getRootCause(@NonNull Throwable t) { while (t.getCause() != null) t = t.getCause(); return t; } } services/accessibility/java/com/android/server/accessibility/AccessibilityInputFilter.java +2 −1 Original line number Diff line number Diff line Loading @@ -417,7 +417,8 @@ class AccessibilityInputFilter extends InputFilter implements EventStreamTransfo final boolean triggerable = (mEnabledFeatures & FLAG_FEATURE_TRIGGERED_SCREEN_MAGNIFIER) != 0; mMagnificationGestureHandler = new MagnificationGestureHandler( mContext, mAms, detectControlGestures, triggerable); mContext, mAms.getMagnificationController(), detectControlGestures, triggerable); addFirstEventHandler(mMagnificationGestureHandler); } Loading services/accessibility/java/com/android/server/accessibility/GestureUtils.java +7 −13 Original line number Diff line number Diff line Loading @@ -12,32 +12,27 @@ final class GestureUtils { /* cannot be instantiated */ } public static boolean isTap(MotionEvent down, MotionEvent up, int tapTimeSlop, int tapDistanceSlop, int actionIndex) { return eventsWithinTimeAndDistanceSlop(down, up, tapTimeSlop, tapDistanceSlop, actionIndex); } public static boolean isMultiTap(MotionEvent firstUp, MotionEvent secondUp, int multiTapTimeSlop, int multiTapDistanceSlop, int actionIndex) { int multiTapTimeSlop, int multiTapDistanceSlop) { if (firstUp == null || secondUp == null) return false; return eventsWithinTimeAndDistanceSlop(firstUp, secondUp, multiTapTimeSlop, multiTapDistanceSlop, actionIndex); multiTapDistanceSlop); } private static boolean eventsWithinTimeAndDistanceSlop(MotionEvent first, MotionEvent second, int timeout, int distance, int actionIndex) { int timeout, int distance) { if (isTimedOut(first, second, timeout)) { return false; } final double deltaMove = computeDistance(first, second, actionIndex); final double deltaMove = distance(first, second); if (deltaMove >= distance) { return false; } return true; } public static double computeDistance(MotionEvent first, MotionEvent second, int pointerIndex) { return MathUtils.dist(first.getX(pointerIndex), first.getY(pointerIndex), second.getX(pointerIndex), second.getY(pointerIndex)); public static double distance(MotionEvent first, MotionEvent second) { return MathUtils.dist(first.getX(), first.getY(), second.getX(), second.getY()); } public static boolean isTimedOut(MotionEvent firstUp, MotionEvent secondUp, int timeout) { Loading @@ -54,7 +49,6 @@ final class GestureUtils { /** * Determines whether a two pointer gesture is a dragging one. * * @param event The event with the pointer data. * @return True if the gesture is a dragging one. */ public static boolean isDraggingGesture(float firstPtrDownX, float firstPtrDownY, Loading services/accessibility/java/com/android/server/accessibility/MagnificationController.java +29 −11 Original line number Diff line number Diff line Loading @@ -16,11 +16,6 @@ package com.android.server.accessibility; import com.android.internal.R; import com.android.internal.annotations.GuardedBy; import com.android.internal.os.SomeArgs; import com.android.server.LocalServices; import android.animation.ValueAnimator; import android.annotation.NonNull; import android.content.BroadcastReceiver; Loading @@ -42,6 +37,12 @@ import android.view.View; import android.view.WindowManagerInternal; import android.view.animation.DecelerateInterpolator; import com.android.internal.R; import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.os.SomeArgs; import com.android.server.LocalServices; import java.util.Locale; /** Loading Loading @@ -138,7 +139,7 @@ class MagnificationController implements Handler.Callback { private final WindowManagerInternal mWindowManager; // Flag indicating that we are registered with window manager. private boolean mRegistered; @VisibleForTesting boolean mRegistered; private boolean mUnregisterPending; Loading @@ -148,9 +149,14 @@ class MagnificationController implements Handler.Callback { mHandler = new Handler(context.getMainLooper(), this); } public MagnificationController(Context context, AccessibilityManagerService ams, Object lock, Handler handler, WindowManagerInternal windowManagerInternal, ValueAnimator valueAnimator, SettingsBridge settingsBridge) { public MagnificationController( Context context, AccessibilityManagerService ams, Object lock, Handler handler, WindowManagerInternal windowManagerInternal, ValueAnimator valueAnimator, SettingsBridge settingsBridge) { mHandler = handler; mWindowManager = windowManagerInternal; mMainThreadId = context.getMainLooper().getThread().getId(); Loading Loading @@ -672,8 +678,7 @@ class MagnificationController implements Handler.Callback { * Resets magnification if magnification and auto-update are both enabled. * * @param animate whether the animate the transition * @return {@code true} if magnification was reset to the disabled state, * {@code false} if magnification is still active * @return whether was {@link #isMagnifying magnifying} */ boolean resetIfNeeded(boolean animate) { synchronized (mLock) { Loading Loading @@ -790,6 +795,19 @@ class MagnificationController implements Handler.Callback { return true; } @Override public String toString() { return "MagnificationController{" + "mCurrentMagnificationSpec=" + mCurrentMagnificationSpec + ", mMagnificationRegion=" + mMagnificationRegion + ", mMagnificationBounds=" + mMagnificationBounds + ", mUserId=" + mUserId + ", mIdOfLastServiceToMagnify=" + mIdOfLastServiceToMagnify + ", mRegistered=" + mRegistered + ", mUnregisterPending=" + mUnregisterPending + '}'; } /** * Class responsible for animating spec on the main thread and sending spec * updates to the window manager. Loading services/accessibility/java/com/android/server/accessibility/MagnificationGestureHandler.java +475 −351 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
core/java/android/util/ExceptionUtils.java +8 −0 Original line number Diff line number Diff line Loading @@ -78,4 +78,12 @@ public class ExceptionUtils { propagateIfInstanceOf(t, RuntimeException.class); throw new RuntimeException(t); } /** * Gets the root {@link Throwable#getCause() cause} of {@code t} */ public static @NonNull Throwable getRootCause(@NonNull Throwable t) { while (t.getCause() != null) t = t.getCause(); return t; } }
services/accessibility/java/com/android/server/accessibility/AccessibilityInputFilter.java +2 −1 Original line number Diff line number Diff line Loading @@ -417,7 +417,8 @@ class AccessibilityInputFilter extends InputFilter implements EventStreamTransfo final boolean triggerable = (mEnabledFeatures & FLAG_FEATURE_TRIGGERED_SCREEN_MAGNIFIER) != 0; mMagnificationGestureHandler = new MagnificationGestureHandler( mContext, mAms, detectControlGestures, triggerable); mContext, mAms.getMagnificationController(), detectControlGestures, triggerable); addFirstEventHandler(mMagnificationGestureHandler); } Loading
services/accessibility/java/com/android/server/accessibility/GestureUtils.java +7 −13 Original line number Diff line number Diff line Loading @@ -12,32 +12,27 @@ final class GestureUtils { /* cannot be instantiated */ } public static boolean isTap(MotionEvent down, MotionEvent up, int tapTimeSlop, int tapDistanceSlop, int actionIndex) { return eventsWithinTimeAndDistanceSlop(down, up, tapTimeSlop, tapDistanceSlop, actionIndex); } public static boolean isMultiTap(MotionEvent firstUp, MotionEvent secondUp, int multiTapTimeSlop, int multiTapDistanceSlop, int actionIndex) { int multiTapTimeSlop, int multiTapDistanceSlop) { if (firstUp == null || secondUp == null) return false; return eventsWithinTimeAndDistanceSlop(firstUp, secondUp, multiTapTimeSlop, multiTapDistanceSlop, actionIndex); multiTapDistanceSlop); } private static boolean eventsWithinTimeAndDistanceSlop(MotionEvent first, MotionEvent second, int timeout, int distance, int actionIndex) { int timeout, int distance) { if (isTimedOut(first, second, timeout)) { return false; } final double deltaMove = computeDistance(first, second, actionIndex); final double deltaMove = distance(first, second); if (deltaMove >= distance) { return false; } return true; } public static double computeDistance(MotionEvent first, MotionEvent second, int pointerIndex) { return MathUtils.dist(first.getX(pointerIndex), first.getY(pointerIndex), second.getX(pointerIndex), second.getY(pointerIndex)); public static double distance(MotionEvent first, MotionEvent second) { return MathUtils.dist(first.getX(), first.getY(), second.getX(), second.getY()); } public static boolean isTimedOut(MotionEvent firstUp, MotionEvent secondUp, int timeout) { Loading @@ -54,7 +49,6 @@ final class GestureUtils { /** * Determines whether a two pointer gesture is a dragging one. * * @param event The event with the pointer data. * @return True if the gesture is a dragging one. */ public static boolean isDraggingGesture(float firstPtrDownX, float firstPtrDownY, Loading
services/accessibility/java/com/android/server/accessibility/MagnificationController.java +29 −11 Original line number Diff line number Diff line Loading @@ -16,11 +16,6 @@ package com.android.server.accessibility; import com.android.internal.R; import com.android.internal.annotations.GuardedBy; import com.android.internal.os.SomeArgs; import com.android.server.LocalServices; import android.animation.ValueAnimator; import android.annotation.NonNull; import android.content.BroadcastReceiver; Loading @@ -42,6 +37,12 @@ import android.view.View; import android.view.WindowManagerInternal; import android.view.animation.DecelerateInterpolator; import com.android.internal.R; import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.os.SomeArgs; import com.android.server.LocalServices; import java.util.Locale; /** Loading Loading @@ -138,7 +139,7 @@ class MagnificationController implements Handler.Callback { private final WindowManagerInternal mWindowManager; // Flag indicating that we are registered with window manager. private boolean mRegistered; @VisibleForTesting boolean mRegistered; private boolean mUnregisterPending; Loading @@ -148,9 +149,14 @@ class MagnificationController implements Handler.Callback { mHandler = new Handler(context.getMainLooper(), this); } public MagnificationController(Context context, AccessibilityManagerService ams, Object lock, Handler handler, WindowManagerInternal windowManagerInternal, ValueAnimator valueAnimator, SettingsBridge settingsBridge) { public MagnificationController( Context context, AccessibilityManagerService ams, Object lock, Handler handler, WindowManagerInternal windowManagerInternal, ValueAnimator valueAnimator, SettingsBridge settingsBridge) { mHandler = handler; mWindowManager = windowManagerInternal; mMainThreadId = context.getMainLooper().getThread().getId(); Loading Loading @@ -672,8 +678,7 @@ class MagnificationController implements Handler.Callback { * Resets magnification if magnification and auto-update are both enabled. * * @param animate whether the animate the transition * @return {@code true} if magnification was reset to the disabled state, * {@code false} if magnification is still active * @return whether was {@link #isMagnifying magnifying} */ boolean resetIfNeeded(boolean animate) { synchronized (mLock) { Loading Loading @@ -790,6 +795,19 @@ class MagnificationController implements Handler.Callback { return true; } @Override public String toString() { return "MagnificationController{" + "mCurrentMagnificationSpec=" + mCurrentMagnificationSpec + ", mMagnificationRegion=" + mMagnificationRegion + ", mMagnificationBounds=" + mMagnificationBounds + ", mUserId=" + mUserId + ", mIdOfLastServiceToMagnify=" + mIdOfLastServiceToMagnify + ", mRegistered=" + mRegistered + ", mUnregisterPending=" + mUnregisterPending + '}'; } /** * Class responsible for animating spec on the main thread and sending spec * updates to the window manager. Loading
services/accessibility/java/com/android/server/accessibility/MagnificationGestureHandler.java +475 −351 File changed.Preview size limit exceeded, changes collapsed. Show changes