Merge "Treat accessibility gestures like physical ones." into nyc-dev

am: fb6dd3b

* commit 'fb6dd3bbc18a425e25f9761cbcc96b8eb169b04f':
  Treat accessibility gestures like physical ones.

Change-Id: Idecb2de61673c94c44a128b32bcd035d050c604a
This commit is contained in:
Phil Weaver
2016-04-07 20:39:41 +00:00
committed by android-build-merger
3 changed files with 17 additions and 12 deletions

View File

@@ -600,11 +600,16 @@ public abstract class AccessibilityService extends Service {
* Dispatch a gesture to the touch screen. Any gestures currently in progress, whether from
* the user, this service, or another service, will be cancelled.
* <p>
* The gesture will be dispatched as if it were performed directly on the screen by a user, so
* the events may be affected by features such as magnification and explore by touch.
* </p>
* <p>
* <strong>Note:</strong> In order to dispatch gestures, your service
* must declare the capability by setting the
* {@link android.R.styleable#AccessibilityService_canPerformGestures}
* property in its meta-data. For more information, see
* {@link #SERVICE_META_DATA}.
* </p>
*
* @param gesture The gesture to dispatch
* @param callback The object to call back when the status of the gesture is known. If

View File

@@ -363,12 +363,6 @@ class AccessibilityInputFilter extends InputFilter implements EventStreamTransfo
private void enableFeatures() {
resetStreamState();
if ((mEnabledFeatures & FLAG_FEATURE_INJECT_MOTION_EVENTS) != 0) {
mMotionEventInjector = new MotionEventInjector(mContext.getMainLooper());
addFirstEventHandler(mMotionEventInjector);
mAms.setMotionEventInjector(mMotionEventInjector);
}
if ((mEnabledFeatures & FLAG_FEATURE_AUTOCLICK) != 0) {
mAutoclickController = new AutoclickController(mContext, mUserId);
addFirstEventHandler(mAutoclickController);
@@ -384,6 +378,12 @@ class AccessibilityInputFilter extends InputFilter implements EventStreamTransfo
addFirstEventHandler(mMagnificationGestureHandler);
}
if ((mEnabledFeatures & FLAG_FEATURE_INJECT_MOTION_EVENTS) != 0) {
mMotionEventInjector = new MotionEventInjector(mContext.getMainLooper());
addFirstEventHandler(mMotionEventInjector);
mAms.setMotionEventInjector(mMotionEventInjector);
}
if ((mEnabledFeatures & FLAG_FEATURE_FILTER_KEY_EVENTS) != 0) {
mKeyboardInterceptor = new KeyboardInterceptor(mAms);
addFirstEventHandler(mKeyboardInterceptor);

View File

@@ -156,10 +156,10 @@ class MagnificationController {
final float offsetY = sentSpec.offsetY;
// Compute the new center and update spec as needed.
final float centerX = (mMagnifiedBounds.width() / 2.0f
+ mMagnifiedBounds.left - offsetX) / scale;
final float centerY = (mMagnifiedBounds.height() / 2.0f
+ mMagnifiedBounds.top - offsetY) / scale;
final float centerX = (mMagnifiedBounds.width() / 2.0f - offsetX) / scale
+ mMagnifiedBounds.left;
final float centerY = (mMagnifiedBounds.height() / 2.0f - offsetY) / scale
+ mMagnifiedBounds.top;
if (updateSpec) {
setScaleAndCenter(scale, centerX, centerY, false);
} else {
@@ -256,7 +256,7 @@ class MagnificationController {
public float getCenterX() {
synchronized (mLock) {
return (mMagnifiedBounds.width() / 2.0f
+ mMagnifiedBounds.left - getOffsetX()) / getScale();
- getOffsetX()) / getScale() + mMagnifiedBounds.left;
}
}
@@ -279,7 +279,7 @@ class MagnificationController {
public float getCenterY() {
synchronized (mLock) {
return (mMagnifiedBounds.height() / 2.0f
+ mMagnifiedBounds.top - getOffsetY()) / getScale();
- getOffsetY()) / getScale() + mMagnifiedBounds.top;
}
}