Treat accessibility gestures like physical ones.
Gestures now operate on the screen as the user sees it, so they are affected by magnification. This makes gesture coordinates consistent with the node bounds in screen and makes an eye or head tracking service work much more easily. Bug: 27747314 Change-Id: Idee60398d49d8c9af7405d974893c796b034c974
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -155,10 +155,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 {
|
||||
@@ -255,7 +255,7 @@ class MagnificationController {
|
||||
public float getCenterX() {
|
||||
synchronized (mLock) {
|
||||
return (mMagnifiedBounds.width() / 2.0f
|
||||
+ mMagnifiedBounds.left - getOffsetX()) / getScale();
|
||||
- getOffsetX()) / getScale() + mMagnifiedBounds.left;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -278,7 +278,7 @@ class MagnificationController {
|
||||
public float getCenterY() {
|
||||
synchronized (mLock) {
|
||||
return (mMagnifiedBounds.height() / 2.0f
|
||||
+ mMagnifiedBounds.top - getOffsetY()) / getScale();
|
||||
- getOffsetY()) / getScale() + mMagnifiedBounds.top;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user