Loading services/accessibility/java/com/android/server/accessibility/AccessibilityInputFilter.java +17 −3 Original line number Diff line number Diff line Loading @@ -70,12 +70,22 @@ class AccessibilityInputFilter extends InputFilter implements EventStreamTransfo static final int FLAG_FEATURE_AUTOCLICK = 0x00000008; /** * Flag for enabling motion event injectsion * Flag for enabling motion event injection. * * @see #setUserAndEnabledFeatures(int, int) */ static final int FLAG_FEATURE_INJECT_MOTION_EVENTS = 0x00000010; /** * Flag for enabling the feature to control the screen magnifier. If * {@link #FLAG_FEATURE_SCREEN_MAGNIFIER} is set this flag is ignored * as the screen magnifier feature performs a super set of the work * performed by this feature. * * @see #setUserAndEnabledFeatures(int, int) */ static final int FLAG_FEATURE_CONTROL_SCREEN_MAGNIFIER = 0x00000020; private final Runnable mProcessBatchedEventsRunnable = new Runnable() { @Override public void run() { Loading Loading @@ -373,8 +383,12 @@ class AccessibilityInputFilter extends InputFilter implements EventStreamTransfo addFirstEventHandler(mTouchExplorer); } if ((mEnabledFeatures & FLAG_FEATURE_SCREEN_MAGNIFIER) != 0) { mMagnificationGestureHandler = new MagnificationGestureHandler(mContext, mAms); if ((mEnabledFeatures & FLAG_FEATURE_CONTROL_SCREEN_MAGNIFIER) != 0 || (mEnabledFeatures & FLAG_FEATURE_SCREEN_MAGNIFIER) != 0) { final boolean detectControlGestures = (mEnabledFeatures & FLAG_FEATURE_SCREEN_MAGNIFIER) != 0; mMagnificationGestureHandler = new MagnificationGestureHandler( mContext, mAms, detectControlGestures); addFirstEventHandler(mMagnificationGestureHandler); } Loading services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java +3 −0 Original line number Diff line number Diff line Loading @@ -1311,6 +1311,9 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub { if (userState.mIsDisplayMagnificationEnabled) { flags |= AccessibilityInputFilter.FLAG_FEATURE_SCREEN_MAGNIFIER; } if (userHasMagnificationServicesLocked(userState)) { flags |= AccessibilityInputFilter.FLAG_FEATURE_CONTROL_SCREEN_MAGNIFIER; } // Touch exploration without accessibility makes no sense. if (userState.isHandlingAccessibilityEvents() && userState.mIsTouchExplorationEnabled) { Loading services/accessibility/java/com/android/server/accessibility/MagnificationGestureHandler.java +44 −29 Original line number Diff line number Diff line Loading @@ -80,7 +80,6 @@ class MagnificationGestureHandler implements EventStreamTransformation { private static final boolean DEBUG_STATE_TRANSITIONS = false; private static final boolean DEBUG_DETECTING = false; private static final boolean DEBUG_PANNING = false; private static final boolean DEBUG_SCALING = false; private static final int STATE_DELEGATING = 1; private static final int STATE_DETECTING = 2; Loading @@ -95,6 +94,9 @@ class MagnificationGestureHandler implements EventStreamTransformation { private final MagnifiedContentInteractionStateHandler mMagnifiedContentInteractionStateHandler; private final StateViewportDraggingHandler mStateViewportDraggingHandler; private final boolean mDetectControlGestures; private EventStreamTransformation mNext; private int mCurrentState; Loading @@ -107,12 +109,14 @@ class MagnificationGestureHandler implements EventStreamTransformation { private long mDelegatingStateDownTime; public MagnificationGestureHandler(Context context, AccessibilityManagerService ams) { public MagnificationGestureHandler(Context context, AccessibilityManagerService ams, boolean detectControlGestures) { mMagnificationController = ams.getMagnificationController(); mDetectingStateHandler = new DetectingStateHandler(context); mStateViewportDraggingHandler = new StateViewportDraggingHandler(); mMagnifiedContentInteractionStateHandler = new MagnifiedContentInteractionStateHandler(context); mDetectControlGestures = detectControlGestures; transitionToState(STATE_DETECTING); } Loading @@ -125,6 +129,12 @@ class MagnificationGestureHandler implements EventStreamTransformation { } return; } if (!mDetectControlGestures) { if (mNext != null) { dispatchTransformedEvent(event, rawEvent, policyFlags); } return; } mMagnifiedContentInteractionStateHandler.onMotionEvent(event, rawEvent, policyFlags); switch (mCurrentState) { case STATE_DELEGATING: { Loading @@ -140,7 +150,7 @@ class MagnificationGestureHandler implements EventStreamTransformation { } break; case STATE_MAGNIFIED_INTERACTION: { // mMagnifiedContentInteractonStateHandler handles events only // mMagnifiedContentInteractionStateHandler handles events only // if this is the current state since it uses ScaleGestureDetecotr // and a GestureDetector which need well formed event stream. } Loading Loading @@ -208,6 +218,19 @@ class MagnificationGestureHandler implements EventStreamTransformation { break; } if (mNext != null) { // We cache some events to see if the user wants to trigger magnification. // If no magnification is triggered we inject these events with adjusted // time and down time to prevent subsequent transformations being confused // by stale events. After the cached events, which always have a down, are // injected we need to also update the down time of all subsequent non cached // events. All delegated events cached and non-cached are delivered here. event.setDownTime(mDelegatingStateDownTime); dispatchTransformedEvent(event, rawEvent, policyFlags); } } private void dispatchTransformedEvent(MotionEvent event, MotionEvent rawEvent, int policyFlags) { // If the event is within the magnified portion of the screen we have // to change its location to be where the user thinks he is poking the // UI which may have been magnified and panned. Loading @@ -233,16 +256,8 @@ class MagnificationGestureHandler implements EventStreamTransformation { coords, 0, 0, 1.0f, 1.0f, event.getDeviceId(), 0, event.getSource(), event.getFlags()); } // We cache some events to see if the user wants to trigger magnification. // If no magnification is triggered we inject these events with adjusted // time and down time to prevent subsequent transformations being confused // by stale events. After the cached events, which always have a down, are // injected we need to also update the down time of all subsequent non cached // events. All delegated events cached and non-cached are delivered here. event.setDownTime(mDelegatingStateDownTime); mNext.onMotionEvent(event, rawEvent, policyFlags); } } private PointerCoords[] getTempPointerCoordsWithMinSize(int size) { final int oldSize = (mTempPointerCoords != null) ? mTempPointerCoords.length : 0; Loading Loading
services/accessibility/java/com/android/server/accessibility/AccessibilityInputFilter.java +17 −3 Original line number Diff line number Diff line Loading @@ -70,12 +70,22 @@ class AccessibilityInputFilter extends InputFilter implements EventStreamTransfo static final int FLAG_FEATURE_AUTOCLICK = 0x00000008; /** * Flag for enabling motion event injectsion * Flag for enabling motion event injection. * * @see #setUserAndEnabledFeatures(int, int) */ static final int FLAG_FEATURE_INJECT_MOTION_EVENTS = 0x00000010; /** * Flag for enabling the feature to control the screen magnifier. If * {@link #FLAG_FEATURE_SCREEN_MAGNIFIER} is set this flag is ignored * as the screen magnifier feature performs a super set of the work * performed by this feature. * * @see #setUserAndEnabledFeatures(int, int) */ static final int FLAG_FEATURE_CONTROL_SCREEN_MAGNIFIER = 0x00000020; private final Runnable mProcessBatchedEventsRunnable = new Runnable() { @Override public void run() { Loading Loading @@ -373,8 +383,12 @@ class AccessibilityInputFilter extends InputFilter implements EventStreamTransfo addFirstEventHandler(mTouchExplorer); } if ((mEnabledFeatures & FLAG_FEATURE_SCREEN_MAGNIFIER) != 0) { mMagnificationGestureHandler = new MagnificationGestureHandler(mContext, mAms); if ((mEnabledFeatures & FLAG_FEATURE_CONTROL_SCREEN_MAGNIFIER) != 0 || (mEnabledFeatures & FLAG_FEATURE_SCREEN_MAGNIFIER) != 0) { final boolean detectControlGestures = (mEnabledFeatures & FLAG_FEATURE_SCREEN_MAGNIFIER) != 0; mMagnificationGestureHandler = new MagnificationGestureHandler( mContext, mAms, detectControlGestures); addFirstEventHandler(mMagnificationGestureHandler); } Loading
services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java +3 −0 Original line number Diff line number Diff line Loading @@ -1311,6 +1311,9 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub { if (userState.mIsDisplayMagnificationEnabled) { flags |= AccessibilityInputFilter.FLAG_FEATURE_SCREEN_MAGNIFIER; } if (userHasMagnificationServicesLocked(userState)) { flags |= AccessibilityInputFilter.FLAG_FEATURE_CONTROL_SCREEN_MAGNIFIER; } // Touch exploration without accessibility makes no sense. if (userState.isHandlingAccessibilityEvents() && userState.mIsTouchExplorationEnabled) { Loading
services/accessibility/java/com/android/server/accessibility/MagnificationGestureHandler.java +44 −29 Original line number Diff line number Diff line Loading @@ -80,7 +80,6 @@ class MagnificationGestureHandler implements EventStreamTransformation { private static final boolean DEBUG_STATE_TRANSITIONS = false; private static final boolean DEBUG_DETECTING = false; private static final boolean DEBUG_PANNING = false; private static final boolean DEBUG_SCALING = false; private static final int STATE_DELEGATING = 1; private static final int STATE_DETECTING = 2; Loading @@ -95,6 +94,9 @@ class MagnificationGestureHandler implements EventStreamTransformation { private final MagnifiedContentInteractionStateHandler mMagnifiedContentInteractionStateHandler; private final StateViewportDraggingHandler mStateViewportDraggingHandler; private final boolean mDetectControlGestures; private EventStreamTransformation mNext; private int mCurrentState; Loading @@ -107,12 +109,14 @@ class MagnificationGestureHandler implements EventStreamTransformation { private long mDelegatingStateDownTime; public MagnificationGestureHandler(Context context, AccessibilityManagerService ams) { public MagnificationGestureHandler(Context context, AccessibilityManagerService ams, boolean detectControlGestures) { mMagnificationController = ams.getMagnificationController(); mDetectingStateHandler = new DetectingStateHandler(context); mStateViewportDraggingHandler = new StateViewportDraggingHandler(); mMagnifiedContentInteractionStateHandler = new MagnifiedContentInteractionStateHandler(context); mDetectControlGestures = detectControlGestures; transitionToState(STATE_DETECTING); } Loading @@ -125,6 +129,12 @@ class MagnificationGestureHandler implements EventStreamTransformation { } return; } if (!mDetectControlGestures) { if (mNext != null) { dispatchTransformedEvent(event, rawEvent, policyFlags); } return; } mMagnifiedContentInteractionStateHandler.onMotionEvent(event, rawEvent, policyFlags); switch (mCurrentState) { case STATE_DELEGATING: { Loading @@ -140,7 +150,7 @@ class MagnificationGestureHandler implements EventStreamTransformation { } break; case STATE_MAGNIFIED_INTERACTION: { // mMagnifiedContentInteractonStateHandler handles events only // mMagnifiedContentInteractionStateHandler handles events only // if this is the current state since it uses ScaleGestureDetecotr // and a GestureDetector which need well formed event stream. } Loading Loading @@ -208,6 +218,19 @@ class MagnificationGestureHandler implements EventStreamTransformation { break; } if (mNext != null) { // We cache some events to see if the user wants to trigger magnification. // If no magnification is triggered we inject these events with adjusted // time and down time to prevent subsequent transformations being confused // by stale events. After the cached events, which always have a down, are // injected we need to also update the down time of all subsequent non cached // events. All delegated events cached and non-cached are delivered here. event.setDownTime(mDelegatingStateDownTime); dispatchTransformedEvent(event, rawEvent, policyFlags); } } private void dispatchTransformedEvent(MotionEvent event, MotionEvent rawEvent, int policyFlags) { // If the event is within the magnified portion of the screen we have // to change its location to be where the user thinks he is poking the // UI which may have been magnified and panned. Loading @@ -233,16 +256,8 @@ class MagnificationGestureHandler implements EventStreamTransformation { coords, 0, 0, 1.0f, 1.0f, event.getDeviceId(), 0, event.getSource(), event.getFlags()); } // We cache some events to see if the user wants to trigger magnification. // If no magnification is triggered we inject these events with adjusted // time and down time to prevent subsequent transformations being confused // by stale events. After the cached events, which always have a down, are // injected we need to also update the down time of all subsequent non cached // events. All delegated events cached and non-cached are delivered here. event.setDownTime(mDelegatingStateDownTime); mNext.onMotionEvent(event, rawEvent, policyFlags); } } private PointerCoords[] getTempPointerCoordsWithMinSize(int size) { final int oldSize = (mTempPointerCoords != null) ? mTempPointerCoords.length : 0; Loading